[ ] destroy doors -> fail may spawn enemy due to noise
[ ] Sometimes bribery fails
+## animations
+
+[ ] make table for each actor type where animations can be looked up
+ e.g. idle for each, walk left, walk right, walk up, walk down, attack etc
+
+[ ] allow sub tile movement by setting up a rt_st_x and _y value in each actor
+ this value will then be inc/dec in special move left, right, up, down wait states
+ this value will be added to the rendered object in unit_draw
player_anim_table:
+ anim_header 32, player_anim_table_f2
anim_ent 0, 8, 0x8C, OAM_FXFLIP
anim_ent 0, 0, 0x8E, OAM_FXFLIP
anim_ent 0, 0, 0x00, 0
- dw player_anim_table_f2
player_anim_table_f2:
+ anim_header 32, player_anim_table
anim_ent 1, 8, 0x8C, OAM_FXFLIP
anim_ent 1, 0, 0x8E, OAM_FXFLIP
anim_ent 0, 0, 0x00, 0
- dw player_anim_table
; translates tile to screen
; inputs:
pop af
ld l, a
push hl
- pop bc ; bc = anim talbe entry
+ pop bc
+ ; bc = animation header
+ push bc ; save header for later
+ inc bc
+ inc bc
+ inc bc ; go past header
+
+ ; bc = anim talbe entry
call unit_draw_obj
call unit_draw_obj
call unit_draw_obj
- ; load next anim table
- ; every few frames
- ld a, [frame_count]
- cp a, 4
- jr nz, @no_new_frame REL
+ ; process header
+ pop bc
- ld hl, act_anim_table
- add hl, de
- ld a, [bc]
- ld [hl+], a
- inc bc
- ld a, [bc]
- ld [hl], a
+ ld hl, act_rt_anim_timer
+ add hl, de ; hl = animation timer
+ ld a, [hl]
+ inc a
+ ld [hl], a ; timer++
+
+ push de
+ ld d, a ; d = current timer
+ ld a, [bc] ; a = expected timer
+ cp a, d ; next frame?
+ pop de
+ jr nz, @no_new_frame REL
+
+ ; if new frame: clear timer
+ xor a, a
+ ld [hl], a ; clear timer
+
+ inc bc ; bc = next animation ptr
+ ; load next table
+ ld hl, act_anim_table
+ add hl, de
+ ld a, [bc]
+ ld [hl+], a
+ inc bc
+ ld a, [bc]
+ ld [hl], a
@no_new_frame:
ret
; state switching may change this value.
.de act_rt_timer, 1
+ ; animation frame timer
+.de act_rt_anim_timer, 1
+
; stats1
.de act_level, 1
.de act_hp, stat_size
.de action_st_action_ptr, 2
.de action_size, 0
+ ; animation header
+.se 0
+.de anim_header_frame_time, 1
+.de anim_header_next, 2
+
; animation entry struct
-; an animation table is *always*
-; 3 entries followed by a next ptr
+; start with a header
+; an animation table *always* has
+; 3 entries
; if the tile is 0x00 the entry is not rendered
.se 0
.de anim_ent_y_offset, 1
; rt timer
.db 0
+ ; rt animation timer
+ .db 0
#endmacro
; defines an actor's stats (1/2)
sub a, c
ld b, a
#endmacro
+
+ ; animation header
+ ; inputs:
+ ; $1: frame time
+ ; $2: next frame ptr
+#macro anim_header
+ .db $1
+ dw $2
+#endmacro
; animation entry
; inputs:
unit_demo_guard_anim_table:
+ anim_header 0, unit_demo_guard_anim_table
anim_ent 0, 0, 0x88, 0
anim_ent 0, 8, 0x8A, 0
anim_ent 0, 0, 0x00, 0
- dw unit_demo_guard_anim_table
unit_demo_dog_anim_table:
+ anim_header 0, unit_demo_dog_anim_table
anim_ent 0, 0, 0x90, 0
anim_ent 0, 8, 0x92, 0
anim_ent 0, 0, 0x00, 0
- dw unit_demo_dog_anim_table
unit_demo_hazmat_anim_table:
+ anim_header 0, unit_demo_hazmat_anim_table
anim_ent 0, 0, 0x94, 0
anim_ent 0, 8, 0x96, 0
anim_ent 0, 0, 0x00, 0
- dw unit_demo_hazmat_anim_table
unit_demo_1_init:
ldnull bc