Tagged: BASIC
BAYSICK talk in Edinburgh
Tiny BASIC for the Raspberry Pi
A complete Tiny BASIC environment has been ported to the Raspberry Pi.
Only slightly miffed that no one seems to have noticed that I was running BASIC on this platform more than three months ago
Getting booted from Wikipedia
A short article on “Binsic Is Not Sinclair Instruction Code” (BINSIC), my BASIC-like interpreter/DSL for Groovy faces getting deleted from Wikipedia on the grounds of lack-of-notability.
It would not be right or proper for me to intervene to stop this, but if you have been a BINSIC user then a proper third-party reference to it (followed by a clearance of the deletion message in the prescribed manner) would be very much appreciated.
The BINSIC article does not generate much traffic here (perhaps a visit a day), so I admit it is not a particularly important project in the world of computer science, but I hope it has been fun for at least a few people and it is worth keeping as a link to a quick and easy way to get BASIC on your computer.
Related articles
- Wickedpedia: The dark side of Wikipedia (zdnet.com)
- Is Wikipedia going commercial? (salon.com)
- Another time. Another attack to Wikipedia. (jacopobacchi.wordpress.com)
- Wikipedia Is Nearing Completion, in a Sense (theatlantic.com)
- Where Are All the Women of Wikipedia? [Wikipedia] (jezebel.com)
- Requesting open-licensed, open-format recordings of the voices of Wikipedia subjects for Wikimedia Commons (pigsonthewing.org.uk)
More than a game: the Game of Life
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.
Related articles
- BINSIC plotting working (cartesianproduct.wordpress.com)
- Relive the ZX81 experience on your desktop (cartesianproduct.wordpress.com)
- A glider on an aperiodic cellular automaton exists! (aperiodical.com)
- Running BASIC on the Raspberry Pi (cartesianproduct.wordpress.com)
- Google Hides a “Game of Life” Easter Egg on the Search Page (news.softpedia.com)
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.
As 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.
Related articles
- Running BASIC on the Raspberry Pi (cartesianproduct.wordpress.com)
- The expressive power of BASIC (cartesianproduct.wordpress.com)
- Relive the ZX81 experience on your desktop (cartesianproduct.wordpress.com)
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.
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).
Related articles
- Raspbian Linux now available for Raspberry Pi: Up to 40 percent faster than Debian (liliputing.com)
- Raspberry Pi now available for general order (slashgear.com)
- Raspbian: The fastest operating system for the Raspberry Pi (liliputing.com)
- Want to buy more than one Raspberry Pi? Now you can! (raspberrypi.org)
- ODROID-X: The $129 Quad-core Alternative to Raspberry Pi (tomshardware.com)
- Raspberry Pi launched by balloon broadcast images from 40km high (raspberrypi.org)
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)
Life: rewritten
Well, what else was I going to do? This works and that means I think BINSIC does too. It’s not quite a fully functional BASIC – try as I might I cannot get GOTO or even GOSUB to work inside loops (though I might do better if plough on with the GOSUB stuff), but I’ll hopefully launch it all tomorrow evening.
10 REM Game of Life 20 PRINT "Conway's Game of Life" 30 PRINT "Copyright Adrian McMenamin, 2012" 35 PRINT "adrianmcmenamin@gmail.com" 40 PRINT "Licensed under the GPL version 3" 50 DIM A(48, 70) 60 DIM B$(24) 70 PRINT "Please enter your pattern" 75 PRINT " - up to 24 lines of 70 characters" 80 FOR I = 1 TO 24 90 INPUT B$(I) 95 LET T = 0 97 IF B$(I) = "DONE" THEN LET T = 1 98 IF T = 1 THEN LET B$(I) = "" 100 IF T = 1 THEN GOTO 150 110 PRINT B$(I) 120 NEXT I 150 REM Parse Input 160 LET P = 0 170 LET G = 0 175 LET Y = 0 177 LET Q = 0 180 FOR Y = 1 TO 24 190 LET Z = LEN B$(Y) 210 IF Z = 0 THEN NEXT Y 220 FOR Q = 1 TO Z 222 LET A(Y, Q) = 0 225 IF MID$(B$(Y), Q, 1) = " " THEN LET A(Y + 24, Q) = 0 230 IF MID$(B$(Y), Q, 1) <> " " THEN LET A(Y, Q) = 1 232 IF MID$(B$(Y), Q, 1) <> " " THEN LET A(Y + 24, Q) = 1 234 IF MID$(B$(Y), Q, 1) <> " " THEN LET P = P + 1 240 NEXT Q 250 FOR Q = Z + 1 TO 70 260 LET A(Y, Q) = 0 265 LET A(Y + 24, Q) = 0 270 NEXT Q 280 NEXT Y 300 REM Display Map 310 PRINT 320 PRINT 330 PRINT 340 PRINT "Generation ", G, " Population is ", P 350 FOR M = 1 TO 24 355 PRINT 360 FOR N = 1 TO 70 370 IF A(M + 24, N) = 1 THEN PRINT "*"; 375 IF A(M + 24, N) <> 1 THEN PRINT " "; 380 NEXT N 390 NEXT M 400 REM Map next generation 410 FOR M = 1 TO 24 420 FOR N = 1 TO 70 430 LET A(M, N) = 0 440 IF M + 1 < 25 AND A(M + 25, N) = 1 THEN LET A(M, N) = A(M, N) + 1 450 IF M - 1 > 0 AND A(M + 23, N) = 1 THEN LET A(M, N) = A(M, N) + 1 460 IF N + 1 < 71 AND A(M + 24, N + 1) = 1 THEN LET A(M, N) = A(M, N) + 1 470 IF N - 1 > 0 AND A(M + 24, N - 1) = 1 THEN LET A(M, N) = A(M, N) + 1 480 IF M - 1 > 0 AND N - 1 > 0 AND A(M + 23, N - 1) = 1 THEN LET A(M, N) = A(M, N) + 1 490 IF M - 1 > 0 AND N + 1 < 71 AND A(M + 23, N + 1) = 1 THEN LET A(M, N) = A(M, N) + 1 500 IF M + 1 < 25 AND N - 1 > 0 AND A(M + 25, N - 1) = 1 THEN LET A(M, N) = A(M, N) + 1 510 IF M + 1 < 25 AND N + 1 < 71 AND A(M + 25, N + 1) = 1 THEN LET A(M, N) = A(M, N) + 1 520 NEXT N 530 NEXT M 540 LET P = 0 600 FOR M = 1 TO 24 610 FOR N = 1 TO 70 611 LET ZZ = 0 612 LET SC = A(M, N) 612 IF A(M + 24, N) = 1 THEN LET ZZ = 1 613 LET RES = 0 614 IF ZZ = 0 AND SC = 3 THEN LET RES = 1 615 IF ZZ = 1 AND (SC = 2 OR SC = 3) THEN LET RES = 1 616 LET A(M + 24, N) = RES 617 LET P = P + RES 650 NEXT N 660 NEXT M 700 PAUSE 50000 800 LET G = G + 1 900 GOTO 310
A problem with Life

