From: Lukas Krickl Date: Thu, 18 Dec 2025 05:47:52 +0000 (+0100) Subject: actor: Added act nearby and prop nearby X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=15158fc24bd97b3e323c666a5904103c96184271;p=gbrg%2F.git actor: Added act nearby and prop nearby Added stubs for updating and drawing actors --- diff --git a/src/actor.s b/src/actor.s index cb382a7..7745ca5 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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 diff --git a/src/levels.s b/src/levels.s index e5da4d7..2641081 100644 --- a/src/levels.s +++ b/src/levels.s @@ -11,6 +11,12 @@ 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 diff --git a/src/map.s b/src/map.s index 8f4360b..1ba296e 100644 --- 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 diff --git a/src/wram.s b/src/wram.s index 8fcf163..d79219b 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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