mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-26 09:29:45 +00:00
Puts machine name into ROMMachine::ROM.
Also switches to idiomatic exit codes.
This commit is contained in:
parent
2129bfc570
commit
2432151bf8
@ -781,8 +781,9 @@ template <bool has_fdc> class ConcreteMachine:
|
||||
ay_.ay().set_port_handler(&key_state_);
|
||||
|
||||
// construct the list of necessary ROMs
|
||||
const std::string machine_name = "AmstradCPC";
|
||||
std::vector<ROMMachine::ROM> 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 <bool has_fdc> 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];
|
||||
|
@ -347,29 +347,30 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
|
||||
|
||||
// Pick the required ROMs.
|
||||
using Target = Analyser::Static::AppleII::Target;
|
||||
const std::string machine_name = "AppleII";
|
||||
std::vector<ROMMachine::ROM> 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;
|
||||
|
@ -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]);
|
||||
|
@ -70,6 +70,7 @@ template <Analyser::Static::Macintosh::Target::Model model> 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<ROMMachine::ROM> rom_descriptions;
|
||||
switch(model) {
|
||||
@ -77,19 +78,19 @@ template <Analyser::Static::Macintosh::Target::Model model> 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<uint32_t> 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 <Analyser::Static::Macintosh::Target::Model model> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<ROMMachine::ROM> rom_names = { ROMMachine::ROM("basic.bin") };
|
||||
const std::string machine_name = "Vic20";
|
||||
std::vector<ROMMachine::ROM> 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) {
|
||||
|
@ -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<ROMMachine::ROM> 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) {
|
||||
|
@ -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<ROMMachine::ROM> 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;
|
||||
|
@ -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;
|
||||
|
@ -228,19 +228,20 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
|
||||
diskii_.set_clocking_hint_observer(this);
|
||||
}
|
||||
|
||||
std::vector<ROMMachine::ROM> rom_names = { {"colour.rom"} };
|
||||
const std::string machine_name = "Oric";
|
||||
std::vector<ROMMachine::ROM> 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 <Analyser::Static::Oric::Target::DiskInterface disk_interface> 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;
|
||||
}
|
||||
|
@ -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<uint32_t> 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<uint32_t> 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<uint32_t> 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<std::vector<std::unique_ptr<std::vector<uint8_t>>>(const std::string &machine, const std::vector<ROM> &roms)> ROMFetcher;
|
||||
typedef std::function<std::vector<std::unique_ptr<std::vector<uint8_t>>>(const std::vector<ROM> &roms)> ROMFetcher;
|
||||
|
||||
enum class Error {
|
||||
MissingROMs
|
||||
|
@ -78,8 +78,8 @@ template<bool is_zx81> 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;
|
||||
|
||||
|
@ -15,13 +15,13 @@
|
||||
#include <string>
|
||||
|
||||
ROMMachine::ROMFetcher CSROMFetcher(std::vector<ROMMachine::ROM> *missing_roms) {
|
||||
return [missing_roms] (const std::string &machine, const std::vector<ROMMachine::ROM> &roms) -> std::vector<std::unique_ptr<std::vector<std::uint8_t>>> {
|
||||
NSString *const subdirectory = [@"ROMImages/" stringByAppendingString:[NSString stringWithUTF8String:machine.c_str()]];
|
||||
return [missing_roms] (const std::vector<ROMMachine::ROM> &roms) -> std::vector<std::unique_ptr<std::vector<std::uint8_t>>> {
|
||||
NSArray<NSURL *> *const supportURLs = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
|
||||
|
||||
std::vector<std::unique_ptr<std::vector<std::uint8_t>>> 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) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@ -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<ROMMachine::ROM> requested_roms;
|
||||
std::string machine_name;
|
||||
ROMMachine::ROMFetcher rom_fetcher = [&requested_roms, &machine_name, &arguments]
|
||||
(const std::string &machine, const std::vector<ROMMachine::ROM> &roms) -> std::vector<std::unique_ptr<std::vector<uint8_t>>> {
|
||||
ROMMachine::ROMFetcher rom_fetcher = [&requested_roms, &arguments]
|
||||
(const std::vector<ROMMachine::ROM> &roms) -> std::vector<std::unique_ptr<std::vector<uint8_t>>> {
|
||||
requested_roms.insert(requested_roms.end(), roms.begin(), roms.end());
|
||||
machine_name = machine;
|
||||
|
||||
std::vector<std::string> 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user