Bill Gosper’s Glider Gun in action—a variation of Conway’s Game of Life. This image was made by using Life32 v2.15 beta, by Johan G. Bontes. (Photo credit: Wikipedia)
I had hoped to “launch” BINSIC – Binsic Is Not Sinclair Instruction Code – my BASIC-as-a-DSL project built using Groovy, this weekend. For the launch I wanted to publish a jar file (so usable by everyone with Java) that ran the version of Conway’s Game of Life (seemed very appropriate for both general – Life being the ultimate hacker meme – and personal – I once wrote a version of Life in Z80 machine code for the ZX80 – reasons) found in Basic Computer Games – but I don’t think I am going to manage it now
The problem is that the code in the book is totally banjaxxed. It uses variables before they are declared and in general looks as though either some lines have been transposed or some code has been omitted altogether. It is certainly plain that the printout of the running program in the book does not reflect the code found on its pages. In any case hacking at this code reveals the full horror of BASIC and how difficult it is to maintain code that is not even in blocks, never mind any other sort of order.
So I have two choices – refactor the BASIC I have in quite a big way to get it to run, or find some new code instead.
But the exercise has not been completely wasted. While hunting down the bugs in David H Ahl’s code I have found more than a few in BINSIC itself.
Related articles
- Life in Life: Conway’s Game of Life Self-Similarity (adafruit.com)
- Conway’s Game of Life in HD (hackaday.com)
- Life imitates Life (aperiodical.com)
- Hadoop’s Game of Life (datasalt.com)