Submit initial patch from FS#12176. Adds support for several new game music formats...
[kugel-rb.git] / apps / codecs / libgme / hes_apu.h
blob8a49a5afc760f963c4f2a6566ebb664295c9ea13
1 // Turbo Grafx 16 (PC Engine) PSG sound chip emulator
3 // Game_Music_Emu 0.5.2
4 #ifndef HES_APU_H
5 #define HES_APU_H
7 #include "blargg_common.h"
8 #include "blip_buffer.h"
10 enum { amp_range = 0x8000 };
11 enum { osc_count = 6 };
12 enum { start_addr = 0x0800 };
13 enum { end_addr = 0x0809 };
15 struct Hes_Osc
17 unsigned char wave [32];
18 short volume [2];
19 int last_amp [2];
20 int delay;
21 int period;
22 unsigned char noise;
23 unsigned char phase;
24 unsigned char balance;
25 unsigned char dac;
26 blip_time_t last_time;
28 struct Blip_Buffer* outputs [2];
29 struct Blip_Buffer* chans [3];
30 unsigned noise_lfsr;
31 unsigned char control;
34 void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ) ICODE_ATTR;
36 struct Hes_Apu {
37 struct Hes_Osc oscs [osc_count];
39 int latch;
40 int balance;
41 struct Blip_Synth synth;
44 // Init HES apu sound chip
45 void Apu_init( struct Hes_Apu* this );
47 // Reset HES apu couns chip
48 void Apu_reset( struct Hes_Apu* this );
50 void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) ICODE_ATTR;
51 void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ) ICODE_ATTR;
52 void Apu_end_frame( struct Hes_Apu* this, blip_time_t ) ICODE_ATTR;
54 static inline void Apu_volume( struct Hes_Apu* this, double v ) { Synth_volume( &this->synth, 1.8 / osc_count / amp_range * v ); }
55 #endif