From: Lukas Krickl Date: Sat, 21 Feb 2026 06:25:07 +0000 (+0100) Subject: player: targeting now is done by pressing the select button X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;ds=inline;p=gbrg%2F.git player: targeting now is done by pressing the select button --- diff --git a/src/player.s b/src/player.s index 6b7517f..1305d32 100644 --- a/src/player.s +++ b/src/player.s @@ -192,6 +192,37 @@ player_do_action_b: ld l, a jp action_exec + ; y/x coordinates for target update +_player_update_target_coords: + .db 0, -1 + .db -1, 0 + .db 0, 1 + .db 1, 0 + + ; rotates the current target +player_update_target: + ld a, [player_target_index] + inc a + and a, 3 ; there are only 4 directions + ld [player_target_index], a + + add a, a ; *2 to get 2 byte offset + + ld hl, _player_update_target_coords + ld d, 0 + ld e, a + add hl, de + + ; y pos + ld a, [hl+] + ld [player_target_y], a + ld a, [hl] + + ; x pos + ld [player_target_x], a + ret + + ; moves the player ; does not move out of bounds ; based on the last queued input @@ -208,10 +239,13 @@ player_handle_move: call player_do_action_b @not_action_b: + ld b, BTNSELECT + input_just + call nz, player_update_target + ld b, DIRLEFT input_held jr z, @not_left REL - _player_set_target 0, -1 ld a, [player+act_pos_x] dec a @@ -232,7 +266,6 @@ player_handle_move: ld b, DIRRIGHT input_held jr z, @not_right REL - _player_set_target 0, 1 ld a, [player+act_pos_x] inc a @@ -252,7 +285,6 @@ player_handle_move: ld b, DIRUP input_held jr z, @not_up REL - _player_set_target -1, 0 ld a, [player+act_pos_y] dec a @@ -274,7 +306,6 @@ player_handle_move: ld b, DIRDOWN input_held jr z, @not_down REL - _player_set_target 1, 0 ld a, [player+act_pos_y] inc a diff --git a/src/wram.s b/src/wram.s index 27ed876..bdf805d 100644 --- a/src/wram.s +++ b/src/wram.s @@ -101,6 +101,8 @@ player_viewradius: .adv 1 player_target_y: .adv 1 player_target_x: .adv 1 +player_target_index: .adv 1 + ; ptrs to actions on a or b button player_action_a: .adv 2 player_action_b: .adv 2