| Routines

32379: Make MISS TAKE chase ERIC (2)

The address of this interruptible subcommand routine is placed into bytes 9 and 10 of MISS TAKE's buffer by the routine at 32373. It makes MISS TAKE stalk ERIC while he's in the girls' skool or the girls' playground, but stand on guard by the skool gate if ERIC is on the boys' side.
Input
H | 204 (MISS TAKE)
32379 | LD L,29 | Point HL at byte 29 of MISS TAKE's buffer
32381 | LD A,205 | 205=ALBERT
32383 | SET 7,(HL) | Set bit 7 at byte 29 of MISS TAKE's buffer, making her run
32385 | LD (32757),A | Set the character number of the adult who last gave ERIC lines (stored at 32757) to 205 (ALBERT); this has the effect of making any teacher (including whoever last gave ERIC lines) available for lines-giving ASAP (see 32032 and 32062)
32388 | LD L,0 | Point HL at byte 0 of MISS TAKE's character buffer
32390 | BIT 0,(HL) | Is MISS TAKE midstride?
32392 | JP NZ,25950 | Finish the stride if so
Now check whether a command list restart has been requested. This request will have been made if the lesson in which MISS TAKE started chasing ERIC has ended, and the next lesson has just begun (see 63309).
32395 | LD L,29 | Set the zero flag if MISS TAKE should continue hounding ERIC
32397 | BIT 0,(HL)
This entry point is used by the routines at 61595 and 62794 with the zero flag reset and H holding the character number of a teacher chasing ERIC.
32399 | LD L,1 | Collect the teacher's coordinates in DE
32401 | LD E,(HL)
32402 | INC HL
32403 | LD D,(HL)
32404 | JR Z,32418 | Jump if this teacher is MISS TAKE and she should continue chasing ERIC
32406 | CALL 25554 | Is the teacher on a staircase?
32409 | JP NC,25488 | If not, terminate this interruptible subcommand
The chase is over, and the teacher is on a staircase. It's not a good idea to remove the interruptible subcommand routine address from bytes 9 and 10 of the teacher's buffer at this point, though, because the next command in the teacher's command list will be 25700, and that command will not work if the teacher's starting point is on a staircase. So continue chasing ERIC until the top or bottom of the staircase has been reached.
32412 | JP 25944 | Continue chasing ERIC
32415 | NOP |
32416 | NOP
32417 | NOP
MISS TAKE is chasing ERIC, but she only chases so far.
32418 | LD A,(53761) | A=ERIC's x-coordinate
32421 | CP 138 | This x-coordinate is just to the right of the plant in the girls' playground
32423 | JR NC,32429 | Jump if ERIC's to the right of this
32425 | LD A,E | A=MISS TAKE's x-coordinate
32426 | CP 137 | This is the x-coordinate where MISS TAKE stands on guard for the truant ERIC
32428 | RET Z | Return if MISS TAKE is already here
32429 | JP 25944 | Otherwise MISS TAKE continues chasing ERIC