Arculator WASM

discuss emulators of 26-bit acorn systems e.g. arculator and rpcemu
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Arculator WASM

Post by pdjstone »

I set myself a challenge to see if I could use Emscripten to compile Arculator to WebAssembly (WASM), allowing it to run in a web browser. The eventual goal would be something like jsbeeb which would allow anyone to try Archimedes games and apps just by following a link.

Arculator already uses SDL and OpenAL which are well supported by Emscripten. Even so, I was surprised that only very minimal changes were needed to the source code and build scripts to get a basic version of Arculator building and running. Thanks to Sarah Walker for creating such an easy-to-hack-on codebase!

There's lots still to do - I've only done the absolute minimum to get something that will run in a browser. Currently sound doesn't work (not sure why) and there's no way to configure the machine or load a disk. Performance isn't great either - it runs at about 60% speed on my fairly fast machine, though I've not spent any time looking into what's causing this. This is my first time using Emscripten, so hopefully there's some low-hanging fruit performance wise.

The source code is at https://github.com/pdjstone/arculator-wasm - see Readme-EMSCRIPTEN.txt for build instructions. You can still build the standard native version of Arculator from these sources too.

You can try a demo out at https://pdjstone.github.io/arculator-wa ... lator.html - just don't expect too much from it at the moment, like I said it's a bit slow right now. Once it boots to the desktop, click inside the emulator until the browser captures the mouse cursor, otherwise it goes a bit haywire!

I'm hoping to add disk image loading support, fix sound and improve the performance when I can, although I don't get much time to work on this. If anyone is interested in helping out, contributions are very welcome!

Paul
User avatar
IanJeffray
Posts: 5963
Joined: Sat Jun 06, 2020 3:50 pm
Contact:

Re: Arculator WASM

Post by IanJeffray »

Holy moses that's boggling! =D> =D> =D> It seems like the mouse step is just enormous - with care the desktop can be used. Wow.
steve3000
Posts: 2909
Joined: Sun Nov 25, 2012 12:43 am
Contact:

Re: Arculator WASM

Post by steve3000 »

:shock: now that is impressive! Well done getting it this far =D>

Works fine on my laptop, feels possibly just a tad slower than ARM2, but not at all bad, and perfectly usable with my mouse and keyboard!

Was a little harder to control on my phone though :wink:
steve3000
Posts: 2909
Joined: Sun Nov 25, 2012 12:43 am
Contact:

Re: Arculator WASM

Post by steve3000 »

...and this was just silly!
armemulatingarmonarm.jpg
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

I got it running at full speed - raw performance wasn't a problem, I just had to tweak how many cycles were executed per frame. Browsers are limited to 60 fps, whereas Arculator wated to run at 100 fps. I also got sound working - it works great in Chrome, but is a bit glitchy in Firefox. I need to understand the sound code a bit better to figure out if there's anything I can tweak to improve it.

I've also updated the demo linked above with a couple of disk images to try. The remaining work now is mainly improving the web interface.
User avatar
baz4096
Posts: 1103
Joined: Sat Apr 10, 2021 3:51 pm
Location: Baildon, West Yorkshire
Contact:

Re: Arculator WASM

Post by baz4096 »

I had a go at this last night, and it reported ~275% speed, however the F12 cursor was definitely flashing faster than normal and I was consistently getting double (or treble) presses on keys, making it tricky to type on. Otherwise, it feels pretty solid and astounding to run a complete RISC OS machine in a browser tab!

(Chrome, Win11, Intel i9)
I run a little online shop called "Vintage Imitation Parts" to sell a few Acorn Archimedes and BBC Micro related bits and pieces, such as my imitation keyboard surrounds and just recently my imitation function strips.

Take a look! vintage.imitation.parts
User avatar
kieranhj
Posts: 1103
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Arculator WASM

Post by kieranhj »

pdjstone wrote: Tue Mar 29, 2022 8:09 pm I got it running at full speed - raw performance wasn't a problem, I just had to tweak how many cycles were executed per frame. Browsers are limited to 60 fps, whereas Arculator wated to run at 100 fps. I also got sound working - it works great in Chrome, but is a bit glitchy in Firefox. I need to understand the sound code a bit better to figure out if there's anything I can tweak to improve it.

I've also updated the demo linked above with a couple of disk images to try. The remaining work now is mainly improving the web interface.
I have to say this is ridiculously amazing to see Lander running at 100% in a browser. =D> =D> =D> We've been dreaming of jsArchie for a while now, as a means to share Archimedes demos more authentically than falling back to YouTube. Would you be willing to accept disc images & autoboot options as a URL parameter from trusted sources, like github, similar to jsBeeb? Sadly I have zero web development skills so not sure where to start to contribute such a change. #-o
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

