From 592981d0f22081d10205a917fe33364142ec3931 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 12 May 2025 21:47:51 +0200 Subject: [PATCH] unit: Added camera scroll code --- src/unit.s | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/unit.s b/src/unit.s index f5fd020..72dbf82 100644 --- a/src/unit.s +++ b/src/unit.s @@ -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 -- 2.30.2