mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-09 05:25:01 +00:00
The cathode ray view no longer hard codes the frame size. So that's one less coupling. Doubled pixel output size to give sufficient sampling detail to capture the NTSC colour clock (ummm, hopefully).
This commit is contained in:
@@ -20,7 +20,7 @@ Machine::Machine()
|
|||||||
_horizontalTimer = horizontalTimerReload;
|
_horizontalTimer = horizontalTimerReload;
|
||||||
_lastOutputStateDuration = 0;
|
_lastOutputStateDuration = 0;
|
||||||
_lastOutputState = OutputState::Sync;
|
_lastOutputState = OutputState::Sync;
|
||||||
_crt = new Outputs::CRT(228, 262, 1, 4);
|
_crt = new Outputs::CRT(456, 262, 1, 4);
|
||||||
_piaTimerStatus = 0xff;
|
_piaTimerStatus = 0xff;
|
||||||
|
|
||||||
setup6502();
|
setup6502();
|
||||||
@@ -33,7 +33,7 @@ Machine::~Machine()
|
|||||||
|
|
||||||
void Machine::switch_region()
|
void Machine::switch_region()
|
||||||
{
|
{
|
||||||
_crt->set_new_timing(228, 312);
|
_crt->set_new_timing(456, 312);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::get_output_pixel(uint8_t *pixel, int offset)
|
void Machine::get_output_pixel(uint8_t *pixel, int offset)
|
||||||
@@ -127,10 +127,10 @@ void Machine::get_output_pixel(uint8_t *pixel, int offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// map that colour to an RGBA
|
// map that colour to an RGBA
|
||||||
pixel[0] = palette[outputColour >> 4][0];
|
pixel[0] = pixel[4] = palette[outputColour >> 4][0];
|
||||||
pixel[1] = palette[outputColour >> 4][1];
|
pixel[1] = pixel[5] = palette[outputColour >> 4][1];
|
||||||
pixel[2] = palette[outputColour >> 4][2];
|
pixel[2] = pixel[6] = palette[outputColour >> 4][2];
|
||||||
pixel[3] = alphaValues[(outputColour >> 1)&7];
|
pixel[3] = pixel[7] = alphaValues[(outputColour >> 1)&7];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::output_pixels(int count)
|
void Machine::output_pixels(int count)
|
||||||
@@ -175,22 +175,22 @@ void Machine::output_pixels(int count)
|
|||||||
{
|
{
|
||||||
switch(_lastOutputState)
|
switch(_lastOutputState)
|
||||||
{
|
{
|
||||||
case OutputState::Blank: _crt->output_blank(_lastOutputStateDuration); break;
|
case OutputState::Blank: _crt->output_blank(_lastOutputStateDuration*2); break;
|
||||||
case OutputState::Sync: _crt->output_sync(_lastOutputStateDuration); break;
|
case OutputState::Sync: _crt->output_sync(_lastOutputStateDuration*2); break;
|
||||||
case OutputState::Pixel: _crt->output_data(_lastOutputStateDuration, atari2600DataType); break;
|
case OutputState::Pixel: _crt->output_data(_lastOutputStateDuration*2, atari2600DataType); break;
|
||||||
}
|
}
|
||||||
_lastOutputStateDuration = 0;
|
_lastOutputStateDuration = 0;
|
||||||
_lastOutputState = state;
|
_lastOutputState = state;
|
||||||
|
|
||||||
if(state == OutputState::Pixel)
|
if(state == OutputState::Pixel)
|
||||||
{
|
{
|
||||||
_crt->allocate_write_area(160);
|
_crt->allocate_write_area(320);
|
||||||
_outputBuffer = _crt->get_write_target_for_buffer(0);
|
_outputBuffer = _crt->get_write_target_for_buffer(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state == OutputState::Pixel && _outputBuffer)
|
if(state == OutputState::Pixel && _outputBuffer)
|
||||||
get_output_pixel(&_outputBuffer[_lastOutputStateDuration * 4], 159 - _horizontalTimer);
|
get_output_pixel(&_outputBuffer[_lastOutputStateDuration * 8], 159 - _horizontalTimer);
|
||||||
|
|
||||||
// assumption here: signed shifts right; otherwise it's just
|
// assumption here: signed shifts right; otherwise it's just
|
||||||
// an attempt to avoid both the % operator and a conditional
|
// an attempt to avoid both the % operator and a conditional
|
||||||
|
@@ -22,6 +22,10 @@
|
|||||||
GLint _textureCoordinatesAttribute;
|
GLint _textureCoordinatesAttribute;
|
||||||
GLint _lateralAttribute;
|
GLint _lateralAttribute;
|
||||||
|
|
||||||
|
GLint _texIDUniform;
|
||||||
|
GLint _textureSizeUniform;
|
||||||
|
GLint _alphaUniform;
|
||||||
|
|
||||||
GLuint _textureName;
|
GLuint _textureName;
|
||||||
CRTSize _textureSize;
|
CRTSize _textureSize;
|
||||||
|
|
||||||
@@ -161,11 +165,13 @@ const char *vertexShader =
|
|||||||
"out vec2 srcCoordinatesVarying;\n"
|
"out vec2 srcCoordinatesVarying;\n"
|
||||||
"out float lateralVarying;\n"
|
"out float lateralVarying;\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"uniform vec2 textureSize;\n"
|
||||||
|
"\n"
|
||||||
"void main (void)\n"
|
"void main (void)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"srcCoordinatesVarying = vec2(srcCoordinates.x / 512.0, (srcCoordinates.y + 0.5) / 512.0);\n"
|
"srcCoordinatesVarying = vec2(srcCoordinates.x / textureSize.x, (srcCoordinates.y + 0.5) / textureSize.y);\n"
|
||||||
"lateralVarying = lateral + 1.0707963267949;\n"
|
"lateralVarying = lateral + 1.0707963267949;\n"
|
||||||
"gl_Position = vec4(position.x * 2.0 - 1.0, 1.0 - position.y * 2.0 + position.x / 131.0, 0.0, 1.0);\n"
|
"gl_Position = vec4(position.x * 2.0 - 1.0, 1.0 - position.y * 2.0 , 0.0, 1.0);\n" // + position.x / 131.0
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
// TODO: this should be factored out and be per project
|
// TODO: this should be factored out and be per project
|
||||||
@@ -175,6 +181,7 @@ const char *fragmentShader =
|
|||||||
"in vec2 srcCoordinatesVarying;\n"
|
"in vec2 srcCoordinatesVarying;\n"
|
||||||
"in float lateralVarying;"
|
"in float lateralVarying;"
|
||||||
"out vec4 fragColour;\n"
|
"out vec4 fragColour;\n"
|
||||||
|
"\n"
|
||||||
"uniform sampler2D texID;\n"
|
"uniform sampler2D texID;\n"
|
||||||
"uniform float alpha;\n"
|
"uniform float alpha;\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -231,9 +238,12 @@ const char *fragmentShader =
|
|||||||
|
|
||||||
glUseProgram(_shaderProgram);
|
glUseProgram(_shaderProgram);
|
||||||
|
|
||||||
_positionAttribute = glGetAttribLocation(_shaderProgram, "position");
|
_positionAttribute = glGetAttribLocation(_shaderProgram, "position");
|
||||||
_textureCoordinatesAttribute = glGetAttribLocation(_shaderProgram, "srcCoordinates");
|
_textureCoordinatesAttribute = glGetAttribLocation(_shaderProgram, "srcCoordinates");
|
||||||
_lateralAttribute = glGetAttribLocation(_shaderProgram, "lateral");
|
_lateralAttribute = glGetAttribLocation(_shaderProgram, "lateral");
|
||||||
|
_texIDUniform = glGetUniformLocation(_shaderProgram, "texID");
|
||||||
|
_alphaUniform = glGetUniformLocation(_shaderProgram, "alpha");
|
||||||
|
_textureSizeUniform = glGetUniformLocation(_shaderProgram, "textureSize");
|
||||||
|
|
||||||
glEnableVertexAttribArray(_positionAttribute);
|
glEnableVertexAttribArray(_positionAttribute);
|
||||||
glEnableVertexAttribArray(_textureCoordinatesAttribute);
|
glEnableVertexAttribArray(_textureCoordinatesAttribute);
|
||||||
@@ -260,6 +270,7 @@ const char *fragmentShader =
|
|||||||
|
|
||||||
if (_crtFrame)
|
if (_crtFrame)
|
||||||
{
|
{
|
||||||
|
glUniform2f(_textureSizeUniform, _crtFrame->size.width, _crtFrame->size.height);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, _crtFrame->number_of_runs*6);
|
glDrawArrays(GL_TRIANGLES, 0, _crtFrame->number_of_runs*6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,8 +57,8 @@ CRT::CRT(int cycles_per_line, int height_of_display, int number_of_buffers, ...)
|
|||||||
|
|
||||||
// generate buffers for signal storage as requested — format is
|
// generate buffers for signal storage as requested — format is
|
||||||
// number of buffers, size of buffer 1, size of buffer 2...
|
// number of buffers, size of buffer 1, size of buffer 2...
|
||||||
const int bufferWidth = 512;
|
const int bufferWidth = 2048;
|
||||||
const int bufferHeight = 512;
|
const int bufferHeight = 2048;
|
||||||
for(int frame = 0; frame < sizeof(_frame_builders) / sizeof(*_frame_builders); frame++)
|
for(int frame = 0; frame < sizeof(_frame_builders) / sizeof(*_frame_builders); frame++)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
|
Reference in New Issue
Block a user