| Routines

26194: 'O' pressed - left

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 'O' or '5' is pressed, and is also used by the routines at 25983 and 26084.
Input
B | ERIC's animatory state
DE | ERIC's coordinates
26194 | CALL 25956 | Is ERIC sitting or lying down?
26197 | RET NZ | Return if so
26198 | CALL 26184 | Check whether ERIC is on a staircase
26201 | LD A,E | A=ERIC's x-coordinate
26202 | JR Z,26212 | Jump if ERIC's not on a staircase
26204 | CP 48 | Is ERIC on a staircase at the right of the skool?
26206 | JP NC,25983 | Move ERIC down a step if so
26209 | JP 26084 | Otherwise move ERIC up a step
26212 | BIT 7,B | Is ERIC facing right?
26214 | JP NZ,25962 | Turn ERIC round if so
ERIC is facing left, and is not on a staircase.
26217 | AND A | Is ERIC standing at the far left side of the skool?
26218 | RET Z | Return if so
26219 | LD A,D | A=ERIC's y-coordinate
26220 | CP 169 | Is ERIC on the bottom floor?
26222 | JR Z,26234 | Jump if so
26224 | CP 155 | Set the zero flag if ERIC is on the top floor
26226 | LD A,58 | This is the x-coordinate of the wall between the Map and Reading Rooms
26228 | JR Z,26232 | Jump if ERIC's on the top floor
26230 | LD A,39 | This is the x-coordinate of the wall between the Exam and White Rooms
26232 | CP E | Is ERIC facing this wall (from the right side)?
26233 | RET Z | Return if so (ERIC cannot walk through walls)
There is no wall obstructing ERIC, so it's time to put him midstride.
26234 | LD A,1 | A=1 (ERIC midstride, facing left)
26236 | LD L,E | L=ERIC's current x-coordinate
26237 | DEC E | E=ERIC's post-midstride x-coordinate
This entry point is used by the routine at 26282 with A=129 (ERIC facing right, midstride).
26238 | LD C,A | C=1/129 (ERIC midstride)
26239 | LD A,(32764) | 32764 holds the ASCII code of the last keypress
26242 | BIT 5,A | Was the last keypress upper case (fast)?
26244 | JR Z,26250 | Jump if so
26246 | LD A,C | Clearly these instructions have no effect, but one wonders what they might once have been and done
26247 | ADD A,0
26249 | LD C,A
26250 | LD A,(32763) | Collect ERIC's status flags from 32763
26253 | BIT 6,A | Bit 6 is always reset, so this jump is always made
26255 | JR Z,26261
26257 | LD A,C | Clearly these instructions have no effect, but one wonders what they might once have been and done
26258 | ADD A,0
26260 | LD C,A
26261 | LD A,C | A=1/129 (ERIC midstride)
26262 | LD H,D | H=ERIC's current y-coordinate
26263 | LD B,A | B=2/130 (ERIC standing, phase 3)
26264 | INC B
26265 | BIT 0,L | Is ERIC's current x-coordinate even?
26267 | JR Z,26273 | Jump if so
26269 | DEC B | Adjust ERIC's midstride animatory state (in A) to 3/131 and post-midstride animatory state (in B) to 0/128 if ERIC's current x-coordinate is odd
26270 | DEC B
26271 | ADD A,2
26273 | JP 25916 | Put ERIC midstride