1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 03:32:01 +00:00

Made an initial attempt to mark sprite positions. But without hmove implemented, they're all over the place.

This commit is contained in:
Thomas Harte 2017-02-09 20:53:42 -05:00
parent 2e9ef2b0ef
commit 3b20d862f0
2 changed files with 41 additions and 11 deletions

View File

@ -304,7 +304,7 @@ void TIA::set_player_delay(int player, bool delay)
void TIA::set_player_position(int player)
{
player_[player].position = ((horizontal_counter_ - first_pixel_cycle) + 6)%160;
player_[player].position = 0;
}
void TIA::set_player_motion(int player, uint8_t motion)
@ -395,6 +395,8 @@ void TIA::output_for_cycles(int number_of_cycles)
// accumulate an OR'd version of the output into the collision buffer
draw_playfield(output_cursor, horizontal_counter_);
draw_player(player_[0], CollisionType::Player0, output_cursor, horizontal_counter_);
draw_player(player_[1], CollisionType::Player1, output_cursor, horizontal_counter_);
// convert to television signals
@ -568,3 +570,30 @@ void TIA::draw_playfield(int start, int end)
aligned_position += 4;
}
}
#pragma mark - Player output
void TIA::draw_player(Player &player, CollisionType identity, int start, int end)
{
// don't do anything if this window ends too early
if(end < first_pixel_cycle + (horizontal_blank_extend_ ? 8 : 0)) return;
int length = end - start;
// check for initial trigger; player.position is guaranteed to be less than 160 so this is easy
if(player.position + length >= 160)
{
int trigger_position = 160 - player.position;
int terminus = std::min(160, trigger_position+8);
while(trigger_position < terminus)
{
collision_buffer_[trigger_position] |= (uint8_t)identity;
trigger_position++;
}
}
// update position counter
player.position = (player.position + end - start) % 160;
}

View File

@ -75,16 +75,6 @@ class TIA {
private:
std::shared_ptr<Outputs::CRT::CRT> crt_;
// drawing methods
inline void output_for_cycles(int number_of_cycles);
inline void output_line();
inline void draw_playfield(int start, int end);
int pixels_start_location_;
uint8_t *pixel_target_;
inline void output_pixels(int start, int end);
// the master counter; counts from 0 to 228 with all visible pixels being in the final 160
int horizontal_counter_;
@ -156,6 +146,17 @@ class TIA {
// movement
bool horizontal_blank_extend_;
// drawing methods and state
inline void output_for_cycles(int number_of_cycles);
inline void output_line();
inline void draw_playfield(int start, int end);
inline void draw_player(Player &player, CollisionType identity, int start, int end);
int pixels_start_location_;
uint8_t *pixel_target_;
inline void output_pixels(int start, int end);
};
}