Prev: $1A50 Up: Map Next: $1B2E
$1A51: Check whether a character is beside a chair
This corresponds to $6BF0 in the ZX Spectrum version.
Used by the routines at $1CEC and $3687. Returns with the carry flag set if the character must turn round first. Otherwise returns with the zero flag set only if the character is standing beside a chair and is facing the right way to sit on it.
$1A51 LDA $26 Pick up the character's animatory state from $26.
$1A53 ASL A Is the character facing left?
$1A54 BCC $1A59 Branch if so.
$1A56 JMP $1ADD Otherwise jump forward.
The character is facing left.
$1A59 LDX $FC Pick up the character's x- and y-coordinates from $FB and $FC.
$1A5B LDY $FB
$1A5D JSR $126D Get the play area region identifier for the character's location.
$1A60 BEQ $1AAB Branch if the character's on the top floor, to the left of the Map Room wall.
$1A62 CMP #$04 Is the character on the top floor, to the right of the Map Room wall?
$1A64 BEQ $1AAB Branch if so.
The character is facing left, and is on the middle floor.
$1A66 LDA $FC Pick up the character's x-coordinate from $FC.
$1A68 CMP #$27 Is the character to the right of the Exam Room wall?
$1A6A BCS $1A82 Branch if so.
$1A6C CMP #$1D Is the character at or to the right of the leftmost chair in the White Room?
$1A6E BCS $1A73 Branch if so.
$1A70 JMP $1B1E Jump forward (the character should turn round).
$1A73 CMP #$26 Is the character to the right of the rightmost chair in the White Room?
$1A75 BCS $1A7F Branch if so (the character is not beside a chair).
$1A77 STA $57 Store the character's x-coordinate at $57.
$1A79 LSR A Is the character's x-coordinate even?
$1A7A BCC $1A7F Branch if so (the character is not beside a chair).
$1A7C JMP $1B2A Otherwise jump forward (the character is beside a chair).
$1A7F JMP $1B24 Jump forward (the character should keep moving in the same direction).
The character is facing left, and is on the middle floor, to the right of the Exam Room wall.
$1A82 CMP #$2B Is the character at or to the right of the leftmost chair in the Exam Room?
$1A84 BCS $1A89 Branch if so.
$1A86 JMP $1B1E Jump forward (the character should turn round).
$1A89 CMP #$45 Is the character to the right of the rightmost chair in the Exam Room?
$1A8B BCS $1AA8 Branch if so (the character is not beside a chair).
$1A8D CMP #$3C Is the character between the first and last chairs in the set furthest from the blackboard?
$1A8F BCS $1AA0 Branch if so.
$1A91 CMP #$36 Is the character to the right of the set of chairs nearest the blackboard?
$1A93 BCS $1A9D Branch if so (the character is not beside a chair).
$1A95 STA $57 Store the character's x-coordinate at $57.
$1A97 LSR A Is the character's x-coordinate even?
$1A98 BCC $1A9D Branch if so (the character should keep moving in the same direction).
$1A9A JMP $1B2A Otherwise jump forward (the character is beside a chair).
$1A9D JMP $1B24 Jump forward (the character should keep moving in the same direction).
$1AA0 STA $57 Store the character's x-coordinate at $57.
$1AA2 LSR A Is the character's x-coordinate odd?
$1AA3 BCS $1AA8 Branch if so (the character should keep moving in the same direction).
$1AA5 JMP $1B2A Otherwise jump forward (the character is beside a chair).
$1AA8 JMP $1B24 Jump forward (the character should keep moving in the same direction).
The character is facing left, and is on the top floor.
$1AAB LDA $FC Pick up the character's x-coordinate from $FC.
$1AAD CMP #$3A Is the character to the right of the Map Room wall?
$1AAF BCS $1AC7 Branch if so.
$1AB1 CMP #$30 Is the character at or to the right of the leftmost chair in the Reading Room?
$1AB3 BCS $1AB8 Branch if so.
$1AB5 JMP $1B1E Otherwise jump forward (the character should turn round).
$1AB8 CMP #$39 Is the character to the right of the rightmost chair in the Reading Room?
$1ABA BCS $1AC4 Branch if so (the character is not beside a chair).
$1ABC STA $57 Store the character's x-coordinate at $57.
$1ABE LSR A Is the character's x-coordinate odd?
$1ABF BCS $1AC4 Branch if so (the character should keep moving in the same direction).
$1AC1 JMP $1B2A Otherwise jump forward (the character is beside a chair).
$1AC4 JMP $1B24 Jump forward (the character should keep moving in the same direction).
The character is facing left, and is on the top floor, to the right of the Map Room wall.
$1AC7 CMP #$40 Is the character at or to the right of the leftmost chair in the Map Room?
$1AC9 BCS $1ACE Branch if so.
$1ACB JMP $1B1E Otherwise jump forward (the character should turn round).
$1ACE CMP #$49 Is the character to the right of the rightmost chair in the Map Room?
$1AD0 BCS $1ADA Branch if so (the character is not beside a chair).
$1AD2 STA $57 Store the character's x-coordinate at $57.
$1AD4 LSR A Is the character's x-coordinate odd?
$1AD5 BCS $1ADA Branch if so (the character should keep moving in the same direction).
$1AD7 JMP $1B2A Otherwise jump forward (the character is beside a chair).
$1ADA JMP $1B24 Jump forward (the character should keep moving in the same direction).
The character is facing right.
$1ADD LDX $FC Pick up the character's x- and y-coordinates from $FB and $FC.
$1ADF LDY $FB
$1AE1 JSR $126D Get the play area region identifier for the character's location.
$1AE4 BEQ $1B04 Branch if the character is on the top floor, to the left of the Map Room wall.
$1AE6 CMP #$04 Is the character on the top floor, to the right of the Map Room wall?
$1AE8 BEQ $1B04 Branch if so.
The character is facing right, and is on the middle floor.
$1AEA LDA $FC Pick up the character's x-coordinate from $FC.
$1AEC CMP #$27 Is the character to the right of the Exam Room wall?
$1AEE BCS $1AFA Branch if so.
$1AF0 CMP #$25 Is the character to the right of the rightmost chair in the White Room?
$1AF2 BCS $1AF7 Branch if so (the character should turn round).
$1AF4 JMP $1B24 Otherwise jump forward (the character should keep moving in the same direction).
$1AF7 JMP $1B1E Jump forward (the character should turn round).
The character is facing right, and is on the middle floor, to the right of the Exam Room wall.
$1AFA CMP #$44 Is the character to the right of the rightmost chair in the Exam Room?
$1AFC BCS $1B01 Branch if so (the character should turn round).
$1AFE JMP $1B24 Otherwise jump forward (the character should keep moving in the same direction).
$1B01 JMP $1B1E Jump forward (the character should turn round).
The character is facing right, and is on the top floor.
$1B04 LDA $FC Pick up the character's x-coordinate from $FC.
$1B06 CMP #$3A Is the character to the right of the Map Room wall?
$1B08 BCS $1B14 Branch if so.
$1B0A CMP #$38 Is the character at or to the right of the rightmost chair in the Reading Room?
$1B0C BCS $1B11 Branch if so (the character should turn round).
$1B0E JMP $1B24 Otherwise jump forward (the character should keep moving in the same direction).
$1B11 JMP $1B1E Jump forward (the character should turn round).
The character is facing right, and is on the top floor, to the right of the Map Room wall.
$1B14 CMP #$48 Is the character to the right of the rightmost chair in the Map Room?
$1B16 BCS $1B1B Branch if so (the character should turn round).
$1B18 JMP $1B24 Otherwise jump forward (the character should keep moving in the same direction).
$1B1B JMP $1B1E Jump forward (this instruction is redundant).
$1B1E SEC Carry flag set and zero flag reset: the character should turn round.
$1B1F LDA #$FF
$1B21 JMP $1B2D Return.
$1B24 CLC Carry flag reset and zero flag reset: the character should keep moving in the same direction.
$1B25 LDA #$FF
$1B27 JMP $1B2D Return.
$1B2A CLC Carry flag reset and zero flag set: the character is beside a chair and facing the right way to sit down.
$1B2B LDA #$00
$1B2D RTS
Prev: $1A50 Up: Map Next: $1B2E