Topics

running BBCSDL in a browser

 

Recently read an interesting IEEE Spectrum article on the advances in getting complex stuff to run in any (supporting) web browser.  Here's the link:

https://spectrum.ieee.org/computing/software/webassembly-will-finally-let-you-run-highperformance-applications-in-your-browser

It seems to me, as a dilettante in these matters, that if BBCSDL is written entirely in C, then the tools mentioned in this article would enable it to be translated into asm.js and/or WebAssembly, enabling any modern browser to run it without a heinous efficiency penalty.  Browser-based BBC Basic?  What's not to love about that?  These tools apparently enable the translation of "million line" C++ games so I would have thought, in my untutored way, that a well-crafted, well-written piece of C programming should be pretty straightforward.

That's the limit of my understanding at this point, but it seemed too interesting and relevant to not share.

Richard Russell
 

On Tue, Jan 2, 2018 at 04:17 am, Kendall Castor-Perry wrote:
t seems to me, as a dilettante in these matters, that if BBCSDL is written entirely in C, then the tools mentioned in this article would enable it to be translated into asm.js and/or WebAssembly
I've looked into this in the past.  There are restrictions on what kinds of things you can and can't do, and BBC BASIC relies on some of the things that are not allowed (I think multiple threads is one, and being able to allocate 'executable' memory at an address of your choosing is another).  Also my code is not by any means 'standard' C: it relies on many GCC extensions such as register-based variables, SIMD intrinsics, non-standard use of void pointers, nested functions etc.

Even if you could somehow overcome these difficulties, you would not have graphics, or sound, or OSCLI commands, or VDU commands, or access to the Operating System (at least, not in a compatible way).  So it wouldn't be the BBC BASIC that we are familiar with these days.

Richard.

Richard Russell
 

On Tue, Jan 2, 2018 at 04:17 am, Kendall Castor-Perry wrote:
That's the limit of my understanding at this point, but it seemed too interesting and relevant to not share.
Further to my previous reply, I've now read the article you linked to.  A lot of it is about Emscripten, which I've already investigated and is incompatible with BBC BASIC.  The main restriction which makes it impossible is that it forbids "Code that relies on x86 alignment behaviour", and (my) BBC BASIC's heap is entirely unaligned.  Indeed the only reason BBCSDL can run on an ARM CPU is that modern versions of the architecture (e.g. ARMv7 and ARMv8) do support unaligned accesses, contrary to what it says on the Emscripten page (I pass the -munaligned-access option to GCC). 

Richard.

J.G.Harston
 

If you are running your own server and configure your own settings and manage your own execution security, you can execute BBC BASIC programs as CGI code. Jon Ripley wrote up some example code:
https://bb4w.wikispaces.com/Writing+console+mode+programs+that+will+also+run+in+the+IDE

--
J.G.Harston - jgh@... - mdfs.net/jgh