summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/hes_apu.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/hes_apu.h')
-rw-r--r--apps/codecs/libgme/hes_apu.h43
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
10enum { amp_range = 0x8000 }; 11enum { amp_range = 0x8000 };
11enum { osc_count = 6 }; 12enum { osc_count = 6 }; // 0 <= chan < osc_count
12enum { start_addr = 0x0800 }; 13
13enum { end_addr = 0x0809 }; 14// Registers are at io_addr to io_addr+io_size-1
15enum { apu_io_addr = 0x0800 };
16enum { apu_io_size = 10 };
14 17
15struct Hes_Osc 18struct 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
34void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ); 40void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t );
35 41
36struct Hes_Apu { 42struct 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 );
48void Apu_reset( struct Hes_Apu* this ); 54void Apu_reset( struct Hes_Apu* this );
49 55
50void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ); 56void 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
51void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ); 59void 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.
52void Apu_end_frame( struct Hes_Apu* this, blip_time_t ); 63void Apu_end_frame( struct Hes_Apu* this, blip_time_t );
53 64
54static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } 65static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); }