objanim: the animation now overwrites player rt special flags
authorLukas Krickl <lukas@krickl.dev>
Sun, 10 Aug 2025 06:47:07 +0000 (08:47 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 10 Aug 2025 06:47:07 +0000 (08:47 +0200)
This makes it so the room is only uncovered when the animation finishes.

src/objanim.s
src/player.s

index eaa0f0059177d7dcc7a347f167e37c53d16b321d..ffd3b800f1ceda925253d1f89bb9a2054bb2dfed 100644 (file)
@@ -16,6 +16,7 @@ objanim_init:
        ; inputs:
        ;               a: tile flags
        ;               b: tile index
+       ;         c: previous player rt special flags
        ;        de: actor
 objanim_door_open:
        push de
@@ -29,9 +30,10 @@ objanim_door_open:
        pop de
        ld hl, act_pos_y
        add hl, de ; hl = act y pos
-
-
-       xor a, a
+       
+       ; save palyer rt flags in flags
+       ; but invert CF_COVERED
+       ld a, c 
        ld de, objanim+obja_flags       
        ld [de], a
        inc de ; de = y pos
@@ -66,6 +68,7 @@ objanim_door_open:
 objanim_door_open_fn:
 #define TMP_Y, scratch
 #define TMP_X, scratch+1
+       
 
        call load_unit_obj
        ld de, objanim+st_size
@@ -75,6 +78,9 @@ objanim_door_open_fn:
        ; de = anim flags 
        
        ; set first object
+       ; reload rt flags from backup while the animation is playing
+       ld a, [de]
+       ld [player_rt_special_flags], a
        inc de ; skip flags
        ld a, [de] ; a = y position
        inc de ; de = x postion
index 555d7ba2a21bed4b67e1b7aa60096cb9c72042ce..101244f6f21857b7c2b5ee1bc4cf072cab5cb573 100644 (file)
@@ -38,6 +38,7 @@ unit_player_update:
        and a, CF_COVERED
        ld b, a
        ld a, [player_rt_special_flags]
+       ld c, a ; remove door might needs this in c
        and a, (~CF_COVERED) & 0xFF
        or a, b
        ld [player_rt_special_flags], a