Previous 199869 Revisions Next

r17875 Friday 14th September, 2012 at 03:39:57 UTC by R. Belmont
es5503: Fix IRQ timing error introduced when I did the device conversion. [R. Belmont]
[src/emu/sound]es5503.c

trunk/src/emu/sound/es5503.c
r17874r17875
11/*
22
3  ES5503 - Ensoniq ES5503 "DOC" emulator v1.
3  ES5503 - Ensoniq ES5503 "DOC" emulator v2.1.1
44  By R. Belmont.
55
66  Copyright R. Belmont.
r17874r17875
3333  1.0 (RB) - properly respects the input clock
3434  2.0 (RB) - C++ conversion, more accurate oscillator IRQ timing
3535  2.1 (RB) - Corrected phase when looping; synthLAB, Arkanoid, and Arkanoid II no longer go out of tune
36  2.1.1 (RB) - Fixed issue introduced in 2.0 where IRQs were delayed
3637*/
3738
3839#include "emu.h"
r17874r17875
117118   int mode = (pOsc->control>>1) & 3;
118119
119120   // if 0 found in sample data or mode is not free-run, halt this oscillator
120   if ((type != MODE_FREE) || (mode > 0))
121   if ((mode != MODE_FREE) || (type != 0))
121122   {
122123      pOsc->control |= 1;
123124   }
124   else    // preserve the relative phase of the oscillator when looping.  I think.
125   else    // preserve the relative phase of the oscillator when looping
125126   {
126127        UINT16 wtsize = pOsc->wtsize - 1;
127128        UINT32 altram = (*accumulator) >> resshift;
r17874r17875
142143   if (mode == MODE_SWAP)
143144   {
144145      pPartner->control &= ~1;   // clear the halt bit
145      pPartner->accumulator = 0;   // and make sure it starts from the top
146      pPartner->accumulator = 0;   // and make sure it starts from the top (does this also need phase preservation?)
146147   }
147148
148149   // IRQ enabled for this voice?
r17874r17875
249250   // find our direct access
250251   m_direct = &space()->direct();
251252
252   rege0 = 0x80;
253   rege0 = 0xff;
253254
254255   for (osc = 0; osc < 32; osc++)
255256   {
r17874r17875
269270   m_stream = machine().sound().stream_alloc(*this, 0, 2, output_rate, this);
270271
271272   m_timer = timer_alloc(0, NULL);
272   m_timer->adjust(attotime::from_hz(output_rate));
273   m_timer->adjust(attotime::from_hz(output_rate), 0, attotime::from_hz(output_rate));
273274}
274275
275276void es5503_device::device_reset()
276277{
277   rege0 = 0x80;
278   rege0 = 0xff;
278279
279280   for (int osc = 0; osc < 32; osc++)
280281   {
r17874r17875
344345   {
345346      switch (offset)
346347      {
347         case 0xe0:   // interrupt status
348            case 0xe0:   // interrupt status
348349            retval = rege0;
349350
351                if (m_irq_func)
352                {
353                    m_irq_func(this, 0);
354                }
355
350356            // scan all oscillators
351357            for (i = 0; i < oscsenabled+1; i++)
352358            {
r17874r17875
358364                  rege0 = retval | 0x80;
359365
360366                  // and clear its flag
361                  oscillators[i].irqpend--;
362
363                  if (m_irq_func)
364                  {
365                     m_irq_func(this, 0);
366                  }
367                  oscillators[i].irqpend = 0;
367368                  break;
368369               }
369370            }
r17874r17875
467468
468469            output_rate = (clock()/8)/(2+oscsenabled);
469470            m_stream->set_sample_rate(output_rate);
470            m_timer->adjust(attotime::from_hz(output_rate));
471            m_timer->adjust(attotime::from_hz(output_rate), 0, attotime::from_hz(output_rate));
471472            break;
472473
473474         case 0xe2:   // A/D converter

Previous 199869 Revisions Next


© 1997-2024 The MAME Team