From: Lukas Krickl Date: Sun, 25 Jan 2026 13:54:27 +0000 (+0100) Subject: actions: Added stub for action calling X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;ds=inline;p=gbrg%2F.git actions: Added stub for action calling --- diff --git a/src/action.s b/src/action.s new file mode 100644 index 0000000..b62f050 --- /dev/null +++ b/src/action.s @@ -0,0 +1,25 @@ + ; actions always originate from an actor + ; and target a tile + ; inputs: + ; de: actor + ; bc: target y/x + + ; runs an action + ; inputs: + ; hl: action ptr + ; de: actor + ; bc: target tile y/x +action_exec: + jp hl + + +action_table: +dw action_attack + + ; performs an attack action + ; inputs: + ; de: actor + ; bc: target tile +action_attack: + BREAK + ret diff --git a/src/defs.s b/src/defs.s index dbc8f34..61c72b7 100644 --- a/src/defs.s +++ b/src/defs.s @@ -315,3 +315,4 @@ ; the coordinates are fixed .de os_data, (OS_WIDTH * OS_HEIGHT) .de os_size, 0 + diff --git a/src/main.s b/src/main.s index 189c048..414d820 100644 --- a/src/main.s +++ b/src/main.s @@ -71,6 +71,7 @@ main: #include "attributes.s" #include "item.s" #include "render.s" +#include "action.s" #include "tiles.inc" #include "text.s" diff --git a/src/player.s b/src/player.s index 0e10116..066b3a9 100644 --- a/src/player.s +++ b/src/player.s @@ -72,6 +72,15 @@ player_init: ld [player+act_hp+1], a _player_set_target -1, 0 + + ; set default actions + ld a, action_attack HI + ld [player_action_a], a + ld [player_action_b], a + + ld a, action_attack LO + ld [player_action_a+1], a + ld [player_action_b+1], a ret @@ -163,12 +172,16 @@ player_load_target_tile: ret - ; player attack call -player_attack: + ; player perform action a +player_do_action_a: call player_load_target_tile call map_get_tile - ret + ld a, [player_action_a] + ld h, a + ld a, [player_action_a+1] + ld l, a + jp action_exec ; moves the player ; does not move out of bounds @@ -178,7 +191,7 @@ player_handle_move: input_just jr z, @not_attack REL ld de, player - call player_attack + call player_do_action_a @not_attack: ld b, DIRLEFT diff --git a/src/wram.s b/src/wram.s index 8f0dfa6..999d451 100644 --- a/src/wram.s +++ b/src/wram.s @@ -101,6 +101,10 @@ player_viewradius: .adv 1 player_target_y: .adv 1 player_target_x: .adv 1 + ; ptrs to actions on a or b button +player_action_a: .adv 2 +player_action_b: .adv 2 + actors: player: .adv act_size map_actors: .adv act_size * ACT_MAX