Routines
 Prev: 61689 Up: Map Next: 61764
61696: Open or close a door and update the screen refresh buffer
Used by the routines at 61764 and 63437. 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 32752)
61696 LD A,L A=240-249
61697 SUB 58 A=182-191
61699 LD L,A Point HL at the relevant entry in the door locations table at 65462
61700 LD H,255
61702 LD A,(HL) Pick up the entry from the door locations table
61703 AND 248 Discard bits 0-2 of the x-coordinate
61705 LD E,A Copy the result to E
61706 RRCA Now divide the result by 8
61707 RRCA
61708 RRCA
61709 LD L,A Point HL at the entry in the table of Z values at 48384 that corresponds to the door
61710 LD H,189
61712 LD A,(HL) Flip bit 2 of the Z value for y-coordinates 30-35 (set=closed, reset=open)
61713 XOR 4
61715 LD (HL),A
61716 AND 3 Set the zero flag if this is a shop door
61718 LD BC,8764 B=34 (y-coordinate of the base of a house door), C=60 (00111100)
61721 JR NZ,61731 Jump unless this is a shop door
61723 LD BC,9408 B=36 (y-coordinate of the base of a shop door), C=192 (11000000)
61726 INC H Point HL at the entry in the table of Z values at 48640 that corresponds to the door
61727 LD A,(HL) Flip bits 2, 3 and 4 of the Z value for y-coordinates 36-41
61728 XOR 28
61730 LD (HL),A
This entry point is used by the routine at 64549 with B=10 (y-coordinate of the rope), C=255 (11111111), and E=208 or 216.
61731 LD HL,32766 32766 holds X, the x-coordinate of the leftmost column of the play area on screen
61734 LD A,E A=x-coordinate of the door or rope (rounded down to the nearest multiple of 8)
61735 SUB (HL) Subtract X
61736 RRCA Divide the result by 8
61737 RRCA
61738 RRCA
61739 CP 4 Is the door or rope off-screen to the left or right?
61741 RET NC Return if so
61742 LD E,A E=0, 1, 2 or 3, denoting the 8-tile wide column of the screen that contains the door or rope
61743 INC L HL=32767, which holds Y, the y-coordinate of the topmost row of the play area on screen
61744 LD A,B A=10 (y-coordinate of the rope), 34 or 36 (y-coordinate of the base of the door)
61745 LD B,6 Doors are at most 6 tiles high
61747 SUB (HL) Subtract Y from the y-coordinate of the rope or base of the door
61748 ADD A,A Multiply by 4