GB: Display first frame after enabling LCD as a blank frame

Fixes bad frames that show up in various games during screen transitions
This commit is contained in:
Sour 2020-05-28 23:58:22 -04:00
parent dc986b72b7
commit a9c456b75a
2 changed files with 10 additions and 1 deletions

View file

@ -504,6 +504,12 @@ void GbPpu::SendFrame()
_state.FrameCount++;
_console->GetNotificationManager()->SendNotification(ConsoleNotificationType::PpuFrameDone);
if(_isFirstFrame) {
//Send blank frame on the first frame after enabling LCD
std::fill(_currentBuffer, _currentBuffer + 256 * 239, 0x7FFF);
_isFirstFrame = false;
}
#ifdef LIBRETRO
_console->GetVideoDecoder()->UpdateFrameSync(_currentBuffer, 256, 239, _state.FrameCount, false);
#else
@ -580,6 +586,7 @@ void GbPpu::Write(uint16_t addr, uint8_t value)
//"If the HDMA started when the screen was on, when the screen is switched off it will copy one block after the switch."
_dmaController->ProcessHdma();
} else {
_isFirstFrame = true;
_state.Cycle = 4;
_state.Scanline = 0;
ResetRenderer();
@ -737,7 +744,7 @@ void GbPpu::Serialize(Serializer& s)
_state.Status, _state.FrameCount, _lastFrameTime, _state.LyCoincidenceFlag,
_state.CgbBgPalAutoInc, _state.CgbBgPalPosition,
_state.CgbObjPalAutoInc, _state.CgbObjPalPosition, _state.CgbVramBank, _state.CgbEnabled,
_latchWindowX, _latchWindowY, _latchWindowEnabled, _windowCounter
_latchWindowX, _latchWindowY, _latchWindowEnabled, _windowCounter, _isFirstFrame
);
s.StreamArray(_state.CgbBgPalettes, 4 * 8);

View file

@ -48,6 +48,8 @@ private:
uint8_t _spriteX[10] = {};
uint8_t _spriteIndexes[10] = {};
bool _isFirstFrame = true;
__forceinline void ProcessPpuCycle();
__forceinline void ExecCycle();