| Routines

27904: Control a boy during assembly

Used by command lists 20, 40 and 88. 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 (190-199, 206-208)
27904 | 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 1 of the character buffer)
27905 | AND 3
27907 | CPL
27908 | LD L,1
27910 | ADD A,(HL)
27911 | LD L,11 | Store this x-coordinate in byte 11 of the boy's character buffer
27913 | LD (HL),A
Having determined where the boy will sit, send him there.
27914 | LD BC,25581 | Redirect control to the routine at 25581 (walk to location) and then return to 27920
27917 | CALL 25503
This entry point is used after the boy has reached the point where he will sit.
27920 | LD L,0 | Byte 0 of the character buffer holds the boy's animatory state
27922 | BIT 7,(HL) | Is he facing left?
27924 | JP Z,25648 | Make him turn round to face the stage if so
27927 | LD L,4 | Remove the address of this routine's entry point (27920) from bytes 3 and 4 of the character buffer
27929 | LD (HL),0
27931 | CALL 25012 | Update the SRB for the boy's current animatory state and location
27934 | AND 240 | A=animatory state of the boy sitting on the floor
27936 | ADD A,5
27938 | CALL 30534 | Update the boy's animatory state, update the SRB, and place the address of the entry point at 27941 (below) into bytes 17 and 18 of the character buffer
This entry point is used after the boy has sat down facing the stage.
27941 | LD A,(32640) | Check bit 7 of 32640 (set by 61658, reset by 62032): has assembly finished yet?
27944 | RLCA
27945 | RET C | Return if not
27946 | LD L,18 | Remove the address of this routine's entry point (27941) from bytes 17 and 18 of the character's buffer, triggering a move to the next command in the command list
27948 | LD (HL),0
27950 | JP 26818 | Make the boy stand up before continuing, though