summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/sms_apu.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libgme/sms_apu.h')
-rw-r--r--lib/rbcodec/codecs/libgme/sms_apu.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/sms_apu.h b/lib/rbcodec/codecs/libgme/sms_apu.h
new file mode 100644
index 0000000000..6dd65591ce
--- /dev/null
+++ b/lib/rbcodec/codecs/libgme/sms_apu.h
@@ -0,0 +1,63 @@
1// Sega Master System SN76489 PSG sound chip emulator
2
3// Sms_Snd_Emu 0.1.2
4#ifndef SMS_APU_H
5#define SMS_APU_H
6
7#include "blargg_common.h"
8#include "blip_buffer.h"
9
10// 0: Square 1, 1: Square 2, 2: Square 3, 3: Noise
11enum { sms_osc_count = 4 }; // 0 <= chan < osc_count
12
13struct Osc
14{
15 struct Blip_Buffer* outputs [4]; // NULL, right, left, center
16 struct Blip_Buffer* output;
17 int last_amp;
18
19 int volume;
20 int period;
21 int delay;
22 unsigned phase;
23};
24
25struct Sms_Apu {
26 struct Osc oscs [sms_osc_count];
27 int ggstereo;
28 int latch;
29
30 blip_time_t last_time;
31 int min_tone_period;
32 unsigned noise_feedback;
33 unsigned looped_feedback;
34 struct Blip_Synth synth;
35};
36
37// Basics
38
39void Sms_apu_init( struct Sms_Apu* this );
40
41// Sets buffer(s) to generate sound into, or 0 to mute. If only center is not 0,
42// output is mono.
43void Sms_apu_set_output( struct Sms_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right);
44
45// Emulates to time t, then writes data to Game Gear left/right assignment byte
46void Sms_apu_write_ggstereo( struct Sms_Apu* this, blip_time_t t, int data );
47
48// Emulates to time t, then writes data
49void Sms_apu_write_data( struct Sms_Apu* this, blip_time_t t, int data );
50
51// Emulates to time t, then subtracts t from the current time.
52// OK if previous write call had time slightly after t.
53void Sms_apu_end_frame( struct Sms_Apu* this, blip_time_t t );
54
55// More features
56
57// Resets sound chip and sets noise feedback bits and width
58void Sms_apu_reset( struct Sms_Apu* this, unsigned noise_feedback, int noise_width );
59
60// Sets overall volume, where 1.0 is normal
61void Sms_apu_volume( struct Sms_Apu* this, int vol );
62
63#endif