![]() |
Routines |
| Prev: CC78 | Up: Map | Next: CD8B |
|
Used by the routine at ProcessScriptCommandWithCounter.
Gets the character's script position and dispatches the next command.
|
||||
| DispatchCharacterScript | CC82 | LD L,(IY+$01) | Get the character's script position. | |
| CC85 | LD H,(IY+$02) | |||
| CC88 | XOR A | Clear the display. | ||
| CC89 | LD ($B934),A | |||
| CC8C | LD A,($CC0B) | Jump to TerminateCharacterScript if the script command counter at CC0B is 0A. | ||
| CC8F | CP $0A | |||
| CC91 | JP Z,TerminateCharacterScript | |||
| DispatchCharacterScript_NextByte | CC94 | LD A,(HL) | Jump ahead to DispatchCharacterScript_UseCommand if this byte is not zero. | |
| CC95 | AND A | |||
| CC96 | JR NZ,DispatchCharacterScript_UseCommand | |||
| CC98 | INC HL | Jump back to DispatchCharacterScript_NextByte to find next command. | ||
| CC99 | JR DispatchCharacterScript_NextByte | |||
|
Use the saved pointer as the character record, then record the pointer in the currently processed character command position at CurrentCharacter_CommandPosition, then keep bits 0-3.
Process the current script command.
|
||||
| DispatchCharacterScript_UseCommand | CC9B | PUSH HL | Record the current character command position. | |
| CC9C | POP IX | |||
| CC9E | LD ($9FD9),HL | |||
| CCA1 | AND %00001111 | Keep the script command number (the low nibble). | ||
| CCA3 | CP $0A | Jump to DispatchCharacterScript_TestGoto when the command is at least 0A. | ||
| CCA5 | JR NC,DispatchCharacterScript_TestGoto | |||
| CCA7 | LD A,($CC0D) | Go to DispatchCharacterScript_DispatchOpcode unless the display-list flag at CC0D is 01. | ||
| CCAA | CP $01 | |||
| CCAC | JR NZ,DispatchCharacterScript_DispatchOpcode | |||
| CCAE | SUB A | Clear the display-list flag at CC0D. | ||
| CCAF | LD ($CC0D),A | |||
|
The room display asked to skip?
|
||||
| CCB2 | LD A,(HL) | Read this script byte, call ProcessScriptDisplay, and jump to CD91 if it returns carry. | ||
| CCB3 | CALL ProcessScriptDisplay | |||
| CCB6 | JP C,$CD91 | |||
| CCB9 | JR Z,DispatchCharacterScript_DispatchOpcode | Go to DispatchCharacterScript_DispatchOpcode if ProcessScriptDisplay returns zero. | ||
|
Did ProcessDisplayAction accept this display?
|
||||
| CCBB | CALL ProcessDisplayAction | Return if ProcessDisplayAction does not accept this display. | ||
| CCBE | RET NC | |||
| CCBF | CALL FindCharacterScriptEntry | Call FindCharacterScriptEntry to find the character script, then write 02 into the object attribute. | ||
| CCC2 | LD (IX+$05),$02 | |||
| CCC6 | RET | Return. | ||
|
Reads one command byte from the character script and dispatches it. Command 07 refreshes the room display.
|
||||
| DispatchCharacterScript_DispatchOpcode | CCC7 | LD A,(HL) | Get the command byte. | |
| CCC8 | AND %00001111 | Extract the command type. | ||
| CCCA | CP $07 | Jump ahead to HandleRoomDisplay when the command is 07. | ||
| CCCC | JP Z,HandleRoomDisplay | |||
| CCCF | CP $06 | Jump ahead to PrintCommandMessage when the command is 06. | ||
| CCD1 | JP Z,PrintCommandMessage | |||
| CCD4 | CP $05 | Jump ahead to ShowRoomDescription when the command is 05. | ||
| CCD6 | JP Z,ShowRoomDescription | |||
| CCD9 | CP $04 | Jump ahead to CDBF when the command is 04. | ||
| CCDB | JP Z,$CDBF | |||
| CCDE | CP $01 | Jump ahead to RunSimpleAction when the command is 01. | ||
| CCE0 | JP Z,RunSimpleAction | |||
| CCE3 | CP $03 | Jump ahead to ClearRoomDisplayParameters when the command is 03. | ||
| CCE5 | JP Z,ClearRoomDisplayParameters | |||
| CCE8 | CP $08 | Jump ahead to DispatchCharacterScript_Push when the command is 08. | ||
| CCEA | JR Z,DispatchCharacterScript_Push | |||
| CCEC | CP $09 | Jump ahead to DispatchCharacterScript_Pop when the command is 09. | ||
| CCEE | JR Z,DispatchCharacterScript_Pop | |||
| CCF0 | JP $CE18 | Jump ahead to CE18 to handle display room description. | ||
|
Handles command Type 0E/0C/0B/0A.
|
||||
| DispatchCharacterScript_TestGoto | CCF3 | CP $0E | Jump to DispatchCharacterScript_TestStop when the command is not 0E. | |
| CCF5 | JR NZ,DispatchCharacterScript_TestStop | |||
| CCF7 | LD A,(IX+$01) | Copy IX+01 into IY+01. | ||
| CCFA | LD (IY+$01),A | |||
| CCFD | LD A,(IX+$02) | Copy the script position into the character record and parse again from DispatchCharacterScript. | ||
| CD00 | LD (IY+$02),A | |||
| CD03 | JP DispatchCharacterScript | |||
|
Command 0C repeats, and command 0B copies the script pointer, returning when it is 02.
|
||||
| DispatchCharacterScript_TestStop | CD06 | CP $0C | See whether the command is 0C. | |
| DispatchCharacterScript_0 | CD08 | JR Z,DispatchCharacterScript_0 | Jump back to DispatchCharacterScript_0 if the command is 0C. | |
| CD0A | CP $0B | Jump to DispatchCharacterScript_TestNested when the command is not 0B. | ||
| CD0C | JR NZ,DispatchCharacterScript_TestNested | |||
| CD0E | CALL GetScriptPointer | Call GetScriptPointer and return when it reports 02. | ||
| CD11 | CP $02 | |||
| CD13 | RET Z | |||
| CD14 | JP ContinueScriptExecution | Jump ahead to ContinueScriptExecution to resume script execution. | ||
|
Command 10 copies it is 2.
|
||||
| DispatchCharacterScript_TestNested | CD17 | CP $0A | Jump to DispatchCharacterScript_MarkError when the command is not 0A. | |
| CD19 | JR NZ,DispatchCharacterScript_MarkError | |||
| CD1B | CALL GetScriptPointer | Call GetScriptPointer and return when it reports 02. | ||
| CD1E | CP $02 | |||
| CD20 | RET Z | |||
| CD21 | JP ProcessScriptCommandWithCounter | Jump ahead to ProcessScriptCommandWithCounter to run script command with counter. | ||
|
Handles push Stack.
|
||||
| DispatchCharacterScript_Push | CD24 | LD A,(IX+$01) | Read the moved marker and use 02 for the record, then call AllocateMemory to allocate memory. | |
| CD27 | PUSH AF | |||
| CD28 | LD A,$02 | |||
| CD2A | CALL AllocateMemory | |||
| CD2D | LD HL,($9FE7) | Read the saved pointer. | ||
| CD30 | LD ($9FE7),IX | |||
| CD34 | LD (IX-$02),L | Store the low byte of the pointer in the previous record. | ||
| CD37 | LD (IX-$01),H | Store the high byte of the pointer in the previous record. | ||
| CD3A | LD A,($A036) | Write *CurrentCharacter_ID to *IX+00. | ||
| CD3D | LD (IX+$00),A | |||
| CD40 | POP AF | Restore AF from the stack. | ||
| CD41 | LD (IX+$01),A | Store A at offset 01 and jump to ContinueScriptExecution. | ||
| CD44 | JP ContinueScriptExecution | |||
|
Handles pop Stack.
|
||||
| DispatchCharacterScript_Pop | CD47 | LD B,(IX+$01) | Use the character list pointer at CharacterListPointer. | |
| CD4A | LD IX,$9FE9 | |||
| DispatchCharacterScript_Loop | CD4E | CALL FetchObjectPointerFromStack | Go to ProcessScriptCommandWithCounter if the object pointer is zero. | |
| CD51 | JP Z,ProcessScriptCommandWithCounter | |||
| CD54 | LD A,($A036) | Jump back to DispatchCharacterScript_Loop while this id does not match the moved marker. | ||
| CD57 | CP (IX+$01) | |||
| CD5A | JR NZ,DispatchCharacterScript_Loop | |||
| CD5C | LD A,B | Jump back to DispatchCharacterScript_Loop while this id does not match the record's flag byte. | ||
| CD5D | CP (IX+$00) | |||
| CD60 | JR NZ,DispatchCharacterScript_Loop | |||
| CD62 | PUSH IY | Save the schedule entry. | ||
| CD64 | PUSH IX | Copy the character record from IX into DE. | ||
| CD66 | POP DE | |||
| CD67 | LD IY,$9FE7 | Use the saved pointer (9FE7). | ||
|
Step pointer and compare.
|
||||
| CD6B | CALL IncrementPointerAndCompare | Call IncrementPointerAndCompare to compare the pointer with the next record. | ||
| CD6E | LD L,(IX-$02) | Read the pointer saved ahead of this record. | ||
| CD71 | LD H,(IX-$01) | |||
| CD74 | LD (IY-$02),L | Store the low byte of the pointer in the previous record. | ||
| CD77 | LD (IY-$01),H | Store the high byte of the link and call ProcessMemoryEntry. | ||
| CD7A | CALL ProcessMemoryEntry | |||
| CD7D | POP IY | |||
| CD7F | JP ContinueScriptExecution | Jump ahead to ContinueScriptExecution to resume script execution. | ||
|
Sets character Script Error.
Set script completion flag.
|
||||
| DispatchCharacterScript_MarkError | CD82 | LD HL,$0001 | Write 0001 to *CharacterScriptCycles. | |
| CD85 | LD ($A01F),HL | |||
| CD88 | JP ContinueScriptExecution | Jump ahead to ContinueScriptExecution to resume script execution. | ||
| Prev: CC78 | Up: Map | Next: CD8B |