HP-41 Star Trek Game! Back to main page
I've had a lot of visitors but few comments! Let me hear from you! Send Gene an email!
The two programs below will play the game of Star Trek. The main program originally appeared in the Feb/Mar 1980 PPC Journal (V7N2) on page 43 by John Rausch. Thanks to him wherever he is today! This version of Star Trek is different from most in that it is designed to have a SEPARATE Klingon Battle Logic Program. That means that although I've provided my own Klingon Battle Program below (Label KL), if you don't like it, think it's too easy, too hard, etc., you can program your own. In fact, if you do, please send it to me to include here. If you provide logic in the label "EL", then you can have both sides play against each other. One way to do so would be to get rid of the 0, RTN after the EL label in the second program.

The program is fairly straight forward. The main program is 458 bytes long as written. The subprograms for battle logic (Labels EL and KL) total another 53 bytes. The program uses registers 0-7.

Register 0 is the total number of commands per turn (defaulted to 2 commands per turn). 
Register 1 is the number of commands left in this turn for the current player. 
Register 2 is the range in thousands of kilometers between the two ships. 
Register 3 is the damage to the active ship (the ship who's turn it currently is). 
Register 4 is the damage to the inactive ship. 
Register 5 is the evade percent for the active ship. 
Register 6 is the evade percent for the inactive ship. 
Register 7 holds the random number seed. 
Commands are :
1 - Attack
2 - Disengage
3 - Evade
4 - Fire Phasers
5 - Repair
6 - Status
Each command uses one of your two available actions during your turn.
Sample Game. Note that the display will change the settings for flags 1 and 2 as both you and the Klingon use up your two commands per turn.
Key:	                See:
XEQ "STAR"	        SEED?
0.123456789 R/S	        RANGE 13K
                 	*KLINGON*
                 	ATTACK
                 	RANGE 11K
                 	ATTACK
                 	RANGE 1K

                 	*ENTERPRISE*
	                CMD?
4 R/S	                PHASER
	                UNITS 23
                 	DAMAGE 23
                 	CMD?
4 R/S	                PHASER
	                UNITS 8
	                DAMAGE 31
 
                 	*KLINGON*
                 	PHASER
                 	UNITS 21
                 	DAMAGE 21
                 	PHASER
                 	UNITS 27
                 	DAMAGE 48

                 	*ENTERPRISE*
                 	CMD?
4 R/S                	PHASER
                 	UNITS 13
                 	DAMAGE 44
                 	CMD?
4 R/S	                PHASER
                 	UNITS 15
                 	DAMAGE 59

                 	*KLINGON*
                 	PHASER
                 	UNITS 29
                 	DAMAGE 77
                 	PHASER
                 	UNITS 36
                 	DAMAGE 113
                 	DESTROYED
He got me. Perhaps you can do  better?
Program Listing: Most lines below are easy to key in. Line 04 is SumReg 01, and Line 18 is ClearSumRegs. If you can't figure one out, email me.
Line & Instruction 
01	LBL "STAR" 
02	FIX 0 
03	CF 29 
04	EREG 01 
05	"SEED?"
06	PROMPT 
07	X=0? 
08	PI 
09	STO 07 
10	CF 22 
11	2 
12	STO 00 
13	LBL 14 
14	CF 02 
15	CF 03 
16	CF 04 
17	CF 05 
18	CLE 
19	1 
20	STO 01 
21	30 
22	XEQ 99 
23	% 
24	10 
25	+ 
26	GTO 12 
27	LBL 00 
28	FS? 05 
29	XEQ "KL" 
30	FC? 05 
31	XEQ "EL" 
32	GTO IND X 
33	LBL 00 
34	"CMD?" 
35	LBL 13 
36	PROMPT 
37	FC?C 22 
38	GTO 13 
39	X < 0? 
40	GTO 13 
41	6 
42	X < Y? 
43	GTO 13 
44	GTO IND Y 
45	LBL 01 
46	"ATTACK" 
47	AVIEW 
48	RCL 02 
49	10 
50	RCL 03 
51	20 
52	/ 
53	- 
54	STO Z 
55	- 
56	X > Y? 
57	GTO 12 
58	RCL 02 
59	XEQ 99 
60	% 
61	- 
62	X < Y? 
63	X <> Y 
64	GTO 12 
65	LBL 02 
66	"DISENGAGE" 
67	AVIEW 
68	RCL 02 
69	10 
70	RCL 03 
71	20 
72	/ 
73	- 
74	+ 
75	LBL 12 
76	RND 
77	STO 02 
78	"RANGE " 
79	ARCLX 
80	->"K"
81	GTO 11 
82	LBL 03 
83	"EVADE" 
84	AVIEW 
85	XEQ 99 
86	2 
87	/ 
88	RND 
89	ST+5 
90	"PROB "
91	ARCL 05 
92	->"%" 
93	GTO 11 
94	LBL 04 
95	"PHASER" 
96	AVIEW 
97	"OUT OF RANGE" 
98	10 
99	RCL 02 
100	X > Y? 
101	GTO 11 
102	"INOPERATIVE" 
103	79 
104	RCL 03 
105	X > Y? 
106	GTO 11 
107	RCL 06 
108	X=0? 
109	GTO 15 
110	"EVADED"
111	XEQ 99 
112	RND 
113	X < Y? 
114	GTO 11 
115	LBL 15 
116	44 
117	RCL 02 
118	4 
119	* 
120	- 
121	XEQ 99 
122	% 
123	RND 
124	ST+ 04 
125	RCL 04 
126	GTO 15 
127	LBL 05 
128	"REPAIR" 
129	AVIEW 
130	XEQ 99 
131	5 
132	/ 
133	RND 
134	ST- 03 
135	RCL 03 
136	X < 0? 
137	CLX 
138	STO 03 
139	LBL 15 
140	"UNITS "
141	ARCL Y 
142	AVIEW 
143	PSE 
144	"DAMAGE " 
145	ARCL X 
146	GTO 11 
147	LBL 06 
148	"STATUS" 
149	AVIEW 
150	PSE 
151	"DMG " 
152	ARCL 03 
153	->"/" 
154	ARCL 04 
155	AVIEW 
156	PSE 
157	"EV% " 
158	ARCL 05 
159	->"/" 
160	ARCL 06 
161	AVIEW 
162	1 
163	ST+ 01 
164	RCL 02 
165	GTO 12 
166	LBL 11 
167	AVIEW 
168	1 E2 
169	RCL 04 
170	X < Y? 
171	GTO 15 
172	PSE 
173	"DESTROYED" 
174	AVIEW 
175	GTO 14 
176	LBL 15 
177	CF IND 01 
178	DSE 01 
179	GTO 15 
180	PSE 
181	FC?C 05 
182	SF 05 
183	FC? 05 
184	"*ENTERPRISE*" 
185	FS? 05 
186	"*KLINGON*" 
187	AVIEW 
188	RCL 03 
189	X<> 04 
190	STO 03 
191	RCL 05 
192	STO 06 
193	CLX 
194	STO 05 
195	RCL 00 
196	STO 01 
197	LBL 15 
198	SF IND 01 
199	GTO 00 
200	LBL 99 
201	RCL 07 
202	997 
203	* 
204	FRC 
205	STO 07 
206	1 E2 
207	* 
208	END 

Line & Instruction 
01	LBL "EL" 
02	0 
03	RTN 
04	LBL "KL" 
05	RCL 02 
06	6 
07	X<=Y? 
08	GTO 12 
09	RCL 03 
10	80 
11	X<=Y? 
12	GTO 02 
13	LBL 04 
14	4 
15	RTN 
16	LBL 12 
17	RCL 03 
18	60 
19	X<=Y? 
20	GTO 10 
21	LBL 01 
22	1 
23	RTN 
24	LBL 10 
25	RUP 
26	13 
27	X>Y? 
28	GTO 02 
29	LBL 05
30	5
31	RTN
32	LBL 02 
33	2 
34	END

Visitors since 6/8/97