Prev: 62A0 Up: Map Next: 62D7
62B2: Determine whether a character should be moved (1)
Used by the routine at 6226. 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 0x7B 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 (0x98-0xAB)
62B2 LD L,$7B Byte 0x7B contains a counter that is reset to a random even number between 2 and 32; see below
62B4 DEC (HL)
62B5 JR Z,$62C0 Jump if it's time to consider a change of pace
62B7 BIT 0,(HL) Is the counter even?
62B9 RET Z Return (to move the character) if so
62BA DEC L L=0x7A
62BB BIT 7,(HL) Is this character walking fast?
62BD RET Z Return (to move the character) if so
62BE POP HL Drop the return address from the stack so that the character will not be moved this time round
62BF 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.
62C0 CALL $61A1 A=random number
62C3 AND $3D A=even number between 2 and 32, and the carry flag holds a random bit
62C5 ADD A,$04
62C7 RRA
62C8 LD (HL),A Place this even number into byte 0x7B of the character's buffer
62C9 DEC L L=0x7A
62CA RL (HL) Bit 7 of byte 0x7A is now equal to the random bit that was pushed into the carry flag by the RRA instruction above
62CC RRC (HL)
62CE LD A,(HL) Bit 5 of byte 0x7A is set for catapult pellets and stampeding boys to ensure they always go at top speed
62CF BIT 5,A
62D1 JR Z,$6317 Jump if we're not dealing with such a thing
62D3 RES 7,(HL) Signal: fly or run at top speed
62D5 JR $6317 Jump over the routine at 62D7
Prev: 62A0 Up: Map Next: 62D7