1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Fix border lengths.

This commit is contained in:
Thomas Harte 2023-01-08 17:04:19 -05:00
parent cb19c2ffb0
commit b522d65c50

View File

@ -470,35 +470,42 @@ void TMS9918<personality>::run_for(const HalfCycles cycles) {
} }
template <Personality personality> template <Personality personality>
void Base<personality>::output_border(int cycles, uint32_t cram_dot) { void Base<personality>::output_border(int cycles, [[maybe_unused]] uint32_t cram_dot) {
cycles *= 4; cycles = this->clock_converter_.to_crt_clock(cycles);
const uint32_t border_colour = const uint32_t border_colour =
is_sega_vdp(personality) ? is_sega_vdp(personality) ?
master_system_.colour_ram[16 + background_colour_] : master_system_.colour_ram[16 + background_colour_] :
palette[background_colour_]; palette[background_colour_];
if(cram_dot) { if constexpr (is_sega_vdp(personality)) {
uint32_t *const pixel_target = reinterpret_cast<uint32_t *>(crt_.begin_data(1)); if(cram_dot) {
if(pixel_target) {
*pixel_target = border_colour | cram_dot;
}
crt_.output_level(4);
cycles -= 4;
}
if(cycles) {
// If the border colour is 0, that can be communicated
// more efficiently as an explicit blank.
if(border_colour) {
uint32_t *const pixel_target = reinterpret_cast<uint32_t *>(crt_.begin_data(1)); uint32_t *const pixel_target = reinterpret_cast<uint32_t *>(crt_.begin_data(1));
if(pixel_target) { if(pixel_target) {
*pixel_target = border_colour; *pixel_target = border_colour | cram_dot;
} }
crt_.output_level(cycles);
} else { // Four CRT cycles is one pixel width, so this doesn't need clock conversion.
crt_.output_blank(cycles); // TODO: on the Mega Drive it may be only 3 colour cycles, depending on mode.
crt_.output_level(4);
cycles -= 4;
} }
} }
if(!cycles) {
return;
}
// If the border colour is 0, that can be communicated
// more efficiently as an explicit blank.
if(border_colour) {
uint32_t *const pixel_target = reinterpret_cast<uint32_t *>(crt_.begin_data(1));
if(pixel_target) {
*pixel_target = border_colour;
}
crt_.output_level(cycles);
} else {
crt_.output_blank(cycles);
}
} }
template <Personality personality> template <Personality personality>