Prev: AFF6 Up: Map Next: B03F
B01C: Turn Light Horizontally
Used by the routine at MoveLightUp.
Tries to turn a light so that it goes left or right. If neither of the cells is part of the frame then the light is turned round, and the routine tries to turn it vertically instead, but only once.
Input
DE Address of the attribute that the light is in
IX Light
TurnLightHorizontally B01C LD L,E Point HL at the cell on the left.
B01D LD H,D
B01E DEC L
B01F LD A,(HL) Fetch the attribute of the cell.
B020 CP $48 Jump to turn left if it is part of the frame.
B022 JR Z,SetLightLeft
B024 INC L Move to the cell on the right.
B025 INC L
B026 LD A,(HL) Fetch the attribute of the cell.
B027 CP $48 Jump to turn right if it is part of the frame.
B029 JR Z,SetLightRight
B02B LD A,($9629) Fetch the flag that says that the light has turned.
B02E AND A Return if it has.
B02F RET NZ
B030 OR $01 Set the flag...
B032 LD ($9629),A ...and store it.
B035 LD A,(IX+$00) Fetch the type of the light.
B038 XOR $08 Turn the light round, and store it.
B03A LD (IX+$00),A
B03D JR TurnLightVertically Jump to try to turn the light vertically.
Prev: AFF6 Up: Map Next: B03F