--- /dev/null
+
+ ; sets up default actions for a new game
+ ; for button A and button B
+actions_new_game_init:
+ ; write default action ptrs
+ ld hl, action_btna
+
+ ; default A button action
+ ld a, st_action_attack HI
+ ld [hl+], a
+ ld a, st_action_attack LO
+ ld [hl+], a
+
+ ; default B button action
+ ld a, st_action_attack HI
+ ld [hl+], a
+ ld a, st_action_attack LO
+ ld [hl+], a
+
+ ret
+
+ ; handles an assinged action
+ ; a player can assign any in-game action to either A or B
+ ; inputs:
+ ; hl: action ptr (usually action btna or action btnb)
+ ; returns:
+ ; bc: next state
+unit_handle_assigned_action:
+ ; load state ptr for action
+ ld a, [hl+]
+ ld b, a
+ ld a, [hl]
+ ld c, a
+ ret
+
+ ; picks a direction for an attack
+ ; inputs:
+ ; de: unit
+ ; returns:
+ ; bc: next action
+unit_action_attack_pick_direction:
+ ldnull bc
+ ret
+
+ ; default attack state
+st_action_attack:
+ st_def 0x00, unit_action_attack_pick_direction, st_action_attack
; last collision with actor
; set during unit_collision_woth_any_other
.de act_rt_collided_with, 2
- ; indicates which order the actor has in battle mode
- ; the actors attack rotuine should wait until battle_order == their battle order
- ; and then perform an action
- ; battle order should also determine where the battle draw rotuine
- ; draws the actor
-.de act_rt_battle_order, 1
; sub-tile drawing vars
; during this animation the actor is already technically in its new
.de obja_timer, 1
.de obja_size, 0
-#define BR_MAX 4
- ; battle record
+ ; action struct
.se 0
-.de br_act_ptr, 2
-.de br_size, 0
-
+.de action_st_action_ptr, 2
+.de action_size, 0
; special text commands
.db 0 ; act_rt_sub_tile
; act_rt_loot_table_dat
dw 0
- ; battle order
- .db 0
#endmacro
; defines an actor's stats (1/2)
#include "actsave.s"
#include "objanim.s"
#include "battle.s"
+#include "action.s"
; fill bank
.fill 0xFF, 0x4000 - $
; push next state to the stack for now
ld bc, NULL
push bc
+
+ ld b, BTNA
+ input_just
+ ld hl, action_btna
+ jr z, @nota REL
+ pop bc
+ call unit_handle_assigned_action
+ push bc ; bc = next state
+@nota:
ld b, BTNUP
input_held
call ui_init
call unit_load_default_player
+ call actions_new_game_init
; init initial map
act_sg: .adv act_sg_size * UNITS_MAX * FLOOR_MAP_COUNT
act_sg_end:
-battle_records: .adv br_size * BR_MAX
- ; current battle number
- ; compate to act_rt_battle_order to see whose turn it is
-battle_order: .adv 1
+; buttton-assigned actions
+action_btna: .adv action_size
+action_btnb: .adv action_size
state_end: