| Routines

26084: 'Q' pressed - up

The address of this routine is found in the table of keypress handling routines at 26624. It is called from the main loop at 26471 when 'Q' or '7' is pressed, and is also used by the routines at 26194 and 26282.
Input
B | ERIC's animatory state
DE | ERIC's coordinates
26084 | CALL 25956 | Is ERIC sitting or lying down?
26087 | RET NZ | Return if so
26088 | BIT 6,A | Bit 6 of ERIC's status flags at 32763 is always reset, so this jump is never made
26090 | JR NZ,26067
26092 | LD A,D | A=ERIC's y-coordinate
26093 | CP 155 | Is ERIC on the top floor?
26095 | JR Z,26067 | Jump if so
26097 | CP 162 | Is ERIC on the middle floor?
26099 | JR Z,26147 | Jump if so
26101 | CP 169 | Is ERIC on the bottom floor?
26103 | JR Z,26147 | Jump if so
ERIC's not on the top, middle or bottom floor, so he must be on a staircase. Should he go up a step, or turn round first?
26105 | LD A,E | A=ERIC's x-coordinate
26106 | CP 48 | Set the carry flag if ERIC's on a staircase at the left of the skool
26108 | BIT 7,B | Set the zero flag if ERIC is facing left
26110 | JR C,26117 | Jump if ERIC's on a staircase at the left of the skool
26112 | JP Z,25962 | Turn ERIC round if he's facing down a staircase at the right of the skool
26115 | JR 26120 |
26117 | JP NZ,25962 | Turn ERIC round if he's facing down a staircase at the left of the skool
ERIC's at the bottom of or on a staircase, facing the top of it.
26120 | DEC D | Up a step
26121 | LD H,D | Copy ERIC's next coordinates to HL
26122 | LD L,E
26123 | DEC E | One pace to the left
26124 | LD B,2 | 2=ERIC standing, facing left
26126 | CP 48 | Is ERIC on a staircase on the left side of the skool?
26128 | JR C,26134 | Jump if so
26130 | LD B,130 | 130=ERIC standing, facing right
26132 | INC E | One pace to the right (taking into the account the one pace to the left made above)
26133 | INC E
26134 | LD A,B | A=2/130
26135 | BIT 0,L | A=3/131, B=2/130 if ERIC's current x-coordinate is even (which is a bug); A=3/131, B=0/128 if ERIC's current x-coordinate is odd
26137 | JR Z,26141
26139 | DEC B
26140 | DEC B
26141 | ADD A,2
26143 | DEC A
26144 | JP 25916 | Update ERIC's animatory state and location
ERIC is on the middle floor or the top floor.
26147 | LD A,E | A=ERIC's x-coordinate
26148 | CP 19 | This is the x-coordinate of the bottoms of the staircases at the left of the skool
26150 | JR NZ,26159 | Jump unless ERIC is here
26152 | BIT 7,B | Is ERIC facing right?
26154 | JP NZ,26282 | Move ERIC right if so
26157 | JR 26120 | Otherwise send ERIC up a step
26159 | CP 70 | This is the x-coordinate of the bottoms of the staircases at the right of the skool
26161 | JR NZ,26167 | Jump unless ERIC is here
26163 | BIT 7,B | Is ERIC facing right?
26165 | JR NZ,26120 | Send ERIC up a step if so
26167 | BIT 7,B | Is ERIC facing left?
26169 | JP Z,26194 | Move ERIC left if so
26172 | JP 26282 | Otherwise move ERIC right