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