Prev: F5D9 Up: Map Next: F64F
F5DA: Collect a keypress during the game (or simulate one in demo mode)
Called from the main loop at 6767. Returns with A holding the ASCII code of the last (actual or simulated) keypress, or the zero flag set if there was no (actual or simulated) keypress.
F5DA LD HL,$7FEA 7FEA holds the game mode indicator
F5DD LD A,(HL) Are we in demo mode?
F5DE AND A
F5DF JP NZ,$673A Collect a keypress if not
We're in demo mode.
F5E2 LD L,$C7 Point HL at the MSB of the lines total
F5E4 LD B,$04 Reset the score (stored at 7FC4) and lines total (stored at 7FC6) to zero
F5E6 LD (HL),A
F5E7 DEC L
F5E8 DJNZ $F5E6
F5EA CALL $673A Check for input from the keyboard or joystick
F5ED JP NZ,$7DFA Exit demo mode if there was input
We're in demo mode and there was no keyboard or joystick input. Time to simulate a keypress to move ERIC.
F5F0 LD A,($AC60) A=ERIC's animatory state
F5F3 CP $05 0x05=ERIC sitting in a chair
F5F5 LD HL,$7FC1 7FC1 holds the stand-up delay counter
F5F8 JR NZ,$F614 Jump unless ERIC is sitting in a chair
F5FA LD A,($A260) A=animatory state of little boy no. 11
F5FD CP $45 0x45=little boy sitting in a chair
F5FF JR Z,$F611 Jump if little boy no. 11 is sitting in a chair
ERIC is sitting in a chair, but little boy no. 11 isn't. ERIC should stand up now or soon.
F601 LD A,(HL) The stand-up delay counter at 7FC1 normally holds 0x00; if little boy no. 11 has just stood up, initialise the delay counter to 0x1D
F602 AND A
F603 JR Z,$F60E
F605 DEC (HL) Is it time for ERIC to stand up?
F606 JR NZ,$F60C Jump if not
F608 LD A,$73 Set A to 0x73 to simulate 's' (sit/stand) being pressed
F60A AND A Return with the zero flag reset to indicate input
F60B RET
F60C XOR A Return with the zero flag set to indicate no input
F60D RET
F60E LD (HL),$1D Initialise the stand-up delay counter at 7FC1 to 0x1D
F610 RET Return with the zero flag set to indicate no input
F611 LD (HL),$00 Set the stand-up delay counter at 7FC1 to 0x00
F613 RET Return with the zero flag set to indicate no input
ERIC isn't sitting in a chair. Is he sitting on the floor or lying on his back?
F614 LD (HL),$00 Set the stand-up delay counter at 7FC1 to 0x00
F616 LD L,$FB HL=7FFB (ERIC's status flags)
F618 BIT 7,(HL) Is ERIC sitting on the floor or lying on his back?
F61A JR NZ,$F608 Simulate 's' to make ERIC stand up if so
ERIC is upright. Seek little boy no. 11 for guidance on where to go next.
F61C LD HL,$A261 Pick up the coordinates of little boy no. 11 in DE
F61F LD D,(HL)
F620 INC L
F621 LD E,(HL)
F622 LD H,$AC 0xAC=ERIC
F624 CALL $7ADC Determine ERIC's next move in his pursuit of little boy no. 11
F627 AND A Are ERIC and this boy in the same location?
F628 JR NZ,$F639 Jump if not
ERIC and little boy no. 11 are in the same location.
F62A LD A,($A260) A=animatory state of little boy no. 11
F62D CP $45 Is little boy no. 11 sitting in a chair?
F62F JR NZ,$F60C Jump if not (without simulating a keypress)
F631 LD A,($AC60) A=ERIC's animatory state
F634 RLCA Is ERIC facing left?
F635 JR NC,$F608 Simulate 's' (sit down) if so
F637 LD A,$03 Otherwise set A=3: ERIC should go left (i.e. turn round)
Now A=1 if ERIC should go up, 2 if down, 3 if left, or 4 if right (to follow little boy no. 11).
F639 LD B,$51 0x51=ASCII code for 'Q' (up)
F63B DEC A Should ERIC go up?
F63C JR Z,$F646 Jump if so
F63E LD B,$41 0x41=ASCII code for 'A' (down)
F640 DEC A Should ERIC go down?
F641 JR Z,$F646 Jump if so
F643 ADD A,$4E B=0x4F ('O') or 0x50 ('P')
F645 LD B,A
Now B holds the ASCII code of the simulated keypress: Q, A, O or P. Decide whether to switch to lower case (slow).
F646 LD A,($5C78) 5C78=LSB of the FRAMES system variable
F649 AND $80 A=0x20 (lower case, slow) or 0x00 (upper case, fast)
F64B RRCA
F64C RRCA
F64D ADD A,B A=simulated keycode
F64E RET Return with the zero flag reset to indicate input
Prev: F5D9 Up: Map Next: F64F