summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-06-25 17:34:42 -0400
committerPaul Duncan <pabs@pablotron.org>2018-06-25 17:34:42 -0400
commitb5c7989e9b5a801df6c65004b9fcaeb19e99826a (patch)
treefe79d94eaf346a2c4b26c524e4c36fc04a155533
parentf8012322fc758990f47a1ac469cd713d636861c3 (diff)
downloadgb-c-b5c7989e9b5a801df6c65004b9fcaeb19e99826a.tar.bz2
gb-c-b5c7989e9b5a801df6c65004b9fcaeb19e99826a.zip
fix gpu timings
-rw-r--r--ops.yaml33
1 files changed, 18 insertions, 15 deletions
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);
}