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

Adds latching of scroll values.

This commit is contained in:
Thomas Harte 2018-10-10 21:28:18 -04:00
parent f00f6c8c23
commit 2e379b0834
2 changed files with 22 additions and 8 deletions

View File

@ -64,6 +64,9 @@ Base::Base(Personality p) :
if(is_sega_vdp(personality_)) {
mode_timing_.line_interrupt_position = 4;
mode_timing_.end_of_frame_interrupt_position.column = 296;
mode_timing_.end_of_frame_interrupt_position.row = 191;
}
}
@ -548,7 +551,7 @@ HalfCycles TMS9918::get_time_until_interrupt() {
if(get_interrupt_line()) return HalfCycles(0);
// Calculate the amount of time until the next end-of-frame interrupt.
const int frame_length = 342 * mode_timing_.pixel_lines;
const int frame_length = 342 * mode_timing_.total_lines;
const int time_until_frame_interrupt =
(
((mode_timing_.end_of_frame_interrupt_position.row * 342) + mode_timing_.end_of_frame_interrupt_position.column + frame_length) -
@ -762,14 +765,14 @@ void Base::draw_sms(int start, int end) {
int tile_start = start, tile_end = end;
int tile_offset = start;
if(row_ >= 16 || !master_system_.horizontal_scroll_lock) {
for(int c = start; c < (master_system_.horizontal_scroll & 7); ++c) {
for(int c = start; c < (master_system_.latched_horizontal_scroll & 7); ++c) {
colour_buffer[c] = 16 + background_colour_;
++tile_offset;
}
// Remove the border area from that to which tiles will be drawn.
tile_start = std::max(start - (master_system_.horizontal_scroll & 7), 0);
tile_end = std::max(end - (master_system_.horizontal_scroll & 7), 0);
tile_start = std::max(start - (master_system_.latched_horizontal_scroll & 7), 0);
tile_end = std::max(end - (master_system_.latched_horizontal_scroll & 7), 0);
}

View File

@ -199,13 +199,15 @@ class Base {
uint32_t colour_ram[32];
bool cram_is_selected = false;
// Temporary buffers for a line of Master System graphics.
// Temporary buffers for a line of Master System graphics,
// and latched scrolling offsets.
struct {
size_t offset;
uint8_t flags;
} names[32];
uint8_t tile_graphics[32][4];
size_t next_column = 0;
uint8_t latched_vertical_scroll = 0;
uint8_t latched_horizontal_scroll = 0;
} master_system_;
// Holds results of sprite data fetches that occur on this
@ -654,12 +656,21 @@ class Base {
slot(location+14): \
slot(location+15): fetch_tile(column+3)
// Latch scrolling position at slot 33 for now; unless or until
// a more accurate number becomes apparent.
if(start < 33 && end >= 33) {
if(!row_) {
master_system_.latched_vertical_scroll = master_system_.vertical_scroll;
}
master_system_.latched_horizontal_scroll = master_system_.horizontal_scroll;
}
// Determine the coarse horizontal scrolling offset; this isn't applied on the first two lines if the programmer has requested it.
const int horizontal_offset = (row_ >= 16 || !master_system_.horizontal_scroll_lock) ? (master_system_.horizontal_scroll >> 3) : 0;
const int horizontal_offset = (row_ >= 16 || !master_system_.horizontal_scroll_lock) ? (master_system_.latched_horizontal_scroll >> 3) : 0;
// Determine row info for the screen both (i) if vertical scrolling is applied; and (ii) if it isn't.
// The programmer can opt out of applying vertical scrolling to the right-hand portion of the display.
const int scrolled_row = (row_ + master_system_.vertical_scroll) % 224;
const int scrolled_row = (row_ + master_system_.latched_vertical_scroll) % 224;
struct RowInfo {
size_t pattern_address_base;
size_t sub_row[2];