main:
@forever:
- jp @forever
+ ld a, [frame_ready]
+ cp a, 0
+ jr z, @forever REL
+ call update
+ xor a, a
+ ld [frame_ready], a
+ jr @forever REL
#include "tiles.inc"
#include "video.s"
#include "strings.s"
#include "sys.s"
#include "input.s"
+#include "player.s"
+#include "update.s"
; fill bank
.fill 0, 0x7FFF - $
--- /dev/null
+ ; update the player
+ ; players do not behave like regular actors
+ ; and are not allocate to the regular
+ ; actor table
+ ; inputs:
+ ; hl: pointer to player memory
+player_update:
+ ret
--- /dev/null
+ ; called after vblank
+update:
+ ld a, [frame_count]
+ inc a
+ ld [frame_count], a
+
+ ; update player
+ ld hl, player
+ call player_update
+
+ ret
; vblank handler
vblank:
+ ; dma previous frame's oam
call OAMDMAFN
+ ; get inputs
call poll_inputs
; test puts
ld de, SCRN0
call puts
-
+ ld a, 1
+ ld [frame_ready], a
ret
; wait for next vblank
shadow_oam: .adv OBJSMAX * oamsize
+frame_ready: .adv 1
+frame_count: .adv 1
+
#define ACTORS_MAX 16
; current frame's inputs
.de actor_size, 0
actor_table: .adv ACTORS_MAX * actor_size
+
+; struct player
+.se 0
+.de player_y, 1
+.de player_x, 1
+.de player_flags, 1
+.de player_size, 0
+
+player: .adv player_size