50 years of BASIC!

Wow time flies!

So if you are interested, TIME magazine has a fantastic article on the history of basic!

To celebrate, there is the GE simulator ‘true basic‘ on Dartmouth , and another more obscure (and seemingly deleted) simulator for MS-DOS.  Which is interesting at least for more demo programs.

There is even a ‘web‘ based simulator, but I haven’t tried it.

For the heck of it, I took an old ‘game’ taxman.bas (Downloaded from here, and which I extracted with SIMH) and with a couple of line changes, got it to run.

10 DIM T(10)
20 DIM L(50)
101 PRINT
104 PRINT”HI, I’M THE TAXMAN”
106 PRINT”DO YOU WANT THE REGULATIONS”
108 LET R = 1
110 IF R<>0 THEN 900
120 REM ***INITIALZATION
122 GOSUB 800
124 REM ***THE HUMAN TAKES A NUMBER
126 GOSUB 500
128 REM *** COMPUTE THE HUMAN’S AND TAXMANS TOTLES
130 GOSUB 570
132 REM *** PRINT THE NEW LIST
134 GOSUB 600
136 REM *** CHECK IF ANY NUMBERS STILL HAVE FACTORS
138 GOSUB 650
140 IF M=1 THEN 126
142 REM *** FIND THE WINNER
144 GOSUB 700
146 REM *** AGAIN?
148 GOTO 750
496 REM
497 REM *** THE HUMAN MOVES
498 REM
500 PRINT
502 PRINT
504 PRINT”YOU TAKE”;
506 INPUT K
508 LET K=INT(K)
510 IF K <= 0 THEN 750
512 IF K <=N THEN 518
514 PRINT K;”IS NOT IN THE LIST — TRY AGAIN.”
516 GOTO 502
518 IF L(K)=0 THEN 514
520 REM FIND ALL THE FACTORS
522 IF K>1 THEN 530
524 PRINT”THERE ARE NO FACTORS OF”;K;”FOR ME.”
526 PRINT”ARE YOU TRYING TO SHORT-CHANGE THE TAXMAN?”
528 GOTO 502
530 LET M=0
532 FOR I=1 TO K/2
534 IF L(I)=0 THEN 544
536 IF K <> I*INT(K/I) THEN 544
538 LET M=M+1
540 LET T(M)=I
542 LET L(I)=0
544 NEXT I
546 REM CHECK WETHER THERE WERE ANY FACTORS
548 IF M=0 THEN 524
550 LET L(K)=0
552 RETURN
566 REM
567 REM *** COMPUTE THE HUMAN’S AND TAXMAN’S TOTALS
568 REM
570 LET Y=Y+K
572 PRINT”YOUR TOTAL IS”;Y
574 PRINT”I GET”;
576 FOR I=1 TO M
578 PRINT T(I);
580 LET Z=Z+T(I)
582 NEXT I
584 PRINT
586 PRINT”MY TOTAL IS”;Z
588 RETURN
596 REM
597 REM *** PRINT THE NEW LIST
598 REM
600 PRINT
602 PRINT”NEW LIST:”;
604 LET M=0
606 FOR I=1 TO N
608 IF L(I)=0 THEN 614
610 PRINT I;
612 LET M=1
614 NEXT I
616 RETURN
646 REM
647 REM *** CHECK IF ANY NUMBERS STILL HAVE FACTORS
648 REM
649 REM CHECK IF THE LIST IS EMPTY
650 IF M=0 THEN 690
652 FOR I=N TO 4 STEP -1
654 FOR J=2 TO I/2
656 IF L(J)=0 THEN 664
658 IF I<> J*INT(I/J) THEN 664
660 LET M=1
662 RETURN
664 NEXT J
666 NEXT I
668 REM THE TAXMAN GETS THE REST OF THE NUMBERS
670 PRINT
672 PRINT”I GET”;
674 FOR I=1 TO N
676 IF L(I)=0 THEN 682
678 PRINT I;
680 LET Z=Z+I
682 NEXT I
684 PRINT”BECAUSE NO FACTORS OF ANY NUMBER ARE LEFT.”
686 PRINT”MY TOTAL IS”;Z
688 LET M=0
690 RETURN
696 REM
697 REM *** FIND THE WINNER
698 REM
700 PRINT
702 IF Z>Y THEN 708
704 PRINT”YOU”;Y;” TAXMAN”;Z;” YOU WIN!!!”
706 RETURN
708 PRINT”TAXMAN”;Z;” YOU”;Y;” THE TAXMAN WINS.”
710 RETURN
746 REM
747 REM *** AGAIN?
748 REM
750 PRINT
752 PRINT
754 PRINT”AGAIN (Type 0 for NO)”;
756 INPUT R
759 IF R=0 THEN 999
760 GOTO 122
796 REM
797 REM *** INITIALATION
798 REM
800 PRINT
802 PRINT”HOW MANY NUMBERS DO YOU WANT IN THE LIST”;
804 INPUT N
806 LET N=INT(N)
808 IF N <= 0 THEN 999
810 IF N=50 THEN 818
811 IF N<50 THEN 818
812 PRINT”AT THIS TIME, REGULATIONS ALLOW A MAXIMUM OF 50 NUMBERS.”
814 GOTO 800
818 LET Y=0
820 LET Z=0
822 PRINT
824 PRINT”THE LIST IS:”;
826 FOR I=1 TO N
828 PRINT I;
830 LET L(I)=1
832 NEXT I
834 IF N>1 THEN 844
836 PRINT
838 PRINT”HOW VERY GENEROUS OF YOU TO FORFEIT ALL TO THE TAXMAN.”
840 PRINT”TAXMAN 1 YOU 0 THE TAXMAN WINS.”
842 GOTO 750
844 RETURN
896 REM
897 REM *** INSTRUCTIONS
898 REM
900 PRINT
901 PRINT”YOU TRY TO BEAT THE TAXMAN.”
902 PRINT
904 PRINT”WE START WITH A LIST OF WHOLE NUMBERS IN NUMERICAL”
906 PRINT”ORDER (YOU DECIDE HOW MANY).”
908 PRINT
910 PRINT”YOU TAKE A NUMBER FROM THE LIST — THE TAXMAN GETS”
912 PRINT”ALL THE FACTORS OF YOUR NUMBER THAT ARE STILL LEFT”
914 PRINT”YOUR NUMBER AND ALL OF ITS FACTORS ARE THEN DELETED”
916 PRINT”FROM THE LIST.”
918 PRINT
920 PRINT”FOR EXAMPLE, SUPPOSE YOU WANT TEN NUMBERS TO BE IN THE LIST.”
922 PRINT”THEN THE LIST WOULD BE: 1 2 3 4 5 6 7 8 9 10″
924 PRINT
926 PRINT”IF YOU TOOK 8, THE TAXMAN WOULD GET: 1, 2, AND 4″
928 PRINT”AND THE NEW LIST WOULD BE: 3 5 6 7 9 10″
929 PRINT”TYPE <RETURN> TO GO ON”
932 PRINT”THE TAXMAN MUST GET SOMTHING EVERY TIME SO YOU CAN”
934 PRINT”ONLY PICK A NUMBER THAT HAS FACTORS LEFT,”
936 PRINT
938 PRINT”WHEN NONE OF THE REMAINING FACTORS,”
940 PRINT”THE TAXMAN GETS THEM!!!”
942 PRINT
944 PRINT”YOUR SCORE IS THE SUM OF NUMBERS YOU TAKE.”
946 PRINT”IF YOU WANT TO GIVE UP, TAKE 0.”
948 PRINT”GOOD LUCK !!!”
950 GOTO 122
999 END

