all repos — mgba @ c60251de732a63ce3fa4c8723fbb429fb4a35fac

mGBA Game Boy Advance Emulator

GB Video: Fix oam-bug 1
Jeffrey Pfau jeffrey@endrift.com
Fri, 05 Feb 2016 20:44:49 -0800
commit

c60251de732a63ce3fa4c8723fbb429fb4a35fac

parent

adc57d0da7a09098cfc73a15cd034aa721474b68

1 files changed, 7 insertions(+), 5 deletions(-)

jump to
M src/gb/video.csrc/gb/video.c

@@ -201,14 +201,16 @@ }

void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) { if (!GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC]) && GBRegisterLCDCIsEnable(value)) { - // TODO: Does enabling the LCD start in vblank? video->mode = 2; - video->nextMode = GB_VIDEO_MODE_2_LENGTH; + video->nextMode = GB_VIDEO_MODE_2_LENGTH - 5; // TODO: Why is this fudge factor needed? Might be related to T-cycles for load/store differing video->nextEvent = video->nextMode; - video->eventDiff = 0; - video->stat = GBRegisterSTATSetMode(video->stat, video->mode); + video->eventDiff = -video->p->cpu->cycles; + // TODO: Does this read as 0 for 4 T-cycles? + video->stat = GBRegisterSTATSetMode(video->stat, 2); video->p->memory.io[REG_STAT] = video->stat; - video->eventDiff = 0; + video->ly = 0; + video->p->memory.io[REG_LY] = 0; + if (video->p->cpu->cycles + video->nextEvent < video->p->cpu->nextEvent) { video->p->cpu->nextEvent = video->p->cpu->cycles + video->nextEvent; }