Debian Codegraph @

src/engine/platform/sound/qsound.h

raw
1 #ifndef QSOUND_H
2 #define QSOUND_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 /*
8
9 Capcom DL-1425 QSound emulator
10 ==============================
11
12 by superctr (Ian Karlsson)
13 with thanks to Valley Bell
14
15 2018-05-12 - 2018-05-15
16
17 */
18
19 #include <stdint.h>
20
21 struct qsound_voice {
22 uint16_t bank;
23 int16_t addr; // top word is the sample address
24 uint16_t phase;
25 uint16_t rate;
26 int16_t loop_len;
27 int16_t end_addr;
28 int16_t volume;
29 int16_t echo;
30 };
31
32 struct qsound_adpcm {
33 uint16_t start_addr;
34 uint16_t end_addr;
35 uint16_t bank;
36 int16_t volume;
37 uint16_t flag;
38 int16_t cur_vol;
39 int16_t step_size;
40 uint16_t cur_addr;
41 };
42
43 // Q1 Filter
44 struct qsound_fir {
45 int tap_count; // usually 95
46 int delay_pos;
47 int16_t table_pos;
48 int16_t taps[95];
49 int16_t delay_line[95];
50 };
51
52 // Delay line
53 struct qsound_delay {
54 int16_t delay;
55 int16_t volume;
56 int16_t write_pos;
57 int16_t read_pos;
58 int16_t delay_line[51];
59 };
60
61 struct qsound_echo {
62 uint16_t end_pos;
63
64 int16_t feedback;
65 int16_t length;
66 int16_t last_sample;
67 int16_t delay_line[1024];
68 int16_t delay_pos;
69 };
70
71 struct qsound_chip {
72
73 unsigned long rom_mask;
74 uint8_t *rom_data;
75
76 uint32_t mute_mask;
77
78 uint16_t data_latch;
79 int16_t out[2];
80
81 int16_t pan_tables[2][2][98];
82
83 struct qsound_voice voice[16];
84 struct qsound_adpcm adpcm[3];
85
86 uint16_t voice_pan[16+3];
87 int16_t voice_output[16+3];
88
89 struct qsound_echo echo;
90
91 struct qsound_fir filter[2];
92 struct qsound_fir alt_filter[2];
93
94 struct qsound_delay wet[2];
95 struct qsound_delay dry[2];
96
97 uint16_t state;
98 uint16_t next_state;
99
100 uint16_t delay_update;
101
102 int state_counter;
103 int ready_flag;
104
105 uint16_t *register_map[256];
106 };
107
108 long qsound_start(struct qsound_chip *chip, int clock);
109 void qsound_reset(struct qsound_chip *chip);
110 void qsound_update(struct qsound_chip *chip);
111
112 void qsound_stream_update(struct qsound_chip *chip, int16_t **outputs, int samples);
113 void qsound_w(struct qsound_chip *chip, uint8_t offset, uint8_t data);
114 uint8_t qsound_r(struct qsound_chip *chip);
115 void qsound_write_data(struct qsound_chip *chip, uint8_t address, uint16_t data);
116 uint16_t qsound_read_data(struct qsound_chip *chip, uint8_t address);
117
118 #ifdef __cplusplus
119 };
120 #endif
121 #endif