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).
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 |
---|---|---|
AB | Angle Begin (limits heading in navigation based on speed) | |
AD | defined but not used | 243.3322 |
AE | Angle End (limits heading in navigation based on speed) | |
AL | auto-nav target, i.e. the ship we're heading toward | |
AP | auto-nav target modifier; 0=current position, 1=projected position | |
AS | speed for semi-auto nav | 4.35331 |
B1 | set to 1 by COMMUNICATION when you attempt to bluff the Vegans (successfully or not); set to random (1-4) by INFO1 | |
BP | set by INFO2 during torp calculations; not used | |
BS | shield control: 0=manual, 1=semi-auto, 2=auto | 2 |
CA | available repair droids (in the pool) | 15 |
CB | Call Bluff: 1-5 they call your bluff, 6 they fall for it | |
CR | constant? used by INFO2 | 300 |
CT | defined but not used | 50 |
DA | current turn number | |
DR | number of radians in one degree | 0.0174533 |
EC | constant? used by INFO2 | 492 |
ED | auto-nav distance to travel | |
EG | End Game:
| |
EH | current heading | |
EP | auto-nav setting: 0=manual, 1=semi-auto, 2=auto | |
EV | Evasive action (/ 100, so 10 in the UI is 0.1) | 0.1 |
EW | current speed | |
EX | player ship X position | 10000 |
EY | player ship Y position | 10000 |
F1 | number of opposing ships, set in ENTER; set to 1 when you attempt to surrender to the Vegans (bug) | 0 |
F2 | set when surrender accepted; not really used | |
F9 | Vegan surrender chance: 1=they won't, 2=they will | 1 |
FA | Future Angle (heading) | |
FF | planned response to offer of surrender: 1=reject, 2=accept | |
FH | number of torpedo tubes with fire orders? | |
FS | Future Speed | |
HW | engine power adjustment factor - computed by INFO2, used by MAIN MENU to boost EN[11] and AL[11] before calling TARGET | |
KN | defined but not used | 3 |
LM | temp var used in WEAPONS | |
LP | number of loaded torpedo tubes | |
LS | absolute maximum speed; depends on light engine damage and FE(11/12) | 12 |
MN | min value for FS | 0 |
MP | maximum power; used for "total power" bar chart; same as MP(15) | 9999 |
MS | max value for FS | 8 |
SH | commonly-used result variable; holds ship number | 3 |
X | commonly holds result from subroutine | |
Y | HTAB(Y) offset for menu selection | |
Z | number 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 | |
DC(4) | ? | [0-4]=1 |
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 |
|
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 |
|
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.
Some common functions:
INT ( RND (1) * X + 1)
yields integer between 1 and N, inclusive.System numbers (for energy and damage):
Life support stations (for e.g. DT(n)):
Copyright 2020 by Andy McFadden