From e90eb291599bdcaac826faf1769fd5148d27ebcf Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 12 Aug 2025 18:23:20 +0200 Subject: [PATCH] objanim: Added simple animation for down door opening. This now just needs to be made more generic for the other directions. --- src/objanim.s | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/objanim.s b/src/objanim.s index 34bb5ab..516c756 100644 --- a/src/objanim.s +++ b/src/objanim.s @@ -49,8 +49,8 @@ objanim_door_open: ld [de], a inc de ; de = timer - ; set timer - ld a, 0x40 + ; clear frame counter + xor a, a ld [de], a ; set gameplay flag to pause object updates @@ -85,8 +85,16 @@ objanim_door_open_down_fn: ld a, [de] ; a = x position tile_to_scrn OBJ_OFF_X, c - ld [hl+], a ld [TMP_X], a + ; offset position by counter + push af + ld a, [objanim+obja_timer] + sra a + ld b, a + pop af + sub a, b + ld [hl+], a + ; door tile ld a, DOOR_SPRITE_TILE @@ -106,6 +114,13 @@ objanim_door_open_down_fn: ; set x pos ld a, [TMP_X] add a, 8 ; move over a tile + ; offset position by counter + push af + ld a, [objanim+obja_timer] + sra a + ld b, a + pop af + add a, b ld [hl+], a ; tile @@ -117,10 +132,10 @@ objanim_door_open_down_fn: ld [hl], a ; check if we are done - ld de, objanim+obja_timer - ld a, [de] - dec a - ld [de], a ; timer-- + ld a, [objanim+obja_timer] + inc a + ld [objanim+obja_timer], a ; frame counter++ + cp a, 0x10 ; end frame? jr z, @timer_done REL ldnull bc -- 2.30.2