Taxman!

Taxman!

It’s not much to look at, but it is kinda neat to see it run.

But really, read the Time article!

Oregon Trail

Oh noes!

I had just found out that the Oregon Trail game is a LOT older than the Apple II version that infested schools in the 1980’s and gave us the infamous broken axle. As a matter of fact it was first written for the HP 2100, in BASIC.

Yes the computer was the size of a wagon!

There is a most excellent blog, The Digital Antiquarian that goes over the restoration of this old gem.  Even better they managed to get it loaded up onto a timesharing image, on the internet so you can play it! (it’s been since taken offline. sorry).

You can download the source here/mirror, along with a revised 1978 version.

Directions from the site:

1. Telnet to mickey.ath.cx. (Telnet, mind you. None of that newfangled SSH!)
2. Slowly alternate CTL-J and CTL-M until you see a “PLEASE LOG IN” message.
3. Enter “HEL-T001,HP2000,1″. Without the quotes, of course — and note that those are zeroes. Oh, and the system isn’t case-sensitive, but for the authentic experience you might want to have your caps lock on.
4. Enter “GET-OREGON” to load the 1975 version, “GET-ORE2″ to load the 1978 version.
5. “LIST” the program if you like, or just “RUN” it.

You can download a working disk for the SIMH HP-2100 emulator(mirror) here/mirror.  This comes pre-loaded with the 1978 version.

