ld [hl+], a
+ ret
+
+ ; actor no-op call
+act_nop:
+ ret
+
+ ; tables for each actor type
+actor_update_draw_table:
+ dw act_nop
+ dw player_update_and_draw
+ dw act_guard_update_and_draw
+
+ ; calls update for all actors
+ ; and draws them
+actor_update_all:
+ ld de, actors
+ ld b, ACTS_MAX
+@loop:
+ ; look up rotuine from table
+ ld a, [de] ; a = type
+ add a, a ; * 2 for offset
+
+ push_all
+ ld b, 0
+ ld c, a ; bc = offset
+ ld hl, actor_update_draw_table
+ add hl, bc
+ ld a, [hl+]
+ ld b, a
+ ld a, [hl]
+ ld h, a
+ ld l, b
+
+ call_hl
+ pop_all
+
+ ; move to next actor
+ ld hl, act_size
+ add hl, de
+ push hl
+ pop de ; de = next act
+
+ dec b ; counter--
+ jr nz, @loop REL
+ ret
+
+ ; loads a test actor
+actor_load_test:
+ ld de, act_enemy_guard
+ ld hl, actors
+ ld bc, act_size
+ call memcpy
+
+ ; set a test position
+ ld a, 130
+ ld [actors+act_pos_y], a
+ ld [actors+act_pos_x], a
+
ret
--- /dev/null
+
+#define GUARD_SPRITE_IDLE1 0x88
+
+act_enemy_guard:
+ actdef ACT_T_GUARD, 0, 0, 10, 0
+
+ ; updates the guard enemy
+ ; inputs:
+ ; de: actor ptr
+act_guard_update:
+ ret
+
+ ; draws the guard enemy
+ ; inputs:
+ ; de: actor ptr
+act_guard_draw:
+ push de
+ ld a, 2
+ call oamalloc
+ pop de
+
+ push de
+ ld b, GUARD_SPRITE_IDLE1
+ ld c, 0
+ ld a, 0
+ call actor_draw
+ pop de
+
+ ld b, GUARD_SPRITE_IDLE1+2
+ ld c, 0
+ ld a, 8
+ call actor_draw
+ ret
+
+ ; combination of update and draw call
+act_guard_update_and_draw:
+ call act_guard_draw
+ jp act_guard_update
#include "sys.s"
#include "input.s"
#include "player.s"
+#include "enemy.s"
#include "update.s"
#include "ui.s"
#include "audio.s"
player_update:
ret
-#define PLAYER_SPRITE_IDLE1 0x88
+#define PLAYER_SPRITE_IDLE1 0x8D
; draws the special player actor
player_draw:
ld a, 8
call actor_draw
ret
+
+ ; combination of update and draw call
+player_update_and_draw:
+ call player_draw
+ jp player_update
call player_draw
call player_update
+
+ call actor_update_all
ret
ld de, l1_map
call map_load
+ call actor_load_test
+
ld hl, update_game
call game_set_state