1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-10-25 09:27:01 +00:00

Adopt normative public-then-private ordering.

This commit is contained in:
Thomas Harte
2025-10-06 13:28:04 -04:00
parent ab73b4de6b
commit 2496257bcf

View File

@@ -54,61 +54,6 @@ struct Delegate {
colour phase for colour composite video.
*/
class CRT {
private:
// Incoming clock lengths are multiplied by @c time_multiplier_ to increase precision across the line.
int time_multiplier_ = 1;
// Two flywheels regulate scanning; the vertical with a range much greater than the horizontal.
Flywheel horizontal_flywheel_, vertical_flywheel_;
// A divider to reduce the vertcial flywheel into a 16-bit range.
int vertical_flywheel_output_divider_ = 1;
int cycles_since_horizontal_sync_ = 0;
/// Samples the flywheels to generate a raster endpoint, tagging it with the specified @c data_offset.
Display::ScanTarget::Scan::EndPoint end_point(uint16_t data_offset);
struct Scan {
enum Type {
Sync, Level, Data, Blank, ColourBurst
} type = Scan::Blank;
int number_of_cycles = 0, number_of_samples = 0;
uint8_t phase = 0, amplitude = 0;
};
void output_scan(const Scan &scan);
uint8_t colour_burst_amplitude_ = 30;
int colour_burst_phase_adjustment_ = 0xff;
int64_t phase_denominator_ = 1;
int64_t phase_numerator_ = 0;
int64_t colour_cycle_numerator_ = 1;
bool is_alternate_line_ = false, phase_alternates_ = false, should_be_alternate_line_ = false;
void advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_requested, const Scan::Type type, int number_of_samples);
Flywheel::SyncEvent get_next_vertical_sync_event(bool vsync_is_requested, int cycles_to_run_for, int *cycles_advanced);
Flywheel::SyncEvent get_next_horizontal_sync_event(bool hsync_is_requested, int cycles_to_run_for, int *cycles_advanced);
Delegate *delegate_ = nullptr;
int frames_since_last_delegate_call_ = 0;
bool is_receiving_sync_ = false; // @c true if the CRT is currently receiving sync (i.e. this is for edge triggering of horizontal sync); @c false otherwise.
bool is_accumulating_sync_ = false; // @c true if a sync level has triggered the suspicion that a vertical sync might be in progress; @c false otherwise.
bool is_refusing_sync_ = false; // @c true once a vertical sync has been detected, until a prolonged period of non-sync has ended suspicion of an ongoing vertical sync.
int sync_capacitor_charge_threshold_ = 0; // Charges up during times of sync and depletes otherwise; needs to hit a required threshold to trigger a vertical sync.
int cycles_of_sync_ = 0; // The number of cycles since the potential vertical sync began.
int cycles_since_sync_ = 0; // The number of cycles since last in sync, for defeating the possibility of this being a vertical sync.
int cycles_per_line_ = 1;
Outputs::Display::ScanTarget *scan_target_ = &Outputs::Display::NullScanTarget::singleton;
Outputs::Display::ScanTarget::Modals scan_target_modals_;
static constexpr uint8_t DefaultAmplitude = 41; // Based upon a black level to maximum excursion and positive burst peak of: NTSC: 882 & 143; PAL: 933 & 150.
#ifndef NDEBUG
size_t allocated_data_length_ = std::numeric_limits<size_t>::min();
#endif
public:
/*! Constructs the CRT with a specified clock rate, height and colour subcarrier frequency.
The requested number of buffers, each with the requested number of bytes per pixel,
@@ -346,6 +291,61 @@ public:
/*! Sets the output brightness. */
void set_brightness(float);
private:
// Incoming clock lengths are multiplied by @c time_multiplier_ to increase precision across the line.
int time_multiplier_ = 1;
// Two flywheels regulate scanning; the vertical with a range much greater than the horizontal.
Flywheel horizontal_flywheel_, vertical_flywheel_;
// A divider to reduce the vertcial flywheel into a 16-bit range.
int vertical_flywheel_output_divider_ = 1;
int cycles_since_horizontal_sync_ = 0;
/// Samples the flywheels to generate a raster endpoint, tagging it with the specified @c data_offset.
Display::ScanTarget::Scan::EndPoint end_point(uint16_t data_offset);
struct Scan {
enum Type {
Sync, Level, Data, Blank, ColourBurst
} type = Scan::Blank;
int number_of_cycles = 0, number_of_samples = 0;
uint8_t phase = 0, amplitude = 0;
};
void output_scan(const Scan &scan);
uint8_t colour_burst_amplitude_ = 30;
int colour_burst_phase_adjustment_ = 0xff;
int64_t phase_denominator_ = 1;
int64_t phase_numerator_ = 0;
int64_t colour_cycle_numerator_ = 1;
bool is_alternate_line_ = false, phase_alternates_ = false, should_be_alternate_line_ = false;
void advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_requested, const Scan::Type type, int number_of_samples);
Flywheel::SyncEvent get_next_vertical_sync_event(bool vsync_is_requested, int cycles_to_run_for, int *cycles_advanced);
Flywheel::SyncEvent get_next_horizontal_sync_event(bool hsync_is_requested, int cycles_to_run_for, int *cycles_advanced);
Delegate *delegate_ = nullptr;
int frames_since_last_delegate_call_ = 0;
bool is_receiving_sync_ = false; // @c true if the CRT is currently receiving sync (i.e. this is for edge triggering of horizontal sync); @c false otherwise.
bool is_accumulating_sync_ = false; // @c true if a sync level has triggered the suspicion that a vertical sync might be in progress; @c false otherwise.
bool is_refusing_sync_ = false; // @c true once a vertical sync has been detected, until a prolonged period of non-sync has ended suspicion of an ongoing vertical sync.
int sync_capacitor_charge_threshold_ = 0; // Charges up during times of sync and depletes otherwise; needs to hit a required threshold to trigger a vertical sync.
int cycles_of_sync_ = 0; // The number of cycles since the potential vertical sync began.
int cycles_since_sync_ = 0; // The number of cycles since last in sync, for defeating the possibility of this being a vertical sync.
int cycles_per_line_ = 1;
Outputs::Display::ScanTarget *scan_target_ = &Outputs::Display::NullScanTarget::singleton;
Outputs::Display::ScanTarget::Modals scan_target_modals_;
static constexpr uint8_t DefaultAmplitude = 41; // Based upon a black level to maximum excursion and positive burst peak of: NTSC: 882 & 143; PAL: 933 & 150.
#ifndef NDEBUG
size_t allocated_data_length_ = std::numeric_limits<size_t>::min();
#endif
};
}