GB: Fix LYC behavior on scanline 0
This commit is contained in:
parent
2ccef88375
commit
86bd6c4deb
1 changed files with 11 additions and 8 deletions
|
@ -195,6 +195,8 @@ void GbPpu::ProcessVblankScanline()
|
||||||
|
|
||||||
if(_state.Scanline == 154) {
|
if(_state.Scanline == 154) {
|
||||||
_state.Scanline = 0;
|
_state.Scanline = 0;
|
||||||
|
_state.Ly = 0;
|
||||||
|
_state.LyForCompare = 0;
|
||||||
_console->ProcessEvent(EventType::StartFrame);
|
_console->ProcessEvent(EventType::StartFrame);
|
||||||
if(_console->IsDebugging()) {
|
if(_console->IsDebugging()) {
|
||||||
_currentEventViewerBuffer = _currentEventViewerBuffer == _eventViewerBuffers[0] ? _eventViewerBuffers[1] : _eventViewerBuffers[0];
|
_currentEventViewerBuffer = _currentEventViewerBuffer == _eventViewerBuffers[0] ? _eventViewerBuffers[1] : _eventViewerBuffers[0];
|
||||||
|
@ -209,6 +211,13 @@ void GbPpu::ProcessVblankScanline()
|
||||||
|
|
||||||
void GbPpu::ProcessFirstScanlineAfterPowerOn()
|
void GbPpu::ProcessFirstScanlineAfterPowerOn()
|
||||||
{
|
{
|
||||||
|
if(_drawnPixels == 160) {
|
||||||
|
//IRQ flag for Hblank is 1 cycle late compared to the mode register
|
||||||
|
_state.IrqMode = PpuMode::HBlank;
|
||||||
|
_drawnPixels = 0;
|
||||||
|
_state.IdleCycles = 448 - _state.Cycle - 1;
|
||||||
|
}
|
||||||
|
|
||||||
switch(_state.Cycle) {
|
switch(_state.Cycle) {
|
||||||
case 1:
|
case 1:
|
||||||
_state.IrqMode = PpuMode::NoIrq;
|
_state.IrqMode = PpuMode::NoIrq;
|
||||||
|
@ -250,11 +259,11 @@ void GbPpu::ProcessVisibleScanline()
|
||||||
switch(_state.Cycle) {
|
switch(_state.Cycle) {
|
||||||
case 3:
|
case 3:
|
||||||
_state.Ly = _state.Scanline;
|
_state.Ly = _state.Scanline;
|
||||||
_state.LyForCompare = -1;
|
|
||||||
|
|
||||||
if(_state.Scanline > 0) {
|
if(_state.Scanline > 0) {
|
||||||
//On scanlines 1-143, the OAM IRQ fires 1 cycle early
|
//On scanlines 1-143, the OAM IRQ fires 1 cycle early
|
||||||
_state.IrqMode = PpuMode::OamEvaluation;
|
_state.IrqMode = PpuMode::OamEvaluation;
|
||||||
|
_state.LyForCompare = -1;
|
||||||
} else {
|
} else {
|
||||||
//On scanline 0, hblank gets set for 1 cycle here
|
//On scanline 0, hblank gets set for 1 cycle here
|
||||||
_state.Mode = PpuMode::HBlank;
|
_state.Mode = PpuMode::HBlank;
|
||||||
|
@ -673,9 +682,8 @@ void GbPpu::Write(uint16_t addr, uint8_t value)
|
||||||
_state.Cycle = 0;
|
_state.Cycle = 0;
|
||||||
_state.Scanline = 0;
|
_state.Scanline = 0;
|
||||||
_state.Ly = 0;
|
_state.Ly = 0;
|
||||||
_state.LyForCompare = -1;
|
_state.LyForCompare = 0;
|
||||||
_state.Mode = PpuMode::HBlank;
|
_state.Mode = PpuMode::HBlank;
|
||||||
_state.IrqMode = PpuMode::HBlank;
|
|
||||||
|
|
||||||
//Send a blank (white) frame
|
//Send a blank (white) frame
|
||||||
_lastFrameTime = _gameboy->GetCycleCount();
|
_lastFrameTime = _gameboy->GetCycleCount();
|
||||||
|
@ -688,13 +696,8 @@ void GbPpu::Write(uint16_t addr, uint8_t value)
|
||||||
} else {
|
} else {
|
||||||
_isFirstFrame = true;
|
_isFirstFrame = true;
|
||||||
_state.Cycle = -1;
|
_state.Cycle = -1;
|
||||||
_state.Scanline = 0;
|
|
||||||
_state.Ly = 0;
|
|
||||||
_state.LyForCompare = 0;
|
|
||||||
_state.IdleCycles = 0;
|
_state.IdleCycles = 0;
|
||||||
ResetRenderer();
|
ResetRenderer();
|
||||||
_state.Mode = PpuMode::HBlank;
|
|
||||||
_state.IrqMode = PpuMode::HBlank;
|
|
||||||
_state.LyCoincidenceFlag = _state.LyCompare == _state.LyForCompare;
|
_state.LyCoincidenceFlag = _state.LyCompare == _state.LyForCompare;
|
||||||
UpdateStatIrq();
|
UpdateStatIrq();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue