Previous 199869 Revisions Next

r29531 Friday 11th April, 2014 at 07:36:56 UTC by Fabio Priuli
rf5c68: converted to use delegates. nw.
[src/emu/sound]rf5c68.c rf5c68.h
[src/mess/drivers]fmtowns.c

trunk/src/emu/sound/rf5c68.c
r29530r29531
2424      m_stream(NULL),
2525      m_cbank(0),
2626      m_wbank(0),
27      m_enable(0),
28      m_sample_callback(NULL)
27      m_enable(0)
2928{
3029   memset(m_data, 0, sizeof(UINT8)*0x10000);
3130}
r29530r29531
3736
3837void rf5c68_device::device_start()
3938{
40   const rf5c68_interface* intf = (const rf5c68_interface*)static_config();
41
39   m_sample_end_cb.bind_relative_to(*owner());
40   
4241   /* allocate memory for the chip */
4342   memset(m_data, 0xff, sizeof(m_data));
4443
4544   /* allocate the stream */
4645   m_stream = stream_alloc(0, 2, clock() / 384);
47
48   /* set up callback */
49   if(intf != NULL)
50      m_sample_callback = intf->sample_end_callback;
51   else
52      m_sample_callback = NULL;
5346}
5447
5548
r29530r29531
8881            int sample;
8982
9083            /* trigger sample callback */
91            if(m_sample_callback)
84            if(!m_sample_end_cb.isnull())
9285            {
9386               if(((chan->addr >> 11) & 0xfff) == 0xfff)
94                  m_sample_callback(this, ((chan->addr >> 11)/0x2000));
87                  m_sample_end_cb((chan->addr >> 11)/0x2000);
9588            }
9689
9790            /* fetch the sample and handle looping */
trunk/src/emu/sound/rf5c68.h
r29530r29531
1919#define MCFG_RF5C68_REPLACE(_tag, _clock) \
2020   MCFG_DEVICE_REPLACE(_tag, RF5C68, _clock)
2121
22#define MCFG_RF5C68_SAMPLE_END_CB(_class, _method) \
23   rf5c68_device::set_end_callback(*device, rf5c68_sample_end_cb_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
2224
2325//**************************************************************************
2426//  TYPE DEFINITIONS
2527//**************************************************************************
2628
27struct rf5c68_interface
28{
29   void (*sample_end_callback)(device_t* device, int channel);
30};
29typedef device_delegate<void (int channel)> rf5c68_sample_end_cb_delegate;
3130
31#define RF5C68_SAMPLE_END_CB_MEMBER(_name)   void _name(int channel)
3232
33
3334struct rf5c68_pcm_channel
3435{
3536   rf5c68_pcm_channel() :
r29530r29531
5152};
5253
5354
54
5555// ======================> rf5c68_device
5656
5757class rf5c68_device : public device_t,
r29530r29531
6161   rf5c68_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
6262   ~rf5c68_device() { }
6363
64   static void set_end_callback(device_t &device, rf5c68_sample_end_cb_delegate callback) { downcast<rf5c68_device &>(device).m_sample_end_cb = callback; }
65   
6466protected:
6567   // device-level overrides
6668   virtual void device_start();
r29530r29531
8284   UINT8                m_wbank;
8385   UINT8                m_enable;
8486   UINT8                m_data[0x10000];
85   void                (*m_sample_callback)(device_t* device,int channel);
87
88   rf5c68_sample_end_cb_delegate m_sample_end_cb;
8689};
8790
8891extern const device_type RF5C68;
trunk/src/mess/drivers/fmtowns.c
r29530r29531
20782078}
20792079
20802080// PCM interrupt (IRQ 13)
2081static void towns_pcm_irq(device_t* device, int channel)
2081RF5C68_SAMPLE_END_CB_MEMBER(towns_state::towns_pcm_irq)
20822082{
2083   towns_state* state = device->machine().driver_data<towns_state>();
2084   pic8259_device* pic = state->m_pic_slave;
2085
2086   if(state->m_towns_pcm_channel_mask & (1 << channel))
2083   if (m_towns_pcm_channel_mask & (1 << channel))
20872084   {
2088      state->m_towns_pcm_irq_flag = 1;
2089      state->m_towns_pcm_channel_flag |= (1 << channel);
2090      pic->ir5_w(1);
2085      m_towns_pcm_irq_flag = 1;
2086      m_towns_pcm_channel_flag |= (1 << channel);
2087      m_pic_slave->ir5_w(1);
20912088      if(IRQ_LOG) logerror("PIC: IRQ13 (PCM) set high (channel %i)\n",channel);
20922089   }
20932090}
r29530r29531
26702667   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }
26712668};
26722669
2673static const rf5c68_interface rf5c68_intf =
2674{
2675   towns_pcm_irq
2676};
2677
26782670static const gfx_layout fnt_chars_16x16 =
26792671{
26802672   16,16,
r29530r29531
27332725   MCFG_SOUND_ADD("fm", YM3438, 53693100 / 7) // actual clock speed unknown
27342726   MCFG_YM2612_IRQ_HANDLER(WRITELINE(towns_state, towns_fm_irq))
27352727   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
2728
27362729   MCFG_RF5C68_ADD("pcm", 53693100 / 7)  // actual clock speed unknown
2737   MCFG_SOUND_CONFIG(rf5c68_intf)
2730   MCFG_RF5C68_SAMPLE_END_CB(towns_state, towns_pcm_irq)
27382731   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.50)
27392732   MCFG_SOUND_ADD("cdda",CDDA,0)
27402733   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team