openMSX
Y8950Adpcm.hh
Go to the documentation of this file.
1 #ifndef Y8950ADPCM_HH
2 #define Y8950ADPCM_HH
3 
4 #include "TrackedRam.hh"
5 #include "Schedulable.hh"
6 #include "Clock.hh"
7 #include "serialize_meta.hh"
8 #include "openmsx.hh"
9 
10 namespace openmsx {
11 
12 class DeviceConfig;
13 class Y8950;
14 
15 class Y8950Adpcm final : public Schedulable
16 {
17 public:
18  Y8950Adpcm(Y8950& y8950, const DeviceConfig& config,
19  const std::string& name, unsigned sampleRam);
20 
21  void clearRam();
22  void reset(EmuTime::param time);
23  bool isMuted() const;
24  void writeReg(byte rg, byte data, EmuTime::param time);
25  byte readReg(byte rg, EmuTime::param time);
26  byte peekReg(byte rg, EmuTime::param time) const;
27  int calcSample();
28  void sync(EmuTime::param time);
29  void resetStatus();
30 
31  template<typename Archive>
32  void serialize(Archive& ar, unsigned version);
33 
34 private:
35  // This data is updated while playing
36  struct PlayData {
37  unsigned memPntr;
38  unsigned nowStep;
39  int out;
40  int output;
41  int diff;
42  int nextLeveling;
43  int sampleStep;
44  byte adpcm_data;
45  };
46 
47  // Schedulable
48  void executeUntil(EmuTime::param time) override;
49 
50  void schedule();
51  void restart(PlayData& pd);
52 
53  bool isPlaying() const;
54  void writeData(byte data);
55  byte peekReg(byte rg) const;
56  byte readData();
57  byte peekData() const;
58  void writeMemory(unsigned memPntr, byte value);
59  byte readMemory(unsigned memPntr) const;
60  int calcSample(bool doEmu);
61 
62  Y8950& y8950;
63  TrackedRam ram;
64 
65  // copy/pasted from Y8950.hh
66  static constexpr int CLOCK_FREQ = 3579545;
67  static constexpr int CLOCK_FREQ_DIV = 72;
69 
70  PlayData emu; // used for emulator behaviour (read back of sample data)
71  PlayData aud; // used by audio generation thread
72 
73  unsigned startAddr;
74  unsigned stopAddr;
75  unsigned addrMask;
76  int volume;
77  int volumeWStep;
78  int readDelay;
79  int delta;
80  byte reg7;
81  byte reg15;
82  bool romBank;
83 };
85 
86 } // namespace openmsx
87 
88 #endif
openmsx.hh
Clock.hh
openmsx::Y8950Adpcm::calcSample
int calcSample()
Definition: Y8950Adpcm.cc:431
openmsx::Y8950Adpcm
Definition: Y8950Adpcm.hh:16
openmsx::Y8950Adpcm::Y8950Adpcm
Y8950Adpcm(Y8950 &y8950, const DeviceConfig &config, const std::string &name, unsigned sampleRam)
Definition: Y8950Adpcm.cc:47
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
serialize_meta.hh
openmsx::Y8950Adpcm::isMuted
bool isMuted() const
Definition: Y8950Adpcm.cc:89
openmsx::Schedulable
Every class that wants to get scheduled at some point must inherit from this class.
Definition: Schedulable.hh:34
openmsx::Y8950Adpcm::sync
void sync(EmuTime::param time)
Definition: Y8950Adpcm.cc:106
Schedulable.hh
openmsx::Y8950Adpcm::reset
void reset(EmuTime::param time)
Definition: Y8950Adpcm.cc:63
openmsx::Y8950Adpcm::readReg
byte readReg(byte rg, EmuTime::param time)
Definition: Y8950Adpcm.cc:301
openmsx::SERIALIZE_CLASS_VERSION
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
openmsx::Y8950Adpcm::clearRam
void clearRam()
Definition: Y8950Adpcm.cc:58
TrackedRam.hh
openmsx::Y8950Adpcm::resetStatus
void resetStatus()
Definition: Y8950Adpcm.cc:333
openmsx::Y8950Adpcm::writeReg
void writeReg(byte rg, byte data, EmuTime::param time)
Definition: Y8950Adpcm.cc:151
openmsx::Y8950Adpcm::serialize
void serialize(Archive &ar, unsigned version)
Definition: Y8950Adpcm.cc:516
openmsx::Y8950
Y8950
Definition: Y8950.cc:1367
openmsx::Y8950Adpcm::peekReg
byte peekReg(byte rg, EmuTime::param time) const
Definition: Y8950Adpcm.cc:310
openmsx::Clock< CLOCK_FREQ, CLOCK_FREQ_DIV >
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::TrackedRam
Definition: TrackedRam.hh:10
openmsx::Y8950
Definition: Y8950.hh:24