diff --git a/desktop-ui/emulator/arcade.cpp b/desktop-ui/emulator/arcade.cpp index c9cb96a3a9..1634797aa1 100644 --- a/desktop-ui/emulator/arcade.cpp +++ b/desktop-ui/emulator/arcade.cpp @@ -1,6 +1,6 @@ struct Arcade : Emulator { Arcade(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; auto group() -> string override { return "Arcade"; } @@ -33,17 +33,21 @@ Arcade::Arcade() { } } -auto Arcade::load() -> bool { +auto Arcade::load() -> LoadResult { game = mia::Medium::create("Arcade"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Arcade"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; //Determine from the game manifest which core to use for the given arcade rom #ifdef CORE_SG if(game->pak->attribute("board") == "sega/sg1000a") { - if(!ares::SG1000::load(root, {"[Sega] SG-1000A"})) return false; + if(!ares::SG1000::load(root, {"[Sega] SG-1000A"})) return otherError; systemPakName = "SG-1000A"; gamePakName = "Arcade Cartridge"; @@ -51,11 +55,11 @@ auto Arcade::load() -> bool { port->allocate(); port->connect(); } - return true; + return successful; } #endif - return false; + return otherError; } auto Arcade::save() -> bool { diff --git a/desktop-ui/emulator/atari-2600.cpp b/desktop-ui/emulator/atari-2600.cpp index 00e922d080..b7699a4dbc 100644 --- a/desktop-ui/emulator/atari-2600.cpp +++ b/desktop-ui/emulator/atari-2600.cpp @@ -1,6 +1,6 @@ struct Atari2600 : Emulator { Atari2600(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -38,15 +38,19 @@ Atari2600::Atari2600() { } } -auto Atari2600::load() -> bool { +auto Atari2600::load() -> LoadResult { game = mia::Medium::create("Atari 2600"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return couldNotParseManifest; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Atari 2600"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; auto region = Emulator::region(); - if(!ares::Atari2600::load(root, {"[Atari] Atari 2600 (", region, ")"})) return false; + if(!ares::Atari2600::load(root, {"[Atari] Atari 2600 (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -63,7 +67,7 @@ auto Atari2600::load() -> bool { port->connect(); } - return true; + return successful; } auto Atari2600::save() -> bool { diff --git a/desktop-ui/emulator/colecovision.cpp b/desktop-ui/emulator/colecovision.cpp index 223c5e9b53..59fb28cc43 100644 --- a/desktop-ui/emulator/colecovision.cpp +++ b/desktop-ui/emulator/colecovision.cpp @@ -1,6 +1,6 @@ struct ColecoVision : Emulator { ColecoVision(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -39,15 +39,24 @@ ColecoVision::ColecoVision() { } } -auto ColecoVision::load() -> bool { +auto ColecoVision::load() -> LoadResult { game = mia::Medium::create("ColecoVision"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("ColecoVision"); - if(!system->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + if(system->load(firmware[0].location) != successful) { + result.firmwareSystemName = "ColecoVision"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } auto region = Emulator::region(); - if(!ares::ColecoVision::load(root, {"[Coleco] ColecoVision (", region, ")"})) return false; + if(!ares::ColecoVision::load(root, {"[Coleco] ColecoVision (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -64,7 +73,7 @@ auto ColecoVision::load() -> bool { port->connect(); } - return true; + return successful; } auto ColecoVision::save() -> bool { diff --git a/desktop-ui/emulator/emulator.cpp b/desktop-ui/emulator/emulator.cpp index 623faf26c9..4b6a3911d2 100644 --- a/desktop-ui/emulator/emulator.cpp +++ b/desktop-ui/emulator/emulator.cpp @@ -54,12 +54,66 @@ auto Emulator::region() -> string { return {}; } +auto Emulator::handleLoadResult(LoadResult result) -> void { + string errorText; + + switch (result.result) { + case successful: + return; + case noFileSelected: + return; + case invalidROM: + errorText = { "There was an error trying to parse the selected ROM. \n", + "Your ROM may be corrupt or contain a bad dump." }; + break; + case couldNotParseManifest: + errorText = { "An error occurred while parsing the database file. You \n", + "may need to reinstall ares." }; + break; + case databaseNotFound: + errorText = { "The database file for the system was not found. \n", + "Make sure that you have installed or packaged ares correctly. \n", + "Missing database file: " }; + break; + case noFirmware: + errorText = { "Error: firmware is missing or invalid.\n", + result.firmwareSystemName, " - ", result.firmwareType, " (", result.firmwareRegion, ") is required to play this game.\n", + "Would you like to configure firmware settings now?" }; + break; + case romNotFound: + errorText = "The selected ROM file was not found or could not be opened."; + break; + case romNotFoundInDatabase: + errorText = "The selected ROM was not found in the database."; + break; + case otherError: + errorText = "An internal error occurred when initializing the emulator core."; + break; + } + + if(result.info) { + errorText = { errorText, result.info }; + } + + switch (result.result) { + case noFirmware: + if(MessageDialog().setText({ + errorText + }).question() == "Yes") { + settingsWindow.show("Firmware"); + firmwareSettings.select(emulator->name, result.firmwareType, result.firmwareRegion); + } + default: + error(errorText); + } +} + auto Emulator::load(const string& location) -> bool { if(inode::exists(location)) locationQueue.append(location); - - if(!load()) { - error("Failed to load system! Database files may have been incorrectly \n" - "installed. Make sure you have packaged or installed ares correctly."); + + LoadResult result = load(); + handleLoadResult(result); + if(result != successful) { return false; } setBoolean("Color Emulation", settings.video.colorEmulation); @@ -178,18 +232,6 @@ auto Emulator::error(const string& text) -> void { MessageDialog().setTitle("Error").setText(text).setAlignment(presentation).error(); } -auto Emulator::errorFirmware(const Firmware& firmware, string system) -> void { - if(!system) system = emulator->name; - if(MessageDialog().setText({ - "Error: firmware is missing or invalid.\n", - system, " - ", firmware.type, " (", firmware.region, ") is required to play this game.\n" - "Would you like to configure firmware settings now?" - }).question() == "Yes") { - settingsWindow.show("Firmware"); - firmwareSettings.select(system, firmware.type, firmware.region); - } -} - auto Emulator::input(ares::Node::Input::Input input) -> void { //looking up inputs is very time-consuming; skip call if input was called too recently //note: allow rumble to be polled at full speed to prevent missed motor events diff --git a/desktop-ui/emulator/emulator.hpp b/desktop-ui/emulator/emulator.hpp index ff6b71dec1..30a0ac5e97 100644 --- a/desktop-ui/emulator/emulator.hpp +++ b/desktop-ui/emulator/emulator.hpp @@ -19,13 +19,13 @@ struct Emulator { auto setOverscan(bool value) -> bool; auto setColorBleed(bool value) -> bool; auto error(const string& text) -> void; - auto errorFirmware(const Firmware&, string system = "") -> void; auto load(mia::Pak& node, string name) -> bool; auto save(mia::Pak& node, string name) -> bool; virtual auto input(ares::Node::Input::Input) -> void; auto inputKeyboard(string name) -> bool; + auto handleLoadResult(LoadResult result) -> void; virtual auto load(Menu) -> void {} - virtual auto load() -> bool = 0; + virtual auto load() -> LoadResult = 0; virtual auto save() -> bool { return true; } virtual auto pak(ares::Node::Object) -> shared_pointer = 0; virtual auto notify(const string& message) -> void {} diff --git a/desktop-ui/emulator/famicom-disk-system.cpp b/desktop-ui/emulator/famicom-disk-system.cpp index fabbcd3064..b7d2dd8485 100644 --- a/desktop-ui/emulator/famicom-disk-system.cpp +++ b/desktop-ui/emulator/famicom-disk-system.cpp @@ -1,7 +1,7 @@ struct FamicomDiskSystem : Emulator { FamicomDiskSystem(); auto load(Menu) -> void override; - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; auto notify(const string& message) -> void override; @@ -65,17 +65,28 @@ auto FamicomDiskSystem::load(Menu menu) -> void { return (void)disk1sideA.setChecked(); } -auto FamicomDiskSystem::load() -> bool { +auto FamicomDiskSystem::load() -> LoadResult { game = mia::Medium::create("Famicom Disk System"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; bios = mia::Medium::create("Famicom"); - if(!bios->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + result = bios->load(firmware[0].location); + if(result != successful) { + result.firmwareSystemName = "Famicom"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } system = mia::System::create("Famicom"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; - if(!ares::Famicom::load(root, "[Nintendo] Famicom (NTSC-J)")) return false; + if(!ares::Famicom::load(root, "[Nintendo] Famicom (NTSC-J)")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -101,7 +112,7 @@ auto FamicomDiskSystem::load() -> bool { port->connect(); } - return true; + return successful; } auto FamicomDiskSystem::save() -> bool { diff --git a/desktop-ui/emulator/famicom.cpp b/desktop-ui/emulator/famicom.cpp index 109e698587..529eff423c 100644 --- a/desktop-ui/emulator/famicom.cpp +++ b/desktop-ui/emulator/famicom.cpp @@ -1,6 +1,6 @@ struct Famicom : Emulator { Famicom(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -35,15 +35,19 @@ Famicom::Famicom() { } } -auto Famicom::load() -> bool { +auto Famicom::load() -> LoadResult { game = mia::Medium::create("Famicom"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Famicom"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; auto region = Emulator::region(); - if(!ares::Famicom::load(root, {"[Nintendo] Famicom (", region, ")"})) return false; + if(!ares::Famicom::load(root, {"[Nintendo] Famicom (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -67,7 +71,7 @@ auto Famicom::load() -> bool { } } - return true; + return successful; } auto Famicom::save() -> bool { diff --git a/desktop-ui/emulator/game-boy-advance.cpp b/desktop-ui/emulator/game-boy-advance.cpp index 4546e4035d..473801092d 100644 --- a/desktop-ui/emulator/game-boy-advance.cpp +++ b/desktop-ui/emulator/game-boy-advance.cpp @@ -1,7 +1,7 @@ struct GameBoyAdvance : Emulator { GameBoyAdvance(); auto load(Menu) -> void override; - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -50,23 +50,32 @@ auto GameBoyAdvance::load(Menu menu) -> void { } } -auto GameBoyAdvance::load() -> bool { +auto GameBoyAdvance::load() -> LoadResult { game = mia::Medium::create("Game Boy Advance"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Game Boy Advance"); - if(!system->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + if(system->load(firmware[0].location) != successful) { + result.firmwareSystemName = "Game Boy Advance"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } ares::GameBoyAdvance::option("Pixel Accuracy", settings.video.pixelAccuracy); - if(!ares::GameBoyAdvance::load(root, "[Nintendo] Game Boy Advance")) return false; + if(!ares::GameBoyAdvance::load(root, "[Nintendo] Game Boy Advance")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); port->connect(); } - return true; + return successful; } auto GameBoyAdvance::save() -> bool { diff --git a/desktop-ui/emulator/game-boy-color.cpp b/desktop-ui/emulator/game-boy-color.cpp index ea53a98506..87e21bd780 100644 --- a/desktop-ui/emulator/game-boy-color.cpp +++ b/desktop-ui/emulator/game-boy-color.cpp @@ -1,6 +1,6 @@ struct GameBoyColor : Emulator { GameBoyColor(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -27,14 +27,18 @@ GameBoyColor::GameBoyColor() { } } -auto GameBoyColor::load() -> bool { +auto GameBoyColor::load() -> LoadResult { game = mia::Medium::create("Game Boy Color"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Game Boy Color"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; - if(!ares::GameBoy::load(root, "[Nintendo] Game Boy Color")) return false; + if(!ares::GameBoy::load(root, "[Nintendo] Game Boy Color")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -45,7 +49,7 @@ auto GameBoyColor::load() -> bool { fastBoot->setValue(settings.boot.fast); } - return true; + return successful; } auto GameBoyColor::save() -> bool { diff --git a/desktop-ui/emulator/game-boy.cpp b/desktop-ui/emulator/game-boy.cpp index ad8d2c2034..e3b342e215 100644 --- a/desktop-ui/emulator/game-boy.cpp +++ b/desktop-ui/emulator/game-boy.cpp @@ -1,6 +1,6 @@ struct GameBoy : Emulator { GameBoy(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -28,14 +28,18 @@ GameBoy::GameBoy() { } } -auto GameBoy::load() -> bool { +auto GameBoy::load() -> LoadResult { game = mia::Medium::create("Game Boy"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Game Boy"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; - if(!ares::GameBoy::load(root, "[Nintendo] Game Boy")) return false; + if(!ares::GameBoy::load(root, "[Nintendo] Game Boy")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -46,7 +50,7 @@ auto GameBoy::load() -> bool { fastBoot->setValue(settings.boot.fast); } - return true; + return successful; } auto GameBoy::load(Menu menu) -> void { diff --git a/desktop-ui/emulator/game-gear.cpp b/desktop-ui/emulator/game-gear.cpp index 7d909dc2bd..a13cb83967 100644 --- a/desktop-ui/emulator/game-gear.cpp +++ b/desktop-ui/emulator/game-gear.cpp @@ -1,6 +1,6 @@ struct GameGear : Emulator { GameGear(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -27,23 +27,27 @@ GameGear::GameGear() { } } -auto GameGear::load() -> bool { +auto GameGear::load() -> LoadResult { game = mia::Medium::create("Game Gear"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); system = mia::System::create("Game Gear"); - if(!system->load(firmware[0].location)) return false; + result = system->load(firmware[0].location); + if(result != successful) return otherError; - if(!ares::MasterSystem::load(root, {"[Sega] Game Gear (", region, ")"})) return false; + if(!ares::MasterSystem::load(root, {"[Sega] Game Gear (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); port->connect(); } - return true; + return successful; } auto GameGear::save() -> bool { diff --git a/desktop-ui/emulator/master-system.cpp b/desktop-ui/emulator/master-system.cpp index 7095418600..268c8f181f 100644 --- a/desktop-ui/emulator/master-system.cpp +++ b/desktop-ui/emulator/master-system.cpp @@ -1,6 +1,6 @@ struct MasterSystem : Emulator { MasterSystem(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -90,9 +90,12 @@ MasterSystem::MasterSystem() { } } -auto MasterSystem::load() -> bool { +auto MasterSystem::load() -> LoadResult { game = mia::Medium::create("Master System"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority @@ -101,10 +104,11 @@ auto MasterSystem::load() -> bool { if(region == "NTSC-U") regionID = 0; system = mia::System::create("Master System"); - if(!system->load(firmware[regionID].location)) return false; - if(!game->pak && !system->pak->read("bios.rom")) return false; + result = system->load(firmware[regionID].location); + if(result != successful) return otherError; + if(!game->pak && !system->pak->read("bios.rom")) return otherError; - if(!ares::MasterSystem::load(root, {"[Sega] Master System (", region, ")"})) return false; + if(!ares::MasterSystem::load(root, {"[Sega] Master System (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -130,7 +134,7 @@ auto MasterSystem::load() -> bool { port->connect(); } - return true; + return successful; } auto MasterSystem::save() -> bool { diff --git a/desktop-ui/emulator/mega-32x.cpp b/desktop-ui/emulator/mega-32x.cpp index d43fe1f6d0..3480e8c718 100644 --- a/desktop-ui/emulator/mega-32x.cpp +++ b/desktop-ui/emulator/mega-32x.cpp @@ -1,6 +1,6 @@ struct Mega32X : Emulator { Mega32X(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -43,10 +43,13 @@ Mega32X::Mega32X() { } } -auto Mega32X::load() -> bool { +auto Mega32X::load() -> LoadResult { game = mia::Medium::create("Mega 32X"); - if(!game->load(Emulator::load(game, configuration.game))) return false; - + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; + auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority if(region == "PAL" ) regionID = 2; @@ -60,22 +63,30 @@ auto Mega32X::load() -> bool { for(auto& emulator : emulators) { if(emulator->name == "Mega CD") firmware = emulator->firmware; } - if(!firmware) return false; //should never occur + if(!firmware) return otherError; //should never occur name = "Mega CD 32X"; system = mia::System::create("Mega CD 32X"); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID], "Mega CD"), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "Mega CD 32X"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } disc = mia::Medium::create("Mega CD"); - if(!disc->load(Emulator::load(disc, configuration.game))) disc.reset(); + if(disc->load(Emulator::load(disc, configuration.game)) != successful) disc.reset(); } else { name = "Mega 32X"; system = mia::System::create("Mega 32X"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; } ares::MegaDrive::option("Recompiler", !settings.general.forceInterpreter); - if(!ares::MegaDrive::load(root, {"[Sega] ", name, " (", region, ")"})) return false; + if(!ares::MegaDrive::load(root, {"[Sega] ", name, " (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -97,7 +108,7 @@ auto Mega32X::load() -> bool { port->connect(); } - return true; + return successful; } auto Mega32X::save() -> bool { diff --git a/desktop-ui/emulator/mega-cd-32x.cpp b/desktop-ui/emulator/mega-cd-32x.cpp index 96a6f666d4..54b837c4ce 100644 --- a/desktop-ui/emulator/mega-cd-32x.cpp +++ b/desktop-ui/emulator/mega-cd-32x.cpp @@ -1,6 +1,6 @@ struct MegaCD32X : Emulator { MegaCD32X(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto unload() -> void override; auto save() -> bool override; @@ -45,9 +45,12 @@ MegaCD32X::MegaCD32X() { } } -auto MegaCD32X::load() -> bool { +auto MegaCD32X::load() -> LoadResult { game = mia::Medium::create("Mega CD"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority @@ -60,14 +63,21 @@ auto MegaCD32X::load() -> bool { for(auto& emulator : emulators) { if(emulator->name == "Mega CD") firmware = emulator->firmware; } - if(!firmware) return false; //should never occur + if(!firmware) return otherError; //should never occur system = mia::System::create("Mega CD 32X"); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID], "Mega CD"), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "Mega CD"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } ares::MegaDrive::option("Recompiler", !settings.general.forceInterpreter); - if(!ares::MegaDrive::load(root, {"[Sega] Mega CD 32X (", region, ")"})) return false; + if(!ares::MegaDrive::load(root, {"[Sega] Mega CD 32X (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -98,7 +108,7 @@ auto MegaCD32X::load() -> bool { discTrayTimer = Timer{}; - return true; + return successful; } @@ -110,7 +120,7 @@ auto MegaCD32X::load(Menu menu) -> void { auto tray = root->find("Mega CD/Disc Tray"); tray->disconnect(); - if(!game->load(Emulator::load(game, configuration.game))) { + if(game->load(Emulator::load(game, configuration.game)) != successful) { return; } diff --git a/desktop-ui/emulator/mega-cd.cpp b/desktop-ui/emulator/mega-cd.cpp index acefa19156..13a51fee69 100644 --- a/desktop-ui/emulator/mega-cd.cpp +++ b/desktop-ui/emulator/mega-cd.cpp @@ -1,6 +1,6 @@ struct MegaCD : Emulator { MegaCD(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto unload() -> void override; auto save() -> bool override; @@ -60,9 +60,12 @@ MegaCD::MegaCD() { } } -auto MegaCD::load() -> bool { +auto MegaCD::load() -> LoadResult { game = mia::Medium::create("Mega CD"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority @@ -71,9 +74,16 @@ auto MegaCD::load() -> bool { if(region == "NTSC-U") regionID = 0; system = mia::System::create("Mega CD"); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID]), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "Mega CD"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } - if(!ares::MegaDrive::load(root, {"[Sega] Mega CD (", region, ")"})) return false; + if(!ares::MegaDrive::load(root, {"[Sega] Mega CD (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -104,7 +114,7 @@ auto MegaCD::load() -> bool { discTrayTimer = Timer{}; - return true; + return successful; } auto MegaCD::load(Menu menu) -> void { @@ -115,7 +125,7 @@ auto MegaCD::load(Menu menu) -> void { auto tray = root->find("Mega CD/Disc Tray"); tray->disconnect(); - if(!game->load(Emulator::load(game, configuration.game))) { + if(game->load(Emulator::load(game, configuration.game)) != successful) { return; } diff --git a/desktop-ui/emulator/mega-drive.cpp b/desktop-ui/emulator/mega-drive.cpp index 01b30380ac..6bc2215dd3 100644 --- a/desktop-ui/emulator/mega-drive.cpp +++ b/desktop-ui/emulator/mega-drive.cpp @@ -1,6 +1,6 @@ struct MegaDrive : Emulator { MegaDrive(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -54,9 +54,12 @@ MegaDrive::MegaDrive() { } } -auto MegaDrive::load() -> bool { +auto MegaDrive::load() -> LoadResult { game = mia::Medium::create("Mega Drive"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority @@ -71,22 +74,30 @@ auto MegaDrive::load() -> bool { for(auto& emulator : emulators) { if(emulator->name == "Mega CD") firmware = emulator->firmware; } - if(!firmware) return false; //should never occur + if(!firmware) return otherError; //should never occur name = "Mega CD"; system = mia::System::create("Mega CD"); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID], "Mega CD"), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "Mega CD"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } disc = mia::Medium::create("Mega CD"); - if(!disc->load(Emulator::load(disc, configuration.game))) disc.reset(); + if(disc->load(Emulator::load(disc, configuration.game)) != successful) disc.reset(); } else { name = "Mega Drive"; system = mia::System::create("Mega Drive"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; } ares::MegaDrive::option("TMSS", settings.megadrive.tmss); - if(!ares::MegaDrive::load(root, {"[Sega] ", name, " (", region, ")"})) return false; + if(!ares::MegaDrive::load(root, {"[Sega] ", name, " (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -108,7 +119,7 @@ auto MegaDrive::load() -> bool { port->connect(); } - return true; + return successful; } auto MegaDrive::save() -> bool { diff --git a/desktop-ui/emulator/msx.cpp b/desktop-ui/emulator/msx.cpp index 55bc7119af..8f41fcc264 100644 --- a/desktop-ui/emulator/msx.cpp +++ b/desktop-ui/emulator/msx.cpp @@ -1,6 +1,6 @@ struct MSX : Emulator { MSX(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -37,16 +37,26 @@ MSX::MSX() { } } -auto MSX::load() -> bool { +auto MSX::load() -> LoadResult { game = mia::Medium::create("MSX"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; bool isTape = game->pak->attribute("tape").boolean(); system = mia::System::create("MSX"); - if(!system->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + result = system->load(firmware[0].location); + if(result != successful) { + result.firmwareSystemName = "MSX"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } auto region = Emulator::region(); - if(!ares::MSX::load(root, {"[Microsoft] MSX (", region, ")"})) return false; + if(!ares::MSX::load(root, {"[Microsoft] MSX (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -76,7 +86,7 @@ auto MSX::load() -> bool { port->connect(); } - return true; + return successful; } auto MSX::load(Menu menu) -> void { diff --git a/desktop-ui/emulator/msx2.cpp b/desktop-ui/emulator/msx2.cpp index db4967c95b..bb8c74b828 100644 --- a/desktop-ui/emulator/msx2.cpp +++ b/desktop-ui/emulator/msx2.cpp @@ -1,6 +1,6 @@ struct MSX2 : MSX { MSX2(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; auto input(ares::Node::Input::Input) -> void override; @@ -31,18 +31,25 @@ MSX2::MSX2() { } } -auto MSX2::load() -> bool { +auto MSX2::load() -> LoadResult { game = mia::Medium::create("MSX2"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; bool isTape = game->pak->attribute("tape").boolean(); system = mia::System::create("MSX2"); if(!system->loadMultiple({firmware[0].location, firmware[1].location})) { - return errorFirmware(firmware[0]), false; + result.result = noFirmware; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.firmwareSystemName = "MSX2"; + return result; } auto region = Emulator::region(); - if(!ares::MSX::load(root, {"[Microsoft] MSX2 (", region, ")"})) return false; + if(!ares::MSX::load(root, {"[Microsoft] MSX2 (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -69,7 +76,7 @@ auto MSX2::load() -> bool { port->connect(); } - return true; + return successful; } auto MSX2::save() -> bool { diff --git a/desktop-ui/emulator/myvision.cpp b/desktop-ui/emulator/myvision.cpp index bc09c05c48..efc05b2c6e 100644 --- a/desktop-ui/emulator/myvision.cpp +++ b/desktop-ui/emulator/myvision.cpp @@ -1,6 +1,6 @@ struct MyVision: Emulator { MyVision(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer < vfs::directory > override; }; @@ -42,23 +42,27 @@ MyVision::MyVision() { } } -auto MyVision::load() -> bool { +auto MyVision::load() -> LoadResult { game = mia::Medium::create("MyVision"); - if (!game -> load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("MyVision"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; if (!ares::MyVision::load(root, { "[Nichibutsu] MyVision" - })) return false; + })) return otherError; if (auto port = root -> find < ares::Node::Port > ("Cartridge Slot")) { port -> allocate(); port -> connect(); } - return true; + return successful; } auto MyVision::save() -> bool { diff --git a/desktop-ui/emulator/neo-geo-aes.cpp b/desktop-ui/emulator/neo-geo-aes.cpp index 8125f96517..1be98c73f0 100644 --- a/desktop-ui/emulator/neo-geo-aes.cpp +++ b/desktop-ui/emulator/neo-geo-aes.cpp @@ -1,6 +1,6 @@ struct NeoGeoAES : Emulator { NeoGeoAES(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; auto arcade() -> bool override { return true; } @@ -34,14 +34,24 @@ NeoGeoAES::NeoGeoAES() { } } -auto NeoGeoAES::load() -> bool { +auto NeoGeoAES::load() -> LoadResult { game = mia::Medium::create("Neo Geo"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Neo Geo AES"); - if(!system->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + result = system->load(firmware[0].location); + if(result != successful) { + result.firmwareSystemName = "Neo Geo AES"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } - if(!ares::NeoGeo::load(root, "[SNK] Neo Geo AES")) return false; + if(!ares::NeoGeo::load(root, "[SNK] Neo Geo AES")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -63,7 +73,7 @@ auto NeoGeoAES::load() -> bool { port->connect(); } - return true; + return successful; } auto NeoGeoAES::save() -> bool { diff --git a/desktop-ui/emulator/neo-geo-mvs.cpp b/desktop-ui/emulator/neo-geo-mvs.cpp index cc0e46719a..c02fbf39a4 100644 --- a/desktop-ui/emulator/neo-geo-mvs.cpp +++ b/desktop-ui/emulator/neo-geo-mvs.cpp @@ -1,6 +1,6 @@ struct NeoGeoMVS : Emulator { NeoGeoMVS(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; auto group() -> string override { return "Arcade"; } @@ -35,14 +35,24 @@ NeoGeoMVS::NeoGeoMVS() { } } -auto NeoGeoMVS::load() -> bool { +auto NeoGeoMVS::load() -> LoadResult { game = mia::Medium::create("Neo Geo"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Neo Geo MVS"); - if(!system->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + result = system->load(firmware[0].location); + if(result != successful) { + result.firmwareSystemName = "Neo Geo MVS"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } - if(!ares::NeoGeo::load(root, "[SNK] Neo Geo MVS")) return false; + if(!ares::NeoGeo::load(root, "[SNK] Neo Geo MVS")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -64,7 +74,7 @@ auto NeoGeoMVS::load() -> bool { port->connect(); } - return true; + return successful; } auto NeoGeoMVS::save() -> bool { diff --git a/desktop-ui/emulator/neo-geo-pocket-color.cpp b/desktop-ui/emulator/neo-geo-pocket-color.cpp index eeae7a802f..a78b01822b 100644 --- a/desktop-ui/emulator/neo-geo-pocket-color.cpp +++ b/desktop-ui/emulator/neo-geo-pocket-color.cpp @@ -1,6 +1,6 @@ struct NeoGeoPocketColor : Emulator { NeoGeoPocketColor(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -29,14 +29,24 @@ NeoGeoPocketColor::NeoGeoPocketColor() { } } -auto NeoGeoPocketColor::load() -> bool { +auto NeoGeoPocketColor::load() -> LoadResult { game = mia::Medium::create("Neo Geo Pocket Color"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Neo Geo Pocket Color"); - if(!system->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + result = system->load(firmware[0].location); + if(result != successful) { + result.firmwareSystemName = "Neo Geo Pocket Color"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } - if(!ares::NeoGeoPocket::load(root, "[SNK] Neo Geo Pocket Color")) return false; + if(!ares::NeoGeoPocket::load(root, "[SNK] Neo Geo Pocket Color")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -47,7 +57,7 @@ auto NeoGeoPocketColor::load() -> bool { fastBoot->setValue(settings.boot.fast); } - return true; + return successful; } auto NeoGeoPocketColor::save() -> bool { diff --git a/desktop-ui/emulator/neo-geo-pocket.cpp b/desktop-ui/emulator/neo-geo-pocket.cpp index b4ed9d67c4..33a4b97c70 100644 --- a/desktop-ui/emulator/neo-geo-pocket.cpp +++ b/desktop-ui/emulator/neo-geo-pocket.cpp @@ -1,6 +1,6 @@ struct NeoGeoPocket : Emulator { NeoGeoPocket(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -29,14 +29,24 @@ NeoGeoPocket::NeoGeoPocket() { } } -auto NeoGeoPocket::load() -> bool { +auto NeoGeoPocket::load() -> LoadResult { game = mia::Medium::create("Neo Geo Pocket"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Neo Geo Pocket"); - if(!system->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + result = system->load(firmware[0].location); + if(result != successful) { + result.firmwareSystemName = "Neo Geo Pocket"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } - if(!ares::NeoGeoPocket::load(root, "[SNK] Neo Geo Pocket")) return false; + if(!ares::NeoGeoPocket::load(root, "[SNK] Neo Geo Pocket")) return otherError;; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -47,7 +57,7 @@ auto NeoGeoPocket::load() -> bool { fastBoot->setValue(settings.boot.fast); } - return true; + return successful; } auto NeoGeoPocket::save() -> bool { diff --git a/desktop-ui/emulator/nintendo-64.cpp b/desktop-ui/emulator/nintendo-64.cpp index 1b8be315c4..5a097bbaa5 100644 --- a/desktop-ui/emulator/nintendo-64.cpp +++ b/desktop-ui/emulator/nintendo-64.cpp @@ -1,6 +1,6 @@ struct Nintendo64 : Emulator { Nintendo64(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto portMenu(Menu& portMenu, ares::Node::Port port) -> void override; auto unload() -> void override; @@ -54,9 +54,12 @@ Nintendo64::Nintendo64() { } } -auto Nintendo64::load() -> bool { +auto Nintendo64::load() -> LoadResult { game = mia::Medium::create("Nintendo 64"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); @@ -67,15 +70,16 @@ auto Nintendo64::load() -> bool { for(auto& emulator : emulators) { if(emulator->name == "Nintendo 64DD") firmware = emulator->firmware; } - if(!firmware) return false; //should never occur + if(!firmware) return otherError; //should never occur name = "Nintendo 64DD"; disk = mia::Medium::create("Nintendo 64DD"); - if(!disk->load(Emulator::load(disk, configuration.game))) { + if(disk->load(Emulator::load(disk, configuration.game)) != successful) { disk.reset(); name = "Nintendo 64"; system = mia::System::create("Nintendo 64"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; } else { region = disk->pak->attribute("region"); //if statements below are ordered by lowest to highest priority @@ -84,12 +88,20 @@ auto Nintendo64::load() -> bool { if (region == "NTSC-J") regionID = 0; system = mia::System::create(name); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID], "Nintendo 64DD"), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "Nintendo 64"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } } } else { name = "Nintendo 64"; system = mia::System::create("Nintendo 64"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; } ares::Nintendo64::option("Quality", settings.video.quality); @@ -105,7 +117,7 @@ auto Nintendo64::load() -> bool { ares::Nintendo64::option("Recompiler", !settings.general.forceInterpreter); ares::Nintendo64::option("Expansion Pak", settings.nintendo64.expansionPak); - if(!ares::Nintendo64::load(root, {"[Nintendo] ", name, " (", region, ")"})) return false; + if(!ares::Nintendo64::load(root, {"[Nintendo] ", name, " (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -135,7 +147,7 @@ auto Nintendo64::load() -> bool { if(auto slot = transferPak->find("Cartridge Slot")) { gb = mia::Medium::create("Game Boy"); string tmpPath; - if(gb->load(Emulator::load(gb, tmpPath))) { + if(gb->load(Emulator::load(gb, tmpPath)) == successful) { slot->allocate(); slot->connect(); transferPakConnected = true; @@ -165,7 +177,7 @@ auto Nintendo64::load() -> bool { diskInsertTimer = Timer{}; - return true; + return successful; } auto Nintendo64::load(Menu menu) -> void { @@ -177,7 +189,7 @@ auto Nintendo64::load(Menu menu) -> void { auto drive = root->find("Nintendo 64DD/Disk Drive"); drive->disconnect(); - if(!disk->load(Emulator::load(disk, configuration.game))) { + if(disk->load(Emulator::load(disk, configuration.game)) != successful) { return; } @@ -278,7 +290,7 @@ auto Nintendo64::portMenu(Menu& portMenu, ares::Node::Port port) -> void { if(auto slot = transferPak->find("Cartridge Slot")) { emulator->gb = mia::Medium::create("Game Boy"); string tmpPath; - if(emulator->gb->load(emulator->load(emulator->gb, tmpPath))) { + if(emulator->gb->load(emulator->load(emulator->gb, tmpPath)) == successful) { slot->allocate(); slot->connect(); } else { diff --git a/desktop-ui/emulator/nintendo-64dd.cpp b/desktop-ui/emulator/nintendo-64dd.cpp index 8711716625..8ddf69596b 100644 --- a/desktop-ui/emulator/nintendo-64dd.cpp +++ b/desktop-ui/emulator/nintendo-64dd.cpp @@ -1,6 +1,6 @@ struct Nintendo64DD : Nintendo64 { Nintendo64DD(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto unload() -> void override; auto save() -> bool override; @@ -56,9 +56,12 @@ Nintendo64DD::Nintendo64DD() { } } -auto Nintendo64DD::load() -> bool { +auto Nintendo64DD::load() -> LoadResult { game = mia::Medium::create("Nintendo 64DD"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = game->pak->attribute("region"); //if statements below are ordered by lowest to highest priority @@ -67,7 +70,14 @@ auto Nintendo64DD::load() -> bool { if (region == "NTSC-J" ) regionID = 0; system = mia::System::create("Nintendo 64DD"); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID]), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "Nintendo 64DD"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } ares::Nintendo64::option("Quality", settings.video.quality); ares::Nintendo64::option("Supersampling", settings.video.supersampling); @@ -82,7 +92,7 @@ auto Nintendo64DD::load() -> bool { ares::Nintendo64::option("Recompiler", !settings.general.forceInterpreter); ares::Nintendo64::option("Expansion Pak", settings.nintendo64.expansionPak); - if(!ares::Nintendo64::load(root, {"[Nintendo] Nintendo 64DD (", region, ")"})) return false; + if(!ares::Nintendo64::load(root, {"[Nintendo] Nintendo 64DD (", region, ")"})) return otherError; if(auto port = root->find("Nintendo 64DD/Disk Drive")) { port->allocate(); @@ -104,7 +114,7 @@ auto Nintendo64DD::load() -> bool { if(auto slot = transferPak->find("Cartridge Slot")) { gb = mia::Medium::create("Game Boy"); string tmpPath; - if(gb->load(Emulator::load(gb, tmpPath))) { + if(gb->load(Emulator::load(gb, tmpPath)) == successful) { slot->allocate(); slot->connect(); transferPakConnected = true; @@ -134,7 +144,7 @@ auto Nintendo64DD::load() -> bool { diskInsertTimer = Timer{}; - return true; + return successful; } auto Nintendo64DD::load(Menu menu) -> void { @@ -145,7 +155,7 @@ auto Nintendo64DD::load(Menu menu) -> void { auto drive = root->find("Nintendo 64DD/Disk Drive"); drive->disconnect(); - if(!game->load(Emulator::load(game, configuration.game))) { + if(game->load(Emulator::load(game, configuration.game)) != successful) { return; } diff --git a/desktop-ui/emulator/pc-engine-cd.cpp b/desktop-ui/emulator/pc-engine-cd.cpp index fbc069d05f..0e8dfd97b9 100644 --- a/desktop-ui/emulator/pc-engine-cd.cpp +++ b/desktop-ui/emulator/pc-engine-cd.cpp @@ -1,6 +1,6 @@ struct PCEngineCD : PCEngine { PCEngineCD(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -20,9 +20,12 @@ PCEngineCD::PCEngineCD() { allocatePorts(); } -auto PCEngineCD::load() -> bool { +auto PCEngineCD::load() -> LoadResult { game = mia::Medium::create("PC Engine CD"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority @@ -39,15 +42,23 @@ auto PCEngineCD::load() -> bool { } bios = mia::Medium::create("PC Engine"); - if(!bios->load(firmware[biosID].location)) return errorFirmware(firmware[biosID]), false; + result = bios->load(firmware[biosID].location); + if(result != successful) { + result.firmwareSystemName = "PC Engine"; + result.firmwareType = firmware[biosID].type; + result.firmwareRegion = firmware[biosID].region; + result.result = noFirmware; + return result; + } system = mia::System::create("PC Engine"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::PCEngine::option("Pixel Accuracy", settings.video.pixelAccuracy); auto name = region == "NTSC-J" ? "PC Engine Duo" : "TurboDuo"; - if(!ares::PCEngine::load(root, {"[NEC] ", name, " (", region, ")"})) return false; + if(!ares::PCEngine::load(root, {"[NEC] ", name, " (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -61,7 +72,7 @@ auto PCEngineCD::load() -> bool { connectPorts(); - return true; + return successful; } auto PCEngineCD::save() -> bool { diff --git a/desktop-ui/emulator/pc-engine.cpp b/desktop-ui/emulator/pc-engine.cpp index cb4deb46aa..c613b4ae53 100644 --- a/desktop-ui/emulator/pc-engine.cpp +++ b/desktop-ui/emulator/pc-engine.cpp @@ -1,6 +1,6 @@ struct PCEngine : Emulator { PCEngine(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; auto allocatePorts() -> void; @@ -87,18 +87,22 @@ auto PCEngine::connectPorts() -> void { } } -auto PCEngine::load() -> bool { +auto PCEngine::load() -> LoadResult { game = mia::Medium::create("PC Engine"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("PC Engine"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::PCEngine::option("Pixel Accuracy", settings.video.pixelAccuracy); auto region = Emulator::region(); string name = region == "NTSC-J" ? "PC Engine" : "TurboGrafx 16"; - if(!ares::PCEngine::load(root, {"[NEC] ", name, " (", region, ")"})) return false; + if(!ares::PCEngine::load(root, {"[NEC] ", name, " (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -107,7 +111,7 @@ auto PCEngine::load() -> bool { connectPorts(); - return true; + return successful; } auto PCEngine::save() -> bool { diff --git a/desktop-ui/emulator/playstation.cpp b/desktop-ui/emulator/playstation.cpp index 01e8756ca4..cff010f517 100644 --- a/desktop-ui/emulator/playstation.cpp +++ b/desktop-ui/emulator/playstation.cpp @@ -1,6 +1,6 @@ struct PlayStation : Emulator { PlayStation(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto unload() -> void override; auto save() -> bool override; @@ -75,9 +75,12 @@ PlayStation::PlayStation() { } } -auto PlayStation::load() -> bool { +auto PlayStation::load() -> LoadResult { game = mia::Medium::create("PlayStation"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority @@ -86,11 +89,18 @@ auto PlayStation::load() -> bool { if(region == "NTSC-U") regionID = 0; system = mia::System::create("PlayStation"); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID]), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "PlayStation"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } ares::PlayStation::option("Recompiler", !settings.general.forceInterpreter); - if(!ares::PlayStation::load(root, {"[Sony] PlayStation (", region, ")"})) return false; + if(!ares::PlayStation::load(root, {"[Sony] PlayStation (", region, ")"})) return otherError; if(auto fastBoot = root->find("Fast Boot")) { fastBoot->setValue(settings.boot.fast); @@ -121,7 +131,7 @@ auto PlayStation::load() -> bool { discTrayTimer = Timer{}; - return true; + return successful; } auto PlayStation::load(Menu menu) -> void { @@ -132,7 +142,7 @@ auto PlayStation::load(Menu menu) -> void { auto tray = root->find("PlayStation/Disc Tray"); tray->disconnect(); - if(!game->load(Emulator::load(game, configuration.game))) { + if(game->load(Emulator::load(game, configuration.game)) != successful) { return; } diff --git a/desktop-ui/emulator/pocket-challenge-v2.cpp b/desktop-ui/emulator/pocket-challenge-v2.cpp index 66f1be2f18..30dc30ccd3 100644 --- a/desktop-ui/emulator/pocket-challenge-v2.cpp +++ b/desktop-ui/emulator/pocket-challenge-v2.cpp @@ -1,7 +1,7 @@ struct PocketChallengeV2 : Emulator { PocketChallengeV2(); auto load(Menu) -> void override; - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -34,23 +34,27 @@ auto PocketChallengeV2::load(Menu menu) -> void { //as such, neither the ares::WonderSwan core nor desktop-ui provide an orientation setting. } -auto PocketChallengeV2::load() -> bool { +auto PocketChallengeV2::load() -> LoadResult { game = mia::Medium::create("Pocket Challenge V2"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Pocket Challenge V2"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::WonderSwan::option("Pixel Accuracy", settings.video.pixelAccuracy); - if(!ares::WonderSwan::load(root, "[Benesse] Pocket Challenge V2")) return false; + if(!ares::WonderSwan::load(root, "[Benesse] Pocket Challenge V2")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); port->connect(); } - return true; + return successful; } auto PocketChallengeV2::save() -> bool { diff --git a/desktop-ui/emulator/saturn.cpp b/desktop-ui/emulator/saturn.cpp index 53e6d8bf8e..970c68ec0f 100644 --- a/desktop-ui/emulator/saturn.cpp +++ b/desktop-ui/emulator/saturn.cpp @@ -1,6 +1,6 @@ struct Saturn : Emulator { Saturn(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -16,9 +16,12 @@ Saturn::Saturn() { firmware.append({"BIOS", "Europe"}); //PAL } -auto Saturn::load() -> bool { +auto Saturn::load() -> LoadResult { game = mia::Medium::create("Saturn"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; auto region = Emulator::region(); //if statements below are ordered by lowest to highest priority @@ -27,9 +30,16 @@ auto Saturn::load() -> bool { if(region == "NTSC-U") regionID = 0; system = mia::System::create("Saturn"); - if(!system->load(firmware[regionID].location)) return errorFirmware(firmware[regionID]), false; + result = system->load(firmware[regionID].location); + if(result != successful) { + result.firmwareSystemName = "Saturn"; + result.firmwareType = firmware[regionID].type; + result.firmwareRegion = firmware[regionID].region; + result.result = noFirmware; + return result; + } - if(!ares::Saturn::load(root, {"[Sega] Saturn (", region, ")"})) return false; + if(!ares::Saturn::load(root, {"[Sega] Saturn (", region, ")"})) return otherError; if(auto port = root->find("Saturn/Disc Tray")) { port->allocate(); diff --git a/desktop-ui/emulator/sg-1000.cpp b/desktop-ui/emulator/sg-1000.cpp index 3b85846492..dc76716fb8 100644 --- a/desktop-ui/emulator/sg-1000.cpp +++ b/desktop-ui/emulator/sg-1000.cpp @@ -1,6 +1,6 @@ struct SG1000 : Emulator { SG1000(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -25,15 +25,19 @@ SG1000::SG1000() { } } -auto SG1000::load() -> bool { +auto SG1000::load() -> LoadResult { game = mia::Medium::create("SG-1000"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("SG-1000"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; auto region = Emulator::region(); - if(!ares::SG1000::load(root, {"[Sega] SG-1000 (", region, ")"})) return false; + if(!ares::SG1000::load(root, {"[Sega] SG-1000 (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -50,7 +54,7 @@ auto SG1000::load() -> bool { port->connect(); } - return true; + return successful; } auto SG1000::save() -> bool { diff --git a/desktop-ui/emulator/super-famicom.cpp b/desktop-ui/emulator/super-famicom.cpp index acedd99bb4..7da2d90101 100644 --- a/desktop-ui/emulator/super-famicom.cpp +++ b/desktop-ui/emulator/super-famicom.cpp @@ -1,6 +1,6 @@ struct SuperFamicom : Emulator { SuperFamicom(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -93,17 +93,21 @@ SuperFamicom::SuperFamicom() { inputBlacklist = {"Justifiers", "Super Multitap"}; } -auto SuperFamicom::load() -> bool { +auto SuperFamicom::load() -> LoadResult { game = mia::Medium::create("Super Famicom"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("Super Famicom"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::SuperFamicom::option("Pixel Accuracy", settings.video.pixelAccuracy); auto region = Emulator::region(); - if(!ares::SuperFamicom::load(root, {"[Nintendo] Super Famicom (", region, ")"})) return false; + if(!ares::SuperFamicom::load(root, {"[Nintendo] Super Famicom (", region, ")"})) return otherError; if(auto port = root->find("Cartridge Slot")) { auto cartridge = port->allocate(); @@ -111,7 +115,7 @@ auto SuperFamicom::load() -> bool { if(auto slot = cartridge->find("Super Game Boy/Cartridge Slot")) { gb = mia::Medium::create("Game Boy"); - if(gb->load(Emulator::load(gb, settings.paths.superFamicom.gameBoy))) { + if(gb->load(Emulator::load(gb, settings.paths.superFamicom.gameBoy)) != successful) { slot->allocate(); slot->connect(); } else { @@ -121,7 +125,7 @@ auto SuperFamicom::load() -> bool { if(auto slot = cartridge->find("BS Memory Slot")) { bs = mia::Medium::create("BS Memory"); - if(bs->load(Emulator::load(bs, settings.paths.superFamicom.bsMemory))) { + if(bs->load(Emulator::load(bs, settings.paths.superFamicom.bsMemory)) != successful) { slot->allocate(); slot->connect(); } else { @@ -131,7 +135,7 @@ auto SuperFamicom::load() -> bool { if(auto slot = cartridge->find("Sufami Turbo Slot A")) { stA = mia::Medium::create("Sufami Turbo"); - if(stA->load(Emulator::load(stA, settings.paths.superFamicom.sufamiTurbo))) { + if(stA->load(Emulator::load(stA, settings.paths.superFamicom.sufamiTurbo)) != successful) { slot->allocate(); slot->connect(); } else { @@ -141,7 +145,7 @@ auto SuperFamicom::load() -> bool { if(auto slot = cartridge->find("Sufami Turbo Slot B")) { stB = mia::Medium::create("Sufami Turbo"); - if(stB->load(Emulator::load(stB, settings.paths.superFamicom.sufamiTurbo))) { + if(stB->load(Emulator::load(stB, settings.paths.superFamicom.sufamiTurbo)) != successful) { slot->allocate(); slot->connect(); } else { @@ -160,7 +164,7 @@ auto SuperFamicom::load() -> bool { port->connect(); } - return true; + return successful; } auto SuperFamicom::save() -> bool { diff --git a/desktop-ui/emulator/supergrafx-cd.cpp b/desktop-ui/emulator/supergrafx-cd.cpp index 53c5f7df0d..52cbd4e5b0 100644 --- a/desktop-ui/emulator/supergrafx-cd.cpp +++ b/desktop-ui/emulator/supergrafx-cd.cpp @@ -1,6 +1,6 @@ struct SuperGrafxCD : PCEngine { SuperGrafxCD(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -17,19 +17,30 @@ SuperGrafxCD::SuperGrafxCD() { allocatePorts(); } -auto SuperGrafxCD::load() -> bool { +auto SuperGrafxCD::load() -> LoadResult { game = mia::Medium::create("PC Engine CD"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; bios = mia::Medium::create("PC Engine"); - if(!bios->load(firmware[0].location)) return errorFirmware(firmware[0]), false; + result = bios->load(firmware[0].location); + if(result != successful) { + result.firmwareSystemName = "SuperGrafx CD"; + result.firmwareType = firmware[0].type; + result.firmwareRegion = firmware[0].region; + result.result = noFirmware; + return result; + } system = mia::System::create("SuperGrafx"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::PCEngine::option("Pixel Accuracy", settings.video.pixelAccuracy); - if(!ares::PCEngine::load(root, "[NEC] SuperGrafx (NTSC-J)")) return false; + if(!ares::PCEngine::load(root, "[NEC] SuperGrafx (NTSC-J)")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -43,7 +54,7 @@ auto SuperGrafxCD::load() -> bool { connectPorts(); - return true; + return successful; } auto SuperGrafxCD::save() -> bool { diff --git a/desktop-ui/emulator/supergrafx.cpp b/desktop-ui/emulator/supergrafx.cpp index 41d8921fa1..a2b1c35a1b 100644 --- a/desktop-ui/emulator/supergrafx.cpp +++ b/desktop-ui/emulator/supergrafx.cpp @@ -1,6 +1,6 @@ struct SuperGrafx : PCEngine { SuperGrafx(); - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -12,16 +12,20 @@ SuperGrafx::SuperGrafx() { allocatePorts(); } -auto SuperGrafx::load() -> bool { +auto SuperGrafx::load() -> LoadResult { game = mia::Medium::create("SuperGrafx"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("SuperGrafx"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::PCEngine::option("Pixel Accuracy", settings.video.pixelAccuracy); - if(!ares::PCEngine::load(root, "[NEC] SuperGrafx (NTSC-J)")) return false; + if(!ares::PCEngine::load(root, "[NEC] SuperGrafx (NTSC-J)")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); @@ -30,7 +34,7 @@ auto SuperGrafx::load() -> bool { connectPorts(); - return true; + return successful; } auto SuperGrafx::save() -> bool { diff --git a/desktop-ui/emulator/wonderswan-color.cpp b/desktop-ui/emulator/wonderswan-color.cpp index c22bf176fb..cfd29030a3 100644 --- a/desktop-ui/emulator/wonderswan-color.cpp +++ b/desktop-ui/emulator/wonderswan-color.cpp @@ -1,7 +1,7 @@ struct WonderSwanColor : Emulator { WonderSwanColor(); auto load(Menu) -> void override; - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -57,23 +57,27 @@ auto WonderSwanColor::load(Menu menu) -> void { } } -auto WonderSwanColor::load() -> bool { +auto WonderSwanColor::load() -> LoadResult { game = mia::Medium::create("WonderSwan Color"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("WonderSwan Color"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::WonderSwan::option("Pixel Accuracy", settings.video.pixelAccuracy); - if(!ares::WonderSwan::load(root, "[Bandai] WonderSwan Color")) return false; + if(!ares::WonderSwan::load(root, "[Bandai] WonderSwan Color")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); port->connect(); } - return true; + return successful; } auto WonderSwanColor::save() -> bool { diff --git a/desktop-ui/emulator/wonderswan.cpp b/desktop-ui/emulator/wonderswan.cpp index f1159f00b0..9a03b0d835 100644 --- a/desktop-ui/emulator/wonderswan.cpp +++ b/desktop-ui/emulator/wonderswan.cpp @@ -1,7 +1,7 @@ struct WonderSwan : Emulator { WonderSwan(); auto load(Menu) -> void override; - auto load() -> bool override; + auto load() -> LoadResult override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -57,23 +57,27 @@ auto WonderSwan::load(Menu menu) -> void { } } -auto WonderSwan::load() -> bool { +auto WonderSwan::load() -> LoadResult { game = mia::Medium::create("WonderSwan"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("WonderSwan"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; ares::WonderSwan::option("Pixel Accuracy", settings.video.pixelAccuracy); - if(!ares::WonderSwan::load(root, "[Bandai] WonderSwan")) return false; + if(!ares::WonderSwan::load(root, "[Bandai] WonderSwan")) return otherError; if(auto port = root->find("Cartridge Slot")) { port->allocate(); port->connect(); } - return true; + return successful; } auto WonderSwan::save() -> bool { diff --git a/desktop-ui/emulator/zx-spectrum-128.cpp b/desktop-ui/emulator/zx-spectrum-128.cpp index 1cba4d36ef..a8451908b3 100644 --- a/desktop-ui/emulator/zx-spectrum-128.cpp +++ b/desktop-ui/emulator/zx-spectrum-128.cpp @@ -1,6 +1,6 @@ struct ZXSpectrum128 : ZXSpectrum { ZXSpectrum128(); - auto load() -> bool override; + auto load() -> LoadResult override; auto pak(ares::Node::Object) -> shared_pointer override; }; @@ -9,14 +9,18 @@ ZXSpectrum128::ZXSpectrum128() { name = "ZX Spectrum 128"; } -auto ZXSpectrum128::load() -> bool { +auto ZXSpectrum128::load() -> LoadResult { game = mia::Medium::create("ZX Spectrum"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("ZX Spectrum 128"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; - if(!ares::ZXSpectrum::load(root, "[Sinclair] ZX Spectrum 128")) return false; + if(!ares::ZXSpectrum::load(root, "[Sinclair] ZX Spectrum 128")) return otherError; if(auto port = root->find("Tape Deck/Tray")) { port->allocate(); @@ -28,7 +32,7 @@ auto ZXSpectrum128::load() -> bool { port->connect(); } - return true; + return successful; } auto ZXSpectrum128::pak(ares::Node::Object node) -> shared_pointer { diff --git a/desktop-ui/emulator/zx-spectrum.cpp b/desktop-ui/emulator/zx-spectrum.cpp index e678ab58d2..666d5ea667 100644 --- a/desktop-ui/emulator/zx-spectrum.cpp +++ b/desktop-ui/emulator/zx-spectrum.cpp @@ -1,6 +1,6 @@ struct ZXSpectrum : Emulator { ZXSpectrum(); - auto load() -> bool override; + auto load() -> LoadResult override; auto load(Menu) -> void override; auto save() -> bool override; auto pak(ares::Node::Object) -> shared_pointer override; @@ -12,14 +12,18 @@ ZXSpectrum::ZXSpectrum() { name = "ZX Spectrum"; } -auto ZXSpectrum::load() -> bool { +auto ZXSpectrum::load() -> LoadResult { game = mia::Medium::create("ZX Spectrum"); - if(!game->load(Emulator::load(game, configuration.game))) return false; + string location = Emulator::load(game, configuration.game); + if(!location) return noFileSelected; + LoadResult result = game->load(location); + if(result != successful) return result; system = mia::System::create("ZX Spectrum"); - if(!system->load()) return false; + result = system->load(); + if(result != successful) return result; - if(!ares::ZXSpectrum::load(root, "[Sinclair] ZX Spectrum")) return false; + if(!ares::ZXSpectrum::load(root, "[Sinclair] ZX Spectrum")) return otherError; if(auto port = root->find("Tape Deck/Tray")) { port->allocate(); @@ -31,7 +35,7 @@ auto ZXSpectrum::load() -> bool { port->connect(); } - return true; + return successful; } auto ZXSpectrum::load(Menu menu) -> void { diff --git a/mia/CMakeLists.txt b/mia/CMakeLists.txt index 85e0fc03ae..041fca48c9 100644 --- a/mia/CMakeLists.txt +++ b/mia/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(mia STATIC mia.cpp resource/resource.cpp) +add_library(mia STATIC mia.cpp mia.hpp resource/resource.cpp) add_library(ares::mia ALIAS mia) target_sources( diff --git a/mia/medium/arcade.cpp b/mia/medium/arcade.cpp index f57770847e..a2d3e61928 100644 --- a/mia/medium/arcade.cpp +++ b/mia/medium/arcade.cpp @@ -1,23 +1,23 @@ struct Arcade : Mame { auto name() -> string override { return "Arcade"; } auto extensions() -> vector override { return {}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Arcade::load(string location) -> bool { +auto Arcade::load(string location) -> LoadResult { auto foundDatabase = Medium::loadDatabase(); - if(!foundDatabase) return false; + if(!foundDatabase) return { databaseNotFound, "Arcade.bml" }; manifest = manifestDatabaseArcade(Medium::name(location)); - if(!manifest) return false; + if(!manifest) return romNotFoundInDatabase; auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; //Sega SG-1000 based arcade if(document["game/board"].string() == "sega/sg1000a") { vector rom = loadRoms(location, document, "maincpu"); - if(!rom) return false; + if(!rom) return { invalidROM, "Ensure your ROM is in a MAME-compatible .zip format." }; this->location = location; @@ -28,10 +28,10 @@ auto Arcade::load(string location) -> bool { pak->append("manifest.bml", manifest); pak->append("program.rom", rom); - return true; + return successful; } - return false; + return otherError; } auto Arcade::save(string location) -> bool { diff --git a/mia/medium/atari-2600.cpp b/mia/medium/atari-2600.cpp index 04a97ff1db..24670291f6 100644 --- a/mia/medium/atari-2600.cpp +++ b/mia/medium/atari-2600.cpp @@ -1,28 +1,28 @@ struct Atari2600 : Cartridge { auto name() -> string override { return "Atari 2600"; } auto extensions() -> vector override { return {"a26", "bin"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom, string location) -> string; auto match(vector& rom, vector pattern, u8 target_matches = 1) -> bool; }; -auto Atari2600::load(string location) -> bool { +auto Atari2600::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->sha256 = Hash::SHA256(rom).digest(); this->location = location; this->manifest = Medium::manifestDatabase(sha256); if(!manifest) manifest = analyze(rom, location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -31,7 +31,7 @@ auto Atari2600::load(string location) -> bool { pak->append("manifest.bml", manifest); pak->append("program.rom", rom); - return true; + return successful; } auto Atari2600::save(string location) -> bool { diff --git a/mia/medium/bs-memory.cpp b/mia/medium/bs-memory.cpp index bb4c74083e..99cf848fc7 100644 --- a/mia/medium/bs-memory.cpp +++ b/mia/medium/bs-memory.cpp @@ -1,12 +1,12 @@ struct BSMemory : Cartridge { auto name() -> string override { return "BS Memory"; } auto extensions() -> vector override { return {"bs"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto BSMemory::load(string location) -> bool { +auto BSMemory::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); @@ -14,16 +14,16 @@ auto BSMemory::load(string location) -> bool { } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->sha256 = Hash::SHA256(rom).digest(); this->location = location; auto foundDatabase = Medium::loadDatabase(); - if(!foundDatabase) return false; + if(!foundDatabase) return { databaseNotFound, "BS Memory.bml" }; this->manifest = Medium::manifestDatabase(sha256); if(!manifest) manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -36,7 +36,7 @@ auto BSMemory::load(string location) -> bool { Pak::load("program.flash", ".sav"); } - return true; + return successful; } auto BSMemory::save(string location) -> bool { diff --git a/mia/medium/colecovision.cpp b/mia/medium/colecovision.cpp index 9f08252581..26f5b5fd57 100644 --- a/mia/medium/colecovision.cpp +++ b/mia/medium/colecovision.cpp @@ -1,24 +1,24 @@ struct ColecoVision : Cartridge { auto name() -> string override { return "ColecoVision"; } auto extensions() -> vector override { return {"cv", "col"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto ColecoVision::load(string location) -> bool { +auto ColecoVision::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("board", document["game/board" ].string()); @@ -27,7 +27,7 @@ auto ColecoVision::load(string location) -> bool { pak->append("manifest.bml", manifest); pak->append("program.rom", rom); - return true; + return successful; } auto ColecoVision::save(string location) -> bool { diff --git a/mia/medium/famicom-disk-system.cpp b/mia/medium/famicom-disk-system.cpp index 35ffe94396..b12b2f4803 100644 --- a/mia/medium/famicom-disk-system.cpp +++ b/mia/medium/famicom-disk-system.cpp @@ -1,13 +1,13 @@ struct FamicomDiskSystem : FloppyDisk { auto name() -> string override { return "Famicom Disk System"; } auto extensions() -> vector override { return {"fds"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze() -> string; auto transform(array_view input) -> vector; }; -auto FamicomDiskSystem::load(string location) -> bool { +auto FamicomDiskSystem::load(string location) -> LoadResult { if(directory::exists(location)) { this->location = location; this->manifest = analyze(); @@ -42,14 +42,14 @@ auto FamicomDiskSystem::load(string location) -> bool { } } - if(!pak) return false; + if(!pak) return romNotFound; Pak::load("disk1.sideA", ".d1a"); Pak::load("disk1.sideB", ".d1b"); Pak::load("disk2.sideA", ".d2a"); Pak::load("disk2.sideB", ".d2b"); - return true; + return successful; } auto FamicomDiskSystem::save(string location) -> bool { diff --git a/mia/medium/famicom.cpp b/mia/medium/famicom.cpp index 5210c955a6..c3ce8ca9fa 100644 --- a/mia/medium/famicom.cpp +++ b/mia/medium/famicom.cpp @@ -1,7 +1,7 @@ struct Famicom : Cartridge { auto name() -> string override { return "Famicom"; } auto extensions() -> vector override { return {"fc", "nes", "unf", "unif", "unh"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& data) -> string; auto analyzeFDS(vector& data) -> string; @@ -9,7 +9,7 @@ struct Famicom : Cartridge { auto analyzeUNIF(vector& data) -> string; }; -auto Famicom::load(string location) -> bool { +auto Famicom::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "ines.rom"}); @@ -18,12 +18,12 @@ auto Famicom::load(string location) -> bool { } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -70,7 +70,7 @@ auto Famicom::load(string location) -> bool { Medium::load(node, ".chr"); } - return true; + return successful; } auto Famicom::save(string location) -> bool { diff --git a/mia/medium/game-boy-advance.cpp b/mia/medium/game-boy-advance.cpp index 3d72b64985..3d8e50632c 100644 --- a/mia/medium/game-boy-advance.cpp +++ b/mia/medium/game-boy-advance.cpp @@ -1,25 +1,25 @@ struct GameBoyAdvance : Cartridge { auto name() -> string override { return "Game Boy Advance"; } auto extensions() -> vector override { return {"gba"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto GameBoyAdvance::load(string location) -> bool { +auto GameBoyAdvance::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->sha256 = Hash::SHA256(rom).digest(); this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -45,7 +45,7 @@ auto GameBoyAdvance::load(string location) -> bool { } pak->setAttribute("mirror", mirror); - return true; + return successful; } auto GameBoyAdvance::save(string location) -> bool { diff --git a/mia/medium/game-boy.cpp b/mia/medium/game-boy.cpp index ae724d7e20..b62bcdae23 100644 --- a/mia/medium/game-boy.cpp +++ b/mia/medium/game-boy.cpp @@ -1,24 +1,24 @@ struct GameBoy : Cartridge { auto name() -> string override { return "Game Boy"; } auto extensions() -> vector override { return {"gb"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto GameBoy::load(string location) -> bool { +auto GameBoy::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -42,7 +42,7 @@ auto GameBoy::load(string location) -> bool { Medium::load(node, ".rtc"); } - return true; + return successful; } auto GameBoy::save(string location) -> bool { diff --git a/mia/medium/game-gear.cpp b/mia/medium/game-gear.cpp index 7f8ec4cb67..3ea4c95116 100644 --- a/mia/medium/game-gear.cpp +++ b/mia/medium/game-gear.cpp @@ -1,25 +1,25 @@ struct GameGear : Cartridge { auto name() -> string override { return "Game Gear"; } auto extensions() -> vector override { return {"gg"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom, string location) -> string; }; -auto GameGear::load(string location) -> bool { +auto GameGear::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } else { - return false; + return romNotFound; } this->location = location; this->manifest = analyze(rom, location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("board", document["game/board" ].string()); @@ -33,7 +33,7 @@ auto GameGear::load(string location) -> bool { Medium::load(node, ".ram"); } - return true; + return successful; } auto GameGear::save(string location) -> bool { diff --git a/mia/medium/mame.cpp b/mia/medium/mame.cpp index 40fb6b046e..d70ecd07d3 100644 --- a/mia/medium/mame.cpp +++ b/mia/medium/mame.cpp @@ -8,9 +8,8 @@ auto Mame::loadRoms(string location, Markup::Node& info, string sectionName) -> vector output; Decode::ZIP archive; - if(!archive.open(location)) { - return output; - } + if(!location.iendsWith(".zip")) return output; + if(!archive.open(location)) return output; string filename = {}; vector input = {}; diff --git a/mia/medium/master-system.cpp b/mia/medium/master-system.cpp index 1b3aa15d2d..b340f3aa60 100644 --- a/mia/medium/master-system.cpp +++ b/mia/medium/master-system.cpp @@ -1,25 +1,25 @@ struct MasterSystem : Cartridge { auto name() -> string override { return "Master System"; } auto extensions() -> vector override { return {"ms", "sms"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto MasterSystem::load(string location) -> bool { +auto MasterSystem::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } else { - return false; + return romNotFound; } this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("board", document["game/board" ].string()); @@ -34,7 +34,7 @@ auto MasterSystem::load(string location) -> bool { Medium::load(node, ".ram"); } - return true; + return successful; } auto MasterSystem::save(string location) -> bool { diff --git a/mia/medium/mega-32x.cpp b/mia/medium/mega-32x.cpp index 2ddc927980..3ae3f6be16 100644 --- a/mia/medium/mega-32x.cpp +++ b/mia/medium/mega-32x.cpp @@ -1,7 +1,7 @@ struct Mega32X : Cartridge { auto name() -> string override { return "Mega 32X"; } auto extensions() -> vector override { return {"32x"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; auto analyzeStorage(vector& rom, string hash) -> void; @@ -25,19 +25,19 @@ struct Mega32X : Cartridge { } eeprom; }; -auto Mega32X::load(string location) -> bool { +auto Mega32X::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -67,7 +67,7 @@ auto Mega32X::load(string location) -> bool { } } - return true; + return successful; } auto Mega32X::save(string location) -> bool { diff --git a/mia/medium/mega-cd.cpp b/mia/medium/mega-cd.cpp index dea98ccc6a..3a15555579 100644 --- a/mia/medium/mega-cd.cpp +++ b/mia/medium/mega-cd.cpp @@ -1,18 +1,18 @@ struct MegaCD : CompactDisc { auto name() -> string override { return "Mega CD"; } auto extensions() -> vector override { return {"cue", "chd"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(string location) -> string; }; -auto MegaCD::load(string location) -> bool { - if(!inode::exists(location)) return false; +auto MegaCD::load(string location) -> LoadResult { + if(!inode::exists(location)) return romNotFound; this->location = location; this->manifest = analyze(location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -27,7 +27,7 @@ auto MegaCD::load(string location) -> bool { pak->append("cd.rom", vfs::cdrom::open(location)); } - return true; + return successful; } auto MegaCD::save(string location) -> bool { diff --git a/mia/medium/mega-drive.cpp b/mia/medium/mega-drive.cpp index d61ada7ee6..f5833e7941 100644 --- a/mia/medium/mega-drive.cpp +++ b/mia/medium/mega-drive.cpp @@ -1,7 +1,7 @@ struct MegaDrive : Cartridge { auto name() -> string override { return "Mega Drive"; } auto extensions() -> vector override { return {"md", "gen", "bin"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; auto analyzeStorage(vector& rom, string hash) -> void; @@ -37,19 +37,19 @@ struct MegaDrive : Cartridge { } peripherals; }; -auto MegaDrive::load(string location) -> bool { +auto MegaDrive::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -100,7 +100,7 @@ auto MegaDrive::load(string location) -> bool { pak->setAttribute("jcart", true); } - return true; + return successful; } auto MegaDrive::save(string location) -> bool { diff --git a/mia/medium/msx.cpp b/mia/medium/msx.cpp index 996c08ad44..1e5f298fd8 100644 --- a/mia/medium/msx.cpp +++ b/mia/medium/msx.cpp @@ -1,14 +1,14 @@ struct MSX : Cartridge { auto name() -> string override { return "MSX"; } auto extensions() -> vector override { return {"msx", "rom", "wav"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; - auto loadTape(string location) -> bool; + auto loadTape(string location) -> LoadResult; auto analyzeTape(string location) -> string; }; -auto MSX::load(string location) -> bool { +auto MSX::load(string location) -> LoadResult { if(location.iendsWith(".wav")) { return loadTape(location); } @@ -19,16 +19,16 @@ auto MSX::load(string location) -> bool { } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->sha256 = Hash::SHA256(rom).digest(); this->location = location; auto foundDatabase = Medium::loadDatabase(); - if(!foundDatabase) return false; + if(!foundDatabase) return { databaseNotFound, "MSX.bml" }; this->manifest = Medium::manifestDatabase(sha256); if(!manifest) manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -38,7 +38,7 @@ auto MSX::load(string location) -> bool { pak->append("manifest.bml", manifest); pak->append("program.rom", rom); - return true; + return successful; } auto MSX::save(string location) -> bool { @@ -141,13 +141,13 @@ auto MSX::analyze(vector& rom) -> string { } -auto MSX::loadTape(string location) -> bool { - if(!inode::exists(location)) return false; +auto MSX::loadTape(string location) -> LoadResult { + if(!inode::exists(location)) return romNotFound; this->location = location; this->manifest = analyzeTape(location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -177,7 +177,7 @@ auto MSX::loadTape(string location) -> bool { } } - return true; + return successful; } auto MSX::analyzeTape(string location) -> string { diff --git a/mia/medium/myvision.cpp b/mia/medium/myvision.cpp index e63c47ae5d..454aecbe91 100644 --- a/mia/medium/myvision.cpp +++ b/mia/medium/myvision.cpp @@ -4,32 +4,32 @@ struct MyVision : Cartridge { auto name() -> string override { return "MyVision"; } auto extensions() -> vector override { return {"myv"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto MyVision::load(string location) -> bool { +auto MyVision::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->sha256 = Hash::SHA256(rom).digest(); this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); pak->append("manifest.bml", manifest); pak->append("program.rom", rom); - return true; + return successful; } auto MyVision::save(string location) -> bool { diff --git a/mia/medium/neo-geo-pocket.cpp b/mia/medium/neo-geo-pocket.cpp index 0d20a03efb..f171e129d6 100644 --- a/mia/medium/neo-geo-pocket.cpp +++ b/mia/medium/neo-geo-pocket.cpp @@ -1,25 +1,25 @@ struct NeoGeoPocket : Cartridge { auto name() -> string override { return "Neo Geo Pocket"; } auto extensions() -> vector override { return {"ngp"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; auto label(vector& data) -> string; }; -auto NeoGeoPocket::load(string location) -> bool { +auto NeoGeoPocket::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.flash"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -28,7 +28,7 @@ auto NeoGeoPocket::load(string location) -> bool { Pak::load("program.flash", ".sav"); - return true; + return successful; } auto NeoGeoPocket::save(string location) -> bool { diff --git a/mia/medium/neo-geo.cpp b/mia/medium/neo-geo.cpp index cc2795db96..93c85e383c 100644 --- a/mia/medium/neo-geo.cpp +++ b/mia/medium/neo-geo.cpp @@ -6,7 +6,7 @@ struct NeoGeo : Mame { auto name() -> string override { return "Neo Geo"; } auto extensions() -> vector override { return {"ng"}; } auto read(string location, string match) -> vector; - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto board() -> string; auto save(string location) -> bool override; auto analyze(vector& p, vector& m, vector& c, vector& s, vector& vA, vector& vB) -> string; @@ -58,7 +58,7 @@ auto NeoGeo::read(string location, string match) -> vector { return {}; } -auto NeoGeo::load(string location) -> bool { +auto NeoGeo::load(string location) -> LoadResult { vector programROM; //P ROM (68K CPU program) vector musicROM; //M ROM (Z80 APU program) vector characterROM; //C ROM (sprite and background character graphics) @@ -67,7 +67,7 @@ auto NeoGeo::load(string location) -> bool { vector voiceBROM; //V ROM (ADPCM-B voice samples) auto foundDatabase = Medium::loadDatabase(); - if(!foundDatabase) return false; + if(!foundDatabase) return { databaseNotFound, "Neo Geo.bml" }; this->info = BML::unserialize(manifestDatabaseArcade(Medium::name(location))); if(file::exists(location)) { @@ -78,12 +78,14 @@ auto NeoGeo::load(string location) -> bool { voiceAROM = NeoGeo::read(location, "voice-a.rom"); voiceBROM = NeoGeo::read(location, "voice-b.rom"); } - - if(!programROM ) return false; - if(!musicROM ) return false; - if(!characterROM) return false; - if(!staticROM ) return false; - if(!voiceAROM ) return false; + + string invalidRomInfo = "Ensure your ROM is in a MAME-compatible .zip format."; + + if(!programROM ) return { invalidROM, invalidRomInfo }; + if(!musicROM ) return { invalidROM, invalidRomInfo }; + if(!characterROM) return { invalidROM, invalidRomInfo }; + if(!staticROM ) return { invalidROM, invalidRomInfo }; + if(!voiceAROM ) return { invalidROM, invalidRomInfo }; //voiceB is optional //many games have encrypted roms, so let's decrypt them here @@ -101,7 +103,7 @@ auto NeoGeo::load(string location) -> bool { this->location = location; this->manifest = analyze(programROM, musicROM, characterROM, staticROM, voiceAROM, voiceBROM); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("sha256", sha256); @@ -114,7 +116,7 @@ auto NeoGeo::load(string location) -> bool { pak->append("static.rom", staticROM); pak->append("voice-a.rom", voiceAROM); pak->append("voice-b.rom", voiceBROM); - return true; + return successful; } auto NeoGeo::save(string location) -> bool { diff --git a/mia/medium/nintendo-64.cpp b/mia/medium/nintendo-64.cpp index 47bed77b94..d1875d1430 100644 --- a/mia/medium/nintendo-64.cpp +++ b/mia/medium/nintendo-64.cpp @@ -1,7 +1,7 @@ struct Nintendo64 : Cartridge { auto name() -> string override { return "Nintendo 64"; } auto extensions() -> vector override { return {"n64", "v64", "z64"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; auto ipl2checksum(u32 seed, array_view rom) -> u64; @@ -82,21 +82,21 @@ auto Nintendo64::ipl2checksum(u32 seed, array_view rom) -> u64 { return checksum & 0xffffffffffffull; } -auto Nintendo64::load(string location) -> bool { +auto Nintendo64::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->sha256 = Hash::SHA256(rom).digest(); this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("id", document["game/id"].string()); @@ -123,7 +123,7 @@ auto Nintendo64::load(string location) -> bool { Medium::load(node, ".rtc"); } - return true; + return successful; } auto Nintendo64::save(string location) -> bool { diff --git a/mia/medium/nintendo-64dd.cpp b/mia/medium/nintendo-64dd.cpp index 1906a6db4d..c9d4e448e5 100644 --- a/mia/medium/nintendo-64dd.cpp +++ b/mia/medium/nintendo-64dd.cpp @@ -1,7 +1,7 @@ struct Nintendo64DD : FloppyDisk { auto name() -> string override { return "Nintendo 64DD"; } auto extensions() -> vector override { return {"n64dd", "ndd", "d64"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom, vector errorTable) -> string; auto transform(array_view input, vector errorTable) -> vector; @@ -10,24 +10,24 @@ struct Nintendo64DD : FloppyDisk { auto createErrorTable(array_view input) -> vector; }; -auto Nintendo64DD::load(string location) -> bool { +auto Nintendo64DD::load(string location) -> LoadResult { vector input; if(directory::exists(location)) { append(input, {location, "program.disk"}); } else if(file::exists(location)) { input = FloppyDisk::read(location); } - if(!input) return false; + if(!input) return romNotFound; array_view view{input}; auto errorTable = createErrorTable(view); - if(!errorTable) return false; + if(!errorTable) return invalidROM; auto sizeValid = sizeCheck(view); - if(!sizeValid) return false; + if(!sizeValid) return invalidROM; this->location = location; this->manifest = analyze(input, errorTable); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = shared_pointer{new vfs::directory}; pak->setAttribute("title", document["game/title"].string()); pak->setAttribute("region", document["game/region"].string()); @@ -38,11 +38,11 @@ auto Nintendo64DD::load(string location) -> bool { pak->append("program.disk", output); } - if(!pak) return false; + if(!pak) return otherError; Pak::load("program.disk", ".disk"); - return true; + return successful; } auto Nintendo64DD::save(string location) -> bool { diff --git a/mia/medium/pc-engine-cd.cpp b/mia/medium/pc-engine-cd.cpp index bdf64bd743..e58475db8f 100644 --- a/mia/medium/pc-engine-cd.cpp +++ b/mia/medium/pc-engine-cd.cpp @@ -1,18 +1,18 @@ struct PCEngineCD : CompactDisc { auto name() -> string override { return "PC Engine CD"; } auto extensions() -> vector override { return {"cue", "chd"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(string location) -> string; }; -auto PCEngineCD::load(string location) -> bool { - if(!inode::exists(location)) return false; +auto PCEngineCD::load(string location) -> LoadResult { + if(!inode::exists(location)) return romNotFound; this->location = location; this->manifest = analyze(location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -27,7 +27,7 @@ auto PCEngineCD::load(string location) -> bool { pak->append("cd.rom", vfs::cdrom::open(location)); } - return true; + return successful; } auto PCEngineCD::save(string location) -> bool { diff --git a/mia/medium/pc-engine.cpp b/mia/medium/pc-engine.cpp index 204db2ea32..ad3805c580 100644 --- a/mia/medium/pc-engine.cpp +++ b/mia/medium/pc-engine.cpp @@ -1,24 +1,24 @@ struct PCEngine : Cartridge { auto name() -> string override { return "PC Engine"; } auto extensions() -> vector override { return {"pce"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto PCEngine::load(string location) -> bool { +auto PCEngine::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -37,7 +37,7 @@ auto PCEngine::load(string location) -> bool { Medium::load(node, ".wram"); } - return true; + return successful; } auto PCEngine::save(string location) -> bool { diff --git a/mia/medium/playstation.cpp b/mia/medium/playstation.cpp index 043e0497dc..c855ed50cc 100644 --- a/mia/medium/playstation.cpp +++ b/mia/medium/playstation.cpp @@ -1,19 +1,19 @@ struct PlayStation : CompactDisc { auto name() -> string override { return "PlayStation"; } auto extensions() -> vector override { return {"cue", "chd", "exe"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(string location) -> string; auto cdFromExecutable(string location) -> vector; }; -auto PlayStation::load(string location) -> bool { - if(!inode::exists(location)) return false; +auto PlayStation::load(string location) -> LoadResult { + if(!inode::exists(location)) return romNotFound; this->location = location; this->manifest = analyze(location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -36,7 +36,7 @@ auto PlayStation::load(string location) -> bool { } } - return true; + return successful; } auto PlayStation::save(string location) -> bool { diff --git a/mia/medium/saturn.cpp b/mia/medium/saturn.cpp index 2361f61931..8e64528cbb 100644 --- a/mia/medium/saturn.cpp +++ b/mia/medium/saturn.cpp @@ -1,18 +1,18 @@ struct Saturn : CompactDisc { auto name() -> string override { return "Saturn"; } auto extensions() -> vector override { return {"cue", "chd"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(string location) -> string; }; -auto Saturn::load(string location) -> bool { - if(!inode::exists(location)) return false; +auto Saturn::load(string location) -> LoadResult { + if(!inode::exists(location)) return romNotFound; this->location = location; this->manifest = analyze(location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -26,7 +26,7 @@ auto Saturn::load(string location) -> bool { pak->append("cd.rom", vfs::cdrom::open(location)); } - return true; + return successful; } auto Saturn::save(string location) -> bool { diff --git a/mia/medium/sg-1000.cpp b/mia/medium/sg-1000.cpp index d8bef675da..6b04f21418 100644 --- a/mia/medium/sg-1000.cpp +++ b/mia/medium/sg-1000.cpp @@ -1,24 +1,24 @@ struct SG1000 : Cartridge { auto name() -> string override { return "SG-1000"; } auto extensions() -> vector override { return {"sg1000", "sg"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; }; -auto SG1000::load(string location) -> bool { +auto SG1000::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("board", document["game/board" ].string()); @@ -31,7 +31,7 @@ auto SG1000::load(string location) -> bool { Medium::load(node, ".ram"); } - return true; + return successful; } auto SG1000::save(string location) -> bool { diff --git a/mia/medium/sufami-turbo.cpp b/mia/medium/sufami-turbo.cpp index 5bbacb2953..e1d009ab82 100644 --- a/mia/medium/sufami-turbo.cpp +++ b/mia/medium/sufami-turbo.cpp @@ -1,28 +1,28 @@ struct SufamiTurbo : Cartridge { auto name() -> string override { return "Sufami Turbo"; } auto extensions() -> vector override { return {"st"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& data) -> string; }; -auto SufamiTurbo::load(string location) -> bool { +auto SufamiTurbo::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->sha256 = Hash::SHA256(rom).digest(); this->location = location; auto foundDatabase = Medium::loadDatabase(); - if(!foundDatabase) return false; + if(!foundDatabase) return { databaseNotFound, "Sufami Turbo.bml" }; this->manifest = Medium::manifestDatabase(sha256); if(!manifest) manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -33,7 +33,7 @@ auto SufamiTurbo::load(string location) -> bool { Medium::load(node, ".ram"); } - return true; + return successful; } auto SufamiTurbo::save(string location) -> bool { diff --git a/mia/medium/super-famicom.cpp b/mia/medium/super-famicom.cpp index de272869f5..da73ebf0fe 100644 --- a/mia/medium/super-famicom.cpp +++ b/mia/medium/super-famicom.cpp @@ -1,7 +1,7 @@ struct SuperFamicom : Cartridge { auto name() -> string override { return "Super Famicom"; } auto extensions() -> vector override { return {"sfc", "smc", "swc", "fig"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; @@ -33,7 +33,7 @@ struct SuperFamicom : Cartridge { u32 headerAddress = 0; }; -auto SuperFamicom::load(string location) -> bool { +auto SuperFamicom::load(string location) -> LoadResult { vector rom; string directory = location; bool local_firmware = false; @@ -75,7 +75,7 @@ auto SuperFamicom::load(string location) -> bool { directory = Location::dir(location); } - if(!rom) return false; + if(!rom) return romNotFound; //append firmware to the ROM if it is missing auto tmp_manifest = analyze(rom); @@ -85,7 +85,7 @@ auto SuperFamicom::load(string location) -> bool { this->sha256 = Hash::SHA256(rom).digest(); this->location = location; auto foundDatabase = Medium::loadDatabase(); - if(!foundDatabase) return false; + if(!foundDatabase) return { databaseNotFound, "Super Famicom.bml" }; this->manifest = Medium::manifestDatabase(sha256); if(!manifest) { @@ -102,7 +102,7 @@ auto SuperFamicom::load(string location) -> bool { if(!manifest) manifest = analyze(rom); document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -182,7 +182,7 @@ auto SuperFamicom::load(string location) -> bool { Medium::load(node, ".dram"); } - return true; + return successful; } auto SuperFamicom::save(string location) -> bool { diff --git a/mia/medium/wonderswan.cpp b/mia/medium/wonderswan.cpp index d52982362d..2670beebcc 100644 --- a/mia/medium/wonderswan.cpp +++ b/mia/medium/wonderswan.cpp @@ -1,25 +1,25 @@ struct WonderSwan : Cartridge { auto name() -> string override { return "WonderSwan"; } auto extensions() -> vector override { return {"ws"}; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto analyze(vector& rom) -> string; virtual auto mapper(vector& rom) -> string; }; -auto WonderSwan::load(string location) -> bool { +auto WonderSwan::load(string location) -> LoadResult { vector rom; if(directory::exists(location)) { append(rom, {location, "program.rom"}); } else if(file::exists(location)) { rom = Cartridge::read(location); } - if(!rom) return false; + if(!rom) return romNotFound; this->location = location; this->manifest = analyze(rom); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -43,7 +43,7 @@ auto WonderSwan::load(string location) -> bool { Medium::load(node, ".rtc"); } - return true; + return successful; } auto WonderSwan::save(string location) -> bool { diff --git a/mia/medium/zx-spectrum.cpp b/mia/medium/zx-spectrum.cpp index 9a5442f802..ff97c37cfb 100644 --- a/mia/medium/zx-spectrum.cpp +++ b/mia/medium/zx-spectrum.cpp @@ -1,30 +1,30 @@ struct ZXSpectrum : Medium { auto name() -> string override { return "ZX Spectrum"; } auto extensions() -> vector override { return {"wav", "tzx", "tap" }; } - auto load(string location) -> bool override; - auto loadWav(string location) -> bool; - auto loadTzx(string location) -> bool; + auto load(string location) -> LoadResult override; + auto loadWav(string location) -> LoadResult; + auto loadTzx(string location) -> LoadResult; auto save(string location) -> bool override; auto analyze(string location) -> string; }; -auto ZXSpectrum::load(string location) -> bool { - if(!inode::exists(location)) return false; +auto ZXSpectrum::load(string location) -> LoadResult { + if(!inode::exists(location)) return romNotFound; if(location.iendsWith(".tap") || location.iendsWith(".tzx")) return loadTzx(location); if(location.iendsWith(".wav")) return loadWav(location); - return false; + return invalidROM; } -auto ZXSpectrum::loadTzx(string location) -> bool { +auto ZXSpectrum::loadTzx(string location) -> LoadResult { this->location = location; this->manifest = analyze(location); auto document = BML::unserialize(manifest); - if (!document) return false; + if(!document) return couldNotParseManifest; vector input = file::read(location); TZXFile tzx; - if(tzx.DecodeFile(input.data(), input.size()) == FileTypeUndetermined) return false; + if(tzx.DecodeFile(input.data(), input.size()) == FileTypeUndetermined) return invalidROM; tzx.GenerateAudioData(); pak = new vfs::directory; @@ -45,14 +45,14 @@ auto ZXSpectrum::loadTzx(string location) -> bool { } pak->append("program.tape", output); - return true; + return successful; } -auto ZXSpectrum::loadWav(string location) -> bool { +auto ZXSpectrum::loadWav(string location) -> LoadResult { this->location = location; this->manifest = analyze(location); auto document = BML::unserialize(manifest); - if(!document) return false; + if(!document) return couldNotParseManifest; pak = new vfs::directory; pak->setAttribute("title", document["game/title"].string()); @@ -80,7 +80,7 @@ auto ZXSpectrum::loadWav(string location) -> bool { } } - return true; + return successful; } auto ZXSpectrum::save(string location) -> bool { diff --git a/mia/mia.cpp b/mia/mia.cpp index 228f944690..f8a00fc4fc 100644 --- a/mia/mia.cpp +++ b/mia/mia.cpp @@ -144,7 +144,7 @@ auto identify(const string& filename) -> string { for(auto& medium : media) { auto pak = mia::Medium::create(medium); if(pak->extensions().find(extension)) { - if(!pak->load(filename)) continue; // Skip medium that the system cannot load + if(pak->load(filename) != successful) continue; // Skip medium that the system cannot load if(pak->pak->attribute("audio").boolean()) continue; // Skip audio-only media to give the next system a chance to match return pak->name(); } @@ -154,7 +154,7 @@ auto identify(const string& filename) -> string { } auto import(shared_pointer pak, const string& filename) -> bool { - if(pak->load(filename)) { + if(pak->load(filename) == successful) { string pathname = {Path::user(), "Emulation/", pak->name(), "/", Location::prefix(filename), ".", pak->extensions().first(), "/"}; if(!directory::create(pathname)) return false; for(auto& node : *pak->pak) { @@ -194,7 +194,7 @@ auto main(Arguments arguments) -> void { if(!pak) return; if(string manifest; arguments.take("--manifest", manifest)) { - if(pak->load(manifest)) { + if(pak->load(manifest) == successful) { if(auto fp = pak->pak->read("manifest.bml")) return print(fp->reads()); } return; diff --git a/mia/mia.hpp b/mia/mia.hpp index cbc58a62d3..fbed61769f 100644 --- a/mia/mia.hpp +++ b/mia/mia.hpp @@ -17,6 +17,38 @@ using namespace hiro; #include #include +enum ResultEnum { + successful, + noFileSelected, + databaseNotFound, + romNotFoundInDatabase, + romNotFound, + invalidROM, + couldNotParseManifest, + noFirmware, + otherError +}; + +struct LoadResult { + ResultEnum result; + + string info; + string firmwareType; + string firmwareSystemName; + string firmwareRegion; + + LoadResult(ResultEnum r) : result(r) {} + + LoadResult(ResultEnum r, string i) : result(r), info(i) {} + + bool operator==(const LoadResult& other) { + return result == other.result; + } + bool operator!=(const LoadResult& other) { + return result != other.result; + } +}; + namespace mia { #include "settings/settings.hpp" #include "pak/pak.hpp" @@ -33,4 +65,5 @@ namespace mia { auto construct() -> void; auto identify(const string& filename) -> string; auto import(shared_pointer, const string& filename) -> bool; + } diff --git a/mia/pak/pak.hpp b/mia/pak/pak.hpp index 3fab950325..eb5e79fabc 100644 --- a/mia/pak/pak.hpp +++ b/mia/pak/pak.hpp @@ -5,7 +5,7 @@ struct Pak { virtual auto type() -> string { return pak->attribute("type"); } virtual auto name() -> string { return pak->attribute("name"); } virtual auto extensions() -> vector { return {}; } - virtual auto load(string location = {}) -> bool { return true; } + virtual auto load(string location = {}) -> LoadResult { return successful; } virtual auto loadMultiple(vector location = {}) -> bool { return true; } virtual auto save(string location = {}) -> bool { return true; } diff --git a/mia/system/arcade.cpp b/mia/system/arcade.cpp index 0a691fcebe..23e5bfc7c3 100644 --- a/mia/system/arcade.cpp +++ b/mia/system/arcade.cpp @@ -1,13 +1,13 @@ struct Arcade : System { auto name() -> string override { return "Arcade"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Arcade::load(string location) -> bool { +auto Arcade::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; - return true; + return successful; } auto Arcade::save(string location) -> bool { diff --git a/mia/system/atari-2600.cpp b/mia/system/atari-2600.cpp index 41efb378fe..2ed297132a 100644 --- a/mia/system/atari-2600.cpp +++ b/mia/system/atari-2600.cpp @@ -1,13 +1,13 @@ struct Atari2600 : System { auto name() -> string override { return "Atari 2600"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Atari2600::load(string location) -> bool { +auto Atari2600::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; - return true; + return successful; } auto Atari2600::save(string location) -> bool { diff --git a/mia/system/colecovision.cpp b/mia/system/colecovision.cpp index b81d60befd..f7749c2ee9 100644 --- a/mia/system/colecovision.cpp +++ b/mia/system/colecovision.cpp @@ -1,17 +1,17 @@ struct ColecoVision : System { auto name() -> string override { return "ColecoVision"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto ColecoVision::load(string location) -> bool { +auto ColecoVision::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; pak->append("bios.rom", bios); - return true; + return successful; } auto ColecoVision::save(string location) -> bool { diff --git a/mia/system/famicom.cpp b/mia/system/famicom.cpp index 19b77d70b4..cbdd23ac51 100644 --- a/mia/system/famicom.cpp +++ b/mia/system/famicom.cpp @@ -1,13 +1,13 @@ struct Famicom : System { auto name() -> string override { return "Famicom"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Famicom::load(string location) -> bool { +auto Famicom::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; - return true; + return successful; } auto Famicom::save(string location) -> bool { diff --git a/mia/system/game-boy-advance.cpp b/mia/system/game-boy-advance.cpp index 2eff570ec8..f5b6881b8c 100644 --- a/mia/system/game-boy-advance.cpp +++ b/mia/system/game-boy-advance.cpp @@ -1,17 +1,17 @@ struct GameBoyAdvance : System { auto name() -> string override { return "Game Boy Advance"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto GameBoyAdvance::load(string location) -> bool { +auto GameBoyAdvance::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; pak->append("bios.rom", bios); - return true; + return successful; } auto GameBoyAdvance::save(string location) -> bool { diff --git a/mia/system/game-boy-color.cpp b/mia/system/game-boy-color.cpp index 1f1a9741ae..932a6c7ace 100644 --- a/mia/system/game-boy-color.cpp +++ b/mia/system/game-boy-color.cpp @@ -1,14 +1,14 @@ struct GameBoyColor : System { auto name() -> string override { return "Game Boy Color"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto GameBoyColor::load(string location) -> bool { +auto GameBoyColor::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("boot.rom", Resource::GameBoyColor::BootCGB0); - return true; + return successful; } auto GameBoyColor::save(string location) -> bool { diff --git a/mia/system/game-boy.cpp b/mia/system/game-boy.cpp index 9ec031eb4d..53aae623cf 100644 --- a/mia/system/game-boy.cpp +++ b/mia/system/game-boy.cpp @@ -1,14 +1,14 @@ struct GameBoy : System { auto name() -> string override { return "Game Boy"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto GameBoy::load(string location) -> bool { +auto GameBoy::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("boot.rom", Resource::GameBoy::BootDMG1); - return true; + return successful; } auto GameBoy::save(string location) -> bool { diff --git a/mia/system/game-gear.cpp b/mia/system/game-gear.cpp index c3260fca64..1240b6893b 100644 --- a/mia/system/game-gear.cpp +++ b/mia/system/game-gear.cpp @@ -1,17 +1,17 @@ struct GameGear : System { auto name() -> string override { return "Game Gear"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto GameGear::load(string location) -> bool { +auto GameGear::load(string location) -> LoadResult { auto bios = Pak::read(location); //optional this->location = locate(); pak = new vfs::directory; if(bios) pak->append("bios.rom", bios); - return true; + return successful; } auto GameGear::save(string location) -> bool { diff --git a/mia/system/master-system.cpp b/mia/system/master-system.cpp index 414e86eb64..ef30510d23 100644 --- a/mia/system/master-system.cpp +++ b/mia/system/master-system.cpp @@ -1,17 +1,17 @@ struct MasterSystem : System { auto name() -> string override { return "Master System"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto MasterSystem::load(string location) -> bool { +auto MasterSystem::load(string location) -> LoadResult { auto bios = Pak::read(location); //optional this->location = locate(); pak = new vfs::directory; if(bios) pak->append("bios.rom", bios); - return true; + return successful; } auto MasterSystem::save(string location) -> bool { diff --git a/mia/system/mega-32x.cpp b/mia/system/mega-32x.cpp index 1299f4bbea..f42cf9f086 100644 --- a/mia/system/mega-32x.cpp +++ b/mia/system/mega-32x.cpp @@ -1,17 +1,17 @@ struct Mega32X : System { auto name() -> string override { return "Mega 32X"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Mega32X::load(string location) -> bool { +auto Mega32X::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("tmss.rom", Resource::MegaDrive::TMSS); pak->append("vector.rom", Resource::Mega32X::Vector); pak->append("sh2.boot.mrom", Resource::Mega32X::SH2BootM); pak->append("sh2.boot.srom", Resource::Mega32X::SH2BootS); - return true; + return successful; } auto Mega32X::save(string location) -> bool { diff --git a/mia/system/mega-cd-32x.cpp b/mia/system/mega-cd-32x.cpp index a6f7619ae0..2428f1a9b7 100644 --- a/mia/system/mega-cd-32x.cpp +++ b/mia/system/mega-cd-32x.cpp @@ -1,6 +1,6 @@ struct MegaCD32X : System { auto name() -> string override { return "Mega CD 32X"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; static constexpr u8 bram[64] = { @@ -11,9 +11,9 @@ struct MegaCD32X : System { }; }; -auto MegaCD32X::load(string location) -> bool { +auto MegaCD32X::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; @@ -32,7 +32,7 @@ auto MegaCD32X::load(string location) -> bool { Pak::load("backup.ram", ".bram"); - return true; + return successful; } auto MegaCD32X::save(string location) -> bool { diff --git a/mia/system/mega-cd.cpp b/mia/system/mega-cd.cpp index d672aecbde..0d78e824fb 100644 --- a/mia/system/mega-cd.cpp +++ b/mia/system/mega-cd.cpp @@ -1,6 +1,6 @@ struct MegaCD : System { auto name() -> string override { return "Mega CD"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; static constexpr u8 bram[64] = { @@ -11,9 +11,9 @@ struct MegaCD : System { }; }; -auto MegaCD::load(string location) -> bool { +auto MegaCD::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; @@ -29,7 +29,7 @@ auto MegaCD::load(string location) -> bool { Pak::load("backup.ram", ".bram"); - return true; + return successful; } auto MegaCD::save(string location) -> bool { diff --git a/mia/system/mega-drive.cpp b/mia/system/mega-drive.cpp index 601a470d48..0d2f5365f4 100644 --- a/mia/system/mega-drive.cpp +++ b/mia/system/mega-drive.cpp @@ -1,14 +1,14 @@ struct MegaDrive : System { auto name() -> string override { return "Mega Drive"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto MegaDrive::load(string location) -> bool { +auto MegaDrive::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("tmss.rom", Resource::MegaDrive::TMSS); - return true; + return successful; } auto MegaDrive::save(string location) -> bool { diff --git a/mia/system/msx.cpp b/mia/system/msx.cpp index 1c3a98cc0a..483bfc0645 100644 --- a/mia/system/msx.cpp +++ b/mia/system/msx.cpp @@ -1,17 +1,17 @@ struct MSX : System { auto name() -> string override { return "MSX"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto MSX::load(string location) -> bool { +auto MSX::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; pak->append("bios.rom", bios); - return true; + return successful; } auto MSX::save(string location) -> bool { diff --git a/mia/system/myvision.cpp b/mia/system/myvision.cpp index 123259624f..7c04ce665d 100644 --- a/mia/system/myvision.cpp +++ b/mia/system/myvision.cpp @@ -1,15 +1,15 @@ struct MyVision : System { auto name() -> string override { return "MyVision"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto MyVision::load(string location) -> bool { +auto MyVision::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; - return true; + return successful; } auto MyVision::save(string location) -> bool { diff --git a/mia/system/neo-geo-aes.cpp b/mia/system/neo-geo-aes.cpp index 4e595b83c7..60e483f847 100644 --- a/mia/system/neo-geo-aes.cpp +++ b/mia/system/neo-geo-aes.cpp @@ -1,11 +1,11 @@ struct NeoGeoAES : System { auto name() -> string override { return "Neo Geo AES"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto endianSwap(vector&) -> void; }; -auto NeoGeoAES::load(string location) -> bool { +auto NeoGeoAES::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; @@ -26,9 +26,9 @@ auto NeoGeoAES::load(string location) -> bool { if (bios) pak->append("bios.rom", bios); } - if(pak->count() != 1) return false; + if(pak->count() != 1) return romNotFound; - return true; + return successful; } auto NeoGeoAES::save(string location) -> bool { diff --git a/mia/system/neo-geo-mvs.cpp b/mia/system/neo-geo-mvs.cpp index e42d056bce..1c5ac99969 100644 --- a/mia/system/neo-geo-mvs.cpp +++ b/mia/system/neo-geo-mvs.cpp @@ -1,11 +1,11 @@ struct NeoGeoMVS : System { auto name() -> string override { return "Neo Geo MVS"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; auto endianSwap(vector&) -> void; }; -auto NeoGeoMVS::load(string location) -> bool { +auto NeoGeoMVS::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; @@ -26,9 +26,9 @@ auto NeoGeoMVS::load(string location) -> bool { if(bios) pak->append("bios.rom", bios); } - if(pak->count() != 1) return false; + if(pak->count() != 1) return romNotFound; - return true; + return successful; } auto NeoGeoMVS::save(string location) -> bool { diff --git a/mia/system/neo-geo-pocket-color.cpp b/mia/system/neo-geo-pocket-color.cpp index f65c895c5c..d9e2ab37eb 100644 --- a/mia/system/neo-geo-pocket-color.cpp +++ b/mia/system/neo-geo-pocket-color.cpp @@ -1,12 +1,12 @@ struct NeoGeoPocketColor : System { auto name() -> string override { return "Neo Geo Pocket Color"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto NeoGeoPocketColor::load(string location) -> bool { +auto NeoGeoPocketColor::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; @@ -17,7 +17,7 @@ auto NeoGeoPocketColor::load(string location) -> bool { Pak::load("cpu.ram", ".cram"); Pak::load("apu.ram", ".aram"); - return true; + return successful; } auto NeoGeoPocketColor::save(string location) -> bool { diff --git a/mia/system/neo-geo-pocket.cpp b/mia/system/neo-geo-pocket.cpp index 08885a8a54..6a3d363c2a 100644 --- a/mia/system/neo-geo-pocket.cpp +++ b/mia/system/neo-geo-pocket.cpp @@ -1,12 +1,12 @@ struct NeoGeoPocket : System { auto name() -> string override { return "Neo Geo Pocket"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto NeoGeoPocket::load(string location) -> bool { +auto NeoGeoPocket::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; @@ -17,7 +17,7 @@ auto NeoGeoPocket::load(string location) -> bool { Pak::load("cpu.ram", ".cram"); Pak::load("apu.ram", ".aram"); - return true; + return successful; } auto NeoGeoPocket::save(string location) -> bool { diff --git a/mia/system/nintendo-64.cpp b/mia/system/nintendo-64.cpp index dba2540d4a..ce10088e34 100644 --- a/mia/system/nintendo-64.cpp +++ b/mia/system/nintendo-64.cpp @@ -1,16 +1,16 @@ struct Nintendo64 : System { auto name() -> string override { return "Nintendo 64"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Nintendo64::load(string location) -> bool { +auto Nintendo64::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("pif.ntsc.rom", Resource::Nintendo64::PIFNTSC); pak->append("pif.pal.rom", Resource::Nintendo64::PIFPAL ); pak->append("pif.sm5.rom", Resource::Nintendo64::PIFSM5 ); - return true; + return successful; } auto Nintendo64::save(string location) -> bool { diff --git a/mia/system/nintendo-64dd.cpp b/mia/system/nintendo-64dd.cpp index 686b465dfd..029fbfcad5 100644 --- a/mia/system/nintendo-64dd.cpp +++ b/mia/system/nintendo-64dd.cpp @@ -1,12 +1,12 @@ struct Nintendo64DD : System { auto name() -> string override { return "Nintendo 64DD"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Nintendo64DD::load(string location) -> bool { +auto Nintendo64DD::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; @@ -21,7 +21,7 @@ auto Nintendo64DD::load(string location) -> bool { } Pak::load("time.rtc", ".rtc"); - return true; + return successful; } auto Nintendo64DD::save(string location) -> bool { diff --git a/mia/system/pc-engine.cpp b/mia/system/pc-engine.cpp index ffe3ef01ab..625cac252b 100644 --- a/mia/system/pc-engine.cpp +++ b/mia/system/pc-engine.cpp @@ -1,17 +1,17 @@ struct PCEngine : System { auto name() -> string override { return "PC Engine"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto PCEngine::load(string location) -> bool { +auto PCEngine::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("backup.ram", 2_KiB); Pak::load("backup.ram", ".bram"); - return true; + return successful; } auto PCEngine::save(string location) -> bool { diff --git a/mia/system/playstation.cpp b/mia/system/playstation.cpp index 2377b7baef..af477814ee 100644 --- a/mia/system/playstation.cpp +++ b/mia/system/playstation.cpp @@ -1,18 +1,18 @@ struct PlayStation : System { auto name() -> string override { return "PlayStation"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto PlayStation::load(string location) -> bool { +auto PlayStation::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; pak->append("bios.rom", bios); - return true; + return successful; } auto PlayStation::save(string location) -> bool { diff --git a/mia/system/pocket-challenge-v2.cpp b/mia/system/pocket-challenge-v2.cpp index 56d015fd6e..df8413a285 100644 --- a/mia/system/pocket-challenge-v2.cpp +++ b/mia/system/pocket-challenge-v2.cpp @@ -1,15 +1,15 @@ struct PocketChallengeV2 : System { auto name() -> string override { return "Pocket Challenge V2"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto PocketChallengeV2::load(string location) -> bool { +auto PocketChallengeV2::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("boot.rom", Resource::PocketChallengeV2::Boot); - return true; + return successful; } auto PocketChallengeV2::save(string location) -> bool { diff --git a/mia/system/saturn.cpp b/mia/system/saturn.cpp index 3a69885b52..1f0ef5fabc 100644 --- a/mia/system/saturn.cpp +++ b/mia/system/saturn.cpp @@ -1,18 +1,18 @@ struct Saturn : System { auto name() -> string override { return "Saturn"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto Saturn::load(string location) -> bool { +auto Saturn::load(string location) -> LoadResult { auto bios = Pak::read(location); - if(!bios) return false; + if(!bios) return romNotFound; this->location = locate(); pak = new vfs::directory; pak->append("bios.rom", bios); - return true; + return successful; } auto Saturn::save(string location) -> bool { diff --git a/mia/system/sc-3000.cpp b/mia/system/sc-3000.cpp index 5430067710..d0bd9106e2 100644 --- a/mia/system/sc-3000.cpp +++ b/mia/system/sc-3000.cpp @@ -1,13 +1,13 @@ struct SC3000 : System { auto name() -> string override { return "SC-3000"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto SC3000::load(string location) -> bool { +auto SC3000::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; - return true; + return successful; } auto SC3000::save(string location) -> bool { diff --git a/mia/system/sg-1000.cpp b/mia/system/sg-1000.cpp index 31ac9214ee..af74c87995 100644 --- a/mia/system/sg-1000.cpp +++ b/mia/system/sg-1000.cpp @@ -1,13 +1,13 @@ struct SG1000 : System { auto name() -> string override { return "SG-1000"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto SG1000::load(string location) -> bool { +auto SG1000::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; - return true; + return successful; } auto SG1000::save(string location) -> bool { diff --git a/mia/system/super-famicom.cpp b/mia/system/super-famicom.cpp index 8f97172261..df8d18f1a5 100644 --- a/mia/system/super-famicom.cpp +++ b/mia/system/super-famicom.cpp @@ -1,15 +1,17 @@ struct SuperFamicom : System { auto name() -> string override { return "Super Famicom"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto SuperFamicom::load(string location) -> bool { +auto SuperFamicom::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("ipl.rom", Resource::SuperFamicom::IPLROM); - pak->append("boards.bml", file::read(mia::locate("Database/Super Famicom Boards.bml"))); - return true; + auto romLocation = mia::locate("Database/Super Famicom Boards.bml"); + if(!romLocation) return { databaseNotFound, "Super Famicom Boards.bml" }; + pak->append("boards.bml", file::read(romLocation)); + return successful; } auto SuperFamicom::save(string location) -> bool { diff --git a/mia/system/supergrafx.cpp b/mia/system/supergrafx.cpp index 0f44eba5b6..a944fce04d 100644 --- a/mia/system/supergrafx.cpp +++ b/mia/system/supergrafx.cpp @@ -1,17 +1,17 @@ struct SuperGrafx : System { auto name() -> string override { return "SuperGrafx"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto SuperGrafx::load(string location) -> bool { +auto SuperGrafx::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("backup.ram", 2_KiB); Pak::load("backup.ram", ".bram"); - return true; + return successful; } auto SuperGrafx::save(string location) -> bool { diff --git a/mia/system/wonderswan-color.cpp b/mia/system/wonderswan-color.cpp index a76966208d..882fe20ed3 100644 --- a/mia/system/wonderswan-color.cpp +++ b/mia/system/wonderswan-color.cpp @@ -1,10 +1,10 @@ struct WonderSwanColor : System { auto name() -> string override { return "WonderSwan Color"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto WonderSwanColor::load(string location) -> bool { +auto WonderSwanColor::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("boot.rom", Resource::WonderSwanColor::Boot); @@ -12,7 +12,7 @@ auto WonderSwanColor::load(string location) -> bool { Pak::load("save.eeprom", ".eeprom"); - return true; + return successful; } auto WonderSwanColor::save(string location) -> bool { diff --git a/mia/system/wonderswan.cpp b/mia/system/wonderswan.cpp index 4dc0707be9..2669791d43 100644 --- a/mia/system/wonderswan.cpp +++ b/mia/system/wonderswan.cpp @@ -1,10 +1,10 @@ struct WonderSwan : System { auto name() -> string override { return "WonderSwan"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto WonderSwan::load(string location) -> bool { +auto WonderSwan::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("boot.rom", Resource::WonderSwan::Boot); @@ -12,7 +12,7 @@ auto WonderSwan::load(string location) -> bool { Pak::load("save.eeprom", ".eeprom"); - return true; + return successful; } auto WonderSwan::save(string location) -> bool { diff --git a/mia/system/zx-spectrum-128.cpp b/mia/system/zx-spectrum-128.cpp index 099846ae8e..69cd816a5d 100644 --- a/mia/system/zx-spectrum-128.cpp +++ b/mia/system/zx-spectrum-128.cpp @@ -1,15 +1,15 @@ struct ZXSpectrum128 : System { auto name() -> string override { return "ZX Spectrum 128"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto ZXSpectrum128::load(string location) -> bool { +auto ZXSpectrum128::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("bios.rom", Resource::ZXSpectrum128::BIOS); pak->append("sub.rom", Resource::ZXSpectrum128::Sub); - return true; + return successful; } auto ZXSpectrum128::save(string location) -> bool { diff --git a/mia/system/zx-spectrum.cpp b/mia/system/zx-spectrum.cpp index c28f18d672..ea14b069ec 100644 --- a/mia/system/zx-spectrum.cpp +++ b/mia/system/zx-spectrum.cpp @@ -1,14 +1,14 @@ struct ZXSpectrum : System { auto name() -> string override { return "ZX Spectrum"; } - auto load(string location) -> bool override; + auto load(string location) -> LoadResult override; auto save(string location) -> bool override; }; -auto ZXSpectrum::load(string location) -> bool { +auto ZXSpectrum::load(string location) -> LoadResult { this->location = locate(); pak = new vfs::directory; pak->append("bios.rom", Resource::ZXSpectrum::BIOS); - return true; + return successful; } auto ZXSpectrum::save(string location) -> bool {