| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifndef MAME_SOUND_SAA1099_H |
| 8 |
#define MAME_SOUND_SAA1099_H |
| 9 |
|
| 10 |
#pragma once |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#define MCFG_SAA1099_ADD(_tag, _clock) \ |
| 17 |
MCFG_DEVICE_ADD(_tag, SAA1099, _clock) |
| 18 |
#define MCFG_SAA1099_REPLACE(_tag, _clock) \ |
| 19 |
MCFG_DEVICE_REPLACE(_tag, SAA1099, _clock) |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class NullInt { |
| 28 |
int value; |
| 29 |
public: |
| 30 |
operator int& () { |
| 31 |
return value; |
| 32 |
} |
| 33 |
|
| 34 |
int& operator= ( int set ) { |
| 35 |
value = set; |
| 36 |
return value; |
| 37 |
} |
| 38 |
|
| 39 |
NullInt( int set = 0 ) : value( set ) { |
| 40 |
} |
| 41 |
}; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
class saa1099_device : public device_t, |
| 46 |
public device_sound_interface |
| 47 |
{ |
| 48 |
public: |
| 49 |
saa1099_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); |
| 50 |
|
| 51 |
DECLARE_WRITE8_MEMBER( control_w ); |
| 52 |
DECLARE_WRITE8_MEMBER( data_w ); |
| 53 |
|
| 54 |
DECLARE_WRITE8_MEMBER( write ); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
virtual void device_start(); |
| 59 |
|
| 60 |
|
| 61 |
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); |
| 62 |
|
| 63 |
private: |
| 64 |
struct saa1099_channel |
| 65 |
{ |
| 66 |
saa1099_channel() { |
| 67 |
|
| 68 |
memset( this, 0, sizeof( *this ) ); |
| 69 |
} |
| 70 |
|
| 71 |
int frequency ; |
| 72 |
int freq_enable ; |
| 73 |
int noise_enable ; |
| 74 |
int octave ; |
| 75 |
int amplitude[2]; |
| 76 |
int envelope[2]; |
| 77 |
|
| 78 |
|
| 79 |
double counter ; |
| 80 |
double freq ; |
| 81 |
int level ; |
| 82 |
|
| 83 |
}; |
| 84 |
|
| 85 |
struct saa1099_noise |
| 86 |
{ |
| 87 |
saa1099_noise() { |
| 88 |
counter = 0; |
| 89 |
freq = 0; |
| 90 |
level = 0xFFFFFFFF; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
double counter; |
| 95 |
double freq; |
| 96 |
uint32_t level; |
| 97 |
}; |
| 98 |
|
| 99 |
void envelope_w(int ch); |
| 100 |
|
| 101 |
sound_stream *m_stream; |
| 102 |
int m_noise_params[2]; |
| 103 |
int m_env_enable[2]; |
| 104 |
int m_env_reverse_right[2]; |
| 105 |
int m_env_mode[2]; |
| 106 |
int m_env_bits[2]; |
| 107 |
int m_env_clock[2]; |
| 108 |
int m_env_step[2]; |
| 109 |
int m_all_ch_enable; |
| 110 |
int m_sync_state; |
| 111 |
int m_selected_reg; |
| 112 |
saa1099_channel m_channels[6]; |
| 113 |
saa1099_noise m_noise[2]; |
| 114 |
double m_sample_rate; |
| 115 |
int m_master_clock; |
| 116 |
}; |
| 117 |
|
| 118 |
DECLARE_DEVICE_TYPE(SAA1099, saa1099_device) |
| 119 |
|
| 120 |
#endif |