unit: Added camera scroll code
authorLukas Krickl <lukas@krickl.dev>
Mon, 12 May 2025 19:47:51 +0000 (21:47 +0200)
committerLukas Krickl <lukas@krickl.dev>
Mon, 12 May 2025 19:47:51 +0000 (21:47 +0200)
src/unit.s

index f5fd0209ec9c9a131904773c615efe315f310987..72dbf8271c8beecbf0fbdb9369e3eb392b3897ba 100644 (file)
@@ -229,13 +229,44 @@ unit_scroll_center:
   ld hl, act_pos_y
   add hl, de
   ; hl = pos y
+
+  ; y position scroll
   ld a, [hl+]
+
+  ; max y
+  cp a, 0x10 
+  jr c, @not_max_y REL
+    ld a, 0x10
+@not_max_y: 
+
+  ; min y
+  cp a, 0x07
+  jr nc, @not_min_y REL
+    ld a, 0x07
+@not_min_y:
+  ; adjust scroll
   sub a, (MAP_H - 10) / 2
   mul8 a
   ld [scroll_y], a
 
+  ; x position scroll
   ld a, [hl]
+
+  BREAK
+  ; max x
+  cp a, 0x16
+  jr c, @not_max_x REL
+    ld a, 0x16
+@not_max_x:
+
+  ; min x
+  cp a, 0x0A
+  jr nc, @not_min_x REL
+    ld a, 0x0A
+@not_min_x:
+
   sub a, (MAP_W - 12) / 2
+
   mul8 a
   ld [scroll_x], a