diff --git a/Machines/Sinclair/ZXSpectrum/Video.hpp b/Machines/Sinclair/ZXSpectrum/Video.hpp index 8363d0ad3..a6bc38a14 100644 --- a/Machines/Sinclair/ZXSpectrum/Video.hpp +++ b/Machines/Sinclair/ZXSpectrum/Video.hpp @@ -401,6 +401,8 @@ template class Video { uint8_t last_fetches_[4] = {0xff, 0xff, 0xff, 0xff}; uint8_t last_contended_access_ = 0xff; + friend struct State; + #define RGB(r, g, b) (r << 4) | (g << 2) | b static constexpr uint8_t palette[] = { RGB(0, 0, 0), RGB(0, 0, 2), RGB(2, 0, 0), RGB(2, 0, 2), @@ -412,13 +414,29 @@ template class Video { }; struct State: public Reflection::StructImpl { - uint8_t border_colour; + uint8_t border_colour = 0; + int time_into_frame = 0; + bool flash = 0; + int flash_counter = 0; + bool is_alternate_line = false; State() { if(needs_declare()) { DeclareField(border_colour); + DeclareField(time_into_frame); + DeclareField(flash); + DeclareField(flash_counter); + DeclareField(is_alternate_line); } } + + template void apply(Video &target) { + target.set_border_colour(border_colour); + target.time_into_frame_ = time_into_frame; + target.flash_mask_ = flash ? 0xff : 0x00; + target.flash_counter_ = flash_counter; + target.is_alternate_line_ = is_alternate_line; + } }; } diff --git a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp index 83a07ab98..7a4bdd9c7 100644 --- a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp +++ b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp @@ -127,6 +127,7 @@ template class ConcreteMachine: if(target.state) { const auto state = static_cast(target.state.get()); state->z80.apply(z80_); + state->video.apply(*video_.last_valid()); // If this is a 48k or 16k machine, remap source data from its original // linear form to whatever the banks end up being; otherwise copy as is. @@ -138,8 +139,6 @@ template class ConcreteMachine: } else { memcpy(ram_.data(), state->ram.data(), std::min(ram_.size(), state->ram.size())); } - - LOG("TODO: apply rest of state"); } }