HP-2100 menu

HP-2100 menu

Select option J and away you go.

It seems easier then I recall as a kid, not to mention I won the first time I played it!

Victory!

Duke 3d & the Build engine

Well I was looking at some stuff on old games, and naturally everyone always did love Duke Nukem 3D!

Now what is really cool, is that that the guy behind the build engine, Ken Silverman released the source to the ‘build’ engine, but also some of the builds of build as it progressed.

Ken is a big fan of QuickBasic, so to compile his earliest version, you’ll need QuickBasic 4.5, or the QBasic that came with MS-DOS 5.0 and above.

Download picrot4.bas, and run it through basic, and you’ll get this:

Qbasic 'Build'

Qbasic ‘Build’

Under some emulators (Virtual PC) you’ll get a corrupted screen at first, hit any of the arrow keys, and it’ll redraw the screen into what it should look like. Considering the 8kb of basic code includes the engine, and the map it’s pretty snazzy!

You can find the timeline, and other versions of the build engine as it progressed on Ken’s web page.

As the engine improved, and was ported into C, it only got better! Then it was sold and licensed out, which gave rise to great games like 3D Realms Duke Nukem!

Notice the similarities?

Notice the similarities?

After the build engine went open, 3D realms followed up, in releasing their extensive modifications to build which can be found here.

In the off chance you don’t have the game, you can still get the shareware version of it from 3D Realms here, and of course the full version on Good Old Games for $5.99 USD.

With the release of Build & Duke 3D, it’s only natural that they shed their humble MS-DOS beginnings and found their way onto Windows as full Win32 applications taking advantage of the hardware. Thanks to the work of Ken & Jonathon. You can find the results on Jonathon Fowler’s page here.

I suppose later I’ll have to see if it’ll build with the win64 tools… It’s be neat for a 64bit version of Duke!

Bywater basic

bwbasic and life.bas

bwbasic and life.bas

Well I forget what it was I was looking for, but I came across this great site, all about Vintage BASIC, and some various GAMES!

Now back in the 1970’s and early 1980’s BASIC was quite different then it is in it’s current Microsoft incarnation as Visual Basic .NET. But not all that surprising is that Microsoft was a popular BASIC distributor to the microcomputers of the time, supplying BASIC for Commodore, among others, wikipedia has a great list of all the variants of their 8 bit rommable basic.

Back in college a friend was just a little obsessed with basic (he probably still is) and he was all happy as hell to have found this little interpreter written in C, that we could run on the RS/6000 called Bywater BASIC.

Now while vintage-basic has this basic interpreter written in Haskell to run the programs, I thought I’d see if I could get some to run on Bywater.

First was picking a version, and building it. I found that version of 2.5 was the easiest to build on my NeXT, and with a minor amount of hacking, even windows.. bwbasic needs a BIG stack… so 16bit stuff is out, but I guess it doesn’t matter as they had Quick Basic, and the old MS basic so this would be redundant.

Anyways out of the examples I chose the life program, and with a few changes it’ll run on QuickBASIC as a test, and bwbasic 2.5

