From 5e2e3864b7ecfc308f0f390dbb8b2f9f9aa16199 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 13 Nov 2015 21:34:44 -0800 Subject: [PATCH] GBA Hardware: Fix Game Boy Player rumble in Pokemon Pinball --- CHANGES | 1 + src/gba/hardware.c | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CHANGES b/CHANGES index f1e68eec8..630b0e7ab 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Bugfixes: - GBA Memory: Fix unaligned out-of-bounds ROM loads - GBA: Fix warnings when creating and loading savestates - Qt: Add additional checks in CheatModel to prevent crashes + - GBA Hardware: Fix Game Boy Player rumble in Pokemon Pinball Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper diff --git a/src/gba/hardware.c b/src/gba/hardware.c index f96d48c6d..31d069e8a 100644 --- a/src/gba/hardware.c +++ b/src/gba/hardware.c @@ -486,9 +486,7 @@ static const uint32_t _gbpTxData[] = { 0xB1BA4E45, 0xB1BA4F44, 0xB0BB4F44, 0xB0BB8002, 0x10000010, 0x20000013, - 0x30000003, 0x30000003, - 0x30000003, 0x30000003, - 0x30000003, 0x00000000, + 0x30000003 }; static const uint32_t _gbpRxData[] = { @@ -498,9 +496,7 @@ static const uint32_t _gbpRxData[] = { 0x4E45B1BA, 0x4F44B1BA, 0x4F44B0BB, 0x8000B0BB, 0x10000010, 0x20000013, - 0x40000004, 0x40000004, - 0x40000004, 0x40000004, - 0x40000004, 0x40000004 + 0x40000004 }; bool GBAHardwarePlayerCheckScreen(const struct GBAVideo* video) { @@ -548,16 +544,17 @@ uint16_t _gbpSioWriteRegister(struct GBASIODriver* driver, uint32_t address, uin struct GBAGBPSIODriver* gbp = (struct GBAGBPSIODriver*) driver; if (address == REG_SIOCNT) { if (value & 0x0080) { - if (gbp->p->gbpTxPosition <= 16 && gbp->p->gbpTxPosition > 0) { - uint32_t rx = gbp->p->p->memory.io[REG_SIODATA32_LO >> 1] | (gbp->p->p->memory.io[REG_SIODATA32_HI >> 1] << 16); + uint32_t rx = gbp->p->p->memory.io[REG_SIODATA32_LO >> 1] | (gbp->p->p->memory.io[REG_SIODATA32_HI >> 1] << 16); + if (gbp->p->gbpTxPosition < 12 && gbp->p->gbpTxPosition > 0) { uint32_t expected = _gbpRxData[gbp->p->gbpTxPosition]; // TODO: Check expected - uint32_t mask = 0; - if (gbp->p->gbpTxPosition == 15) { - mask = 0x22; - if (gbp->p->p->rumble) { - gbp->p->p->rumble->setRumble(gbp->p->p->rumble, (rx & mask) == mask); - } + } else if (gbp->p->gbpTxPosition >= 12) { + uint32_t mask = 0x33; + // 0x00 = Stop + // 0x11 = Hard Stop + // 0x22 = Start + if (gbp->p->p->rumble) { + gbp->p->p->rumble->setRumble(gbp->p->p->rumble, (rx & mask) == 0x22); } } gbp->p->gbpNextEvent = 2048; @@ -572,9 +569,11 @@ int32_t _gbpSioProcessEvents(struct GBASIODriver* driver, int32_t cycles) { gbp->p->gbpNextEvent -= cycles; if (gbp->p->gbpNextEvent <= 0) { uint32_t tx = 0; - if (gbp->p->gbpTxPosition <= 16) { + if (gbp->p->gbpTxPosition <= 12) { tx = _gbpTxData[gbp->p->gbpTxPosition]; - ++gbp->p->gbpTxPosition; + if (gbp->p->gbpTxPosition < 12) { + ++gbp->p->gbpTxPosition; + } } gbp->p->p->memory.io[REG_SIODATA32_LO >> 1] = tx; gbp->p->p->memory.io[REG_SIODATA32_HI >> 1] = tx >> 16;