1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Ensures AY registers are conveyed.

This commit is contained in:
Thomas Harte 2021-04-26 17:39:11 -04:00
parent 700c505974
commit 3348167c46
4 changed files with 30 additions and 1 deletions

View File

@ -12,6 +12,8 @@
#include "../../Outputs/Speaker/Implementation/SampleSource.hpp"
#include "../../Concurrency/AsyncTaskQueue.hpp"
#include "../../Reflection/Struct.hpp"
namespace GI {
namespace AY38910 {
@ -162,6 +164,8 @@ template <bool is_stereo> class AY38910: public ::Outputs::Speaker::SampleSource
uint8_t a_left_ = 255, a_right_ = 255;
uint8_t b_left_ = 255, b_right_ = 255;
uint8_t c_left_ = 255, c_right_ = 255;
friend struct State;
};
/*!
@ -192,6 +196,26 @@ struct Utility {
};
struct State: public Reflection::StructImpl<State> {
uint8_t registers[16]{};
// TODO: all audio-production thread state.
State() {
if(needs_declare()) {
DeclareField(registers);
}
}
template <typename AY> void apply(AY &target) {
// Establish emulator-thread state
for(uint8_t c = 0; c < 16; c++) {
target.select_register(c);
target.set_register_value(registers[c]);
}
}
};
}
}

View File

@ -11,7 +11,9 @@
#include "../../../Reflection/Struct.hpp"
#include "../../../Processors/Z80/State/State.hpp"
#include "Video.hpp"
#include "../../../Components/AY38910/AY38910.hpp"
namespace Sinclair {
namespace ZXSpectrum {
@ -29,6 +31,7 @@ struct State: public Reflection::StructImpl<State> {
// Meaningful for 128kb machines only.
uint8_t last_7ffd = 0;
uint8_t last_fffd = 0;
GI::AY38910::State ay;
// Meaningful for the +2a and +3 only.
uint8_t last_1ffd = 0;
@ -41,6 +44,7 @@ struct State: public Reflection::StructImpl<State> {
DeclareField(last_7ffd);
DeclareField(last_fffd);
DeclareField(last_1ffd);
DeclareField(ay);
}
}
};

View File

@ -128,6 +128,7 @@ template<Model model> class ConcreteMachine:
const auto state = static_cast<State *>(target.state.get());
state->z80.apply(z80_);
state->video.apply(*video_.last_valid());
state->ay.apply(ay_);
// 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.

View File

@ -142,7 +142,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
}
state->last_fffd = file.get8();
file.seek(16, SEEK_CUR); // Sound chip registers: TODO.
file.read(state->ay.registers, 16);
if(bonus_header_size != 23) {
// More Z80, the emulator, lack of encapsulation to deal with here.