openMSX
Y8950Adpcm.hh
Go to the documentation of this file.
1#ifndef Y8950ADPCM_HH
2#define Y8950ADPCM_HH
3
4#include "Clock.hh"
5#include "Schedulable.hh"
6#include "TrackedRam.hh"
7#include "openmsx.hh"
8#include "serialize_meta.hh"
9
10namespace openmsx {
11
12class DeviceConfig;
13class Y8950;
14
15class Y8950Adpcm final : public Schedulable
16{
17public:
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 [[nodiscard]] bool isMuted() const;
24 void writeReg(byte rg, byte data, EmuTime::param time);
25 [[nodiscard]] byte readReg(byte rg, EmuTime::param time);
26 [[nodiscard]] byte peekReg(byte rg, EmuTime::param time) const;
27 [[nodiscard]] int calcSample();
28 void sync(EmuTime::param time);
29 void resetStatus();
30
31 template<typename Archive>
32 void serialize(Archive& ar, unsigned version);
33
34private:
35 // This data is updated while playing
36 struct PlayData {
37 unsigned memPtr;
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) const;
52
53 [[nodiscard]] bool isPlaying() const;
54 void writeData(byte data);
55 [[nodiscard]] byte peekReg(byte rg) const;
56 [[nodiscard]] byte readData();
57 [[nodiscard]] byte peekData() const;
58 void writeMemory(unsigned memPtr, byte value);
59 [[nodiscard]] byte readMemory(unsigned memPtr) const;
60 [[nodiscard]] int calcSample(bool doEmu);
61
62private:
63 Y8950& y8950;
64 TrackedRam ram;
65
66 // copy/pasted from Y8950.hh
67 static constexpr int CLOCK_FREQ = 3579545;
68 static constexpr int CLOCK_FREQ_DIV = 72;
70
71 PlayData emu; // used for emulator behaviour (read back of sample data)
72 PlayData aud; // used by audio generation thread
73
74 unsigned startAddr;
75 unsigned stopAddr;
76 unsigned addrMask;
77 int volume = 0;
78 int volumeWStep;
79 int readDelay;
80 int delta;
81 byte reg7;
82 byte reg15;
83 bool romBank;
84};
86
87} // namespace openmsx
88
89#endif
Represents a clock with a fixed frequency.
Definition Clock.hh:19
Every class that wants to get scheduled at some point must inherit from this class.
void sync(EmuTime::param time)
byte readReg(byte rg, EmuTime::param time)
bool isMuted() const
Definition Y8950Adpcm.cc:94
byte peekReg(byte rg, EmuTime::param time) const
void writeReg(byte rg, byte data, EmuTime::param time)
void serialize(Archive &ar, unsigned version)
void reset(EmuTime::param time)
Definition Y8950Adpcm.cc:68
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define SERIALIZE_CLASS_VERSION(CLASS, VERSION)