baz4096 wrote: Wed Mar 30, 2022 8:44 am I had a go at this last night, and it reported ~275% speed ...
(Chrome, Win11, Intel i9)
Hm, interesting - that would suggest your browser is running at more than 60 fps. Could you give the following links a try and let me know what they report as your monitor refresh rate / FPS ?
I definitely have some more work to do to keep the frame rate and sound steady. It looks like jsBeeb adjusts the number of execution cycles per frame which is what I'm planning to do.
kieranhj wrote: Wed Mar 30, 2022 9:21 am Would you be willing to accept disc images & autoboot options as a URL parameter from trusted sources, like github, similar to jsBeeb?
Yes absolutely, those things are next on my list! My web dev skills are a bit rusty, but it should be straightforward to add those. Is there an existing collection of hosted Archimedes disc images similar to the STH archive that jsBeeb uses? They would need to have the appropriate HTTP headers set (e.g. Access-Control-Allow-Origin: *) It seems that GitHub Pages already supports that, so fetching Bitshifters discs should be no problem.
User avatar
baz4096
Posts: 1103
Joined: Sat Apr 10, 2021 3:51 pm
Location: Baildon, West Yorkshire
Contact:

Re: Arculator WASM

Post by baz4096 »

pdjstone wrote: Wed Mar 30, 2022 12:59 pm Hm, interesting - that would suggest your browser is running at more than 60 fps. Could you give the following links a try and let me know what they report as your monitor refresh rate / FPS ?
It's running at 165Hz, which would completely explain the issue. Thanks!
I run a little online shop called "Vintage Imitation Parts" to sell a few Acorn Archimedes and BBC Micro related bits and pieces, such as my imitation keyboard surrounds and just recently my imitation function strips.

Take a look! vintage.imitation.parts
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

baz4096 wrote: Wed Mar 30, 2022 2:14 pm It's running at 165Hz, which would completely explain the issue. Thanks!
I've updated how the main loop runs, and it should now adapt to any frame rate. I've also added an alternative mode which tries to run at a fixed frame rate. Could you give the following links a go and let me know which works best for you (particularly when playing music, e.g. in Lemmings). I've tested it on a couple of my machines in Chrome and Firefox and it seems to work well. It also seems to fix the glitchy sound I was getting in Firefox. I've replaced the speed percentage value in the title with a MIPS counter, but I'm not sure it's being calculated correctly.
kieranhj wrote: Wed Mar 30, 2022 9:21 am Would you be willing to accept disc images & autoboot options as a URL parameter from trusted sources, like github, similar to jsBeeb?
I've written some quick Javascript that can load a disc image, or a ZIP file with a disc image in from a URL. The following link will put a disc in the drive but not load it:

https://pdjstone.github.io/arculator-wa ... ango01.zip

I have also implemented an autoboot parameter, which dumps the value of the parameter into a !boot file on HostFS, so you can do something like this:

https://pdjstone.github.io/arculator-wa ... d*!lemdemo

I tried to get the Chipo Django demo to autoboot, but it doesn't seem to like being launched before getting to the Desktop. Maybe someone can find a fix for this by changing what goes in the boot file?

https://pdjstone.github.io/arculator-wa ... *!Django01
User avatar
baz4096
Posts: 1103
Joined: Sat Apr 10, 2021 3:51 pm
Location: Baildon, West Yorkshire
Contact:

Re: Arculator WASM

Post by baz4096 »

Both of those work identically for me, and feel about A3000 kind of speed. Thank you!
I run a little online shop called "Vintage Imitation Parts" to sell a few Acorn Archimedes and BBC Micro related bits and pieces, such as my imitation keyboard surrounds and just recently my imitation function strips.

Take a look! vintage.imitation.parts
tomc
Posts: 15
Joined: Fri May 20, 2016 7:20 pm
Contact:

Re: Arculator WASM

Post by tomc »

This is incredible. What brilliant work! I have wondered in the past if this would be possible but always assumed the speed would make it impractical. This is super impressive though.

I'm not sure I'll have the ability or time to add much to this great project, but this is to run the Chipo Django demo on boot:

https://pdjstone.github.io/arculator-wa ... .!Django01

This will load into the desktop first then run the demo. Note that the demo takes a little while to initially load so be patient - it might look like nothing is happening!
User avatar
kieranhj
Posts: 1103
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Arculator WASM

Post by kieranhj »

tomc wrote: Thu Apr 07, 2022 4:28 pm This is incredible. What brilliant work! I have wondered in the past if this would be possible but always assumed the speed would make it impractical. This is super impressive though.

