From 4cbc87a17dba3641a2325b3bc699820bc904c74f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 10 Nov 2017 22:20:44 -0500 Subject: [PATCH] Corrects out-of-order initialisations for the 1770, Atari 2600 joystick, Pitfall II bus extender, Microdisc and 6502. --- Components/1770/1770.cpp | 20 +---------- Components/1770/1770.hpp | 33 +++++++++---------- Machines/Atari2600/Atari2600.cpp | 2 +- Machines/Atari2600/Cartridges/Pitfall2.hpp | 14 +++----- Machines/Oric/Microdisc.cpp | 8 +---- Machines/Oric/Microdisc.hpp | 10 +++--- .../6502/Implementation/6502Storage.cpp | 14 +------- .../6502/Implementation/6502Storage.hpp | 20 +++++------ 8 files changed, 40 insertions(+), 81 deletions(-) diff --git a/Components/1770/1770.cpp b/Components/1770/1770.cpp index f71756601..7efc7f426 100644 --- a/Components/1770/1770.cpp +++ b/Components/1770/1770.cpp @@ -11,28 +11,10 @@ using namespace WD; -WD1770::Status::Status() : - type(Status::One), - write_protect(false), - record_type(false), - spin_up(false), - record_not_found(false), - crc_error(false), - seek_error(false), - lost_data(false), - data_request(false), - interrupt_request(false), - busy(false) {} - WD1770::WD1770(Personality p) : Storage::Disk::MFMController(8000000), - interesting_event_mask_(static_cast(Event1770::Command)), - resume_point_(0), - delay_time_(0), - index_hole_count_target_(-1), - delegate_(nullptr), personality_(p), - head_is_loaded_(false) { + interesting_event_mask_(static_cast(Event1770::Command)) { set_is_double_density(false); posit_event(static_cast(Event1770::Command)); } diff --git a/Components/1770/1770.hpp b/Components/1770/1770.hpp index 0f8205a0d..aa15a5259 100644 --- a/Components/1770/1770.hpp +++ b/Components/1770/1770.hpp @@ -85,20 +85,19 @@ class WD1770: public Storage::Disk::MFMController { inline bool has_head_load_line() { return (personality_ == P1793 ); } struct Status { - Status(); - bool write_protect; - bool record_type; - bool spin_up; - bool record_not_found; - bool crc_error; - bool seek_error; - bool lost_data; - bool data_request; - bool interrupt_request; - bool busy; + bool write_protect = false; + bool record_type = false; + bool spin_up = false; + bool record_not_found = false; + bool crc_error = false; + bool seek_error = false; + bool lost_data = false; + bool data_request = false; + bool interrupt_request = false; + bool busy = false; enum { One, Two, Three - } type; + } type = One; } status_; uint8_t track_; uint8_t sector_; @@ -106,7 +105,7 @@ class WD1770: public Storage::Disk::MFMController { uint8_t command_; int index_hole_count_; - int index_hole_count_target_; + int index_hole_count_target_ = -1; int distance_into_section_; int step_direction_; @@ -121,17 +120,17 @@ class WD1770: public Storage::Disk::MFMController { }; void posit_event(int type); int interesting_event_mask_; - int resume_point_; - unsigned int delay_time_; + int resume_point_ = 0; + unsigned int delay_time_ = 0; // ID buffer uint8_t header_[6]; // 1793 head-loading logic - bool head_is_loaded_; + bool head_is_loaded_ = false; // delegate - Delegate *delegate_; + Delegate *delegate_ = nullptr; }; } diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 34e67e806..7806e9282 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -53,8 +53,8 @@ class Joystick: public Inputs::Joystick { } private: - size_t shift_, fire_tia_input_; Bus *bus_; + size_t shift_, fire_tia_input_; }; class ConcreteMachine: diff --git a/Machines/Atari2600/Cartridges/Pitfall2.hpp b/Machines/Atari2600/Cartridges/Pitfall2.hpp index 36cd1ff59..aed11320d 100644 --- a/Machines/Atari2600/Cartridges/Pitfall2.hpp +++ b/Machines/Atari2600/Cartridges/Pitfall2.hpp @@ -16,11 +16,7 @@ class Pitfall2: public BusExtender { public: Pitfall2(uint8_t *rom_base, size_t rom_size) : BusExtender(rom_base, rom_size), - rom_ptr_(rom_base), - random_number_generator_(0), - featcher_address_{0, 0, 0, 0, 0, 0, 0, 0}, - mask_{0, 0, 0, 0, 0, 0, 0, 0}, - cycles_since_audio_update_(0) {} + rom_ptr_(rom_base) {} void advance_cycles(int cycles) { cycles_since_audio_update_ += cycles; @@ -119,13 +115,13 @@ class Pitfall2: public BusExtender { return level_table[table_position]; } - uint16_t featcher_address_[8]; - uint8_t top_[8], bottom_[8], mask_[8]; + uint16_t featcher_address_[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + uint8_t top_[8], bottom_[8], mask_[8] = {0, 0, 0, 0, 0, 0, 0, 0}; uint8_t music_mode_[3]; - uint8_t random_number_generator_; + uint8_t random_number_generator_ = 0; uint8_t *rom_ptr_; uint8_t audio_channel_[3]; - Cycles cycles_since_audio_update_; + Cycles cycles_since_audio_update_ = 0; }; } diff --git a/Machines/Oric/Microdisc.cpp b/Machines/Oric/Microdisc.cpp index 681701a62..a9701967e 100644 --- a/Machines/Oric/Microdisc.cpp +++ b/Machines/Oric/Microdisc.cpp @@ -18,13 +18,7 @@ namespace { const int head_load_request_counter_target = 7653333; } -Microdisc::Microdisc() : - irq_enable_(false), - delegate_(nullptr), - paging_flags_(BASICDisable), - head_load_request_counter_(-1), - WD1770(P1793), - last_control_(0) { +Microdisc::Microdisc() : WD1770(P1793) { set_control_register(last_control_, 0xff); } diff --git a/Machines/Oric/Microdisc.hpp b/Machines/Oric/Microdisc.hpp index 69c0338fe..1ea325dc7 100644 --- a/Machines/Oric/Microdisc.hpp +++ b/Machines/Oric/Microdisc.hpp @@ -45,11 +45,11 @@ class Microdisc: public WD::WD1770 { bool get_drive_is_ready(); std::shared_ptr drives_[4]; int selected_drive_; - bool irq_enable_; - int paging_flags_; - int head_load_request_counter_; - Delegate *delegate_; - uint8_t last_control_; + bool irq_enable_ = false; + int paging_flags_ = BASICDisable; + int head_load_request_counter_ = -1; + Delegate *delegate_ = nullptr; + uint8_t last_control_ = 0; }; } diff --git a/Processors/6502/Implementation/6502Storage.cpp b/Processors/6502/Implementation/6502Storage.cpp index 9e226266d..688bee285 100644 --- a/Processors/6502/Implementation/6502Storage.cpp +++ b/Processors/6502/Implementation/6502Storage.cpp @@ -244,19 +244,7 @@ const ProcessorStorage::MicroOp ProcessorStorage::operations[256][10] = { #undef Immediate #undef Implied -ProcessorStorage::ProcessorStorage() : - is_jammed_(false), - ready_line_is_enabled_(false), - ready_is_active_(false), - inverse_interrupt_flag_(0), - irq_request_history_(0), - s_(0), - next_bus_operation_(BusOperation::None), - interrupt_requests_(InterruptRequestFlags::PowerOn), - irq_line_(0), - nmi_line_is_enabled_(false), - set_overflow_line_is_enabled_(false), - scheduled_program_counter_(nullptr) { +ProcessorStorage::ProcessorStorage() { // only the interrupt flag is defined upon reset but get_flags isn't going to // mask the other flags so we need to do that, at least carry_flag_ &= Flag::Carry; diff --git a/Processors/6502/Implementation/6502Storage.hpp b/Processors/6502/Implementation/6502Storage.hpp index 27a19fe3c..227def011 100644 --- a/Processors/6502/Implementation/6502Storage.hpp +++ b/Processors/6502/Implementation/6502Storage.hpp @@ -64,14 +64,14 @@ class ProcessorStorage { static const MicroOp operations[256][10]; - const MicroOp *scheduled_program_counter_; + const MicroOp *scheduled_program_counter_ = nullptr; /* Storage for the 6502 registers; F is stored as individual flags. */ RegisterPair pc_, last_operation_pc_; - uint8_t a_, x_, y_, s_; - uint8_t carry_flag_, negative_result_, zero_result_, decimal_flag_, overflow_flag_, inverse_interrupt_flag_; + uint8_t a_, x_, y_, s_ = 0; + uint8_t carry_flag_, negative_result_, zero_result_, decimal_flag_, overflow_flag_, inverse_interrupt_flag_ = 0; /* Temporary state for the micro programs. @@ -83,7 +83,7 @@ class ProcessorStorage { Temporary storage allowing a common dispatch point for calling perform_bus_operation; possibly deferring is no longer of value. */ - BusOperation next_bus_operation_; + BusOperation next_bus_operation_ = BusOperation::None; uint16_t bus_address_; uint8_t *bus_value_; @@ -105,7 +105,7 @@ class ProcessorStorage { */ inline void set_flags(uint8_t flags); - bool is_jammed_; + bool is_jammed_ = false; Cycles cycles_left_to_run_; enum InterruptRequestFlags: uint8_t { @@ -115,13 +115,13 @@ class ProcessorStorage { PowerOn = 0x10, }; - uint8_t interrupt_requests_; + uint8_t interrupt_requests_ = InterruptRequestFlags::PowerOn; - bool ready_is_active_; - bool ready_line_is_enabled_; + bool ready_is_active_ = false; + bool ready_line_is_enabled_ = false; - uint8_t irq_line_, irq_request_history_; - bool nmi_line_is_enabled_, set_overflow_line_is_enabled_; + uint8_t irq_line_ = 0, irq_request_history_ = 0; + bool nmi_line_is_enabled_ = false, set_overflow_line_is_enabled_ = false; /*! Gets the program representing an RST response.