Properly pass through GBA GPIO writes

This commit is contained in:
Raphaël Zumer 2019-12-10 18:44:53 -05:00
parent ca9f183d24
commit f257b007a2
3 changed files with 92 additions and 0 deletions

View File

@ -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++;

View File

@ -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)

View File

@ -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);
}
}