.LL25 JMP PLANET ; Jump to the PLANET routine, returning from the ; subroutine using a tail call .LL9 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA TYPE ; If the ship type is negative then this indicates a BMI LL25 ; planet or sun, so jump to PLANET via LL25 above LDA #31 ; Set XX4 = 31 to store the ship's distance for later STA XX4 ; comparison with the visibility distance. We will ; update this value below with the actual ship's ; distance if it turns out to be visible on-screen LDA NEWB ; If bit 7 of the ship's NEWB flags is set, then the BMI EE51 ; ship has been scooped or has docked, so jump down to ; EE51 to skip drawing the ship so it doesn't appear ; on-screen LDA #%00100000 ; If bit 5 of the ship's byte #31 is set, then the ship BIT XX1+31 ; is currently exploding, so jump down to EE28 BNE EE28 BPL EE28 ; If bit 7 of the ship's byte #31 is clear then the ship ; has not just been killed, so jump down to EE28 ; Otherwise bit 5 is clear and bit 7 is set, so the ship ; is not yet exploding but it has been killed, so we ; need to start an explosion ORA XX1+31 ; Clear bits 6 and 7 of the ship's byte #31, to stop the AND #%00111111 ; ship from firing its laser and to mark it as no longer STA XX1+31 ; having just been killed LDA #0 ; Set the ship's acceleration in byte #31 to 0, updating LDY #28 ; the byte in the workspace K% data block so we don't STA (INF),Y ; have to copy it back from INWK later LDY #30 ; Set the ship's pitch counter in byte #30 to 0, to stop STA (INF),Y ; the ship from pitching JSR HideShip ; Update the ship so it is no longer shown on the ; scanner LDA #18 ; Set the explosion cloud counter in INWK+34 to 18 so we STA INWK+34 ; can use it in DOEXP when drawing the explosion cloud LDY #37 ; Set byte #37 of the ship's data block to a random JSR DORND ; number to use as a random number seed value for STA (INF),Y ; generating the explosion cloud INY ; Set byte #38 of the ship's data block to a random JSR DORND ; number to use as a random number seed value for STA (INF),Y ; generating the explosion cloud INY ; Set byte #39 of the ship's data block to a random JSR DORND ; number to use as a random number seed value for STA (INF),Y ; generating the explosion cloud INY ; Set byte #40 of the ship's data block to a random JSR DORND ; number to use as a random number seed value for STA (INF),Y ; generating the explosion cloud SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 .EE28 LDA XX1+8 ; Set A = z_sign .EE49 BPL LL10 ; If A is positive, i.e. the ship is in front of us, ; jump down to LL10 .LL14 ; If we get here then we do not draw the ship on-screen, ; for example when the ship is no longer on-screen, or ; is too far away to be fully drawn, and so on LDA XX1+31 ; If bit 5 of the ship's byte #31 is clear, then the AND #%00100000 ; ship is not currently exploding, so jump down to EE51 BEQ EE51 ; to skip drawing the ship LDA XX1+31 ; The ship is exploding, so clear bit 3 of the ship's AND #%11110111 ; byte #31 to denote that the ship is no longer being STA XX1+31 ; drawn on-screen JMP DOEXP ; Jump to DOEXP to remove the explosion burst sprites ; from the screen (if they are visible), returning from ; the subroutine using a tail call .EE51 LDA XX1+31 ; Clear bits 3 and 6 in the ship's byte #31, which stops AND #%10110111 ; drawing the ship on-screen (bit 3), and denotes that STA XX1+31 ; the explosion has not been drawn and there are no ; lasers firing (bit 6) RTS ; Return from the subroutineName: LL9 (Part 1 of 12) [Show more] Type: Subroutine Category: Drawing ships Summary: Draw ship: Check if ship is exploding, check if ship is in front Deep dive: Drawing shipsContext: See this subroutine in context in the source code References: This subroutine is called as follows: * HAS1 calls LL9 * LL9_b1 calls LL9
This routine draws the current ship on the screen. This part checks to see if the ship is exploding, or if it should start exploding, and if it does it sets things up accordingly. In this code, XX1 is used to point to the current ship's data block at INWK (the two labels are interchangeable).
Arguments: XX1 XX1 shares its location with INWK, which contains the zero-page copy of the data block for this ship from the K% workspace INF The address of the data block for this ship in workspace K% XX0 The address of the blueprint for this ship
Other entry points: EE51 Remove the current ship from the screen, called from SHPPT before drawing the ship as a point
[X]
Subroutine DOEXP (category: Drawing ships)
Draw an exploding ship
[X]
Subroutine DORND (category: Maths (Arithmetic))
Generate random numbers
[X]
Label EE28 is local to this routine
[X]
Entry point EE51 in subroutine LL9 (Part 1 of 12) (category: Drawing ships)
Remove the current ship from the screen, called from SHPPT before drawing the ship as a point
[X]
Subroutine HideShip (category: Dashboard)
Update the current ship so it is no longer shown on the scanner
[X]
Label LL10 in subroutine LL9 (Part 2 of 12)
[X]
Label LL25 is local to this routine
[X]
Subroutine PLANET (category: Drawing planets)
Draw the planet or sun
[X]
Macro SETUP_PPU_FOR_ICON_BAR (category: PPU)
If the PPU has started drawing the icon bar, configure the PPU to use nametable 0 and pattern table 0