Key features of BBC BASIC for Windows / SDL 2.0

for discussion of bbc basic for windows/sdl, brandy and more
Post Reply
Deleted User 9295

Key features of BBC BASIC for Windows / SDL 2.0

Post by Deleted User 9295 »

The adminstrator of this forum has generously allowed BBC BASIC for Windows (BB4W) and BBC BASIC for SDL 2.0 (BBCSDL) to be discussed here, even though they are arguably off-topic at a forum which specialises in Acorn products. There may be a few members who don't know very much about them, so I thought I would take the opportunity to list their key features. I hope that's OK. :)

First and foremost, 'my' BASICs are designed to be general-purpose programming languages, not emulators. Although they do emulate Acorn Operating Systems and hardware to an extent, because it's necessary (and expected) to achieve an acceptable degree of compatibility, that is secondary to being able to support native features of the platforms on which they run (graphics, sound, libraries etc.).

For example although MODE 7 is emulated accurately, other MODEs aren't to the same extent. In BB4W and BBCSDL graphics pixels are the same size and shape in MODE 0 as they are in MODE 2, because they are the native pixels of the host platform (possibly after 'high DPI scaling')! Although this does impair compatibility with Acorn platforms, it means that ordinary BBC BASIC output can be freely mixed with, say, antialiased graphics and proportional-spaced text in the same window. It also means that hardware acceleration can be taken advantage of.

Similarly, whilst the BBC Micro's SOUND and ENVELOPE statements are emulated fairly faithfully (although the noise channel less so) it is also possible to output music and sounds from other sources (e.g. WAV or MP3 files) in a BBC BASIC program. The SYS statement, borrowed from ARM BASIC, accesses native 'OS' (Windows in the case of BB4W, SDL 2.0 in the case of BBCSDL) and library API functions, and makes no attempt to emulate RISC OS. This is also useful in being able to access hardware interfaces.

The objective, which I hope I have met, is to make BBC BASIC a serious competitor to the likes of Python or Javascript on the relevant host platforms. That's not to say that BB4W and BBCSDL are not suitable for running BBC Micro or RISC OS BASIC programs, often they will run with little or no modification, but it's not its raison d'être. Whilst BB4W is proprietary, BBCSDL is entirely free and Open Source.

