summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/hes_apu.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libgme/hes_apu.h')
-rw-r--r--lib/rbcodec/codecs/libgme/hes_apu.h66
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
11enum { amp_range = 0x8000 };
12enum { osc_count = 6 }; // 0 <= chan < osc_count
13
14// Registers are at io_addr to io_addr+io_size-1
15enum { apu_io_addr = 0x0800 };
16enum { apu_io_size = 10 };
17
18struct 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
40void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t );
41
42struct 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
51void Apu_init( struct Hes_Apu* this );
52
53// Reset HES apu couns chip
54void Apu_reset( struct Hes_Apu* this );
55
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
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.
63void Apu_end_frame( struct Hes_Apu* this, blip_time_t );
64
65static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); }
66#endif