Prev: 45019 Up: Map Next: 45085
45020: Script Routine: (27) Animate trap door / update Berk interaction
Animate the trap door for Drutt's current action and refresh Berk's interaction with it.
ScriptRoutine_AnimateTrapDoorBerk 45020 LD A,(29371) Load A with Drutt's animation counter (DruttAnimationCounter).
45023 OR A Is Drutt's animation counter (DruttAnimationCounter) zero? If not, jump to AdvanceScriptInstruction to run the next script instruction.
45024 JP NZ,AdvanceScriptInstruction
45027 LD A,12 Load A with sound index 12.
45029 CALL Queue_Sound Call Queue_Sound to queue a sound effect.
45032 LD IY,37005 Point IY at complex entity state StateData_Complex_30.
45036 DEC (IY+5) Move the referenced entity one character up.
45039 DEC (IY+6)
45042 LD A,(IY+6) Load A with the referenced entity's y-extent.
45045 CP 22 Is the y-extent still below the trap door open threshold 22? If not, jump to AnimateTrapDoor_ToggleFrame.
45047 JR NZ,AnimateTrapDoor_ToggleFrame
45049 CALL Reset_Trap_Door_Animation_State Call Reset_Trap_Door_Animation_State to reset trap door animation state.
45052 XOR A Clear the trap door flags.
45053 LD (29370),A Set the trap door flags (TrapDoorFlags).
45056 JR AnimateTrapDoor_SetLayoutB Jump to AnimateTrapDoor_SetLayoutB to handle the trap door.
Toggle the lever animation phase and choose open facing left (GraphicLayout_LeverOpenLeft) or closed facing left (GraphicLayout_LeverClosedLeft).
AnimateTrapDoor_ToggleFrame 45058 LD A,(29370) Load A with the trap door flags (TrapDoorFlags).
45061 XOR %00000001 Toggle the trap door animation phase bit in A.
45063 LD (29370),A Set the trap door flags (TrapDoorFlags).
45066 SRL A Shift the trap door animation phase bit into the success marker.
45068 JR NC,AnimateTrapDoor_SetLayoutB Jump to AnimateTrapDoor_SetLayoutB to handle the trap door if the result did not underflow.
45070 LD BC,43032 Point BC at the lever open, facing left (GraphicLayout_LeverOpenLeft).
45073 JR AnimateTrapDoor_WriteLayout Jump to AnimateTrapDoor_WriteLayout to handle the trap door.
Use the lever closed, facing left at GraphicLayout_LeverClosedLeft.
AnimateTrapDoor_SetLayoutB 45075 LD BC,43047 Point BC at the lever closed, facing left (GraphicLayout_LeverClosedLeft).
Install the chosen lever layout into Pointer_AnimatingSceneryLayout and continue the script.
AnimateTrapDoor_WriteLayout 45078 LD (37295),BC Store BC in the animating scenery layout pointer (Pointer_AnimatingSceneryLayout).
45082 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Prev: 45019 Up: Map Next: 45085