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