I'm not sure I'll have the ability or time to add much to this great project, but this is to run the Chipo Django demo on boot:

https://pdjstone.github.io/arculator-wa ... .!Django01

This will load into the desktop first then run the demo. Note that the demo takes a little while to initially load so be patient - it might look like nothing is happening!
Ahahaha! Thank you for figuring this out for me. =D> I consulted a higher power, i.e. Sarah, to enquire why my demo fell over from !Boot with that memory allocation error. It turns out that this is apparently a hangover from Arthur - there are various RISCOS system calls that do not work correctly/at all outside of the context of the desktop. :? Thus the solution is to boot into the desktop first and run from there, good job!

This means we can now do this: https://pdjstone.github.io/arculator-wa ... $.!Horizon. :D
And this! https://pdjstone.github.io/arculator-wa ... 0.$.!Reach. 8)

(Although the latter might be a little slow until we can also configure the machine via URL.)

Time to start collating an Archie demo archive. :-k
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/
steve3000
Posts: 2909
Joined: Sun Nov 25, 2012 12:43 am
Contact:

Re: Arculator WASM

Post by steve3000 »

Fantastic!!! =D> =D> =D>
User avatar
kieranhj
Posts: 1103
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Arculator WASM

Post by kieranhj »

steve3000 wrote: Thu Apr 07, 2022 8:31 pm Fantastic!!! =D> =D> =D>
You can now run Archie demos on your watch Steve. :D
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

It's awesome to see these demos running live in a browser! Next on my todo list:
  • Ability to choose machine type
  • "fast forward" parameter to run the emulation as quick as possible (without sound or video) up to a certain point in time, so that demos can load faster
  • Unzip a program from a URL onto HostFS, which should be quicker than loading from a disc image
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

I've added a very basic BASIC editor to the web page - it's currently a fairly shoddy imitation of https://bbcmic.ro but works ok for me. You can try it out using the ?basic=... parameter, e.g. https://pdjstone.github.io/arculator-wa ... 0GOTO%2010

Since it takes a while to fully reboot the machine, the 'Run' button currently sends the escape key, and then F1 which I've configured to re-run !Boot which types and runs the program. Does anyone know how to trigger a 'soft' reboot either from inside RISC OS, or via Arculator? I seem to remember a soft reboot being quicker.

If you give it a try, please let me know if you encounter any bugs or odd behaviour!

I'm thinking about how to directly open links to various archive formats, e.g. ZIP, ArcFS, SparkFS etc.. AIUI, some ArcFS/SparkFS archives are ZIP format, but some aren't. Are there any open-source Linux/Windows tools that can unpack non-ZIP SparkFS files?
User avatar
davidb
Posts: 3395
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Arculator WASM

Post by davidb »

pdjstone wrote: Sat Apr 09, 2022 6:56 pm I'm thinking about how to directly open links to various archive formats, e.g. ZIP, ArcFS, SparkFS etc.. AIUI, some ArcFS/SparkFS archives are ZIP format, but some aren't. Are there any open-source Linux/Windows tools that can unpack non-ZIP SparkFS files?
nspark will read Spark files. See this repository, and this page for other links and useful information.
User avatar
pixelblip
Posts: 4050
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Arculator WASM

Post by pixelblip »

Hi
This project looks very interesting.
Amazing you got it working in a web browser...and BASIC in there.........do you have any news on this as it's been a while?
Amazing work...keep it up if you can!
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

It's still alive, although I've not had time to work on it over the summer. The code is split across a few projects: You can see a preview of it working at https://archi.medes.live - there's still a few bugs to fix and I'm in the middle of creating better UI to browse and load software. I'm hoping to get it into a better state over the next few weeks. I'd appreciate any help, particularly on the UI/CSS side as my web design skills are somewhat rusty!
User avatar
sa_scott
Posts: 420
Joined: Wed Feb 09, 2011 11:34 pm
Location: Witley, Surrey, UK
Contact:

Re: Arculator WASM

Post by sa_scott »

I'm so pleased with the progress made on this so far. Such a great way to experience RISC OS games without the faff!

I'm keen to share a 'working' URL for the Hamsters game, because I've missed hammering cute animals with wild abandon for 25 years :twisted: and I think Twitter needs an outlet to let off some steam...

I came up with this:

https://archi.medes.live/#preset=a3020& ... .!Hamsters

However, the user would still need to click on the Hamsters icon in the iconbar to play it. Is there any way the !Run file within the !Hamsters directory can be invoked, so the game just works with minimal intervention?
--
Stephen Scott, Digital Media Muckerupper
Games: Androidz Redux, Headcase Hotel, Polymer Picker
www.sassquad.net
User avatar
IanJeffray
Posts: 5963
Joined: Sat Jun 06, 2020 3:50 pm
Contact:

