openMSX
VLM5030.hh
Go to the documentation of this file.
1 #ifndef VLM5030_HH
2 #define VLM5030_HH
3 
5 #include "Rom.hh"
6 #include "EmuTime.hh"
7 #include "openmsx.hh"
8 #include <string>
9 
10 namespace openmsx {
11 
12 class DeviceConfig;
13 
14 class VLM5030 final : public ResampledSoundDevice
15 {
16 public:
17  VLM5030(const std::string& name, const std::string& desc,
18  const std::string& romFilename, const DeviceConfig& config);
19  ~VLM5030();
20  void reset();
21 
23  void writeData(byte data);
24 
26  void writeControl(byte data, EmuTime::param time);
27 
29  bool getBSY(EmuTime::param time) const;
30 
31  template<typename Archive>
32  void serialize(Archive& ar, unsigned version);
33 
34 private:
35  void setRST(bool pin);
36  void setVCU(bool pin);
37  void setST (bool pin);
38 
39  // SoundDevice
40  void generateChannels(float** bufs, unsigned num) override;
41  float getAmplificationFactorImpl() const override;
42 
43  void setupParameter(byte param);
44  int getBits(unsigned sbit, unsigned bits);
45  int parseFrame();
46 
47  Rom rom;
48  int address_mask;
49 
50  // state of option paramter
51  int frame_size;
52  int pitch_offset;
53 
54  // these contain data describing the current and previous voice frames
55  // these are all used to contain the current state of the sound generation
56  unsigned current_energy;
57  unsigned current_pitch;
58  int current_k[10];
59  int x[10];
60 
61  word address;
62  word vcu_addr_h;
63 
64  int16_t old_k[10];
65  int16_t new_k[10];
66  int16_t target_k[10];
67  word old_energy;
68  word new_energy;
69  word target_energy;
70  byte old_pitch;
71  byte new_pitch;
72  byte target_pitch;
73 
74  byte interp_step;
75  byte interp_count; // number of interp periods
76  byte sample_count; // sample number within interp
77  byte pitch_count;
78 
79  byte latch_data;
80  byte parameter;
81  byte phase;
82  bool pin_BSY;
83  bool pin_ST;
84  bool pin_VCU;
85  bool pin_RST;
86 };
87 
88 } // namespace openmsx
89 
90 #endif
void serialize(Archive &ar, unsigned version)
Definition: VLM5030.cc:549
void writeControl(byte data, EmuTime::param time)
set RST / VCU / ST pins
Definition: VLM5030.cc:432
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void writeData(byte data)
latch control data
Definition: VLM5030.cc:427
constexpr auto data(C &c) -> decltype(c.data())
Definition: span.hh:69
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
VLM5030(const std::string &name, const std::string &desc, const std::string &romFilename, const DeviceConfig &config)
Definition: VLM5030.cc:522
bool getBSY(EmuTime::param time) const
get BSY pin level
Definition: VLM5030.cc:420