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