diff --git a/README.md b/README.md index 42df01e..37bfb46 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,64 @@ The following keys can be used for controlling games: |Cursor Right | RIGHT | +Options for the WebEmulator +-------- + +The following options are available for the WebEmulator. With the exception of manifest, they all work exactly the same as in the normal emulator. +* `manifest` +* `ram` +* `cpu` +* `mhz` +* `keymap` +* `longpwron` +* `widescreen` +* `capture` +* `midlineeffects` + +#### The Address Line +`manifest` tells the emulator what should be loaded as a startup program. If the file is a .bas or .prg, the emulator will load it and try to execute it. If the file is a .zip, the WebEmulator will get access to all the files inside that zip-file. When using a zip-file you may add a manifest file to provide additional information - See section below for more information on `manifest.json` + +On the Commander X16 forums, a link to the webemulator could look something like this: +https://cx16forum.org/webemu/x16emu.html?manifest=/forum/download/file.php?id=1218&ram=2048&cpu=c816&mhz=10&keymap=da&widescreen&capture +This will load the forum file with id 1218 into the emulator. +Give the emulator 2MB of RAM +Set the CPU type to 65C816 +Set the CPU speed at 10 MHz +Set the keyboard layout to Danish +Show the emulator in widescreen mode +Capture the mouse and keyboard input +The options `longpwron`, `widescreen`, `capture` & `midlineeffects` do not have any values, it is enough to have them on the address line to enable the feature. + +#### The manifest.json File +If an application requires more than a single file to function, for example graphics or audio assets, it is necessary to package the needed files in a zip file. If there are more than one start file (BAS or PRG) the `manifest.json` file can be used to specify the default start file with `start_prg` or `start_bas` otherwise the WebEmulator will start the .prg or .bas it finds in the zip file. + +Here is an example of the optional `manifest.json` file + + { + "manifest_version": "1.0.0", + "name": "My Program", + "author": "John Smith", + "app_version": "1.0.0", + "license": "GPL 3", + "ram": "2048", + "cpu": "c816", + "mhz": "10", + "keymap": "da", + "widescreen": true, + "capture": true, + "longpwron": false, + "midlineeffects": false, + "start_prg": "MYPROG.PRG", + "resources": [ + "MYPROG.PRG", + "FILE1.BIN", + "FILE2.BIN" + ] + } + +If the resources section is present, only files specified will be made available to the WebEmulator. +Options set in `manifest.json` will override options on the address line. + Functions while running ----------------------- diff --git a/webassembly/main.js b/webassembly/main.js index 1f68c26..aeb3dbe 100644 --- a/webassembly/main.js +++ b/webassembly/main.js @@ -73,6 +73,11 @@ var manifest_link = url.searchParams.get("manifest"); var ram_val = url.searchParams.get("ram"); var cpu_val = url.searchParams.get("cpu"); var mhz_val = url.searchParams.get("mhz"); +var lang_val = url.searchParams.get("keymap"); +var diag = url.searchParams.get("longpwron"); +var wide = url.searchParams.get("widescreen"); +var capture = url.searchParams.get("capture"); +var midline = url.searchParams.get("midlineeffects"); var emuArguments = ['-keymap', lang, '-rtc']; @@ -80,12 +85,28 @@ if (ram_val) { emuArguments.push('-ram', ram_val); } if (cpu_val) { - if (cpu_val == 'c816') + if (cpu_val == 'c816') { emuArguments.push('-c816'); + } } if (mhz_val) { emuArguments.push('-mhz', mhz_val); } +if (lang_val) { + emuArguments.push('-keymap', lang_val); +} +if (diag != null) { + emuArguments.push('-longpwron'); +} +if (wide != null) { + emuArguments.push('-widescreen'); +} +if (capture != null) { + emuArguments.push('-capture'); +} +if (midline != null) { + emuArguments.push('-midline-effects'); +} if (manifest_link) { openFs(); @@ -310,6 +331,40 @@ function extractManifestFromBuffer(zip) { console.log("Parsed manifest from zip:") console.log(manifestObject); + if (manifestObject.ram) { + console.log('Found RAM amount: '+manifestObject.ram); + emuArguments.push('-ram', manifestObject.ram); + } + if (manifestObject.cpu) { + console.log('Found CPU type: '+manifestObject.cpu); + if (manifestObject.cpu == 'c816') + emuArguments.push('-c816'); + } + if (manifestObject.mhz) { + console.log('Found mhz variable: '+manifestObject.mhz); + emuArguments.push('-mhz', manifestObject.mhz); + } + if (manifestObject.keymap) { + console.log('Found keymap variable: '+manifestObject.keymap); + emuArguments.push('-keymap', manifestObject.keymap); + } + if (manifestObject.longpwron) { + console.log('Found longpwron variable'); + emuArguments.push('-longpwron'); + } + if (manifestObject.widescreen) { + console.log('Found widescreen variable'); + emuArguments.push('-widescreen'); + } + if (manifestObject.capture) { + console.log('Found capture variable'); + emuArguments.push('-capture'); + } + if (manifestObject.midlineeffects) { + console.log('Found midlineeffects variable'); + emuArguments.push('-midline-effects'); + } + const promises = []; if (manifestObject.resources) { console.log('Found resources section in manifest.');