Mercurial > audlegacy
comparison Plugins/Input/console/Sms_Apu.h @ 493:c04dff121e1d trunk
[svn] hostile merge, phase 2: reimport based on new plugin code
author | nenolod |
---|---|
date | Tue, 24 Jan 2006 20:19:01 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
492:ccb68bad47b2 | 493:c04dff121e1d |
---|---|
1 | |
2 // Sega Master System SN76489 PSG sound chip emulator | |
3 | |
4 // Sms_Snd_Emu 0.1.3 | |
5 | |
6 #ifndef SMS_APU_H | |
7 #define SMS_APU_H | |
8 | |
9 typedef long sms_time_t; // clock cycle count | |
10 | |
11 #include "Sms_Oscs.h" | |
12 | |
13 class Sms_Apu { | |
14 public: | |
15 // Set overall volume of all oscillators, where 1.0 is full volume | |
16 void volume( double ); | |
17 | |
18 // Set treble equalization | |
19 void treble_eq( const blip_eq_t& ); | |
20 | |
21 // Outputs can be assigned to a single buffer for mono output, or to three | |
22 // buffers for stereo output (using Stereo_Buffer to do the mixing). | |
23 | |
24 // Assign all oscillator outputs to specified buffer(s). If buffer | |
25 // is NULL, silences all oscillators. | |
26 void output( Blip_Buffer* mono ); | |
27 void output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right ); | |
28 | |
29 // Assign single oscillator output to buffer(s). Valid indicies are 0 to 3, | |
30 // which refer to Square 1, Square 2, Square 3, and Noise. If buffer is NULL, | |
31 // silences oscillator. | |
32 enum { osc_count = 4 }; | |
33 void osc_output( int index, Blip_Buffer* mono ); | |
34 void osc_output( int index, Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right ); | |
35 | |
36 // Reset oscillators and internal state | |
37 void reset(); | |
38 | |
39 // Write GameGear left/right assignment byte | |
40 void write_ggstereo( sms_time_t, int ); | |
41 | |
42 // Write to data port | |
43 void write_data( sms_time_t, int ); | |
44 | |
45 // Run all oscillators up to specified time, end current frame, then | |
46 // start a new frame at time 0. Returns true if any oscillators added | |
47 // sound to one of the left/right buffers, false if they only added | |
48 // to the center buffer. | |
49 bool end_frame( sms_time_t ); | |
50 | |
51 public: | |
52 Sms_Apu(); | |
53 ~Sms_Apu(); | |
54 private: | |
55 // noncopyable | |
56 Sms_Apu( const Sms_Apu& ); | |
57 Sms_Apu& operator = ( const Sms_Apu& ); | |
58 | |
59 Sms_Osc* oscs [osc_count]; | |
60 Sms_Square squares [3]; | |
61 Sms_Square::Synth square_synth; // used by squares | |
62 sms_time_t last_time; | |
63 int latch; | |
64 bool stereo_found; | |
65 Sms_Noise noise; | |
66 | |
67 void run_until( sms_time_t ); | |
68 }; | |
69 | |
70 struct sms_apu_state_t | |
71 { | |
72 unsigned char regs [8] [2]; | |
73 unsigned char latch; | |
74 }; | |
75 | |
76 inline void Sms_Apu::output( Blip_Buffer* b ) { output( b, b, b ); } | |
77 | |
78 inline void Sms_Apu::osc_output( int i, Blip_Buffer* b ) { osc_output( i, b, b, b ); } | |
79 | |
80 #endif | |
81 |