all repos — mgba @ f9ff88302f3de521a0f71ffbe8d15d9bfd9d0c8c

mGBA Game Boy Advance Emulator

GB Video: Delay LYC STAT check (fixes #1331)
Vicki Pfau vi@endrift.com
Sun, 03 Mar 2019 12:46:46 -0800
commit

f9ff88302f3de521a0f71ffbe8d15d9bfd9d0c8c

parent

eafb1ca06be6adcaa737cabf52eeef41e1b0d7d4

2 files changed, 9 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -9,6 +9,7 @@ - GBA: Reset now reloads multiboot ROMs

- GBA BIOS: Fix multiboot entry point (fixes Magic Floor) - Qt: More app metadata fixes - Qt: Fix load recent from archive (fixes mgba.io/i/1325) + - GB Video: Delay LYC STAT check (fixes mgba.io/i/1331) Misc: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash
M src/gb/video.csrc/gb/video.c

@@ -224,7 +224,6 @@ int32_t next;

++video->ly; video->p->memory.io[REG_LY] = video->ly; GBRegisterSTAT oldStat = video->stat; - video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly); if (video->ly < GB_VIDEO_VERTICAL_PIXELS) { next = GB_VIDEO_MODE_2_LENGTH; video->mode = 2;

@@ -246,6 +245,14 @@ video->stat = GBRegisterSTATSetMode(video->stat, video->mode);

if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { 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); video->p->memory.io[REG_STAT] = video->stat; mTimingSchedule(timing, &video->modeEvent, (next << video->p->doubleSpeed) - cyclesLate);