Mercurial > pmdwin
comparison fmgen/opna.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 __OPNA_H__ | |
2 #define __OPNA_H__ | |
3 | |
4 #include <stdint.h> | |
5 #include "op.h" | |
6 #include "psg.h" | |
7 | |
8 // YM2608 (OPNA) ------------------------------------------------------ | |
9 typedef struct _OPNA | |
10 { | |
11 int fmvolume; | |
12 uint32_t clock; | |
13 uint32_t rate; | |
14 uint32_t psgrate; | |
15 uint32_t status; | |
16 Channel4 ch[6]; | |
17 Channel4* csmch; | |
18 | |
19 int32_t mixdelta; | |
20 int mpratio; | |
21 uint8_t interpolation; | |
22 | |
23 uint8_t timer_status; | |
24 uint8_t regtc; | |
25 uint8_t regta[2]; | |
26 | |
27 int32_t timera, timera_count; | |
28 int32_t timerb, timerb_count; | |
29 int32_t timer_step; | |
30 uint8_t prescale; | |
31 uint8_t devmask; | |
32 | |
33 PSG psg; | |
34 | |
35 Rhythm rhythm[6]; | |
36 int8_t rhythmtl; | |
37 int rhythmtvol; | |
38 uint8_t rhythmkey; | |
39 | |
40 int32_t mixl, mixl1; | |
41 uint8_t pan[6]; | |
42 uint8_t fnum2[9]; | |
43 | |
44 uint8_t reg22; | |
45 uint32_t reg29; | |
46 uint32_t statusnext; | |
47 | |
48 uint32_t lfocount; | |
49 uint32_t lfodcount; | |
50 | |
51 uint32_t fnum[6]; | |
52 uint32_t fnum3[3]; | |
53 } OPNA; | |
54 | |
55 #ifdef __cplusplus | |
56 extern "C" { | |
57 #endif | |
58 | |
59 // --------------------------------------------------------------------------- | |
60 uint8_t OPNAInit(OPNA *opna, uint c, uint r, uint8_t ipflag); | |
61 void OPNAReset(OPNA *opna); | |
62 void SetVolumeFM(OPNA *opna, int db); | |
63 void SetVolumeRhythmTotal(OPNA *opna, int db); | |
64 uint8_t OPNASetRate(OPNA *opna, uint r, uint8_t ipflag); | |
65 void OPNASetChannelMask(OPNA *opna, uint mask); | |
66 void OPNASetReg(OPNA *opna, uint addr, uint data); | |
67 uint8_t OPNATimerCount(OPNA *opna, int32_t us); | |
68 void OPNAMix(OPNA *opna, Sample* buffer, uint32_t nsamples); | |
69 | |
70 // --------------------------------------------------------------------------- | |
71 static inline uint32_t ReadStatus(OPNA *opna) { return opna->status & 0x03; } | |
72 static inline void SetVolumeRhythm(OPNA *opna, int index, int db) | |
73 { | |
74 db = Min(db, 20); | |
75 opna->rhythm[index].volume = -(db * 2 / 3); | |
76 } | |
77 | |
78 static inline int32_t OPNAGetNextEvent(OPNA *opna) | |
79 { | |
80 uint32_t ta = ((opna->timera_count + 0xffff) >> 16) - 1; | |
81 uint32_t tb = ((opna->timerb_count + 0xfff) >> 12) - 1; | |
82 return (ta < tb ? ta : tb) + 1; | |
83 } | |
84 | |
85 #ifdef __cplusplus | |
86 }; | |
87 #endif | |
88 | |
89 #endif // FM_OPNA_H |