Prev: 25248 Up: Map Next: 25303
25266: Determine whether a character should be moved (1)
Used by the routine at 25126. Returns to that routine if the character under consideration should be moved on this pass; otherwise drops the return address from the stack, thus skipping ahead to consider the next character. Also reinitialises the walking speed change delay counter in byte 123 of the character's buffer when it reaches 0, and sets the new walking speed as appropriate: slow for teachers, fast or slow (at random) for boys.
Input
H Character number (152-171)
25266 LD L,123 Byte 123 contains a counter that is reset to a random even number between 2 and 32; see below
25268 DEC (HL)
25269 JR Z,25280 Jump if it's time to consider a change of pace
25271 BIT 0,(HL) Is the counter even?
25273 RET Z Return (to move the character) if so
25274 DEC L L=122
25275 BIT 7,(HL) Is this character walking fast?
25277 RET Z Return (to move the character) if so
25278 POP HL Drop the return address from the stack so that the character will not be moved this time round
25279 RET Return to consider the next character, or return to the main loop
It's time to consider a change of pace for the character being moved.
25280 CALL 24993 A=random number
25283 AND 61 A=even number between 2 and 32, and the carry flag holds a random bit
25285 ADD A,4
25287 RRA
25288 LD (HL),A Place this even number into byte 123 of the character's buffer
25289 DEC L L=122
25290 RL (HL) Bit 7 of byte 122 is now equal to the random bit that was pushed into the carry flag by the RRA instruction above
25292 RRC (HL)
25294 LD A,(HL) Bit 5 of byte 122 is set for catapult pellets and stampeding boys to ensure they always go at top speed
25295 BIT 5,A
25297 JR Z,25367 Jump if we're not dealing with such a thing
25299 RES 7,(HL) Signal: fly or run at top speed
25301 JR 25367 Jump over the routine at 25303
Prev: 25248 Up: Map Next: 25303