From b5c7989e9b5a801df6c65004b9fcaeb19e99826a Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 25 Jun 2018 17:34:42 -0400 Subject: fix gpu timings --- ops.yaml | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'ops.yaml') diff --git a/ops.yaml b/ops.yaml index eac671c..5cf9c77 100644 --- a/ops.yaml +++ b/ops.yaml @@ -10139,7 +10139,7 @@ templates: } static void - gpu_draw( + gpu_draw_line( gb_t * const ctx ) { struct { @@ -10238,26 +10238,28 @@ templates: switch (gpu_get_mode(ctx)) { case GPU_MODE_OAM: - if (ctx->gpu.clock > 79) { + if (ctx->gpu.clock >= 80) { // clear clock, set mode - ctx->gpu.clock = 0; + ctx->gpu.clock -= 80; gpu_set_mode(ctx, GPU_MODE_VRAM); } break; case GPU_MODE_VRAM: - if (ctx->gpu.clock > 171) { + if (ctx->gpu.clock >= 172) { // clear clock, set mode - ctx->gpu.clock = 0; + ctx->gpu.clock -= 172; gpu_set_mode(ctx, GPU_MODE_HBLANK); } break; case GPU_MODE_HBLANK: - if (ctx->gpu.clock > 203) { + if (ctx->gpu.clock >= 204) { // clear clock, draw line, increment line - ctx->gpu.clock = 0; - gpu_draw(ctx); + ctx->gpu.clock -= 204; + + // draw and increment line + gpu_draw_line(ctx); gpu_set_line(ctx, ctx->gpu.line + 1); if (ctx->gpu.line < 144) { @@ -10274,14 +10276,15 @@ templates: break; case GPU_MODE_VBLANK: - if (ctx->gpu.clock > 204) { - // clear clock, increment line - ctx->gpu.clock = 0; - gpu_set_line(ctx, ctx->gpu.line + 1); + if (ctx->gpu.clock >= 204) { + // clear clock + ctx->gpu.clock -= 204; - if (ctx->gpu.line > 153) { - // reset clock, reset line, set mode - ctx->gpu.clock = 0; + if (ctx->gpu.line < 154) { + // increment line + gpu_set_line(ctx, ctx->gpu.line + 1); + } else { + // reset line, set mode gpu_set_line(ctx, 0); gpu_set_mode(ctx, GPU_MODE_OAM); } -- cgit v1.2.3