all repos — mgba @ c4cfff45819d261ef6c158dabff9e4c2082fb3c1

mGBA Game Boy Advance Emulator

GB Video: Improved video timings
Jeffrey Pfau jeffrey@endrift.com
Sun, 25 Sep 2016 19:18:46 -0700
commit

c4cfff45819d261ef6c158dabff9e4c2082fb3c1

parent

59e61c31ea4f7daef3692a890f8702b7494df683

3 files changed, 10 insertions(+), 7 deletions(-)

jump to
M CHANGESCHANGES

@@ -21,6 +21,7 @@ Misc:

- All: Only update version info if needed - FFmpeg: Encoding cleanup - GB Memory: Initialize RAM pattern for GBC + - GB Video: Improved video timings 0.5.0: (2016-09-19) Features:
M src/gb/video.csrc/gb/video.c

@@ -110,7 +110,7 @@ ++video->ly;

video->p->memory.io[REG_LY] = video->ly; video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly); if (video->ly < GB_VIDEO_VERTICAL_PIXELS) { - video->nextMode = GB_VIDEO_MODE_2_LENGTH; + video->nextMode = GB_VIDEO_MODE_2_LENGTH + (video->p->memory.io[REG_SCX] & 7); video->mode = 2; if (!GBRegisterSTATIsHblankIRQ(video->stat) && GBRegisterSTATIsOAMIRQ(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);

@@ -142,7 +142,8 @@ ++video->ly;

if (video->ly == GB_VIDEO_VERTICAL_TOTAL_PIXELS + 1) { video->ly = 0; video->p->memory.io[REG_LY] = video->ly; - video->nextMode = GB_VIDEO_MODE_2_LENGTH; + // TODO: Cache SCX & 7 in case it changes during mode 2 + video->nextMode = GB_VIDEO_MODE_2_LENGTH + (video->p->memory.io[REG_SCX] & 7); video->mode = 2; if (GBRegisterSTATIsOAMIRQ(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);

@@ -175,11 +176,12 @@ _cleanOAM(video, video->ly);

video->dotCounter = 0; video->nextEvent = GB_VIDEO_HORIZONTAL_LENGTH; video->x = 0; - video->nextMode = GB_VIDEO_MODE_3_LENGTH_BASE + video->objMax * 12; + // TODO: Estimate sprite timings better + video->nextMode = GB_VIDEO_MODE_3_LENGTH_BASE + video->objMax * 11 - (video->p->memory.io[REG_SCX] & 7); video->mode = 3; break; case 3: - video->nextMode = GB_VIDEO_MODE_0_LENGTH_BASE - video->objMax * 12; + video->nextMode = GB_VIDEO_MODE_0_LENGTH_BASE - video->objMax * 11; video->mode = 0; if (GBRegisterSTATIsHblankIRQ(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);
M src/gb/video.hsrc/gb/video.h

@@ -19,9 +19,9 @@ GB_VIDEO_VBLANK_PIXELS = 10,

GB_VIDEO_VERTICAL_TOTAL_PIXELS = GB_VIDEO_VERTICAL_PIXELS + GB_VIDEO_VBLANK_PIXELS, // TODO: Figure out exact lengths - GB_VIDEO_MODE_2_LENGTH = 78, - GB_VIDEO_MODE_3_LENGTH_BASE = 160, - GB_VIDEO_MODE_0_LENGTH_BASE = 218, + GB_VIDEO_MODE_2_LENGTH = 83, + GB_VIDEO_MODE_3_LENGTH_BASE = 158, + GB_VIDEO_MODE_0_LENGTH_BASE = 215, GB_VIDEO_HORIZONTAL_LENGTH = GB_VIDEO_MODE_0_LENGTH_BASE + GB_VIDEO_MODE_2_LENGTH + GB_VIDEO_MODE_3_LENGTH_BASE,