player: disabled rendering while door animation is playing
authorLukas Krickl <lukas@krickl.dev>
Sun, 10 Aug 2025 09:24:25 +0000 (11:24 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 10 Aug 2025 09:24:25 +0000 (11:24 +0200)
src/objanim.s
src/player.s
src/unit.s

index ffd3b800f1ceda925253d1f89bb9a2054bb2dfed..acd2e8bda0e18cf2be48d9befa048c8cad2e1676 100644 (file)
@@ -60,6 +60,11 @@ objanim_door_open:
        or a, GPF_PAUSE_UPDATE
        ld [gameplay_flags], a
 
+       ; prevent player from drawing
+       ld de, player_unit
+       ld bc, unit_nop_draw
+       call unit_set_draw
+
        ret
 
        ; state function for door opening animation
@@ -130,12 +135,18 @@ objanim_door_open_fn:
        ldnull bc
        ret
 @timer_done:
-       ld bc, st_null
 
        ; unset pause object update
        ld a, [gameplay_flags]
        and a, ~GPF_PAUSE_UPDATE & 0xFF
        ld [gameplay_flags], a
+
+       ; restore player draw call
+       ld de, player_unit
+       ld bc, player_draw
+       call unit_set_draw
+
+       ld bc, st_null
        ret
 #undefine TMP_X
 #undefine TMP_Y
index 00e4e44a0b4ff89ac29fe863a711244cc582b18a..463963fe8f6d7cddad3054d4b3fd66a653cb141d 100644 (file)
@@ -70,15 +70,16 @@ unit_player_update:
        ; and skip inputs
        ; load next state in case this ret is hit
        pop af
-       ldnull bc 
-       ret nz
+       jr nz, @early_ret REL
 
   push de
   call unit_handle_inputs
   pop de
 
   ret
+@early_ret:
+       ldnull bc
+       ret
        
        ; removes the door tile the player is currently
        ; standing on
@@ -260,6 +261,7 @@ map_exit_relative_adjust:
   pop_all
   ret
 
+#define player_draw unit_draw
 
 unit_player:
   st_def 0x00, unit_player_init, st_unit_idle
@@ -267,7 +269,7 @@ unit_player:
   act_stat_def1 1, 1, 1, 1
   act_stat_def2 1, 1, 90, 1 
   act_st_def NULL, NULL, st_unit_player_update, st_unit_idle
-  act_def_meta unit_draw, 0x8C, OAM_FPRIO, NULL
+  act_def_meta player_draw, 0x8C, OAM_FPRIO, NULL
 
 st_unit_player_update:
   st_def 0x00, unit_player_update, st_unit_player_update 
index 81480116814f0009e2db8b188057f2d6da4774b3..ffe8d6f5e6369c9dd9db9778caa90a7957f50af4 100644 (file)
@@ -143,7 +143,7 @@ unit_generic_draw_adjust_subtile:
   pop hl ; hl = obj
   ld b, a ; b = rt_sub_tile value
   cp a, 0
-  ; if this value is 0 we are not movin
+  ; if this value is 0 we are not moving
   jp z, @done 
 
   ld a, [de] ; load timer
@@ -198,6 +198,11 @@ unit_generic_draw_adjust_subtile:
   add a, $1 
   sub a, $2 
 #endmacro
+       
+       ; performs no drawing
+unit_nop_draw:
+       ldnull bc
+       ret
 
   ; draws any unit
   ; inputs:
@@ -753,6 +758,20 @@ unit_get_inventory:
   ;    a: equipment length
 unit_get_equipment:
   ret
+       
+       ; sets a draw routine for a unit
+       ; inputs:
+       ;               de: unit
+       ;               bc: draw routine
+unit_set_draw:
+       ld hl, act_draw
+       add hl, de
+       ; hl = draw ptr
+       ld a, c 
+       ld [hl+], a
+       ld a, b 
+       ld [hl], a
+       ret
 
 st_unit_idle:
   st_def 0x00, unit_idle, st_unit_idle