Prev: 65DB Up: Map Next: 663F
65E4: 'Q' pressed - up
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 'Q' or '7' is pressed, and is also used by the routines at 6652 and 66AA.
Input
B ERIC's animatory state
DE ERIC's coordinates
65E4 CALL $6564 Is ERIC sitting or lying down?
65E7 RET NZ Return if so
65E8 BIT 6,A Bit 6 of ERIC's status flags at 7FFB is always reset, so this jump is never made
65EA JR NZ,$65D3
65EC LD A,D A=ERIC's y-coordinate
65ED CP $9B Is ERIC on the top floor?
65EF JR Z,$65D3 Jump if so
65F1 CP $A2 Is ERIC on the middle floor?
65F3 JR Z,$6623 Jump if so
65F5 CP $A9 Is ERIC on the bottom floor?
65F7 JR Z,$6623 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?
65F9 LD A,E A=ERIC's x-coordinate
65FA CP $30 Set the carry flag if ERIC's on a staircase at the left of the skool
65FC BIT 7,B Set the zero flag if ERIC is facing left
65FE JR C,$6605 Jump if ERIC's on a staircase at the left of the skool
6600 JP Z,$656A Turn ERIC round if he's facing down a staircase at the right of the skool
6603 JR $6608
6605 JP NZ,$656A 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.
6608 DEC D Up a step
6609 LD H,D Copy ERIC's next coordinates to HL
660A LD L,E
660B DEC E One pace to the left
660C LD B,$02 0x02=ERIC standing, facing left
660E CP $30 Is ERIC on a staircase on the left side of the skool?
6610 JR C,$6616 Jump if so
6612 LD B,$82 0x82=ERIC standing, facing right
6614 INC E One pace to the right (taking into the account the one pace to the left made above)
6615 INC E
6616 LD A,B A=0x02/0x82
6617 BIT 0,L A=0x03/0x83, B=0x02/0x82 if ERIC's current x-coordinate is even (which is a bug); A=0x03/0x83, B=0x00/0x80 if ERIC's current x-coordinate is odd
6619 JR Z,$661D
661B DEC B
661C DEC B
661D ADD A,$02
661F DEC A
6620 JP $653C Update ERIC's animatory state and location
ERIC is on the middle floor or the top floor.
6623 LD A,E A=ERIC's x-coordinate
6624 CP $13 This is the x-coordinate of the bottoms of the staircases at the left of the skool
6626 JR NZ,$662F Jump unless ERIC is here
6628 BIT 7,B Is ERIC facing right?
662A JP NZ,$66AA Move ERIC right if so
662D JR $6608 Otherwise send ERIC up a step
662F CP $46 This is the x-coordinate of the bottoms of the staircases at the right of the skool
6631 JR NZ,$6637 Jump unless ERIC is here
6633 BIT 7,B Is ERIC facing right?
6635 JR NZ,$6608 Send ERIC up a step if so
6637 BIT 7,B Is ERIC facing left?
6639 JP Z,$6652 Move ERIC left if so
663C JP $66AA Otherwise move ERIC right
Prev: 65DB Up: Map Next: 663F