## Minehunt Game for the HP42S

Back to main page | Email me at: Gene!

This is a version of the Minehunt game from the HP48.
Converted to the HP42S by Erik Ehrling, Sweden (email:f95-eeh@nada.kth.se). Comments welcome.

Introduction:

The goal is simple - try to reach the exit square in the lower-right corner without hitting any of the hidden mines. There are 16 mines hidden at random places in the grid. To your guidance, you are informed about the number of mines next to your current position. From that, and with some thinking, it is usually possible to figure out where the mines are and to avoid them. However, there are some situations where you can't know for sure and have to guess.

If you manage to reach the exit square, then go for the harder goal, try to visit every square except for the ones where the mines are. (Note that, like in a patience, the game is not always possible to solve completely.)

A sample game:

Setup This takes around 40 seconds (be patient). Each dot represents
the placement of one of the 16 mines.

Play Move by using the numerical keys (diagonal movement also possible).
The digit next to the mine shows the number of mines in adjacent squares.
(If you anytime during the game want to give up, press the + key).

Game Over If you hit a mine, or reach the exit square the game ends and
your score is displayed. Also shown is the position of all hidden mines.

Some technical notes:
• Minehunt requires the small program called UFL found below.

• The program builds a 7×14 complex matrix where the real part is the number of mines in adjacent squares, and the imaginary part stands for unvisited (0), visited (1), mine (-1) and exit (-2) square. Illegal movements are easily detected by using the indexed matrix position and the matrix wrap flag (76) and undone by simply restoring the last position.

Keys are read by GETKEY and action is taken by an XEQ IND of the value. (Flag 25, error flag, is set before this call to suppress calls to any non-defined label).

• The game is more pleasant to play if you put your HP42S in fast mode before running the game.

Good luck!
Main program:

