all repos — mgba @ 3cfdad192c2e54ad6a94430008bf8f99c1c831cc

mGBA Game Boy Advance Emulator

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

3cfdad192c2e54ad6a94430008bf8f99c1c831cc

parent

6f9a0d9758537b80df5291bd05dff26a626113ff

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

jump to
M CHANGESCHANGES

@@ -22,6 +22,7 @@ - All: Only update version info if needed

- FFmpeg: Encoding cleanup - GB Memory: Initialize RAM pattern for GBC - SDL: Remove scancode key input + - 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,