2 PRINT TAB(34);"LIFE"
4 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
6 PRINT: PRINT: PRINT
8 PRINT "ENTER YOUR PATTERN:"
9 X1=1: Y1=1: X2=24: Y2=70
10 DIM A(24,70),B$(24)
20 C=1
30 INPUT B$(C)
40 IF B$(C)="DONE" THEN B$(C)="": GOTO 80
50 IF LEFT$(B$(C),1)="." THEN
B$(C)=" "+RIGHT$(B$(C),LEN(B$(C))-1)
END IF
60 C=C+1
70 GOTO 30
80 C=C-1: L=0
90 FOR X=1 TO C-1
100 IF LEN(B$(X))>L THEN L=LEN(B$(X))
110 NEXT X
120 X1=11-C/2
130 Y1=33-L/2
140 FOR X=1 TO C
150 FOR Y=1 TO LEN(B$(X))
160 IF MID$(B$(X),Y,1)<>" " THEN A(X1+X,Y1+Y)=1:P=P+1
170 NEXT Y
180 NEXT X
200 PRINT: PRINT: PRINT
210 PRINT "GENERATION:";G,"POPULATION:";P;:
IF I9 THEN
PRINT "INVALID!";
END IF
215 X3=24:Y3=70:X4=1: Y4=1: P=0
220 G=G+1
225 FOR X=1 TO X1-1:
PRINT:
NEXT X
230 FOR X=X1 TO X2
240 PRINT
250 FOR Y=Y1 TO Y2
253 IF A(X,Y)=2 THEN A(X,Y)=0:GOTO 270
256 IF A(X,Y)=3 THEN A(X,Y)=1:GOTO 261
260 IF A(X,Y)<>1 THEN 270
261 PRINT TAB(Y);"*";
262 IF X<X3 THEN X3=X
264 IF X>X4 THEN X4=X
266 IF Y<Y3 THEN Y3=Y
268 IF Y>Y4 THEN Y4=Y
270 NEXT Y
290 NEXT X
295 FOR X=X2+1 TO 24:
PRINT:
NEXT X
299 X1=X3: X2=X4: Y1=Y3: Y2=Y4
301 IF X1<3 THEN X1=3:I9=-1
303 IF X2>22 THEN X2=22:I9=-1
305 IF Y1<3 THEN Y1=3:I9=-1
307 IF Y2>68 THEN Y2=68:I9=-1
309 P=0
500 FOR X=X1-1 TO X2+1
510 FOR Y=Y1-1 TO Y2+1
520 C=0
530 FOR I=X-1 TO X+1
540 FOR J=Y-1 TO Y+1
550 IF A(I,J)=1 OR A(I,J)=2 THEN C=C+1
560 NEXT J
570 NEXT I
580 IF A(X,Y)=0 THEN 610
590 IF C<3 OR C>4 THEN A(X,Y)=2: GOTO 600
595 P=P+1
600 GOTO 620
610 IF C=3 THEN A(X,Y)=3:P=P+1
620 NEXT Y
630 NEXT X
635 X1=X1-1:Y1=Y1-1:X2=X2+1:Y2=Y2+1
640 GOTO 210
650 END

You just type in some stuff as a starting pattern, then type in “DONE” on it’s own on a single line, and it’ll animate the sequence…

I should also add that the history of Bywater basic is kind of interesting it was started by Verda Spell, the grandmother of Ted Campbell who released it into the public domain.

From the original documentation:

Her (Verda’s) programming efforts were cut
tragically short when she was thrown from a Beaumont to Port
Arthur commuter train in the summer of 1986. I found the source
code to bwBASIC on a single-density Osborne diskette in her knitting
bag and eventually managed to have it all copied over to a PC
diskette. I have revised it slightly prior to this release.

NeXTSTEP audio & mod files…

Well I’ve been looking for a way to get some audio out of Quake for NeXTSTEP… and it’s incredibly complicated. I found some ‘smallish’ program for the m68k black hardware that is a MOD player, modPlayer 2.5 which also included source!

