| Routines

7596: Deal with a character who has been knocked over

The address of this uninterruptible subcommand routine is placed into bytes 0x11 and 0x12 of the stricken character's buffer by the routine at 74C8. It knocks the character to the floor, makes him give lines to any nearby kids (if he's a teacher), and then makes him get up.
Input
H | Character number (0xB7-0xD1)
7596 | LD L,$13 | Byte 0x13 of the character's buffer holds the knockout delay counter
7598 | DEC (HL) | Has the character already got up?
7599 | JP Z,$6394 | Terminate this uninterruptible subcommand if so
759C | LD A,(HL) | A=knockout delay counter
759D | DEC A | Is it time for the character to get up yet?
759E | JR NZ,$75A9 | Jump if not
This entry point is used by the routine at F939.
75A0 | CALL $61B4 | Update the SRB for the character's current animatory state
This entry point is used by the routine at 7132.
75A3 | LD L,$14 | Byte 0x14 of the character's buffer holds the pre-knockout animatory state saved earlier
75A5 | LD A,(HL) | Pick this up in A
75A6 | JP $6130 | Update the character's animatory state and update the SRB
It's not time for the character to get up yet.
75A9 | DEC A | Jump forward unless the knockout delay counter has reached 2
75AA | JR NZ,$75B9
75AC | LD A,H | A=number of the stricken character
75AD | CP $CD | Is it ALBERT?
75AF | RET NZ | Return if not
75B0 | LD A,($7FE4) | Pick up the MSB of the lesson clock
75B3 | AND A | Is the lesson nearly over?
75B4 | RET Z | Return if so
75B5 | LD L,$13 | Set the knockout delay counter to 3 so that ALBERT will not get up until the lesson's almost over
75B7 | INC (HL)
75B8 | RET |
The knockout delay counter has not reached 2 yet. Is it time to knock the character down?
75B9 | CP $0F | Is it time for the character to fall over?
75BB | JR NZ,$75E4 | Jump if not
75BD | LD A,H | A=number of the stricken character
75BE | LD DE,$7FE4 | Point DE at the MSB of the lesson clock
75C1 | CP $CD | Was ALBERT struck?
75C3 | JR NZ,$75CB | Jump if not
75C5 | LD A,(DE) | Add 0x0C to the MSB of the lesson clock if ALBERT was knocked down, thus giving ERIC some extra time to work with
75C6 | ADD A,$0C
75C8 | LD (DE),A
75C9 | JR $75D7 | Knock ALBERT down
75CB | CP $D1 | Was HAYLEY struck?
75CD | JR NZ,$75D7 | Jump if not
75CF | LD E,$E2 | DE=7FE2 (kiss counter)
75D1 | LD A,(DE) | Pick this up in A
75D2 | AND A | Are there any kisses left?
75D3 | JR Z,$75D7 | Jump if not
75D5 | DEC A | Otherwise decrease the kiss counter by 1
75D6 | LD (DE),A
Knock the character down.
75D7 | CALL $61B4 | Update the SRB for the character's current animatory state
75DA | LD L,$14 | Store the character's current animatory state in byte 0x14 of the buffer for retrieval later (when the character gets up)
75DC | LD (HL),A
75DD | AND $F8 | A=animatory state of the character sitting or lying on the floor
75DF | ADD A,$06
75E1 | JP $6130 | Update the character's animatory state and update the SRB
It's not time to knock the character down.
75E4 | CP $08 | Is it time for a felled teacher to give lines?
75E6 | RET NZ | Return if not
75E7 | LD A,H | A=number of the stricken character
75E8 | CP $C8 | Return if it's not a teacher
75EA | RET C
75EB | CP $CD
75ED | RET NC
75EE | PUSH HL |
75EF | CALL $6D7D | Find the main kid who is closest to the teacher and within lines-giving range (if any)
75F2 | POP HL |
75F3 | AND A | Is there a main kid close enough to the felled teacher?
75F4 | RET Z | Return if not
75F5 | LD B,$0F | Message 0x0F: NOW DON'T DO IT AGAIN
75F7 | JP $7414 | Give lines to the nearest main kid