Prev: 7D15 Up: Map Next: 7D36
7D20: Make any nearby teacher give ERIC lines if necessary (1)
Used by the routine at F6B4. Makes any nearby teacher give ERIC lines for rule breakages other than hitting, firing a catapult, firing a waterpistol, writing on a blackboard, or dropping a stinkbomb.
7D20 LD HL,$7FF6 Decrement the LSB of the lines-giving delay counter at 7FF6
7D23 DEC (HL)
7D24 RET NZ Return unless it's time to inspect the MSB
7D25 LD (HL),$0F Reset the LSB to 0x0F
7D27 INC L HL=7FF7 (MSB of the lines-giving delay counter)
7D28 INC (HL) Has the lines-giving delay counter reached 0?
7D29 DEC (HL)
7D2A JR Z,$7D31 Jump if so
7D2C DEC (HL) Otherwise decrement the MSB of the counter
7D2D LD A,(HL) Pick up the MSB in A
7D2E CP $06 Has enough time passed since the last time ERIC was given lines?
7D30 RET NC Return if not
The MSB of the lines-giving delay counter (which is reset to 0x0A by the routine at 7D3E when ERIC is given lines) is now 0x05 or less. This means the minimum interval between two lines-givings (75 passes through the main loop) has elapsed. However, the teacher who gave ERIC lines last time must wait until the MSB reaches zero before he can give ERIC lines again.
7D31 CALL $7D00 A=location identifier for ERIC
7D34 JR $7D3E Skip over the routine at 7D36
Prev: 7D15 Up: Map Next: 7D36