objanim: Added placeholder animation for when a door opens.
authorLukas Krickl <lukas@krickl.dev>
Fri, 8 Aug 2025 15:21:10 +0000 (17:21 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 8 Aug 2025 15:21:10 +0000 (17:21 +0200)
This serves as a proof of concept for obj animations.
Soon there should be proper opening sprites for doors in all directions.

src/defs.s
src/objanim.s

index b12ada45c80ad0db315cfdbbef7ab474b2de9ca1..a2a6990027800dd52198cf61f47704dd672e8364 100644 (file)
 .de obja_pos_y, 1
 .de obja_pos_x, 1
 .de obja_dat, 1
+       ; time in frames
+.de obja_timer, 1
 .de obja_size, 0
 
 ; special text commands
index 7775a55f46cf590a43d9a996fc26c8369a0b8185..ae697f3dcb9267ed6808b38aaa736967a6132d08 100644 (file)
@@ -15,20 +15,87 @@ objanim_init:
        ; inputs:
        ;               a: tile flags
        ;               b: tile index
+       ;        de: actor
 objanim_door_open:
+       push de
+       push bc
        ld de, st_objanim_door_open
        ld hl, objanim
        ld bc, st_size
        call memcpy
+       pop bc
+
+       pop de
+       ld hl, act_pos_y
+       add hl, de ; hl = act y pos
+
+
+       xor a, a
+       ld de, objanim+obja_flags       
+       ld [de], a
+       inc de ; de = y pos
+       
+       ld a, [hl+]
+       ld [de], a
+       inc de ; de = x pos
+
+       ld a, [hl]
+       ld [de], a
+       inc de ; de = dat
+       
+       ; dat = tile index
+       ld a, b
+       ld [de], a
+       inc de ; de = timer
+       
+       ; set timer
+       ld a, 0x40
+       ld [de], a
+
        ret
 
        ; state function for door opening animation
        ; inputs:
        ;               de: objanim
 objanim_door_open_fn:
-       BREAK
+       call load_unit_obj
+       ld de, objanim+st_size
+       call load_scroll
+
+       ; hl = oam ptr
+       ; de = anim flags 
+
+       inc de ; skip flags
+       ld a, [de] ; a = y position
+       inc de ; de = x postion
+       mul16 a
+       add a, OBJ_OFF_Y
+       sub a, b
+       ld [hl+], a
+
+       ld a, [de] ; a = x position
+       mul16 a
+       add a, OBJ_OFF_X
+       sub a, c
+       ld [hl+], a
+       
+       ld a, 0x80 
+       ld [hl+], a
+
+       xor a, a
+       ld [hl+], a  ; no flags
+
+       ld de, objanim+obja_timer
+       ld a, [de]
+       dec a
+       ld [de], a ; timer--
+       jr z, @timer_done REL
+
        ldnull bc
        ret
+@timer_done:   
+       ld bc, st_null
+       ret
 
 st_objanim_door_open:
-       st_def 0x08, objanim_door_open_fn, st_null 
+       st_def 0x00, objanim_door_open_fn, st_objanim_door_open