1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

Simplifies and corrects low-resolution colour generation.

Possibly disproving the premise for this whole experiment, all colours seem immediately to work correctly. Hmmm.
This commit is contained in:
Thomas Harte 2018-04-18 21:41:11 -04:00
parent f6c2f6e896
commit 5f1c210746
2 changed files with 17 additions and 8 deletions

View File

@ -57,8 +57,8 @@ void VideoBase::setup_tables() {
((c & 0x40) ? 0x6000 : 0x0000); ((c & 0x40) ? 0x6000 : 0x0000);
uint8_t *const table_entry = reinterpret_cast<uint8_t *>(&scaled_byte[c]); uint8_t *const table_entry = reinterpret_cast<uint8_t *>(&scaled_byte[c]);
table_entry[1] = static_cast<uint8_t>(value & 0xff);
table_entry[0] = static_cast<uint8_t>(value >> 8); table_entry[0] = static_cast<uint8_t>(value >> 8);
table_entry[1] = static_cast<uint8_t>(value & 0xff);
} }
for(int c = 128; c < 256; ++c) { for(int c = 128; c < 256; ++c) {
uint8_t *const source_table_entry = reinterpret_cast<uint8_t *>(&scaled_byte[c & 0x7f]); uint8_t *const source_table_entry = reinterpret_cast<uint8_t *>(&scaled_byte[c & 0x7f]);
@ -69,14 +69,23 @@ void VideoBase::setup_tables() {
} }
for(int c = 0; c < 16; ++c) { for(int c = 0; c < 16; ++c) {
uint8_t *table_entry = reinterpret_cast<uint8_t *>(&low_resolution_patterns[0][c]); // Produce the whole 28-bit pattern that would cover two bytes.
table_entry[1] = static_cast<uint8_t>(c | (c << 4)); int pattern = 0;
table_entry[0] = static_cast<uint8_t>((c >> 3) | (c << 1) | (c << 5)); for(int l = 0; l < 7; ++l) {
pattern <<= 4;
pattern |= c;
}
table_entry = reinterpret_cast<uint8_t *>(&low_resolution_patterns[1][c]); // Pack that 28-bit pattern into the appropriate look-up tables.
table_entry[1] = static_cast<uint8_t>((c >> 2) | (c << 2) | (c << 6)); uint8_t *const left_entry = reinterpret_cast<uint8_t *>(&low_resolution_patterns[0][c]);
table_entry[0] = static_cast<uint8_t>((c >> 1) | (c << 3)); uint8_t *const right_entry = reinterpret_cast<uint8_t *>(&low_resolution_patterns[1][c]);
left_entry[0] = static_cast<uint8_t>(pattern >> 21);
left_entry[1] = static_cast<uint8_t>(pattern >> 14);
right_entry[0] = static_cast<uint8_t>(pattern >> 7);
right_entry[1] = static_cast<uint8_t>(pattern);
} }
printf("");
} }
void VideoBase::set_graphics_mode() { void VideoBase::set_graphics_mode() {

View File

@ -128,7 +128,7 @@ template <class BusHandler> class Video: public VideoBase {
case GraphicsMode::LowRes: case GraphicsMode::LowRes:
for(int c = column_; c < pixel_end; ++c) { for(int c = column_; c < pixel_end; ++c) {
const uint8_t character = bus_handler_.perform_read(static_cast<uint16_t>(text_address + c)); const uint8_t character = bus_handler_.perform_read(static_cast<uint16_t>(text_address + c));
pixel_pointer_[c] = low_resolution_patterns[column_&1][(character >> row_shift)&0xf]; pixel_pointer_[c] = low_resolution_patterns[c&1][(character >> row_shift)&0xf];
} }
break; break;