Skip to navigation

Elite on the BBC Micro and NES

Version analysis of TT210

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

Code variations between these versions are shown below.

Name: TT210 Type: Subroutine Category: Market Summary: Show a list of current cargo in our hold, optionally to sell
Show a list of current cargo in our hold, either with the ability to sell (the Sell Cargo screen) or without (the Inventory screen), depending on the current view.
Arguments: QQ11 The current view: * 4 = Sell Cargo * 8 = Inventory

Code variation 1 of 14A variation in the comments only

This variation is blank in the Cassette, Disc (flight) and Electron versions.

Other entry points: NWDAVxx Used to rejoin this routine from the call to NWDAV4
.TT210 LDY #0 \ We're going to loop through all the available market \ items and check whether we have any in the hold (and, \ if we are in the Sell Cargo screen, whether we want \ to sell any items), so we set up a counter in Y to \ denote the current item and start it at 0 .TT211 STY QQ29 \ Store the current item number in QQ29

Code variation 2 of 14A variation in the labels only

This variation is blank in the Cassette, Disc (flight) and Electron versions.

.NWDAVxx
 LDX QQ20,Y             \ Fetch into X the amount of the current item that we
 BEQ TT212              \ have in our cargo hold, which is stored in QQ20+Y,
                        \ and if there are no items of this type in the hold,
                        \ jump down to TT212 to skip to the next item

 TYA                    \ Set Y = Y * 4, so this will act as an index into the
 ASL A                  \ market prices table at QQ23 for this item (as there
 ASL A                  \ are four bytes per item in the table)
 TAY

 LDA QQ23+1,Y           \ Fetch byte #1 from the market prices table for the
 STA QQ19+1             \ current item and store it in QQ19+1, for use by the
                        \ call to TT152 below

 TXA                    \ Store the amount of item in the hold (in X) on the
 PHA                    \ stack

 JSR TT69               \ Call TT69 to set Sentence Case and print a newline

 CLC                    \ Print recursive token 48 + QQ29, which will be in the
 LDA QQ29               \ range 48 ("FOOD") to 64 ("ALIEN ITEMS"), so this
 ADC #208               \ prints the current item's name
 JSR TT27

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

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

LDA #14 \ Move the text cursor to column 14, for the item's STA XC \ quantity
LDA #14 \ Move the text cursor to column 14, for the item's JSR DOXC \ quantity
 PLA                    \ Restore the amount of item in the hold into X
 TAX

Code variation 4 of 14Related to an enhanced feature

In the enhanced versions, you can specify how much of each individual commodity you want to sell. In the cassette version, for each commodity you have to choose whether to sell all of your stock, or none.

See below for more variations related to this code.

This variation is blank in the Cassette, Disc (flight) and Electron versions.

STA QQ25 \ Store the amount of this item in the hold in QQ25
 CLC                    \ Print the 8-bit number in X to 3 digits, without a
 JSR pr2                \ decimal point

 JSR TT152              \ Print the unit ("t", "kg" or "g") for the market item
                        \ whose byte #1 from the market prices table is in
                        \ QQ19+1 (which we set up above)

Code variation 5 of 14Specific to an individual platform

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

