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 template<typename Archive>
33 void serialize(Archive& ar, unsigned version);
34
35private:
36 // SoundDevice
37 [[nodiscard]] float getAmplificationFactorImpl() const override;
38 void generateChannels(std::span<float*> bufs, unsigned num) override;
39
40 [[nodiscard]] uint8_t readWave(unsigned channel, unsigned address, EmuTime::param time) const;
41 void writeWave(unsigned channel, unsigned address, uint8_t value);
42 void setDeformReg(uint8_t value, EmuTime::param time);
43 void setDeformRegHelper(uint8_t value);
44 void setFreqVol(unsigned address, uint8_t value, EmuTime::param time);
45 [[nodiscard]] uint8_t getFreqVol(unsigned address) const;
46
47private:
48 static constexpr int CLOCK_FREQ = 3579545;
49
50 struct Debuggable final : SimpleDebuggable {
51 Debuggable(MSXMotherBoard& motherBoard, const std::string& name);
52 [[nodiscard]] uint8_t read(unsigned address, EmuTime::param time) override;
53 void write(unsigned address, uint8_t value, EmuTime::param time) override;
54 } debuggable;
55
56 Clock<CLOCK_FREQ> deformTimer;
57 Mode currentMode;
58
59 std::array<std::array<int8_t, 32>, 5> wave;
60 std::array<std::array<float, 32>, 5> volAdjustedWave; // ints stored as floats, see comment in adjust()
61 std::array<unsigned, 5> incr;
62 std::array<unsigned, 5> count;
63 std::array<unsigned, 5> pos;
64 std::array<unsigned, 5> period;
65 std::array<unsigned, 5> orgPeriod;
66 std::array<float, 5> out; // ints stored as floats
67 std::array<uint8_t, 5> volume;
68 uint8_t ch_enable;
69
70 uint8_t deformValue;
71 std::array<bool, 5> rotate;
72 std::array<bool, 5> readOnly;
73};
74
75} // namespace openmsx
76
77#endif
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