From 31100addb29d2dacaf5d518cf77d8690dba30a1f Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 8 Aug 2025 15:10:27 +0200 Subject: [PATCH] objanim: Added setup code for object animations --- src/objanim.s | 30 ++++++++++++++++++++++++++++++ src/player.s | 7 +++++++ src/update.s | 4 ++++ 3 files changed, 41 insertions(+) diff --git a/src/objanim.s b/src/objanim.s index d13fca2..7775a55 100644 --- a/src/objanim.s +++ b/src/objanim.s @@ -1,4 +1,34 @@ ; sets up object animation state objanim_init: + ld de, st_null + ld hl, objanim + ld bc, st_size + call memcpy + + ret + + ; sets objanim to display a door + ; opening animation. + ; decides which animation to play based on the tile inex + ; supplied. + ; inputs: + ; a: tile flags + ; b: tile index +objanim_door_open: + ld de, st_objanim_door_open + ld hl, objanim + ld bc, st_size + call memcpy ret + + ; state function for door opening animation + ; inputs: + ; de: objanim +objanim_door_open_fn: + BREAK + ldnull bc + ret + +st_objanim_door_open: + st_def 0x08, objanim_door_open_fn, st_null diff --git a/src/player.s b/src/player.s index 431c76a..555d7ba 100644 --- a/src/player.s +++ b/src/player.s @@ -74,7 +74,14 @@ unit_player_update: ; inputs: ; de: actor ; hl: ptr to tile player is on + ; b: tile index + ; a: tile flags unit_player_remove_door: + ; schedule animation + push_all + call objanim_door_open + pop_all + ; remove door tile, door flag ; and redraw map ld a, 0x48 ; roof tile diff --git a/src/update.s b/src/update.s index 64616b5..70df9f9 100644 --- a/src/update.s +++ b/src/update.s @@ -16,6 +16,10 @@ update_game: ld hl, p0_units call units_update + ; play obj animation + ld de, objanim + call st_update + ldnull bc ret -- 2.30.2