Prev: EB8C Up: Map Next: EC53
EC2E: Advance HL To Next Script Instruction And Execute
Used by the routines at ScriptRoutine_AnimateTrapDoorBerk, Update_Berk_ReadControls, Berk_ReadControls_DownBranch, Berk_Interact_With_Entity, Berk_Pick_Up_Entity, Update_ThingUpstairs_Entity_State, ScriptRoutine_ThingUpstairsRaise, ScriptRoutine_ThingUpstairsResetRoom, ScriptRoutine_ThingUpstairsFillAttributes, ScriptRoutine_ThingUpstairsChase, Update_TaskTwoEntityState, ScriptRoutine_TaskTwoArmScriptFlags, ScriptRoutine_TaskTwoWalkVertical, ScriptRoutine_TaskTwoRiseOnEvent, ScriptRoutine_TaskTwoWalkRight, ScriptRoutine_TaskTwoWalkHorizontal, ScriptRoutine_TaskTwoSpawnHelper, Update_Task_Three_Entity_State, ScriptRoutine_TaskThreeQueueSound, ScriptRoutine_TaskThreeSeekBerk, ScriptRoutine_TaskThreeClearUpstairs, ScriptRoutine_TaskThreeBerkRightWindow, ScriptRoutine_SlimyDropAndHeat, ScriptRoutine_ArmCauldronFlags, Update_TaskFourEntityState, ScriptRoutine_TaskFourAlignCreature, ScriptRoutine_TaskFourRandomiseExtra, ScriptRoutine_TaskFourStepToward, ScriptRoutine_TaskFourArmScriptFlags, ScriptRoutine_TaskFourTickOfferItem, ScriptRoutine_TaskFourRaiseY, ScriptRoutine_TaskFourLowerY, ScriptRoutine_TaskFourBerkOverlap, Update_Vat, ScriptRoutine_VatQueueSound, ScriptRoutine_VatRoomTransition, ScriptRoutine_VatDecY, ScriptRoutine_VatIncY, ScriptRoutine_VatClearBit6AndReset, Collect_Entity, ScriptRoutine_CollectibleScanCounter, ScriptRoutine_CollectibleSetHeld, ScriptRoutine_CollectibleIncRoomTwice, ScriptRoutine_CollectibleIncXIfClearAbove, ScriptRoutine_CollectibleDecXIfClearLeft, ScriptRoutine_CollectibleLeaveRoomDown, ScriptRoutine_CollectibleLeaveRoomUp, ScriptRoutine_EndScriptLoop, ScriptRoutine_BerkDoorInFront, ScriptRoutine_BerkDoorBehind, ScriptRoutine_CloseTrapDoor, ScriptRoutine_OpenTrapDoor, ScriptRoutine_MoveHeldUpOneRoom, ScriptRoutine_StartLoop, ScriptRoutine_ResetDirectionFlags, ScriptRoutine_FaceRight, ScriptRoutine_FaceLeft, ScriptRoutine_FaceUp, ScriptRoutine_FaceDown, ScriptRoutine_JumpIfCarrying, ScriptRoutine_MoveLeft, ScriptRoutine_MoveRight, ScriptRoutine_MoveUp, ScriptRoutine_MoveDown, ScriptRoutine_MoveLeftTwo, ScriptRoutine_MoveRightTwo, ScriptRoutine_MoveDownTwo, ScriptRoutine_MoveUpTwo, ScriptRoutine_PutDownCarried, ScriptRoutine_PickUpHeld, ScriptRoutine_FaceLeftAfterPutDown, ScriptRoutine_FaceRightAfterPutDown, ScriptRoutine_PlacePutDownLeft, ScriptRoutine_PlacePutDownRight, ScriptRoutine_StartDruttScript and ScriptRoutine_ContinueToNextInstruction.
Advance the script pointer by two bytes and execute the instruction at HL. A zero high byte means a script opcode (dispatched via TableScriptHandlers); otherwise the word is a graphic layout address stored into the entity at IX.
Input
IX Address of complex state data for an entity
Output
HL Current position in script data
AdvanceScriptInstruction EC2E INC HL Advance HL to the next script instruction.
EC2F INC HL
ScriptInstruction EC30 INC HL Advance HL to the next script byte.
EC31 LD A,(HL) Load A from *HL.
EC32 DEC HL Step HL back one byte in the current data stream.
EC33 OR A Is A zero? If so, jump to ExecuteScript to dispatch the script opcode.
EC34 JR Z,ExecuteScript
EC36 LD ($72CF),HL Store HL in the active script cursor (Pointer_ActiveScriptCursor).
EC39 LD A,(HL) Load A from *HL.
EC3A LD (IX+$0A),A Set the current entity's graphic layout address (low).
EC3D INC HL Advance HL to the next script byte.
EC3E LD A,(HL) Load A from *HL.
EC3F LD (IX+$0B),A Set the current entity's graphic layout address (high).
EC42 RET Return.
Dispatch the script opcode in the low byte at HL via TableScriptHandlers.
ExecuteScript EC43 LD A,(HL) Load A from *HL.
EC44 PUSH HL Stash HL on the stack.
EC45 LD HL,$EB8C Point HL at the script handler table (TableScriptHandlers).
EC48 ADD A,A Double A to form a word index into the script/handler table.
EC49 LD C,A Keep the index in C.
EC4A LD B,$00 Load B with 00.
EC4C ADD HL,BC HL+=BC.
EC4D LD C,(HL) Fetch the word at HL into BC.
EC4E INC HL
EC4F LD B,(HL)
EC50 POP HL Restore HL from the stack.
EC51 PUSH BC Stash BC on the stack.
EC52 RET Return.
Prev: EB8C Up: Map Next: EC53