Prev: D036 Up: Map Next: D06C
D040: Update Vat: Event And Direction
Used by the routine at Update_Vat.
When the vat entity is not type 0C, test game-event / direction bits and either copy the Data_CrusherEntityTemplate template into the crusher slot or randomly set direction bit 00.
Load game-event flags and test direction bit 00.
Update_Vat_TestEventAndDirBit0 D040 LD A,($72B3) Load A with the game event flags (GameEventFlags).
D043 BIT 0,(IX+$09) Is bit 00 of the current entity's direction / state set?.
D047 JR Z,Update_Vat_RandomSetDirBit0 If not, jump to Update_Vat_RandomSetDirBit0.
D049 BIT 1,A Is bit 01 of A set?.
D04B RET Z If not, return.
D04C LD DE,$8FC9 Point DE at the crusher entity (StateData_Complex_16).
D04F LD HL,$D036 Point HL at the vat template (Data_CrusherEntityTemplate).
D052 LD BC,$000A Load BC with length 000A.
D055 LDIR Copy the template into the crusher entity slot.
D057 LD HL,$CF88 Point HL at DruttScript_Copy.
D05A JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Randomly set direction bit 00 when bit 01 of A is clear.
Update_Vat_RandomSetDirBit0 D05D BIT 1,A Is bit 01 of A set?.
D05F RET NZ If so, return.
D060 LD A,$3C Load A with 3C.
D062 CALL PseudoRandom Call PseudoRandom to pick a pseudo-random value.
D065 OR A Is A zero?.
D066 RET NZ If not, return.
D067 SET 0,(IX+$09) Set bit 00 of the current entity's direction / state.
D06B RET Return.
Prev: D036 Up: Map Next: D06C