| Routines

62468: Decrement and check the blown fuse delay counters

Used by the routine at 61440. Checks each fuse to see whether it was recently blown and should now be fixed, and updates the SRB for the windows affected by the fuse accordingly.
62468 | LD HL,32674 | Point HL at the first of the blown fuse delay counters at 32674
62471 | LD A,(HL) | Pick up a delay counter
62472 | AND A | Is it 0?
62473 | JR Z,62478 | Jump if so to examine the next fuse
62475 | DEC (HL) | Otherwise decrement the delay counter (this fuse was recently blown)
62476 | JR Z,62484 | Jump if it's time to fix this fuse
62478 | INC L | Move to the next fuse
62479 | BIT 3,L | Have we examined all the fuses yet?
62481 | JR Z,62471 | Jump back if not
62483 | RET |
If we're entering here from the loop above, it's time to fix a fuse that was recently blown. This entry point is also used by the routine at 29866 to blow a fuse.
62484 | LD A,L | A=162-167, corresponding to the fuse
62485 | LD HL,65471 | Prepare HL to scan the table at 65472
62488 | INC L | Point HL at the next byte in the table
62489 | BIT 5,L | Have we reached the end of the table yet?
62491 | RET NZ | Return if so
62492 | CP (HL) | Does this byte correspond to a segment that is affected by the fuse?
62493 | JR NZ,62488 | Jump back to check the next byte if not
62495 | PUSH AF | Save the LSB of the address of the blown fuse delay counter
62496 | PUSH HL | Save the table pointer
62497 | LD A,L | A=x/8 (where x is the x-coordinate of the leftmost column of the 8-tile wide segment that is affected by the fuse)
62498 | AND 31
62500 | LD L,A | Point HL at the Z value for the 5th floor in this segment
62501 | LD H,185
62503 | PUSH HL | Save the Z value pointer
62504 | CALL 62368 | Update the SRB for any windows on this floor
62507 | POP HL | Restore the Z value pointer to HL
62508 | INC H | Point HL at the Z value for the next floor down in this segment
62509 | LD A,H | Have we done every floor down to the first yet?
62510 | CP 190
62512 | JR NZ,62503 | Jump back if not
62514 | POP HL | Restore the table pointer to HL
62515 | POP AF | Restore the LSB of the address of the blown fuse delay counter to A
62516 | JR 62488 | Check the next byte in the table