| 1 |
// T6W28_Snd_Emu |
| 2 |
|
| 3 |
#ifndef SMS_APU_H |
| 4 |
#define SMS_APU_H |
| 5 |
|
| 6 |
namespace MDFN_IEN_NGP |
| 7 |
{ |
| 8 |
|
| 9 |
typedef long sms_time_t; // clock cycle count |
| 10 |
|
| 11 |
} |
| 12 |
|
| 13 |
#include "blip_buf.h" |
| 14 |
#include "../../../dispatch.h" |
| 15 |
|
| 16 |
#include "T6W28_Oscs.h" |
| 17 |
|
| 18 |
namespace MDFN_IEN_NGP |
| 19 |
{ |
| 20 |
|
| 21 |
typedef struct |
| 22 |
{ |
| 23 |
int sq_period[3]; |
| 24 |
int sq_phase[3]; |
| 25 |
unsigned int noise_period; |
| 26 |
unsigned int noise_period_extra; |
| 27 |
unsigned int noise_shifter; |
| 28 |
unsigned int noise_tap; |
| 29 |
|
| 30 |
int delay[4]; |
| 31 |
int volume_left[4]; |
| 32 |
int volume_right[4]; |
| 33 |
unsigned char latch_left, latch_right; |
| 34 |
} T6W28_ApuState; |
| 35 |
|
| 36 |
class T6W28_Apu { |
| 37 |
public: |
| 38 |
|
| 39 |
// Outputs can be assigned to a single buffer for mono output, or to three |
| 40 |
// buffers for stereo output (using Stereo_Buffer to do the mixing). |
| 41 |
|
| 42 |
// Assign all oscillator outputs to specified buffer(s). If buffer |
| 43 |
// is NULL, silences all oscillators. |
| 44 |
void output( blip_buffer_t* left, blip_buffer_t* right ); |
| 45 |
|
| 46 |
// Assign single oscillator output to buffer(s). Valid indicies are 0 to 3, |
| 47 |
// which refer to Square 1, Square 2, Square 3, and Noise. If buffer is NULL, |
| 48 |
// silences oscillator. |
| 49 |
enum { osc_count = 4 }; |
| 50 |
void osc_output( int index, DivDispatchOscBuffer* oscBuf ); |
| 51 |
|
| 52 |
// Reset oscillators and internal state |
| 53 |
void reset(); |
| 54 |
|
| 55 |
// Write to data port |
| 56 |
void write_data_left( sms_time_t, int ); |
| 57 |
void write_data_right( sms_time_t, int ); |
| 58 |
|
| 59 |
// Run all oscillators up to specified time, end current frame, then |
| 60 |
// start a new frame at time 0. Returns true if any oscillators added |
| 61 |
// sound to one of the left/right buffers, false if they only added |
| 62 |
// to the center buffer. |
| 63 |
bool end_frame( sms_time_t ); |
| 64 |
|
| 65 |
public: |
| 66 |
T6W28_Apu(); |
| 67 |
~T6W28_Apu(); |
| 68 |
private: |
| 69 |
// noncopyable |
| 70 |
T6W28_Apu( const T6W28_Apu& ); |
| 71 |
T6W28_Apu& operator = ( const T6W28_Apu& ); |
| 72 |
|
| 73 |
T6W28_Osc* oscs [osc_count]; |
| 74 |
T6W28_Square squares [3]; |
| 75 |
//T6W28_Square::Synth square_synth; // used by squares |
| 76 |
sms_time_t last_time; |
| 77 |
int latch_left, latch_right; |
| 78 |
T6W28_Noise noise; |
| 79 |
|
| 80 |
void run_until( sms_time_t ); |
| 81 |
}; |
| 82 |
} |
| 83 |
|
| 84 |
#endif |
| 85 |
|