Skip to navigation

Elite on the BBC Micro

Equipment: prx [Elite-A, Parasite]

Name: prx [Show more] Type: Subroutine Category: Equipment Summary: Return the price of a piece of equipment
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * EQSHP calls prx * eq calls prx * EQSHP calls entry point prx-3 * status_equip calls entry point prx-3 * eq calls entry point c

This routine returns the price of equipment as listed in the table at PRXS. Arguments: A The item number of the piece of equipment (0-13) as shown in the table at PRXS Returns: (Y X) The item price in Cr * 10 (Y = high byte, X = low byte) (A X) Contains the same as (Y X) Other entry points: prx-3 Return the price of the item with number A - 1 c Contains an RTS
SEC \ Decrement A (for when this routine is called via SBC #1 \ prx-3) .prx ASL A \ Set A = A * 2, so it can act as an index into the \ PRXS table, which has two bytes per entry BEQ n_fcost \ If A = 0, skip the following, as we are fetching the \ price of fuel, and fuel is always the same price, \ regardless of ship type ADC new_costs \ In Elite-A the PRXS table has multiple sections, for \ the different types of ship we can buy, and the offset \ to the price table for our current ship is held in \ new_costs, so this points the index in A to the \ correct section of the PRXS table for our current ship .n_fcost TAY \ Copy A into Y, so it can be used as an index LDX PRXS,Y \ Fetch the low byte of the price into X LDA PRXS+1,Y \ Fetch the high byte of the price into A and transfer TAY \ it to X, so the price is now in (Y X) .c RTS \ Return from the subroutine