objanim: Added setup code for object animations
authorLukas Krickl <lukas@krickl.dev>
Fri, 8 Aug 2025 13:10:27 +0000 (15:10 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 8 Aug 2025 13:10:27 +0000 (15:10 +0200)
src/objanim.s
src/player.s
src/update.s

index d13fca2946de6967d5ff7c8f6ab639f8220aacc5..7775a55f46cf590a43d9a996fc26c8369a0b8185 100644 (file)
@@ -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 
index 431c76abf8abc2ffb3d25c4fd9a2ff6d6eca7341..555d7ba2a21bed4b67e1b7aa60096cb9c72042ce 100644 (file)
@@ -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
index 64616b548a7eb5ab6b78e23fdec15998016dbaa9..70df9f9509de6fdb5194dc779780b97e211318b7 100644 (file)
@@ -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