2015-07-19 17:36:27 +00:00
|
|
|
//
|
|
|
|
// CRT.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 19/07/2015.
|
|
|
|
// Copyright © 2015 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef CRT_cpp
|
|
|
|
#define CRT_cpp
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Outputs {
|
|
|
|
|
|
|
|
class CRT {
|
|
|
|
public:
|
2015-07-20 01:21:34 +00:00
|
|
|
CRT(int cycles_per_line, int number_of_buffers, ...);
|
|
|
|
~CRT();
|
|
|
|
|
2015-07-19 17:36:27 +00:00
|
|
|
void output_sync(int number_of_cycles);
|
2015-07-20 01:21:34 +00:00
|
|
|
void output_level(int number_of_cycles, std::string type);
|
|
|
|
void output_data(int number_of_cycles, std::string type);
|
2015-07-19 22:32:42 +00:00
|
|
|
|
|
|
|
struct CRTRun {
|
|
|
|
struct Point {
|
|
|
|
float x, y;
|
|
|
|
} start_point, end_point;
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
Sync, Level, Data
|
|
|
|
} type;
|
|
|
|
|
2015-07-20 01:21:34 +00:00
|
|
|
std::string data_type;
|
2015-07-19 22:32:42 +00:00
|
|
|
uint8_t *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CRTDelegate {
|
|
|
|
public:
|
|
|
|
void crt_did_start_vertical_retrace_with_runs(CRTRun *runs, int number_of_runs);
|
|
|
|
};
|
|
|
|
void set_crt_delegate(CRTDelegate *);
|
|
|
|
|
2015-07-20 01:21:34 +00:00
|
|
|
void allocate_write_area(int required_length);
|
|
|
|
uint8_t *get_write_target_for_buffer(int buffer);
|
|
|
|
|
2015-07-19 22:32:42 +00:00
|
|
|
private:
|
|
|
|
CRTDelegate *_delegate;
|
|
|
|
|
|
|
|
int _syncCapacitorChargeLevel;
|
|
|
|
float _horizontalOffset, _verticalOffset;
|
2015-07-20 01:21:34 +00:00
|
|
|
|
|
|
|
uint8_t **_buffers;
|
|
|
|
int *_bufferSizes;
|
|
|
|
int _numberOfBuffers;
|
|
|
|
|
|
|
|
int _write_allocation_pointer, _write_target_pointer;
|
2015-07-19 17:36:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* CRT_cpp */
|