mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
Added a helper to calculate a visible rect based on output timings, used it to scale the Electron output up to the full window size.
This commit is contained in:
parent
a3c2cd880e
commit
7276a06cc0
@ -67,6 +67,7 @@ void Machine::setup_output()
|
||||
// "return vec4(1.0);"
|
||||
"}");
|
||||
_crt->set_output_device(Outputs::CRT::Monitor);
|
||||
_crt->set_visible_area(_crt->get_rect_for_area(first_graphics_line - 3, 256, first_graphics_cycle * crt_cycles_multiplier, 80 * crt_cycles_multiplier, 4.0f / 3.0f));
|
||||
|
||||
// The maximum output frequency is 62500Hz and all other permitted output frequencies are integral divisions of that;
|
||||
// however setting the speaker on or off can happen on any 2Mhz cycle, and probably (?) takes effect immediately. So
|
||||
|
@ -19,7 +19,6 @@ class Atari2600Document: MachineDocument {
|
||||
override func windowControllerDidLoadNib(aController: NSWindowController) {
|
||||
super.windowControllerDidLoadNib(aController)
|
||||
atari2600.view = openGLView
|
||||
// openGLView.frameBounds = CGRectMake(0.1, 0.1, 0.8, 0.8)
|
||||
}
|
||||
|
||||
override class func autosavesInPlace() -> Bool {
|
||||
|
@ -357,3 +357,41 @@ void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider
|
||||
};
|
||||
output_scan(&scan);
|
||||
}
|
||||
|
||||
Outputs::CRT::Rect CRT::get_rect_for_area(int first_line_after_sync, int number_of_lines, int first_cycle_after_sync, int number_of_cycles, float aspect_ratio)
|
||||
{
|
||||
first_cycle_after_sync *= _time_multiplier;
|
||||
number_of_cycles *= _time_multiplier;
|
||||
|
||||
// determine prima facie x extent
|
||||
unsigned int horizontal_period = _horizontal_flywheel->get_standard_period();
|
||||
unsigned int horizontal_scan_period = _horizontal_flywheel->get_scan_period();
|
||||
unsigned int horizontal_retrace_period = horizontal_period - horizontal_scan_period;
|
||||
|
||||
float start_x = (float)((unsigned)first_cycle_after_sync - horizontal_retrace_period) / (float)horizontal_scan_period;
|
||||
float width = (float)number_of_cycles / (float)horizontal_scan_period;
|
||||
|
||||
// determine prima facie y extent
|
||||
unsigned int vertical_period = _vertical_flywheel->get_standard_period();
|
||||
unsigned int vertical_scan_period = _vertical_flywheel->get_scan_period();
|
||||
unsigned int vertical_retrace_period = vertical_period - vertical_scan_period;
|
||||
float start_y = (float)(((unsigned)first_line_after_sync * horizontal_period) - vertical_retrace_period) / (float)vertical_scan_period;
|
||||
float height = (float)((unsigned)number_of_lines * horizontal_period) / vertical_scan_period;
|
||||
|
||||
// adjust to ensure aspect ratio is correct
|
||||
float adjusted_aspect_ratio = (3.0f*aspect_ratio / 4.0f);
|
||||
float ideal_width = height * adjusted_aspect_ratio;
|
||||
if(ideal_width > width)
|
||||
{
|
||||
start_x -= (ideal_width - width) * 0.5f;
|
||||
width = ideal_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
float ideal_height = width / adjusted_aspect_ratio;
|
||||
start_y -= (ideal_height - height) * 0.5f;
|
||||
height = ideal_height;
|
||||
}
|
||||
|
||||
return Rect(start_x, start_y, width, height);
|
||||
}
|
||||
|
@ -247,6 +247,8 @@ class CRT {
|
||||
{
|
||||
_openGL_output_builder->set_visible_area(visible_area);
|
||||
}
|
||||
|
||||
Rect get_rect_for_area(int first_line_after_sync, int number_of_lines, int first_cycle_after_sync, int number_of_cycles, float aspect_ratio);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ struct Rect {
|
||||
|
||||
Rect() {}
|
||||
Rect(float x, float y, float width, float height) :
|
||||
origin({.x = x, .y = y}), size({.width = width, .height =height}) {}
|
||||
origin({.x = x, .y = y}), size({.width = width, .height = height}) {}
|
||||
};
|
||||
|
||||
enum DisplayType {
|
||||
|
Loading…
Reference in New Issue
Block a user