all repos — mgba @ edd60a85b581e05dc50f725f6902a1769c3bdd79

mGBA Game Boy Advance Emulator

GBA Hardware: e-Reader calibration initialization
Vicki Pfau vi@endrift.com
Wed, 19 Feb 2020 21:12:48 -0800
commit

edd60a85b581e05dc50f725f6902a1769c3bdd79

parent

e0ca7c69a256b6085d658d81adf3a843b1b493f9

2 files changed, 19 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -1,5 +1,6 @@

0.9.0: (Future) Features: + - e-Reader card scanning - Add APNG recording Emulation fixes: - ARM: Fix ALU reading PC after shifting
M src/gba/hardware.csrc/gba/hardware.c

@@ -95,6 +95,15 @@ { 1, 0, 0, 0, 1 },

{ 1, 0, 0, 0, 0 } }; +const uint8_t EREADER_CALIBRATION_TEMPLATE[] = { + 0x43, 0x61, 0x72, 0x64, 0x2d, 0x45, 0x20, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x32, 0x30, + 0x30, 0x31, 0x00, 0x00, 0xcf, 0x72, 0x2f, 0x37, 0x3a, 0x3a, 0x3a, 0x38, 0x33, 0x30, 0x30, 0x37, + 0x3a, 0x39, 0x37, 0x35, 0x33, 0x2f, 0x2f, 0x34, 0x36, 0x36, 0x37, 0x36, 0x34, 0x31, 0x2d, 0x30, + 0x32, 0x34, 0x35, 0x35, 0x34, 0x30, 0x2a, 0x2d, 0x2d, 0x2f, 0x31, 0x32, 0x31, 0x2f, 0x29, 0x2a, + 0x2c, 0x2b, 0x2c, 0x2e, 0x2e, 0x2d, 0x18, 0x2d, 0x8f, 0x03, 0x00, 0x00, 0xc0, 0xfd, 0x77, 0x00, + 0x00, 0x00, 0x01 +}; + static void _readPins(struct GBACartridgeHardware* hw); static void _outputPins(struct GBACartridgeHardware* hw, unsigned pins);

@@ -686,6 +695,15 @@

void GBAHardwareInitEReader(struct GBACartridgeHardware* hw) { hw->devices |= HW_EREADER; _eReaderReset(hw); + + if (hw->p->memory.savedata.data[0xD000] == 0xFF) { + memset(&hw->p->memory.savedata.data[0xD000], 0, 0x1000); + memcpy(&hw->p->memory.savedata.data[0xD000], EREADER_CALIBRATION_TEMPLATE, sizeof(EREADER_CALIBRATION_TEMPLATE)); + } + if (hw->p->memory.savedata.data[0xE000] == 0xFF) { + memset(&hw->p->memory.savedata.data[0xE000], 0, 0x1000); + memcpy(&hw->p->memory.savedata.data[0xE000], EREADER_CALIBRATION_TEMPLATE, sizeof(EREADER_CALIBRATION_TEMPLATE)); + } } void GBAHardwareEReaderWrite(struct GBACartridgeHardware* hw, uint32_t address, uint16_t value) {