Routines
| Prev: BA60 | Up: Map | Next: BB46 |
BA67: Watson's reply to something the player says
|
Parses the remark into a statement (BD7E: subject $BA19, relation $BA1A from the verb's place in 994D, object BA1B), then looks for it in Watson's own list at 9A7D (empty: $FF at once) and in the case table (BD51). A statement about the case is remembered: added to the list at $9FF4 (5-byte heap nodes holding the three bytes) unless already there. Watson then answers 'THAT IS BRILLIANT HOLMES.' (6F54) or, by chance, asks whether there is 'SOME CONNECTION BETWEEN THE ... AND ...' two things (6F62, using BD06); a statement with flags bit 5 set (the four 'Tricia Fender / Phipps KILLED ...' ones) gets a different answer.
SAY TO WATSON "MRS BROWN KILLED HERSELF" at the start gets a reply and the list at $9FF4 gains a node 5E 05 60 (Mrs Brown / KILLED / herself); "PHIPPS HAS PLANS" gets a reply and a node 06 03 61. "' and 'Watson says " That is brilliant Holmes. "THE LAMP IS ON", which is not about the case, gets 'Watson says " What "'; "THE LAMP IS OPEN" gets no reply at all.
|
||||||||||||||
| BA67 | LD ($BA60),A | Store A in "More variables for BA67-BB5C" (BA60) - A = 0 on entry: clear the two flags BA60 (how the statement was matched) and $BA61 (remember Parse the next statement out of the remark into Carry: nothing usable, jump to the reply code at Z: try the next one | ||||||||||||
| BA6A | LD ($BA61),A | Store A in $BA61 in "More variables for BA67-BB5C" | ||||||||||||
| BA6D | CALL $BD7E | Call BD7E (inside "Find the statement $BA19-BA1B in the case...") | ||||||||||||
| BA70 | JP C,$BBBE | If the carry flag is set, jump on to BBBE | ||||||||||||
| BA73 | JR Z,$BAA6 | If the zero flag is set, jump on to BAA6 | ||||||||||||
| BA75 | CALL $BD4B | Call BD4B (inside "Try to prove statement IX") - Is it in Watson's own list (BD4B)? | ||||||||||||
| BA78 | JR NZ,$BA85 | If the zero flag is clear, skip ahead to BA85 | ||||||||||||
| BA7A | LD A,$01 | Yes: match kind 1 | ||||||||||||
| BA7C | CALL $BB46 | Record the kind in BA60 and set $BA61 (BB46) | ||||||||||||
| BA7F | LD ($BA65),IX | Store IX in $BA65 in "More variables for BA67-BB5C" - Remember the record found, for the handler at BB5C | ||||||||||||
| BA83 | JR $BAAB | Skip ahead to BAAB | ||||||||||||
| BA85 | CALL $BD51 | Call the routine "Find the statement $BA19-BA1B in the case table" (BD51) - Is it in the case table (BD51)? | ||||||||||||
| BA88 | JR NZ,$BA9D | If the zero flag is clear, skip ahead to BA9D | ||||||||||||
| BA8A | LD A,$02 | Yes: kind 2 | ||||||||||||
| BA8C | BIT 5,(IX+$03) | Test bit 5 of byte +3 of the record at IX - Statement flag bit 5 (the 'Tricia Fender / Phipps KILLED' ones)? | ||||||||||||
| BA90 | JR NZ,$BA7C | If bit 5 of byte +3 of the record at IX is set, go back to BA7C | ||||||||||||
| BA92 | CALL $D29D | Otherwise roll 1-100 (D29D)... | ||||||||||||
| BA95 | CP $32 | ... | ||||||||||||
| BA97 | LD A,$03 | Load A with $03 - ...kind 3 if under 50 | ||||||||||||
| BA99 | JR C,$BA7C | If A is below $32, go back to BA7C | ||||||||||||
| BA9B | JR $BAA6 | Else give up on this one | ||||||||||||
| BA9D | CALL $D29D | Not in either table: roll 1-100... | ||||||||||||
| BAA0 | CP $46 | ... | ||||||||||||
| BAA2 | LD A,$04 | Load A with $04 - ...kind 4 if under 70 | ||||||||||||
| BAA4 | JR C,$BA7C | If A is below $46, go back to BA7C | ||||||||||||
| BAA6 | CALL $AEA9 | Call the routine "IY = the next node in the list (Z at the end)" (AEA9) - Next word group of the remark (AEA9); more: loop to BA6D | ||||||||||||
| BAA9 | JR NZ,$BA6D | If the zero flag is clear, go back to BA6D | ||||||||||||
| BAAB | LD A,($BA60) | Read "More variables for BA67-BB5C" (BA60) into A - Was anything matched? | ||||||||||||
| BAAE | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||||
| BAAF | JP Z,$BB3F | No: the stock reply at BB3F | ||||||||||||
| BAB2 | LD A,($BA61) | Read $BA61 in "More variables for BA67-BB5C" into A - Is the statement to be remembered? | ||||||||||||
| BAB5 | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||||
| BAB6 | JR Z,$BB16 | No: skip to BB16 | ||||||||||||
| BAB8 | LD IX,$9FF6 | Point IX at $9FF6 in "Game variables" - Walk the list of remembered statements at $9FF6 (A0F7)... | ||||||||||||
| BABC | CALL $A0F7 | Call the routine "Move IX to the next node of a list" (A0F7) | ||||||||||||
| BABF | JR Z,$BAF5 | ...end of list: not there, make a node | ||||||||||||
| BAC1 | LD A,($BA62) | Read $BA62 in "More variables for BA67-BB5C" into A - ...comparing the three bytes $BA62-$BA64 with each node | ||||||||||||
| BAC4 | CP (IX+$00) | Compare A with the first byte of the record at IX | ||||||||||||
| BAC7 | JR NZ,$BABC | If A differs from the first byte of the record at IX, go back to BABC | ||||||||||||
| BAC9 | LD A,($BA63) | Read $BA63 in "More variables for BA67-BB5C" into A | ||||||||||||
| BACC | CP (IX+$01) | Compare A with byte +1 of the record at IX | ||||||||||||
| BACF | JR NZ,$BABC | If A differs from byte +1 of the record at IX, go back to BABC | ||||||||||||
| BAD1 | LD A,($BA64) | Read $BA64 in "More variables for BA67-BB5C" into A | ||||||||||||
| BAD4 | CP (IX+$02) | Compare A with byte +2 of the record at IX | ||||||||||||
| BAD7 | JR NZ,$BABC | If A differs from byte +2 of the record at IX, go back to BABC | ||||||||||||
| BAD9 | PUSH IY | Save IY on the stack - Found it already: unlink the node from the list (A104)... | ||||||||||||
| BADB | PUSH IX | Save IX on the stack | ||||||||||||
| BADD | POP DE | Restore DE from the stack | ||||||||||||
| BADE | LD IY,$9FF4 | Point IY at $9FF4 in "Game variables" | ||||||||||||
| BAE2 | CALL $A104 | Call the routine "Find the node before node DE in the list at IY" (A104) | ||||||||||||
| BAE5 | LD A,(IX-$02) | Read byte -2 of the record at IX into A - ...closing the gap | ||||||||||||
| BAE8 | LD (IY-$02),A | Store A in byte -2 of the record at IY | ||||||||||||
| BAEB | LD A,(IX-$01) | Read byte -1 of the record at IX into A | ||||||||||||
| BAEE | LD (IY-$01),A | Store A in byte -1 of the record at IY | ||||||||||||
| BAF1 | POP IY | Restore IY from the stack | ||||||||||||
| BAF3 | JR $BAFA | Skip ahead to BAFA | ||||||||||||
| BAF5 | LD A,$05 | Load A with $05 - Not there: get a 5-byte heap node (A11C) | ||||||||||||
| BAF7 | CALL $A11C | Call the routine "Allocate A + 3 bytes from the free list, cleared" (A11C) | ||||||||||||
| BAFA | LD A,($BA62) | Read $BA62 in "More variables for BA67-BB5C" into A - Fill in the node with the three bytes... | ||||||||||||
| BAFD | LD HL,($BA63) | Read $BA63 in "More variables for BA67-BB5C" into HL | ||||||||||||
| BB00 | LD (IX+$00),A | Store A in the first byte of the record at IX | ||||||||||||
| BB03 | LD (IX+$01),L | Store L in byte +1 of the record at IX | ||||||||||||
| BB06 | LD (IX+$02),H | Store H in byte +2 of the record at IX | ||||||||||||
| BB09 | LD HL,($9FF4) | Read $9FF4 in "Game variables" into HL - ...and put it at the head of the list $9FF4 (most recent first) | ||||||||||||
| BB0C | LD ($9FF4),IX | Store IX in $9FF4 in "Game variables" | ||||||||||||
| BB10 | LD (IX-$02),L | Store L in byte -2 of the record at IX | ||||||||||||
| BB13 | LD (IX-$01),H | Store H in byte -1 of the record at IX | ||||||||||||
| BB16 | LD A,($BA60) | Read "More variables for BA67-BB5C" (BA60) into A - Kind 1 (already in Watson's list)? | ||||||||||||
| BB19 | CP $01 | Compare A with $01 | ||||||||||||
| BB1B | JR Z,$BB5C | Yes: jump to its handler (BB5C) | ||||||||||||
| BB1D | CALL $D29D | Otherwise roll 1-100 | ||||||||||||
| BB20 | CP $19 | Compare A with $19 - 25 or more: the stock reply | ||||||||||||
| BB22 | JR C,$BB3F | If A is below $19, skip ahead to BB3F | ||||||||||||
| BB24 | LD IX,$BA62 | Point IX at $BA62 in "More variables for BA67-BB5C" - Under 25: try to make the 'SOME CONNECTION BETWEEN' remark from the statement (BD06) | ||||||||||||
| BB28 | CALL $BD06 | Call BD06 (inside "Try to prove statement IX") | ||||||||||||
| BB2B | JR NZ,$BB3F | Nothing to connect: the stock reply | ||||||||||||
| BB2D | LD A,C | Copy C into A - Print the two things' names (A4BC) as message parameters... | ||||||||||||
| BB2E | PUSH BC | Save BC on the stack | ||||||||||||
| BB2F | CALL $A4BC | Call the routine "HL = thing A's record + 7" (A4BC) | ||||||||||||
| BB32 | POP AF | Restore AF from the stack | ||||||||||||
| BB33 | PUSH HL | Save HL on the stack | ||||||||||||
| BB34 | CALL $A4BC | Call the routine "HL = thing A's record + 7" (A4BC) | ||||||||||||
| BB37 | PUSH HL | Save HL on the stack | ||||||||||||
| BB38 | LD HL,$6F62 | Point HL at the message "YOU SAY" WELL DO YOU THINK THERE IS SOME... (6F62) - ...'SOME CONNECTION BETWEEN THE ... AND ...' (6F62) | ||||||||||||
| BB3B | CALL $A59F | Call the routine "Print the message at HL" (A59F) | ||||||||||||
| BB3E | RET | Return to the caller | ||||||||||||
| BB3F | LD HL,$6F54 | Point HL at the message "YOU SAY" THAT IS BRILLIANT HOLMES."." (6F54) - Stock reply: 'THAT IS BRILLIANT HOLMES.' (6F54) | ||||||||||||
| BB42 | CALL $A59F | Call the routine "Print the message at HL" (A59F) | ||||||||||||
| BB45 | RET | Return to the caller | ||||||||||||
| Prev: BA60 | Up: Map | Next: BB46 |