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/hes_apu.h | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lib/rbcodec/codecs/libgme/hes_apu.h (limited to 'lib/rbcodec/codecs/libgme/hes_apu.h') diff --git a/lib/rbcodec/codecs/libgme/hes_apu.h b/lib/rbcodec/codecs/libgme/hes_apu.h new file mode 100644 index 0000000000..0265e6a3ad --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_apu.h @@ -0,0 +1,66 @@ +// Turbo Grafx 16 (PC Engine) PSG sound chip emulator + +// Game_Music_Emu 0.5.2 +#ifndef HES_APU_H +#define HES_APU_H + +#include "blargg_common.h" +#include "blargg_source.h" +#include "blip_buffer.h" + +enum { amp_range = 0x8000 }; +enum { osc_count = 6 }; // 0 <= chan < osc_count + +// Registers are at io_addr to io_addr+io_size-1 +enum { apu_io_addr = 0x0800 }; +enum { apu_io_size = 10 }; + +struct Hes_Osc +{ + byte wave [32]; + int delay; + int period; + int phase; + + int noise_delay; + byte noise; + unsigned lfsr; + + byte control; + byte balance; + byte dac; + short volume [2]; + int last_amp [2]; + + blip_time_t last_time; + struct Blip_Buffer* output [2]; + struct Blip_Buffer* outputs [3]; +}; + +void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ); + +struct Hes_Apu { + + int latch; + int balance; + struct Blip_Synth synth; + struct Hes_Osc oscs [osc_count]; +}; + +// Init HES apu sound chip +void Apu_init( struct Hes_Apu* this ); + +// Reset HES apu couns chip +void Apu_reset( struct Hes_Apu* this ); + +void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ); + +// Emulates to time t, then writes data to addr +void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ); + +// Emulates to time t, then subtracts t from the current time. +// OK if previous write call had time slightly after t. +void Apu_end_frame( struct Hes_Apu* this, blip_time_t ); + +static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } +#endif -- cgit v1.2.3