mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-18 23:23:56 +00:00
Added an incorrectly-coded version of horizontal move, at least so that I can verify that information is going into the correct slots.
This commit is contained in:
parent
3b20d862f0
commit
64d5712d1d
@ -304,12 +304,12 @@ void TIA::set_player_delay(int player, bool delay)
|
|||||||
|
|
||||||
void TIA::set_player_position(int player)
|
void TIA::set_player_position(int player)
|
||||||
{
|
{
|
||||||
player_[player].position = 0;
|
position_[(int)MotionIndex::Player0 + player] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIA::set_player_motion(int player, uint8_t motion)
|
void TIA::set_player_motion(int player, uint8_t motion)
|
||||||
{
|
{
|
||||||
player_[player].motion = motion >> 4;
|
motion_[(int)MotionIndex::Player0 + player] = motion >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIA::set_player_missile_colour(int player, uint8_t colour)
|
void TIA::set_player_missile_colour(int player, uint8_t colour)
|
||||||
@ -352,10 +352,12 @@ void TIA::set_ball_motion(uint8_t motion)
|
|||||||
void TIA::move()
|
void TIA::move()
|
||||||
{
|
{
|
||||||
horizontal_blank_extend_ = true;
|
horizontal_blank_extend_ = true;
|
||||||
|
is_moving_[0] = is_moving_[1] = is_moving_[2] = is_moving_[3] = is_moving_[4] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIA::clear_motion()
|
void TIA::clear_motion()
|
||||||
{
|
{
|
||||||
|
motion_[0] = motion_[1] = motion_[2] = motion_[3] = motion_[4] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t TIA::get_collision_flags(int offset)
|
uint8_t TIA::get_collision_flags(int offset)
|
||||||
@ -395,8 +397,8 @@ void TIA::output_for_cycles(int number_of_cycles)
|
|||||||
|
|
||||||
// accumulate an OR'd version of the output into the collision buffer
|
// accumulate an OR'd version of the output into the collision buffer
|
||||||
draw_playfield(output_cursor, horizontal_counter_);
|
draw_playfield(output_cursor, horizontal_counter_);
|
||||||
draw_player(player_[0], CollisionType::Player0, output_cursor, horizontal_counter_);
|
draw_player(player_[0], CollisionType::Player0, (int)MotionIndex::Player0, output_cursor, horizontal_counter_);
|
||||||
draw_player(player_[1], CollisionType::Player1, output_cursor, horizontal_counter_);
|
draw_player(player_[1], CollisionType::Player1, (int)MotionIndex::Player1, output_cursor, horizontal_counter_);
|
||||||
|
|
||||||
// convert to television signals
|
// convert to television signals
|
||||||
|
|
||||||
@ -573,27 +575,40 @@ void TIA::draw_playfield(int start, int end)
|
|||||||
|
|
||||||
#pragma mark - Player output
|
#pragma mark - Player output
|
||||||
|
|
||||||
void TIA::draw_player(Player &player, CollisionType identity, int start, int end)
|
void TIA::draw_player(Player &player, CollisionType collision_identity, const int position_identity, int start, int end)
|
||||||
{
|
{
|
||||||
// don't do anything if this window ends too early
|
// don't do anything if this window ends too early
|
||||||
if(end < first_pixel_cycle + (horizontal_blank_extend_ ? 8 : 0)) return;
|
int first_pixel = first_pixel_cycle + (horizontal_blank_extend_ ? 8 : 0);
|
||||||
|
if(end < first_pixel) return;
|
||||||
|
if(start < first_pixel) start = first_pixel;
|
||||||
|
|
||||||
int length = end - start;
|
int length = end - start;
|
||||||
|
uint8_t &position = position_[position_identity];
|
||||||
|
|
||||||
|
// quick hack!
|
||||||
|
if(is_moving_[position_identity])
|
||||||
|
{
|
||||||
|
int motion = motion_[position_identity];
|
||||||
|
position += 8;
|
||||||
|
position += motion;
|
||||||
|
if(motion&8) position -= 16;
|
||||||
|
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
|
// check for initial trigger; player.position is guaranteed to be less than 160 so this is easy
|
||||||
if(player.position + length >= 160)
|
if(player.graphic && position + length >= 160)
|
||||||
{
|
{
|
||||||
int trigger_position = 160 - player.position;
|
int trigger_position = 160 - position;
|
||||||
|
|
||||||
int terminus = std::min(160, trigger_position+8);
|
int terminus = std::min(160, trigger_position+8);
|
||||||
while(trigger_position < terminus)
|
while(trigger_position < terminus)
|
||||||
{
|
{
|
||||||
collision_buffer_[trigger_position] |= (uint8_t)identity;
|
collision_buffer_[trigger_position] |= (uint8_t)collision_identity;
|
||||||
trigger_position++;
|
trigger_position++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update position counter
|
// update position counter
|
||||||
player.position = (player.position + end - start) % 160;
|
position = (position + end - start) % 160;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -134,9 +134,6 @@ class TIA {
|
|||||||
int copy_flags; // a bit field, corresponding to the first few values of NUSIZ
|
int copy_flags; // a bit field, corresponding to the first few values of NUSIZ
|
||||||
uint8_t graphic; // the player graphic
|
uint8_t graphic; // the player graphic
|
||||||
int reverse_mask; // 7 for a reflected player, 0 for normal
|
int reverse_mask; // 7 for a reflected player, 0 for normal
|
||||||
uint8_t motion; // low four bits used
|
|
||||||
uint8_t position; // in the range [0, 160) to indicate offset from the left margin, i.e. phase difference
|
|
||||||
// between the player counter and the background pixel counter.
|
|
||||||
} player_[2];
|
} player_[2];
|
||||||
|
|
||||||
// missile state
|
// missile state
|
||||||
@ -146,13 +143,25 @@ class TIA {
|
|||||||
|
|
||||||
// movement
|
// movement
|
||||||
bool horizontal_blank_extend_;
|
bool horizontal_blank_extend_;
|
||||||
|
uint8_t motion_[5];
|
||||||
|
uint8_t position_[5];
|
||||||
|
bool is_moving_[5];
|
||||||
|
enum class MotionIndex : uint8_t {
|
||||||
|
Ball,
|
||||||
|
Player0,
|
||||||
|
Player1,
|
||||||
|
Missile0,
|
||||||
|
Missile1
|
||||||
|
};
|
||||||
|
|
||||||
// drawing methods and state
|
// drawing methods and state
|
||||||
inline void output_for_cycles(int number_of_cycles);
|
inline void output_for_cycles(int number_of_cycles);
|
||||||
inline void output_line();
|
inline void output_line();
|
||||||
|
|
||||||
inline void draw_playfield(int start, int end);
|
inline void draw_playfield(int start, int end);
|
||||||
inline void draw_player(Player &player, CollisionType identity, int start, int end);
|
inline void draw_player(Player &player, CollisionType collision_identity, const int position_identity, int start, int end);
|
||||||
|
|
||||||
|
inline void update_motion(int start, int end);
|
||||||
|
|
||||||
int pixels_start_location_;
|
int pixels_start_location_;
|
||||||
uint8_t *pixel_target_;
|
uint8_t *pixel_target_;
|
||||||
|
Loading…
Reference in New Issue
Block a user