Skip to navigation

Elite on the BBC Micro and NES

Version analysis of qv

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: qv Type: Subroutine Category: Equipment Summary: Print a menu of the four space views, for buying lasers
Print a menu in the bottom-middle of the screen, at row 16, column 12, that lists the four available space views, like this: 0 Front 1 Rear 2 Left 3 Right Also print a "View ?" prompt and ask for a view number. The menu is shown when we choose to buy a new laser in the Equip Ship screen.
Returns: X The chosen view number (0-3)
.qv

Code variation 1 of 6Related to a standard feature

When buying a laser in the cassette version, the menu of available views is always shown below the equipment list. In the other versions, the list of equipment in systems with tech level 8 and above is too long to squeeze in the menu (due to the extra lasers you can buy in these versions), so when buying lasers in these systems, the whole screen is cleared and the menu is shown in the middle of the screen.

This variation is blank in the Cassette and Electron versions.

LDA tek \ If the current system's tech level is less than 8, CMP #8 \ skip the next two instructions, otherwise we clear the BCC P%+7 \ screen to prevent the view menu from clashing with the \ longer equipment menu available in higher tech systems LDA #32 \ Clear the top part of the screen, draw a white border, JSR TT66 \ and set the current view type in QQ11 to 32 (Equip \ Ship screen)

Code variation 2 of 6Related to Elite's use of the Tube

Tap on a block to expand it, and tap it again to revert.

LDY #16 \ Move the text cursor to row 16, and at the same time STY YC \ set Y to a counter going from 16 to 19 in the loop \ below
LDA #16 \ Move the text cursor to row 16, and at the same time TAY \ set Y to a counter going from 16 to 19 in the loop STA YC \ below
LDA #16 \ Move the text cursor to row 16, and at the same time TAY \ set Y to a counter going from 16 to 19 in the loop JSR DOYC \ below
.qv1

Code variation 3 of 6Related to Elite's use of the Tube

Tap on a block to expand it, and tap it again to revert.

LDX #12 \ Move the text cursor to column 12 STX XC
LDA #12 \ Move the text cursor to column 12 STA XC
LDA #12 \ Move the text cursor to column 12 JSR DOXC
 TYA                    \ Transfer the counter value from Y to A

 CLC                    \ Print ASCII character "0" - 16 + A, so as A goes from
 ADC #'0'-16            \ 16 to 19, this prints "0" through "3" followed by a
 JSR spc                \ space

 LDA YC                 \ Print recursive text token 80 + YC, so as YC goes from
 CLC                    \ 16 to 19, this prints "FRONT", "REAR", "LEFT" and
 ADC #80                \ "RIGHT"
 JSR TT27

Code variation 4 of 6Related to Elite's use of the Tube

Tap on a block to expand it, and tap it again to revert.

INC YC \ Move the text cursor down a row, and increment the \ counter in YC at the same time
JSR INCYC \ Move the text cursor down a row, and increment the \ counter in YC at the same time
 LDY YC                 \ Update Y with the incremented counter in YC

 CPY #20                \ If Y < 20 then loop back up to qv1 to print the next
 BCC qv1                \ view in the menu

Code variation 5 of 6A variation in the labels only

This variation is blank in the Disc (docked), 6502 Second Processor and Master versions.

.qv3
 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

.qv2

 LDA #175               \ Print recursive text token 15 ("VIEW ") followed by
 JSR prq                \ a question mark

 JSR TT217              \ Scan the keyboard until a key is pressed, and return
                        \ the key's ASCII code in A (and X)

 SEC                    \ Subtract ASCII "0" from the key pressed, to leave the
 SBC #'0'               \ numeric value of the key in A (if it was a number key)

Code variation 6 of 6Minor and very low-impact

Tap on a block to expand it, and tap it again to revert.

CMP #4 \ If the number entered in A >= 4, then it is not a BCS qv3 \ valid view number, so jump back to qv3 to try again
CMP #4 \ If the number entered in A < 4, then it is a valid BCC qv3 \ view number, so jump down to qv3 as we are done JSR CLYNS \ Otherwise we didn't get a valid view number, so clear \ the bottom three text rows of the upper screen, and \ move the text cursor to column 1 on row 21 JMP qv2 \ Jump back to qv2 to try again .qv3
 TAX                    \ We have a valid view number, so transfer it to X

 RTS                    \ Return from the subroutine