actor: Added act nearby and prop nearby
authorLukas Krickl <lukas@krickl.dev>
Thu, 18 Dec 2025 05:47:52 +0000 (06:47 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 18 Dec 2025 05:47:52 +0000 (06:47 +0100)
Added stubs for updating and drawing actors

src/actor.s
src/levels.s
src/map.s
src/wram.s

index cb382a7344f91e39c54526c44d10c5d2430fb6f2..7745ca5b73ec086d3ba91218ec20f147393f9fc7 100644 (file)
@@ -33,8 +33,18 @@ act_dir_back:
        .db TF_SE ; NORTH
        .db TF_EE ; WEST
        .db TF_WE ; EAST
-
        
+       ; loads an actor table into ram
+       ; actors are loaded until the type byte of
+       ; the next actor is set to 0
+       ; inputs:
+       ;               hl: actor table
+act_table_load:
+       ret
+
+       ; updates the entire current actor table
+act_all_update:
+       ret
 
        ; updates and draws an actor
        ; calls different routines fro combat and map state
@@ -45,6 +55,14 @@ act_update:
        ; and call
        ret
        
+       ; draws an actor if they are near
+       ; usuall act_nearby or prop_nearby
+       ; to the camera
+       ; inputs:
+       ;               hl: actor ptr
+act_draw_nearby:
+       ret
+       
        ; clears tact at the current actors position
        ; inputs:
        ;               de: actor
@@ -321,5 +339,3 @@ act_move_back:
        ret
 
 
-act_bat:
-       actdef ACT_T_BAT, 0, 10, 10, 0, 0 
index e5da4d7424eb30f155a9581e7d1766a8e743fb08..2641081d69b9333a0b56b0484d60905bdcb17e43 100644 (file)
 l1:
        mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, tile_banks_default 
 #include "l1.inc"
+       
+       ; l1 actor table
+l1_acts:
+       actdef ACT_T_BAT, 0, 10, 10, 0, 0
+       .db 0 ; terminate
+       
 
 tile_banks_default:
        dw bank8000
index 8f4360bbea25c64b59bb603da3d2be7bdd3ff36b..1ba296e3eab952f6279c86477af612f9c7ff58a8 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -330,7 +330,33 @@ map_get_tile:
 @done:
 .endscope
 #endmacro
+       
+       ; writes the input tiles
+       ; act and prop into act_nearby and prop_nearby
+       ; inputs:
+       ;               hl: tile
+       ; preserves: 
+       ;               all registers
+map_write_nearby_act_prop:
+       push_all
 
+       ld de, t_act
+       add hl, de
+       
+       ; write act
+       ld a, [hl+]
+       ld [act_nearby], a
+       ld a, [hl+]
+       ld [act_nearby+1], a
+
+       ; write prop
+       ld a, [hl+]
+       ld [prop_nearby], a
+       ld a, [hl]
+       ld [prop_nearby+1], a
+       
+       pop_all
+       ret
 
        ; counts the tiles the player can move forward
        ;       inputs:
@@ -350,6 +376,12 @@ map_full_draw_count_forward_attributes:
        ld [tmp_map_far_left_door], a
        ld [tmp_map_far_right_door], a
 
+       ; clear nearby prop and act
+       ld [act_nearby], a
+       ld [act_nearby+1], a
+       ld [prop_nearby], a
+       ld [prop_nearby+1], a
+
        ld a, [player+act_pos_y]
        ld b, a
        ld a, [player+act_pos_x]
@@ -378,6 +410,8 @@ map_full_draw_count_forward_attributes:
 
        dec b ; move one tile back
        call map_get_tile
+       call map_write_nearby_act_prop
+
        map_full_draw_door_state TF_NE, TF_WE, TF_EE
        map_full_draw_write_door_state 3, 2, ret
        ret
@@ -387,6 +421,8 @@ map_full_draw_count_forward_attributes:
        
        inc b ; move one tile forward
        call map_get_tile
+       call map_write_nearby_act_prop
+
        map_full_draw_door_state TF_SE, TF_WE, TF_EE
        map_full_draw_write_door_state 3, 2, ret
        ret
@@ -396,6 +432,8 @@ map_full_draw_count_forward_attributes:
 
        inc c ; move one tile east
        call map_get_tile
+       call map_write_nearby_act_prop
+
        map_full_draw_door_state TF_EE, TF_NE, TF_SE
        map_full_draw_write_door_state 3, 2, ret
        ret
@@ -405,6 +443,8 @@ map_full_draw_count_forward_attributes:
 
        dec c ; move one tile west
        call map_get_tile
+       call map_write_nearby_act_prop
+
        map_full_draw_door_state TF_WE, TF_SE, TF_NE
        map_full_draw_write_door_state 3, 2, ret
        ret
index 8fcf163b77e31136008abe2da08897be1fb6ffdd..d79219b1bacfa75f07f796f371b9f810c37d8fb8 100644 (file)
@@ -130,3 +130,13 @@ tmp_map_near_left_door: .adv 1
 tmp_map_near_right_door: .adv 1
 tmp_map_far_left_door: .adv 1
 tmp_map_far_right_door: .adv 1
+       
+       ; actor that is adjacent
+       ; to the players current facing
+       ; direction
+       ; populated when map is drawn
+act_nearby: .adv 2
+       ; prop actor that is adjacent 
+       ; to the current players facing direction
+       ; populated when map is drawn
+prop_nearby: .adv 2