Routines 
Prev: 32060  Up: Map  Next: 32371 
Continues from 32032. On entry, A contains a location identifier for ERIC:


32062  AND A  Is ERIC in a forbidden zone?  
32063  JP Z,32232  Jump with A=0 (0+62=62: YOU ARE NOT ALLOWED HERE) if so  
ERIC's not in a forbidden zone. Check whether he's standing on a plant, or riding the bike in the boys' skool.


32066  LD B,A  B=ERIC's location identifier (18)  
32067  LD L,251  HL=32763 (ERIC's status flags)  
32069  BIT 1,(HL)  Is ERIC on the bike, on a plant, or falling?  
32071  JR Z,32091  Jump if not  
ERIC is on the bike, on a plant, or falling.


32073  LD L,237  HL=32749 (ERIC's other status flags)  
32075  LD A,(HL)  Pick these up in A  
32076  AND 131  Check bits 0, 1 and 7  
32078  JR Z,32091  Jump if ERIC's falling  
32080  AND 2  A=2 (2+62=64: GET OFF THE PLANTS) if ERIC's standing on a plant or plant pot  
32082  JP NZ,32232  Jump if ERIC is (a) standing on a plant or plant pot, or (b) riding or standing on the saddle of the bike inside the boys' skool  
32085  DEC B  B=0 now if ERIC's in the playground  
32086  LD A,3  3+62=65: DON'T RIDE BIKES IN HERE  
32088  JR NZ,32082  Jump if ERIC's riding the bike in the boys' skool  
32090  INC B  B=ERIC's location identifier (18)  
Now to check whether ERIC's in the room or area he's supposed to be in this period.


32091  LD L,224  HL=32736 (lesson descriptor)  
32093  LD A,(HL)  Pick this up in A  
32094  AND 15  Keep only the 'room' bits (bits 03)  
32096  LD C,A  Copy the room bits to C  
Now the value in C indicates where this lesson takes place:


32097  LD L,128  HL=32640 (various game status flags)  
32099  BIT 6,(HL)  Should ERIC be in class, assembly or the dinner hall by now?  
32101  JR NZ,32167  Jump if so  
32103  LD L,228  Pick up the MSB of the lesson clock  
32105  LD A,(HL)  
32106  CP 12  Should ERIC by now have left the classroom he was in last period?  
32108  JR C,32134  Jump if so  
It's too soon to be telling ERIC to GET ALONG NOW. Check whether he's sitting on the floor anywhere outside the assembly hall.


32110  LD L,251  HL=32763 (ERIC's status flags)  
32112  BIT 2,(HL)  Is ERIC sitting or lying down?  
32114  RET Z  Return if not  
32115  LD A,(53760)  A=ERIC's animatory state  
32118  CP 4  4: Is ERIC sitting in a chair?  
32120  RET Z  Return if so  
32121  CP 133  133: ERIC sitting on the floor facing right  
32123  LD A,4  4+62=66: GET OFF THE FLOOR  
32125  JP NZ,32232  Give lines if ERIC's sitting on the floor facing left, or lying down  
32128  LD A,B  A=ERIC's location identifier (18)  
32129  CP 3  ERIC is sitting on the floor facing right; is he in the assembly hall?  
32131  JR NZ,32123  Give lines if not  
32133  RET  
By now, ERIC should have left the classroom he was in last period.


32134  LD A,5  Location IDs 68 correspond to the boys' skool classrooms  
32136  CP B  Is ERIC in the Blue Room, Yellow Room or Science Lab?  
32137  JR C,32167  Jump if so  
32139  LD A,2  Is it PLAYTIME?  
32141  CP C  
32142  JR Z,32158  Jump if so  
32144  DEC A  A=1  
32145  CP B  B=1 if ERIC's in the playground  
32146  LD A,5  5+62=67: GET BACK TO SCHOOL  
32148  JR Z,32232  Give lines if ERIC is in the playground  
32150  LD A,C  Is it ASSEMBLY?  
32151  CP 3  
32153  JR NZ,32158  Jump if not  
32155  CP B  Is ERIC in the assembly hall?  
32156  JR Z,32182  Jump if so  
32158  LD L,251  HL=32763 (ERIC's status flags)  
32160  BIT 2,(HL)  Is ERIC sitting or lying down?  
32162  RET Z  Return if not  
32163  LD A,4  4+62=66: GET OFF THE FLOOR  
32165  JR 32232  Give lines  
ERIC should be in class, assembly or the dinner hall by now.


32167  LD A,B  A=ERIC's location identifier (18)  
32168  CP C  Compare that with where he should be  
32169  LD A,6  6+62=68: GET ALONG NOW  
32171  JR NZ,32232  Give lines if ERIC's not where he should be  
32173  DEC A  A=5  
32174  CP C  C > 5 if this lesson is in a classroom  
32175  JR C,32209  Jump if this lesson is in a classroom  
32177  LD A,C  Is it ASSEMBLY?  
32178  CP 3  
32180  JR NZ,32158  Jump if not  
32182  LD L,128  HL=32640 (various game status flags)  
32184  BIT 7,(HL)  Bit 7 is set if ERIC should be sitting down now  
32186  LD A,(53760)  A=ERIC's animatory state  
32189  JR NZ,32196  Jump if ERIC should be sitting facing the stage now  
32191  CP 133  133: Is ERIC sitting on the floor facing right?  
32193  JR NZ,32158  Jump if not  
32195  RET  
It's assembly, ERIC is in the assembly hall, and he should be sitting down facing the stage now. Check whether he is.


32196  CP 133  133: Is ERIC sitting on the floor facing right?  
32198  RET Z  Return if so  
32199  LD L,251  HL=32763 (ERIC's status flags)  
32201  LD A,7  7+62=69: SIT FACING THE STAGE  
32203  BIT 2,(HL)  Is ERIC sitting (facing left) or lying down?  
32205  JR Z,32232  Tell ERIC to sit facing the stage if not (this is a bug)  
32207  JR 32228  Otherwise tell ERIC to sit down  
This lesson takes place in a classroom, and ERIC is present. Check whether ERIC is sitting in a chair.


32209  LD A,(53760)  A=ERIC's animatory state  
32212  CP 4  4: Is ERIC sitting in a chair?  
32214  RET Z  Return if so  
32215  LD L,251  HL=32763 (ERIC's status flags)  
32217  BIT 2,(HL)  Bit 2 is set if ERIC's sitting or lying on the floor  
32219  LD A,4  4+62=66: GET OFF THE FLOOR  
32221  JR NZ,32232  Give lines if ERIC's sitting or lying on the floor  
32223  LD L,128  HL=32640 (various game status flags)  
32225  BIT 7,(HL)  Should ERIC be seated by now (bit 7 is set by 61696)?  
32227  RET Z  Return if not  
32228  LD A,8  8+62=70: NOW SIT DOWN  
32230  NOP  
32231  NOP  
At this point, A holds the lines reprimand ID.


32232  AND A  Is ERIC in a forbidden zone?  
32233  JR NZ,32278  Jump if not  
ERIC is somewhere he's never allowed to be.


32235  LD L,128  HL=32640 (various game status flags)  
32237  BIT 5,(HL)  Is MISS TAKE chasing ERIC?  
32239  JR NZ,32277  Jump if so  
32241  LD A,(32736)  A=lesson descriptor  
32244  CP 2  Is it PLAYTIME?  
32246  JR Z,32277  Jump if so  
32248  LD A,E  A=ERIC's xcoordinate  
32249  CP 160  Is ERIC in the girls' skool?  
32251  JR C,32277  Jump if not  
So it's not playtime, ERIC is in the girls' skool, and MISS TAKE is not (yet) chasing him out. Should she start?


32253  LD HL,52226  Point HL at byte 2 of MISS TAKE's buffer  
32256  LD A,(HL)  A=MISS TAKE's ycoordinate  
32257  CP D  Are ERIC and MISS TAKE on the same floor?  
32258  JR NZ,32275  Jump if not  
32260  LD L,29  Set bit 0 of byte 29 of MISS TAKE's character buffer, triggering a restart of her command list (set to 32371 below)  
32262  SET 0,(HL)  
32264  DEC L  Place the address of the command list at 32371 into bytes 27 and 28 of MISS TAKE's buffer; this command list contains a single routine address: 32373  
32265  LD (HL),126  
32267  DEC L  
32268  LD (HL),115  
32270  LD HL,32640  32640 holds various game status flags  
32273  SET 5,(HL)  Signal: MISS TAKE is chasing ERIC  
32275  LD H,127  Point HL at the game status buffer page  
32277  XOR A  0+62=62: YOU ARE NOT ALLOWED HERE  
Check how long it's been since ERIC last got lines.


32278  LD L,247  HL=32759 (MSB of the linesgiving delay counter)  
32280  DEC (HL)  Reset the zero flag if it's too soon for the teacher who gave ERIC lines last time to give him lines again  
32281  INC (HL)  
This entry point is used by the routine at 63586 with the zero flag set (meaning any teacher may give ERIC lines) and A holding a lines reprimand ID.


32282  PUSH AF  Save the lines reprimand ID and the zero flag  
32283  NOP  
32284  NOP  
32285  JR Z,32296  Jump if any teacher (including the one who gave him lines last time) can give ERIC lines now  
It's too soon for the teacher who gave ERIC lines last time to give him lines again. Remove that teacher from linesgiving range temporarily.


32287  LD L,245  Collect from 32757 into H the character number of the teacher who last gave ERIC lines  
32289  LD H,(HL)  
32290  LD L,1  A=this teacher's xcoordinate  
32292  LD A,(HL)  
32293  LD (HL),224  Set this teacher's xcoordinate to 224 temporarily to take him out of linesgiving range  
32295  LD L,A  Save the teacher's real xcoordinate in L  
Now to find out which teacher (if any) should give ERIC lines.


32296  PUSH HL  
32297  CALL 28002  Find the first adult within linesgiving range of ERIC  
32300  POP HL  
32301  LD D,A  D=character number of this adult, or 0 if there are none in range  
32302  POP AF  
32303  LD B,A  B=lines reprimand ID  
32304  JR Z,32310  Jump unless we need to restore the xcoordinate of the teacher who last gave ERIC lines  
32306  LD A,L  Restore the xcoordinate of the teacher who last gave ERIC lines  
32307  LD L,1  
32309  LD (HL),A  
32310  LD A,D  A=character number of the adult who can see ERIC, or 0 if there are no adults in range  
32311  CP 205  Is it ALBERT (and therefore none of the teachers)?  
32313  RET Z  Return if so (ALBERT doesn't give lines)  
32314  AND A  Can any adult character see ERIC?  
32315  RET Z  Return if not  
A teacher is within linesgiving range.


32316  LD HL,32640  32640 holds various game status flags  
32319  BIT 1,(HL)  Is MR WACKER chasing ERIC to expel him?  
32321  RET NZ  Return if so  
32322  LD L,245  Store the character number of the linesgiver at 32757  
32324  LD (HL),A  
32325  LD L,247  Reset the MSB of the linesgiving delay counter at 32759 to 10  
32327  LD (HL),10  
32329  LD A,B  A=lines reprimand ID  
32330  CP 6  6+62=68: GET ALONG NOW  
32332  JR NZ,32361  Jump unless ERIC is late for class, dinner or assembly  
ERIC is late for class, dinner or assembly. The appropriate lines reprimand depends on who saw him: his teacher for this period, or some other teacher.


32334  LD A,(32736)  Collect the lesson descriptor from 32736  
32337  AND 240  Keep only the bits relating to ERIC's teacher and shift them into bits 03  
32339  RLCA  
32340  RLCA  
32341  RLCA  
32342  RLCA  
32343  ADD A,199  Now A=character number of ERIC's teacher (200203)  
32345  CP D  Was it that teacher who saw ERIC?  
32346  JR NZ,32361  Jump if not  
ERIC's teacher for this period is the linesgiver. His lines reprimand alternates between 'COME ALONG YOU MONSTER' and 'DON'T KEEP ME WAITING'.


32348  LD L,128  HL=32640 (various game status flags)  
32350  LD A,16  Set bit 4 in A  
32352  LD B,9  9+62=71: COME ALONG YOU MONSTER  
32354  XOR (HL)  Flip bit 4 in 32640, toggling between 71 and 72  
32355  LD (HL),A  
32356  BIT 4,(HL)  Should ERIC's teacher say 'COME ALONG YOU MONSTER' this time (bit 4 set)?  
32358  JR NZ,32361  Jump if so  
32360  INC B  10+62=72: DON'T KEEP ME WAITING  
At this point D holds the character number of the teacher who is going to give ERIC lines, and B holds the lines reprimand ID.


32361  EX DE,HL  Now H=character number of the linesgiver  
32362  LD A,B  B=lines reprimand ID  
32363  ADD A,62  
32365  LD B,A  
32366  LD A,210  210=ERIC (the lines recipient)  
32368  JP 29716  Make the teacher give lines to ERIC 
Prev: 32060  Up: Map  Next: 32371 