1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-21 05:29:13 +00:00

Use Yamaha palette pervasively.

This commit is contained in:
Thomas Harte 2023-01-29 21:17:00 -05:00
parent 3142f5c21d
commit 73e79b14ea
3 changed files with 16 additions and 12 deletions

View File

@ -556,10 +556,8 @@ void Base<personality>::output_border(int cycles, [[maybe_unused]] uint32_t cram
crt_.output_level(4); crt_.output_level(4);
cycles -= 4; cycles -= 4;
} }
} else if constexpr (is_yamaha_vdp(personality)) {
border_colour = Storage<personality>::palette_[background_colour_];
} else { } else {
border_colour = palette[background_colour_]; border_colour = palette()[background_colour_];
} }
if(!cycles) { if(!cycles) {

View File

@ -131,7 +131,7 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
int indirect_register_ = 0; int indirect_register_ = 0;
bool increment_indirect_register_ = false; bool increment_indirect_register_ = false;
uint32_t palette_[16]{}; std::array<uint32_t, 16> palette_{};
uint8_t new_colour_ = 0; uint8_t new_colour_ = 0;
uint8_t palette_entry_ = 0; uint8_t palette_entry_ = 0;
@ -400,7 +400,7 @@ template <Personality personality> struct Base: public Storage<personality> {
} }
// The default TMS palette. // The default TMS palette.
static constexpr std::array<uint32_t, 16> palette { static constexpr std::array<uint32_t, 16> default_palette {
palette_pack(0, 0, 0), palette_pack(0, 0, 0),
palette_pack(0, 0, 0), palette_pack(0, 0, 0),
palette_pack(33, 200, 66), palette_pack(33, 200, 66),
@ -421,6 +421,12 @@ template <Personality personality> struct Base: public Storage<personality> {
palette_pack(204, 204, 204), palette_pack(204, 204, 204),
palette_pack(255, 255, 255) palette_pack(255, 255, 255)
}; };
const std::array<uint32_t, 16> &palette() {
if constexpr (is_yamaha_vdp(personality)) {
return Storage<personality>::palette_;
}
return default_palette;
}
Outputs::CRT::CRT crt_; Outputs::CRT::CRT crt_;
TVStandard tv_standard_ = TVStandard::NTSC; TVStandard tv_standard_ = TVStandard::NTSC;

View File

@ -19,7 +19,7 @@ void Base<personality>::draw_tms_character(int start, int end) {
const int pixels_left = end - start; const int pixels_left = end - start;
if(this->screen_mode_ == ScreenMode::MultiColour) { if(this->screen_mode_ == ScreenMode::MultiColour) {
for(int c = start; c < end; ++c) { for(int c = start; c < end; ++c) {
pixel_target_[c] = palette[ pixel_target_[c] = palette()[
(line_buffer.patterns[c >> 3][0] >> (((c & 4)^4))) & 15 (line_buffer.patterns[c >> 3][0] >> (((c & 4)^4))) & 15
]; ];
} }
@ -32,8 +32,8 @@ void Base<personality>::draw_tms_character(int start, int end) {
int pattern = Numeric::bit_reverse(line_buffer.patterns[byte_column][0]) >> shift; int pattern = Numeric::bit_reverse(line_buffer.patterns[byte_column][0]) >> shift;
uint8_t colour = line_buffer.patterns[byte_column][1]; uint8_t colour = line_buffer.patterns[byte_column][1];
uint32_t colours[2] = { uint32_t colours[2] = {
palette[(colour & 15) ? (colour & 15) : background_colour_], palette()[(colour & 15) ? (colour & 15) : background_colour_],
palette[(colour >> 4) ? (colour >> 4) : background_colour_] palette()[(colour >> 4) ? (colour >> 4) : background_colour_]
}; };
int background_pixels_left = pixels_left; int background_pixels_left = pixels_left;
@ -51,8 +51,8 @@ void Base<personality>::draw_tms_character(int start, int end) {
pattern = Numeric::bit_reverse(line_buffer.patterns[byte_column][0]); pattern = Numeric::bit_reverse(line_buffer.patterns[byte_column][0]);
colour = line_buffer.patterns[byte_column][1]; colour = line_buffer.patterns[byte_column][1];
colours[0] = palette[(colour & 15) ? (colour & 15) : background_colour_]; colours[0] = palette()[(colour & 15) ? (colour & 15) : background_colour_];
colours[1] = palette[(colour >> 4) ? (colour >> 4) : background_colour_]; colours[1] = palette()[(colour >> 4) ? (colour >> 4) : background_colour_];
} }
} }
@ -93,7 +93,7 @@ void Base<personality>::draw_tms_character(int start, int end) {
sprite_colour &= colour_masks[sprite.image[2]&15]; sprite_colour &= colour_masks[sprite.image[2]&15];
pixel_origin_[c] = pixel_origin_[c] =
(pixel_origin_[c] & sprite_colour_selection_masks[sprite_colour^1]) | (pixel_origin_[c] & sprite_colour_selection_masks[sprite_colour^1]) |
(palette[sprite.image[2]&15] & sprite_colour_selection_masks[sprite_colour]); (palette()[sprite.image[2]&15] & sprite_colour_selection_masks[sprite_colour]);
sprite.shift_position += shift_advance; sprite.shift_position += shift_advance;
} }
@ -107,7 +107,7 @@ void Base<personality>::draw_tms_character(int start, int end) {
template <Personality personality> template <Personality personality>
void Base<personality>::draw_tms_text(int start, int end) { void Base<personality>::draw_tms_text(int start, int end) {
LineBuffer &line_buffer = line_buffers_[output_pointer_.row]; LineBuffer &line_buffer = line_buffers_[output_pointer_.row];
const uint32_t colours[2] = { palette[background_colour_], palette[text_colour_] }; const uint32_t colours[2] = { palette()[background_colour_], palette()[text_colour_] };
const int shift = start % 6; const int shift = start % 6;
int byte_column = start / 6; int byte_column = start / 6;