Still pondering over BASIC


Last month I put a bit of effort into fixing BINSIC – the collection of Groovy scripts that allows the execution of Sinclair ZX80/81 BASIC programs – and I have been thinking about the thing that they offer that modern computers don’t: the ability to switch on and just write a simple program to solve a problem.

The obvious thing to do would be a browser plug-in that replicates the straight-to-coding environment: particularly for Chromebooks and the like.

BASIC lacks expressive power but it is simple to use and would be a good choice, though I guess the line numbers abstraction would have to go.

More than a game: the Game of Life


English: Diagram from the Game of Life
English: Diagram from the Game of Life (Photo credit: Wikipedia)

Conway’s Game of Life has long fascinated me. Thirty years ago I wrote some Z80 machine code to run it on a Sinclair ZX80 and when I wrote BINSIC, my reimplentation of Sinclair ZX81 BASIC, Life was the obvious choice for a demonstration piece of BASIC (and I had to rewrite it from scratch when I discovered that the version in Basic Computer Games was banjaxed).

But Life is much more than a game – it continues to be the foundation of ongoing research into computability and geometry – as the linked article in the New Scientist reports.

For me, it’s just fun though. When I wrote my first version of it back in 1981 I merely used the rubric in Basic Computer Games – there was no description of gliders or any of the other fascinating patterns that the game throws up – so in a sense I “discovered” them independently, with all the excitement that implies: it is certainly possible to spend hours typing in patterns to see what results they produce and to keep coming back for more.

  • “Life.bas” should run on any system that will support the Java SDK – for instance it will run on a Raspberry Pi – follow the instructions on the BINSIC page. A more up to date version may be available in the Github repository at any given time (for instance, at the time of writing, the version in Git supports graphics plotting, the version in the JAR file on the server only supports text plotting). On the other hand, at any given time the version in Git may not work at all: thems the breaks. If you need assistance then just comment here or email me adrianmcmenamin at gmail.

BINSIC plotting working


At the risk of being attacked as an enemy of all that is good, I have to confess to being less than riveted by the Olympics, so far. So I have made far more productive use of my time in seeking to recreate the computing experience of 30 years ago – by working some more on BINSIC – Binsic Is Not Sinclair Instruction Code, my reimplementation of Sinclair ZX81 BASIC.

I have finally got PLOT and UNPLOT to work – not on the same screen as ordinary output, but on a separate graphics console.

Game of Life on BINSIC graphics consoleAs the above – from Conway’s Game of Life –  shows, this has all the sophistication and élan of the original ZX81 experience!

It’s just in the Git repo now (at Github under mcmenaminadrian) but an executable JAR will follow shortly.

 

Running BASIC on the Raspberry Pi


Actually, I ran BINSIC, my very own dialect of BASIC on the Raspberry Pi – it is very slow (a bit slower even than a ZX81 back in the day) but it does work.Raspberry Pi running

Haven’t had a chance to investigate what happens if I tweak the settings on the thing – possibly I might be able to speed execution up. Could be that Java and Groovy is just too much bloat, could be that BINSIC just demands a lot of computation (I refuse to consider that it might be poorly designed and executed).

Some fixes for BINSIC


I have made a few small, but important, fixes to BINSIC, the reimplementation of BASIC I have built using Groovy.

You can download the jar file (which can be run in any standard Java environment) from here: http://88.198.44.150/binsic.jar

Here’s another BASIC “game” (it’s amazing that this sort of thing used to fascinate those of us with these machines), for you to try – it was fixing this up that helped me find the bugs:

