From 85a559e078aba209514eef8bdf973c6cecc1e14e Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 20 Jun 2025 21:15:31 +0200 Subject: [PATCH] defs: removed some magic numbers from scroll center --- src/defs.s | 3 +++ src/unit.s | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/defs.s b/src/defs.s index 8156739..22d281c 100644 --- a/src/defs.s +++ b/src/defs.s @@ -19,6 +19,9 @@ #define MAP_H 24 #define MAP_SIZE (MAP_W * MAP_H) +#define VIEW_PORT_TILES_W 12 +#define VIEW_PORT_TILES_H 10 + ; seed for the rng ; 8 bit signed int #define RAND_MAGIC 0x1B diff --git a/src/unit.s b/src/unit.s index a04511c..b51c747 100644 --- a/src/unit.s +++ b/src/unit.s @@ -380,7 +380,7 @@ unit_scroll_center: ld a, 0x07 @not_min_y: ; adjust scroll - sub a, (MAP_H - 10) / 2 + sub a, (MAP_H - VIEW_PORT_TILES_H) / 2 mul8 a ld [scroll_y], a @@ -399,7 +399,7 @@ unit_scroll_center: ld a, 0x0A @not_min_x: - sub a, (MAP_W - 12) / 2 + sub a, (MAP_W - VIEW_PORT_TILES_W ) / 2 mul8 a ld [scroll_x], a -- 2.30.2