openMSX
SCC.hh
Go to the documentation of this file.
1#ifndef SCC_HH
2#define SCC_HH
3
5
6#include "SimpleDebuggable.hh"
7#include "Clock.hh"
8#include "openmsx.hh"
9
10#include <array>
11#include <cstdint>
12
13namespace openmsx {
14
15class SCC final : public ResampledSoundDevice
16{
17public:
18 enum class Mode {Real, Compatible, Plus};
19
20 SCC(const std::string& name, const DeviceConfig& config,
21 EmuTime::param time, Mode mode = Mode::Real);
22 ~SCC();
23
24 // interaction with realCartridge
25 void powerUp(EmuTime::param time);
26 void reset(EmuTime::param time);
27 [[nodiscard]] uint8_t readMem(uint8_t address,EmuTime::param time);
28 [[nodiscard]] uint8_t peekMem(uint8_t address,EmuTime::param time) const;
29 void writeMem(uint8_t address, uint8_t value, EmuTime::param time);
30 void setMode(Mode newMode);
31
32 // public getters for classes interested to show SCC data
33 const std::array<std::array<int8_t, 32>, 5>& getWaveData() const { return wave; }
34
35 template<typename Archive>
36 void serialize(Archive& ar, unsigned version);
37
38private:
39 // SoundDevice
40 [[nodiscard]] float getAmplificationFactorImpl() const override;
41 void generateChannels(std::span<float*> bufs, unsigned num) override;
42
43 [[nodiscard]] uint8_t readWave(unsigned channel, unsigned address, EmuTime::param time) const;
44 void writeWave(unsigned channel, unsigned address, uint8_t value);
45 void setDeformReg(uint8_t value, EmuTime::param time);
46 void setDeformRegHelper(uint8_t value);
47 void setFreqVol(unsigned address, uint8_t value, EmuTime::param time);
48 [[nodiscard]] uint8_t getFreqVol(unsigned address) const;
49
50private:
51 static constexpr int CLOCK_FREQ = 3579545;
52
53 struct Debuggable final : SimpleDebuggable {
54 Debuggable(MSXMotherBoard& motherBoard, const std::string& name);
55 [[nodiscard]] uint8_t read(unsigned address, EmuTime::param time) override;
56 void write(unsigned address, uint8_t value, EmuTime::param time) override;
57 } debuggable;
58
59 Clock<CLOCK_FREQ> deformTimer;
60 Mode currentMode;
61
62 std::array<std::array<int8_t, 32>, 5> wave;
63 std::array<std::array<float, 32>, 5> volAdjustedWave; // ints stored as floats, see comment in adjust()
64 std::array<unsigned, 5> incr;
65 std::array<unsigned, 5> count;
66 std::array<unsigned, 5> pos;
67 std::array<unsigned, 5> period;
68 std::array<unsigned, 5> orgPeriod;
69 std::array<float, 5> out; // ints stored as floats
70 std::array<uint8_t, 5> volume;
71 uint8_t ch_enable;
72
73 uint8_t deformValue;
74 std::array<bool, 5> rotate;
75 std::array<bool, 5> readOnly;
76};
77
78} // namespace openmsx
79
80#endif
const std::array< std::array< int8_t, 32 >, 5 > & getWaveData() const
Definition SCC.hh:33
void setMode(Mode newMode)
Definition SCC.cc:183
void serialize(Archive &ar, unsigned version)
Definition SCC.cc:551
void powerUp(EmuTime::param time)
Definition SCC.cc:141
uint8_t readMem(uint8_t address, EmuTime::param time)
Definition SCC.cc:193
void reset(EmuTime::param time)
Definition SCC.cc:173
uint8_t peekMem(uint8_t address, EmuTime::param time) const
Definition SCC.cc:206
void writeMem(uint8_t address, uint8_t value, EmuTime::param time)
Definition SCC.cc:285
This file implemented 3 utility functions:
Definition Autofire.cc:11