From fe089cf62669e095d2005df81ce8a58c60a5dc1a Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Fri, 9 Nov 2018 14:43:09 -0800 Subject: [PATCH] Fix chip select status bits not being casted to bool properly on non stdbool.h platforms Also fixed the 64k install limit. --- bugs/brokenLibretroPlatforms.txt | 2 +- bugs/missingFunctions.txt | 2 ++ bugs/unimplementedHardware.txt | 1 + qtBuildSystem/Mu/Mu.pro | 3 +-- src/debug/sandbox.c | 25 ++++++++++++++++++++++++- src/hardwareRegistersAccessors.c.h | 14 +++++++------- src/hardwareRegistersTiming.c.h | 4 ++-- src/sed1376.c | 2 +- 8 files changed, 39 insertions(+), 14 deletions(-) diff --git a/bugs/brokenLibretroPlatforms.txt b/bugs/brokenLibretroPlatforms.txt index c285606..e21c48f 100644 --- a/bugs/brokenLibretroPlatforms.txt +++ b/bugs/brokenLibretroPlatforms.txt @@ -1,10 +1,10 @@ PSP -msvc2010 classics/new haxchi(should work) xbox(don't know) xbox360(don't know) Fixed: +msvc2010 msvc2003 remove old haxchi emscripten diff --git a/bugs/missingFunctions.txt b/bugs/missingFunctions.txt index 034df2a..8952057 100644 --- a/bugs/missingFunctions.txt +++ b/bugs/missingFunctions.txt @@ -6,8 +6,10 @@ If there is no userdata-en-m515.ram on Android the emu won't create it(this is l Theres no auto ROM installer app install hack needs to be removed when SD card works double pressing power button issue +16 bpp mode is broken Fixed: +64k app install limit device runs at around half speed for some reason(the SYSCLK divider was not scaled properly) Sound(those cute little PWM beeps) Mac Qt build has no icons diff --git a/bugs/unimplementedHardware.txt b/bugs/unimplementedHardware.txt index 6c860af..aef3c1a 100644 --- a/bugs/unimplementedHardware.txt +++ b/bugs/unimplementedHardware.txt @@ -41,6 +41,7 @@ the unemulated chip selects(CSB1, CSC0/1) privilege violation interrupts will no SED1376: swivelview register +16 bpp mode is broken and crushed to the top of the screen ADS7846: verify chip select(no test has been done yet, put everything points to port g bit 2) diff --git a/qtBuildSystem/Mu/Mu.pro b/qtBuildSystem/Mu/Mu.pro index fac99c2..0a60992 100644 --- a/qtBuildSystem/Mu/Mu.pro +++ b/qtBuildSystem/Mu/Mu.pro @@ -185,8 +185,7 @@ DISTFILES += \ images/stateManager.svg \ images/stop.svg \ images/todo.svg \ - images/up.svg \ - ../../src/m68k/cyclone/Cyclone.s + images/up.svg RESOURCES += \ mainwindow.qrc diff --git a/src/debug/sandbox.c b/src/debug/sandbox.c index f18e6f5..afb24fd 100644 --- a/src/debug/sandbox.c +++ b/src/debug/sandbox.c @@ -402,7 +402,28 @@ static void freePalmString(uint32_t address){ } static bool installResourceToDevice(buffer_t resourceBuffer){ - uint32_t palmSideResourceData = callFunction(false, 0x00000000, MemPtrNew, "p(l)", (uint32_t)resourceBuffer.size); + /* + #define memNewChunkFlagNonMovable 0x0200 + #define memNewChunkFlagAllowLarge 0x1000 // this is not in the sdk *g* + + void *MemPtrNewL ( UInt32 size ) { + + SysAppInfoPtr appInfoP; + UInt16 ownerID; + + ownerID = + ((SysAppInfoPtr)SysGetAppInfo(&appInfoP, &appInfoP))->memOwnerID; + + return MemChunkNew ( 0, size, ownerID | + memNewChunkFlagNonMovable | + memNewChunkFlagAllowLarge ); + + } + */ + + //uint32_t palmSideResourceData = callFunction(false, 0x00000000, MemPtrNew, "p(l)", (uint32_t)resourceBuffer.size); + uint32_t palmSideResourceData = callFunction(false, 0x00000000, MemChunkNew, "p(wlw)", 1/*heapID, storage RAM*/, (uint32_t)resourceBuffer.size, 0x1200/*attr, seems to work without memOwnerID*/); + bool storageRamReadOnly = chips[CHIP_DX_RAM].readOnlyForProtectedMemory; uint16_t error; uint32_t count; @@ -410,8 +431,10 @@ static bool installResourceToDevice(buffer_t resourceBuffer){ if(!palmSideResourceData) return false; + chips[CHIP_DX_RAM].readOnlyForProtectedMemory = false;//need to unprotect storage RAM for(count = 0; count < resourceBuffer.size; count++) m68k_write_memory_8(palmSideResourceData + count, resourceBuffer.data[count]); + chips[CHIP_DX_RAM].readOnlyForProtectedMemory = storageRamReadOnly;//restore old protection state error = callFunction(false, 0x00000000, DmCreateDatabaseFromImage, "w(p)", palmSideResourceData);//Err DmCreateDatabaseFromImage(MemPtr bufferP);//this looks best callFunction(false, 0x00000000, MemChunkFree, "w(p)", palmSideResourceData); diff --git a/src/hardwareRegistersAccessors.c.h b/src/hardwareRegistersAccessors.c.h index 47911b0..c04fd86 100644 --- a/src/hardwareRegistersAccessors.c.h +++ b/src/hardwareRegistersAccessors.c.h @@ -125,7 +125,7 @@ static void pwm1FifoFlush(void){ //register setters static void setCsa(uint16_t value){ chips[CHIP_A0_ROM].enable = value & 0x0001; - chips[CHIP_A0_ROM].readOnly = value & 0x8000; + chips[CHIP_A0_ROM].readOnly = !!(value & 0x8000); chips[CHIP_A0_ROM].lineSize = 0x20000/*128kb*/ << (value >> 1 & 0x0007); //CSA is now just a normal chip select @@ -144,12 +144,12 @@ static void setCsb(uint16_t value){ uint16_t csControl1 = registerArrayRead16(CSCTRL1); chips[CHIP_B0_SED].enable = value & 0x0001; - chips[CHIP_B0_SED].readOnly = value & 0x8000; + chips[CHIP_B0_SED].readOnly = !!(value & 0x8000); chips[CHIP_B0_SED].lineSize = 0x20000/*128kb*/ << (value >> 1 & 0x0007); //attributes - chips[CHIP_B0_SED].supervisorOnlyProtectedMemory = value & 0x4000; - chips[CHIP_B0_SED].readOnlyForProtectedMemory = value & 0x2000; + chips[CHIP_B0_SED].supervisorOnlyProtectedMemory = !!(value & 0x4000); + chips[CHIP_B0_SED].readOnlyForProtectedMemory = !!(value & 0x2000); if(csControl1 & 0x4000 && csControl1 & 0x0001) chips[CHIP_B0_SED].unprotectedSize = chips[CHIP_B0_SED].lineSize / (1 << 7 - ((value >> 11 & 0x0003) | 0x0004)); else @@ -162,15 +162,15 @@ static void setCsd(uint16_t value){ uint16_t csControl1 = registerArrayRead16(CSCTRL1); chips[CHIP_DX_RAM].enable = value & 0x0001; - chips[CHIP_DX_RAM].readOnly = value & 0x8000; + chips[CHIP_DX_RAM].readOnly = !!(value & 0x8000); if(csControl1 & 0x0040 && value & 0x0200) chips[CHIP_DX_RAM].lineSize = 0x800000/*8mb*/ << (value >> 1 & 0x0001); else chips[CHIP_DX_RAM].lineSize = 0x8000/*32kb*/ << (value >> 1 & 0x0007); //attributes - chips[CHIP_DX_RAM].supervisorOnlyProtectedMemory = value & 0x4000; - chips[CHIP_DX_RAM].readOnlyForProtectedMemory = value & 0x2000; + chips[CHIP_DX_RAM].supervisorOnlyProtectedMemory = !!(value & 0x4000); + chips[CHIP_DX_RAM].readOnlyForProtectedMemory = !!(value & 0x2000); if(csControl1 & 0x4000 && csControl1 & 0x0010) chips[CHIP_DX_RAM].unprotectedSize = chips[CHIP_DX_RAM].lineSize / (1 << 7 - ((value >> 11 & 0x0003) | 0x0004)); else diff --git a/src/hardwareRegistersTiming.c.h b/src/hardwareRegistersTiming.c.h index e4b7cfd..880a86d 100644 --- a/src/hardwareRegistersTiming.c.h +++ b/src/hardwareRegistersTiming.c.h @@ -7,7 +7,7 @@ static void timer1(uint8_t reason, double sysclks){ uint16_t timer1Compare = registerArrayRead16(TCMP1); double timer1OldCount = timerCycleCounter[0]; double timer1Prescaler = (registerArrayRead16(TPRER1) & 0x00FF) + 1; - bool timer1Enabled = timer1Control & 0x0001;//no need for a bool cast, already using the lowest bit + bool timer1Enabled = timer1Control & 0x0001; if(timer1Enabled){ switch((timer1Control & 0x000E) >> 1){ @@ -74,7 +74,7 @@ static void timer2(uint8_t reason, double sysclks){ uint16_t timer2Compare = registerArrayRead16(TCMP2); double timer2OldCount = timerCycleCounter[1]; double timer2Prescaler = (registerArrayRead16(TPRER2) & 0x00FF) + 1; - bool timer2Enabled = timer2Control & 0x0001;//no need for a bool cast, already using the lowest bit + bool timer2Enabled = timer2Control & 0x0001; if(timer2Enabled){ switch((timer2Control & 0x000E) >> 1){ diff --git a/src/sed1376.c b/src/sed1376.c index 2147022..85190ac 100644 --- a/src/sed1376.c +++ b/src/sed1376.c @@ -172,7 +172,7 @@ void sed1376LoadState(uint8_t* data){ } bool sed1376PowerSaveEnabled(void){ - return sed1376Registers[PWR_SAVE_CFG] & 0x01;//no need for a bool cast, already using the lowest bit + return sed1376Registers[PWR_SAVE_CFG] & 0x01; } uint8_t sed1376GetRegister(uint8_t address){