From 089e692bd1f18ef4ea687606903c8bcf9098b4be Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 29 Dec 2015 22:59:36 -0500 Subject: [PATCH] GBA: Allow blocking of opposing directional input --- src/gba/gba.c | 1 + src/gba/gba.h | 1 + src/gba/io.c | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/src/gba/gba.c b/src/gba/gba.c index 3bfdb4eec..30df843a7 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -101,6 +101,7 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) { gba->realisticTiming = true; gba->hardCrash = true; + gba->allowOpposingDirections = true; gba->performingDMA = false; diff --git a/src/gba/gba.h b/src/gba/gba.h index 961d871ba..846f58492 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -128,6 +128,7 @@ struct GBA { bool realisticTiming; bool hardCrash; + bool allowOpposingDirections; }; struct GBACartridge { diff --git a/src/gba/io.c b/src/gba/io.c index bda2d3562..b56d6e82b 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -674,6 +674,17 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { } else if (gba->keySource) { input = *gba->keySource; } + if (!gba->allowOpposingDirections) { + unsigned rl = input & 0x030; + unsigned ud = input & 0x0C0; + input &= 0x30F; + if (rl != 0x030) { + input |= rl; + } + if (ud != 0x0C0) { + input |= ud; + } + } if (gba->rr && gba->rr->isRecording(gba->rr)) { gba->rr->logInput(gba->rr, input); }