player: actors can now write their pointer to the tile they are located at
authorLukas Krickl <lukas@krickl.dev>
Wed, 17 Dec 2025 13:44:16 +0000 (14:44 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 17 Dec 2025 13:44:16 +0000 (14:44 +0100)
src/actor.s
src/defs.s
src/player.s

index c8720860c5bf2ad213c0bf4022b359cdc462d5a4..41c94b4ad2e05ded192138a6fb48143bd10d8815 100644 (file)
@@ -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
index 75da3a037535d18001d4922b3aebfbd75e7ee713..8de6270f345225bdfa1716e96d48aeb089c5a8f1 100644 (file)
 .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
index d2e3baa0204860570398426e34ff5ae3f8adcc39..5ed0077cba1c425c49c36eee96e937e39f27edb8 100644 (file)
@@ -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