Mercurial > pmdwin
comparison fmgen/psg.h @ 0:c55ea9478c80
Hello Gensokyo!
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 21 May 2013 10:29:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c55ea9478c80 |
---|---|
1 #ifndef __PSG_H__ | |
2 #define __PSG_H__ | |
3 | |
4 #include <stdint.h> | |
5 #define PSG_SAMPLETYPE int32_t // any of int16_t, int32_t or float will work here. | |
6 | |
7 // Constants for the shift amounts used in the counters. | |
8 // | |
9 enum { | |
10 toneshift = 24, | |
11 envshift = 22 | |
12 }; | |
13 | |
14 typedef struct _PSG { | |
15 uint8_t reg[16]; | |
16 | |
17 const uint32_t *envelop; | |
18 uint32_t rng; | |
19 uint32_t olevel[3]; | |
20 uint32_t scount[3], speriod[3]; | |
21 uint32_t ecount, eperiod; | |
22 uint32_t ncount, nperiod; | |
23 uint32_t tperiodbase; | |
24 uint32_t eperiodbase; | |
25 int volume; | |
26 int mask; | |
27 } PSG; | |
28 | |
29 #ifdef __cplusplus | |
30 extern "C" { | |
31 #endif | |
32 | |
33 // Mostly self-explanatory. | |
34 // Actual descriptions of each function can be found in psg.c | |
35 // Also, PSGGetReg() is basically useless. | |
36 // (More info on that can *also* be found in psg.c). | |
37 void PSGInit(PSG *psg); | |
38 void PSGReset(PSG *psg); | |
39 void PSGSetClock(PSG *psg, uint32_t clock, uint32_t rate); | |
40 void SetVolumePSG(PSG *psg, int volume); | |
41 void PSGSetChannelMask(PSG *psg, int c); | |
42 void PSGSetReg(PSG *psg, uint8_t regnum, uint8_t data); | |
43 void PSGMix(PSG *psg, int32_t *dest, uint32_t nsamples); | |
44 | |
45 static inline uint32_t PSGGetReg(PSG *psg, uint8_t regnum) { | |
46 return psg->reg[regnum & 0x0f]; | |
47 } | |
48 | |
49 #ifdef __cplusplus | |
50 }; | |
51 #endif | |
52 | |
53 #endif // PSG_H |