LDA QQ11 \ If the current view type in QQ11 is not 4 (Sell Cargo CMP #4 \ screen), jump to TT212 to skip the option to sell BNE TT212 \ items

Code variation 6 of 14A variation in the comments only

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

\JSR TT162 \ This instruction is commented out in the original \ source

Code variation 7 of 14Related to an enhanced feature

See variation 4 above for details.

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

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

LDA #205 \ Set A to recursive token 45 ("SELL") JSR TT214 \ Call TT214 to print "Sell(Y/N)?" and return the \ response in the C flag BCC TT212 \ If the response was "no", jump to TT212 to move on to \ the next item
LDA #205 \ Print recursive token 45 ("SELL") JSR TT27 LDA #206 \ Print extended token 206 ("{all caps}(Y/N)?") JSR DETOK JSR gnum \ Call gnum to get a number from the keyboard, which \ will be the number of the item we want to sell, \ returning the number entered in A and R, and setting \ the C flag if the number is bigger than the available \ amount of this item in QQ25 BEQ TT212 \ If no number was entered, jump to TT212 to move on to \ the next item BCS NWDAV4 \ If the number entered was too big, jump to NWDAV4 to \ print an "ITEM?" error, make a beep and rejoin the \ routine at NWDAVxx above

Code variation 8 of 14Specific to an individual platform

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

LDA QQ29 \ We are selling this item, so fetch the item number \ from QQ29 LDX #255 \ Set QQ17 = 255 to disable printing STX QQ17 JSR TT151 \ Call TT151 to set QQ24 to the item's price / 4 (the \ routine doesn't print the item details, as we just \ disabled printing)

Code variation 9 of 14Related to an enhanced feature

See variation 4 above for details.

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

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

LDY QQ29 \ Set P to the amount of this item we have in our cargo LDA QQ20,Y \ hold (which is the amount to sell) STA P
LDY QQ29 \ Subtract R (the number of items we just asked to buy) LDA QQ20,Y \ from the available amount of this item in QQ20, as we SEC \ just bought them SBC R STA QQ20,Y LDA R \ Set P to the amount of this item we just bought STA P

Code variation 10 of 14Specific to an individual platform

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

LDA QQ24 \ Set Q to the item's price / 4 STA Q JSR GCASH \ Call GCASH to calculate \ \ (Y X) = P * Q * 4 \ \ which will be the total price we make from this sale \ (as P contains the quantity we're selling and Q \ contains the item's price / 4) JSR MCASH \ Add (Y X) cash to the cash pot in CASH

Code variation 11 of 14Related to an enhanced feature

See variation 4 above for details.

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

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

LDA #0 \ We've made the sale, so set the amount LDY QQ29 STA QQ20,Y STA QQ17 \ Set QQ17 = 0, which enables printing again
LDA #0 \ We've made the sale, so set the amount STA QQ17 \ Set QQ17 = 0, which enables printing again
.TT212

 LDY QQ29               \ Fetch the item number from QQ29 into Y, and increment
 INY                    \ Y to point to the next item

Code variation 12 of 14Minor and very low-impact

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

CPY #17 \ If Y >= 17 then skip the next instruction as we have BCS P%+5 \ done the last item JMP TT211 \ Otherwise loop back to TT211 to print the next item \ in the hold
CPY #17 \ Loop back to TT211 to print the next item in the hold BCC TT211 \ until Y = 17 (at which point we have done the last \ item)
CPY #17 \ If Y < 17 then loop back to TT211 to print the next BCC TT211 \ item in the hold RTS \ Otherwise return from the subroutine

Code variation 13 of 14Specific to an individual platform

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

LDA QQ11 \ If the current view type in QQ11 is not 4 (Sell Cargo CMP #4 \ screen), skip the next two instructions and just BNE P%+8 \ return from the subroutine JSR dn2 \ This is the Sell Cargo screen, so call dn2 to make a \ short, high beep and delay for 1 second JMP BAY2 \ And then jump to BAY2 to display the Inventory \ screen, as we have finished selling cargo

Code variation 14 of 14Related to the Master version

The Master version contains a fair amount of Trumble-related code, though it doesn't have any effect as we never get to pick up any Trumbles (though if we did, they would take over our cargo bay and hoof up all the food and narcotics, just as in the Commodore 64 version, so their essence is still encoded in the Master version).

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

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

RTS \ Return from the subroutine
JSR TT69 \ Call TT69 to set Sentence Case and print a newline LDA TRIBBLE \ If there are any Trumbles in the hold, skip the ORA TRIBBLE+1 \ following RTS and continue on (in the Master version, BNE P%+3 \ there are never any Trumbles, so this value will \ always be zero) .zebra RTS \ There are no Trumbles in the hold, so return from the \ subroutine \ If we get here then we have Trumbles in the hold, so \ we print out the number (though we never get here in \ the Master version) CLC \ Clear the C flag, so the call to TT11 below doesn't \ include a decimal point LDA #0 \ Set A = 0, for the call to TT11 below, so we don't pad \ out the number of Trumbles LDX TRIBBLE \ Fetch the number of Trumbles into (Y X) LDY TRIBBLE+1 JSR TT11 \ Call TT11 to print the number of Trumbles in (Y X), \ with no decimal point JSR DORND \ Print out a random extended token from 111 to 114, all AND #3 \ of which are blank in this version of Elite CLC ADC #111 JSR DETOK LDA #198 \ Print extended token 198, which is blank, but would JSR DETOK \ contain the text "LITTLE TRUMBLE" if the Trumbles \ mission was enabled LDA TRIBBLE+1 \ If we have more than 256 Trumbles, skip to DOANS BNE DOANS LDX TRIBBLE \ If we have exactly one Trumble, return from the DEX \ subroutine (as zebra contains an RTS) BEQ zebra .DOANS LDA #'s' \ We have more than one Trumble, so print an 's' and JMP DASC \ return from the subroutine using a tail call