| Routines

6D00: Control a boy during assembly

Used by command lists 0x14, 0x28 and 0x58. Makes a boy find a spot to sit down in the assembly hall, and stay seated until assembly is finished.
Input
H | Boy's character number (0xBE-0xC7, 0xCE-0xD0)
6D00 | LD A,H | Determine the x-coordinate at which this boy will sit during assembly based on his character number (H) and his current x-coordinate (in byte 0x01 of the character buffer)
6D01 | AND $03
6D03 | CPL
6D04 | LD L,$01
6D06 | ADD A,(HL)
6D07 | LD L,$0B | Store this x-coordinate in byte 0x0B of the boy's character buffer
6D09 | LD (HL),A
Having determined where the boy will sit, send him there.
6D0A | LD BC,$63ED | Redirect control to the routine at 63ED (walk to location) and then return to 6D10
6D0D | CALL $639F
This entry point is used after the boy has reached the point where he will sit.
6D10 | LD L,$00 | Byte 0x00 of the character buffer holds the boy's animatory state
6D12 | BIT 7,(HL) | Is he facing left?
6D14 | JP Z,$6430 | Make him turn round to face the stage if so
6D17 | LD L,$04 | Remove the address of this routine's entry point (6D10) from bytes 0x03 and 0x04 of the character buffer
6D19 | LD (HL),$00
6D1B | CALL $61B4 | Update the SRB for the boy's current animatory state and location
6D1E | AND $F0 | A=animatory state of the boy sitting on the floor
6D20 | ADD A,$05
6D22 | CALL $7746 | Update the boy's animatory state, update the SRB, and place the address of the entry point at 6D25 (below) into bytes 0x11 and 0x12 of the character buffer
This entry point is used after the boy has sat down facing the stage.
6D25 | LD A,($7F80) | Check bit 7 of 7F80 (set by F0DA, reset by F250): has assembly finished yet?
6D28 | RLCA
6D29 | RET C | Return if not
6D2A | LD L,$12 | Remove the address of this routine's entry point (6D25) from bytes 0x11 and 0x12 of the character's buffer, triggering a move to the next command in the command list
6D2C | LD (HL),$00
6D2E | JP $68C2 | Make the boy stand up before continuing, though