However, for me I can’t run it as the monitor to my cube is busted… But I was able to compile it to verify the source ‘works’. I then built it on my white box (P4 2.4Ghz 1GB of ram, and a real soundblaster 16!) and, after removing the reference to the decrunch routine it produced.. noise, and lots of it. But I did feel like I was getting *somewhere*.

I figure the main reason it’s exploding is that the m68k port uses the same CPU as the Amiga for these MOD files, so no doubt there is some bit flipping needed to go from big endian to little endian, but I know *nothing* about the MOD format.. So after a quick google search on basic mod players, I found qmod, a module player written in Quick Basic!!

So I looked around for a copy of Quick Basic 4.5, and tried to build the program, and it was all crash & burn.

At work we have a copy of PDS, the Professional Development System, also known as Basic 7.1 .. This thing is still useful, it will target OS/2 so you can write these massive programs (and run them under Windows 2000). So I figured I could use that to get the thing to build.. And I ran into the same errors about overflows, and all kinds of crap.

So the next thing to try was a copy of Visual Basic 1.0 for DOS that I got from ebay a while back.. I made images of the disks, which was fun, installed the thing to get.. the exact same errors. But I have to say VB for DOS was cool in that the output window can be in a windows (although text one) and you can trace and see at the same time… If only this was on store shelves in 1992!!!!

Anyways after looking at the command line options for VB for dos, I spotted this…

/Ah Enable huge dynamic arrays

I was surprised! So it would seem the answer was in the compiler, not the nice interface.. I just has ‘assumed’ that the interface would provide all the options.. Not so.

So I re-extracted the qmod source as I’d hopelessly altered it, then ‘fixed’ the one line that prevented compilation…

DEF SEG = VARSEG(mixarea(0))

I just removed that line, and ran the compiler & linker.. and it runs!

C:\TEMP>bc /Ah /O qmod.bas

Microsoft (R) Visual Basic (TM) for MS-DOS (R)
Compiler – Professional Edition Version 1.00
Copyright (C) 1982-1992 Microsoft Corporation. All rights reserved.

Object Filename [qmod.obj]:

Source Listing [nul.lst]:

42555 Bytes Available
33278 Bytes Free

0 Warning Error(s)
0 Severe Error(s)

C:\TEMP>link qmod.obj

Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992
Copyright (C) Microsoft Corp 1984-1992. All rights reserved.

Run File [qmod.exe]:
List File [nul.map]:
Libraries [.lib];
Definitions File [nul.def]:

C:\TEMP>

Now this program does require a sound blaster card, and it also requires the blaster environment variable set properly… So for Virtual PC it’s simply

SET BLASTER=A220 I5 D1 H5 T4

Then run qmod and the supplied mod file, and away it goes!

Qmod under Virtual PC

Qmod under Virtual PC

And I have to say it’s really cool to listen to this thing work, only using peek/poke (ok it’s inp/out in the new syntax…) but it’s playing the soundblaster, and it sounds GREAT.

So going back to PDS & Quick Basic 4.5 they all support the /Ah flag.. So it’ll build on any of them.

So for those who aren’t inclined to play compiler games, here is a pre-built version of Qmod, and it includes a mod file.

Now for those of you who don’t have Virtual PC, or not running on Windows, the program will run on DOSBox as well!

I just found I had to tweak the cpu config a little to make it run.. This is my CPU block in the configuration file.

[cpu]
#core=auto
core=simple
#cputype=auto
cputype=486_slow
cycles=auto
cycleup=500
cycledown=500

Now when you launch DOSBox, it’ll pick some low cpu cycle number and stay there when you launch qmod.. And it’s too low so it’ll sound horrible. So hitting CTRL+F12 will increase the cycles. Set it to 25000, and it’ll run fine. If you set it too high, CTRL+F11 will bring it down. DOSBox already sets the blaster environment variable for you, so it should ‘just work’.

From there I’d recommend sites like Amiga Music Preservation, or Mod Archive. Qmod can play quite a few of the files with the MOD extension, but not all.. But it’s a great small example program.

As luck would have it, my whitebox is having some weird boot issue, so I can’t go any further on this… But I figure I’d share this much with the world…