1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Creates a virtual interface that can be adopted by classes that are able to provide some insight as to target machine.

This commit is contained in:
Thomas Harte 2017-08-27 15:19:03 -04:00
parent 9aa150c338
commit 56dd677e9c
3 changed files with 18 additions and 2 deletions

View File

@ -20,9 +20,11 @@ ZX80O81P::ZX80O81P(const char *file_name) :
// If it's a ZX81 file, prepend a file name. // If it's a ZX81 file, prepend a file name.
std::string type = extension(); std::string type = extension();
platform_type_ = TargetPlatform::ZX80;
if(type == "p" || type == "81") { if(type == "p" || type == "81") {
// TODO, maybe: prefix a proper file name; this is leaving the file nameless. // TODO, maybe: prefix a proper file name; this is leaving the file nameless.
data_.insert(data_.begin(), 0x80); data_.insert(data_.begin(), 0x80);
platform_type_ = TargetPlatform::ZX81;
} }
std::shared_ptr<::Storage::Data::ZX8081::File> file = Storage::Data::ZX8081::FileFromData(data_); std::shared_ptr<::Storage::Data::ZX8081::File> file = Storage::Data::ZX8081::FileFromData(data_);
@ -100,3 +102,7 @@ Tape::Pulse ZX80O81P::virtual_get_next_pulse() {
return pulse; return pulse;
} }
TargetPlatform::Type ZX80O81P::target_platform_type() {
return platform_type_;
}

View File

@ -11,6 +11,7 @@
#include "../Tape.hpp" #include "../Tape.hpp"
#include "../../FileHolder.hpp" #include "../../FileHolder.hpp"
#include "../../TargetPlatforms.hpp"
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
@ -21,7 +22,7 @@ namespace Tape {
/*! /*!
Provides a @c Tape containing a ZX80-format .O tape image, which is a byte stream capture. Provides a @c Tape containing a ZX80-format .O tape image, which is a byte stream capture.
*/ */
class ZX80O81P: public Tape, public Storage::FileHolder { class ZX80O81P: public Tape, public Storage::FileHolder, public TargetPlatform::TypeDistinguisher {
public: public:
/*! /*!
Constructs a @c ZX80O containing content from the file with name @c file_name. Constructs a @c ZX80O containing content from the file with name @c file_name.
@ -34,10 +35,14 @@ class ZX80O81P: public Tape, public Storage::FileHolder {
ErrorNotZX80O81P ErrorNotZX80O81P
}; };
private:
// implemented to satisfy @c Tape // implemented to satisfy @c Tape
bool is_at_end(); bool is_at_end();
private: // implemented to satisfy TargetPlatform::TypeDistinguisher
TargetPlatform::Type target_platform_type();
TargetPlatform::Type platform_type_;
void virtual_reset(); void virtual_reset();
Pulse virtual_get_next_pulse(); Pulse virtual_get_next_pulse();
bool has_finished_data(); bool has_finished_data();

View File

@ -26,6 +26,11 @@ enum Type: IntType {
AllDisk = Acorn | AmstradCPC | Commodore | Oric, AllDisk = Acorn | AmstradCPC | Commodore | Oric,
}; };
class TypeDistinguisher {
public:
virtual Type target_platform_type() = 0;
};
} }
#endif /* TargetPlatforms_h */ #endif /* TargetPlatforms_h */