Skip to content

Commit

Permalink
add mount image option
Browse files Browse the repository at this point in the history
  • Loading branch information
rwv committed Apr 20, 2019
1 parent bd9f8a2 commit dd1e167
Showing 1 changed file with 40 additions and 19 deletions.
59 changes: 40 additions & 19 deletions static/emularity/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ var Module = null;
config_args.push(cfgr.model(modulecfg.driver),
cfgr.rom(modulecfg.bios_filenames));
} else if (module && module.indexOf("pce-") === 0) {
config_args.push(cfgr.model(modulecfg.driver));
config_args.push(cfgr.model(modulecfg.driver),
cfgr.extraArgs(modulecfg.extra_args));
} else if (module) { // MAME
config_args.push(cfgr.driver(modulecfg.driver),
cfgr.extraArgs(modulecfg.extra_args));
Expand Down Expand Up @@ -296,6 +297,9 @@ var Module = null;
files_with_ext_from_filelist(filelist, meta.emulator_ext).forEach(function (file, i) {
wanted_files.push(file.name);
});
files_with_ext_from_filelist(filelist, "conf").forEach(function (file, i) {
wanted_files.push(file.name);
});
meta_props_matching(meta, /^vice_drive_([89])$/).forEach(function (result) {
let key = result[0], match = result[1];
drives[match[1]] = meta[key];
Expand Down Expand Up @@ -570,7 +574,7 @@ var Module = null;
*/
function DosBoxLoader() {
var config = Array.prototype.reduce.call(arguments, extend);
config.emulator_arguments = build_dosbox_arguments(config.emulatorStart, config.files, config.extra_dosbox_args);
config.emulator_arguments = build_dosbox_arguments(config.emulatorStart, config.files, config.extra_dosbox_args, config.images);
config.runner = EmscriptenRunner;
return config;
}
Expand All @@ -583,16 +587,29 @@ var Module = null;
DosBoxLoader.extraArgs = function (args) {
return { extra_dosbox_args: args };
};
DosBoxLoader.mountZip = function (drive, file, drive_type="hdd") {
// driver type: hdd, floppy, cdrom, img

DosBoxLoader.mountZip = function (drive, file, drive_type) {
// driver type: hdd, floppy, cdrom
return { files: [{ drive: drive,
mountpoint: "/" + drive,
file: file,
drive_type: drive_type,
drive_type: drive_type || "hdd",
}] };
};

DosBoxLoader.mountImage = function(drive, filepath, drive_type, file_system){
// See also https://www.dosbox.com/wiki/IMGMOUNT
// drive: the drive to mount
// filepath: the location of image file, like "/c/test.iso" NOTE: this depends on the method `DosBoxLoader.mountZip` or `DosBoxLoader.mountFile`
// drive_type: floppy, iso, hdd
// file_system: iso, fat, none
return { images: [{ drive: drive,
filepath: filepath,
drive_type: drive_type,
file_system: file_system
}] };
};

/**
* PC98DosBoxLoader
*/
Expand All @@ -602,15 +619,7 @@ var Module = null;
config.runner = PC98DosBoxRunner;
return config;
}
PC98DosBoxLoader.__proto__ = BaseLoader;

PC98DosBoxLoader.startExe = function (path) {
return { emulatorStart: path };
};

PC98DosBoxLoader.extraArgs = function (args) {
return { extra_dosbox_args: args };
};
PC98DosBoxLoader.__proto__ = DosBoxLoader;

/**
* MAMELoader
Expand Down Expand Up @@ -723,6 +732,9 @@ var Module = null;
function PCELoader() {
var config = Array.prototype.reduce.call(arguments, extend);
config.emulator_arguments = ["-c", "/emulator/pce-"+ config.pceModel +".cfg"];
if (config.extra_pce_args && config.extra_pce_args.length > 0) {
config.emulator_arguments = config.emulator_arguments.concat(config.extra_pce_args);
}
config.runner = EmscriptenRunner;
return config;
}
Expand All @@ -732,6 +744,10 @@ var Module = null;
return { pceModel: model };
};

PCELoader.extraArgs = function (args) {
return { extra_pce_args: args };
};

var build_mame_arguments = function (muted, driver, native_resolution, sample_rate, peripheral, extra_args, keepaspect) {
var args = [driver,
'-verbose',
Expand Down Expand Up @@ -765,7 +781,7 @@ var Module = null;
return args;
};

var build_dosbox_arguments = function (emulator_start, files, extra_args) {
var build_dosbox_arguments = function (emulator_start, files, extra_args, images) {
var args = ['-conf', '/emulator/dosbox.conf'];

var len = files.length;
Expand All @@ -781,12 +797,17 @@ var Module = null;
else if(files[i].drive_type==='cdrom'){
args.push('-c', 'mount '+ files[i].drive +' /emulator'+ files[i].mountpoint + ' -t cdrom');
}
else if(files[i].drive_type==='img'){
args.push('-c', 'mount '+ files[i].drive +' /emulator'+ files[i].mountpoint + ' -t iso');
}
}
}

if (images){
var len = images.length;
for (var i = 0; i < len; i++) {
//See also https://www.dosbox.com/wiki/IMGMOUNT
args.push('-c', 'imgmount ' + images[i].drive + ' /emulator' + images[i].filepath + ' -t ' + images[i].drive_type + ' -fs ' + images[i].file_system);
};
};

if (extra_args) {
args = args.concat(extra_args);
}
Expand Down

0 comments on commit dd1e167

Please sign in to comment.