Prev: D6BF Up: Map Next: D835
D6C1: Parse Input
Command parser. It reads the line buffer at 5B00, tokenises it, and handles backspace and quoting. A non-zero return means the script step succeeded.
Run by CA64 after the display record at D6BF.
ParseInput D6C1 CALL ReadCommandLine Return zero through ParseInputNumber_ReturnZero if no command was entered.
D6C4 JP Z,ParseInputNumber_ReturnZero
D6C7 XOR A Clear the parser state.
D6C8 LD ($D714),A
D6CB OR %00000001 Reset the zero flag.
D6CD RET Return.
D6CE LD HL,$5B00 Take the line buffer.
ParseInput_Loop D6D1 CALL SkipSpaces Call SkipSpaces to read the next character and jump to ParseInput_Next when it is D0.
D6D4 CP $D0
D6D6 JP Z,ParseInput_Next
D6D9 CP $C0 Jump back to ParseInput_Loop while the character is not C0.
D6DB JR NZ,ParseInput_Loop
D6DD OR %00000001 Reset the zero flag.
D6DF RET Return.
Hands the following step back to the caller and reports that the test failed.
ParseInput_Next D6E0 LD HL,$D6E5 Hand back the address of the following step.
D6E3 XOR A Clear A.
D6E4 RET Return.
D6E5 LD A,$01 Set the print mode to 01 and point HL at the message at 6857+02.
D6E7 LD ($A027),A
D6EA LD HL,$6859
Print text and handle control characters.
D6ED CALL PrintTextAndHandleControlCharacters Call PrintTextAndHandleControlCharacters to print this message.
D6F0 LD HL,($D6BD) Read the parser pointer, write C0 there and read the word at SavedTextPointer.
D6F3 LD (HL),$C0
D6F5 LD HL,($A029)
ParseInput_Byte D6F8 LD A,(HL) Jump ahead to ParseInput_0 if this byte is not 2E.
D6F9 CP $2E
D6FB JR NZ,ParseInput_0
D6FD LD A,$20 Take a space.
ParseInput_0 D6FF CALL Print_Character Call Print_Character to print the character.
D702 INC HL Step on and jump back to ParseInput_Byte until a space has been printed.
D703 CP $20
D705 JR NZ,ParseInput_Byte
D707 LD A,$22 Print character 22 through Print_Character, then call PrintNewline to print a new line.
D709 CALL Print_Character
D70C CALL PrintNewline
D70F XOR A Clear A so the print mode that follows starts at zero.
D710 LD ($A027),A Record the result in the print mode.
D713 RET Return.
D714 DEFB $00 Parser state byte, read by ParseInput and IgnoreInputUntilGameHasStarted.
Named from the script command at 9928.
D715 DEFB $40,$00,$CE,$D6 Display record read by ProcessDisplayRecord: flags 40 value 00 handler D6CE.
Run by CA64 after the display record at D715.
D719 XOR A Clear the parser state.
D71A LD ($A019),A Record the parser.
Reset screen display.
D71D CALL ResetScreenDisplay Call ResetScreenDisplay to reset the screen.
D720 LD A,($D714) Jump to ParseInput_RecordParserPointer if the state byte at D714 is set.
D723 AND A
D724 JR NZ,ParseInput_RecordParserPointer
D726 LD HL,$5B81 Call ClearBuffer to clear buffer.
D729 LD B,$60
D72B CALL ClearBuffer
D72E LD HL,$5B00 Take the line buffer.
D731 LD IY,$5B81
ParseInput_CharacterParseInput D735 LD (IY+$00),$C0 Store C0 as this character's id, then call SkipSpaces to skip spaces.
D739 CALL SkipSpaces
D73C LD (IY+$00),D Store D, step on one byte and jump ahead to ParseInput_CharacterLowByte if the character is E0.
D73F INC IY
D741 CP $E0
D743 JR Z,ParseInput_CharacterLowByte
D745 CP $F0 Jump ahead to ParseInput_CharacterLowByte if the character is F0.
D747 JR Z,ParseInput_CharacterLowByte
D749 CP $90 Jump ahead to ParseInput_CharacterLowByte if the character is 90.
D74B JR Z,ParseInput_CharacterLowByte
D74D CP $80 Jump ahead to ParseInput_Pointer if the character is at least 80.
D74F JR NC,ParseInput_Pointer
ParseInput_CharacterLowByte D751 LD (IY+$00),B Store B and C as the word at IY+00-01.
D754 LD (IY+$01),C
D757 INC IY Step on two places.
D759 INC IY
ParseInput_Pointer D75B LD A,D Jump back to ParseInput_CharacterParseInput while the result in D is not C0.
D75C CP $C0
D75E JR NZ,ParseInput_CharacterParseInput
ParseInput_RecordParserPointer D760 LD HL,$5B81 Record the parser pointer.
D763 LD ($D6BD),HL
D766 OR %00000001 Reset the zero flag.
D768 RET Return.
Named from the script command at 992D.
D769 DEFB $40,$00,$70,$D7 Display record read by ProcessDisplayRecord: flags 40 value 00 handler D770.
Run by CA64 after the display record at D769.
D76D OR %00000001 Reset the zero flag.
D76F RET Return.
Reached through the display record at D769, dispatched by DispatchLookedUpHandlerThird.
D770 LD HL,($D6BD) Read the parser pointer.
D773 LD A,(HL) Read the next input character.
D774 AND $F0 Keep bits 4-7.
D776 CP $C0 See whether the high nibble is C0.
D778 JP Z,ParseInputNumber_ReturnZero Jump to ParseInputNumber_ReturnZero when the high nibble is C0.
D77B OR %00000001 Reset the zero flag.
D77D RET Return.
Named from the script command at 9932.
D77E DEFB $00,$00 Display record read by ProcessDisplayRecord: flags 00 value 00.
Run by CA64 after the display record at D77E.
D780 XOR A Clear the character script entry list and set the command mode at A024 to 01.
D781 LD ($9FEB),A
D784 INC A
D785 LD ($A024),A
D788 LD HL,($D6BD) Read the parser pointer, store it in the word at ActiveTextPointer and call PrepareCharacterForDisplay.
D78B LD ($A02B),HL
D78E CALL PrepareCharacterForDisplay
D791 PUSH AF Clear the initialised flag.
D792 XOR A
D793 LD ($A01B),A
D796 POP AF
D797 LD HL,($A02B) Read the word at ActiveTextPointer.
D79A LD ($D6BD),HL Store the parser pointer and go to ParseInput_ReadsBothDisplay if preparing the character succeeded.
D79D JR NZ,ParseInput_ReadsBothDisplay
D79F LD HL,($9FF0) Read the first display link and store the pointer in the next display link.
D7A2 LD ($9FF2),HL
D7A5 LD HL,$0000 Clear the pointer.
D7A8 LD ($9FF0),HL Store the zero pointer in the first display link and clear the parser workspace byte at D6B8.
D7AB XOR A
D7AC LD ($D6B8),A
D7AF OR %00000001 Reset the zero flag.
D7B1 RET Return.
Reads both display links, and takes the special path when the code is 2.
ParseInput_ReadsBothDisplay D7B2 PUSH AF Call ReadFirstDisplayLink to read the first display link.
D7B3 CALL ReadFirstDisplayLink
D7B6 CALL ReadNextDisplayLink Call ReadNextDisplayLink to read the next display link.
D7B9 POP AF
D7BA CP $02 Jump ahead to ParseInput_ScriptCyclePointer if the character is 02.
D7BC JR Z,ParseInput_ScriptCyclePointer
D7BE LD A,$01 Set the print mode to 01 and point HL at the message at 685F+07.
D7C0 LD ($A027),A
D7C3 LD HL,$6866
Print text and handle control characters.
D7C6 CALL PrintTextAndHandleControlCharacters Call PrintTextAndHandleControlCharacters to print this message.
D7C9 XOR A Clear the print mode and return zero through ParseInputNumber_ReturnZero.
D7CA LD ($A027),A
D7CD JP ParseInputNumber_ReturnZero
Read the script-cycle pointer and return when it is still set.
ParseInput_ScriptCyclePointer D7D0 LD HL,($A01F) Return if the script-cycle pointer at CharacterScriptCycles is not zero.
D7D3 LD A,H
D7D4 OR L
D7D5 RET NZ
D7D6 JP ParseInputNumber_ReturnZero Return zero through ParseInputNumber_ReturnZero.
Named from the script command at 9937.
D7D9 DEFB $40,$00,$E1,$D7 Display record read by ProcessDisplayRecord: flags 40 value 00 handler D7E1.
Run by CA64 after the display record at D7D9.
D7DD OR %00000001 Reset the zero flag.
D7DF RET Return.
D7E0 DEFB $00 State byte for this input step. Read by D7E1 and written by D7E7 and RecordParserFailure_StepSucceedsScript.
Reached through the display record at D7D9, dispatched by DispatchLookedUpHandlerThird.
D7E1 LD A,($D7E0) Jump to ParseInput_TestDisplayLinkSet if the state byte at D7E0 is zero.
D7E4 AND A
D7E5 JR Z,ParseInput_TestDisplayLinkSet
D7E7 XOR A Clear the state byte at D7E0 and call ReadNextDisplayLink to read the next display link.
D7E8 LD ($D7E0),A
D7EB CALL ReadNextDisplayLink
D7EE JP ParseInputNumber_ReturnZero Return zero through ParseInputNumber_ReturnZero.
Read the next display link and return when it is still set.
ParseInput_TestDisplayLinkSet D7F1 LD HL,($9FF2) Return if the next display link at 9FEE+04 is set.
D7F4 LD A,L
D7F5 OR H
D7F6 RET NZ
D7F7 JP ParseInputNumber_ReturnZero Return zero through ParseInputNumber_ReturnZero.
Named from the script command at 993C.
D7FA DEFB $00,$00 Display record read by ProcessDisplayRecord: flags 00 value 00.
Run by CA64 after the display record at D7FA.
D7FC XOR A Clear the display.
D7FD LD A,($D6B8)
D800 LD ($A01C),A
D803 LD IY,($9FF2) Read the next display link.
D807 LD HL,($D6BB) Call InitialiseDisplayBuffer to initialise display buffer.
D80A LD ($B17E),HL
D80D CALL InitialiseDisplayBuffer
A command is being read.
D810 LD A,$01 Remember that a command is being read, and leave the line when the display buffer came back empty.
D812 LD ($A00B),A
D815 JP Z,RecordParserFailure
D818 LD A,($A01C) Store the display flag in the parser workspace byte at D6B8.
D81B LD ($D6B8),A
D81E LD A,$01 Write 01 to the token format flag.
D820 LD ($A026),A
D823 LD A,($A033) Record the current room.
D826 LD ($9FD6),A
D829 LD HL,($A034) Read the room display parameter.
D82C LD ($9FD7),HL Record the location value and read the object table pointer.
D82F LD HL,($B17E)
D832 LD ($D6BB),HL Record the parser workspace.
Prev: D6BF Up: Map Next: D835