Routines
| Prev: BC9C | Up: Map | Next: BD51 |
BCC9: Try to prove statement IX
|
If it has evidence (flags bit 2), checks it (BF08) and fails if it is not all there. Then marks it proven (bit 1 set, bit 0 clear) and runs its routine (+4/+5) if bit 4 is set; a statement with bit 5 set is only marked as waiting (bit 0). Z = proven.
How it works:
1. If the statement has evidence (flags bit 2), check all of it (BF08). If any is missing, return NZ: not proved.
2. If flags bit 5 is set, the statement is only marked as waiting (bit 0 set) and Z is returned. It will be settled later by BC46.
3. Otherwise mark it proved (bit 1 set, bit 0 clear). If bit 4 is set, run its routine at +4/+5 (D1DB): the routines from 99FC on, which print what Lestrade or Watson says and may set a marker.
4. Return Z: proved.
|
||||||||||||
| BCC9 | BIT 2,(IX+$03) | Test bit 2 of byte +3 of the record at IX - Does the statement have evidence (flags bit 2)? | ||||||||||
| BCCD | JR Z,$BCDA | If bit 2 of byte +3 of the record at IX is clear, skip ahead to BCDA | ||||||||||
| BCCF | PUSH IX | Save IX on the stack - Yes: check the evidence (BF08)... | ||||||||||
| BCD1 | PUSH BC | Save BC on the stack | ||||||||||
| BCD2 | CALL $BF08 | Call the routine "Check every piece of evidence in the group after IX..." (BF08) - Yes: is it all there (BF08)? If not, NZ - not proven | ||||||||||
| BCD5 | POP BC | Restore BC from the stack | ||||||||||
| BCD6 | POP IX | Restore IX from the stack | ||||||||||
| BCD8 | JR Z,$BD03 | ...not all there: fail, NZ (BD03) | ||||||||||
| BCDA | BIT 5,(IX+$03) | Test bit 5 of byte +3 of the record at IX - Flags bit 5 set? | ||||||||||
| BCDE | JR Z,$BCE6 | If bit 5 of byte +3 of the record at IX is clear, skip ahead to BCE6 | ||||||||||
| BCE0 | SET 0,(IX+$03) | Set bit 0 of byte +3 of the record at IX - Then only mark it as waiting (bit 0) | ||||||||||
| BCE4 | JR $BD01 | Skip ahead to BD01 | ||||||||||
| BCE6 | SET 1,(IX+$03) | Otherwise mark it proven (bit 1 set)... | ||||||||||
| BCEA | RES 0,(IX+$03) | ...and bit 0 clear | ||||||||||
| BCEE | BIT 4,(IX+$03) | Test bit 4 of byte +3 of the record at IX - Bit 4 set: it has a routine... | ||||||||||
| BCF2 | JR Z,$BD01 | If bit 4 of byte +3 of the record at IX is clear, skip ahead to BD01 | ||||||||||
| BCF4 | LD L,(IX+$04) | Read byte +4 of the record at IX into L - ...run the routine at +4/+5 (D1DB) | ||||||||||
| BCF7 | LD H,(IX+$05) | Read byte +5 of the record at IX into H | ||||||||||
| BCFA | PUSH IX | Save IX on the stack | ||||||||||
| BCFC | CALL $D1DB | Call the routine "Jump to HL" (D1DB) | ||||||||||
| BCFF | POP IX | Restore IX from the stack | ||||||||||
| BD01 | XOR A | Set A to zero, which sets the zero flag for the caller - Z: proven | ||||||||||
| BD02 | RET | Return to the caller | ||||||||||
| BD03 | OR $01 | Make A non-zero, which clears the zero flag, and hand that back to the caller - NZ: not proven | ||||||||||
| BD05 | RET | Return to the caller | ||||||||||
|
This entry point is used by the routine at BA67.
|
||||||||||||
| BD06 | PUSH IY | Save IY on the stack - Look for a remembered statement (list at $9FF6, nodes of subject, relation, object) that shares one end with the statement at IX but | ||||||||||
| BD08 | PUSH IX | Save IX on the stack | ||||||||||
| BD0A | POP IY | Restore IY from the stack | ||||||||||
| BD0C | LD IX,$9FF6 | Point IX at $9FF6 in "Game variables" - IX walks the list (A0F7) | ||||||||||
| BD10 | CALL $A0F7 | Call the routine "Move IX to the next node of a list" (A0F7) | ||||||||||
| BD13 | JR Z,$BD46 | End of list: nothing found, NZ (BD46) | ||||||||||
| BD15 | LD B,(IX+$02) | Read byte +2 of the record at IX into B - Compare subject with subject, subject with object, object with object, object with subject in turn... | ||||||||||
| BD18 | LD C,(IY+$02) | Read byte +2 of the record at IY into C | ||||||||||
| BD1B | LD A,(IX+$00) | Read the first byte of the record at IX into A | ||||||||||
| BD1E | CP (IY+$00) | Compare A with the first byte of the record at IY | ||||||||||
| BD21 | JR Z,$BD3E | If A equals the first byte of the record at IY, skip ahead to BD3E | ||||||||||
| BD23 | LD C,(IY+$00) | Read the first byte of the record at IY into C | ||||||||||
| BD26 | CP (IY+$02) | Compare A with byte +2 of the record at IY | ||||||||||
| BD29 | JR Z,$BD3E | If A equals byte +2 of the record at IY, skip ahead to BD3E | ||||||||||
| BD2B | LD B,(IX+$00) | Read the first byte of the record at IX into B | ||||||||||
| BD2E | LD A,(IX+$02) | Read byte +2 of the record at IX into A | ||||||||||
| BD31 | CP (IY+$02) | Compare A with byte +2 of the record at IY | ||||||||||
| BD34 | JR Z,$BD3E | If A equals byte +2 of the record at IY, skip ahead to BD3E | ||||||||||
| BD36 | LD C,(IY+$02) | Read byte +2 of the record at IY into C | ||||||||||
| BD39 | CP (IY+$00) | Compare A with the first byte of the record at IY | ||||||||||
| BD3C | JR NZ,$BD10 | If A differs from the first byte of the record at IY, go back to BD10 | ||||||||||
| BD3E | LD A,B | ...B and C then hold the two things that do not match; | ||||||||||
| BD3F | CP C | Compare A with C - if they are the same thing, try the next node | ||||||||||
| BD40 | JR Z,$BD10 | If A equals C, go back to BD10 | ||||||||||
| BD42 | POP IY | Restore IY from the stack - Found: B and C are the pair to connect, Z | ||||||||||
| BD44 | XOR A | Set A to zero, which sets the zero flag for the caller | ||||||||||
| BD45 | RET | Return to the caller | ||||||||||
| BD46 | OR $01 | Set bit 0 of A | ||||||||||
| BD48 | POP IY | Restore IY from the stack | ||||||||||
| BD4A | RET | Return to the caller | ||||||||||
|
This entry point is used by the routine at BA67.
|
||||||||||||
| BD4B | LD IX,$9A7D | Watson's own list (9A7D) | ||||||||||
| BD4F | JR $BD55 | Join the walk | ||||||||||
| Prev: BC9C | Up: Map | Next: BD51 |