src/emu/sound/asc.c
| r9415 | r9416 | |
| 101 | 101 | // LIVE DEVICE |
| 102 | 102 | //************************************************************************** |
| 103 | 103 | |
| 104 | // does nothing, this timer exists only to make MAME sync itself at our audio rate |
| 105 | static TIMER_CALLBACK( sync_timer_cb ) |
| 106 | { |
| 107 | asc_device *pDevice = (asc_device *)ptr; |
| 108 | |
| 109 | stream_update(pDevice->m_stream); |
| 110 | } |
| 111 | |
| 104 | 112 | //------------------------------------------------- |
| 105 | 113 | // asc_device - constructor |
| 106 | 114 | //------------------------------------------------- |
| r9415 | r9416 | |
| 125 | 133 | m_stream = stream_create(this, 0, 2, 22257, this, static_stream_generate); |
| 126 | 134 | |
| 127 | 135 | memset(m_regs, 0, sizeof(m_regs)); |
| 136 | |
| 137 | m_sync_timer = timer_alloc(this->machine, sync_timer_cb, this); |
| 128 | 138 | } |
| 129 | 139 | |
| 130 | 140 | |
| r9415 | r9416 | |
| 198 | 208 | m_fifo_cap_b--; |
| 199 | 209 | } |
| 200 | 210 | |
| 201 | | if ((m_fifo_cap_a) || (m_fifo_cap_b)) |
| 211 | switch (m_chip_type) |
| 202 | 212 | { |
| 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) |
| 207 | 219 | { |
| 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); |
| 214 | 221 | } |
| 215 | | break; |
| 222 | } |
| 223 | break; |
| 216 | 224 | |
| 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)) |
| 219 | 230 | { |
| 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); |
| 225 | 232 | } |
| 233 | } |
| 226 | 234 | |
| 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)) |
| 229 | 240 | { |
| 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); |
| 235 | 242 | } |
| 236 | | break; |
| 237 | | } |
| 243 | } |
| 244 | break; |
| 238 | 245 | } |
| 239 | 246 | |
| 240 | 247 | outL[i] = smpll * 64; |
| r9415 | r9416 | |
| 274 | 281 | } |
| 275 | 282 | break; |
| 276 | 283 | } |
| 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); |
| 277 | 286 | } |
| 278 | 287 | |
| 279 | 288 | //------------------------------------------------- |
| r9415 | r9416 | |
| 361 | 370 | // reading this register clears all bits |
| 362 | 371 | m_regs[R_FIFOSTAT-0x800] = 0; |
| 363 | 372 | |
| 364 | | // reading this clears interrupts? |
| 373 | // reading this clears interrupts |
| 365 | 374 | if (m_irq_cb) |
| 366 | 375 | { |
| 367 | 376 | m_irq_cb(this, 0); |
| r9415 | r9416 | |
| 425 | 434 | m_fifo_a[m_fifo_a_wrptr++] = data; |
| 426 | 435 | m_fifo_cap_a++; |
| 427 | 436 | |
| 428 | | if (m_fifo_cap_a == 0x800) |
| 437 | if (m_fifo_cap_a == 0x3ff) |
| 429 | 438 | { |
| 430 | 439 | m_regs[R_FIFOSTAT-0x800] |= 2; // fifo A full |
| 431 | 440 | } |
| r9415 | r9416 | |
| 444 | 453 | m_fifo_b[m_fifo_b_wrptr++] = data; |
| 445 | 454 | m_fifo_cap_b++; |
| 446 | 455 | |
| 447 | | if (m_fifo_cap_b == 0x800) |
| 456 | if (m_fifo_cap_b == 0x3ff) |
| 448 | 457 | { |
| 449 | 458 | m_regs[R_FIFOSTAT-0x800] |= 8; // fifo B full |
| 450 | 459 | } |
| r9415 | r9416 | |
| 471 | 480 | m_fifo_a_rdptr = m_fifo_b_rdptr = 0; |
| 472 | 481 | m_fifo_a_wrptr = m_fifo_b_wrptr = 0; |
| 473 | 482 | 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 | } |
| 474 | 492 | } |
| 475 | 493 | break; |
| 476 | 494 | |