GB: Implement keypad IRQs
Vicki Pfau vi@endrift.com
Sun, 11 Jun 2017 14:51:48 -0700
5 files changed,
14 insertions(+),
1 deletions(-)
M
include/mgba/internal/gb/gb.h
→
include/mgba/internal/gb/gb.h
@@ -139,6 +139,8 @@ bool GBIsROM(struct VFile* vf);
void GBGetGameTitle(const struct GB* gba, char* out); void GBGetGameCode(const struct GB* gba, char* out); +void GBTestKeypadIRQ(struct GB* gb); + void GBFrameEnded(struct GB* gb); CXX_GUARD_END
M
src/gb/core.c
→
src/gb/core.c
@@ -432,11 +432,13 @@
static void _GBCoreSetKeys(struct mCore* core, uint32_t keys) { struct GBCore* gbcore = (struct GBCore*) core; gbcore->keys = keys; + GBTestKeypadIRQ(core->board); } static void _GBCoreAddKeys(struct mCore* core, uint32_t keys) { struct GBCore* gbcore = (struct GBCore*) core; gbcore->keys |= keys; + GBTestKeypadIRQ(core->board); } static void _GBCoreClearKeys(struct mCore* core, uint32_t keys) {
M
src/gb/gb.c
→
src/gb/gb.c
@@ -710,4 +710,6 @@ struct mCheatSet* cheats = *mCheatSetsGetPointer(&device->cheats, i);
mCheatRefresh(device, cheats); } } + + GBTestKeypadIRQ(gb); }
M
src/gb/io.c
→
src/gb/io.c
@@ -564,6 +564,13 @@ success:
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; void GBIOSerialize(const struct GB* gb, struct GBSerializedState* state) { memcpy(state->io, gb->memory.io, GB_SIZE_IO);