+#define DOOR_SPRITE_TILE 0x80
; sets up object animation state
objanim_init:
; inputs:
; de: objanim
objanim_door_open_fn:
+#define TMP_Y, scratch
+#define TMP_X, scratch+1
+
call load_unit_obj
ld de, objanim+st_size
call load_scroll
; hl = oam ptr
; de = anim flags
-
+
+ ; set first object
inc de ; skip flags
ld a, [de] ; a = y position
inc de ; de = x postion
tile_to_scrn OBJ_OFF_Y, b
ld [hl+], a
+ ld [TMP_Y], a
ld a, [de] ; a = x position
- tile_to_scrn OBJ_OFF_X, b
+ tile_to_scrn OBJ_OFF_X, c
ld [hl+], a
+ ld [TMP_X], a
- ld a, 0x80
+ ; door tile
+ ld a, DOOR_SPRITE_TILE
ld [hl+], a
xor a, a
ld [de], a ; timer--
jr z, @timer_done REL
+ ; set up second object
+ call load_unit_obj
+
+ ; set y pos
+ ld a, [TMP_Y]
+ ld [hl+], a
+
+ ; set x pos
+ ld a, [TMP_X]
+ add a, 8 ; move over a tile
+ ld [hl+], a
+
+ ; tile
+ ld a, DOOR_SPRITE_TILE+1
+ ld [hl+], a
+
+ ; flags
+ xor a, a
+ ld [hl], a
+
+
ldnull bc
ret
@timer_done:
ld bc, st_null
ret
+#undefine TMP_X
+#undefine TMP_Y
st_objanim_door_open:
st_def 0x00, objanim_door_open_fn, st_objanim_door_open