GBA Hardware: Fix Game Boy Player rumble in Pokemon Pinball

This commit is contained in:
Jeffrey Pfau 2015-11-13 21:34:44 -08:00
parent aefb4b62a1
commit 5e2e3864b7
2 changed files with 16 additions and 16 deletions

View File

@ -26,6 +26,7 @@ Bugfixes:
- GBA Memory: Fix unaligned out-of-bounds ROM loads - GBA Memory: Fix unaligned out-of-bounds ROM loads
- GBA: Fix warnings when creating and loading savestates - GBA: Fix warnings when creating and loading savestates
- Qt: Add additional checks in CheatModel to prevent crashes - Qt: Add additional checks in CheatModel to prevent crashes
- GBA Hardware: Fix Game Boy Player rumble in Pokemon Pinball
Misc: Misc:
- Qt: Window size command line options are now supported - Qt: Window size command line options are now supported
- Qt: Increase usability of key mapper - Qt: Increase usability of key mapper

View File

@ -486,9 +486,7 @@ static const uint32_t _gbpTxData[] = {
0xB1BA4E45, 0xB1BA4F44, 0xB1BA4E45, 0xB1BA4F44,
0xB0BB4F44, 0xB0BB8002, 0xB0BB4F44, 0xB0BB8002,
0x10000010, 0x20000013, 0x10000010, 0x20000013,
0x30000003, 0x30000003, 0x30000003
0x30000003, 0x30000003,
0x30000003, 0x00000000,
}; };
static const uint32_t _gbpRxData[] = { static const uint32_t _gbpRxData[] = {
@ -498,9 +496,7 @@ static const uint32_t _gbpRxData[] = {
0x4E45B1BA, 0x4F44B1BA, 0x4E45B1BA, 0x4F44B1BA,
0x4F44B0BB, 0x8000B0BB, 0x4F44B0BB, 0x8000B0BB,
0x10000010, 0x20000013, 0x10000010, 0x20000013,
0x40000004, 0x40000004, 0x40000004
0x40000004, 0x40000004,
0x40000004, 0x40000004
}; };
bool GBAHardwarePlayerCheckScreen(const struct GBAVideo* video) { 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; struct GBAGBPSIODriver* gbp = (struct GBAGBPSIODriver*) driver;
if (address == REG_SIOCNT) { if (address == REG_SIOCNT) {
if (value & 0x0080) { 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]; uint32_t expected = _gbpRxData[gbp->p->gbpTxPosition];
// TODO: Check expected // TODO: Check expected
uint32_t mask = 0; } else if (gbp->p->gbpTxPosition >= 12) {
if (gbp->p->gbpTxPosition == 15) { uint32_t mask = 0x33;
mask = 0x22; // 0x00 = Stop
if (gbp->p->p->rumble) { // 0x11 = Hard Stop
gbp->p->p->rumble->setRumble(gbp->p->p->rumble, (rx & mask) == mask); // 0x22 = Start
} if (gbp->p->p->rumble) {
gbp->p->p->rumble->setRumble(gbp->p->p->rumble, (rx & mask) == 0x22);
} }
} }
gbp->p->gbpNextEvent = 2048; gbp->p->gbpNextEvent = 2048;
@ -572,9 +569,11 @@ int32_t _gbpSioProcessEvents(struct GBASIODriver* driver, int32_t cycles) {
gbp->p->gbpNextEvent -= cycles; gbp->p->gbpNextEvent -= cycles;
if (gbp->p->gbpNextEvent <= 0) { if (gbp->p->gbpNextEvent <= 0) {
uint32_t tx = 0; uint32_t tx = 0;
if (gbp->p->gbpTxPosition <= 16) { if (gbp->p->gbpTxPosition <= 12) {
tx = _gbpTxData[gbp->p->gbpTxPosition]; 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_LO >> 1] = tx;
gbp->p->p->memory.io[REG_SIODATA32_HI >> 1] = tx >> 16; gbp->p->p->memory.io[REG_SIODATA32_HI >> 1] = tx >> 16;