Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running in Browser #16

Closed
phillvancejr opened this issue Nov 2, 2021 · 11 comments
Closed

Running in Browser #16

phillvancejr opened this issue Nov 2, 2021 · 11 comments

Comments

@phillvancejr
Copy link

Is there a way to configure a particular file to run on startup so we can run applications in the browser without the user having to select the file via the gui editor?

Thank you for this project, it is very cool!

@rtrussell
Copy link
Owner

Running a specific application is a case of adding the appropriate parameter(s) to the URL:

?run=<path/program>  Run the specified supplied example program
?dir=<path>          Use the specified directory for subsequent files
?load=<url>          Load the specified file (sub-module or resource file)
?chain=<url>         Load and run the specified program (must be .bbc)

You might like to look at how the direct links to the browser demos here do it.

@phillvancejr
Copy link
Author

wow thanks, this is awesome!

@phillvancejr
Copy link
Author

phillvancejr commented Nov 2, 2021

When trying to build src for the browser using the makefile in the wasm folder I got an error when trying to build Box2D231.o. Is this some external dependency?

@rtrussell
Copy link
Owner

Is this some external dependency?

It's the Box2D physics engine; it's only needed for the demos in the examples/physics directory. Why do you need to build the browser edition yourself, can't you use use the one installed at wasm.bbcbasic.co.uk? That's already configured to work with Firefox (i.e. it supports the COOP and COEP headers).

@phillvancejr
Copy link
Author

phillvancejr commented Nov 3, 2021

I'm just tinkering with the repo, but I am interested in building the browser edition myself in case I wanted to try and embed a project built with it in a website. I could always use something like an Iframe I suppose

@rtrussell
Copy link
Owner

I'm just tinkering with the repo, but I am interested in building the browser edition myself

Fair enough. Obviously if you do that it will be your responsibility to re-build it if there are bug fixes or other important updates, whereas the version at wasm.bbcbasic.co.uk should always be up-to-date.

I've just noticed that the Box2D object file isn't in the repo because it's excluded by the .gitignore rules, I wonder if there's a way I can override them for that particular file. Apart from that dependency (which you can remove) you should be able to build it yourself but I know there are issues with some versions of Emscripten/SDL and multi-threading. I had to choose which version of Emscripten to use with some care.

@phillvancejr
Copy link
Author

I'm just tinkering with the repo, but I am interested in building the browser edition myself

Fair enough. Obviously if you do that it will be your responsibility to re-build it if there are bug fixes or other important updates, whereas the version at wasm.bbcbasic.co.uk should always be up-to-date.

I've just noticed that the Box2D object file isn't in the repo because it's excluded by the .gitignore rules, I wonder if there's a way I can override them for that particular file. Apart from that dependency (which you can remove) you should be able to build it yourself but I know there are issues with some versions of Emscripten/SDL and multi-threading. I had to choose which version of Emscripten to use with some care.

Ok great, I think I'll try removing the dependency. I've compiled other C++ using threads with Emscripten before with no problems but I'll keep an eye for for when trying to build. Thanks again!

@rtrussell
Copy link
Owner

I've compiled other C++ using threads with Emscripten before with no problems but I'll keep an eye

The symptom to watch out for is a deadlock during start up, see here.

@phillvancejr
Copy link
Author

I've compiled other C++ using threads with Emscripten before with no problems but I'll keep an eye

The symptom to watch out for is a deadlock during start up, see here.

I successfully compiled it with some additional tweaks modifying files that use Box2D. When launching index.html it takes me to the immediate mode interpreter, but when going to bbcbasic.co.uk/bbcsdl.html without any additional link it goes to the resources folder, how was this done? Does bbcsdl direct you to a specific directory?

@phillvancejr
Copy link
Author

Oh I see, sorry, you mentioned it is in lib/autorun.bbc in the forum link above, I'll look into that

@rtrussell
Copy link
Owner

rtrussell commented Nov 3, 2021

When launching index.html it takes me to the immediate mode interpreter, but when going to bbcbasic.co.uk/bbcsdl.html without any additional link it goes to the resources folder, how was this done?

During initialisation it looks for the file lib/autorun.bbc and if found runs it automatically rather than entering the immediate mode command loop. In the version installed at wasm.bbcbasic.co.uk this program handles the URL parameters I listed previously, and if none are present it CHAINs examples/tools/touchide.bbc.

Generally, anything that can be done with a BASIC program is done that way rather than bloating the interpreter. The GUI interfaces provided by the desktop, mobile and browser editions of BBC BASIC are all themselves BASIC programs (examples/tools/SDLIDE.bbc for the desktop editions, examples/tools/touchide.bbc for the mobile and browser editions).

Incidentally I forgot one of the available URL parameters, which was added later to support running a program short enough to be included in its entirety in the URL:

?embed=<base64url-encoded tokenised program>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants