Skip to navigation

Elite on the BBC Micro and NES

Start and end: TITLE

[NES version, Bank 0]

Name: TITLE [Show more] Type: Subroutine Category: Start and end Summary: Display a title screen with a rotating ship and prompt
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawTitleScreen calls TITLE

Display the title screen, with a selection of rotating ships.
Arguments: X The type of the ship to show (see variable XX21 for a list of ship types) Y The distance to show the ship rotating, once it has finished moving towards us
Returns: C flag If the A button, Start or Select was being pressed but has now been released, on either one of the controllers, then the C flag is set, otherwise it is clear
.TITLE STY distaway ; Store the ship distance in distaway STX TYPE ; Store the ship type in location TYPE JSR RESET ; Reset our ship so we can use it for the rotating ; title ship JSR U% ; Call U% to clear the key logger JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA #96 ; Set nosev_z hi = 96 (96 is the value of unity in the STA INWK+14 ; rotation vector) LDA #55 ; Set A = 55 as the distance that the ship starts at STA INWK+7 ; Set z_hi, the high byte of the ship's z-coordinate, ; to 96, which is the distance at which the rotating ; ship starts out before coming towards us LDX #127 ; Set roll counter = 127, so don't dampen the roll and STX INWK+29 ; make the roll direction clockwise STX INWK+30 ; Set pitch counter = 127, so don't dampen the pitch and ; set the pitch direction to dive INX ; Set QQ17 to 128 (so bit 7 is set) to switch to STX QQ17 ; Sentence Case, with the next letter printing in upper ; case LDA TYPE ; Set up a new ship, using the ship type in TYPE JSR NWSHP .awe JSR HideFromScanner_b1 ; Hide the ship from the scanner LDA #12 ; Set CNT2 = 12 as the outer loop counter for the loop STA CNT2 ; starting at TLL2 LDA #5 ; Set the main loop counter in MCNT to 5, to act as the STA MCNT ; inner loop counter for the loop starting at TLL2 LDY #0 ; Set DELTA = 0 (i.e. ship speed = 0) STY DELTA LDA #$01 ; Clear the screen and set the view type in QQ11 to $01 JSR ChangeToView ; (Title screen) LDA #7 ; Set YP = 7 to use as the outer loop counter for the STA YP ; loop starting at TLL2 .titl1 LDA #25 ; Set XP = 25 to use as the inner loop counter for the STA XP ; loop starting at TLL2 .TLL2 LDA INWK+7 ; If z_hi (the ship's distance) is 1, jump to TL1 to CMP #1 ; skip the following decrement BEQ TL1 DEC INWK+7 ; Decrement the ship's distance, to bring the ship ; a bit closer to us .TL1 JSR titl5 ; Call titl5 below as a subroutine to rotate and move ; the ship in space BCS titl3 ; If a button was been pressed during the ship drawing, ; then the C flag sill be set, so jump to titl3 to ; return from the subroutine with the C flag set to ; indicate a button press DEC XP ; Decrement the inner loop counter in XP BNE TLL2 ; Loop back to keep the ship rotating, until the inner ; loop counter is zero DEC YP ; Decrement the outer loop counter in YP BNE titl1 ; Loop back to keep the ship rotating, until the outer ; loop counter is zero .titl2 LDA INWK+7 ; If z_hi (the ship's distance) is 55 or greater, jump CMP #55 ; to titl4 to return from the subroutine with the C flag BCS titl4 ; clear, as the ship has now come towards us and has ; gone away again, all without any buttons being pressed INC INWK+7 ; Increment the ship's distance, to move the ship a bit ; further away from us JSR titl5 ; Call titl5 below as a subroutine to rotate and move ; the ship in space BCC titl2 ; If no button was pressed during the ship drawing, then ; the C flag will be clear, so loop back to titl2 to ; move the ship away from us ; If a button was pressed, then the C flag will be set, ; so we now return from the subroutine with the C flag ; set .titl3 SEC ; Set the C flag to indicate that a button has been ; pressed RTS ; Return from the subroutine .titl4 CLC ; Clear the C flag to indicate that a button has not ; been pressed RTS ; Return from the subroutine .titl5 ; We call this part of the code as a subroutine from ; above JSR MV30 ; Call MV30 at the end of part 2 of MVEIT, so we move ; the ship in space but without tidying the orientation ; vectors or applying tactics (neither of which are ; necessary on the title screen) LDX distaway ; Set z_lo to the distance value we passed to the STX INWK+6 ; routine, so this is the closest the ship gets to us LDA MCNT ; This has no effect - it is presumably left over from AND #3 ; the other versions of Elite which only scan the ; keyboard once every four loops, but that isn't the ; case here as the result is not acted upon LDA #0 ; Set x_lo = 0, so the ship remains in the screen centre STA INWK STA INWK+3 ; Set y_lo = 0, so the ship remains in the screen centre 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 JSR DrawShipInBitplane ; Flip the drawing bitplane and draw the current ship in ; the newly flipped bitplane INC MCNT ; Increment the main loop counter LDA controller1A ; If any of the A button, Start or Select are being ORA controller1Start ; pressed on controller 1, jump to tite1 to check the ORA controller1Select ; same buttons on controller 2, as these don't count as BMI tite1 ; a button press until they are released BNE tite3 ; If the result is non-zero, then at least one of the ; A button, Start or Select were being pressed but have ; now been released, so jump to tite3 to set the number ; of pilots to one (as the buttons are being pressed on ; controller 1), and return from the subroutine with ; the C flag set, to indicate the button press .tite1 LDA controller2A ; If any of the A button, Start or Select are being ORA controller2Start ; pressed on controller 2, jump to tite2 to return from ORA controller2Select ; the subroutine with the C flag clear, as these don't BMI tite2 ; count as a button press until they are released BNE tite4 ; If the result is non-zero, then at least one of the ; A button, Start or Select were being pressed but have ; now been released, so jump to tite4 to keep the number ; of pilots to two (as the buttons are being pressed on ; controller 2) to return from the subroutine with the ; C flag set, to indicate the button press .tite2 CLC ; Clear the C flag to indicate that a button has not ; been pressed RTS ; Return from the subroutine .tite3 LSR numberOfPilots ; Set numberOfPilots = 0 to configure the game for one ; pilot .tite4 SEC ; Set the C flag to indicate that a button has been ; pressed RTS ; Return from the subroutine