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/hes_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/hes_apu.h')
-rw-r--r-- | lib/rbcodec/codecs/libgme/hes_apu.h | 66 |
1 files changed, 66 insertions, 0 deletions
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 @@ | |||
1 | // Turbo Grafx 16 (PC Engine) PSG sound chip emulator | ||
2 | |||
3 | // Game_Music_Emu 0.5.2 | ||
4 | #ifndef HES_APU_H | ||
5 | #define HES_APU_H | ||
6 | |||
7 | #include "blargg_common.h" | ||
8 | #include "blargg_source.h" | ||
9 | #include "blip_buffer.h" | ||
10 | |||
11 | enum { amp_range = 0x8000 }; | ||
12 | enum { osc_count = 6 }; // 0 <= chan < osc_count | ||
13 | |||
14 | // Registers are at io_addr to io_addr+io_size-1 | ||
15 | enum { apu_io_addr = 0x0800 }; | ||
16 | enum { apu_io_size = 10 }; | ||
17 | |||
18 | struct Hes_Osc | ||
19 | { | ||
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; | ||
32 | short volume [2]; | ||
33 | int last_amp [2]; | ||
34 | |||
35 | blip_time_t last_time; | ||
36 | struct Blip_Buffer* output [2]; | ||
37 | struct Blip_Buffer* outputs [3]; | ||
38 | }; | ||
39 | |||
40 | void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ); | ||
41 | |||
42 | struct Hes_Apu { | ||
43 | |||
44 | int latch; | ||
45 | int balance; | ||
46 | struct Blip_Synth synth; | ||
47 | struct Hes_Osc oscs [osc_count]; | ||
48 | }; | ||
49 | |||
50 | // Init HES apu sound chip | ||
51 | void Apu_init( struct Hes_Apu* this ); | ||
52 | |||
53 | // Reset HES apu couns chip | ||
54 | void Apu_reset( struct Hes_Apu* this ); | ||
55 | |||
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 | ||
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. | ||
63 | void Apu_end_frame( struct Hes_Apu* this, blip_time_t ); | ||
64 | |||
65 | static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } | ||
66 | #endif | ||