From d83b00e4fab151c588f10fad678548c1b26914d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 31 Dec 2014 04:43:06 -0800 Subject: [PATCH] GBA: Put in tilt sensor stubs --- src/gba/gba-gpio.c | 6 ++++++ src/gba/gba-gpio.h | 4 +--- src/gba/gba-memory.c | 5 +++++ src/gba/gba.c | 12 ++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/gba/gba-gpio.c b/src/gba/gba-gpio.c index 92b2f50a0..3108f0a92 100644 --- a/src/gba/gba-gpio.c +++ b/src/gba/gba-gpio.c @@ -360,6 +360,12 @@ void _lightReadPins(struct GBACartridgeGPIO* gpio) { GBALog(0, GBA_LOG_DEBUG, "[SOLAR] Output %u with pins %u", gpio->lightCounter, gpio->pinState); } +// == Tilt (not technically GPIO) + +void GBAGPIOInitTilt(struct GBACartridgeGPIO* gpio) { + gpio->gpioDevices |= GPIO_TILT; +} + // == Serialization void GBAGPIOSerialize(struct GBACartridgeGPIO* gpio, struct GBASerializedState* state) { diff --git a/src/gba/gba-gpio.h b/src/gba/gba-gpio.h index a876703e8..e6e3d2ebb 100644 --- a/src/gba/gba-gpio.h +++ b/src/gba/gba-gpio.h @@ -113,12 +113,10 @@ void GBAGPIOInit(struct GBACartridgeGPIO* gpio, uint16_t* gpioBase); void GBAGPIOWrite(struct GBACartridgeGPIO* gpio, uint32_t address, uint16_t value); void GBAGPIOInitRTC(struct GBACartridgeGPIO* gpio); - void GBAGPIOInitGyro(struct GBACartridgeGPIO* gpio); - void GBAGPIOInitRumble(struct GBACartridgeGPIO* gpio); - void GBAGPIOInitLightSensor(struct GBACartridgeGPIO* gpio); +void GBAGPIOInitTilt(struct GBACartridgeGPIO* gpio); struct GBASerializedState; void GBAGPIOSerialize(struct GBACartridgeGPIO* gpio, struct GBASerializedState* state); diff --git a/src/gba/gba-memory.c b/src/gba/gba-memory.c index 4529928f6..718ea2ea8 100644 --- a/src/gba/gba-memory.c +++ b/src/gba/gba-memory.c @@ -448,6 +448,9 @@ int8_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { value = memory->savedata.data[address & (SIZE_CART_SRAM - 1)]; } else if (memory->savedata.type == SAVEDATA_FLASH512 || memory->savedata.type == SAVEDATA_FLASH1M) { value = GBASavedataReadFlash(&memory->savedata, address); + } else if (memory->gpio.gpioDevices & GPIO_TILT) { + GBALog(gba, GBA_LOG_STUB, "Unimplemented tilt sensor read: 0x%08X", address); + value = 0xFF; } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Reading from non-existent SRAM: 0x%08X", address); value = 0xFF; @@ -663,6 +666,8 @@ void GBAStore8(struct ARMCore* cpu, uint32_t address, int8_t value, int* cycleCo GBASavedataWriteFlash(&memory->savedata, address, value); } else if (memory->savedata.type == SAVEDATA_SRAM) { memory->savedata.data[address & (SIZE_CART_SRAM - 1)] = value; + } else if (memory->gpio.gpioDevices & GPIO_TILT) { + GBALog(gba, GBA_LOG_STUB, "Unimplemented tilt sensor write: 0x%08X", address); } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address); } diff --git a/src/gba/gba.c b/src/gba/gba.c index bfafd0a86..a599d5196 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -53,6 +53,9 @@ static const struct GBACartridgeOverride _overrides[] = { // Final Fantasy Tactics Advance { "AFXE", SAVEDATA_FLASH512, GPIO_NONE, 0x8000418 }, + // Koro Koro Puzzle - Happy Panechu! + { "KHPJ", SAVEDATA_EEPROM, GPIO_TILT, -1 }, + // Mega Man Battle Network { "AREE", SAVEDATA_SRAM, GPIO_NONE, 0x800032E }, @@ -112,6 +115,11 @@ static const struct GBACartridgeOverride _overrides[] = { { "RZWE", SAVEDATA_SRAM, GPIO_RUMBLE | GPIO_GYRO, -1 }, { "RZWP", SAVEDATA_SRAM, GPIO_RUMBLE | GPIO_GYRO, -1 }, + // Yoshi's Universal Gravitation + { "KYGJ", SAVEDATA_EEPROM, GPIO_TILT, -1 }, + { "KYGE", SAVEDATA_EEPROM, GPIO_TILT, -1 }, + { "KYGP", SAVEDATA_EEPROM, GPIO_TILT, -1 }, + { { 0, 0, 0, 0 }, 0, 0, -1 } }; @@ -724,6 +732,10 @@ void _checkOverrides(struct GBA* gba, uint32_t id) { GBAGPIOInitLightSensor(&gba->memory.gpio); } + if (_overrides[i].gpio & GPIO_TILT) { + GBAGPIOInitTilt(&gba->memory.gpio); + } + gba->busyLoop = _overrides[i].busyLoop; return; }