diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
tree | 9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libgme/nes_vrc7_apu.h | |
parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/libgme/nes_vrc7_apu.h')
-rw-r--r-- | lib/rbcodec/codecs/libgme/nes_vrc7_apu.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/nes_vrc7_apu.h b/lib/rbcodec/codecs/libgme/nes_vrc7_apu.h new file mode 100644 index 0000000000..1f45a435db --- /dev/null +++ b/lib/rbcodec/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, int r ); | ||
31 | void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ); | ||
32 | |||
33 | void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ); | ||
34 | void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t, int data ); | ||
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, int v ) { Synth_volume( &this->synth, v / 3 / 4096 ); } | ||
51 | |||
52 | #endif | ||