Routines

62483: Check for keypresses during game (or simulate them in demo mode)


Called from the main loop at 63210

62483 3ADE7F LD A,(32734)
62486 3C INC A Are we in demo mode?
62487 C2FA71 JP NZ,29178 Jump if not
62490 210000 LD HL,0
62493 22E57F LD (32741),HL Set score to 0
62496 22E77F LD (32743),HL Set number of lines to 0
62499 CDBE71 CALL 29118 Check for keypresses
62502 C2D5F6 JP NZ,63189 Start a new game if there was one
62505 ED5B01C7 LD DE,(50945) Pick up the coordinates of little boy no. 10 in DE
62509 26D2 LD H,210 210=ERIC
62511 CDF364 CALL 25843 Compare the coordinates of ERIC and little boy no. 10
62514 A7 AND A Are they the same?
62515 2810 JR Z,62533 Jump if so
62517 3D DEC A 0≤A≤3
62518 21785C LD HL,23672 Point HL at the LSB of the system variable FRAMES
62521 EE02 XOR 2 Flip bit 1 of A
62523 CB7E BIT 7,(HL)
62525 2802 JR Z,62529 Jump if the LSB of FRAMES is < 128
62527 C604 ADD A,4 4≤A≤7: force lowercase (slow) keypress
62529 87 ADD A,A A=80+2n where 0≤n≤7 ("simulated" keypress for LEFT, RIGHT, UP, DOWN or left, right, up, down)
62530 C650 ADD A,80
62532 C9 RET
62533 3A00C7 LD A,(50944) A=animatory state of little boy no. 10
62536 FE44 CP 68 68: little boy sitting in a chair
62538 2100D2 LD HL,53760
62541 2806 JR Z,62549 Jump if little boy no. 10 is sitting in a chair
62543 FEC5 CP 197 197: Is little boy no. 10 sitting on the floor facing right (as in assembly)?
62545 2802 JR Z,62549 Jump if so
62547 AF XOR A No simulated keypress (ERIC stays still)
62548 C9 RET
62549 AE XOR (HL) Set carry if ERIC and little boy no. 10 are facing in opposite directions
62550 07 RLCA
62551 3E62 LD A,98 98=keypress code for 'S' (sit/stand)
62553 D0 RET NC Return if ERIC and little boy no. 10 are facing the same way
62554 7E LD A,(HL) A=ERIC's animatory state
62555 07 RLCA Set A to 1 if ERIC is facing left (leading to a simulated keypress code of 82, or RIGHT), 0 if he's facing right (leading to a simulated keypress code of 80, or LEFT); that is, make ERIC turn round
62556 9F SBC A,A
62557 3C INC A
62558 18E1 JR 62529