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

Switched to a very large number of buffers, and resolved stupid attempt to reassign a reference.

This commit is contained in:
Thomas Harte 2018-10-14 18:19:11 -04:00
parent 6c09abc6cb
commit d66979c68f
2 changed files with 29 additions and 21 deletions

View File

@ -193,11 +193,13 @@ void TMS9918::run_for(const HalfCycles cycles) {
int read_cycles_pool = int_cycles;
while(write_cycles_pool || read_cycles_pool) {
LineBufferPointer backup = read_pointer_;
if(write_cycles_pool) {
// Determine how much writing to do.
const int write_cycles = std::min(342 - write_pointer_.column, write_cycles_pool);
const int end_column = write_pointer_.column + write_cycles;
LineBuffer &line_buffer = line_buffers_[0];//write_pointer_.row & 1];
LineBuffer &line_buffer = line_buffers_[write_pointer_.row];
@ -217,7 +219,7 @@ void TMS9918::run_for(const HalfCycles cycles) {
// Perform memory accesses.
// ------------------------
#define fetch(function) \
if(final_window < 171) { \
if(final_window != 171) { \
function<true>(first_window, final_window);\
} else {\
function<false>(first_window, final_window);\
@ -282,43 +284,47 @@ void TMS9918::run_for(const HalfCycles cycles) {
if(write_pointer_.column == 342) {
write_pointer_.column = 0;
write_pointer_.row = (write_pointer_.row + 1) % mode_timing_.total_lines;
line_buffer = line_buffers_[0];//write_pointer_.row & 1];
LineBuffer &next_line_buffer = line_buffers_[write_pointer_.row];
// Establish the output mode for the next line.
set_current_screen_mode();
// Based on the output mode, pick a line mode.
line_buffer.first_pixel_output_column = 86;
line_buffer.next_border_column = 342;
next_line_buffer.first_pixel_output_column = 86;
next_line_buffer.next_border_column = 342;
mode_timing_.maximum_visible_sprites = 4;
switch(screen_mode_) {
case ScreenMode::Text:
line_buffer.line_mode = LineMode::Text;
line_buffer.first_pixel_output_column = 94;
line_buffer.next_border_column = 334;
next_line_buffer.line_mode = LineMode::Text;
next_line_buffer.first_pixel_output_column = 94;
next_line_buffer.next_border_column = 334;
break;
case ScreenMode::SMSMode4:
line_buffer.line_mode = LineMode::SMS;
next_line_buffer.line_mode = LineMode::SMS;
mode_timing_.maximum_visible_sprites = 8;
break;
default:
line_buffer.line_mode = LineMode::Character;
next_line_buffer.line_mode = LineMode::Character;
break;
}
if(
(screen_mode_ == ScreenMode::Blank) ||
(write_pointer_.row >= mode_timing_.pixel_lines && write_pointer_.row != mode_timing_.total_lines-1))
line_buffer.line_mode = LineMode::Refresh;
next_line_buffer.line_mode = LineMode::Refresh;
}
}
assert(backup.row == read_pointer_.row && backup.column == read_pointer_.column);
backup = write_pointer_;
if(read_cycles_pool) {
// Determine how much time has passed in the remainder of this line, and proceed.
const int read_cycles = std::min(342 - read_pointer_.column, read_cycles_pool);
const int end_column = read_pointer_.column + read_cycles;
LineBuffer &line_buffer = line_buffers_[0];//read_pointer_.row & 1];
LineBuffer &line_buffer = line_buffers_[read_pointer_.row];
@ -425,6 +431,8 @@ void TMS9918::run_for(const HalfCycles cycles) {
read_pointer_.row = (read_pointer_.row + 1) % mode_timing_.total_lines;
}
}
assert(backup.row == write_pointer_.row && backup.column == write_pointer_.column);
}
}
@ -820,7 +828,7 @@ void Base::draw_tms_character(int start, int end) {
}
void Base::draw_tms_text(int start, int end) {
LineBuffer &line_buffer = line_buffers_[0];//read_pointer_.row & 1];
LineBuffer &line_buffer = line_buffers_[read_pointer_.row];
const uint32_t colours[2] = { palette[background_colour_], palette[text_colour_] };
const int shift = start % 6;
@ -844,7 +852,7 @@ void Base::draw_tms_text(int start, int end) {
}
void Base::draw_sms(int start, int end) {
LineBuffer &line_buffer = line_buffers_[0];//read_pointer_.row & 1];
LineBuffer &line_buffer = line_buffers_[read_pointer_.row];
int colour_buffer[256];
/*
@ -925,7 +933,7 @@ void Base::draw_sms(int start, int end) {
if(line_buffer.active_sprite_slot) {
int sprite_buffer[256];
int sprite_collision = 0;
memset(&sprite_buffer[start], 0, size_t(end - start)*sizeof(int));
memset(&sprite_buffer[start], 0, size_t(end - start)*sizeof(sprite_buffer[0]));
// Draw all sprites into the sprite buffer.
for(int index = line_buffer.active_sprite_slot - 1; index >= 0; --index) {

View File

@ -212,8 +212,8 @@ class Base {
e.g. standard 256-pixel modes will want to set
first_pixel_output_column = 86, next_border_column = 342.
*/
int first_pixel_output_column;
int next_border_column;
int first_pixel_output_column = 94;
int next_border_column = 334;
// An active sprite is one that has been selected for composition onto
// this line.
@ -231,7 +231,7 @@ class Base {
// being evaluated for display. This flag determines whether the sentinel has yet been reached.
void reset_sprite_collection();
} line_buffers_[2];
} line_buffers_[313];
void posit_sprite(LineBuffer &buffer, int sprite_number, int sprite_y, int screen_row);
// There is a delay between reading into the line buffer and outputting from there to the screen. That delay
@ -455,7 +455,7 @@ class Base {
fetch_columns_4(location, column); \
fetch_columns_4(location+12, column+4);
LineBuffer &line_buffer = line_buffers_[0];//write_pointer_.row & 1];
LineBuffer &line_buffer = line_buffers_[write_pointer_.row];
const size_t row_base = pattern_name_address_ & (0x3c00 | static_cast<size_t>(write_pointer_.row >> 3) * 40);
const size_t row_offset = pattern_generator_table_address_ & (0x3800 | (write_pointer_.row & 7));
@ -538,7 +538,7 @@ class Base {
slot(location+14): \
slot(location+15): fetch_tile(column+3)
LineBuffer &line_buffer = line_buffers_[0];//write_pointer_.row & 1];
LineBuffer &line_buffer = line_buffers_[write_pointer_.row];
const size_t row_base = pattern_name_address_ + static_cast<size_t>((write_pointer_.row << 2)&~31);
size_t pattern_base = pattern_generator_table_address_;
@ -683,7 +683,7 @@ class Base {
slot(location+15): fetch_tile(column+3)
// Determine the coarse horizontal scrolling offset; this isn't applied on the first two lines if the programmer has requested it.
LineBuffer &line_buffer = line_buffers_[0];//write_pointer_ .row & 1];
LineBuffer &line_buffer = line_buffers_[write_pointer_.row];
const int horizontal_offset = (write_pointer_.row >= 16 || !master_system_.horizontal_scroll_lock) ? (line_buffer.latched_horizontal_scroll >> 3) : 0;
// Determine row info for the screen both (i) if vertical scrolling is applied; and (ii) if it isn't.