summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}