From b2786d249555ea02250471ebc1c01e3bc849dd71 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 17 Dec 2025 14:44:16 +0100 Subject: [PATCH] player: actors can now write their pointer to the tile they are located at --- src/actor.s | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++- src/defs.s | 2 +- src/player.s | 14 ++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) diff --git a/src/actor.s b/src/actor.s index c872086..41c94b4 100644 --- a/src/actor.s +++ b/src/actor.s @@ -45,6 +45,103 @@ act_update: ; and call ret + ; clears tact at the current actors position + ; inputs: + ; de: actor +act_clear_tact: + ld hl, act_pos_y + add hl, de + ld a, [hl+] + ld b, a + ld a, [hl] + ld c, a + call map_get_tile + ; get tile + + ld bc, t_act + add hl, bc + ; clear value + xor a, a + ld [hl+], a + ld [hl], a + + ret + + ; sets tact at the current actors location + ; inputs: + ; de: actor +act_set_tact: + push de + ld hl, act_pos_y + add hl, de + ld a, [hl+] + ld b, a + ld a, [hl] + ld c, a + call map_get_tile + ; get tile + + ld bc, t_act + add hl, bc + + ; set ptr + pop de + + ld a, d + ld [hl+], a + ld a, e + ld [hl], a + ret + + + ; clears tprop t the current prop position + ; inputs: + ; de: actor +act_clear_tprop: + ld hl, act_pos_y + add hl, de + ld a, [hl+] + ld b, a + ld a, [hl] + ld c, a + call map_get_tile + ; get tile + + ld bc, t_prop + add hl, bc + ; clear value + xor a, a + ld [hl+], a + ld [hl], a + + ret + + ; sets tprop at the current prop location + ; inputs: + ; de: actor +act_set_tprop: + push de + ld hl, act_pos_y + add hl, de + ld a, [hl+] + ld b, a + ld a, [hl] + ld c, a + call map_get_tile + ; get tile + + ld bc, t_prop + add hl, bc + + ; set ptr + pop de + + ld a, d + ld [hl+], a + ld a, e + ld [hl], a + ret + ; checks if the selected actor can move forward ; inputs: ; de: actor @@ -69,7 +166,6 @@ act_can_move: add hl, de ld a, [hl] ld b, a ; b = tile flags - pop de ld hl, act_dir diff --git a/src/defs.s b/src/defs.s index 75da3a0..8de6270 100644 --- a/src/defs.s +++ b/src/defs.s @@ -108,7 +108,7 @@ .de t_flags, 1 ; actor currently ; standing on tile (ptr) -.de t_actor, 2 +.de t_act, 2 ; prop actor ptr ; currently located at this tile ; this actor does not block the tile diff --git a/src/player.s b/src/player.s index d2e3baa..5ed0077 100644 --- a/src/player.s +++ b/src/player.s @@ -95,9 +95,23 @@ player_handle_move: ret player_move_forward: + ld de, player + call act_clear_tact + + ld de, player call act_move_forward + + ld de, player + call act_set_tact jp map_full_draw player_move_back: + ld de, player + call act_clear_tact + + ld de, player call act_move_back + + ld de, player + call act_set_tact jp map_full_draw -- 2.30.2