Since retro gaming seems to be all the rage on PIs I thought I’d try some vintage BASIC computer games. While psBASIC is great for many things including translating CSV bank reconciliation files, mining data from Apache logs and automating tasks with other CLI oriented tools, I thought I’d take a whack at running the “Hunt the Wumpus” game with it.
Growing up with the TRS-80 model 1 I was given a copy of the “BASIC Computer Games” from Creative Computing. I typed in many of those games. But in those early years saving and loading from cassettes was iffy at best. I must have lost about 75% of what I typed in. I think I lost “Super Star Trek” at least a dozen times before I managed to get one to stick on cassette. Thank heaven for floppies!
I wanted to try a smaller game to begin with. And several years back I translated “Super Star Trek” to FreePascal, making a Linux terminal version with some enhancements, including: color and added difficulty. So I wanted to try something new to me. I chased down the source to “wumpus”. Its actually available many places, including the Atari archives.
The biggest problem I’ve seen with these historic archives of BASIC programs is that it seems they are all OCR’d from scanned listings. There are usually a number of scan+OCR gaffs to chase and fix. But Wumpus is small and it seemed there was only one mistranslation, which was easily fixed with S&R.
Here’s a patch of changes I made:
--- wumpus1.bas 2024-10-29 14:50:05.631744515 -0700
+++ wumpus3.bas 2024-10-29 15:15:18.509937884 -0700
@@ -24,9 +24,9 @@
-0170 DEF FNA(X)=INT(20*RND(0))+1
-0180 DEF FNB(X)=INT(3*RND(0))+1
-0190 DEF FNC(X)=INT(4*RND(0))+1
+0170 FUNCTION FNA(X) : FNA=INT(20*RND(0))+1 : END FUNCTION
+0180 FUNCTION FNB(X) : FNB=INT(3*RND(0))+1 : END FUNCTION
+0190 FUNCTION FNC(X) : FNC=INT(4*RND(0))+1 : END FUNCTION
@@ -51,7 +51,7 @@
-0420 GOTO O OF 440,480
+0420 ON O GOTO 440,480
@@ -70,7 +70,7 @@
-0610 IF I$#"Y" THEN 240
+0610 IF I$<>"Y" THEN 240
@@ -118,8 +118,8 @@
-2040 IF S(L(1),K)#L(J) THEN 2110
+2040 IF S(L(1),K)<>L(J) THEN 2110
-2050 GOTO J-1 OF 2060,2080,2080,2100,2100
+2050 ON J-1 GOTO 2060,2080,2080,2100,2100
@@ -134,10 +134,10 @@
-2530 IF I$#"S" THEN 2560
+2530 IF I$<>"S" THEN 2560
-2560 IF I$#"M" THEN 2510
+2560 IF I$<>"M" THEN 2510
@@ -176,18 +176,18 @@
-3300 IF L#L(2) THEN 3340
+3300 IF L<>L(2) THEN 3340
-3340 IF L#L(1) THEN 3210
+3340 IF L<>L(1) THEN 3210
-3410 IF L(2)#L THEN 3440
+3410 IF L(2)<>L THEN 3440
@@ -206,19 +206,19 @@
-4150 IF L#L(2) THEN 4220
+4150 IF L<>L(2) THEN 4220
-4220 IF L#L(3) AND L#L(4) THEN 4270
+4220 IF L<>L(3) AND L<>L(4) THEN 4270
-4270 IF L#L(5) AND L#L(6) THEN 4310
+4270 IF L<>L(5) AND L<>L(6) THEN 4310
I dropped the context from the patch. Since all lines are numbered its irrelevant. I also interleaved the changes so that they are hopefully more obvious. The changes were pretty simple:
- Replace “#” with “<>”. Apparently OCR doesn’t understand the less than and greater than being side-by-side.
- The original BASIC dialect for Wumpus apparently had a strange syntax for
ON ... GOTO
that needed translation. - psBASIC doesn’t have the condensed
DEF FN...
syntax in favor of the more powerfulFUNCTION
syntax.
It was not uncommon for variations in BASIC dialects to require edits for BASIC programs to succeed on your particular machine. In those days I learned quite a lot about BASIC programming by trying to deduce what the original author’s dialect was doing and then adapting the source to run on my TRS-80.
It didn’t take but half an hour and I finally got to try my hand at hunting the Wumpus. And then I decided to add some sound effects from my collection of sound clip CDs that came with my original SoundBlaster “Multimedia kit for windows” (win3.0). Using psBASIC’s shell()
function its easy enough to pass MP3s or WAVs off to the appropriate program to play. And then for the fun of it I added the ability to shoot the bats too!