From 4add2c1051f01f2c92eb839ded21e08cfc3fa8f1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 10 Nov 2017 22:57:43 -0500 Subject: [PATCH] Corrects order-of-initialisation errors in the TIA. --- Machines/Atari2600/TIA.cpp | 11 +---------- Machines/Atari2600/TIA.hpp | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Machines/Atari2600/TIA.cpp b/Machines/Atari2600/TIA.cpp index 885ab69bf..16ac3fe45 100644 --- a/Machines/Atari2600/TIA.cpp +++ b/Machines/Atari2600/TIA.cpp @@ -20,16 +20,7 @@ namespace { uint8_t reverse_table[256]; } -TIA::TIA(bool create_crt) : - horizontal_counter_(0), - pixels_start_location_(0), - output_mode_(0), - pixel_target_(nullptr), - background_{0, 0}, - background_half_mask_(0), - horizontal_blank_extend_(false), - collision_flags_(0) -{ +TIA::TIA(bool create_crt) { if(create_crt) { crt_.reset(new Outputs::CRT::CRT(cycles_per_line * 2 - 1, 1, Outputs::CRT::DisplayType::NTSC60, 1)); crt_->set_output_device(Outputs::CRT::Television); diff --git a/Machines/Atari2600/TIA.hpp b/Machines/Atari2600/TIA.hpp index 5426ea989..510d8350a 100644 --- a/Machines/Atari2600/TIA.hpp +++ b/Machines/Atari2600/TIA.hpp @@ -81,10 +81,10 @@ class TIA { std::function line_end_function_; // the master counter; counts from 0 to 228 with all visible pixels being in the final 160 - int horizontal_counter_; + int horizontal_counter_ = 0; // contains flags to indicate whether sync or blank are currently active - int output_mode_; + int output_mode_ = 0; // keeps track of the target pixel buffer for this line and when it was acquired, and a corresponding collision buffer alignas(alignof(uint32_t)) uint8_t collision_buffer_[160]; @@ -97,7 +97,7 @@ class TIA { Missile1 = (1 << 5) }; - int collision_flags_; + int collision_flags_ = 0; int collision_flags_by_buffer_vaules_[64]; // colour mapping tables @@ -118,19 +118,20 @@ class TIA { uint8_t colour_palette_[4]; // playfield state - int background_half_mask_; + int background_half_mask_ = 0; enum class PlayfieldPriority { Standard, Score, OnTop } playfield_priority_; - uint32_t background_[2]; // contains two 20-bit bitfields representing the background state; - // at index 0 is the left-hand side of the playfield with bit 0 being - // the first bit to display, bit 1 the second, etc. Index 1 contains - // a mirror image of index 0. If the playfield is being displayed in - // mirroring mode, background_[0] will be output on the left and - // background_[1] on the right; otherwise background_[0] will be - // output twice. + uint32_t background_[2] = {0, 0}; + // contains two 20-bit bitfields representing the background state; + // at index 0 is the left-hand side of the playfield with bit 0 being + // the first bit to display, bit 1 the second, etc. Index 1 contains + // a mirror image of index 0. If the playfield is being displayed in + // mirroring mode, background_[0] will be output on the left and + // background_[1] on the right; otherwise background_[0] will be + // output twice. // objects template struct Object { @@ -287,7 +288,7 @@ class TIA { } ball_; // motion - bool horizontal_blank_extend_; + bool horizontal_blank_extend_ = false; template void perform_border_motion(T &object, int start, int end); template void perform_motion_step(T &object); @@ -300,8 +301,8 @@ class TIA { inline void output_for_cycles(int number_of_cycles); inline void output_line(); - int pixels_start_location_; - uint8_t *pixel_target_; + int pixels_start_location_ = 0; + uint8_t *pixel_target_ = nullptr; inline void output_pixels(int start, int end); };