mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
Adds latching of scroll values.
This commit is contained in:
parent
f00f6c8c23
commit
2e379b0834
@ -64,6 +64,9 @@ Base::Base(Personality p) :
|
|||||||
|
|
||||||
if(is_sega_vdp(personality_)) {
|
if(is_sega_vdp(personality_)) {
|
||||||
mode_timing_.line_interrupt_position = 4;
|
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);
|
if(get_interrupt_line()) return HalfCycles(0);
|
||||||
|
|
||||||
// Calculate the amount of time until the next end-of-frame interrupt.
|
// 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 =
|
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) -
|
((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_start = start, tile_end = end;
|
||||||
int tile_offset = start;
|
int tile_offset = start;
|
||||||
if(row_ >= 16 || !master_system_.horizontal_scroll_lock) {
|
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_;
|
colour_buffer[c] = 16 + background_colour_;
|
||||||
++tile_offset;
|
++tile_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the border area from that to which tiles will be drawn.
|
// Remove the border area from that to which tiles will be drawn.
|
||||||
tile_start = std::max(start - (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_.horizontal_scroll & 7), 0);
|
tile_end = std::max(end - (master_system_.latched_horizontal_scroll & 7), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,13 +199,15 @@ class Base {
|
|||||||
uint32_t colour_ram[32];
|
uint32_t colour_ram[32];
|
||||||
bool cram_is_selected = false;
|
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 {
|
struct {
|
||||||
size_t offset;
|
size_t offset;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
} names[32];
|
} names[32];
|
||||||
uint8_t tile_graphics[32][4];
|
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_;
|
} master_system_;
|
||||||
|
|
||||||
// Holds results of sprite data fetches that occur on this
|
// Holds results of sprite data fetches that occur on this
|
||||||
@ -654,12 +656,21 @@ class Base {
|
|||||||
slot(location+14): \
|
slot(location+14): \
|
||||||
slot(location+15): fetch_tile(column+3)
|
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.
|
// 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.
|
// 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.
|
// 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 {
|
struct RowInfo {
|
||||||
size_t pattern_address_base;
|
size_t pattern_address_base;
|
||||||
size_t sub_row[2];
|
size_t sub_row[2];
|
||||||
|
Loading…
Reference in New Issue
Block a user