From 7b0afc87debe0a955c09754e1b51e111dccf123c Mon Sep 17 00:00:00 2001 From: Sgeo Date: Tue, 28 Aug 2018 00:18:11 -0400 Subject: [PATCH] get_vice_files and related code. No guarantee that this is coherent. --- loader.js | 38 ++++++++++++++++++++++++++++++++++++++ vice_todo.txt | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/loader.js b/loader.js index 34546bd9..8cf56203 100644 --- a/loader.js +++ b/loader.js @@ -190,6 +190,11 @@ var Module = null; config_args.push(cfgr.startExe(metadata.getElementsByTagName("emulator_start") .item(0) .textContent)); + } else if (module && module.indexOf("vice-") === 0) { + config_args.push(cfgr.autoLoad(metadata.getElementsByTagName("emulator_start") + .item(0) + .textContent)); + } } else if (module && module.indexOf("sae-") === 0) { config_args.push(cfgr.model(modulecfg.driver), cfgr.rom(modulecfg.bios_filenames)); @@ -267,6 +272,35 @@ var Module = null; }); return files; } + + function get_vice_files(cfgr, metadata, modulecfg, filelist) { + var default_drive = "8", + drives = {}, files = [], + meta = dict_from_xml(metadata); + files_with_ext_from_filelist(filelist, meta.emulator_ext).forEach(function (file, i) { + drives[default_drive] = file.name; + }); + meta_props_matching(meta, /^vice_drive_([89])$/).forEach(function (result) { + let key = result[0], match = result[1]; + drives[match[1]] = meta[key]; + }); + var mounts = Object.keys(drives), + len = mounts.length; + mounts.forEach(function (drive, i) { + var title = "Game File ("+ (i+1) +" of "+ len +")", + filename = drives[drive], + url = (filename.includes("/")) ? get_zip_url(filename) + : get_zip_url(filename, get_item_name(game)); + if (filename.toLowerCase().endsWith(".zip")) { + files.push(cfgr.mountZip(drive, + cfgr.fetchFile(title, url))); + } else { + files.push(cfgr.mountFile('/'+ filename, + cfgr.fetchFile(title, url))); + } + }); + return files; + } function get_mame_files(cfgr, metadata, modulecfg, filelist) { var files = [], @@ -573,6 +607,10 @@ var Module = null; config.runner = VICERunner; } VICELoader.__proto__ = BaseLoader; + + VICELoader.autoLoad = function (path) { + return { emulatorStart: path }; + }; /** * SAELoader diff --git a/vice_todo.txt b/vice_todo.txt index f36ddde5..3f07a8a2 100644 --- a/vice_todo.txt +++ b/vice_todo.txt @@ -1,5 +1,5 @@ * Add logo -* Define get_vice_files: This is where to add support for metadata entries (ala dosbox_drive_d) +* Define get_vice_files: This is where to add support for metadata entries (ala dosbox_drive_d) [done, imperfectly] * Define VICELoader * Define VICERunner * Add entry in config_args push area (don't fall through to MAME)