Previous 199869 Revisions Next

r18234 Monday 1st October, 2012 at 20:39:34 UTC by hap
removed SN76496 legacy device
[src/emu/sound]sn76496.c sn76496.h

trunk/src/emu/sound/sn76496.c
r18233r18234
104104  frequency register, while the others have 0x400 as before. Should fix a bug
105105  or two on sega games, particularly Vigilante on Sega Master System. Verified
106106  on SMS hardware.
107 
108  27/06/2012: Michael Zapf
109  Converted to modern device, legacy devices were gradually removed afterwards.
107110
108111  TODO: * Implement the TMS9919 - any difference to sn94624?
109112        * Implement the T6W28; has registers in a weird order, needs writes
r18233r18234
117120#include "emu.h"
118121#include "sn76496.h"
119122
120
121123#define MAX_OUTPUT 0x7fff
122#define NOISEMODE (R->Register[6]&4)?1:0
123124
124125
125struct sn76496_state
126{
127   sound_stream * Channel;
128   INT32 VolTable[16];   /* volume table (for 4-bit to db conversion)*/
129   INT32 Register[8];   /* registers */
130   INT32 LastRegister;   /* last register written */
131   INT32 Volume[4];   /* db volume of voice 0-2 and noise */
132   UINT32 RNG;         /* noise generator LFSR*/
133   INT32 ClockDivider;   /* clock divider */
134   INT32 CurrentClock;
135   INT32 FeedbackMask;   /* mask for feedback */
136   INT32 WhitenoiseTap1;   /* mask for white noise tap 1 (higher one, usually bit 14) */
137   INT32 WhitenoiseTap2;   /* mask for white noise tap 2 (lower one, usually bit 13)*/
138   INT32 Negate;      /* output negate flag */
139   INT32 Stereo;      /* whether we're dealing with stereo or not */
140   INT32 StereoMask;   /* the stereo output mask */
141   INT32 Period[4];   /* Length of 1/2 of waveform */
142   INT32 Count[4];      /* Position within the waveform */
143   INT32 Output[4];   /* 1-bit output of each channel, pre-volume */
144   INT32 CyclestoREADY;/* number of cycles until the READY line goes active */
145   INT32 Freq0IsMax;   /* flag for if frequency zero acts as if it is one more than max (0x3ff+1) or if it acts like 0 */
146};
147
148
149INLINE sn76496_state *get_safe_token(device_t *device)
150{
151   assert(device != NULL);
152   assert(device->type() == SN76496 ||
153         device->type() == U8106 ||
154         device->type() == Y2404 ||
155         device->type() == SN76489 ||
156         device->type() == SN76489A ||
157         device->type() == SN76494 ||
158         device->type() == SN94624 ||
159         device->type() == NCR7496 ||
160         device->type() == GAMEGEAR ||
161         device->type() == SEGAPSG);
162   return (sn76496_state *)downcast<sn76496_device *>(device)->token();
163}
164
165READ_LINE_DEVICE_HANDLER( sn76496_ready_r )
166{
167   sn76496_state *R = get_safe_token(device);
168   R->Channel->update();
169   return (R->CyclestoREADY? 0 : 1);
170}
171
172WRITE8_DEVICE_HANDLER( sn76496_stereo_w )
173{
174   sn76496_state *R = get_safe_token(device);
175   R->Channel->update();
176   if (R->Stereo) R->StereoMask = data;
177   else fatalerror("Call to stereo write with mono chip!\n");
178}
179
180WRITE8_DEVICE_HANDLER( sn76496_w )
181{
182   sn76496_state *R = get_safe_token(device);
183   int n, r, c;
184
185
186   /* update the output buffer before changing the registers */
187   R->Channel->update();
188
189   /* set number of cycles until READY is active; this is always one
190           'sample', i.e. it equals the clock divider exactly; until the
191           clock divider is fully supported, we delay until one sample has
192           played. The fact that this below is '2' and not '1' is because
193           of a ?race condition? in the mess crvision driver, where after
194           any sample is played at all, no matter what, the cycles_to_ready
195           ends up never being not ready, unless this value is greater than
196           1. Once the full clock divider stuff is written, this should no
197           longer be an issue. */
198   R->CyclestoREADY = 2;
199
200   if (data & 0x80)
201   {
202      r = (data & 0x70) >> 4;
203      R->LastRegister = r;
204      R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f);
205   }
206   else
207    {
208      r = R->LastRegister;
209   }
210   c = r/2;
211   switch (r)
212   {
213      case 0:   /* tone 0 : frequency */
214      case 2:   /* tone 1 : frequency */
215      case 4:   /* tone 2 : frequency */
216          if ((data & 0x80) == 0) R->Register[r] = (R->Register[r] & 0x0f) | ((data & 0x3f) << 4);
217         if ((R->Register[r] != 0) || (R->Freq0IsMax == 0)) R->Period[c] = R->Register[r];
218         else R->Period[c] = 0x400;
219
220         if (r == 4)
221         {
222            /* update noise shift frequency */
223            if ((R->Register[6] & 0x03) == 0x03)
224               R->Period[3] = 2 * R->Period[2];
225         }
226         break;
227      case 1:   /* tone 0 : volume */
228      case 3:   /* tone 1 : volume */
229      case 5:   /* tone 2 : volume */
230      case 7:   /* noise  : volume */
231         R->Volume[c] = R->VolTable[data & 0x0f];
232         if ((data & 0x80) == 0) R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f);
233         break;
234      case 6:   /* noise  : frequency, mode */
235         {
236            if ((data & 0x80) == 0) logerror("sn76489: write to reg 6 with bit 7 clear; data was %03x, new write is %02x! report this to LN!\n", R->Register[6], data);
237            if ((data & 0x80) == 0) R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f);
238            n = R->Register[6];
239            /* N/512,N/1024,N/2048,Tone #3 output */
240            R->Period[3] = ((n&3) == 3) ? 2 * R->Period[2] : (1 << (5+(n&3)));
241            R->RNG = R->FeedbackMask;
242         }
243         break;
244   }
245}
246
247static STREAM_UPDATE( SN76496Update )
248{
249   int i;
250   sn76496_state *R = (sn76496_state *)param;
251   stream_sample_t *lbuffer = outputs[0];
252   stream_sample_t *rbuffer = (R->Stereo)?outputs[1]:NULL;
253   INT16 out = 0;
254   INT16 out2 = 0;
255
256   while (samples > 0)
257   {
258      // clock chip once
259      if (R->CurrentClock > 0) // not ready for new divided clock
260      {
261         R->CurrentClock--;
262      }
263      else // ready for new divided clock, make a new sample
264      {
265         R->CurrentClock = R->ClockDivider-1;
266         /* decrement Cycles to READY by one */
267         if (R->CyclestoREADY >0) R->CyclestoREADY--;
268
269         // handle channels 0,1,2
270         for (i = 0;i < 3;i++)
271         {
272            R->Count[i]--;
273            if (R->Count[i] <= 0)
274            {
275               R->Output[i] ^= 1;
276               R->Count[i] = R->Period[i];
277            }
278         }
279
280         // handle channel 3
281         R->Count[3]--;
282         if (R->Count[3] <= 0)
283         {
284         // if noisemode is 1, both taps are enabled
285         // if noisemode is 0, the lower tap, whitenoisetap2, is held at 0
286            if (((R->RNG & R->WhitenoiseTap1)?1:0) ^ ((((R->RNG & R->WhitenoiseTap2)?1:0))*(NOISEMODE)))
287            {
288               R->RNG >>= 1;
289               R->RNG |= R->FeedbackMask;
290            }
291            else
292            {
293               R->RNG >>= 1;
294            }
295            R->Output[3] = R->RNG & 1;
296
297            R->Count[3] = R->Period[3];
298         }
299      }
300
301
302      if (R->Stereo)
303      {
304         out = (((R->StereoMask&0x10)&&R->Output[0])?R->Volume[0]:0)
305            + (((R->StereoMask&0x20)&&R->Output[1])?R->Volume[1]:0)
306            + (((R->StereoMask&0x40)&&R->Output[2])?R->Volume[2]:0)
307            + (((R->StereoMask&0x80)&&R->Output[3])?R->Volume[3]:0);
308
309         out2 = (((R->StereoMask&0x1)&&R->Output[0])?R->Volume[0]:0)
310            + (((R->StereoMask&0x2)&&R->Output[1])?R->Volume[1]:0)
311            + (((R->StereoMask&0x4)&&R->Output[2])?R->Volume[2]:0)
312            + (((R->StereoMask&0x8)&&R->Output[3])?R->Volume[3]:0);
313      }
314      else
315      {
316         out = (R->Output[0]?R->Volume[0]:0)
317            +(R->Output[1]?R->Volume[1]:0)
318            +(R->Output[2]?R->Volume[2]:0)
319            +(R->Output[3]?R->Volume[3]:0);
320      }
321
322      if(R->Negate) { out = -out; out2 = -out2; }
323
324      *(lbuffer++) = out;
325      if (R->Stereo) *(rbuffer++) = out2;
326      samples--;
327   }
328}
329
330
331
332static void SN76496_set_gain(sn76496_state *R,int gain)
333{
334   int i;
335   double out;
336
337
338   gain &= 0xff;
339
340   /* increase max output basing on gain (0.2 dB per step) */
341   out = MAX_OUTPUT / 4; // four channels, each gets 1/4 of the total range
342   while (gain-- > 0)
343      out *= 1.023292992;   /* = (10 ^ (0.2/20)) */
344
345   /* build volume table (2dB per step) */
346   for (i = 0;i < 15;i++)
347   {
348      /* limit volume to avoid clipping */
349      if (out > MAX_OUTPUT / 4) R->VolTable[i] = MAX_OUTPUT / 4;
350      else R->VolTable[i] = out;
351
352      out /= 1.258925412;   /* = 10 ^ (2/20) = 2dB */
353   }
354   R->VolTable[15] = 0;
355}
356
357
358
359static int SN76496_init(device_t *device, sn76496_state *R, int stereo)
360{
361   int sample_rate = device->clock()/2;
362   int i;
363
364   R->Channel = device->machine().sound().stream_alloc(*device,0,(stereo?2:1),sample_rate,R,SN76496Update);
365
366   for (i = 0;i < 4;i++) R->Volume[i] = 0;
367
368   R->LastRegister = 0;
369   for (i = 0;i < 8;i+=2)
370   {
371      R->Register[i] = 0;
372      R->Register[i + 1] = 0x0f;   /* volume = 0 */
373   }
374
375   for (i = 0;i < 4;i++)
376   {
377      R->Output[i] = R->Period[i] = R->Count[i] = 0;
378   }
379
380   /* Default is SN76489A */
381   R->ClockDivider = 8;
382   R->FeedbackMask = 0x10000;     /* mask for feedback */
383   R->WhitenoiseTap1 = 0x04;   /* mask for white noise tap 1*/
384   R->WhitenoiseTap2 = 0x08;   /* mask for white noise tap 2*/
385   R->Negate = 0; /* channels are not negated */
386   R->Stereo = stereo; /* depends on init */
387   R->CyclestoREADY = 1; /* assume ready is not active immediately on init. is this correct?*/
388   R->StereoMask = 0xFF; /* all channels enabled */
389   R->Freq0IsMax = 1; /* frequency set to 0 results in freq = 0x400 rather than 0 */
390
391   R->RNG = R->FeedbackMask;
392   R->Output[3] = R->RNG & 1;
393
394   return 0;
395}
396
397
398static void generic_start(device_t *device, int feedbackmask, int noisetap1, int noisetap2, int negate, int stereo, int clockdivider, int freq0)
399{
400   sn76496_state *chip = get_safe_token(device);
401
402   if (SN76496_init(device,chip,stereo) != 0)
403      fatalerror("Error creating SN76496 chip\n");
404   SN76496_set_gain(chip, 0);
405
406   chip->FeedbackMask = feedbackmask;
407   chip->WhitenoiseTap1 = noisetap1;
408   chip->WhitenoiseTap2 = noisetap2;
409   chip->Negate = negate;
410   chip->Stereo = stereo;
411   chip->ClockDivider = clockdivider;
412   chip->CurrentClock = clockdivider-1;
413   chip->Freq0IsMax = freq0;
414
415   device->save_item(NAME(chip->VolTable));
416   device->save_item(NAME(chip->Register));
417   device->save_item(NAME(chip->LastRegister));
418   device->save_item(NAME(chip->Volume));
419   device->save_item(NAME(chip->RNG));
420   device->save_item(NAME(chip->ClockDivider));
421   device->save_item(NAME(chip->CurrentClock));
422   device->save_item(NAME(chip->FeedbackMask));
423   device->save_item(NAME(chip->WhitenoiseTap1));
424   device->save_item(NAME(chip->WhitenoiseTap2));
425   device->save_item(NAME(chip->Negate));
426   device->save_item(NAME(chip->Stereo));
427   device->save_item(NAME(chip->StereoMask));
428   device->save_item(NAME(chip->Period));
429   device->save_item(NAME(chip->Count));
430   device->save_item(NAME(chip->Output));
431   device->save_item(NAME(chip->CyclestoREADY));
432   device->save_item(NAME(chip->Freq0IsMax));
433}
434
435// function parameters: device, feedback destination tap, feedback source taps (1,2),
436// normal(false)/invert(true), mono(false)/stereo(true), clock divider factor
437
438static DEVICE_START( sn76489 )
439{
440   generic_start(device, 0x4000, 0x01, 0x02, TRUE, FALSE, 8, TRUE); // SN76489 not verified yet. todo: verify;
441}
442
443static DEVICE_START( u8106 )
444{
445   generic_start(device, 0x4000, 0x01, 0x02, TRUE, FALSE, 8, TRUE); // U8106 not verified yet. todo: verify; (a custom marked sn76489? only used on mr. do and maybe other universal games)
446}
447
448static DEVICE_START( sn76489a )
449{
450   generic_start(device, 0x10000, 0x04, 0x08, FALSE, FALSE, 8, TRUE); // SN76489A: whitenoise verified, phase verified, periodic verified (by plgdavid)
451}
452
453static DEVICE_START( y2404 )
454{
455   generic_start(device, 0x10000, 0x04, 0x08, FALSE, FALSE, 8, TRUE); // Y2404 not verified yet. todo: verify; (don't be fooled by the Y, it's a TI chip, not Yamaha)
456}
457
458static DEVICE_START( sn76494 )
459{
460   generic_start(device, 0x10000, 0x04, 0x08, FALSE, FALSE, 1, TRUE); // SN76494 not verified, (according to datasheet: same as sn76489a but without the /8 divider)
461}
462
463static DEVICE_START( sn76496 )
464{
465   generic_start(device, 0x10000, 0x04, 0x08, FALSE, FALSE, 8, TRUE); // SN76496: Whitenoise verified, phase verified, periodic verified (by Michael Zapf)
466}
467
468static DEVICE_START( sn94624 )
469{
470   generic_start(device, 0x4000, 0x01, 0x02, TRUE, FALSE, 1, TRUE); // SN94624 whitenoise verified, phase verified, period verified; verified by PlgDavid
471}
472
473static DEVICE_START( ncr7496 )
474{
475   generic_start(device, 0x8000, 0x02, 0x20, FALSE, FALSE, 8, TRUE); // NCR7496 not verified; info from smspower wiki
476}
477
478static DEVICE_START( gamegear )
479{
480   generic_start(device, 0x8000, 0x01, 0x08, TRUE, TRUE, 8, FALSE); // Verified by Justin Kerk
481}
482
483static DEVICE_START( segapsg )
484{
485   generic_start(device, 0x8000, 0x01, 0x08, TRUE, FALSE, 8, FALSE); // todo: verify; from smspower wiki, assumed to have same invert as gamegear
486}
487
488const device_type SN76496 = &device_creator<sn76496_device>;
489
490sn76496_device::sn76496_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
491   : device_t(mconfig, SN76496, "SN76496", tag, owner, clock),
492     device_sound_interface(mconfig, *this)
493{
494   m_token = global_alloc_clear(sn76496_state);
495}
496sn76496_device::sn76496_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
497   : device_t(mconfig, type, name, tag, owner, clock),
498     device_sound_interface(mconfig, *this)
499{
500   m_token = global_alloc_clear(sn76496_state);
501}
502
503//-------------------------------------------------
504//  device_config_complete - perform any
505//  operations now that the configuration is
506//  complete
507//-------------------------------------------------
508
509void sn76496_device::device_config_complete()
510{
511}
512
513//-------------------------------------------------
514//  device_start - device-specific startup
515//-------------------------------------------------
516
517void sn76496_device::device_start()
518{
519   DEVICE_START_NAME( sn76496 )(this);
520}
521
522//-------------------------------------------------
523//  sound_stream_update - handle a stream update
524//-------------------------------------------------
525
526void sn76496_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
527{
528   // should never get here
529   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
530}
531
532
533const device_type U8106 = &device_creator<u8106_device>;
534
535u8106_device::u8106_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
536   : sn76496_device(mconfig, U8106, "U8106", tag, owner, clock)
537{
538}
539
540//-------------------------------------------------
541//  device_start - device-specific startup
542//-------------------------------------------------
543
544void u8106_device::device_start()
545{
546   DEVICE_START_NAME( u8106 )(this);
547}
548
549//-------------------------------------------------
550//  sound_stream_update - handle a stream update
551//-------------------------------------------------
552
553void u8106_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
554{
555   // should never get here
556   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
557}
558
559
560const device_type Y2404 = &device_creator<y2404_device>;
561
562y2404_device::y2404_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
563   : sn76496_device(mconfig, Y2404, "Y2404", tag, owner, clock)
564{
565}
566
567//-------------------------------------------------
568//  device_start - device-specific startup
569//-------------------------------------------------
570
571void y2404_device::device_start()
572{
573   DEVICE_START_NAME( y2404 )(this);
574}
575
576//-------------------------------------------------
577//  sound_stream_update - handle a stream update
578//-------------------------------------------------
579
580void y2404_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
581{
582   // should never get here
583   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
584}
585
586
587const device_type SN76489 = &device_creator<sn76489_device>;
588
589sn76489_device::sn76489_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
590   : sn76496_device(mconfig, SN76489, "SN76489", tag, owner, clock)
591{
592}
593
594//-------------------------------------------------
595//  device_start - device-specific startup
596//-------------------------------------------------
597
598void sn76489_device::device_start()
599{
600   DEVICE_START_NAME( sn76489 )(this);
601}
602
603//-------------------------------------------------
604//  sound_stream_update - handle a stream update
605//-------------------------------------------------
606
607void sn76489_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
608{
609   // should never get here
610   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
611}
612
613
614const device_type SN76489A = &device_creator<sn76489a_device>;
615
616sn76489a_device::sn76489a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
617   : sn76496_device(mconfig, SN76489A, "SN76489A", tag, owner, clock)
618{
619}
620
621//-------------------------------------------------
622//  device_start - device-specific startup
623//-------------------------------------------------
624
625void sn76489a_device::device_start()
626{
627   DEVICE_START_NAME( sn76489a )(this);
628}
629
630//-------------------------------------------------
631//  sound_stream_update - handle a stream update
632//-------------------------------------------------
633
634void sn76489a_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
635{
636   // should never get here
637   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
638}
639
640
641const device_type SN76494 = &device_creator<sn76494_device>;
642
643sn76494_device::sn76494_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
644   : sn76496_device(mconfig, SN76494, "SN76494", tag, owner, clock)
645{
646}
647
648//-------------------------------------------------
649//  device_start - device-specific startup
650//-------------------------------------------------
651
652void sn76494_device::device_start()
653{
654   DEVICE_START_NAME( sn76494 )(this);
655}
656
657//-------------------------------------------------
658//  sound_stream_update - handle a stream update
659//-------------------------------------------------
660
661void sn76494_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
662{
663   // should never get here
664   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
665}
666
667
668const device_type SN94624 = &device_creator<sn94624_device>;
669
670sn94624_device::sn94624_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
671   : sn76496_device(mconfig, SN94624, "SN94624", tag, owner, clock)
672{
673}
674
675//-------------------------------------------------
676//  device_start - device-specific startup
677//-------------------------------------------------
678
679void sn94624_device::device_start()
680{
681   DEVICE_START_NAME( sn94624 )(this);
682}
683
684//-------------------------------------------------
685//  sound_stream_update - handle a stream update
686//-------------------------------------------------
687
688void sn94624_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
689{
690   // should never get here
691   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
692}
693
694
695const device_type NCR7496 = &device_creator<ncr7496_device>;
696
697ncr7496_device::ncr7496_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
698   : sn76496_device(mconfig, NCR7496, "NCR7496", tag, owner, clock)
699{
700}
701
702//-------------------------------------------------
703//  device_start - device-specific startup
704//-------------------------------------------------
705
706void ncr7496_device::device_start()
707{
708   DEVICE_START_NAME( ncr7496 )(this);
709}
710
711//-------------------------------------------------
712//  sound_stream_update - handle a stream update
713//-------------------------------------------------
714
715void ncr7496_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
716{
717   // should never get here
718   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
719}
720
721
722const device_type GAMEGEAR = &device_creator<gamegear_device>;
723
724gamegear_device::gamegear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
725   : sn76496_device(mconfig, GAMEGEAR, "Game Gear PSG", tag, owner, clock)
726{
727}
728
729//-------------------------------------------------
730//  device_start - device-specific startup
731//-------------------------------------------------
732
733void gamegear_device::device_start()
734{
735   DEVICE_START_NAME( gamegear )(this);
736}
737
738//-------------------------------------------------
739//  sound_stream_update - handle a stream update
740//-------------------------------------------------
741
742void gamegear_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
743{
744   // should never get here
745   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
746}
747
748
749const device_type SEGAPSG = &device_creator<segapsg_device>;
750
751segapsg_device::segapsg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
752   : sn76496_device(mconfig, SEGAPSG, "SEGA VDP PSG", tag, owner, clock)
753{
754}
755
756//-------------------------------------------------
757//  device_start - device-specific startup
758//-------------------------------------------------
759
760void segapsg_device::device_start()
761{
762   DEVICE_START_NAME( segapsg )(this);
763}
764
765//-------------------------------------------------
766//  sound_stream_update - handle a stream update
767//-------------------------------------------------
768
769void segapsg_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
770{
771   // should never get here
772   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
773}
774
775
776
777/*****************************************************************
778    New class implementation
779    Michael Zapf, June 2012
780*****************************************************************/
781
782126sn76496_base_device::sn76496_base_device(const machine_config &mconfig, device_type type,  const char *name,
783127   const char *tag, int feedbackmask, int noisetap1, int noisetap2, bool negate, bool stereo, int clockdivider, int freq0,
784128   device_t *owner, UINT32 clock)
trunk/src/emu/sound/sn76496.h
r18233r18234
33#ifndef __SN76496_H__
44#define __SN76496_H__
55
6#include "devlegcy.h"
76
8READ_LINE_DEVICE_HANDLER( sn76496_ready_r );
9DECLARE_WRITE8_DEVICE_HANDLER( sn76496_w );
10DECLARE_WRITE8_DEVICE_HANDLER( sn76496_stereo_w );
11
12class sn76496_device : public device_t,
13                                  public device_sound_interface
14{
15public:
16   sn76496_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
17   sn76496_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
18   ~sn76496_device() { global_free(m_token); }
19
20   // access to legacy token
21   void *token() const { assert(m_token != NULL); return m_token; }
22protected:
23   // device-level overrides
24   virtual void device_config_complete();
25   virtual void device_start();
26
27   // sound stream update overrides
28   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
29private:
30   // internal state
31   void *m_token;
32};
33
34extern const device_type SN76496;
35
36class u8106_device : public sn76496_device
37{
38public:
39   u8106_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
40protected:
41   // device-level overrides
42   virtual void device_start();
43
44   // sound stream update overrides
45   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
46};
47
48extern const device_type U8106;
49
50class y2404_device : public sn76496_device
51{
52public:
53   y2404_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
54protected:
55   // device-level overrides
56   virtual void device_start();
57
58   // sound stream update overrides
59   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
60};
61
62extern const device_type Y2404;
63
64class sn76489_device : public sn76496_device
65{
66public:
67   sn76489_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
68protected:
69   // device-level overrides
70   virtual void device_start();
71
72   // sound stream update overrides
73   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
74};
75
76extern const device_type SN76489;
77
78class sn76489a_device : public sn76496_device
79{
80public:
81   sn76489a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
82protected:
83   // device-level overrides
84   virtual void device_start();
85
86   // sound stream update overrides
87   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
88};
89
90extern const device_type SN76489A;
91
92class sn76494_device : public sn76496_device
93{
94public:
95   sn76494_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
96protected:
97   // device-level overrides
98   virtual void device_start();
99
100   // sound stream update overrides
101   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
102};
103
104extern const device_type SN76494;
105
106class sn94624_device : public sn76496_device
107{
108public:
109   sn94624_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
110protected:
111   // device-level overrides
112   virtual void device_start();
113
114   // sound stream update overrides
115   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
116};
117
118extern const device_type SN94624;
119
120class ncr7496_device : public sn76496_device
121{
122public:
123   ncr7496_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
124protected:
125   // device-level overrides
126   virtual void device_start();
127
128   // sound stream update overrides
129   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
130};
131
132extern const device_type NCR7496;
133
134class gamegear_device : public sn76496_device
135{
136public:
137   gamegear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
138protected:
139   // device-level overrides
140   virtual void device_start();
141
142   // sound stream update overrides
143   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
144};
145
146extern const device_type GAMEGEAR;
147
148class segapsg_device : public sn76496_device
149{
150public:
151   segapsg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
152protected:
153   // device-level overrides
154   virtual void device_start();
155
156   // sound stream update overrides
157   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
158};
159
160extern const device_type SEGAPSG;
161
162
163/*****************************************************************
164    New class implementation
165    Michael Zapf, June 2012
166*****************************************************************/
167
1687extern const device_type SN76496_NEW;
1698extern const device_type U8106_NEW;
1709extern const device_type Y2404_NEW;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team