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 const 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
void setChipMode(ChipMode newMode)
Definition: SCC.cc:182
void writeMem(byte address, byte value, EmuTime::param time)
Definition: SCC.cc:289
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void reset(EmuTime::param time)
Definition: SCC.cc:172
byte readMem(byte address, EmuTime::param time)
Definition: SCC.cc:192
SCC(const std::string &name, const DeviceConfig &config, EmuTime::param time, ChipMode mode=SCC_Real)
Definition: SCC.cc:120
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
byte peekMem(byte address, EmuTime::param time) const
Definition: SCC.cc:205
void serialize(Archive &ar, unsigned version)
Definition: SCC.cc:554
void powerUp(EmuTime::param time)
Definition: SCC.cc:140