Prev: 53364 Up: Map Next: 53676
53587: Script Routine: (67) Vat action
Run the vat's room-transition sequence when its direction bit asks for it.
Input
IX Address of complex state data for an entity
ScriptRoutine_VatRoomTransition 53587 BIT 2,(IX+9) Is bit 2 of the current entity's direction / state set? If so, jump to ScriptRoutine_VatRoomTransition_ClearDirBit2.
53591 JR NZ,ScriptRoutine_VatRoomTransition_ClearDirBit2
53593 BIT 3,(IX+9) Is bit 3 of the current entity's direction / state set? If not, jump to AdvanceScriptInstruction.
53597 JP Z,AdvanceScriptInstruction
53600 RES 3,(IX+9) Reset bit 3 of the current entity's direction / state.
53604 LD A,(IX+4) Load A with the current entity's room index.
53607 CP 1 Is the current entity's room index equal to 1? If so, jump to AdvanceScriptInstruction.
53609 JP Z,AdvanceScriptInstruction
53612 CALL Adjust_CameraY Call Adjust_CameraY to adjust the camera Y coordinate.
53615 JP NC,AdvanceScriptInstruction If Adjust_CameraY cleared carry, jump to AdvanceScriptInstruction to run the next script instruction.
53618 CALL Adjust_CameraX Call Adjust_CameraX to adjust the camera X coordinate.
53621 JR C,ScriptRoutine_VatRoomTransition_DecRoom Jump to ScriptRoutine_VatRoomTransition_DecRoom if the result underflowed.
53623 CP 31 Is the current entity's room index equal to 31? If so, jump to AdvanceScriptInstruction.
53625 JP Z,AdvanceScriptInstruction
Complete a downward room transition: move the vat back one room.
ScriptRoutine_VatRoomTransition_DecRoom 53628 LD DE,4 Load DE with entity-field offset 0004.
53631 ADD HL,DE Add the offset in DE to the pointer in HL.
53632 DEC (IX+4) Move this entity back one room.
53635 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Clear direction bit 2 and try an upward room transition when not already in room 5.
ScriptRoutine_VatRoomTransition_ClearDirBit2 53638 RES 2,(IX+9) Reset bit 2 of the current entity's direction / state.
53642 LD A,(IX+4) Load A with the current entity's room index.
53645 CP 5 Is the current entity's room index equal to 5? If so, jump to AdvanceScriptInstruction.
53647 JP Z,AdvanceScriptInstruction
53650 CALL Test_EntityOverlap_AtDepth Call Test_EntityOverlap_AtDepth to test collectible / room collision.
53653 JP NC,AdvanceScriptInstruction If Test_EntityOverlap_AtDepth cleared carry, jump to AdvanceScriptInstruction to run the next script instruction.
53656 CALL Test_EntityOverlap Call Test_EntityOverlap to set Entity Attribute Byte.
53659 JR C,ScriptRoutine_VatRoomTransition_IncRoom Jump to ScriptRoutine_VatRoomTransition_IncRoom if the result underflowed.
53661 CP 31 Is the current entity's room index equal to 31? If so, jump to AdvanceScriptInstruction.
53663 JP Z,AdvanceScriptInstruction
Complete an upward room transition: advance the vat into the next room.
ScriptRoutine_VatRoomTransition_IncRoom 53666 LD DE,8 Load DE with 0008 as a field offset within an entity.
53669 ADD HL,DE Add the offset in DE to the pointer in HL.
53670 INC (IX+4) Advance this entity into the next room.
53673 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Prev: 53364 Up: Map Next: 53676