GBA Hardware: e-Reader calibration initialization

This commit is contained in:
Vicki Pfau 2020-02-19 21:12:48 -08:00
parent e0ca7c69a2
commit edd60a85b5
2 changed files with 19 additions and 0 deletions

View File

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

View File

@ -95,6 +95,15 @@ const int EREADER_NYBBLE_5BIT[16][5] = {
{ 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 _gbpSioProcessEvents(struct mTiming* timing, void* user, uint32_t cyclesLat
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) {