| Routines

62620: Wait till everyone has gone past the gate or the boys' skool door

Used by command list 76. Makes ALBERT wait at the skool gate or the boys' skool door until all the female characters are on the girls' side of the gate and all the male characters are to his left.
Input
H | 205 (ALBERT)
62620 | LD L,1 | Point HL at byte 1 of ALBERT's buffer
62622 | LD E,(HL) | E=ALBERT's x-coordinate
62623 | LD H,209 | 209=HAYLEY
62625 | LD A,(HL) | A=HAYLEY's x-coordinate
62626 | LD H,182 |
62628 | LD B,4 | There are 4 little girls (183-186) who sometimes venture past the skool gate
62630 | JR 62633 |
62632 | LD A,(HL) | A=girl's x-coordinate
62633 | CP 136 | Is this girl on the right side of the gate?
62635 | RET C | Return if not
62636 | INC H | Next girl
62637 | DJNZ 62632 | Jump back until HAYLEY and girls 1-4 have been checked
The female characters are safely on the right side of the gate. Now check the male characters.
62639 | LD A,E | A=ALBERT's x-coordinate
62640 | SUB 2 |
62642 | LD H,210 | 210=ERIC
62644 | CP (HL) | Is ERIC at least 2 spaces to the left of ALBERT?
62645 | RET C | Return if not
62646 | LD H,193 | 193=little boy no. 4
62648 | LD B,11 | There are 7 little boys and 4 male teachers who may venture out of the boys' skool
62650 | CP (HL) | Is this character at least 2 spaces to the left of ALBERT?
62651 | RET C | Return if not
62652 | INC H | Next teacher or little boy
62653 | DJNZ 62650 | Jump back until little boys 4-10 and the male teachers have been checked
ERIC, the male teachers and all the little boys are safely to ALBERT's left. Now check the remaining boys.
62655 | LD H,206 | 206=BOY WANDER
62657 | LD B,3 | 3 main boys: BOY WANDER, ANGELFACE and EINSTEIN
62659 | CP (HL) | Is this character at least 2 spaces to the left of ALBERT?
62660 | RET C | Return if not
62661 | INC H | Next main boy
62662 | DJNZ 62659 | Jump back until the three main boys have been checked
62664 | JP 25484 | Move to the next command in the command list now it's safe to shut the gate or door