With that introduction out of the way (and with apologies to those who knew all this already), here's the promised list of key features of BB4W and BBCSDL which distinguish them from Acorn's BASICs and (to a lesser extent) Matrix Brandy:
  • Unlimited-length strings (32-bit length).
  • NUL-terminated strings ($$p).
  • New numeric variable types: byte (v&), 64-bit integer (v%%), 64-bit double (v#).
  • Structures and arrays of structures (no, you can't do the same thing with indirection!).
  • System variables (starting with @).
  • Line-continuation character (\) to extend logical lines to multiple physical lines.
  • Address-of operator (^) and string memory pointer (PTR(s$)).
  • GET$#file extended to specify delimiter (TO) or length (BY).
  • GET(x,y) and GET$(x,y) return character at text coordinates.
  • EXIT FOR, EXIT REPEAT, EXIT WHILE statements.
  • ON CLOSE, ON MOUSE, ON MOVE, ON SYS, ON TIME event interrupts.
  • PRIVATE (static) variables, arrays and structures.
  • RESTORE LOCAL to restore formal parameters and LOCAL variables, e.g. on error.
  • SYS can pass and return floating-point values.
  • WAIT n delays by n centiseconds.
  • WIDTH(s$) returns the width of a (possibly proportional-spaced) string.
  • Stereo SOUND and waveform selection.
  • Indirect (by pointer) function and procedure calls.
  • Opaque arrays and structures (defined in and returned from FN/PROC).
  • Labels as destination of GOTO, GOSUB, RESTORE (if you must!).
There are probably some things I have forgotten. It has been suggested that I might like to present some of this at a Virtual ABug session, but I'm not at all sure that I could make it appeal to those whose interests are mainly in 'retro' computing. If you are enthusiastic, let me know.
Soruk
Posts: 1136
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Soruk »

Richard Russell wrote: Sat Jun 06, 2020 12:18 pm It has been suggested that I might like to present some of this at a Virtual ABug session, but I'm not at all sure that I could make it appeal to those whose interests are mainly in 'retro' computing. If you are enthusiastic, let me know.
I think this is a fantastic idea, and I will definitely tune in if it happens. Also, your background with the Computer Literacy Project would make for a very interesting talk for pretty much everybody here, as this is what brought the BBC Micro into being what it was, what put Acorn on the map, and I dare say this board wouldn't exist, nor would either of our projects, if it weren't for the BBC Micro.
Matrix Brandy BASIC VI (work in progress) The Distillery (another work in progress) Note Quiz (New educational software for the BBC and modern kit)
BBC Master 128, PiTubeDirect (Pi 3B), Pi1MHz, 5.25+3.5in dual floppy.
Deleted User 9295

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Deleted User 9295 »

Soruk wrote: Sun Jun 07, 2020 12:40 pmyour background with the Computer Literacy Project would make for a very interesting talk for pretty much everybody here
There's nothing I can add that hasn't already been covered, and anyway my memories of those days are now very vague and unreliable. I was asked to take part in a recorded interview at the Centre for Computing History; I refused. :wink:

I think it could all be rather awkward if I offered to do a virtual ABug session about BB4W/BBCSDL and all that anybody wanted to hear about was my involvement with the BBC Micro. :(
Soruk
Posts: 1136
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Soruk »

Richard Russell wrote: Sun Jun 07, 2020 12:58 pm
Soruk wrote: Sun Jun 07, 2020 12:40 pmyour background with the Computer Literacy Project would make for a very interesting talk for pretty much everybody here
There's nothing I can add that hasn't already been covered, and anyway my memories of those days are now very vague and unreliable. I was asked to take part in a recorded interview at the Centre for Computing History; I refused. :wink:

I think it could all be rather awkward if I offered to do a virtual ABug session about BB4W/BBCSDL and all that anybody wanted to hear about was my involvement with the BBC Micro. :(
I must respectfully disagree, a live demo of the System 1, the internals of how floppy discs and emulators work all are only tangentially related to the BBC Micro yet were well attended and enjoyed. I for one would welcome a talk on BB4W/BBCSDL, and Arcadian last night even suggested that I could do one on Matrix Brandy at some point! So, I would not think such a talk from you would be out of place in the slightest.
Matrix Brandy BASIC VI (work in progress) The Distillery (another work in progress) Note Quiz (New educational software for the BBC and modern kit)
BBC Master 128, PiTubeDirect (Pi 3B), Pi1MHz, 5.25+3.5in dual floppy.
Deleted User 9295

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Deleted User 9295 »

Soruk wrote: Sun Jun 07, 2020 1:10 pmI for one would welcome a talk on BB4W/BBCSDL
You do seem to be the only one though, so that's not really a big enough audience to justify it! :lol:

I strongly suspect I am unique in using BBC BASIC daily as my main programming language on modern platforms. I can barely code in any other language TBH (my C is dreadful, as a glance of the BBCSDL source code will testify) and I don't know C++, Python, Java and the rest of them at all. Most people understandably think this is crazy, but it does motivate me to keep the language going!

I wrote a couple of little routines today which I'm really pleased with, they provide the ability to allocate and free memory blocks in BBC BASIC's heap by leveraging the built-in memory management used for strings. Basically the memory block is allocated in a string, and inevitably it's very BB4W/BBCSDL specific (not least because it assumes strings can be of any length).

This is functionality that I more commonly achieve by calling malloc/free using SYS (or GlobalAlloc/GlobalFree in Windows), but it's nice to have a 'pure BASIC' way of doing it. The trick is to squirrel away the string descriptor just below the allocated block, and then turn it back into a string before freeing:

Code: Select all

      DEF FN_heapalloc(N%)
      LOCAL a$, p%%
      a$ = STRING$(N% + 23, CHR$0)
      p%% = PTR(a$) + 23 AND -16
      SWAP ](p%%-8), ]^a$
      = p%%

Code: Select all

      DEF PROC_heapfree(p%%)
      LOCAL a$
      SWAP ]^a$, ](p%%-8)
      a$ = ""
      ENDPROC
