Prev: C568 Up: Map Next: C5F6
C582: Script Routine: (2E) Task-three entity action
Run the task-three right-window encounter when Berk is at that window.
Input
IX Address of complex state data for an entity
ScriptRoutine_TaskThreeBerkRightWindow C582 LD A,($7305) Load A with Berk's room-index copy (BerkRoomIndexCopy).
C585 CP (IX+$04) Is Berk in the same room as this entity (IX+04)? If not, jump to ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent.
C588 JR NZ,ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent
C58A LD BC,($C2E6) Load BC from C2E6.
C58E LD A,($7304) Load A with Berk's X-extent copy (BerkXExtentCopy).
C591 CP B Is Berk's X-extent copy (BerkXExtentCopy) left of B? If so, jump to ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent.
C592 JR C,ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent
C594 LD A,($7303) Load A with Berk's X-coordinate copy (BerkXCoordinateCopy).
C597 CP C Is Berk's X-coordinate copy (BerkXCoordinateCopy) at or beyond C? If so, jump to ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent.
C598 JR NC,ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent
Resolve a door / interaction hit via Reposition_CameraFollowEntity, then advance the script.
TaskThree_DoorHitThenNextScript C59A CALL Reposition_CameraFollowEntity Call Reposition_CameraFollowEntity to handle the door / interaction hit.
C59D JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Right-window miss: only continue if the cauldron (StateData_Complex_27) overlaps the stored X window.
ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent C5A0 LD IY,$9063 Point IY at the cauldron entity at StateData_Complex_27.
C5A4 LD A,(IX+$04) Load A with the current entity's room index.
C5A7 CP (IX+$04) Is Berk in the same room as this entity (IX+04)? If not, jump to AdvanceScriptInstruction.
C5AA JP NZ,AdvanceScriptInstruction
C5AD LD A,(IY+$08) Load A with the referenced entity's x-extent.
C5B0 CP B Is the referenced entity's x-extent less than B? If so, jump to AdvanceScriptInstruction.
C5B1 JP C,AdvanceScriptInstruction
C5B4 CP C Is the referenced entity's x-extent at or beyond C? If not, jump to AdvanceScriptInstruction.
C5B5 JP NC,AdvanceScriptInstruction
C5B8 JR ScriptRoutine_TaskThreeBerkRightWindow_SetFlagsAndLayout Jump to ScriptRoutine_TaskThreeBerkRightWindow_SetFlagsAndLayout to continue this routine.
This entry point is used by the routine at ScriptRoutine_TaskThreeBerkLeftWindow.
Left-window miss: only continue if the cauldron (StateData_Complex_27) overlaps the stored X window.
ScriptRoutine_TaskThreeBerkLeftWindow_CheckCreatureX C5BA LD IY,$9063 Point IY at the cauldron entity at StateData_Complex_27.
C5BE LD A,(IX+$04) Load A with the current entity's room index.
C5C1 CP (IY+$04) Does this entity share the referenced entity's room (IY+04)? If not, jump to AdvanceScriptInstruction.
C5C4 JP NZ,AdvanceScriptInstruction
C5C7 LD A,(IY+$07) Load A with the referenced entity's x-coordinate.
C5CA CP B Is the referenced entity's x at or beyond B? If not, jump to AdvanceScriptInstruction.
C5CB JP NC,AdvanceScriptInstruction
C5CE CP C Is the referenced entity's x less than C? If so, jump to AdvanceScriptInstruction.
C5CF JP C,AdvanceScriptInstruction
Raise BoilEmUp / BoilEmUpLatch on TaskThreeFlags, swap in layout GraphicLayout_CauldronCooking, and bump the task-three timer.
ScriptRoutine_TaskThreeBerkRightWindow_SetFlagsAndLayout C5D2 LD A,($72B6) Load A with the task-three flags (TaskThreeFlags).
C5D5 BIT 7,A Is bit 07 of task-three flags set? If not, jump to AdvanceScriptInstruction.
C5D7 JP Z,AdvanceScriptInstruction
C5DA SET 4,A Set BoilEmUp (bit 04 of TaskThreeFlags. cleared by Update_Stove. tested by D927).
C5DC SET 5,A Set BoilEmUpLatch (bit 05 of TaskThreeFlags. cleared by Update_Stove / C39A).
C5DE LD ($72B6),A Set the task-three flags (TaskThreeFlags).
C5E1 LD BC,$9F75 Point BC at the cauldron cooking layout (GraphicLayout_CauldronCooking).
C5E4 LD ($906D),BC Write the layout address into the cauldron entity (906D).
C5E8 LD A,($72C3) Load A with the task-three timer (TaskThreeTimer).
C5EB ADD A,$32 Add 32 to the task-three timer in A.
C5ED JP C,AdvanceScriptInstruction If that add overflowed (carry), jump to AdvanceScriptInstruction without storing.
C5F0 LD ($72C3),A Set the task-three timer (TaskThreeTimer).
C5F3 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Prev: C568 Up: Map Next: C5F6