Re: Arculator WASM

Post by IanJeffray »

sa_scott wrote: Mon Mar 06, 2023 1:19 pm Is there any way the !Run file within the !Hamsters directory can be invoked, so the game just works with minimal intervention?
*configure boot
*configure filesystem hostfs

Create a !Boot obey file which does *run hostfs:$.!Hamsters or whatever

Then you won't even get the desktop in the way - straight to Hamsters.
User avatar
sa_scott
Posts: 420
Joined: Wed Feb 09, 2011 11:34 pm
Location: Witley, Surrey, UK
Contact:

Re: Arculator WASM

Post by sa_scott »

IanJeffray wrote: Mon Mar 06, 2023 1:27 pm
sa_scott wrote: Mon Mar 06, 2023 1:19 pm Is there any way the !Run file within the !Hamsters directory can be invoked, so the game just works with minimal intervention?
*configure boot
*configure filesystem hostfs

Create a !Boot obey file which does *run hostfs:$.!Hamsters or whatever

Then you won't even get the desktop in the way - straight to Hamsters.
I suppose I could do it if I hosted the disc image. However, it would be good if this could be added to the image present on the site, along with any others. Surely the idea is to be able to play these games, without the OS getting in the way?
--
Stephen Scott, Digital Media Muckerupper
Games: Androidz Redux, Headcase Hotel, Polymer Picker
www.sassquad.net
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

I am planning to add an automatic autoboot option for most games I add to the library, so you'd just need to specify the game title, and "autoboot" without any parameters. This works for most games, but unfortunately Hamsters has a pointless WIMP launcher. I had a quick look inside the game and it seems that the WIMP launcher and game itself are both part of the single MCODE binary. You could probably jump straight to the game if you knew the right address to call within the game code. If someone fancies doing a bit of disassembly, it may be doable?
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

BTW, this is what happens if you launch the game without booting to Desktop first!
hamsters-01.png
User avatar
baz4096
Posts: 1103
Joined: Sat Apr 10, 2021 3:51 pm
Location: Baildon, West Yorkshire
Contact:

Re: Arculator WASM

Post by baz4096 »

EDIT: Cross post with above!
User avatar
IanJeffray
Posts: 5963
Joined: Sat Jun 06, 2020 3:50 pm
Contact:

Re: Arculator WASM

Post by IanJeffray »

pdjstone wrote: Mon Mar 06, 2023 3:07 pm BTW, this is what happens if you launch the game without booting to Desktop first!
Oh. I didn't realise it had a desktop interface. Why does it have a desktop interface!?
User avatar
baz4096
Posts: 1103
Joined: Sat Apr 10, 2021 3:51 pm
Location: Baildon, West Yorkshire
Contact:

Re: Arculator WASM

Post by baz4096 »

IanJeffray wrote: Mon Mar 06, 2023 3:38 pm Oh. I didn't realise it had a desktop interface. Why does it have a desktop interface!?
[ X ] Multitasking!
User avatar
IanJeffray
Posts: 5963
Joined: Sat Jun 06, 2020 3:50 pm
Contact:

Re: Arculator WASM

Post by IanJeffray »

baz4096 wrote: Mon Mar 06, 2023 3:46 pm
IanJeffray wrote: Mon Mar 06, 2023 3:38 pm Oh. I didn't realise it had a desktop interface. Why does it have a desktop interface!?
[ X ] Multitasking!
Quite. Ridiculous. It doesn't even do anything as far as I can see. So after launching that, you could run a program which enumerates Iconbar icons, finds one with the !Hamsters sprite, and sends it a mouse click.
pdjstone
Posts: 45
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Arculator WASM

Post by pdjstone »

I finally got my "fast-forward" feature working, which allows you to skip the emulation ahead a specified number of milliseconds from boot. This makes the auto-boot experience much more instant for games and demos. I previously tried to get this working last year, but had problems with the Arculator disc-drive noise routines being tangled up with the main emulator loop, which caused problems when trying to fast-forward the emulation with sound and video disabled. I've now changed the disc noise routines to be called from an emulator timer and it should all work pretty nicely now.

I've started to enable autoboot for items in the Archimedes Live software catalogue, which will automatically select the recommended machine preset, run the software, and fast-forward to the correct starting point.

Some fast-forward examples: For modern demoscene titles, I'm now automatically selecting the "more reduced" sound filter option so the music should sound a lot better too! I'd be grateful if people could try the above links and let me know of any problems or glitches you encounter (particularly with sound)
Post Reply

Return to “32-bit acorn emulators”