Routines
| Prev: C7A6 | Up: Map | Next: C863 |
C821: Can the current actor ($A036) see thing A?
|
Addresses named in the title: $A036.
NZ if it can. Yes when the thing is what the actor is in or on (the root of the actor's own containment chain, C863); no when the thing's +5 bit 7 is clear (the underground trains, objects 37-41); yes when the thing's chain ends at the actor (carried, or in something open the actor carries) or at the same holder as the actor's; and when neither is held by anything, yes if the actor's room (A00A, set by CC29) is one of the thing's rooms (+0 is how many, from +15 on).
During one WAIT at the start, CC64 asks it about the player (thing 0) for every actor, and it answers yes only for Watson (actor 3, room 8) and the player himself, both in the sitting room; Mrs Hudson (actor 2, room 10) and everyone else get no.
Resolves the id in A via D237 and the current id in $A036 via C863 (the containment-chain walker above), and compares them - essentially 'does this candidate's ultimate container match the thing in $A036 (usually the player, or the room being checked)'.
How it works:
1. The thing is seen if it is what the actor is in or on, or the actor's own container.
2. A thing with +5 bit 7 clear cannot be seen.
3. Things held by the actor, or with the same top-level holder, can be seen; things with different holders cannot.
4. If neither is held, the thing can be seen when it is in the actor's room.
|
||||||||||||
| C821 | PUSH IX | Save IX on the stack | ||||||||||
| C823 | PUSH BC | Save BC on the stack | ||||||||||
| C824 | CALL $D237 | Call the routine "Resolve an id (in A) to its full entity record" (D237) - IX = the thing's record; B = the thing | ||||||||||
| C827 | LD B,A | Copy A into B | ||||||||||
| C828 | LD A,($A036) | Read $A036 in "Game variables" into A - A = what the actor is in or held by, at the top (C863) | ||||||||||
| C82B | CALL $C863 | Call the routine "Is thing number A here? (C86E)" (C863) | ||||||||||
| C82E | CP B | Compare A with B - The thing itself: yes | ||||||||||
| C82F | JR Z,$C85D | If A equals B, jump on to C85D | ||||||||||
| C831 | BIT 7,(IX+$05) | Test bit 7 of the flags byte (+5) of the thing record at IX (revealed) - +5 bit 7 clear: no | ||||||||||
| C835 | JR Z,$C85A | If bit 7 of the flags byte (+5) of the thing record at IX is clear, skip ahead to C85A | ||||||||||
| C837 | LD C,A | Copy A into C - B = the actor's top; A = the thing's own top | ||||||||||
| C838 | LD A,B | Copy B into A | ||||||||||
| C839 | LD B,C | Copy C into B | ||||||||||
| C83A | CALL $C863 | Call the routine "Is thing number A here? (C86E)" (C863) | ||||||||||
| C83D | LD C,A | Copy A into C | ||||||||||
| C83E | LD A,($A036) | Read $A036 in "Game variables" into A - Held by the actor: yes | ||||||||||
| C841 | CP C | Compare A with C | ||||||||||
| C842 | JR Z,$C85D | If A equals C, skip ahead to C85D | ||||||||||
| C844 | LD A,C | Copy C into A - Different tops: no | ||||||||||
| C845 | CP B | Compare A with B | ||||||||||
| C846 | JR NZ,$C85A | If A differs from B, skip ahead to C85A | ||||||||||
| C848 | INC A | Add one to A - The same holder (not $FF): yes | ||||||||||
| C849 | JR NZ,$C85D | If A is not zero, skip ahead to C85D | ||||||||||
| C84B | LD B,(IX+$00) | Read the number byte (+0) of the thing record at IX into B - Neither held: is the actor's room one of the thing's rooms? | ||||||||||
| C84E | LD A,($A00A) | Read the current actor's room (A00A) into A | ||||||||||
| C851 | CP (IX+$0F) | Compare A with the rooms byte (+15) of the thing record at IX | ||||||||||
| C854 | JR Z,$C85D | If A equals the rooms byte (+15) of the thing record at IX, skip ahead to C85D | ||||||||||
| C856 | INC IX | Step IX on to the next byte | ||||||||||
| C858 | DJNZ $C851 | Count B down and, while it is not zero, go back to C851 | ||||||||||
| C85A | XOR A | Clear A to zero (and the carry flag) - Z: no | ||||||||||
| C85B | JR $C85F | Skip ahead to C85F | ||||||||||
| C85D | OR $01 | Set bit 0 of A - NZ: yes | ||||||||||
| C85F | POP BC | Restore BC from the stack | ||||||||||
| C860 | POP IX | Restore IX from the stack | ||||||||||
| C862 | RET | Return to the caller | ||||||||||
| Prev: C7A6 | Up: Map | Next: C863 |