Skip to navigation

Elite on the BBC Micro and NES

Version analysis of TT214

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

Code variations between these versions are shown below.

Name: TT214 Type: Subroutine Category: Keyboard Summary: Ask a question with a "Y/N?" prompt and return the response
Arguments: A The text token to print before the "Y/N?" prompt
Returns: C flag Set if the response was "yes", clear otherwise

Code variation 1 of 2Related to a standard feature

In the cassette version, there's an extra space before the "Y/N?" prompt in the Buy Cargo and Sell Cargo screens compared to the other versions.

This variation is blank in the Disc (docked) version.

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

PHA \ Print a space, using the stack to preserve the value JSR TT162 \ of A PLA
\.TT214 \ These instructions are commented out in the original \PHA \ source \JSR TT162 \PLA

 JSR TT27               \ Print the text token in A

Code variation 2 of 2Minor and very low-impact

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

LDA #225 \ Print recursive token 65 ("(Y/N)?") JSR TT27
LDA #206 \ Print extended token 206 ("{all caps}(Y/N)?") JSR DETOK
 JSR TT217              \ Scan the keyboard until a key is pressed, and return
                        \ the key's ASCII code in A and X

 ORA #%00100000         \ Set bit 5 in the value of the key pressed, which
                        \ converts it to lower case

 CMP #'y'               \ If "y" was pressed, jump to TT218
 BEQ TT218

 LDA #'n'               \ Otherwise jump to TT26 to print "n" and return from
 JMP TT26               \ the subroutine using a tail call (so all other
                        \ responses apart from "y" indicate a no)


 JSR TT26               \ Print the character in A, i.e. print "y"

 SEC                    \ Set the C flag to indicate a "yes" response

 RTS                    \ Return from the subroutine