From 48f903fbc0ac04dd77c2ebc4a984f5627a732a8b Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 28 Nov 2025 06:25:50 +0100 Subject: [PATCH] tiles: Added event struct --- src/defs.s | 20 ++++++++++++++++---- src/macros.inc | 19 +++++++++++++++++-- src/player.s | 6 +++--- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/defs.s b/src/defs.s index 0343f35..3d56155 100644 --- a/src/defs.s +++ b/src/defs.s @@ -114,13 +114,25 @@ ; standing on tile ; 0 = player, 1-N = map actors .de t_actor, 1 - ; 2 bytes of custom state storage - ; to be used by tile routine -.de t_p0, 1 -.de t_state, 1 + ; if != 0 this points to an event + ; that should execute when the player hits the tile +.de t_event, 2 ; graphical tile .de t_tile, 1 .de t_size, 0 + + ; tile event struct +.se 0 +.de te_type, 1 +.de te_flags, 1 + ; pointer to map + ; that should be loaded on + ; event trigger + ; if it is 0000 + ; the current map remains +.de te_target_map, 2 +.de te_y, 1 +.de te_x, 1 diff --git a/src/macros.inc b/src/macros.inc index 8c8ffa2..3855ba7 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -179,11 +179,26 @@ $1: ; $2: flags ; $3: tile gfx #macro tiledef - .db $1, $2, 0 - ; t_actor, p0 and state + .db $1, $2 + ; t_actor + .db 0 + ; t_event .db 0, 0 .db $3 #endmacro + + ; defines a tile event + ; inputs: + ; $1: type + ; $2: flags + ; $3: target map (or NULL) + ; $4: y pos + ; $5: x pos +#macro tileeventdef + .db $1, $2 + dw $3 + .db $4, $5 +#endmacro ; defines a new actor ; inputs: diff --git a/src/player.s b/src/player.s index 536f234..5d0a713 100644 --- a/src/player.s +++ b/src/player.s @@ -12,7 +12,7 @@ player_init: ; updates the special player actor player_update: - call scroll_center_player + ; call scroll_center_player call player_inputs call player_handle_move @@ -80,7 +80,7 @@ player_handle_move: and a, BTNDOWN jr z, @not_down REL ld a, [player+act_pos_y] - cp a, 0xF0 ; max value + cp a, 0x60 ; max value jr z, @not_down REL inc a ld [player+act_pos_y], a @@ -110,7 +110,7 @@ player_handle_move: and a, BTNRIGHT jr z, @not_right REL ld a, [player+act_pos_x] - cp a, 0xF0 ; max value + cp a, 0x90 ; max value jr z, @not_right REL inc a ld [player+act_pos_x], a -- 2.30.2