diff --git a/Core/SNES/Coprocessors/SGB/SuperGameboy.cpp b/Core/SNES/Coprocessors/SGB/SuperGameboy.cpp index d9ea7b8fb..57940aac0 100644 --- a/Core/SNES/Coprocessors/SGB/SuperGameboy.cpp +++ b/Core/SNES/Coprocessors/SGB/SuperGameboy.cpp @@ -163,22 +163,27 @@ void SuperGameboy::ProcessInputPortWrite(uint8_t value) LogPacket(); } } else { - _packetData[_packetByte] &= ~(1 << _packetBit); + + _packetByteBuffer &= ~(1 << _packetBit); } _packetBit++; if(_packetBit == 8) { + _packetData[_packetByte] = _packetByteBuffer; _packetBit = 0; - _packetByte++; + _packetByte++; } + + } else if(value == 0x10) { //1 bit if(_packetByte >= 16) { //Invalid bit _listeningForPacket = false; } else { - _packetData[_packetByte] |= (1 << _packetBit); + _packetByteBuffer |= (1 << _packetBit); _packetBit++; if(_packetBit == 8) { + _packetData[_packetByte] = _packetByteBuffer; _packetBit = 0; _packetByte++; } diff --git a/Core/SNES/Coprocessors/SGB/SuperGameboy.h b/Core/SNES/Coprocessors/SGB/SuperGameboy.h index bf7314fa0..ac5f7fd2c 100644 --- a/Core/SNES/Coprocessors/SGB/SuperGameboy.h +++ b/Core/SNES/Coprocessors/SGB/SuperGameboy.h @@ -40,6 +40,7 @@ class SuperGameboy : public BaseCoprocessor, public IAudioProvider uint64_t _inputWriteClock = 0; uint8_t _inputValue = 0; uint8_t _packetData[16] = {}; + uint8_t _packetByteBuffer = 0x00; uint8_t _packetByte = 0; uint8_t _packetBit = 0;