Prev: 6E4F Up: Map Next: 6E91
6E50: Check whether a character is on a staircase
Used by the routines at 5D4F, 5EC7, 6F14, 6F2C, 6F44, 6FA0, 7140 and F3D7 to check whether ERIC is on a staircase, and by the routines at 64F3 and 6558 to check whether ERIC or a teacher is on a staircase. Returns with the carry flag reset if the character is not on a staircase. Otherwise returns with the carry flag set and A holding 0x00 (if the staircase goes up and to the left) or 0x80 (if the staircase goes up and to the right).
Input
H Character number (0xC8-0xCC, 0xD2)
6E50 LD H,$D2 0xD2=ERIC
This entry point is used by the routines at 64F3 and 6558.
6E52 LD L,$01 Collect the character's coordinates in DE
6E54 LD E,(HL)
6E55 INC L
6E56 LD D,(HL)
6E57 LD A,D A=character's y-coordinate
6E58 CP $03 Is the character on the top floor?
6E5A RET Z Return with the carry flag reset if so
6E5B CP $0A Is the character on the middle floor?
6E5D RET Z Return with the carry flag reset if so
6E5E CP $11 Is the character on the bottom floor?
6E60 RET Z Return with the carry flag reset if so
6E61 CP $0E The assembly hall stage has y-coordinate 14
6E63 JR NZ,$6E6D Jump if the character's y-coordinate doesn't match that
6E65 LD A,E A=character's x-coordinate
6E66 CP $52 This is the x-coordinate of the right-hand edge of the assembly hall stage
6E68 JR NC,$6E6D Jump if the character's to the right of this
6E6A CP $4C This is the x-coordinate of the left-hand edge of the assembly hall stage
6E6C RET NC Return with the carry flag reset if the character's on the stage
The character is not standing on the top floor, middle floor, bottom floor or assembly hall stage, so he must be on a staircase. Determine the orientation of the staircase.
6E6D LD A,D A=character's y-coordinate
6E6E CP $0A Is the character somewhere between the middle and bottom floors?
6E70 JR NC,$6E7F Jump if so
6E72 LD A,E A=character's x-coordinate
6E73 CP $40 Is the character on the stairs leading up to the Revision Library?
6E75 JR C,$6E7B Jump if so
6E77 LD A,$00 Signal: character is on an up-and-to-the-left staircase
6E79 SCF Signal: character's on a staircase
6E7A RET Return with the carry flag set and A=0x00
6E7B LD A,$80 Signal: character is on an up-and-to-the-right staircase
6E7D SCF Signal: character's on a staircase
6E7E RET Return with the carry flag set and A=0x80
6E7F CP $0F
6E81 LD A,E A=character's x-coordinate
6E82 JR C,$6E8A Jump if the character is on or above the level of the assembly hall stage
6E84 CP $80 Is the character on either the stairs leading down from the stage or the stairs leading down from the toilets in the boys' skool?
6E86 JR C,$6E77 Jump if so
6E88 JR $6E7B The character is on the stairs leading down to the bottom floor in the girls' skool
6E8A CP $40 Is the character on either the stairs leading down to the stage or the stairs leading down to the bottom floor in the girls' skool?
6E8C JR NC,$6E7B Jump if so
6E8E LD A,$00 Signal: character is on an up-and-to-the-left staircase (the one leading down from the toilets in the boys' skool, in fact)
6E90 RET Return with the carry flag set and A=0
Prev: 6E4F Up: Map Next: 6E91