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 
9 namespace openmsx {
10 
11 class SCC final : public ResampledSoundDevice
12 {
13 public:
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  byte readMem(byte address,EmuTime::param time);
24  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 
31 private:
32  // SoundDevice
33  float getAmplificationFactorImpl() const override;
34  void generateChannels(float** bufs, unsigned num) override;
35 
36  inline float adjust(signed char wav, byte vol);
37  byte readWave(unsigned channel, unsigned address, EmuTime::param time) const;
38  void writeWave(unsigned channel, unsigned address, byte value);
39  void setDeformReg(byte value, EmuTime::param time);
40  void setDeformRegHelper(byte value);
41  void setFreqVol(unsigned address, byte value, EmuTime::param time);
42  byte getFreqVol(unsigned address) const;
43 
44  static constexpr int CLOCK_FREQ = 3579545;
45 
46  struct Debuggable final : SimpleDebuggable {
47  Debuggable(MSXMotherBoard& motherBoard, const std::string& name);
48  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
openmsx.hh
Clock.hh
openmsx::ResampledSoundDevice
Definition: ResampledSoundDevice.hh:17
openmsx::SCC::SCC
SCC(const std::string &name, const DeviceConfig &config, EmuTime::param time, ChipMode mode=SCC_Real)
Definition: SCC.cc:120
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::SimpleDebuggable
Definition: SimpleDebuggable.hh:12
openmsx::SCC::reset
void reset(EmuTime::param time)
Definition: SCC.cc:172
openmsx::SCC::~SCC
~SCC()
Definition: SCC.cc:135
openmsx::SCC::readMem
byte readMem(byte address, EmuTime::param time)
Definition: SCC.cc:192
openmsx::Debuggable
Definition: Debuggable.hh:10
openmsx::SCC
Definition: SCC.hh:12
openmsx::MSXMotherBoard
Definition: MSXMotherBoard.hh:60
openmsx::SCC::powerUp
void powerUp(EmuTime::param time)
Definition: SCC.cc:140
SimpleDebuggable.hh
openmsx::SCC::SCC_Real
@ SCC_Real
Definition: SCC.hh:14
openmsx::SCC::peekMem
byte peekMem(byte address, EmuTime::param time) const
Definition: SCC.cc:205
openmsx::SCC::SCC_Compatible
@ SCC_Compatible
Definition: SCC.hh:14
openmsx::SCC::serialize
void serialize(Archive &ar, unsigned version)
Definition: SCC.cc:554
openmsx::SCC::setChipMode
void setChipMode(ChipMode newMode)
Definition: SCC.cc:182
openmsx::SCC::writeMem
void writeMem(byte address, byte value, EmuTime::param time)
Definition: SCC.cc:289
openmsx::SCC::ChipMode
ChipMode
Definition: SCC.hh:14
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::SCC::SCC_plusmode
@ SCC_plusmode
Definition: SCC.hh:14
ResampledSoundDevice.hh