trunk/src/mame/video/taitoic.c
| r23670 | r23671 | |
| 544 | 544 | /* */ |
| 545 | 545 | /***************************************************************************/ |
| 546 | 546 | |
| 547 | | struct pc080sn_state |
| 548 | | { |
| 549 | | UINT16 ctrl[8]; |
| 547 | #define PC080SN_RAM_SIZE 0x10000 |
| 550 | 548 | |
| 551 | | UINT16 * ram; |
| 552 | | UINT16 * bg_ram[2]; |
| 553 | | UINT16 * bgscroll_ram[2]; |
| 549 | const device_type PC080SN = &device_creator<pc080sn_device>; |
| 554 | 550 | |
| 555 | | int bgscrollx[2], bgscrolly[2]; |
| 556 | | int xoffs, yoffs; |
| 551 | pc080sn_device::pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 552 | : device_t(mconfig, PC080SN, "Taito PC080SN", tag, owner, clock) |
| 553 | { |
| 554 | } |
| 557 | 555 | |
| 558 | | tilemap_t *tilemap[2]; |
| 559 | | int bg_gfx; |
| 560 | | int yinvert, dblwidth; |
| 561 | | }; |
| 556 | //------------------------------------------------- |
| 557 | // device_config_complete - perform any |
| 558 | // operations now that the configuration is |
| 559 | // complete |
| 560 | //------------------------------------------------- |
| 562 | 561 | |
| 563 | | #define PC080SN_RAM_SIZE 0x10000 |
| 562 | void pc080sn_device::device_config_complete() |
| 563 | { |
| 564 | // inherit a copy of the static data |
| 565 | const pc080sn_interface *intf = reinterpret_cast<const pc080sn_interface *>(static_config()); |
| 566 | if (intf != NULL) |
| 567 | *static_cast<pc080sn_interface *>(this) = *intf; |
| 568 | |
| 569 | // or initialize to defaults if none provided |
| 570 | else |
| 571 | { |
| 572 | } |
| 573 | } |
| 564 | 574 | |
| 565 | | /***************************************************************************** |
| 566 | | INLINE FUNCTIONS |
| 567 | | *****************************************************************************/ |
| 575 | //------------------------------------------------- |
| 576 | // device_start - device-specific startup |
| 577 | //------------------------------------------------- |
| 568 | 578 | |
| 569 | | INLINE pc080sn_state *pc080sn_get_safe_token( device_t *device ) |
| 579 | void pc080sn_device::device_start() |
| 570 | 580 | { |
| 571 | | assert(device != NULL); |
| 572 | | assert(device->type() == PC080SN); |
| 581 | /* use the given gfx set for bg tiles */ |
| 582 | if (!m_dblwidth) /* standard tilemaps */ |
| 583 | { |
| 584 | m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); |
| 585 | m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); |
| 586 | } |
| 587 | else /* double width tilemaps */ |
| 588 | { |
| 589 | m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); |
| 590 | m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); |
| 591 | } |
| 573 | 592 | |
| 574 | | return (pc080sn_state *)downcast<pc080sn_device *>(device)->token(); |
| 575 | | } |
| 593 | m_tilemap[0]->set_transparent_pen(0); |
| 594 | m_tilemap[1]->set_transparent_pen(0); |
| 576 | 595 | |
| 577 | | INLINE const pc080sn_interface *pc080sn_get_interface( device_t *device ) |
| 578 | | { |
| 579 | | assert(device != NULL); |
| 580 | | assert((device->type() == PC080SN)); |
| 581 | | return (const pc080sn_interface *) device->static_config(); |
| 596 | m_tilemap[0]->set_scrolldx(-16 + m_x_offset, -16 - m_x_offset); |
| 597 | m_tilemap[0]->set_scrolldy(m_y_offset, -m_y_offset); |
| 598 | m_tilemap[1]->set_scrolldx(-16 + m_x_offset, -16 - m_x_offset); |
| 599 | m_tilemap[1]->set_scrolldy(m_y_offset, -m_y_offset); |
| 600 | |
| 601 | if (!m_dblwidth) |
| 602 | { |
| 603 | m_tilemap[0]->set_scroll_rows(512); |
| 604 | m_tilemap[1]->set_scroll_rows(512); |
| 605 | } |
| 606 | |
| 607 | m_ram = auto_alloc_array_clear(machine(), UINT16, PC080SN_RAM_SIZE / 2); |
| 608 | |
| 609 | m_bg_ram[0] = m_ram + 0x0000 /2; |
| 610 | m_bg_ram[1] = m_ram + 0x8000 /2; |
| 611 | m_bgscroll_ram[0] = m_ram + 0x4000 /2; |
| 612 | m_bgscroll_ram[1] = m_ram + 0xc000 /2; |
| 613 | |
| 614 | save_pointer(NAME(m_ram), PC080SN_RAM_SIZE / 2); |
| 615 | save_item(NAME(m_ctrl)); |
| 616 | machine().save().register_postload(save_prepost_delegate(FUNC(pc080sn_device::restore_scroll), this)); |
| 617 | |
| 582 | 618 | } |
| 583 | 619 | |
| 584 | 620 | /***************************************************************************** |
| 585 | 621 | DEVICE HANDLERS |
| 586 | 622 | *****************************************************************************/ |
| 587 | 623 | |
| 588 | | INLINE void common_get_pc080sn_bg_tile_info( running_machine &machine, device_t *device, tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) |
| 624 | void pc080sn_device::common_get_pc080sn_bg_tile_info( tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) |
| 589 | 625 | { |
| 590 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 591 | 626 | UINT16 code, attr; |
| 592 | | |
| 593 | | if (!pc080sn->dblwidth) |
| 627 | |
| 628 | if (!m_dblwidth) |
| 594 | 629 | { |
| 595 | 630 | code = (ram[2 * tile_index + 1] & 0x3fff); |
| 596 | 631 | attr = ram[2 * tile_index]; |
| r23670 | r23671 | |
| 601 | 636 | attr = ram[tile_index]; |
| 602 | 637 | } |
| 603 | 638 | |
| 604 | | SET_TILE_INFO( |
| 639 | SET_TILE_INFO_MEMBER( |
| 605 | 640 | gfxnum, |
| 606 | 641 | code, |
| 607 | 642 | (attr & 0x1ff), |
| 608 | 643 | TILE_FLIPYX((attr & 0xc000) >> 14)); |
| 609 | 644 | } |
| 610 | 645 | |
| 611 | | INLINE void common_get_pc080sn_fg_tile_info( running_machine &machine, device_t *device, tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) |
| 646 | TILE_GET_INFO_MEMBER(pc080sn_device::get_bg_tile_info) |
| 612 | 647 | { |
| 613 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 614 | | UINT16 code,attr; |
| 648 | common_get_pc080sn_bg_tile_info( tileinfo, tile_index, m_bg_ram[0], m_gfxnum ); |
| 649 | } |
| 615 | 650 | |
| 616 | | if (!pc080sn->dblwidth) |
| 651 | void pc080sn_device::common_get_pc080sn_fg_tile_info( tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) |
| 652 | { |
| 653 | UINT16 code,attr; |
| 654 | |
| 655 | if (!m_dblwidth) |
| 617 | 656 | { |
| 618 | 657 | code = (ram[2 * tile_index + 1] & 0x3fff); |
| 619 | 658 | attr = ram[2 * tile_index]; |
| r23670 | r23671 | |
| 624 | 663 | attr = ram[tile_index]; |
| 625 | 664 | } |
| 626 | 665 | |
| 627 | | SET_TILE_INFO( |
| 666 | SET_TILE_INFO_MEMBER( |
| 628 | 667 | gfxnum, |
| 629 | 668 | code, |
| 630 | 669 | (attr & 0x1ff), |
| 631 | 670 | TILE_FLIPYX((attr & 0xc000) >> 14)); |
| 632 | 671 | } |
| 633 | 672 | |
| 634 | | TILE_GET_INFO_MEMBER(pc080sn_device::pc080sn_get_bg_tile_info) |
| 673 | TILE_GET_INFO_MEMBER(pc080sn_device::get_fg_tile_info) |
| 635 | 674 | { |
| 636 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(this); |
| 637 | | common_get_pc080sn_bg_tile_info(machine(), this, tileinfo, tile_index, pc080sn->bg_ram[0], pc080sn->bg_gfx); |
| 675 | common_get_pc080sn_fg_tile_info( tileinfo, tile_index, m_bg_ram[1], m_gfxnum ); |
| 638 | 676 | } |
| 639 | 677 | |
| 640 | | TILE_GET_INFO_MEMBER(pc080sn_device::pc080sn_get_fg_tile_info) |
| 678 | READ16_MEMBER( pc080sn_device::word_r ) |
| 641 | 679 | { |
| 642 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(this); |
| 643 | | common_get_pc080sn_fg_tile_info(machine(), this, tileinfo, tile_index, pc080sn->bg_ram[1], pc080sn->bg_gfx); |
| 680 | return m_ram[offset]; |
| 644 | 681 | } |
| 645 | 682 | |
| 646 | | |
| 647 | | READ16_DEVICE_HANDLER( pc080sn_word_r ) |
| 683 | WRITE16_MEMBER( pc080sn_device::word_w ) |
| 648 | 684 | { |
| 649 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 650 | | return pc080sn->ram[offset]; |
| 651 | | } |
| 685 | COMBINE_DATA(&m_ram[offset]); |
| 652 | 686 | |
| 653 | | WRITE16_DEVICE_HANDLER( pc080sn_word_w ) |
| 654 | | { |
| 655 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 656 | | |
| 657 | | COMBINE_DATA(&pc080sn->ram[offset]); |
| 658 | | |
| 659 | | if (!pc080sn->dblwidth) |
| 687 | if (!m_dblwidth) |
| 660 | 688 | { |
| 661 | 689 | if (offset < 0x2000) |
| 662 | | pc080sn->tilemap[0]->mark_tile_dirty(offset / 2); |
| 690 | m_tilemap[0]->mark_tile_dirty(offset / 2); |
| 663 | 691 | else if (offset >= 0x4000 && offset < 0x6000) |
| 664 | | pc080sn->tilemap[1]->mark_tile_dirty((offset & 0x1fff) / 2); |
| 692 | m_tilemap[1]->mark_tile_dirty((offset & 0x1fff) / 2); |
| 665 | 693 | } |
| 666 | 694 | else |
| 667 | 695 | { |
| 668 | 696 | if (offset < 0x4000) |
| 669 | | pc080sn->tilemap[0]->mark_tile_dirty((offset & 0x1fff)); |
| 697 | m_tilemap[0]->mark_tile_dirty((offset & 0x1fff)); |
| 670 | 698 | else if (offset >= 0x4000 && offset < 0x8000) |
| 671 | | pc080sn->tilemap[1]->mark_tile_dirty((offset & 0x1fff)); |
| 699 | m_tilemap[1]->mark_tile_dirty((offset & 0x1fff)); |
| 672 | 700 | } |
| 673 | 701 | } |
| 674 | 702 | |
| 675 | | WRITE16_DEVICE_HANDLER( pc080sn_xscroll_word_w ) |
| 703 | WRITE16_MEMBER( pc080sn_device::xscroll_word_w ) |
| 676 | 704 | { |
| 677 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 705 | COMBINE_DATA(&m_ctrl[offset]); |
| 678 | 706 | |
| 679 | | COMBINE_DATA(&pc080sn->ctrl[offset]); |
| 707 | data = m_ctrl[offset]; |
| 680 | 708 | |
| 681 | | data = pc080sn->ctrl[offset]; |
| 682 | | |
| 683 | 709 | switch (offset) |
| 684 | 710 | { |
| 685 | 711 | case 0x00: |
| 686 | | pc080sn->bgscrollx[0] = -data; |
| 712 | m_bgscrollx[0] = -data; |
| 687 | 713 | break; |
| 688 | 714 | |
| 689 | 715 | case 0x01: |
| 690 | | pc080sn->bgscrollx[1] = -data; |
| 716 | m_bgscrollx[1] = -data; |
| 691 | 717 | break; |
| 692 | 718 | } |
| 693 | 719 | } |
| 694 | 720 | |
| 695 | | WRITE16_DEVICE_HANDLER( pc080sn_yscroll_word_w ) |
| 721 | WRITE16_MEMBER( pc080sn_device::yscroll_word_w ) |
| 696 | 722 | { |
| 697 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 723 | COMBINE_DATA(&m_ctrl[offset + 2]); |
| 698 | 724 | |
| 699 | | COMBINE_DATA(&pc080sn->ctrl[offset + 2]); |
| 725 | data = m_ctrl[offset + 2]; |
| 700 | 726 | |
| 701 | | data = pc080sn->ctrl[offset + 2]; |
| 702 | | |
| 703 | | if (pc080sn->yinvert) |
| 727 | if (m_y_invert) |
| 704 | 728 | data = -data; |
| 705 | 729 | |
| 706 | 730 | switch (offset) |
| 707 | 731 | { |
| 708 | 732 | case 0x00: |
| 709 | | pc080sn->bgscrolly[0] = -data; |
| 733 | m_bgscrolly[0] = -data; |
| 710 | 734 | break; |
| 711 | 735 | |
| 712 | 736 | case 0x01: |
| 713 | | pc080sn->bgscrolly[1] = -data; |
| 737 | m_bgscrolly[1] = -data; |
| 714 | 738 | break; |
| 715 | 739 | } |
| 716 | 740 | } |
| 717 | 741 | |
| 718 | | WRITE16_DEVICE_HANDLER( pc080sn_ctrl_word_w ) |
| 742 | WRITE16_MEMBER( pc080sn_device::ctrl_word_w ) |
| 719 | 743 | { |
| 720 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 744 | COMBINE_DATA(&m_ctrl[offset + 4]); |
| 721 | 745 | |
| 722 | | COMBINE_DATA(&pc080sn->ctrl[offset + 4]); |
| 746 | data = m_ctrl[offset + 4]; |
| 723 | 747 | |
| 724 | | data = pc080sn->ctrl[offset + 4]; |
| 725 | | |
| 726 | 748 | switch (offset) |
| 727 | 749 | { |
| 728 | 750 | case 0x00: |
| 729 | 751 | { |
| 730 | 752 | int flip = (data & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; |
| 731 | 753 | |
| 732 | | pc080sn->tilemap[0]->set_flip(flip); |
| 733 | | pc080sn->tilemap[1]->set_flip(flip); |
| 754 | m_tilemap[0]->set_flip(flip); |
| 755 | m_tilemap[1]->set_flip(flip); |
| 734 | 756 | break; |
| 735 | 757 | } |
| 736 | 758 | } |
| r23670 | r23671 | |
| 743 | 765 | /* This routine is needed as an override by Jumping, which |
| 744 | 766 | doesn't set proper scroll values for foreground tilemap */ |
| 745 | 767 | |
| 746 | | void pc080sn_set_scroll( device_t *device, int tilemap_num, int scrollx, int scrolly ) |
| 768 | void pc080sn_device::set_scroll( int tilemap_num, int scrollx, int scrolly ) |
| 747 | 769 | { |
| 748 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 749 | | |
| 750 | | pc080sn->tilemap[tilemap_num]->set_scrollx(0, scrollx); |
| 751 | | pc080sn->tilemap[tilemap_num]->set_scrolly(0, scrolly); |
| 770 | m_tilemap[tilemap_num]->set_scrollx(0, scrollx); |
| 771 | m_tilemap[tilemap_num]->set_scrolly(0, scrolly); |
| 752 | 772 | } |
| 753 | 773 | |
| 754 | 774 | /* This routine is needed as an override by Jumping */ |
| 755 | 775 | |
| 756 | | void pc080sn_set_trans_pen( device_t *device, int tilemap_num, int pen ) |
| 776 | void pc080sn_device::set_trans_pen( int tilemap_num, int pen ) |
| 757 | 777 | { |
| 758 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 759 | | pc080sn->tilemap[tilemap_num]->set_transparent_pen(pen); |
| 778 | m_tilemap[tilemap_num]->set_transparent_pen(pen); |
| 760 | 779 | } |
| 761 | 780 | |
| 762 | 781 | |
| 763 | | void pc080sn_tilemap_update( device_t *device ) |
| 782 | void pc080sn_device::tilemap_update( ) |
| 764 | 783 | { |
| 765 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 766 | 784 | int j; |
| 767 | 785 | |
| 768 | | pc080sn->tilemap[0]->set_scrolly(0, pc080sn->bgscrolly[0]); |
| 769 | | pc080sn->tilemap[1]->set_scrolly(0, pc080sn->bgscrolly[1]); |
| 786 | m_tilemap[0]->set_scrolly(0, m_bgscrolly[0]); |
| 787 | m_tilemap[1]->set_scrolly(0, m_bgscrolly[1]); |
| 770 | 788 | |
| 771 | | if (!pc080sn->dblwidth) |
| 789 | if (!m_dblwidth) |
| 772 | 790 | { |
| 773 | 791 | for (j = 0; j < 256; j++) |
| 774 | | pc080sn->tilemap[0]->set_scrollx((j + pc080sn->bgscrolly[0]) & 0x1ff, pc080sn->bgscrollx[0] - pc080sn->bgscroll_ram[0][j]); |
| 792 | m_tilemap[0]->set_scrollx((j + m_bgscrolly[0]) & 0x1ff, m_bgscrollx[0] - m_bgscroll_ram[0][j]); |
| 775 | 793 | |
| 776 | 794 | for (j = 0; j < 256; j++) |
| 777 | | pc080sn->tilemap[1]->set_scrollx((j + pc080sn->bgscrolly[1]) & 0x1ff, pc080sn->bgscrollx[1] - pc080sn->bgscroll_ram[1][j]); |
| 795 | m_tilemap[1]->set_scrollx((j + m_bgscrolly[1]) & 0x1ff, m_bgscrollx[1] - m_bgscroll_ram[1][j]); |
| 778 | 796 | } |
| 779 | 797 | else |
| 780 | 798 | { |
| 781 | | pc080sn->tilemap[0]->set_scrollx(0, pc080sn->bgscrollx[0]); |
| 782 | | pc080sn->tilemap[1]->set_scrollx(0, pc080sn->bgscrollx[1]); |
| 799 | m_tilemap[0]->set_scrollx(0, m_bgscrollx[0]); |
| 800 | m_tilemap[1]->set_scrollx(0, m_bgscrollx[1]); |
| 783 | 801 | } |
| 784 | 802 | } |
| 785 | 803 | |
| r23670 | r23671 | |
| 833 | 851 | } |
| 834 | 852 | |
| 835 | 853 | |
| 836 | | static void topspeed_custom_draw( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, |
| 837 | | UINT32 priority, UINT16 *color_ctrl_ram ) |
| 854 | void pc080sn_device::topspeed_custom_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *color_ctrl_ram ) |
| 838 | 855 | { |
| 839 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 840 | 856 | UINT16 *dst16, *src16; |
| 841 | 857 | UINT8 *tsrc; |
| 842 | 858 | UINT16 scanline[1024]; /* won't be called by a wide-screen game, but just in case... */ |
| 843 | 859 | |
| 844 | | bitmap_ind16 &srcbitmap = pc080sn->tilemap[layer]->pixmap(); |
| 845 | | bitmap_ind8 &flagsbitmap = pc080sn->tilemap[layer]->flagsmap(); |
| 860 | bitmap_ind16 &srcbitmap = m_tilemap[layer]->pixmap(); |
| 861 | bitmap_ind8 &flagsbitmap = m_tilemap[layer]->flagsmap(); |
| 846 | 862 | |
| 847 | 863 | UINT16 a, color; |
| 848 | 864 | int sx, x_index; |
| r23670 | r23671 | |
| 860 | 876 | |
| 861 | 877 | if (!flip) |
| 862 | 878 | { |
| 863 | | sx = pc080sn->bgscrollx[layer] + 16 - pc080sn->xoffs; |
| 864 | | y_index = pc080sn->bgscrolly[layer] + min_y - pc080sn->yoffs; |
| 879 | sx = m_bgscrollx[layer] + 16 - m_x_offset; |
| 880 | y_index = m_bgscrolly[layer] + min_y - m_y_offset; |
| 865 | 881 | } |
| 866 | 882 | else // never used |
| 867 | 883 | { |
| r23670 | r23671 | |
| 877 | 893 | do |
| 878 | 894 | { |
| 879 | 895 | src_y_index = y_index & 0x1ff; /* tilemaps are 512 px up/down */ |
| 880 | | row_index = (src_y_index - pc080sn->bgscrolly[layer]) & 0x1ff; |
| 881 | | color = color_ctrl_ram[(row_index + pc080sn->yoffs - 2) & 0xff]; |
| 896 | row_index = (src_y_index - m_bgscrolly[layer]) & 0x1ff; |
| 897 | color = color_ctrl_ram[(row_index + m_y_offset - 2) & 0xff]; |
| 882 | 898 | |
| 883 | | x_index = sx - (pc080sn->bgscroll_ram[layer][row_index]); |
| 899 | x_index = sx - (m_bgscroll_ram[layer][row_index]); |
| 884 | 900 | |
| 885 | 901 | src16 = &srcbitmap.pix16(src_y_index); |
| 886 | 902 | tsrc = &flagsbitmap.pix8(src_y_index); |
| r23670 | r23671 | |
| 916 | 932 | } |
| 917 | 933 | } |
| 918 | 934 | |
| 919 | | taitoic_drawscanline(bitmap, cliprect, 0, y, scanline, (flags & TILEMAP_DRAW_OPAQUE) ? 0 : 1, ROT0, device->machine().priority_bitmap, priority); |
| 935 | taitoic_drawscanline(bitmap, cliprect, 0, y, scanline, (flags & TILEMAP_DRAW_OPAQUE) ? 0 : 1, ROT0, machine().priority_bitmap, priority); |
| 920 | 936 | y_index++; |
| 921 | 937 | |
| 922 | 938 | if (!machine_flip) |
| r23670 | r23671 | |
| 927 | 943 | while ((!machine_flip && y <= max_y) || (machine_flip && y >= min_y)); |
| 928 | 944 | } |
| 929 | 945 | |
| 930 | | void pc080sn_tilemap_draw( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority ) |
| 946 | void pc080sn_device::tilemap_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority ) |
| 931 | 947 | { |
| 932 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 933 | | pc080sn->tilemap[layer]->draw(bitmap, cliprect, flags, priority); |
| 948 | m_tilemap[layer]->draw(bitmap, cliprect, flags, priority); |
| 934 | 949 | } |
| 935 | 950 | |
| 936 | | void pc080sn_tilemap_draw_offset( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, int xoffs, int yoffs ) |
| 951 | void pc080sn_device::tilemap_draw_offset( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, int x_offset, int y_offset ) |
| 937 | 952 | { |
| 938 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(device); |
| 939 | | int basedx = -16 - pc080sn->xoffs; |
| 940 | | int basedxflip = -16 + pc080sn->xoffs; |
| 941 | | int basedy = pc080sn->yoffs; |
| 942 | | int basedyflip = -pc080sn->yoffs; |
| 953 | int basedx = -16 - m_x_offset; |
| 954 | int basedxflip = -16 + m_x_offset; |
| 955 | int basedy = m_y_offset; |
| 956 | int basedyflip = -m_y_offset; |
| 943 | 957 | |
| 944 | | pc080sn->tilemap[layer]->set_scrolldx(basedx + xoffs, basedxflip + xoffs); |
| 945 | | pc080sn->tilemap[layer]->set_scrolldy(basedy + yoffs, basedyflip + yoffs); |
| 946 | | pc080sn->tilemap[layer]->draw(bitmap, cliprect, flags, priority); |
| 947 | | pc080sn->tilemap[layer]->set_scrolldx(basedx, basedxflip); |
| 948 | | pc080sn->tilemap[layer]->set_scrolldy(basedy, basedyflip); |
| 958 | m_tilemap[layer]->set_scrolldx(basedx + x_offset, basedxflip + x_offset); |
| 959 | m_tilemap[layer]->set_scrolldy(basedy + y_offset, basedyflip + y_offset); |
| 960 | m_tilemap[layer]->draw(bitmap, cliprect, flags, priority); |
| 961 | m_tilemap[layer]->set_scrolldx(basedx, basedxflip); |
| 962 | m_tilemap[layer]->set_scrolldy(basedy, basedyflip); |
| 949 | 963 | } |
| 950 | 964 | |
| 951 | | void pc080sn_tilemap_draw_special( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *ram ) |
| 965 | void pc080sn_device::tilemap_draw_special( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *ram ) |
| 952 | 966 | { |
| 953 | | topspeed_custom_draw(device, bitmap, cliprect, layer, flags, priority, ram); |
| 967 | pc080sn_device::topspeed_custom_draw(bitmap, cliprect, layer, flags, priority, ram); |
| 954 | 968 | } |
| 955 | 969 | |
| 956 | 970 | |
| 957 | | void pc080sn_device::pc080sn_restore_scroll() |
| 971 | void pc080sn_device::restore_scroll() |
| 958 | 972 | { |
| 959 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(this); |
| 973 | |
| 960 | 974 | int flip; |
| 961 | 975 | |
| 962 | | pc080sn->bgscrollx[0] = -pc080sn->ctrl[0]; |
| 963 | | pc080sn->bgscrollx[1] = -pc080sn->ctrl[1]; |
| 964 | | pc080sn->bgscrolly[0] = -pc080sn->ctrl[2]; |
| 965 | | pc080sn->bgscrolly[1] = -pc080sn->ctrl[3]; |
| 976 | m_bgscrollx[0] = -m_ctrl[0]; |
| 977 | m_bgscrollx[1] = -m_ctrl[1]; |
| 978 | m_bgscrolly[0] = -m_ctrl[2]; |
| 979 | m_bgscrolly[1] = -m_ctrl[3]; |
| 966 | 980 | |
| 967 | | flip = (pc080sn->ctrl[4] & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; |
| 968 | | pc080sn->tilemap[0]->set_flip(flip); |
| 969 | | pc080sn->tilemap[1]->set_flip(flip); |
| 981 | flip = (m_ctrl[4] & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; |
| 982 | m_tilemap[0]->set_flip(flip); |
| 983 | m_tilemap[1]->set_flip(flip); |
| 970 | 984 | } |
| 971 | 985 | |
| 972 | | const device_type PC080SN = &device_creator<pc080sn_device>; |
| 973 | 986 | |
| 974 | | pc080sn_device::pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 975 | | : device_t(mconfig, PC080SN, "Taito PC080SN", tag, owner, clock) |
| 976 | | { |
| 977 | | m_token = global_alloc_clear(pc080sn_state); |
| 978 | | } |
| 979 | | |
| 980 | | //------------------------------------------------- |
| 981 | | // device_config_complete - perform any |
| 982 | | // operations now that the configuration is |
| 983 | | // complete |
| 984 | | //------------------------------------------------- |
| 985 | | |
| 986 | | void pc080sn_device::device_config_complete() |
| 987 | | { |
| 988 | | } |
| 989 | | |
| 990 | | //------------------------------------------------- |
| 991 | | // device_start - device-specific startup |
| 992 | | //------------------------------------------------- |
| 993 | | |
| 994 | | void pc080sn_device::device_start() |
| 995 | | { |
| 996 | | pc080sn_state *pc080sn = pc080sn_get_safe_token(this); |
| 997 | | const pc080sn_interface *intf = pc080sn_get_interface(this); |
| 998 | | |
| 999 | | /* use the given gfx set for bg tiles */ |
| 1000 | | pc080sn->bg_gfx = intf->gfxnum; |
| 1001 | | |
| 1002 | | pc080sn->yinvert = intf->y_invert; |
| 1003 | | pc080sn->dblwidth = intf->dblwidth; |
| 1004 | | pc080sn->xoffs = intf->x_offset; |
| 1005 | | pc080sn->yoffs = intf->y_offset; |
| 1006 | | |
| 1007 | | if (!pc080sn->dblwidth) /* standard tilemaps */ |
| 1008 | | { |
| 1009 | | pc080sn->tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); |
| 1010 | | pc080sn->tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); |
| 1011 | | } |
| 1012 | | else /* double width tilemaps */ |
| 1013 | | { |
| 1014 | | pc080sn->tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); |
| 1015 | | pc080sn->tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); |
| 1016 | | } |
| 1017 | | |
| 1018 | | pc080sn->tilemap[0]->set_transparent_pen(0); |
| 1019 | | pc080sn->tilemap[1]->set_transparent_pen(0); |
| 1020 | | |
| 1021 | | pc080sn->tilemap[0]->set_scrolldx(-16 + pc080sn->xoffs, -16 - pc080sn->xoffs); |
| 1022 | | pc080sn->tilemap[0]->set_scrolldy(pc080sn->yoffs, -pc080sn->yoffs); |
| 1023 | | pc080sn->tilemap[1]->set_scrolldx(-16 + pc080sn->xoffs, -16 - pc080sn->xoffs); |
| 1024 | | pc080sn->tilemap[1]->set_scrolldy(pc080sn->yoffs, -pc080sn->yoffs); |
| 1025 | | |
| 1026 | | if (!pc080sn->dblwidth) |
| 1027 | | { |
| 1028 | | pc080sn->tilemap[0]->set_scroll_rows(512); |
| 1029 | | pc080sn->tilemap[1]->set_scroll_rows(512); |
| 1030 | | } |
| 1031 | | |
| 1032 | | pc080sn->ram = auto_alloc_array_clear(machine(), UINT16, PC080SN_RAM_SIZE / 2); |
| 1033 | | |
| 1034 | | pc080sn->bg_ram[0] = pc080sn->ram + 0x0000 /2; |
| 1035 | | pc080sn->bg_ram[1] = pc080sn->ram + 0x8000 /2; |
| 1036 | | pc080sn->bgscroll_ram[0] = pc080sn->ram + 0x4000 /2; |
| 1037 | | pc080sn->bgscroll_ram[1] = pc080sn->ram + 0xc000 /2; |
| 1038 | | |
| 1039 | | save_pointer(NAME(pc080sn->ram), PC080SN_RAM_SIZE / 2); |
| 1040 | | save_item(NAME(pc080sn->ctrl)); |
| 1041 | | machine().save().register_postload(save_prepost_delegate(FUNC(pc080sn_device::pc080sn_restore_scroll), this)); |
| 1042 | | |
| 1043 | | } |
| 1044 | | |
| 1045 | 987 | /***************************************************************************/ |
| 1046 | 988 | /* */ |
| 1047 | 989 | /* PC090OJ */ |