User avatar
sweh
Posts: 3313
Joined: Sat Mar 10, 2012 12:05 pm
Location: 07410 New Jersey
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by sweh »

Because of timezone differences I can't make the vABUGs, even though I want to (I'm in New York, and Saturdays are normally when I see my girlfriend).

But if I did make them, BB4W and Brandy would definitely be of interest. The _history_ of BB4W and the original design decisions (compatibility, compromises, etc) would also be interesting.

Yes, you may be unique in the world in have BBC Basic as your primary language, but that doesn't mean you're the only one who finds this interesting.

I keep thinking that if I ever get around to doing android development, maybe I'll use your BBC Basic toolkit... but that's been a decade old plan that I've never got around to!

(Maybe I'll use Free Pascal instead... Or maybe I'll just never get around to doing it!)
Rgds
Stephen
User avatar
richardtoohey
Posts: 4075
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by richardtoohey »

Just like Stephen, definitely would find it of interest (and there's lots of things of interest, and lots of old projects and plans ... even down to Free Pascal, too!)

I won't be Zooming but because the videos are downloadable =D> I'm certainly planning on downloading and watching any of interest.
User avatar
JudgeBeeb
Posts: 1251
Joined: Thu Sep 10, 2015 9:56 pm
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by JudgeBeeb »

I would love to see a talk on this. I often find a need to write scripts and other programs on a PC to support my retro projects but really don't have the time to learn a new language like Python or Javascript. I would be particularly interested in learning how BBCSDL can interact with the native OS and, in particular, handling of native file systems. Please do reconsider.
There is so much wonder in the universe; why should you want to imagine that there is more?
Deleted User 9295

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Deleted User 9295 »

sweh wrote: Tue Jun 09, 2020 1:59 amThe _history_ of BB4W and the original design decisions (compatibility, compromises, etc) would also be interesting.
I'm afraid that, after 20 years, my recollection is quite vague. I do know that it took me about 18 months to develop BB4W, spending roughly an hour every evening on it (this was when I was still in full-time employment by the BBC of course). Of that, about half was spent translating the 16-bit 8086 assembler code of BBC BASIC (86) for MS-DOS to 32-bit 80386 code (at the same time adding in some of the BASIC V extensions that I hadn't bothered with up to that point) and the other half writing the BB4W IDE in C (relying very heavily on Petzold's 'Programming Windows 95' book). The Windows 95 PC I used still works and occasionally I run it up just to check that my claim that BB4W installs and runs in Windows 95 OSR2 remains true!

As far as 'compatibility and compromises' are concerned I'm afraid rather less thought went into it than you might like. Compatibility with BBC BASIC (86) was uppermost in my mind then (much more so than compatibility with any Acorn products), although where incompatibilities with the BBC Micro had arisen because of limitations in MS-DOS I did try to restore them if Windows allowed (e.g. display resolutions). The overriding consideration, as with all my BASICs, was to prioritise support for the native features of the platform over compatibility, since it was (and is) first and foremost a native Windows implementation of BBC BASIC rather than an emulator.

There you go: the history of BB4W in a nutshell. No ABug session needed! :lol:
Deleted User 9295

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Deleted User 9295 »

JudgeBeeb wrote: Tue Jun 09, 2020 9:30 amI would be particularly interested in learning how BBCSDL can interact with the native OS and, in particular, handling of native file systems. Please do reconsider.
Do keep the suggestions coming. If I did consider doing a session it wouid be necessary to choose quite a narrow focus, otherwise the whole thing would be too rambling and disjointed. Personally I would probably prefer to concentrate on BBCSDL over BB4W, since it's my main 'current' project, but I know that there's probably more interest out there in BB4W than in BBCSDL. Then there are questions of whether my extensions to the language are of more or less of interest than, say, support for I/O (graphics, sound etc.) or the IDEs.

Let's see if there's any kind of consensus on what such a session should concentrate on, or whether (as I fear) there are as many different areas of interest in BB4W/BBCSDL as there are potential audience members!
User avatar
JudgeBeeb
Posts: 1251
Joined: Thu Sep 10, 2015 9:56 pm
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by JudgeBeeb »

My personal preference is BBCSDL, as my preferred platform is macOS.
There is so much wonder in the universe; why should you want to imagine that there is more?
Deleted User 9295

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Deleted User 9295 »

JudgeBeeb wrote: Tue Jun 09, 2020 10:11 am My personal preference is BBCSDL, as my preferred platform is macOS.
If I were to give a talk on BBCSDL as it specifically relates to the Mac it would be very short and uninformative! Of all the platforms I support, Apple's (MacOS and iOS) are by far the ones I know least about. Before obtaining a Mac Mini and an iPod 6, specifically for the purpose of porting BBCSDL, I knew nothing at all about them, and my ignorance is still quite profound. As with all the non-Windows platforms, I am totally dependent on SDL 2.0's role as an 'abstraction layer' in isolating me from their peculiarities.
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by BigEd »

Richard Russell wrote: Sat Jun 06, 2020 12:18 pm It has been suggested that I might like to present some of this at a Virtual ABug session, but I'm not at all sure that I could make it appeal to those whose interests are mainly in 'retro' computing. If you are enthusiastic, let me know.
Such a talk would certainly appeal to me, especially coming from you with your from-day-one involvement in the language. It fits into my definition of retrocomputing too, if you allow me to think of BBC Basic as a retro language - whether or not it's running on a retro computer. Basic has a long and storied history, and is up there with Cobol, Fortran, Algol, Lisp, as being part of the foundation of subsequent language developments. And it's interesting as to how and why Basic has changed and why BBC Basic has the shape it has. It's interesting that you've implemented the language several times for different platforms.

It's still a challenge, when walking up to a computer with only the OS installed, as to how readily one might get to the position of writing and running some code, especially if you want that code to draw graphics or interact with the user. I think BBC Basic is an appropriate way to answer that challenge. And it also speaks to the challenge of how to get a beginner started with coding.

(Sorry, APL and Forth, I didn't mention you... but you're not forgotten.)
User avatar
pixelblip
Posts: 4050
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by pixelblip »

I'd be very interested to hear you Richard and I'm sure many others as well. You have a wealth of knowledge and have kept the BBC Basic flag flying. I couldn't have done my pictures and progressed if it wasn't for BBC Basic for windows.
I think BBC Basic for SDL would be better all around as we have different platforms.
I have certainly found it interesting trying to get Android apps working using SDL to test.
Deleted User 9295

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by Deleted User 9295 »

pixelblip wrote: Thu Jun 11, 2020 3:44 pm I'd be very interested to hear you Richard and I'm sure many others as well.
OK. As I said, to progress this I think we would need to refine the subject to be more tightly-focussed than just BBCSDL, which is too wide-ranging for me to construct a structured talk around. One possibility would be the extensions I've made to the BBC BASIC language, although that's a bit dry and not specific to BBCSDL. Really I'm struggling to think of something with enough content to occupy a sensible time slot but focussed enough not to deteriorate into a ramble!
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by BigEd »

I think some of the talks have been relatively short, allowing lots of time for questions and discussion - and that can be a very good thing.

The thing is that it's a very friendly and sympathetic audience, so it can be more of a structured conversation.
User avatar
KarateEd
Posts: 6367
Joined: Fri Sep 20, 2013 10:15 pm
Location: Squamish, BC, Canada
Contact:

Re: Key features of BBC BASIC for Windows / SDL 2.0

Post by KarateEd »

The idea of extensions to the BBC language really appeals to me. I'd be interested to see what more would be possible on a 32/64 bit system like I have. It could shove me over the procrastination edge of actually purchasing said BBC4W program. I've come very close but perhaps the extensions talk would be the final nail in the coffin.

To me what intrigued me most for the BBC was it's BASIC so extensions would be exciting and interesting.

please do consider it.
Ed...... :-)

3 working Beebs, 1 RetroClinic Master, 1 normal Master, 1 A3010, 1 Pi2 RISC OS, 2 broken Beeb Motherboards, 1 Omnibus A7000+ server, 1 A7000+ Desktop, 1 PET, 1 C64, 1 C128, 1 Amiga 500 and 1 Roamer.
Post Reply

Return to “modern implementations of classic programming languages”