Prev: 8D0F Up: Map Next: 8DAA
8D73: Move and draw the light beam in Solar Power Generator
Used by the routine at 870E.
8D73 LD HL,$5C17 Point HL at the cell at (0,23) in the attribute buffer at 5C00 (the source of the light beam)
8D76 LD DE,$0020 Prepare DE for addition (the beam travels vertically downwards to start with)
The beam-drawing loop begins here.
8D79 LD A,($8029) Pick up the attribute byte of the floor tile for the cavern from 8029
8D7C CP (HL) Does HL point at a floor tile?
8D7D RET Z Return if so (the light beam stops here)
8D7E LD A,($803B) Pick up the attribute byte of the wall tile for the cavern from 803B
8D81 CP (HL) Does HL point at a wall tile?
8D82 RET Z Return if so (the light beam stops here)
8D83 LD A,$27 A=0x27 (INK 7: PAPER 4)
8D85 CP (HL) Does HL point at a tile with this attribute value?
8D86 JR NZ,$8D98 Jump if not (the light beam is not touching Willy)
8D88 EXX Switch to the shadow registers briefly (to preserve DE and HL)
8D89 CALL $8A3C Decrease the air supply by four units
8D8C CALL $8A3C
8D8F CALL $8A3C
8D92 CALL $8A3C
8D95 EXX Switch back to the normal registers (restoring DE and HL)
8D96 JR $8DA5 Jump forward to draw the light beam over Willy
8D98 LD A,($8020) Pick up the attribute byte of the background tile for the cavern from 8020
8D9B CP (HL) Does HL point at a background tile?
8D9C JR Z,$8DA5 Jump if so (the light beam will not be reflected at this point)
8D9E LD A,E Toggle the value in DE between 32 and -1 (and therefore the direction of the light beam between vertically downwards and horizontally to the left): the light beam has hit a guardian
8D9F XOR $DF
8DA1 LD E,A
8DA2 LD A,D
8DA3 CPL
8DA4 LD D,A
8DA5 LD (HL),$77 Draw a portion of the light beam with attribute value 0x77 (INK 7: PAPER 6: BRIGHT 1)
8DA7 ADD HL,DE Point HL at the cell where the next portion of the light beam will be drawn
8DA8 JR $8D79 Jump back to draw the next portion of the light beam
Prev: 8D0F Up: Map Next: 8DAA