--- /dev/null
+ ; draws a single object
+ ; for an actor accounting for scroll
+ ; inputs:
+ ; de: actor
+ ; hl: oam ptr
+ ; b: tile
+ ; c: oam flags
+ ; a: nnnn0000: y offset from actor pos;
+ ; 0000nnnn: x offset from actor pos
+ ; returns:
+ ; hl: next oam ptr (if reserved!)
+actor_draw:
+ ret
#include "rowpatterns.s"
#include "math.s"
#include "game.s"
+#include "actor.s"
#include "tiles.inc"
#include "text.s"
; to make bottom of scrn0 visible
ld a, 144
ld [scroll_y], a
+
+ call player_init
ret
; loads all tile banks
+ ; sets up the player actor
+player_init:
+ ; initial position
+ ld a, 232
+ ld [player+act_pos_y], a
+ ld a, 64
+ ld [player+act_pos_x], a
+ ret
+
+ ; updates the special player actor
+player_update:
+ ret
+
+#define PLAYER_SPRITE_IDLE1 0x8A
+
+ ; draws the special player actor
+player_draw:
+ ld a, 2
+ call oamalloc
+
+ ld de, player
+ ld b, PLAYER_SPRITE_IDLE1
+ ld c, 0
+ ld a, 0
+ call actor_draw
+
+ ret
; hl = function value
jp hl
- ; loads scroll into bc
- ; returns:
- ; b: scroll y
- ; c: scroll x
-load_scroll:
- ld a, [scroll_y]
- ld b, a ; b = scroll_y
- ld a, [scroll_x]
- ld c, a ; c = scroll_x
- ret
-
; loads unit sprite into hl
; increments unit sprite
+ ; inputs:
+ ; a: amount of objects to reserve
; returns;
; hl: current unit sprite
-load_oam_obj:
+oamalloc:
+ push af
ld a, [current_oam_obj]
add hl, de ; hl = next oam
; next object
- add a, oamsize
+ ld b, a
+ pop af
+ sla a
+ sla a ; * 4 to get oam size from requsted objs
+ add a, b ; current oam + input * 4
ld [current_oam_obj], a
ret
; resets unit obj
-reset_oam_obj:
+oamfree_all:
xor a, a
ld [current_oam_obj], a
ret
; clear oam
call shadow_oam_clear
+
+ call player_draw
+ call player_update
ret
ld [frame_count], a
; reset objects
- call reset_oam_obj
+ call oamfree_all
; load current sate routine
ld a, [game_state]
srand: .adv 2
-; units
-; player_unit (unit 0) is reserved
-player_unit: .adv 0
+player: .adv act_size
actors: .adv act_size * ACTS_MAX
map_objs: .adv mo_size * MAP_OBJ_MAX