Debian Codegraph @

src/engine/platform/sound/c64_d/dsid.h

raw
1 #ifndef DSID_H
2 #define DSID_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #include <stdint.h>
9
10 struct SID_ctx_chan {
11 double rcnt;
12 double envcnt;
13 double expcnt;
14 double pacc;
15 double pracc;
16 int FSW;
17 int nLFSR;
18 double prevwfout;
19 uint8_t pSR;
20 int Ast;
21 };
22
23 struct SID_ctx {
24 int sMSBrise;
25 int sMSB;
26 double plp;
27 double pbp;
28 struct SID_ctx_chan ch[3];
29 };
30
31 struct SIDVOICE {
32 uint8_t freq_low;
33 uint8_t freq_high;
34 uint8_t pw_low;
35 uint8_t pw_high : 4;
36 uint8_t UNUSED : 4;
37 uint8_t control;
38 uint8_t decay : 4;
39 uint8_t attack : 4;
40 uint8_t susres;
41 // uint8_t release : 4;
42 // uint8_t sustain : 4;
43 };
44
45 struct SIDMEM {
46 struct SIDVOICE v[3];
47 uint8_t UNUSED : 4;
48 uint8_t cutoff_low : 4;
49 uint8_t cutoff_high;
50 uint8_t reso_rt : 4;
51 uint8_t reso : 4;
52 uint8_t volume : 4;
53 uint8_t filter_mode : 4;
54 uint8_t paddlex;
55 uint8_t paddley;
56 uint8_t osc3;
57 uint8_t env3;
58 };
59
60 struct SID_globals {
61 double ckr;
62 double ctfr;
63 double ctf_ratio_6581;
64
65 double ctf_table[2048];
66
67 int trsaw[4096];
68 int pusaw[4096];
69 int Pulsetrsaw[4096];
70
71 double Aprd[16];
72 int Astp[16];
73 int model;
74 };
75
76 #define MemLen 65536
77
78 struct SID_chip {
79 struct SID_globals g;
80 struct SID_ctx SIDct[3];
81 uint8_t M[MemLen];
82 int16_t lastOut[3];
83 int mute_mask;
84 double fakeplp[3];
85 double fakepbp[3];
86 };
87
88 double dSID_render(struct SID_chip* sid);
89 void dSID_init(struct SID_chip* sid, double clockRate, double samplingRate, int model, unsigned char init_wf);
90 float dSID_getVolume(struct SID_chip* sid, int channel);
91 void dSID_setMuteMask(struct SID_chip* sid, int mute_mask);
92
93 void dSID_write(struct SID_chip* sid, unsigned char addr, unsigned char val);
94
95 #ifdef __cplusplus
96 }
97 #endif
98
99 #endif