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
37 enum class Phase : uint8_t {
38 RESET,
39 IDLE,
40 SETUP,
41 WAIT,
42 RUN,
43 STOP,
44 END
45 };
46
47private:
48 void setRST(bool pin);
49 void setVCU(bool pin);
50 void setST (bool pin);
51
52 // SoundDevice
53 void generateChannels(std::span<float*> bufs, unsigned num) override;
54 [[nodiscard]] float getAmplificationFactorImpl() const override;
55
56 void setupParameter(uint8_t param);
57 [[nodiscard]] unsigned getBits(unsigned sBit, unsigned bits) const;
58 [[nodiscard]] int parseFrame();
59
60private:
61 Rom rom;
62 unsigned address_mask;
63
64 // state of option parameter
65 uint8_t frame_size;
66 int pitch_offset;
67
68 // these contain data describing the current and previous voice frames
69 // these are all used to contain the current state of the sound generation
70 unsigned current_energy;
71 unsigned current_pitch;
72 std::array<int, 10> current_k;
73 std::array<int, 10> x;
74
75 uint16_t address;
76 uint16_t vcu_addr_h;
77
78 std::array<int16_t, 10> old_k;
79 std::array<int16_t, 10> new_k;
80 std::array<int16_t, 10> target_k;
81 uint16_t old_energy;
82 uint16_t new_energy;
83 uint16_t target_energy;
84 uint8_t old_pitch;
85 uint8_t new_pitch;
86 uint8_t target_pitch;
87
88 uint8_t interp_step;
89 uint8_t interp_count; // number of interp periods
90 uint8_t sample_count; // sample number within interp
91 uint8_t pitch_count;
92
93 uint8_t latch_data{0};
94 uint8_t parameter;
95 Phase phase;
96 bool pin_BSY{false};
97 bool pin_ST{false};
98 bool pin_VCU{false};
99 bool pin_RST{false};
100};
102
103} // namespace openmsx
104
105#endif
void writeData(uint8_t data)
latch control data
Definition VLM5030.cc:421
bool getBSY(EmuTime::param time) const
get BSY pin level
Definition VLM5030.cc:414
void writeControl(uint8_t data, EmuTime::param time)
set RST / VCU / ST pins
Definition VLM5030.cc:426
void serialize(Archive &ar, unsigned version)
Definition VLM5030.cc:554
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define SERIALIZE_CLASS_VERSION(CLASS, VERSION)