2017-06-06 21:53:23 +00:00
|
|
|
//
|
|
|
|
// Video.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 06/06/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#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-06-06 21:53:23 +00:00
|
|
|
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
2017-06-06 22:01:33 +00:00
|
|
|
|
2017-07-23 03:02:28 +00:00
|
|
|
/// Advances time by @c 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:
|
|
|
|
bool sync_;
|
|
|
|
uint8_t *line_data_, *line_data_pointer_;
|
|
|
|
unsigned int cycles_since_update_;
|
|
|
|
std::shared_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 */
|