diff --git a/Storage/Tape/Formats/CommodoreTAP.cpp b/Storage/Tape/Formats/CommodoreTAP.cpp index a2fe1b22d..03ab3e7ad 100644 --- a/Storage/Tape/Formats/CommodoreTAP.cpp +++ b/Storage/Tape/Formats/CommodoreTAP.cpp @@ -23,6 +23,7 @@ CommodoreTAP::Serialiser::Serialiser(const std::string &file_name) : if(!is_c64 && !is_c16) { throw ErrorNotCommodoreTAP; } + type_ = is_c16 ? FileType::C16 : FileType::C64; // Get and check the file version. version_ = file_.get8(); @@ -31,18 +32,8 @@ CommodoreTAP::Serialiser::Serialiser(const std::string &file_name) : } // Read clock rate-implying bytes. - enum Platform: uint8_t { - C64 = 0, - Vic20 = 1, - C16 = 2, - }; - const auto platform = Platform(file_.get8()); - enum VideoStandard: uint8_t { - PAL = 0, - NTSC1 = 1, - NTSC2 = 2, - }; - const auto video = VideoStandard(file_.get8()); + platform_ = Platform(file_.get8()); + video_ = VideoStandard(file_.get8()); file_.seek(1, SEEK_CUR); // Read file size. @@ -51,12 +42,12 @@ CommodoreTAP::Serialiser::Serialiser(const std::string &file_name) : // Pick clock rate. current_pulse_.length.clock_rate = static_cast( [&] { - switch(platform) { - case Vic20: return video == PAL ? 1'108'000 : 1'022'000; // TODO: these are inexact. - case C64: return video == PAL ? 985'248 : 1'022'727; - case C16: return video == PAL ? 886'722 : 894'886; + switch(platform_) { // TODO: Vic-20 numbers are inexact. + case Platform::Vic20: return video_ == VideoStandard::PAL ? 1'108'000 : 1'022'000; + case Platform::C64: return video_ == VideoStandard::PAL ? 985'248 : 1'022'727; + case Platform::C16: return video_ == VideoStandard::PAL ? 886'722 : 894'886; } - }() * 1 //(half_waves() ? 1 : 2) + }() * (half_waves() ? 1 : 2) ); reset(); } diff --git a/Storage/Tape/Formats/CommodoreTAP.hpp b/Storage/Tape/Formats/CommodoreTAP.hpp index 3efb1f03f..e0e791310 100644 --- a/Storage/Tape/Formats/CommodoreTAP.hpp +++ b/Storage/Tape/Formats/CommodoreTAP.hpp @@ -44,12 +44,26 @@ private: Storage::FileHolder file_; uint32_t file_size_; + enum class FileType { + C16, C64, + } type_; + enum class Platform: uint8_t { + C64 = 0, + Vic20 = 1, + C16 = 2, + } platform_; + enum class VideoStandard: uint8_t { + PAL = 0, + NTSC1 = 1, + NTSC2 = 2, + } video_; uint8_t version_; bool updated_layout() const { return version_ >= 1; } bool half_waves() const { - return version_ >= 2; + return type_ == FileType::C16; +// return version_ >= 2; } Pulse current_pulse_;