GB Video: Delay LYC STAT check (fixes #1331)

This commit is contained in:
Vicki Pfau 2019-03-03 12:46:46 -08:00
parent eafb1ca06b
commit f9ff88302f
2 changed files with 9 additions and 1 deletions

View File

@ -9,6 +9,7 @@ Bugfixes:
- GBA BIOS: Fix multiboot entry point (fixes Magic Floor) - GBA BIOS: Fix multiboot entry point (fixes Magic Floor)
- Qt: More app metadata fixes - Qt: More app metadata fixes
- Qt: Fix load recent from archive (fixes mgba.io/i/1325) - Qt: Fix load recent from archive (fixes mgba.io/i/1325)
- GB Video: Delay LYC STAT check (fixes mgba.io/i/1331)
Misc: Misc:
- GBA Savedata: EEPROM performance fixes - GBA Savedata: EEPROM performance fixes
- GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash

View File

@ -224,7 +224,6 @@ void _endMode0(struct mTiming* timing, void* context, uint32_t cyclesLate) {
++video->ly; ++video->ly;
video->p->memory.io[REG_LY] = video->ly; video->p->memory.io[REG_LY] = video->ly;
GBRegisterSTAT oldStat = video->stat; GBRegisterSTAT oldStat = video->stat;
video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly);
if (video->ly < GB_VIDEO_VERTICAL_PIXELS) { if (video->ly < GB_VIDEO_VERTICAL_PIXELS) {
next = GB_VIDEO_MODE_2_LENGTH; next = GB_VIDEO_MODE_2_LENGTH;
video->mode = 2; video->mode = 2;
@ -246,6 +245,14 @@ void _endMode0(struct mTiming* timing, void* context, uint32_t cyclesLate) {
if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) {
video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);
} }
// LYC stat is delayed 1 T-cycle
oldStat = video->stat;
video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly);
if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) {
video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);
}
GBUpdateIRQs(video->p); GBUpdateIRQs(video->p);
video->p->memory.io[REG_STAT] = video->stat; video->p->memory.io[REG_STAT] = video->stat;
mTimingSchedule(timing, &video->modeEvent, (next << video->p->doubleSpeed) - cyclesLate); mTimingSchedule(timing, &video->modeEvent, (next << video->p->doubleSpeed) - cyclesLate);