Previous 199869 Revisions Next

r22752 Friday 10th May, 2013 at 21:38:13 UTC by smf
modernized the YM2608 [smf]
[src/emu/sound]2608intf.c 2608intf.h
[src/mame/drivers]bbusters.c itech8.c pipedrm.c tail2nos.c wc90.c
[src/mess/drivers]pc8801.c
[src/mess/machine]pc9801_118.c pc9801_86.c

trunk/src/mame/drivers/pipedrm.c
r22751r22752
330330
331331static ADDRESS_MAP_START( hatris_sound_portmap, AS_IO, 8, pipedrm_state )
332332   ADDRESS_MAP_GLOBAL_MASK(0xff)
333   AM_RANGE(0x00, 0x03) AM_MIRROR(0x08) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w)
333   AM_RANGE(0x00, 0x03) AM_MIRROR(0x08) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write)
334334   AM_RANGE(0x04, 0x04) AM_READ(sound_command_r)
335335   AM_RANGE(0x05, 0x05) AM_READWRITE(pending_command_r, pending_command_clear_w)
336336ADDRESS_MAP_END
r22751r22752
581581}
582582
583583
584static const ym2608_interface ym2608_config =
584static const ay8910_interface ay8910_config =
585585{
586   {
587      AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
588      AY8910_DEFAULT_LOADS,
589      DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
590   },
591   DEVCB_DRIVER_LINE_MEMBER(pipedrm_state,irqhandler)
586   AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
587   AY8910_DEFAULT_LOADS,
588   DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
592589};
593590
594591
r22751r22752
716713   MCFG_SPEAKER_STANDARD_MONO("mono")
717714
718715   MCFG_SOUND_ADD("ymsnd", YM2608, 8000000)
719   MCFG_SOUND_CONFIG(ym2608_config)
716   MCFG_YM2608_IRQ_HANDLER(WRITELINE(pipedrm_state, irqhandler))
717   MCFG_YM2608_AY8910_INTF(&ay8910_config)
720718   MCFG_SOUND_ROUTE(0, "mono", 0.50)
721719   MCFG_SOUND_ROUTE(1, "mono", 1.0)
722720   MCFG_SOUND_ROUTE(2, "mono", 1.0)
trunk/src/mame/drivers/wc90.c
r22751r22752
154154static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, wc90_state )
155155   AM_RANGE(0x0000, 0xbfff) AM_ROM
156156   AM_RANGE(0xf000, 0xf7ff) AM_RAM
157   AM_RANGE(0xf800, 0xf803) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w)
157   AM_RANGE(0xf800, 0xf803) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write)
158158   AM_RANGE(0xfc00, 0xfc00) AM_READNOP /* ??? adpcm ??? */
159159   AM_RANGE(0xfc10, 0xfc10) AM_READ(soundlatch_byte_r)
160160ADDRESS_MAP_END
r22751r22752
295295   m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
296296}
297297
298static const ym2608_interface ym2608_config =
298static const ay8910_interface ay8910_config =
299299{
300   {
301      AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
302      AY8910_DEFAULT_LOADS,
303      DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
304   },
305   DEVCB_DRIVER_LINE_MEMBER(wc90_state,irqhandler)
300   AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
301   AY8910_DEFAULT_LOADS,
302   DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
306303};
307304
308305static MACHINE_CONFIG_START( wc90, wc90_state )
r22751r22752
336333   MCFG_SPEAKER_STANDARD_MONO("mono")
337334
338335   MCFG_SOUND_ADD("ymsnd", YM2608, XTAL_8MHz)  /* verified on pcb */
339   MCFG_SOUND_CONFIG(ym2608_config)
336   MCFG_YM2608_IRQ_HANDLER(WRITELINE(wc90_state, irqhandler))
337   MCFG_YM2608_AY8910_INTF(&ay8910_config)
340338   MCFG_SOUND_ROUTE(0, "mono", 0.50)
341339   MCFG_SOUND_ROUTE(1, "mono", 1.0)
342340   MCFG_SOUND_ROUTE(2, "mono", 1.0)
trunk/src/mame/drivers/itech8.c
r22751r22752
936936static ADDRESS_MAP_START( sound2608b_map, AS_PROGRAM, 8, itech8_state )
937937   AM_RANGE(0x1000, 0x1000) AM_WRITENOP
938938   AM_RANGE(0x2000, 0x2000) AM_READ(sound_data_r)
939   AM_RANGE(0x4000, 0x4003) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w)
939   AM_RANGE(0x4000, 0x4003) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write)
940940   AM_RANGE(0x6000, 0x67ff) AM_RAM
941941   AM_RANGE(0x8000, 0xffff) AM_ROM
942942ADDRESS_MAP_END
r22751r22752
16491649};
16501650
16511651
1652static const ym2608_interface ym2608b_config =
1652static const ay8910_interface ay8910_config =
16531653{
1654   {
1655      AY8910_LEGACY_OUTPUT,
1656      AY8910_DEFAULT_LOADS,
1657      DEVCB_NULL,
1658      DEVCB_NULL,
1659      DEVCB_NULL,
1660      DEVCB_DRIVER_MEMBER(itech8_state,ym2203_portb_out),
1661   },
1662   DEVCB_DRIVER_LINE_MEMBER(itech8_state,generate_sound_irq)
1654   AY8910_LEGACY_OUTPUT,
1655   AY8910_DEFAULT_LOADS,
1656   DEVCB_NULL,
1657   DEVCB_NULL,
1658   DEVCB_NULL,
1659   DEVCB_DRIVER_MEMBER(itech8_state,ym2203_portb_out),
16631660};
16641661
16651662
r22751r22752
17411738
17421739   /* sound hardware */
17431740   MCFG_SOUND_ADD("ymsnd", YM2608, CLOCK_8MHz)
1744   MCFG_SOUND_CONFIG(ym2608b_config)
1741   MCFG_YM2608_IRQ_HANDLER(WRITELINE(itech8_state, generate_sound_irq))
1742   MCFG_YM2608_AY8910_INTF(&ay8910_config)
17451743   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
17461744MACHINE_CONFIG_END
17471745
trunk/src/mame/drivers/tail2nos.c
r22751r22752
5757static ADDRESS_MAP_START( sound_port_map, AS_IO, 8, tail2nos_state )
5858   ADDRESS_MAP_GLOBAL_MASK(0xff)
5959   AM_RANGE(0x07, 0x07) AM_READ(soundlatch_byte_r) AM_WRITENOP /* the write is a clear pending command */
60   AM_RANGE(0x08, 0x0b) AM_DEVWRITE_LEGACY("ymsnd", ym2608_w)
60   AM_RANGE(0x08, 0x0b) AM_DEVWRITE("ymsnd", ym2608_device, write)
6161#if 0
62   AM_RANGE(0x18, 0x1b) AM_DEVREAD_LEGACY("ymsnd", ym2608_r)
62   AM_RANGE(0x18, 0x1b) AM_DEVREAD("ymsnd", ym2608_device, read)
6363#endif
6464ADDRESS_MAP_END
6565
r22751r22752
181181   m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
182182}
183183
184static const ym2608_interface ym2608_config =
184static const ay8910_interface ay8910_config =
185185{
186   {
187      AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
188      AY8910_DEFAULT_LOADS,
189      DEVCB_NULL,
190      DEVCB_NULL,
191      DEVCB_NULL,
192      DEVCB_DRIVER_MEMBER(tail2nos_state,sound_bankswitch_w)
193   },
194   DEVCB_DRIVER_LINE_MEMBER(tail2nos_state,irqhandler)
186   AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
187   AY8910_DEFAULT_LOADS,
188   DEVCB_NULL,
189   DEVCB_NULL,
190   DEVCB_NULL,
191   DEVCB_DRIVER_MEMBER(tail2nos_state,sound_bankswitch_w)
195192};
196193
197194
r22751r22752
256253   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
257254
258255   MCFG_SOUND_ADD("ymsnd", YM2608, XTAL_8MHz)  /* verified on pcb */
259   MCFG_SOUND_CONFIG(ym2608_config)
256   MCFG_YM2608_IRQ_HANDLER(WRITELINE(tail2nos_state, irqhandler))
257   MCFG_YM2608_AY8910_INTF(&ay8910_config)
260258   MCFG_SOUND_ROUTE(0, "lspeaker",  0.25)
261259   MCFG_SOUND_ROUTE(0, "rspeaker", 0.25)
262260   MCFG_SOUND_ROUTE(1, "lspeaker",  1.0)
trunk/src/mame/drivers/bbusters.c
r22751r22752
383383
384384static ADDRESS_MAP_START( sounda_portmap, AS_IO, 8, bbusters_state )
385385   ADDRESS_MAP_GLOBAL_MASK(0xff)
386   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w)
386   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write)
387387   AM_RANGE(0xc0, 0xc1) AM_WRITENOP /* -> Main CPU */
388388ADDRESS_MAP_END
389389
r22751r22752
638638   m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
639639}
640640
641static const ym2608_interface ym2608_config =
641static const ay8910_interface ay8910_config =
642642{
643   {
644      AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
645      AY8910_DEFAULT_LOADS,
646      DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
647   },
648   DEVCB_DRIVER_LINE_MEMBER(bbusters_state,sound_irq)
643   AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
644   AY8910_DEFAULT_LOADS,
645   DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
649646};
650647
651648/******************************************************************************/
r22751r22752
726723   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
727724
728725   MCFG_SOUND_ADD("ymsnd", YM2608, 8000000)
729   MCFG_SOUND_CONFIG(ym2608_config)
726   MCFG_YM2608_IRQ_HANDLER(WRITELINE(bbusters_state, sound_irq))
727   MCFG_YM2608_AY8910_INTF(&ay8910_config)
730728   MCFG_SOUND_ROUTE(0, "lspeaker",  0.50)
731729   MCFG_SOUND_ROUTE(0, "rspeaker", 0.50)
732730   MCFG_SOUND_ROUTE(1, "lspeaker",  1.0)
trunk/src/emu/sound/2608intf.c
r22751r22752
1616#include "2608intf.h"
1717#include "fm.h"
1818
19struct ym2608_state
20{
21   sound_stream *  stream;
22   emu_timer * timer[2];
23   void *          chip;
24   void *          psg;
25   const ym2608_interface *intf;
26   device_t *device;
27   devcb_resolved_write_line irqhandler;
28};
29
30
31INLINE ym2608_state *get_safe_token(device_t *device)
32{
33   assert(device != NULL);
34   assert(device->type() == YM2608);
35   return (ym2608_state *)downcast<ym2608_device *>(device)->token();
36}
37
38
39
4019static void psg_set_clock(void *param, int clock)
4120{
42   ym2608_state *info = (ym2608_state *)param;
43   ay8910_set_clock_ym(info->psg, clock);
21   ym2608_device *ym2608 = (ym2608_device *) param;
22   ay8910_set_clock_ym(ym2608->_psg(), clock);
4423}
4524
4625static void psg_write(void *param, int address, int data)
4726{
48   ym2608_state *info = (ym2608_state *)param;
49   ay8910_write_ym(info->psg, address, data);
27   ym2608_device *ym2608 = (ym2608_device *) param;
28   ay8910_write_ym(ym2608->_psg(), address, data);
5029}
5130
5231static int psg_read(void *param)
5332{
54   ym2608_state *info = (ym2608_state *)param;
55   return ay8910_read_ym(info->psg);
33   ym2608_device *ym2608 = (ym2608_device *) param;
34   return ay8910_read_ym(ym2608->_psg());
5635}
5736
5837static void psg_reset(void *param)
5938{
60   ym2608_state *info = (ym2608_state *)param;
61   ay8910_reset_ym(info->psg);
39   ym2608_device *ym2608 = (ym2608_device *) param;
40   ay8910_reset_ym(ym2608->_psg());
6241}
6342
6443static const ssg_callbacks psgintf =
r22751r22752
6948   psg_reset
7049};
7150
51void *ym2608_device::_psg()
52{
53   return m_psg;
54}
7255
7356/* IRQ Handler */
7457static void IRQHandler(void *param,int irq)
7558{
76   ym2608_state *info = (ym2608_state *)param;
77   if (!info->irqhandler.isnull())
78      info->irqhandler(irq);
59   ym2608_device *ym2608 = (ym2608_device *) param;
60   ym2608->_IRQHandler(irq);
7961}
8062
81/* Timer overflow callback from timer.c */
82static TIMER_CALLBACK( timer_callback_2608_0 )
63void ym2608_device::_IRQHandler(int irq)
8364{
84   ym2608_state *info = (ym2608_state *)ptr;
85   ym2608_timer_over(info->chip,0);
65   if (!m_irq_handler.isnull())
66      m_irq_handler(irq);
8667}
8768
88static TIMER_CALLBACK( timer_callback_2608_1 )
69/* Timer overflow callback from timer.c */
70void ym2608_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
8971{
90   ym2608_state *info = (ym2608_state *)ptr;
91   ym2608_timer_over(info->chip,1);
72   switch(id)
73   {
74   case 0:
75      ym2608_timer_over(m_chip,0);
76      break;
77
78   case 1:
79      ym2608_timer_over(m_chip,1);
80      break;
81   }
9282}
9383
9484static void timer_handler(void *param,int c,int count,int clock)
9585{
96   ym2608_state *info = (ym2608_state *)param;
86   ym2608_device *ym2608 = (ym2608_device *) param;
87   ym2608->_timer_handler(c, count, clock);
88}
89
90void ym2608_device::_timer_handler(int c,int count,int clock)
91{
9792   if( count == 0 )
9893   {   /* Reset FM Timer */
99      info->timer[c]->enable(false);
94      m_timer[c]->enable(false);
10095   }
10196   else
10297   {   /* Start FM Timer */
10398      attotime period = attotime::from_hz(clock) * count;
104      if (!info->timer[c]->enable(true))
105         info->timer[c]->adjust(period);
99
100      if (!m_timer[c]->enable(true))
101         m_timer[c]->adjust(period);
106102   }
107103}
108104
109105/* update request from fm.c */
110106void ym2608_update_request(void *param)
111107{
112   ym2608_state *info = (ym2608_state *)param;
113   info->stream->update();
108   ym2608_device *ym2608 = (ym2608_device *) param;
109   ym2608->_ym2608_update_request();
114110}
115111
116static STREAM_UPDATE( ym2608_stream_update )
112void ym2608_device::_ym2608_update_request()
117113{
118   ym2608_state *info = (ym2608_state *)param;
119   ym2608_update_one(info->chip, outputs, samples);
114   m_stream->update();
120115}
121116
117//-------------------------------------------------
118//  sound_stream_update - handle a stream update
119//-------------------------------------------------
122120
123static void ym2608_intf_postload(ym2608_state *info)
121void ym2608_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
124122{
125   ym2608_postload(info->chip);
123   ym2608_update_one(m_chip, outputs, samples);
126124}
127125
128126
129static DEVICE_START( ym2608 )
127void ym2608_device::device_post_load()
130128{
131   static const ym2608_interface generic_2608 =
129   ym2608_postload(m_chip);
130}
131
132
133//-------------------------------------------------
134//  device_start - device-specific startup
135//-------------------------------------------------
136
137void ym2608_device::device_start()
138{
139   static const ay8910_interface generic_ay8910 =
132140   {
133      {
134         AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
135         AY8910_DEFAULT_LOADS,
136         DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
137      },
138      DEVCB_NULL
141      AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
142      AY8910_DEFAULT_LOADS,
143      DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
139144   };
140   const ym2608_interface *intf = device->static_config() ? (const ym2608_interface *)device->static_config() : &generic_2608;
141   int rate = device->clock()/72;
145
146   int rate = clock()/72;
142147   void *pcmbufa;
143148   int  pcmsizea;
144149
145   ym2608_state *info = get_safe_token(device);
150   const ay8910_interface *ay8910_intf = m_ay8910_intf != NULL ? m_ay8910_intf : &generic_ay8910;
146151
147   info->intf = intf;
148   info->device = device;
149
150   info->irqhandler.resolve(intf->irqhandler, *device);
151
152   m_irq_handler.resolve();
152153   /* FIXME: Force to use simgle output */
153   info->psg = ay8910_start_ym(NULL, YM2608, device, device->clock(), &intf->ay8910_intf);
154   assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip");
154   m_psg = ay8910_start_ym(NULL, type(), this, clock(), ay8910_intf);
155   assert_always(m_psg != NULL, "Error creating YM2608/AY8910 chip");
155156
156157   /* Timer Handler set */
157   info->timer[0] = device->machine().scheduler().timer_alloc(FUNC(timer_callback_2608_0), info);
158   info->timer[1] = device->machine().scheduler().timer_alloc(FUNC(timer_callback_2608_1), info);
158   m_timer[0] = timer_alloc(0);
159   m_timer[1] = timer_alloc(1);
159160
160161   /* stream system initialize */
161   info->stream = device->machine().sound().stream_alloc(*device,0,2,rate,info,ym2608_stream_update);
162   m_stream = machine().sound().stream_alloc(*this,0,2,rate);
162163   /* setup adpcm buffers */
163   pcmbufa  = *device->region();
164   pcmsizea = device->region()->bytes();
164   pcmbufa  = *region();
165   pcmsizea = region()->bytes();
165166
166167   /* initialize YM2608 */
167   info->chip = ym2608_init(info,device,device->clock(),rate,
168   m_chip = ym2608_init(this,this,clock(),rate,
168169               pcmbufa,pcmsizea,
169170               timer_handler,IRQHandler,&psgintf);
170   assert_always(info->chip != NULL, "Error creating YM2608 chip");
171
172   device->machine().save().register_postload(save_prepost_delegate(FUNC(ym2608_intf_postload), info));
171   assert_always(m_chip != NULL, "Error creating YM2608 chip");
173172}
174173
175static DEVICE_STOP( ym2608 )
174//-------------------------------------------------
175//  device_stop - device-specific stop
176//-------------------------------------------------
177
178void ym2608_device::device_stop()
176179{
177   ym2608_state *info = get_safe_token(device);
178   ym2608_shutdown(info->chip);
179   ay8910_stop_ym(info->psg);
180   ym2608_shutdown(m_chip);
181   ay8910_stop_ym(m_psg);
180182}
181183
182static DEVICE_RESET( ym2608 )
184//-------------------------------------------------
185//  device_reset - device-specific reset
186//-------------------------------------------------
187
188void ym2608_device::device_reset()
183189{
184   ym2608_state *info = get_safe_token(device);
185   ym2608_reset_chip(info->chip);
190   ym2608_reset_chip(m_chip);
186191}
187192
188193
189READ8_DEVICE_HANDLER( ym2608_r )
194READ8_MEMBER( ym2608_device::read )
190195{
191   ym2608_state *info = get_safe_token(device);
192   return ym2608_read(info->chip, offset & 3);
196   return ym2608_read(m_chip, offset & 3);
193197}
194198
195WRITE8_DEVICE_HANDLER( ym2608_w )
199WRITE8_MEMBER( ym2608_device::write )
196200{
197   ym2608_state *info = get_safe_token(device);
198   ym2608_write(info->chip, offset & 3, data);
201   ym2608_write(m_chip, offset & 3, data);
199202}
200203
201READ8_DEVICE_HANDLER( ym2608_read_port_r ) { return ym2608_r(device, space, 1); }
202READ8_DEVICE_HANDLER( ym2608_status_port_a_r ) { return ym2608_r(device, space, 0); }
203READ8_DEVICE_HANDLER( ym2608_status_port_b_r ) { return ym2608_r(device, space, 2); }
204
205WRITE8_DEVICE_HANDLER( ym2608_control_port_a_w ) { ym2608_w(device, space, 0, data); }
206WRITE8_DEVICE_HANDLER( ym2608_control_port_b_w ) { ym2608_w(device, space, 2, data); }
207WRITE8_DEVICE_HANDLER( ym2608_data_port_a_w ) { ym2608_w(device, space, 1, data); }
208WRITE8_DEVICE_HANDLER( ym2608_data_port_b_w ) { ym2608_w(device, space, 3, data); }
209
210204const device_type YM2608 = &device_creator<ym2608_device>;
211205
212206ym2608_device::ym2608_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
213207   : device_t(mconfig, YM2608, "YM2608", tag, owner, clock),
214      device_sound_interface(mconfig, *this)
208      device_sound_interface(mconfig, *this),
209      m_irq_handler(*this)
215210{
216   m_token = global_alloc_clear(ym2608_state);
217211}
218212
219213//-------------------------------------------------
r22751r22752
225219void ym2608_device::device_config_complete()
226220{
227221}
228
229//-------------------------------------------------
230//  device_start - device-specific startup
231//-------------------------------------------------
232
233void ym2608_device::device_start()
234{
235   DEVICE_START_NAME( ym2608 )(this);
236}
237
238//-------------------------------------------------
239//  device_reset - device-specific reset
240//-------------------------------------------------
241
242void ym2608_device::device_reset()
243{
244   DEVICE_RESET_NAME( ym2608 )(this);
245}
246
247//-------------------------------------------------
248//  device_stop - device-specific stop
249//-------------------------------------------------
250
251void ym2608_device::device_stop()
252{
253   DEVICE_STOP_NAME( ym2608 )(this);
254}
255
256//-------------------------------------------------
257//  sound_stream_update - handle a stream update
258//-------------------------------------------------
259
260void ym2608_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
261{
262   // should never get here
263   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
264}
trunk/src/emu/sound/2608intf.h
r22751r22752
33#ifndef __2608INTF_H__
44#define __2608INTF_H__
55
6#include "devlegcy.h"
7
6#include "emu.h"
87#include "fm.h"
98#include "ay8910.h"
109
1110void ym2608_update_request(void *param);
1211
13struct ym2608_interface
14{
15   const ay8910_interface ay8910_intf;
16   devcb_write_line irqhandler; /* IRQ handler for the YM2608 */
17};
12#define MCFG_YM2608_IRQ_HANDLER(_devcb) \
13   devcb = &ym2608_device::set_irq_handler(*device, DEVCB2_##_devcb);
1814
19DECLARE_READ8_DEVICE_HANDLER( ym2608_r );
20DECLARE_WRITE8_DEVICE_HANDLER( ym2608_w );
15#define MCFG_YM2608_AY8910_INTF(_ay8910_intf) \
16   ym2608_device::set_ay8910_intf(*device, _ay8910_intf);
2117
22DECLARE_READ8_DEVICE_HANDLER( ym2608_read_port_r );
23DECLARE_READ8_DEVICE_HANDLER( ym2608_status_port_a_r );
24DECLARE_READ8_DEVICE_HANDLER( ym2608_status_port_b_r );
25
26DECLARE_WRITE8_DEVICE_HANDLER( ym2608_control_port_a_w );
27DECLARE_WRITE8_DEVICE_HANDLER( ym2608_control_port_b_w );
28DECLARE_WRITE8_DEVICE_HANDLER( ym2608_data_port_a_w );
29DECLARE_WRITE8_DEVICE_HANDLER( ym2608_data_port_b_w );
30
3118class ym2608_device : public device_t,
3219                           public device_sound_interface
3320{
3421public:
3522   ym2608_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
36   ~ym2608_device() { global_free(m_token); }
3723
38   // access to legacy token
39   void *token() const { assert(m_token != NULL); return m_token; }
24   // static configuration helpers
25   template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<ym2608_device &>(device).m_irq_handler.set_callback(object); }
26   static void set_ay8910_intf(device_t &device, const ay8910_interface *ay8910_intf) { downcast<ym2608_device &>(device).m_ay8910_intf = ay8910_intf; }
27
28   DECLARE_READ8_MEMBER( read );
29   DECLARE_WRITE8_MEMBER( write );
30
31   void *_psg();
32   void _IRQHandler(int irq);
33   void _timer_handler(int c,int count,int clock);
34   void _ym2608_update_request();
35
4036protected:
4137   // device-level overrides
4238   virtual void device_config_complete();
4339   virtual void device_start();
40   virtual void device_post_load();
4441   virtual void device_stop();
4542   virtual void device_reset();
4643
44   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
45
4746   // sound stream update overrides
4847   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
48
4949private:
5050   // internal state
51   void *m_token;
51   sound_stream *  m_stream;
52   emu_timer *     m_timer[2];
53   void *          m_chip;
54   void *          m_psg;
55   devcb2_write_line m_irq_handler;
56   const ay8910_interface *m_ay8910_intf;
5257};
5358
5459extern const device_type YM2608;
trunk/src/mess/drivers/pc8801.c
r22751r22752
304304         m_pic(*this, I8214_TAG),
305305         m_rtc(*this, UPD1990A_TAG),
306306         m_cassette(*this, "cassette"),
307         m_beeper(*this, "beeper")
307         m_beeper(*this, "beeper"),
308         m_opna(*this, "opna")
308309   { }
309310
310311   required_device<cpu_device> m_maincpu;
r22751r22752
313314   required_device<upd1990a_device> m_rtc;
314315   required_device<cassette_image_device> m_cassette;
315316   required_device<beep_device> m_beeper;
317   required_device<ym2608_device> m_opna;
316318   UINT8 *m_work_ram;
317319   UINT8 *m_hi_work_ram;
318320   UINT8 *m_ext_work_ram;
r22751r22752
16961698READ8_MEMBER(pc8801_state::pc8801_sound_board_r)
16971699{
16981700   if(m_has_opna)
1699      return ym2608_r(machine().device("opna"), space, offset);
1701      return m_opna->read(space, offset);
17001702
17011703   return (offset & 2) ? 0xff : ym2203_r(machine().device("opn"), space, offset);
17021704}
r22751r22752
17041706WRITE8_MEMBER(pc8801_state::pc8801_sound_board_w)
17051707{
17061708   if(m_has_opna)
1707      ym2608_w(machine().device("opna"), space, offset,data);
1709      m_opna->write(space, offset,data);
17081710   else if((offset & 2) == 0)
17091711      ym2203_w(machine().device("opn"), space, offset,data);
17101712}
r22751r22752
17121714READ8_MEMBER(pc8801_state::pc8801_opna_r)
17131715{
17141716   if(m_has_opna && (offset & 2) == 0)
1715      return ym2608_r(machine().device("opna"), space, (offset & 1) | ((offset & 4) >> 1));
1717      return m_opna->read(space, (offset & 1) | ((offset & 4) >> 1));
17161718
17171719   return 0xff;
17181720}
r22751r22752
17201722WRITE8_MEMBER(pc8801_state::pc8801_opna_w)
17211723{
17221724   if(m_has_opna && (offset & 2) == 0)
1723      ym2608_w(machine().device("opna"), space, (offset & 1) | ((offset & 4) >> 1),data);
1725      m_opna->write(space, (offset & 1) | ((offset & 4) >> 1),data);
17241726   else if(m_has_opna && offset == 2)
17251727   {
17261728      m_sound_irq_mask = ((data & 0x80) == 0);
r22751r22752
25992601   DEVCB_DRIVER_LINE_MEMBER(pc8801_state,pc8801_sound_irq)
26002602};
26012603
2602static const ym2608_interface pc88_ym2608_intf =
2604static const ay8910_interface ay8910_config =
26032605{
2604   {
2605      AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
2606      AY8910_DEFAULT_LOADS,
2607      DEVCB_DRIVER_MEMBER(pc8801_state,opn_porta_r),
2608      DEVCB_DRIVER_MEMBER(pc8801_state,opn_portb_r),
2609      DEVCB_NULL,
2610      DEVCB_NULL
2611   },
2612   DEVCB_DRIVER_LINE_MEMBER(pc8801_state,pc8801_sound_irq)
2606   AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
2607   AY8910_DEFAULT_LOADS,
2608   DEVCB_DRIVER_MEMBER(pc8801_state,opn_porta_r),
2609   DEVCB_DRIVER_MEMBER(pc8801_state,opn_portb_r),
2610   DEVCB_NULL,
2611   DEVCB_NULL
26132612};
26142613
26152614/* Cassette Configuration */
r22751r22752
27072706   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
27082707
27092708   MCFG_SOUND_ADD("opna", YM2608, MASTER_CLOCK*2)
2710   MCFG_SOUND_CONFIG(pc88_ym2608_intf)
2709   MCFG_YM2608_IRQ_HANDLER(WRITELINE(pc8801_state, pc8801_sound_irq))
2710   MCFG_YM2608_AY8910_INTF(&ay8910_config)
27112711   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
27122712
27132713   MCFG_SOUND_ADD("beeper", BEEP, 0)
trunk/src/mess/machine/pc9801_86.c
r22751r22752
4141   pic8259_ir4_w(machine().device("pic8259_slave"), state);
4242}
4343
44static const ym2608_interface pc98_ym2608_intf =
44static const ay8910_interface ay8910_config =
4545{
46   {
47      AY8910_LEGACY_OUTPUT,
48      AY8910_DEFAULT_LOADS,
49      DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_porta_r),
50      DEVCB_NULL,//(pc9801_state,opn_portb_r),
51      DEVCB_NULL,//(pc9801_state,opn_porta_w),
52      DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_portb_w),
53   },
54   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,pc9801_sound_irq)
46   AY8910_LEGACY_OUTPUT,
47   AY8910_DEFAULT_LOADS,
48   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_porta_r),
49   DEVCB_NULL,//(pc9801_state,opn_portb_r),
50   DEVCB_NULL,//(pc9801_state,opn_porta_w),
51   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_portb_w),
5552};
5653
5754static MACHINE_CONFIG_FRAGMENT( pc9801_86_config )
5855   MCFG_SPEAKER_STANDARD_MONO("mono")
5956   MCFG_SOUND_ADD("opna", YM2608, MAIN_CLOCK_X1*4) // unknown clock / divider
60   MCFG_SOUND_CONFIG(pc98_ym2608_intf)
57   MCFG_YM2608_IRQ_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, pc9801_86_device, pc9801_sound_irq))
58   MCFG_YM2608_AY8910_INTF(&ay8910_config)
6159   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
6260MACHINE_CONFIG_END
6361
r22751r22752
192190READ8_MEMBER(pc9801_86_device::pc9801_86_r)
193191{
194192   if((offset & 1) == 0)
195      return ym2608_r(m_opna, space, offset >> 1);
193      return m_opna->read(space, offset >> 1);
196194   else // odd
197195   {
198196      printf("PC9801-86: Read to undefined port [%02x]\n",offset+0x188);
r22751r22752
204202WRITE8_MEMBER(pc9801_86_device::pc9801_86_w)
205203{
206204   if((offset & 1) == 0)
207      ym2608_w(m_opna,space, offset >> 1,data);
205      m_opna->write(space, offset >> 1,data);
208206   else // odd
209207      printf("PC9801-86: Write to undefined port [%02x] %02x\n",offset+0x188,data);
210208}
trunk/src/mess/machine/pc9801_118.c
r22751r22752
4141   pic8259_ir4_w(machine().device("pic8259_slave"), state);
4242}
4343
44static const ym2608_interface pc98_ym2608_intf =
44static const ay8910_interface ay8910_config =
4545{
46   {
47      AY8910_LEGACY_OUTPUT,
48      AY8910_DEFAULT_LOADS,
49      DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_porta_r),
50      DEVCB_NULL,//(pc9801_state,opn_portb_r),
51      DEVCB_NULL,//(pc9801_state,opn_porta_w),
52      DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_portb_w),
53   },
54   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,pc9801_sound_irq)
46   AY8910_LEGACY_OUTPUT,
47   AY8910_DEFAULT_LOADS,
48   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_porta_r),
49   DEVCB_NULL,//(pc9801_state,opn_portb_r),
50   DEVCB_NULL,//(pc9801_state,opn_porta_w),
51   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_portb_w),
5552};
5653
5754static MACHINE_CONFIG_FRAGMENT( pc9801_118_config )
5855   MCFG_SPEAKER_STANDARD_MONO("mono")
5956   MCFG_SOUND_ADD("opn3", YM2608, MAIN_CLOCK_X1*4) // actually YMF288, unknown clock / divider
60   MCFG_SOUND_CONFIG(pc98_ym2608_intf)
57   MCFG_YM2608_IRQ_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, pc9801_118_device, pc9801_sound_irq))
58   MCFG_YM2608_AY8910_INTF(&ay8910_config)
6159   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
6260MACHINE_CONFIG_END
6361
r22751r22752
192190READ8_MEMBER(pc9801_118_device::pc9801_118_r)
193191{
194192   if(((offset & 5) == 0) || m_ext_reg)
195      return ym2608_r(m_opn3, space, offset >> 1);
193      return m_opn3->read(space, offset >> 1);
196194   else // odd
197195   {
198196      //printf("PC9801-118: Read to undefined port [%02x]\n",offset+0x188);
r22751r22752
204202WRITE8_MEMBER(pc9801_118_device::pc9801_118_w)
205203{
206204   if(((offset & 5) == 0) || m_ext_reg)
207      ym2608_w(m_opn3,space, offset >> 1,data);
205      m_opn3->write(space, offset >> 1,data);
208206   //else // odd
209207   //  printf("PC9801-118: Write to undefined port [%02x] %02x\n",offset+0x188,data);
210208}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team