DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/mame/saa1099.cpp
00001 // license:BSD-3-Clause
00002 // copyright-holders:Juergen Buchmueller, Manuel Abadia
00003 /***************************************************************************
00004 
00005     Philips SAA1099 Sound driver
00006 
00007     By Juergen Buchmueller and Manuel Abadia
00008 
00009     SAA1099 register layout:
00010     ========================
00011 
00012     offs | 7654 3210 | description
00013     -----+-----------+---------------------------
00014     0x00 | ---- xxxx | Amplitude channel 0 (left)
00015     0x00 | xxxx ---- | Amplitude channel 0 (right)
00016     0x01 | ---- xxxx | Amplitude channel 1 (left)
00017     0x01 | xxxx ---- | Amplitude channel 1 (right)
00018     0x02 | ---- xxxx | Amplitude channel 2 (left)
00019     0x02 | xxxx ---- | Amplitude channel 2 (right)
00020     0x03 | ---- xxxx | Amplitude channel 3 (left)
00021     0x03 | xxxx ---- | Amplitude channel 3 (right)
00022     0x04 | ---- xxxx | Amplitude channel 4 (left)
00023     0x04 | xxxx ---- | Amplitude channel 4 (right)
00024     0x05 | ---- xxxx | Amplitude channel 5 (left)
00025     0x05 | xxxx ---- | Amplitude channel 5 (right)
00026          |           |
00027     0x08 | xxxx xxxx | Frequency channel 0
00028     0x09 | xxxx xxxx | Frequency channel 1
00029     0x0a | xxxx xxxx | Frequency channel 2
00030     0x0b | xxxx xxxx | Frequency channel 3
00031     0x0c | xxxx xxxx | Frequency channel 4
00032     0x0d | xxxx xxxx | Frequency channel 5
00033          |           |
00034     0x10 | ---- -xxx | Channel 0 octave select
00035     0x10 | -xxx ---- | Channel 1 octave select
00036     0x11 | ---- -xxx | Channel 2 octave select
00037     0x11 | -xxx ---- | Channel 3 octave select
00038     0x12 | ---- -xxx | Channel 4 octave select
00039     0x12 | -xxx ---- | Channel 5 octave select
00040          |           |
00041     0x14 | ---- ---x | Channel 0 frequency enable (0 = off, 1 = on)
00042     0x14 | ---- --x- | Channel 1 frequency enable (0 = off, 1 = on)
00043     0x14 | ---- -x-- | Channel 2 frequency enable (0 = off, 1 = on)
00044     0x14 | ---- x--- | Channel 3 frequency enable (0 = off, 1 = on)
00045     0x14 | ---x ---- | Channel 4 frequency enable (0 = off, 1 = on)
00046     0x14 | --x- ---- | Channel 5 frequency enable (0 = off, 1 = on)
00047          |           |
00048     0x15 | ---- ---x | Channel 0 noise enable (0 = off, 1 = on)
00049     0x15 | ---- --x- | Channel 1 noise enable (0 = off, 1 = on)
00050     0x15 | ---- -x-- | Channel 2 noise enable (0 = off, 1 = on)
00051     0x15 | ---- x--- | Channel 3 noise enable (0 = off, 1 = on)
00052     0x15 | ---x ---- | Channel 4 noise enable (0 = off, 1 = on)
00053     0x15 | --x- ---- | Channel 5 noise enable (0 = off, 1 = on)
00054          |           |
00055     0x16 | ---- --xx | Noise generator parameters 0
00056     0x16 | --xx ---- | Noise generator parameters 1
00057          |           |
00058     0x18 | --xx xxxx | Envelope generator 0 parameters
00059     0x18 | x--- ---- | Envelope generator 0 control enable (0 = off, 1 = on)
00060     0x19 | --xx xxxx | Envelope generator 1 parameters
00061     0x19 | x--- ---- | Envelope generator 1 control enable (0 = off, 1 = on)
00062          |           |
00063     0x1c | ---- ---x | All channels enable (0 = off, 1 = on)
00064     0x1c | ---- --x- | Synch & Reset generators
00065 
00066     Unspecified bits should be written as zero.
00067 
00068 ***************************************************************************/
00069 
00070 #include "emu.h"
00071 #include "saa1099.h"
00072 
00073 #define LEFT    0x00
00074 #define RIGHT   0x01
00075 
00076 static const int amplitude_lookup[16] = {
00077                 0*32767/16,  1*32767/16,  2*32767/16,   3*32767/16,
00078                 4*32767/16,  5*32767/16,  6*32767/16,   7*32767/16,
00079                 8*32767/16,  9*32767/16, 10*32767/16, 11*32767/16,
00080         12*32767/16, 13*32767/16, 14*32767/16, 15*32767/16
00081 };
00082 
00083 static const uint8_t envelope[8][64] = {
00084         /* zero amplitude */
00085         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00086                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00087                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00088                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
00089         /* maximum amplitude */
00090         {15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
00091                 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
00092                 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
00093                 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, },
00094         /* single decay */
00095         {15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
00096                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00097                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00098                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
00099         /* repetitive decay */
00100         {15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
00101                 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
00102                 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
00103                 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
00104         /* single triangular */
00105         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
00106                 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
00107                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00108                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
00109         /* repetitive triangular */
00110         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
00111                 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
00112                 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
00113                 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
00114         /* single attack */
00115         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
00116                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00117                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00118                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
00119         /* repetitive attack */
00120         { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
00121                 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
00122                 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
00123                 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 }
00124 };
00125 
00126 
00127 // device type definition
00128 //DEFINE_DEVICE_TYPE(SAA1099, saa1099_device, "saa1099", "Philips SAA1099")
00129 #define SAA1099 1
00130 
00131 //**************************************************************************
00132 //  LIVE DEVICE
00133 //**************************************************************************
00134 
00135 //-------------------------------------------------
00136 //  saa1099_device - constructor
00137 //-------------------------------------------------
00138 
00139 #define FILL_ARRAY( _FILL_ ) memset( _FILL_, 0, sizeof( _FILL_ ) )
00140 
00141 saa1099_device::saa1099_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
00142         : device_t(mconfig, SAA1099, tag, owner, clock)
00143         , device_sound_interface(mconfig, *this)
00144         , m_stream(0)
00145 #if 0
00146         , m_noise_params{ 0, 0 }
00147         , m_env_enable{ 0, 0 }
00148         , m_env_reverse_right{ 0, 0 }
00149         , m_env_mode{ 0, 0 }
00150         , m_env_bits{ 0, 0 }
00151         , m_env_clock{ 0, 0 }
00152         , m_env_step{ 0, 0 }
00153 #endif
00154         , m_all_ch_enable(0)
00155         , m_sync_state(0)
00156         , m_selected_reg(0)
00157         , m_sample_rate(0.0)
00158 {
00159         FILL_ARRAY( m_noise_params );
00160         FILL_ARRAY( m_env_enable );
00161         FILL_ARRAY( m_env_reverse_right );
00162         FILL_ARRAY( m_env_mode );
00163         FILL_ARRAY( m_env_bits );
00164         FILL_ARRAY( m_env_clock );
00165         FILL_ARRAY( m_env_step );
00166         
00167 }
00168 
00169 
00170 //-------------------------------------------------
00171 //  device_start - device-specific startup
00172 //-------------------------------------------------
00173 
00174 void saa1099_device::device_start()
00175 {
00176         /* copy global parameters */
00177         m_master_clock = clock();
00178         m_sample_rate = clock() / 256;
00179 
00180         /* for each chip allocate one stream */
00181         m_stream = stream_alloc(0, 2, (int)m_sample_rate);
00182 
00183         save_item(NAME(m_noise_params));
00184         save_item(NAME(m_env_enable));
00185         save_item(NAME(m_env_reverse_right));
00186         save_item(NAME(m_env_mode));
00187         save_item(NAME(m_env_bits));
00188         save_item(NAME(m_env_clock));
00189         save_item(NAME(m_env_step));
00190         save_item(NAME(m_all_ch_enable));
00191         save_item(NAME(m_sync_state));
00192         save_item(NAME(m_selected_reg));
00193 
00194         for (int i = 0; i < 6; i++)
00195         {
00196                 save_item(NAME(m_channels[i].frequency), i);
00197                 save_item(NAME(m_channels[i].freq_enable), i);
00198                 save_item(NAME(m_channels[i].noise_enable), i);
00199                 save_item(NAME(m_channels[i].octave), i);
00200                 save_item(NAME(m_channels[i].amplitude), i);
00201                 save_item(NAME(m_channels[i].envelope), i);
00202                 save_item(NAME(m_channels[i].counter), i);
00203                 save_item(NAME(m_channels[i].freq), i);
00204                 save_item(NAME(m_channels[i].level), i);
00205         }
00206 
00207         for (int i = 0; i < 2; i++)
00208         {
00209                 save_item(NAME(m_noise[i].counter), i);
00210                 save_item(NAME(m_noise[i].freq), i);
00211                 save_item(NAME(m_noise[i].level), i);
00212         }
00213 }
00214 
00215 
00216 //-------------------------------------------------
00217 //  sound_stream_update - handle a stream update
00218 //-------------------------------------------------
00219 
00220 void saa1099_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
00221 {
00222     (void)stream;
00223     (void)inputs;
00224         int j, ch;
00225         /* if the channels are disabled we're done */
00226         if (!m_all_ch_enable)
00227         {
00228                 /* init output data */
00229                 memset(outputs[LEFT],0,samples*sizeof(*outputs[LEFT]));
00230                 memset(outputs[RIGHT],0,samples*sizeof(*outputs[RIGHT]));
00231                 return;
00232         }
00233 
00234         for (ch = 0; ch < 2; ch++)
00235         {
00236                 switch (m_noise_params[ch])
00237                 {
00238                 case 0: m_noise[ch].freq = m_master_clock/256.0 * 2; break;
00239                 case 1: m_noise[ch].freq = m_master_clock/512.0 * 2; break;
00240                 case 2: m_noise[ch].freq = m_master_clock/1024.0 * 2; break;
00241                 case 3: m_noise[ch].freq = m_channels[ch * 3].freq;   break; // todo: this case will be m_master_clock/[ch*3's octave divisor, 0 is = 256*2, higher numbers are higher] * 2 if the tone generator phase reset bit (0x1c bit 1) is set.
00242                 }
00243         }
00244 
00245         /* fill all data needed */
00246         for( j = 0; j < samples; j++ )
00247         {
00248                 int output_l = 0, output_r = 0;
00249 
00250                 /* for each channel */
00251                 for (ch = 0; ch < 6; ch++)
00252                 {
00253                         if (m_channels[ch].freq == 0.0)
00254                                 m_channels[ch].freq = (double)((2 * m_master_clock / 512) << m_channels[ch].octave) /
00255                                         (511.0 - (double)m_channels[ch].frequency);
00256 
00257                         /* check the actual position in the square wave */
00258                         m_channels[ch].counter -= m_channels[ch].freq;
00259                         while (m_channels[ch].counter < 0)
00260                         {
00261                                 /* calculate new frequency now after the half wave is updated */
00262                                 m_channels[ch].freq = (double)((2 * m_master_clock / 512) << m_channels[ch].octave) /
00263                                         (511.0 - (double)m_channels[ch].frequency);
00264 
00265                                 m_channels[ch].counter += m_sample_rate;
00266                                 m_channels[ch].level ^= 1;
00267 
00268                                 /* eventually clock the envelope counters */
00269                                 if (ch == 1 && m_env_clock[0] == 0)
00270                                         envelope_w(0);
00271                                 if (ch == 4 && m_env_clock[1] == 0)
00272                                         envelope_w(1);
00273                         }
00274 
00275                         // if the noise is enabled
00276                         if (m_channels[ch].noise_enable)
00277                         {
00278                                 // if the noise level is high (noise 0: chan 0-2, noise 1: chan 3-5)
00279                                 if (m_noise[ch/3].level & 1)
00280                                 {
00281                                         // subtract to avoid overflows, also use only half amplitude
00282                                         output_l -= m_channels[ch].amplitude[ LEFT] * m_channels[ch].envelope[ LEFT] / 16 / 2;
00283                                         output_r -= m_channels[ch].amplitude[RIGHT] * m_channels[ch].envelope[RIGHT] / 16 / 2;
00284                                 }
00285                         }
00286                         // if the square wave is enabled
00287                         if (m_channels[ch].freq_enable)
00288                         {
00289                                 // if the channel level is high
00290                                 if (m_channels[ch].level & 1)
00291                                 {
00292                                         output_l += m_channels[ch].amplitude[ LEFT] * m_channels[ch].envelope[ LEFT] / 16;
00293                                         output_r += m_channels[ch].amplitude[RIGHT] * m_channels[ch].envelope[RIGHT] / 16;
00294                                 }
00295                         }
00296                 }
00297 
00298                 for (ch = 0; ch < 2; ch++)
00299                 {
00300                         /* update the state of the noise generator
00301                          * polynomial is x^18 + x^11 + x (i.e. 0x20400) and is a plain XOR, initial state is probably all 1s
00302                          * see http://www.vogons.org/viewtopic.php?f=9&t=51695 */
00303                         m_noise[ch].counter -= m_noise[ch].freq;
00304                         while (m_noise[ch].counter < 0)
00305                         {
00306                                 m_noise[ch].counter += m_sample_rate;
00307                                 if( ((m_noise[ch].level & 0x20000) == 0) != ((m_noise[ch].level & 0x0400) == 0) )
00308                                         m_noise[ch].level = (m_noise[ch].level << 1) | 1;
00309                                 else
00310                                         m_noise[ch].level <<= 1;
00311                         }
00312                 }
00313                 /* write sound data to the buffer */
00314                 outputs[LEFT][j] = output_l / 6;
00315                 outputs[RIGHT][j] = output_r / 6;
00316         }
00317 }
00318 
00319 
00320 void saa1099_device::envelope_w(int ch)
00321 {
00322         if (m_env_enable[ch])
00323         {
00324                 int step, mode, mask;
00325                 mode = m_env_mode[ch];
00326                 /* step from 0..63 and then loop in steps 32..63 */
00327                 step = m_env_step[ch] =
00328                         ((m_env_step[ch] + 1) & 0x3f) | (m_env_step[ch] & 0x20);
00329 
00330                 mask = 15;
00331                 if (m_env_bits[ch])
00332                         mask &= ~1;     /* 3 bit resolution, mask LSB */
00333 
00334                 m_channels[ch*3+0].envelope[ LEFT] =
00335                 m_channels[ch*3+1].envelope[ LEFT] =
00336                 m_channels[ch*3+2].envelope[ LEFT] = envelope[mode][step] & mask;
00337                 if (m_env_reverse_right[ch] & 0x01)
00338                 {
00339                         m_channels[ch*3+0].envelope[RIGHT] =
00340                         m_channels[ch*3+1].envelope[RIGHT] =
00341                         m_channels[ch*3+2].envelope[RIGHT] = (15 - envelope[mode][step]) & mask;
00342                 }
00343                 else
00344                 {
00345                         m_channels[ch*3+0].envelope[RIGHT] =
00346                         m_channels[ch*3+1].envelope[RIGHT] =
00347                         m_channels[ch*3+2].envelope[RIGHT] = envelope[mode][step] & mask;
00348                 }
00349         }
00350         else
00351         {
00352                 /* envelope mode off, set all envelope factors to 16 */
00353                 m_channels[ch*3+0].envelope[ LEFT] =
00354                 m_channels[ch*3+1].envelope[ LEFT] =
00355                 m_channels[ch*3+2].envelope[ LEFT] =
00356                 m_channels[ch*3+0].envelope[RIGHT] =
00357                 m_channels[ch*3+1].envelope[RIGHT] =
00358                 m_channels[ch*3+2].envelope[RIGHT] = 16;
00359         }
00360 }
00361 
00362 
00363 WRITE8_MEMBER( saa1099_device::control_w )
00364 {
00365     (void)offset;
00366     (void)space;
00367         if ((data & 0xff) > 0x1c)
00368         {
00369                 /* Error! */
00370                 logerror("%s: (SAA1099 '%s') Unknown register selected\n", machine().describe_context(), tag());
00371         }
00372 
00373         m_selected_reg = data & 0x1f;
00374         if (m_selected_reg == 0x18 || m_selected_reg == 0x19)
00375         {
00376                 /* clock the envelope channels */
00377                 if (m_env_clock[0])
00378                         envelope_w(0);
00379                 if (m_env_clock[1])
00380                         envelope_w(1);
00381         }
00382 }
00383 
00384 
00385 WRITE8_MEMBER( saa1099_device::data_w )
00386 {
00387     (void)offset;
00388     (void)space;
00389         int reg = m_selected_reg;
00390         int ch;
00391 
00392         /* first update the stream to this point in time */
00393         m_stream->update();
00394 
00395         switch (reg)
00396         {
00397         /* channel i amplitude */
00398         case 0x00:  case 0x01:  case 0x02:  case 0x03:  case 0x04:  case 0x05:
00399                 ch = reg & 7;
00400                 m_channels[ch].amplitude[LEFT] = amplitude_lookup[data & 0x0f];
00401                 m_channels[ch].amplitude[RIGHT] = amplitude_lookup[(data >> 4) & 0x0f];
00402                 break;
00403         /* channel i frequency */
00404         case 0x08:  case 0x09:  case 0x0a:  case 0x0b:  case 0x0c:  case 0x0d:
00405                 ch = reg & 7;
00406                 m_channels[ch].frequency = data & 0xff;
00407                 break;
00408         /* channel i octave */
00409         case 0x10:  case 0x11:  case 0x12:
00410                 ch = (reg - 0x10) << 1;
00411                 m_channels[ch + 0].octave = data & 0x07;
00412                 m_channels[ch + 1].octave = (data >> 4) & 0x07;
00413                 break;
00414         /* channel i frequency enable */
00415         case 0x14:
00416                 m_channels[0].freq_enable = data & 0x01;
00417                 m_channels[1].freq_enable = data & 0x02;
00418                 m_channels[2].freq_enable = data & 0x04;
00419                 m_channels[3].freq_enable = data & 0x08;
00420                 m_channels[4].freq_enable = data & 0x10;
00421                 m_channels[5].freq_enable = data & 0x20;
00422                 break;
00423         /* channel i noise enable */
00424         case 0x15:
00425                 m_channels[0].noise_enable = data & 0x01;
00426                 m_channels[1].noise_enable = data & 0x02;
00427                 m_channels[2].noise_enable = data & 0x04;
00428                 m_channels[3].noise_enable = data & 0x08;
00429                 m_channels[4].noise_enable = data & 0x10;
00430                 m_channels[5].noise_enable = data & 0x20;
00431                 break;
00432         /* noise generators parameters */
00433         case 0x16:
00434                 m_noise_params[0] = data & 0x03;
00435                 m_noise_params[1] = (data >> 4) & 0x03;
00436                 break;
00437         /* envelope generators parameters */
00438         case 0x18:  case 0x19:
00439                 ch = reg - 0x18;
00440                 m_env_reverse_right[ch] = data & 0x01;
00441                 m_env_mode[ch] = (data >> 1) & 0x07;
00442                 m_env_bits[ch] = data & 0x10;
00443                 m_env_clock[ch] = data & 0x20;
00444                 m_env_enable[ch] = data & 0x80;
00445                 /* reset the envelope */
00446                 m_env_step[ch] = 0;
00447                 break;
00448         /* channels enable & reset generators */
00449         case 0x1c:
00450                 m_all_ch_enable = data & 0x01;
00451                 m_sync_state = data & 0x02;
00452                 if (data & 0x02)
00453                 {
00454                         int i;
00455 
00456                         /* Synch & Reset generators */
00457                         logerror("%s: (SAA1099 '%s') -reg 0x1c- Chip reset\n", machine().describe_context(), tag());
00458                         for (i = 0; i < 6; i++)
00459                         {
00460                                 m_channels[i].level = 0;
00461                                 m_channels[i].counter = 0.0;
00462                         }
00463                 }
00464                 break;
00465         default:    /* Error! */
00466                 if (data != 0)
00467                         logerror("%s: (SAA1099 '%s') Unknown operation (reg:%02x, data:%02x)\n", machine().describe_context(), tag(), reg, data);
00468         }
00469 }
00470 
00471 WRITE8_MEMBER(saa1099_device::write)
00472 {
00473         if (offset & 1)
00474                 control_w(space, 0, data);
00475         else
00476                 data_w(space, 0, data);
00477 }
00478 
00479 void saa1099_device::SaveState( std::ostream& stream )
00480 {
00481         // - pure data
00482         device_t::SaveState(stream);
00483  
00484         WRITE_POD( &m_noise_params, m_noise_params );
00485         WRITE_POD( &m_env_enable, m_env_enable );
00486         WRITE_POD( &m_env_reverse_right, m_env_reverse_right );
00487         WRITE_POD( &m_env_mode, m_env_mode );
00488         WRITE_POD( &m_env_bits, m_env_bits );
00489         WRITE_POD( &m_env_clock, m_env_clock );
00490         WRITE_POD( &m_env_step, m_env_step );
00491         WRITE_POD( &m_all_ch_enable, m_all_ch_enable );
00492         WRITE_POD( &m_sync_state, m_sync_state );
00493         WRITE_POD( &m_selected_reg, m_selected_reg );
00494         WRITE_POD( &m_channels, m_channels );
00495         WRITE_POD( &m_noise, m_noise );
00496         WRITE_POD( &m_sample_rate, m_sample_rate );
00497         WRITE_POD( &m_master_clock, m_master_clock );
00498 }
00499 
00500 
00501 void saa1099_device::LoadState( std::istream& stream )
00502 {
00503         // - pure data
00504         device_t::LoadState(stream);
00505 
00506         READ_POD( &m_noise_params, m_noise_params );
00507         READ_POD( &m_env_enable, m_env_enable );
00508         READ_POD( &m_env_reverse_right, m_env_reverse_right );
00509         READ_POD( &m_env_mode, m_env_mode );
00510         READ_POD( &m_env_bits, m_env_bits );
00511         READ_POD( &m_env_clock, m_env_clock );
00512         READ_POD( &m_env_step, m_env_step );
00513         READ_POD( &m_all_ch_enable, m_all_ch_enable );
00514         READ_POD( &m_sync_state, m_sync_state );
00515         READ_POD( &m_selected_reg, m_selected_reg );
00516         READ_POD( &m_channels, m_channels );
00517         READ_POD( &m_noise, m_noise );
00518         READ_POD( &m_sample_rate, m_sample_rate );
00519         READ_POD( &m_master_clock, m_master_clock );
00520 }