mirror of
https://github.com/libretro/Mu.git
synced 2026-09-25 08:06:04 +00:00
Cleanups, implement FEATURE_SYNCED_RTC, allow disabling graffiti
Also patched RetroArch makefile again, this will enable ARM on more platforms, possibly causing more build issues when merged.
This commit is contained in:
@@ -2,6 +2,9 @@ EMU_PATH := $(CORE_DIR)/../src
|
||||
LIBRETRO_COMM_DIR := $(CORE_DIR)/libretro-common
|
||||
COREDEFINES :=
|
||||
|
||||
# my first make function!!!
|
||||
CHECK_ALL = $(foreach v,$(2),$(if $(findstring $(v),$(1)),$(v),))
|
||||
|
||||
INCFLAGS := -I$(LIBRETRO_COMM_DIR)/include
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
@@ -11,11 +14,12 @@ else
|
||||
endif
|
||||
|
||||
# "unix" or "win" is not specific enough, need to know the CPU arch too
|
||||
this_system = $(platform)
|
||||
this_system := $(platform)
|
||||
ifneq (,$(filter unix win,$(this_system)))
|
||||
this_system = $(shell $(CC) -dumpmachine)
|
||||
this_system := $(shell $(CC) -dumpmachine)
|
||||
endif
|
||||
|
||||
|
||||
ifneq (,$(findstring msvc200,$(this_system)))
|
||||
INCFLAGS += -I$(LIBRETRO_COMM_DIR)/include/compat/msvc
|
||||
endif
|
||||
@@ -26,12 +30,13 @@ ifneq (,$(findstring msvc20,$(this_system)))
|
||||
COREDEFINES += -Dinline=_inline -DINLINE=_inline
|
||||
endif
|
||||
|
||||
ifneq (,$(filter %windows% %mingw%,$(this_system)))
|
||||
|
||||
ifneq (,$(call CHECK_ALL,$(this_system),windows mingw))
|
||||
# Windows
|
||||
ifeq (,$(findstring msvc,$(this_system)))
|
||||
EMU_SUPPORT_PALM_OS5 := 1
|
||||
EMU_OS := windows
|
||||
ifneq (,$(filter %x64 %x86_64,$(this_system)))
|
||||
ifneq (,$(call CHECK_ALL,$(this_system),x86_64 x64))
|
||||
EMU_ARCH := x86_64
|
||||
else
|
||||
EMU_ARCH := x86_32
|
||||
@@ -40,24 +45,24 @@ ifneq (,$(filter %windows% %mingw%,$(this_system)))
|
||||
# MSVC uses its own(incompatible) ASM syntax
|
||||
EMU_SUPPORT_PALM_OS5 := 0
|
||||
endif
|
||||
else ifneq (,$(filter %armv8% %aarch64%,$(this_system)))
|
||||
else ifneq (,$(call CHECK_ALL,$(this_system),armv8 aarch64))
|
||||
# ARM Linux 64
|
||||
EMU_SUPPORT_PALM_OS5 := 1
|
||||
EMU_ARCH := armv8
|
||||
EMU_OS := linux
|
||||
else ifneq (,$(filter %armv% rpi2 rpi3,$(this_system)))
|
||||
else ifneq (,$(call CHECK_ALL,$(this_system),armv rpi2 rpi3))
|
||||
# ARM Linux(rpi3 is aarch64 but its almost always used in 32bit mode)
|
||||
EMU_SUPPORT_PALM_OS5 := 1
|
||||
EMU_ARCH := armv7
|
||||
EMU_OS := linux
|
||||
else ifneq (,$(findstring armhf,$(this_system)))
|
||||
# ARM Linux ARMv5
|
||||
# this needs to be before "linux%" because it will trigger the linux case
|
||||
# this needs to be before "linux" because it will trigger the linux case
|
||||
EMU_SUPPORT_PALM_OS5 := 0
|
||||
else ifneq (,$(filter osx% linux% ,$(this_system)))
|
||||
else ifneq (,$(call CHECK_ALL,$(this_system),osx linux))
|
||||
# x86_* Linux
|
||||
EMU_SUPPORT_PALM_OS5 := 1
|
||||
ifneq (,$(filter osx %x86_64% %x64%,$(this_system)))
|
||||
ifneq (,$(call CHECK_ALL,$(this_system),osx x86_64 x64))
|
||||
EMU_ARCH := x86_64
|
||||
else
|
||||
EMU_ARCH := x86_32
|
||||
@@ -78,7 +83,7 @@ endif
|
||||
|
||||
# use all CPUs and optimize for the most likely outcome, Android is handled separately
|
||||
# Apple broke OpenMP in there port of Clang so no Mac OS or iOS
|
||||
ifneq (,$(filter %armv% windows% linux%,$(this_system)))
|
||||
ifneq (,$(call CHECK_ALL,$(this_system),windows linux))
|
||||
# none of libretros MSVC compilers work with these optimizations for multiple different reasons
|
||||
# they dont have the library "VCOMP.lib"
|
||||
# they are too old for the extension to exist
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#define JOYSTICK_DEADZONE 4000
|
||||
#define JOYSTICK_MULTIPLIER 0.0001
|
||||
#define SCREEN_HIRES (!(palmFramebufferWidth == 160 && palmFramebufferHeight == 220))
|
||||
#define SCREEN_HIRES (!(palmFramebufferWidth == 160))
|
||||
|
||||
|
||||
static retro_log_printf_t log_cb = NULL;
|
||||
@@ -36,16 +36,30 @@ static retro_input_state_t input_state_cb = NULL;
|
||||
static uint32_t emuFeatures;
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
static bool useOs5;
|
||||
static bool firstRetroRunCall;
|
||||
#endif
|
||||
static bool firstRetroRunCall;
|
||||
static bool dontRenderGraffiti;
|
||||
static bool useJoystickAsMouse;
|
||||
static float touchCursorX;
|
||||
static float touchCursorY;
|
||||
static char contentPath[PATH_MAX_LENGTH];
|
||||
static uint16_t mouseCursorOldArea[32 * 32];
|
||||
static bool runningImgFile;
|
||||
static uint16_t screenYEnd;
|
||||
|
||||
|
||||
static void frontendGetCurrentTime(uint8_t* writeBack){
|
||||
time_t rawTime;
|
||||
struct tm* timeInfo;
|
||||
|
||||
time(&rawTime);
|
||||
timeInfo = localtime(&rawTime);
|
||||
|
||||
writeBack[0] = timeInfo->tm_hour;
|
||||
writeBack[1] = timeInfo->tm_min;
|
||||
writeBack[2] = timeInfo->tm_sec;
|
||||
}
|
||||
|
||||
static void renderMouseCursor(int16_t screenX, int16_t screenY){
|
||||
if(SCREEN_HIRES){
|
||||
int8_t x;
|
||||
@@ -151,6 +165,10 @@ static void check_variables(bool booting){
|
||||
if(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
useJoystickAsMouse = !strcmp(var.value, "enabled");
|
||||
|
||||
var.key = "palm_emu_disable_graffiti";
|
||||
if(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
dontRenderGraffiti = !strcmp(var.value, "enabled");
|
||||
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
var.key = "palm_emu_use_os5";
|
||||
if(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
@@ -215,8 +233,9 @@ void retro_set_environment(retro_environment_t cb){
|
||||
{ "palm_emu_feature_hle_apis", "HLE API Implementations; disabled|enabled" },
|
||||
{ "palm_emu_feature_durable", "Ignore Invalid Behavior; disabled|enabled" },
|
||||
{ "palm_emu_use_joystick_as_mouse", "Use Left Joystick As Mouse; disabled|enabled" },
|
||||
{ "palm_emu_disable_graffiti", "Disable Graffiti Area; disabled|enabled" },
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
{ "palm_emu_use_os5", "Boot Apps In OS 5; disabled|enabled" },
|
||||
{ "palm_emu_use_os5", "Boot Apps In OS 5(DEV ONLY); disabled|enabled" },
|
||||
#endif
|
||||
{ 0 }
|
||||
};
|
||||
@@ -226,6 +245,11 @@ void retro_set_environment(retro_environment_t cb){
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "Touchscreen Mouse Click" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Dpad Up" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Dpad Down" },
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Dpad Left" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Dpad Right" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Dpad Center" },
|
||||
#endif
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Power" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Date Book" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Address Book" },
|
||||
@@ -283,22 +307,39 @@ void retro_reset(void){
|
||||
void retro_run(void){
|
||||
input_poll_cb();
|
||||
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
//some RetroArch functions can only be called from this function so call those if needed
|
||||
if(unlikely(firstRetroRunCall)){
|
||||
struct retro_game_geometry geometry;
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
if(useOs5){
|
||||
struct retro_game_geometry geometry;
|
||||
|
||||
geometry.base_width = 320;
|
||||
geometry.base_height = 480;
|
||||
geometry.max_width = 320;
|
||||
geometry.max_height = 480;
|
||||
geometry.aspect_ratio = 320.0 / 480.0;
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
|
||||
if(dontRenderGraffiti){
|
||||
geometry.base_width = 320;
|
||||
geometry.base_height = 320;
|
||||
geometry.max_width = 320;
|
||||
geometry.max_height = 480;
|
||||
}
|
||||
else{
|
||||
geometry.base_width = 320;
|
||||
geometry.base_height = 480;
|
||||
}
|
||||
}
|
||||
else{
|
||||
#endif
|
||||
if(dontRenderGraffiti){
|
||||
geometry.base_width = 160;
|
||||
geometry.base_height = 160;
|
||||
}
|
||||
else{
|
||||
geometry.base_width = 160;
|
||||
geometry.base_height = 220;
|
||||
}
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
}
|
||||
#endif
|
||||
geometry.aspect_ratio = (float)geometry.base_width / (float)geometry.base_height;
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
|
||||
firstRetroRunCall = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
//touchscreen
|
||||
if(useJoystickAsMouse){
|
||||
@@ -328,13 +369,20 @@ void retro_run(void){
|
||||
else{
|
||||
//use RetroArch internal pointer
|
||||
palmInput.touchscreenX = ((float)input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X) / 0x7FFF + 1.0) / 2.0;
|
||||
palmInput.touchscreenY = ((float)input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y) / 0x7FFF + 1.0) / 2.0;
|
||||
palmInput.touchscreenY = ((float)input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y) / 0x7FFF + 1.0) / 2.0 * ((float)screenYEnd / palmFramebufferHeight);
|
||||
palmInput.touchscreenTouched = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
|
||||
}
|
||||
|
||||
//dpad
|
||||
palmInput.buttonUp = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP);
|
||||
palmInput.buttonDown = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN);
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
if(useOs5){
|
||||
palmInput.buttonLeft = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT);
|
||||
palmInput.buttonRight = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
||||
palmInput.buttonCenter = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT);
|
||||
}
|
||||
#endif
|
||||
|
||||
//app buttons
|
||||
palmInput.buttonCalendar = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A);
|
||||
@@ -352,7 +400,7 @@ void retro_run(void){
|
||||
if(useJoystickAsMouse)
|
||||
renderMouseCursor(touchCursorX, touchCursorY);
|
||||
|
||||
video_cb(palmFramebuffer, palmFramebufferWidth, palmFramebufferHeight, palmFramebufferWidth * sizeof(uint16_t));
|
||||
video_cb(palmFramebuffer, palmFramebufferWidth, screenYEnd, palmFramebufferWidth * sizeof(uint16_t));
|
||||
audio_cb(palmAudio, AUDIO_SAMPLES_PER_FRAME);
|
||||
if(led_cb)
|
||||
led_cb(0, palmMisc.powerButtonLed);
|
||||
@@ -562,13 +610,28 @@ bool retro_load_game(const struct retro_game_info *info){
|
||||
return false;
|
||||
}
|
||||
|
||||
//set the time callback
|
||||
palmGetRtcFromHost = frontendGetCurrentTime;
|
||||
|
||||
//set mouse position
|
||||
touchCursorX = palmFramebufferWidth / 2;
|
||||
touchCursorY = palmFramebufferHeight / 2;
|
||||
|
||||
//make touches land on the correct spot and screen render the correct size when the graffiti area is off
|
||||
if(dontRenderGraffiti){
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
firstRetroRunCall = true;
|
||||
if(useOs5)
|
||||
screenYEnd = 320;
|
||||
else
|
||||
#endif
|
||||
screenYEnd = 160;
|
||||
}
|
||||
else{
|
||||
screenYEnd = palmFramebufferHeight;
|
||||
}
|
||||
|
||||
//used to resize things properly
|
||||
firstRetroRunCall = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "emuwrapper.h"
|
||||
#include "../../src/emulator.h"
|
||||
@@ -58,6 +59,18 @@ void frontendHandleDebugPrint(){
|
||||
}
|
||||
}
|
||||
|
||||
static void frontendGetCurrentTime(uint8_t* writeBack){
|
||||
time_t rawTime;
|
||||
struct tm* timeInfo;
|
||||
|
||||
time(&rawTime);
|
||||
timeInfo = localtime(&rawTime);
|
||||
|
||||
writeBack[0] = timeInfo->tm_hour;
|
||||
writeBack[1] = timeInfo->tm_min;
|
||||
writeBack[2] = timeInfo->tm_sec;
|
||||
}
|
||||
|
||||
|
||||
EmuWrapper::EmuWrapper(){
|
||||
if(alreadyExists == true)
|
||||
@@ -162,6 +175,7 @@ uint32_t EmuWrapper::init(const QString& assetPath, bool useOs5, uint32_t featur
|
||||
if(error == EMU_ERROR_NONE){
|
||||
QTime now = QTime::currentTime();
|
||||
|
||||
palmGetRtcFromHost = frontendGetCurrentTime;
|
||||
emulatorSetRtc(QDate::currentDate().day(), now.hour(), now.minute(), now.second());
|
||||
|
||||
if(ramFile.open(QFile::ReadOnly | QFile::ExistingOnly)){
|
||||
|
||||
@@ -1166,7 +1166,7 @@ void dbvzLoadBootloader(uint8_t* data, uint32_t size){
|
||||
if(!data)
|
||||
size = 0;
|
||||
|
||||
size = uintMin(size, DBVZ_BOOTLOADER_SIZE);
|
||||
size = FAST_MIN(size, DBVZ_BOOTLOADER_SIZE);
|
||||
|
||||
//copy size bytes from buffer to bootloader area
|
||||
for(index = 0; index < size; index++)
|
||||
@@ -1422,7 +1422,7 @@ void dbvzExecute(void){
|
||||
double cyclesRemaining = dbvzSysclksPerClk32 / 2.0;
|
||||
|
||||
while(cyclesRemaining >= 1.0){
|
||||
double sysclks = floatMin(cyclesRemaining, DBVZ_SYSCLK_PRECISION);
|
||||
double sysclks = FAST_MIN(cyclesRemaining, DBVZ_SYSCLK_PRECISION);
|
||||
int32_t cpuCycles = sysclks * pctlrCpuClockDivider * palmClockMultiplier;
|
||||
|
||||
if(cpuCycles > 0)
|
||||
|
||||
@@ -107,7 +107,7 @@ int32_t pwm1FifoRunSample(int32_t now, int32_t clockOffset){
|
||||
//try to get next sample, if none are available play old sample
|
||||
if(pwm1FifoEntrys() > 0)
|
||||
pwm1ReadPosition = (pwm1ReadPosition + 1) % 6;
|
||||
dutyCycle = floatMin((float)pwm1Fifo[pwm1ReadPosition] / period, 1.00);
|
||||
dutyCycle = FAST_MIN((float)pwm1Fifo[pwm1ReadPosition] / period, 1.00);
|
||||
|
||||
for(index = 0; index < repeat; index++){
|
||||
#if !defined(EMU_NO_SAFETY)
|
||||
|
||||
@@ -249,16 +249,36 @@ static void rtcAddSecondClk32(void){
|
||||
uint8_t minutes = oldRtcTime >> 16 & 0x0000003F;
|
||||
uint8_t seconds = oldRtcTime & 0x0000003F;
|
||||
|
||||
seconds++;
|
||||
rtcInterruptEvents |= 0x0010;
|
||||
if(seconds >= 60){
|
||||
if(palmEmuFeatures.info & FEATURE_SYNCED_RTC && palmGetRtcFromHost){
|
||||
//get new RTC value from system
|
||||
uint16_t stopwatch = registerArrayRead16(STPWCH);
|
||||
uint8_t alarmHours = rtcAlrm >> 24;
|
||||
uint8_t alarmMinutes = rtcAlrm >> 16 & 0x0000003F;
|
||||
uint8_t alarmSeconds = rtcAlrm & 0x0000003F;
|
||||
uint8_t time[3];
|
||||
|
||||
palmGetRtcFromHost(time);
|
||||
|
||||
//day rollover happened
|
||||
if(hours > time[0]){
|
||||
days++;
|
||||
rtcInterruptEvents |= 0x0008;
|
||||
}
|
||||
|
||||
if(time[0] != hours)
|
||||
rtcInterruptEvents |= 0x0020;
|
||||
|
||||
if(time[1] != minutes)
|
||||
rtcInterruptEvents |= 0x0002;
|
||||
|
||||
if(time[2] != seconds)
|
||||
rtcInterruptEvents |= 0x0010;
|
||||
|
||||
if(stopwatch != 0x003F){
|
||||
if(stopwatch == 0x0000)
|
||||
stopwatch -= FAST_ABS(time[1] - minutes);
|
||||
|
||||
if(stopwatch <= 0x0000)
|
||||
stopwatch = 0x003F;
|
||||
else
|
||||
stopwatch--;
|
||||
registerArrayWrite16(STPWCH, stopwatch);
|
||||
}
|
||||
|
||||
@@ -266,27 +286,64 @@ static void rtcAddSecondClk32(void){
|
||||
if(stopwatch == 0x003F)
|
||||
rtcInterruptEvents |= 0x0001;
|
||||
|
||||
minutes++;
|
||||
seconds = 0;
|
||||
rtcInterruptEvents |= 0x0002;
|
||||
if(minutes >= 60){
|
||||
hours++;
|
||||
minutes = 0;
|
||||
rtcInterruptEvents |= 0x0020;
|
||||
if(hours >= 24){
|
||||
hours = 0;
|
||||
days++;
|
||||
rtcInterruptEvents |= 0x0008;
|
||||
newRtcTime = time[2];//seconds
|
||||
newRtcTime |= time[1] << 16;//minutes
|
||||
newRtcTime |= time[0] << 24;//hours
|
||||
|
||||
//check alarm range to see if it triggered in the time that has passed
|
||||
if(days == dayAlrm){
|
||||
if(hours < alarmHours || hours == alarmHours && minutes < alarmMinutes || hours == alarmHours && minutes == alarmMinutes && seconds < alarmSeconds){
|
||||
//old time is before alarm
|
||||
if(time[0] > alarmHours || time[0] == alarmHours && time[1] > alarmMinutes || time[0] == alarmHours && time[1] == alarmMinutes && time[0] >= alarmSeconds){
|
||||
//new time is after alarm
|
||||
rtcInterruptEvents |= 0x0040;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
//standard frame based time increment
|
||||
|
||||
newRtcTime = seconds;
|
||||
newRtcTime |= minutes << 16;
|
||||
newRtcTime |= hours << 24;
|
||||
seconds++;
|
||||
rtcInterruptEvents |= 0x0010;
|
||||
if(seconds >= 60){
|
||||
uint16_t stopwatch = registerArrayRead16(STPWCH);
|
||||
|
||||
if(newRtcTime == rtcAlrm && days == dayAlrm)
|
||||
rtcInterruptEvents |= 0x0040;
|
||||
if(stopwatch != 0x003F){
|
||||
if(stopwatch == 0x0000)
|
||||
stopwatch = 0x003F;
|
||||
else
|
||||
stopwatch--;
|
||||
registerArrayWrite16(STPWCH, stopwatch);
|
||||
}
|
||||
|
||||
//if stopwatch ran out above or was enabled with 0x003F in the register trigger interrupt
|
||||
if(stopwatch == 0x003F)
|
||||
rtcInterruptEvents |= 0x0001;
|
||||
|
||||
minutes++;
|
||||
seconds = 0;
|
||||
rtcInterruptEvents |= 0x0002;
|
||||
if(minutes >= 60){
|
||||
hours++;
|
||||
minutes = 0;
|
||||
rtcInterruptEvents |= 0x0020;
|
||||
if(hours >= 24){
|
||||
hours = 0;
|
||||
days++;
|
||||
rtcInterruptEvents |= 0x0008;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newRtcTime = seconds;
|
||||
newRtcTime |= minutes << 16;
|
||||
newRtcTime |= hours << 24;
|
||||
|
||||
if(newRtcTime == rtcAlrm && days == dayAlrm)
|
||||
rtcInterruptEvents |= 0x0040;
|
||||
}
|
||||
|
||||
rtcInterruptEvents &= registerArrayRead16(RTCIENR);
|
||||
if(rtcInterruptEvents){
|
||||
|
||||
@@ -60,6 +60,7 @@ int16_t* palmAudio;
|
||||
blip_t* palmAudioResampler;
|
||||
double palmCycleCounter;//can be greater then 0 if too many cycles where run
|
||||
double palmClockMultiplier;//used by the emulator to overclock the emulated Palm
|
||||
void (*palmGetRtcFromHost)(uint8_t* writeBack);//[0] = hours, [1] = minutes, [2] = seconds
|
||||
|
||||
|
||||
uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmBootloaderData, uint32_t palmBootloaderSize, uint32_t enabledEmuFeatures){
|
||||
@@ -77,6 +78,8 @@ uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmB
|
||||
if(!palmRomData || palmRomSize < 0x8)
|
||||
return EMU_ERROR_INVALID_PARAMETER;
|
||||
|
||||
palmGetRtcFromHost = NULL;
|
||||
|
||||
#if defined(EMU_SUPPORT_PALM_OS5)
|
||||
//0x00000004 is boot program counter on 68k, its just 0x00000000 on ARM
|
||||
palmEmulatingTungstenT3 = !(palmRomData[0x4] || palmRomData[0x5] || palmRomData[0x6] || palmRomData[0x7]);
|
||||
@@ -96,7 +99,7 @@ uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmB
|
||||
pxa255Deinit();
|
||||
return EMU_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(palmRom, palmRomData, uintMin(palmRomSize, TUNGSTEN_T3_ROM_SIZE));
|
||||
memcpy(palmRom, palmRomData, FAST_MIN(palmRomSize, TUNGSTEN_T3_ROM_SIZE));
|
||||
if(palmRomSize < TUNGSTEN_T3_ROM_SIZE)
|
||||
memset(palmRom + palmRomSize, 0x00, TUNGSTEN_T3_ROM_SIZE - palmRomSize);
|
||||
memset(palmRam, 0x00, TUNGSTEN_T3_RAM_SIZE);
|
||||
@@ -140,7 +143,7 @@ uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmB
|
||||
}
|
||||
|
||||
//set default values
|
||||
memcpy(palmRom, palmRomData, uintMin(palmRomSize, M515_ROM_SIZE));
|
||||
memcpy(palmRom, palmRomData, FAST_MIN(palmRomSize, M515_ROM_SIZE));
|
||||
if(palmRomSize < M515_ROM_SIZE)
|
||||
memset(palmRom + palmRomSize, 0x00, M515_ROM_SIZE - palmRomSize);
|
||||
swap16BufferIfLittle(palmRom, M515_ROM_SIZE / sizeof(uint16_t));
|
||||
|
||||
@@ -177,6 +177,7 @@ extern int16_t* palmAudio;//read allowed, 2 channel signed 16 bit audio
|
||||
extern blip_t* palmAudioResampler;//dont touch
|
||||
extern double palmCycleCounter;//dont touch
|
||||
extern double palmClockMultiplier;//read/write allowed, setting by multiplication and cacheing the result is the best way
|
||||
extern void (*palmGetRtcFromHost)(uint8_t* writeBack);//[0] = hours, [1] = minutes, [2] = seconds
|
||||
|
||||
//functions
|
||||
uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmBootloaderData, uint32_t palmBootloaderSize, uint32_t enabledEmuFeatures);
|
||||
|
||||
@@ -82,44 +82,9 @@ static inline uintmax_t rightShiftUse1s(uintmax_t value, uint8_t count){
|
||||
}
|
||||
|
||||
//range capping
|
||||
static inline uintmax_t uintMin(uintmax_t x, uintmax_t y){
|
||||
return x < y ? x : y;
|
||||
}
|
||||
|
||||
static inline uintmax_t uintMax(uintmax_t x, uintmax_t y){
|
||||
return x > y ? x : y;
|
||||
}
|
||||
|
||||
static inline uintmax_t uintClamp(uintmax_t low, uintmax_t value, uintmax_t high){
|
||||
//low must always be less than high!
|
||||
return uintMax(low, uintMin(value, high));
|
||||
}
|
||||
|
||||
static inline intmax_t intMin(intmax_t x, intmax_t y){
|
||||
return x < y ? x : y;
|
||||
}
|
||||
|
||||
static inline intmax_t intMax(intmax_t x, intmax_t y){
|
||||
return x > y ? x : y;
|
||||
}
|
||||
|
||||
static inline intmax_t intClamp(intmax_t low, intmax_t value, intmax_t high){
|
||||
//low must always be less than high!
|
||||
return intMax(low, intMin(value, high));
|
||||
}
|
||||
|
||||
static inline double floatMin(double x, double y){
|
||||
return x < y ? x : y;
|
||||
}
|
||||
|
||||
static inline double floatMax(double x, double y){
|
||||
return x > y ? x : y;
|
||||
}
|
||||
|
||||
static inline double floatClamp(double low, double value, double high){
|
||||
//low must always be less than high!
|
||||
return floatMax(low, floatMin(value, high));
|
||||
}
|
||||
#define FAST_MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
#define FAST_MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#define FAST_ABS(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
//float platform safety
|
||||
static inline uint64_t getUint64FromDouble(double data){
|
||||
|
||||
@@ -237,14 +237,14 @@ bool sdCardExchangeBit(bool bit){
|
||||
break;
|
||||
|
||||
case SEND_STATUS:
|
||||
//HACK, need to add real write protection, this command is also how the host reads the value of the little switch on the side
|
||||
//TODO: need to add real write protection, this command is also how the host reads the value of the little switch on the side
|
||||
sdCardDoResponseR2(palmSdCard.inIdleState, palmSdCard.sdInfo.writeProtectSwitch);
|
||||
break;
|
||||
|
||||
case SEND_WRITE_PROT:{
|
||||
const uint8_t writeProtBits[4] = {0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
//HACK, need to add real write protection
|
||||
//TODO: need to add real write protection
|
||||
sdCardDoResponseR1(palmSdCard.inIdleState);
|
||||
sdCardDoResponseDelay(1);
|
||||
sdCardDoResponseDataPacket(DATA_TOKEN_DEFAULT, writeProtBits, sizeof(writeProtBits));
|
||||
@@ -339,7 +339,7 @@ bool sdCardExchangeBit(bool bit){
|
||||
|
||||
case SET_WR_BLOCK_ERASE_COUNT:
|
||||
sdCardDoResponseR1(palmSdCard.inIdleState);
|
||||
//HACK, this command isnt actually supported yet, called when formmating the SD card
|
||||
//TODO: this command isnt actually supported yet, called when formmating the SD card
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -374,7 +374,7 @@ bool sdCardExchangeBit(bool bit){
|
||||
if(unlikely(palmSdCard.runningCommandVars[2] >= SD_CARD_BLOCK_DATA_PACKET_SIZE * 8)){
|
||||
//packet finished, verify and write block to chip
|
||||
if(likely(palmSdCard.allowInvalidCrc) || sdCardCrc16(palmSdCard.runningCommandPacket + 1, SD_CARD_BLOCK_SIZE) == (palmSdCard.runningCommandPacket[SD_CARD_BLOCK_DATA_PACKET_SIZE - 2] << 8 | palmSdCard.runningCommandPacket[SD_CARD_BLOCK_DATA_PACKET_SIZE - 1])){
|
||||
//HACK, also need to check if block is write protected, not just the card as a whole
|
||||
//TODO: also need to check if block is write protected, not just the card as a whole
|
||||
if(likely(palmSdCard.runningCommandVars[0] < palmSdCard.flashChipSize && !palmSdCard.sdInfo.writeProtectSwitch)){
|
||||
memcpy(palmSdCard.flashChipData + palmSdCard.runningCommandVars[0], palmSdCard.runningCommandPacket + 1, SD_CARD_BLOCK_SIZE);
|
||||
sdCardDoResponseDataResponse(DR_ACCEPTED);
|
||||
|
||||
@@ -391,8 +391,8 @@ void sed1376Render(void){
|
||||
//debugLog("PIP state, start x:%d, end x:%d, start y:%d, end y:%d\n", pipStartX, pipEndX, pipStartY, pipEndY);
|
||||
//render PIP only if PIP window is onscreen
|
||||
if(pipStartX < 160 && pipStartY < 160){
|
||||
pipEndX = uintMin(pipEndX, 160);
|
||||
pipEndY = uintMin(pipEndY, 160);
|
||||
pipEndX = FAST_MIN(pipEndX, 160);
|
||||
pipEndY = FAST_MIN(pipEndY, 160);
|
||||
screenStartAddress = getPipStartAddress();
|
||||
lineSize = (sed1376Registers[PIP_LINE_SZ_1] << 8 | sed1376Registers[PIP_LINE_SZ_0]) * 4;
|
||||
MULTITHREAD_DOUBLE_LOOP(pixelX, pixelY) for(pixelY = pipStartY; pixelY < pipEndY; pixelY++)
|
||||
|
||||
Reference in New Issue
Block a user