From 8de6caf6ff2296f383ef4f625eee967ea7232947 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 11 Feb 2017 12:59:13 -0500 Subject: [PATCH] Started trying to get into a proper structure here. Chickened out. --- Machines/Atari2600/TIA.cpp | 45 +++++++++++++++++++++----------------- Machines/Atari2600/TIA.hpp | 1 + 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Machines/Atari2600/TIA.cpp b/Machines/Atari2600/TIA.cpp index 1fa3b28b4..d9f34cbb2 100644 --- a/Machines/Atari2600/TIA.cpp +++ b/Machines/Atari2600/TIA.cpp @@ -353,6 +353,7 @@ void TIA::move() { horizontal_blank_extend_ = true; is_moving_[0] = is_moving_[1] = is_moving_[2] = is_moving_[3] = is_moving_[4] = true; + horizontal_move_start_time_ = horizontal_counter_; } void TIA::clear_motion() @@ -582,30 +583,34 @@ void TIA::draw_player(Player &player, CollisionType collision_identity, const in if(end < first_pixel) return; if(start < first_pixel) start = first_pixel; - int length = end - start; uint8_t &position = position_[position_identity]; + uint8_t &motion = motion_[position_identity]; + bool &is_moving = is_moving_[position_identity]; +// while(start < end) +// { + int length = end - start; - // quick hack! - if(is_moving_[position_identity]) - { - int motion = motion_[position_identity] ^ 8; - position += motion; - is_moving_[position_identity] = false; - position = (position + 160)%160; - } - - // check for initial trigger; player.position is guaranteed to be less than 160 so this is easy - if(player.graphic && position + length >= 160) - { - int trigger_position = 160 - position + 6 + start - first_pixel_cycle; - - int terminus = std::min(160, trigger_position+8); - while(trigger_position < terminus) + // quick hack! + if(is_moving) { - collision_buffer_[trigger_position] |= (uint8_t)collision_identity; - trigger_position++; + position += (motion ^ 8); + is_moving_[position_identity] = false; + position = (position + 160)%160; } - } + + // check for initial trigger; player.position is guaranteed to be less than 160 so this is easy + if(player.graphic && position + length >= 160) + { + int trigger_position = 160 - position + 5 + start - first_pixel_cycle; + + int terminus = std::min(160, trigger_position+8); + while(trigger_position < terminus) + { + collision_buffer_[trigger_position] |= (uint8_t)collision_identity; + trigger_position++; + } + } +// } // update position counter position = (position + end - start) % 160; diff --git a/Machines/Atari2600/TIA.hpp b/Machines/Atari2600/TIA.hpp index ac704c629..789d786d0 100644 --- a/Machines/Atari2600/TIA.hpp +++ b/Machines/Atari2600/TIA.hpp @@ -143,6 +143,7 @@ class TIA { // movement bool horizontal_blank_extend_; + int horizontal_move_start_time_; uint8_t motion_[5]; uint8_t position_[5]; bool is_moving_[5];