Skip to navigation


Start and end: TITLE

[Apple II version]

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: * BR1 (Part 1 of 2) calls TITLE * BR1 (Part 2 of 2) calls TITLE

Display the title screen, with a rotating ship and a text token at the bottom of the screen.
Arguments: A The number of the extended token to show below the rotating ship (see variable TKN1 for details of recursive tokens) 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: X If a key is being pressed, X contains the ASCII code of the key pressed
.TITLE STY distaway ; Store the ship distance in distaway PHA ; Store the token number on the stack for later STX TYPE ; Store the ship type in location TYPE LDA #$FF ; Set MULIE to $FF to prevent the RESET routine from STA MULIE ; stopping the title music that is currently playing JSR RESET ; Reset our ship so we can use it for the rotating ; title ship LDA #0 ; Set MULIE back to 0 so the RESET routine goes back to STA MULIE ; its normal behaviour of stopping any music that is ; playing JSR ZEKTRAN ; Call ZEKTRAN to clear the key logger ;LDA #32 ; These instructions are commented out in the original ;JSR DOVDU19 ; source LDA #13 ; Clear the top part of the screen, draw a border box, JSR TT66 ; and set the current view type in QQ11 to 13 (rotating ; ship view) ;LDA #RED ; These instructions are commented out in the original ;JSR DOCOL ; source LDA #0 ; Set QQ11 to 0, so from here on we are using a space STA QQ11 ; view LDA #96 ; Set nosev_z hi = 96 (96 is the value of unity in the STA INWK+14 ; rotation vector) LDA #96 ; Set A = 96 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 LDA #6 ; Move the text cursor to column 6 STA XC LDA #30 ; Print recursive token 144 ("---- E L I T E ----") JSR plf ; followed by a newline LDA #10 ; Print a line feed to move the text cursor down a line JSR TT26 LDA #6 ; Move the text cursor to column 6 again STA XC LDA PATG ; If PATG = 0, skip the following two lines, which BEQ awe ; print the author credits (PATG can be toggled by ; pausing the game and pressing "X") LDA #13 ; Print extended token 13 ("BY D.BRABEN & I.BELL") JSR DETOK .awe LDA brkd ; If brkd = 0, jump to BRBR2 to skip the following, as BEQ BRBR2 ; we do not have a system error message to display ; If we get here then brkd = $FF, which indicates that ; we have a system error we need to display INC brkd ; Set brkd = 0 to clear the error flag and indicate that ; the error has been processed LDA #7 ; Move the text cursor to column 7 STA XC LDA #9 ; Move the text cursor to row 9 STA YC ; The following loop prints out the null-terminated ; message pointed to by ($FD $FE), which is the OS ; error message pointer - so this prints the error ; message on the next line LDY #0 ; Set Y = 0 to act as a character counter JSR CHPR ; Print the character in A (which contains a line feed ; on the first loop iteration), and then any non-zero ; characters we fetch from the error message INY ; Increment the loop counter LDA ($FD),Y ; Fetch the Y-th byte of the block pointed to by ; ($FD $FE), so that's the Y-th character of the message ; pointed to by the OS error message pointer BNE P%-6 ; If the fetched character is non-zero, loop back to the ; JSR CHPR above to print it, and keep looping until ; we fetch a zero (which marks the end of the message) .BRBR2 LDY #0 ; Set DELTA = 0 (i.e. ship speed = 0) STY DELTA STY JSTK ; Set JSTK = 0 (i.e. keyboard, not joystick) LDA #14 ; Move the text cursor to row 14 STA YC LDA #1 ; Move the text cursor to column 1 STA XC PLA ; Restore the recursive token number we stored on the ; stack at the start of this subroutine JSR DETOK ; Print the extended token in A LDA #3 ; Move the text cursor to column 3 STA XC LDA #12 ; Print extended token 12 ("{single cap}C) {single JSR DETOK ; cap}D.{single cap}BRABEN & {single cap}I.{single ; cap}BELL 1985") 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 .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 MVEIT ; Move the ship in space according to the orientation ; vectors and the new value in z_hi 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 JSR LL9 ; Call LL9 to display the ship JSR RDKEY ; Scan the keyboard for a key press and return the ASCII ; code of the key pressed in A and X (or 0 for no key ; press) ; ; This also clears the C flag if no keys are being ; pressed DEC MCNT ; Decrement the main loop counter LDA $C061 ; Combine the soft switches at PB0 and PB1, which are ORA $C062 ; mapped to push button 0 and 1 (i.e. the fire buttons ; on the joysticks) ; ; If a fire button is being pressed then bit 7 in that ; soft switch will be set, so this sets bit 7 of A if ; either one of the fire buttons is being pressed IF _IB_DISK OR _4AM_CRACK AND fireButtonMask ; This is a strange bit of code - fireButtonMask is set ; to %00001011 but it is never changed, so this AND will ; always clear bit 7 ; ; This means that we will never take the following ; branch to TL3, so we will never be able to configure ; the joystick from the title screen by pressing fire ; ; The value of %00001011 in fireButtonMask is also a bit ; odd, as $C061 and $C062 only record the button status ; in bit 7, so the mask value is rather intriguing too ENDIF BMI TL3 ; If bit 7 of A is set then the fire button is being ; pressed, so jump to TL3 to set the JSTK configuration ; option to enable joysticks BCC TLL2 ; If no key is being pressed then the C flag will be ; clear from the call to RDKEY, so loop back up to ; move/rotate the ship and check again for a key press RTS ; Return from the subroutine .TL3 DEC JSTK ; Joystick fire button was pressed, so set JSTK to $FF ; (it was set to 0 above), to disable keyboard and ; enable joysticks RTS ; Return from the subroutine