objanim: Added left and right door opening animations
authorLukas Krickl <lukas@krickl.dev>
Wed, 13 Aug 2025 15:02:11 +0000 (17:02 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 13 Aug 2025 15:02:11 +0000 (17:02 +0200)
src/objanim.s

index 85ea0f4a951d1bb78bc70fb3f82b9e24f18a4fdf..459a8753ba1b8ac49b80904e5cf0aa4a2619846f 100644 (file)
@@ -178,7 +178,6 @@ objanim_door_open_left_fn:
 
        ; adjust x position based on timer
        ; offset position by counter 
-       sra a
        ld b, a
        ld a, [hl]
        sub a, b
@@ -195,7 +194,7 @@ objanim_door_open_left_fn:
        
        ; hl = obj2 y 
        ld a, [hl]
-       add a, b
+       sub a, b
        ; write adjusted obj2 y 
        ld [hl+], a
        inc hl ; skip obj2 x 
@@ -218,34 +217,40 @@ objanim_door_open_right_fn:
        pop af
        push bc ; save next state
        ; hl = oam ptr
-       inc hl ; skip obj1 y
 
        ; adjust x position based on timer
        ; offset position by counter 
-       sra a
        ld b, a
        ld a, [hl]
        sub a, b
-       ; wirte adjusted obj1 x 
+       ; wirte adjusted obj1 y 
        ld [hl+], a ; hl = obj1 tile
+       inc hl ; skip obj1 x 
 
-       inc hl ; skip obj1 tile
-       ld a, OAM_FYFLIP
+       ; adjust tile by 4 (next tile) and ++
+       ld a, DOOR_SPRITE_TILE + 6 
+       ld [hl+], a
+       
+       ld a, OAM_FXFLIP
        ld [hl+], a ; write obj1 flag and ++
-       inc hl ; skip obj2 y 
        
-       ; hl = obj2 x 
+       ; hl = obj2 y 
        ld a, [hl]
-       add a, b
-       ; write adjusted obj2 x
+       sub a, b
+       ; write adjusted obj2 y 
+       ld [hl+], a
+       inc hl ; skip obj2 x 
+       
+       ; adjust tile by 4 (next tile) and ++
+       ld a, DOOR_SPRITE_TILE + 4 
        ld [hl+], a
 
-       inc hl ; skip obj2 tile
-       ld a, OAM_FYFLIP ; write obj2 flag 
+       ld a, OAM_FXFLIP
        ld [hl], a
        
        pop bc ; restore next state
        ret
+
        ; state function for door opening animation
        ; is called by more specific functions that take this base setup
        ; and set the right tiles and animations after