2016-08-15 23:44:41 +00:00
|
|
|
//
|
|
|
|
// TapePRG.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 14/08/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
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"
|
|
|
|
#include <cstdint>
|
2016-08-15 23:44:41 +00:00
|
|
|
|
|
|
|
namespace Storage {
|
2016-08-27 21:09:45 +00:00
|
|
|
namespace 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.
|
|
|
|
*/
|
2016-08-27 21:09:45 +00:00
|
|
|
PRG(const char *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
|
2016-11-21 12:14:09 +00:00
|
|
|
} file_phase_;
|
|
|
|
int phase_offset_;
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2016-11-21 12:14:09 +00:00
|
|
|
int bit_phase_;
|
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_;
|
|
|
|
uint8_t copy_mask_;
|
2016-08-15 23:44:41 +00:00
|
|
|
};
|
|
|
|
|
2016-08-27 21:09:45 +00:00
|
|
|
}
|
2016-08-15 23:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* T64_hpp */
|