From 2432151bf8364eb1f365a45f10bd1d18ff4a26c6 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 22 Jul 2019 21:14:21 -0400 Subject: [PATCH] Puts machine name into ROMMachine::ROM. Also switches to idiomatic exit codes. --- Machines/AmstradCPC/AmstradCPC.cpp | 9 ++++--- Machines/Apple/AppleII/AppleII.cpp | 19 +++++++------- Machines/Apple/AppleII/DiskIICard.cpp | 5 ++-- Machines/Apple/Macintosh/Macintosh.cpp | 9 ++++--- Machines/ColecoVision/ColecoVision.cpp | 3 +-- .../Commodore/1540/Implementation/C1540.cpp | 2 +- Machines/Commodore/Vic-20/Vic20.cpp | 25 +++++++++--------- Machines/Electron/Electron.cpp | 13 +++++----- Machines/MSX/MSX.cpp | 13 +++++----- Machines/MasterSystem/MasterSystem.cpp | 2 +- Machines/Oric/Oric.cpp | 17 ++++++------ Machines/ROMMachine.hpp | 26 +++++++++++-------- Machines/ZX8081/ZX8081.cpp | 4 +-- .../Mac/Clock Signal/Machine/CSROMFetcher.mm | 4 +-- OSBindings/SDL/main.cpp | 25 +++++++++--------- 15 files changed, 92 insertions(+), 84 deletions(-) diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index 05bf98f3a..c1ad3173f 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -781,8 +781,9 @@ template class ConcreteMachine: ay_.ay().set_port_handler(&key_state_); // construct the list of necessary ROMs + const std::string machine_name = "AmstradCPC"; std::vector required_roms = { - ROMMachine::ROM("the Amstrad Disk Operating System", "amsdos.rom", 16*1024, 0x1fe22ecd) + ROMMachine::ROM(machine_name, "the Amstrad Disk Operating System", "amsdos.rom", 16*1024, 0x1fe22ecd) }; std::string model_number; uint32_t crcs[2]; @@ -806,11 +807,11 @@ template class ConcreteMachine: crcs[1] = 0x32fee492; break; } - required_roms.emplace_back("the CPC " + model_number + "firmware", "os" + model_number + ".rom", 16*1024, crcs[0]); - required_roms.emplace_back("the CPC " + model_number + "BASIC ROM", "basic" + model_number + ".rom", 16*1024, crcs[1]); + required_roms.emplace_back(machine_name, "the CPC " + model_number + "firmware", "os" + model_number + ".rom", 16*1024, crcs[0]); + required_roms.emplace_back(machine_name, "the CPC " + model_number + "BASIC ROM", "basic" + model_number + ".rom", 16*1024, crcs[1]); // fetch and verify the ROMs - const auto roms = rom_fetcher("AmstradCPC", required_roms); + const auto roms = rom_fetcher(required_roms); for(std::size_t index = 0; index < roms.size(); ++index) { auto &data = roms[index]; diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 67435b4c5..8e04458d5 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -347,29 +347,30 @@ template class ConcreteMachine: // Pick the required ROMs. using Target = Analyser::Static::AppleII::Target; + const std::string machine_name = "AppleII"; std::vector rom_descriptions; size_t rom_size = 12*1024; switch(target.model) { default: - rom_descriptions.emplace_back("the basic Apple II character ROM", "apple2-character.rom", 2*1024, 0x64f415c6); - rom_descriptions.emplace_back("the original Apple II ROM", "apple2o.rom", 12*1024, 0xba210588); + rom_descriptions.emplace_back(machine_name, "the basic Apple II character ROM", "apple2-character.rom", 2*1024, 0x64f415c6); + rom_descriptions.emplace_back(machine_name, "the original Apple II ROM", "apple2o.rom", 12*1024, 0xba210588); break; case Target::Model::IIplus: - rom_descriptions.emplace_back("the basic Apple II character ROM", "apple2-character.rom", 2*1024, 0x64f415c6); - rom_descriptions.emplace_back("the Apple II+ ROM", "apple2.rom", 12*1024, 0xf66f9c26); + rom_descriptions.emplace_back(machine_name, "the basic Apple II character ROM", "apple2-character.rom", 2*1024, 0x64f415c6); + rom_descriptions.emplace_back(machine_name, "the Apple II+ ROM", "apple2.rom", 12*1024, 0xf66f9c26); break; case Target::Model::IIe: rom_size += 3840; - rom_descriptions.emplace_back("the Apple IIe character ROM", "apple2eu-character.rom", 4*1024, 0x816a86f1); - rom_descriptions.emplace_back("the Apple IIe ROM", "apple2eu.rom", 32*1024, 0xe12be18d); + rom_descriptions.emplace_back(machine_name, "the Apple IIe character ROM", "apple2eu-character.rom", 4*1024, 0x816a86f1); + rom_descriptions.emplace_back(machine_name, "the Apple IIe ROM", "apple2eu.rom", 32*1024, 0xe12be18d); break; case Target::Model::EnhancedIIe: rom_size += 3840; - rom_descriptions.emplace_back("the Enhanced Apple IIe character ROM", "apple2e-character.rom", 4*1024, 0x2651014d); - rom_descriptions.emplace_back("the Enhanced Apple IIe ROM", "apple2e.rom", 32*1024, 0x65989942); + rom_descriptions.emplace_back(machine_name, "the Enhanced Apple IIe character ROM", "apple2e-character.rom", 4*1024, 0x2651014d); + rom_descriptions.emplace_back(machine_name, "the Enhanced Apple IIe ROM", "apple2e.rom", 32*1024, 0x65989942); break; } - const auto roms = rom_fetcher("AppleII", rom_descriptions); + const auto roms = rom_fetcher(rom_descriptions); if(!roms[0] || !roms[1]) { throw ROMMachine::Error::MissingROMs; diff --git a/Machines/Apple/AppleII/DiskIICard.cpp b/Machines/Apple/AppleII/DiskIICard.cpp index 869770bfc..4bb530d27 100644 --- a/Machines/Apple/AppleII/DiskIICard.cpp +++ b/Machines/Apple/AppleII/DiskIICard.cpp @@ -12,10 +12,9 @@ using namespace Apple::II; DiskIICard::DiskIICard(const ROMMachine::ROMFetcher &rom_fetcher, bool is_16_sector) : diskii_(2045454) { const auto roms = rom_fetcher( - "DiskII", { - ROMMachine::ROM(is_16_sector ? "boot-16.rom" : "boot-13.rom"), - ROMMachine::ROM(is_16_sector ? "state-machine-16.rom" : "state-machine-13.rom") + {"DiskII", is_16_sector ? "boot-16.rom" : "boot-13.rom"}, + {"DiskII", is_16_sector ? "state-machine-16.rom" : "state-machine-13.rom"} }); boot_ = std::move(*roms[0]); diskii_.set_state_machine(*roms[1]); diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index 3915edadd..32f979528 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -70,6 +70,7 @@ template class ConcreteMachin // Select a ROM name and determine the proper ROM and RAM sizes // based on the machine model. using Model = Analyser::Static::Macintosh::Target::Model; + const std::string machine_name = "Macintosh"; uint32_t ram_size, rom_size; std::vector rom_descriptions; switch(model) { @@ -77,19 +78,19 @@ template class ConcreteMachin case Model::Mac128k: ram_size = 128*1024; rom_size = 64*1024; - rom_descriptions.emplace_back("the Macintosh 128k ROM", "mac128k.rom", 64*1024, 0x6d0c8a28); + rom_descriptions.emplace_back(machine_name, "the Macintosh 128k ROM", "mac128k.rom", 64*1024, 0x6d0c8a28); break; case Model::Mac512k: ram_size = 512*1024; rom_size = 64*1024; - rom_descriptions.emplace_back("the Macintosh 512k ROM", "mac512k.rom", 64*1024, 0xcf759e0d); + rom_descriptions.emplace_back(machine_name, "the Macintosh 512k ROM", "mac512k.rom", 64*1024, 0xcf759e0d); break; case Model::Mac512ke: case Model::MacPlus: { ram_size = 512*1024; rom_size = 128*1024; const std::initializer_list crc32s = { 0x4fa5b399, 0x7cacd18f, 0xb2102e8e }; - rom_descriptions.emplace_back("the Macintosh Plus ROM", "macplus.rom", 128*1024, crc32s); + rom_descriptions.emplace_back(machine_name, "the Macintosh Plus ROM", "macplus.rom", 128*1024, crc32s); } break; } ram_mask_ = (ram_size >> 1) - 1; @@ -97,7 +98,7 @@ template class ConcreteMachin video_.set_ram_mask(ram_mask_); // Grab a copy of the ROM and convert it into big-endian data. - const auto roms = rom_fetcher("Macintosh", rom_descriptions); + const auto roms = rom_fetcher(rom_descriptions); if(!roms[0]) { throw ROMMachine::Error::MissingROMs; } diff --git a/Machines/ColecoVision/ColecoVision.cpp b/Machines/ColecoVision/ColecoVision.cpp index 8ffde6ecf..d699a4016 100644 --- a/Machines/ColecoVision/ColecoVision.cpp +++ b/Machines/ColecoVision/ColecoVision.cpp @@ -131,8 +131,7 @@ class ConcreteMachine: joysticks_.emplace_back(new Joystick); const auto roms = rom_fetcher( - "ColecoVision", - { ROMMachine::ROM("the ColecoVision BIOS", "coleco.rom", 8*1024, 0x3aa93ef3) }); + { {"ColecoVision", "the ColecoVision BIOS", "coleco.rom", 8*1024, 0x3aa93ef3} }); if(!roms[0]) { throw ROMMachine::Error::MissingROMs; diff --git a/Machines/Commodore/1540/Implementation/C1540.cpp b/Machines/Commodore/1540/Implementation/C1540.cpp index d88b6f152..515dee334 100644 --- a/Machines/Commodore/1540/Implementation/C1540.cpp +++ b/Machines/Commodore/1540/Implementation/C1540.cpp @@ -52,7 +52,7 @@ MachineBase::MachineBase(Personality personality, const ROMMachine::ROMFetcher & break; } - auto roms = rom_fetcher("Commodore1540", { ROMMachine::ROM("the " + device_name + " ROM", device_name + ".bin", 16*1024, crc) }); + auto roms = rom_fetcher({ {"Commodore1540", "the " + device_name + " ROM", device_name + ".bin", 16*1024, crc} }); if(!roms[0]) { throw ROMMachine::Error::MissingROMs; } diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 342d3cdb9..84c1b05f1 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -323,31 +323,32 @@ class ConcreteMachine: // install a joystick joysticks_.emplace_back(new Joystick(*user_port_via_port_handler_, *keyboard_via_port_handler_)); - std::vector rom_names = { ROMMachine::ROM("basic.bin") }; + const std::string machine_name = "Vic20"; + std::vector rom_names = { {machine_name, "basic.bin"} }; switch(target.region) { default: - rom_names.emplace_back("characters-english.bin"); - rom_names.emplace_back("kernel-pal.bin"); + rom_names.emplace_back(machine_name, "characters-english.bin"); + rom_names.emplace_back(machine_name, "kernel-pal.bin"); break; case Analyser::Static::Commodore::Target::Region::American: - rom_names.emplace_back("characters-english.bin"); - rom_names.emplace_back("kernel-ntsc.bin"); + rom_names.emplace_back(machine_name, "characters-english.bin"); + rom_names.emplace_back(machine_name, "kernel-ntsc.bin"); break; case Analyser::Static::Commodore::Target::Region::Danish: - rom_names.emplace_back("characters-danish.bin"); - rom_names.emplace_back("kernel-danish.bin"); + rom_names.emplace_back(machine_name, "characters-danish.bin"); + rom_names.emplace_back(machine_name, "kernel-danish.bin"); break; case Analyser::Static::Commodore::Target::Region::Japanese: - rom_names.emplace_back("characters-japanese.bin"); - rom_names.emplace_back("kernel-japanese.bin"); + rom_names.emplace_back(machine_name, "characters-japanese.bin"); + rom_names.emplace_back(machine_name, "kernel-japanese.bin"); break; case Analyser::Static::Commodore::Target::Region::Swedish: - rom_names.emplace_back("characters-swedish.bin"); - rom_names.emplace_back("kernel-japanese.bin"); + rom_names.emplace_back(machine_name, "characters-swedish.bin"); + rom_names.emplace_back(machine_name, "kernel-japanese.bin"); break; } - const auto roms = rom_fetcher("Vic20", rom_names); + const auto roms = rom_fetcher(rom_names); for(const auto &rom: roms) { if(!rom) { diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 48378fb2e..f0a31815e 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -64,19 +64,20 @@ class ConcreteMachine: speaker_.set_input_rate(2000000 / SoundGenerator::clock_rate_divider); speaker_.set_high_frequency_cutoff(7000); + const std::string machine_name = "Electron"; std::vector required_roms = { - {"the Acorn BASIC II ROM", "basic.rom", 16*1024, 0x79434781}, - {"the Electron MOS ROM", "os.rom", 16*1024, 0xbf63fb1f} + {machine_name, "the Acorn BASIC II ROM", "basic.rom", 16*1024, 0x79434781}, + {machine_name, "the Electron MOS ROM", "os.rom", 16*1024, 0xbf63fb1f} }; if(target.has_adfs) { - required_roms.emplace_back("the E00 ADFS ROM, first slot", "ADFS-E00_1.rom", 16*1024, 0x51523993); - required_roms.emplace_back("the E00 ADFS ROM, second slot", "ADFS-E00_2.rom", 16*1024, 0x8d17de0e); + required_roms.emplace_back(machine_name, "the E00 ADFS ROM, first slot", "ADFS-E00_1.rom", 16*1024, 0x51523993); + required_roms.emplace_back(machine_name, "the E00 ADFS ROM, second slot", "ADFS-E00_2.rom", 16*1024, 0x8d17de0e); } const size_t dfs_rom_position = required_roms.size(); if(target.has_dfs) { - required_roms.emplace_back("the 1770 DFS ROM", "DFS-1770-2.20.rom", 16*1024, 0xf3dc9bc5); + required_roms.emplace_back(machine_name, "the 1770 DFS ROM", "DFS-1770-2.20.rom", 16*1024, 0xf3dc9bc5); } - const auto roms = rom_fetcher("Electron", required_roms); + const auto roms = rom_fetcher(required_roms); for(const auto &rom: roms) { if(!rom) { diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index e99a3e834..a4b563d01 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -173,8 +173,9 @@ class ConcreteMachine: mixer_.set_relative_volumes({0.5f, 0.1f, 0.4f}); // Install the proper TV standard and select an ideal BIOS name. + const std::string machine_name = "MSX"; std::vector required_roms = { - {"any MSX BIOS", "msx.rom", 32*1024, 0x94ee12f3} + {machine_name, "any MSX BIOS", "msx.rom", 32*1024, 0x94ee12f3} }; bool is_ntsc = true; @@ -185,7 +186,7 @@ class ConcreteMachine: // TODO: CRCs below are incomplete, at best. switch(target.region) { case Target::Region::Japan: - required_roms.emplace_back("a Japanese MSX BIOS", "msx-japanese.rom", 32*1024, 0xee229390); + required_roms.emplace_back(machine_name, "a Japanese MSX BIOS", "msx-japanese.rom", 32*1024, 0xee229390); vdp_.set_tv_standard(TI::TMS::TVStandard::NTSC); is_ntsc = true; @@ -193,7 +194,7 @@ class ConcreteMachine: date_format = 0; break; case Target::Region::USA: - required_roms.emplace_back("an American MSX BIOS", "msx-american.rom", 32*1024, 0); + required_roms.emplace_back(machine_name, "an American MSX BIOS", "msx-american.rom", 32*1024, 0); vdp_.set_tv_standard(TI::TMS::TVStandard::NTSC); is_ntsc = true; @@ -201,7 +202,7 @@ class ConcreteMachine: date_format = 1; break; case Target::Region::Europe: - required_roms.emplace_back("a European MSX BIOS", "msx-european.rom", 32*1024, 0); + required_roms.emplace_back(machine_name, "a European MSX BIOS", "msx-european.rom", 32*1024, 0); vdp_.set_tv_standard(TI::TMS::TVStandard::PAL); is_ntsc = false; @@ -215,9 +216,9 @@ class ConcreteMachine: size_t disk_index = 0; if(target.has_disk_drive) { disk_index = required_roms.size(); - required_roms.emplace_back("the MSX-DOS ROM", "disk.rom", 16*1024, 0x721f61df); + required_roms.emplace_back(machine_name, "the MSX-DOS ROM", "disk.rom", 16*1024, 0x721f61df); } - const auto roms = rom_fetcher("MSX", required_roms); + const auto roms = rom_fetcher(required_roms); if((!roms[0] && !roms[1]) || (target.has_disk_drive && !roms[2])) { throw ROMMachine::Error::MissingROMs; diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp index abde5b954..05b37493e 100644 --- a/Machines/MasterSystem/MasterSystem.cpp +++ b/Machines/MasterSystem/MasterSystem.cpp @@ -134,7 +134,7 @@ class ConcreteMachine: if(has_bios()) { // TODO: there's probably a million other versions of the Master System BIOS; try to build a // CRC32 catalogue of those. - const auto roms = rom_fetcher("MasterSystem", { {"the Master System BIOS", "bios.sms", 8*1024, 0x0072ed54} }); + const auto roms = rom_fetcher({ {"MasterSystem", "the Master System BIOS", "bios.sms", 8*1024, 0x0072ed54} }); if(!roms[0]) { // No BIOS found; attempt to boot as though it has already disabled itself. memory_control_ |= 0x08; diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 5382dc710..37bf52b4f 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -228,19 +228,20 @@ template class Co diskii_.set_clocking_hint_observer(this); } - std::vector rom_names = { {"colour.rom"} }; + const std::string machine_name = "Oric"; + std::vector rom_names = { {machine_name, "colour.rom"} }; switch(target.rom) { - case Analyser::Static::Oric::Target::ROM::BASIC10: rom_names.emplace_back("basic10.rom"); break; - case Analyser::Static::Oric::Target::ROM::BASIC11: rom_names.emplace_back("basic11.rom"); break; - case Analyser::Static::Oric::Target::ROM::Pravetz: rom_names.emplace_back("pravetz.rom"); break; + case Analyser::Static::Oric::Target::ROM::BASIC10: rom_names.emplace_back(machine_name, "basic10.rom"); break; + case Analyser::Static::Oric::Target::ROM::BASIC11: rom_names.emplace_back(machine_name, "basic11.rom"); break; + case Analyser::Static::Oric::Target::ROM::Pravetz: rom_names.emplace_back(machine_name, "pravetz.rom"); break; } switch(disk_interface) { default: break; - case Analyser::Static::Oric::Target::DiskInterface::Microdisc: rom_names.emplace_back("microdisc.rom"); break; - case Analyser::Static::Oric::Target::DiskInterface::Pravetz: rom_names.emplace_back("8dos.rom"); break; + case Analyser::Static::Oric::Target::DiskInterface::Microdisc: rom_names.emplace_back(machine_name, "microdisc.rom"); break; + case Analyser::Static::Oric::Target::DiskInterface::Pravetz: rom_names.emplace_back(machine_name, "8dos.rom"); break; } - const auto roms = rom_fetcher("Oric", rom_names); + const auto roms = rom_fetcher(rom_names); for(std::size_t index = 0; index < roms.size(); ++index) { if(!roms[index]) { @@ -261,7 +262,7 @@ template class Co pravetz_rom_ = std::move(*roms[2]); pravetz_rom_.resize(512); - auto state_machine_rom = rom_fetcher("DiskII", { ROMMachine::ROM("state-machine-16.rom") }); + auto state_machine_rom = rom_fetcher({ {"DiskII", "state-machine-16.rom"} }); if(!state_machine_rom[0]) { throw ROMMachine::Error::MissingROMs; } diff --git a/Machines/ROMMachine.hpp b/Machines/ROMMachine.hpp index 3b47fb41a..071eb68f4 100644 --- a/Machines/ROMMachine.hpp +++ b/Machines/ROMMachine.hpp @@ -21,7 +21,11 @@ namespace ROMMachine { system software that is an inherent part of a machine. */ struct ROM { - /// A descriptive name for this ROM, e.g. "Electron MOS 1.0". + /// The machine with which this ROM is associated, in a form that is safe for using as + /// part of a file name. + std::string machine_name; + /// A descriptive name for this ROM, suitable for use in a bullet-point list, a bracket + /// clause, etc, e.g. "the Electron MOS 1.0". std::string descriptive_name; /// An idiomatic file name for this ROM, e.g. "os10.rom". std::string file_name; @@ -33,24 +37,24 @@ struct ROM { std::vector crc32s; /// This is a temporary constructor provided for transitional purposes. - ROM(std::string file_name) : - file_name(file_name) {} + ROM(std::string machine_name, std::string file_name) : + machine_name(machine_name), file_name(file_name) {} - ROM(std::string descriptive_name, std::string file_name, size_t size, uint32_t crc32) : - descriptive_name(descriptive_name), file_name(file_name), size(size), crc32s({crc32}) {} - ROM(std::string descriptive_name, std::string file_name, size_t size, std::initializer_list crc32s) : - descriptive_name(descriptive_name), file_name(file_name), size(size), crc32s(crc32s) {} + ROM(std::string machine_name, std::string descriptive_name, std::string file_name, size_t size, uint32_t crc32) : + machine_name(machine_name), descriptive_name(descriptive_name), file_name(file_name), size(size), crc32s({crc32}) {} + ROM(std::string machine_name, std::string descriptive_name, std::string file_name, size_t size, std::initializer_list crc32s) : + machine_name(machine_name), descriptive_name(descriptive_name), file_name(file_name), size(size), crc32s(crc32s) {} }; /*! Defines the signature for a function that must be supplied by the host environment in order to give machines a route for fetching any system ROMs they might need. - The caller will supply the idiomatic name of the machine plus a vector of the names of ROM files that it expects - to be present. The recevier should return a vector of unique_ptrs that either contain the contents of the - ROM from @c names that corresponds by index, or else are the nullptr + The caller will supply a vector of the names of ROM files that it would like to inspect. The recevier should + return a vector of unique_ptrs that either contain the contents of the ROM from @c names that corresponds by + index, or else are @c nullptr. */ -typedef std::function>>(const std::string &machine, const std::vector &roms)> ROMFetcher; +typedef std::function>>(const std::vector &roms)> ROMFetcher; enum class Error { MissingROMs diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index fcf995060..024601e41 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -78,8 +78,8 @@ template class ConcreteMachine: const bool use_zx81_rom = target.is_ZX81 || target.ZX80_uses_ZX81_ROM; const auto roms = use_zx81_rom ? - rom_fetcher("ZX8081", { {"the ZX81 ROM", "zx81.rom", 8 * 1024, 0x4b1dd6eb} }) : - rom_fetcher("ZX8081", { {"the ZX80 ROM", "zx80.rom", 4 * 1024, 0x4c7fc597} }); + rom_fetcher({ {"ZX8081", "the ZX81 BASIC ROM", "zx81.rom", 8 * 1024, 0x4b1dd6eb} }) : + rom_fetcher({ {"ZX8081", "the ZX80 BASIC ROM", "zx80.rom", 4 * 1024, 0x4c7fc597} }); if(!roms[0]) throw ROMMachine::Error::MissingROMs; diff --git a/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm b/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm index 9345040c0..474a36b41 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm @@ -15,13 +15,13 @@ #include ROMMachine::ROMFetcher CSROMFetcher(std::vector *missing_roms) { - return [missing_roms] (const std::string &machine, const std::vector &roms) -> std::vector>> { - NSString *const subdirectory = [@"ROMImages/" stringByAppendingString:[NSString stringWithUTF8String:machine.c_str()]]; + return [missing_roms] (const std::vector &roms) -> std::vector>> { NSArray *const supportURLs = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]; std::vector>> results; for(const auto &rom: roms) { NSData *fileData; + NSString *const subdirectory = [@"ROMImages/" stringByAppendingString:[NSString stringWithUTF8String:rom.machine_name.c_str()]]; // Check for this file first within the application support directories. for(NSURL *supportURL in supportURLs) { diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 301f5ccb5..ffa356b30 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -339,21 +340,21 @@ int main(int argc, char *argv[]) { } std::cout << std::endl; } - return 0; + return EXIT_SUCCESS; } // Perform a sanity check on arguments. if(arguments.file_name.empty()) { std::cerr << "Usage: " << final_path_component(argv[0]) << usage_suffix << std::endl; std::cerr << "Use --help to learn more about available options." << std::endl; - return -1; + return EXIT_FAILURE; } // Determine the machine for the supplied file. Analyser::Static::TargetList targets = Analyser::Static::GetTargets(arguments.file_name); if(targets.empty()) { std::cerr << "Cannot open " << arguments.file_name << "; no target machine found" << std::endl; - return -1; + return EXIT_FAILURE; } Concurrency::BestEffortUpdater updater; @@ -366,11 +367,9 @@ int main(int argc, char *argv[]) { // /usr/share/CLK/[system]; or // [user-supplied path]/[system] std::vector requested_roms; - std::string machine_name; - ROMMachine::ROMFetcher rom_fetcher = [&requested_roms, &machine_name, &arguments] - (const std::string &machine, const std::vector &roms) -> std::vector>> { + ROMMachine::ROMFetcher rom_fetcher = [&requested_roms, &arguments] + (const std::vector &roms) -> std::vector>> { requested_roms.insert(requested_roms.end(), roms.begin(), roms.end()); - machine_name = machine; std::vector paths = { "/usr/local/share/CLK/", @@ -389,7 +388,7 @@ int main(int argc, char *argv[]) { for(const auto &rom: roms) { FILE *file = nullptr; for(const auto &path: paths) { - std::string local_path = path + machine + "/" + rom.file_name; + std::string local_path = path + rom.machine_name + "/" + rom.file_name; file = std::fopen(local_path.c_str(), "rb"); if(file) break; } @@ -426,7 +425,7 @@ int main(int argc, char *argv[]) { std::cerr << "Could not find system ROMs; please install to /usr/local/share/CLK/ or /usr/share/CLK/, or provide a --rompath." << std::endl; std::cerr << "One or more of the following was needed but not found:" << std::endl; for(const auto &rom: requested_roms) { - std::cerr << machine_name << '/' << rom.file_name; + std::cerr << rom.machine_name << '/' << rom.file_name; if(!rom.descriptive_name.empty()) { std::cerr << " (" << rom.descriptive_name << ")"; } @@ -435,7 +434,7 @@ int main(int argc, char *argv[]) { break; } - return -1; + return EXIT_FAILURE; } best_effort_updater_delegate.machine = machine.get(); @@ -445,7 +444,7 @@ int main(int argc, char *argv[]) { // Attempt to set up video and audio. if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { std::cerr << "SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl; - return -1; + return EXIT_FAILURE; } // Ask for no depth buffer, a core profile and vsync-aligned rendering. @@ -467,7 +466,7 @@ int main(int argc, char *argv[]) { if(!window || !gl_context) { std::cerr << "Could not create " << (window ? "OpenGL context" : "window"); std::cerr << "; reported error: \"" << SDL_GetError() << "\"" << std::endl; - return -1; + return EXIT_FAILURE; } SDL_GL_MakeCurrent(window, gl_context); @@ -820,5 +819,5 @@ int main(int argc, char *argv[]) { SDL_DestroyWindow( window ); SDL_Quit(); - return 0; + return EXIT_SUCCESS; }