1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-11 08:30:55 +00:00

With large swathes of implementation missing, compiles.

This commit is contained in:
Thomas Harte 2021-06-03 22:39:18 -04:00
parent f9954619d4
commit f05cdd5e34
3 changed files with 52 additions and 22 deletions

View File

@ -8,20 +8,23 @@
#include "ROMCatalogue.hpp"
#include <algorithm>
#include <cassert>
using namespace ROM;
Request::Request(Name name, bool optional) :
node.name(name), node.is_optional(optional) {}
Request::Request() {}
Request::Request(Name name, bool optional) {
node.name = name;
node.is_optional = optional;
}
Request Request::operator &&(const Request &rhs) {
(void)rhs;
return *this;
}
Request Request::operator ||(const Request &rhs) {
(void)rhs;
return *this;
}
@ -31,12 +34,12 @@ bool Request::validate(const Map &) const {
}
std::vector<ROM::Description> Request::all_descriptions() const {
std::vector<Description>() result;
std::vector<Description> result;
node.add_descriptions(result);
return result;
}
void Request::Node::add_descriptions(std::vector<Description> &result) {
void Request::Node::add_descriptions(std::vector<Description> &result) const {
if(type == Type::One) {
result.push_back(name);
return;
@ -47,40 +50,53 @@ void Request::Node::add_descriptions(std::vector<Description> &result) {
}
}
std::optional<Description> Description::from_crc(uint32_t crc32) {
for(int name = 1; name <= SpectrumPlus3; name++) {
const Description candidate = Description(ROM::Name(name));
const auto found_crc = std::find(candidate.crc32s.begin(), candidate.crc32s.end(), crc32);
if(found_crc != candidate.crc32s.end()) {
return candidate;
}
}
return std::nullopt;
}
Description::Description(Name name) {
switch(name) {
default: assert(false); break;
case Name::AMSDOS:
*this = Request("AmstradCPC", "the Amstrad Disk Operating System", "amsdos.rom", 16*1024, 0x1fe22ecdu);
*this = Description(name, "AmstradCPC", "the Amstrad Disk Operating System", "amsdos.rom", 16*1024, 0x1fe22ecdu);
break;
case Name::CPC464Firmware:
*this = Request("AmstradCPC", "the CPC 464 firmware", "os464.rom", 16*1024, 0x815752dfu);
*this = Description(name, "AmstradCPC", "the CPC 464 firmware", "os464.rom", 16*1024, 0x815752dfu);
break;
case Name::CPC464BASIC:
*this = Request("AmstradCPC", "the CPC 464 BASIC ROM", "basic464.rom", 16*1024, 0x7d9a3bacu);
*this = Description(name, "AmstradCPC", "the CPC 464 BASIC ROM", "basic464.rom", 16*1024, 0x7d9a3bacu);
break;
case Name::CPC664Firmware:
*this = Request("AmstradCPC", "the CPC 664 firmware", "os664.rom", 16*1024, 0x3f5a6dc4u);
*this = Description(name, "AmstradCPC", "the CPC 664 firmware", "os664.rom", 16*1024, 0x3f5a6dc4u);
break;
case Name::CPC664BASIC:
*this = Request("AmstradCPC", "the CPC 664 BASIC ROM", "basic664.rom", 16*1024, 0x32fee492u);
*this = Description(name, "AmstradCPC", "the CPC 664 BASIC ROM", "basic664.rom", 16*1024, 0x32fee492u);
break;
case Name::CPC6128Firmware:
*this = Request("AmstradCPC", "the CPC 6128 firmware", "os664.rom", 16*1024, 0x0219bb74u);
*this = Description(name, "AmstradCPC", "the CPC 6128 firmware", "os664.rom", 16*1024, 0x0219bb74u);
break;
case Name::CPC6128BASIC:
*this = Request("AmstradCPC", "the CPC 6128 BASIC ROM", "basic664.rom", 16*1024, 0xca6af63du);
*this = Description(name, "AmstradCPC", "the CPC 6128 BASIC ROM", "basic664.rom", 16*1024, 0xca6af63du);
break;
//"AppleII"
AppleIIOriginal,
AppleIIPlus,
AppleIICharacter,
AppleIIe,
AppleIIeCharacter,
AppleIIEnhancedE,
AppleIIEnhancedECharacter,
// AppleIIOriginal,
// AppleIIPlus,
// AppleIICharacter,
// AppleIIe,
// AppleIIeCharacter,
// AppleIIEnhancedE,
// AppleIIEnhancedECharacter,
}
// rom_descriptions.push_back(video_.rom_description(Video::VideoBase::CharacterROM::EnhancedIIe));

View File

@ -10,6 +10,8 @@
#define ROMCatalogue_hpp
#include <map>
#include <optional>
#include <string>
#include <vector>
namespace ROM {
@ -135,11 +137,19 @@ struct Description {
/// Constructs the @c Description that correlates to @c name.
Description(Name name);
/// Constructs the @c Description that correlates to @c crc32.
static std::optional<Description> from_crc(uint32_t crc32);
private:
template <typename FileNameT, typename CRC32T> Description(
Name name, std::string machine_name, std::string descriptive_name, FileNameT file_names, size_t size, CRC32T crc32s
) : name{name}, machine_name{machine_name}, descriptive_name{descriptive_name}, file_names{file_names}, size{size}, crc32s{crc32s} {}
};
struct Request {
Request(Name name, bool optional = false);
Request();
Request() {}
Request operator &&(const Request &);
Request operator ||(const Request &);
@ -163,7 +173,7 @@ struct Request {
bool is_optional = false;
std::vector<Node> children;
void add_descriptions(std::vector<Description> &);
void add_descriptions(std::vector<Description> &) const;
};
Node node;
};

View File

@ -12,6 +12,8 @@
4B0333AF2094081A0050B93D /* AppleDSK.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0333AD2094081A0050B93D /* AppleDSK.cpp */; };
4B0333B02094081A0050B93D /* AppleDSK.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0333AD2094081A0050B93D /* AppleDSK.cpp */; };
4B049CDD1DA3C82F00322067 /* BCDTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B049CDC1DA3C82F00322067 /* BCDTest.swift */; };
4B051C912669C90B00CA44E8 /* ROMCatalogue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B051C5826670A9300CA44E8 /* ROMCatalogue.cpp */; };
4B051C922669C90B00CA44E8 /* ROMCatalogue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B051C5826670A9300CA44E8 /* ROMCatalogue.cpp */; };
4B05401E219D1618001BF69C /* ScanTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B05401D219D1618001BF69C /* ScanTarget.cpp */; };
4B05401F219D1618001BF69C /* ScanTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B05401D219D1618001BF69C /* ScanTarget.cpp */; };
4B055A7A1FAE78A00060FFFF /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B055A771FAE78210060FFFF /* SDL2.framework */; };
@ -5325,6 +5327,7 @@
4BB0A65C2044FD3000FB3688 /* SN76489.cpp in Sources */,
4B595FAE2086DFBA0083CAA8 /* AudioToggle.cpp in Sources */,
4B0F1C242605996900B85C66 /* ZXSpectrumTAP.cpp in Sources */,
4B051C912669C90B00CA44E8 /* ROMCatalogue.cpp in Sources */,
4B055AB91FAE86170060FFFF /* Acorn.cpp in Sources */,
4B302185208A550100773308 /* DiskII.cpp in Sources */,
4B0F1BB32602645900B85C66 /* StaticAnalyser.cpp in Sources */,
@ -5541,6 +5544,7 @@
4B15A9FC208249BB005E6C8D /* StaticAnalyser.cpp in Sources */,
4B5FADC01DE3BF2B00AEC565 /* Microdisc.cpp in Sources */,
4B0F1BDA2602FF9800B85C66 /* Video.cpp in Sources */,
4B051C922669C90B00CA44E8 /* ROMCatalogue.cpp in Sources */,
4B54C0C81F8D91E50050900F /* Keyboard.cpp in Sources */,
4B79A5011FC913C900EEDAD5 /* MSX.cpp in Sources */,
4BEE0A701D72496600532C7B /* PRG.cpp in Sources */,