From 9e4f630f648a0c0cd75fa1fe25ea9979de2e348b Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Sat, 14 Jul 2018 17:11:20 -0700 Subject: [PATCH] Add better way to read single reference ADC values Alos remove incomplete remote access drivers since they are no longer needed and taking up some of the 32k CODE0 space. --- hwTestSuite/cpu.c | 5 +- hwTestSuite/irda.c | 175 -------------- hwTestSuite/irda.h | 10 - hwTestSuite/irdaAccessors.c.h | 57 ----- hwTestSuite/make.sh | 2 +- hwTestSuite/tools.c | 64 +----- hwTestSuite/tools.h | 3 +- hwTestSuite/viewer.c | 1 - hwTestSuite/vnc.c | 78 ------- hwTestSuite/vnc.h | 12 - qtBuildSystem/Mu/Mu.pro | 2 +- qtBuildSystem/Mu/Mu.pro.user | 354 ++--------------------------- src/emulator.c | 4 +- src/emulator.h | 13 +- src/hardwareRegisters.c | 2 - src/hardwareRegistersAccessors.c.h | 9 +- 16 files changed, 47 insertions(+), 744 deletions(-) delete mode 100644 hwTestSuite/irda.c delete mode 100644 hwTestSuite/irda.h delete mode 100644 hwTestSuite/irdaAccessors.c.h delete mode 100644 hwTestSuite/vnc.c delete mode 100644 hwTestSuite/vnc.h diff --git a/hwTestSuite/cpu.c b/hwTestSuite/cpu.c index 4707ffa..9732c5a 100644 --- a/hwTestSuite/cpu.c +++ b/hwTestSuite/cpu.c @@ -17,7 +17,7 @@ static uint8_t oldScr; void turnInterruptsOff(){ if(interruptsEnabled){ oldImr = readArbitraryMemory32(HW_REG_ADDR(IMR)); - writeArbitraryMemory32(HW_REG_ADDR(IMR), 0xFFFFF0FD);/*leave timer 1 and button interrupts enabled or program will freeze*/ + writeArbitraryMemory32(HW_REG_ADDR(IMR), 0xFFFFFFFF); interruptsEnabled = false; } } @@ -102,8 +102,6 @@ var enterUnsafeMode(){ oldScr = readArbitraryMemory8(HW_REG_ADDR(SCR)); writeArbitraryMemory8(HW_REG_ADDR(SCR), oldScr & 0xEF); - turnInterruptsOff(); - unsafeMode = true; resetFunctionViewer(); return makeVar(LENGTH_1, TYPE_BOOL, true);/*now in unsafe mode*/ @@ -116,7 +114,6 @@ var exitUnsafeMode(){ exitSubprogram();/*only run once/for one frame*/ if(unsafeMode){ - turnInterruptsOn(); writeArbitraryMemory8(HW_REG_ADDR(SCR), oldScr); unsafeMode = false; resetFunctionViewer(); diff --git a/hwTestSuite/irda.c b/hwTestSuite/irda.c deleted file mode 100644 index 2520d83..0000000 --- a/hwTestSuite/irda.c +++ /dev/null @@ -1,175 +0,0 @@ -#include -#include -#include - -#include "testSuite.h" -#include "specs/irdaCommands.h" -#include "debug.h" -#include "ugui.h" -#include "vnc.h" - - -/*since modern OSs dont support any way to communicate with Palm OS I am making my own with an IR LED and receiver*/ -/*this is mainly because running any sort of test takes 3 minutes to compile it, get it on a memory card, load it then find out it doesnt work*/ - - -#define IRDA_WAIT_FOREVER 0x7FFFFFFF - - -static Boolean irdaRunning = false; -static Err irdaError; -static Boolean irdaUseThreadedVnc;/*use Dragonball VZ timer 2 interrupt as a second thread for VNC*/ -static uint16_t irdaPortId; - - -#include "irdaAccessors.c.h" - -void irdaHandleCommands(){ - if(irdaRunning){ - uint8_t irdaCommand = irdaReceiveUint8(); - while(irdaCommand != IRDA_COMMAND_NONE){ - switch(irdaCommand){ - case IRDA_COMMAND_NONE: - break; - - case IRDA_COMMAND_GET_BYTE:{ - uint32_t location = irdaReceiveUint32(); - irdaTransmitUint8(IRDA_COMMAND_RETURN); - irdaTransmitUint8(readArbitraryMemory8(location)); - break; - } - - case IRDA_COMMAND_SET_BYTE:{ - uint32_t location = irdaReceiveUint32(); - uint8_t data = irdaReceiveUint8(); - writeArbitraryMemory8(location, data); - break; - } - - default: - /*todo: print error and terminate*/ - break; - } - - irdaCommand = irdaReceiveUint8(); - } - } -} - -static Boolean irdaInit(Boolean useThreadedVnc){ - if(!irdaRunning){ - uint32_t value; - - irdaError = FtrGet(sysFileCSerialMgr, sysFtrNewSerialPresent, &value); - if(irdaError != errNone || value == false) - return false; - - irdaError = SrmOpen(serPortIrPort, 9600, &irdaPortId); - if(irdaError != errNone) - return false; - - if(useThreadedVnc){ - Boolean success; - success = vncInit(); - if(success) - irdaUseThreadedVnc = true; - else - irdaUseThreadedVnc = false; - } - else{ - irdaUseThreadedVnc = false; - } - - irdaRunning = true; - return true; - } - - return true;/*its already running, return success*/ -} - -static void irdaExit(){ - if(irdaRunning){ - if(irdaUseThreadedVnc) - vncExit(); - irdaTransmitUint8(IRDA_COMMAND_CLOSE_CONNECTION); - SrmSendWait(irdaPortId); - SrmReceiveFlush(irdaPortId, 1); - SrmSendFlush(irdaPortId); - SrmClose(irdaPortId); - } -} - -var irdaCommandLoop(){ - static Boolean firstRun = true; - static Boolean running; - - if(firstRun){ - Boolean success; - firstRun = false; - running = false; - success = irdaInit(varsEqual(getSubprogramArgs(), makeVar(LENGTH_1, TYPE_BOOL, true))); - if(success){ - debugSafeScreenClear(C_WHITE); - StrPrintF(sharedDataBuffer, "IRDA remote control\n mode running..."); - UG_PutString(0, 0, sharedDataBuffer); - } - else{ - debugSafeScreenClear(C_WHITE); - StrPrintF(sharedDataBuffer, "IRDA startup failed!"); - UG_PutString(0, 0, sharedDataBuffer); - } - } - - if(getButtonPressed(buttonBack)){ - firstRun = true; - irdaExit(); - exitSubprogram(); - } - - if(!irdaUseThreadedVnc) - irdaHandleCommands(); - - return makeVar(LENGTH_0, TYPE_NULL, 0); -} - -var irdaRun(){ - static Boolean firstRun = true; - uint16_t y = 0; - - if(firstRun){ - firstRun = false; - if(!unsafeMode){ - /*cant run VNC server anyway*/ - setSubprogramArgs(makeVar(LENGTH_1, TYPE_BOOL, false)); - execSubprogram(irdaCommandLoop); - return makeVar(LENGTH_0, TYPE_NULL, 0); - } - - debugSafeScreenClear(C_WHITE); - StrPrintF(sharedDataBuffer, "Use Dragonball VZ timer 2 as VNC thread?"); - UG_PutString(0, y, sharedDataBuffer); - y += (FONT_HEIGHT + 1) * 2; - StrPrintF(sharedDataBuffer, "Left = No, Right = Yes"); - UG_PutString(0, y, sharedDataBuffer); - y += FONT_HEIGHT + 1; - } - - if(getButtonPressed(buttonLeft)){ - firstRun = true; - setSubprogramArgs(makeVar(LENGTH_1, TYPE_BOOL, false)); - execSubprogram(irdaCommandLoop); - } - - if(getButtonPressed(buttonRight)){ - firstRun = true; - setSubprogramArgs(makeVar(LENGTH_1, TYPE_BOOL, true)); - execSubprogram(irdaCommandLoop); - } - - if(getButtonPressed(buttonBack)){ - firstRun = true; - exitSubprogram(); - } - - return makeVar(LENGTH_0, TYPE_NULL, 0); -} diff --git a/hwTestSuite/irda.h b/hwTestSuite/irda.h deleted file mode 100644 index 57d2d68..0000000 --- a/hwTestSuite/irda.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef IRDA_HEADER -#define IRDA_HEADER - -#include "testSuite.h" - -void irdaHandleCommands(); -var irdaRun(); - -#endif - diff --git a/hwTestSuite/irdaAccessors.c.h b/hwTestSuite/irdaAccessors.c.h deleted file mode 100644 index 920739f..0000000 --- a/hwTestSuite/irdaAccessors.c.h +++ /dev/null @@ -1,57 +0,0 @@ -static void irdaTransmitUint8(uint8_t data){ - if(irdaRunning) - SrmSend(irdaPortId, &data, 1/*bytes*/, &irdaError); -} - -static uint8_t irdaReceiveUint8(){ - if(irdaRunning){ - uint8_t data; - - SrmReceive(irdaPortId, &data, 1/*bytes*/, IRDA_WAIT_FOREVER, &irdaError); - return data; - } - - return 0x00; -} - -static void irdaTransmitUint16(uint16_t data){ - if(irdaRunning) - SrmSend(irdaPortId, &data, 2/*bytes*/, &irdaError); -} - -static uint16_t irdaReceiveUint16(){ - if(irdaRunning){ - uint16_t data; - - SrmReceive(irdaPortId, &data, 2/*bytes*/, IRDA_WAIT_FOREVER, &irdaError); - return data; - } - - return 0x0000; -} - -static void irdaTransmitUint32(uint32_t data){ - if(irdaRunning) - SrmSend(irdaPortId, &data, 4/*bytes*/, &irdaError); -} - -static uint32_t irdaReceiveUint32(){ - if(irdaRunning){ - uint32_t data; - - SrmReceive(irdaPortId, &data, 4/*bytes*/, IRDA_WAIT_FOREVER, &irdaError); - return data; - } - - return 0x00000000; -} - -static void irdaTransmitBuffer(uint8_t* data, uint32_t size){ - if(irdaRunning) - SrmSend(irdaPortId, data, size, &irdaError); -} - -static void irdaReceiveBuffer(uint8_t* data, uint32_t size){ - if(irdaRunning) - SrmReceive(irdaPortId, data, size/*bytes*/, IRDA_WAIT_FOREVER, &irdaError); -} diff --git a/hwTestSuite/make.sh b/hwTestSuite/make.sh index d414803..2048878 100755 --- a/hwTestSuite/make.sh +++ b/hwTestSuite/make.sh @@ -12,7 +12,7 @@ if [ "$1" = "clean" ]; then exit fi -declare -a FILES=("testSuite" "viewer" "tools" "tests" "cpu" "irda" "vnc" "emuFunctions" "ugui" "undocumentedApis") +declare -a FILES=("testSuite" "viewer" "tools" "tests" "cpu" "emuFunctions" "ugui" "undocumentedApis") DEFINES="-DHW_TEST" CFLAGS="-palmos4 -O3 $DEFINES" diff --git a/hwTestSuite/tools.c b/hwTestSuite/tools.c index 6b9508f..3304a86 100644 --- a/hwTestSuite/tools.c +++ b/hwTestSuite/tools.c @@ -52,16 +52,18 @@ Err makeFile(uint8_t* data, uint32_t size, char* fileName){ return error; } -uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bit){ +uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8Bit){ uint8_t config = 0x80; uint16_t value; volatile uint32_t wasteTime; - if(mode8bit) + if(mode8Bit) config |= 0x08; - if(referenceMode) + if(referenceMode){ config |= 0x04; + config |= 0x03;/*force ADC and reference always on*/ + } config |= channel << 4 & 0x70; @@ -74,9 +76,8 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bi writeArbitraryMemory8(HW_REG_ADDR(PEPUEN), readArbitraryMemory8(HW_REG_ADDR(PEPUEN)) & 0xFE); /*enable SPI 2 if disabled*/ - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4207); + writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4200); -#if 1 /*send data, only send the first 5 bits to leave the ADC enabled*/ writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config >> 3); writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4304); @@ -94,20 +95,6 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bi /*get value returned*/ value = readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)) & 0x0FFF; -#else - /*send data*/ - writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config << 1); - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4308); - while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); - - /*receive data*/ - writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), 0x0000);/*clear to prevent sending a new control byte*/ - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x430F); - while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); - - /*get value returned*/ - value = readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)) >> (mode8bit ? 8 : 4); -#endif /*disable SPI2*/ writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0xE000); @@ -120,45 +107,6 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bi return value; } -float percentageOfTimeAs1(uint32_t address, uint8_t readSize, uint8_t bitNumber, uint32_t samples, uint32_t delay){ - /*gets the percentage of time a bit spends as a 1, for example a clock line should be exactly 50%, delay is in CLK32 pulses*/ - uint32_t sampleCount; - uint32_t timesAs1 = 0; - - for(sampleCount = 0; sampleCount < samples; sampleCount++){ - uint32_t value; - uint32_t wait; - Boolean lastClk32; - - switch(readSize){ - case 8: - value = readArbitraryMemory8(address); - break; - - case 16: - value = readArbitraryMemory16(address); - break; - - case 32: - value = readArbitraryMemory32(address); - break; - } - - if(value >> bitNumber & 1) - timesAs1++; - - lastClk32 = readArbitraryMemory16(HW_REG_ADDR(PLLFSR)) >> 15; - while(wait < delay){ - if(readArbitraryMemory16(HW_REG_ADDR(PLLFSR)) >> 15 != lastClk32){ - lastClk32 = !lastClk32; - wait++; - } - } - } - - return (float)timesAs1 / (float)samples * 100.0; -} - var hexRamBrowser(){ static Boolean firstRun = true; static uint32_t nibble; diff --git a/hwTestSuite/tools.h b/hwTestSuite/tools.h index f82f4e8..ba7ae0e 100644 --- a/hwTestSuite/tools.h +++ b/hwTestSuite/tools.h @@ -6,8 +6,7 @@ #include "testSuite.h" Err makeFile(uint8_t* data, uint32_t size, char* fileName); -uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bit); -float percentageOfTimeAs1(uint32_t address, uint8_t readSize, uint8_t bitNumber, uint32_t samples, uint32_t delay); +uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8Bit); var hexRamBrowser(); var getTrapAddress(); var manualLssa(); diff --git a/hwTestSuite/viewer.c b/hwTestSuite/viewer.c index b0b346a..1a6b36d 100644 --- a/hwTestSuite/viewer.c +++ b/hwTestSuite/viewer.c @@ -7,7 +7,6 @@ #include "tests.h" #include "debug.h" #include "cpu.h" -#include "irda.h" #include "ugui.h" diff --git a/hwTestSuite/vnc.c b/hwTestSuite/vnc.c deleted file mode 100644 index b938e37..0000000 --- a/hwTestSuite/vnc.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - -#include "testSuite.h" -#include "specs/hardwareRegisterNames.h" -#include "irda.h" -#include "cpu.h" - - -/*the OS doesnt seem to use timer 2(at least on Sony Clie PEG-SL10) since it was added after*/ -/*the OS was written since it was originally for the Dragonball 328,*/ -/*this makes it perfect for using as a hardware thread*/ - - -static Boolean vncRunning = false; -static void (*palmOsIntLevel6Handler)(); - - -static void vncInterruptHandler(){ - /*called when VNC is enabled and a level 6 interrupt occurs*/ - if(readArbitraryMemory16(HW_REG_ADDR(TSTAT2))){ - /*the interrupt was called by timer 2*/ - irdaHandleCommands(); - - /*clear timer 2 interrupt, it must be read before writing it is possible but that is performed by the check above*/ - writeArbitraryMemory16(HW_REG_ADDR(TSTAT2), 0x0000); - } - else{ - /*not timer 2, send interrupt to Palm OS*/ - palmOsIntLevel6Handler(); - } -} - -Boolean vncInit(){ - if(!vncRunning){ - uint16_t ilcr; - - turnInterruptsOff(); - - /*install interrupt handler*/ - palmOsIntLevel6Handler = (void*)readArbitraryMemory32(readArbitraryMemory8(HW_REG_ADDR(IVR) | 6/*int level*/) * 4); - writeArbitraryMemory32(readArbitraryMemory8(HW_REG_ADDR(IVR) | 6/*int level*/) * 4, (uint32_t)vncInterruptHandler); - - /*set timer 2 interrupt priority, using level 6 because its the highest*/ - ilcr = readArbitraryMemory16(HW_REG_ADDR(ILCR)); - ilcr &= 0x7770;/*remove TMR2 field*/ - ilcr |= 0x0006;/*set new TMR2 field*/ - writeArbitraryMemory16(HW_REG_ADDR(ILCR), ilcr); - - /*set interrupt to trigger every 32768 / 15 seconds, 15 fps*/ - readArbitraryMemory16(HW_REG_ADDR(TSTAT2));/*clear any existing interrupt*/ - writeArbitraryMemory16(HW_REG_ADDR(TSTAT2), 0x0000);/*clear any existing interrupt*/ - writeArbitraryMemory16(HW_REG_ADDR(TPRER2), 0x0000);/*timer prescaler off*/ - writeArbitraryMemory16(HW_REG_ADDR(TCMP2), 32768 / 15);/*timer duration*/ - writeArbitraryMemory16(HW_REG_ADDR(TCTL2), 0x001F);/*turn on timer 2, using CLK32 as the source*/ - - turnInterruptsOn(); - - vncRunning = true; - } - - return true;/*its already running, return success*/ -} - -void vncExit(){ - if(vncRunning){ - turnInterruptsOff(); - - /*turn off timer 2*/ - writeArbitraryMemory16(HW_REG_ADDR(TCTL2), 0x0000); - - writeArbitraryMemory32(readArbitraryMemory8(HW_REG_ADDR(IVR) | 6/*int level*/) * 4, (uint32_t)palmOsIntLevel6Handler); - - turnInterruptsOn(); - - vncRunning = false; - } -} diff --git a/hwTestSuite/vnc.h b/hwTestSuite/vnc.h deleted file mode 100644 index d1ee7bd..0000000 --- a/hwTestSuite/vnc.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef VNC_HEADER -#define VNC_HEADER - -#include - -#include "testSuite.h" - -Boolean vncInit(); -void vncExit(); - -#endif - diff --git a/qtBuildSystem/Mu/Mu.pro b/qtBuildSystem/Mu/Mu.pro index 4aef9a4..3c92049 100644 --- a/qtBuildSystem/Mu/Mu.pro +++ b/qtBuildSystem/Mu/Mu.pro @@ -31,7 +31,7 @@ macx { } CONFIG(debug, debug|release){ - DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER EMU_LOG_REGISTER_ACCESS_UNKNOWN + DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER EMU_LOG_REGISTER_ACCESS_ALL # DEFINES += EMU_OPCODE_LEVEL_DEBUG EMU_LOG_APIS } diff --git a/qtBuildSystem/Mu/Mu.pro.user b/qtBuildSystem/Mu/Mu.pro.user index faae2b5..648b4be 100644 --- a/qtBuildSystem/Mu/Mu.pro.user +++ b/qtBuildSystem/Mu/Mu.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -59,14 +59,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.11.0 clang 64bit - Desktop Qt 5.11.0 clang 64bit - qt.qt5.5110.clang_64_kit + Desktop Qt 5.11.1 clang 64bit + Desktop Qt 5.11.1 clang 64bit + qt.qt5.5111.clang_64_kit 0 0 0 - /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_0_clang_64bit-Debug + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_1_clang_64bit-Debug true @@ -126,7 +126,7 @@ true - /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_0_clang_64bit-Release + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_1_clang_64bit-Release true @@ -137,7 +137,7 @@ false false - false + true true @@ -186,7 +186,7 @@ true - /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_0_clang_64bit-Profile + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_1_clang_64bit-Profile true @@ -197,7 +197,7 @@ false true - false + true true @@ -300,336 +300,14 @@ 13 14 - 2 + -1 - Mu + + + + - Qt4ProjectManager.Qt4RunConfiguration:/Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/Mu/Mu.pro - true - - Mu.pro - false - - /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_0_clang_64bit-Debug/Mu.app/Contents/MacOS - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.Target.1 - - Android for armeabi-v7a (GCC 4.9, Qt 5.11.0 for Android armv7) - Android for armeabi-v7a (GCC 4.9, Qt 5.11.0 for Android armv7) - {d4fa28a3-e781-4010-a73c-9fd20aa71367} - 1 - 0 - 0 - - /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_0_for_Android_armv7-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - - true - Copy application data - - Qt4ProjectManager.AndroidPackageInstallationStep - - - android-26 - - true - Build Android APK - - QmakeProjectManager.AndroidBuildApkStep - false - false - - 4 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_0_for_Android_armv7-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - - true - Copy application data - - Qt4ProjectManager.AndroidPackageInstallationStep - - - android-26 - - true - Build Android APK - - QmakeProjectManager.AndroidBuildApkStep - false - false - - 4 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_0_for_Android_armv7-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - - true - Copy application data - - Qt4ProjectManager.AndroidPackageInstallationStep - - - android-26 - - true - Build Android APK - - QmakeProjectManager.AndroidBuildApkStep - false - false - - 4 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - - true - Deploy to Android device - - Qt4ProjectManager.AndroidDeployQtStep - false - - 1 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy to Android device - - Qt4ProjectManager.AndroidDeployConfiguration2 - - 1 - - ZY223CQT6S - 27 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - - - Mu - Mu - Qt4ProjectManager.AndroidRunConfiguration:/Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/Mu/Mu.pro - Mu.pro + ProjectExplorer.CustomExecutableRunConfiguration 3768 false true @@ -642,7 +320,7 @@ ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/src/emulator.c b/src/emulator.c index e18e8be..33e6872 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -715,7 +715,7 @@ void emulatorSaveState(uint8_t* data){ offset += sizeof(uint8_t); writeStateValueUint8(data + offset, palmMisc.batteryLevel); offset += sizeof(uint8_t); - writeStateValueUint8(data + offset, palmMisc.inDock); + writeStateValueUint8(data + offset, palmMisc.dataPort); offset += sizeof(uint8_t); } @@ -858,7 +858,7 @@ void emulatorLoadState(uint8_t* data){ offset += sizeof(uint8_t); palmMisc.batteryLevel = readStateValueUint8(data + offset); offset += sizeof(uint8_t); - palmMisc.inDock = readStateValueUint8(data + offset); + palmMisc.dataPort = readStateValueUint8(data + offset); offset += sizeof(uint8_t); } diff --git a/src/emulator.h b/src/emulator.h index 35a493f..799ac08 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -57,13 +57,22 @@ enum{ //sdcard types enum{ - CARD_BEGIN = 0, CARD_NONE = 0, CARD_SD, CARD_MMC, CARD_END }; +//port types +enum{ + PORT_NONE = 0, + PORT_USB_CRADLE, + PORT_SERIAL_CRADLE, + PORT_USB_PERIPHERAL, + PORT_SERIAL_PERIPHERAL, + PORT_END +}; + //types typedef struct{ uint8_t* data; @@ -111,7 +120,7 @@ typedef struct{ bool vibratorOn; bool batteryCharging; uint8_t batteryLevel; - bool inDock; + uint8_t dataPort; }misc_hw_t; //CPU diff --git a/src/hardwareRegisters.c b/src/hardwareRegisters.c index f3a8cac..2ea3a39 100644 --- a/src/hardwareRegisters.c +++ b/src/hardwareRegisters.c @@ -144,7 +144,6 @@ static void recalculateCpuSpeed(){ newCpuSpeed = 0.0; } - /* if(newCpuSpeed != palmCrystalCycles){ debugLog("New CPU frequency of:%f cycles per second.\n", newCpuSpeed * CRYSTAL_FREQUENCY); debugLog("New CLK32 cycle count of:%f.\n", newCpuSpeed); @@ -155,7 +154,6 @@ static void recalculateCpuSpeed(){ debugLog("CPU turned off with DISPLL bit.\n"); } } - */ palmCrystalCycles = newCpuSpeed; } diff --git a/src/hardwareRegistersAccessors.c.h b/src/hardwareRegistersAccessors.c.h index c50073f..8fe2af3 100644 --- a/src/hardwareRegistersAccessors.c.h +++ b/src/hardwareRegistersAccessors.c.h @@ -252,6 +252,13 @@ static inline void setSpiCont2(uint16_t value){ uint16_t spi2Data = registerArrayRead16(SPIDATA2); //uint16_t oldSpi2Data = spi2Data; + /* + if(spi2Data == 0x0AE0){ + //first ADS7846 access, for debugging + spi2Data = spi2Data; + } + */ + //the input data is shifted into the unused bits if the transfer is less than 16 bits for(uint8_t bits = 0; bits < bitCount; bits++){ bool newBit = ads7846ExchangeBit(spi2Data & startBit); @@ -446,7 +453,7 @@ static inline uint8_t getPortKValue(){ uint8_t portKDir = registerArrayRead8(PKDIR); uint8_t portKSel = registerArrayRead8(PKSEL); - portKValue |= !palmMisc.inDock << 2; + portKValue |= !(palmMisc.dataPort == PORT_USB_CRADLE || palmMisc.dataPort == PORT_SERIAL_CRADLE) << 2;//true if charging portKValue |= 0xFB;//floating pins are high portKValue &= ~portKDir & portKSel; portKValue |= portKData & portKDir & portKSel;