Prev: 50536 Up: Map Next: 50678
50562: Script Routine: (46) 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 50562 LD A,(29445) Load A with Berk's room-index copy (BerkRoomIndexCopy).
50565 CP (IX+4) Is Berk in the same room as this entity (IX+4)? If not, jump to ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent.
50568 JR NZ,ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent
50570 LD BC,(49894) Load BC from 49894.
50574 LD A,(29444) Load A with Berk's X-extent copy (BerkXExtentCopy).
50577 CP B Is Berk's X-extent copy (BerkXExtentCopy) left of B? If so, jump to ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent.
50578 JR C,ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent
50580 LD A,(29443) Load A with Berk's X-coordinate copy (BerkXCoordinateCopy).
50583 CP C Is Berk's X-coordinate copy (BerkXCoordinateCopy) at or beyond C? If so, jump to ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent.
50584 JR NC,ScriptRoutine_TaskThreeBerkRightWindow_CheckCreatureXExtent
Resolve a door / interaction hit via Reposition_CameraFollowEntity, then advance the script.
TaskThree_DoorHitThenNextScript 50586 CALL Reposition_CameraFollowEntity Call Reposition_CameraFollowEntity to handle the door / interaction hit.
50589 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 50592 LD IY,36963 Point IY at the cauldron entity at StateData_Complex_27.
50596 LD A,(IX+4) Load A with the current entity's room index.
50599 CP (IX+4) Is Berk in the same room as this entity (IX+4)? If not, jump to AdvanceScriptInstruction.
50602 JP NZ,AdvanceScriptInstruction
50605 LD A,(IY+8) Load A with the referenced entity's x-extent.
50608 CP B Is the referenced entity's x-extent less than B? If so, jump to AdvanceScriptInstruction.
50609 JP C,AdvanceScriptInstruction
50612 CP C Is the referenced entity's x-extent at or beyond C? If not, jump to AdvanceScriptInstruction.
50613 JP NC,AdvanceScriptInstruction
50616 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 50618 LD IY,36963 Point IY at the cauldron entity at StateData_Complex_27.
50622 LD A,(IX+4) Load A with the current entity's room index.
50625 CP (IY+4) Does this entity share the referenced entity's room (IY+4)? If not, jump to AdvanceScriptInstruction.
50628 JP NZ,AdvanceScriptInstruction
50631 LD A,(IY+7) Load A with the referenced entity's x-coordinate.
50634 CP B Is the referenced entity's x at or beyond B? If not, jump to AdvanceScriptInstruction.
50635 JP NC,AdvanceScriptInstruction
50638 CP C Is the referenced entity's x less than C? If so, jump to AdvanceScriptInstruction.
50639 JP C,AdvanceScriptInstruction
Raise BoilEmUp / BoilEmUpLatch on TaskThreeFlags, swap in layout GraphicLayout_CauldronCooking, and bump the task-three timer.
ScriptRoutine_TaskThreeBerkRightWindow_SetFlagsAndLayout 50642 LD A,(29366) Load A with the task-three flags (TaskThreeFlags).
50645 BIT 7,A Is bit 7 of task-three flags set? If not, jump to AdvanceScriptInstruction.
50647 JP Z,AdvanceScriptInstruction
50650 SET 4,A Set BoilEmUp (bit 4 of TaskThreeFlags. cleared by Update_Stove. tested by 55591).
50652 SET 5,A Set BoilEmUpLatch (bit 5 of TaskThreeFlags. cleared by Update_Stove / 50074).
50654 LD (29366),A Set the task-three flags (TaskThreeFlags).
50657 LD BC,40821 Point BC at the cauldron cooking layout (GraphicLayout_CauldronCooking).
50660 LD (36973),BC Write the layout address into the cauldron entity (36973).
50664 LD A,(29379) Load A with the task-three timer (TaskThreeTimer).
50667 ADD A,50 Add 50 to the task-three timer in A.
50669 JP C,AdvanceScriptInstruction If that add overflowed (carry), jump to AdvanceScriptInstruction without storing.
50672 LD (29379),A Set the task-three timer (TaskThreeTimer).
50675 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Prev: 50536 Up: Map Next: 50678