trunk/src/mame/video/antic.c
| r32026 | r32027 | |
| 6 | 6 | Juergen Buchmueller, June 1998 |
| 7 | 7 | ******************************************************************************/ |
| 8 | 8 | |
| 9 | | #include "emu.h" |
| 10 | 9 | #include "antic.h" |
| 11 | | #include "includes/atari.h" |
| 12 | | #include "cpu/m6502/m6502.h" |
| 13 | 10 | |
| 14 | 11 | #ifdef MAME_DEBUG |
| 15 | 12 | #define VERBOSE 1 |
| r32026 | r32027 | |
| 19 | 16 | |
| 20 | 17 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 21 | 18 | |
| 19 | // devices |
| 20 | const device_type ATARI_ANTIC = &device_creator<antic_device>; |
| 21 | |
| 22 | //------------------------------------------------- |
| 23 | // upd7220_device - constructor |
| 24 | //------------------------------------------------- |
| 25 | |
| 26 | antic_device::antic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 27 | device_t(mconfig, ATARI_ANTIC, "Atari ANTIC", tag, owner, clock, "antic", __FILE__), |
| 28 | m_gtia_tag(NULL) |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | |
| 33 | //------------------------------------------------- |
| 34 | // device_start - device-specific startup |
| 35 | //------------------------------------------------- |
| 36 | |
| 37 | void antic_device::device_start() |
| 38 | { |
| 39 | m_gtia = machine().device<gtia_device>(m_gtia_tag); |
| 40 | assert(m_gtia); |
| 41 | |
| 42 | /* save states */ |
| 43 | save_pointer(NAME((UINT8 *) &m_r), sizeof(m_r)); |
| 44 | save_pointer(NAME((UINT8 *) &m_w), sizeof(m_w)); |
| 45 | |
| 46 | m_bitmap = auto_bitmap_ind16_alloc(machine(), machine().first_screen()->width(), machine().first_screen()->height()); |
| 47 | |
| 48 | m_cclk_expand = auto_alloc_array(machine(), UINT32, 21 * 256); |
| 49 | |
| 50 | m_pf_21 = &m_cclk_expand[ 0 * 256]; |
| 51 | m_pf_x10b = &m_cclk_expand[ 1 * 256]; |
| 52 | m_pf_3210b2 = &m_cclk_expand[ 3 * 256]; |
| 53 | m_pf_210b4 = &m_cclk_expand[11 * 256]; |
| 54 | m_pf_210b2 = &m_cclk_expand[15 * 256]; |
| 55 | m_pf_1b = &m_cclk_expand[17 * 256]; |
| 56 | m_pf_gtia1 = &m_cclk_expand[18 * 256]; |
| 57 | m_pf_gtia2 = &m_cclk_expand[19 * 256]; |
| 58 | m_pf_gtia3 = &m_cclk_expand[20 * 256]; |
| 59 | |
| 60 | m_used_colors = auto_alloc_array(machine(), UINT8, 21 * 256); |
| 61 | |
| 62 | memset(m_used_colors, 0, 21 * 256 * sizeof(UINT8)); |
| 63 | |
| 64 | m_uc_21 = &m_used_colors[ 0 * 256]; |
| 65 | m_uc_x10b = &m_used_colors[ 1 * 256]; |
| 66 | m_uc_3210b2 = &m_used_colors[ 3 * 256]; |
| 67 | m_uc_210b4 = &m_used_colors[11 * 256]; |
| 68 | m_uc_210b2 = &m_used_colors[15 * 256]; |
| 69 | m_uc_1b = &m_used_colors[17 * 256]; |
| 70 | m_uc_g1 = &m_used_colors[18 * 256]; |
| 71 | m_uc_g2 = &m_used_colors[19 * 256]; |
| 72 | m_uc_g3 = &m_used_colors[20 * 256]; |
| 73 | |
| 74 | LOG(("atari cclk_init\n")); |
| 75 | cclk_init(); |
| 76 | |
| 77 | for (int i = 0; i < 64; i++) |
| 78 | m_prio_table[i] = auto_alloc_array(machine(), UINT8, 8*256); |
| 79 | |
| 80 | LOG(("atari prio_init\n")); |
| 81 | prio_init(); |
| 82 | |
| 83 | for (int i = 0; i < machine().first_screen()->height(); i++) |
| 84 | m_video[i] = auto_alloc_clear(machine(), VIDEO); |
| 85 | } |
| 86 | |
| 87 | |
| 88 | //------------------------------------------------- |
| 89 | // device_reset - device-specific reset |
| 90 | //------------------------------------------------- |
| 91 | |
| 92 | void antic_device::device_reset() |
| 93 | { |
| 94 | /* reset the ANTIC read / write registers */ |
| 95 | memset(&m_r, 0, sizeof(m_r)); |
| 96 | memset(&m_w, 0, sizeof(m_w)); |
| 97 | m_r.antic00 = 0xff; |
| 98 | m_r.antic01 = 0xff; |
| 99 | m_r.antic02 = 0xff; |
| 100 | m_r.antic03 = 0xff; |
| 101 | m_r.antic04 = 0xff; |
| 102 | m_r.antic05 = 0xff; |
| 103 | m_r.antic06 = 0xff; |
| 104 | m_r.antic07 = 0xff; |
| 105 | m_r.antic08 = 0xff; |
| 106 | m_r.antic09 = 0xff; |
| 107 | m_r.antic0a = 0xff; |
| 108 | m_r.penh = 0x00; |
| 109 | m_r.penv = 0x00; |
| 110 | m_r.antic0e = 0xff; |
| 111 | m_r.nmist = 0x1f; |
| 112 | |
| 113 | m_render1 = 0; |
| 114 | m_render2 = 0; |
| 115 | m_render3 = 0; |
| 116 | m_tv_artifacts = 0; |
| 117 | } |
| 118 | |
| 119 | |
| 22 | 120 | /************************************************************************* |
| 23 | 121 | * The priority tables tell which playfield, player or missile colors |
| 24 | 122 | * have precedence about the others, depending on the contents of the |
| r32026 | r32027 | |
| 77 | 175 | * luminance of the modes foreground (ie. colpf1). |
| 78 | 176 | * Any combination of players/missiles (256) is checked for the highest |
| 79 | 177 | * priority player or missile and the resulting color is stored into |
| 80 | | * antic.prio_table. The second part (20-3F) contains the resulting |
| 178 | * m_prio_table. The second part (20-3F) contains the resulting |
| 81 | 179 | * color values for the EOR mode, which is derived from the *visible* |
| 82 | 180 | * player/missile colors calculated for the first part (00-1F). |
| 83 | 181 | * The priorities of combining priority bits (which games use!) are: |
| r32026 | r32027 | |
| 409 | 507 | * prio_init |
| 410 | 508 | * Initialize player/missile priority lookup tables |
| 411 | 509 | ************************************************************************/ |
| 412 | | void prio_init() |
| 510 | void antic_device::prio_init() |
| 413 | 511 | { |
| 414 | 512 | int i, j, pm, p, c; |
| 415 | 513 | const UINT8 * prio; |
| r32026 | r32027 | |
| 430 | 528 | if (((prio[p] & pm) == prio[p]) && (prio[p+1])) |
| 431 | 529 | c = prio[p+1]; |
| 432 | 530 | } |
| 433 | | antic.prio_table[i][(j << 8) + pm] = c; |
| 531 | m_prio_table[i][(j << 8) + pm] = c; |
| 434 | 532 | if( (c==PL0 || c==P000 || c==P001 || c==P010 || c==P011) && |
| 435 | 533 | (pm & (P0+P1))==(P0+P1)) |
| 436 | 534 | c = EOR; |
| 437 | 535 | if( (c==PL2 || c==P200 || c==P201 || c==P210 || c==P211) && |
| 438 | 536 | (pm & (P2+P3))==(P2+P3)) |
| 439 | 537 | c = EOR; |
| 440 | | antic.prio_table[32 + i][(j << 8) + pm] = c; |
| 538 | m_prio_table[32 + i][(j << 8) + pm] = c; |
| 441 | 539 | } |
| 442 | 540 | } |
| 443 | 541 | } |
| r32026 | r32027 | |
| 447 | 545 | * cclk_init |
| 448 | 546 | * Initialize "color clock" lookup tables |
| 449 | 547 | ************************************************************************/ |
| 450 | | static void cclk_init() |
| 548 | void antic_device::cclk_init() |
| 451 | 549 | { |
| 452 | 550 | static const UINT8 _pf_21[4] = {T00,T01,T10,T11}; |
| 453 | 551 | static const UINT8 _pf_1b[4] = {G00,G01,G10,G11}; |
| r32026 | r32027 | |
| 460 | 558 | for( i = 0; i < 256; i++ ) |
| 461 | 559 | { |
| 462 | 560 | /****** text mode (2,3) **********/ |
| 463 | | dst = (UINT8 *)&antic.pf_21[0x000+i]; |
| 561 | dst = (UINT8 *)&m_pf_21[0x000+i]; |
| 464 | 562 | *dst++ = _pf_21[(i>>6)&3]; |
| 465 | 563 | *dst++ = _pf_21[(i>>4)&3]; |
| 466 | 564 | *dst++ = _pf_21[(i>>2)&3]; |
| 467 | 565 | *dst++ = _pf_21[(i>>0)&3]; |
| 468 | 566 | |
| 469 | 567 | /****** 4 color text (4,5) with pf2, D, E **********/ |
| 470 | | dst = (UINT8 *)&antic.pf_x10b[0x000+i]; |
| 568 | dst = (UINT8 *)&m_pf_x10b[0x000+i]; |
| 471 | 569 | *dst++ = _pf_210b[(i>>6)&3]; |
| 472 | 570 | *dst++ = _pf_210b[(i>>4)&3]; |
| 473 | 571 | *dst++ = _pf_210b[(i>>2)&3]; |
| 474 | 572 | *dst++ = _pf_210b[(i>>0)&3]; |
| 475 | | dst = (UINT8 *)&antic.pf_x10b[0x100+i]; |
| 573 | dst = (UINT8 *)&m_pf_x10b[0x100+i]; |
| 476 | 574 | *dst++ = _pf_310b[(i>>6)&3]; |
| 477 | 575 | *dst++ = _pf_310b[(i>>4)&3]; |
| 478 | 576 | *dst++ = _pf_310b[(i>>2)&3]; |
| 479 | 577 | *dst++ = _pf_310b[(i>>0)&3]; |
| 480 | 578 | |
| 481 | 579 | /****** pf0 color text (6,7), 9, B, C **********/ |
| 482 | | dst = (UINT8 *)&antic.pf_3210b2[0x000+i*2]; |
| 580 | dst = (UINT8 *)&m_pf_3210b2[0x000+i*2]; |
| 483 | 581 | *dst++ = (i&0x80)?PF0:PBK; |
| 484 | 582 | *dst++ = (i&0x40)?PF0:PBK; |
| 485 | 583 | *dst++ = (i&0x20)?PF0:PBK; |
| r32026 | r32027 | |
| 490 | 588 | *dst++ = (i&0x01)?PF0:PBK; |
| 491 | 589 | |
| 492 | 590 | /****** pf1 color text (6,7), 9, B, C **********/ |
| 493 | | dst = (UINT8 *)&antic.pf_3210b2[0x200+i*2]; |
| 591 | dst = (UINT8 *)&m_pf_3210b2[0x200+i*2]; |
| 494 | 592 | *dst++ = (i&0x80)?PF1:PBK; |
| 495 | 593 | *dst++ = (i&0x40)?PF1:PBK; |
| 496 | 594 | *dst++ = (i&0x20)?PF1:PBK; |
| r32026 | r32027 | |
| 501 | 599 | *dst++ = (i&0x01)?PF1:PBK; |
| 502 | 600 | |
| 503 | 601 | /****** pf2 color text (6,7), 9, B, C **********/ |
| 504 | | dst = (UINT8 *)&antic.pf_3210b2[0x400+i*2]; |
| 602 | dst = (UINT8 *)&m_pf_3210b2[0x400+i*2]; |
| 505 | 603 | *dst++ = (i&0x80)?PF2:PBK; |
| 506 | 604 | *dst++ = (i&0x40)?PF2:PBK; |
| 507 | 605 | *dst++ = (i&0x20)?PF2:PBK; |
| r32026 | r32027 | |
| 512 | 610 | *dst++ = (i&0x01)?PF2:PBK; |
| 513 | 611 | |
| 514 | 612 | /****** pf3 color text (6,7), 9, B, C **********/ |
| 515 | | dst = (UINT8 *)&antic.pf_3210b2[0x600+i*2]; |
| 613 | dst = (UINT8 *)&m_pf_3210b2[0x600+i*2]; |
| 516 | 614 | *dst++ = (i&0x80)?PF3:PBK; |
| 517 | 615 | *dst++ = (i&0x40)?PF3:PBK; |
| 518 | 616 | *dst++ = (i&0x20)?PF3:PBK; |
| r32026 | r32027 | |
| 523 | 621 | *dst++ = (i&0x01)?PF3:PBK; |
| 524 | 622 | |
| 525 | 623 | /****** 4 color graphics 4 cclks (8) **********/ |
| 526 | | dst = (UINT8 *)&antic.pf_210b4[i*4]; |
| 624 | dst = (UINT8 *)&m_pf_210b4[i*4]; |
| 527 | 625 | *dst++ = _pf_210b[(i>>6)&3]; |
| 528 | 626 | *dst++ = _pf_210b[(i>>6)&3]; |
| 529 | 627 | *dst++ = _pf_210b[(i>>6)&3]; |
| r32026 | r32027 | |
| 542 | 640 | *dst++ = _pf_210b[(i>>0)&3]; |
| 543 | 641 | |
| 544 | 642 | /****** 4 color graphics 2 cclks (A) **********/ |
| 545 | | dst = (UINT8 *)&antic.pf_210b2[i*2]; |
| 643 | dst = (UINT8 *)&m_pf_210b2[i*2]; |
| 546 | 644 | *dst++ = _pf_210b[(i>>6)&3]; |
| 547 | 645 | *dst++ = _pf_210b[(i>>6)&3]; |
| 548 | 646 | *dst++ = _pf_210b[(i>>4)&3]; |
| r32026 | r32027 | |
| 553 | 651 | *dst++ = _pf_210b[(i>>0)&3]; |
| 554 | 652 | |
| 555 | 653 | /****** high resolution graphics (F) **********/ |
| 556 | | dst = (UINT8 *)&antic.pf_1b[i]; |
| 654 | dst = (UINT8 *)&m_pf_1b[i]; |
| 557 | 655 | *dst++ = _pf_1b[(i>>6)&3]; |
| 558 | 656 | *dst++ = _pf_1b[(i>>4)&3]; |
| 559 | 657 | *dst++ = _pf_1b[(i>>2)&3]; |
| 560 | 658 | *dst++ = _pf_1b[(i>>0)&3]; |
| 561 | 659 | |
| 562 | 660 | /****** gtia mode 1 **********/ |
| 563 | | dst = (UINT8 *)&antic.pf_gtia1[i]; |
| 661 | dst = (UINT8 *)&m_pf_gtia1[i]; |
| 564 | 662 | *dst++ = GT1+((i>>4)&15); |
| 565 | 663 | *dst++ = GT1+((i>>4)&15); |
| 566 | 664 | *dst++ = GT1+(i&15); |
| 567 | 665 | *dst++ = GT1+(i&15); |
| 568 | 666 | |
| 569 | 667 | /****** gtia mode 2 **********/ |
| 570 | | dst = (UINT8 *)&antic.pf_gtia2[i]; |
| 668 | dst = (UINT8 *)&m_pf_gtia2[i]; |
| 571 | 669 | *dst++ = GT2+((i>>4)&15); |
| 572 | 670 | *dst++ = GT2+((i>>4)&15); |
| 573 | 671 | *dst++ = GT2+(i&15); |
| 574 | 672 | *dst++ = GT2+(i&15); |
| 575 | 673 | |
| 576 | 674 | /****** gtia mode 3 **********/ |
| 577 | | dst = (UINT8 *)&antic.pf_gtia3[i]; |
| 675 | dst = (UINT8 *)&m_pf_gtia3[i]; |
| 578 | 676 | *dst++ = GT3+((i>>4)&15); |
| 579 | 677 | *dst++ = GT3+((i>>4)&15); |
| 580 | 678 | *dst++ = GT3+(i&15); |
| r32026 | r32027 | |
| 586 | 684 | for( i = 0; i < 256; i++ ) |
| 587 | 685 | { |
| 588 | 686 | /* used colors in text modes 2,3 */ |
| 589 | | antic.uc_21[i] = (i) ? PF2 | PF1 : PF2; |
| 687 | m_uc_21[i] = (i) ? PF2 | PF1 : PF2; |
| 590 | 688 | |
| 591 | 689 | /* used colors in text modes 4,5 and graphics modes D,E */ |
| 592 | 690 | switch( i & 0x03 ) |
| 593 | 691 | { |
| 594 | | case 0x01: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break; |
| 595 | | case 0x02: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break; |
| 596 | | case 0x03: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break; |
| 692 | case 0x01: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break; |
| 693 | case 0x02: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break; |
| 694 | case 0x03: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break; |
| 597 | 695 | } |
| 598 | 696 | switch( i & 0x0c ) |
| 599 | 697 | { |
| 600 | | case 0x04: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break; |
| 601 | | case 0x08: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break; |
| 602 | | case 0x0c: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break; |
| 698 | case 0x04: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break; |
| 699 | case 0x08: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break; |
| 700 | case 0x0c: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break; |
| 603 | 701 | } |
| 604 | 702 | switch( i & 0x30 ) |
| 605 | 703 | { |
| 606 | | case 0x10: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break; |
| 607 | | case 0x20: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break; |
| 608 | | case 0x30: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break; |
| 704 | case 0x10: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break; |
| 705 | case 0x20: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break; |
| 706 | case 0x30: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break; |
| 609 | 707 | } |
| 610 | 708 | switch( i & 0xc0 ) |
| 611 | 709 | { |
| 612 | | case 0x40: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break; |
| 613 | | case 0x80: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break; |
| 614 | | case 0xc0: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break; |
| 710 | case 0x40: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break; |
| 711 | case 0x80: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break; |
| 712 | case 0xc0: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break; |
| 615 | 713 | } |
| 616 | 714 | |
| 617 | 715 | /* used colors in text modes 6,7 and graphics modes 9,B,C */ |
| 618 | 716 | if( i ) |
| 619 | 717 | { |
| 620 | | antic.uc_3210b2[0x000+i*2] |= PF0; |
| 621 | | antic.uc_3210b2[0x200+i*2] |= PF1; |
| 622 | | antic.uc_3210b2[0x400+i*2] |= PF2; |
| 623 | | antic.uc_3210b2[0x600+i*2] |= PF3; |
| 718 | m_uc_3210b2[0x000+i*2] |= PF0; |
| 719 | m_uc_3210b2[0x200+i*2] |= PF1; |
| 720 | m_uc_3210b2[0x400+i*2] |= PF2; |
| 721 | m_uc_3210b2[0x600+i*2] |= PF3; |
| 624 | 722 | } |
| 625 | 723 | |
| 626 | 724 | /* used colors in graphics mode 8 */ |
| 627 | 725 | switch( i & 0x03 ) |
| 628 | 726 | { |
| 629 | | case 0x01: antic.uc_210b4[i*4] |= PF0; break; |
| 630 | | case 0x02: antic.uc_210b4[i*4] |= PF1; break; |
| 631 | | case 0x03: antic.uc_210b4[i*4] |= PF2; break; |
| 727 | case 0x01: m_uc_210b4[i*4] |= PF0; break; |
| 728 | case 0x02: m_uc_210b4[i*4] |= PF1; break; |
| 729 | case 0x03: m_uc_210b4[i*4] |= PF2; break; |
| 632 | 730 | } |
| 633 | 731 | switch( i & 0x0c ) |
| 634 | 732 | { |
| 635 | | case 0x04: antic.uc_210b4[i*4] |= PF0; break; |
| 636 | | case 0x08: antic.uc_210b4[i*4] |= PF1; break; |
| 637 | | case 0x0c: antic.uc_210b4[i*4] |= PF2; break; |
| 733 | case 0x04: m_uc_210b4[i*4] |= PF0; break; |
| 734 | case 0x08: m_uc_210b4[i*4] |= PF1; break; |
| 735 | case 0x0c: m_uc_210b4[i*4] |= PF2; break; |
| 638 | 736 | } |
| 639 | 737 | switch( i & 0x30 ) |
| 640 | 738 | { |
| 641 | | case 0x10: antic.uc_210b4[i*4] |= PF0; break; |
| 642 | | case 0x20: antic.uc_210b4[i*4] |= PF1; break; |
| 643 | | case 0x30: antic.uc_210b4[i*4] |= PF2; break; |
| 739 | case 0x10: m_uc_210b4[i*4] |= PF0; break; |
| 740 | case 0x20: m_uc_210b4[i*4] |= PF1; break; |
| 741 | case 0x30: m_uc_210b4[i*4] |= PF2; break; |
| 644 | 742 | } |
| 645 | 743 | switch( i & 0xc0 ) |
| 646 | 744 | { |
| 647 | | case 0x40: antic.uc_210b4[i*4] |= PF0; break; |
| 648 | | case 0x80: antic.uc_210b4[i*4] |= PF1; break; |
| 649 | | case 0xc0: antic.uc_210b4[i*4] |= PF2; break; |
| 745 | case 0x40: m_uc_210b4[i*4] |= PF0; break; |
| 746 | case 0x80: m_uc_210b4[i*4] |= PF1; break; |
| 747 | case 0xc0: m_uc_210b4[i*4] |= PF2; break; |
| 650 | 748 | } |
| 651 | 749 | |
| 652 | 750 | /* used colors in graphics mode A */ |
| 653 | 751 | switch( i & 0x03 ) |
| 654 | 752 | { |
| 655 | | case 0x01: antic.uc_210b2[i*2] |= PF0; break; |
| 656 | | case 0x02: antic.uc_210b2[i*2] |= PF1; break; |
| 657 | | case 0x03: antic.uc_210b2[i*2] |= PF2; break; |
| 753 | case 0x01: m_uc_210b2[i*2] |= PF0; break; |
| 754 | case 0x02: m_uc_210b2[i*2] |= PF1; break; |
| 755 | case 0x03: m_uc_210b2[i*2] |= PF2; break; |
| 658 | 756 | } |
| 659 | 757 | switch( i & 0x0c ) |
| 660 | 758 | { |
| 661 | | case 0x04: antic.uc_210b2[i*2] |= PF0; break; |
| 662 | | case 0x08: antic.uc_210b2[i*2] |= PF1; break; |
| 663 | | case 0x0c: antic.uc_210b2[i*2] |= PF2; break; |
| 759 | case 0x04: m_uc_210b2[i*2] |= PF0; break; |
| 760 | case 0x08: m_uc_210b2[i*2] |= PF1; break; |
| 761 | case 0x0c: m_uc_210b2[i*2] |= PF2; break; |
| 664 | 762 | } |
| 665 | 763 | switch( i & 0x30 ) |
| 666 | 764 | { |
| 667 | | case 0x10: antic.uc_210b2[i*2] |= PF0; break; |
| 668 | | case 0x20: antic.uc_210b2[i*2] |= PF1; break; |
| 669 | | case 0x30: antic.uc_210b2[i*2] |= PF2; break; |
| 765 | case 0x10: m_uc_210b2[i*2] |= PF0; break; |
| 766 | case 0x20: m_uc_210b2[i*2] |= PF1; break; |
| 767 | case 0x30: m_uc_210b2[i*2] |= PF2; break; |
| 670 | 768 | } |
| 671 | 769 | switch( i & 0xc0 ) |
| 672 | 770 | { |
| 673 | | case 0x40: antic.uc_210b2[i*2] |= PF0; break; |
| 674 | | case 0x80: antic.uc_210b2[i*2] |= PF1; break; |
| 675 | | case 0xc0: antic.uc_210b2[i*2] |= PF2; break; |
| 771 | case 0x40: m_uc_210b2[i*2] |= PF0; break; |
| 772 | case 0x80: m_uc_210b2[i*2] |= PF1; break; |
| 773 | case 0xc0: m_uc_210b2[i*2] |= PF2; break; |
| 676 | 774 | } |
| 677 | 775 | |
| 678 | 776 | /* used colors in graphics mode F */ |
| 679 | 777 | if( i ) |
| 680 | | antic.uc_1b[i] |= PF1; |
| 778 | m_uc_1b[i] |= PF1; |
| 681 | 779 | |
| 682 | 780 | /* used colors in GTIA graphics modes */ |
| 683 | 781 | /* GTIA 1 is 16 different luminances with hue of colbk */ |
| 684 | | antic.uc_g1[i] = 0x00; |
| 782 | m_uc_g1[i] = 0x00; |
| 685 | 783 | /* GTIA 2 is all 9 colors (8..15 is colbk) */ |
| 686 | 784 | switch( i & 0x0f ) |
| 687 | 785 | { |
| 688 | | case 0x00: antic.uc_g2[i] = 0x10; break; |
| 689 | | case 0x01: antic.uc_g2[i] = 0x20; break; |
| 690 | | case 0x02: antic.uc_g2[i] = 0x40; break; |
| 691 | | case 0x03: antic.uc_g2[i] = 0x80; break; |
| 692 | | case 0x04: antic.uc_g2[i] = 0x01; break; |
| 693 | | case 0x05: antic.uc_g2[i] = 0x02; break; |
| 694 | | case 0x06: antic.uc_g2[i] = 0x04; break; |
| 695 | | case 0x07: antic.uc_g2[i] = 0x08; break; |
| 696 | | default: antic.uc_g2[i] = 0x00; |
| 786 | case 0x00: m_uc_g2[i] = 0x10; break; |
| 787 | case 0x01: m_uc_g2[i] = 0x20; break; |
| 788 | case 0x02: m_uc_g2[i] = 0x40; break; |
| 789 | case 0x03: m_uc_g2[i] = 0x80; break; |
| 790 | case 0x04: m_uc_g2[i] = 0x01; break; |
| 791 | case 0x05: m_uc_g2[i] = 0x02; break; |
| 792 | case 0x06: m_uc_g2[i] = 0x04; break; |
| 793 | case 0x07: m_uc_g2[i] = 0x08; break; |
| 794 | default: m_uc_g2[i] = 0x00; |
| 697 | 795 | } |
| 698 | 796 | |
| 699 | 797 | /* GTIA 3 is 16 different hues with luminance of colbk */ |
| 700 | | antic.uc_g3[i] = 0x00; |
| 798 | m_uc_g3[i] = 0x00; |
| 701 | 799 | } |
| 702 | 800 | } |
| 703 | 801 | |
| 704 | 802 | |
| 705 | 803 | |
| 706 | | ANTIC antic; |
| 707 | | |
| 708 | | void antic_start(running_machine &machine) |
| 709 | | { |
| 710 | | /* save states */ |
| 711 | | machine.save().save_pointer(NAME((UINT8 *) &antic.r), sizeof(antic.r)); |
| 712 | | machine.save().save_pointer(NAME((UINT8 *) &antic.w), sizeof(antic.w)); |
| 713 | | } |
| 714 | | |
| 715 | | void antic_vstart(running_machine &machine) |
| 716 | | { |
| 717 | | LOG(("atari antic_vh_start\n")); |
| 718 | | memset(&antic, 0, sizeof(antic)); |
| 719 | | |
| 720 | | antic.bitmap = auto_bitmap_ind16_alloc(machine, machine.first_screen()->width(), machine.first_screen()->height()); |
| 721 | | |
| 722 | | antic.cclk_expand = auto_alloc_array(machine, UINT32, 21 * 256); |
| 723 | | |
| 724 | | antic.pf_21 = &antic.cclk_expand[ 0 * 256]; |
| 725 | | antic.pf_x10b = &antic.cclk_expand[ 1 * 256]; |
| 726 | | antic.pf_3210b2 = &antic.cclk_expand[ 3 * 256]; |
| 727 | | antic.pf_210b4 = &antic.cclk_expand[11 * 256]; |
| 728 | | antic.pf_210b2 = &antic.cclk_expand[15 * 256]; |
| 729 | | antic.pf_1b = &antic.cclk_expand[17 * 256]; |
| 730 | | antic.pf_gtia1 = &antic.cclk_expand[18 * 256]; |
| 731 | | antic.pf_gtia2 = &antic.cclk_expand[19 * 256]; |
| 732 | | antic.pf_gtia3 = &antic.cclk_expand[20 * 256]; |
| 733 | | |
| 734 | | antic.used_colors = auto_alloc_array(machine, UINT8, 21 * 256); |
| 735 | | |
| 736 | | memset(antic.used_colors, 0, 21 * 256 * sizeof(UINT8)); |
| 737 | | |
| 738 | | antic.uc_21 = &antic.used_colors[ 0 * 256]; |
| 739 | | antic.uc_x10b = &antic.used_colors[ 1 * 256]; |
| 740 | | antic.uc_3210b2 = &antic.used_colors[ 3 * 256]; |
| 741 | | antic.uc_210b4 = &antic.used_colors[11 * 256]; |
| 742 | | antic.uc_210b2 = &antic.used_colors[15 * 256]; |
| 743 | | antic.uc_1b = &antic.used_colors[17 * 256]; |
| 744 | | antic.uc_g1 = &antic.used_colors[18 * 256]; |
| 745 | | antic.uc_g2 = &antic.used_colors[19 * 256]; |
| 746 | | antic.uc_g3 = &antic.used_colors[20 * 256]; |
| 747 | | |
| 748 | | LOG(("atari cclk_init\n")); |
| 749 | | cclk_init(); |
| 750 | | |
| 751 | | for (int i = 0; i < 64; i++) |
| 752 | | antic.prio_table[i] = auto_alloc_array(machine, UINT8, 8*256); |
| 753 | | |
| 754 | | LOG(("atari prio_init\n")); |
| 755 | | prio_init(); |
| 756 | | |
| 757 | | for (int i = 0; i < machine.first_screen()->height(); i++) |
| 758 | | antic.video[i] = auto_alloc_clear(machine, VIDEO); |
| 759 | | } |
| 760 | | |
| 761 | 804 | /************************************************************** |
| 762 | 805 | * |
| 763 | | * Reset ANTIC |
| 764 | | * |
| 765 | | **************************************************************/ |
| 766 | | |
| 767 | | void antic_reset(void) |
| 768 | | { |
| 769 | | /* reset the ANTIC read / write registers */ |
| 770 | | memset(&antic.r, 0, sizeof(antic.r)); |
| 771 | | memset(&antic.w, 0, sizeof(antic.w)); |
| 772 | | antic.r.antic00 = 0xff; |
| 773 | | antic.r.antic01 = 0xff; |
| 774 | | antic.r.antic02 = 0xff; |
| 775 | | antic.r.antic03 = 0xff; |
| 776 | | antic.r.antic04 = 0xff; |
| 777 | | antic.r.antic05 = 0xff; |
| 778 | | antic.r.antic06 = 0xff; |
| 779 | | antic.r.antic07 = 0xff; |
| 780 | | antic.r.antic08 = 0xff; |
| 781 | | antic.r.antic09 = 0xff; |
| 782 | | antic.r.antic0a = 0xff; |
| 783 | | antic.r.penh = 0x00; |
| 784 | | antic.r.penv = 0x00; |
| 785 | | antic.r.antic0e = 0xff; |
| 786 | | antic.r.nmist = 0x1f; |
| 787 | | } |
| 788 | | |
| 789 | | /************************************************************** |
| 790 | | * |
| 791 | 806 | * Read ANTIC hardware registers |
| 792 | 807 | * |
| 793 | 808 | **************************************************************/ |
| 794 | | READ8_MEMBER ( atari_common_state::atari_antic_r ) |
| 809 | READ8_MEMBER ( antic_device::read ) |
| 795 | 810 | { |
| 796 | 811 | UINT8 data = 0xff; |
| 797 | 812 | |
| 798 | 813 | switch (offset & 15) |
| 799 | 814 | { |
| 800 | 815 | case 0: /* nothing */ |
| 801 | | data = antic.r.antic00; |
| 816 | data = m_r.antic00; |
| 802 | 817 | break; |
| 803 | 818 | case 1: /* nothing */ |
| 804 | | data = antic.r.antic01; |
| 819 | data = m_r.antic01; |
| 805 | 820 | break; |
| 806 | 821 | case 2: /* nothing */ |
| 807 | | data = antic.r.antic02; |
| 822 | data = m_r.antic02; |
| 808 | 823 | break; |
| 809 | 824 | case 3: /* nothing */ |
| 810 | | data = antic.r.antic03; |
| 825 | data = m_r.antic03; |
| 811 | 826 | break; |
| 812 | 827 | case 4: /* nothing */ |
| 813 | | data = antic.r.antic04; |
| 828 | data = m_r.antic04; |
| 814 | 829 | break; |
| 815 | 830 | case 5: /* nothing */ |
| 816 | | data = antic.r.antic05; |
| 831 | data = m_r.antic05; |
| 817 | 832 | break; |
| 818 | 833 | case 6: /* nothing */ |
| 819 | | data = antic.r.antic06; |
| 834 | data = m_r.antic06; |
| 820 | 835 | break; |
| 821 | 836 | case 7: /* nothing */ |
| 822 | | data = antic.r.antic07; |
| 837 | data = m_r.antic07; |
| 823 | 838 | break; |
| 824 | 839 | case 8: /* nothing */ |
| 825 | | data = antic.r.antic08; |
| 840 | data = m_r.antic08; |
| 826 | 841 | break; |
| 827 | 842 | case 9: /* nothing */ |
| 828 | | data = antic.r.antic09; |
| 843 | data = m_r.antic09; |
| 829 | 844 | break; |
| 830 | 845 | case 10: /* WSYNC read */ |
| 831 | 846 | space.machine().device("maincpu")->execute().spin_until_trigger(TRIGGER_HSYNC); |
| 832 | | antic.w.wsync = 1; |
| 833 | | data = antic.r.antic0a; |
| 847 | m_w.wsync = 1; |
| 848 | data = m_r.antic0a; |
| 834 | 849 | break; |
| 835 | 850 | case 11: /* vert counter (scanline / 2) */ |
| 836 | | data = antic.r.vcount = antic.scanline >> 1; |
| 851 | data = m_r.vcount = m_scanline >> 1; |
| 837 | 852 | break; |
| 838 | 853 | case 12: /* light pen horz pos */ |
| 839 | | data = antic.r.penh; |
| 854 | data = m_r.penh; |
| 840 | 855 | break; |
| 841 | 856 | case 13: /* light pen vert pos */ |
| 842 | | data = antic.r.penv; |
| 857 | data = m_r.penv; |
| 843 | 858 | break; |
| 844 | 859 | case 14: /* NMI enable */ |
| 845 | | data = antic.r.antic0e; |
| 860 | data = m_r.antic0e; |
| 846 | 861 | break; |
| 847 | 862 | case 15: /* NMI status */ |
| 848 | | data = antic.r.nmist; |
| 863 | data = m_r.nmist; |
| 849 | 864 | break; |
| 850 | 865 | } |
| 851 | 866 | return data; |
| r32026 | r32027 | |
| 857 | 872 | * |
| 858 | 873 | **************************************************************/ |
| 859 | 874 | |
| 860 | | WRITE8_MEMBER ( atari_common_state::atari_antic_w ) |
| 875 | WRITE8_MEMBER ( antic_device::write ) |
| 861 | 876 | { |
| 862 | 877 | int temp; |
| 863 | 878 | |
| 864 | 879 | switch (offset & 15) |
| 865 | 880 | { |
| 866 | 881 | case 0: |
| 867 | | if( data == antic.w.dmactl ) |
| 882 | if( data == m_w.dmactl ) |
| 868 | 883 | break; |
| 869 | 884 | LOG(("ANTIC 00 write DMACTL $%02X\n", data)); |
| 870 | | antic.w.dmactl = data; |
| 885 | m_w.dmactl = data; |
| 871 | 886 | switch (data & 3) |
| 872 | 887 | { |
| 873 | | case 0: antic.pfwidth = 0; break; |
| 874 | | case 1: antic.pfwidth = 32; break; |
| 875 | | case 2: antic.pfwidth = 40; break; |
| 876 | | case 3: antic.pfwidth = 48; break; |
| 888 | case 0: m_pfwidth = 0; break; |
| 889 | case 1: m_pfwidth = 32; break; |
| 890 | case 2: m_pfwidth = 40; break; |
| 891 | case 3: m_pfwidth = 48; break; |
| 877 | 892 | } |
| 878 | 893 | break; |
| 879 | 894 | case 1: |
| 880 | | if( data == antic.w.chactl ) |
| 895 | if( data == m_w.chactl ) |
| 881 | 896 | break; |
| 882 | 897 | LOG(("ANTIC 01 write CHACTL $%02X\n", data)); |
| 883 | | antic.w.chactl = data; |
| 884 | | antic.chand = (data & 1) ? 0x00 : 0xff; |
| 885 | | antic.chxor = (data & 2) ? 0xff : 0x00; |
| 898 | m_w.chactl = data; |
| 899 | m_chand = (data & 1) ? 0x00 : 0xff; |
| 900 | m_chxor = (data & 2) ? 0xff : 0x00; |
| 886 | 901 | break; |
| 887 | 902 | case 2: |
| 888 | 903 | LOG(("ANTIC 02 write DLISTL $%02X\n", data)); |
| 889 | | antic.w.dlistl = data; |
| 890 | | temp = (antic.w.dlisth << 8) + antic.w.dlistl; |
| 891 | | antic.dpage = temp & DPAGE; |
| 892 | | antic.doffs = temp & DOFFS; |
| 904 | m_w.dlistl = data; |
| 905 | temp = (m_w.dlisth << 8) + m_w.dlistl; |
| 906 | m_dpage = temp & DPAGE; |
| 907 | m_doffs = temp & DOFFS; |
| 893 | 908 | break; |
| 894 | 909 | case 3: |
| 895 | 910 | LOG(("ANTIC 03 write DLISTH $%02X\n", data)); |
| 896 | | antic.w.dlisth = data; |
| 897 | | temp = (antic.w.dlisth << 8) + antic.w.dlistl; |
| 898 | | antic.dpage = temp & DPAGE; |
| 899 | | antic.doffs = temp & DOFFS; |
| 911 | m_w.dlisth = data; |
| 912 | temp = (m_w.dlisth << 8) + m_w.dlistl; |
| 913 | m_dpage = temp & DPAGE; |
| 914 | m_doffs = temp & DOFFS; |
| 900 | 915 | break; |
| 901 | 916 | case 4: |
| 902 | | if( data == antic.w.hscrol ) |
| 917 | if( data == m_w.hscrol ) |
| 903 | 918 | break; |
| 904 | 919 | LOG(("ANTIC 04 write HSCROL $%02X\n", data)); |
| 905 | | antic.w.hscrol = data & 15; |
| 920 | m_w.hscrol = data & 15; |
| 906 | 921 | break; |
| 907 | 922 | case 5: |
| 908 | | if( data == antic.w.vscrol ) |
| 923 | if( data == m_w.vscrol ) |
| 909 | 924 | break; |
| 910 | 925 | LOG(("ANTIC 05 write VSCROL $%02X\n", data)); |
| 911 | | antic.w.vscrol = data & 15; |
| 926 | m_w.vscrol = data & 15; |
| 912 | 927 | break; |
| 913 | 928 | case 6: |
| 914 | | if( data == antic.w.pmbasl ) |
| 929 | if( data == m_w.pmbasl ) |
| 915 | 930 | break; |
| 916 | 931 | LOG(("ANTIC 06 write PMBASL $%02X\n", data)); |
| 917 | | /* antic.w.pmbasl = data; */ |
| 932 | /* m_w.pmbasl = data; */ |
| 918 | 933 | break; |
| 919 | 934 | case 7: |
| 920 | | if( data == antic.w.pmbash ) |
| 935 | if( data == m_w.pmbash ) |
| 921 | 936 | break; |
| 922 | 937 | LOG(("ANTIC 07 write PMBASH $%02X\n", data)); |
| 923 | | antic.w.pmbash = data; |
| 924 | | antic.pmbase_s = (data & 0xfc) << 8; |
| 925 | | antic.pmbase_d = (data & 0xf8) << 8; |
| 938 | m_w.pmbash = data; |
| 939 | m_pmbase_s = (data & 0xfc) << 8; |
| 940 | m_pmbase_d = (data & 0xf8) << 8; |
| 926 | 941 | break; |
| 927 | 942 | case 8: |
| 928 | | if( data == antic.w.chbasl ) |
| 943 | if( data == m_w.chbasl ) |
| 929 | 944 | break; |
| 930 | 945 | LOG(("ANTIC 08 write CHBASL $%02X\n", data)); |
| 931 | | /* antic.w.chbasl = data; */ |
| 946 | /* m_w.chbasl = data; */ |
| 932 | 947 | break; |
| 933 | 948 | case 9: |
| 934 | | if( data == antic.w.chbash ) |
| 949 | if( data == m_w.chbash ) |
| 935 | 950 | break; |
| 936 | 951 | LOG(("ANTIC 09 write CHBASH $%02X\n", data)); |
| 937 | | antic.w.chbash = data; |
| 952 | m_w.chbash = data; |
| 938 | 953 | break; |
| 939 | 954 | case 10: /* WSYNC write */ |
| 940 | 955 | LOG(("ANTIC 0A write WSYNC $%02X\n", data)); |
| 941 | 956 | space.machine().device("maincpu")->execute().spin_until_trigger(TRIGGER_HSYNC); |
| 942 | | antic.w.wsync = 1; |
| 957 | m_w.wsync = 1; |
| 943 | 958 | break; |
| 944 | 959 | case 11: |
| 945 | | if( data == antic.w.antic0b ) |
| 960 | if( data == m_w.antic0b ) |
| 946 | 961 | break; |
| 947 | 962 | LOG(("ANTIC 0B write ?????? $%02X\n", data)); |
| 948 | | antic.w.antic0b = data; |
| 963 | m_w.antic0b = data; |
| 949 | 964 | break; |
| 950 | 965 | case 12: |
| 951 | | if( data == antic.w.antic0c ) |
| 966 | if( data == m_w.antic0c ) |
| 952 | 967 | break; |
| 953 | 968 | LOG(("ANTIC 0C write ?????? $%02X\n", data)); |
| 954 | | antic.w.antic0c = data; |
| 969 | m_w.antic0c = data; |
| 955 | 970 | break; |
| 956 | 971 | case 13: |
| 957 | | if( data == antic.w.antic0d ) |
| 972 | if( data == m_w.antic0d ) |
| 958 | 973 | break; |
| 959 | 974 | LOG(("ANTIC 0D write ?????? $%02X\n", data)); |
| 960 | | antic.w.antic0d = data; |
| 975 | m_w.antic0d = data; |
| 961 | 976 | break; |
| 962 | 977 | case 14: |
| 963 | | if( data == antic.w.nmien ) |
| 978 | if( data == m_w.nmien ) |
| 964 | 979 | break; |
| 965 | 980 | LOG(("ANTIC 0E write NMIEN $%02X\n", data)); |
| 966 | | antic.w.nmien = data; |
| 981 | m_w.nmien = data; |
| 967 | 982 | break; |
| 968 | 983 | case 15: |
| 969 | 984 | LOG(("ANTIC 0F write NMIRES $%02X\n", data)); |
| 970 | | antic.r.nmist = 0x1f; |
| 971 | | antic.w.nmires = data; |
| 985 | m_r.nmist = 0x1f; |
| 986 | m_w.nmires = data; |
| 972 | 987 | break; |
| 973 | 988 | } |
| 974 | 989 | } |
| r32026 | r32027 | |
| 976 | 991 | /************* ANTIC mode 00: ********************************* |
| 977 | 992 | * generate 1-8 empty scanlines |
| 978 | 993 | ***************************************************************/ |
| 979 | | static inline void antic_mode_0_xx(address_space &space, VIDEO *video) |
| 994 | inline void antic_device::mode_0(address_space &space, VIDEO *video) |
| 980 | 995 | { |
| 981 | 996 | PREPARE(); |
| 982 | 997 | memset(dst, PBK, HWIDTH*4); |
| r32026 | r32027 | |
| 991 | 1006 | /************* ANTIC mode 02: ********************************* |
| 992 | 1007 | * character mode 8x8:2 (32/40/48 byte per line) |
| 993 | 1008 | ***************************************************************/ |
| 994 | | #define MODE2(s) COPY4(dst, antic.pf_21[video->data[s]]) |
| 1009 | #define MODE2(s) COPY4(dst, m_pf_21[video->data[s]]) |
| 995 | 1010 | |
| 996 | | static inline void antic_mode_2(address_space &space, VIDEO *video, int bytes, int erase) |
| 1011 | inline void antic_device::mode_2(address_space &space, VIDEO *video, int bytes, int erase) |
| 997 | 1012 | { |
| 998 | 1013 | PREPARE_TXT2(space, bytes); |
| 999 | 1014 | ERASE(erase); |
| r32026 | r32027 | |
| 1005 | 1020 | /************* ANTIC mode 03: ********************************* |
| 1006 | 1021 | * character mode 8x10:2 (32/40/48 byte per line) |
| 1007 | 1022 | ***************************************************************/ |
| 1008 | | #define MODE3(s) COPY4(dst, antic.pf_21[video->data[s]]) |
| 1023 | #define MODE3(s) COPY4(dst, m_pf_21[video->data[s]]) |
| 1009 | 1024 | |
| 1010 | | static inline void antic_mode_3(address_space &space, VIDEO *video, int bytes, int erase) |
| 1025 | inline void antic_device::mode_3(address_space &space, VIDEO *video, int bytes, int erase) |
| 1011 | 1026 | { |
| 1012 | 1027 | PREPARE_TXT3(space, bytes); |
| 1013 | 1028 | ERASE(erase); |
| r32026 | r32027 | |
| 1019 | 1034 | /************* ANTIC mode 04: ********************************* |
| 1020 | 1035 | * character mode 8x8:4 multi color (32/40/48 byte per line) |
| 1021 | 1036 | ***************************************************************/ |
| 1022 | | #define MODE4(s) COPY4(dst, antic.pf_x10b[video->data[s]]) |
| 1037 | #define MODE4(s) COPY4(dst, m_pf_x10b[video->data[s]]) |
| 1023 | 1038 | |
| 1024 | | static inline void antic_mode_4(address_space &space, VIDEO *video, int bytes, int erase) |
| 1039 | inline void antic_device::mode_4(address_space &space, VIDEO *video, int bytes, int erase) |
| 1025 | 1040 | { |
| 1026 | 1041 | PREPARE_TXT45(space, bytes, 0); |
| 1027 | 1042 | ERASE(erase); |
| r32026 | r32027 | |
| 1033 | 1048 | /************* ANTIC mode 05: ********************************* |
| 1034 | 1049 | * character mode 8x16:4 multi color (32/40/48 byte per line) |
| 1035 | 1050 | ***************************************************************/ |
| 1036 | | #define MODE5(s) COPY4(dst, antic.pf_x10b[video->data[s]]) |
| 1051 | #define MODE5(s) COPY4(dst, m_pf_x10b[video->data[s]]) |
| 1037 | 1052 | |
| 1038 | | static inline void antic_mode_5(address_space &space, VIDEO *video, int bytes, int erase) |
| 1053 | inline void antic_device::mode_5(address_space &space, VIDEO *video, int bytes, int erase) |
| 1039 | 1054 | { |
| 1040 | 1055 | PREPARE_TXT45(space, bytes, 1); |
| 1041 | 1056 | ERASE(erase); |
| r32026 | r32027 | |
| 1047 | 1062 | /************* ANTIC mode 06: ********************************* |
| 1048 | 1063 | * character mode 16x8:5 single color (16/20/24 byte per line) |
| 1049 | 1064 | ***************************************************************/ |
| 1050 | | #define MODE6(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1]) |
| 1065 | #define MODE6(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1]) |
| 1051 | 1066 | |
| 1052 | | static inline void antic_mode_6(address_space &space, VIDEO *video, int bytes, int erase) |
| 1067 | inline void antic_device::mode_6(address_space &space, VIDEO *video, int bytes, int erase) |
| 1053 | 1068 | { |
| 1054 | 1069 | PREPARE_TXT67(space, bytes, 0); |
| 1055 | 1070 | ERASE(erase); |
| r32026 | r32027 | |
| 1061 | 1076 | /************* ANTIC mode 07: ********************************* |
| 1062 | 1077 | * character mode 16x16:5 single color (16/20/24 byte per line) |
| 1063 | 1078 | ***************************************************************/ |
| 1064 | | #define MODE7(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1]) |
| 1079 | #define MODE7(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1]) |
| 1065 | 1080 | |
| 1066 | | static inline void antic_mode_7(address_space &space, VIDEO *video, int bytes, int erase) |
| 1081 | inline void antic_device::mode_7(address_space &space, VIDEO *video, int bytes, int erase) |
| 1067 | 1082 | { |
| 1068 | 1083 | PREPARE_TXT67(space, bytes, 1); |
| 1069 | 1084 | ERASE(erase); |
| r32026 | r32027 | |
| 1075 | 1090 | /************* ANTIC mode 08: ********************************* |
| 1076 | 1091 | * graphics mode 8x8:4 (8/10/12 byte per line) |
| 1077 | 1092 | ***************************************************************/ |
| 1078 | | #define MODE8(s) COPY16(dst, antic.pf_210b4[video->data[s]],antic.pf_210b4[video->data[s]+1],antic.pf_210b4[video->data[s]+2],antic.pf_210b4[video->data[s]+3]) |
| 1093 | #define MODE8(s) COPY16(dst, m_pf_210b4[video->data[s]],m_pf_210b4[video->data[s]+1],m_pf_210b4[video->data[s]+2],m_pf_210b4[video->data[s]+3]) |
| 1079 | 1094 | |
| 1080 | | static inline void antic_mode_8(address_space &space, VIDEO *video, int bytes, int erase) |
| 1095 | inline void antic_device::mode_8(address_space &space, VIDEO *video, int bytes, int erase) |
| 1081 | 1096 | { |
| 1082 | 1097 | PREPARE_GFX8(space, bytes); |
| 1083 | 1098 | ERASE(erase); |
| r32026 | r32027 | |
| 1089 | 1104 | /************* ANTIC mode 09: ********************************* |
| 1090 | 1105 | * graphics mode 4x4:2 (8/10/12 byte per line) |
| 1091 | 1106 | ***************************************************************/ |
| 1092 | | #define MODE9(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1]) |
| 1107 | #define MODE9(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1]) |
| 1093 | 1108 | |
| 1094 | | static inline void antic_mode_9(address_space &space, VIDEO *video, int bytes, int erase) |
| 1109 | inline void antic_device::mode_9(address_space &space, VIDEO *video, int bytes, int erase) |
| 1095 | 1110 | { |
| 1096 | 1111 | PREPARE_GFX9BC(space, bytes); |
| 1097 | 1112 | ERASE(erase); |
| r32026 | r32027 | |
| 1103 | 1118 | /************* ANTIC mode 0A: ********************************* |
| 1104 | 1119 | * graphics mode 4x4:4 (16/20/24 byte per line) |
| 1105 | 1120 | ***************************************************************/ |
| 1106 | | #define MODEA(s) COPY8(dst, antic.pf_210b2[video->data[s]], antic.pf_210b2[video->data[s]+1]) |
| 1121 | #define MODEA(s) COPY8(dst, m_pf_210b2[video->data[s]], m_pf_210b2[video->data[s]+1]) |
| 1107 | 1122 | |
| 1108 | | static inline void antic_mode_a(address_space &space, VIDEO *video, int bytes, int erase) |
| 1123 | inline void antic_device::mode_a(address_space &space, VIDEO *video, int bytes, int erase) |
| 1109 | 1124 | { |
| 1110 | 1125 | PREPARE_GFXA(space, bytes); |
| 1111 | 1126 | ERASE(erase); |
| r32026 | r32027 | |
| 1117 | 1132 | /************* ANTIC mode 0B: ********************************* |
| 1118 | 1133 | * graphics mode 2x2:2 (16/20/24 byte per line) |
| 1119 | 1134 | ***************************************************************/ |
| 1120 | | #define MODEB(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1]) |
| 1135 | #define MODEB(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1]) |
| 1121 | 1136 | |
| 1122 | | static inline void antic_mode_b(address_space &space, VIDEO *video, int bytes, int erase) |
| 1137 | inline void antic_device::mode_b(address_space &space, VIDEO *video, int bytes, int erase) |
| 1123 | 1138 | { |
| 1124 | 1139 | PREPARE_GFX9BC(space, bytes); |
| 1125 | 1140 | ERASE(erase); |
| r32026 | r32027 | |
| 1131 | 1146 | /************* ANTIC mode 0C: ********************************* |
| 1132 | 1147 | * graphics mode 2x1:2 (16/20/24 byte per line) |
| 1133 | 1148 | ***************************************************************/ |
| 1134 | | #define MODEC(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1]) |
| 1149 | #define MODEC(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1]) |
| 1135 | 1150 | |
| 1136 | | static inline void antic_mode_c(address_space &space, VIDEO *video, int bytes, int erase) |
| 1151 | inline void antic_device::mode_c(address_space &space, VIDEO *video, int bytes, int erase) |
| 1137 | 1152 | { |
| 1138 | 1153 | PREPARE_GFX9BC(space, bytes); |
| 1139 | 1154 | ERASE(erase); |
| r32026 | r32027 | |
| 1145 | 1160 | /************* ANTIC mode 0D: ********************************* |
| 1146 | 1161 | * graphics mode 2x2:4 (32/40/48 byte per line) |
| 1147 | 1162 | ***************************************************************/ |
| 1148 | | #define MODED(s) COPY4(dst, antic.pf_x10b[video->data[s]]) |
| 1163 | #define MODED(s) COPY4(dst, m_pf_x10b[video->data[s]]) |
| 1149 | 1164 | |
| 1150 | | static inline void antic_mode_d(address_space &space, VIDEO *video, int bytes, int erase) |
| 1165 | inline void antic_device::mode_d(address_space &space, VIDEO *video, int bytes, int erase) |
| 1151 | 1166 | { |
| 1152 | 1167 | PREPARE_GFXDE(space, bytes); |
| 1153 | 1168 | ERASE(erase); |
| r32026 | r32027 | |
| 1159 | 1174 | /************* ANTIC mode 0E: ********************************* |
| 1160 | 1175 | * graphics mode 2x1:4 (32/40/48 byte per line) |
| 1161 | 1176 | ***************************************************************/ |
| 1162 | | #define MODEE(s) COPY4(dst, antic.pf_x10b[video->data[s]]) |
| 1177 | #define MODEE(s) COPY4(dst, m_pf_x10b[video->data[s]]) |
| 1163 | 1178 | |
| 1164 | | static inline void antic_mode_e(address_space &space, VIDEO *video, int bytes, int erase) |
| 1179 | inline void antic_device::mode_e(address_space &space, VIDEO *video, int bytes, int erase) |
| 1165 | 1180 | { |
| 1166 | 1181 | PREPARE_GFXDE(space, bytes); |
| 1167 | 1182 | ERASE(erase); |
| r32026 | r32027 | |
| 1173 | 1188 | /************* ANTIC mode 0F: ********************************* |
| 1174 | 1189 | * graphics mode 1x1:2 (32/40/48 byte per line) |
| 1175 | 1190 | ***************************************************************/ |
| 1176 | | #define MODEF(s) COPY4(dst, antic.pf_1b[video->data[s]]) |
| 1191 | #define MODEF(s) COPY4(dst, m_pf_1b[video->data[s]]) |
| 1177 | 1192 | |
| 1178 | | static inline void antic_mode_f(address_space &space, VIDEO *video, int bytes, int erase) |
| 1193 | inline void antic_device::mode_f(address_space &space, VIDEO *video, int bytes, int erase) |
| 1179 | 1194 | { |
| 1180 | 1195 | PREPARE_GFXF(space, bytes); |
| 1181 | 1196 | ERASE(erase); |
| r32026 | r32027 | |
| 1187 | 1202 | /************* ANTIC mode 0F : GTIA mode 1 ******************** |
| 1188 | 1203 | * graphics mode 8x1:16 (32/40/48 byte per line) |
| 1189 | 1204 | ***************************************************************/ |
| 1190 | | #define GTIA1(s) COPY4(dst, antic.pf_gtia1[video->data[s]]) |
| 1205 | #define GTIA1(s) COPY4(dst, m_pf_gtia1[video->data[s]]) |
| 1191 | 1206 | |
| 1192 | | static inline void antic_mode_gtia1(address_space &space, VIDEO *video, int bytes, int erase) |
| 1207 | inline void antic_device::mode_gtia1(address_space &space, VIDEO *video, int bytes, int erase) |
| 1193 | 1208 | { |
| 1194 | 1209 | PREPARE_GFXG1(space, bytes); |
| 1195 | 1210 | ERASE(erase); |
| r32026 | r32027 | |
| 1201 | 1216 | /************* ANTIC mode 0F : GTIA mode 2 ******************** |
| 1202 | 1217 | * graphics mode 8x1:16 (32/40/48 byte per line) |
| 1203 | 1218 | ***************************************************************/ |
| 1204 | | #define GTIA2(s) COPY4(dst, antic.pf_gtia2[video->data[s]]) |
| 1219 | #define GTIA2(s) COPY4(dst, m_pf_gtia2[video->data[s]]) |
| 1205 | 1220 | |
| 1206 | | static inline void antic_mode_gtia2(address_space &space, VIDEO *video, int bytes, int erase) |
| 1221 | inline void antic_device::mode_gtia2(address_space &space, VIDEO *video, int bytes, int erase) |
| 1207 | 1222 | { |
| 1208 | 1223 | PREPARE_GFXG2(space, bytes); |
| 1209 | 1224 | ERASE(erase); |
| r32026 | r32027 | |
| 1215 | 1230 | /************* ANTIC mode 0F : GTIA mode 3 ******************** |
| 1216 | 1231 | * graphics mode 8x1:16 (32/40/48 byte per line) |
| 1217 | 1232 | ***************************************************************/ |
| 1218 | | #define GTIA3(s) COPY4(dst, antic.pf_gtia3[video->data[s]]) |
| 1233 | #define GTIA3(s) COPY4(dst, m_pf_gtia3[video->data[s]]) |
| 1219 | 1234 | |
| 1220 | | static inline void antic_mode_gtia3(address_space &space, VIDEO *video, int bytes, int erase) |
| 1235 | inline void antic_device::mode_gtia3(address_space &space, VIDEO *video, int bytes, int erase) |
| 1221 | 1236 | { |
| 1222 | 1237 | PREPARE_GFXG3(space, bytes); |
| 1223 | 1238 | ERASE(erase); |
| r32026 | r32027 | |
| 1229 | 1244 | |
| 1230 | 1245 | /************* ANTIC render ********************/ |
| 1231 | 1246 | |
| 1232 | | void antic_render(address_space &space, int param1, int param2, int param3) |
| 1247 | void antic_device::render(address_space &space, int param1, int param2, int param3) |
| 1233 | 1248 | { |
| 1234 | | VIDEO *video = antic.video[antic.scanline]; |
| 1249 | VIDEO *video = m_video[m_scanline]; |
| 1235 | 1250 | int add_bytes = 0, erase = 0; |
| 1236 | 1251 | |
| 1237 | 1252 | if (param3 == 0 || param2 <= 1) |
| 1238 | 1253 | { |
| 1239 | | antic_mode_0_xx(space, video); |
| 1254 | mode_0(space, video); |
| 1240 | 1255 | return; |
| 1241 | 1256 | } |
| 1242 | 1257 | |
| r32026 | r32027 | |
| 1262 | 1277 | switch (param2) |
| 1263 | 1278 | { |
| 1264 | 1279 | case 0x02: |
| 1265 | | antic_mode_2(space, video, add_bytes, erase); |
| 1280 | mode_2(space, video, add_bytes, erase); |
| 1266 | 1281 | return; |
| 1267 | 1282 | case 0x03: |
| 1268 | | antic_mode_3(space, video, add_bytes, erase); |
| 1283 | mode_3(space, video, add_bytes, erase); |
| 1269 | 1284 | return; |
| 1270 | 1285 | case 0x04: |
| 1271 | | antic_mode_4(space, video, add_bytes, erase); |
| 1286 | mode_4(space, video, add_bytes, erase); |
| 1272 | 1287 | return; |
| 1273 | 1288 | case 0x05: |
| 1274 | | antic_mode_5(space, video, add_bytes, erase); |
| 1289 | mode_5(space, video, add_bytes, erase); |
| 1275 | 1290 | return; |
| 1276 | 1291 | case 0x06: |
| 1277 | | antic_mode_6(space, video, add_bytes >> 1, erase); |
| 1292 | mode_6(space, video, add_bytes >> 1, erase); |
| 1278 | 1293 | return; |
| 1279 | 1294 | case 0x07: |
| 1280 | | antic_mode_7(space, video, add_bytes >> 1, erase); |
| 1295 | mode_7(space, video, add_bytes >> 1, erase); |
| 1281 | 1296 | return; |
| 1282 | 1297 | case 0x08: |
| 1283 | | antic_mode_8(space, video, add_bytes >> 2, erase); |
| 1298 | mode_8(space, video, add_bytes >> 2, erase); |
| 1284 | 1299 | return; |
| 1285 | 1300 | case 0x09: |
| 1286 | | antic_mode_9(space, video, add_bytes >> 1, erase); |
| 1301 | mode_9(space, video, add_bytes >> 1, erase); |
| 1287 | 1302 | return; |
| 1288 | 1303 | case 0x0a: |
| 1289 | | antic_mode_a(space, video, add_bytes >> 1, erase); |
| 1304 | mode_a(space, video, add_bytes >> 1, erase); |
| 1290 | 1305 | return; |
| 1291 | 1306 | case 0x0b: |
| 1292 | | antic_mode_b(space, video, add_bytes >> 1, erase); |
| 1307 | mode_b(space, video, add_bytes >> 1, erase); |
| 1293 | 1308 | return; |
| 1294 | 1309 | case 0x0c: |
| 1295 | | antic_mode_c(space, video, add_bytes >> 1, erase); |
| 1310 | mode_c(space, video, add_bytes >> 1, erase); |
| 1296 | 1311 | return; |
| 1297 | 1312 | case 0x0d: |
| 1298 | | antic_mode_d(space, video, add_bytes, erase); |
| 1313 | mode_d(space, video, add_bytes, erase); |
| 1299 | 1314 | return; |
| 1300 | 1315 | case 0x0e: |
| 1301 | | antic_mode_e(space, video, add_bytes, erase); |
| 1316 | mode_e(space, video, add_bytes, erase); |
| 1302 | 1317 | return; |
| 1303 | 1318 | case 0x0f: |
| 1304 | | antic_mode_f(space, video, add_bytes, erase); |
| 1319 | mode_f(space, video, add_bytes, erase); |
| 1305 | 1320 | return; |
| 1306 | 1321 | case 0x10: |
| 1307 | | antic_mode_gtia1(space, video, add_bytes, erase); |
| 1322 | mode_gtia1(space, video, add_bytes, erase); |
| 1308 | 1323 | return; |
| 1309 | 1324 | case 0x11: |
| 1310 | | antic_mode_gtia2(space, video, add_bytes, erase); |
| 1325 | mode_gtia2(space, video, add_bytes, erase); |
| 1311 | 1326 | return; |
| 1312 | 1327 | case 0x12: |
| 1313 | | antic_mode_gtia3(space, video, add_bytes, erase); |
| 1328 | mode_gtia3(space, video, add_bytes, erase); |
| 1314 | 1329 | return; |
| 1315 | 1330 | default: |
| 1316 | 1331 | return; |
| r32026 | r32027 | |
| 1318 | 1333 | } |
| 1319 | 1334 | |
| 1320 | 1335 | |
| 1321 | | |
| 1322 | 1336 | /************************************************************************ |
| 1323 | 1337 | * atari_vh_screenrefresh |
| 1324 | 1338 | * Refresh screen bitmap. |
| 1325 | 1339 | * Note: Actual drawing is done scanline wise during atari_interrupt |
| 1326 | 1340 | ************************************************************************/ |
| 1327 | | UINT32 atari_common_state::screen_update_atari(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 1341 | UINT32 antic_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 1328 | 1342 | { |
| 1329 | 1343 | UINT32 new_tv_artifacts = screen.ioport("artifacts")->read_safe(0); |
| 1330 | | copybitmap(bitmap, *antic.bitmap, 0, 0, 0, 0, cliprect); |
| 1344 | copybitmap(bitmap, *m_bitmap, 0, 0, 0, 0, cliprect); |
| 1331 | 1345 | |
| 1332 | | if (tv_artifacts != new_tv_artifacts) |
| 1333 | | tv_artifacts = new_tv_artifacts; |
| 1346 | if (m_tv_artifacts != new_tv_artifacts) |
| 1347 | m_tv_artifacts = new_tv_artifacts; |
| 1334 | 1348 | |
| 1335 | 1349 | return 0; |
| 1336 | 1350 | } |
| 1337 | 1351 | |
| 1338 | | void atari_common_state::artifacts_gfx(UINT8 *src, UINT8 *dst, int width) |
| 1352 | void antic_device::artifacts_gfx(UINT8 *src, UINT8 *dst, int width) |
| 1339 | 1353 | { |
| 1340 | 1354 | UINT8 n, bits = 0; |
| 1341 | 1355 | UINT8 b = m_gtia->get_w_colbk() & 0xf0; |
| r32026 | r32027 | |
| 1409 | 1423 | } |
| 1410 | 1424 | } |
| 1411 | 1425 | |
| 1412 | | void atari_common_state::artifacts_txt(UINT8 * src, UINT8 * dst, int width) |
| 1426 | void antic_device::artifacts_txt(UINT8 * src, UINT8 * dst, int width) |
| 1413 | 1427 | { |
| 1414 | 1428 | UINT8 n, bits = 0; |
| 1415 | 1429 | UINT8 b = m_gtia->get_w_colpf2() & 0xf0; |
| r32026 | r32027 | |
| 1484 | 1498 | } |
| 1485 | 1499 | |
| 1486 | 1500 | |
| 1487 | | void atari_common_state::antic_linerefresh() |
| 1501 | void antic_device::linerefresh() |
| 1488 | 1502 | { |
| 1489 | 1503 | int x, y; |
| 1490 | 1504 | UINT8 *src; |
| r32026 | r32027 | |
| 1493 | 1507 | UINT16 *color_lookup = m_gtia->get_color_lookup(); |
| 1494 | 1508 | |
| 1495 | 1509 | /* increment the scanline */ |
| 1496 | | if( ++antic.scanline == machine().first_screen()->height() ) |
| 1510 | if( ++m_scanline == machine().first_screen()->height() ) |
| 1497 | 1511 | { |
| 1498 | 1512 | /* and return to the top if the frame was complete */ |
| 1499 | | antic.scanline = 0; |
| 1500 | | antic.modelines = 0; |
| 1513 | m_scanline = 0; |
| 1514 | m_modelines = 0; |
| 1501 | 1515 | /* count frames gone since last write to hitclr */ |
| 1502 | 1516 | m_gtia->count_hitclr_frames(); |
| 1503 | 1517 | } |
| 1504 | 1518 | |
| 1505 | | if( antic.scanline < MIN_Y || antic.scanline > MAX_Y ) |
| 1519 | if( m_scanline < MIN_Y || m_scanline > MAX_Y ) |
| 1506 | 1520 | return; |
| 1507 | 1521 | |
| 1508 | | y = antic.scanline - MIN_Y; |
| 1509 | | src = &antic.cclock[PMOFFSET - antic.hscrol_old + 12]; |
| 1522 | y = m_scanline - MIN_Y; |
| 1523 | src = &m_cclock[PMOFFSET - m_hscrol_old + 12]; |
| 1510 | 1524 | dst = scanline; |
| 1511 | 1525 | |
| 1512 | | if( tv_artifacts ) |
| 1526 | if( m_tv_artifacts ) |
| 1513 | 1527 | { |
| 1514 | | if( (antic.cmd & 0x0f) == 2 || (antic.cmd & 0x0f) == 3 ) |
| 1528 | if( (m_cmd & 0x0f) == 2 || (m_cmd & 0x0f) == 3 ) |
| 1515 | 1529 | { |
| 1516 | 1530 | artifacts_txt(src, (UINT8*)(dst + 3), HCHARS); |
| 1517 | 1531 | return; |
| 1518 | 1532 | } |
| 1519 | 1533 | else |
| 1520 | | if( (antic.cmd & 0x0f) == 15 ) |
| 1534 | if( (m_cmd & 0x0f) == 15 ) |
| 1521 | 1535 | { |
| 1522 | 1536 | artifacts_gfx(src, (UINT8*)(dst + 3), HCHARS); |
| 1523 | 1537 | return; |
| r32026 | r32027 | |
| 1526 | 1540 | dst[0] = color_lookup[PBK] | color_lookup[PBK] << 16; |
| 1527 | 1541 | dst[1] = color_lookup[PBK] | color_lookup[PBK] << 16; |
| 1528 | 1542 | dst[2] = color_lookup[PBK] | color_lookup[PBK] << 16; |
| 1529 | | if ( (antic.cmd & ANTIC_HSCR) == 0 || (antic.pfwidth == 48) || (antic.pfwidth == 32)) |
| 1543 | if ( (m_cmd & ANTIC_HSCR) == 0 || (m_pfwidth == 48) || (m_pfwidth == 32)) |
| 1530 | 1544 | { |
| 1531 | 1545 | /* no hscroll */ |
| 1532 | 1546 | dst[3] = color_lookup[src[BYTE_XOR_LE(0)]] | color_lookup[src[BYTE_XOR_LE(1)]] << 16; |
| r32026 | r32027 | |
| 1544 | 1558 | { |
| 1545 | 1559 | /* if hscroll is enabled, more data are fetched by ANTIC, but it still renders playfield |
| 1546 | 1560 | of width defined by pfwidth. */ |
| 1547 | | switch( antic.pfwidth ) |
| 1561 | switch( m_pfwidth ) |
| 1548 | 1562 | { |
| 1549 | 1563 | case 0: |
| 1550 | 1564 | { |
| r32026 | r32027 | |
| 1590 | 1604 | dst[2] = color_lookup[PBK] | color_lookup[PBK] << 16; |
| 1591 | 1605 | dst[3] = color_lookup[PBK] | color_lookup[PBK] << 16; |
| 1592 | 1606 | |
| 1593 | | draw_scanline8(*antic.bitmap, 12, y, MIN(antic.bitmap->width() - 12, sizeof(scanline)), (const UINT8 *) scanline, NULL); |
| 1607 | draw_scanline8(*m_bitmap, 12, y, MIN(m_bitmap->width() - 12, sizeof(scanline)), (const UINT8 *) scanline, NULL); |
| 1594 | 1608 | } |
| 1595 | 1609 | |
| 1596 | 1610 | |
| 1597 | 1611 | #define ANTIC_TIME_FROM_CYCLES(cycles) \ |
| 1598 | 1612 | (attotime)(machine().first_screen()->scan_period() * (cycles) / CYCLES_PER_LINE) |
| 1599 | 1613 | |
| 1600 | | void atari_common_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 1614 | void antic_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 1601 | 1615 | { |
| 1602 | 1616 | switch (id) |
| 1603 | 1617 | { |
| 1604 | 1618 | case TIMER_CYCLE_STEAL: |
| 1605 | | antic_steal_cycles(ptr, param); |
| 1619 | steal_cycles(ptr, param); |
| 1606 | 1620 | break; |
| 1607 | 1621 | case TIMER_ISSUE_DLI: |
| 1608 | | antic_issue_dli(ptr, param); |
| 1622 | issue_dli(ptr, param); |
| 1609 | 1623 | break; |
| 1610 | 1624 | case TIMER_LINE_REND: |
| 1611 | | antic_scanline_render(ptr, param); |
| 1625 | scanline_render(ptr, param); |
| 1612 | 1626 | break; |
| 1613 | 1627 | case TIMER_LINE_DONE: |
| 1614 | | antic_line_done(ptr, param); |
| 1628 | line_done(ptr, param); |
| 1615 | 1629 | break; |
| 1616 | 1630 | } |
| 1617 | 1631 | } |
| 1618 | 1632 | |
| 1619 | | int atari_common_state::cycle() |
| 1633 | int antic_device::cycle() |
| 1620 | 1634 | { |
| 1621 | 1635 | return machine().first_screen()->hpos() * CYCLES_PER_LINE / machine().first_screen()->width(); |
| 1622 | 1636 | } |
| 1623 | 1637 | |
| 1624 | | TIMER_CALLBACK_MEMBER( atari_common_state::antic_issue_dli ) |
| 1638 | TIMER_CALLBACK_MEMBER( antic_device::issue_dli ) |
| 1625 | 1639 | { |
| 1626 | | if( antic.w.nmien & DLI_NMI ) |
| 1640 | if( m_w.nmien & DLI_NMI ) |
| 1627 | 1641 | { |
| 1628 | 1642 | LOG((" @cycle #%3d issue DLI\n", cycle())); |
| 1629 | | antic.r.nmist |= DLI_NMI; |
| 1643 | m_r.nmist |= DLI_NMI; |
| 1630 | 1644 | machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| 1631 | 1645 | } |
| 1632 | 1646 | else |
| r32026 | r32027 | |
| 1641 | 1655 | * Antic Line Done |
| 1642 | 1656 | * |
| 1643 | 1657 | *****************************************************************************/ |
| 1644 | | TIMER_CALLBACK_MEMBER( atari_common_state::antic_line_done ) |
| 1658 | TIMER_CALLBACK_MEMBER( antic_device::line_done ) |
| 1645 | 1659 | { |
| 1646 | | LOG((" @cycle #%3d antic_line_done\n", cycle())); |
| 1647 | | if( antic.w.wsync ) |
| 1660 | LOG((" @cycle #%3d line_done\n", cycle())); |
| 1661 | if( m_w.wsync ) |
| 1648 | 1662 | { |
| 1649 | 1663 | LOG((" @cycle #%3d release WSYNC\n", cycle())); |
| 1650 | 1664 | /* release the CPU if it was actually waiting for HSYNC */ |
| 1651 | 1665 | machine().scheduler().trigger(TRIGGER_HSYNC); |
| 1652 | 1666 | /* and turn off the 'wait for hsync' flag */ |
| 1653 | | antic.w.wsync = 0; |
| 1667 | m_w.wsync = 0; |
| 1654 | 1668 | } |
| 1655 | 1669 | LOG((" @cycle #%3d release CPU\n", cycle())); |
| 1656 | 1670 | /* release the CPU (held for emulating cycles stolen by ANTIC DMA) */ |
| 1657 | 1671 | machine().scheduler().trigger(TRIGGER_STEAL); |
| 1658 | 1672 | |
| 1659 | 1673 | /* refresh the display (translate color clocks to pixels) */ |
| 1660 | | antic_linerefresh(); |
| 1674 | linerefresh(); |
| 1661 | 1675 | } |
| 1662 | 1676 | |
| 1663 | 1677 | /***************************************************************************** |
| r32026 | r32027 | |
| 1669 | 1683 | * TRIGGER_HSYNC if WSYNC (D01A) was accessed |
| 1670 | 1684 | * |
| 1671 | 1685 | *****************************************************************************/ |
| 1672 | | TIMER_CALLBACK_MEMBER( atari_common_state::antic_steal_cycles ) |
| 1686 | TIMER_CALLBACK_MEMBER( antic_device::steal_cycles ) |
| 1673 | 1687 | { |
| 1674 | | LOG((" @cycle #%3d steal %d cycles\n", cycle(), antic.steal_cycles)); |
| 1675 | | timer_set(ANTIC_TIME_FROM_CYCLES(antic.steal_cycles), TIMER_LINE_DONE); |
| 1676 | | antic.steal_cycles = 0; |
| 1688 | LOG((" @cycle #%3d steal %d cycles\n", cycle(), m_steal_cycles)); |
| 1689 | timer_set(ANTIC_TIME_FROM_CYCLES(m_steal_cycles), TIMER_LINE_DONE); |
| 1690 | m_steal_cycles = 0; |
| 1677 | 1691 | machine().device("maincpu")->execute().spin_until_trigger(TRIGGER_STEAL); |
| 1678 | 1692 | } |
| 1679 | 1693 | |
| r32026 | r32027 | |
| 1686 | 1700 | * of the GTIA if enabled (DMA_PLAYER or DMA_MISSILE) |
| 1687 | 1701 | * |
| 1688 | 1702 | *****************************************************************************/ |
| 1689 | | TIMER_CALLBACK_MEMBER( atari_common_state::antic_scanline_render ) |
| 1703 | TIMER_CALLBACK_MEMBER( antic_device::scanline_render ) |
| 1690 | 1704 | { |
| 1691 | 1705 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 1692 | 1706 | |
| 1693 | | LOG((" @cycle #%3d render mode $%X lines to go #%d\n", cycle(), (antic.cmd & 0x0f), antic.modelines)); |
| 1707 | LOG((" @cycle #%3d render mode $%X lines to go #%d\n", cycle(), (m_cmd & 0x0f), m_modelines)); |
| 1694 | 1708 | |
| 1695 | | antic_render(space, m_antic_render1, m_antic_render2, m_antic_render3); |
| 1709 | render(space, m_render1, m_render2, m_render3); |
| 1696 | 1710 | |
| 1697 | 1711 | /* if player/missile graphics is enabled */ |
| 1698 | | if( antic.scanline < 256 && (antic.w.dmactl & (DMA_PLAYER|DMA_MISSILE)) ) |
| 1712 | if( m_scanline < 256 && (m_w.dmactl & (DMA_PLAYER|DMA_MISSILE)) ) |
| 1699 | 1713 | { |
| 1700 | 1714 | /* new player/missile graphics data for every scanline ? */ |
| 1701 | | if( antic.w.dmactl & DMA_PM_DBLLINE ) |
| 1715 | if( m_w.dmactl & DMA_PM_DBLLINE ) |
| 1702 | 1716 | { |
| 1703 | 1717 | /* transport missile data to GTIA ? */ |
| 1704 | | if( antic.w.dmactl & DMA_MISSILE ) |
| 1718 | if( m_w.dmactl & DMA_MISSILE ) |
| 1705 | 1719 | { |
| 1706 | | antic.steal_cycles += 1; |
| 1720 | m_steal_cycles += 1; |
| 1707 | 1721 | m_gtia->write(space, 0x11, RDPMGFXD(space, 3*256)); |
| 1708 | 1722 | } |
| 1709 | 1723 | /* transport player data to GTIA ? */ |
| 1710 | | if( antic.w.dmactl & DMA_PLAYER ) |
| 1724 | if( m_w.dmactl & DMA_PLAYER ) |
| 1711 | 1725 | { |
| 1712 | | antic.steal_cycles += 4; |
| 1726 | m_steal_cycles += 4; |
| 1713 | 1727 | m_gtia->write(space, 0x0d, RDPMGFXD(space, 4*256)); |
| 1714 | 1728 | m_gtia->write(space, 0x0e, RDPMGFXD(space, 5*256)); |
| 1715 | 1729 | m_gtia->write(space, 0x0f, RDPMGFXD(space, 6*256)); |
| r32026 | r32027 | |
| 1719 | 1733 | else |
| 1720 | 1734 | { |
| 1721 | 1735 | /* transport missile data to GTIA ? */ |
| 1722 | | if( antic.w.dmactl & DMA_MISSILE ) |
| 1736 | if( m_w.dmactl & DMA_MISSILE ) |
| 1723 | 1737 | { |
| 1724 | | if( (antic.scanline & 1) == 0 ) /* even line ? */ |
| 1725 | | antic.steal_cycles += 1; |
| 1738 | if( (m_scanline & 1) == 0 ) /* even line ? */ |
| 1739 | m_steal_cycles += 1; |
| 1726 | 1740 | m_gtia->write(space, 0x11, RDPMGFXS(space, 3*128)); |
| 1727 | 1741 | } |
| 1728 | 1742 | /* transport player data to GTIA ? */ |
| 1729 | | if( antic.w.dmactl & DMA_PLAYER ) |
| 1743 | if( m_w.dmactl & DMA_PLAYER ) |
| 1730 | 1744 | { |
| 1731 | | if( (antic.scanline & 1) == 0 ) /* even line ? */ |
| 1732 | | antic.steal_cycles += 4; |
| 1745 | if( (m_scanline & 1) == 0 ) /* even line ? */ |
| 1746 | m_steal_cycles += 4; |
| 1733 | 1747 | m_gtia->write(space, 0x0d, RDPMGFXS(space, 4*128)); |
| 1734 | 1748 | m_gtia->write(space, 0x0e, RDPMGFXS(space, 5*128)); |
| 1735 | 1749 | m_gtia->write(space, 0x0f, RDPMGFXS(space, 6*128)); |
| r32026 | r32027 | |
| 1738 | 1752 | } |
| 1739 | 1753 | } |
| 1740 | 1754 | |
| 1741 | | if (antic.scanline >= VBL_END && antic.scanline < 256) |
| 1742 | | m_gtia->render((UINT8 *)antic.pmbits + PMOFFSET, (UINT8 *)antic.cclock + PMOFFSET - antic.hscrol_old, (UINT8 *)antic.prio_table[m_gtia->get_w_prior() & 0x3f], (UINT8 *)&antic.pmbits); |
| 1755 | if (m_scanline >= VBL_END && m_scanline < 256) |
| 1756 | m_gtia->render((UINT8 *)m_pmbits + PMOFFSET, (UINT8 *)m_cclock + PMOFFSET - m_hscrol_old, (UINT8 *)m_prio_table[m_gtia->get_w_prior() & 0x3f], (UINT8 *)&m_pmbits); |
| 1743 | 1757 | |
| 1744 | | antic.steal_cycles += CYCLES_REFRESH; |
| 1745 | | LOG((" run CPU for %d cycles\n", CYCLES_HSYNC - CYCLES_HSTART - antic.steal_cycles)); |
| 1746 | | timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSYNC - CYCLES_HSTART - antic.steal_cycles), TIMER_CYCLE_STEAL); |
| 1758 | m_steal_cycles += CYCLES_REFRESH; |
| 1759 | LOG((" run CPU for %d cycles\n", CYCLES_HSYNC - CYCLES_HSTART - m_steal_cycles)); |
| 1760 | timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSYNC - CYCLES_HSTART - m_steal_cycles), TIMER_CYCLE_STEAL); |
| 1747 | 1761 | } |
| 1748 | 1762 | |
| 1749 | 1763 | |
| 1750 | 1764 | |
| 1751 | | void atari_common_state::LMS(int new_cmd) |
| 1765 | void antic_device::LMS(int new_cmd) |
| 1752 | 1766 | { |
| 1753 | 1767 | /************************************************************** |
| 1754 | 1768 | * If the LMS bit (load memory scan) of the current display |
| r32026 | r32027 | |
| 1760 | 1774 | { |
| 1761 | 1775 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 1762 | 1776 | int addr = RDANTIC(space); |
| 1763 | | antic.doffs = (antic.doffs + 1) & DOFFS; |
| 1777 | m_doffs = (m_doffs + 1) & DOFFS; |
| 1764 | 1778 | addr += 256 * RDANTIC(space); |
| 1765 | | antic.doffs = (antic.doffs + 1) & DOFFS; |
| 1766 | | antic.vpage = addr & VPAGE; |
| 1767 | | antic.voffs = addr & VOFFS; |
| 1779 | m_doffs = (m_doffs + 1) & DOFFS; |
| 1780 | m_vpage = addr & VPAGE; |
| 1781 | m_voffs = addr & VOFFS; |
| 1768 | 1782 | LOG((" LMS $%04x\n", addr)); |
| 1769 | 1783 | /* steal two more clock cycles from the cpu */ |
| 1770 | | antic.steal_cycles += 2; |
| 1784 | m_steal_cycles += 2; |
| 1771 | 1785 | } |
| 1772 | 1786 | } |
| 1773 | 1787 | |
| r32026 | r32027 | |
| 1781 | 1795 | * if so, read a new command and set up the renderer function |
| 1782 | 1796 | * |
| 1783 | 1797 | *****************************************************************************/ |
| 1784 | | void atari_common_state::antic_scanline_dma(int param) |
| 1798 | void antic_device::scanline_dma(int param) |
| 1785 | 1799 | { |
| 1786 | 1800 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 1787 | 1801 | LOG((" @cycle #%3d DMA fetch\n", cycle())); |
| 1788 | | if (antic.scanline == VBL_END) |
| 1789 | | antic.r.nmist &= ~VBL_NMI; |
| 1790 | | if( antic.w.dmactl & DMA_ANTIC ) |
| 1802 | if (m_scanline == VBL_END) |
| 1803 | m_r.nmist &= ~VBL_NMI; |
| 1804 | if( m_w.dmactl & DMA_ANTIC ) |
| 1791 | 1805 | { |
| 1792 | | if( antic.scanline >= VBL_END && antic.scanline < VBL_START ) |
| 1806 | if( m_scanline >= VBL_END && m_scanline < VBL_START ) |
| 1793 | 1807 | { |
| 1794 | | if( antic.modelines <= 0 ) |
| 1808 | if( m_modelines <= 0 ) |
| 1795 | 1809 | { |
| 1796 | | m_antic_render1 = 0; |
| 1797 | | m_antic_render3 = antic.w.dmactl & 3; |
| 1810 | m_render1 = 0; |
| 1811 | m_render3 = m_w.dmactl & 3; |
| 1798 | 1812 | UINT8 vscrol_subtract = 0; |
| 1799 | 1813 | UINT8 new_cmd; |
| 1800 | 1814 | |
| 1801 | 1815 | new_cmd = RDANTIC(space); |
| 1802 | | antic.doffs = (antic.doffs + 1) & DOFFS; |
| 1816 | m_doffs = (m_doffs + 1) & DOFFS; |
| 1803 | 1817 | /* steal at one clock cycle from the CPU for fetching the command */ |
| 1804 | | antic.steal_cycles += 1; |
| 1818 | m_steal_cycles += 1; |
| 1805 | 1819 | LOG((" ANTIC CMD $%02x\n", new_cmd)); |
| 1806 | 1820 | /* command 1 .. 15 ? */ |
| 1807 | 1821 | if (new_cmd & ANTIC_MODE) |
| 1808 | 1822 | { |
| 1809 | | antic.w.chbasl = 0; |
| 1823 | m_w.chbasl = 0; |
| 1810 | 1824 | /* vertical scroll mode changed ? */ |
| 1811 | | if( (antic.cmd ^ new_cmd) & ANTIC_VSCR ) |
| 1825 | if( (m_cmd ^ new_cmd) & ANTIC_VSCR ) |
| 1812 | 1826 | { |
| 1813 | 1827 | /* vertical scroll activate now ? */ |
| 1814 | 1828 | if( new_cmd & ANTIC_VSCR ) |
| 1815 | 1829 | { |
| 1816 | | antic.vscrol_old = |
| 1830 | m_vscrol_old = |
| 1817 | 1831 | vscrol_subtract = |
| 1818 | | antic.w.chbasl = antic.w.vscrol; |
| 1832 | m_w.chbasl = m_w.vscrol; |
| 1819 | 1833 | } |
| 1820 | 1834 | else |
| 1821 | 1835 | { |
| 1822 | | vscrol_subtract = ~antic.vscrol_old; |
| 1836 | vscrol_subtract = ~m_vscrol_old; |
| 1823 | 1837 | } |
| 1824 | 1838 | } |
| 1825 | 1839 | /* does this command have horizontal scroll enabled ? */ |
| 1826 | 1840 | if( new_cmd & ANTIC_HSCR ) |
| 1827 | 1841 | { |
| 1828 | | m_antic_render1 = 1; |
| 1829 | | antic.hscrol_old = antic.w.hscrol; |
| 1842 | m_render1 = 1; |
| 1843 | m_hscrol_old = m_w.hscrol; |
| 1830 | 1844 | } |
| 1831 | 1845 | else |
| 1832 | 1846 | { |
| 1833 | | antic.hscrol_old = 0; |
| 1847 | m_hscrol_old = 0; |
| 1834 | 1848 | } |
| 1835 | 1849 | } |
| 1836 | 1850 | /* Set the ANTIC mode renderer function */ |
| 1837 | | m_antic_render2 = new_cmd & ANTIC_MODE; |
| 1851 | m_render2 = new_cmd & ANTIC_MODE; |
| 1838 | 1852 | |
| 1839 | 1853 | switch( new_cmd & ANTIC_MODE ) |
| 1840 | 1854 | { |
| 1841 | 1855 | case 0x00: |
| 1842 | 1856 | /* generate 1 .. 8 empty lines */ |
| 1843 | | antic.modelines = ((new_cmd >> 4) & 7) + 1; |
| 1857 | m_modelines = ((new_cmd >> 4) & 7) + 1; |
| 1844 | 1858 | /* did the last ANTIC command have vertical scroll enabled ? */ |
| 1845 | | if( antic.cmd & ANTIC_VSCR ) |
| 1859 | if( m_cmd & ANTIC_VSCR ) |
| 1846 | 1860 | { |
| 1847 | 1861 | /* yes, generate vscrol_old additional empty lines */ |
| 1848 | | antic.modelines += antic.vscrol_old; |
| 1862 | m_modelines += m_vscrol_old; |
| 1849 | 1863 | } |
| 1850 | 1864 | /* leave only bit 7 (DLI) set in ANTIC command */ |
| 1851 | 1865 | new_cmd &= ANTIC_DLI; |
| r32026 | r32027 | |
| 1862 | 1876 | if( new_cmd & ANTIC_LMS ) |
| 1863 | 1877 | { |
| 1864 | 1878 | int addr = RDANTIC(space); |
| 1865 | | antic.doffs = (antic.doffs + 1) & DOFFS; |
| 1879 | m_doffs = (m_doffs + 1) & DOFFS; |
| 1866 | 1880 | addr += 256 * RDANTIC(space); |
| 1867 | | antic.dpage = addr & DPAGE; |
| 1868 | | antic.doffs = addr & DOFFS; |
| 1881 | m_dpage = addr & DPAGE; |
| 1882 | m_doffs = addr & DOFFS; |
| 1869 | 1883 | /* produce empty scanlines until vblank start */ |
| 1870 | | antic.modelines = VBL_START + 1 - antic.scanline; |
| 1871 | | if( antic.modelines < 0 ) |
| 1872 | | antic.modelines = machine().first_screen()->height() - antic.scanline; |
| 1873 | | LOG((" JVB $%04x\n", antic.dpage|antic.doffs)); |
| 1884 | m_modelines = VBL_START + 1 - m_scanline; |
| 1885 | if( m_modelines < 0 ) |
| 1886 | m_modelines = machine().first_screen()->height() - m_scanline; |
| 1887 | LOG((" JVB $%04x\n", m_dpage|m_doffs)); |
| 1874 | 1888 | } |
| 1875 | 1889 | else |
| 1876 | 1890 | { |
| 1877 | 1891 | int addr = RDANTIC(space); |
| 1878 | | antic.doffs = (antic.doffs + 1) & DOFFS; |
| 1892 | m_doffs = (m_doffs + 1) & DOFFS; |
| 1879 | 1893 | addr += 256 * RDANTIC(space); |
| 1880 | | antic.dpage = addr & DPAGE; |
| 1881 | | antic.doffs = addr & DOFFS; |
| 1894 | m_dpage = addr & DPAGE; |
| 1895 | m_doffs = addr & DOFFS; |
| 1882 | 1896 | /* produce a single empty scanline */ |
| 1883 | | antic.modelines = 1; |
| 1884 | | LOG((" JMP $%04x\n", antic.dpage|antic.doffs)); |
| 1897 | m_modelines = 1; |
| 1898 | LOG((" JMP $%04x\n", m_dpage|m_doffs)); |
| 1885 | 1899 | } |
| 1886 | 1900 | break; |
| 1887 | 1901 | case 0x02: |
| 1888 | 1902 | LMS(new_cmd); |
| 1889 | | antic.chbase = (antic.w.chbash & 0xfc) << 8; |
| 1890 | | antic.modelines = 8 - (vscrol_subtract & 7); |
| 1891 | | if( antic.w.chactl & 4 ) /* decrement chbasl? */ |
| 1892 | | antic.w.chbasl = antic.modelines - 1; |
| 1903 | m_chbase = (m_w.chbash & 0xfc) << 8; |
| 1904 | m_modelines = 8 - (vscrol_subtract & 7); |
| 1905 | if( m_w.chactl & 4 ) /* decrement chbasl? */ |
| 1906 | m_w.chbasl = m_modelines - 1; |
| 1893 | 1907 | break; |
| 1894 | 1908 | case 0x03: |
| 1895 | 1909 | LMS(new_cmd); |
| 1896 | | antic.chbase = (antic.w.chbash & 0xfc) << 8; |
| 1897 | | antic.modelines = 10 - (vscrol_subtract & 9); |
| 1898 | | if( antic.w.chactl & 4 ) /* decrement chbasl? */ |
| 1899 | | antic.w.chbasl = antic.modelines - 1; |
| 1910 | m_chbase = (m_w.chbash & 0xfc) << 8; |
| 1911 | m_modelines = 10 - (vscrol_subtract & 9); |
| 1912 | if( m_w.chactl & 4 ) /* decrement chbasl? */ |
| 1913 | m_w.chbasl = m_modelines - 1; |
| 1900 | 1914 | break; |
| 1901 | 1915 | case 0x04: |
| 1902 | 1916 | LMS(new_cmd); |
| 1903 | | antic.chbase = (antic.w.chbash & 0xfc) << 8; |
| 1904 | | antic.modelines = 8 - (vscrol_subtract & 7); |
| 1905 | | if( antic.w.chactl & 4 ) /* decrement chbasl? */ |
| 1906 | | antic.w.chbasl = antic.modelines - 1; |
| 1917 | m_chbase = (m_w.chbash & 0xfc) << 8; |
| 1918 | m_modelines = 8 - (vscrol_subtract & 7); |
| 1919 | if( m_w.chactl & 4 ) /* decrement chbasl? */ |
| 1920 | m_w.chbasl = m_modelines - 1; |
| 1907 | 1921 | break; |
| 1908 | 1922 | case 0x05: |
| 1909 | 1923 | LMS(new_cmd); |
| 1910 | | antic.chbase = (antic.w.chbash & 0xfc) << 8; |
| 1911 | | antic.modelines = 16 - (vscrol_subtract & 15); |
| 1912 | | if( antic.w.chactl & 4 ) /* decrement chbasl? */ |
| 1913 | | antic.w.chbasl = antic.modelines - 1; |
| 1924 | m_chbase = (m_w.chbash & 0xfc) << 8; |
| 1925 | m_modelines = 16 - (vscrol_subtract & 15); |
| 1926 | if( m_w.chactl & 4 ) /* decrement chbasl? */ |
| 1927 | m_w.chbasl = m_modelines - 1; |
| 1914 | 1928 | break; |
| 1915 | 1929 | case 0x06: |
| 1916 | 1930 | LMS(new_cmd); |
| 1917 | | antic.chbase = (antic.w.chbash & 0xfe) << 8; |
| 1918 | | antic.modelines = 8 - (vscrol_subtract & 7); |
| 1919 | | if( antic.w.chactl & 4 ) /* decrement chbasl? */ |
| 1920 | | antic.w.chbasl = antic.modelines - 1; |
| 1931 | m_chbase = (m_w.chbash & 0xfe) << 8; |
| 1932 | m_modelines = 8 - (vscrol_subtract & 7); |
| 1933 | if( m_w.chactl & 4 ) /* decrement chbasl? */ |
| 1934 | m_w.chbasl = m_modelines - 1; |
| 1921 | 1935 | break; |
| 1922 | 1936 | case 0x07: |
| 1923 | 1937 | LMS(new_cmd); |
| 1924 | | antic.chbase = (antic.w.chbash & 0xfe) << 8; |
| 1925 | | antic.modelines = 16 - (vscrol_subtract & 15); |
| 1926 | | if( antic.w.chactl & 4 ) /* decrement chbasl? */ |
| 1927 | | antic.w.chbasl = antic.modelines - 1; |
| 1938 | m_chbase = (m_w.chbash & 0xfe) << 8; |
| 1939 | m_modelines = 16 - (vscrol_subtract & 15); |
| 1940 | if( m_w.chactl & 4 ) /* decrement chbasl? */ |
| 1941 | m_w.chbasl = m_modelines - 1; |
| 1928 | 1942 | break; |
| 1929 | 1943 | case 0x08: |
| 1930 | 1944 | LMS(new_cmd); |
| 1931 | | antic.modelines = 8 - (vscrol_subtract & 7); |
| 1945 | m_modelines = 8 - (vscrol_subtract & 7); |
| 1932 | 1946 | break; |
| 1933 | 1947 | case 0x09: |
| 1934 | 1948 | LMS(new_cmd); |
| 1935 | | antic.modelines = 4 - (vscrol_subtract & 3); |
| 1949 | m_modelines = 4 - (vscrol_subtract & 3); |
| 1936 | 1950 | break; |
| 1937 | 1951 | case 0x0a: |
| 1938 | 1952 | LMS(new_cmd); |
| 1939 | | antic.modelines = 4 - (vscrol_subtract & 3); |
| 1953 | m_modelines = 4 - (vscrol_subtract & 3); |
| 1940 | 1954 | break; |
| 1941 | 1955 | case 0x0b: |
| 1942 | 1956 | LMS(new_cmd); |
| 1943 | | antic.modelines = 2 - (vscrol_subtract & 1); |
| 1957 | m_modelines = 2 - (vscrol_subtract & 1); |
| 1944 | 1958 | break; |
| 1945 | 1959 | case 0x0c: |
| 1946 | 1960 | LMS(new_cmd); |
| 1947 | | antic.modelines = 1; |
| 1961 | m_modelines = 1; |
| 1948 | 1962 | break; |
| 1949 | 1963 | case 0x0d: |
| 1950 | 1964 | LMS(new_cmd); |
| 1951 | | antic.modelines = 2 - (vscrol_subtract & 1); |
| 1965 | m_modelines = 2 - (vscrol_subtract & 1); |
| 1952 | 1966 | break; |
| 1953 | 1967 | case 0x0e: |
| 1954 | 1968 | LMS(new_cmd); |
| 1955 | | antic.modelines = 1; |
| 1969 | m_modelines = 1; |
| 1956 | 1970 | break; |
| 1957 | 1971 | case 0x0f: |
| 1958 | 1972 | LMS(new_cmd); |
| r32026 | r32027 | |
| 1961 | 1975 | switch (m_gtia->get_w_prior() >> 6) |
| 1962 | 1976 | { |
| 1963 | 1977 | case 0: break; |
| 1964 | | case 1: m_antic_render2 = 16; break; |
| 1965 | | case 2: m_antic_render2 = 17; break; |
| 1966 | | case 3: m_antic_render2 = 18; break; |
| 1978 | case 1: m_render2 = 16; break; |
| 1979 | case 2: m_render2 = 17; break; |
| 1980 | case 3: m_render2 = 18; break; |
| 1967 | 1981 | } |
| 1968 | | antic.modelines = 1; |
| 1982 | m_modelines = 1; |
| 1969 | 1983 | break; |
| 1970 | 1984 | } |
| 1971 | 1985 | /* set new (current) antic command */ |
| 1972 | | antic.cmd = new_cmd; |
| 1986 | m_cmd = new_cmd; |
| 1973 | 1987 | } |
| 1974 | 1988 | } |
| 1975 | 1989 | else |
| 1976 | 1990 | { |
| 1977 | 1991 | LOG((" out of visible range\n")); |
| 1978 | | antic.cmd = 0x00; |
| 1979 | | m_antic_render1 = 0; |
| 1980 | | m_antic_render2 = 0; |
| 1981 | | m_antic_render3 = 0; |
| 1992 | m_cmd = 0x00; |
| 1993 | m_render1 = 0; |
| 1994 | m_render2 = 0; |
| 1995 | m_render3 = 0; |
| 1982 | 1996 | } |
| 1983 | 1997 | } |
| 1984 | 1998 | else |
| 1985 | 1999 | { |
| 1986 | 2000 | LOG((" DMA is off\n")); |
| 1987 | | antic.cmd = 0x00; |
| 1988 | | m_antic_render1 = 0; |
| 1989 | | m_antic_render2 = 0; |
| 1990 | | m_antic_render3 = 0; |
| 2001 | m_cmd = 0x00; |
| 2002 | m_render1 = 0; |
| 2003 | m_render2 = 0; |
| 2004 | m_render3 = 0; |
| 1991 | 2005 | } |
| 1992 | 2006 | |
| 1993 | | antic.r.nmist &= ~DLI_NMI; |
| 1994 | | if (antic.modelines == 1 && (antic.cmd & antic.w.nmien & DLI_NMI)) |
| 2007 | m_r.nmist &= ~DLI_NMI; |
| 2008 | if (m_modelines == 1 && (m_cmd & m_w.nmien & DLI_NMI)) |
| 1995 | 2009 | timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_DLI_NMI), TIMER_ISSUE_DLI); |
| 1996 | 2010 | |
| 1997 | 2011 | timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSTART), TIMER_LINE_REND); |
| 1998 | 2012 | } |
| 2013 | |
| 2014 | /***************************************************************************** |
| 2015 | * |
| 2016 | * Generic Atari Interrupt Dispatcher |
| 2017 | * This is called once per scanline and handles: |
| 2018 | * vertical blank interrupt |
| 2019 | * ANTIC DMA to possibly access the next display list command |
| 2020 | * |
| 2021 | *****************************************************************************/ |
| 2022 | |
| 2023 | void antic_device::generic_interrupt(int button_count) |
| 2024 | { |
| 2025 | LOG(("ANTIC #%3d @cycle #%d scanline interrupt\n", m_scanline, cycle())); |
| 2026 | |
| 2027 | if( m_scanline < VBL_START ) |
| 2028 | { |
| 2029 | scanline_dma(0); |
| 2030 | return; |
| 2031 | } |
| 2032 | |
| 2033 | if( m_scanline == VBL_START ) |
| 2034 | { |
| 2035 | /* specify buttons relevant to this Atari variant */ |
| 2036 | m_gtia->button_interrupt(button_count, machine().root_device().ioport("djoy_b")->read_safe(0)); |
| 2037 | |
| 2038 | /* do nothing new for the rest of the frame */ |
| 2039 | m_modelines = machine().first_screen()->height() - VBL_START; |
| 2040 | m_render1 = 0; |
| 2041 | m_render2 = 0; |
| 2042 | m_render3 = 0; |
| 2043 | |
| 2044 | /* if the CPU want's to be interrupted at vertical blank... */ |
| 2045 | if( m_w.nmien & VBL_NMI ) |
| 2046 | { |
| 2047 | LOG((" cause VBL NMI\n")); |
| 2048 | /* set the VBL NMI status bit */ |
| 2049 | m_r.nmist |= VBL_NMI; |
| 2050 | machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| 2051 | } |
| 2052 | } |
| 2053 | |
| 2054 | /* refresh the display (translate color clocks to pixels) */ |
| 2055 | linerefresh(); |
| 2056 | } |
| 2057 | |
trunk/src/mame/video/antic.h
| r32026 | r32027 | |
| 12 | 12 | #define __ANTIC_H__ |
| 13 | 13 | |
| 14 | 14 | #include "emu.h" |
| 15 | #include "video/gtia.h" |
| 15 | 16 | |
| 17 | |
| 18 | #define CYCLES_PER_LINE 114 /* total number of cpu cycles per scanline (incl. hblank) */ |
| 19 | #define CYCLES_REFRESH 9 /* number of cycles lost for ANTICs RAM refresh using DMA */ |
| 20 | #define CYCLES_HSTART 32 /* where does the ANTIC DMA fetch start */ |
| 21 | #define CYCLES_DLI_NMI 7 /* number of cycles until the CPU recognizes a DLI */ |
| 22 | #define CYCLES_HSYNC 104 /* where does the HSYNC position of a scanline start */ |
| 23 | |
| 24 | #define VBL_END 8 /* vblank ends in this scanline */ |
| 25 | #define VDATA_START 11 /* video display begins in this scanline */ |
| 26 | #define VDATA_END 244 /* video display ends in this scanline */ |
| 27 | #define VBL_START 248 /* vblank starts in this scanline */ |
| 28 | |
| 29 | /* total number of lines per frame (incl. vblank) */ |
| 30 | #define TOTAL_LINES_60HZ 262 |
| 31 | #define TOTAL_LINES_50HZ 312 |
| 32 | |
| 33 | /* frame rates */ |
| 34 | #define FRAME_RATE_50HZ (double)1789790/114/TOTAL_LINES_50HZ |
| 35 | #define FRAME_RATE_60HZ (double)1789790/114/TOTAL_LINES_60HZ |
| 36 | |
| 16 | 37 | #define HWIDTH 48 /* total characters per line */ |
| 17 | 38 | #define HCHARS 44 /* visible characters per line */ |
| 18 | 39 | #define VHEIGHT 32 |
| r32026 | r32027 | |
| 122 | 143 | #define COPY8(dst,s1,s2) *dst++ = s1; *dst++ = s2 |
| 123 | 144 | #define COPY16(dst,s1,s2,s3,s4) *dst++ = s1; *dst++ = s2; *dst++ = s3; *dst++ = s4 |
| 124 | 145 | |
| 125 | | struct ANTIC_R { |
| 126 | | UINT8 antic00; /* 00 nothing */ |
| 127 | | UINT8 antic01; /* 01 nothing */ |
| 128 | | UINT8 antic02; /* 02 nothing */ |
| 129 | | UINT8 antic03; /* 03 nothing */ |
| 130 | | UINT8 antic04; /* 04 nothing */ |
| 131 | | UINT8 antic05; /* 05 nothing */ |
| 132 | | UINT8 antic06; /* 06 nothing */ |
| 133 | | UINT8 antic07; /* 07 nothing */ |
| 134 | | UINT8 antic08; /* 08 nothing */ |
| 135 | | UINT8 antic09; /* 09 nothing */ |
| 136 | | UINT8 antic0a; /* 0a nothing */ |
| 137 | | UINT8 vcount; /* 0b vertical (scanline) counter */ |
| 138 | | UINT8 penh; /* 0c light pen horizontal pos */ |
| 139 | | UINT8 penv; /* 0d light pen vertical pos */ |
| 140 | | UINT8 antic0e; /* 0e nothing */ |
| 141 | | UINT8 nmist; /* 0f NMI status */ |
| 142 | | }; /* read registers */ |
| 146 | #define RDANTIC(space) space.read_byte(m_dpage+m_doffs) |
| 147 | #define RDVIDEO(space,o) space.read_byte(m_vpage+((m_voffs+(o))&VOFFS)) |
| 148 | #define RDCHGEN(space,o) space.read_byte(m_chbase+(o)) |
| 149 | #define RDPMGFXS(space,o) space.read_byte(m_pmbase_s+(o)+(m_scanline>>1)) |
| 150 | #define RDPMGFXD(space,o) space.read_byte(m_pmbase_d+(o)+m_scanline) |
| 143 | 151 | |
| 144 | | struct ANTIC_W { |
| 145 | | UINT8 dmactl; /* 00 write DMA control */ |
| 146 | | UINT8 chactl; /* 01 write character control */ |
| 147 | | UINT8 dlistl; /* 02 display list low */ |
| 148 | | UINT8 dlisth; /* 03 display list high */ |
| 149 | | UINT8 hscrol; /* 04 horz scroll */ |
| 150 | | UINT8 vscrol; /* 05 vert scroll */ |
| 151 | | UINT8 pmbasl; /* 06 player/missile base addr low */ |
| 152 | | UINT8 pmbash; /* 07 player/missile base addr high */ |
| 153 | | UINT8 chbasl; /* 08 character generator base addr low */ |
| 154 | | UINT8 chbash; /* 09 character generator base addr high */ |
| 155 | | UINT8 wsync; /* 0a wait for hsync */ |
| 156 | | UINT8 antic0b; /* 0b nothing */ |
| 157 | | UINT8 antic0c; /* 0c nothing */ |
| 158 | | UINT8 antic0d; /* 0d nothing */ |
| 159 | | UINT8 nmien; /* 0e NMI enable */ |
| 160 | | UINT8 nmires; /* 0f NMI reset */ |
| 161 | | }; /* write registers */ |
| 162 | | |
| 163 | | /* per scanline buffer for video data (and optimization variables) */ |
| 164 | | struct VIDEO { |
| 165 | | UINT32 cmd; /* antic command for this scanline */ |
| 166 | | UINT16 data[HWIDTH]; /* graphics data buffer (text through chargen) */ |
| 167 | | }; |
| 168 | | |
| 169 | | typedef void (*atari_renderer_func)(address_space &space, VIDEO *video); |
| 170 | | |
| 171 | | struct ANTIC { |
| 172 | | atari_renderer_func renderer; /* current renderer */ |
| 173 | | UINT32 cmd; /* currently executed display list command */ |
| 174 | | UINT32 steal_cycles; /* steal how many cpu cycles for this line ? */ |
| 175 | | UINT32 vscrol_old; /* old vscrol value */ |
| 176 | | UINT32 hscrol_old; /* old hscrol value */ |
| 177 | | INT32 modelines; /* number of lines for current ANTIC mode */ |
| 178 | | UINT32 chbase; /* character mode source base */ |
| 179 | | UINT32 chand; /* character and mask (chactl) */ |
| 180 | | UINT32 chxor; /* character xor mask (chactl) */ |
| 181 | | UINT32 scanline; /* current scan line */ |
| 182 | | UINT32 pfwidth; /* playfield width */ |
| 183 | | UINT32 dpage; /* display list address page */ |
| 184 | | UINT32 doffs; /* display list offset into page */ |
| 185 | | UINT32 vpage; /* video data source page */ |
| 186 | | UINT32 voffs; /* video data offset into page */ |
| 187 | | UINT32 pmbase_s; /* p/m graphics single line source base */ |
| 188 | | UINT32 pmbase_d; /* p/m graphics double line source base */ |
| 189 | | ANTIC_R r; /* ANTIC read registers */ |
| 190 | | ANTIC_W w; /* ANTIC write registers */ |
| 191 | | UINT8 cclock[256+32]; /* color clock buffer filled by ANTIC */ |
| 192 | | UINT8 pmbits[256+32]; /* player missile buffer filled by GTIA */ |
| 193 | | UINT8 *prio_table[64]; /* player/missile priority tables */ |
| 194 | | VIDEO *video[312]; /* video buffer */ |
| 195 | | UINT32 *cclk_expand; /* shared buffer for the following: */ |
| 196 | | UINT32 *pf_21; /* 1cclk 2 color txt 2,3 */ |
| 197 | | UINT32 *pf_x10b; /* 1cclk 4 color txt 4,5, gfx D,E */ |
| 198 | | UINT32 *pf_3210b2; /* 1cclk 5 color txt 6,7, gfx 9,B,C */ |
| 199 | | UINT32 *pf_210b4; /* 4cclk 4 color gfx 8 */ |
| 200 | | UINT32 *pf_210b2; /* 2cclk 4 color gfx A */ |
| 201 | | UINT32 *pf_1b; /* 1cclk hires gfx F */ |
| 202 | | UINT32 *pf_gtia1; /* 1cclk gtia mode 1 */ |
| 203 | | UINT32 *pf_gtia2; /* 1cclk gtia mode 2 */ |
| 204 | | UINT32 *pf_gtia3; /* 1cclk gtia mode 3 */ |
| 205 | | UINT8 *used_colors; /* shared buffer for the following: */ |
| 206 | | UINT8 *uc_21; /* used colors for txt (2,3) */ |
| 207 | | UINT8 *uc_x10b; /* used colors for txt 4,5, gfx D,E */ |
| 208 | | UINT8 *uc_3210b2; /* used colors for txt 6,7, gfx 9,B,C */ |
| 209 | | UINT8 *uc_210b4; /* used colors for gfx 8 */ |
| 210 | | UINT8 *uc_210b2; /* used colors for gfx A */ |
| 211 | | UINT8 *uc_1b; /* used colors for gfx F */ |
| 212 | | UINT8 *uc_g1; /* used colors for gfx GTIA 1 */ |
| 213 | | UINT8 *uc_g2; /* used colors for gfx GTIA 2 */ |
| 214 | | UINT8 *uc_g3; /* used colors for gfx GTIA 3 */ |
| 215 | | bitmap_ind16 *bitmap; |
| 216 | | }; |
| 217 | | |
| 218 | | #define RDANTIC(space) space.read_byte(antic.dpage+antic.doffs) |
| 219 | | #define RDVIDEO(space,o) space.read_byte(antic.vpage+((antic.voffs+(o))&VOFFS)) |
| 220 | | #define RDCHGEN(space,o) space.read_byte(antic.chbase+(o)) |
| 221 | | #define RDPMGFXS(space,o) space.read_byte(antic.pmbase_s+(o)+(antic.scanline>>1)) |
| 222 | | #define RDPMGFXD(space,o) space.read_byte(antic.pmbase_d+(o)+antic.scanline) |
| 223 | | |
| 224 | 152 | #define PREPARE() \ |
| 225 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET] |
| 153 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET] |
| 226 | 154 | |
| 227 | 155 | #define PREPARE_TXT2(space,width) \ |
| 228 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 156 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 229 | 157 | for (int i = 0; i < width; i++) \ |
| 230 | 158 | { \ |
| 231 | 159 | UINT16 ch = RDVIDEO(space,i) << 3; \ |
| 232 | 160 | if (ch & 0x400) \ |
| 233 | 161 | { \ |
| 234 | | ch = RDCHGEN(space,(ch & 0x3f8) + antic.w.chbasl); \ |
| 235 | | ch = (ch ^ antic.chxor) & antic.chand; \ |
| 162 | ch = RDCHGEN(space,(ch & 0x3f8) + m_w.chbasl); \ |
| 163 | ch = (ch ^ m_chxor) & m_chand; \ |
| 236 | 164 | } \ |
| 237 | 165 | else \ |
| 238 | 166 | { \ |
| 239 | | ch = RDCHGEN(space,ch + antic.w.chbasl); \ |
| 167 | ch = RDCHGEN(space,ch + m_w.chbasl); \ |
| 240 | 168 | } \ |
| 241 | 169 | video->data[i] = ch; \ |
| 242 | 170 | } |
| 243 | 171 | |
| 244 | 172 | #define PREPARE_TXT3(space,width) \ |
| 245 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 173 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 246 | 174 | for (int i = 0; i < width; i++) \ |
| 247 | 175 | { \ |
| 248 | 176 | UINT16 ch = RDVIDEO(space,i) << 3; \ |
| r32026 | r32027 | |
| 251 | 179 | ch &= 0x3f8; \ |
| 252 | 180 | if ((ch & 0x300) == 0x300) \ |
| 253 | 181 | { \ |
| 254 | | if (antic.w.chbasl < 2) /* first two lines empty */ \ |
| 182 | if (m_w.chbasl < 2) /* first two lines empty */ \ |
| 255 | 183 | ch = 0x00; \ |
| 256 | 184 | else /* lines 2..7 are standard, 8&9 are 0&1 */ \ |
| 257 | | ch = RDCHGEN(space,ch + (antic.w.chbasl & 7));\ |
| 185 | ch = RDCHGEN(space,ch + (m_w.chbasl & 7));\ |
| 258 | 186 | } \ |
| 259 | 187 | else \ |
| 260 | 188 | { \ |
| 261 | | if (antic.w.chbasl > 7) /* last two lines empty */ \ |
| 189 | if (m_w.chbasl > 7) /* last two lines empty */ \ |
| 262 | 190 | ch = 0x00; \ |
| 263 | 191 | else /* lines 0..7 are standard */ \ |
| 264 | | ch = RDCHGEN(space,ch + antic.w.chbasl); \ |
| 192 | ch = RDCHGEN(space,ch + m_w.chbasl); \ |
| 265 | 193 | } \ |
| 266 | | ch = (ch ^ antic.chxor) & antic.chand; \ |
| 194 | ch = (ch ^ m_chxor) & m_chand; \ |
| 267 | 195 | } \ |
| 268 | 196 | else \ |
| 269 | 197 | { \ |
| 270 | 198 | if ((ch & 0x300) == 0x300) \ |
| 271 | 199 | { \ |
| 272 | | if (antic.w.chbasl < 2) /* first two lines empty */ \ |
| 200 | if (m_w.chbasl < 2) /* first two lines empty */ \ |
| 273 | 201 | ch = 0x00; \ |
| 274 | 202 | else /* lines 2..7 are standard, 8&9 are 0&1 */ \ |
| 275 | | ch = RDCHGEN(space,ch + (antic.w.chbasl & 7));\ |
| 203 | ch = RDCHGEN(space,ch + (m_w.chbasl & 7));\ |
| 276 | 204 | } \ |
| 277 | 205 | else \ |
| 278 | 206 | { \ |
| 279 | | if (antic.w.chbasl > 7) /* last two lines empty */ \ |
| 207 | if (m_w.chbasl > 7) /* last two lines empty */ \ |
| 280 | 208 | ch = 0x00; \ |
| 281 | 209 | else /* lines 0..7 are standard */ \ |
| 282 | | ch = RDCHGEN(space,ch + antic.w.chbasl); \ |
| 210 | ch = RDCHGEN(space,ch + m_w.chbasl); \ |
| 283 | 211 | } \ |
| 284 | 212 | } \ |
| 285 | 213 | video->data[i] = ch; \ |
| 286 | 214 | } |
| 287 | 215 | |
| 288 | 216 | #define PREPARE_TXT45(space,width,shift) \ |
| 289 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 217 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 290 | 218 | for (int i = 0; i < width; i++) \ |
| 291 | 219 | { \ |
| 292 | 220 | UINT16 ch = RDVIDEO(space,i) << 3; \ |
| 293 | | ch = ((ch>>2)&0x100)|RDCHGEN(space,(ch&0x3f8)+(antic.w.chbasl>>shift)); \ |
| 221 | ch = ((ch>>2)&0x100)|RDCHGEN(space,(ch&0x3f8)+(m_w.chbasl>>shift)); \ |
| 294 | 222 | video->data[i] = ch; \ |
| 295 | 223 | } |
| 296 | 224 | |
| 297 | 225 | |
| 298 | 226 | #define PREPARE_TXT67(space,width,shift) \ |
| 299 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 227 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 300 | 228 | for (int i = 0; i < width; i++) \ |
| 301 | 229 | { \ |
| 302 | 230 | UINT16 ch = RDVIDEO(space,i) << 3; \ |
| 303 | | ch = (ch&0x600)|(RDCHGEN(space,(ch&0x1f8)+(antic.w.chbasl>>shift))<<1); \ |
| 231 | ch = (ch&0x600)|(RDCHGEN(space,(ch&0x1f8)+(m_w.chbasl>>shift))<<1); \ |
| 304 | 232 | video->data[i] = ch; \ |
| 305 | 233 | } |
| 306 | 234 | |
| 307 | 235 | #define PREPARE_GFX8(space,width) \ |
| 308 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 236 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 309 | 237 | for (int i = 0; i < width; i++) \ |
| 310 | 238 | video->data[i] = RDVIDEO(space,i) << 2 |
| 311 | 239 | |
| 312 | 240 | #define PREPARE_GFX9BC(space,width) \ |
| 313 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 241 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 314 | 242 | for (int i = 0; i < width; i++) \ |
| 315 | 243 | video->data[i] = RDVIDEO(space,i) << 1 |
| 316 | 244 | |
| 317 | 245 | #define PREPARE_GFXA(space,width) \ |
| 318 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 246 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 319 | 247 | for (int i = 0; i < width; i++) \ |
| 320 | 248 | video->data[i] = RDVIDEO(space,i) << 1 |
| 321 | 249 | |
| 322 | 250 | #define PREPARE_GFXDE(space,width) \ |
| 323 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 251 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 324 | 252 | for (int i = 0; i < width; i++) \ |
| 325 | 253 | video->data[i] = RDVIDEO(space,i) |
| 326 | 254 | |
| 327 | 255 | #define PREPARE_GFXF(space,width) \ |
| 328 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 256 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 329 | 257 | for (int i = 0; i < width; i++) \ |
| 330 | 258 | video->data[i] = RDVIDEO(space,i) |
| 331 | 259 | |
| 332 | 260 | #define PREPARE_GFXG1(space,width) \ |
| 333 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 261 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 334 | 262 | for (int i = 0; i < width; i++) \ |
| 335 | 263 | video->data[i] = RDVIDEO(space,i) |
| 336 | 264 | |
| 337 | 265 | #define PREPARE_GFXG2(space,width) \ |
| 338 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 266 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 339 | 267 | for (int i = 0; i < width; i++) \ |
| 340 | 268 | video->data[i] = RDVIDEO(space,i) |
| 341 | 269 | |
| 342 | 270 | #define PREPARE_GFXG3(space,width) \ |
| 343 | | UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]; \ |
| 271 | UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]; \ |
| 344 | 272 | for (int i = 0; i < width; i++) \ |
| 345 | 273 | video->data[i] = RDVIDEO(space,i) |
| 346 | 274 | |
| r32026 | r32027 | |
| 348 | 276 | * common end of a single antic/gtia mode emulation function |
| 349 | 277 | ******************************************************************/ |
| 350 | 278 | #define POST() \ |
| 351 | | --antic.modelines |
| 279 | --m_modelines |
| 352 | 280 | |
| 353 | 281 | #define POST_GFX(width) \ |
| 354 | | antic.steal_cycles += width; \ |
| 355 | | if (--antic.modelines == 0) \ |
| 356 | | antic.voffs = (antic.voffs + width) & VOFFS |
| 282 | m_steal_cycles += width; \ |
| 283 | if (--m_modelines == 0) \ |
| 284 | m_voffs = (m_voffs + width) & VOFFS |
| 357 | 285 | |
| 358 | 286 | #define POST_TXT(width) \ |
| 359 | | antic.steal_cycles += width; \ |
| 360 | | if (--antic.modelines == 0) \ |
| 361 | | antic.voffs = (antic.voffs + width) & VOFFS; \ |
| 362 | | else if (antic.w.chactl & 4) \ |
| 363 | | antic.w.chbasl--; \ |
| 287 | m_steal_cycles += width; \ |
| 288 | if (--m_modelines == 0) \ |
| 289 | m_voffs = (m_voffs + width) & VOFFS; \ |
| 290 | else if (m_w.chactl & 4) \ |
| 291 | m_w.chbasl--; \ |
| 364 | 292 | else \ |
| 365 | | antic.w.chbasl++ |
| 293 | m_w.chbasl++ |
| 366 | 294 | |
| 367 | 295 | /* erase a number of color clocks to background color PBK */ |
| 368 | 296 | #define ERASE(size) \ |
| r32026 | r32027 | |
| 387 | 315 | } \ |
| 388 | 316 | |
| 389 | 317 | |
| 390 | | void antic_start(running_machine &machine); |
| 391 | | void antic_vstart(running_machine &machine); |
| 392 | | void antic_reset(void); |
| 393 | | void antic_render(address_space &space, int param1, int param2, int param3); |
| 394 | 318 | |
| 319 | struct ANTIC_R { |
| 320 | UINT8 antic00; /* 00 nothing */ |
| 321 | UINT8 antic01; /* 01 nothing */ |
| 322 | UINT8 antic02; /* 02 nothing */ |
| 323 | UINT8 antic03; /* 03 nothing */ |
| 324 | UINT8 antic04; /* 04 nothing */ |
| 325 | UINT8 antic05; /* 05 nothing */ |
| 326 | UINT8 antic06; /* 06 nothing */ |
| 327 | UINT8 antic07; /* 07 nothing */ |
| 328 | UINT8 antic08; /* 08 nothing */ |
| 329 | UINT8 antic09; /* 09 nothing */ |
| 330 | UINT8 antic0a; /* 0a nothing */ |
| 331 | UINT8 vcount; /* 0b vertical (scanline) counter */ |
| 332 | UINT8 penh; /* 0c light pen horizontal pos */ |
| 333 | UINT8 penv; /* 0d light pen vertical pos */ |
| 334 | UINT8 antic0e; /* 0e nothing */ |
| 335 | UINT8 nmist; /* 0f NMI status */ |
| 336 | }; /* read registers */ |
| 395 | 337 | |
| 396 | | extern ANTIC antic; |
| 338 | struct ANTIC_W { |
| 339 | UINT8 dmactl; /* 00 write DMA control */ |
| 340 | UINT8 chactl; /* 01 write character control */ |
| 341 | UINT8 dlistl; /* 02 display list low */ |
| 342 | UINT8 dlisth; /* 03 display list high */ |
| 343 | UINT8 hscrol; /* 04 horz scroll */ |
| 344 | UINT8 vscrol; /* 05 vert scroll */ |
| 345 | UINT8 pmbasl; /* 06 player/missile base addr low */ |
| 346 | UINT8 pmbash; /* 07 player/missile base addr high */ |
| 347 | UINT8 chbasl; /* 08 character generator base addr low */ |
| 348 | UINT8 chbash; /* 09 character generator base addr high */ |
| 349 | UINT8 wsync; /* 0a wait for hsync */ |
| 350 | UINT8 antic0b; /* 0b nothing */ |
| 351 | UINT8 antic0c; /* 0c nothing */ |
| 352 | UINT8 antic0d; /* 0d nothing */ |
| 353 | UINT8 nmien; /* 0e NMI enable */ |
| 354 | UINT8 nmires; /* 0f NMI reset */ |
| 355 | }; /* write registers */ |
| 397 | 356 | |
| 357 | /* per scanline buffer for video data (and optimization variables) */ |
| 358 | struct VIDEO { |
| 359 | UINT32 cmd; /* antic command for this scanline */ |
| 360 | UINT16 data[HWIDTH]; /* graphics data buffer (text through chargen) */ |
| 361 | }; |
| 362 | |
| 363 | |
| 364 | class antic_device : public device_t |
| 365 | { |
| 366 | public: |
| 367 | // construction/destruction |
| 368 | antic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 369 | |
| 370 | // device-level overrides |
| 371 | virtual void device_start(); |
| 372 | virtual void device_reset(); |
| 373 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 374 | |
| 375 | static void set_gtia_tag(device_t &device, const char *tag) { downcast<antic_device &>(device).m_gtia_tag = tag; } |
| 376 | |
| 377 | DECLARE_READ8_MEMBER( read ); |
| 378 | DECLARE_WRITE8_MEMBER( write ); |
| 379 | |
| 380 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 381 | void generic_interrupt(int button_count); |
| 382 | |
| 383 | private: |
| 384 | static const device_timer_id TIMER_CYCLE_STEAL = 0; |
| 385 | static const device_timer_id TIMER_ISSUE_DLI = 1; |
| 386 | static const device_timer_id TIMER_LINE_REND = 2; |
| 387 | static const device_timer_id TIMER_LINE_DONE = 3; |
| 388 | |
| 389 | const char *m_gtia_tag; |
| 390 | gtia_device *m_gtia; |
| 391 | |
| 392 | UINT32 m_tv_artifacts; |
| 393 | int m_render1, m_render2, m_render3; |
| 394 | |
| 395 | inline void mode_0(address_space &space, VIDEO *video); |
| 396 | inline void mode_2(address_space &space, VIDEO *video, int bytes, int erase); |
| 397 | inline void mode_3(address_space &space, VIDEO *video, int bytes, int erase); |
| 398 | inline void mode_4(address_space &space, VIDEO *video, int bytes, int erase); |
| 399 | inline void mode_5(address_space &space, VIDEO *video, int bytes, int erase); |
| 400 | inline void mode_6(address_space &space, VIDEO *video, int bytes, int erase); |
| 401 | inline void mode_7(address_space &space, VIDEO *video, int bytes, int erase); |
| 402 | inline void mode_8(address_space &space, VIDEO *video, int bytes, int erase); |
| 403 | inline void mode_9(address_space &space, VIDEO *video, int bytes, int erase); |
| 404 | inline void mode_a(address_space &space, VIDEO *video, int bytes, int erase); |
| 405 | inline void mode_b(address_space &space, VIDEO *video, int bytes, int erase); |
| 406 | inline void mode_c(address_space &space, VIDEO *video, int bytes, int erase); |
| 407 | inline void mode_d(address_space &space, VIDEO *video, int bytes, int erase); |
| 408 | inline void mode_e(address_space &space, VIDEO *video, int bytes, int erase); |
| 409 | inline void mode_f(address_space &space, VIDEO *video, int bytes, int erase); |
| 410 | inline void mode_gtia1(address_space &space, VIDEO *video, int bytes, int erase); |
| 411 | inline void mode_gtia2(address_space &space, VIDEO *video, int bytes, int erase); |
| 412 | inline void mode_gtia3(address_space &space, VIDEO *video, int bytes, int erase); |
| 413 | |
| 414 | UINT32 m_cmd; /* currently executed display list command */ |
| 415 | UINT32 m_steal_cycles; /* steal how many cpu cycles for this line ? */ |
| 416 | UINT32 m_vscrol_old; /* old vscrol value */ |
| 417 | UINT32 m_hscrol_old; /* old hscrol value */ |
| 418 | INT32 m_modelines; /* number of lines for current ANTIC mode */ |
| 419 | UINT32 m_chbase; /* character mode source base */ |
| 420 | UINT32 m_chand; /* character and mask (chactl) */ |
| 421 | UINT32 m_chxor; /* character xor mask (chactl) */ |
| 422 | UINT32 m_scanline; /* current scan line */ |
| 423 | UINT32 m_pfwidth; /* playfield width */ |
| 424 | UINT32 m_dpage; /* display list address page */ |
| 425 | UINT32 m_doffs; /* display list offset into page */ |
| 426 | UINT32 m_vpage; /* video data source page */ |
| 427 | UINT32 m_voffs; /* video data offset into page */ |
| 428 | UINT32 m_pmbase_s; /* p/m graphics single line source base */ |
| 429 | UINT32 m_pmbase_d; /* p/m graphics double line source base */ |
| 430 | ANTIC_R m_r; /* ANTIC read registers */ |
| 431 | ANTIC_W m_w; /* ANTIC write registers */ |
| 432 | UINT8 m_cclock[256+32]; /* color clock buffer filled by ANTIC */ |
| 433 | UINT8 m_pmbits[256+32]; /* player missile buffer filled by GTIA */ |
| 434 | UINT8 *m_prio_table[64]; /* player/missile priority tables */ |
| 435 | VIDEO *m_video[312]; /* video buffer */ |
| 436 | UINT32 *m_cclk_expand; /* shared buffer for the following: */ |
| 437 | UINT32 *m_pf_21; /* 1cclk 2 color txt 2,3 */ |
| 438 | UINT32 *m_pf_x10b; /* 1cclk 4 color txt 4,5, gfx D,E */ |
| 439 | UINT32 *m_pf_3210b2; /* 1cclk 5 color txt 6,7, gfx 9,B,C */ |
| 440 | UINT32 *m_pf_210b4; /* 4cclk 4 color gfx 8 */ |
| 441 | UINT32 *m_pf_210b2; /* 2cclk 4 color gfx A */ |
| 442 | UINT32 *m_pf_1b; /* 1cclk hires gfx F */ |
| 443 | UINT32 *m_pf_gtia1; /* 1cclk gtia mode 1 */ |
| 444 | UINT32 *m_pf_gtia2; /* 1cclk gtia mode 2 */ |
| 445 | UINT32 *m_pf_gtia3; /* 1cclk gtia mode 3 */ |
| 446 | UINT8 *m_used_colors; /* shared buffer for the following: */ |
| 447 | UINT8 *m_uc_21; /* used colors for txt (2,3) */ |
| 448 | UINT8 *m_uc_x10b; /* used colors for txt 4,5, gfx D,E */ |
| 449 | UINT8 *m_uc_3210b2; /* used colors for txt 6,7, gfx 9,B,C */ |
| 450 | UINT8 *m_uc_210b4; /* used colors for gfx 8 */ |
| 451 | UINT8 *m_uc_210b2; /* used colors for gfx A */ |
| 452 | UINT8 *m_uc_1b; /* used colors for gfx F */ |
| 453 | UINT8 *m_uc_g1; /* used colors for gfx GTIA 1 */ |
| 454 | UINT8 *m_uc_g2; /* used colors for gfx GTIA 2 */ |
| 455 | UINT8 *m_uc_g3; /* used colors for gfx GTIA 3 */ |
| 456 | bitmap_ind16 *m_bitmap; |
| 457 | |
| 458 | void prio_init(); |
| 459 | void cclk_init(); |
| 460 | |
| 461 | void artifacts_gfx(UINT8 *src, UINT8 *dst, int width); |
| 462 | void artifacts_txt(UINT8 *src, UINT8 *dst, int width); |
| 463 | |
| 464 | void linerefresh(); |
| 465 | int cycle(); |
| 466 | |
| 467 | TIMER_CALLBACK_MEMBER( issue_dli ); |
| 468 | TIMER_CALLBACK_MEMBER( line_done ); |
| 469 | TIMER_CALLBACK_MEMBER( steal_cycles ); |
| 470 | TIMER_CALLBACK_MEMBER( scanline_render ); |
| 471 | |
| 472 | void render(address_space &space, int param1, int param2, int param3); |
| 473 | |
| 474 | inline void LMS(int new_cmd); |
| 475 | void scanline_dma(int param); |
| 476 | }; |
| 477 | |
| 478 | |
| 479 | // device type definition |
| 480 | extern const device_type ATARI_ANTIC; |
| 481 | |
| 482 | |
| 483 | |
| 484 | #define MCFG_ANTIC_GTIA(_tag) \ |
| 485 | antic_device::set_gtia_tag(*device, _tag); |
| 486 | |
| 487 | |
| 398 | 488 | #endif /* __GTIA_H__ */ |