00 { 658-Byte Prgm }
01 LBL "MINE"
02 CLLCD
03 CF 34
04 SF 35
05 5
06 32
07 XEQ 05
08 7
09 14
10 NEWMAT
11 STO "A"
12 8
13 16
14 NEWMAT
15 STO "C"
16 1
17 LASTX
18 NEWMAT
19 ENTER
20 COMPLEX
21 STO "B"
22 1.016
23 STO 00
24 LBL 00
25 RAN
26 7
27 ×
28 1
29 +
30 IP
31 RAN
32 14
33 ×
34 1
35 +
36 IP
37 ENTER
38 RCL× ST Z
39 1
40 -
41 X=0?
42 GTO 00
43 R
44 INDEX "A"
45 STOIJ
46 RCLEL
47 X0?
48 GTO 00
49 LASTX
50 +/-
51 STOEL
52 RCLIJ
53 COMPLEX
54 INDEX "B"
55 1
56 RCL 00
57 STOIJ
58 RCL ST Z
59 STOEL
60 COMPLEX
61 INDEX "C"
62 STOIJ
63 J+
64 XEQ 01
65 J+
66 XEQ 01
67 I+
68 XEQ 01
69 I+
70 XEQ 01
71 J-
72 XEQ 01
73 J-
74 XEQ 01
75 I-
76 XEQ 01
77 I-
78 XEQ 01
79 9
80 4
81 RCL× 00
82 38
83 +
84 PIXEL
85 ISG 00
86 GTO 00
87 2
88 ENTER
89 STOIJ
90 7
91 14
92 GETM
93 CLV "C"
94 RCL "A"
95 COMPLEX
96 STO "A"
97 CLLCD
98 "BDB@@A"
99"@UQ÷"
100 127
101 XTOA
102 XTOA
103 4
104 XTOA
105"@OPO@A"
106"AAA"
107 10
108 131.086
109 LBL 03
110 AGRAPH
111 DSE ST X
112 GTO 03
113 1
114 69
115 XEQ 05
116 CLA
117 255
118 XTOA
119 170
120 XTOA
121 XTOA
122 XTOA
123 X<>Y
124 XTOA
125 1.05304
126 STO 00
127 LBL 04
128 0
129 RCL 00
130 AGRAPH
131 8
132 X<>Y
133 AGRAPH
134 ISG 00
135 GTO 04
136 "#××"
137 14
138 X<>Y
139 AGRAPH
140 INDEX "A"
141 J-
142 0
143 STO 01
144 -2
145 COMPLEX
146 STOEL
147 J+
148 LBL 06
149 RCLEL
150 COMPLEX
151 2
152 77
153 RCL ST T
154 SF 35
155 XEQ "UFL"
156 SF 34
157 CF 35
158 "÷×"
159 R
160 R
161 X0?
162 XEQ 07
163 RCLIJ
164 STO 02
165 4
166 ×
167 2
168 -
169 X<>Y
170 STO 03
171 LASTX
172 ×
173 X<>Y
174 AGRAPH
175 "÷×"
176 CF 34
177 GETKEY
178 9
179 +
180 R
181 AGRAPH
182 SF 25
183 XEQ IND ST T
184 FC? 76
185 GTO 06
186 LBL 11
187 RCL 03
188 RCL 02
189 STOIJ
190 GTO 06
191 LBL 07
192 X0?
193 GTO 09
194 R
195 1
196 STO+ 01
197 COMPLEX
198 STOEL
199 CF 34
200 "×÷×"
201 RTN
202 LBL 28
203 I-
204 FS? 76
205 GTO 11
206 J-
207 RTN
208 LBL 29
209 I-
210 RTN
211 LBL 30
212 I-
213 FS? 76
214 GTO 11
215 J+
216 RTN
217 LBL 33
218 J-
219 RTN
220 LBL 35
221 J+
222 RTN
223 LBL 38
224 I+
225 FS? 76
226 GTO 11
227 J-
228 RTN
229 LBL 39
230 I+
231 RTN
232 LBL 40
233 I+
234 FS? 76
235 GTO 11
236 J+
237 RTN
238 LBL 01
239 RCLEL
240 1
241 +
242 STOEL
243 RTN
244 LBL 05
245 "0HLj2÷("
246 AGRAPH
247 RTN
248 LBL 09
249 -1
250 X=Y?
251 GTO 10
252 TONE 1
253 TONE 5
254 TONE 4
255 TONE 2
256 ""
257 GTO 08
258 LBL 10
259 TONE 5
260 TONE 2
261 TONE 0
262 "cw>Ö>wc"
263 LBL 08
264 9
265 68
266 CF 34
267 AGRAPH
268 8
279 -
270 0.1
271 RCL× 01
272 IP
273 STO 02
274 XEQ "UFL"
275 9
276 64
277 RCL 01
278 10
279 RCL× 02
280 -
281 XEQ "UFL"
282 INDEX "B"
283 LBL 02
284 RCLEL
285 COMPLEX
286 4
287 ×
288 1
289 -
290 X<>Y
291 2
292 ×
293 X<>Y
294 PIXEL
295 J+
296 FC? 76
297 GTO 02
298 STOP
299 END

UFL - Displays digits in "small font" manner

Syntax
Z:Y-coord
Y:X-coord
X:Digit 0-9
(no error checking)

00 { 73-Byte Prgm }
01 LBL "UFL"
02 XEQ IND ST X
03 R
04 AGRAPH
05 RTN
06 LBL 00
07 ">">"
08 RTN
09 LBL 01
10 "\$> "
11 RTN
12 LBL 02
13 ":*."
14 RTN
15 LBL 03
16 ""*>"
17 RTN
18 LBL 04
19 ">"
20 RTN
21 LBL 05
22 ".*:"
23 RTN
24 LBL 06
25 ">*:"
26 RTN
27 LBL 07
28 ">"
29 RTN
30 LBL 08
31 ">*>"
32 RTN
33 LBL 09
34 ".*>"
35 RTN
36 END

That's it! Thanks to Erik!