Prev: D074 Up: Map Next: D1AC
D153: Script Routine: (43) 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 D153 BIT 2,(IX+$09) Is bit 02 of the current entity's direction / state set? If so, jump to ScriptRoutine_VatRoomTransition_ClearDirBit2.
D157 JR NZ,ScriptRoutine_VatRoomTransition_ClearDirBit2
D159 BIT 3,(IX+$09) Is bit 03 of the current entity's direction / state set? If not, jump to AdvanceScriptInstruction.
D15D JP Z,AdvanceScriptInstruction
D160 RES 3,(IX+$09) Reset bit 03 of the current entity's direction / state.
D164 LD A,(IX+$04) Load A with the current entity's room index.
D167 CP $01 Is the current entity's room index equal to 01? If so, jump to AdvanceScriptInstruction.
D169 JP Z,AdvanceScriptInstruction
D16C CALL Adjust_CameraY Call Adjust_CameraY to adjust the camera Y coordinate.
D16F JP NC,AdvanceScriptInstruction If Adjust_CameraY cleared carry, jump to AdvanceScriptInstruction to run the next script instruction.
D172 CALL Adjust_CameraX Call Adjust_CameraX to adjust the camera X coordinate.
D175 JR C,ScriptRoutine_VatRoomTransition_DecRoom Jump to ScriptRoutine_VatRoomTransition_DecRoom if the result underflowed.
D177 CP $1F Is the current entity's room index equal to 1F? If so, jump to AdvanceScriptInstruction.
D179 JP Z,AdvanceScriptInstruction
Complete a downward room transition: move the vat back one room.
ScriptRoutine_VatRoomTransition_DecRoom D17C LD DE,$0004 Load DE with entity-field offset 0004.
D17F ADD HL,DE Add the offset in DE to the pointer in HL.
D180 DEC (IX+$04) Move this entity back one room.
D183 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Clear direction bit 02 and try an upward room transition when not already in room 05.
ScriptRoutine_VatRoomTransition_ClearDirBit2 D186 RES 2,(IX+$09) Reset bit 02 of the current entity's direction / state.
D18A LD A,(IX+$04) Load A with the current entity's room index.
D18D CP $05 Is the current entity's room index equal to 05? If so, jump to AdvanceScriptInstruction.
D18F JP Z,AdvanceScriptInstruction
D192 CALL Test_EntityOverlap_AtDepth Call Test_EntityOverlap_AtDepth to test collectible / room collision.
D195 JP NC,AdvanceScriptInstruction If Test_EntityOverlap_AtDepth cleared carry, jump to AdvanceScriptInstruction to run the next script instruction.
D198 CALL Test_EntityOverlap Call Test_EntityOverlap to set Entity Attribute Byte.
D19B JR C,ScriptRoutine_VatRoomTransition_IncRoom Jump to ScriptRoutine_VatRoomTransition_IncRoom if the result underflowed.
D19D CP $1F Is the current entity's room index equal to 1F? If so, jump to AdvanceScriptInstruction.
D19F JP Z,AdvanceScriptInstruction
Complete an upward room transition: advance the vat into the next room.
ScriptRoutine_VatRoomTransition_IncRoom D1A2 LD DE,$0008 Load DE with 0008 as a field offset within an entity.
D1A5 ADD HL,DE Add the offset in DE to the pointer in HL.
D1A6 INC (IX+$04) Advance this entity into the next room.
D1A9 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Prev: D074 Up: Map Next: D1AC