Prev: 66A4 Up: Map Next: 66E0
66AA: 'P' pressed - right
The address of this routine is found in the table of keypress handling routines at 6800. It is called from the main loop at 6767 when 'P' or '8' is pressed, and is also used by the routines at 657F and 65E4.
Input
B ERIC's animatory state
DE ERIC's coordinates
66AA CALL $6564 Is ERIC sitting or lying down?
66AD RET NZ Return if so
66AE CALL $6648 Check whether ERIC is on a staircase
66B1 LD A,E A=ERIC's x-coordinate
66B2 JR Z,$66BC Jump if ERIC's not on a staircase
66B4 CP $30 Is ERIC on a staircase at the right of the skool?
66B6 JP NC,$65E4 Jump if so
66B9 JP $657F
66BC BIT 7,B Is ERIC facing left?
66BE JP Z,$656A Turn ERIC round if so
ERIC is facing right, and is not on a staircase.
66C1 CP $5D Is ERIC at the far right of the skool?
66C3 RET Z Return if so
66C4 LD A,D A=ERIC's y-coordinate
66C5 CP $A9 Is ERIC on the bottom floor?
66C7 JR Z,$66D9 Jump if so
66C9 CP $A2 Is ERIC on the middle floor?
66CB JR NZ,$66D5 Jump if not
66CD LD A,E A=ERIC's x-coordinate
66CE CP $4E This is the x-coordinate of the far right wall on the middle floor
66D0 RET Z Return if ERIC is facing this wall
66D1 LD A,$25 This is the x-coordinate of the wall between the White and Exam Rooms
66D3 JR $66D7
66D5 LD A,$38 This is the x-coordinate of the wall between the Reading and Map Rooms
66D7 CP E Is ERIC facing this wall (from the left side)?
66D8 RET Z Return if so (ERIC cannot walk through walls)
There is no wall obstructing ERIC, so it's time to put him midstride.
66D9 LD A,$81 0x81=ERIC midstride, facing right
66DB LD L,E L=ERIC's current x-coordinate
66DC INC E E=ERIC's post-midstride x-coordinate
66DD JP $667E Put ERIC midstride
Prev: 66A4 Up: Map Next: 66E0