GB:Fix serial emulation when compiled with NO_LINK

Fix https://github.com/libretro/vbam-libretro/issues/83
This commit is contained in:
negativeExponent 2021-05-22 08:00:33 +08:00
parent e38b4c40c9
commit 15bcad1351
1 changed files with 29 additions and 5 deletions

View File

@ -1065,10 +1065,13 @@ void gbWriteMemory(uint16_t address, uint8_t value)
}
#endif
}
#else
gbMemory[0xff02] = value;
if (gbSerialOn)
gbSerialTicks = GBSERIAL_CLOCK_TICKS;
#endif
gbSerialBits = 0;
return;
#endif
}
case 0x04: {
@ -5295,6 +5298,27 @@ void gbEmulate(int ticksToStop)
}
#endif
}
#else
static int SIOctr = 0;
SIOctr++;
if (SIOctr % 5) {
if (gbSerialOn) {
if (gbMemory[0xff02] & 1) {
gbSerialTicks -= clockTicks;
while (gbSerialTicks <= 0) {
gbMemory[0xff01] = (gbMemory[0xff01] << 1) | 1;
gbSerialBits++;
if (gbSerialBits >= 8) {
gbMemory[0xff02] &= 0x7f;
gbMemory[0xff0f] = register_IF |= 8;
gbSerialOn = 0;
gbSerialBits = 0;
} else
gbSerialTicks += GBSERIAL_CLOCK_TICKS;
}
}
}
}
#endif
// TODO: evaluate and fix this
// On VBA-M (gb core running twice as fast?), each vblank is uses 35112 cycles.