From: Lukas Krickl Date: Wed, 3 Dec 2025 05:09:47 +0000 (+0100) Subject: map: reworked tiles and exit defs X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=cdcfef2356a73d96a50a30050aab08862929249a;p=gbrg%2F.git map: reworked tiles and exit defs --- diff --git a/TODO.md b/TODO.md index eaad12b..dbc2ed4 100644 --- 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 diff --git a/man/map.md b/man/map.md index 4e910f8..3ca8f6e 100644 --- a/man/map.md +++ b/man/map.md @@ -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. diff --git a/src/actor.s b/src/actor.s index e194775..5290782 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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 diff --git a/src/defs.s b/src/defs.s index bd59a2d..5bcb6b6 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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 @@ -51,23 +50,8 @@ .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 @@ -101,7 +83,10 @@ ; 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 @@ -115,30 +100,10 @@ ; 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 diff --git a/src/levels.s b/src/levels.s index 62477fd..e6a66cb 100644 --- a/src/levels.s +++ b/src/levels.s @@ -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 diff --git a/src/macros.inc b/src/macros.inc index b2e2e66..30e048f 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -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 diff --git a/src/tiles.s b/src/tiles.s index 230b933..1288244 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -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 diff --git a/src/wram.s b/src/wram.s index f37419a..9acbc11 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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