| Routines

30102: Deal with a character who has been knocked over

The address of this uninterruptible subcommand routine is placed into bytes 17 and 18 of the stricken character's buffer by the routine at 29896. 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 (183-209)
30102 | LD L,19 | Byte 19 of the character's buffer holds the knockout delay counter
30104 | DEC (HL) | Has the character already got up?
30105 | JP Z,25492 | Terminate this uninterruptible subcommand if so
30108 | LD A,(HL) | A=knockout delay counter
30109 | DEC A | Is it time for the character to get up yet?
30110 | JR NZ,30121 | Jump if not
This entry point is used by the routine at 63801.
30112 | CALL 25012 | Update the SRB for the character's current animatory state
This entry point is used by the routine at 28978.
30115 | LD L,20 | Byte 20 of the character's buffer holds the pre-knockout animatory state saved earlier
30117 | LD A,(HL) | Pick this up in A
30118 | JP 24880 | Update the character's animatory state and update the SRB
It's not time for the character to get up yet.
30121 | DEC A | Jump forward unless the knockout delay counter has reached 2
30122 | JR NZ,30137
30124 | LD A,H | A=number of the stricken character
30125 | CP 205 | Is it ALBERT?
30127 | RET NZ | Return if not
30128 | LD A,(32740) | Pick up the MSB of the lesson clock
30131 | AND A | Is the lesson nearly over?
30132 | RET Z | Return if so
30133 | LD L,19 | Set the knockout delay counter to 3 so that ALBERT will not get up until the lesson's almost over
30135 | INC (HL)
30136 | RET |
The knockout delay counter has not reached 2 yet. Is it time to knock the character down?
30137 | CP 15 | Is it time for the character to fall over?
30139 | JR NZ,30180 | Jump if not
30141 | LD A,H | A=number of the stricken character
30142 | LD DE,32740 | Point DE at the MSB of the lesson clock
30145 | CP 205 | Was ALBERT struck?
30147 | JR NZ,30155 | Jump if not
30149 | LD A,(DE) | Add 12 to the MSB of the lesson clock if ALBERT was knocked down, thus giving ERIC some extra time to work with
30150 | ADD A,12
30152 | LD (DE),A
30153 | JR 30167 | Knock ALBERT down
30155 | CP 209 | Was HAYLEY struck?
30157 | JR NZ,30167 | Jump if not
30159 | LD E,226 | DE=32738 (kiss counter)
30161 | LD A,(DE) | Pick this up in A
30162 | AND A | Are there any kisses left?
30163 | JR Z,30167 | Jump if not
30165 | DEC A | Otherwise decrease the kiss counter by 1
30166 | LD (DE),A
Knock the character down.
30167 | CALL 25012 | Update the SRB for the character's current animatory state
30170 | LD L,20 | Store the character's current animatory state in byte 20 of the buffer for retrieval later (when the character gets up)
30172 | LD (HL),A
30173 | AND 248 | A=animatory state of the character sitting or lying on the floor
30175 | ADD A,6
30177 | JP 24880 | Update the character's animatory state and update the SRB
It's not time to knock the character down.
30180 | CP 8 | Is it time for a felled teacher to give lines?
30182 | RET NZ | Return if not
30183 | LD A,H | A=number of the stricken character
30184 | CP 200 | Return if it's not a teacher
30186 | RET C
30187 | CP 205
30189 | RET NC
30190 | PUSH HL |
30191 | CALL 28029 | Find the main kid who is closest to the teacher and within lines-giving range (if any)
30194 | POP HL |
30195 | AND A | Is there a main kid close enough to the felled teacher?
30196 | RET Z | Return if not
30197 | LD B,15 | Message 15: NOW DON'T DO IT AGAIN
30199 | JP 29716 | Give lines to the nearest main kid