Elite on the BBC Micro and NES

# Market: TT210

## [BBC Micro disc version, Flight]

```       Name: TT210                                                   [Show more]
Type: Subroutine
Category: Market
Summary: Show a list of current cargo in our hold, optionally to sell
Context: 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:
* TT213 calls TT210

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

.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

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,

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

LDA #14                \ Move the text cursor to column 14, for the item's
STA XC                 \ quantity

PLA                    \ Restore the amount of item in the hold into X
TAX

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)

.TT212

LDY QQ29               \ Fetch the item number from QQ29 into Y, and increment
INY                    \ Y to point to the next 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
```