1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Simplifies code a little and gives something on screen.

This commit is contained in:
Thomas Harte 2017-11-28 21:19:28 -05:00
parent 642bb8333f
commit 563aa051e4
2 changed files with 14 additions and 10 deletions

View File

@ -93,13 +93,14 @@ void TMS9918::run_for(const HalfCycles cycles) {
int end = std::min(154, column_); int end = std::min(154, column_);
// TODO: optimise this, probably // TODO: optimise this, probably
const int row_base = ((row_ >> 3)&~31); const int row_base = ((row_ << 2)&~31);
while(access_pointer_ < end) { while(access_pointer_ < end) {
switch(access_pointer_&1) { int character_column = ((access_pointer_ - 26) >> 2);
case 0: line_buffer_[access_pointer_] = ram_[pattern_name_address_ + row_base + ((access_pointer_ - 26) >> 2)]; break; switch(access_pointer_&3) {
case 0: pattern_name_ = ram_[pattern_name_address_ + row_base + character_column]; break;
case 1: break; // TODO: sprites / CPU access. case 1: break; // TODO: sprites / CPU access.
case 2: line_buffer_[access_pointer_] = ram_[colour_table_address_ + (line_buffer_[access_pointer_ - 2] >> 3)]; break; case 2: colour_buffer_[character_column] = ram_[colour_table_address_ + (pattern_name_ >> 3)]; break;
case 3: line_buffer_[access_pointer_] = ram_[pattern_generator_table_address_ + (line_buffer_[access_pointer_-3] << 3) + (row_ & 7)]; break; case 3: pattern_buffer_[character_column] = ram_[pattern_generator_table_address_ + (pattern_name_ << 3) + (row_ & 7)]; break;
} }
access_pointer_++; access_pointer_++;
} }
@ -132,12 +133,13 @@ void TMS9918::run_for(const HalfCycles cycles) {
int pixels_end = std::min(first_right_border_column_, column_); int pixels_end = std::min(first_right_border_column_, column_);
if(output_column_ < pixels_end) { if(output_column_ < pixels_end) {
while(output_column_ < pixels_end) { while(output_column_ < pixels_end) {
int base = (output_column_ >> 1); int base = (output_column_ - first_pixel_column_);
int address = base & ~3; int address = base >> 3;
// uint8_t colour = line_buffer_[address]; // uint8_t colour = line_buffer_[address];
uint8_t pattern = line_buffer_[address+1]; uint8_t pattern = pattern_buffer_[address];
pattern >>= ((base&3)*2) + (output_column_ & 1); pattern >>= ((base&3)*2) + (output_column_ & 1);
pixel_target_[0] = (pattern&1) ? 0xffffff : 0x000000;
*pixel_target_ = (pattern&1) ? 0xffffff : 0x000000;
pixel_target_ ++; pixel_target_ ++;
output_column_ ++; output_column_ ++;
} }

View File

@ -90,8 +90,10 @@ class TMS9918 {
} line_mode_ = LineMode::Text; } line_mode_ = LineMode::Text;
int first_pixel_column_, first_right_border_column_; int first_pixel_column_, first_right_border_column_;
uint8_t line_buffer_[171]; uint8_t pattern_buffer_[40];
uint8_t colour_buffer_[32];
int access_pointer_ = 0; int access_pointer_ = 0;
uint8_t pattern_name_;
}; };
}; };