Previous 15994 Revisions Next

r14068 Monday 16th January, 2012 at 21:25:23 UTC by R. Belmont
SoundBlaster: added DMA timer for more realistic IRQ acks, added 0xD0 stop DMA command, cleaned up DRQ semantics. [R. Belmont]
[src/mess/machine]isa_sblaster.c isa_sblaster.h

src/mess/machine/isa_sblaster.c
r14067r14068
5151   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, /* Ax */
5252   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, /* Bx */
5353   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, /* Cx */
54   -1,  1, -1,  1, -1, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1, /* Dx */
54    1,  1, -1,  1, -1, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1, /* Dx */
5555    2,  1,  2, -1,  2, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1, /* Ex */
5656   -1, -1,  1, -1, -1, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1  /* Fx */
5757};
r14067r14068
270270            case 0x10:  // Direct DAC
271271                break;
272272
273            case 0x14:  // 8-bit DMA
273            case 0x14:  // 8-bit DMA, no autoinit
274274                m_dsp.dma_length = (m_dsp.fifo[1] + (m_dsp.fifo[2]<<8)) + 1;
275//                printf("Start DMA (not autoinit, size = %x)\n", m_dsp.dma_length);
275                printf("Start DMA (not autoinit, size = %x)\n", m_dsp.dma_length);
276276                m_dsp.dma_transferred = 0;
277277                m_dsp.dma_autoinit = 0;
278278                m_isa->drq1_w(1);
279279                break;
280280
281            case 0x1c:
281            case 0x1c:  // 8-bit DMA with autoinit
282282               printf("Start DMA (autoinit, size = %x)\n", m_dsp.dma_length);
283283                m_dsp.dma_transferred = 0;
284284                m_dsp.dma_autoinit = 1;
285285                m_isa->drq1_w(1);
286286               break;
287287
288
289288            case 0x40:  // set time constant
290289                m_dsp.frequency = (1000000 / (256 - m_dsp.fifo[1]));
291290                printf("Set time constant: %02x -> %d\n", m_dsp.fifo[1], m_dsp.frequency);
r14067r14068
295294                m_dsp.dma_length = (m_dsp.fifo[1] + (m_dsp.fifo[2]<<8)) + 1;
296295            break;
297296
297            case 0xd0:  // halt 8-bit DMA
298                m_timer->adjust(attotime::never, 0);
299                m_isa->drq1_w(0);   // drop DRQ
300                break;
301
298302            case 0xd1: // speaker on
299303            // ...
300304            m_dsp.speaker_on = 1;
r14067r14068
421425
422426void sb8_device::device_start()
423427{
428   m_isa->install_device(                   0x0226, 0x0227, 0, 0, read8_delegate(FUNC(sb8_device::dsp_reset_r), this), write8_delegate(FUNC(sb8_device::dsp_reset_w), this));
429   m_isa->install_device(subdevice("ym3812"),    0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
430   m_isa->install_device(                   0x022a, 0x022b, 0, 0, read8_delegate(FUNC(sb8_device::dsp_data_r), this), write8_delegate(FUNC(sb8_device::dsp_data_w), this) );
431   m_isa->install_device(                   0x022c, 0x022d, 0, 0, read8_delegate(FUNC(sb8_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_cmd_w), this) );
432   m_isa->install_device(                   0x022e, 0x022f, 0, 0, read8_delegate(FUNC(sb8_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_rbuf_status_w), this) );
433   m_isa->install_device(subdevice("ym3812"),    0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
434
435    m_timer = timer_alloc(0, NULL);
424436}
425437
426438void isa8_sblaster1_0_device::device_start()
427439{
428440    set_isa_device();
441    // 1.0 always has the SAA1099s for CMS back-compatibility
429442   m_isa->install_device(subdevice("saa1099.1"), 0x0220, 0x0221, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) );
430443   m_isa->install_device(subdevice("saa1099.2"), 0x0222, 0x0223, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) );
431   m_isa->install_device(                   0x0226, 0x0227, 0, 0, read8_delegate(FUNC(sb8_device::dsp_reset_r), this), write8_delegate(FUNC(sb8_device::dsp_reset_w), this));
432   m_isa->install_device(subdevice("ym3812"),    0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
433   m_isa->install_device(                   0x022a, 0x022b, 0, 0, read8_delegate(FUNC(sb8_device::dsp_data_r), this), write8_delegate(FUNC(sb8_device::dsp_data_w), this) );
434   m_isa->install_device(                   0x022c, 0x022d, 0, 0, read8_delegate(FUNC(sb8_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_cmd_w), this) );
435   m_isa->install_device(                   0x022e, 0x022f, 0, 0, read8_delegate(FUNC(sb8_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_rbuf_status_w), this) );
436   m_isa->install_device(subdevice("ym3812"),    0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
437444   m_dsp.version = 0x0105;
445    sb8_device::device_start();
438446}
439447
440448void isa8_sblaster1_5_device::device_start()
441449{
442450    set_isa_device();
443451   /* 1.5 makes CM/S support optional (empty sockets, but they work if the user populates them!) */
444   m_isa->install_device(                   0x0226, 0x0227, 0, 0, read8_delegate(FUNC(sb8_device::dsp_reset_r), this), write8_delegate(FUNC(sb8_device::dsp_reset_w), this));
445   m_isa->install_device(subdevice("ym3812"),    0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
446   m_isa->install_device(                   0x022a, 0x022b, 0, 0, read8_delegate(FUNC(sb8_device::dsp_data_r), this), write8_delegate(FUNC(sb8_device::dsp_data_w), this) );
447   m_isa->install_device(                   0x022c, 0x022d, 0, 0, read8_delegate(FUNC(sb8_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_cmd_w), this) );
448   m_isa->install_device(                   0x022e, 0x022f, 0, 0, read8_delegate(FUNC(sb8_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_rbuf_status_w), this) );
449   m_isa->install_device(subdevice("ym3812"),    0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
450452   m_dsp.version = 0x0200;
453    sb8_device::device_start();
451454}
452455
453456//-------------------------------------------------
r14067r14068
482485//    printf("dack_w: line %x data %02x\n", line, data);
483486//   if(data != 0x80)
484487//      printf("%02x\n",data);
488
489    // set the transfer over timer on the 1st byte
490    if (m_dsp.dma_transferred == 0)
491    {
492        double time_constant = (double)m_dsp.frequency;
493
494        time_constant /= (double)m_dsp.dma_length;
495//        printf("DMA timer set for %f Hz\n", time_constant);
496
497        m_timer->adjust(attotime::from_hz(time_constant), 0);
498    }
499
485500    m_dsp.dma_transferred++;
486501    if (m_dsp.dma_transferred >= m_dsp.dma_length)
487502    {
488        //printf("DMA completed\n");
489        if(m_dsp.dma_autoinit)
490         m_dsp.dma_transferred = 0;
503//        printf("DMA fill completed (%d out of %d)\n", m_dsp.dma_transferred, m_dsp.dma_length);
504        m_isa->drq1_w(0);   // drop DRQ here
505    }
506}
491507
492         m_isa->drq1_w(0);   // drop DRQ?
493         m_isa->irq5_w(1);   // definitely raise IRQ as per the Creative manual
508void sb8_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
509{
510    printf("DMA timer expire\n");
511    if(m_dsp.dma_autoinit)
512    {
513        m_dsp.dma_transferred = 0;
514        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)
494515    }
516
517    m_isa->irq5_w(1);   // raise IRQ as per the Creative manual
518
519    m_timer->adjust(attotime::never, 0);
495520}
496
src/mess/machine/isa_sblaster.h
r14067r14068
5555        // device-level overrides
5656        virtual void device_start();
5757        virtual void device_reset();
58      virtual bool have_dack(int line);
58        virtual bool have_dack(int line);
5959        virtual UINT8 dack_r(int line);
6060        virtual void dack_w(int line, UINT8 data);
61        virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
6162
6263        struct sb8_dsp_state m_dsp;
6364        UINT8 m_dack_out;
65
6466private:
67        emu_timer *m_timer;
6568};
6669
6770class isa8_sblaster1_0_device : public sb8_device

Previous 15994 Revisions Next


© 1998-2018 The MESS Team