| Routines

7316: Deal with ERIC when he's standing on the saddle of the bike

Called by the routine at F7AD when bit 7 at 7FED is set (by the routine at 725E). Listens for and responds appropriately to keypresses while ERIC is standing on the saddle of the bike.
7316 | LD HL,$7FF3 | 7FF3 holds ERIC's main action timer
7319 | DEC (HL) | Is it time to deal with ERIC yet?
731A | RET NZ | Return if not
731B | INC (HL) | Set ERIC's action timer to 1, ensuring that we pass through the following section of code on the next call to this routine if no keypress is detected this time
731C | CALL $71FA | A=value from the keypress offset table corresponding to the key just pressed (if any)
731F | RET Z | Return if no game key was pressed
7320 | LD HL,$7FF3 | 7FF3 holds ERIC's main action timer
7323 | CP $72 | Was 'jump' pressed?
7325 | JR Z,$734D | Jump if so
7327 | SET 3,A | Ignore the difference between fast (upper case) and slow (lower case) keys when ERIC's on the bike
7329 | CP $5C | Was 'up' pressed?
732B | JR Z,$734D | Jump if so
732D | CP $5E | Was 'down' pressed?
732F | RET NZ | Return if not
This entry point is used by the routine at 7386 when ERIC has just got on the bike.
7330 | LD (HL),$05 | Reset ERIC's main action timer at 7FF3 to 5
7332 | LD L,$ED | HL=7FED (ERIC's status flags)
7334 | LD (HL),$01 | Set bit 0: ERIC is riding the bike
7336 | LD H,$D2 | 0xD2=ERIC
7338 | CALL $61B4 | Update the SRB for ERIC's current animatory state and location
733B | INC H | H=0xD3: bike
733C | CALL $61B4 | Update the SRB for the bike's current animatory state and location
733F | LD L,$01 | Point HL at byte 0x01 of the bike's buffer
7341 | LD (HL),$E0 | Set the bike's x-coordinate to 224 (out of sight)
7343 | LD L,$12 | Remove the address of the routine at 720A from bytes 0x11 and 0x12 of the bike's buffer
7345 | LD (HL),$00
7347 | DEC H | H=0xD2: ERIC
7348 | SUB $0C | A=animatory state of ERIC riding the bike
734A | JP $6130 | Update ERIC's animatory state and update the SRB
ERIC has tried to jump off the saddle of the bike. Check whether he has the frog and is underneath a cup.
734D | LD H,$D2 | 0xD2=ERIC
734F | CALL $61B4 | Update the SRB for ERIC's current animatory state and location
7352 | ADD A,$02 | A=0x02 or 0x82
7354 | DEC D | Set D to the y-coordinate of the spot above ERIC's hand as he jumps from the saddle
7355 | DEC D
7356 | CALL $FBDA | Prepare ERIC for his descent from the bike saddle
7359 | LD H,$D2 | 0xD2=ERIC
735B | XOR A |
735C | LD L,A | Point HL at byte 0x00 of ERIC's buffer
735D | BIT 7,(HL) | Is ERIC facing left?
735F | JR Z,$7363 | Jump if so
7361 | LD A,$02 |
7363 | INC L | Point HL at byte 0x01 of ERIC's buffer
7364 | ADD A,(HL) | A=x-coordinate of ERIC's hand
7365 | LD E,A | Now DE=coordinates of the spot above ERIC's hand
7366 | LD HL,$7FEB | 7FEB holds the inventory flags
7369 | BIT 2,(HL) | Has ERIC got the frog?
736B | RET Z | Return if not
736C | CALL $7608 | Is ERIC's arm directly underneath a cup?
736F | RET NZ | Return if not
7370 | RES 2,(HL) | Signal: ERIC no longer has the frog
7372 | LD H,$D4 | 0xD4=frog
7374 | LD A,$1C | 0x1C: frog sitting (as on the floor or in a cup)
7376 | DEC E | Set DE to the frog's new in-cup coordinates
7377 | LD D,$0B
7379 | CALL $6130 | Update the frog's animatory state and location and update the SRB
737C | JP $F3C1 | Print the inventory and make a celebratory sound effect