map: reworked tiles and exit defs
authorLukas Krickl <lukas@krickl.dev>
Wed, 3 Dec 2025 05:09:47 +0000 (06:09 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 3 Dec 2025 05:09:47 +0000 (06:09 +0100)
TODO.md
man/map.md
src/actor.s
src/defs.s
src/levels.s
src/macros.inc
src/tiles.s
src/wram.s

diff --git a/TODO.md b/TODO.md
index eaad12bbcc07a656e0ffad797a67036bf331e9fa..dbc2ed4882c595e734bfacbcd423dbf8a32ccf47 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -1,43 +1,13 @@
 # TODO
 
-- Code style: Replace leading spaces with tabs (space was set to 2) 
-
 ## scope
 
-[ ] Mini turn based rpg
-[ ] One button per slot
-    - Weapon (A)
-    - Cast (B)
-    - Item (Select)
-[ ] 
-    
 
 ## Game field
 
 [ ] 10x8 map 
 [ ] Load map with pre-determined tiles
 
-[ ] Player - Moves from tile to tile
-[ ] Actors 
-    [ ] Each map may have up to 4 actors
-    [ ] An actor may have dialog, be a shotkeeper
-        or start combat when talked to
-    [ ] actors may patrol
-    [ ] actors mark the tile they are on with their actor index
-    [ ] one actor update per frame
-[ ] player updates very frame
-
-[ ] on hostile maps only:
-    [ ] when the player moves a danger level increments every frame
-    [ ] when the danger level + rng roll from 1-16 > 64 combat starts
-    [ ] each map may define up to 4 enemy sets that can appear
-[ ] each map may define 4 exits (north, west, east, south)
-    that are triggered when the player presses up,left,right,down 
-    on the respective tiles
-[ ] each map may define one special exit that is triggere by touching a tile 
-    with the exit flag set
-[ ] the player may level up and gain HP or MP (choice to be made)
-
 
 # Combat
 
index 4e910f8e605b10594a31cd17e762e3842c5eafb5..3ca8f6ea9b83d7944ba935719cebb5478d29bdf8 100644 (file)
@@ -3,20 +3,15 @@
 Maps are the building blokc of the world
 
 Each map has a header containg data about what kind of map it is,
-what tiles to load, what encounter to load etc.
+what tiles to load, what actors to load etc.
 
 ## Tiles
 
 Each map can point to a table of tiles.
-Tiles can hold information such as tiles to render and event pointers.
-
-## Events
-
-Events can be anything that happens when a player touches the tile.
-Common events are exits, scripted encounters or cutscenes.
+Tiles can hold information such as tiles to render.
 
 ## Exits
 
 Each map can point to a table of exits.
-This table is referenced by exit events.
+Exits point to an exit table entry in t_state.
 
index e19477542c9c048ad7e13ea5c4ba6e5799676ea0..529078272b2a51c69e516337fe979f4e5ab221f9 100644 (file)
@@ -146,11 +146,5 @@ actors_combat_update:
        ; and call
        ret
 
-act_shop_keeper:
-       actdef ACT_T_SHOP_KEEPER, 0, 10, 10, 0, 0, NULL
-
 act_bat:
-       actdef ACT_T_BAT, 0, 10, 10, 0, 0, act_bat_cb
-
-act_bat_cb:
-       actcbdef 1, 1, 1, 2, 0
+       actdef ACT_T_BAT, 0, 10, 10, 0, 0 
index bd59a2d3f1ab159c8efbee9047640e1b988c33b8..5bcb6b672606cbd3dbc48ba6e0e72dd7598573a3 100644 (file)
@@ -35,7 +35,6 @@
 .se 0
 .de ACT_T_NULL, 1
 .de ACT_T_PLAYER, 1
-.de ACT_T_SHOP_KEEPER, 1
 .de ACT_T_BAT, 1
        
        ; actor struct 
 .de act_state, 1
 .de act_hp, 1
 .de act_mp, 1
-.de act_cb, 2
 .de act_size, 0
 
-       ; actor combat stats struct
-       ; this can be shared by many actors
-.se 0
-.de act_cb_flags, 1
-.de act_cb_lvl, 1
-.de act_cb_exp, 2
-.de act_cb_atk, 1
-.de act_cb_def, 1
-.de act_cb_hp_max, 1
-.de act_cb_mp_max, 1
-.de act_cb_p0, 1
-.de act_cb_state, 1
-.de act_cb_size, 0
-
  
        ; map flags
 .se 1
@@ -80,8 +64,6 @@
 .de map_routine, 2
        ; ptr to actor table for this map
 .de map_acts, 2
-       ; ptr to encounter table
-.de map_encounters, 2
        ; ptr to exit table 
 .de map_exits, 2
   ; pointers to tile banks to be loaded 
        ; tile type enum
 .se 0
 .de TT_EMPTY, 1
-.de TT_WALL, 1 
+.de TT_WALL, 1
+       ; exit tiles store index in exit table
+       ; in p0
+.de TT_EXIT, 1
 
        ; tile flags
 .se 1
        ; standing on tile
        ; 0 = player, 1-N = map actors
 .de t_actor, 1
-       ; if != 0 this points to an event
-       ; that should execute when the player hits the tile
-.de t_event, 2
+.de t_p0, 1
        ; graphical tile
 .de t_tile, 1
 .de t_size, 0
-       
-       ; tile event types
-.se 0
-       ; exit on touch
-       ; p0: exit table entry
-       ; p1: new y pos
-       ;       p2: new x pos
-.de TE_EXIT, 1
-
-
-       ; tile event struct
-.se 0
-.de te_type, 1
-.de te_flags, 1
-.de te_p0, 1
-.de te_p1, 1
-.de te_p2, 1
-.de te_size, 0
 
        ; exit table entry
 .se 0
index 62477fdae8715b3e5f33e28dff19cd71f8da0a3f..e6a66cb6afb17823591f8ce6bab3efb339ec3b12 100644 (file)
@@ -13,7 +13,7 @@
        ; where each tile has values and its current state. The map can be drawn from this.
 
 l1:
-       mapdef 0, map_r_nop, 0, 0, 0, bank8000, bank8800, bank8C00, bank9000, tile_id_table
+       mapdef 0, map_r_nop, 0, 0, bank8000, bank8800, bank8C00, bank9000, tile_id_table
        .db TWL, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
        .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
        .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
index b2e2e66e99fa55a6033c5b6e960dbcf3cfbd6e5f..30e048fe7fad6c09a0dc20073c486f5badcb7bc9 100644 (file)
@@ -155,13 +155,12 @@ $1:
        ;               $1: flags
        ;               $2: map routine
        ;               $3: actors
-       ;               $4: encounters
-       ;               $5: exits
-       ;               $6: tile bank 0
-       ;               $7: tile bank 1
-       ;               $8: tile bank 2
-       ;               $9: tile bank 3
-       ;               $10: tile id table
+       ;               $4: exits
+       ;               $5: tile bank 0
+       ;               $6: tile bank 1
+       ;               $7: tile bank 2
+       ;               $8: tile bank 3
+       ;               $9: tile id table
 #macro mapdef
        .db $1
        dw $2
@@ -172,35 +171,22 @@ $1:
        dw $7
        dw $8
        dw $9
-       dw $10
 #endmacro
        
        ; define a tile
        ; inputs:
        ;               $1: type
        ;               $2: flags
-       ;               $3: tile gfx
+       ;               $3: p0
+       ;               $4: tile gfx
 #macro tiledef
        .db $1, $2 
        ; t_actor
        .db 0
-       ; t_event
-       .db 0, 0 
        .db $3
+       .db $4
 #endmacro
 
-       ; defines a tile event
-       ; inputs:
-       ;               $1: type
-       ;               $2: flags
-       ;               $3: p0
-       ;               $4: p1
-       ;               $5: p2
-#macro tileeventdef
-       .db $1, $2
-       .db $3, $4, $5
-#endmacro
-       
        ; defines a new actor
        ; inputs:
        ;               $1: type
@@ -209,13 +195,11 @@ $1:
        ;               $4: x
        ;               $5: hp
        ;               $6: mp
-       ;               $7: combat stats ptr (or NULL)
 #macro actdef
        .db $1, $2, $3, $4
        ; p0 and state
        .db 0, 0 
        .db $5, $6
-       .db $7
 #endmacro
 
        ; defines combat stats
index 230b9332af5f3bbd6dfed50e0a79f5643700bace..1288244ca57b12996d8e623b1834a23f3f843e6b 100644 (file)
@@ -12,10 +12,10 @@ tile_id_table:
        
        ; fallback tile 
 tile_null:
-       tiledef 0, 0, 0
+       tiledef 0, 0, 0, 0
 
 tile_grass:
-       tiledef TT_EMPTY, 0, GFX_GRASS
+       tiledef TT_EMPTY, 0, 0, GFX_GRASS
 
 tile_wall:
-       tiledef TT_WALL, TF_WALL, GFX_WALL
+       tiledef TT_WALL, TF_WALL, 0, GFX_WALL
index f37419a33da81af87bb94628b508998b6731dc43..9acbc11920311edfce66bf71aa045ebc9b2d9a08 100644 (file)
@@ -69,8 +69,6 @@ animation_frame: .adv 1
   ; seed must never be 0
 srand: .adv 2
        
-       ; player combtat stats
-player_cb: .adv act_cb_size
        ; stores the last move direction
 player_direction: .adv 1
 player_move_timer: .adv 1