Routines
| Prev: D770 | Up: Map | Next: D7D9 |
D77E: Player's turn: parse the next sentence (RUN at $9932)
|
Addresses named in the title: 9932.
The body runs the sentence parser (AAB2) from the token at (D6BD). On success the rest of the line (9FF0) is kept at 9FF2 for next time and D6B8 cleared. On failure both word lists are freed (D87D, D88A) and - unless the parser's result was 2 and an action time was set - the game says 'WHAT ?' (6866) and fails. Part of the player's own plan script.
This record is one step of the loop in the player's own plan script at 9921: DO LOOK once, then read a line (D6BF), split it into words (D715), check there is a word (D769), parse a sentence (D77E), check there is a sentence (D7D9), turn it into a command (D7FA) and DO it. When you wear the china man's disguise the same script runs for him; the counts below include both.
|
||||||||||
| D77E | DEFB $00,$00 | Action record header: flags $00; byte 1 $00 | ||||||||
| D780 | XOR A | Clear A to zero (and the carry flag) - Action-record body: 9FEB = 0 | ||||||||
| D781 | LD ($9FEB),A | Store A in 9FEB in "Game variables" | ||||||||
| D784 | INC A | Add one to A - $A024 = 1 | ||||||||
| D785 | LD ($A024),A | Store A in $A024 in "Game variables" | ||||||||
| D788 | LD HL,($D6BD) | Read D6BD in "A flag of the player's script step, and..." into HL - Keep the parser's token pointer (D6BD) in $A02B across the parse | ||||||||
| D78B | LD ($A02B),HL | Store HL in $A02B in "Game variables" | ||||||||
| D78E | CALL $AAB2 | Call the routine "Parse the next sentence from the word list" (AAB2) - Parse a sentence (AAB2) | ||||||||
| D791 | PUSH AF | Save AF on the stack | ||||||||
| D792 | XOR A | Clear A to zero (and the carry flag) - $A01B = 0 (flags preserved) | ||||||||
| D793 | LD ($A01B),A | Store A in $A01B in "Game variables" | ||||||||
| D796 | POP AF | Restore AF from the stack | ||||||||
| D797 | LD HL,($A02B) | Read $A02B in "Game variables" into HL - Put the token pointer back | ||||||||
| D79A | LD ($D6BD),HL | Store HL in D6BD in "A flag of the player's script step, and..." | ||||||||
| D79D | JR NZ,$D7B2 | NZ: the parse failed | ||||||||
| D79F | LD HL,($9FF0) | Read words the player has (9FF0) into HL - Parsed: keep the rest of the line (9FF0) as 9FF2... | ||||||||
| D7A2 | LD ($9FF2),HL | Store HL in 9FF2 in "Game variables" | ||||||||
| D7A5 | LD HL,$0000 | Load HL with $0000 - ...and empty 9FF0 | ||||||||
| D7A8 | LD ($9FF0),HL | Store HL in words the player has (9FF0) | ||||||||
| D7AB | XOR A | Clear A to zero (and the carry flag) | ||||||||
| D7AC | LD ($D6B8),A | D6B8 = 0 | ||||||||
| D7AF | OR $01 | Make A non-zero, which clears the zero flag, and hand that back to the caller - Return NZ: success | ||||||||
| D7B1 | RET | Return to the caller | ||||||||
| D7B2 | PUSH AF | Save AF on the stack - Failed: free both word lists (D87D, D88A) | ||||||||
| D7B3 | CALL $D87D | Call the routine "Free the current sentence's word list (9FF0)" (D87D) | ||||||||
| D7B6 | CALL $D88A | Call the routine "Free the rest of the typed line's word list (9FF2)" (D88A) | ||||||||
| D7B9 | POP AF | Restore AF from the stack | ||||||||
| D7BA | CP $02 | Compare A with $02 - Parser result 2 (an action time was set)? | ||||||||
| D7BC | JR Z,$D7D0 | If A equals $02, skip ahead to D7D0 | ||||||||
| D7BE | LD A,$01 | Load A with $01 - Otherwise print 'WHAT ?' (6866) with quoted printing on... | ||||||||
| D7C0 | LD ($A027),A | Store A in $A027 in "Game variables" | ||||||||
| D7C3 | LD HL,$6866 | Point HL at the message "WHAT ?" (6866) | ||||||||
| D7C6 | CALL $A59F | Call the routine "Print the message at HL" (A59F) | ||||||||
| D7C9 | XOR A | Clear A to zero (and the carry flag) - ...then off | ||||||||
| D7CA | LD ($A027),A | Store A in $A027 in "Game variables" | ||||||||
| D7CD | JP $DC15 | and fail (DC15) | ||||||||
| D7D0 | LD HL,($A01F) | Read $A01F in "Game variables" into HL - Result 2: fail if $A01F is zero, else return NZ | ||||||||
| D7D3 | LD A,H | Copy H into A | ||||||||
| D7D4 | OR L | Set in A the bits that are set in L | ||||||||
| D7D5 | RET NZ | If the result is not zero, return | ||||||||
| D7D6 | JP $DC15 | Jump on to the routine "Fail: A = 0, HL = 0, Z set" (DC15) | ||||||||
| Prev: D770 | Up: Map | Next: D7D9 |