1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-13 07:30:21 +00:00

Corrects order-of-initialisation errors in the CPC (again), TextureBuilder, TextureTarget, Z80, MFM parser and binary tape player.

This commit is contained in:
Thomas Harte 2017-11-10 22:57:03 -05:00
parent d9e56711ce
commit cb0f58ab7a
10 changed files with 26 additions and 43 deletions

View File

@ -678,8 +678,9 @@ class ConcreteMachine:
crtc_(Motorola::CRTC::HD6845S, crtc_bus_handler_), crtc_(Motorola::CRTC::HD6845S, crtc_bus_handler_),
i8255_port_handler_(key_state_, crtc_, ay_, tape_player_), i8255_port_handler_(key_state_, crtc_, ay_, tape_player_),
i8255_(i8255_port_handler_), i8255_(i8255_port_handler_),
crtc_counter_(HalfCycles(4)), // This starts the CRTC exactly out of phase with the CPU's memory accesses tape_player_(8000000),
tape_player_(8000000) { crtc_counter_(HalfCycles(4)) // This starts the CRTC exactly out of phase with the CPU's memory accesses
{
// primary clock is 4Mhz // primary clock is 4Mhz
set_clock_rate(4000000); set_clock_rate(4000000);

View File

@ -51,12 +51,7 @@ struct DefaultBookender: public TextureBuilder::Bookender {
} }
TextureBuilder::TextureBuilder(size_t bytes_per_pixel, GLenum texture_unit) : TextureBuilder::TextureBuilder(size_t bytes_per_pixel, GLenum texture_unit) :
bytes_per_pixel_(bytes_per_pixel), bytes_per_pixel_(bytes_per_pixel) {
write_areas_start_x_(0),
write_areas_start_y_(0),
first_unsubmitted_y_(0),
is_full_(false),
number_of_write_areas_(0) {
image_.resize(bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight); image_.resize(bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight);
glGenTextures(1, &texture_name_); glGenTextures(1, &texture_name_);

View File

@ -127,15 +127,15 @@ class TextureBuilder {
// the list of write areas that have ascended to the flush queue // the list of write areas that have ascended to the flush queue
std::vector<WriteArea> write_areas_; std::vector<WriteArea> write_areas_;
size_t number_of_write_areas_; size_t number_of_write_areas_ = 0;
bool is_full_, was_full_; bool is_full_ = false, was_full_ = false;
uint16_t first_unsubmitted_y_; uint16_t first_unsubmitted_y_ = 0;
inline uint8_t *pointer_to_location(uint16_t x, uint16_t y); inline uint8_t *pointer_to_location(uint16_t x, uint16_t y);
// Usually: the start position for the current batch of write areas. // Usually: the start position for the current batch of write areas.
// Caveat: reset to the origin upon a submit. So used in comparison by flush to // Caveat: reset to the origin upon a submit. So used in comparison by flush to
// determine whether the current batch of write areas needs to be relocated. // determine whether the current batch of write areas needs to be relocated.
uint16_t write_areas_start_x_, write_areas_start_y_; uint16_t write_areas_start_x_ = 0, write_areas_start_y_ = 0;
std::unique_ptr<Bookender> bookender_; std::unique_ptr<Bookender> bookender_;
}; };

View File

@ -15,11 +15,8 @@ using namespace OpenGL;
TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit, GLint mag_filter) : TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit, GLint mag_filter) :
_width(width), _width(width),
_height(height), _height(height),
_pixel_shader(nullptr), _texture_unit(texture_unit),
_drawing_vertex_array(0), _set_aspect_ratio(0.0f) {
_drawing_array_buffer(0),
_set_aspect_ratio(0.0f),
_texture_unit(texture_unit) {
glGenFramebuffers(1, &_framebuffer); glGenFramebuffers(1, &_framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer);

View File

@ -73,7 +73,7 @@ class TextureTarget {
GLenum _texture_unit; GLenum _texture_unit;
std::unique_ptr<Shader> _pixel_shader; std::unique_ptr<Shader> _pixel_shader;
GLuint _drawing_vertex_array, _drawing_array_buffer; GLuint _drawing_vertex_array = 0, _drawing_array_buffer = 0;
float _set_aspect_ratio; float _set_aspect_ratio;
}; };

View File

@ -11,17 +11,7 @@
using namespace CPU::Z80; using namespace CPU::Z80;
ProcessorStorage::ProcessorStorage() : ProcessorStorage::ProcessorStorage() {
halt_mask_(0xff),
interrupt_mode_(0),
wait_line_(false),
request_status_(Interrupt::PowerOn),
last_request_status_(Interrupt::PowerOn),
irq_line_(false),
nmi_line_(false),
bus_request_line_(false),
pc_increment_(1),
scheduled_program_counter_(nullptr) {
set_flags(0xff); set_flags(0xff);
} }

View File

@ -121,8 +121,8 @@ class ProcessorStorage {
RegisterPair ix_, iy_, pc_, sp_; RegisterPair ix_, iy_, pc_, sp_;
RegisterPair ir_, refresh_addr_; RegisterPair ir_, refresh_addr_;
bool iff1_, iff2_; bool iff1_, iff2_;
int interrupt_mode_; int interrupt_mode_ = 0;
uint16_t pc_increment_; uint16_t pc_increment_ = 1;
uint8_t sign_result_; // the sign flag is set if the value in sign_result_ is negative uint8_t sign_result_; // the sign flag is set if the value in sign_result_ is negative
uint8_t zero_result_; // the zero flag is set if the value in zero_result_ is zero uint8_t zero_result_; // the zero flag is set if the value in zero_result_ is zero
uint8_t half_carry_result_; // the half-carry flag is set if bit 4 of half_carry_result_ is set uint8_t half_carry_result_; // the half-carry flag is set if bit 4 of half_carry_result_ is set
@ -130,7 +130,7 @@ class ProcessorStorage {
uint8_t parity_overflow_result_; // the parity/overflow flag is set if the corresponding bit of parity_overflow_result_ is set uint8_t parity_overflow_result_; // the parity/overflow flag is set if the corresponding bit of parity_overflow_result_ is set
uint8_t subtract_flag_; // contains a copy of the subtract flag in isolation uint8_t subtract_flag_; // contains a copy of the subtract flag in isolation
uint8_t carry_result_; // the carry flag is set if bit 0 of carry_result_ is set uint8_t carry_result_; // the carry flag is set if bit 0 of carry_result_ is set
uint8_t halt_mask_; uint8_t halt_mask_ = 0xff;
HalfCycles number_of_cycles_; HalfCycles number_of_cycles_;
@ -140,17 +140,17 @@ class ProcessorStorage {
Reset = 0x04, Reset = 0x04,
PowerOn = 0x08 PowerOn = 0x08
}; };
uint8_t request_status_; uint8_t request_status_ = Interrupt::PowerOn;
uint8_t last_request_status_; uint8_t last_request_status_ = Interrupt::PowerOn;
bool irq_line_, nmi_line_; bool irq_line_ = false, nmi_line_ = false;
bool bus_request_line_; bool bus_request_line_ = false;
bool wait_line_; bool wait_line_ = false;
uint8_t operation_; uint8_t operation_;
RegisterPair temp16_, memptr_; RegisterPair temp16_, memptr_;
uint8_t temp8_; uint8_t temp8_;
const MicroOp *scheduled_program_counter_; const MicroOp *scheduled_program_counter_ = nullptr;
std::vector<MicroOp> conditional_call_untaken_program_; std::vector<MicroOp> conditional_call_untaken_program_;
std::vector<MicroOp> reset_program_; std::vector<MicroOp> reset_program_;

View File

@ -15,7 +15,7 @@
using namespace Storage::Encodings::MFM; using namespace Storage::Encodings::MFM;
Parser::Parser(bool is_mfm, const std::shared_ptr<Storage::Disk::Disk> &disk) : Parser::Parser(bool is_mfm, const std::shared_ptr<Storage::Disk::Disk> &disk) :
is_mfm_(is_mfm), disk_(disk) {} disk_(disk), is_mfm_(is_mfm) {}
void Parser::install_sectors_from_track(const Storage::Disk::Track::Address &address) { void Parser::install_sectors_from_track(const Storage::Disk::Track::Address &address) {
if(sectors_by_address_by_track_.find(address) != sectors_by_address_by_track_.end()) { if(sectors_by_address_by_track_.find(address) != sectors_by_address_by_track_.end()) {

View File

@ -117,7 +117,7 @@ void TapePlayer::process_next_event() {
#pragma mark - Binary Player #pragma mark - Binary Player
BinaryTapePlayer::BinaryTapePlayer(unsigned int input_clock_rate) : BinaryTapePlayer::BinaryTapePlayer(unsigned int input_clock_rate) :
TapePlayer(input_clock_rate), motor_is_running_(false), input_level_(false), delegate_(nullptr) TapePlayer(input_clock_rate)
{} {}
bool BinaryTapePlayer::is_sleeping() { bool BinaryTapePlayer::is_sleeping() {

View File

@ -146,10 +146,10 @@ class BinaryTapePlayer: public TapePlayer {
bool is_sleeping(); bool is_sleeping();
protected: protected:
Delegate *delegate_; Delegate *delegate_ = nullptr;
virtual void process_input_pulse(const Storage::Tape::Tape::Pulse &pulse); virtual void process_input_pulse(const Storage::Tape::Tape::Pulse &pulse);
bool input_level_; bool input_level_ = false;
bool motor_is_running_; bool motor_is_running_ = false;
}; };
} }