Previous 15994 Revisions Next

r6295 Wednesday 4th November, 2009 at 18:00:43 UTC by Jonathan Gevaryahu
Update SN76489/A to have correct PRNG waveforms (a 0 bit was missing at the beginning, and beginning of SN76489 waveform was all 1s instead of 0s as measured on hardware). Add SN94624 (same as SN76489). [Lord Nightmare, plgDavid (David Viens)]
[src/emu/sound]sn76496.c sn76496.h

src/emu/sound/sn76496.c
r6294r6295
1212  duty cycle channel.
1313
1414  Noise emulation for all chips should be accurate:
15  SN76489 uses a 15-bit shift register with taps on bits D and E, output on /E
15  SN76489 uses a 15-bit shift register with taps on bits D and E, output on E,
16  XOR function; SN94624 is identical to SN76489.
1617  * It uses a 15-bit ring buffer for periodic noise/arbitrary duty cycle.
17  SN76489A uses a 16-bit shift register with taps on bits D and F, output on F
18  SN76489A uses a 16-bit shift register with taps on bits D and E, output on F,
19  XNOR function
1820  * It uses a 16-bit ring buffer for periodic noise/arbitrary duty cycle.
1921  SN76494 and SN76496 are PROBABLY identical in operation to the SN76489A
2022  * They have an audio input line which is mixed with the 4 channels of output.
r6294r6295
3638  28/04/2009 : Lord Nightmare
3739  Add READY line readback; cleaned up struct a bit. Cleaned up comments.
3840  Add more TODOs. Fixed some unsaved savestate related stuff.
41 
42  04/11/2009 : Lord Nightmare
43  Changed the way that the invert works (it now selects between XOR and XNOR
44  for the taps), and added R->OldNoise to simulate the extra 0 that is always
45  output before the noise LFSR contents are after an LFSR reset.
46  This fixes SN76489/A to match chips. Added SN94624.
3947
4048  TODO: * Implement a function for setting stereo regs for the game gear.
4149          Requires making the core support both mono and stereo, and have
4250          a select register which determines which channels go where.
43        * Implement the TMS9919 and SN94624, which are earlier versions,
44          possibly lacking the /8 clock divider, of the SN76489, and hence
45          would have a max clock of 500Khz and 4 clocks per sample, as
46          opposed to max of 4Mhz and 32 clocks per sample on the SN76489A
51        * Implement the TMS9919 which is an earlier version, possibly
52          lacking the /8 clock divider, of the SN76489, and hence would
53          have a max clock of 500Khz and 4 clocks per sample, as opposed to
54          max of 4Mhz and 32 clocks per sample on the SN76489A.
4755        * Implement the T6W28; has registers in a weird order, needs writes
4856          to be 'sanitized' first. Also is stereo, similar to game gear.
4957        * Implement the NCR 7496; Is probably 100% compatible with SN76496,
r6294r6295
7381   UINT32 RNG;         /* noise generator LFSR*/
7482   INT32 FeedbackMask;   /* mask for feedback */
7583   INT32 WhitenoiseTaps;   /* mask for white noise taps */
76   INT32 WhitenoiseInvert;   /* white noise invert flag */
84   INT32 FeedbackInvert;   /* feedback invert flag (xor vs xnor) */
7785   INT32 Period[4];   /* Length of 1/2 of waveform */
7886   INT32 Count[4];      /* Position within the waveform */
87   INT32 OldNoise;      /* 1 bit output of the PREVIOUS noise output, buffered by the volume amp */
7988   INT32 Output[4];   /* 1-bit output of each channel, pre-volume */
8089   INT32 CyclestoREADY;/* number of cycles until the READY line goes active */
8190};
r6294r6295
247256         {
248257              if (NOISEMODE == 1) /* White Noise Mode */
249258              {
250                 if (((R->RNG & R->WhitenoiseTaps) != R->WhitenoiseTaps) && ((R->RNG & R->WhitenoiseTaps) != 0)) /* crappy xor! */
259                 if ((((R->RNG & R->WhitenoiseTaps) != R->WhitenoiseTaps) && ((R->RNG & R->WhitenoiseTaps) != 0)) ^ R->FeedbackInvert ) /* XOR or XNOR */
251260               {
252261                    R->RNG >>= 1;
253262                    R->RNG |= R->FeedbackMask;
r6294r6295
256265               {
257266                    R->RNG >>= 1;
258267               }
259               R->Output[3] = R->WhitenoiseInvert ? !(R->RNG & 1) : R->RNG & 1;
260268            }
261269            else /* Periodic noise mode */
262270            {
r6294r6295
269277               {
270278                    R->RNG >>= 1;
271279               }
272               R->Output[3] = R->RNG & 1;
273280            }
281            R->Output[3] = R->OldNoise;
282            R->OldNoise = R->RNG & 1;
274283            R->Count[3] += R->Period[3];
275284            if (R->Output[3]) vol[3] += R->Period[3];
276285         }
r6294r6295
344353   /* Default is SN76489 non-A */
345354   R->FeedbackMask = 0x4000;     /* mask for feedback */
346355   R->WhitenoiseTaps = 0x03;   /* mask for white noise taps */
347   R->WhitenoiseInvert = 1; /* white noise invert flag */
356   R->FeedbackInvert = 0; /* feedback invert flag */
348357   R->CyclestoREADY = 1; /* assume ready is not active immediately on init. is this correct?*/
349358
350359   R->RNG = R->FeedbackMask;
351   R->Output[3] = R->RNG & 1;
360   R->OldNoise = 0;
361   R->Output[3] = R->OldNoise;
362   R->OldNoise = R->RNG & 1;
352363
353364   return 0;
354365}
355366
356367
357static void generic_start(const device_config *device, int feedbackmask, int noisetaps, int noiseinvert)
368static void generic_start(const device_config *device, int feedbackmask, int noisetaps, int feedbackinvert)
358369{
359370   sn76496_state *chip = get_safe_token(device);
360371
r6294r6295
364375
365376   chip->FeedbackMask = feedbackmask;
366377   chip->WhitenoiseTaps = noisetaps;
367   chip->WhitenoiseInvert = noiseinvert;
378   chip->FeedbackInvert = feedbackinvert;
368379
369380   state_save_register_device_item_array(device, 0, chip->VolTable);
370381   state_save_register_device_item_array(device, 0, chip->Register);
r6294r6295
373384   state_save_register_device_item(device, 0, chip->RNG);
374385   state_save_register_device_item(device, 0, chip->FeedbackMask);
375386   state_save_register_device_item(device, 0, chip->WhitenoiseTaps);
376   state_save_register_device_item(device, 0, chip->WhitenoiseInvert);
387   state_save_register_device_item(device, 0, chip->FeedbackInvert);
377388   state_save_register_device_item_array(device, 0, chip->Period);
378389   state_save_register_device_item_array(device, 0, chip->Count);
390   state_save_register_device_item(device, 0, chip->OldNoise);
379391   state_save_register_device_item_array(device, 0, chip->Output);
380392   state_save_register_device_item(device, 0, chip->CyclestoREADY);
381393}
r6294r6295
383395
384396static DEVICE_START( sn76489 )
385397{
386   generic_start(device, 0x4000, 0x03, TRUE);
398   generic_start(device, 0x4000, 0x03, FALSE);
387399}
388400
389401static DEVICE_START( sn76489a )
390402{
391   generic_start(device, 0x8000, 0x06, FALSE);
403   generic_start(device, 0x8000, 0x06, TRUE);
392404}
393405
394406static DEVICE_START( sn76494 )
395407{
396   generic_start(device, 0x8000, 0x06, FALSE);
408   generic_start(device, 0x8000, 0x06, TRUE);
397409}
398410
399411static DEVICE_START( sn76496 )
400412{
401   generic_start(device, 0x8000, 0x06, FALSE);
413   generic_start(device, 0x8000, 0x06, TRUE);
402414}
403415
416static DEVICE_START( sn94624 )
417{
418   generic_start(device, 0x4000, 0x03, FALSE);
419}
420
404421static DEVICE_START( gamegear )
405422{
406   generic_start(device, 0x8000, 0x09, FALSE);
423   generic_start(device, 0x8000, 0x09, TRUE);
407424}
408425
409426static DEVICE_START( smsiii )
410427{
411   generic_start(device, 0x8000, 0x09, FALSE);
428   generic_start(device, 0x8000, 0x09, TRUE);
412429}
413430
414431
r6294r6295
447464   }
448465}
449466
467DEVICE_GET_INFO( sn94624 )
468{
469   switch (state)
470   {
471      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME( sn94624 );      break;
472      case DEVINFO_STR_NAME:                     strcpy(info->s, "SN94624");                  break;
473      default:                               DEVICE_GET_INFO_CALL(sn76496);                  break;
474   }
475}
476
450477DEVICE_GET_INFO( sn76489a )
451478{
452479   switch (state)
src/emu/sound/sn76496.h
r6294r6295
1010DEVICE_GET_INFO( sn76489 );
1111DEVICE_GET_INFO( sn76489a );
1212DEVICE_GET_INFO( sn76494 );
13DEVICE_GET_INFO( sn94624 );
1314DEVICE_GET_INFO( gamegear );
1415DEVICE_GET_INFO( smsiii );
1516
r6294r6295
1718#define SOUND_SN76489 DEVICE_GET_INFO_NAME( sn76489 )
1819#define SOUND_SN76489A DEVICE_GET_INFO_NAME( sn76489a )
1920#define SOUND_SN76494 DEVICE_GET_INFO_NAME( sn76494 )
21#define SOUND_SN94624 DEVICE_GET_INFO_NAME( sn94624 )
2022#define SOUND_GAMEGEAR DEVICE_GET_INFO_NAME( gamegear )
2123#define SOUND_SMSIII DEVICE_GET_INFO_NAME( smsiii )
2224

Previous 15994 Revisions Next


© 1998-2018 The MESS Team