src/mess/machine/isa_sblaster.c
| r15378 | r15379 | |
| 14 | 14 | #include "sound/speaker.h" |
| 15 | 15 | #include "sound/3812intf.h" |
| 16 | 16 | #include "sound/saa1099.h" |
| 17 | #include "sound/dac.h" |
| 17 | 18 | #include "machine/pic8259.h" |
| 18 | 19 | |
| 19 | 20 | /* |
| r15378 | r15379 | |
| 98 | 99 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 99 | 100 | MCFG_SOUND_ADD("saa1099.2", SAA1099, 4772720) |
| 100 | 101 | 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) |
| 101 | 105 | MACHINE_CONFIG_END |
| 102 | 106 | |
| 103 | 107 | static MACHINE_CONFIG_FRAGMENT( sblaster1_5_config ) |
| r15378 | r15379 | |
| 107 | 111 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 108 | 112 | /* no CM/S support (empty sockets) */ |
| 109 | 113 | |
| 114 | MCFG_SOUND_ADD("sbdac", DAC, 0) |
| 115 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 110 | 116 | MACHINE_CONFIG_END |
| 111 | 117 | |
| 112 | 118 | |
| r15378 | r15379 | |
| 229 | 235 | m_dsp.dma_autoinit = 0; |
| 230 | 236 | m_isa->irq5_w(0); |
| 231 | 237 | 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; |
| 232 | 242 | |
| 233 | 243 | //printf("%02x\n",data); |
| 234 | 244 | } |
| r15378 | r15379 | |
| 253 | 263 | READ8_MEMBER(sb8_device::dsp_rbuf_status_r) |
| 254 | 264 | { |
| 255 | 265 | // printf("read Rbufstat @ %x\n", offset); |
| 256 | | m_isa->irq5_w(0); // reading this port ACKs the card's IRQ |
| 257 | 266 | |
| 258 | 267 | if(offset) |
| 259 | 268 | return 0xff; |
| 260 | 269 | |
| 270 | // printf("Clear IRQ5\n"); |
| 271 | m_isa->irq5_w(0); // reading this port ACKs the card's IRQ |
| 272 | |
| 261 | 273 | return m_dsp.rbuf_status; |
| 262 | 274 | } |
| 263 | 275 | |
| r15378 | r15379 | |
| 288 | 300 | else if(m_dsp.fifo_ptr == m_cmd_fifo_length[cmd]) |
| 289 | 301 | { |
| 290 | 302 | /* get FIFO params */ |
| 291 | | printf("SB FIFO command: %02x\n", cmd); |
| 303 | // printf("SB FIFO command: %02x\n", cmd); |
| 292 | 304 | switch(cmd) |
| 293 | 305 | { |
| 294 | 306 | case 0x10: // Direct DAC |
| r15378 | r15379 | |
| 296 | 308 | |
| 297 | 309 | case 0x14: // 8-bit DMA, no autoinit |
| 298 | 310 | 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); |
| 300 | 312 | m_dsp.dma_transferred = 0; |
| 301 | 313 | m_dsp.dma_autoinit = 0; |
| 314 | m_dsp.dma_timer_started = false; |
| 315 | m_dsp.dma_throttled = false; |
| 302 | 316 | m_isa->drq1_w(1); |
| 303 | 317 | break; |
| 304 | 318 | |
| 305 | 319 | 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); |
| 307 | 321 | m_dsp.dma_transferred = 0; |
| 308 | 322 | m_dsp.dma_autoinit = 1; |
| 323 | m_dsp.dma_timer_started = false; |
| 324 | m_dsp.dma_throttled = false; |
| 309 | 325 | m_isa->drq1_w(1); |
| 310 | 326 | break; |
| 311 | 327 | |
| r15378 | r15379 | |
| 321 | 337 | case 0xd0: // halt 8-bit DMA |
| 322 | 338 | m_timer->adjust(attotime::never, 0); |
| 323 | 339 | m_isa->drq1_w(0); // drop DRQ |
| 340 | m_dsp.dma_throttled = false; |
| 341 | m_dsp.dma_timer_started = false; |
| 324 | 342 | break; |
| 325 | 343 | |
| 326 | 344 | case 0xd1: // speaker on |
| r15378 | r15379 | |
| 453 | 471 | |
| 454 | 472 | sb8_device::sb8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, const char *name) : |
| 455 | 473 | 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") |
| 457 | 476 | { |
| 458 | 477 | } |
| 459 | 478 | |
| r15378 | r15379 | |
| 538 | 557 | // if(data != 0x80) |
| 539 | 558 | // printf("%02x\n",data); |
| 540 | 559 | |
| 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) |
| 543 | 562 | { |
| 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 | } |
| 545 | 567 | |
| 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; |
| 548 | 570 | |
| 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; |
| 550 | 576 | } |
| 551 | 577 | |
| 552 | 578 | m_dsp.dma_transferred++; |
| 553 | 579 | if (m_dsp.dma_transferred >= m_dsp.dma_length) |
| 554 | 580 | { |
| 555 | 581 | // printf("DMA fill completed (%d out of %d)\n", m_dsp.dma_transferred, m_dsp.dma_length); |
| 582 | |
| 556 | 583 | 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 |
| 557 | 596 | } |
| 558 | 597 | } |
| 559 | 598 | |
| 560 | 599 | void sb8_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr) |
| 561 | 600 | { |
| 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) |
| 564 | 608 | { |
| 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 | } |
| 567 | 615 | } |
| 568 | | |
| 569 | | m_isa->irq5_w(1); // raise IRQ as per the Creative manual |
| 570 | | |
| 571 | | m_timer->adjust(attotime::never, 0); |
| 572 | 616 | } |