.TITLE PHA \ Store the token number on the stack for later 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 ZEKTRAN \ Reset the key logger buffer that gets returned from \ the I/O processor LDA #32 \ Send a #SETVDU19 32 command to the I/O processor to JSR DOVDU19 \ set the mode 1 palette to yellow (colour 1), white \ (colour 2) and cyan (colour 3) LDA #1 \ Clear the top part of the screen, draw a white border, JSR TT66 \ and set the current view type in QQ11 to 1 LDA #RED \ Send a #SETCOL RED command to the I/O processor to JSR DOCOL \ switch to colour 2, which is white in the title screen STZ QQ11 \ Set QQ11 to 0, so from here on we are using a space \ view LDA #96 \ Set nosev_z hi = 96 (96 is the value of unity in the STA INWK+14 \ rotation vector) 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 JSR DOXC 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 JSR DOXC 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 INC brkd \ Increment the brkd counter LDA #7 \ Move the text cursor to column 7 JSR DOXC LDA #10 \ Move the text cursor to row 10 JSR DOYC \ The following loop prints out the null-terminated \ message pointed to by (&FD &FE), which is the MOS \ 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 OSWRCH \ 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 MOS error message pointer BNE P%-6 \ If the fetched character is non-zero, loop back to the \ JSR OSWRCH above to print it, and keep looping until \ we fetch a zero (which marks the end of the message) .BRBR2 JSR CLYNS \ Clear the bottom three text rows of the upper screen, \ and move the text cursor to column 1 on row 21, i.e. \ the start of the top row of the three bottom rows. \ It also returns with Y = 0 STY DELTA \ Set DELTA = 0 (i.e. ship speed = 0) STY JSTK \ Set JSTK = 0 (i.e. keyboard, not joystick) PLA \ Restore the recursive token number we stored on the \ stack at the start of this subroutine \JSR ex \ This instruction is commented out in the original \ source (it would print the recursive token in A) JSR DETOK \ Print the extended token in A LDA #7 \ Move the text cursor to column 7 JSR DOXC LDA #12 \ Print extended token 12 ("({single cap}C) ACORNSOFT JSR DETOK \ 1984") 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 #128 \ Set z_lo = 128, so the closest the ship gets to us is STX INWK+6 \ z_hi = 1, z_lo = 128, or 256 + 128 = 384 LDA MCNT \ This value will be zero on one out of every four AND #3 \ iterations, so for the other three, skip to nodesire BNE nodesire \ so we only scan for key presses once every four loops STX NEEDKEY \ Set NEEDKEY = 128, so the call to LL9 below draws the \ ship and scans for key presses (LL9 resets NEEDKEY to \ 0 so we have to reset NEEDKEY every four iterations \ round the inner loop) .nodesire STZ INWK \ Set x_lo = 0, so the ship remains in the screen centre STZ INWK+3 \ Set y_lo = 0, so the ship remains in the screen centre JSR LL9 \ Call LL9 to display the ship LDA KTRAN+12 \ Fetch the key press state for the joystick 1 fire \ button from the key logger buffer, which contains \ the value of the 6522 System VIA input register IRB \ (SHEILA &40) AND #%00010000 \ Bit 4 of IRB (PB4) is clear if joystick 1's fire \ button is pressed, otherwise it is set, so AND'ing \ the value of IRB with %10000 extracts this bit TAX \ Copy the joystick fire button state to X, though this \ instruction has no effect, as the comparison flags are \ already set by the AND, and the value of X is not used \ anywhere BEQ TL2 \ If the joystick fire button is pressed, jump to TL2 LDA KTRAN \ Fetch the internal key number of the current key \ press from the key logger buffer BNE TL3 \ If a key is being pressed, jump to TL3 DEC MCNT \ Decrement the inner loop counter BNE TLL2 \ Loop back to keep the ship rotating, until the inner \ loop counter is zero DEC CNT2 \ Decrement the outer loop counter in CNT2 BNE TLL2 \ Loop back to keep the ship rotating, until the outer \ loop counter is zero JMP DEMON \ Once we have iterated through CNT2 iterations of MCNT, \ jump to DEMON to start the demo .TL2 DEC JSTK \ Joystick fire button was pressed, so set JSTK to &FF \ (it was set to 0 above), to disable keyboard and \ enable joysticks .TL3 RTS \ Return from the subroutineName: TITLE [Show more] Type: Subroutine Category: Start and end Summary: Display a title screen with a rotating ship and promptContext: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions 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)
Returns: X If a key is being pressed, X contains the internal key number, otherwise it contains 0
[X]
Label BRBR2 is local to this routine
[X]
Subroutine CLYNS (category: Drawing the screen)
Clear the bottom three text rows of the mode 1 screen by sending a #clyns command to the I/O processor
[X]
Subroutine DEMON (category: Demo)
Show the demo
[X]
Subroutine DETOK (category: Text)
Print an extended recursive token from the TKN1 token table
[X]
Subroutine DOCOL (category: Text)
Set the text colour by sending a #SETCOL command to the I/O processor
[X]
Subroutine DOVDU19 (category: Drawing the screen)
Change the mode 1 palette by sending a #SETVDU19 command to the I/O processor
[X]
Subroutine DOXC (category: Text)
Move the text cursor to a specified column by sending a #SETXC command to the I/O processor
[X]
Subroutine DOYC (category: Text)
Move the text cursor to a specified row by sending a #SETYC command to the I/O processor
[X]
Variable JSTK in workspace Parasite variables
Keyboard or joystick configuration setting
[X]
Variable KTRAN (category: Keyboard)
The key logger buffer that gets updated by the OSWORD 240 command
[X]
Subroutine LL9 (Part 1 of 12) (category: Drawing ships)
Draw ship: Check if ship is exploding, check if ship is in front
[X]
Subroutine MVEIT (Part 1 of 9) (category: Moving)
Move current ship: Tidy the orientation vectors
[X]
Subroutine NWSHP (category: Universe)
Add a new ship to our local bubble of universe
[X]
Configuration variable OSWRCH = &FFEE
The address for the OSWRCH routine
[X]
Variable PATG in workspace Parasite variables
Configuration setting to show the author names on the start-up screen and enable manual hyperspace mis-jumps
[X]
Configuration variable RED = %11110000
Four mode 1 pixels of colour 2 (red, magenta or white)
[X]
Subroutine RESET (category: Start and end)
Reset most variables
[X]
Label TL1 is local to this routine
[X]
Label TL2 is local to this routine
[X]
Label TL3 is local to this routine
[X]
Label TLL2 is local to this routine
[X]
Subroutine TT26 (category: Text)
Print a character at the text cursor, with support for verified text in extended tokens
[X]
Subroutine TT66 (category: Drawing the screen)
Clear the screen and set the current view type
[X]
Subroutine ZEKTRAN (category: Keyboard)
Reset the key logger buffer at KTRAN
[X]
Label awe is local to this routine
[X]
Variable brkd (category: Utility routines)
The brkd counter for error handling
[X]
Label nodesire is local to this routine
[X]
Subroutine plf (category: Text)
Print a text token followed by a newline