(back to project page)

Starship Commander Global Variables

In Applesoft, all variables have global scope. Strings, numeric variables, and arrays live in different namespaces however, so AL and AL(0) are separate entities.


There are a few global strings, primarily used to control the Hi-Res Character Generator:

The HRCG has many more features, but only the above are commonly used by the game (there's one place in INFO1 that uses CHR$(143)/CHR$(144) directly to set and clear blend mode).

Numeric Variables

Variable names in bold are included in the save game file. Initial values (mostly set by DIM) are shown when available. Many other variables are used locally and are technically visible to other programs, but these are the ones that are referenced across multiple files. (In a few cases values are initialized by DIM but never actually used.)

Var Description Initial Value
ABAngle Begin (limits heading in navigation based on speed)
ADdefined but not used243.3322
AEAngle End (limits heading in navigation based on speed)
ALauto-nav target, i.e. the ship we're heading toward
APauto-nav target modifier; 0=current position, 1=projected position
ASspeed for semi-auto nav4.35331
B1set to 1 by COMMUNICATION when you attempt to bluff the Vegans (successfully or not); set to random (1-4) by INFO1
BPset by INFO2 during torp calculations; not used
BSshield control: 0=manual, 1=semi-auto, 2=auto2
CAavailable repair droids (in the pool)15
CBCall Bluff: 1-5 they call your bluff, 6 they fall for it
CRconstant? used by INFO2300
CTdefined but not used50
DAcurrent turn number
DRnumber of radians in one degree0.0174533
ECconstant? used by INFO2492
EDauto-nav distance to travel
EGEnd Game:
  • set to -1 by TARGET if the player's ship is destroyed
  • set to -2 by COMMUNICATION if the player surrenders
  • set to 1 by DAMAGE when all crews on all vessels are dead
  • set to 2 by TARGET if all Vegan ships are destroyed
  • set to 3 by COMMUNICATION if the Vegans surrender
  • also set to 1 by MAIN MENU when you request end of game, but this appears to be just a signal to DAMAGE that it should call STORE DATA next.
EHcurrent heading
EPauto-nav setting: 0=manual, 1=semi-auto, 2=auto
EVEvasive action (/ 100, so 10 in the UI is 0.1)0.1
EWcurrent speed5 4
EXplayer ship X position10000
EYplayer ship Y position10000
F1number of opposing ships, set in ENTER; set to 1 when you attempt to surrender to the Vegans (bug)0
F2set when surrender accepted; not really used
F9Vegan surrender chance: 1=they won't, 2=they will1
FAFuture Angle (heading)
FFplanned response to offer of surrender: 1=reject, 2=accept
FHnumber of torpedo tubes with fire orders?
FSFuture Speed5 4
HWengine power adjustment factor - computed by INFO2, used by MAIN MENU to boost EN[11] and AL[11] before calling TARGET
KNdefined but not used3
LMtemp var used in WEAPONS
LPnumber of loaded torpedo tubes
LSabsolute maximum speed; depends on light engine damage and FE(11/12)12
MNmin value for FS0
MPmaximum power; used for "total power" bar chart; same as MP(15)9999
MSmax value for FS8
SHcommonly-used result variable; holds ship number3
Xcommonly holds result from subroutine
YHTAB(Y) offset for menu selection
Znumber of menu items for menu selection (e.g. line 41000)


Var Description Initial Value
AL(15)Allocated power levels for each system; capped to MP(n) [1]=900, [2]=700, [3]=700, [4]=600, [5-15]=EN[5-15]
AS(4)Auto-Shield assignments: percentages for each shield [1]=35, [2]=30, [3]=25, [4]=10
AX(3)projected X position of ship N (used by auto-nav) [0]=10000
AY(3)projected Y position of ship N (used by auto-nav) [0]=10000
C(3,3)used by TARGET during "scanning" phase
CE(4,3)Crew Efficiency for station (n) team (m); from 0-0.99 [x,y]=0.94 for [x=1-4, y=1-3]
CM(4,3)count of Crew Members at each team for each station (1=weap, 2=eng, 3=nav, 4=def); initially 10 per team. Looks like (0,0) holds total crewmember count. If [0,0] is <= 0, all crew is dead, and MAIN MENU skips user input and goes straight to TARGET. [0,0]=120
CO(4,3)Crew Officer efficiency factor: see LIFE line 25000 and 28000: sum of team member ranks (CR=3 to CMD=7) [1-4][1-3] read from DIM line 56010 (all values mid-to-high 30s)
CX(7)has station N been visited this turn? (used to place asterisks in main menu)
CT(4,3)Crew Team status: for each station (1=weap, 2=eng, 3=nav, 4=def), and each team (1-3), holds status: 1=duty, 2=standby, 3=sleep [x,y]=y for [x=1-4, y=1-3]
D(15)boolean or bit flag indicating system N is damaged (0=not damaged). D(5) holds the number of damaged torpedo tubes, D(11) holds 1 (stbd light eng), 2 (port light eng), or 3 (both)
D2(3)not used
DK(3)Distance to enemy ship N; related to MS(n)?; if > 6500, ships disengage [1-3]=3500
DT(4)indirect index to Duty Team, e.g. CT(3,DT(3)) is always 1. DT(1-3) zeroed out when crew is reshuffled in life support.
E(15)Efficiency rating of the system (0-99?). Shield efficiency is reduced with every hit over 50 pts (see DAMAGE line 40000). [1-15]=0.88 + rand(index / 10)
EN(15)current Energy levels for each system; capped to MP(n) [1]=900, [2]=700, [3]=700, [4]=600, [6-9]=200, [10]=80, [11]=1000, [12]=150, [13]=100, [14]=80, [15]=3500
EV(3)(it looks like this was supposed to be Evasive action for enemy ships, but it's never initialized... it's used in a couple of to-hit calculations in INFO2, so all Vegans have evasive of zero.)
F(9)firing target: F[0-3] indicates target for positrons 1-4 (0=none, 1=detas, ...), F[4-9] indicates target for torpedos 1-6. [1-6]=1
FE(16)quad root of efficiency: FE(n) = E(n) ^ 1/4
GX(63)used by TARGET during "scanning" phase
GY(63)used by TARGET during "scanning" phase
GZ(63)used by TARGET during "scanning" phase
HS(4)used by TARGET: amount of damage dealt to player's shield N this turn
K(3)indicates active enemy ship; set to 0 or 1 [1-3]=1
K$(4)enemy names [1]="DETAS", [2]="MILAS", [3]="KAMAS"
K2(3)number of torps fired on previous turn by ship N
KC(3)number of Crew on enemy ship N [n]=150 + 15 * KT(n)
KH(3)enemy ship Heading [1-3]=rand(360)
KP(3,7)current power for enemy ship systems
  • KP(n,m) = 1 / 7 * MK(n,0) * 0.9 + rand(1) / 10
  • KP(n,0) = MK(z,0) * 0.8 + rand(1) / 10 (entry 0 represents total power)
  • KP(n,1-4) is power for shield 1-4
  • KP(n,5) is power available for weapons
  • KP(n,6) is power for engines
  • KP(n,7) not really used; might have been intended for battery?
KT(3)enemy ship class (1=DD, 2=CL, 3=DR) [1]=1, [2]=2, [3]=3
KW(3)enemy ship current speed [1-3]=0
KX(3)enemy ship X position [1]=9500, [2]=11500, [3]=11500 + rand(1500)
KY(3)enemy ship Y position [1]=10400 + rand(1900), [2]=11500 + rand(1900), [3]=9500 - rand(2000)
LW(9)Locked Weapons (boolean): 0-3 for positrons 1-4, 4-9 for torpedos 1-6
LS(4)Life Support percentage allocations: how much life support is dedicated to each station (weap, eng, nav, def) [1-4]=0.25
LP(9)torpedo loaded / time in tube: 0=not loaded, 1=just loaded, 2=loaded prev turn, ready to fire (only 1-6 are saved) [1-6]=1
MH(3,9)Maximum Hit damage that can be caused to ship N with weapon system M; e.g. (2,0) is max damage vs. Milas firing positron 1; e.g. (0,4) is max hits vs. Detas firing torpedos with a spread of 1
MK(3,7)max power for enemy ship systems, initialized in ENTER
  • MK(n,0) = 6000 + KT(n) * 1000 -- total max
  • MK(n,1) = MK(n,0) * 0.14
  • MK(n,2) = MK(n,0) * 0.12
  • MK(n,3) = MK(n,0) * 0.12
  • MK(n,4) = MK(n,0) * 0.1
  • MK(n,5) = MK(n,0) * 0.4
  • MK(n,6) = MK(n,0)
  • MK(n,7) = MK(n,0)
MN(-)(not used)[0]=8
MP(15)maximum power values for each system [1-15]=1200, 1000, 1000, 800, 0, 200, 160, 160, 60, 100, 1000, 175, 300, 80, 9999
MS(3)Maximum Speed for enemy ships; can be reduced by damage ENTER: MS(n) = 14 - KT(n)
“DIM: [0]=8; MS[1-3] = 14-KT[1-3], or: [1]=13, [2]=12, [3]=11
MT(3)(not used)
MX(2)ship icon positioning, used for weapons station "position" display [0]=35, [1]=53, [2]=53
MY(2)ship icon positioning, used for weapons station "position" display [0]=28, [1]=28, [2]=36
OF(6)modifies odds of enemy torpedo hit (see TARGET line 28000); essentially a spread modifier. Single torp fired has full change, two torps each have 0.8x change, and so on. [1-6]=1, 0.8, 0.6, 0.5, 0.4, 0.3
OX(3)previous ship X position: 0=player, 1-3=Vegans
OY(3)previous ship Y position: 0=player, 1-3=Vegans
PC(4,3)life support energy consumed by each station; set by LIFE line 25500.
(duty crew) + (0.5 * stby) + (0 * sleep) + (2 for each crew) = 36
PW(3,9)weapon probability for ship N targeted by weapon M, e.g. (1,0) is Detas positron 1, while (2,3) is Kamas positron 4
RP(15)repairs needed on system N (points of damage)
RS(3)distance to projected location? (computed by INFO2, used by TARGET line 28000)
RT(15)repair droids assigned to system N [1-10]=4; [5]=0, [11]=5, [12]=5
SD(3)boolean, set true when KC(n) <=0 (all enemy crew dead on ship N)
SP(6)torpedo spread for each tube
TA(3)Target Angle; used by movement calculations
VH(3)total damage inflicted to enemy ship N this turn
VR(3)set to 1 if ship N is alive but out of range (used in BYE line 20000)
WH(3)max warp based on engine power; used by INFO1
WL(3)min warp based on engine power; used by INFO1
W$(31)temp var, used when reading crew names
X(5,7)(small pos+neg integers from DIM line 56000)
XA(3)enemy ship angle: which way enemy is heading
XS(3)enemy shield facing; XS(n) holds a value from 1-4 indicating which of our shields is facing toward that enemy ship
Y(5,7)(small pos+neg integers from DIM line 56000)
YA(3)angle bearing of enemy ship N; used for things like weapons station target info panel
YR(3)(not used)
YS(3)enemy shield facing us; YS(n) holds a value from 1-4 indicating which of the enemy ship's shields is facing us
Z$(32)frequently used temp var; for crew it holds crew names
Z1(32)holds crew efficiency values
Z(31)frequently used temp var; for menus it holds vtab position for each item; for crew it holds members for all teams for a given station

Memory address 7788 ($1E6C) holds station assignments, by station (weap, eng, nav, def) and team. Even addresses hold efficiency + 100 (negative values = dead?). Odd addresses are crew indices, initially a direct map. See DIM line 55000.

Odds & Ends

Some common functions:

System numbers (for energy and damage):

  1. shield 1
  2. shield 2
  3. shield 3
  4. shield 4
  5. torpedos (unused for energy); D(5) is number of damaged torpedo tubes
  6. positron 1
  7. positron 2
  8. positron 3
  9. positron 4
  10. ion engine
  11. light engine (D(11): 1=port light engine, 2=stbd, 3=both); RP/RT(11) holds damage/repair droids for port light engine
  12. life support; RP/RT(12) holds damage/repair droids for stbd light engine; E(12) holds efficiency for stbd light engine
  13. general operations
  14. communications
  15. battery

Life support stations (for e.g. DT(n)):

  1. weapons
  2. engineering
  3. navigation
  4. defense

Copyright 2020 by Andy McFadden