Prev: CE8F Up: Map Next: CEDE
CEB8: Process Script Command With Counter
Processes a character script command, tracking how many commands have been executed. If the counter limit is reached, the script is terminated.
Input
A Counter value (maximum number of commands to process)
ProcessScriptCommandWithCounter CEB8 LD HL,$CC0B Increment the script command counter.
CEBB INC (HL)
CEBC CALL GetCurrentScriptState Get the current script state (command byte and position).
CEBF CALL AdvanceScriptPointerByCommandSize Call AdvanceScriptPointerByCommandSize to advance past this script command.
CEC2 BIT 4,(IX+$00) Jump to ProcessScriptCommandWithCounter_UpdatePosition if a marker on the record's flag byte is clear.
CEC6 JR Z,ProcessScriptCommandWithCounter_UpdatePosition
CEC8 LD E,(HL) Read the command's address into HL.
CEC9 INC HL
CECA LD D,(HL)
CECB EX DE,HL
ProcessScriptCommandWithCounter_UpdatePosition CECC LD (IY+$01),L Update the character's script position pointer (IY+01/02).
CECF LD (IY+$02),H Store H at IY+02.
CED2 PUSH IX Calculate how many bytes have been processed in the script (HL-IX).
CED4 POP DE
CED5 AND A
CED6 SBC HL,DE
CED8 JP Z,TerminateCharacterScript Go to TerminateCharacterScript if the subtraction comes out at zero.
CEDB JP DispatchCharacterScript Another command remains, so parse it from DispatchCharacterScript.
Prev: CE8F Up: Map Next: CEDE