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

Added multiple options to webemulator. #308

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------

Expand Down
57 changes: 56 additions & 1 deletion webassembly/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,40 @@ 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'];

if (ram_val) {
emuArguments.push('-ram', ram_val);
}
if (cpu_val) {
if (cpu_val == 'c816')
if (cpu_val == 'c816') {
emuArguments.push('-c816');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one point here, it's possible that 816 will become the default later, so perhaps this should check for c02 in cpu_val and if it is set, add -c02 to the emu args.

This will have to be done in a new PR.

}
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();
Expand Down Expand Up @@ -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.');
Expand Down
Loading