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
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
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 {
|
2024-12-02 02:44:14 +00:00
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Constructs a @c T64 containing content from the file with name @c file_name, of type @c type.
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
@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.
|
|
|
|
*/
|
|
|
|
PRG(const std::string &file_name);
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
enum {
|
|
|
|
ErrorBadFormat
|
|
|
|
};
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
// implemented to satisfy @c Tape
|
|
|
|
bool is_at_end();
|
2016-08-30 01:53:06 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
private:
|
|
|
|
FileHolder file_;
|
|
|
|
Pulse virtual_get_next_pulse();
|
|
|
|
void virtual_reset();
|
2016-09-11 21:09:00 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
uint16_t load_address_;
|
|
|
|
uint16_t length_;
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
enum FilePhase {
|
|
|
|
FilePhaseLeadIn,
|
|
|
|
FilePhaseHeader,
|
|
|
|
FilePhaseHeaderDataGap,
|
|
|
|
FilePhaseData,
|
|
|
|
FilePhaseAtEnd
|
|
|
|
} file_phase_ = FilePhaseLeadIn;
|
|
|
|
int phase_offset_ = 0;
|
2016-08-15 23:44:41 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
int bit_phase_ = 3;
|
|
|
|
enum OutputToken {
|
|
|
|
Leader,
|
|
|
|
Zero,
|
|
|
|
One,
|
|
|
|
WordMarker,
|
|
|
|
EndOfBlock,
|
|
|
|
Silence
|
|
|
|
} output_token_;
|
|
|
|
void get_next_output_token();
|
|
|
|
uint8_t output_byte_;
|
|
|
|
uint8_t check_digit_;
|
|
|
|
uint8_t copy_mask_ = 0x80;
|
2016-08-15 23:44:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|