diff options
author | Raphaël Zumer <rzumer@tebako.net> | 2019-12-10 18:44:53 -0500 |
---|---|---|
committer | Raphaël Zumer <rzumer@tebako.net> | 2019-12-10 19:10:14 -0500 |
commit | f257b007a250e33ecc7a86c7447ccf049964dd8d (patch) | |
tree | f249fb6d7cef765d1ca1f627fa34c0db67cdce98 /src | |
parent | ca9f183d24c028cbbbecbe07aefb37bdcd04a581 (diff) |
Properly pass through GBA GPIO writes
Diffstat (limited to 'src')
-rw-r--r-- | src/GBACart.cpp | 2 | ||||
-rw-r--r-- | src/NDS.cpp | 88 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 2 |
3 files changed, 92 insertions, 0 deletions
diff --git a/src/GBACart.cpp b/src/GBACart.cpp index a7ddf9b..7e5e3b5 100644 --- a/src/GBACart.cpp +++ b/src/GBACart.cpp @@ -630,8 +630,10 @@ void Process(GBACart::GPIO* gpio) if (gpio->data & 4) return; // Boktai chip select
if (gpio->data & 2) // Reset
{
+ u8 prev = LightSample;
LightCounter = 0;
LightSample = LIGHT_VALUE;
+ printf("Solar sensor reset (sample: 0x%02X -> 0x%02X)\n", prev, LightSample);
}
if (gpio->data & 1 && LightEdge) LightCounter++;
diff --git a/src/NDS.cpp b/src/NDS.cpp index a906fbb..47f96c9 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1803,6 +1803,19 @@ void ARM9Write8(u32 addr, u8 val) // checkme return; + case 0x08000000: + case 0x09000000: + if (ExMemCnt[0] & (1<<7)) return; // deselected CPU, skip the write + if (GBACart::CartInserted) + { + if ((addr & 0x00FFFFFF) >= 0xC4 && (addr & 0x00FFFFFF) <= 0xC9) + { + GBACart::WriteGPIO(addr & (GBACart::CartROMSize-1), val); + return; + } + } + break; + case 0x0A000000: if (ExMemCnt[0] & (1<<7)) return; // deselected CPU, skip the write if (GBACart::CartInserted) @@ -1854,6 +1867,21 @@ void ARM9Write16(u32 addr, u16 val) *(u16*)&GPU::OAM[addr & 0x7FF] = val; return; + case 0x08000000: + case 0x09000000: + if (ExMemCnt[0] & (1<<7)) return; // deselected CPU, skip the write + if (GBACart::CartInserted) + { + // Note: the lower bound is adjusted such that a write starting + // there will hit the first byte of the GPIO region. + if ((addr & 0x00FFFFFF) >= 0xC3 && (addr & 0x00FFFFFF) <= 0xC9) + { + GBACart::WriteGPIO(addr & (GBACart::CartROMSize-1), val); + return; + } + } + break; + case 0x0A000000: if (ExMemCnt[0] & (1<<7)) return; // deselected CPU, skip the write if (GBACart::CartInserted) @@ -1905,6 +1933,22 @@ void ARM9Write32(u32 addr, u32 val) *(u32*)&GPU::OAM[addr & 0x7FF] = val; return; + case 0x08000000: + case 0x09000000: + if (ExMemCnt[0] & (1<<7)) return; // deselected CPU, skip the write + if (GBACart::CartInserted) + { + // Note: the lower bound is adjusted such that a write starting + // there will hit the first byte of the GPIO region. + if ((addr & 0x00FFFFFF) >= 0xC1 && (addr & 0x00FFFFFF) <= 0xC9) + { + GBACart::WriteGPIO(addr & (GBACart::CartROMSize-1), val & 0xFF); + GBACart::WriteGPIO((addr + 2) & (GBACart::CartROMSize-1), (val >> 16) & 0xFF); + return; + } + } + break; + case 0x0A000000: if (ExMemCnt[0] & (1<<7)) return; // deselected CPU, skip the write if (GBACart::CartInserted) @@ -2177,6 +2221,19 @@ void ARM7Write8(u32 addr, u8 val) GPU::WriteVRAM_ARM7<u8>(addr, val); return; + case 0x08000000: + case 0x09000000: + if (!(ExMemCnt[0] & (1<<7))) return; // deselected CPU, skip the write + if (GBACart::CartInserted) + { + if ((addr & 0x00FFFFFF) >= 0xC4 && (addr & 0x00FFFFFF) <= 0xC9) + { + GBACart::WriteGPIO(addr & (GBACart::CartROMSize-1), val); + return; + } + } + break; + case 0x0A000000: if (!(ExMemCnt[0] & (1<<7))) return; // deselected CPU, skip the write if (GBACart::CartInserted) @@ -2231,6 +2288,21 @@ void ARM7Write16(u32 addr, u16 val) GPU::WriteVRAM_ARM7<u16>(addr, val); return; + case 0x08000000: + case 0x09000000: + if (!(ExMemCnt[0] & (1<<7))) return; // deselected CPU, skip the write + if (GBACart::CartInserted) + { + // Note: the lower bound is adjusted such that a write starting + // there will hit the first byte of the GPIO region. + if ((addr & 0x00FFFFFF) >= 0xC3 && (addr & 0x00FFFFFF) <= 0xC9) + { + GBACart::WriteGPIO(addr & (GBACart::CartROMSize-1), val); + return; + } + } + break; + case 0x0A000000: if (!(ExMemCnt[0] & (1<<7))) return; // deselected CPU, skip the write if (GBACart::CartInserted) @@ -2286,6 +2358,22 @@ void ARM7Write32(u32 addr, u32 val) GPU::WriteVRAM_ARM7<u32>(addr, val); return; + case 0x08000000: + case 0x09000000: + if (!(ExMemCnt[0] & (1<<7))) return; // deselected CPU, skip the write + if (GBACart::CartInserted) + { + // Note: the lower bound is adjusted such that a write starting + // there will hit the first byte of the GPIO region. + if ((addr & 0x00FFFFFF) >= 0xC1 && (addr & 0x00FFFFFF) <= 0xC9) + { + GBACart::WriteGPIO(addr & (GBACart::CartROMSize-1), val & 0xFF); + GBACart::WriteGPIO((addr + 2) & (GBACart::CartROMSize-1), (val >> 16) & 0xFF); + return; + } + } + break; + case 0x0A000000: if (!(ExMemCnt[0] & (1<<7))) return; // deselected CPU, skip the write if (GBACart::CartInserted) diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 1b7cfe6..d2a38f2 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -1297,6 +1297,7 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt) if (GBACart::CartInserted && GBACart::HasSolarSensor) { if (GBACart_SolarSensor::LightLevel > 0) GBACart_SolarSensor::LightLevel--; + printf("Solar sensor level set to %d\n", GBACart_SolarSensor::LightLevel); } } else if (evt->Scancode == 0x4D) // Keypad right @@ -1304,6 +1305,7 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt) if (GBACart::CartInserted && GBACart::HasSolarSensor) { if (GBACart_SolarSensor::LightLevel < 10) GBACart_SolarSensor::LightLevel++; + printf("Solar sensor level set to %d\n", GBACart_SolarSensor::LightLevel); } } |