map: wip map transitons
authorLukas Krickl <lukas@krickl.dev>
Fri, 12 Dec 2025 06:57:43 +0000 (07:57 +0100)
committerLukas Krickl <lukas@krickl.dev>
Fri, 12 Dec 2025 06:57:43 +0000 (07:57 +0100)
maps/spawn.inc
src/map.s
src/player.s
src/update.s

index c0186aabb27440df31aa7c16122485644da19e54..438f048eea112362ef07da64f90c6971cd1b721d 100644 (file)
@@ -1,14 +1,14 @@
 ; this map was generated by tmx2map.py
 
 .db 0x1, 0x2, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5
-.db 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5
+.db 0x5, 0x0, 0x0, 0x5, 0x5, 0x5, 0x5, 0x5
 .db 0x5, 0x1, 0x2, 0x5, 0x3, 0x4, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x4, 0x5
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0
-.db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+.db 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x5, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3
 .db 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1
 .db 0x5, 0x0, 0x0, 0x0, 0x0, 0x5, 0x5, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
-.db 0x0, 0x0, 0x0, 0x3, 0x2, 0x0, 0x0, 0x0
+.db 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
-.db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5
-.db 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
-.db 0x0, 0x0, 0x0, 0x5, 0x5, 0x5, 0x5, 0x5
-.db 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5
+.db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+.db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+.db 0x0, 0x0, 0x0, 0x0, 0x5, 0x5, 0x5, 0x5
 .db 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5
+.db 0x5, 0x5, 0x0, 0x0, 0x5, 0x5, 0x5, 0x5
index b4d47d9cd4bddb8c323125dd3cac26844da4d787..b88153f43b6363ac5bfaddc241a8cd89d747f328 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -366,10 +366,16 @@ map_full_draw:
        map_full_draw_inc_b
 
        ret
+
+       ; map transition routines
+       ; gets the down exit and sets transition state
+map_get_exit_down_and_set_load:
+       ld hl, update_map_load_down
+       call game_set_state
+       ret
        
        ; nop map rotuine
 map_r_nop:
        ret
 
 
-
index 62836a7bf868a40c57e4c06631a0a2bbabf1922c..dcacc09a5f8aceb76d5d6c754f2b0cb4f631467f 100644 (file)
@@ -149,6 +149,8 @@ player_update:
                ld [player_jump_peak], a
                ld [player_jump_timer], a
 @not_down_collision:
+
+       call player_check_map_transition_trigger
        ret
        
        ; moves the player 
@@ -158,20 +160,6 @@ player_handle_move:
        xor a, a
        ld [col_direction], a
 
-       ld b, BTNDOWN
-       input_held
-       jr z, @not_down REL
-               ld a, [player+act_pos_y]
-               cp a, 0x60 ; max value
-               jr z, @not_down REL
-               inc a
-               ld [player+act_pos_y], a
-
-               ld a, [col_direction]
-               or a, DIRDOWN
-               ld [col_direction], a
-@not_down:
-
        ld b, BTNA
        input_held
        jr z, @not_up REL
@@ -223,6 +211,18 @@ player_handle_move:
 @not_right:    
        ret
        
+       ; tests player position to
+       ; see if a map transiton point was hit
+       ; if the position is too far off-screen
+       ; it will initiate a map transition
+player_check_map_transition_trigger:
+       ; check down    
+       ld a, [player+act_pos_y]
+       cp a, 0x80 ; max y value
+       call nc, map_get_exit_down_and_set_load
+
+       ret
+       
        ; draws player at current location
 player_draw:
        ; flicker the cursor 
index 67fe3d6c262bca639ed112bb096e4def82a0bc54..51ae3a57d3d354bcf06c6c5d4ca7bbb70fdb2d86 100644 (file)
@@ -25,6 +25,10 @@ update_game:
 
   ret
        
+       ; game state
+       ; for loading a map down
+update_map_load_down:
+       ret
        
 new_game:
        ld de, l1