1 // Sega Master System SN76489 PSG sound chip emulator
7 #include "blargg_common.h"
8 #include "blip_buffer.h"
10 // 0: Square 1, 1: Square 2, 2: Square 3, 3: Noise
11 enum { sms_osc_count
= 4 }; // 0 <= chan < osc_count
15 struct Blip_Buffer
* outputs
[4]; // NULL, right, left, center
16 struct Blip_Buffer
* output
;
26 struct Osc oscs
[sms_osc_count
];
30 blip_time_t last_time
;
32 unsigned noise_feedback
;
33 unsigned looped_feedback
;
34 struct Blip_Synth synth
;
39 void Sms_apu_init( struct Sms_Apu
* this );
41 // Sets buffer(s) to generate sound into, or 0 to mute. If only center is not 0,
43 void Sms_apu_set_output( struct Sms_Apu
* this, int i
, struct Blip_Buffer
* center
, struct Blip_Buffer
* left
, struct Blip_Buffer
* right
);
45 // Emulates to time t, then writes data to Game Gear left/right assignment byte
46 void Sms_apu_write_ggstereo( struct Sms_Apu
* this, blip_time_t t
, int data
) ICODE_ATTR
;
48 // Emulates to time t, then writes data
49 void Sms_apu_write_data( struct Sms_Apu
* this, blip_time_t t
, int data
) ICODE_ATTR
;
51 // Emulates to time t, then subtracts t from the current time.
52 // OK if previous write call had time slightly after t.
53 void Sms_apu_end_frame( struct Sms_Apu
* this, blip_time_t t
) ICODE_ATTR
;
57 // Resets sound chip and sets noise feedback bits and width
58 void Sms_apu_reset( struct Sms_Apu
* this, unsigned noise_feedback
, int noise_width
);
60 // Sets overall volume, where 1.0 is normal
61 void Sms_apu_volume( struct Sms_Apu
* this, double vol
);