diff options
Diffstat (limited to 'apps/codecs/libgme/nes_vrc7_apu.h')
-rw-r--r-- | apps/codecs/libgme/nes_vrc7_apu.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/apps/codecs/libgme/nes_vrc7_apu.h b/apps/codecs/libgme/nes_vrc7_apu.h new file mode 100644 index 0000000000..5453e6b403 --- /dev/null +++ b/apps/codecs/libgme/nes_vrc7_apu.h | |||
@@ -0,0 +1,52 @@ | |||
1 | // Konami VRC7 sound chip emulator | ||
2 | |||
3 | #ifndef NES_VRC7_APU_H | ||
4 | #define NES_VRC7_APU_H | ||
5 | |||
6 | #include "blargg_common.h" | ||
7 | #include "blip_buffer.h" | ||
8 | |||
9 | #include "emu2413.h" | ||
10 | |||
11 | enum { vrc7_osc_count = 6 }; | ||
12 | |||
13 | struct vrc7_osc_t { | ||
14 | struct Blip_Buffer* output; | ||
15 | int last_amp; | ||
16 | }; | ||
17 | |||
18 | struct Nes_Vrc7_Apu { | ||
19 | OPLL opll; | ||
20 | int addr; | ||
21 | blip_time_t next_time; | ||
22 | struct vrc7_osc_t osc; | ||
23 | struct Blip_Synth synth; | ||
24 | e_uint32 mask; | ||
25 | }; | ||
26 | |||
27 | // See Nes_Apu.h for reference | ||
28 | void Vrc7_init( struct Nes_Vrc7_Apu* this ); | ||
29 | void Vrc7_reset( struct Nes_Vrc7_Apu* this ); | ||
30 | void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, double r ); | ||
31 | void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ) ICODE_ATTR; | ||
32 | |||
33 | void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ) ICODE_ATTR; | ||
34 | void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t, int data ) ICODE_ATTR; | ||
35 | |||
36 | void output_changed( struct Nes_Vrc7_Apu* this ); | ||
37 | static inline void Vrc7_set_output( struct Nes_Vrc7_Apu* this, int i, struct Blip_Buffer* buf ) | ||
38 | { | ||
39 | assert( (unsigned) i < vrc7_osc_count ); | ||
40 | this->mask |= 1 << i; | ||
41 | |||
42 | // Will use OPLL_setMask to mute voices | ||
43 | if ( buf ) { | ||
44 | this->mask ^= 1 << i; | ||
45 | this->osc.output = buf; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | // DB2LIN_AMP_BITS == 11, * 2 | ||
50 | static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, double v ) { Synth_volume( &this->synth, 1.0 / 3 / 4096 * v ); } | ||
51 | |||
52 | #endif | ||