From 90d9da72fdab944793e8d63dead5fec9000b55e6 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 19 Sep 2025 05:50:31 +0200 Subject: [PATCH] position rework: positions are now absolute pixels This of course broke various components --- src/animation.s | 1 - src/map.s | 6 ++++++ src/mapgen.s | 4 ++++ src/player.s | 6 +++--- src/unit.s | 12 +++++++----- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/animation.s b/src/animation.s index 5cabafb..78a4cc5 100644 --- a/src/animation.s +++ b/src/animation.s @@ -101,7 +101,6 @@ anim_list_hazmat: ; $2: register containing scroll ; a: tile position #macro tile_to_scrn - mul16 a add a, $1 sub a, $2 #endmacro diff --git a/src/map.s b/src/map.s index 045cb60..adb8314 100644 --- a/src/map.s +++ b/src/map.s @@ -87,6 +87,12 @@ map_draw_area_title: call ui_request_redraw ret + + ; same as map_get_tile + ; but also divides the b/c input by 16 +map_get_tile_div16: + div16 b + div16 c ; gets the tile at a y/x position ; inputs: diff --git a/src/mapgen.s b/src/mapgen.s index fc3a0e1..56db1e2 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -592,9 +592,11 @@ mapgen_unit_randomize_position: ; write y and x positions ld a, b + mul16 a ld [hl+], a ld a, c + mul16 a ld [hl], a pop_all @@ -652,9 +654,11 @@ mapgen_select_player_spawn: ld de, act_pos_y add hl, de ld a, b + mul16 a ld [hl+], a ; write y ld a, c + mul16 a ld [hl], a ; write x ld de, player_unit diff --git a/src/player.s b/src/player.s index 7739785..4a6c82d 100644 --- a/src/player.s +++ b/src/player.s @@ -35,7 +35,7 @@ unit_player_update: ; first read the current tile call unit_get_pos - call map_get_tile + call map_get_tile_div16 push af ; store for later use ; a = tile flags @@ -94,7 +94,7 @@ unit_player_remove_door: ld c, a xor a, a ld [hl], a ; clear cf - call map_get_tile + call map_get_tile_div16 pop de ; schedule animation @@ -146,7 +146,7 @@ unit_check_exit_hit: ld a, [hl] ; hl = x pos ld c, a ; c = x pos - call map_get_tile + call map_get_tile_div16 ; a = flags ld b, a ; b = flags for later use and a, CF_EXIT diff --git a/src/unit.s b/src/unit.s index 95d3c7b..da6fcf9 100644 --- a/src/unit.s +++ b/src/unit.s @@ -178,7 +178,7 @@ unit_handle_inputs: push bc push hl ; save hl = rt cf value - call map_get_tile + call map_get_tile_div16 ; set flags result pop hl ld [hl], a ; store last cf @@ -308,7 +308,7 @@ unit_try_move_up: pop de ret z - dec a + sub a, 16 ld [hl], a call play_walk_noise @@ -326,7 +326,7 @@ unit_try_move_down: cp a, MAP_H - 1 ; lower bound ret z - inc a + add a, 16 ld [hl], a call play_walk_noise @@ -344,7 +344,7 @@ unit_try_move_left: cp a, 0 ; left bound ret z - dec a + sub a, 16 ld [hl], a call play_walk_noise @@ -362,7 +362,7 @@ unit_try_move_right: cp a, MAP_W - 1 ; right bound ret z - inc a + add a, 16 ld [hl], a call play_walk_noise @@ -381,6 +381,7 @@ unit_scroll_center: ; y position scroll ld a, [hl+] + div16 a ; max y cp a, 0x0E @@ -400,6 +401,7 @@ unit_scroll_center: ; x position scroll ld a, [hl] + div16 a ; max x cp a, 0x0B -- 2.30.2