exits: removed rerferences to existing exit tables
authorLukas Krickl <lukas@krickl.dev>
Thu, 21 Aug 2025 06:56:35 +0000 (08:56 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 21 Aug 2025 06:56:35 +0000 (08:56 +0200)
This is the first step for the exti system rework.

15 files changed:
maps/map_bc.s
maps/map_be.s
maps/map_bw.s
maps/map_c.s
maps/map_ce.s
maps/map_cw.s
maps/map_tc.s
maps/map_te.s
maps/map_tw.s
src/defs.s
src/exittables.s
src/map.s
src/player.s
src/wram.s
tools/tms2map.py

index 65fd2ea50e42471969b46887d6be3a7a71be5736..0d9c1cdcfceebb49aef18357525d7d6d5c6b9651 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_bc_exit_table
 
 map_bc_bg:
 
index 9563a23ba395f23eaecdfdb8109ef831497ac11f..151bc9a8719a805390f87dbb22b135eb3688bdf4 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_be_exit_table
 
 map_be_bg:
 
index 4d47b49c32c46365c841e0b91daa737762849b68..11ffaa1f4b9f15eb615b17d3d20372365b579c3f 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_bw_exit_table
 
 map_bw_bg:
 
index 77b9b6bf7156e325eca7a8ce366d6d337950be00..eff1eeaffed40c6c8491cb9d2756d0ac6fb0f79b 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_c_exit_table
 
 map_c_bg:
 
index 229addf4f311705ca492ad545eb4987390918cdc..cc6951549b54d3a11a2147304201297ac426a1d7 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_ce_exit_table
 
 map_ce_bg:
 
index d9bbd8374355ce57c23a4098f1a4cbbf7a23380d..54d29a61581cd8e7c343721d6354b6dcf11b5da8 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_cw_exit_table
 
 map_cw_bg:
 
index 54526d5e535bc7ee5230c2e28b6ea889b8185b62..12fe21dc7dfed98cbd24a6c6ce699fa0b7ee3c18 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_tc_exit_table
 
 map_tc_bg:
 
index e89f838ba46283da61740d2609365814c48d539e..38ae4ce428e2e9dd647c3efb7bd5e3677997ee9c 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_te_exit_table
 
 map_te_bg:
 
index 8a56c202429d88d6301e59d20b0467c07966233d..00dd49ad6c2516eb409bf44bce846cddf30a9efc 100644 (file)
@@ -9,7 +9,6 @@ dw bank8000
 dw bank8800
 dw bank8C00
 dw bank9000
-dw map_tw_exit_table
 
 map_tw_bg:
 
index 23e5aead5db05916f2753539450a05bb882b92ef..849af37b860c2c0b357f627a1acc02de17e688b9 100644 (file)
 .se 1 
 .de CF_COLLISION, 1
   ; exit flag
-  ; if this flag is set
-  ; the upper nibble is
-  ; an index into the current map's 
-  ; exit table
+       ; flags this tile as a valid exit
+       ; must be at the edge of the map
+       ; TODO: maybe add a special exit as a default
 .de CF_EXIT, 2
 .de CF_DOOR, 4
        ; if this flag is set do not 
 .de map_tile_bank1_ptr, 2
 .de map_tile_bank2_ptr, 2
 .de map_tile_bank3_ptr, 2
-
-  ; pointer to exit table
-  ; 
-.de map_exit_table_ptr, 2
 .de map_header_size, 0
 
   ; map actor table struct
   ; list of be pointers to actors
 .de map_actor_table_act_ptrs, 0
 
-  ; map exit flags
-.se 1
-  ; if these flags are set goto_y and
-  ; goto_x are treated as relative offsets
-  ; instead of absolute tile positions
-.de EXITF_GOTOY_REL, 1
-.de EXITF_GOTOX_REL, 2
-
-.def int EXITF_GOTOXY_REL = EXITF_GOTOY_REL | EXITF_GOTOX_REL
 
   ; map exit table entry struct
 .se 0
index ad25915fec422717b79ac35a46294e1ecdf79204..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,59 +0,0 @@
-; exit tables:
-;   down: 0
-;   left: 1
-;   right: 2
-;   up: 3
-
-map_tc_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_tw_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_te_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_c_header 
-
-map_te_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_ce_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_tc_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_c_header 
-
-map_tw_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_cw_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_tc_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_c_header 
-
-map_c_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_bc_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_cw_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_ce_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_tc_header 
-
-map_ce_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_be_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_te_header 
-
-map_cw_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_bw_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_tw_header 
-
-map_bc_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_bw_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_be_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_c_header 
-
-map_be_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_bc_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_bc_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_ce_header 
-
-map_bw_exit_table:
-exit_def EXITF_GOTOXY_REL, BTNDOWN, -15, 0, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNLEFT, 0, 15, map_c_header 
-exit_def EXITF_GOTOXY_REL, BTNRIGHT, 0, -15, map_bc_header 
-exit_def EXITF_GOTOXY_REL, BTNUP, 15, 0, map_cw_header 
index 3cbf1286d9805c4f8bfe2597a53da4ae092afcdb..22afe0dfd2cfb2ef8e09c8f6893a63302dccf20f 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -56,10 +56,6 @@ map_load:
   push hl
   call map_tile_banks_load
   pop hl
-  
-  push hl
-  call map_load_exit_table
-  pop hl
 
   ret
 
@@ -342,20 +338,6 @@ map_tile_banks_load:
   
   ret
   
-  ; loads the exit table
-  ; inputs:
-  ;   hl: map ptr
-map_load_exit_table:
-  ld de, map_exit_table_ptr
-  add hl, de ; hl = exit table
-
-  ld a, [hl+]
-  ld [map_exit_table], a
-  ld a, [hl]
-  ld [map_exit_table+1], a
-
-  ret
-
   ; draws all cells currently loaded to the screen
   ; only call during blank!
 map_draw_all:
index 330e8953179fb3817f722d7401dbfc80f23e25ce..b7f9d38ecbcbd5711b728338d00c9537326f9bfd 100644 (file)
@@ -110,7 +110,7 @@ unit_player_remove_door:
        ld a, 0x48 ; roof tile
        ; clear map
        ld [hl+], a
-       ld a, CF_COVERED
+       ld a, CF_EXIT 
        ld [hl], a
        
        ld hl, act_rt_collision_pos_y
@@ -128,9 +128,15 @@ unit_player_remove_door:
 
   ; checks the current tile
   ; and checks for exit flags
+       ; if an exit flag is set, checks if 
+       ; the player is in position y == 0 
+       ; y == MAP_H-1, x == 0 or x == MAP_W-1
+       ; to determine where to take the player
+       ; the direction moving the player oob must be pressed to move the player
   ; inputs:
   ;   de: actor
 unit_check_exit_hit:
+       push de
   ld hl, act_pos_y
   add hl, de ; hl = actor_y
   
@@ -143,100 +149,27 @@ unit_check_exit_hit:
   ; a = flags
   ld b, a ; b = flags for later use
   and a, CF_EXIT
+       pop de
   ret z ; if not we bail
 
   ; now it's time to look up
-  ; the exit
-  
-  ; de = exit ptr
-  ld de, map_exit_table
-  ld a, [de]
-  ld l, a
-  inc de
-  ld a, [de]
-  ld h, a
-  ; hl = first entry in exit table
-  ld a, b ; a = flags
-  and a, 0xF0 ; we only care about the upper nibble
-  swap a ; a = exit table offset
-  cp a, 0 ; do not do this if a == 0
-  jr z, @done_calculate_ptr REL
-
-  ; add exit size to de a times
-  ld de, exit_size
-@calculate_ptr:
-    add hl, de  
-    dec a
-  jr nz, @calculate_ptr REL
-@done_calculate_ptr:
+  ; the exit's position
   
-  ; hl == the exit table entry
-  ; check if input is required
-
-  inc hl ; hl = required input
-  ld a, [hl]
-  dec hl ; hl = exit flags
-
-  cp a, 0
-  jr z, @skip_input_check REL
-    ; if inputs is not 0 we check button state
-    ld b, a ; b = button mask
-    input_held
-    ret z ; if not input bail
-@skip_input_check:
   
+@load_map:  
   ; fade out
   call video_fade_out
+       
+       ; TODO: adjust player map cursor
 
-  ; now we can load the map
-
-  ; load map ptr
-  push hl
-  ld de, exit_to
-  add hl, de ; hl = map ptr
-  
-
-  ld a, [hl+]
-  ld c, a
-  ld a, [hl]
-  ld h, a
-  ld a, c
-  ld l, a ; hl = map header ptr
-  call map_load 
-
-  pop bc ; bc = exit table now 
-  ; finally adjust player position
+       ; generate new map
+  call mapgen 
   
   ; hl = player
   ld hl, player_unit 
   ld de, act_pos_y
   add hl, de ; hl = y pos
   
-  ; adjust y position
-  ld a, [bc]
-  and a, EXITF_GOTOY_REL
-  
-  inc bc 
-  inc bc ; bc = y adjust
-  ld a, [bc]
-  dec bc
-  dec bc
-  call z, map_exit_absolute_adjust
-  call nz, map_exit_relative_adjust
-  
-  inc hl ; hl = x pos
-
-  ; adjust x position
-  ld a, [bc]
-  and a, EXITF_GOTOX_REL
-  
-  inc bc 
-  inc bc
-  inc bc ; bc = x adjust
-  ld a, [bc]
-  call z, map_exit_absolute_adjust
-  call nz, map_exit_relative_adjust
-
 
   ; scroll to player's position
   ld de, player_unit 
@@ -251,32 +184,6 @@ unit_check_exit_hit:
 
   ret
 
-  ; adjusts player position to aboslute
-  ; position
-  ; inputs:
-  ;   hl: player_y or player_x
-  ;    a: new y or new x
-  ; preserves all registers and flags
-map_exit_absolute_adjust:
-  ld [hl], a 
-  ret
-
-  ; adjusts player position by a relative  
-  ; position offset
-  ; inputs:
-  ;   hl: player_y or player_x
-  ;    a: new y or new x
-  ; preserves all registers and flags
-map_exit_relative_adjust:
-  push_all
-
-  ld b, a
-  ld a, [hl]
-  add a, b
-  ld [hl], a
-
-  pop_all
-  ret
        
        ; player attack state
        ;       inputs:
index 4db82bc8e7dfd4f431598daeb9904a348b1daaca..d157d9cd30e0f3ed0ae5309b53d55cfc3a6bf71a 100644 (file)
@@ -181,8 +181,6 @@ map_end:
   
   ; mape state machine
 map_st: .adv st_size
-  ; current exit table ptr
-map_exit_table: .adv 2
        ; ptr to the last map header used
 map_header: .adv 2
        
index 2706b4581bfb33d2817048aa48d7cbc0bd8221be..23282766b55773da0ddf61d5ebb42ce5a612ae86 100755 (executable)
@@ -13,7 +13,6 @@ tile_bank0 = "bank8000"
 tile_bank1 = "bank8800"
 tile_bank2 = "bank8C00"
 tile_bank3 = "bank9000"
-exit_table = "map_c_exit_table"
 actor_table_ptr = "map_actor_table_null"
 map_name = "noname"
 NAME_LEN = 8
@@ -108,7 +107,6 @@ def print_header(name):
     print("dw " + tile_bank1)
     print("dw " + tile_bank2)
     print("dw " + tile_bank3)
-    print("dw " + exit_table)
     print("")
     
 def get_flag(tile):
@@ -138,7 +136,6 @@ def get_map_props(root):
     global tile_bank2
     global tile_bank3
     global map_name
-    global exit_table
 
     for child in root:
         if child.tag == "properties":
@@ -159,8 +156,6 @@ def get_map_props(root):
                     tile_bank3 = value
                 elif name == 'map_name':
                     map_name = value
-                elif name == 'exit_table':
-                    exit_table = value
 
     return