GBA Hardware: Fix Game Boy Player rumble in Pokemon Pinball
Jeffrey Pfau jeffrey@endrift.com
Fri, 13 Nov 2015 21:34:44 -0800
2 files changed,
16 insertions(+),
16 deletions(-)
M
CHANGES
→
CHANGES
@@ -26,6 +26,7 @@ - GBA: Initialize uninitialized pristineRom and pristineRomSize members
- 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
M
src/gba/hardware.c
→
src/gba/hardware.c
@@ -486,9 +486,7 @@ 0xABB1544E, 0xABB14E45,
0xB1BA4E45, 0xB1BA4F44, 0xB0BB4F44, 0xB0BB8002, 0x10000010, 0x20000013, - 0x30000003, 0x30000003, - 0x30000003, 0x30000003, - 0x30000003, 0x00000000, + 0x30000003 }; static const uint32_t _gbpRxData[] = {@@ -498,9 +496,7 @@ 0x544EABB1, 0x4E45ABB1,
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, uint16_t value) {
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 @@ struct GBAGBPSIODriver* gbp = (struct GBAGBPSIODriver*) driver;
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;