Previous 15994 Revisions Next

r9416 Wednesday 20th October, 2010 at 02:21:53 UTC by R. Belmont
[MAC] Flawless playback in SoundTrecker on IIcx. System sounds still have issues.
[src/emu/sound]asc.c asc.h

src/emu/sound/asc.c
r9415r9416
101101//  LIVE DEVICE
102102//**************************************************************************
103103
104// does nothing, this timer exists only to make MAME sync itself at our audio rate
105static TIMER_CALLBACK( sync_timer_cb )
106{
107   asc_device *pDevice = (asc_device *)ptr;
108
109   stream_update(pDevice->m_stream);
110}
111
104112//-------------------------------------------------
105113//  asc_device - constructor
106114//-------------------------------------------------
r9415r9416
125133   m_stream = stream_create(this, 0, 2, 22257, this, static_stream_generate);
126134
127135   memset(m_regs, 0, sizeof(m_regs));
136
137   m_sync_timer = timer_alloc(this->machine, sync_timer_cb, this);
128138}
129139
130140
r9415r9416
198208               m_fifo_cap_b--;
199209            }
200210
201            if ((m_fifo_cap_a) || (m_fifo_cap_b))
211            switch (m_chip_type)
202212            {
203               switch (m_chip_type)
204               {
205                  case ASC_TYPE_SONORA:
206                     if (m_fifo_cap_a <= 0x200)
213               case ASC_TYPE_SONORA:
214                  if (m_fifo_cap_a < 0x200)
215                  {
216                     m_regs[R_FIFOSTAT-0x800] |= 0x4;   // fifo less than half full
217                     m_regs[R_FIFOSTAT-0x800] |= 0x8;   // just pass the damn test
218                     if (m_irq_cb)
207219                     {
208                        m_regs[R_FIFOSTAT-0x800] |= 0x4;   // fifo less than half full
209                        m_regs[R_FIFOSTAT-0x800] |= 0x8;   // just pass the damn test
210                        if (m_irq_cb)
211                        {
212                           m_irq_cb(this, 1);
213                        }
220                        m_irq_cb(this, 1);
214221                     }
215                     break;
222                  }
223                  break;
216224
217                  default:
218                     if (m_fifo_cap_a <= 0x200)
225               default:
226                  if (m_fifo_cap_a == 0x1ff)
227                  {
228                     m_regs[R_FIFOSTAT-0x800] |= 1;   // fifo A half-empty
229                     if ((m_irq_cb) && (m_fifo_cap_a))
219230                     {
220                        m_regs[R_FIFOSTAT-0x800] |= 1;   // fifo A half-empty
221                        if (m_irq_cb)
222                        {
223                           m_irq_cb(this, 1);
224                        }
231                        m_irq_cb(this, 1);
225232                     }
233                  }
226234
227                     // don't update for non-(E)ASC
228                     if (m_fifo_cap_b <= 0x200)
235                  // don't update for non-(E)ASC
236                  if (m_fifo_cap_b == 0x1ff)
237                  {
238                     m_regs[R_FIFOSTAT-0x800] |= 4;   // fifo B half-empty
239                     if ((m_irq_cb) && (m_fifo_cap_b))
229240                     {
230                        m_regs[R_FIFOSTAT-0x800] |= 4;   // fifo B half-empty
231                        if (m_irq_cb)
232                        {
233                           m_irq_cb(this, 1);
234                        }
241                        m_irq_cb(this, 1);
235242                     }
236                     break;
237               }
243                  }
244                  break;
238245            }
239246
240247            outL[i] = smpll * 64;
r9415r9416
274281         }
275282         break;
276283   }
284
285//   printf("rdA %04x rdB %04x wrA %04x wrB %04x (capA %04x B %04x)\n", m_fifo_a_rdptr, m_fifo_b_rdptr, m_fifo_a_wrptr, m_fifo_b_wrptr, m_fifo_cap_a, m_fifo_cap_b);
277286}
278287
279288//-------------------------------------------------
r9415r9416
361370            // reading this register clears all bits
362371            m_regs[R_FIFOSTAT-0x800] = 0;
363372
364            // reading this clears interrupts?
373            // reading this clears interrupts
365374            if (m_irq_cb)
366375            {
367376               m_irq_cb(this, 0);
r9415r9416
425434         m_fifo_a[m_fifo_a_wrptr++] = data;
426435         m_fifo_cap_a++;
427436
428         if (m_fifo_cap_a == 0x800)
437         if (m_fifo_cap_a == 0x3ff)
429438         {
430439            m_regs[R_FIFOSTAT-0x800] |= 2;   // fifo A full
431440         }
r9415r9416
444453         m_fifo_b[m_fifo_b_wrptr++] = data;
445454         m_fifo_cap_b++;
446455
447         if (m_fifo_cap_b == 0x800)
456         if (m_fifo_cap_b == 0x3ff)
448457         {
449458            m_regs[R_FIFOSTAT-0x800] |= 8;   // fifo B full
450459         }
r9415r9416
471480               m_fifo_a_rdptr = m_fifo_b_rdptr = 0;
472481               m_fifo_a_wrptr = m_fifo_b_wrptr = 0;
473482               m_fifo_cap_a = m_fifo_cap_b = 0;
483
484               if (data != 0)
485               {
486                  timer_adjust_periodic(m_sync_timer, attotime_zero, 0, ATTOTIME_IN_HZ(22257/4));
487               }
488               else
489               {
490                  timer_adjust_oneshot(m_sync_timer, attotime_never, 0);
491               }
474492            }
475493            break;
476494
src/emu/sound/asc.h
r9415r9416
9999   UINT8 read(UINT16 offset);
100100   void write(UINT16 offset, UINT8 data);
101101
102   sound_stream *m_stream;
103
102104protected:
103105   enum
104106   {
r9415r9416
133135
134136   UINT8   m_chip_type;
135137   void (*m_irq_cb)(running_device *device, int state);
136   sound_stream *m_stream;
137138
138139   UINT8   m_fifo_a[0x400];
139140   UINT8   m_fifo_b[0x400];
r9415r9416
145146   int   m_fifo_a_rdptr, m_fifo_b_rdptr;
146147   int   m_fifo_a_wrptr, m_fifo_b_wrptr;
147148   int    m_fifo_cap_a, m_fifo_cap_b;
149
150   emu_timer *m_sync_timer;
148151};
149152
150153

Previous 15994 Revisions Next


© 1998-2018 The MESS Team