10 REM **DICE GAME**SLR/1983**
20 LET A=0
30 LET B=0
40 PRINT "DICE GAME"
60 PRINT "YOUR THROW="
70 GOSUB 160
80 PRINT "MY THROW="
90 GOSUB 220
100 IF A>B THEN PRINT "YOU WIN"
110 IF A<B THEN PRINT "I WIN"
120 IF A = B THEN PRINT "TIE"
130 LET X$ = INKEY$
132 IF X$ = "" THEN GOTO 130
136 CLS
140 IF X$ = "S" THEN STOP
150 GOTO 10
160 FOR G=1 TO 2
170 LET Z=INT (RND*6+1)
180 LET A=A+Z
190 GOSUB 280
195 PRINT
200 NEXT G
210 RETURN
220 FOR G=1 TO 2
230 LET Z=INT (RND*6+1)
240 LET B=B+Z
250 GOSUB 280
260 NEXT G
270 RETURN
280 REM Draw
282 PAUSE 100
285 IF Z = 1 THEN GOSUB 500
290 IF Z = 2 THEN GOSUB 600
300 IF Z = 3 THEN GOSUB 700
310 IF Z = 4 THEN GOSUB 800
320 IF Z = 5 THEN GOSUB 900
330 IF Z = 6 THEN GOSUB 1000
340 RETURN
400 PRINT "[ ][ ][ ]"
410 RETURN
420 PRINT "[*][ ][*]"
430 RETURN
440 PRINT "[ ][*][ ]"
450 RETURN
460 PRINT "[*][ ][ ]"
470 RETURN
480 PRINT "[ ][ ][*]"
490 RETURN
500 REM 1
510 GOSUB 400
520 GOSUB 440
530 GOSUB 400
540 RETURN
600 REM 2
610 GOSUB 460
620 GOSUB 400
630 GOSUB 480
640 RETURN
700 REM 3
710 GOSUB 460
720 GOSUB 440
730 GOSUB 480
740 RETURN
800 REM 4
810 GOSUB 420
820 GOSUB 400
830 GOSUB 420
840 RETURN
900 REM 5
910 GOSUB 420
920 GOSUB 440
930 GOSUB 420
940 RETURN
1000 REM 6
1010 GOSUB 420
1020 GOSUB 420
1030 GOSUB 420
1040 RETURN

The original game can be found here: http://zx81.reids4fun.com/zx81/dice/dice_list.html – I had to change it to cope with the main weakness of BINSIC – that GOTOs to lines inside loops fail.

Relive the ZX81 experience on your desktop


BINSIC – my reimplementation of ZX80 or ZX81 (Timex Sinclair 1000 or 1500 for US readers) BASIC is now available for download in binary form – look at the page on the site: Binsic Is Not Sinclair Instruction Code.

It comes with Conway’s Game of Life for the authentic black and white text based feel too.

(Source code is also available here)

Progress with BINSIC


BINSIC – Binsic Is Not Sinclair Instruction Code – my effort to re-implement Sinclair ZX80/ZX81 BASIC as a domain specific language via Groovy (and eventually a runnable Java JAR file), is making more progress.

ZX80 + bubble TV = modernist bliss (p1120918)
ZX80 + bubble TV = modernist bliss (p1120918) (Photo credit: acb)

Right now it supports:

IF ... THEN ... ELSE
GOTO
GOSUB ... RETURN
LET
FOR ... TO ... STEP ... NEXT
DIM A(x, y, z) (and array derefencing)
CLS
PRINT

Still one or two difficult areas to get through and I have had to make one compromise – unlike on the ZX80 one cannot have a variable and an array with the same letter designation – just too difficult to implement on Java/Groovy.

But, it’s getting there…

Another software death march begins…


I have a new software project now … BINSIC … Binsic Is Not Sinclair Instruction Code.

Sinclair
Sinclair (Photo credit: mofetos)

Instead Binsic is my attempt to reimplement Sinclair’s ZX80/ZX81 BASIC (with a few pieces that were deeply frustrating through their absence all those years ago) as domain specific language using Groovy.

I have spent a fair bit of yesterday and today on this and have not got very far as yet … not even enough to pin up a few dozen lines of code on GitHub.

I have been spending my time trying to get the PRINT command to work. And, well, it doesn’t. I can print some things, but generally only by imposing constraints on the language that were not there in BASIC and so are self-defeating.

And I haven’t even begun to think seriously about how I can tackle the line number problem.

In the meantime, if you know about Groovy and DSLs, you could help me enormously by having a look at this question I have posted on StackOverflow.

Breadboard 81


Benkid77 ZX80 Factorial
Image via Wikipedia

Not everything about computing is on the internet.

Sometime around this point thirty years ago my brother and I went to a computer exhibition in London – “Breadboard 81”

There are a couple of references to it findable through Google. But not much.

It was a fantastic experience – but perhaps also the end of an era: the computer that feature most of all was the “UK 101” – a kit based effort with a real keyboard (unlike the ZX80 Conor and I were using).

It is impossible to describe the thrill one could get from being able to see, use and program (in either BASIC or assembler/machine code) any of these devices: everyone was a pioneer and everyone was equal. (Though this book this book captures the feel of the era that was dying even as it peaked.)

Perhaps there are others who will read this who were also there and who can share their memories of this moment… reminding me of where it even was would be a start? Olympia?