25296 | CDD662 | CALL 25302 | Move one character |
25299 | CDD662 | CALL 25302 | Move next character |
25302 | 21FC7F | LD HL,32764 | |
25305 | 7E | LD A,(HL) | A=number of character last moved (183-209, 211-214) |
25306 | 3C | INC A | |
25307 | FED2 | CP 210 | 210=ERIC |
25309 | 28FB | JR Z,25306 | We don't want to move ERIC! |
25311 | FED7 | CP 215 | |
25313 | 3802 | JR C,25317 | |
25315 | 3EB7 | LD A,183 | Back to 183 (little boy no. 1) if necessary |
25317 | FEC6 | CP 198 | Are we dealing with little girls 1-7 or little boys 1-8? |
25319 | 3027 | JR NC,25360 | Jump if not |
25321 | 5F | LD E,A | |
25322 | 16BE | LD D,190 | |
25324 | 3AFF7F | LD A,(32767) | A=column of play area at far left of screen |
25327 | FE50 | CP 80 | 80: middle of assembly hall stage |
25329 | 3007 | JR NC,25338 | Jump if we can't see to the left of this |
25331 | 7B | LD A,E | |
25332 | BA | CP D | D=190 (little boy no. 1) |
25333 | 3019 | JR NC,25360 | Move all boys but no girls if (32767) < 80 |
25335 | 7A | LD A,D | |
25336 | 1816 | JR 25360 | |
25338 | FE78 | CP 120 | 120: roughly below middle of field in boys' playground |
25340 | 7B | LD A,E | |
25341 | 3807 | JR C,25350 | Jump if we can't see the first half of the girls' playground |
25343 | BA | CP D | D=190 (little boy no. 1) |
25344 | 380E | JR C,25360 | Move all girls if we can see the first half of the girls' playground |
25346 | 3EC6 | LD A,198 | 198 = little boy no. 9 |
25348 | 180A | JR 25360 | |
25350 | FEBA | CP 186 | 186 = little girl no. 4 (NB: 80≤(32767)<120) |
25352 | 3806 | JR C,25360 | Move girls who sometimes leave girls' skool (183-185) |
25354 | FEC1 | CP 193 | 193 = little boy no. 4 |
25356 | 3002 | JR NC,25360 | |
25358 | 3EC1 | LD A,193 | Don't move little boys who never leave skool (190-192) |
25360 | 77 | LD (HL),A | Restore number of character to be moved next to 32764 |
25361 | 67 | LD H,A | H=number of character to move |
25362 | 2E1E | LD L,30 | HL points to byte 30 of character's buffer |
25364 | 35 | DEC (HL) | |
25365 | 2022 | JR NZ,25401 | |
25367 | CD9162 | CALL 25233 | A=random number |
25370 | E61F | AND 31 | 0≤A≤31 |
25372 | C620 | ADD A,32 | 32≤A≤63 |
25374 | 1F | RRA | 16≤A≤31 and carry set if random number was odd |
25375 | 77 | LD (HL),A | Place this number into byte 30 of the character's buffer |
25376 | 9F | SBC A,A | A=0 if random number was even, 255 otherwise |
25377 | 2D | DEC L | L=29 |
25378 | E680 | AND 128 | A=0 (character will continue to walk slow for a while if he already was) or 128 (character will now walk fast if he's a kid) |
25380 | B6 | OR (HL) | Superimpose the current contents of byte 29 |
25381 | CB76 | BIT 6,(HL) | Is this a human character (183≤H≤209)? |
25383 | 2004 | JR NZ,25389 | Jump if not |
25385 | CB66 | BIT 4,(HL) | Bit 4 of byte 29 is unused and always reset |
25387 | 2804 | JR Z,25393 | Always make this jump |
25389 | F680 | OR 128 | Ensure that bit 7 of byte 29 is set for non-human characters |
25391 | 1806 | JR 25399 | |
25393 | CB6E | BIT 5,(HL) | Is this an adult character (200≤H≤205)? |
25395 | 2802 | JR Z,25399 | Jump if not |
25397 | E67F | AND 127 | Ensure that bit 7 of byte 29 is reset for adult characters |
25399 | 77 | LD (HL),A | Restore byte 29 with bit 7 set or reset as appropriate |
25400 | 2C | INC L | L=30 |
25401 | CB46 | BIT 0,(HL) | |
25403 | 2804 | JR Z,25409 | Make this jump half the time (when byte 30 is even) |
25405 | 2D | DEC L | L=29 |
25406 | CB7E | BIT 7,(HL) | Is the character walking slow? |
25408 | C8 | RET Z | Return if so |
25409 | 2E12 | LD L,18 | |
25411 | 7E | LD A,(HL) | A=MSB of address of controlling routine, or 0 |
25412 | A7 | AND A | Is there a controlling routine address in bytes 17 and 18? |
25413 | 2040 | JR NZ,25479 | Jump if so |
25415 | 2E18 | LD L,24 | |
25417 | 7E | LD A,(HL) | A=MSB of address of controlling routine, or 0 |
25418 | A7 | AND A | Is there a controlling routine address in bytes 23 and 24? |
25419 | 280B | JR Z,25432 | Jump if not |
25421 | E5 | PUSH HL | |
25422 | 015763 | LD BC,25431 | |
25425 | C5 | PUSH BC | |
25426 | 47 | LD B,A | Collect the address of the controlling routine at bytes 23 and 24 into BC and push it onto the stack |
25427 | 2D | DEC L | |
25428 | 4E | LD C,(HL) | |
25429 | C5 | PUSH BC | |
25430 | C9 | RET | JP (BC) and then return to 25431 below |
25431 | E1 | POP HL | Restore character page number to H |
25432 | 2E0A | LD L,10 | |
25434 | 7E | LD A,(HL) | A=MSB of address of controlling routine, or 0 |
25435 | A7 | AND A | Is there a controlling routine address in bytes 9 and 10? |
25436 | 2029 | JR NZ,25479 | Jump if so |
25438 | 2E1D | LD L,29 | |
25440 | CB46 | BIT 0,(HL) | Do we need to return to the start of the table of A&P? |
25442 | 280D | JR Z,25457 | Jump if not |
25444 | CB86 | RES 0,(HL) | |
25446 | 54 | LD D,H | |
25447 | 2E1B | LD L,27 | HL points to where the address of the character's current table of A&P is held |
25449 | 1E19 | LD E,25 | DE points to where the address of the place reached in the character's current table of A&P is held |
25451 | EDA0 | LDI | Copy the former into the latter (thus returning to the start of the table) |
25453 | EDA0 | LDI | |
25455 | 180A | JR 25467 | |
25457 | 2E04 | LD L,4 | |
25459 | 7E | LD A,(HL) | A=MSB of address of controlling routine, or 0 |
25460 | A7 | AND A | Is there a controlling routine address in bytes 3 and 4? |
25461 | 2010 | JR NZ,25479 | Jump if so |
25463 | 2E1D | LD L,29 | |
25465 | CB9E | RES 3,(HL) | |
25467 | CBA6 | RES 4,(HL) | Reset bit 4 of byte 29 (though this is unused and always reset) |
25469 | 2E18 | LD L,24 | Remove the address of any controlling routine from bytes 23 and 24 of the buffer |
25471 | 3600 | LD (HL),0 |
25473 | 2E03 | LD L,3 | Collect address of controlling routine from character's current table of A&P and place it in bytes 3 and 4 of the buffer |
25475 | CD6462 | CALL 25188 | |
25478 | 2C | INC L | |
25479 | 46 | LD B,(HL) | Place the address of the current controlling routine into BC |
25480 | 2D | DEC L | |
25481 | 4E | LD C,(HL) | |
25482 | C5 | PUSH BC | |
25483 | C9 | RET | In effect, JP (BC) |