2017-06-06 21:53:23 +00:00
|
|
|
//
|
|
|
|
// Video.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 06/06/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-06-06 21:53:23 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Machines_ZX8081_Video_hpp
|
|
|
|
#define Machines_ZX8081_Video_hpp
|
|
|
|
|
|
|
|
#include "../../Outputs/CRT/CRT.hpp"
|
2017-07-26 00:20:55 +00:00
|
|
|
#include "../../ClockReceiver/ClockReceiver.hpp"
|
2017-06-06 21:53:23 +00:00
|
|
|
|
|
|
|
namespace ZX8081 {
|
|
|
|
|
2017-06-06 22:01:33 +00:00
|
|
|
/*!
|
|
|
|
Packages a ZX80/81-style video feed into a CRT-compatible waveform.
|
|
|
|
|
|
|
|
While sync is active, this feed will output the sync level.
|
|
|
|
|
|
|
|
While sync is inactive, this feed will output the white level unless it is supplied
|
|
|
|
with a byte to output. When a byte is supplied for output, it will be interpreted as
|
|
|
|
a 1-bit graphic and output over the next 4 cycles, picking between the white level
|
|
|
|
and the black level.
|
|
|
|
*/
|
2017-07-27 11:40:02 +00:00
|
|
|
class Video {
|
2017-06-06 21:53:23 +00:00
|
|
|
public:
|
2017-06-06 22:01:33 +00:00
|
|
|
/// Constructs an instance of the video feed; a CRT is also created.
|
2017-06-06 21:53:23 +00:00
|
|
|
Video();
|
2017-06-06 22:01:33 +00:00
|
|
|
/// @returns The CRT this video feed is feeding.
|
2017-12-18 02:26:06 +00:00
|
|
|
Outputs::CRT::CRT *get_crt();
|
2017-06-06 22:01:33 +00:00
|
|
|
|
2018-04-15 22:00:51 +00:00
|
|
|
/// Advances time by @c half-cycles.
|
2017-07-28 02:05:29 +00:00
|
|
|
void run_for(const HalfCycles);
|
2017-06-06 22:01:33 +00:00
|
|
|
/// Forces output to catch up to the current output position.
|
2017-06-06 21:53:23 +00:00
|
|
|
void flush();
|
|
|
|
|
2017-06-06 22:01:33 +00:00
|
|
|
/// Sets the current sync output.
|
2017-06-06 21:53:23 +00:00
|
|
|
void set_sync(bool sync);
|
2017-06-06 22:01:33 +00:00
|
|
|
/// Causes @c byte to be serialised into pixels and output over the next four cycles.
|
2017-06-06 21:53:23 +00:00
|
|
|
void output_byte(uint8_t byte);
|
|
|
|
|
|
|
|
private:
|
2017-11-10 03:14:22 +00:00
|
|
|
bool sync_ = false;
|
|
|
|
uint8_t *line_data_ = nullptr;
|
|
|
|
uint8_t *line_data_pointer_ = nullptr;
|
2018-06-02 22:25:00 +00:00
|
|
|
HalfCycles time_since_update_ = 0;
|
2017-12-18 02:26:06 +00:00
|
|
|
std::unique_ptr<Outputs::CRT::CRT> crt_;
|
2017-06-06 22:01:33 +00:00
|
|
|
|
|
|
|
void flush(bool next_sync);
|
2017-06-06 21:53:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Video_hpp */
|