From 66f2c10c044a7a77bbf336929969f5f2c4876408 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 19 Apr 2016 21:00:48 -0400 Subject: [PATCH] Resolved potential crash if tape requests are made without one inserted. Softened glFinish to glFlush, though I'm still not sure I should strictly need even that. --- Machines/Electron/Electron.cpp | 10 +++++++++- Machines/Electron/Electron.hpp | 4 ++++ Outputs/CRT/Internals/CRTOpenGL.cpp | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index a1e2465b6..a153b8144 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -304,6 +304,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin { if( _use_fast_tape_hack && + _tape.has_tape() && (operation == CPU6502::BusOperation::ReadOpcode) && ( (address == 0xf4e5) || (address == 0xf4e6) || // double NOPs at 0xf4e5, 0xf6de, 0xf6fa and 0xfa51 @@ -886,7 +887,14 @@ void Tape::set_tape(std::shared_ptr tape) inline void Tape::get_next_tape_pulse() { _input.time_into_pulse = 0; - _input.current_pulse = _tape->get_next_pulse(); + if(_tape) + _input.current_pulse = _tape->get_next_pulse(); + else + { + _input.current_pulse.length.length = 1; + _input.current_pulse.length.clock_rate = 1; + _input.current_pulse.type = Storage::Tape::Pulse::Zero; + } if(_input.pulse_stepper == nullptr || _input.current_pulse.length.clock_rate != _input.pulse_stepper->get_output_rate()) { _input.pulse_stepper = std::unique_ptr(new SignalProcessing::Stepper(_input.current_pulse.length.clock_rate, 2000000)); diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index afafba2ee..dfd8818ac 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -63,6 +63,10 @@ class Tape { Tape(); void set_tape(std::shared_ptr tape); + inline bool has_tape() + { + return (bool)_tape; + } inline uint8_t get_data_register(); inline void set_data_register(uint8_t value); diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index dfe3a67eb..cc007e43d 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -229,7 +229,6 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out } // transfer to screen - glFinish(); glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer); compositeTexture->bind_texture(); perform_output_stage(output_width, output_height, composite_output_shader_program.get()); @@ -287,6 +286,8 @@ void OpenGLOutputBuilder::perform_output_stage(unsigned int output_width, unsign { // draw glUniform4fv(timestampBaseUniform, 1, timestampBases); + glFlush(); + GLsizei primitive_count = (GLsizei)(count / OutputVertexSize); GLsizei max_count = (GLsizei)((OutputVertexBufferDataSize - start) / OutputVertexSize); if(primitive_count < max_count)