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