mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 03:32:01 +00:00
Switches away from C strings and allows Vic-20 region inference from filenames.
This commit is contained in:
parent
cc49140f6f
commit
e1c4035812
@ -39,7 +39,7 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
|
|||||||
return vic20_cartridges;
|
return vic20_cartridges;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyser::Static::Commodore::AddTargets(const Media &media, std::vector<std::unique_ptr<Analyser::Static::Target>> &destination) {
|
void Analyser::Static::Commodore::AddTargets(const Media &media, std::vector<std::unique_ptr<Analyser::Static::Target>> &destination, const std::string &file_name) {
|
||||||
std::unique_ptr<Target> target(new Target);
|
std::unique_ptr<Target> target(new Target);
|
||||||
target->machine = Machine::Vic20; // TODO: machine estimation
|
target->machine = Machine::Vic20; // TODO: machine estimation
|
||||||
target->confidence = 0.5; // TODO: a proper estimation
|
target->confidence = 0.5; // TODO: a proper estimation
|
||||||
@ -140,6 +140,14 @@ void Analyser::Static::Commodore::AddTargets(const Media &media, std::vector<std
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!target->media.empty())
|
if(!target->media.empty()) {
|
||||||
|
// Inspect filename for a region hint.
|
||||||
|
std::string lowercase_name = file_name;
|
||||||
|
std::transform(lowercase_name.begin(), lowercase_name.end(), lowercase_name.begin(), ::tolower);
|
||||||
|
if(lowercase_name.find("ntsc") != std::string::npos) {
|
||||||
|
target->region = Analyser::Static::Commodore::Target::Region::American;
|
||||||
|
}
|
||||||
|
|
||||||
destination.push_back(std::move(target));
|
destination.push_back(std::move(target));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -10,12 +10,13 @@
|
|||||||
#define StaticAnalyser_Commodore_StaticAnalyser_hpp
|
#define StaticAnalyser_Commodore_StaticAnalyser_hpp
|
||||||
|
|
||||||
#include "../StaticAnalyser.hpp"
|
#include "../StaticAnalyser.hpp"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Analyser {
|
namespace Analyser {
|
||||||
namespace Static {
|
namespace Static {
|
||||||
namespace Commodore {
|
namespace Commodore {
|
||||||
|
|
||||||
void AddTargets(const Media &media, std::vector<std::unique_ptr<Target>> &destination);
|
void AddTargets(const Media &media, std::vector<std::unique_ptr<Target>> &destination, const std::string &file_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,21 +52,16 @@
|
|||||||
|
|
||||||
using namespace Analyser::Static;
|
using namespace Analyser::Static;
|
||||||
|
|
||||||
static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType &potential_platforms) {
|
static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::IntType &potential_platforms) {
|
||||||
|
Media result;
|
||||||
|
|
||||||
// Get the extension, if any; it will be assumed that extensions are reliable, so an extension is a broad-phase
|
// Get the extension, if any; it will be assumed that extensions are reliable, so an extension is a broad-phase
|
||||||
// test as to file format.
|
// test as to file format.
|
||||||
const char *mixed_case_extension = strrchr(file_name, '.');
|
std::string::size_type final_dot = file_name.find_last_of(".");
|
||||||
char *lowercase_extension = nullptr;
|
if(final_dot == std::string::npos) return result;
|
||||||
if(mixed_case_extension) {
|
std::string extension = file_name.substr(final_dot + 1);
|
||||||
lowercase_extension = strdup(mixed_case_extension+1);
|
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
||||||
char *parser = lowercase_extension;
|
|
||||||
while(*parser) {
|
|
||||||
*parser = (char)tolower(*parser);
|
|
||||||
parser++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Media result;
|
|
||||||
#define Insert(list, class, platforms) \
|
#define Insert(list, class, platforms) \
|
||||||
list.emplace_back(new Storage::class(file_name));\
|
list.emplace_back(new Storage::class(file_name));\
|
||||||
potential_platforms |= platforms;\
|
potential_platforms |= platforms;\
|
||||||
@ -78,12 +73,11 @@ static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType
|
|||||||
Insert(list, class, platforms) \
|
Insert(list, class, platforms) \
|
||||||
} catch(...) {}
|
} catch(...) {}
|
||||||
|
|
||||||
#define Format(extension, list, class, platforms) \
|
#define Format(ext, list, class, platforms) \
|
||||||
if(!std::strcmp(lowercase_extension, extension)) { \
|
if(extension == ext) { \
|
||||||
TryInsert(list, class, platforms) \
|
TryInsert(list, class, platforms) \
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lowercase_extension) {
|
|
||||||
Format("80", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 80
|
Format("80", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 80
|
||||||
Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81
|
Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81
|
||||||
Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26
|
Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26
|
||||||
@ -110,7 +104,7 @@ static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType
|
|||||||
Format("p81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P81
|
Format("p81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P81
|
||||||
|
|
||||||
// PRG
|
// PRG
|
||||||
if(!std::strcmp(lowercase_extension, "prg")) {
|
if(extension == "prg") {
|
||||||
// try instantiating as a ROM; failing that accept as a tape
|
// try instantiating as a ROM; failing that accept as a tape
|
||||||
try {
|
try {
|
||||||
Insert(result.cartridges, Cartridge::PRG, TargetPlatform::Commodore)
|
Insert(result.cartridges, Cartridge::PRG, TargetPlatform::Commodore)
|
||||||
@ -136,20 +130,15 @@ static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType
|
|||||||
#undef Insert
|
#undef Insert
|
||||||
#undef TryInsert
|
#undef TryInsert
|
||||||
|
|
||||||
// Filter potential platforms as per file preferences, if any.
|
|
||||||
|
|
||||||
free(lowercase_extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Media Analyser::Static::GetMedia(const char *file_name) {
|
Media Analyser::Static::GetMedia(const std::string &file_name) {
|
||||||
TargetPlatform::IntType throwaway;
|
TargetPlatform::IntType throwaway;
|
||||||
return GetMediaAndPlatforms(file_name, throwaway);
|
return GetMediaAndPlatforms(file_name, throwaway);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Target>> Analyser::Static::GetTargets(const char *file_name) {
|
std::vector<std::unique_ptr<Target>> Analyser::Static::GetTargets(const std::string &file_name) {
|
||||||
std::vector<std::unique_ptr<Target>> targets;
|
std::vector<std::unique_ptr<Target>> targets;
|
||||||
|
|
||||||
// Collect all disks, tapes and ROMs as can be extrapolated from this file, forming the
|
// Collect all disks, tapes and ROMs as can be extrapolated from this file, forming the
|
||||||
@ -163,7 +152,7 @@ std::vector<std::unique_ptr<Target>> Analyser::Static::GetTargets(const char *fi
|
|||||||
if(potential_platforms & TargetPlatform::AmstradCPC) AmstradCPC::AddTargets(media, targets);
|
if(potential_platforms & TargetPlatform::AmstradCPC) AmstradCPC::AddTargets(media, targets);
|
||||||
if(potential_platforms & TargetPlatform::Atari2600) Atari::AddTargets(media, targets);
|
if(potential_platforms & TargetPlatform::Atari2600) Atari::AddTargets(media, targets);
|
||||||
if(potential_platforms & TargetPlatform::ColecoVision) Coleco::AddTargets(media, targets);
|
if(potential_platforms & TargetPlatform::ColecoVision) Coleco::AddTargets(media, targets);
|
||||||
if(potential_platforms & TargetPlatform::Commodore) Commodore::AddTargets(media, targets);
|
if(potential_platforms & TargetPlatform::Commodore) Commodore::AddTargets(media, targets, file_name);
|
||||||
if(potential_platforms & TargetPlatform::MSX) MSX::AddTargets(media, targets);
|
if(potential_platforms & TargetPlatform::MSX) MSX::AddTargets(media, targets);
|
||||||
if(potential_platforms & TargetPlatform::Oric) Oric::AddTargets(media, targets);
|
if(potential_platforms & TargetPlatform::Oric) Oric::AddTargets(media, targets);
|
||||||
if(potential_platforms & TargetPlatform::ZX8081) ZX8081::AddTargets(media, targets, potential_platforms);
|
if(potential_platforms & TargetPlatform::ZX8081) ZX8081::AddTargets(media, targets, potential_platforms);
|
||||||
|
@ -53,12 +53,12 @@ struct Target {
|
|||||||
|
|
||||||
@returns The list of potential targets, sorted from most to least probable.
|
@returns The list of potential targets, sorted from most to least probable.
|
||||||
*/
|
*/
|
||||||
std::vector<std::unique_ptr<Target>> GetTargets(const char *file_name);
|
std::vector<std::unique_ptr<Target>> GetTargets(const std::string &file_name);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Inspects the supplied file and determines the media included.
|
Inspects the supplied file and determines the media included.
|
||||||
*/
|
*/
|
||||||
Media GetMedia(const char *file_name);
|
Media GetMedia(const std::string &file_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
using namespace Storage::Cartridge;
|
using namespace Storage::Cartridge;
|
||||||
|
|
||||||
BinaryDump::BinaryDump(const char *file_name) {
|
BinaryDump::BinaryDump(const std::string &file_name) {
|
||||||
// the file should be exactly 16 kb
|
// the file should be exactly 16 kb
|
||||||
struct stat file_stats;
|
struct stat file_stats;
|
||||||
stat(file_name, &file_stats);
|
stat(file_name.c_str(), &file_stats);
|
||||||
|
|
||||||
// grab contents
|
// grab contents
|
||||||
FILE *file = std::fopen(file_name, "rb");
|
FILE *file = std::fopen(file_name.c_str(), "rb");
|
||||||
if(!file) throw ErrorNotAccessible;
|
if(!file) throw ErrorNotAccessible;
|
||||||
std::size_t data_length = static_cast<std::size_t>(file_stats.st_size);
|
std::size_t data_length = static_cast<std::size_t>(file_stats.st_size);
|
||||||
std::vector<uint8_t> contents(data_length);
|
std::vector<uint8_t> contents(data_length);
|
||||||
|
@ -11,12 +11,14 @@
|
|||||||
|
|
||||||
#include "../Cartridge.hpp"
|
#include "../Cartridge.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Cartridge {
|
namespace Cartridge {
|
||||||
|
|
||||||
class BinaryDump : public Cartridge {
|
class BinaryDump : public Cartridge {
|
||||||
public:
|
public:
|
||||||
BinaryDump(const char *file_name);
|
BinaryDump(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotAccessible
|
ErrorNotAccessible
|
||||||
|
@ -15,16 +15,16 @@
|
|||||||
|
|
||||||
using namespace Storage::Cartridge;
|
using namespace Storage::Cartridge;
|
||||||
|
|
||||||
PRG::PRG(const char *file_name) {
|
PRG::PRG(const std::string &file_name) {
|
||||||
struct stat file_stats;
|
struct stat file_stats;
|
||||||
stat(file_name, &file_stats);
|
stat(file_name.c_str(), &file_stats);
|
||||||
|
|
||||||
// accept only files sized less than 8kb
|
// accept only files sized less than 8kb
|
||||||
if(file_stats.st_size > 0x2000 + 2)
|
if(file_stats.st_size > 0x2000 + 2)
|
||||||
throw ErrorNotROM;
|
throw ErrorNotROM;
|
||||||
|
|
||||||
// get the loading address, and the rest of the contents
|
// get the loading address, and the rest of the contents
|
||||||
FILE *file = std::fopen(file_name, "rb");
|
FILE *file = std::fopen(file_name.c_str(), "rb");
|
||||||
|
|
||||||
int loading_address = fgetc(file);
|
int loading_address = fgetc(file);
|
||||||
loading_address |= fgetc(file) << 8;
|
loading_address |= fgetc(file) << 8;
|
||||||
|
@ -11,12 +11,14 @@
|
|||||||
|
|
||||||
#include "../Cartridge.hpp"
|
#include "../Cartridge.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Cartridge {
|
namespace Cartridge {
|
||||||
|
|
||||||
class PRG : public Cartridge {
|
class PRG : public Cartridge {
|
||||||
public:
|
public:
|
||||||
PRG(const char *file_name);
|
PRG(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotROM
|
ErrorNotROM
|
||||||
|
@ -17,7 +17,7 @@ namespace {
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
AcornADF::AcornADF(const char *file_name) : MFMSectorDump(file_name) {
|
AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
|
||||||
// very loose validation: the file needs to be a multiple of 256 bytes
|
// very loose validation: the file needs to be a multiple of 256 bytes
|
||||||
// and not ungainly large
|
// and not ungainly large
|
||||||
if(file_.stats().st_size % static_cast<off_t>(128 << sector_size)) throw ErrorNotAcornADF;
|
if(file_.stats().st_size % static_cast<off_t>(128 << sector_size)) throw ErrorNotAcornADF;
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include "MFMSectorDump.hpp"
|
#include "MFMSectorDump.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ class AcornADF: public MFMSectorDump {
|
|||||||
@throws ErrorCantOpen if this file can't be opened.
|
@throws ErrorCantOpen if this file can't be opened.
|
||||||
@throws ErrorNotAcornADF if the file doesn't appear to contain an Acorn .ADF format image.
|
@throws ErrorNotAcornADF if the file doesn't appear to contain an Acorn .ADF format image.
|
||||||
*/
|
*/
|
||||||
AcornADF(const char *file_name);
|
AcornADF(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotAcornADF,
|
ErrorNotAcornADF,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
CPCDSK::CPCDSK(const char *file_name) :
|
CPCDSK::CPCDSK(const std::string &file_name) :
|
||||||
file_name_(file_name),
|
file_name_(file_name),
|
||||||
is_extended_(false) {
|
is_extended_(false) {
|
||||||
FileHolder file(file_name);
|
FileHolder file(file_name);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "../../../FileHolder.hpp"
|
#include "../../../FileHolder.hpp"
|
||||||
#include "../../Encodings/MFM/Sector.hpp"
|
#include "../../Encodings/MFM/Sector.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
@ -29,7 +30,7 @@ class CPCDSK: public DiskImage {
|
|||||||
@throws ErrorCantOpen if this file can't be opened.
|
@throws ErrorCantOpen if this file can't be opened.
|
||||||
@throws ErrorNotAcornADF if the file doesn't appear to contain an Acorn .ADF format image.
|
@throws ErrorNotAcornADF if the file doesn't appear to contain an Acorn .ADF format image.
|
||||||
*/
|
*/
|
||||||
CPCDSK(const char *file_name);
|
CPCDSK(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotCPCDSK,
|
ErrorNotCPCDSK,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
D64::D64(const char *file_name) :
|
D64::D64(const std::string &file_name) :
|
||||||
file_(file_name) {
|
file_(file_name) {
|
||||||
// in D64, this is it for validation without imposing potential false-negative tests — check that
|
// in D64, this is it for validation without imposing potential false-negative tests — check that
|
||||||
// the file size appears to be correct. Stone-age stuff.
|
// the file size appears to be correct. Stone-age stuff.
|
||||||
@ -29,10 +29,9 @@ D64::D64(const char *file_name) :
|
|||||||
// then, ostensibly, this is a valid file. Hmmm. Pick a disk ID as a function of the file_name,
|
// then, ostensibly, this is a valid file. Hmmm. Pick a disk ID as a function of the file_name,
|
||||||
// being the most stable thing available
|
// being the most stable thing available
|
||||||
disk_id_ = 0;
|
disk_id_ = 0;
|
||||||
while(*file_name) {
|
for(const auto &character: file_name) {
|
||||||
disk_id_ ^= file_name[0];
|
disk_id_ ^= character;
|
||||||
disk_id_ = static_cast<uint16_t>((disk_id_ << 2) ^ (disk_id_ >> 13));
|
disk_id_ = static_cast<uint16_t>((disk_id_ << 2) ^ (disk_id_ >> 13));
|
||||||
file_name++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class D64: public DiskImage {
|
|||||||
@throws ErrorCantOpen if this file can't be opened.
|
@throws ErrorCantOpen if this file can't be opened.
|
||||||
@throws ErrorNotD64 if the file doesn't appear to contain a .D64 format image.
|
@throws ErrorNotD64 if the file doesn't appear to contain a .D64 format image.
|
||||||
*/
|
*/
|
||||||
D64(const char *file_name);
|
D64(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotD64,
|
ErrorNotD64,
|
||||||
|
@ -32,7 +32,7 @@ std::unique_ptr<Storage::Encodings::MFM::Encoder> new_encoder(Storage::Disk::PCM
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DMK::DMK(const char *file_name) :
|
DMK::DMK(const std::string &file_name) :
|
||||||
file_(file_name) {
|
file_(file_name) {
|
||||||
// Determine whether this DMK represents a read-only disk (whether intentionally,
|
// Determine whether this DMK represents a read-only disk (whether intentionally,
|
||||||
// or by virtue of placement).
|
// or by virtue of placement).
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "../DiskImage.hpp"
|
#include "../DiskImage.hpp"
|
||||||
#include "../../../FileHolder.hpp"
|
#include "../../../FileHolder.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ class DMK: public DiskImage {
|
|||||||
|
|
||||||
@throws ErrorNotDMK if this file doesn't appear to be a DMK.
|
@throws ErrorNotDMK if this file doesn't appear to be a DMK.
|
||||||
*/
|
*/
|
||||||
DMK(const char *file_name);
|
DMK(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotDMK
|
ErrorNotDMK
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
G64::G64(const char *file_name) :
|
G64::G64(const std::string &file_name) :
|
||||||
file_(file_name) {
|
file_(file_name) {
|
||||||
// read and check the file signature
|
// read and check the file signature
|
||||||
if(!file_.check_signature("GCR-1541")) throw ErrorNotG64;
|
if(!file_.check_signature("GCR-1541")) throw ErrorNotG64;
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "../DiskImage.hpp"
|
#include "../DiskImage.hpp"
|
||||||
#include "../../../FileHolder.hpp"
|
#include "../../../FileHolder.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -27,7 +29,7 @@ class G64: public DiskImage {
|
|||||||
@throws ErrorNotG64 if the file doesn't appear to contain a .G64 format image.
|
@throws ErrorNotG64 if the file doesn't appear to contain a .G64 format image.
|
||||||
@throws ErrorUnknownVersion if this file appears to be a .G64 but has an unrecognised version number.
|
@throws ErrorUnknownVersion if this file appears to be a .G64 but has an unrecognised version number.
|
||||||
*/
|
*/
|
||||||
G64(const char *file_name);
|
G64(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorCantOpen,
|
ErrorCantOpen,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
HFE::HFE(const char *file_name) :
|
HFE::HFE(const std::string &file_name) :
|
||||||
file_(file_name) {
|
file_(file_name) {
|
||||||
if(!file_.check_signature("HXCPICFE")) throw ErrorNotHFE;
|
if(!file_.check_signature("HXCPICFE")) throw ErrorNotHFE;
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "../DiskImage.hpp"
|
#include "../DiskImage.hpp"
|
||||||
#include "../../../FileHolder.hpp"
|
#include "../../../FileHolder.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ class HFE: public DiskImage {
|
|||||||
@throws ErrorCantOpen if this file can't be opened.
|
@throws ErrorCantOpen if this file can't be opened.
|
||||||
@throws ErrorNotSSD if the file doesn't appear to contain a .SSD format image.
|
@throws ErrorNotSSD if the file doesn't appear to contain a .SSD format image.
|
||||||
*/
|
*/
|
||||||
HFE(const char *file_name);
|
HFE(const std::string &file_name);
|
||||||
~HFE();
|
~HFE();
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
MFMSectorDump::MFMSectorDump(const char *file_name) : file_(file_name) {}
|
MFMSectorDump::MFMSectorDump(const std::string &file_name) : file_(file_name) {}
|
||||||
|
|
||||||
void MFMSectorDump::set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density) {
|
void MFMSectorDump::set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density) {
|
||||||
sectors_per_track_ = sectors_per_track;
|
sectors_per_track_ = sectors_per_track;
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "../DiskImage.hpp"
|
#include "../DiskImage.hpp"
|
||||||
#include "../../../FileHolder.hpp"
|
#include "../../../FileHolder.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ namespace Disk {
|
|||||||
*/
|
*/
|
||||||
class MFMSectorDump: public DiskImage {
|
class MFMSectorDump: public DiskImage {
|
||||||
public:
|
public:
|
||||||
MFMSectorDump(const char *file_name);
|
MFMSectorDump(const std::string &file_name);
|
||||||
void set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density);
|
void set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density);
|
||||||
|
|
||||||
bool get_is_read_only() override;
|
bool get_is_read_only() override;
|
||||||
|
@ -17,7 +17,7 @@ namespace {
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
MSXDSK::MSXDSK(const char *file_name) :
|
MSXDSK::MSXDSK(const std::string &file_name) :
|
||||||
MFMSectorDump(file_name) {
|
MFMSectorDump(file_name) {
|
||||||
// The only sanity check here is whether a sensible
|
// The only sanity check here is whether a sensible
|
||||||
// geometry can be guessed.
|
// geometry can be guessed.
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include "MFMSectorDump.hpp"
|
#include "MFMSectorDump.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ namespace Disk {
|
|||||||
*/
|
*/
|
||||||
class MSXDSK: public MFMSectorDump {
|
class MSXDSK: public MFMSectorDump {
|
||||||
public:
|
public:
|
||||||
MSXDSK(const char *file_name);
|
MSXDSK(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotMSXDSK,
|
ErrorNotMSXDSK,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
OricMFMDSK::OricMFMDSK(const char *file_name) :
|
OricMFMDSK::OricMFMDSK(const std::string &file_name) :
|
||||||
file_(file_name) {
|
file_(file_name) {
|
||||||
if(!file_.check_signature("MFM_DISK"))
|
if(!file_.check_signature("MFM_DISK"))
|
||||||
throw ErrorNotOricMFMDSK;
|
throw ErrorNotOricMFMDSK;
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "../DiskImage.hpp"
|
#include "../DiskImage.hpp"
|
||||||
#include "../../../FileHolder.hpp"
|
#include "../../../FileHolder.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Disk {
|
namespace Disk {
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ class OricMFMDSK: public DiskImage {
|
|||||||
|
|
||||||
@throws ErrorNotOricMFMDSK if the file doesn't appear to contain an Oric MFM format image.
|
@throws ErrorNotOricMFMDSK if the file doesn't appear to contain an Oric MFM format image.
|
||||||
*/
|
*/
|
||||||
OricMFMDSK(const char *file_name);
|
OricMFMDSK(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotOricMFMDSK,
|
ErrorNotOricMFMDSK,
|
||||||
|
@ -19,7 +19,7 @@ namespace {
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
SSD::SSD(const char *file_name) : MFMSectorDump(file_name) {
|
SSD::SSD(const std::string &file_name) : MFMSectorDump(file_name) {
|
||||||
// very loose validation: the file needs to be a multiple of 256 bytes
|
// very loose validation: the file needs to be a multiple of 256 bytes
|
||||||
// and not ungainly large
|
// and not ungainly large
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ SSD::SSD(const char *file_name) : MFMSectorDump(file_name) {
|
|||||||
if(file_.stats().st_size > 800*256) throw ErrorNotSSD;
|
if(file_.stats().st_size > 800*256) throw ErrorNotSSD;
|
||||||
|
|
||||||
// this has two heads if the suffix is .dsd, one if it's .ssd
|
// this has two heads if the suffix is .dsd, one if it's .ssd
|
||||||
head_count_ = (tolower(file_name[std::strlen(file_name) - 3]) == 'd') ? 2 : 1;
|
head_count_ = (tolower(file_name[file_name.size() - 3]) == 'd') ? 2 : 1;
|
||||||
track_count_ = static_cast<int>(file_.stats().st_size / (256 * 10));
|
track_count_ = static_cast<int>(file_.stats().st_size / (256 * 10));
|
||||||
if(track_count_ < 40) track_count_ = 40;
|
if(track_count_ < 40) track_count_ = 40;
|
||||||
else if(track_count_ < 80) track_count_ = 80;
|
else if(track_count_ < 80) track_count_ = 80;
|
||||||
|
@ -25,7 +25,7 @@ class SSD: public MFMSectorDump {
|
|||||||
@throws ErrorCantOpen if this file can't be opened.
|
@throws ErrorCantOpen if this file can't be opened.
|
||||||
@throws ErrorNotSSD if the file doesn't appear to contain a .SSD format image.
|
@throws ErrorNotSSD if the file doesn't appear to contain a .SSD format image.
|
||||||
*/
|
*/
|
||||||
SSD(const char *file_name);
|
SSD(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotSSD,
|
ErrorNotSSD,
|
||||||
|
@ -17,7 +17,7 @@ namespace {
|
|||||||
const uint8_t header_signature[8] = {0x1f, 0xa6, 0xde, 0xba, 0xcc, 0x13, 0x7d, 0x74};
|
const uint8_t header_signature[8] = {0x1f, 0xa6, 0xde, 0xba, 0xcc, 0x13, 0x7d, 0x74};
|
||||||
}
|
}
|
||||||
|
|
||||||
CAS::CAS(const char *file_name) {
|
CAS::CAS(const std::string &file_name) {
|
||||||
Storage::FileHolder file(file_name);
|
Storage::FileHolder file(file_name);
|
||||||
uint8_t lookahead[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
uint8_t lookahead[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "../../FileHolder.hpp"
|
#include "../../FileHolder.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
@ -28,7 +29,7 @@ class CAS: public Tape {
|
|||||||
|
|
||||||
@throws ErrorNotCAS if this file could not be opened and recognised as a valid CAS file.
|
@throws ErrorNotCAS if this file could not be opened and recognised as a valid CAS file.
|
||||||
*/
|
*/
|
||||||
CAS(const char *file_name);
|
CAS(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotCAS
|
ErrorNotCAS
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Tape;
|
using namespace Storage::Tape;
|
||||||
|
|
||||||
CSW::CSW(const char *file_name) :
|
CSW::CSW(const std::string &file_name) :
|
||||||
source_data_pointer_(0) {
|
source_data_pointer_(0) {
|
||||||
Storage::FileHolder file(file_name);
|
Storage::FileHolder file(file_name);
|
||||||
if(file.stats().st_size < 0x20) throw ErrorNotCSW;
|
if(file.stats().st_size < 0x20) throw ErrorNotCSW;
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
#include "../Tape.hpp"
|
#include "../Tape.hpp"
|
||||||
#include "../../FileHolder.hpp"
|
#include "../../FileHolder.hpp"
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Tape {
|
namespace Tape {
|
||||||
@ -28,7 +29,7 @@ class CSW: public Tape {
|
|||||||
|
|
||||||
@throws ErrorNotCSW if this file could not be opened and recognised as a valid CSW file.
|
@throws ErrorNotCSW if this file could not be opened and recognised as a valid CSW file.
|
||||||
*/
|
*/
|
||||||
CSW(const char *file_name);
|
CSW(const std::string &file_name);
|
||||||
|
|
||||||
enum class CompressionType {
|
enum class CompressionType {
|
||||||
RLE,
|
RLE,
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Tape;
|
using namespace Storage::Tape;
|
||||||
|
|
||||||
CommodoreTAP::CommodoreTAP(const char *file_name) :
|
CommodoreTAP::CommodoreTAP(const std::string &file_name) :
|
||||||
file_(file_name)
|
file_(file_name)
|
||||||
{
|
{
|
||||||
if(!file_.check_signature("C64-TAPE-RAW"))
|
if(!file_.check_signature("C64-TAPE-RAW"))
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
#include "../Tape.hpp"
|
#include "../Tape.hpp"
|
||||||
#include "../../FileHolder.hpp"
|
#include "../../FileHolder.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Tape {
|
namespace Tape {
|
||||||
@ -26,7 +28,7 @@ class CommodoreTAP: public Tape {
|
|||||||
|
|
||||||
@throws ErrorNotCommodoreTAP if this file could not be opened and recognised as a valid Commodore-format TAP.
|
@throws ErrorNotCommodoreTAP if this file could not be opened and recognised as a valid Commodore-format TAP.
|
||||||
*/
|
*/
|
||||||
CommodoreTAP(const char *file_name);
|
CommodoreTAP(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotCommodoreTAP
|
ErrorNotCommodoreTAP
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Tape;
|
using namespace Storage::Tape;
|
||||||
|
|
||||||
OricTAP::OricTAP(const char *file_name) :
|
OricTAP::OricTAP(const std::string &file_name) :
|
||||||
file_(file_name)
|
file_(file_name)
|
||||||
{
|
{
|
||||||
// check the file signature
|
// check the file signature
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
#include "../Tape.hpp"
|
#include "../Tape.hpp"
|
||||||
#include "../../FileHolder.hpp"
|
#include "../../FileHolder.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Tape {
|
namespace Tape {
|
||||||
@ -26,7 +28,7 @@ class OricTAP: public Tape {
|
|||||||
|
|
||||||
@throws ErrorNotOricTAP if this file could not be opened and recognised as a valid Oric-format TAP.
|
@throws ErrorNotOricTAP if this file could not be opened and recognised as a valid Oric-format TAP.
|
||||||
*/
|
*/
|
||||||
OricTAP(const char *file_name);
|
OricTAP(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotOricTAP
|
ErrorNotOricTAP
|
||||||
|
@ -17,7 +17,7 @@ const unsigned int StandardTZXClock = 3500000;
|
|||||||
const unsigned int TZXClockMSMultiplier = 3500;
|
const unsigned int TZXClockMSMultiplier = 3500;
|
||||||
}
|
}
|
||||||
|
|
||||||
TZX::TZX(const char *file_name) :
|
TZX::TZX(const std::string &file_name) :
|
||||||
file_(file_name),
|
file_(file_name),
|
||||||
current_level_(false) {
|
current_level_(false) {
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "../PulseQueuedTape.hpp"
|
#include "../PulseQueuedTape.hpp"
|
||||||
#include "../../FileHolder.hpp"
|
#include "../../FileHolder.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Tape {
|
namespace Tape {
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ class TZX: public PulseQueuedTape {
|
|||||||
|
|
||||||
@throws ErrorNotTZX if this file could not be opened and recognised as a valid TZX file.
|
@throws ErrorNotTZX if this file could not be opened and recognised as a valid TZX file.
|
||||||
*/
|
*/
|
||||||
TZX(const char *file_name);
|
TZX(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotTZX
|
ErrorNotTZX
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Tape;
|
using namespace Storage::Tape;
|
||||||
|
|
||||||
PRG::PRG(const char *file_name) :
|
PRG::PRG(const std::string &file_name) :
|
||||||
file_(file_name)
|
file_(file_name)
|
||||||
{
|
{
|
||||||
// There's really no way to validate other than that if this file is larger than 64kb,
|
// There's really no way to validate other than that if this file is larger than 64kb,
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
#include "../Tape.hpp"
|
#include "../Tape.hpp"
|
||||||
#include "../../FileHolder.hpp"
|
#include "../../FileHolder.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Tape {
|
namespace Tape {
|
||||||
@ -27,7 +29,7 @@ class PRG: public Tape {
|
|||||||
@param file_name The name of the file to load.
|
@param file_name The name of the file to load.
|
||||||
@throws ErrorBadFormat if this file could not be opened and recognised as the specified type.
|
@throws ErrorBadFormat if this file could not be opened and recognised as the specified type.
|
||||||
*/
|
*/
|
||||||
PRG(const char *file_name);
|
PRG(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorBadFormat
|
ErrorBadFormat
|
||||||
|
@ -68,8 +68,8 @@ static int gzget32(gzFile file) {
|
|||||||
|
|
||||||
using namespace Storage::Tape;
|
using namespace Storage::Tape;
|
||||||
|
|
||||||
UEF::UEF(const char *file_name) {
|
UEF::UEF(const std::string &file_name) {
|
||||||
file_ = gzopen(file_name, "rb");
|
file_ = gzopen(file_name.c_str(), "rb");
|
||||||
|
|
||||||
char identifier[10];
|
char identifier[10];
|
||||||
int bytes_read = gzread(file_, identifier, 10);
|
int bytes_read = gzread(file_, identifier, 10);
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
|
|
||||||
#include "../../TargetPlatforms.hpp"
|
#include "../../TargetPlatforms.hpp"
|
||||||
|
|
||||||
#include <zlib.h>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Tape {
|
namespace Tape {
|
||||||
@ -29,7 +30,7 @@ class UEF : public PulseQueuedTape, public TargetPlatform::TypeDistinguisher {
|
|||||||
|
|
||||||
@throws ErrorNotUEF if this file could not be opened and recognised as a valid UEF.
|
@throws ErrorNotUEF if this file could not be opened and recognised as a valid UEF.
|
||||||
*/
|
*/
|
||||||
UEF(const char *file_name);
|
UEF(const std::string &file_name);
|
||||||
~UEF();
|
~UEF();
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Tape;
|
using namespace Storage::Tape;
|
||||||
|
|
||||||
ZX80O81P::ZX80O81P(const char *file_name) {
|
ZX80O81P::ZX80O81P(const std::string &file_name) {
|
||||||
Storage::FileHolder file(file_name);
|
Storage::FileHolder file(file_name);
|
||||||
|
|
||||||
// Grab the actual file contents
|
// Grab the actual file contents
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "../../TargetPlatforms.hpp"
|
#include "../../TargetPlatforms.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
@ -30,7 +31,7 @@ class ZX80O81P: public Tape, public TargetPlatform::TypeDistinguisher {
|
|||||||
|
|
||||||
@throws ErrorNotZX80O81P if this file could not be opened and recognised as a valid ZX80-format .O.
|
@throws ErrorNotZX80O81P if this file could not be opened and recognised as a valid ZX80-format .O.
|
||||||
*/
|
*/
|
||||||
ZX80O81P(const char *file_name);
|
ZX80O81P(const std::string &file_name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ErrorNotZX80O81P
|
ErrorNotZX80O81P
|
||||||
|
Loading…
Reference in New Issue
Block a user