src/mess/drivers/atarist.c
| r1014 | r1015 | |
| 453 | 453 | UINT32 base, end, cntr; |
| 454 | 454 | UINT32 baselatch, endlatch; |
| 455 | 455 | UINT16 ctrl, mode; |
| 456 | UINT8 fifo[8]; |
| 457 | UINT8 samples; |
| 458 | int active; |
| 456 | 459 | } dmasound; |
| 457 | 460 | |
| 458 | | static const int DMASOUND_RATE[] = { 6258, 12517, 25033, 50066 }; |
| 461 | static const int DMASOUND_RATE[] = { Y2/640/8, Y2/640/4, Y2/640/2, Y2/640 }; |
| 459 | 462 | |
| 460 | 463 | static mame_timer *dmasound_timer; |
| 461 | 464 | |
| 465 | static void atariste_dmasound_set_state(int state) |
| 466 | { |
| 467 | dmasound.active = state; |
| 468 | mfp68901_tai_w(0, state); |
| 469 | |
| 470 | if (state == 0) |
| 471 | { |
| 472 | dmasound.baselatch = dmasound.base; |
| 473 | dmasound.endlatch = dmasound.end; |
| 474 | } |
| 475 | else |
| 476 | { |
| 477 | dmasound.cntr = dmasound.baselatch; |
| 478 | } |
| 479 | } |
| 480 | |
| 462 | 481 | static TIMER_CALLBACK( atariste_dmasound_tick ) |
| 463 | 482 | { |
| 464 | | INT8 sample = (INT8) (memory_region(REGION_CPU1)[dmasound.cntr]); |
| 465 | | logerror("DMA sound sample %i\n", sample); |
| 483 | if (dmasound.samples == 0) |
| 484 | { |
| 485 | int i; |
| 486 | |
| 487 | for (i = 0; i < 8; i++) |
| 488 | { |
| 489 | dmasound.fifo[i] = memory_region(REGION_CPU1)[dmasound.cntr]; |
| 490 | dmasound.cntr++; |
| 491 | dmasound.samples++; |
| 492 | |
| 493 | if (dmasound.cntr == dmasound.endlatch) |
| 494 | { |
| 495 | atariste_dmasound_set_state(0); |
| 496 | break; |
| 497 | } |
| 498 | } |
| 499 | } |
| 466 | 500 | |
| 467 | | if (dmasound.cntr == dmasound.endlatch) |
| 501 | if (dmasound.ctrl & 0x80) |
| 468 | 502 | { |
| 469 | | if (dmasound.cntr & 0x02) |
| 503 | logerror("DMA sound left %i\n", dmasound.fifo[7 - dmasound.samples]); |
| 504 | dmasound.samples--; |
| 505 | |
| 506 | logerror("DMA sound right %i\n", dmasound.fifo[7 - dmasound.samples]); |
| 507 | dmasound.samples--; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | logerror("DMA sound mono %i\n", dmasound.fifo[7 - dmasound.samples]); |
| 512 | dmasound.samples--; |
| 513 | } |
| 514 | |
| 515 | if ((dmasound.samples == 0) && (dmasound.active == 0)) |
| 516 | { |
| 517 | if ((dmasound.ctrl & 0x03) == 0x03) |
| 470 | 518 | { |
| 471 | | dmasound.baselatch = dmasound.base; |
| 472 | | dmasound.endlatch = dmasound.end; |
| 473 | | dmasound.cntr = dmasound.baselatch; |
| 519 | atariste_dmasound_set_state(1); |
| 474 | 520 | } |
| 475 | 521 | else |
| 476 | 522 | { |
| 477 | 523 | mame_timer_enable(dmasound_timer, 0); |
| 478 | 524 | } |
| 479 | 525 | } |
| 480 | | |
| 481 | | dmasound.cntr++; |
| 482 | 526 | } |
| 483 | 527 | |
| 484 | 528 | static READ16_HANDLER( atariste_sound_dma_control_r ) |
| r1014 | r1015 | |
| 542 | 586 | |
| 543 | 587 | if (dmasound.ctrl & 0x01) |
| 544 | 588 | { |
| 545 | | if (!mame_timer_enabled(dmasound_timer)) |
| 589 | if (!dmasound.active) |
| 546 | 590 | { |
| 547 | | dmasound.baselatch = dmasound.base; |
| 548 | | dmasound.endlatch = dmasound.end; |
| 549 | | dmasound.cntr = dmasound.baselatch; |
| 550 | | |
| 591 | atariste_dmasound_set_state(1); |
| 551 | 592 | mame_timer_pulse(MAME_TIME_IN_HZ(DMASOUND_RATE[dmasound.mode & 0x03]), 0, atariste_dmasound_tick); |
| 552 | 593 | } |
| 553 | 594 | } |
| 554 | 595 | else |
| 555 | 596 | { |
| 597 | atariste_dmasound_set_state(0); |
| 556 | 598 | mame_timer_enable(dmasound_timer, 0); |
| 557 | 599 | } |
| 558 | 600 | } |
| r1014 | r1015 | |
| 571 | 613 | dmasound.base = (dmasound.base & 0x3fff00) | (data & 0xfe); |
| 572 | 614 | break; |
| 573 | 615 | } |
| 616 | |
| 617 | if (!dmasound.active) |
| 618 | { |
| 619 | dmasound.baselatch = dmasound.base; |
| 620 | } |
| 574 | 621 | } |
| 575 | 622 | |
| 576 | 623 | static WRITE16_HANDLER( atariste_sound_dma_end_w ) |
| r1014 | r1015 | |
| 587 | 634 | dmasound.end = (dmasound.end & 0x3fff00) | (data & 0xfe); |
| 588 | 635 | break; |
| 589 | 636 | } |
| 637 | |
| 638 | if (!dmasound.active) |
| 639 | { |
| 640 | dmasound.endlatch = dmasound.end; |
| 641 | } |
| 590 | 642 | } |
| 591 | 643 | |
| 592 | 644 | static WRITE16_HANDLER( atariste_sound_mode_w ) |
| r1014 | r1015 | |
| 759 | 811 | AM_RANGE(0xff8a3a, 0xff8a3b) AM_READWRITE(atarist_blitter_op_r, atarist_blitter_op_w) |
| 760 | 812 | AM_RANGE(0xff8a3c, 0xff8a3d) AM_READWRITE(atarist_blitter_ctrl_r, atarist_blitter_ctrl_w) |
| 761 | 813 | AM_RANGE(0xfffa00, 0xfffa3f) AM_READWRITE(mfp68901_0_register_lsb_r, mfp68901_0_register_msb_w) |
| 814 | // AM_RANGE(0xfffa40, 0xfffa57) AM_READWRITE(megast_fpu_r, megast_fpu_w) |
| 762 | 815 | AM_RANGE(0xfffc00, 0xfffc01) AM_READWRITE(acia6850_0_stat_msb_r, acia6850_0_ctrl_msb_w) |
| 763 | 816 | AM_RANGE(0xfffc02, 0xfffc03) AM_READWRITE(acia6850_0_data_msb_r, acia6850_0_data_msb_w) |
| 764 | 817 | AM_RANGE(0xfffc04, 0xfffc05) AM_READWRITE(acia6850_1_stat_msb_r, acia6850_1_ctrl_msb_w) |
| r1014 | r1015 | |
| 863 | 916 | AM_RANGE(0xff8a3c, 0xff8a3d) AM_READWRITE(atarist_blitter_ctrl_r, atarist_blitter_ctrl_w) |
| 864 | 917 | // AM_RANGE(0xff8e20, 0xff8e21) AM_READWRITE(megaste_cache_r, megaste_cache_w) |
| 865 | 918 | AM_RANGE(0xfffa00, 0xfffa3f) AM_READWRITE(mfp68901_0_register_lsb_r, mfp68901_0_register_msb_w) |
| 866 | | // AM_RANGE(0xfffa40, 0xfffa5f) AM_READWRITE(megaste_fpu_r, megaste_fpu_w) |
| 919 | // AM_RANGE(0xfffa40, 0xfffa5f) AM_READWRITE(megast_fpu_r, megast_fpu_w) |
| 867 | 920 | AM_RANGE(0xff8c80, 0xff8c87) AM_READWRITE(megaste_scc8530_r, megaste_scc8530_w) |
| 868 | 921 | AM_RANGE(0xfffc00, 0xfffc01) AM_READWRITE(acia6850_0_stat_msb_r, acia6850_0_ctrl_msb_w) |
| 869 | 922 | AM_RANGE(0xfffc02, 0xfffc03) AM_READWRITE(acia6850_0_data_msb_r, acia6850_0_data_msb_w) |
| r1014 | r1015 | |
| 1216 | 1269 | } |
| 1217 | 1270 | }; |
| 1218 | 1271 | |
| 1219 | | static MACHINE_START( atarist ) |
| 1272 | static void atarist_configure_memory(void) |
| 1220 | 1273 | { |
| 1221 | 1274 | switch (mess_ram_size) |
| 1222 | 1275 | { |
| r1014 | r1015 | |
| 1263 | 1316 | |
| 1264 | 1317 | memory_configure_bank(3, 0, 1, memory_region(REGION_CPU1) + 0xfa0000, 0); |
| 1265 | 1318 | memory_set_bank(3, 0); |
| 1319 | } |
| 1266 | 1320 | |
| 1267 | | centronics_config(0, atarist_centronics_config); |
| 1268 | | wd17xx_init(WD_TYPE_1772, atarist_fdc_callback, NULL); |
| 1269 | | acia6850_config(0, &acia_ikbd_intf); |
| 1270 | | acia6850_config(1, &acia_midi_intf); |
| 1271 | | mfp68901_config(0, &mfp_intf); |
| 1272 | | |
| 1321 | static void atarist_state_save(void) |
| 1322 | { |
| 1273 | 1323 | memset(&fdc, 0, sizeof(fdc)); |
| 1274 | 1324 | memset(&ikbd, 0, sizeof(ikbd)); |
| 1275 | 1325 | |
| r1014 | r1015 | |
| 1295 | 1345 | state_save_register_global(mfp_tx); |
| 1296 | 1346 | } |
| 1297 | 1347 | |
| 1348 | static MACHINE_START( atarist ) |
| 1349 | { |
| 1350 | atarist_configure_memory(); |
| 1351 | atarist_state_save(); |
| 1352 | |
| 1353 | centronics_config(0, atarist_centronics_config); |
| 1354 | wd17xx_init(WD_TYPE_1772, atarist_fdc_callback, NULL); |
| 1355 | acia6850_config(0, &acia_ikbd_intf); |
| 1356 | acia6850_config(1, &acia_midi_intf); |
| 1357 | mfp68901_config(0, &mfp_intf); |
| 1358 | } |
| 1359 | |
| 1298 | 1360 | static struct rp5c15_interface rtc_intf = |
| 1299 | 1361 | { |
| 1300 | 1362 | NULL |
| r1014 | r1015 | |
| 1306 | 1368 | rp5c15_init(&rtc_intf); |
| 1307 | 1369 | } |
| 1308 | 1370 | |
| 1309 | | static MACHINE_START( atariste ) |
| 1371 | static READ8_HANDLER( atariste_mfp_gpio_r ) |
| 1310 | 1372 | { |
| 1311 | | machine_start_atarist(machine); |
| 1373 | /* |
| 1312 | 1374 | |
| 1375 | bit description |
| 1376 | |
| 1377 | 0 Centronics BUSY |
| 1378 | 1 RS232 DCD |
| 1379 | 2 RS232 CTS |
| 1380 | 3 Blitter done |
| 1381 | 4 Keyboard/MIDI |
| 1382 | 5 FDC |
| 1383 | 6 RS232 RI |
| 1384 | 7 Monochrome monitor detect / DMA sound active |
| 1385 | |
| 1386 | */ |
| 1387 | |
| 1388 | UINT8 data = (centronics_read_handshake(0) & CENTRONICS_NOT_BUSY) >> 7; |
| 1389 | |
| 1390 | data |= (acia_irq << 4); |
| 1391 | data |= (fdc.irq << 5); |
| 1392 | data |= (readinputportbytag("config") & 0x80) ^ (dmasound.active << 7); |
| 1393 | |
| 1394 | return data; |
| 1395 | } |
| 1396 | |
| 1397 | static const mfp68901_interface atariste_mfp_intf = |
| 1398 | { |
| 1399 | Y2/8, |
| 1400 | Y1, |
| 1401 | MFP68901_TDO_LOOPBACK, |
| 1402 | MFP68901_TDO_LOOPBACK, |
| 1403 | &mfp_rx, |
| 1404 | &mfp_tx, |
| 1405 | NULL, |
| 1406 | mfp_interrupt, |
| 1407 | atariste_mfp_gpio_r, |
| 1408 | NULL |
| 1409 | }; |
| 1410 | |
| 1411 | static void atariste_state_save(void) |
| 1412 | { |
| 1313 | 1413 | memset(&mwire, 0, sizeof(mwire)); |
| 1314 | 1414 | memset(&dmasound, 0, sizeof(dmasound)); |
| 1315 | 1415 | |
| r1014 | r1015 | |
| 1320 | 1420 | state_save_register_global(dmasound.endlatch); |
| 1321 | 1421 | state_save_register_global(dmasound.ctrl); |
| 1322 | 1422 | state_save_register_global(dmasound.mode); |
| 1423 | state_save_register_global_array(dmasound.fifo); |
| 1424 | state_save_register_global(dmasound.samples); |
| 1425 | state_save_register_global(dmasound.active); |
| 1323 | 1426 | |
| 1324 | 1427 | state_save_register_global(mwire.data); |
| 1325 | 1428 | state_save_register_global(mwire.mask); |
| 1326 | 1429 | state_save_register_global(mwire.shift); |
| 1327 | 1430 | } |
| 1328 | 1431 | |
| 1432 | static MACHINE_START( atariste ) |
| 1433 | { |
| 1434 | atarist_configure_memory(); |
| 1435 | atariste_state_save(); |
| 1436 | |
| 1437 | centronics_config(0, atarist_centronics_config); |
| 1438 | wd17xx_init(WD_TYPE_1772, atarist_fdc_callback, NULL); |
| 1439 | acia6850_config(0, &acia_ikbd_intf); |
| 1440 | acia6850_config(1, &acia_midi_intf); |
| 1441 | mfp68901_config(0, &atariste_mfp_intf); |
| 1442 | } |
| 1443 | |
| 1329 | 1444 | static MACHINE_START( megaste ) |
| 1330 | 1445 | { |
| 1331 | 1446 | machine_start_atariste(machine); |