Back to Skool Routines
25296: Move the characters
Used by the routine at 63156.
25296 CALL 25302 Move one character
25299 CALL 25302 Move the next character
25302 LD HL,32764
25305 LD A,(HL) A=number of character last moved (183-209, 211-214)
25306 INC A A=number of next character to move
25307 CP 210 Is it ERIC?
25309 JR Z,25306 Jump if so (ee don't want to move ERIC!)
25311 CP 215 Have we completed an entire cast movement cycle?
25313 JR C,25317 Jump if not
25315 LD A,183 Back to 183 (little girl no. 1) if so
25317 CP 198 Are we dealing with little girls 1-7 or little boys 1-8?
25319 JR NC,25360 Jump if not
It's the turn of one of the little girls (183-189), or one of the first 8 little boys (190-197). But if the part of the play area currently on screen is somewhere this character never ventures into, skip ahead to the next suitable candidate.
25321 LD E,A E=character number (183-197)
25322 LD D,190 190=little boy no. 1
25324 LD A,(32767) A=leftmost column of play area on screen
25327 CP 80 80: middle of assembly hall stage
25329 JR NC,25338 Jump if we can't see to the left of this
We are deep into the boys' skool, where no girls ever set foot.
25331 LD A,E A=character number (183-197)
25332 CP D Is this a little boy?
25333 JR NC,25360 Move him if so
25335 LD A,D Otherwise bypass the little girls and skip ahead to little boy no. 1 (190)
25336 JR 25360
The leftmost column of the play area on screen is at least 80.
25338 CP 120 120: about halfway between the tree and the gate
25340 LD A,E A=character number (183-197)
25341 JR C,25350 Jump if we can't see the first half of the girls' playground
The leftmost column of the play area on screen is at least 120. Little boys 1-8 never set foot here.
25343 CP D Is this a little girl?
25344 JR C,25360 Move her if so
25346 LD A,198 Otherwise bypass little boys 1-8 and skip ahead to little boy no. 9 (198)
25348 JR 25360
The leftmost column of the play area on screen is between 80 and 112. Little girls 4-7 and little boys 1-3 never visit these parts.
25350 CP 186 Is this little girl no. 1-3?
25352 JR C,25360 Move her if so
25354 CP 193 Is this little boy no. 4-8?
25356 JR NC,25360 Move him if so
25358 LD A,193 Otherwise bypass little girls 4-7 and little boys 1-3 and skip ahead to little boy no. 4 (193)
We've now determined which character to move next. His character number is in A.
25360 LD (HL),A Store the number of the character to be moved next in 32764
25361 LD H,A H=number of character to move
25362 LD L,30 Point HL at byte 30 of this character's buffer
25364 DEC (HL) Is it time to consider a change in walking speed?
25365 JR NZ,25401 Jump if not
It's time to consider a change in walking speed. If the character is a boy or girl, decide whether they will walk or run for the next little while.
25367 CALL 25233 A=random number
25370 AND 31 0<=A<=31
25372 ADD A,32 32<=A<=63
25374 RRA 16<=A<=31 and carry set if random number was odd
25375 LD (HL),A Place this number into byte 30 of the character's buffer
25376 SBC A,A A=0 if random number was even, 255 otherwise
25377 DEC L L=29
25378 AND 128 A=0 (character will walk) or 128 (character will run if he's a kid)
25380 OR (HL) Superimpose the current contents of byte 29
25381 BIT 6,(HL) Is this a human character (183<=H<=209)?
25383 JR NZ,25389 Jump if not
25385 BIT 4,(HL) Bit 4 of byte 29 is unused and always reset
25387 JR Z,25393 Always make this jump
25389 OR 128 Ensure that bit 7 of byte 29 is set for non-human characters
25391 JR 25399
25393 BIT 5,(HL) Is this an adult character (200<=H<=205)?
25395 JR Z,25399 Jump if not
25397 AND 127 Ensure that bit 7 of byte 29 is reset for adult characters (to make them walk)
25399 LD (HL),A Restore byte 29 with bit 7 set (run) or reset (walk) as appropriate
25400 INC L L=30
Now to determine whether to move the character this time round. The answer will be yes if byte 30 (which is decremented on each pass through this routine) is even, or bit 7 of byte 29 is set (indicating that the character is either running or non-human).
25401 BIT 0,(HL) Is the counter at byte 30 currently even?
25403 JR Z,25409 Jump if so (half the time)
25405 DEC L L=29
25406 BIT 7,(HL) Is the character both human and not running?
25408 RET Z Return if so
The character shall be moved. From this point, the following steps are taken:
Step Action
1 If there is a routine address in bytes 17 and 18 of the character's buffer, jump to it
2 If there is a routine address in bytes 23 and 24 of the character's buffer, call it (and then return to step 3)
3 If there is a routine address in bytes 9 and 10 of the character's buffer, jump to it
4 Restart the command list if bit 0 of byte 29 of the character's buffer is set (and carry on to step 5)
5 If there is a command list routine address in bytes 3 and 4 of the character's buffer, jump to it
6 Remove any routine address from bytes 23 and 24 of the character's buffer
7 Collect the next routine address from the current command list, place it in bytes 3 and 4 of the character's buffer, and jump to it
The address of one of the following routines (or an entry point thereof) may be present in bytes 17 and 18 of the character's buffer:
Address Description
24328 Make HAYLEY hit ERIC
26224 Control character when he's knocked out of his chair
26239 Control character after he's been knocked out of a chair
26263 Control character looking for a chair
27941 Control kid while sitting during assembly
28855 Make character open or close door
29194 Control bike when ERIC's not sitting on the saddle
29896 Control descent of water, sherry or conker
30102 Deal with character who has been knocked over
30380 Control flight of catapult pellet
30643 Deal with BOY WANDER when he is firing
30739 Deal with ANGELFACE when he is hitting
30804 Deal with frog when knocked out of cup
30906 Move frog
31078 Control female character while she's jumping
31092 Make female character start jumping
31254 Control released mouse
53796 Do nothing
62386 Control open desk lid
63627 Control stinkbomb cloud
63733 Make MR WACKER find a window to open after smelling stinkbomb
63960 Control water from pistol
64175 Control watered plant
The address of one of the following routines (or an entry point thereof) may be present in bytes 23 and 24 of the character's buffer:
Address Description
30555 Make BOY WANDER fire now and then
62668 Make ALBERT keep an eye out for ERIC during lessons
63455 Make ANGELFACE find and hit HAYLEY
63492 Make ANGELFACE/BOY WANDER hit/fire now and then
The address of one of the following routines (or an entry point thereof) may be present in bytes 9 and 10 of the character's buffer:
Address Description
25581 Guide character to (intermediate) destination
25656 Make character walk up stairs
25677 Make character walk down stairs
26639 Wipe blackboard
26752 Make character write on board
27144 Make character speak
32379 Make MISS TAKE chase ERIC
61463 Make EINSTEIN talk
61595 Make teacher find ERIC
62794 Make MR WACKER find the truant ERIC
25409 LD L,18 Jump if there is a routine address in bytes 17 and 18 of the character's buffer
25411 LD A,(HL)
25412 AND A
25413 JR NZ,25479
25415 LD L,24 Jump if there is no routine address in bytes 23 and 24 of the character's buffer
25417 LD A,(HL)
25418 AND A
25419 JR Z,25432
25421 PUSH HL Save the character number
25422 LD BC,25431 Push 25431 (the address of the entry point to return to) onto the stack
25425 PUSH BC
25426 LD B,A Collect the address of the routine at bytes 23 and 24 of the character's buffer into BC and push it onto the stack
25427 DEC L
25428 LD C,(HL)
25429 PUSH BC
25430 RET JP (BC) and then return to 25431 below
25431 POP HL Restore the character number to H
This entry point is used by the routine at 25492:
25432 LD L,10 Jump if there is a routine address in bytes 9 and 10 of of the character's buffer
25434 LD A,(HL)
25435 AND A
25436 JR NZ,25479
If we get here, that means there's no routine address in bytes 17 and 18 or in bytes 9 and 10 of the character's buffer at the moment. We take this opportunity to check whether a command list restart has been requested, by inspecting bit 0 of byte 29. This bit is set in the following routines on particular occasions:
Routine Occasion
32062 MISS TAKE needs to chase ERIC out of the girls' skool
61595 Teacher must find the absent ERIC during class, dinner or assembly
62668 MR WACKER must find the truant ERIC
62770 MR WACKER must find and expel ERIC
63309 Lesson ended
In addition, an instruction in the command list may have requested a restart (see 61555, 61624, 62572 and 63501).
25438 LD L,29 Check bit 0 of byte 29: do we need to restart the command list?
25440 BIT 0,(HL)
25442 JR Z,25457 Jump if not
25444 RES 0,(HL) Reset bit 0 of byte 29 now that we are going to restart
25446 LD D,H D=character number
25447 LD L,27 Point HL at where the address of the character's current command list is held
25449 LD E,25 Point DE at where the address of the place reached in the character's current command list is held
25451 LDI Copy the former into the latter (thus returning to the start of the command list)
25453 LDI
25455 JR 25467
25457 LD L,4 Jump if there is a routine address in bytes 3 and 4 of the character's buffer
25459 LD A,(HL)
25460 AND A
25461 JR NZ,25479
25463 LD L,29 Reset bit 3 of byte 29, indicating that this character may not be considered for teleportation for the remainder of this lesson (see 25026)
25465 RES 3,(HL)
25467 RES 4,(HL) Reset bit 4 of byte 29 (though this is unused and always reset)
25469 LD L,24 Remove the address of any routine from bytes 23 and 24 of the character's buffer
25471 LD (HL),0
This entry point is used by the routine at 63447:
25473 LD L,3 Collect the routine address of the next instruction in the character's current command list and place it in bytes 3 and 4 of the buffer
25475 CALL 25188
25478 INC L Collect that routine address into BC
25479 LD B,(HL)
25480 DEC L
25481 LD C,(HL)
25482 PUSH BC Make an indirect jump to the command list routine address
25483 RET