GB: Fix SGB controller selection initialization (fixes #1104)

This commit is contained in:
Vicki Pfau 2019-09-01 21:30:31 -07:00
parent 178348d445
commit 74e09675ce
4 changed files with 5 additions and 4 deletions

View File

@ -55,6 +55,7 @@ Other fixes:
- GBA Cheats: Fix value incrementing in CB slide codes (fixes mgba.io/i/1501)
- Qt: Only show emulator restart warning once per settings saving
- Qt: Improve cheat view UX
- GB: Fix SGB controller selection initialization (fixes mgba.io/i/1104)
Misc:
- GBA Savedata: EEPROM performance fixes
- GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash

View File

@ -435,7 +435,7 @@ void GBReset(struct LR35902Core* cpu) {
gb->sgbBit = -1;
gb->sgbControllers = 0;
gb->sgbCurrentController = 0;
gb->sgbCurrentController = 3;
gb->currentSgbBits = 0;
memset(gb->sgbPacket, 0, sizeof(gb->sgbPacket));

View File

@ -535,13 +535,13 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
static uint8_t _readKeys(struct GB* gb) {
uint8_t keys = *gb->keySource;
if (gb->sgbCurrentController != 0) {
if (gb->sgbCurrentController & gb->sgbControllers) {
keys = 0;
}
uint8_t joyp = gb->memory.io[REG_JOYP];
switch (joyp & 0x30) {
case 0x30:
keys = gb->sgbCurrentController;
keys = gb->sgbCurrentController & gb->sgbControllers;
break;
case 0x20:
keys >>= 4;

View File

@ -702,7 +702,7 @@ void GBVideoWriteSGBPacket(struct GBVideo* video, uint8_t* data) {
break;
case SGB_MLT_REQ:
video->p->sgbControllers = video->sgbPacketBuffer[1] & 0x3;
video->p->sgbCurrentController = 0;
video->p->sgbCurrentController &= video->p->sgbControllers;
return;
case SGB_MASK_EN:
video->renderer->sgbRenderMode = video->sgbPacketBuffer[1] & 0x3;