map: map transitioon loads now fixes player position
authorLukas Krickl <lukas@krickl.dev>
Sun, 14 Dec 2025 07:21:19 +0000 (08:21 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 14 Dec 2025 07:21:19 +0000 (08:21 +0100)
map transitions now use the correct map for flag reads.

src/levels.s
src/map.s
src/update.s

index efa692ac85c0047658ee1de207b7c6c8ed8756d8..45c803b6d8c5f4416fe48d9041a33002656f848e 100644 (file)
@@ -23,3 +23,7 @@ l1_exits:
        dw l1
        dw l1
        dw l1
+
+l2:
+       mapdef 0, map_r_nop, 0, l1_exits, bank8000, bank8800, bank8C00, bank9000, tile_id_table
+#include "spawn.inc"
index a636569063b0d3d6d7ae8517f243d48e71b4ec61..11f48ba2a8cc02b172f78eff6aff50d5a753dc7d 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -39,9 +39,6 @@ map_load:
        call vblank_wait
        call enableinterrupts
 
-       call player_init
-       call ui_init
-
        ret
        
        ; loads all map related data that 
@@ -436,12 +433,7 @@ map_full_draw:
        ; inputs:
        ;               de: new map ptr
 map_try_full_reload:
-       ld hl, map
-       ld a, [hl+]
-       ld h, [hl]
-       ld l, a ; hl = map
-
-       ld a, [hl] ; read flags
+       ld a, [de] ; read flags
        and a, MAP_F_DO_FULL_REDRAW
        ret z 
 
@@ -451,6 +443,11 @@ map_try_full_reload:
        ; map transition routines
        ; gets the down exit and sets transition state
 map_get_exit_down_and_set_load:
+       ; fix player position
+       ld hl, player+act_pos_y
+       xor a, a
+       ld [hl], a
+
        ld hl, map_exit_down
        ld a, [hl+]
        ld d, [hl]
@@ -459,7 +456,7 @@ map_get_exit_down_and_set_load:
        ; this call does not return
        ; if a full load is needed
        call map_try_full_reload
-
+       
        ld hl, update_map_load_down
        call game_set_state
        ret
index 51ae3a57d3d354bcf06c6c5d4ca7bbb70fdb2d86..35cfdbcc05e35389c965209c8ed49e6bd10c69ae 100644 (file)
@@ -84,4 +84,7 @@ game_init:
   ld [ROBP1], a
   ld [shadow_robp1], a
 
+       call player_init
+       call ui_init
+
   ret