openMSX
SN76489.hh
Go to the documentation of this file.
1 #ifndef SN76489_HH
2 #define SN76489_HH
3 
5 #include "SimpleDebuggable.hh"
6 
7 namespace openmsx {
8 
24 class SN76489 final : public ResampledSoundDevice
25 {
26 public:
27  SN76489(const DeviceConfig& config);
28  ~SN76489();
29 
30  // ResampledSoundDevice
31  void generateChannels(float** buffers, unsigned num) override;
32 
33  void reset(EmuTime::param time);
34  void write(byte value, EmuTime::param time);
35 
36  template<typename Archive>
37  void serialize(Archive& ar, unsigned version);
38 
39 private:
40  class NoiseShifter {
41  public:
45  inline void initState(unsigned pattern, unsigned period);
46 
49  inline unsigned getOutput() const;
50 
53  inline void advance();
54 
58  inline void queueAdvance(unsigned steps);
59 
62  void catchUp();
63 
64  template<typename Archive>
65  void serialize(Archive& ar, unsigned version);
66 
67  private:
68  unsigned pattern;
69  unsigned period;
70  unsigned random;
71  unsigned stepsBehind;
72  };
73 
76  void initState();
77 
81  void initNoise();
82 
83  word peekRegister(unsigned reg, EmuTime::param time) const;
84  void writeRegister(unsigned reg, word value, EmuTime::param time);
85  template <bool NOISE> void synthesizeChannel(
86  float*& buffer, unsigned num, unsigned generator);
87 
88  NoiseShifter noiseShifter;
89 
93  word regs[8];
94 
97  byte registerLatch;
98 
103  word counters[4];
104 
107  byte outputs[4];
108 
109  struct Debuggable final : SimpleDebuggable {
110  Debuggable(MSXMotherBoard& motherBoard, const std::string& name);
111  byte read(unsigned address, EmuTime::param time) override;
112  void write(unsigned address, byte value, EmuTime::param time) override;
113  } debuggable;
114 };
115 
116 } // namespace openmsx
117 
118 #endif
openmsx::ResampledSoundDevice
Definition: ResampledSoundDevice.hh:17
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::SimpleDebuggable
Definition: SimpleDebuggable.hh:12
openmsx::MSXMotherBoard
Definition: MSXMotherBoard.hh:61
SimpleDebuggable.hh
openmsx::SN76489::serialize
void serialize(Archive &ar, unsigned version)
Definition: SN76489.cc:312
openmsx::SN76489::SN76489
SN76489(const DeviceConfig &config)
Definition: SN76489.cc:91
openmsx::SN76489
This class implements the Texas Instruments SN76489 sound chip.
Definition: SN76489.hh:25
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::SN76489::generateChannels
void generateChannels(float **buffers, unsigned num) override
Abstract method to generate the actual sound data.
Definition: SN76489.cc:290
openmsx::SN76489::~SN76489
~SN76489()
Definition: SN76489.cc:105
utf8::advance
void advance(octet_iterator &it, distance_type n, octet_iterator end)
Definition: utf8_checked.hh:186
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::SN76489::write
void write(byte value, EmuTime::param time)
Definition: SN76489.cc:150
openmsx::SN76489::reset
void reset(EmuTime::param time)
Definition: SN76489.cc:144
ResampledSoundDevice.hh