Raspberry BASIC

Author Topic: New: In-browser BBC BASIC for SDL 2.0  (Read 3690 times)

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
New: In-browser BBC BASIC for SDL 2.0
« on: August 30, 2020, 07:06:52 PM »
I've built an experimental in-browser (WebAssembly) edition of BBC BASIC for SDL 2.0 which will currently run in Microsoft Edge and Google Chrome (but not Firefox).  It can be run directly from this link.

There are a number of demo programs included which can be found in the examples/games, examples/general, examples/graphics and examples/sounds directories.  For example:

Code: [Select]
*cd examples/graphics
CHAIN "bounce"

There are some significant limitations, the most serious of which is probably that the GCOL 'logical plotting' modes (AND, OR, EOR) don't work; this is because webgl does not support these operations.  Another limitation is that the SYS statement is not supported.  It's also quite slow!

Currently there is no way to load in your own program(s), that needs to be thought about.  Also, the local filesystem provided by Emscripten is volatile and anything saved there will be lost when you close the browser.

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: In-browser BBC BASIC for SDL 2.0
« Reply #1 on: August 31, 2020, 09:29:39 AM »
There are some significant limitations, the most serious of which is probably that the GCOL 'logical plotting' modes (AND, OR, EOR) don't work

To address this, in part, I have arranged that rather than the logical plotting modes being completely non-functional they activate the nearest supported webgl blend mode.  So for example GCOL 1 sets 'add' and GCOL 2 sets 'multiply'; whilst these obviously have significantly different effects from the genuine logical modes (OR and AND), they are equivalent in the special case when the RGB values of the source and destination are all 0.0 (&00) or 1.0 (&FF).

The updated version can be run, as before, from this link; it will only work in Microsoft Edge or Google Chrome.  You may have to clear your browser cache to guarantee picking up the new version.

To demonstrate the newly-implemented GCOL modes I have added polydots.bbc in the examples/graphics directory, which didn't work previously because it relies on GCOL 3,15.

Richard Russell

  • Moderator
  • *****
  • Posts: 66
    • View Profile
Re: New: In-browser BBC BASIC for SDL 2.0
« Reply #2 on: September 07, 2020, 11:02:14 AM »
I have updated the in-browser edition of BBC BASIC for SDL 2.0 to version 1.14y.  The differences in this version are:

  • Fixed a performance issue caused by yielding to the browser too often, which throttled graphics output.

  • Added the sortlib and eventlib libraries, compatible with those supplied with the other editions.

  • Added sorttest.bbc, in the examples/general/ directory, to test the sortlib library.

  • Added multitouch.bbc, in the examples/general/ directory, to demonstrate the eventlib library (needs a touchscreen).

  • Restored aliens.bbc to animate 80 sprites, to demonstrate the improved graphics performance (I get about 30 fps on my Core i7 laptop and 48 fps on my fastest desktop, both in Microsoft Edge).

Users of 32-bit Windows please note that a few of the supplied programs do not work properly, seemingly because of a bug in the 32-bit WebGL.