Prev: 54975 Up: Map Next: 55349
54977: Parse Input
Command parser. It reads the line buffer at 23296, tokenises it, and handles backspace and quoting. A non-zero return means the script step succeeded.
Run by 51812 after the display record at 54975.
ParseInput 54977 CALL ReadCommandLine Return zero through ParseInputNumber_ReturnZero if no command was entered.
54980 JP Z,ParseInputNumber_ReturnZero
54983 XOR A Clear the parser state.
54984 LD (55060),A
54987 OR %00000001 Reset the zero flag.
54989 RET Return.
54990 LD HL,23296 Take the line buffer.
ParseInput_Loop 54993 CALL SkipSpaces Call SkipSpaces to read the next character and jump to ParseInput_Next when it is 208.
54996 CP 208
54998 JP Z,ParseInput_Next
55001 CP 192 Jump back to ParseInput_Loop while the character is not 192.
55003 JR NZ,ParseInput_Loop
55005 OR %00000001 Reset the zero flag.
55007 RET Return.
Hands the following step back to the caller and reports that the test failed.
ParseInput_Next 55008 LD HL,55013 Hand back the address of the following step.
55011 XOR A Clear A.
55012 RET Return.
55013 LD A,1 Set the print mode to 1 and point HL at the message at 26711+2.
55015 LD (40999),A
55018 LD HL,26713
Print text and handle control characters.
55021 CALL PrintTextAndHandleControlCharacters Call PrintTextAndHandleControlCharacters to print this message.
55024 LD HL,(54973) Read the parser pointer, write 192 there and read the word at SavedTextPointer.
55027 LD (HL),192
55029 LD HL,(41001)
ParseInput_Byte 55032 LD A,(HL) Jump ahead to ParseInput_0 if this byte is not 46.
55033 CP 46
55035 JR NZ,ParseInput_0
55037 LD A,32 Take a space.
ParseInput_0 55039 CALL Print_Character Call Print_Character to print the character.
55042 INC HL Step on and jump back to ParseInput_Byte until a space has been printed.
55043 CP 32
55045 JR NZ,ParseInput_Byte
55047 LD A,34 Print character 34 through Print_Character, then call PrintNewline to print a new line.
55049 CALL Print_Character
55052 CALL PrintNewline
55055 XOR A Clear A so the print mode that follows starts at zero.
55056 LD (40999),A Record the result in the print mode.
55059 RET Return.
55060 DEFB 0 Parser state byte, read by ParseInput and IgnoreInputUntilGameHasStarted.
Named from the script command at 39208.
55061 DEFB 64,0,206,214 Display record read by ProcessDisplayRecord: flags 64 value 0 handler 54990.
Run by 51812 after the display record at 55061.
55065 XOR A Clear the parser state.
55066 LD (40985),A Record the parser.
Reset screen display.
55069 CALL ResetScreenDisplay Call ResetScreenDisplay to reset the screen.
55072 LD A,(55060) Jump to ParseInput_RecordParserPointer if the state byte at 55060 is set.
55075 AND A
55076 JR NZ,ParseInput_RecordParserPointer
55078 LD HL,23425 Call ClearBuffer to clear buffer.
55081 LD B,96
55083 CALL ClearBuffer
55086 LD HL,23296 Take the line buffer.
55089 LD IY,23425
ParseInput_CharacterParseInput 55093 LD (IY+0),192 Store 192 as this character's id, then call SkipSpaces to skip spaces.
55097 CALL SkipSpaces
55100 LD (IY+0),D Store D, step on one byte and jump ahead to ParseInput_CharacterLowByte if the character is 224.
55103 INC IY
55105 CP 224
55107 JR Z,ParseInput_CharacterLowByte
55109 CP 240 Jump ahead to ParseInput_CharacterLowByte if the character is 240.
55111 JR Z,ParseInput_CharacterLowByte
55113 CP 144 Jump ahead to ParseInput_CharacterLowByte if the character is 144.
55115 JR Z,ParseInput_CharacterLowByte
55117 CP 128 Jump ahead to ParseInput_Pointer if the character is at least 128.
55119 JR NC,ParseInput_Pointer
ParseInput_CharacterLowByte 55121 LD (IY+0),B Store B and C as the word at IY+0-1.
55124 LD (IY+1),C
55127 INC IY Step on two places.
55129 INC IY
ParseInput_Pointer 55131 LD A,D Jump back to ParseInput_CharacterParseInput while the result in D is not 192.
55132 CP 192
55134 JR NZ,ParseInput_CharacterParseInput
ParseInput_RecordParserPointer 55136 LD HL,23425 Record the parser pointer.
55139 LD (54973),HL
55142 OR %00000001 Reset the zero flag.
55144 RET Return.
Named from the script command at 39213.
55145 DEFB 64,0,112,215 Display record read by ProcessDisplayRecord: flags 64 value 0 handler 55152.
Run by 51812 after the display record at 55145.
55149 OR %00000001 Reset the zero flag.
55151 RET Return.
Reached through the display record at 55145, dispatched by DispatchLookedUpHandlerThird.
55152 LD HL,(54973) Read the parser pointer.
55155 LD A,(HL) Read the next input character.
55156 AND 240 Keep bits 4-7.
55158 CP 192 See whether the high nibble is 192.
55160 JP Z,ParseInputNumber_ReturnZero Jump to ParseInputNumber_ReturnZero when the high nibble is 192.
55163 OR %00000001 Reset the zero flag.
55165 RET Return.
Named from the script command at 39218.
55166 DEFB 0,0 Display record read by ProcessDisplayRecord: flags 0 value 0.
Run by 51812 after the display record at 55166.
55168 XOR A Clear the character script entry list and set the command mode at 40996 to 1.
55169 LD (40939),A
55172 INC A
55173 LD (40996),A
55176 LD HL,(54973) Read the parser pointer, store it in the word at ActiveTextPointer and call PrepareCharacterForDisplay.
55179 LD (41003),HL
55182 CALL PrepareCharacterForDisplay
55185 PUSH AF Clear the initialised flag.
55186 XOR A
55187 LD (40987),A
55190 POP AF
55191 LD HL,(41003) Read the word at ActiveTextPointer.
55194 LD (54973),HL Store the parser pointer and go to ParseInput_ReadsBothDisplay if preparing the character succeeded.
55197 JR NZ,ParseInput_ReadsBothDisplay
55199 LD HL,(40944) Read the first display link and store the pointer in the next display link.
55202 LD (40946),HL
55205 LD HL,0 Clear the pointer.
55208 LD (40944),HL Store the zero pointer in the first display link and clear the parser workspace byte at 54968.
55211 XOR A
55212 LD (54968),A
55215 OR %00000001 Reset the zero flag.
55217 RET Return.
Reads both display links, and takes the special path when the code is 2.
ParseInput_ReadsBothDisplay 55218 PUSH AF Call ReadFirstDisplayLink to read the first display link.
55219 CALL ReadFirstDisplayLink
55222 CALL ReadNextDisplayLink Call ReadNextDisplayLink to read the next display link.
55225 POP AF
55226 CP 2 Jump ahead to ParseInput_ScriptCyclePointer if the character is 2.
55228 JR Z,ParseInput_ScriptCyclePointer
55230 LD A,1 Set the print mode to 1 and point HL at the message at 26719+7.
55232 LD (40999),A
55235 LD HL,26726
Print text and handle control characters.
55238 CALL PrintTextAndHandleControlCharacters Call PrintTextAndHandleControlCharacters to print this message.
55241 XOR A Clear the print mode and return zero through ParseInputNumber_ReturnZero.
55242 LD (40999),A
55245 JP ParseInputNumber_ReturnZero
Read the script-cycle pointer and return when it is still set.
ParseInput_ScriptCyclePointer 55248 LD HL,(40991) Return if the script-cycle pointer at CharacterScriptCycles is not zero.
55251 LD A,H
55252 OR L
55253 RET NZ
55254 JP ParseInputNumber_ReturnZero Return zero through ParseInputNumber_ReturnZero.
Named from the script command at 39223.
55257 DEFB 64,0,225,215 Display record read by ProcessDisplayRecord: flags 64 value 0 handler 55265.
Run by 51812 after the display record at 55257.
55261 OR %00000001 Reset the zero flag.
55263 RET Return.
55264 DEFB 0 State byte for this input step. Read by 55265 and written by 55271 and RecordParserFailure_StepSucceedsScript.
Reached through the display record at 55257, dispatched by DispatchLookedUpHandlerThird.
55265 LD A,(55264) Jump to ParseInput_TestDisplayLinkSet if the state byte at 55264 is zero.
55268 AND A
55269 JR Z,ParseInput_TestDisplayLinkSet
55271 XOR A Clear the state byte at 55264 and call ReadNextDisplayLink to read the next display link.
55272 LD (55264),A
55275 CALL ReadNextDisplayLink
55278 JP ParseInputNumber_ReturnZero Return zero through ParseInputNumber_ReturnZero.
Read the next display link and return when it is still set.
ParseInput_TestDisplayLinkSet 55281 LD HL,(40946) Return if the next display link at 40942+4 is set.
55284 LD A,L
55285 OR H
55286 RET NZ
55287 JP ParseInputNumber_ReturnZero Return zero through ParseInputNumber_ReturnZero.
Named from the script command at 39228.
55290 DEFB 0,0 Display record read by ProcessDisplayRecord: flags 0 value 0.
Run by 51812 after the display record at 55290.
55292 XOR A Clear the display.
55293 LD A,(54968)
55296 LD (40988),A
55299 LD IY,(40946) Read the next display link.
55303 LD HL,(54971) Call InitialiseDisplayBuffer to initialise display buffer.
55306 LD (45438),HL
55309 CALL InitialiseDisplayBuffer
A command is being read.
55312 LD A,1 Remember that a command is being read, and leave the line when the display buffer came back empty.
55314 LD (40971),A
55317 JP Z,RecordParserFailure
55320 LD A,(40988) Store the display flag in the parser workspace byte at 54968.
55323 LD (54968),A
55326 LD A,1 Write 1 to the token format flag.
55328 LD (40998),A
55331 LD A,(41011) Record the current room.
55334 LD (40918),A
55337 LD HL,(41012) Read the room display parameter.
55340 LD (40919),HL Record the location value and read the object table pointer.
55343 LD HL,(45438)
55346 LD (54971),HL Record the parser workspace.
Prev: 54975 Up: Map Next: 55349