From 2d6b3372a7a7e422690a49459cbf13b0637b450d Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Thu, 29 Nov 2018 21:28:12 -0800 Subject: [PATCH] Fix some invalid behavior with IMR, still have the power button issue --- readme.md | 3 +++ src/hardwareRegisters.c | 17 ++++++++++------- src/hardwareRegistersAccessors.c.h | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index ae70517..95900b7 100644 --- a/readme.md +++ b/readme.md @@ -106,5 +106,8 @@ I understand not everyone speaks English so I list both ROMs, I do all my testin ## License Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 United States License. +## Links +[Discord](https://discord.gg/hWSz8VN) + ## Also see Mu's sister project [🐿SquirrelJME](https://multiphasicapps.net) diff --git a/src/hardwareRegisters.c b/src/hardwareRegisters.c index f056397..e40e6e9 100644 --- a/src/hardwareRegisters.c +++ b/src/hardwareRegisters.c @@ -118,11 +118,11 @@ void setWriteProtectViolation(uint32_t address){ } static void pllWakeCpuIfOff(void){ - if(!pllIsOn() && pllWakeWait == -1){ - //PLL is off and not already in the process of waking up - int8_t pllWaitTable[4] = {32, 48, 64, 96}; + const int8_t pllWaitTable[4] = {32, 48, 64, 96}; + + //PLL is off and not already in the process of waking up + if(!pllIsOn() && pllWakeWait == -1) pllWakeWait = pllWaitTable[registerArrayRead16(PLLCR) & 0x0003]; - } } static void checkInterrupts(void){ @@ -728,14 +728,16 @@ void setHwRegister16(uint32_t address, uint16_t value){ break; case IMR: - //this is a 32 bit register but Palm OS writes it as 16 bit chunks + //this is a 32 bit register but Palm OS writes to it as 16 bit chunks registerArrayWrite16(IMR, value & 0x00FF); registerArrayWrite16(ISR, registerArrayRead16(IPR) & registerArrayRead16(IMR)); + checkInterrupts(); break; case IMR + 2: - //this is a 32 bit register but Palm OS writes it as 16 bit chunks - registerArrayWrite16(IMR + 2, value & 0x03FF); + //this is a 32 bit register but Palm OS writes to it as 16 bit chunks + registerArrayWrite16(IMR + 2, value & 0x3FFF); registerArrayWrite16(ISR + 2, registerArrayRead16(IPR + 2) & registerArrayRead16(IMR + 2)); + checkInterrupts(); break; case ISR: @@ -1006,6 +1008,7 @@ void setHwRegister32(uint32_t address, uint32_t value){ case IMR: registerArrayWrite32(IMR, value & 0x00FF3FFF); registerArrayWrite32(ISR, registerArrayRead32(IPR) & registerArrayRead32(IMR)); + checkInterrupts(); break; case LSSA: diff --git a/src/hardwareRegistersAccessors.c.h b/src/hardwareRegistersAccessors.c.h index e345d81..296554a 100644 --- a/src/hardwareRegistersAccessors.c.h +++ b/src/hardwareRegistersAccessors.c.h @@ -264,8 +264,9 @@ static void updateCsdAddressLines(void){ static void setPllfsr(uint16_t value){ uint16_t oldPllfsr = registerArrayRead16(PLLFSR); + + //change frequency if frequency protect bit isnt set if(!(oldPllfsr & 0x4000)){ - //frequency protect bit not set registerArrayWrite16(PLLFSR, (value & 0x4FFF) | (oldPllfsr & 0x8000));//preserve CLK32 bit palmSysclksPerClk32 = sysclksPerClk32(); }