| Routines

720A: Control the bike when ERIC's not sitting on the saddle

The address of this uninterruptible subcommand routine is placed into bytes 0x11 and 0x12 of the bike's buffer by the routine at 725E. It controls the bike when it is wheeling along on its own (after ERIC has dismounted), or when ERIC is standing on the saddle.
720A | LD HL,$7FF0 | 7FF0 holds the bike's momentum
720D | LD A,(HL) | Pick this up in A
720E | SUB $07 | Is it time for the bike to come to rest?
7210 | JR NC,$7227 | Jump if not
It's time for the bike to come to rest.
7212 | LD L,$ED | HL=7FED (ERIC's status flags)
7214 | BIT 7,(HL) | Is ERIC standing on the saddle of the bike?
7216 | JR Z,$721A | Jump if not
7218 | LD (HL),$10 | Set bit 4 at 7FED: ERIC is falling and will not land on his feet
721A | LD H,$D3 | 0xD3=bike
721C | CALL $61B4 | Update the SRB for the bike's current animatory state and location
721F | DEC A | A=animatory state of the bike resting on the floor
7220 | LD L,$12 | Remove the address of this routine from bytes 0x11 and 0x12 of the bike's buffer
7222 | LD (HL),$00
7224 | JP $6130 | Update the bike's animatory state and update the SRB
The bike still has some momentum left. Check whether it has hit anything.
7227 | LD (HL),A | Set the bike's remaining momentum at 7FF0
7228 | LD HL,($D300) | E=bike's x-coordinate, A=bike's animatory state
722B | LD A,L
722C | LD E,H
722D | CALL $7000 | Check for walls, closed doors or ALBERT in the bike's path
7230 | LD L,$ED | HL=7FED (ERIC's status flags)
7232 | JR NC,$723A | Jump if ALBERT's not impeding the bike's progress
7234 | BIT 7,(HL) | Is ERIC standing on the saddle of the bike?
7236 | JR Z,$7244 | Jump if not
7238 | LD (HL),$10 | Set bit 4: ERIC is falling and will not land on his feet
723A | JR NZ,$7244 | Jump if there are no walls or closed doors in the bike's path
723C | BIT 7,(HL) | Is ERIC standing on the saddle of the bike?
723E | JR Z,$721A | Jump if not
7240 | LD (HL),$40 | Set bit 6: ERIC has hit a wall or closed door while standing on the saddle of the bike
7242 | JR $721A |
7244 | LD H,$D3 | 0xD3=bike
7246 | CALL $7250 | Move the bike and one space forward and update the SRB
7249 | LD A,($7FED) | 7FED holds ERIC's status flags
724C | RLCA | Is ERIC standing on the saddle of the bike?
724D | RET NC | Return if not
This entry point is used by the routine at 725E.
724E | LD H,$D2 | 0xD2=ERIC
This entry point is used by the routine at 76AC.
7250 | CALL $61B4 | Update the SRB for the character's current animatory state and location
7253 | RLCA |
7254 | RRCA |
7255 | JR C,$7259 | Jump if the character is facing right
7257 | DEC E |
7258 | DEC E |
7259 | INC E | Now E=x-coordinate of the spot in front of the character
725A | JP $7BEB | Update the character's location, update the SRB, and scroll the screen if necessary