Prev: F401 Up: Map Next: F436
F404: Decrement and check the blown fuse delay counters
Used by the routine at F000. 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.
F404 LD HL,$7FA2 Point HL at the first of the blown fuse delay counters at 7FA2
F407 LD A,(HL) Pick up a delay counter
F408 AND A Is it 0?
F409 JR Z,$F40E Jump if so to examine the next fuse
F40B DEC (HL) Otherwise decrement the delay counter (this fuse was recently blown)
F40C JR Z,$F414 Jump if it's time to fix this fuse
F40E INC L Move to the next fuse
F40F BIT 3,L Have we examined all the fuses yet?
F411 JR Z,$F407 Jump back if not
F413 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 74AA to blow a fuse.
F414 LD A,L A=0xA2-0xA7, corresponding to the fuse
F415 LD HL,$FFBF Prepare HL to scan the table at FFC0
F418 INC L Point HL at the next byte in the table
F419 BIT 5,L Have we reached the end of the table yet?
F41B RET NZ Return if so
F41C CP (HL) Does this byte correspond to a segment that is affected by the fuse?
F41D JR NZ,$F418 Jump back to check the next byte if not
F41F PUSH AF Save the LSB of the address of the blown fuse delay counter
F420 PUSH HL Save the table pointer
F421 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)
F422 AND $1F
F424 LD L,A Point HL at the Z value for the 5th floor in this segment
F425 LD H,$B9
F427 PUSH HL Save the Z value pointer
F428 CALL $F3A0 Update the SRB for any windows on this floor
F42B POP HL Restore the Z value pointer to HL
F42C INC H Point HL at the Z value for the next floor down in this segment
F42D LD A,H Have we done every floor down to the first yet?
F42E CP $BE
F430 JR NZ,$F427 Jump back if not
F432 POP HL Restore the table pointer to HL
F433 POP AF Restore the LSB of the address of the blown fuse delay counter to A
F434 JR $F418 Check the next byte in the table
Prev: F401 Up: Map Next: F436