Previous 15994 Revisions Next

r15379 Saturday 2nd June, 2012 at 01:03:21 UTC by R. Belmont
SoundBlaster: first-pass somewhat naive working version. Autoinit DMA does not work; use sblaster1_0, not 1_5! [R. Belmont]
[src/mess/machine]isa_sblaster.c isa_sblaster.h

src/mess/machine/isa_sblaster.c
r15378r15379
1414#include "sound/speaker.h"
1515#include "sound/3812intf.h"
1616#include "sound/saa1099.h"
17#include "sound/dac.h"
1718#include "machine/pic8259.h"
1819
1920/*
r15378r15379
9899   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
99100   MCFG_SOUND_ADD("saa1099.2", SAA1099, 4772720)
100101   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
102
103    MCFG_SOUND_ADD("sbdac", DAC, 0)
104    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
101105MACHINE_CONFIG_END
102106
103107static MACHINE_CONFIG_FRAGMENT( sblaster1_5_config )
r15378r15379
107111   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
108112   /* no CM/S support (empty sockets) */
109113
114    MCFG_SOUND_ADD("sbdac", DAC, 0)
115    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
110116MACHINE_CONFIG_END
111117
112118
r15378r15379
229235   m_dsp.dma_autoinit = 0;
230236   m_isa->irq5_w(0);
231237   m_timer->adjust(attotime::never, 0);
238    m_dsp.d_rptr = 0;
239    m_dsp.d_wptr = 0;
240    m_dsp.dma_throttled = false;
241    m_dsp.dma_timer_started = false;
232242
233243   //printf("%02x\n",data);
234244}
r15378r15379
253263READ8_MEMBER(sb8_device::dsp_rbuf_status_r)
254264{
255265//    printf("read Rbufstat @ %x\n", offset);
256    m_isa->irq5_w(0);   // reading this port ACKs the card's IRQ
257266
258267    if(offset)
259268      return 0xff;
260269
270//    printf("Clear IRQ5\n");
271    m_isa->irq5_w(0);   // reading this port ACKs the card's IRQ
272
261273   return m_dsp.rbuf_status;
262274}
263275
r15378r15379
288300   else if(m_dsp.fifo_ptr == m_cmd_fifo_length[cmd])
289301   {
290302      /* get FIFO params */
291        printf("SB FIFO command: %02x\n", cmd);
303//        printf("SB FIFO command: %02x\n", cmd);
292304      switch(cmd)
293305      {
294306            case 0x10:  // Direct DAC
r15378r15379
296308
297309            case 0x14:  // 8-bit DMA, no autoinit
298310                m_dsp.dma_length = (m_dsp.fifo[1] + (m_dsp.fifo[2]<<8)) + 1;
299                printf("Start DMA (not autoinit, size = %x)\n", m_dsp.dma_length);
311//                printf("Start DMA (not autoinit, size = %x)\n", m_dsp.dma_length);
300312                m_dsp.dma_transferred = 0;
301313                m_dsp.dma_autoinit = 0;
314                m_dsp.dma_timer_started = false;
315                m_dsp.dma_throttled = false;
302316                m_isa->drq1_w(1);
303317                break;
304318
305319            case 0x1c:  // 8-bit DMA with autoinit
306               printf("Start DMA (autoinit, size = %x)\n", m_dsp.dma_length);
320//               printf("Start DMA (autoinit, size = %x)\n", m_dsp.dma_length);
307321                m_dsp.dma_transferred = 0;
308322                m_dsp.dma_autoinit = 1;
323                m_dsp.dma_timer_started = false;
324                m_dsp.dma_throttled = false;
309325                m_isa->drq1_w(1);
310326               break;
311327
r15378r15379
321337            case 0xd0:  // halt 8-bit DMA
322338                m_timer->adjust(attotime::never, 0);
323339                m_isa->drq1_w(0);   // drop DRQ
340                m_dsp.dma_throttled = false;
341                m_dsp.dma_timer_started = false;
324342                break;
325343
326344            case 0xd1: // speaker on
r15378r15379
453471
454472sb8_device::sb8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, const char *name) :
455473    device_t(mconfig, type, name, tag, owner, clock),
456    device_isa8_card_interface(mconfig, *this)
474    device_isa8_card_interface(mconfig, *this),
475    m_dac(*this, "sbdac")
457476{
458477}
459478
r15378r15379
538557//  if(data != 0x80)
539558//      printf("%02x\n",data);
540559
541    // set the transfer over timer on the 1st byte
542    if (m_dsp.dma_transferred == 0)
560    // set the transfer timer on the 1st byte
561    if (!m_dsp.dma_timer_started)
543562    {
544        double time_constant = (double)m_dsp.frequency;
563        m_timer->adjust(attotime::from_hz((double)m_dsp.frequency), 0, attotime::from_hz((double)m_dsp.frequency));
564        m_dsp.d_rptr = m_dsp.d_wptr = 0;
565        m_dsp.dma_timer_started = true;
566    }
545567
546        time_constant /= (double)m_dsp.dma_length;
547//        printf("DMA timer set for %f Hz\n", time_constant);
568    m_dsp.data[m_dsp.d_wptr++] = data;
569    m_dsp.d_wptr %= 128;
548570
549        m_timer->adjust(attotime::from_hz(time_constant), 0);
571    if (m_dsp.d_wptr == m_dsp.d_rptr)
572    {
573//        printf("throttling DRQ\n");
574        m_isa->drq1_w(0);   // drop DRQ here
575        m_dsp.dma_throttled = true;
550576    }
551577
552578    m_dsp.dma_transferred++;
553579    if (m_dsp.dma_transferred >= m_dsp.dma_length)
554580    {
555581//        printf("DMA fill completed (%d out of %d)\n", m_dsp.dma_transferred, m_dsp.dma_length);
582
556583        m_isa->drq1_w(0);   // drop DRQ here
584
585        if (m_dsp.dma_autoinit)
586        {
587//            printf("autoinit reset\n");
588            m_dsp.dma_transferred = 0;
589            if (!m_dsp.dma_throttled)   // if we're not throttled, re-raise DRQ right now
590            {
591                m_isa->drq1_w(1);   // raise DRQ again (page 3-15 of the Creative manual indicates auto-init will keep going until you stop it)
592            }
593        }
594
595        m_isa->irq5_w(1);   // raise IRQ as per the Creative manual
557596    }
558597}
559598
560599void sb8_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
561600{
562    printf("DMA timer expire\n");
563    if(m_dsp.dma_autoinit)
601//    printf("DMA timer expire\n");
602
603    dac_data_w(m_dac, m_dsp.data[m_dsp.d_rptr]);
604    m_dsp.data[m_dsp.d_rptr++] = 0x80;
605    m_dsp.d_rptr %= 128;
606
607    if (m_dsp.dma_throttled)
564608    {
565        m_dsp.dma_transferred = 0;
566        m_isa->drq1_w(1);   // raise DRQ again (page 3-15 of the Creative manual indicates auto-init will keep going until you stop it)
609        if (m_dsp.d_rptr == m_dsp.d_wptr)
610        {
611//            printf("unthrottling DRQ\n");
612            m_isa->drq1_w(1);   // raise DRQ
613            m_dsp.dma_throttled = false;
614        }
567615    }
568
569    m_isa->irq5_w(1);   // raise IRQ as per the Creative manual
570
571    m_timer->adjust(attotime::never, 0);
572616}
src/mess/machine/isa_sblaster.h
r15378r15379
2525    UINT32 frequency;
2626    UINT32 dma_length, dma_transferred;
2727    UINT8 dma_autoinit;
28    UINT8 data[128], d_wptr, d_rptr;
29    bool dma_timer_started;
30    bool dma_throttled;
2831};
2932
3033// ======================> sb8_device (parent)
r15378r15379
3740        // construction/destruction
3841        sb8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, const char *name);
3942
43        required_device<device_t> m_dac;
44
4045        void process_fifo(UINT8 cmd);
4146        void queue(UINT8 data);
4247        void queue_r(UINT8 data);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team