From bfa167fcdfb2a485223b0a901a7ea6b5d01d03d9 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 26 Feb 2023 13:42:59 -0500 Subject: [PATCH] Make attempt at the TP background-colour bit. --- Components/9918/Implementation/9918.cpp | 8 ++++++++ Components/9918/Implementation/9918Base.hpp | 2 +- Components/9918/Implementation/Storage.hpp | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 87456ed79..ff8724d0a 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -773,9 +773,14 @@ void Base::commit_register(int reg, uint8_t value) { LOG("Screen mode: " << int(current_screen_mode())); break; + case 7: + Storage::background_palette_[0] = Storage::palette_[background_colour_]; + break; + case 8: LOG("TODO: Yamaha VRAM organisation, sprite disable, etc; " << PADHEX(2) << +value); Storage::sprites_enabled_ = !(value & 0x02); + Storage::solid_background_ = value & 0x20; // b7: "1 = input on colour bus, enable mouse; 1 = output on colour bus, disable mouse" [documentation clearly in error] // b6: 1 = enable light pen // b5: sets the colour of code 0 to the colour of the palette (???) @@ -1013,6 +1018,9 @@ void Base::write_palette(uint8_t value) { const uint8_t b = (Storage::new_colour_ & 7) * 255 / 7; Storage::palette_[Storage::palette_entry_ & 0xf] = palette_pack(r, g, b); + Storage::background_palette_[Storage::palette_entry_ & 0xf] = palette_pack(r, g, b); + Storage::background_palette_[0] = Storage::palette_[background_colour_]; + ++Storage::palette_entry_; } } diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 024bf77a5..9e7a95d09 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -75,7 +75,7 @@ template struct Base: public Storage { }; const std::array &palette() { if constexpr (is_yamaha_vdp(personality)) { - return Storage::palette_; + return Storage::solid_background_ ? Storage::palette_ : Storage::background_palette_; } return default_palette; } diff --git a/Components/9918/Implementation/Storage.hpp b/Components/9918/Implementation/Storage.hpp index 80ebb0cf7..f83d8acac 100644 --- a/Components/9918/Implementation/Storage.hpp +++ b/Components/9918/Implementation/Storage.hpp @@ -40,6 +40,9 @@ template struct Storage palette_{}; + std::array background_palette_{}; + bool solid_background_ = true; + uint8_t new_colour_ = 0; uint8_t palette_entry_ = 0; bool palette_write_phase_ = false;