GB: Implement keypad IRQs

This commit is contained in:
Vicki Pfau 2017-06-11 14:51:48 -07:00
parent 1dcf70d6d3
commit 126afa12d9
5 changed files with 14 additions and 1 deletions

View File

@ -21,7 +21,7 @@ Features:
- Debugger: Segment/bank support - Debugger: Segment/bank support
- GB: Symbol table support - GB: Symbol table support
- GB MBC: Add MBC1 multicart support - GB MBC: Add MBC1 multicart support
- GBA: Implement keypad interrupts - Implement keypad interrupts
- LR35902: Watchpoints - LR35902: Watchpoints
- Memory search - Memory search
- Debugger: Execution tracing - Debugger: Execution tracing

View File

@ -139,6 +139,8 @@ bool GBIsROM(struct VFile* vf);
void GBGetGameTitle(const struct GB* gba, char* out); void GBGetGameTitle(const struct GB* gba, char* out);
void GBGetGameCode(const struct GB* gba, char* out); void GBGetGameCode(const struct GB* gba, char* out);
void GBTestKeypadIRQ(struct GB* gb);
void GBFrameEnded(struct GB* gb); void GBFrameEnded(struct GB* gb);
CXX_GUARD_END CXX_GUARD_END

View File

@ -432,11 +432,13 @@ static bool _GBCoreSaveState(struct mCore* core, void* state) {
static void _GBCoreSetKeys(struct mCore* core, uint32_t keys) { static void _GBCoreSetKeys(struct mCore* core, uint32_t keys) {
struct GBCore* gbcore = (struct GBCore*) core; struct GBCore* gbcore = (struct GBCore*) core;
gbcore->keys = keys; gbcore->keys = keys;
GBTestKeypadIRQ(core->board);
} }
static void _GBCoreAddKeys(struct mCore* core, uint32_t keys) { static void _GBCoreAddKeys(struct mCore* core, uint32_t keys) {
struct GBCore* gbcore = (struct GBCore*) core; struct GBCore* gbcore = (struct GBCore*) core;
gbcore->keys |= keys; gbcore->keys |= keys;
GBTestKeypadIRQ(core->board);
} }
static void _GBCoreClearKeys(struct mCore* core, uint32_t keys) { static void _GBCoreClearKeys(struct mCore* core, uint32_t keys) {

View File

@ -710,4 +710,6 @@ void GBFrameEnded(struct GB* gb) {
mCheatRefresh(device, cheats); mCheatRefresh(device, cheats);
} }
} }
GBTestKeypadIRQ(gb);
} }

View File

@ -564,6 +564,13 @@ uint8_t GBIORead(struct GB* gb, unsigned address) {
return gb->memory.io[address] | _registerMask[address]; return gb->memory.io[address] | _registerMask[address];
} }
void GBTestKeypadIRQ(struct GB* gb) {
if (_readKeys(gb)) {
gb->memory.io[REG_IF] |= (1 << GB_IRQ_KEYPAD);
GBUpdateIRQs(gb);
}
}
struct GBSerializedState; struct GBSerializedState;
void GBIOSerialize(const struct GB* gb, struct GBSerializedState* state) { void GBIOSerialize(const struct GB* gb, struct GBSerializedState* state) {
memcpy(state->io, gb->memory.io, GB_SIZE_IO); memcpy(state->io, gb->memory.io, GB_SIZE_IO);