2016-08-15 23:44:41 +00:00
|
|
|
//
|
|
|
|
// TapePRG.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 14/08/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-08-15 23:44:41 +00:00
|
|
|
//
|
|
|
|
|
2016-08-27 21:09:45 +00:00
|
|
|
#ifndef Storage_Tape_PRG_hpp
|
|
|
|
#define Storage_Tape_PRG_hpp
|
2016-08-15 23:44:41 +00:00
|
|
|
|
|
|
|
#include "../Tape.hpp"
|
2016-11-21 12:14:09 +00:00
|
|
|
#include "../../FileHolder.hpp"
|
2018-04-06 21:42:24 +00:00
|
|
|
|
2016-11-21 12:14:09 +00:00
|
|
|
#include <cstdint>
|
2018-04-06 21:42:24 +00:00
|
|
|
#include <string>
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Tape {
|
2016-08-15 23:44:41 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Provides a @c Tape containing a .PRG, which is a direct local file.
|
|
|
|
*/
|
2017-11-03 02:32:00 +00:00
|
|
|
class PRG: public Tape {
|
2016-08-15 23:44:41 +00:00
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Constructs a @c T64 containing content from the file with name @c file_name, of type @c type.
|
|
|
|
|
|
|
|
@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.
|
|
|
|
*/
|
2018-04-06 21:42:24 +00:00
|
|
|
PRG(const std::string &file_name);
|
2016-08-15 23:44:41 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ErrorBadFormat
|
|
|
|
};
|
|
|
|
|
|
|
|
// implemented to satisfy @c Tape
|
2016-08-30 01:53:06 +00:00
|
|
|
bool is_at_end();
|
|
|
|
|
2016-08-15 23:44:41 +00:00
|
|
|
private:
|
2017-11-03 02:32:00 +00:00
|
|
|
FileHolder file_;
|
2016-09-11 21:09:00 +00:00
|
|
|
Pulse virtual_get_next_pulse();
|
|
|
|
void virtual_reset();
|
|
|
|
|
2016-11-21 12:14:09 +00:00
|
|
|
uint16_t load_address_;
|
|
|
|
uint16_t length_;
|
2016-08-15 23:44:41 +00:00
|
|
|
|
|
|
|
enum FilePhase {
|
|
|
|
FilePhaseLeadIn,
|
2016-08-16 02:10:53 +00:00
|
|
|
FilePhaseHeader,
|
2016-08-17 12:03:34 +00:00
|
|
|
FilePhaseHeaderDataGap,
|
2016-08-16 02:10:53 +00:00
|
|
|
FilePhaseData,
|
2016-08-30 01:53:06 +00:00
|
|
|
FilePhaseAtEnd
|
2017-11-10 03:14:22 +00:00
|
|
|
} file_phase_ = FilePhaseLeadIn;
|
|
|
|
int phase_offset_ = 0;
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2017-11-10 03:14:22 +00:00
|
|
|
int bit_phase_ = 3;
|
2016-08-16 00:08:50 +00:00
|
|
|
enum OutputToken {
|
|
|
|
Leader,
|
|
|
|
Zero,
|
|
|
|
One,
|
2016-08-16 02:10:53 +00:00
|
|
|
WordMarker,
|
2016-08-19 14:58:42 +00:00
|
|
|
EndOfBlock,
|
|
|
|
Silence
|
2016-11-21 12:14:09 +00:00
|
|
|
} output_token_;
|
2016-08-16 00:08:50 +00:00
|
|
|
void get_next_output_token();
|
2016-11-21 12:14:09 +00:00
|
|
|
uint8_t output_byte_;
|
|
|
|
uint8_t check_digit_;
|
2017-11-10 03:14:22 +00:00
|
|
|
uint8_t copy_mask_ = 0x80;
|
2016-08-15 23:44:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* T64_hpp */
|