back to article Sinclair BASIC comes to Raspberry Pi

The 80's are so now, as hot on the heels of the RISC OS' Raspberry Pi debut comes the equally retro-tastic news that the BASIC version used in the Sinclair ZX Spectrum can also run on the Pi. The BASIC in question is SpecBAS, is a project run by a chap called Paul Dunn. Full Pi support came to the project with the recently- …

COMMENTS

This topic is closed for new posts.
  1. Anomalous Cowshed

    sincalir

    Makers of the Sincalir Sprectum computer. Now that brings back memories

  2. Antony Shepherd
    WTF?

    Seriously, what the hell is the point.

    1. Grikath
      Thumb Up

      The point?

      a) It can be done.. The root of all evil, but in this case rather innocent.

      b) Nostalgia. Quite a few of us commentards started out on/with this kind of BASIC, or one of it's contemporaries.

      c) Education. There's several ways BASIC can be used to teach logical and programming concepts to kids who otherwise have trouble grasping said concepts *because* of it's linearity, limitations, and relative simplicity.

      d) FUN. Which concept may have eluded you lately. Go get some. It's healthy.

      1. ByeLaw101

        @Grikath

        Just because you can do a thing doesn't mean you should.

        If you want Nostalgia then go and get an emulator, this isn't Nostalgia as it's not Sincalir BASIC at all, it's something else with the Spectrum Basic name on it.

        Education? Are you kidding me? BASIC is not a great language to teach programming concepts, especially Sinclair BASIC!

        and then FUN. Ah yes, I do remember that, and this may be fun for the person who is writing it but this as you know is subjective. So you could also say it's fun to criticize (correclty) someone writing Sinclair BASIC with a view that its Nostalgic, Education and ... well... because it can be done.

        1. Anonymous Coward
          Anonymous Coward

          BASIC is OK

          It's fine to teach simple programming, especially Structured with procedures. The OOP stuff can come along later when the basics (pun half intended) have been learnt.

          Anything that can possibly catch the imagination of a learner is a good thing that can lead onto more afterwards. I believe it's a fallacy that BASIC somehow 'corrupts' a would-be programmer's mind. If one has any aptitude whatsoever one will soon appreciate better ways of doing things as one gains experience.

      2. Anonymous Coward
        Anonymous Coward

        b) This is far off Spectrum basic as QL basic was. This is nothing more of a BBC Basic ripp off.

        c) Sure basic is indeed educational.

        D) Eh? FUN? On a dog slow overly complicated Linux distro? You're kidding are you?

        Make these linuxes run as quick on the desktop as that RISC OS port does and THEN I'm really interested. But as of now, I tried Raspbian, OpenElc's etc... and all of them just suck! The only usable OS on the RPI is RISC OS... but it has seriously ommisions in multimedia and websurfing.

        IMHO if all those supposedly great linux programmers put the same effort in to a collective to build a propper webbrowser, mediapplayer and a few other apps for RISC OS then they would have much more succes. As it is Linux will always remain niche even with the opportunities brought on with the RPI.

        And the RISC OS folk whom still remain don't 'get it!' They keep asking 30 UKP for 'an upgrade from 3.09 to 3.12" (which should be free) or ridiculous asking prices like 150 UKP for an emailprogram or wordprocessor.

    2. mccp

      Eh?

      It seems obvious to me that the point is to spend hobby time writing a BASIC interpreter that will no doubt be used by some for fun.

      In fact, that's exactly the kind of thing that would stand out on a CV from an application for the developer positions I am try to fill.

    3. druck Silver badge
      Happy

      Re: The Point?

      Why would anyone want the inferior Spectrum BASIC on a Pi when you can have the full BBC BASIC experience via the RISC OS port. Unless its so Speccy owners can cry themselves to sleep all over again, because they parents couldn't afford a BBC Micro.

      1. David Given
        Go

        Re: The Point?

        If you like BBC Basic, check here:

        http://www.bbcbasic.co.uk/bbcbasic/z80basic.html

        This is the same version of BBC Basic that the Z88 and NC100, NC200 ran and it's pretty damn good (for a Basic). It even includes Z80 inline assembler. There's a vanilla CP/M version, so you can run it on your old Amstrad PCW if you want (and you know you want to).

        And, of course, it has been exquisitely hacked and munged to run on the Spectrum. http://mdfs.net/Software/Spectrum/BBCBasic/

        R.T. Russell produce a Basic for DOS, that's equally good (inline 80186 assembler! Be afraid) and a Windows version which I have no experience of, but it's apparently Basic 4 compatible. But they're commercial. (I have no idea how you can manage to make charging thirty quid for a pretty crappy Basic by today's standard viable, but there you go.)

        If you're a Linux user, try 'apt-get install brandy' for an open source version.

      2. Irongut

        Re: The Point?

        Ah you deluded BBC owners. I remember you crying yourselves to sleep because your parents wouldn't buy you a Spectrum so you could play all the superior games your school mates were playing.

        1. Manu T

          Re: The Point?

          "Ah you deluded BBC owners. I remember you crying yourselves to sleep because your parents wouldn't buy you a Spectrum so you could play all the superior games your school mates were playing."

          I doubt Speccy games will run on this "basic". Besides this isn't about games but about learn to program. Why so negative? I'd applaud ANY development on the Raspberyy Pi.

    4. Stuart 22
      Thumb Up

      The point is getting a result

      Only a couple of years ago I needed to generate a load of very similar HTML pages. I could have used a proper language but the project was so simple that it was much faster to do in the ultimate procedural language where syntactic errors were flagged up 'in flight'.

      Object orientated coding is not optimal for quick & dirty one-offs. IT 'professionals' sometimes forget that.

    5. plrndl

      COBOLers

      Now how about COBOL and FORTRAN support to amuse all those old banking coders whose jobs have gone to India.

      1. Ian Bush
        Linux

        Re: COBOLers

        Well Fortran, as it has been spelt for 20+ years, is probably there as the gnu compiler collection contains a fortran front end, gfortran

        Ian, who doesn't work in a bank

    6. Giles Jones Gold badge

      I have about 5 or so old books on programming the Spectrum, they're a fun way to pass a rainy day and you can show the kids of today that they don't know they're born. Typing in two or three pages of crudely printed basic listings only for it to not work or do very little.

  3. Pete Spicer

    So it's not really that much like Spectrum BASIC then?

    1. Zola

      The BASIC this article describes sounds more like

      Sinclair QL SuperBASIC, which would be a much better teaching tool than Spectrum BASIC, as QL SuperBASIC was actually quite good (super, in fact).

      1. wheelybird

        Re: The BASIC this article describes sounds more like

        Sounds similar to SAM Coupe BASIC, which was based on Speccy BASIC.

        SAM Coupe BASIC was pretty damn good.

        1. Anonymous Coward
          Anonymous Coward

          Re: The BASIC this article describes sounds more like

          SAM Basic was based on Beta Basic, which was an enhanced version of Spectrum Basic, so sort of right.

      2. MrT

        QL SuperBASIC...

        ...was about as developed as it got - and iirc there was a backwards ports of it to the Speccy that featured on one of the magazine cover tapes. I used to program in both and QL SB was fully procedurised, which was a good basis to learn for things like VisualBASIC and Delphi, both of which I had back when they were v1, stack of 3.5" floppy disks to install. My QL shareware releases were always left in SB so that others could modify and update as required, but the commercial stuff got compiled with Toolkit II and a bunch of other add-ons before release.

  4. Anonymous Coward
    Anonymous Coward

    It won't be the same unless it replicates the rubbery multi-function keyboard. It would take a while to get out of the habit of typing things such as "RUN un" though.

  5. lawndart

    says:

    Better string handling?

    Does it keep the Spectrum's procrustean string logic?

    1. John Brown (no body) Silver badge
      Happy

      Re: says: "procrustean"

      Someone in favour of crabs? Or is that just my warped mind?

  6. Andrew Halliwell
    Paris Hilton

    Better string handling with LEFT$, RIGHT$, MID$, REPEAT$ etc???

    Really?

    I believe the Sinclair BASIC method of string splitting is VASTLY superior to the crippled crappy Commodore method. I think Dunny only added those retarded commands to pander to the people unfortunate enough to have had to endure Microsoft BASIC (of which Commodore BASIC was one dialect).

    The Sinclair method is clear and simple, no need to differentiate between left right and middle.

    take something off the beginning? PRINT A$(TO 5)

    take something off the end? PRINT A$(5 TO)

    take something out of the middle? PRINT A$(3 TO 7)

    And with the use of such functions as LEN, you could do all kinds of things with that simple format,.

    Paris, because Sinclair string splitting was so simple even she could use it.

  7. john devoy

    String handling must have been the only thing that was better. :P

    1. GrantB
      Boffin

      Sinclair Basic

      Ok, so it wasn't BBC Basic, and Procrustean strings... but there was also the odd nice feature...

      Let cyan = 5

      Let magenta = 3

      Let red

      PAPER cyan INK magenta: CLS : PRINT AT 10,10; FLASH 1;"Hello wold"

      And streams seemed pretty elegant at the time....

  8. JimC

    no peeks or pokes?

    or was that just BBC?

    1. tony72

      Re: no peeks or pokes?

      The Speccy indeed had peek and poke, I don't know if this port supports them. More importantly, does it support RANDOMIZE USR (probably the most cryptically named command in any flavour of BASIC)?

      1. Andrew Molyneux

        Re: no peeks or pokes?

        RANDOMIZE USR wasn't actually a command. USR was a function (having the effect of executing some Z80 code at the address provided, returning the value in the BC register when the code returned). RANDOMIZE was a command that set the seed for Sinclair BASIC's pseudo-random number generator (the RND function). Because USR was a function, it couldn't be a statement on its own, so you had to do something with the result. I'm not sure who came up with the idea of using RANDOMIZE - one advantage was that it had no side-effects (unless you planned to use RND, of course). Your other option would be to assign it to a variable (LET a = USR x) but maybe RANDOMIZE was quicker to execute? Who knows. It became a convention, anyway, so a lot of people used it without having a clue what it meant.

        1. David Given

          Re: no peeks or pokes?

          Less typing; RANDOMIZE was one keypress on the Spectrum's gods-forsaken excuse for a keyboard, while LET a = was at least three (I forget whether it needed any shift keys).

          It's not a proper Spectrum BASIC unless it requires you to stare at the keyboard for five minutes trying to find a keyword you don't use very often.

          1. Wize

            Re: no peeks or pokes?

            It was to initiate the random number generator with a seed.

            Use the command:

            RANDOMIZE 5

            or any other constant and the result returned from the random number generator would always be the same.

            Sticking in USR would give an unpredictable number and therefore a random enough seed to the generator to stop any obvious repetitions.

        2. Ian Bush

          Re: no peeks or pokes?

          Guessing here but the RANDOMIZE "convention" might come from the ZX81 where it may have been used in preference to the let form as it took up less memory than the LET form, both in storing the source (key words were tokenised) and possibly avoiding having to store a variable - when you've only got ~3/4kByte for your program every little counted!

      2. Anonymous Coward
        Boffin

        Re: no peeks or pokes?

        Yep, RANDOMIZE was the quickest way of throwing away the result of the USR function, without taking up any memory. More critical on the ZX81 than the Spectrum. The USR function executed a bit of assembly at the given address. It actually put that address into the BC register pair, and on returning, the contents of the BC register pair came back as the function result.

        ULTIMATE / ACG favoured PRINT USR to start their games, but that was on the assumtion that once running, the game never would return to BASIC, so nothing would ever be PRINTed.

        Though in-line or callable Z80/6502 assembly will be a bit useless in a Pi BASIC unless you have the equivalent processor emulator.

        As for BBC vs Sinclair BASIC, they both had their advantages and their gaps in language terms. The only significant difference was that BBC BASIC ran a hell of a lot faster, but that's not an issue with these implementations.

  9. Magnus_Pym

    Excellent...

    ... now where did I put that ZX81 poster that came with the code for 'bomber' on the back and a wildly optimistic illustration of the game on the front.

  10. ByeLaw101
    FAIL

    WTF

    I played with Spectrum basic for a number of years, but couldn't wait to move away from the clunky/slow environment and as soon as I had saved enough pocket money I moved on to other languages. And that was my feeling in the 80's never mind now!!

    With all those features bolted on it's not really Sinclair Basic anymore is it... This is someone who just knocked out a crap interpretation of BASIC and bolted a load of crap at the end of it to try and make it up to date.No one is ever going to use it., little point developing this.

    1. James Hughes 1

      Re: WTF

      My, what a cheery soul you are.

  11. John G Imrie

    Yeah!

    Now I can POKE my PI.

  12. Anonymous Custard
    Joke

    Yes but can it play...

    ...Jet Set Willy?

    1. Anonymous Coward
      Joke

      Re: Yes but can it play Jet Set Willy?

      I heard it got up to level 8...

  13. Lloyd
    FAIL

    Procedures????

    Are you mad, it's quite obviously not Sinclair flavoured Z80 if it supports procedures. Line Number calls are where it's at in Sinclairland.

    1. ZXDunny
      Happy

      Re: Procedures????

      Yes, you can use line numbers (in fact, as in Sinclair BASIC, you must use line numbers). Procedures were added due to demand, and they can be quite useful as they support passing parameters by reference or by value, support local variables and can be CALLed to return a result.

      I kept line numbers in because I think they really force you to think differently about your code, and can be abused in all sorts of ways. There's no CASE structure, but when you can calculate a GOTO or GOSUB using an expression:

      10 GO SUB var*10

      Then you can simulate them quite easily.

      Because line numbers are used, you can easily abuse procedures too - they use the subroutine stack like other handlers, so you could in theory jump in and out of them at will, without having to even call them. Not that I'd advocate that sort of code, but still...

      Aside from all this, I'm frankly amazed at the response - a hell of a lot of people are downloading both the binaries and the source code from the websvn... Not sure I made the right choice about opening up my messy code like that, but it did enable the Pi and linux versions to be made :)

      D.

      1. William Towle
        Thumb Up

        Re: Procedures????

        "Because line numbers are used, you can easily abuse procedures too - they use the subroutine stack like other handlers, so you could in theory jump in and out of them at will, without having to even call them. Not that I'd advocate that sort of code, but still"

        I never felt restricted enough to need this, but did see it done. I liked the Spectrum 16/48K Othello game (CDS Microsystems, http://www.worldofspectrum.org/infoseekid.cgi?id=0003554) so much I had a go at porting it [to AMOS BASIC on the Amiga, for speed]. To save space for the 16K machine they had subroutines that were sometimes GOTO'd to in it - the routine to determine the computer's best move thus doubled as that for the player's help, except there was a priority order to check the empty spaces in the former case but no such favourable weighting for the latter. It took a few goes to get my head around the spaghetti, and I either I became very good at beating the game as a result or failed to port it sanely ... possibly both ;)

      2. Anonymous Coward
        Anonymous Coward

        Re: Procedures????

        Nice work Dunny!

    2. Lloyd
      Thumb Down

      Re: Procedures????

      Can I just point out that I was joking? Apparently hobbyists don't understand sarcasm.

  14. This post has been deleted by its author

    1. david 63

      Re: Just for fun

      I owe you a beer.

      1. Anonymous Coward
        Anonymous Coward

        Re: I owe you a beer.

        Wait I'm confused now. Is it free as in speech AND as in beer?

    2. fawlty
      Thumb Up

      Re: Just for fun

      Upvoted. Hurrah for hobbying. Boo to naysayers.

  15. Anonymous Coward
    Anonymous Coward

    Thanks

    Well done and thanks for giving to the community.

    And I learnt something today too - never heard that word before :)

    http://en.wikipedia.org/wiki/Procrustes

  16. RichardC
    Thumb Up

    Excellent work!!

    Thanks must go to Chris Cowley for compiling it to run on the Pi.

  17. big_Jim
    Thumb Up

    This is excellent news. I can add Sinclair BASIC back onto my CV.

  18. fuzzyfelt
    Stop

    "Man ports old code to new variant architecture"

    FFS - I'm gonna drive my kids around in a clapped out Austin Maxi without seat belts and ban them from shopping on Sundays because everything was better in the eighties.

    Yet another ground breaking story of utter banality which could have been written as - "Man ports old code to new variant architecture"

    Just this weekend I spent two hours teaching a friend's 15 year old son how to write Python. He'd never written a line of code in his life, not even an Excel macro, but by the end of it he was writing his own scripts with an understanding of types, conditions and loops. He'd already pulled in the Random module and was desperate to get his code to work with world. This was all done on his cheapo netbook using IDLE. No Pi, no BASIC required.

    1. RichardC
      WTF?

      Re: "Man ports old code to new variant architecture"

      Well that was two hours of your life you'll never get back...

  19. Jason Bloomberg Silver badge
    FAIL

    Pushing the proprietary button

    you'll first need to run a linux distribution with hard floating point support

    Did they deliberately go out of their way to write their code so it only runs on one particular variant of Linux?

    For a computer whose purpose is to educate in the fine art of computer science this is simply ridiculous.

    1. fuzzyfelt

      Re: Pushing the proprietary button

      Nah, someone wrote a program for Windows for a CPU (presumably x86) with a hardware floating point unit (>386DX) which was then ported to x86 Linux which was then ported to ARM11 Linux.

    2. I like ponies
      Holmes

      Re: Pushing the proprietary button

      The binary linked to on the specbas website is for hard-float ARM linux, since that is what virtually every Raspberry Pi user runs (because it is quicker than soft-float, natch). You can of course build the source to run using software floating point emulation, as has been done (by myself, and quite possibly by others too).

  20. ZXDunny

    Well, I did have some comments but it seems the comment system went awry and my first post got repeated rather than my second post that included info on procedures and suchlike. Shame :)

  21. Andrew Halliwell

    @Lloyd Not sinclair? Rubbish...

    It's quite obviously not pure ZX BASIC true...

    But sinclair did go on to produce machines that used procedures, repeat, defined function, etc.

    First with the QL Superbasic and then with the Z88 (which used a variant of BBC basic iirc)

  22. Nigel Kneale
    WTF?

    Big deal?

    If the author wasn't passing this off as a nextgen Sinclair BASIC and removed all Sinclair-related terms when talking about it, would anyone give a damn about yet another flavour of BASIC?

    1. ZXDunny
      Happy

      Re: Big deal?

      I don't know, but the reason I use the Sinclair-related terms is quite plainly that it is heavily based upon Sinclair BASIC. You'd see that if you tried it, both in the way that the BASIC is entered and the way the language is constructed. Sure, I could call it "A Dartmouth BASIC Remake" but although DMB is at the very roots of my implementation, it was the feel of coding on a Spectrum that I wanted to replicate.

      Judging by the response in the Speccy community, I got that part right at least.

      D.

  23. John Sanders
    Linux

    Programing made fun and practical

    Purebasic: Just like it was in the late 80-90, it is by no means perfect, it is power of C meets Basic-like syntax, even pointers are there if you need them.

    Give it a go there is a demo available on the official website, it is real good.

    It has a compiler 32/64Bit that can produce small and fast standalone exe files.

    Kind of C meets VisualBasic 6 without activex/.net shit.

    Trust me it is fun and practical, it has a lot of functionality under the hood.

  24. Anonymous Coward
    Anonymous Coward

    Dunny - would a solid Spectrum Basic game... like PiMania... work directly on this if converted across?

    1. ZXDunny
      Go

      There are some caveats - bear in mind that the screen resolution is a lot bigger, and that attributes have gone as each pixel is individually coloured...

      But yes, it shouldn't be too hard to do - and if you have problems or find an incompatibility that shouldn't be there, feel free to drop me a line, I'm always ready to fix things that go wrong!

      D.

      1. Anonymous Coward
        Anonymous Coward

        Now having the PiMan appear on the RasPi via this would be something :)

This topic is closed for new posts.

Other stories you might like