defs: removed some magic numbers from scroll center
authorLukas Krickl <lukas@krickl.dev>
Fri, 20 Jun 2025 19:15:31 +0000 (21:15 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 20 Jun 2025 19:15:31 +0000 (21:15 +0200)
src/defs.s
src/unit.s

index 815673991cc6ad6fc56cdf9e45da521b361c8e2d..22d281c67192dce2b795405d777d0b688a2e4544 100644 (file)
@@ -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
index a04511cbdd088a93b5f99ac189bf47dc117be540..b51c747fdd5bd5596bfab3a21cd474f948879ff9 100644 (file)
@@ -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