From: Lukas Krickl Date: Mon, 12 May 2025 19:47:51 +0000 (+0200) Subject: unit: Added camera scroll code X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=592981d0f22081d10205a917fe33364142ec3931;p=gbrg%2F.git unit: Added camera scroll code --- 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