From f40bfc9267b13b54e6379dfe7539447662879d24 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Sat, 25 Jun 2011 21:32:25 -0400 Subject: Add codecs to librbcodec. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97 Reviewed-on: http://gerrit.rockbox.org/137 Reviewed-by: Nils Wallménius Tested-by: Nils Wallménius --- lib/rbcodec/codecs/libgme/nes_vrc7_apu.h | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/rbcodec/codecs/libgme/nes_vrc7_apu.h (limited to 'lib/rbcodec/codecs/libgme/nes_vrc7_apu.h') 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 @@ +// Konami VRC7 sound chip emulator + +#ifndef NES_VRC7_APU_H +#define NES_VRC7_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +#include "emu2413.h" + +enum { vrc7_osc_count = 6 }; + +struct vrc7_osc_t { + struct Blip_Buffer* output; + int last_amp; +}; + +struct Nes_Vrc7_Apu { + OPLL opll; + int addr; + blip_time_t next_time; + struct vrc7_osc_t osc; + struct Blip_Synth synth; + e_uint32 mask; +}; + +// See Nes_Apu.h for reference +void Vrc7_init( struct Nes_Vrc7_Apu* this ); +void Vrc7_reset( struct Nes_Vrc7_Apu* this ); +void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r ); +void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ); + +void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ); +void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t, int data ); + +void output_changed( struct Nes_Vrc7_Apu* this ); +static inline void Vrc7_set_output( struct Nes_Vrc7_Apu* this, int i, struct Blip_Buffer* buf ) +{ + assert( (unsigned) i < vrc7_osc_count ); + this->mask |= 1 << i; + + // Will use OPLL_setMask to mute voices + if ( buf ) { + this->mask ^= 1 << i; + this->osc.output = buf; + } +} + +// DB2LIN_AMP_BITS == 11, * 2 +static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, int v ) { Synth_volume( &this->synth, v / 3 / 4096 ); } + +#endif -- cgit v1.2.3