Prev: 39980 Up: Map Next: 40179
40142: Advance HL to next script instruction and execute
Input
IX Address of complex state data for an entity
Output
HL Current position in script data
AdvanceScriptInstruction 40142 INC HL Advance script data pointer by two bytes.
40143 INC HL
This entry point is used by the routines at 35367, 40529, 40545, 40557, 40574, 40586, 40603, 40615, 42057, 42664, 43054, 46449, 46765, 46857, 47309, 47412, 47632, 49469, 50215, 51598, 53120, 53252, 54462, 54952 and 55039.
ScriptInstruction 40144 INC HL Advance script data pointer by one byte.
40145 LD A,(HL) Load A with the byte at this location.
40146 DEC HL Move HL back one byte.
40147 OR A If byte loaded into A was zero (i.e. a script instruction) then skip ahead to ExecuteScript.
40148 JR Z,ExecuteScript
HL pointing to a graphic layout data address, rather than a script instruction.
40150 LD (28100),HL Store current position in script at CurrentScript.
40153 LD A,(HL) Load word at location HL into graphic layout address in current entity's complex state data entry (IX).
40154 LD (IX+2),A
40157 INC HL
40158 LD A,(HL)
40159 LD (IX+3),A
40162 RET Return.
HL pointing to a script instruction.
ExecuteScript 40163 LD A,(HL) Load A with script "instruction".
40164 PUSH HL Stash HL (pointer to current position in script data) on the stack.
40165 LD HL,39980 Point HL at TableScriptHandlers.
40168 ADD A,A Load BC with double index of script instruction and add as offset in HL to point to start address of required script routine.
40169 LD C,A
40170 LD B,0
40172 ADD HL,BC
40173 LD C,(HL) Load BC with address at this location.
40174 INC HL
40175 LD B,(HL)
40176 POP HL Restore HL (pointer to current position in script data) from the stack.
40177 PUSH BC Push address in BC onto stack and "return" to this address.
40178 RET
Prev: 39980 Up: Map Next: 40179