| Routines

7386: 'M' pressed - mount bike

The address of this routine is found in the table of keypress handling routines at E550. It is called from the main loop at F6EA when 'M' or 'B' is pressed.
Input
A | ERIC's animatory state
D | ERIC's y-coordinate
E | ERIC's x-coordinate
7386 | AND $80 | A=0x00 if ERIC's facing left, 0x80 if facing right
7388 | ADD A,$19 | A=0x19/0x99: bike standing upright
738A | LD B,A | Copy the bike's animatory state to B
738B | LD HL,$D302 | H=0xD3 (bike), L=0x02
738E | LD A,D | A=ERIC's y-coordinate
738F | CP (HL) | Is ERIC on the same floor as the bike?
7390 | RET NZ | Return if not
7391 | DEC L | L=0x01
7392 | LD A,E | A=ERIC's x-coordinate
7393 | CP (HL) | Is ERIC at the same x-coordinate as the bike?
7394 | RET NZ | Return if not
ERIC is standing beside the bike. Prepare to place him on the saddle.
7395 | DEC L | L=0x00
7396 | LD (HL),B | Fill in the animatory state of the bike
7397 | CALL $7154 | Make a sound effect
739A | LD HL,$7FFB | 7FFB holds ERIC's status flags
739D | LD (HL),$02 | Set bit 1: examine the secondary status flags at 7FED
739F | LD A,$12 |
73A1 | LD L,$EE | HL=7FEE (value from the keypress offset table corresponding to the last key pressed while riding the bike)
73A3 | LD (HL),A | Initialise this to 0x12 (which doesn't correspond to any key)
73A4 | INC L | Initialise the bike's speed counter (at 7FEF) to 0x12 (matching its initial momentum, set below, so that it doesn't move forward before ERIC has started pedalling)
73A5 | LD (HL),A
73A6 | INC L | Initialise the bike's momentum (at 7FF0) to 0x12 (giving ERIC a decent chance to start pedalling before the bike falls over)
73A7 | LD (HL),A
73A8 | LD L,$F3 | HL=7FF3 (ERIC's main action timer)
73AA | JP $7330 | Place ERIC on the bike