Skip to navigation

Elite on the BBC Micro

Version analysis of GTNME / GTNMEW

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

Code variations between these versions are shown below.

Code variation 1 of 10A variation in the comments only

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Electron

Docked, 6502SP, Master

Name: GTNME
Name: GTNMEW
Type: Subroutine Category: Save and load Summary: Fetch the name of a commander file to save or load
Get the commander's name for loading or saving a commander file. The name is stored in the INWK workspace and is terminated by a return character (13). If ESCAPE is pressed or a blank name is entered, then the name stored is set to the name from the last saved commander block. Returns:

Code variation 2 of 10A variation in the comments only

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Electron

Docked, 6502SP, Master

INWK The commander name entered, terminated by a return character (13)
INWK The full filename, including drive and directory, in the form ":0.E.JAMESON", for example, terminated by a return character (13)

Code variation 3 of 10A variation in the labels only

This variation is blank in the Cassette and Electron versions.

Docked, 6502SP, Master

.GTNMEW

Code variation 4 of 10Other (e.g. bug fix, optimisation)

The disc version has a delay in the routine to fetch a commander name, though I'm not sure why.

This variation is blank in the Cassette, Master and Electron versions.

Tap on a version to expand it, and tap it again to show to all variations.

Docked

6502SP

LDY #8 \ Wait for 8/50 of a second (0.16 seconds) JSR DELAY
\LDY #8 \ These instructions are commented out in the original \JSR DELAY \ source
.GTNME

Code variation 5 of 10Specific to an individual platform

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

Tap on a version to expand it, and tap it again to show to all variations.

Cassette

Electron

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 #123 \ Print recursive token 123 ("{crlf}COMMANDER'S NAME? ") JSR TT27 JSR DEL8 \ Wait for 8/50 of a second (0.16 seconds)
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 #123 \ Print recursive token 123 ("{crlf}COMMANDER'S NAME? ") JSR TT27 JSR DEL8 \ Call DEL8 to wait for 30 delay loops

Code variation 6 of 10Specific to an individual platform

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

Cassette

LDA #%10000001 \ Clear 6522 System VIA interrupt enable register IER STA VIA+&4E \ (SHEILA &4E) bit 1 (i.e. enable the CA2 interrupt, \ which comes from the keyboard)

Code variation 7 of 10Specific to an individual platform

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

Cassette, Electron

LDA #15 \ Call OSBYTE with A = 15 (flush all buffers) TAX JSR OSBYTE LDX #LO(RLINE) \ Set (Y X) to point to the RLINE parameter block LDY #HI(RLINE) \ configuration block below

Code variation 8 of 10Specific to an individual platform

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

Tap on a version to expand it, and tap it again to show to all variations.

Cassette

Electron

LDA #0 \ Call OSWORD with A = 0 to read a line from the current JSR OSWORD \ input stream (i.e. the keyboard) \LDA #%00000001 \ These instructions are commented out in the original \STA VIA+&4E \ source, but they would set 6522 System VIA interrupt \ enable register IER (SHEILA &4E) bit 1 (i.e. disable \ the CA2 interrupt, which comes from the keyboard) BCS TR1 \ The C flag will be set if we pressed ESCAPE when \ entering the name, in which case jump to TR1 to copy \ the last saved commander's name from NA% to INWK \ and return from the subroutine there
LDA #0 \ Set A = 0 for the following OSWORD call DEC KEYB \ Decrement KEYB, so it is now &FF, to indicate that we \ are reading from the keyboard using an OS command JSR OSWORD \ Call OSWORD with A = 0 to read a line from the current \ input stream (i.e. the keyboard) INC KEYB \ Increment KEYB back to 0 to indicate we are done \ reading the keyboard BCS TR1 \ The C flag will be set if we pressed ESCAPE when \ entering the name, in which case jump to TR1 to copy \ the last saved commander's name from NA% to INWK \ and return from the subroutine there

Code variation 9 of 10Specific to an individual platform

This variation is blank in the Cassette and Electron versions.

Docked, 6502SP, Master

LDX #4 \ First we want to copy the drive and directory part of \ the commander file from S1% (which equals NA%-5), so \ set a counter in x for 5 bytes, as the string is of \ the form ":0.E." .GTL3 LDA NA%-5,X \ Copy the X-th byte from NA%-5 to INWK STA INWK,X DEX \ Decrement the loop counter BPL GTL3 \ Loop back until the whole drive and directory string \ has been copied to INWK to INWK+4 LDA #7 \ The call to MT26 below uses the OSWORD block at RLINE STA RLINE+2 \ to fetch the line, and RLINE+2 defines the maximum \ line length allowed, so this changes the maximum \ length to 7 (as that's the longest commander name \ allowed) LDA #8 \ Print extended token 8 ("{single cap}COMMANDER'S JSR DETOK \ NAME? ") JSR MT26 \ Call MT26 to fetch a line of text from the keyboard \ to INWK+5, with the text length in Y, so INWK now \ contains the full pathname of the file, as in \ ":0.E.JAMESON", for example LDA #9 \ Reset the maximum length in RLINE+2 to the original STA RLINE+2 \ value of 9
 TYA                    \ The OSWORD call returns the length of the commander's
                        \ name in Y, so transfer this to A

 BEQ TR1                \ If A = 0, no name was entered, so jump to TR1 to copy
                        \ the last saved commander's name from NA% to INWK
                        \ and return from the subroutine there

Code variation 10 of 10Specific to an individual platform

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Electron

Docked, 6502SP

Master

JMP TT67 \ We have a name, so jump to TT67 to print a newline \ and return from the subroutine using a tail call
RTS \ Return from the subroutine
STY NAMELEN1 \ Store the length of the length of the commander's that \ was entered in NAMELEN1 RTS \ Return from the subroutine
RSS Feed