actions: Added stub for action calling master origin/HEAD origin/master
authorLukas Krickl <lukas@krickl.dev>
Sun, 25 Jan 2026 13:54:27 +0000 (14:54 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 25 Jan 2026 13:54:27 +0000 (14:54 +0100)
src/action.s [new file with mode: 0644]
src/defs.s
src/main.s
src/player.s
src/wram.s

diff --git a/src/action.s b/src/action.s
new file mode 100644 (file)
index 0000000..b62f050
--- /dev/null
@@ -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
index dbc8f34a71e188470d7e767638849dcc8ee66011..61c72b79afd5f643b899bc9ad4cc22d912fe1077 100644 (file)
        ; the coordinates are fixed
 .de os_data, (OS_WIDTH * OS_HEIGHT)
 .de os_size, 0
+
index 189c04869f28b7057d5b5c0a0f894d53bb2fe4e8..414d82083783ac564a9a80ed98a19e1a553775ac 100644 (file)
@@ -71,6 +71,7 @@ main:
 #include "attributes.s"
 #include "item.s"
 #include "render.s"
+#include "action.s"
 
 #include "tiles.inc"
 #include "text.s"
index 0e1011604a068ea934e0b89a24450b119ae9dc7b..066b3a94d7a682595e7e3528dd9eb067e5628ef5 100644 (file)
@@ -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
index 8f0dfa603e2ce908cefa5d864c9a79e6196591aa..999d451cb7f9527679a973af60e70fdb48232b40 100644 (file)
@@ -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