Skip to navigation


Drawing lines: LASLI

[NES version, Bank 0]

Name: LASLI [Show more] Type: Subroutine Category: Drawing lines Summary: Draw the laser lines for when we fire our lasers
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * Main flight loop (Part 3 of 16) calls LASLI

Draw the laser lines, aiming them to slightly different place each time so they appear to flicker and dance. Also heat up the laser temperature and drain some energy.
Other entry points: LASLI-1 Contains an RTS
.LASLI JSR DORND ; Set A and X to random numbers AND #7 ; Restrict A to a random value in the range 0 to 7 ADC halfScreenHeight ; Set LASY to two pixels above the centre of the SBC #2 ; screen (in halfScreenHeight), plus our random number, STA LASY ; so the laser dances above and below the centre point JSR DORND ; Set A and X to random numbers AND #7 ; Restrict A to a random value in the range 0 to 7 ADC #X-4 ; Set LASX to four pixels left of the centre of the STA LASX ; screen (#X), plus our random number, so the laser ; dances to the left and right of the centre point LDA GNTMP ; Add 6 to the laser temperature in GNTMP ADC #6 STA GNTMP JSR DENGY ; Call DENGY to deplete our energy banks by 1 LDA QQ11 ; If this is not a space view (i.e. QQ11 is non-zero) BNE LASLI-1 ; then jump to MA9 to return from the main flight loop ; (as LASLI-1 is an RTS) LDA #32 ; Set A = 32 and Y = 224 for the first set of laser LDY #224 ; lines (the wider pair of lines) JSR las ; Call las below to draw the first set of laser lines LDA #48 ; Fall through into las with A = 48 and Y = 208 to draw LDY #208 ; a second set of lines (the narrower pair) ; The following routine draws two laser lines, one from ; the centre point down to point A on the bottom row, ; and the other from the centre point down to point Y ; on the bottom row. We therefore get lines from the ; centre point to points 32, 48, 208 and 224 along the ; bottom row, giving us the triangular laser effect ; we're after .las STA X2 ; Set X2 = A LDA LASX ; Set (X1, Y1) to the random centre point we set above STA X1 LDA LASY STA Y1 LDA Yx2M1 ; Set Y2 to the height in pixels of the space view, STA Y2 ; which is in the variable Yx2M1, so this sets Y2 to ; the y-coordinate of the bottom pixel row of the space ; view JSR LOIN ; Draw a line from (X1, Y1) to (X2, Y2), so that's from ; the centre point to (A, 191) LDA LASX ; Set (X1, Y1) to the random centre point we set above STA X1 LDA LASY STA Y1 STY X2 ; Set X2 = Y LDA Yx2M1 ; Set Y2 to the y-coordinate of the bottom pixel row STA Y2 ; of the space view (as before) JMP LOIN ; Draw a line from (X1, Y1) to (X2, Y2), so that's from ; the centre point to (Y, 191), and return from ; the subroutine using a tail call