| Routines

F250: Make MR WACKER put the kids in detention

Used by command list 0x48. Builds a detention message (using a random noun and verb) and makes MR WACKER deliver it.
Input
H | 0xC8 (MR WACKER)
F250 | LD A,($7FFF) | A=leftmost column of the play area on screen
F253 | CP $30 | Is the stage off-screen to the right?
F255 | RET C | Return if so
F256 | CP $58 | Is the stage off-screen to the left?
F258 | RET NC | Return if so
F259 | CALL $6291 | A=random number
F25C | LD DE,$7F8C | Point DE at the first byte of message 0x0A, which will be the verb
F25F | LD L,A | Save the random number in L briefly
F260 | AND $07 | Store the verb message number (0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96 or 0x97) at 7F8C
F262 | ADD A,$90
F264 | LD (DE),A
F265 | LD A,L | Restore the random number to A
F266 | RRCA | Set A to another random number from 0 to 7
F267 | RRCA
F268 | RRCA
F269 | AND $07
F26B | LD E,$8E | Point DE at the first byte of message 0x0B, which will be the noun
F26D | ADD A,$98 | Store the noun message number (0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E or 0x9F) at 7F8E
F26F | LD (DE),A
F270 | LD E,$60 | Message 0x60: YOU'RE ALL IN DETENTION...
F272 | LD BC,$6A08 | Redirect control to the routine at 6A08 (make character speak) and then return to F278 (below)
F275 | CALL $639F
Control of MR WACKER resumes here when he has finished delivering the detention message.
F278 | EX DE,HL | Save MR WACKER's character number in D briefly
F279 | LD HL,$7F80 | Reset bit 6 (ERIC no longer has to be in the assembly hall) and bit 7 (the kids can stand up now) at 7F80
F27C | RES 7,(HL)
F27E | RES 6,(HL)
F280 | NOP |
F281 | NOP
F282 | NOP
F283 | NOP
F284 | LD L,$E4 | Set the MSB of the lesson clock to 1 so that the bell will ring soon
F286 | LD (HL),$01
F288 | EX DE,HL | Restore MR WACKER's character number (0xC8) to H
F289 | JP $638C | Move to the next command in the command list