Prev: F0F9 Up: Map Next: F144
F100: Open or close a door and update the screen refresh buffer
Used by the routines at F144 and F7CD. Updates the play area graphics for the door being opened or closed, and updates the screen refresh buffer (SRB) accordingly.
Input
HL Address of the door status flags (see 7FF0)
F100 LD A,L A=0xF0-0xF9
F101 SUB $3A A=0xB6-0xBF
F103 LD L,A Point HL at the relevant entry in the door locations table at FFB6
F104 LD H,$FF
F106 LD A,(HL) Pick up the entry from the door locations table
F107 AND $F8 Discard bits 0-2 of the x-coordinate
F109 LD E,A Copy the result to E
F10A RRCA Now divide the result by 8
F10B RRCA
F10C RRCA
F10D LD L,A Point HL at the entry in the table of Z values at BD00 that corresponds to the door
F10E LD H,$BD
F110 LD A,(HL) Flip bit 2 of the Z value for y-coordinates 30-35 (set=closed, reset=open)
F111 XOR $04
F113 LD (HL),A
F114 AND $03 Set the zero flag if this is a shop door
F116 LD BC,$223C B=34 (y-coordinate of the base of a house door), C=60 (00111100)
F119 JR NZ,$F123 Jump unless this is a shop door
F11B LD BC,$24C0 B=36 (y-coordinate of the base of a shop door), C=192 (11000000)
F11E INC H Point HL at the entry in the table of Z values at BE00 that corresponds to the door
F11F LD A,(HL) Flip bits 2, 3 and 4 of the Z value for y-coordinates 36-41
F120 XOR $1C
F122 LD (HL),A
This entry point is used by the routine at FC25 with B=10 (y-coordinate of the rope), C=0xFF (11111111), and E=0xD0 or 0xD8.
F123 LD HL,$7FFE 7FFE holds X, the x-coordinate of the leftmost column of the play area on screen
F126 LD A,E A=x-coordinate of the door or rope (rounded down to the nearest multiple of 8)
F127 SUB (HL) Subtract X
F128 RRCA Divide the result by 8
F129 RRCA
F12A RRCA
F12B CP $04 Is the door or rope off-screen to the left or right?
F12D RET NC Return if so
F12E LD E,A E=0, 1, 2 or 3, denoting the 8-tile wide column of the screen that contains the door or rope
F12F INC L HL=7FFF, which holds Y, the y-coordinate of the topmost row of the play area on screen
F130 LD A,B A=10 (y-coordinate of the rope), 34 or 36 (y-coordinate of the base of the door)
F131 LD B,$06 Doors are at most 6 tiles high
F133 SUB (HL) Subtract Y from the y-coordinate of the rope or base of the door
F134 ADD A,A Multiply by 4
F135 ADD A,A
F136 ADD A,E Add E (0-3)
F137 LD L,A Point HL at a byte of the screen refresh buffer (SRB)
F138 CP $60 Is this part of the door below the visible portion of the play area?
F13A RET NC Return if so
F13B LD A,(HL) Set the appropriate bits in the SRB byte for the rope or door
F13C OR C
F13D LD (HL),A
F13E LD A,L Compute the LSB of the address of the next SRB byte
F13F ADD A,$04
F141 DJNZ $F137 Jump back to check whether this SRB byte needs updating
F143 RET
Prev: F0F9 Up: Map Next: F144