position rework: positions are now absolute pixels
authorLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 03:50:31 +0000 (05:50 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 03:50:31 +0000 (05:50 +0200)
This of course broke various components

src/animation.s
src/map.s
src/mapgen.s
src/player.s
src/unit.s

index 5cabafb72d02aea9924ebf6224ff9bcee2281e7a..78a4cc51aa19b0b4285463a42d936360fd89772c 100644 (file)
@@ -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
index 045cb6076bd1327cd05786c75f65191f1b64f352..adb8314ac0c0f62e2f85c19cd6432706fc39daf7 100644 (file)
--- 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:
index fc3a0e124c63f23191faf285154957c3f5734c92..56db1e2608b6e6cecf7838c4d6e235e384dc4383 100644 (file)
@@ -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
index 77397859ea7aacdb275eba92ab5f7df77b210c8b..4a6c82d88fe86b4e4d9ca6e314c0d3dedf3640ee 100644 (file)
@@ -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
index 95d3c7b41f159b4f2eb41107ae0ae4872234c913..da6fcf96f4ef68dab2a4252ca47bef6835d0869e 100644 (file)
@@ -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