04-17-2016, 11:06 PM
Does anybody remember the Galaxis game by Ravensburger from the early 80's? The game looked like this:
This HP-41 program allows you to play this game.
The goal of the game is to find 4 space ships in as few attempts as possible. The game board is a grid of 9 columns by 7 rows, i.e. coordinates A1 through G9. If there is no ship on the coordinates you entered, you'll get as answer the number of ships visible from that location along the lines of the grid (horizontal, vertical, diagonal). You cannot look 'behind' a ship. For example, if the ships are on locations G1, F2, A5 and D7, and you shoot at D4, the answer will be 2 - not 3 because from D4 you can see the ship at F2 but not the ship behind it at G1, so only the ships at F2 and D7 are visible.
I wrote this program in the mid-80's when I first got my 41CV. Looking at it now, I see lots of opportunities to make it faster and shorter so maybe I'll post an update later.
To start, simply XEQ "GALAXIS". You'll be asked whether you want sound or not, and then you can start guessing. Enter coordinates as a letter between A and G followed by a number 1 through 9 (since you're in Alpha mode you'll need to use the shift key to enter the number). The number of ships visible from your entered coordinates will be shown through the indicators for flags 0 through 4. When you've hit all 4 ships, you'll see the number of tries it took you and you'll be asked if you want to play again.
Here a links to png and pdf versions of the game grid that you can print to play the game.
Game grid - PDF
Game grid - PNG
Here's a link to the RAW file for those of you that have the i41CX+ emulator for iPhone by AL Software:
GALAXIS.RAW
Let me know if you have any questions/issues!
Requirements:
27 data registers
885 program bytes (127 registers)
HP-41C with 2 memory modules or quad-memory module and X-functions module
or
HP-41CV with X-functions module
or
HP-41CX
Listing:
Registers:
Flags:
This HP-41 program allows you to play this game.
The goal of the game is to find 4 space ships in as few attempts as possible. The game board is a grid of 9 columns by 7 rows, i.e. coordinates A1 through G9. If there is no ship on the coordinates you entered, you'll get as answer the number of ships visible from that location along the lines of the grid (horizontal, vertical, diagonal). You cannot look 'behind' a ship. For example, if the ships are on locations G1, F2, A5 and D7, and you shoot at D4, the answer will be 2 - not 3 because from D4 you can see the ship at F2 but not the ship behind it at G1, so only the ships at F2 and D7 are visible.
I wrote this program in the mid-80's when I first got my 41CV. Looking at it now, I see lots of opportunities to make it faster and shorter so maybe I'll post an update later.
To start, simply XEQ "GALAXIS". You'll be asked whether you want sound or not, and then you can start guessing. Enter coordinates as a letter between A and G followed by a number 1 through 9 (since you're in Alpha mode you'll need to use the shift key to enter the number). The number of ships visible from your entered coordinates will be shown through the indicators for flags 0 through 4. When you've hit all 4 ships, you'll see the number of tries it took you and you'll be asked if you want to play again.
Here a links to png and pdf versions of the game grid that you can print to play the game.
Game grid - PDF
Game grid - PNG
Here's a link to the RAW file for those of you that have the i41CX+ emulator for iPhone by AL Software:
GALAXIS.RAW
Let me know if you have any questions/issues!
Requirements:
27 data registers
885 program bytes (127 registers)
HP-41C with 2 memory modules or quad-memory module and X-functions module
or
HP-41CV with X-functions module
or
HP-41CX
Listing:
Code:
01◆LBL "GALAXIS"
02 RCLFLAG
03 STO 26
04 "SOUND? Y/N"
05 AON
06 PROMPT
07 AOFF
08 ASTO X
09 "N"
10 ASTO Y
11 SF 26
12 X=Y?
13 CF 26
14 RCL 00
15 ABS
16 STO 00
17◆LBL A
18 0
19 STO 21
20 STO 22
21 STO 23
22 STO 24
23◆LBL 40
24 .9
25 STO 15
26 STO 17
27 .003
28 STO 16
29 FIX 0
30 CF 29
31 X<>F
32 CLA
33 2.005
34 STO 01
35◆LBL 01
36 XEQ 00
37 7
38 *
39 INT
40 65
41 +
42 XTOA
43 XEQ 00
44 8
45 *
46 INT
47 1
48 +
49 ARCL X
50 ASTO IND 01
51 CLA
52 ISG 01
53 GTO 01
54 GTO 43
55◆LBL 00
56 RCL 00
57 9821
58 *
59 .211327
60 +
61 FRC
62 STO 00
63 RTN
64◆LBL 43
65 2.004
66 STO 19
67 STO 20
68◆LBL 41
69 RCL 19
70 1.001
71 +
72 STO 20
73◆LBL 42
74 RCL IND 19
75 RCL IND 20
76 X=Y?
77 GTO 40
78 ISG 20
79 GTO 42
80 ISG 19
81 GTO 41
82◆LBL 02
83 TONE 9
84 "GUESS?"
85 .9
86 STO 15
87 AON
88 PROMPT
89 AOFF
90 0
91 X<>F
92 ASTO 07
93 ASTO 08
94 ASTO 09
95 2.005
96 STO 01
97◆LBL 37
98 RCL 07
99 RCL IND 01
100 X=Y?
101 GTO 39
102 ISG 01
103 GTO 37
104 GTO 33
105◆LBL 39
106 19
107 RCL 01
108 +
109 STO 25
110 RCL IND X
111 X>0?
112 GTO 47
113◆LBL 46
114 1
115 ST+ IND 25
116 ISG 17
117 ISG 16
118 GTO 38
119 GTO 34
120◆LBL 45
121 TONE 0
122 "INVALID"
123 AVIEW
124 PSE
125 GTO 02
126◆LBL 47
127 TONE 0
128 "ALREADY HIT"
129 AVIEW
130 PSE
131 GTO 02
132◆LBL 38
133 TONE C
134 TONE C
135 TONE C
136 "HIT"
137 AVIEW
138 PSE
139 GTO 02
140◆LBL 33
141 CLA
142 ARCL 08
143 ATOX
144 65
145 X<>Y
146 X<Y?
147 GTO 45
148 71
149 X<Y?
150 GTO 45
151 ATOX
152 49
153 X<>Y
154 X<Y?
155 GTO 45
156 57
157 X<Y?
158 GTO 45
159 ATOX
160 X≠0?
161 GTO 45
162 ISG 17
163 CLA
164 ARCL 08
165 ATOX
166 STO 10
167 ANUM
168 STO 11
169 STO 12
170◆LBL 35
171 2.005
172 STO 01
173 1
174 ST- 12
175 RCL 12
176 0
177 X=Y?
178 GTO 04
179 RCL 10
180 CLA
181 XTOA
182 ARCL 12
183 ASTO 13
184◆LBL 03
185 RCL 13
186 RCL IND 01
187 X=Y?
188 GTO 24
189 ISG 01
190 GTO 03
191 GTO 35
192◆LBL 04
193 RCL 11
194 STO 12
195◆LBL 05
196 2.005
197 STO 01
198 1
199 ST+ 12
200 RCL 12
201 10
202 X=Y?
203 GTO 07
204 RCL 10
205 CLA
206 XTOA
207 ARCL 12
208 ASTO 13
209◆LBL 06
210 RCL 13
211 RCL IND 01
212 X=Y?
213 GTO 25
214 ISG 01
215 GTO 06
216 GTO 05
217◆LBL 07
218 RCL 10
219 STO 12
220◆LBL 09
221 2.005
222 STO 01
223 1
224 ST+ 12
225 RCL 12
226 72
227 X=Y?
228 GTO 10
229 RCL 12
230 CLA
231 XTOA
232 ARCL 11
233 ASTO 13
234◆LBL 08
235 RCL 13
236 RCL IND 01
237 X=Y?
238 GTO 26
239 ISG 01
240 GTO 08
241 GTO 09
242◆LBL 10
243 RCL 10
244 STO 12
245◆LBL 11
246 2.005
247 STO 01
248 1
249 ST- 12
250 RCL 12
251 64
252 X=Y?
253 GTO 12
254 RCL 12
255 CLA
256 XTOA
257 ARCL 11
258 ASTO 13
259 ASTO 13
260◆LBL 30
261 RCL 13
262 RCL IND 01
263 X=Y?
264 GTO 27
265 ISG 01
266 GTO 30
267 GTO 11
268◆LBL 12
269 RCL 10
270 STO 12
271 RCL 11
272 STO 14
273◆LBL 14
274 2.005
275 STO 01
276 1
277 ST- 12
278 RCL 12
279 64
280 X=Y?
281 GTO 15
282 1
283 ST- 14
284 RCL 14
285 0
286 X=Y?
287 GTO 15
288 RCL 12
289 CLA
290 XTOA
291 ARCL 14
292 ASTO 13
293◆LBL 13
294 RCL 13
295 RCL IND 01
296 X=Y?
297 GTO 28
298 ISG 01
299 GTO 13
300 GTO 14
301◆LBL 15
302 RCL 10
303 STO 12
304 RCL 11
305 STO 14
306◆LBL 16
307 2.005
308 STO 01
309 1
310 ST+ 12
311 RCL 12
312 72
313 X=Y?
314 GTO 18
315 1
316 ST+ 14
317 RCL 14
318 10
319 X=Y?
320 GTO 18
321 RCL 12
322 CLA
323 XTOA
324 ARCL 14
325 ASTO 13
326◆LBL 17
327 RCL 13
328 RCL IND 01
329 X=Y?
330 GTO 29
331 ISG 01
332 GTO 17
333 GTO 16
334◆LBL 18
335 RCL 10
336 STO 12
337 RCL 11
338 STO 14
339◆LBL 19
340 2.005
341 STO 01
342 1
343 ST+ 12
344 RCL 12
345 72
346 X=Y?
347 GTO 20
348 1
349 ST- 14
350 RCL 14
351 X=0?
352 GTO 20
353 RCL 12
354 CLA
355 XTOA
356 ARCL 14
357 ASTO 13
358◆LBL 36
359 RCL 13
360 RCL IND 01
361 X=Y?
362 GTO 31
363 ISG 01
364 GTO 36
365 GTO 19
366◆LBL 20
367 RCL 10
368 STO 12
369 RCL 11
370 STO 14
371◆LBL 21
372 2.005
373 STO 01
374 1
375 ST- 12
376 RCL 12
377 64
378 X=Y?
379 GTO 23
380 1
381 ST+ 14
382 RCL 14
383 10
384 X=Y?
385 GTO 23
386 RCL 12
387 CLA
388 XTOA
389 ARCL 14
390 ASTO 13
391◆LBL 22
392 RCL 13
393 RCL IND 01
394 X=Y?
395 GTO 32
396 ISG 01
397 GTO 22
398 GTO 21
399◆LBL 23
400 SF IND 15
401 GTO 02
402◆LBL 24
403 ISG 15
404 GTO 04
405◆LBL 25
406 ISG 15
407 GTO 07
408◆LBL 26
409 ISG 15
410 GTO 10
411◆LBL 27
412 ISG 15
413 GTO 12
414◆LBL 28
415 ISG 15
416 GTO 15
417◆LBL 29
418 ISG 15
419 GTO 18
420◆LBL 31
421 ISG 15
422 GTO 20
423◆LBL 32
424 ISG 15
425 GTO 23
426◆LBL 34
427 BEEP
428 "CONGRATS"
429 AVIEW
430 PSE
431 "IN "
432 RCL 17
433 INT
434 ARCL X
435 "⊢ TRIES"
436 AVIEW
437 PSE
438 "AGAIN? Y/N"
439 AON
440 PROMPT
441 AOFF
442 ASTO 16
443 "Y"
444 ASTO 17
445 RCL 16
446 RCL 17
447 X=Y?
448 GTO A
449 RCL 26
450 STOFLAG
451 CLX
452 " BYE"
453 AVIEW
454 END
Registers:
Code:
R00: seed for random number generator
R01: work variable for counter 2.005 -> 5.005
R02: coordinates of ship 1
R03: coordinates of ship 2
R04: coordinates of ship 3
R05: coordinates of ship 4
R06: not used
R07: Entered coordinates
R08: Entered coordinates
R09: Entered coordinates
R10: ASCII value of entered X-coordinate
R11: entered Y-coordinate
R12: work variable used during check how many ships are visible
R13: work variable used during check how many ships are visible (coordinates of position currently being checked)
R14: work variable used during check how many ships are visible
R15: number of visible ships from entered coordinates
R16: number of ships already hit (during the game); Entered answer to the question "AGAIN? Y/N" (after the game)
R17: number of tries (during game); "Y" (after the game)
R18: not used
R19: work counter to determine if computer generated ship locations overlap
R20: work counter to determine if computer generated ship locations overlap
R21: 0 if ship 1 has not been hit, 1 if it has been hit
R22: 0 if ship 2 has not been hit, 1 if it has been hit
R23: 0 if ship 3 has not been hit, 1 if it has been hit
R24: 0 if ship 4 has not been hit, 1 if it has been hit
R25: work pointer to R21 through R24
R26: status of all flags 0-55 at start of game
Flags:
Code:
00: set if 0 ships visible from entered coordinates
01: set if 1 ship visible from entered coordinates
02: set if 2 ships visible from entered coordinates
03: set if 3 ships visible from entered coordinates
04: set if 4 ships visible from entered coordinates
26: turned on if playing with sound, off if playing without sound
29: turned off at the beginning of the game to suppress digit grouping