GBA Hardware: Prepare for adding alarms
Vicki Pfau vi@endrift.com
Mon, 20 Mar 2017 00:34:26 -0700
2 files changed,
18 insertions(+),
12 deletions(-)
M
include/mgba/internal/gba/hardware.h
→
include/mgba/internal/gba/hardware.h
@@ -78,14 +78,13 @@ int32_t bytesRemaining;
int32_t transferStep; int32_t bitsRead; int32_t bits; - int32_t commandActive; + uint8_t commandActive; + uint8_t alarm1[3]; RTCCommandData command; RTCStatus2 status2; uint8_t freeReg; RTCControl control; - uint8_t reserved1; - uint8_t reserved2; - uint8_t reserved3; + uint8_t alarm2[3]; uint8_t time[7]; }; #pragma pack(pop)
M
src/gba/hardware.c
→
src/gba/hardware.c
@@ -33,14 +33,14 @@ static uint16_t _gbpSioWriteRegister(struct GBASIODriver* driver, uint32_t address, uint16_t value);
static void _gbpSioProcessEvents(struct mTiming* timing, void* user, uint32_t cyclesLate); static const int RTC_BYTES[8] = { - 0, // Force reset - 0, // Empty + 1, // Status register 1 + 1, // Duty/alarm 1 7, // Date/Time - 0, // Force IRQ - 1, // Control register - 0, // Empty + 1, // Force IRQ + 1, // Status register 2 + 3, // Alarm 2 3, // Time - 0 // Empty + 1 // Free register }; void GBAHardwareInit(struct GBACartridgeHardware* hw, uint16_t* base) {@@ -245,6 +245,10 @@ break;
case RTC_DATETIME: case RTC_TIME: break; + case RTC_ALARM1: + case RTC_ALARM2: + mLOG(GBA_HW, STUB, "Unimplemented RTC command %u:%02X", RTCCommandDataGetCommand(rtc->command), rtc->bits); + break; } }@@ -272,6 +276,9 @@ break;
case RTC_FREE_REG: outputByte = rtc->freeReg; case RTC_FORCE_IRQ: + case RTC_ALARM1: + case RTC_ALARM2: + mLOG(GBA_HW, STUB, "Unimplemented RTC command %u", RTCCommandDataGetCommand(rtc->command)); break; } unsigned output = (outputByte >> rtc->bitsRead) & 1;@@ -581,7 +588,7 @@ STORE_32(hw->rtc.bytesRemaining, 0, &state->hw.rtc.bytesRemaining);
STORE_32(hw->rtc.transferStep, 0, &state->hw.rtc.transferStep); STORE_32(hw->rtc.bitsRead, 0, &state->hw.rtc.bitsRead); STORE_32(hw->rtc.bits, 0, &state->hw.rtc.bits); - STORE_32(hw->rtc.commandActive, 0, &state->hw.rtc.commandActive); + state->hw.rtc.commandActive = hw->rtc.commandActive; state->hw.rtc.command = hw->rtc.command; state->hw.rtc.control = hw->rtc.control; memcpy(state->hw.rtc.time, hw->rtc.time, sizeof(state->hw.rtc.time));@@ -613,7 +620,7 @@ LOAD_32(hw->rtc.bytesRemaining, 0, &state->hw.rtc.bytesRemaining);
LOAD_32(hw->rtc.transferStep, 0, &state->hw.rtc.transferStep); LOAD_32(hw->rtc.bitsRead, 0, &state->hw.rtc.bitsRead); LOAD_32(hw->rtc.bits, 0, &state->hw.rtc.bits); - LOAD_32(hw->rtc.commandActive, 0, &state->hw.rtc.commandActive); + hw->rtc.commandActive = state->hw.rtc.commandActive; hw->rtc.command = state->hw.rtc.command; hw->rtc.control = state->hw.rtc.control; memcpy(hw->rtc.time, state->hw.rtc.time, sizeof(hw->rtc.time));