Sherlock: annotated disassembly

Routines

Prev: D714 Up: Map Next: D769
D715: Player's turn: split the typed line into words (RUN at $9928)
Addresses named in the title: 9928.
The player's turn starts here: the page line count ($A019) is cleared and the text lines go back to full width (C142). Then, unless '@' asked for the last command again (D714), the typed line at $5B00 is run through the tokenizer (D9C5) word by word into the list at $5B81: one class byte per token, followed by its two-byte value for words of class $E0, $F0 or $90 and for anything below $80; the list ends at class $C0. D6BD is pointed at the list and the record succeeds.
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.
How it works:
1. Clear the page line count and put the text at full width (C142). If '@' was typed, use the last word list again.
2. Otherwise clear the 96-byte word list at $5B81 and read tokens from the typed line (D9C5).
3. Store each token's class; classes $E0, $F0, $90 and those below $80 are followed by a two-byte value.
4. Continue until the end marker.
Output
The typed line split into a word list at $5B81
D715 DEFB $40,$00,$CE,$D6 Action record header: flags $40; bit 6: pre-check at D6CE; byte 1 $00
D719 XOR A Clear A to zero (and the carry flag) - A fresh page count, and full-width text lines
D71A LD ($A019),A Store A in $A019 in "Game variables"
D71D CALL $C142 Call the routine "Text lines full width again (36 characters)" (C142)
D720 LD A,($D714) Read "Flag: repeat the last command ('@')" (D714) into A - '@': use the last word list again
D723 AND A Test A for zero (this leaves A as it was and clears carry)
D724 JR NZ,$D760 If A is not zero, jump on to D760
D726 LD HL,$5B81 Load HL with $5B81 - Clear the 96-byte word list
D729 LD B,$60 Load B with $60
D72B CALL $A2AB Call the routine "Fill B bytes at HL with zero (or, from A2AC, with A)" (A2AB)
D72E LD HL,$5B00 Load HL with $5B00 - HL = the typed line, IY = the word list
D731 LD IY,$5B81 Load IY with $5B81
D735 LD (IY+$00),$C0 Set the first byte of the record at IY to $C0 - Mark the end, then read the next token
D739 CALL $D9C5 Call the routine "Tokenizer: read and classify the next word from input" (D9C5)
D73C LD (IY+$00),D Store D in the first byte of the record at IY - Store its class
D73F INC IY Step IY on to the next byte
D741 CP $E0 Compare A with $E0 - Classes $E0, $F0, $90 and those below $80...
D743 JR Z,$D751 If A equals $E0, skip ahead to D751
D745 CP $F0 Compare A with $F0
D747 JR Z,$D751 If A equals $F0, skip ahead to D751
D749 CP $90 Compare A with $90
D74B JR Z,$D751 If A equals $90, skip ahead to D751
D74D CP $80 Compare A with $80
D74F JR NC,$D75B If A is $80 or more, skip ahead to D75B
D751 LD (IY+$00),B Store B in the first byte of the record at IY - ...are followed by their two-byte value
D754 LD (IY+$01),C Store C in byte +1 of the record at IY
D757 INC IY Step IY on to the next byte
D759 INC IY Step IY on to the next byte
D75B LD A,D Copy D into A - Until the end of the line (class $C0)
D75C CP $C0 Compare A with $C0
D75E JR NZ,$D735 If A differs from $C0, go back to D735
D760 LD HL,$5B81 Load HL with $5B81 - The parser starts at the list
D763 LD ($D6BD),HL Store HL in D6BD in "A flag of the player's script step, and..."
D766 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Succeed
D768 RET Return to the caller
Prev: D714 Up: Map Next: D769