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<personality>::commit_register(int reg, uint8_t value) { LOG("Screen mode: " << int(current_screen_mode<true>())); break; + case 7: + Storage<personality>::background_palette_[0] = Storage<personality>::palette_[background_colour_]; + break; + case 8: LOG("TODO: Yamaha VRAM organisation, sprite disable, etc; " << PADHEX(2) << +value); Storage<personality>::sprites_enabled_ = !(value & 0x02); + Storage<personality>::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<personality>::write_palette(uint8_t value) { const uint8_t b = (Storage<personality>::new_colour_ & 7) * 255 / 7; Storage<personality>::palette_[Storage<personality>::palette_entry_ & 0xf] = palette_pack(r, g, b); + Storage<personality>::background_palette_[Storage<personality>::palette_entry_ & 0xf] = palette_pack(r, g, b); + Storage<personality>::background_palette_[0] = Storage<personality>::palette_[background_colour_]; + ++Storage<personality>::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 <Personality personality> struct Base: public Storage<personality> { }; const std::array<uint32_t, 16> &palette() { if constexpr (is_yamaha_vdp(personality)) { - return Storage<personality>::palette_; + return Storage<personality>::solid_background_ ? Storage<personality>::palette_ : Storage<personality>::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 <Personality personality> struct Storage<personality, std::enable_if_t< bool increment_indirect_register_ = false; std::array<uint32_t, 16> palette_{}; + std::array<uint32_t, 16> background_palette_{}; + bool solid_background_ = true; + uint8_t new_colour_ = 0; uint8_t palette_entry_ = 0; bool palette_write_phase_ = false;