Previous 199869 Revisions Next

r22734 Friday 10th May, 2013 at 14:02:35 UTC by smf
modernised YMZ280B [smf]
[src/emu/sound]ymz280b.c ymz280b.h
[src/mame/drivers]backfire.c bfm_sc4h.c bfm_sc5.c bfm_swp.c bishi.c cave.c coinmvga.c deco156.c deco_mlc.c firebeat.c galpani3.c gunpey.c jchan.c maygayep.c midas.c realbrk.c seibuspi.c sigmab98.c suprnova.c tecmosys.c tetrisp2.c toaplan2.c zn.c

trunk/src/emu/sound/ymz280b.c
r22733r22734
2626
2727
2828#define MAX_SAMPLE_CHUNK    10000
29#define MAKE_WAVS           0
3029
3130#define FRAC_BITS           14
3231#define FRAC_ONE            (1 << FRAC_BITS)
3332#define FRAC_MASK           (FRAC_ONE - 1)
3433
3534#define INTERNAL_BUFFER_SIZE    (1 << 15)
36#define INTERNAL_SAMPLE_RATE    (chip->master_clock * 2.0)
35#define INTERNAL_SAMPLE_RATE    (m_master_clock * 2.0)
3736
3837#if MAKE_WAVS
3938#include "wavwrite.h"
4039#endif
4140
4241
43/* struct describing a single playing ADPCM voice */
44struct YMZ280BVoice
45{
46   UINT8 playing;          /* 1 if we are actively playing */
4742
48   UINT8 keyon;            /* 1 if the key is on */
49   UINT8 looping;          /* 1 if looping is enabled */
50   UINT8 mode;             /* current playback mode */
51   UINT16 fnum;            /* frequency */
52   UINT8 level;            /* output level */
53   UINT8 pan;              /* panning */
54
55   UINT32 start;           /* start address, in nibbles */
56   UINT32 stop;            /* stop address, in nibbles */
57   UINT32 loop_start;      /* loop start address, in nibbles */
58   UINT32 loop_end;        /* loop end address, in nibbles */
59   UINT32 position;        /* current position, in nibbles */
60
61   INT32 signal;           /* current ADPCM signal */
62   INT32 step;             /* current ADPCM step */
63
64   INT32 loop_signal;      /* signal at loop start */
65   INT32 loop_step;        /* step at loop start */
66   UINT32 loop_count;      /* number of loops so far */
67
68   INT32 output_left;      /* output volume (left) */
69   INT32 output_right;     /* output volume (right) */
70   INT32 output_step;      /* step value for frequency conversion */
71   INT32 output_pos;       /* current fractional position */
72   INT16 last_sample;      /* last sample output */
73   INT16 curr_sample;      /* current sample target */
74   UINT8 irq_schedule;     /* 1 if the IRQ state is updated by timer */
75};
76
77struct ymz280b_state
78{
79   sound_stream * stream;          /* which stream are we using */
80   UINT8 *region_base;             /* pointer to the base of the region */
81   UINT32 region_size;
82   UINT8 current_register;         /* currently accessible register */
83   UINT8 status_register;          /* current status register */
84   UINT8 irq_state;                /* current IRQ state */
85   UINT8 irq_mask;                 /* current IRQ mask */
86   UINT8 irq_enable;               /* current IRQ enable */
87   UINT8 keyon_enable;             /* key on enable */
88   UINT8 ext_mem_enable;           /* external memory enable */
89   double master_clock;            /* master clock frequency */
90   devcb_resolved_write_line irq_callback;  /* IRQ callback */
91   struct YMZ280BVoice voice[8];   /* the 8 voices */
92   UINT32 rom_addr_hi;
93   UINT32 rom_addr_mid;
94   UINT32 rom_readback_addr;       /* where the CPU can read the ROM */
95   devcb_resolved_read8 ext_ram_read;      /* external RAM read handler */
96   devcb_resolved_write8 ext_ram_write;    /* external RAM write handler */
97
98#if MAKE_WAVS
99   void * wavresample;             /* resampled waveform */
100#endif
101
102   INT16 *scratch;
103   device_t *device;
104};
105
106static void write_to_register(ymz280b_state *, int);
107
108
10943/* step size index shift table */
11044static const int index_scale[8] = { 0x0e6, 0x0e6, 0x0e6, 0x0e6, 0x133, 0x199, 0x200, 0x266 };
11145
11246/* lookup table for the precomputed difference */
11347static int diff_lookup[16];
11448
115/* timer callback */
116static TIMER_CALLBACK( update_irq_state_timer_0 );
117static TIMER_CALLBACK( update_irq_state_timer_1 );
118static TIMER_CALLBACK( update_irq_state_timer_2 );
119static TIMER_CALLBACK( update_irq_state_timer_3 );
120static TIMER_CALLBACK( update_irq_state_timer_4 );
121static TIMER_CALLBACK( update_irq_state_timer_5 );
122static TIMER_CALLBACK( update_irq_state_timer_6 );
123static TIMER_CALLBACK( update_irq_state_timer_7 );
12449
125static const struct { timer_expired_func func; const char *name; } update_irq_state_cb[] =
50UINT8 ymz280b_device::ymz280b_read_memory(UINT32 offset)
12651{
127   { FUNC(update_irq_state_timer_0) },
128   { FUNC(update_irq_state_timer_1) },
129   { FUNC(update_irq_state_timer_2) },
130   { FUNC(update_irq_state_timer_3) },
131   { FUNC(update_irq_state_timer_4) },
132   { FUNC(update_irq_state_timer_5) },
133   { FUNC(update_irq_state_timer_6) },
134   { FUNC(update_irq_state_timer_7) }
135};
136
137
138INLINE ymz280b_state *get_safe_token(device_t *device)
139{
140   assert(device != NULL);
141   assert(device->type() == YMZ280B);
142   return (ymz280b_state *)downcast<ymz280b_device *>(device)->token();
143}
144
145
146INLINE UINT8 ymz280b_read_memory(ymz280b_state *chip, UINT32 offset)
147{
148   if (chip->ext_ram_read.isnull())
52   if (m_ext_read_handler.isnull())
14953   {
150      if (offset < chip->region_size)
151         return chip->region_base[offset];
54      if (offset < m_region_size)
55         return m_region_base[offset];
15256
15357      /* 16MB chip limit (shouldn't happen) */
15458      else if (offset > 0xffffff)
155         return chip->region_base[offset & 0xffffff];
59         return m_region_base[offset & 0xffffff];
15660
15761      else
15862         return 0;
15963   }
16064   else
161      return chip->ext_ram_read(offset);
65      return m_ext_read_handler(offset);
16266}
16367
16468
165INLINE void update_irq_state(ymz280b_state *chip)
69void ymz280b_device::update_irq_state()
16670{
167   int irq_bits = chip->status_register & chip->irq_mask;
71   int irq_bits = m_status_register & m_irq_mask;
16872
16973   /* always off if the enable is off */
170   if (!chip->irq_enable)
74   if (!m_irq_enable)
17175      irq_bits = 0;
17276
17377   /* update the state if changed */
174   if (irq_bits && !chip->irq_state)
78   if (irq_bits && !m_irq_state)
17579   {
176      chip->irq_state = 1;
177      if (!chip->irq_callback.isnull())
178         chip->irq_callback(1);
80      m_irq_state = 1;
81      if (!m_irq_handler.isnull())
82         m_irq_handler(1);
17983      else logerror("YMZ280B: IRQ generated, but no callback specified!");
18084   }
181   else if (!irq_bits && chip->irq_state)
85   else if (!irq_bits && m_irq_state)
18286   {
183      chip->irq_state = 0;
184      if (!chip->irq_callback.isnull())
185         chip->irq_callback(0);
87      m_irq_state = 0;
88      if (!m_irq_handler.isnull())
89         m_irq_handler(0);
18690      else logerror("YMZ280B: IRQ generated, but no callback specified!");
18791   }
18892}
18993
19094
191INLINE void update_step(ymz280b_state *chip, struct YMZ280BVoice *voice)
95void ymz280b_device::update_step(struct YMZ280BVoice *voice)
19296{
19397   double frequency;
19498
19599   /* compute the frequency */
196100   if (voice->mode == 1)
197      frequency = chip->master_clock * (double)((voice->fnum & 0x0ff) + 1) * (1.0 / 256.0);
101      frequency = m_master_clock * (double)((voice->fnum & 0x0ff) + 1) * (1.0 / 256.0);
198102   else
199      frequency = chip->master_clock * (double)((voice->fnum & 0x1ff) + 1) * (1.0 / 256.0);
103      frequency = m_master_clock * (double)((voice->fnum & 0x1ff) + 1) * (1.0 / 256.0);
200104   voice->output_step = (UINT32)(frequency * (double)FRAC_ONE / INTERNAL_SAMPLE_RATE);
201105}
202106
203107
204INLINE void update_volumes(struct YMZ280BVoice *voice)
108void ymz280b_device::update_volumes(struct YMZ280BVoice *voice)
205109{
206110   if (voice->pan == 8)
207111   {
r22733r22734
223127}
224128
225129
226static void YMZ280B_state_save_update_step(ymz280b_state *chip)
130void ymz280b_device::post_load()
227131{
228132   for (int j = 0; j < 8; j++)
229133   {
230      struct YMZ280BVoice *voice = &chip->voice[j];
231      update_step(chip, voice);
134      struct YMZ280BVoice *voice = &m_voice[j];
135      update_step(voice);
232136      if(voice->irq_schedule)
233         chip->device->machine().scheduler().timer_set(attotime::zero, update_irq_state_cb[j].func, update_irq_state_cb[j].name, 0, chip);
137         voice->timer->adjust(attotime::zero);
234138   }
235139}
236140
237141
238static void update_irq_state_timer_common(void *param, int voicenum)
142void ymz280b_device::update_irq_state_timer_common(int voicenum)
239143{
240   ymz280b_state *chip = (ymz280b_state *)param;
241   struct YMZ280BVoice *voice = &chip->voice[voicenum];
144   struct YMZ280BVoice *voice = &m_voice[voicenum];
242145
243146   if(!voice->irq_schedule) return;
244147
245148   voice->playing = 0;
246   chip->status_register |= 1 << voicenum;
247   update_irq_state(chip);
149   m_status_register |= 1 << voicenum;
150   update_irq_state();
248151   voice->irq_schedule = 0;
249152}
250153
251static TIMER_CALLBACK( update_irq_state_timer_0 ) { update_irq_state_timer_common(ptr, 0); }
252static TIMER_CALLBACK( update_irq_state_timer_1 ) { update_irq_state_timer_common(ptr, 1); }
253static TIMER_CALLBACK( update_irq_state_timer_2 ) { update_irq_state_timer_common(ptr, 2); }
254static TIMER_CALLBACK( update_irq_state_timer_3 ) { update_irq_state_timer_common(ptr, 3); }
255static TIMER_CALLBACK( update_irq_state_timer_4 ) { update_irq_state_timer_common(ptr, 4); }
256static TIMER_CALLBACK( update_irq_state_timer_5 ) { update_irq_state_timer_common(ptr, 5); }
257static TIMER_CALLBACK( update_irq_state_timer_6 ) { update_irq_state_timer_common(ptr, 6); }
258static TIMER_CALLBACK( update_irq_state_timer_7 ) { update_irq_state_timer_common(ptr, 7); }
259
260
261154/**********************************************************************************************
262155
263156     compute_tables -- compute the difference tables
r22733r22734
282175
283176***********************************************************************************************/
284177
285static int generate_adpcm(ymz280b_state *chip, struct YMZ280BVoice *voice, INT16 *buffer, int samples)
178int ymz280b_device::generate_adpcm(struct YMZ280BVoice *voice, INT16 *buffer, int samples)
286179{
287180   int position = voice->position;
288181   int signal = voice->signal;
r22733r22734
296189      while (samples)
297190      {
298191         /* compute the new amplitude and update the current step */
299         val = ymz280b_read_memory(chip, position / 2) >> ((~position & 1) << 2);
192         val = ymz280b_read_memory(position / 2) >> ((~position & 1) << 2);
300193         signal += (step * diff_lookup[val & 15]) / 8;
301194
302195         /* clamp to the maximum */
r22733r22734
335228      while (samples)
336229      {
337230         /* compute the new amplitude and update the current step */
338         val = ymz280b_read_memory(chip, position / 2) >> ((~position & 1) << 2);
231         val = ymz280b_read_memory(position / 2) >> ((~position & 1) << 2);
339232         signal += (step * diff_lookup[val & 15]) / 8;
340233
341234         /* clamp to the maximum */
r22733r22734
398291
399292***********************************************************************************************/
400293
401static int generate_pcm8(ymz280b_state *chip, struct YMZ280BVoice *voice, INT16 *buffer, int samples)
294int ymz280b_device::generate_pcm8(struct YMZ280BVoice *voice, INT16 *buffer, int samples)
402295{
403296   int position = voice->position;
404297   int val;
r22733r22734
410303      while (samples)
411304      {
412305         /* fetch the current value */
413         val = ymz280b_read_memory(chip, position / 2);
306         val = ymz280b_read_memory(position / 2);
414307
415308         /* output to the buffer, scaling by the volume */
416309         *buffer++ = (INT8)val * 256;
r22733r22734
435328      while (samples)
436329      {
437330         /* fetch the current value */
438         val = ymz280b_read_memory(chip, position / 2);
331         val = ymz280b_read_memory(position / 2);
439332
440333         /* output to the buffer, scaling by the volume */
441334         *buffer++ = (INT8)val * 256;
r22733r22734
472365
473366***********************************************************************************************/
474367
475static int generate_pcm16(ymz280b_state *chip, struct YMZ280BVoice *voice, INT16 *buffer, int samples)
368int ymz280b_device::generate_pcm16(struct YMZ280BVoice *voice, INT16 *buffer, int samples)
476369{
477370   int position = voice->position;
478371   int val;
r22733r22734
484377      while (samples)
485378      {
486379         /* fetch the current value */
487         val = (INT16)((ymz280b_read_memory(chip, position / 2 + 0) << 8) + ymz280b_read_memory(chip, position / 2 + 1));
380         val = (INT16)((ymz280b_read_memory(position / 2 + 0) << 8) + ymz280b_read_memory(position / 2 + 1));
488381
489382         /* output to the buffer, scaling by the volume */
490383         *buffer++ = val;
r22733r22734
509402      while (samples)
510403      {
511404         /* fetch the current value */
512         val = (INT16)((ymz280b_read_memory(chip, position / 2 + 0) << 8) + ymz280b_read_memory(chip, position / 2 + 1));
405         val = (INT16)((ymz280b_read_memory(position / 2 + 0) << 8) + ymz280b_read_memory(position / 2 + 1));
513406
514407         /* output to the buffer, scaling by the volume */
515408         *buffer++ = val;
r22733r22734
540433
541434
542435
543/**********************************************************************************************
544436
545     ymz280b_update -- update the sound chip so that it is in sync with CPU execution
437//-------------------------------------------------
438//  sound_stream_update - handle a stream update
439//-------------------------------------------------
546440
547***********************************************************************************************/
548
549static STREAM_UPDATE( ymz280b_update )
441void ymz280b_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
550442{
551   ymz280b_state *chip = (ymz280b_state *)param;
552443   stream_sample_t *lacc = outputs[0];
553444   stream_sample_t *racc = outputs[1];
554445   int v;
r22733r22734
560451   /* loop over voices */
561452   for (v = 0; v < 8; v++)
562453   {
563      struct YMZ280BVoice *voice = &chip->voice[v];
454      struct YMZ280BVoice *voice = &m_voice[v];
564455      INT16 prev = voice->last_sample;
565456      INT16 curr = voice->curr_sample;
566      INT16 *curr_data = chip->scratch;
457      INT16 *curr_data = m_scratch;
567458      INT32 *ldest = lacc;
568459      INT32 *rdest = racc;
569460      UINT32 new_samples, samples_left;
r22733r22734
608499      /* generate them into our buffer */
609500      switch (voice->playing << 7 | voice->mode)
610501      {
611         case 0x81:  samples_left = generate_adpcm(chip, voice, chip->scratch, new_samples); break;
612         case 0x82:  samples_left = generate_pcm8(chip, voice, chip->scratch, new_samples); break;
613         case 0x83:  samples_left = generate_pcm16(chip, voice, chip->scratch, new_samples); break;
614         default:    samples_left = 0; memset(chip->scratch, 0, new_samples * sizeof(chip->scratch[0])); break;
502         case 0x81:  samples_left = generate_adpcm(voice, m_scratch, new_samples); break;
503         case 0x82:  samples_left = generate_pcm8(voice, m_scratch, new_samples); break;
504         case 0x83:  samples_left = generate_pcm16(voice, m_scratch, new_samples); break;
505         default:    samples_left = 0; memset(m_scratch, 0, new_samples * sizeof(m_scratch[0])); break;
615506      }
616507
617508      /* if there are leftovers, ramp back to 0 */
r22733r22734
619510      {
620511         /* note: samples_left bit 16 is set if the voice was finished at the same time the function ended */
621512         int base = new_samples - (samples_left & 0xffff);
622         int i, t = (base == 0) ? curr : chip->scratch[base - 1];
513         int i, t = (base == 0) ? curr : m_scratch[base - 1];
623514         for (i = 0; i < (samples_left & 0xffff); i++)
624515         {
625516            if (t < 0) t = -((-t * 15) >> 4);
626517            else if (t > 0) t = (t * 15) >> 4;
627            chip->scratch[base + i] = t;
518            m_scratch[base + i] = t;
628519         }
629520
630521         /* if we hit the end and IRQs are enabled, signal it */
r22733r22734
633524            voice->playing = 0;
634525
635526            /* set update_irq_state_timer. IRQ is signaled on next CPU execution. */
636            chip->device->machine().scheduler().timer_set(attotime::zero, update_irq_state_cb[v].func, update_irq_state_cb[v].name, 0, chip);
527            voice->timer->adjust(attotime::zero);
637528            voice->irq_schedule = 1;
638529         }
639530      }
r22733r22734
678569
679570
680571
681/**********************************************************************************************
572//-------------------------------------------------
573//  device_start - device-specific startup
574//-------------------------------------------------
682575
683     DEVICE_START/RESET( ymz280b ) -- start/reset emulation of the YMZ280B
684
685***********************************************************************************************/
686
687static DEVICE_START( ymz280b )
576void ymz280b_device::device_start()
688577{
689   static const ymz280b_interface defintrf = { DEVCB_NULL };
690   const ymz280b_interface *intf = (device->static_config() != NULL) ? (const ymz280b_interface *)device->static_config() : &defintrf;
691   ymz280b_state *chip = get_safe_token(device);
578   m_ext_read_handler.resolve();
579   m_ext_write_handler.resolve();
692580
693   chip->device = device;
694   chip->ext_ram_read.resolve(intf->ext_read, *device);
695   chip->ext_ram_write.resolve(intf->ext_write, *device);
696
697581   /* compute ADPCM tables */
698582   compute_tables();
699583
700584   /* initialize the rest of the structure */
701   chip->master_clock = (double)device->clock() / 384.0;
702   chip->region_base = *device->region();
703   chip->region_size = device->region()->bytes();
704   chip->irq_callback.resolve(intf->irq_callback, *device);
585   m_master_clock = (double)clock() / 384.0;
586   m_region_base = *region();
587   m_region_size = region()->bytes();
588   m_irq_handler.resolve();
705589
590   for (int i = 0; i < 8; i++)
591   {
592      m_voice[i].timer = timer_alloc(i);
593   }
594
706595   /* create the stream */
707   chip->stream = device->machine().sound().stream_alloc(*device, 0, 2, INTERNAL_SAMPLE_RATE, chip, ymz280b_update);
596   m_stream = machine().sound().stream_alloc(*this, 0, 2, INTERNAL_SAMPLE_RATE);
708597
709598   /* allocate memory */
710599   assert(MAX_SAMPLE_CHUNK < 0x10000);
711   chip->scratch = auto_alloc_array(device->machine(), INT16, MAX_SAMPLE_CHUNK);
600   m_scratch = auto_alloc_array(machine(), INT16, MAX_SAMPLE_CHUNK);
712601
713602   /* state save */
603   save_item(NAME(m_current_register));
604   save_item(NAME(m_status_register));
605   save_item(NAME(m_irq_state));
606   save_item(NAME(m_irq_mask));
607   save_item(NAME(m_irq_enable));
608   save_item(NAME(m_keyon_enable));
609   save_item(NAME(m_ext_mem_enable));
610   save_item(NAME(m_rom_readback_addr));
611   save_item(NAME(m_rom_addr_hi));
612   save_item(NAME(m_rom_addr_mid));
613   for (int j = 0; j < 8; j++)
714614   {
715      int j;
716      device->save_item(NAME(chip->current_register));
717      device->save_item(NAME(chip->status_register));
718      device->save_item(NAME(chip->irq_state));
719      device->save_item(NAME(chip->irq_mask));
720      device->save_item(NAME(chip->irq_enable));
721      device->save_item(NAME(chip->keyon_enable));
722      device->save_item(NAME(chip->ext_mem_enable));
723      device->save_item(NAME(chip->rom_readback_addr));
724      device->save_item(NAME(chip->rom_addr_hi));
725      device->save_item(NAME(chip->rom_addr_mid));
726      for (j = 0; j < 8; j++)
727      {
728         device->save_item(NAME(chip->voice[j].playing), j);
729         device->save_item(NAME(chip->voice[j].keyon), j);
730         device->save_item(NAME(chip->voice[j].looping), j);
731         device->save_item(NAME(chip->voice[j].mode), j);
732         device->save_item(NAME(chip->voice[j].fnum), j);
733         device->save_item(NAME(chip->voice[j].level), j);
734         device->save_item(NAME(chip->voice[j].pan), j);
735         device->save_item(NAME(chip->voice[j].start), j);
736         device->save_item(NAME(chip->voice[j].stop), j);
737         device->save_item(NAME(chip->voice[j].loop_start), j);
738         device->save_item(NAME(chip->voice[j].loop_end), j);
739         device->save_item(NAME(chip->voice[j].position), j);
740         device->save_item(NAME(chip->voice[j].signal), j);
741         device->save_item(NAME(chip->voice[j].step), j);
742         device->save_item(NAME(chip->voice[j].loop_signal), j);
743         device->save_item(NAME(chip->voice[j].loop_step), j);
744         device->save_item(NAME(chip->voice[j].loop_count), j);
745         device->save_item(NAME(chip->voice[j].output_left), j);
746         device->save_item(NAME(chip->voice[j].output_right), j);
747         device->save_item(NAME(chip->voice[j].output_pos), j);
748         device->save_item(NAME(chip->voice[j].last_sample), j);
749         device->save_item(NAME(chip->voice[j].curr_sample), j);
750         device->save_item(NAME(chip->voice[j].irq_schedule), j);
751      }
615      save_item(NAME(m_voice[j].playing), j);
616      save_item(NAME(m_voice[j].keyon), j);
617      save_item(NAME(m_voice[j].looping), j);
618      save_item(NAME(m_voice[j].mode), j);
619      save_item(NAME(m_voice[j].fnum), j);
620      save_item(NAME(m_voice[j].level), j);
621      save_item(NAME(m_voice[j].pan), j);
622      save_item(NAME(m_voice[j].start), j);
623      save_item(NAME(m_voice[j].stop), j);
624      save_item(NAME(m_voice[j].loop_start), j);
625      save_item(NAME(m_voice[j].loop_end), j);
626      save_item(NAME(m_voice[j].position), j);
627      save_item(NAME(m_voice[j].signal), j);
628      save_item(NAME(m_voice[j].step), j);
629      save_item(NAME(m_voice[j].loop_signal), j);
630      save_item(NAME(m_voice[j].loop_step), j);
631      save_item(NAME(m_voice[j].loop_count), j);
632      save_item(NAME(m_voice[j].output_left), j);
633      save_item(NAME(m_voice[j].output_right), j);
634      save_item(NAME(m_voice[j].output_pos), j);
635      save_item(NAME(m_voice[j].last_sample), j);
636      save_item(NAME(m_voice[j].curr_sample), j);
637      save_item(NAME(m_voice[j].irq_schedule), j);
752638   }
753639
754   device->machine().save().register_postload(save_prepost_delegate(FUNC(YMZ280B_state_save_update_step), chip));
755
756640#if MAKE_WAVS
757   chip->wavresample = wav_open("resamp.wav", INTERNAL_SAMPLE_RATE, 2);
641   m_wavresample = wav_open("resamp.wav", INTERNAL_SAMPLE_RATE, 2);
758642#endif
759643}
760644
761static DEVICE_RESET( ymz280b )
645//-------------------------------------------------
646//  device_reset - device-specific reset
647//-------------------------------------------------
648
649void ymz280b_device::device_reset()
762650{
763651   int i;
764   ymz280b_state *chip = get_safe_token(device);
765652
766653   /* initial clear registers */
767654   for (i = 0xff; i >= 0; i--)
768655   {
769      chip->current_register = i;
770      write_to_register(chip, 0);
656      m_current_register = i;
657      write_to_register(0);
771658   }
772659
773   chip->current_register = 0;
774   chip->status_register = 0;
775   chip->rom_readback_addr = 0;
660   m_current_register = 0;
661   m_status_register = 0;
662   m_rom_readback_addr = 0;
776663
777664   /* clear other voice parameters */
778665   for (i = 0; i < 8; i++)
779666   {
780      struct YMZ280BVoice *voice = &chip->voice[i];
667      struct YMZ280BVoice *voice = &m_voice[i];
781668
782669      voice->curr_sample = 0;
783670      voice->last_sample = 0;
r22733r22734
787674}
788675
789676
677void ymz280b_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
678{
679   update_irq_state_timer_common( param );
680}
790681
682
791683/**********************************************************************************************
792684
793685     write_to_register -- handle a write to the current register
794686
795687***********************************************************************************************/
796688
797static void write_to_register(ymz280b_state *chip, int data)
689void ymz280b_device::write_to_register(int data)
798690{
799691   struct YMZ280BVoice *voice;
800692   int i;
801693
802694   /* lower registers follow a pattern */
803   if (chip->current_register < 0x80)
695   if (m_current_register < 0x80)
804696   {
805      voice = &chip->voice[(chip->current_register >> 2) & 7];
697      voice = &m_voice[(m_current_register >> 2) & 7];
806698
807      switch (chip->current_register & 0xe3)
699      switch (m_current_register & 0xe3)
808700      {
809701         case 0x00:      /* pitch low 8 bits */
810702            voice->fnum = (voice->fnum & 0x100) | (data & 0xff);
811            update_step(chip, voice);
703            update_step(voice);
812704            break;
813705
814706         case 0x01:      /* pitch upper 1 bit, loop, key on, mode */
r22733r22734
816708            voice->looping = (data & 0x10) >> 4;
817709            if ((data & 0x60) == 0) data &= 0x7f; /* ignore mode setting and set to same state as KON=0 */
818710            else voice->mode = (data & 0x60) >> 5;
819            if (!voice->keyon && (data & 0x80) && chip->keyon_enable)
711            if (!voice->keyon && (data & 0x80) && m_keyon_enable)
820712            {
821713               voice->playing = 1;
822714               voice->position = voice->start;
r22733r22734
835727               voice->irq_schedule = 0;
836728            }
837729            voice->keyon = (data & 0x80) >> 7;
838            update_step(chip, voice);
730            update_step(voice);
839731            break;
840732
841733         case 0x02:      /* total level */
r22733r22734
897789            break;
898790
899791         default:
900            logerror("YMZ280B: unknown register write %02X = %02X\n", chip->current_register, data);
792            logerror("YMZ280B: unknown register write %02X = %02X\n", m_current_register, data);
901793            break;
902794      }
903795   }
r22733r22734
905797   /* upper registers are special */
906798   else
907799   {
908      switch (chip->current_register)
800      switch (m_current_register)
909801      {
910802         /* DSP related (not implemented yet) */
911803         case 0x80: // d0-2: DSP Rch, d3: enable Rch (0: yes, 1: no), d4-6: DSP Lch, d7: enable Lch (0: yes, 1: no)
912804         case 0x81: // d0: enable control of $82 (0: yes, 1: no)
913805         case 0x82: // DSP data
914            logerror("YMZ280B: DSP register write %02X = %02X\n", chip->current_register, data);
806            logerror("YMZ280B: DSP register write %02X = %02X\n", m_current_register, data);
915807            break;
916808
917809         case 0x84:      /* ROM readback / RAM write (high) */
918            chip->rom_addr_hi = data << 16;
810            m_rom_addr_hi = data << 16;
919811            break;
920812
921813         case 0x85:      /* ROM readback / RAM write (middle) */
922            chip->rom_addr_mid = data << 8;
814            m_rom_addr_mid = data << 8;
923815            break;
924816
925817         case 0x86:      /* ROM readback / RAM write (low) -> update latch */
926            chip->rom_readback_addr = chip->rom_addr_hi | chip->rom_addr_mid | data;
818            m_rom_readback_addr = m_rom_addr_hi | m_rom_addr_mid | data;
927819            break;
928820
929821         case 0x87:      /* RAM write */
930            if (chip->ext_mem_enable)
822            if (m_ext_mem_enable)
931823            {
932               if (!chip->ext_ram_write.isnull())
933                  chip->ext_ram_write(chip->rom_readback_addr, data);
824               if (!m_ext_write_handler.isnull())
825                  m_ext_write_handler(m_rom_readback_addr, data);
934826               else
935                  logerror("YMZ280B attempted RAM write to %X\n", chip->rom_readback_addr);
936               chip->rom_readback_addr = (chip->rom_readback_addr + 1) & 0xffffff;
827                  logerror("YMZ280B attempted RAM write to %X\n", m_rom_readback_addr);
828               m_rom_readback_addr = (m_rom_readback_addr + 1) & 0xffffff;
937829            }
938830            break;
939831
940832         case 0xfe:      /* IRQ mask */
941            chip->irq_mask = data;
942            update_irq_state(chip);
833            m_irq_mask = data;
834            update_irq_state();
943835            break;
944836
945837         case 0xff:      /* IRQ enable, test, etc */
946            chip->ext_mem_enable = (data & 0x40) >> 6;
947            chip->irq_enable = (data & 0x10) >> 4;
948            update_irq_state(chip);
838            m_ext_mem_enable = (data & 0x40) >> 6;
839            m_irq_enable = (data & 0x10) >> 4;
840            update_irq_state();
949841
950            if (chip->keyon_enable && !(data & 0x80))
842            if (m_keyon_enable && !(data & 0x80))
951843            {
952844               for (i = 0; i < 8; i++)
953845               {
954                  chip->voice[i].playing = 0;
846                  m_voice[i].playing = 0;
955847
956848                  /* if update_irq_state_timer is set, cancel it. */
957                  chip->voice[i].irq_schedule = 0;
849                  m_voice[i].irq_schedule = 0;
958850               }
959851            }
960            else if (!chip->keyon_enable && (data & 0x80))
852            else if (!m_keyon_enable && (data & 0x80))
961853            {
962854               for (i = 0; i < 8; i++)
963855               {
964                  if (chip->voice[i].keyon && chip->voice[i].looping)
965                     chip->voice[i].playing = 1;
856                  if (m_voice[i].keyon && m_voice[i].looping)
857                     m_voice[i].playing = 1;
966858               }
967859            }
968            chip->keyon_enable = (data & 0x80) >> 7;
860            m_keyon_enable = (data & 0x80) >> 7;
969861            break;
970862
971863         default:
972            logerror("YMZ280B: unknown register write %02X = %02X\n", chip->current_register, data);
864            logerror("YMZ280B: unknown register write %02X = %02X\n", m_current_register, data);
973865            break;
974866      }
975867   }
r22733r22734
983875
984876***********************************************************************************************/
985877
986static int compute_status(ymz280b_state *chip)
878int ymz280b_device::compute_status()
987879{
988880   UINT8 result;
989881
990882   /* force an update */
991   chip->stream->update();
883   m_stream->update();
992884
993   result = chip->status_register;
885   result = m_status_register;
994886
995887   /* clear the IRQ state */
996   chip->status_register = 0;
997   update_irq_state(chip);
888   m_status_register = 0;
889   update_irq_state();
998890
999891   return result;
1000892}
r22733r22734
1007899
1008900***********************************************************************************************/
1009901
1010READ8_DEVICE_HANDLER( ymz280b_r )
902READ8_MEMBER( ymz280b_device::read )
1011903{
1012   ymz280b_state *chip = get_safe_token(device);
1013
1014904   if ((offset & 1) == 0)
1015905   {
1016      if (!chip->ext_mem_enable)
906      if (!m_ext_mem_enable)
1017907         return 0xff;
1018908
1019909      /* read from external memory */
1020      UINT8 result = ymz280b_read_memory(chip, chip->rom_readback_addr);
1021      chip->rom_readback_addr = (chip->rom_readback_addr + 1) & 0xffffff;
910      UINT8 result = ymz280b_read_memory(m_rom_readback_addr);
911      m_rom_readback_addr = (m_rom_readback_addr + 1) & 0xffffff;
1022912      return result;
1023913   }
1024914   else
1025      return compute_status(chip);
915      return compute_status();
1026916}
1027917
1028918
1029WRITE8_DEVICE_HANDLER( ymz280b_w )
919WRITE8_MEMBER( ymz280b_device::write )
1030920{
1031   ymz280b_state *chip = get_safe_token(device);
1032
1033921   if ((offset & 1) == 0)
1034      chip->current_register = data;
922      m_current_register = data;
1035923   else
1036924   {
1037925      /* force an update */
1038      chip->stream->update();
926      m_stream->update();
1039927
1040      write_to_register(chip, data);
928      write_to_register(data);
1041929   }
1042930}
1043931
r22733r22734
1046934
1047935ymz280b_device::ymz280b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
1048936   : device_t(mconfig, YMZ280B, "YMZ280B", tag, owner, clock),
1049      device_sound_interface(mconfig, *this)
937      device_sound_interface(mconfig, *this),
938      m_irq_handler(*this),
939      m_ext_read_handler(*this),
940      m_ext_write_handler(*this)
1050941{
1051   m_token = global_alloc_clear(ymz280b_state);
1052942}
1053943
1054944//-------------------------------------------------
r22733r22734
1060950void ymz280b_device::device_config_complete()
1061951{
1062952}
1063
1064//-------------------------------------------------
1065//  device_start - device-specific startup
1066//-------------------------------------------------
1067
1068void ymz280b_device::device_start()
1069{
1070   DEVICE_START_NAME( ymz280b )(this);
1071}
1072
1073//-------------------------------------------------
1074//  device_reset - device-specific reset
1075//-------------------------------------------------
1076
1077void ymz280b_device::device_reset()
1078{
1079   DEVICE_RESET_NAME( ymz280b )(this);
1080}
1081
1082//-------------------------------------------------
1083//  sound_stream_update - handle a stream update
1084//-------------------------------------------------
1085
1086void ymz280b_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
1087{
1088   // should never get here
1089   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
1090}
trunk/src/emu/sound/ymz280b.h
r22733r22734
1010#ifndef __YMZ280B_H__
1111#define __YMZ280B_H__
1212
13#include "devlegcy.h"
13#include "emu.h"
1414
15#define MAKE_WAVS           0
1516
16struct ymz280b_interface
17{
18   devcb_write_line irq_callback;  /* irq callback */
19   devcb_read8 ext_read;           /* external RAM read */
20   devcb_write8 ext_write;     /* external RAM write */
21};
17#define MCFG_YMZ280B_IRQ_HANDLER(_devcb) \
18   devcb = &ymz280b_device::set_irq_handler(*device, DEVCB2_##_devcb);
2219
23DECLARE_READ8_DEVICE_HANDLER ( ymz280b_r );
24DECLARE_WRITE8_DEVICE_HANDLER( ymz280b_w );
20#define MCFG_YMZ280B_EXT_READ_HANDLER(_devcb) \
21   devcb = &ymz280b_device::set_ext_read_handler(*device, DEVCB2_##_devcb);
2522
23#define MCFG_YMZ280B_EXT_WRITE_HANDLER(_devcb) \
24   devcb = &ymz280b_device::set_ext_write_handler(*device, DEVCB2_##_devcb);
25
2626class ymz280b_device : public device_t,
2727                           public device_sound_interface
2828{
2929public:
3030   ymz280b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31   ~ymz280b_device() { global_free(m_token); }
3231
33   // access to legacy token
34   void *token() const { assert(m_token != NULL); return m_token; }
32   // static configuration helpers
33   template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<ymz280b_device &>(device).m_irq_handler.set_callback(object); }
34   template<class _Object> static devcb2_base &set_ext_read_handler(device_t &device, _Object object) { return downcast<ymz280b_device &>(device).m_ext_read_handler.set_callback(object); }
35   template<class _Object> static devcb2_base &set_ext_write_handler(device_t &device, _Object object) { return downcast<ymz280b_device &>(device).m_ext_write_handler.set_callback(object); }
36
37   DECLARE_READ8_MEMBER( read );
38   DECLARE_WRITE8_MEMBER( write );
39
3540protected:
3641   // device-level overrides
3742   virtual void device_config_complete();
3843   virtual void device_start();
44   virtual void post_load();
3945   virtual void device_reset();
46   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
4047
4148   // sound stream update overrides
4249   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
4350private:
51
52   /* struct describing a single playing ADPCM voice */
53   struct YMZ280BVoice
54   {
55      UINT8 playing;          /* 1 if we are actively playing */
56
57      UINT8 keyon;            /* 1 if the key is on */
58      UINT8 looping;          /* 1 if looping is enabled */
59      UINT8 mode;             /* current playback mode */
60      UINT16 fnum;            /* frequency */
61      UINT8 level;            /* output level */
62      UINT8 pan;              /* panning */
63
64      UINT32 start;           /* start address, in nibbles */
65      UINT32 stop;            /* stop address, in nibbles */
66      UINT32 loop_start;      /* loop start address, in nibbles */
67      UINT32 loop_end;        /* loop end address, in nibbles */
68      UINT32 position;        /* current position, in nibbles */
69
70      INT32 signal;           /* current ADPCM signal */
71      INT32 step;             /* current ADPCM step */
72
73      INT32 loop_signal;      /* signal at loop start */
74      INT32 loop_step;        /* step at loop start */
75      UINT32 loop_count;      /* number of loops so far */
76
77      INT32 output_left;      /* output volume (left) */
78      INT32 output_right;     /* output volume (right) */
79      INT32 output_step;      /* step value for frequency conversion */
80      INT32 output_pos;       /* current fractional position */
81      INT16 last_sample;      /* last sample output */
82      INT16 curr_sample;      /* current sample target */
83      UINT8 irq_schedule;     /* 1 if the IRQ state is updated by timer */
84
85      emu_timer *timer;
86   };
87
88   UINT8 ymz280b_read_memory(UINT32 offset);
89   void update_irq_state();
90   void update_step(struct YMZ280BVoice *voice);
91   void update_volumes(struct YMZ280BVoice *voice);
92   void update_irq_state_timer_common(int voicenum);
93   int generate_adpcm(struct YMZ280BVoice *voice, INT16 *buffer, int samples);
94   int generate_pcm8(struct YMZ280BVoice *voice, INT16 *buffer, int samples);
95   int generate_pcm16(struct YMZ280BVoice *voice, INT16 *buffer, int samples);
96   void write_to_register(int data);
97   int compute_status();
98
4499   // internal state
45   void *m_token;
100   sound_stream * m_stream;          /* which stream are we using */
101   UINT8 *m_region_base;             /* pointer to the base of the region */
102   UINT32 m_region_size;
103   UINT8 m_current_register;         /* currently accessible register */
104   UINT8 m_status_register;          /* current status register */
105   UINT8 m_irq_state;                /* current IRQ state */
106   UINT8 m_irq_mask;                 /* current IRQ mask */
107   UINT8 m_irq_enable;               /* current IRQ enable */
108   UINT8 m_keyon_enable;             /* key on enable */
109   UINT8 m_ext_mem_enable;           /* external memory enable */
110   double m_master_clock;            /* master clock frequency */
111   devcb2_write_line m_irq_handler;  /* IRQ callback */
112   struct YMZ280BVoice m_voice[8];   /* the 8 voices */
113   UINT32 m_rom_addr_hi;
114   UINT32 m_rom_addr_mid;
115   UINT32 m_rom_readback_addr;       /* where the CPU can read the ROM */
116   devcb2_read8 m_ext_read_handler;  /* external RAM read handler */
117   devcb2_write8 m_ext_write_handler;/* external RAM write handler */
118
119#if MAKE_WAVS
120   void * m_wavresample;             /* resampled waveform */
121#endif
122
123   INT16 *m_scratch;
46124};
47125
48126extern const device_type YMZ280B;
trunk/src/mame/drivers/tetrisp2.c
r22733r22734
305305   AM_RANGE(0x500000, 0x50ffff) AM_RAM                                                         // Line
306306   AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_SHARE("vram_rot") // Rotation
307307   AM_RANGE(0x650000, 0x651fff) AM_RAM_WRITE(tetrisp2_vram_rot_w)                              // Rotation (mirror)
308   AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)   // Sound
308   AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)   // Sound
309309   AM_RANGE(0x900000, 0x903fff) AM_READ(tetrisp2_nvram_r) AM_WRITE(tetrisp2_nvram_w) AM_SHARE("nvram") // NVRAM
310310   AM_RANGE(0x904000, 0x907fff) AM_READ(tetrisp2_nvram_r) AM_WRITE(tetrisp2_nvram_w)               // NVRAM (mirror)
311311   AM_RANGE(0xb00000, 0xb00001) AM_WRITE(tetrisp2_coincounter_w)                               // Coin Counter
r22733r22734
409409   AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_SHARE("vram_rot") // Rotation
410410   AM_RANGE(0x900000, 0x903fff) AM_READ(rockn_nvram_r) AM_WRITE(tetrisp2_nvram_w) AM_SHARE("nvram")    // NVRAM
411411   AM_RANGE(0xa30000, 0xa30001) AM_READWRITE(rockn_soundvolume_r, rockn_soundvolume_w)         // Sound Volume
412   AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)   // Sound
412   AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)   // Sound
413413   AM_RANGE(0xa44000, 0xa44001) AM_READWRITE(rockn_adpcmbank_r, rockn_adpcmbank_w)             // Sound Bank
414414   AM_RANGE(0xa48000, 0xa48001) AM_NOP                                                         // YMZ280 Reset
415415   AM_RANGE(0xb00000, 0xb00001) AM_WRITE(tetrisp2_coincounter_w)                               // Coin Counter
r22733r22734
443443   AM_RANGE(0x808000, 0x809fff) AM_RAM                                                         // ???
444444   AM_RANGE(0x900000, 0x903fff) AM_READ(rockn_nvram_r) AM_WRITE(tetrisp2_nvram_w) AM_SHARE("nvram")    // NVRAM
445445   AM_RANGE(0xa30000, 0xa30001) AM_READWRITE(rockn_soundvolume_r, rockn_soundvolume_w)         // Sound Volume
446   AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)   // Sound
446   AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)   // Sound
447447   AM_RANGE(0xa44000, 0xa44001) AM_READWRITE(rockn_adpcmbank_r, rockn2_adpcmbank_w)            // Sound Bank
448448   AM_RANGE(0xa48000, 0xa48001) AM_WRITENOP                                                    // YMZ280 Reset
449449   AM_RANGE(0xb00000, 0xb00001) AM_WRITE(tetrisp2_coincounter_w)                               // Coin Counter
r22733r22734
477477//  AM_RANGE(0x808000, 0x809fff) AM_RAM                                                         // ???
478478   AM_RANGE(0x900000, 0x903fff) AM_READ(rockn_nvram_r) AM_WRITE(tetrisp2_nvram_w) AM_SHARE("nvram")    // NVRAM
479479   AM_RANGE(0xa30000, 0xa30001) AM_READWRITE(rockn_soundvolume_r, rockn_soundvolume_w)         // Sound Volume
480   AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)   // Sound
480   AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)   // Sound
481481   AM_RANGE(0xa44000, 0xa44001) AM_READWRITE(rockn_adpcmbank_r, rockn_adpcmbank_w)             // Sound Bank
482482   AM_RANGE(0xa48000, 0xa48001) AM_WRITENOP                                                    // YMZ280 Reset
483483   AM_RANGE(0xa00000, 0xa00001) AM_WRITE(rocknms_main2sub_w)                                   // MAIN -> SUB Communication
r22733r22734
512512//  AM_RANGE(0x808000, 0x809fff) AM_RAM                                                         // ???
513513   AM_RANGE(0x900000, 0x907fff) AM_RAM                                                         // NVRAM
514514   AM_RANGE(0xa30000, 0xa30001) AM_WRITE(rockn_soundvolume_w)                                  // Sound Volume
515   AM_RANGE(0xa40000, 0xa40003) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x00ff)                  // Sound
515   AM_RANGE(0xa40000, 0xa40003) AM_DEVWRITE8("ymz", ymz280b_device, write, 0x00ff)             // Sound
516516   AM_RANGE(0xa44000, 0xa44001) AM_WRITE(rockn_adpcmbank_w)                                    // Sound Bank
517517   AM_RANGE(0xa48000, 0xa48001) AM_WRITENOP                                                    // YMZ280 Reset
518518   AM_RANGE(0xb00000, 0xb00001) AM_WRITE(rocknms_sub2main_w)                                   // MAIN <- SUB Communication
r22733r22734
618618//  AM_RANGE(0xa48000, 0xa48001) AM_WRITENOP    // PC?
619619//  AM_RANGE(0xa4c000, 0xa4c001) AM_WRITENOP    // PC?
620620   AM_RANGE(0xa50000, 0xa50001) AM_READWRITE( soundlatch_word_r, stepstag_soundlatch_word_w )
621   AM_RANGE(0xa60000, 0xa60003) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x00ff)                  // Sound
621   AM_RANGE(0xa60000, 0xa60003) AM_DEVWRITE8("ymz", ymz280b_device, write, 0x00ff)             // Sound
622622
623623   AM_RANGE(0xb00000, 0xb00001) AM_WRITENOP                                                    // Coin Counter plus other things
624624   AM_RANGE(0xb20000, 0xb20001) AM_WRITENOP                                                    // protection related?
trunk/src/mame/drivers/bfm_sc5.c
r22733r22734
191191   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
192192}
193193
194static const ymz280b_interface ymz280b_config =
195{
196   DEVCB_DRIVER_LINE_MEMBER(bfm_sc5_state,bfm_sc5_ym_irqhandler)
197};
198194
199195
200
201196void bfm_sc5_duart_irq_handler(device_t *device, int state, UINT8 vector)
202197{
203198   printf("bfm_sc5_duart_irq_handler\n");
r22733r22734
253248   MCFG_DEFAULT_LAYOUT(layout_bfm_sc5)
254249
255250   MCFG_SOUND_ADD("ymz", YMZ280B, 16000000) // ?? Mhz
256   MCFG_SOUND_CONFIG(ymz280b_config)
251   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(bfm_sc5_state, bfm_sc5_ym_irqhandler))
257252   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
258253MACHINE_CONFIG_END
trunk/src/mame/drivers/firebeat.c
r22733r22734
18521852   AM_RANGE(0x74000000, 0x740003ff) AM_READWRITE(ppc_spu_share_r, ppc_spu_share_w) // SPU shared RAM
18531853   AM_RANGE(0x7d000200, 0x7d00021f) AM_READ(cabinet_r)
18541854   AM_RANGE(0x7d000340, 0x7d000347) AM_READ(sensor_r)
1855   AM_RANGE(0x7d000400, 0x7d000403) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0xffff0000)
1855   AM_RANGE(0x7d000400, 0x7d000403) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xffff0000)
18561856   AM_RANGE(0x7d000800, 0x7d000803) AM_READ(input_r)
18571857   AM_RANGE(0x7d400000, 0x7d5fffff) AM_READWRITE(flashram_r, flashram_w)
18581858   AM_RANGE(0x7d800000, 0x7dbfffff) AM_READWRITE(soundflash_r, soundflash_w)
r22733r22734
18971897{
18981898}
18991899
1900static const ymz280b_interface ymz280b_intf =
1901{
1902   DEVCB_DRIVER_LINE_MEMBER(firebeat_state,sound_irq_callback),         // irq
1903   DEVCB_DRIVER_MEMBER(firebeat_state,soundram_r)
1904};
1905
19061900static INPUT_PORTS_START(ppp)
19071901   PORT_START("IN0")
19081902   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )            // Left
r22733r22734
20952089   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
20962090
20972091   MCFG_SOUND_ADD("ymz", YMZ280B, 16934400)
2098   MCFG_SOUND_CONFIG(ymz280b_intf)
2092   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(firebeat_state, sound_irq_callback))
2093   MCFG_YMZ280B_EXT_READ_HANDLER(READ8(firebeat_state, soundram_r))
20992094   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
21002095   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
21012096
r22733r22734
21482143   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
21492144
21502145   MCFG_SOUND_ADD("ymz", YMZ280B, 16934400)
2151   MCFG_SOUND_CONFIG(ymz280b_intf)
2146   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(firebeat_state, sound_irq_callback))
2147   MCFG_YMZ280B_EXT_READ_HANDLER(READ8(firebeat_state, soundram_r))
21522148   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
21532149   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
21542150
trunk/src/mame/drivers/realbrk.c
r22733r22734
161161   AM_RANGE(0x604000, 0x604fff) AM_RAM_WRITE(realbrk_vram_2_w) AM_SHARE("vram_2")  // Text         (2)
162162   AM_RANGE(0x606000, 0x60600f) AM_RAM_WRITE(realbrk_vregs_w) AM_SHARE("vregs")    // Scroll + Video Regs
163163   AM_RANGE(0x605000, 0x61ffff) AM_RAM                                         //
164   AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0xff00)   // YMZ280
164   AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xff00)   // YMZ280
165165   AM_RANGE(0xfe0000, 0xfeffff) AM_RAM                                         // RAM
166166   AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w)  // TMP68301 Registers
167167ADDRESS_MAP_END
trunk/src/mame/drivers/deco156.c
r22733r22734
170170   AM_RANGE(0x160000, 0x161fff) AM_READWRITE(wcvol95_spriteram_r, wcvol95_spriteram_w)
171171   AM_RANGE(0x170000, 0x170003) AM_NOP // Irq ack?
172172   AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(wcvol95_nonbuffered_palette_w) AM_SHARE("paletteram")
173   AM_RANGE(0x1a0000, 0x1a0007) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x000000ff)
173   AM_RANGE(0x1a0000, 0x1a0007) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x000000ff)
174174ADDRESS_MAP_END
175175
176176
r22733r22734
314314   logerror("sound irq\n");
315315}
316316
317static const ymz280b_interface ymz280b_intf =
318{
319   DEVCB_DRIVER_LINE_MEMBER(deco156_state,sound_irq_gen)
320};
321
322317INTERRUPT_GEN_MEMBER(deco156_state::deco32_vbl_interrupt)
323318{
324319   device.execute().set_input_line(ARM_IRQ_LINE, HOLD_LINE);
r22733r22734
421416   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
422417
423418   MCFG_SOUND_ADD("ymz", YMZ280B, 28000000 / 2)
424   MCFG_SOUND_CONFIG(ymz280b_intf)
419   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(deco156_state, sound_irq_gen))
425420   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
426421   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
427422MACHINE_CONFIG_END
trunk/src/mame/drivers/bishi.c
r22733r22734
153153   AM_RANGE(0x840000, 0x840007) AM_DEVWRITE_LEGACY("k056832", k056832_b_word_w)    // VSCCS
154154   AM_RANGE(0x850000, 0x85001f) AM_DEVWRITE_LEGACY("k054338", k054338_word_w)  // CLTC
155155   AM_RANGE(0x870000, 0x8700ff) AM_DEVWRITE_LEGACY("k055555", k055555_word_w)  // PCU2
156   AM_RANGE(0x880000, 0x880003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0xff00)
156   AM_RANGE(0x880000, 0x880003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xff00)
157157   AM_RANGE(0xa00000, 0xa01fff) AM_DEVREADWRITE_LEGACY("k056832", k056832_ram_word_r, k056832_ram_word_w)  // Graphic planes
158158   AM_RANGE(0xb00000, 0xb03fff) AM_RAM_WRITE(paletteram_xbgr_word_be_w) AM_SHARE("paletteram")
159159   AM_RANGE(0xb04000, 0xb047ff) AM_READ(bishi_mirror_r)    // bug in the ram/rom test?
r22733r22734
363363   m_maincpu->set_input_line(M68K_IRQ_1, (state) ? ASSERT_LINE : CLEAR_LINE);
364364}
365365
366static const ymz280b_interface ymz280b_intf =
367{
368   DEVCB_DRIVER_LINE_MEMBER(bishi_state,sound_irq_gen)
369};
370366
371
372367static const k056832_interface bishi_k056832_intf =
373368{
374369   "gfx1", 0,
r22733r22734
426421   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
427422
428423   MCFG_SOUND_ADD("ymz", YMZ280B, SOUND_CLOCK) /* 16.9344MHz */
429   MCFG_SOUND_CONFIG(ymz280b_intf)
424   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(bishi_state, sound_irq_gen))
430425   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
431426   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
432427MACHINE_CONFIG_END
trunk/src/mame/drivers/deco_mlc.c
r22733r22734
324324   AM_RANGE(0x0440008, 0x044000b) AM_READ(mlc_440008_r) AM_MIRROR(0xff000000)
325325   AM_RANGE(0x044001c, 0x044001f) AM_READWRITE(mlc_44001c_r, mlc_44001c_w) AM_MIRROR(0xff000000)
326326   AM_RANGE(0x0500000, 0x0500003) AM_WRITE(avengrs_eprom_w) AM_MIRROR(0xff000000)
327   AM_RANGE(0x0600000, 0x0600007) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0xff000000) AM_MIRROR(0xff000000)
327   AM_RANGE(0x0600000, 0x0600007) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xff000000) AM_MIRROR(0xff000000)
328328   AM_RANGE(0x070f000, 0x070ffff) AM_READWRITE(stadhr96_prot_146_r, stadhr96_prot_146_w) AM_MIRROR(0xff000000)
329329ADDRESS_MAP_END
330330
trunk/src/mame/drivers/bfm_swp.c
r22733r22734
137137{
138138}
139139
140static const ymz280b_interface ymz280b_config =
141{
142   DEVCB_DRIVER_LINE_MEMBER(bfm_swp_state,irqhandler)
143};
144140
145
146141READ32_MEMBER(bfm_swp_state::bfm_swp_mem_r)
147142{
148143   int pc = space.device().safe_pc();
r22733r22734
223218   MCFG_SPEAKER_STANDARD_MONO("mono")
224219
225220   MCFG_SOUND_ADD("ymz", YMZ280B, 10000000 )
226   MCFG_SOUND_CONFIG(ymz280b_config)
221   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(bfm_swp_state, irqhandler))
227222   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
228223MACHINE_CONFIG_END
229224
trunk/src/mame/drivers/midas.c
r22733r22734
288288   AM_RANGE(0xb40000, 0xb40001) AM_READ(ret_ffff )
289289   AM_RANGE(0xb60000, 0xb60001) AM_READ(ret_ffff )
290290
291   AM_RANGE(0xb80008, 0xb8000b) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff )
291   AM_RANGE(0xb80008, 0xb8000b) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff )
292292
293293   AM_RANGE(0xba0000, 0xba0001) AM_READ_PORT("START3")
294294   AM_RANGE(0xbc0000, 0xbc0001) AM_READ_PORT("PLAYER3")
r22733r22734
367367   AM_RANGE(0xb40000, 0xb40001) AM_READ(ret_ffff )
368368   AM_RANGE(0xb60000, 0xb60001) AM_READ(ret_ffff )
369369
370   AM_RANGE(0xb80008, 0xb8000b) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff )
370   AM_RANGE(0xb80008, 0xb8000b) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff )
371371
372372   AM_RANGE(0xba0000, 0xba0001) AM_READ_PORT("IN1")
373373   AM_RANGE(0xbc0000, 0xbc0001) AM_READ_PORT("HAMMER")
r22733r22734
694694   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
695695}
696696
697static const ymz280b_interface ymz280b_config =
698{
699   DEVCB_DRIVER_LINE_MEMBER(midas_state,livequiz_irqhandler)
700};
701
702697static MACHINE_CONFIG_START( livequiz, midas_state )
703698
704699   /* basic machine hardware */
r22733r22734
723718   /* sound hardware */
724719   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
725720   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
726   MCFG_SOUND_CONFIG(ymz280b_config)
721   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(midas_state, livequiz_irqhandler))
727722   MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
728723   MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
729724MACHINE_CONFIG_END
r22733r22734
756751   /* sound hardware */
757752   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
758753   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
759   MCFG_SOUND_CONFIG(ymz280b_config)
754   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(midas_state, livequiz_irqhandler))
760755   MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
761756   MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
762757MACHINE_CONFIG_END
trunk/src/mame/drivers/coinmvga.c
r22733r22734
374374
375375   AM_RANGE(0x600000, 0x600001) AM_WRITE(ramdac_bg_w)
376376   AM_RANGE(0x600004, 0x600005) AM_WRITE(ramdac_fg_w)
377   AM_RANGE(0x600008, 0x600009) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0xffff)
377   AM_RANGE(0x600008, 0x600009) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xffff)
378378   AM_RANGE(0x610000, 0x61000f) AM_RAM //touch screen i/o
379379
380380   AM_RANGE(0x700000, 0x7fffff) AM_ROM AM_REGION("maincpu", 0) // ?
r22733r22734
655655*    Sound Interface     *
656656*************************/
657657
658static const ymz280b_interface ymz280b_intf =
659{
660   DEVCB_NULL   // irq ?
661};
662
663658INTERRUPT_GEN_MEMBER(coinmvga_state::vblank_irq)
664659{
665660   //printf("1\n");
r22733r22734
698693   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
699694
700695   MCFG_SOUND_ADD("ymz", YMZ280B, SND_CLOCK)
701   MCFG_SOUND_CONFIG(ymz280b_intf)
702696   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
703697   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
704698MACHINE_CONFIG_END
trunk/src/mame/drivers/galpani3.c
r22733r22734
493493   AM_RANGE(0xf00012, 0xf00013) AM_READ_PORT("P2")
494494   AM_RANGE(0xf00014, 0xf00015) AM_READ_PORT("COIN")
495495   AM_RANGE(0xf00016, 0xf00017) AM_NOP // ? read, but overwritten
496   AM_RANGE(0xf00020, 0xf00023) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x00ff)  // sound
496   AM_RANGE(0xf00020, 0xf00023) AM_DEVWRITE8("ymz", ymz280b_device, write, 0x00ff)     // sound
497497   AM_RANGE(0xf00040, 0xf00041) AM_READWRITE(watchdog_reset16_r, watchdog_reset16_w)   // watchdog
498498   AM_RANGE(0xf00050, 0xf00051) AM_NOP // ? written once (3rd opcode, $30.b)
499499ADDRESS_MAP_END
500500
501501
502static const ymz280b_interface ymz280b_intf =
503{
504   DEVCB_NULL   // irq ?
505};
506
507502static MACHINE_CONFIG_START( galpani3, galpani3_state )
508503   MCFG_CPU_ADD("maincpu", M68000, XTAL_28_63636MHz/2) // Confirmed from PCB
509504   MCFG_CPU_PROGRAM_MAP(galpani3_map)
r22733r22734
540535   MCFG_SPEAKER_STANDARD_MONO("mono")
541536
542537   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_33_333MHz / 2)  // Confirmed from PCB
543   MCFG_SOUND_CONFIG(ymz280b_intf)
544538   MCFG_SOUND_ROUTE(0, "mono", 1.0)
545539   MCFG_SOUND_ROUTE(1, "mono", 1.0)
546540MACHINE_CONFIG_END
trunk/src/mame/drivers/toaplan2.c
r22733r22734
14311431   AM_RANGE(0x46, 0x46) AM_WRITE(batrider_clear_nmi_w)
14321432   AM_RANGE(0x48, 0x48) AM_READ(soundlatch_byte_r)
14331433   AM_RANGE(0x4a, 0x4a) AM_READ(soundlatch2_byte_r)
1434   AM_RANGE(0x80, 0x81) AM_DEVREADWRITE_LEGACY("ymz", ymz280b_r, ymz280b_w)
1434   AM_RANGE(0x80, 0x81) AM_DEVREADWRITE("ymz", ymz280b_device, read, write)
14351435ADDRESS_MAP_END
14361436
14371437
r22733r22734
29842984   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
29852985}
29862986
2987static const ymz280b_interface ymz280b_config =
2988{
2989   DEVCB_DRIVER_LINE_MEMBER(toaplan2_state,bbakraid_irqhandler)
2990};
29912987
2992
29932988static MACHINE_CONFIG_START( tekipaki, toaplan2_state )
29942989
29952990   /* basic machine hardware */
r22733r22734
38453840   MCFG_SPEAKER_STANDARD_MONO("mono")
38463841
38473842   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
3848   MCFG_SOUND_CONFIG(ymz280b_config)
3843   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(toaplan2_state, bbakraid_irqhandler))
38493844   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
38503845MACHINE_CONFIG_END
38513846
trunk/src/mame/drivers/cave.c
r22733r22734
423423static ADDRESS_MAP_START( dfeveron_map, AS_PROGRAM, 16, cave_state )
424424   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                                                 // ROM
425425   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                                 // RAM
426   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)                   // YMZ280
426   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)                   // YMZ280
427427/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_SHARE("spriteram")       // Sprites
428428/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_SHARE("spriteram_2")                         // Sprites?
429429/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_SHARE("vram.0")         // Layer 0
r22733r22734
448448static ADDRESS_MAP_START( ddonpach_map, AS_PROGRAM, 16, cave_state )
449449   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                                                 // ROM
450450   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                                 // RAM
451   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)                   // YMZ280
451   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)           // YMZ280
452452/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_SHARE("spriteram")       // Sprites
453453/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_SHARE("spriteram_2")                         // Sprites?
454454/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_SHARE("vram.0")         // Layer 0
r22733r22734
524524static ADDRESS_MAP_START( esprade_map, AS_PROGRAM, 16, cave_state )
525525   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                                                 // ROM
526526   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                                 // RAM
527   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)                   // YMZ280
527   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)           // YMZ280
528528/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_SHARE("spriteram")       // Sprites
529529/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_SHARE("spriteram_2")                         // Sprites?
530530/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_SHARE("vram.0")         // Layer 0
r22733r22734
549549static ADDRESS_MAP_START( gaia_map, AS_PROGRAM, 16, cave_state )
550550   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                                                 // ROM
551551   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                                 // RAM
552   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)                   // YMZ280
552   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)           // YMZ280
553553   AM_RANGE(0x400000, 0x407fff) AM_RAM AM_SHARE("spriteram")       // Sprite bank 1
554554   AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_SHARE("spriteram_2")                         // Sprite bank 2
555555   AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_SHARE("vram.0")         // Layer 0
r22733r22734
586586/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_SHARE("vram.0")         // Layer 0
587587/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_SHARE("vram.1")         // Layer 1
588588/**/AM_RANGE(0x700000, 0x707fff) AM_RAM_WRITE(cave_vram_2_w) AM_SHARE("vram.2")         // Layer 2
589   AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)                   // YMZ280
589   AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)           // YMZ280
590590/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_SHARE("vctrl.0")                             // Layer 0 Control
591591/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_SHARE("vctrl.1")                             // Layer 1 Control
592592/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_SHARE("vctrl.2")                             // Layer 2 Control
r22733r22734
700700   AM_RANGE(0x1c0000, 0x1c0007) AM_READ(cave_irq_cause_r)                                                  // IRQ Cause
701701   AM_RANGE(0x1c0000, 0x1c007f) AM_WRITEONLY AM_SHARE("videoregs")                         // Video Regs
702702   AM_RANGE(0x200000, 0x207fff) AM_WRITEONLY AM_SHARE("paletteram")    // Palette
703//  AM_RANGE(0x240000, 0x240003) AM_DEVREAD8_LEGACY("ymz", ymz280b_r, 0x00ff)                                     // YMZ280
704   AM_RANGE(0x240000, 0x240003) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x00ff)                                  // YMZ280
703//  AM_RANGE(0x240000, 0x240003) AM_DEVREAD8("ymz", ymz280b_device, read, 0x00ff)                           // YMZ280
704   AM_RANGE(0x240000, 0x240003) AM_DEVWRITE8("ymz", ymz280b_device, write, 0x00ff)                         // YMZ280
705705   AM_RANGE(0x280000, 0x280001) AM_READ_PORT("IN0")                                                        // Inputs + ???
706706   AM_RANGE(0x280002, 0x280003) AM_READ_PORT("IN1")                                                        // Inputs + EEPROM
707707   AM_RANGE(0x280008, 0x280009) AM_WRITE(korokoro_leds_w)                                                  // Leds
r22733r22734
716716   AM_RANGE(0x140000, 0x140005) AM_WRITEONLY AM_SHARE("vctrl.0")                           // Layer 0 Control
717717   AM_RANGE(0x180000, 0x187fff) AM_WRITEONLY AM_SHARE("spriteram") // Sprites
718718   AM_RANGE(0x200000, 0x207fff) AM_WRITEONLY AM_SHARE("paletteram")    // Palette
719   AM_RANGE(0x240000, 0x240003) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x00ff)                                  // YMZ280
719   AM_RANGE(0x240000, 0x240003) AM_DEVWRITE8("ymz", ymz280b_device, write, 0x00ff)                         // YMZ280
720720   AM_RANGE(0x280000, 0x280001) AM_READ_PORT("IN0")                                                        // Inputs + ???
721721   AM_RANGE(0x280002, 0x280003) AM_READ_PORT("IN1")                                                        // Inputs + EEPROM
722722   AM_RANGE(0x280008, 0x280009) AM_WRITE(korokoro_leds_w)                                                  // Leds
r22733r22734
991991static ADDRESS_MAP_START( uopoko_map, AS_PROGRAM, 16, cave_state )
992992   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                                                 // ROM
993993   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                                 // RAM
994   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x00ff)                   // YMZ280
994   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x00ff)                   // YMZ280
995995/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_SHARE("spriteram")       // Sprites
996996/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_SHARE("spriteram_2")                         // Sprites?
997997/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_SHARE("vram.0")         // Layer 0
r22733r22734
17971797   m_agallet_vblank_irq = 0;
17981798}
17991799
1800static const ymz280b_interface ymz280b_intf =
1801{
1802   DEVCB_DRIVER_LINE_MEMBER(cave_state,sound_irq_gen)
1803};
1804
18051800WRITE_LINE_MEMBER(cave_state::irqhandler)
18061801{
18071802   m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
r22733r22734
18521847   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
18531848
18541849   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
1855   MCFG_SOUND_CONFIG(ymz280b_intf)
1850   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(cave_state, sound_irq_gen))
18561851   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
18571852   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
18581853MACHINE_CONFIG_END
r22733r22734
18941889   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
18951890
18961891   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
1897   MCFG_SOUND_CONFIG(ymz280b_intf)
1892   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(cave_state, sound_irq_gen))
18981893   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
18991894   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
19001895MACHINE_CONFIG_END
r22733r22734
19861981   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
19871982
19881983   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
1989   MCFG_SOUND_CONFIG(ymz280b_intf)
1984   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(cave_state, sound_irq_gen))
19901985   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
19911986   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
19921987MACHINE_CONFIG_END
r22733r22734
20262021   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
20272022
20282023   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
2029   MCFG_SOUND_CONFIG(ymz280b_intf)
2024   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(cave_state, sound_irq_gen))
20302025   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
20312026   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
20322027MACHINE_CONFIG_END
r22733r22734
20672062   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
20682063
20692064   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
2070   MCFG_SOUND_CONFIG(ymz280b_intf)
2065   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(cave_state, sound_irq_gen))
20712066   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
20722067   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
20732068MACHINE_CONFIG_END
r22733r22734
21632158   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
21642159
21652160   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
2166   MCFG_SOUND_CONFIG(ymz280b_intf)
2161   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(cave_state, sound_irq_gen))
21672162   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
21682163   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
21692164MACHINE_CONFIG_END
r22733r22734
25442539   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
25452540
25462541   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
2547   MCFG_SOUND_CONFIG(ymz280b_intf)
2542   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(cave_state, sound_irq_gen))
25482543   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
25492544   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
25502545MACHINE_CONFIG_END
trunk/src/mame/drivers/tecmosys.c
r22733r22734
351351   AM_RANGE(0x30, 0x30) AM_WRITE(tecmosys_z80_bank_w)
352352   AM_RANGE(0x40, 0x40) AM_READ(soundlatch_byte_r)
353353   AM_RANGE(0x50, 0x50) AM_WRITE(soundlatch2_byte_w)
354   AM_RANGE(0x60, 0x61) AM_DEVREADWRITE_LEGACY("ymz", ymz280b_r, ymz280b_w)
354   AM_RANGE(0x60, 0x61) AM_DEVREADWRITE("ymz", ymz280b_device, read, write)
355355ADDRESS_MAP_END
356356
357357
trunk/src/mame/drivers/jchan.c
r22733r22734
468468   AM_RANGE(0x700000, 0x703fff) AM_RAM_WRITE(jchan_suprnova_sprite32_2_w) AM_SHARE("spriteram_2")
469469   AM_RANGE(0x780000, 0x78003f) AM_RAM_WRITE(jchan_suprnova_sprite32regs_2_w) AM_SHARE("sprregs_2")
470470
471   AM_RANGE(0x800000, 0x800003) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x00ff) // sound
471   AM_RANGE(0x800000, 0x800003) AM_DEVWRITE8("ymz", ymz280b_device, write, 0x00ff) // sound
472472
473473   AM_RANGE(0xa00000, 0xa00001) AM_READWRITE(watchdog_reset16_r, watchdog_reset16_w)   // watchdog
474474ADDRESS_MAP_END
r22733r22734
577577INPUT_PORTS_END
578578
579579
580/* sound stuff */
581
582static const ymz280b_interface ymz280b_intf =
583{
584   DEVCB_NULL   // irq ?
585};
586
587
588580/* machine driver */
589581
590582static MACHINE_CONFIG_START( jchan, jchan_state )
r22733r22734
626618   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
627619
628620   MCFG_SOUND_ADD("ymz", YMZ280B, 16000000)
629   MCFG_SOUND_CONFIG(ymz280b_intf)
630621   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
631622   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
632623MACHINE_CONFIG_END
trunk/src/mame/drivers/bfm_sc4h.c
r22733r22734
189189                     return 0x0000;//space.machine().rand();;
190190
191191                  case 0x1244:
192                     return ymz280b_r(m_ymz,space,0);
192                     return m_ymz->read(space,0);
193193
194194                  case 0x1246:
195                     return ymz280b_r(m_ymz,space,1);
195                     return m_ymz->read(space,1);
196196
197197                  default:
198198                     logerror("%08x maincpu read access offset %08x mem_mask %04x cs %d (LAMPS etc.)\n", pc, offset*2, mem_mask, cs);
r22733r22734
332332                     break;
333333
334334                  case 0x1248:
335                     ymz280b_w(m_ymz,space,0, data & 0xff);
335                     m_ymz->write(space,0, data & 0xff);
336336                     break;
337337
338338                  case 0x124a:
339                     ymz280b_w(m_ymz,space,1, data & 0xff);
339                     m_ymz->write(space,1, data & 0xff);
340340                     break;
341341
342342                  case 0x1330:
r22733r22734
625625   logerror("YMZ280 is generating an interrupt. State=%08x\n",state);
626626}
627627
628static const ymz280b_interface ymz280b_config =
629{
630   DEVCB_DRIVER_LINE_MEMBER(sc4_state,bfm_sc4_irqhandler)
631};
632628
633629
634
635630void bfm_sc4_duart_irq_handler(device_t *device, int state, UINT8 vector)
636631{
637632   sc4_state *drvstate = device->machine().driver_data<sc4_state>();
r22733r22734
760755   MCFG_DEFAULT_LAYOUT(layout_bfm_sc4)
761756
762757   MCFG_SOUND_ADD("ymz", YMZ280B, 16000000) // ?? Mhz
763   MCFG_SOUND_CONFIG(ymz280b_config)
758   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(sc4_state, bfm_sc4_irqhandler))
764759   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
765760MACHINE_CONFIG_END
766761
trunk/src/mame/drivers/maygayep.c
r22733r22734
105105{
106106}
107107
108static const ymz280b_interface ymz280b_config =
109{
110   DEVCB_DRIVER_LINE_MEMBER(maygayep_state,irqhandler)
111};
112108
113
114109static MACHINE_CONFIG_START( maygayep, maygayep_state )
115110   MCFG_CPU_ADD("maincpu", H83002, 16000000 )
116111   MCFG_CPU_PROGRAM_MAP( maygayep_map )
r22733r22734
118113   MCFG_SPEAKER_STANDARD_MONO("mono")
119114
120115   MCFG_SOUND_ADD("ymz", YMZ280B, 10000000 )
121   MCFG_SOUND_CONFIG(ymz280b_config)
116   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(maygayep_state, irqhandler))
122117   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
123118MACHINE_CONFIG_END
124119
trunk/src/mame/drivers/zn.c
r22733r22734
25112511
25122512static ADDRESS_MAP_START( cbaj_z80_port_map, AS_IO, 8, zn_state )
25132513   ADDRESS_MAP_GLOBAL_MASK(0xff)
2514   AM_RANGE( 0x84, 0x85 ) AM_DEVREADWRITE_LEGACY("ymz", ymz280b_r, ymz280b_w )
2514   AM_RANGE( 0x84, 0x85 ) AM_DEVREADWRITE("ymz", ymz280b_device, read, write )
25152515   AM_RANGE( 0x90, 0x90 ) AM_READWRITE(cbaj_z80_latch_r, cbaj_z80_latch_w )
25162516   AM_RANGE( 0x91, 0x91 ) AM_READ(cbaj_z80_ready_r )
25172517ADDRESS_MAP_END
trunk/src/mame/drivers/backfire.c
r22733r22734
326326//  AM_RANGE(0x1e8000, 0x1e8003) AM_READ(backfire_wheel1_r)
327327//  AM_RANGE(0x1e8004, 0x1e8007) AM_READ(backfire_wheel2_r)
328328
329   AM_RANGE(0x1c0000, 0x1c0007) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0x000000ff)
329   AM_RANGE(0x1c0000, 0x1c0007) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0x000000ff)
330330ADDRESS_MAP_END
331331
332332
r22733r22734
438438   logerror("sound irq\n");
439439}
440440
441static const ymz280b_interface ymz280b_intf =
442{
443   DEVCB_DRIVER_LINE_MEMBER(backfire_state,sound_irq_gen)
444};
445
446441INTERRUPT_GEN_MEMBER(backfire_state::deco32_vbl_interrupt)
447442{
448443   device.execute().set_input_line(ARM_IRQ_LINE, HOLD_LINE);
r22733r22734
545540   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
546541
547542   MCFG_SOUND_ADD("ymz", YMZ280B, 28000000 / 2)
548   MCFG_SOUND_CONFIG(ymz280b_intf)
543   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(backfire_state, sound_irq_gen))
549544   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
550545   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
551546MACHINE_CONFIG_END
trunk/src/mame/drivers/seibuspi.c
r22733r22734
11451145   AM_RANGE(0x00000090, 0x00000097) AM_RAM /* Unknown */
11461146   AM_RANGE(0x00000400, 0x00000403) AM_READNOP AM_WRITE(input_select_w)
11471147   AM_RANGE(0x00000404, 0x00000407) AM_WRITE(sys386f2_eeprom_w)
1148   AM_RANGE(0x00000408, 0x0000040f) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x000000ff)
1148   AM_RANGE(0x00000408, 0x0000040f) AM_DEVWRITE8("ymz", ymz280b_device, write, 0x000000ff)
11491149   AM_RANGE(0x00000484, 0x00000487) AM_WRITE(palette_dma_start_w)
11501150   AM_RANGE(0x00000490, 0x00000493) AM_WRITE(video_dma_length_w)
11511151   AM_RANGE(0x00000494, 0x00000497) AM_WRITE(video_dma_address_w)
11521152   AM_RANGE(0x00000500, 0x0000054f) AM_RAM /* Unknown */
11531153   AM_RANGE(0x00000560, 0x00000563) AM_WRITE(sprite_dma_start_w)
1154   AM_RANGE(0x00000600, 0x00000607) AM_DEVREAD8_LEGACY("ymz", ymz280b_r, 0x000000ff)
1154   AM_RANGE(0x00000600, 0x00000607) AM_DEVREAD8("ymz", ymz280b_device, read, 0x000000ff)
11551155   AM_RANGE(0x00000608, 0x0000060b) AM_READ(spi_unknown_r)
11561156   AM_RANGE(0x0000060c, 0x0000060f) AM_READ(spi_controls1_r)   /* Player controls */
11571157   AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_SHARE("spimainram")
trunk/src/mame/drivers/suprnova.c
r22733r22734
685685   /* In between is write only */
686686   AM_RANGE(0x0040000c, 0x0040000f) AM_READ_PORT("40000c")
687687   AM_RANGE(0x00800000, 0x00801fff) AM_RAM AM_SHARE("nvram") /* 'backup' RAM */
688   AM_RANGE(0x00c00000, 0x00c00003) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0xffff0000) /* ymz280_w (sound) */
688   AM_RANGE(0x00c00000, 0x00c00003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xffff0000) /* ymz280_w (sound) */
689689   AM_RANGE(0x01000000, 0x0100000f) AM_DEVREADWRITE8("rtc", msm6242_device, read, write, 0xffffffff)
690690   AM_RANGE(0x01800000, 0x01800003) AM_WRITE(skns_hit2_w)
691691   AM_RANGE(0x02000000, 0x02003fff) AM_RAM AM_SHARE("spriteram") /* sprite ram */
r22733r22734
741741
742742/***** MACHINE DRIVER *****/
743743
744static const ymz280b_interface ymz280b_intf =
745{
746   DEVCB_NULL   // irq ?
747};
748
749
750744static MSM6242_INTERFACE( rtc_intf )
751745{
752746   DEVCB_NULL
r22733r22734
788782   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
789783
790784   MCFG_SOUND_ADD("ymz", YMZ280B, 33333333 / 2)
791   MCFG_SOUND_CONFIG(ymz280b_intf)
792785   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
793786   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
794787MACHINE_CONFIG_END
trunk/src/mame/drivers/sigmab98.c
r22733r22734
521521static ADDRESS_MAP_START( gegege_io_map, AS_IO, 8, sigmab98_state )
522522   ADDRESS_MAP_GLOBAL_MASK(0xff)
523523
524   AM_RANGE( 0x00, 0x01 ) AM_DEVWRITE_LEGACY("ymz", ymz280b_w )
524   AM_RANGE( 0x00, 0x01 ) AM_DEVWRITE("ymz", ymz280b_device, write )
525525
526526   AM_RANGE( 0xa0, 0xa1 ) AM_READWRITE(regs_r,  regs_w )
527527//  AM_RANGE( 0xa2, 0xa3 )
trunk/src/mame/drivers/gunpey.c
r22733r22734
12921292   AM_RANGE(0x7f40, 0x7f45) AM_READ8(gunpey_inputs_r,0xffff)
12931293
12941294   AM_RANGE(0x7f48, 0x7f49) AM_WRITE8(gunpey_output_w,0x00ff)
1295   AM_RANGE(0x7f80, 0x7f81) AM_DEVREADWRITE8_LEGACY("ymz", ymz280b_r, ymz280b_w, 0xffff)
1295   AM_RANGE(0x7f80, 0x7f81) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xffff)
12961296
12971297   AM_RANGE(0x7f88, 0x7f89) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff)
12981298
r22733r22734
13161316   logerror("sound irq\n");
13171317}
13181318
1319static const ymz280b_interface ymz280b_intf =
1320{
1321   DEVCB_DRIVER_LINE_MEMBER(gunpey_state,sound_irq_gen)
1322};
13231319
1324
13251320/***************************************************************************************/
13261321
13271322static INPUT_PORTS_START( gunpey )
r22733r22734
14741469   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25)
14751470
14761471   MCFG_SOUND_ADD("ymz", YMZ280B, XTAL_16_9344MHz)
1477   MCFG_SOUND_CONFIG(ymz280b_intf)
1472   MCFG_YMZ280B_IRQ_HANDLER(WRITELINE(gunpey_state, sound_irq_gen))
14781473   MCFG_SOUND_ROUTE(0, "lspeaker", 0.25)
14791474   MCFG_SOUND_ROUTE(1, "rspeaker", 0.25)
14801475MACHINE_CONFIG_END

Previous 199869 Revisions Next


© 1997-2024 The MAME Team