mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 11:43:56 +00:00
Fix options
This commit is contained in:
@@ -12,6 +12,7 @@ onmessage = async (event) => {
|
||||
runEmulation(
|
||||
payload.file,
|
||||
payload.options,
|
||||
payload.arguments,
|
||||
payload.persist,
|
||||
payload.wasm64,
|
||||
payload.cacheBuster,
|
||||
@@ -71,8 +72,15 @@ function getMessageFromQueue() {
|
||||
return msgQueue.shift();
|
||||
}
|
||||
|
||||
function runEmulation(file, options, persist, wasm64, cacheBuster) {
|
||||
const mainArguments = [...options, "-e", "./root", file];
|
||||
function runEmulation(
|
||||
file,
|
||||
options,
|
||||
appArguments,
|
||||
persist,
|
||||
wasm64,
|
||||
cacheBuster,
|
||||
) {
|
||||
const mainArguments = [...options, "-e", "./root", file, ...appArguments];
|
||||
|
||||
globalThis.Module = {
|
||||
arguments: mainArguments,
|
||||
|
||||
@@ -114,11 +114,14 @@ export class Emulator {
|
||||
this._setState(EmulationState.Running);
|
||||
this.stautsUpdateHandler(createDefaultEmulationStatus());
|
||||
|
||||
const options = translateSettings(settings);
|
||||
|
||||
this.worker.postMessage({
|
||||
message: "run",
|
||||
data: {
|
||||
file,
|
||||
options: translateSettings(settings),
|
||||
options: options.emulatorOptions,
|
||||
arguments: options.applicationOptions,
|
||||
persist: settings.persist,
|
||||
wasm64: settings.wasm64,
|
||||
cacheBuster: import.meta.env.VITE_BUILD_TIME || Date.now(),
|
||||
|
||||
@@ -15,6 +15,11 @@ export interface Settings {
|
||||
commandLine: string;
|
||||
}
|
||||
|
||||
export interface TranslatedSettings {
|
||||
emulatorOptions: string[];
|
||||
applicationOptions: string[];
|
||||
}
|
||||
|
||||
export function createDefaultSettings(): Settings {
|
||||
return {
|
||||
verbose: false,
|
||||
@@ -58,8 +63,9 @@ export function saveSettings(settings: Settings) {
|
||||
localStorage.setItem("settings", JSON.stringify(settings));
|
||||
}
|
||||
|
||||
export function translateSettings(settings: Settings): string[] {
|
||||
export function translateSettings(settings: Settings): TranslatedSettings {
|
||||
const switches: string[] = [];
|
||||
const options: string[] = [];
|
||||
|
||||
if (settings.verbose) {
|
||||
switches.push("-v");
|
||||
@@ -101,10 +107,13 @@ export function translateSettings(settings: Settings): string[] {
|
||||
|
||||
try {
|
||||
const argv = parse(settings.commandLine) as string[];
|
||||
switches.push(...argv);
|
||||
options.push(...argv);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
return switches;
|
||||
return {
|
||||
applicationOptions: options,
|
||||
emulatorOptions: switches,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user