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"
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2016-08-27 21:09:45 +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.
|
|
|
|
@param type The type of data the file should contain.
|
|
|
|
@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);
|
|
|
|
~PRG();
|
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:
|
2016-09-11 21:09:00 +00:00
|
|
|
Pulse virtual_get_next_pulse();
|
|
|
|
void virtual_reset();
|
|
|
|
|
2016-08-15 23:44:41 +00:00
|
|
|
FILE *_file;
|
|
|
|
uint16_t _load_address;
|
2016-08-16 02:40:05 +00:00
|
|
|
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-08-15 23:44:41 +00:00
|
|
|
} _filePhase;
|
2016-08-16 02:10:53 +00:00
|
|
|
int _phaseOffset;
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2016-08-16 00:08:50 +00:00
|
|
|
int _bitPhase;
|
|
|
|
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-08-16 00:08:50 +00:00
|
|
|
} _outputToken;
|
|
|
|
void get_next_output_token();
|
2016-08-16 02:10:53 +00:00
|
|
|
uint8_t _output_byte;
|
2016-08-16 02:40:05 +00:00
|
|
|
uint8_t _check_digit;
|
2016-08-17 12:03:34 +00:00
|
|
|
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 */
|