| Routines

F28E: Deal with ERIC when he's been knocked over

Used by the routine at F7AD when bit 7 at 7FFB is set (by the routine at 74C8). Note that the routine at 663F also sets bit 7 at 7FFB when someone sits in the seat occupied by ERIC, but in that case this routine is not called because bit 2 at 7FFB is still set (indicating that ERIC is sitting) and takes precedence; this is a bug.
F28E | LD HL,$7FDD | 7FDD holds ERIC's knockout delay counter
F291 | LD A,(HL) | Is this the first time this routine's been called since ERIC was downed?
F292 | AND A
F293 | JR Z,$F2A0 | Jump if so
F295 | DEC (HL) | Otherwise wait a while before enabling ERIC to stand up again
F296 | RET NZ
F297 | LD L,$F3 | HL=7FF3 (ERIC's main action timer)
F299 | LD (HL),$01 | Set this to 1 so that the keyboard is checked on the next pass through the main loop
F29B | LD L,$FB | HL=7FFB (ERIC's status flags)
F29D | LD (HL),$04 | Set bit 2: ERIC is sitting or lying down; the routine at F2E2 handles ERIC from this point
F29F | RET |
ERIC has just been hit. Determine the manner of his descent to the floor.
F2A0 | LD (HL),$28 | Initialise ERIC's knockout delay counter at 7FDD to 40
F2A2 | LD H,$D2 | 0xD2=ERIC
F2A4 | CALL $61B4 | Update the SRB for ERIC's current animatory state and location
F2A7 | PUSH DE | Save ERIC's coordinates briefly
F2A8 | PUSH AF | Save ERIC's current animatory state briefly
F2A9 | CP $04 | 0x04: Was ERIC sitting on a chair?
F2AB | JR NZ,$F2B6 | Jump if not
F2AD | CALL $7D00 | Get the identifier of ERIC's location
F2B0 | LD B,$05 | 0x05: ERIC sitting on the floor
F2B2 | CP $06 | Is ERIC in a classroom in the boys' skool (A=6, 7 or 8)?
F2B4 | JR NC,$F2B8 | Jump if so
F2B6 | LD B,$06 | 0x06: ERIC lying on his back
F2B8 | POP AF | Restore ERIC's current animatory state to A
F2B9 | POP DE | Restore ERIC's coordinates to DE
F2BA | AND $80 | Keep only the 'direction' bit (bit 7) of ERIC's current animatory state
F2BC | ADD A,B | A=ERIC's new animatory state (sitting on the floor or lying on his back)
F2BD | CALL $6130 | Update ERIC's animatory state and update the SRB
F2C0 | CALL $62A0 | Update the display
Now to initialise the sound effect parameters. Your browser doesn't support HTML5 audio. Here is a link to the audio instead.
F2C3 | LD HL,$0113 | H=0x01 (pitch adjustment), L=0x13 (border colour XOR mask)
This entry point is used by the routine at 5D63 with H=0x02 and L=0x16.
F2C6 | LD DE,$0000 | D=0x00 (duration), E=0x00 (initial pitch)
F2C9 | LD A,$02 | A=0x02 (initial border colour)
This entry point is used by the routines at F2E2 (with H=0xFF, L=0x17, D=0xFF, E=0xFF) and F975 (with H=0xF8, L=0x12, D=0x80, E=0x00, A=0x04).
F2CB | XOR L | Make a sound effect
F2CC | OUT ($FE),A
F2CE | LD B,E
F2CF | DJNZ $F2CF
F2D1 | LD B,A
F2D2 | LD A,E
F2D3 | ADD A,H
F2D4 | LD E,A
F2D5 | LD A,B
F2D6 | DEC D
F2D7 | JR NZ,$F2CB
This entry point is used by the routine at 5F9D.
F2D9 | EI | Re-enable interrupts
F2DA | LD A,$01 | Reset the border colour to blue
F2DC | OUT ($FE),A
F2DE | RET |