Prev: 703F Up: Map Next: 705F
7040: Open or close a door or window
Used by the routines at 70B7, 70CD and 73F1. On entry, A holds the door/window identifier:
ID Door/window
0x01 Left study door
0x02 Right study door
0x04 Science Lab storeroom door
0x08 Boys' skool door
0x10 Skool gate
0x20 Drinks cabinet door
0x40 Top floor window
0x80 Middle floor window
Input
A Door/window identifier (see table above)
B 0 (close it) or 1 (open it)
7040 PUSH HL
7041 LD HL,$7FF4 7FF4 holds the doors flags
7044 LD C,A Copy the door identifier to C
7045 LD A,(HL) Pick up the doors flags in A
7046 OR C
7047 DEC B Are we opening the door/window?
7048 JR Z,$704B Jump if so
704A XOR C
704B LD (HL),A Restore the doors flags with the appropriate bit set or reset
704C LD A,C A=door identifier
704D LD HL,$E155 Point HL at the appropriate entry in the doors and windows table at E156
7050 INC L
7051 INC L
7052 RRCA
7053 JR NC,$7050
7055 LD A,(HL) Pick up the MSB of the entry in A
7056 ADC A,B Add 1 if opening the door/window
7057 DEC L Point HL at the LSB of the entry
7058 LD L,(HL) Pick this up in L
7059 LD H,A Now HL=address from the doors and windows table (+0100 if opening)
705A CALL $6C18 Alter UDG references in the play area and update the SRB for the newly opened or closed door/window
705D POP HL
705E RET
Prev: 703F Up: Map Next: 705F