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