1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-04 13:31:26 +00:00

Synchronise fetch and draw sprite buffer usage.

This commit is contained in:
Thomas Harte 2023-03-30 19:11:00 -04:00
parent 931d2373a4
commit f3c2c0ffa9
2 changed files with 8 additions and 2 deletions

View File

@ -131,8 +131,11 @@ void Base<personality>::posit_sprite(int sprite_number, int sprite_position, uin
// Evaluation of visibility of sprite 0 is always the first step in
// populating a sprite buffer; so use it to uncork a new one.
if(!sprite_number) {
fetch_line_buffer_->fetched_sprites = true;
advance(fetch_sprite_buffer_);
fetch_sprite_buffer_->reset_sprite_collection();
fetch_sprite_buffer_->sprite_terminator = mode_timing_.sprite_terminator(fetch_line_buffer_->screen_mode);
}
if(!(status_ & StatusSpriteOverflow)) {
@ -359,7 +362,7 @@ void TMS9918<personality>::run_for(const HalfCycles cycles) {
this->fetch_line_buffer_->next_border_column = Timing<personality>::CyclesPerLine;
this->fetch_line_buffer_->pixel_count = 256;
this->fetch_line_buffer_->screen_mode = this->screen_mode_;
// mode_timing_.sprite_terminator(buffer.screen_mode);
this->fetch_line_buffer_->fetched_sprites = false;
this->mode_timing_.maximum_visible_sprites = 4;
switch(this->screen_mode_) {
case ScreenMode::Text:
@ -598,8 +601,10 @@ void TMS9918<personality>::run_for(const HalfCycles cycles) {
// -------------
this->output_pointer_.column = end_column;
if(end_column == Timing<personality>::CyclesPerLine) {
if(this->draw_line_buffer_->fetched_sprites) {
this->advance(this->draw_sprite_buffer_);
}
this->advance(this->draw_line_buffer_);
this->advance(this->draw_sprite_buffer_);
}
}

View File

@ -22,6 +22,7 @@ struct LineBuffer {
FetchMode fetch_mode = FetchMode::Text;
ScreenMode screen_mode = ScreenMode::Text;
VerticalState vertical_state = VerticalState::Blank;
bool fetched_sprites = false;
// Holds the horizontal scroll position to apply to this line;
// of those VDPs currently implemented, affects the Master System only.