1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Introduces a computationally simplified inner loop for TMS graphics modes, modelled on that for text.

This commit is contained in:
Thomas Harte 2017-12-09 16:02:33 -05:00
parent 7a544731e2
commit 7d7e2538bd

View File

@ -350,19 +350,39 @@ void TMS9918::run_for(const HalfCycles cycles) {
output_column_ = pixels_end; output_column_ = pixels_end;
} break; } break;
case LineMode::Character: case LineMode::Character: {
while(output_column_ < pixels_end) { const int shift = (output_column_ - first_pixel_column_) & 7;
int base = (output_column_ - first_pixel_column_); int byte_column = (output_column_ - first_pixel_column_) >> 3;
int address = base >> 3;
uint8_t colour = colour_buffer_[address];
uint8_t pattern = pattern_buffer_[address];
pattern >>= ((base&7)^7);
*pixel_target_ = (pattern&1) ? palette[colour >> 4] : palette[colour & 15]; int pixels_left = pixels_end - output_column_;
pixel_target_ ++; int length = std::min(pixels_left, 8 - shift);
output_column_ ++;
int pattern = pattern_buffer_[byte_column] << shift;
uint8_t colour = colour_buffer_[byte_column];
uint32_t colours[2] = {
(colour & 15) ? palette[colour & 15] : background_colour_,
(colour >> 4) ? palette[colour >> 4] : background_colour_
};
while(true) {
pixels_left -= length;
while(length--) {
*pixel_target_ = colours[(pattern >> 7)&0x01];
pixel_target_++;
pattern <<= 1;
}
if(!pixels_left) break;
length = std::min(8, pixels_left);
byte_column++;
pattern = pattern_buffer_[byte_column];
colour = colour_buffer_[byte_column];
colours[0] = (colour & 15) ? palette[colour & 15] : background_colour_;
colours[1] = (colour >> 4) ? palette[colour >> 4] : background_colour_;
} }
break; output_column_ = pixels_end;
} break;
} }
if(output_column_ == first_right_border_column_) { if(output_column_ == first_right_border_column_) {