jsdf / pce

Emulates Mac Plus, PC, & Atari ST in the browser using WebAssembly
https://jamesfriend.com.au/pce-js
GNU General Public License v2.0
864 stars 154 forks source link

Ability to download data from within the emulated OS #20

Open jywarren opened 4 years ago

jywarren commented 4 years ago

In https://github.com/jsdf/pce/issues/5 @dluciv explored ways to upload data into the emulated OS, and there are some working examples. I'm curious about the opposite; if, say, we create a HyperCard stack inside the emulator, could we copy it onto a disk and then download the disk in the browser environment?

@DrJosh9000 as you seem to have set up the very cool https://hypercardadventures.com/ with the ability to upload a disk at runtime, maybe you had thoughts about downloading data too? Thanks, all.

DrJosh9000 commented 4 years ago

So, loading/saving disk images on HCA wasn't a huge feat of hacks, just:

(a) coming up with a decent UI for letting the user load and save files to JS memory (b) the emscripten file API allowing exchange between JS memory and the emscripten filesystem, and (c) there being a command interface in PCE, which I augmented with some C-side helpers and exported to emscripten

The real trick would be reading and writing individual files (like how Mini vMac has its ImportFl / ExportFl tools), but I didn't get far into the Mini vMac source last time I went looking. Also quirks get in the way of vintage files working in the modern world (legacy encodings, resource forks). Disk images are at least a bit more portable.

jsdf commented 4 years ago

This would be much easier to do with my BasiliskII port, as BasiliskII already has the functionality of exposing the host OS filesystem to the emulator: https://github.com/jsdf/macemu

Once you can transfer files to or from the host filesystem, it's just a matter of using the Emscripten filesystem APIs