mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Fixes: now setting correct frame time estimate, properly enabling the timestamp attribute, and ensuring that the Electron flushes screen work at least once per host frame update.
This commit is contained in:
parent
752db78431
commit
7580d192d5
@ -318,6 +318,12 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
|||||||
return cycles;
|
return cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Machine::update_output()
|
||||||
|
{
|
||||||
|
update_display();
|
||||||
|
update_audio();
|
||||||
|
}
|
||||||
|
|
||||||
void Machine::set_tape(std::shared_ptr<Storage::Tape> tape)
|
void Machine::set_tape(std::shared_ptr<Storage::Tape> tape)
|
||||||
{
|
{
|
||||||
_tape.set_tape(tape);
|
_tape.set_tape(tape);
|
||||||
|
@ -151,6 +151,8 @@ class Machine: public CPU6502::Processor<Machine>, Tape::Delegate {
|
|||||||
|
|
||||||
virtual void tape_did_change_interrupt_status(Tape *tape);
|
virtual void tape_did_change_interrupt_status(Tape *tape);
|
||||||
|
|
||||||
|
void update_output();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
inline void update_display();
|
inline void update_display();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
- (void)doRunForNumberOfCycles:(int)numberOfCycles {
|
- (void)doRunForNumberOfCycles:(int)numberOfCycles {
|
||||||
_electron.run_for_cycles(numberOfCycles);
|
_electron.run_for_cycles(numberOfCycles);
|
||||||
|
_electron.update_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setOSROM:(nonnull NSData *)rom {
|
- (void)setOSROM:(nonnull NSData *)rom {
|
||||||
|
@ -150,8 +150,9 @@ void CRT::draw_frame(unsigned int output_width, unsigned int output_height, bool
|
|||||||
glBindBuffer(GL_ARRAY_BUFFER, _openGL_state->arrayBuffers[run]);
|
glBindBuffer(GL_ARRAY_BUFFER, _openGL_state->arrayBuffers[run]);
|
||||||
if(_run_builders[run]->uploaded_vertices != _run_builders[run]->number_of_vertices)
|
if(_run_builders[run]->uploaded_vertices != _run_builders[run]->number_of_vertices)
|
||||||
{
|
{
|
||||||
// buffersubdata can only replace existing data, not grow the pool, so we'll just have to take this hit
|
// glBufferSubData can only replace existing data, not grow the pool, so for now we'll just take this hit
|
||||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(_run_builders[run]->number_of_vertices * kCRTSizeOfVertex), &_run_builders[run]->_input_runs[0], GL_DYNAMIC_DRAW);
|
uint8_t *data = &_run_builders[run]->_input_runs[0];
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(_run_builders[run]->number_of_vertices * kCRTSizeOfVertex), data, GL_DYNAMIC_DRAW);
|
||||||
_run_builders[run]->uploaded_vertices = _run_builders[run]->number_of_vertices;
|
_run_builders[run]->uploaded_vertices = _run_builders[run]->number_of_vertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,17 +300,18 @@ char *CRT::get_fragment_shader()
|
|||||||
"in float lateralVarying;"
|
"in float lateralVarying;"
|
||||||
"in float age;"
|
"in float age;"
|
||||||
"in vec2 shadowMaskCoordinates;"
|
"in vec2 shadowMaskCoordinates;"
|
||||||
|
"in vec2 srcCoordinatesVarying;"
|
||||||
|
|
||||||
"out vec4 fragColour;"
|
"out vec4 fragColour;"
|
||||||
|
|
||||||
"uniform sampler2D texID;"
|
"uniform sampler2D texID;"
|
||||||
"uniform sampler2D shadowMaskTexID;"
|
"uniform sampler2D shadowMaskTexID;"
|
||||||
|
|
||||||
"in vec2 srcCoordinatesVarying;"
|
|
||||||
"\n%s\n"
|
"\n%s\n"
|
||||||
|
|
||||||
"void main(void)"
|
"void main(void)"
|
||||||
"{"
|
"{"
|
||||||
"fragColour = vec4(rgb_sample(srcCoordinatesVarying).rgb, 1.3 - age);"
|
"fragColour = vec4(rgb_sample(srcCoordinatesVarying).rgb, 2.0 - age);"
|
||||||
"}"
|
"}"
|
||||||
, _rgb_shader);
|
, _rgb_shader);
|
||||||
}
|
}
|
||||||
@ -348,7 +350,7 @@ void CRT::prepare_shader()
|
|||||||
glUniform1i(texIDUniform, 0);
|
glUniform1i(texIDUniform, 0);
|
||||||
glUniform1i(shadowMaskTexIDUniform, 1);
|
glUniform1i(shadowMaskTexIDUniform, 1);
|
||||||
glUniform2f(textureSizeUniform, CRTInputBufferBuilderWidth, CRTInputBufferBuilderHeight);
|
glUniform2f(textureSizeUniform, CRTInputBufferBuilderWidth, CRTInputBufferBuilderHeight);
|
||||||
glUniform1f(ticksPerFrameUniform, (GLfloat)(_cycles_per_line * _height_of_display * _time_multiplier));
|
glUniform1f(ticksPerFrameUniform, (GLfloat)(_cycles_per_line * _height_of_display));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::prepare_vertex_array()
|
void CRT::prepare_vertex_array()
|
||||||
@ -356,7 +358,7 @@ void CRT::prepare_vertex_array()
|
|||||||
glEnableVertexAttribArray((GLuint)_openGL_state->positionAttribute);
|
glEnableVertexAttribArray((GLuint)_openGL_state->positionAttribute);
|
||||||
glEnableVertexAttribArray((GLuint)_openGL_state->textureCoordinatesAttribute);
|
glEnableVertexAttribArray((GLuint)_openGL_state->textureCoordinatesAttribute);
|
||||||
glEnableVertexAttribArray((GLuint)_openGL_state->lateralAttribute);
|
glEnableVertexAttribArray((GLuint)_openGL_state->lateralAttribute);
|
||||||
glEnableVertexAttribArray((GLuint)_openGL_state->timestampBaseUniform);
|
glEnableVertexAttribArray((GLuint)_openGL_state->timestampAttribute);
|
||||||
|
|
||||||
const GLsizei vertexStride = kCRTSizeOfVertex;
|
const GLsizei vertexStride = kCRTSizeOfVertex;
|
||||||
glVertexAttribPointer((GLuint)_openGL_state->positionAttribute, 2, GL_UNSIGNED_SHORT, GL_TRUE, vertexStride, (void *)kCRTVertexOffsetOfPosition);
|
glVertexAttribPointer((GLuint)_openGL_state->positionAttribute, 2, GL_UNSIGNED_SHORT, GL_TRUE, vertexStride, (void *)kCRTVertexOffsetOfPosition);
|
||||||
|
Loading…
Reference in New Issue
Block a user