diff options
Diffstat (limited to 'apps/codecs/libgme/hes_apu.h')
-rw-r--r-- | apps/codecs/libgme/hes_apu.h | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/apps/codecs/libgme/hes_apu.h b/apps/codecs/libgme/hes_apu.h index 8f8a525108..0265e6a3ad 100644 --- a/apps/codecs/libgme/hes_apu.h +++ b/apps/codecs/libgme/hes_apu.h | |||
@@ -5,40 +5,46 @@ | |||
5 | #define HES_APU_H | 5 | #define HES_APU_H |
6 | 6 | ||
7 | #include "blargg_common.h" | 7 | #include "blargg_common.h" |
8 | #include "blargg_source.h" | ||
8 | #include "blip_buffer.h" | 9 | #include "blip_buffer.h" |
9 | 10 | ||
10 | enum { amp_range = 0x8000 }; | 11 | enum { amp_range = 0x8000 }; |
11 | enum { osc_count = 6 }; | 12 | enum { osc_count = 6 }; // 0 <= chan < osc_count |
12 | enum { start_addr = 0x0800 }; | 13 | |
13 | enum { end_addr = 0x0809 }; | 14 | // Registers are at io_addr to io_addr+io_size-1 |
15 | enum { apu_io_addr = 0x0800 }; | ||
16 | enum { apu_io_size = 10 }; | ||
14 | 17 | ||
15 | struct Hes_Osc | 18 | struct Hes_Osc |
16 | { | 19 | { |
17 | unsigned char wave [32]; | 20 | byte wave [32]; |
21 | int delay; | ||
22 | int period; | ||
23 | int phase; | ||
24 | |||
25 | int noise_delay; | ||
26 | byte noise; | ||
27 | unsigned lfsr; | ||
28 | |||
29 | byte control; | ||
30 | byte balance; | ||
31 | byte dac; | ||
18 | short volume [2]; | 32 | short volume [2]; |
19 | int last_amp [2]; | 33 | 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; | ||
27 | 34 | ||
28 | struct Blip_Buffer* outputs [2]; | 35 | blip_time_t last_time; |
29 | struct Blip_Buffer* chans [3]; | 36 | struct Blip_Buffer* output [2]; |
30 | unsigned noise_lfsr; | 37 | struct Blip_Buffer* outputs [3]; |
31 | unsigned char control; | ||
32 | }; | 38 | }; |
33 | 39 | ||
34 | void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ); | 40 | void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ); |
35 | 41 | ||
36 | struct Hes_Apu { | 42 | struct Hes_Apu { |
37 | struct Hes_Osc oscs [osc_count]; | ||
38 | 43 | ||
39 | int latch; | 44 | int latch; |
40 | int balance; | 45 | int balance; |
41 | struct Blip_Synth synth; | 46 | struct Blip_Synth synth; |
47 | struct Hes_Osc oscs [osc_count]; | ||
42 | }; | 48 | }; |
43 | 49 | ||
44 | // Init HES apu sound chip | 50 | // Init HES apu sound chip |
@@ -48,7 +54,12 @@ void Apu_init( struct Hes_Apu* this ); | |||
48 | void Apu_reset( struct Hes_Apu* this ); | 54 | void Apu_reset( struct Hes_Apu* this ); |
49 | 55 | ||
50 | void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ); | 56 | void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ); |
57 | |||
58 | // Emulates to time t, then writes data to addr | ||
51 | void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ); | 59 | void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ); |
60 | |||
61 | // Emulates to time t, then subtracts t from the current time. | ||
62 | // OK if previous write call had time slightly after t. | ||
52 | void Apu_end_frame( struct Hes_Apu* this, blip_time_t ); | 63 | void Apu_end_frame( struct Hes_Apu* this, blip_time_t ); |
53 | 64 | ||
54 | static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } | 65 | static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } |