trunk/src/mame/machine/seicop.c
| r26062 | r26063 | |
| 1599 | 1599 | #define seibu_cop_log logerror |
| 1600 | 1600 | #define LOG_CMDS 1 |
| 1601 | 1601 | |
| 1602 | | static UINT16 *cop_mcu_ram; |
| 1602 | const device_type SEIBU_COP_LEGACY = &device_creator<seibu_cop_legacy_device>; |
| 1603 | 1603 | |
| 1604 | | static UINT16 copd2_table[0x100]; |
| 1605 | | static UINT16 copd2_table_2[0x100/8]; |
| 1606 | | static UINT16 copd2_table_3[0x100/8]; |
| 1607 | | static UINT16 copd2_table_4[0x100/8]; |
| 1604 | seibu_cop_legacy_device::seibu_cop_legacy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 1605 | : device_t(mconfig, SEIBU_COP_LEGACY, "Seibu COP Legacy", tag, owner, clock, "seibu_cop_legacy", __FILE__), |
| 1606 | m_cop_mcu_ram(NULL), |
| 1607 | m_cop_438(0), |
| 1608 | m_cop_43a(0), |
| 1609 | m_cop_43c(0), |
| 1610 | m_cop_dma_fade_table(0), |
| 1611 | m_cop_dma_trigger(0), |
| 1612 | m_cop_scale(0), |
| 1613 | m_cop_rng_max_value(0), |
| 1614 | m_copd2_offs(0), |
| 1615 | m_cop_status(0), |
| 1616 | m_cop_dist(0), |
| 1617 | m_cop_angle(0), |
| 1618 | m_cop_hit_status(0), |
| 1619 | m_cop_hit_val_x(0), |
| 1620 | m_cop_hit_val_y(0), |
| 1621 | m_cop_hit_val_z(0), |
| 1622 | m_cop_hit_val_unk(0), |
| 1623 | m_cop_sort_lookup(0), |
| 1624 | m_cop_sort_ram_addr(0), |
| 1625 | m_cop_sort_param(0), |
| 1626 | m_cop_angle_compare(0), |
| 1627 | m_cop_angle_mod_val(0), |
| 1628 | m_r0(0), |
| 1629 | m_r1(0), |
| 1630 | m_cop_rom_addr_lo(0), |
| 1631 | m_cop_rom_addr_hi(0), |
| 1632 | m_cop_rom_addr_unk(0), |
| 1633 | m_u1(0), |
| 1634 | m_u2(0), |
| 1635 | m_fill_val(0), |
| 1636 | m_pal_brightness_val(0), |
| 1637 | m_pal_brightness_mode(0), |
| 1638 | m_cop_sprite_dma_src(0), |
| 1639 | m_cop_sprite_dma_abs_x(0), |
| 1640 | m_cop_sprite_dma_abs_y(0), |
| 1641 | m_cop_sprite_dma_size(0), |
| 1642 | m_cop_sprite_dma_param(0) |
| 1643 | { |
| 1644 | memset(m_copd2_table, 0, sizeof(UINT16)*0x100); |
| 1645 | memset(m_copd2_table_2, 0, sizeof(UINT16)*0x100/8); |
| 1646 | memset(m_copd2_table_3, 0, sizeof(UINT16)*0x100/8); |
| 1647 | memset(m_copd2_table_4, 0, sizeof(UINT16)*0x100/8); |
| 1648 | memset(m_cop_dma_src, 0, sizeof(UINT16)*0x200); |
| 1649 | memset(m_cop_dma_size, 0, sizeof(UINT16)*0x200); |
| 1650 | memset(m_cop_dma_dst, 0, sizeof(UINT16)*0x200); |
| 1651 | memset(m_seibu_vregs, 0, sizeof(UINT16)*0x50/2); |
| 1652 | |
| 1653 | for (int i = 0; i < 8; i++) |
| 1654 | { |
| 1655 | m_cop_register[i] = 0; |
| 1656 | } |
| 1657 | } |
| 1608 | 1658 | |
| 1609 | | static UINT16 cop_438; |
| 1610 | | static UINT16 cop_43a; |
| 1611 | | static UINT16 cop_43c; |
| 1659 | //------------------------------------------------- |
| 1660 | // device_config_complete - perform any |
| 1661 | // operations now that the configuration is |
| 1662 | // complete |
| 1663 | //------------------------------------------------- |
| 1612 | 1664 | |
| 1613 | | static UINT16 cop_dma_src[0x200]; |
| 1614 | | static UINT16 cop_dma_size[0x200]; |
| 1615 | | static UINT16 cop_dma_dst[0x200]; |
| 1616 | | static UINT16 cop_dma_fade_table; |
| 1617 | | static UINT16 cop_dma_trigger = 0; |
| 1618 | | static UINT16 cop_scale; |
| 1665 | void seibu_cop_legacy_device::device_config_complete() |
| 1666 | { |
| 1667 | } |
| 1619 | 1668 | |
| 1620 | | static UINT8 cop_rng_max_value; |
| 1669 | //------------------------------------------------- |
| 1670 | // device_start - device-specific startup |
| 1671 | //------------------------------------------------- |
| 1621 | 1672 | |
| 1622 | | static UINT16 copd2_offs = 0; |
| 1673 | void seibu_cop_legacy_device::device_start() |
| 1674 | { |
| 1675 | m_cop_mcu_ram = reinterpret_cast<UINT16 *>(machine().root_device().memshare("cop_mcu_ram")->ptr()); |
| 1676 | |
| 1677 | save_item(NAME(m_cop_438)); |
| 1678 | save_item(NAME(m_cop_43a)); |
| 1679 | save_item(NAME(m_cop_43c)); |
| 1680 | save_item(NAME(m_cop_dma_fade_table)); |
| 1681 | save_item(NAME(m_cop_dma_trigger)); |
| 1682 | save_item(NAME(m_cop_scale)); |
| 1683 | save_item(NAME(m_cop_rng_max_value)); |
| 1684 | save_item(NAME(m_copd2_offs)); |
| 1685 | save_item(NAME(m_cop_status)); |
| 1686 | save_item(NAME(m_cop_dist)); |
| 1687 | save_item(NAME(m_cop_angle)); |
| 1688 | save_item(NAME(m_cop_hit_status)); |
| 1689 | save_item(NAME(m_cop_hit_val_x)); |
| 1690 | save_item(NAME(m_cop_hit_val_y)); |
| 1691 | save_item(NAME(m_cop_hit_val_z)); |
| 1692 | save_item(NAME(m_cop_hit_val_unk)); |
| 1693 | save_item(NAME(m_cop_sort_lookup)); |
| 1694 | save_item(NAME(m_cop_sort_ram_addr)); |
| 1695 | save_item(NAME(m_cop_sort_param)); |
| 1696 | save_item(NAME(m_cop_angle_compare)); |
| 1697 | save_item(NAME(m_cop_angle_mod_val)); |
| 1698 | save_item(NAME(m_r0)); |
| 1699 | save_item(NAME(m_r1)); |
| 1700 | save_item(NAME(m_cop_rom_addr_lo)); |
| 1701 | save_item(NAME(m_cop_rom_addr_hi)); |
| 1702 | save_item(NAME(m_cop_rom_addr_unk)); |
| 1703 | save_item(NAME(m_u1)); |
| 1704 | save_item(NAME(m_u2)); |
| 1705 | save_item(NAME(m_fill_val)); |
| 1706 | save_item(NAME(m_pal_brightness_val)); |
| 1707 | save_item(NAME(m_pal_brightness_mode)); |
| 1708 | save_item(NAME(m_cop_sprite_dma_src)); |
| 1709 | save_item(NAME(m_cop_sprite_dma_abs_x)); |
| 1710 | save_item(NAME(m_cop_sprite_dma_abs_y)); |
| 1711 | save_item(NAME(m_cop_sprite_dma_size)); |
| 1712 | save_item(NAME(m_cop_sprite_dma_param)); |
| 1713 | save_item(NAME(m_copd2_table)); |
| 1714 | save_item(NAME(m_copd2_table_2)); |
| 1715 | save_item(NAME(m_copd2_table_3)); |
| 1716 | save_item(NAME(m_copd2_table_4)); |
| 1717 | save_item(NAME(m_cop_dma_src)); |
| 1718 | save_item(NAME(m_cop_dma_size)); |
| 1719 | save_item(NAME(m_cop_dma_dst)); |
| 1720 | save_item(NAME(m_seibu_vregs)); |
| 1721 | } |
| 1623 | 1722 | |
| 1624 | | static void copd2_set_tableoffset(running_machine &machine, UINT16 data) |
| 1723 | //------------------------------------------------- |
| 1724 | // device_reset - device-specific startup |
| 1725 | //------------------------------------------------- |
| 1726 | |
| 1727 | void seibu_cop_legacy_device::device_reset() |
| 1625 | 1728 | { |
| 1729 | } |
| 1730 | |
| 1731 | void seibu_cop_legacy_device::copd2_set_tableoffset(UINT16 data) |
| 1732 | { |
| 1626 | 1733 | //logerror("mcu_offs %04x\n", data); |
| 1627 | | copd2_offs = data; |
| 1628 | | if (copd2_offs>0xff) |
| 1734 | m_copd2_offs = data; |
| 1735 | if (m_copd2_offs>0xff) |
| 1629 | 1736 | { |
| 1630 | 1737 | logerror("copd2 offs > 0x100\n"); |
| 1631 | 1738 | } |
| 1632 | 1739 | |
| 1633 | | copd2_table_2[copd2_offs/8] = cop_438; |
| 1634 | | copd2_table_3[copd2_offs/8] = cop_43a; |
| 1635 | | copd2_table_4[copd2_offs/8] = cop_43c; |
| 1740 | m_copd2_table_2[m_copd2_offs/8] = m_cop_438; |
| 1741 | m_copd2_table_3[m_copd2_offs/8] = m_cop_43a; |
| 1742 | m_copd2_table_4[m_copd2_offs/8] = m_cop_43c; |
| 1636 | 1743 | #if 0 |
| 1637 | 1744 | |
| 1638 | 1745 | { |
| r26062 | r26063 | |
| 1642 | 1749 | fp=fopen(filename, "w+b"); |
| 1643 | 1750 | if (fp) |
| 1644 | 1751 | { |
| 1645 | | fwrite(copd2_table_2, 0x200/8, 1, fp); |
| 1752 | fwrite(m_copd2_table_2, 0x200/8, 1, fp); |
| 1646 | 1753 | fclose(fp); |
| 1647 | 1754 | } |
| 1648 | 1755 | } |
| r26062 | r26063 | |
| 1653 | 1760 | fp=fopen(filename, "w+b"); |
| 1654 | 1761 | if (fp) |
| 1655 | 1762 | { |
| 1656 | | fwrite(copd2_table_3, 0x200/8, 1, fp); |
| 1763 | fwrite(m_copd2_table_3, 0x200/8, 1, fp); |
| 1657 | 1764 | fclose(fp); |
| 1658 | 1765 | } |
| 1659 | 1766 | } |
| r26062 | r26063 | |
| 1664 | 1771 | fp=fopen(filename, "w+b"); |
| 1665 | 1772 | if (fp) |
| 1666 | 1773 | { |
| 1667 | | fwrite(copd2_table_4, 0x200/8, 1, fp); |
| 1774 | fwrite(m_copd2_table_4, 0x200/8, 1, fp); |
| 1668 | 1775 | fclose(fp); |
| 1669 | 1776 | } |
| 1670 | 1777 | } |
| r26062 | r26063 | |
| 1677 | 1784 | for (i=0;i<0x20;i++) |
| 1678 | 1785 | { |
| 1679 | 1786 | int ii; |
| 1680 | | printf("%02x | %01x | %04x | %04x | ", i, copd2_table_2[i], copd2_table_3[i], copd2_table_4[i]); |
| 1787 | printf("%02x | %01x | %04x | %04x | ", i, m_copd2_table_2[i], m_copd2_table_3[i], m_copd2_table_4[i]); |
| 1681 | 1788 | |
| 1682 | 1789 | |
| 1683 | 1790 | for (ii=0;ii<0x8;ii++) |
| 1684 | 1791 | { |
| 1685 | | printf("%03x ", copd2_table[i*8 + ii]); |
| 1792 | printf("%03x ", m_copd2_table[i*8 + ii]); |
| 1686 | 1793 | |
| 1687 | 1794 | } |
| 1688 | 1795 | printf("\n"); |
| r26062 | r26063 | |
| 1693 | 1800 | |
| 1694 | 1801 | } |
| 1695 | 1802 | |
| 1696 | | static void copd2_set_tabledata(running_machine &machine, UINT16 data) |
| 1803 | void seibu_cop_legacy_device::copd2_set_tabledata(UINT16 data) |
| 1697 | 1804 | { |
| 1698 | | copd2_table[copd2_offs] = data; |
| 1805 | m_copd2_table[m_copd2_offs] = data; |
| 1699 | 1806 | |
| 1700 | 1807 | if(data) { |
| 1701 | 1808 | int off = data & 31; |
| 1702 | 1809 | int reg = (data >> 5) & 3; |
| 1703 | 1810 | int op = (data >> 7) & 31; |
| 1704 | 1811 | |
| 1705 | | logerror("COPDIS: %04x s=%02x f1=%x l=%x f2=%02x %x %04x %02x %03x %02x.%x.%02x ", cop_43c, (cop_43c >> 11) << 3, (cop_43c >> 10) & 1, ((cop_43c >> 7) & 7)+1, cop_43c & 0x7f, cop_438, cop_43a, copd2_offs, data, op, reg, off); |
| 1812 | logerror("COPDIS: %04x s=%02x f1=%x l=%x f2=%02x %x %04x %02x %03x %02x.%x.%02x ", m_cop_43c, (m_cop_43c >> 11) << 3, (m_cop_43c >> 10) & 1, ((m_cop_43c >> 7) & 7)+1, m_cop_43c & 0x7f, m_cop_438, m_cop_43a, m_copd2_offs, data, op, reg, off); |
| 1706 | 1813 | |
| 1707 | 1814 | off *= 2; |
| 1708 | 1815 | |
| 1709 | | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 00 188 03.0.08 read32 10(r0) |
| 1710 | | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 01 282 05.0.02 add32 4(r0) |
| 1711 | | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 02 082 01.0.02 write32 4(r0) |
| 1712 | | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 03 b8e 17.0.0e add16h 1c(r0) |
| 1713 | | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 04 98e 13.0.0e write16h 1c(r0) |
| 1816 | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 00 188 03.0.08 read32 10(m_r0) |
| 1817 | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 01 282 05.0.02 add32 4(m_r0) |
| 1818 | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 02 082 01.0.02 write32 4(m_r0) |
| 1819 | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 03 b8e 17.0.0e add16h 1c(m_r0) |
| 1820 | // COPDIS: 0205 s=00 f1=0 l=5 f2=05 6 ffeb 04 98e 13.0.0e write16h 1c(m_r0) |
| 1714 | 1821 | |
| 1715 | 1822 | // 188 182 082 b8e 98e -> 04 = 04+04 1ch = 1c+04 |
| 1716 | 1823 | // 188 188 082 b8e 98e -> 04 = 04+10 1ch = 1c+10 |
| r26062 | r26063 | |
| 1773 | 1880 | fp=fopen(filename, "w+b"); |
| 1774 | 1881 | if (fp) |
| 1775 | 1882 | { |
| 1776 | | fwrite(copd2_table, 0x200, 1, fp); |
| 1883 | fwrite(m_copd2_table, 0x200, 1, fp); |
| 1777 | 1884 | fclose(fp); |
| 1778 | 1885 | } |
| 1779 | 1886 | } |
| 1780 | 1887 | #endif |
| 1781 | 1888 | } |
| 1782 | 1889 | |
| 1783 | | static UINT32 cop_register[8]; |
| 1784 | | static UINT16 seibu_vregs[0x50/2]; |
| 1785 | | |
| 1786 | | static WRITE16_HANDLER( seibu_common_video_regs_w ) |
| 1890 | WRITE16_MEMBER( seibu_cop_legacy_device::seibu_common_video_regs_w ) |
| 1787 | 1891 | { |
| 1788 | 1892 | legionna_state *state = space.machine().driver_data<legionna_state>(); |
| 1789 | | COMBINE_DATA(&seibu_vregs[offset]); |
| 1893 | COMBINE_DATA(&m_seibu_vregs[offset]); |
| 1790 | 1894 | |
| 1791 | 1895 | switch(offset) |
| 1792 | 1896 | { |
| 1793 | | case (0x01a/2): { state->flip_screen_set(seibu_vregs[offset] & 0x01); break; } |
| 1794 | | case (0x01c/2): { state->m_layer_disable = seibu_vregs[offset]; break; } |
| 1795 | | case (0x020/2): { state->m_scrollram16[0] = seibu_vregs[offset]; break; } |
| 1796 | | case (0x022/2): { state->m_scrollram16[1] = seibu_vregs[offset]; break; } |
| 1797 | | case (0x024/2): { state->m_scrollram16[2] = seibu_vregs[offset]; break; } |
| 1798 | | case (0x026/2): { state->m_scrollram16[3] = seibu_vregs[offset]; break; } |
| 1799 | | case (0x028/2): { state->m_scrollram16[4] = seibu_vregs[offset]; break; } |
| 1800 | | case (0x02a/2): { state->m_scrollram16[5] = seibu_vregs[offset]; break; } |
| 1897 | case (0x01a/2): { state->flip_screen_set(m_seibu_vregs[offset] & 0x01); break; } |
| 1898 | case (0x01c/2): { state->m_layer_disable = m_seibu_vregs[offset]; break; } |
| 1899 | case (0x020/2): { state->m_scrollram16[0] = m_seibu_vregs[offset]; break; } |
| 1900 | case (0x022/2): { state->m_scrollram16[1] = m_seibu_vregs[offset]; break; } |
| 1901 | case (0x024/2): { state->m_scrollram16[2] = m_seibu_vregs[offset]; break; } |
| 1902 | case (0x026/2): { state->m_scrollram16[3] = m_seibu_vregs[offset]; break; } |
| 1903 | case (0x028/2): { state->m_scrollram16[4] = m_seibu_vregs[offset]; break; } |
| 1904 | case (0x02a/2): { state->m_scrollram16[5] = m_seibu_vregs[offset]; break; } |
| 1801 | 1905 | default: { logerror("seibu_common_video_regs_w unhandled offset %02x %04x\n",offset*2,data); break; } |
| 1802 | 1906 | } |
| 1803 | 1907 | } |
| r26062 | r26063 | |
| 1919 | 2023 | |
| 1920 | 2024 | *******************************************************************************************/ |
| 1921 | 2025 | |
| 1922 | | // temporary hack until this is a proper device |
| 1923 | | inline void get_ram(running_machine &machine) |
| 1924 | | { |
| 1925 | | if (cop_mcu_ram == NULL) cop_mcu_ram = reinterpret_cast<UINT16 *>(machine.root_device().memshare("cop_mcu_ram")->ptr()); |
| 1926 | | } |
| 1927 | 2026 | |
| 1928 | | READ16_HANDLER( copdxbl_0_r ) |
| 2027 | READ16_MEMBER( seibu_cop_legacy_device::copdxbl_0_r ) |
| 1929 | 2028 | { |
| 1930 | | get_ram(space.machine()); |
| 1931 | | UINT16 retvalue = cop_mcu_ram[offset]; |
| 2029 | UINT16 retvalue = m_cop_mcu_ram[offset]; |
| 1932 | 2030 | |
| 1933 | 2031 | switch(offset) |
| 1934 | 2032 | { |
| r26062 | r26063 | |
| 1941 | 2039 | //case (0x47e/2): |
| 1942 | 2040 | //case (0x5b0/2): |
| 1943 | 2041 | //case (0x5b4/2): |
| 1944 | | // return cop_mcu_ram[offset]; |
| 2042 | // return m_cop_mcu_ram[offset]; |
| 1945 | 2043 | |
| 1946 | 2044 | case (0x700/2): return space.machine().root_device().ioport("DSW1")->read(); |
| 1947 | 2045 | case (0x704/2): return space.machine().root_device().ioport("PLAYERS12")->read(); |
| r26062 | r26063 | |
| 1951 | 2049 | } |
| 1952 | 2050 | } |
| 1953 | 2051 | |
| 1954 | | WRITE16_HANDLER( copdxbl_0_w ) |
| 2052 | WRITE16_MEMBER( seibu_cop_legacy_device::copdxbl_0_w ) |
| 1955 | 2053 | { |
| 1956 | 2054 | legionna_state *state = space.machine().driver_data<legionna_state>(); |
| 1957 | | get_ram(space.machine()); |
| 1958 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 2055 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 1959 | 2056 | |
| 1960 | 2057 | switch(offset) |
| 1961 | 2058 | { |
| r26062 | r26063 | |
| 1966 | 2063 | } |
| 1967 | 2064 | |
| 1968 | 2065 | /*TODO: kludge on x-axis.*/ |
| 1969 | | case (0x660/2): { state->m_scrollram16[0] = cop_mcu_ram[offset] - 0x1f0; break; } |
| 1970 | | case (0x662/2): { state->m_scrollram16[1] = cop_mcu_ram[offset]; break; } |
| 1971 | | case (0x664/2): { state->m_scrollram16[2] = cop_mcu_ram[offset] - 0x1f0; break; } |
| 1972 | | case (0x666/2): { state->m_scrollram16[3] = cop_mcu_ram[offset]; break; } |
| 1973 | | case (0x668/2): { state->m_scrollram16[4] = cop_mcu_ram[offset] - 0x1f0; break; } |
| 1974 | | case (0x66a/2): { state->m_scrollram16[5] = cop_mcu_ram[offset]; break; } |
| 1975 | | case (0x66c/2): { state->m_scrollram16[6] = cop_mcu_ram[offset] - 0x1f0; break; } |
| 1976 | | case (0x66e/2): { state->m_scrollram16[7] = cop_mcu_ram[offset]; break; } |
| 2066 | case (0x660/2): { state->m_scrollram16[0] = m_cop_mcu_ram[offset] - 0x1f0; break; } |
| 2067 | case (0x662/2): { state->m_scrollram16[1] = m_cop_mcu_ram[offset]; break; } |
| 2068 | case (0x664/2): { state->m_scrollram16[2] = m_cop_mcu_ram[offset] - 0x1f0; break; } |
| 2069 | case (0x666/2): { state->m_scrollram16[3] = m_cop_mcu_ram[offset]; break; } |
| 2070 | case (0x668/2): { state->m_scrollram16[4] = m_cop_mcu_ram[offset] - 0x1f0; break; } |
| 2071 | case (0x66a/2): { state->m_scrollram16[5] = m_cop_mcu_ram[offset]; break; } |
| 2072 | case (0x66c/2): { state->m_scrollram16[6] = m_cop_mcu_ram[offset] - 0x1f0; break; } |
| 2073 | case (0x66e/2): { state->m_scrollram16[7] = m_cop_mcu_ram[offset]; break; } |
| 1977 | 2074 | |
| 1978 | 2075 | case (0x740/2): |
| 1979 | 2076 | { |
| r26062 | r26063 | |
| 1990 | 2087 | which seems common to all the games |
| 1991 | 2088 | */ |
| 1992 | 2089 | |
| 1993 | | static UINT16 cop_status,cop_dist,cop_angle; |
| 1994 | | static UINT16 cop_hit_status; |
| 1995 | | static INT16 cop_hit_val_x,cop_hit_val_y,cop_hit_val_z,cop_hit_val_unk; |
| 1996 | | static UINT32 cop_sort_lookup,cop_sort_ram_addr,cop_sort_param; |
| 1997 | | static INT8 cop_angle_compare; |
| 1998 | | static INT8 cop_angle_mod_val; |
| 1999 | | static struct |
| 2000 | | { |
| 2001 | | int x,y; |
| 2002 | | INT16 min_x,min_y,max_x,max_y; |
| 2003 | | UINT16 hitbox; |
| 2004 | | UINT16 hitbox_x,hitbox_y; |
| 2005 | | }cop_collision_info[2]; |
| 2006 | | static int r0, r1; |
| 2007 | | |
| 2008 | | static UINT16 cop_rom_addr_lo,cop_rom_addr_hi,cop_rom_addr_unk; |
| 2009 | | |
| 2010 | 2090 | /* RE from Seibu Cup Soccer bootleg */ |
| 2011 | 2091 | static const UINT8 fade_table(int v) |
| 2012 | 2092 | { |
| r26062 | r26063 | |
| 2016 | 2096 | return (low * (high | (high >> 5)) + 0x210) >> 10; |
| 2017 | 2097 | } |
| 2018 | 2098 | |
| 2019 | | static UINT16 u1,u2; |
| 2020 | 2099 | |
| 2021 | | #define COP_CMD(_1_,_2_,_3_,_4_,_5_,_6_,_7_,_8_,_u1_,_u2_) \ |
| 2022 | | (copd2_table[command+0] == _1_ && copd2_table[command+1] == _2_ && copd2_table[command+2] == _3_ && copd2_table[command+3] == _4_ && \ |
| 2023 | | copd2_table[command+4] == _5_ && copd2_table[command+5] == _6_ && copd2_table[command+6] == _7_ && copd2_table[command+7] == _8_ && \ |
| 2024 | | u1 == _u1_ && u2 == _u2_) |
| 2100 | #define COP_CMD(_1_,_2_,_3_,_4_,_5_,_6_,_7_,_8_,_m_u1_,_m_u2_) \ |
| 2101 | (m_copd2_table[command+0] == _1_ && m_copd2_table[command+1] == _2_ && m_copd2_table[command+2] == _3_ && m_copd2_table[command+3] == _4_ && \ |
| 2102 | m_copd2_table[command+4] == _5_ && m_copd2_table[command+5] == _6_ && m_copd2_table[command+6] == _7_ && m_copd2_table[command+7] == _8_ && \ |
| 2103 | m_u1 == _m_u1_ && m_u2 == _m_u2_) |
| 2025 | 2104 | |
| 2026 | 2105 | /* |
| 2027 | 2106 | Godzilla 0x12c0 X = 0x21ed Y = 0x57da |
| r26062 | r26063 | |
| 2040 | 2119 | Y = collides between 0xd0 and 0x30 (not inclusive) |
| 2041 | 2120 | 0x588 bits 2 & 3 = 0x580 bits 0 & 1 |
| 2042 | 2121 | */ |
| 2043 | | static void cop_take_hit_box_params(UINT8 offs) |
| 2122 | void seibu_cop_legacy_device::cop_take_hit_box_params(UINT8 offs) |
| 2044 | 2123 | { |
| 2045 | 2124 | INT16 start_x,start_y,height,width; |
| 2046 | 2125 | |
| 2047 | 2126 | { |
| 2048 | | height = UINT8(cop_collision_info[offs].hitbox_y >> 8); |
| 2049 | | start_y = INT8(cop_collision_info[offs].hitbox_y); |
| 2050 | | width = UINT8(cop_collision_info[offs].hitbox_x >> 8); |
| 2051 | | start_x = INT8(cop_collision_info[offs].hitbox_x); |
| 2127 | height = UINT8(m_cop_collision_info[offs].hitbox_y >> 8); |
| 2128 | start_y = INT8(m_cop_collision_info[offs].hitbox_y); |
| 2129 | width = UINT8(m_cop_collision_info[offs].hitbox_x >> 8); |
| 2130 | start_x = INT8(m_cop_collision_info[offs].hitbox_x); |
| 2052 | 2131 | } |
| 2053 | 2132 | |
| 2054 | | cop_collision_info[offs].min_x = (cop_collision_info[offs].x >> 16) + start_x; |
| 2055 | | cop_collision_info[offs].max_x = cop_collision_info[offs].min_x + width; |
| 2056 | | cop_collision_info[offs].min_y = (cop_collision_info[offs].y >> 16) + start_y; |
| 2057 | | cop_collision_info[offs].max_y = cop_collision_info[offs].min_y + height; |
| 2133 | m_cop_collision_info[offs].min_x = (m_cop_collision_info[offs].x >> 16) + start_x; |
| 2134 | m_cop_collision_info[offs].max_x = m_cop_collision_info[offs].min_x + width; |
| 2135 | m_cop_collision_info[offs].min_y = (m_cop_collision_info[offs].y >> 16) + start_y; |
| 2136 | m_cop_collision_info[offs].max_y = m_cop_collision_info[offs].min_y + height; |
| 2058 | 2137 | } |
| 2059 | 2138 | |
| 2060 | 2139 | |
| 2061 | | static UINT8 cop_calculate_collsion_detection(running_machine &machine) |
| 2140 | UINT8 seibu_cop_legacy_device::cop_calculate_collsion_detection() |
| 2062 | 2141 | { |
| 2063 | 2142 | static UINT8 res; |
| 2064 | 2143 | |
| 2065 | 2144 | res = 3; |
| 2066 | 2145 | |
| 2067 | 2146 | /* outbound X check */ |
| 2068 | | if(cop_collision_info[0].max_x >= cop_collision_info[1].min_x && cop_collision_info[0].min_x <= cop_collision_info[1].max_x) |
| 2147 | if(m_cop_collision_info[0].max_x >= m_cop_collision_info[1].min_x && m_cop_collision_info[0].min_x <= m_cop_collision_info[1].max_x) |
| 2069 | 2148 | res &= ~2; |
| 2070 | 2149 | |
| 2071 | | if(cop_collision_info[1].max_x >= cop_collision_info[0].min_x && cop_collision_info[1].min_x <= cop_collision_info[0].max_x) |
| 2150 | if(m_cop_collision_info[1].max_x >= m_cop_collision_info[0].min_x && m_cop_collision_info[1].min_x <= m_cop_collision_info[0].max_x) |
| 2072 | 2151 | res &= ~2; |
| 2073 | 2152 | |
| 2074 | 2153 | /* outbound Y check */ |
| 2075 | | if(cop_collision_info[0].max_y >= cop_collision_info[1].min_y && cop_collision_info[0].min_y <= cop_collision_info[1].max_y) |
| 2154 | if(m_cop_collision_info[0].max_y >= m_cop_collision_info[1].min_y && m_cop_collision_info[0].min_y <= m_cop_collision_info[1].max_y) |
| 2076 | 2155 | res &= ~1; |
| 2077 | 2156 | |
| 2078 | | if(cop_collision_info[1].max_y >= cop_collision_info[0].min_y && cop_collision_info[1].min_y <= cop_collision_info[0].max_y) |
| 2157 | if(m_cop_collision_info[1].max_y >= m_cop_collision_info[0].min_y && m_cop_collision_info[1].min_y <= m_cop_collision_info[0].max_y) |
| 2079 | 2158 | res &= ~1; |
| 2080 | 2159 | |
| 2081 | | cop_hit_val_x = (cop_collision_info[0].x - cop_collision_info[1].x) >> 16; |
| 2082 | | cop_hit_val_y = (cop_collision_info[0].y - cop_collision_info[1].y) >> 16; |
| 2083 | | cop_hit_val_z = 1; |
| 2084 | | cop_hit_val_unk = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning |
| 2160 | m_cop_hit_val_x = (m_cop_collision_info[0].x - m_cop_collision_info[1].x) >> 16; |
| 2161 | m_cop_hit_val_y = (m_cop_collision_info[0].y - m_cop_collision_info[1].y) >> 16; |
| 2162 | m_cop_hit_val_z = 1; |
| 2163 | m_cop_hit_val_unk = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning |
| 2085 | 2164 | |
| 2086 | | //popmessage("%d %d %04x %04x %04x %04x",cop_hit_val_x,cop_hit_val_y,cop_collision_info[0].hitbox_x,cop_collision_info[0].hitbox_y,cop_collision_info[1].hitbox_x,cop_collision_info[1].hitbox_y); |
| 2165 | //popmessage("%d %d %04x %04x %04x %04x",m_cop_hit_val_x,m_cop_hit_val_y,m_cop_collision_info[0].hitbox_x,m_cop_collision_info[0].hitbox_y,m_cop_collision_info[1].hitbox_x,m_cop_collision_info[1].hitbox_y); |
| 2087 | 2166 | |
| 2088 | 2167 | //if(res == 0) |
| 2089 | | //popmessage("0:%08x %08x %08x 1:%08x %08x %08x\n",cop_collision_info[0].x,cop_collision_info[0].y,cop_collision_info[0].hitbox,cop_collision_info[1].x,cop_collision_info[1].y,cop_collision_info[1].hitbox); |
| 2090 | | // popmessage("0:%08x %08x %08x %08x 1:%08x %08x %08x %08x\n",cop_collision_info[0].min_x,cop_collision_info[0].max_x,cop_collision_info[0].min_y, cop_collision_info[0].max_y, |
| 2091 | | // cop_collision_info[1].min_x,cop_collision_info[1].max_x,cop_collision_info[1].min_y, cop_collision_info[1].max_y); |
| 2168 | //popmessage("0:%08x %08x %08x 1:%08x %08x %08x\n",m_cop_collision_info[0].x,m_cop_collision_info[0].y,m_cop_collision_info[0].hitbox,m_cop_collision_info[1].x,m_cop_collision_info[1].y,m_cop_collision_info[1].hitbox); |
| 2169 | // popmessage("0:%08x %08x %08x %08x 1:%08x %08x %08x %08x\n",m_cop_collision_info[0].min_x,m_cop_collision_info[0].max_x,m_cop_collision_info[0].min_y, m_cop_collision_info[0].max_y, |
| 2170 | // m_cop_collision_info[1].min_x,m_cop_collision_info[1].max_x,m_cop_collision_info[1].min_y, m_cop_collision_info[1].max_y); |
| 2092 | 2171 | |
| 2093 | 2172 | return res; |
| 2094 | 2173 | } |
| 2095 | 2174 | |
| 2096 | | static READ16_HANDLER( generic_cop_r ) |
| 2175 | READ16_MEMBER( seibu_cop_legacy_device::generic_cop_r ) |
| 2097 | 2176 | { |
| 2098 | 2177 | UINT16 retvalue; |
| 2099 | | get_ram(space.machine()); |
| 2100 | | retvalue = cop_mcu_ram[offset]; |
| 2178 | retvalue = m_cop_mcu_ram[offset]; |
| 2101 | 2179 | |
| 2102 | 2180 | |
| 2103 | 2181 | switch (offset) |
| r26062 | r26063 | |
| 2111 | 2189 | return retvalue; |
| 2112 | 2190 | |
| 2113 | 2191 | case 0x180/2: |
| 2114 | | return cop_hit_status; |
| 2192 | return m_cop_hit_status; |
| 2115 | 2193 | |
| 2116 | 2194 | /* these two controls facing direction in Godzilla opponents (only vs.) - x value compare? */ |
| 2117 | 2195 | case 0x182/2: |
| 2118 | | return (cop_hit_val_y); |
| 2196 | return (m_cop_hit_val_y); |
| 2119 | 2197 | |
| 2120 | 2198 | case 0x184/2: |
| 2121 | | return (cop_hit_val_x); |
| 2199 | return (m_cop_hit_val_x); |
| 2122 | 2200 | |
| 2123 | 2201 | /* Legionnaire only - z value compare? */ |
| 2124 | 2202 | case 0x186/2: |
| 2125 | | return (cop_hit_val_z); |
| 2203 | return (m_cop_hit_val_z); |
| 2126 | 2204 | |
| 2127 | 2205 | case 0x188/2: |
| 2128 | | return cop_hit_val_unk; |
| 2206 | return m_cop_hit_val_unk; |
| 2129 | 2207 | |
| 2130 | 2208 | /* BCD */ |
| 2131 | 2209 | case 0x190/2: |
| r26062 | r26063 | |
| 2140 | 2218 | case 0x1a2/2: |
| 2141 | 2219 | case 0x1a4/2: |
| 2142 | 2220 | case 0x1a6/2: |
| 2143 | | return space.machine().firstcpu->total_cycles() % (cop_rng_max_value+1); |
| 2221 | return space.machine().firstcpu->total_cycles() % (m_cop_rng_max_value+1); |
| 2144 | 2222 | |
| 2145 | 2223 | case 0x1b0/2: |
| 2146 | | return cop_status; |
| 2224 | return m_cop_status; |
| 2147 | 2225 | |
| 2148 | 2226 | case 0x1b2/2: |
| 2149 | | return cop_dist; |
| 2227 | return m_cop_dist; |
| 2150 | 2228 | |
| 2151 | 2229 | case 0x1b4/2: |
| 2152 | | return cop_angle; |
| 2230 | return m_cop_angle; |
| 2153 | 2231 | |
| 2154 | 2232 | default: |
| 2155 | 2233 | seibu_cop_log("%06x: COPX unhandled read returning %04x from offset %04x\n", space.device().safe_pc(), retvalue, offset*2); |
| r26062 | r26063 | |
| 2157 | 2235 | } |
| 2158 | 2236 | } |
| 2159 | 2237 | |
| 2160 | | static UINT32 fill_val; |
| 2161 | | static UINT8 pal_brightness_val,pal_brightness_mode; |
| 2162 | | static UINT32 cop_sprite_dma_src; |
| 2163 | | static int cop_sprite_dma_abs_x,cop_sprite_dma_abs_y,cop_sprite_dma_size; |
| 2164 | | static UINT32 cop_sprite_dma_param; |
| 2165 | | |
| 2166 | | static WRITE16_HANDLER( generic_cop_w ) |
| 2238 | WRITE16_MEMBER( seibu_cop_legacy_device::generic_cop_w ) |
| 2167 | 2239 | { |
| 2168 | 2240 | UINT32 temp32; |
| 2169 | | get_ram(space.machine()); |
| 2170 | | |
| 2241 | |
| 2171 | 2242 | switch (offset) |
| 2172 | 2243 | { |
| 2173 | 2244 | default: |
| r26062 | r26063 | |
| 2177 | 2248 | /* Sprite DMA */ |
| 2178 | 2249 | case (0x000/2): |
| 2179 | 2250 | case (0x002/2): |
| 2180 | | cop_sprite_dma_param = (cop_mcu_ram[0x000/2]) | (cop_mcu_ram[0x002/2] << 16); |
| 2181 | | //popmessage("%08x",cop_sprite_dma_param & 0xffffffc0); |
| 2251 | m_cop_sprite_dma_param = (m_cop_mcu_ram[0x000/2]) | (m_cop_mcu_ram[0x002/2] << 16); |
| 2252 | //popmessage("%08x",m_cop_sprite_dma_param & 0xffffffc0); |
| 2182 | 2253 | break; |
| 2183 | 2254 | |
| 2184 | | case (0x00c/2): { cop_sprite_dma_size = cop_mcu_ram[offset]; break; } |
| 2255 | case (0x00c/2): { m_cop_sprite_dma_size = m_cop_mcu_ram[offset]; break; } |
| 2185 | 2256 | case (0x010/2): |
| 2186 | 2257 | { |
| 2187 | 2258 | if(data) |
| r26062 | r26063 | |
| 2189 | 2260 | else |
| 2190 | 2261 | { |
| 2191 | 2262 | /* guess */ |
| 2192 | | cop_register[4]+=8; |
| 2193 | | cop_sprite_dma_src+=6; |
| 2263 | m_cop_register[4]+=8; |
| 2264 | m_cop_sprite_dma_src+=6; |
| 2194 | 2265 | |
| 2195 | | cop_sprite_dma_size--; |
| 2266 | m_cop_sprite_dma_size--; |
| 2196 | 2267 | |
| 2197 | | if(cop_sprite_dma_size > 0) |
| 2198 | | cop_status &= ~2; |
| 2268 | if(m_cop_sprite_dma_size > 0) |
| 2269 | m_cop_status &= ~2; |
| 2199 | 2270 | else |
| 2200 | | cop_status |= 2; |
| 2271 | m_cop_status |= 2; |
| 2201 | 2272 | } |
| 2202 | 2273 | break; |
| 2203 | 2274 | } |
| 2204 | 2275 | |
| 2205 | 2276 | case (0x012/2): |
| 2206 | 2277 | case (0x014/2): |
| 2207 | | cop_sprite_dma_src = (cop_mcu_ram[0x014/2]) | (cop_mcu_ram[0x012/2] << 16); |
| 2278 | m_cop_sprite_dma_src = (m_cop_mcu_ram[0x014/2]) | (m_cop_mcu_ram[0x012/2] << 16); |
| 2208 | 2279 | break; |
| 2209 | 2280 | |
| 2210 | 2281 | /* triggered before 0x6200 in Seibu Cup, looks like an angle value ... */ |
| 2211 | | case (0x01c/2): cop_angle_compare = INT8(cop_mcu_ram[0x1c/2]); break; |
| 2212 | | case (0x01e/2): cop_angle_mod_val = INT8(cop_mcu_ram[0x1e/2]); break; |
| 2282 | case (0x01c/2): m_cop_angle_compare = INT8(m_cop_mcu_ram[0x1c/2]); break; |
| 2283 | case (0x01e/2): m_cop_angle_mod_val = INT8(m_cop_mcu_ram[0x1e/2]); break; |
| 2213 | 2284 | |
| 2214 | 2285 | /* BCD Protection */ |
| 2215 | 2286 | case (0x020/2): |
| 2216 | 2287 | case (0x022/2): |
| 2217 | | temp32 = (cop_mcu_ram[0x020/2]) | (cop_mcu_ram[0x022/2] << 16); |
| 2218 | | cop_mcu_ram[0x190/2] = (((temp32 / 1) % 10) + (((temp32 / 10) % 10) << 8) + 0x3030); |
| 2219 | | cop_mcu_ram[0x192/2] = (((temp32 / 100) % 10) + (((temp32 / 1000) % 10) << 8) + 0x3030); |
| 2220 | | cop_mcu_ram[0x194/2] = (((temp32 / 10000) % 10) + (((temp32 / 100000) % 10) << 8) + 0x3030); |
| 2221 | | cop_mcu_ram[0x196/2] = (((temp32 / 1000000) % 10) + (((temp32 / 10000000) % 10) << 8) + 0x3030); |
| 2222 | | cop_mcu_ram[0x198/2] = (((temp32 / 100000000) % 10) + (((temp32 / 1000000000) % 10) << 8) + 0x3030); |
| 2288 | temp32 = (m_cop_mcu_ram[0x020/2]) | (m_cop_mcu_ram[0x022/2] << 16); |
| 2289 | m_cop_mcu_ram[0x190/2] = (((temp32 / 1) % 10) + (((temp32 / 10) % 10) << 8) + 0x3030); |
| 2290 | m_cop_mcu_ram[0x192/2] = (((temp32 / 100) % 10) + (((temp32 / 1000) % 10) << 8) + 0x3030); |
| 2291 | m_cop_mcu_ram[0x194/2] = (((temp32 / 10000) % 10) + (((temp32 / 100000) % 10) << 8) + 0x3030); |
| 2292 | m_cop_mcu_ram[0x196/2] = (((temp32 / 1000000) % 10) + (((temp32 / 10000000) % 10) << 8) + 0x3030); |
| 2293 | m_cop_mcu_ram[0x198/2] = (((temp32 / 100000000) % 10) + (((temp32 / 1000000000) % 10) << 8) + 0x3030); |
| 2223 | 2294 | break; |
| 2224 | 2295 | case (0x024/2): |
| 2225 | 2296 | /* |
| r26062 | r26063 | |
| 2232 | 2303 | |
| 2233 | 2304 | case (0x028/2): |
| 2234 | 2305 | case (0x02a/2): |
| 2235 | | fill_val = (cop_mcu_ram[0x028/2]) | (cop_mcu_ram[0x02a/2] << 16); |
| 2306 | m_fill_val = (m_cop_mcu_ram[0x028/2]) | (m_cop_mcu_ram[0x02a/2] << 16); |
| 2236 | 2307 | break; |
| 2237 | 2308 | |
| 2238 | 2309 | /* max possible value returned by the RNG at 0x5a*, trusted */ |
| 2239 | | case (0x02c/2): cop_rng_max_value = cop_mcu_ram[0x2c/2] & 0xff; break; |
| 2310 | case (0x02c/2): m_cop_rng_max_value = m_cop_mcu_ram[0x2c/2] & 0xff; break; |
| 2240 | 2311 | |
| 2241 | 2312 | /* Command tables for 0x500 / 0x502 commands */ |
| 2242 | | case (0x032/2): { copd2_set_tabledata(space.machine(), data); break; } |
| 2243 | | case (0x034/2): { copd2_set_tableoffset(space.machine(), data); break; } |
| 2244 | | case (0x038/2): { cop_438 = data; break; } |
| 2245 | | case (0x03a/2): { cop_43a = data; break; } |
| 2246 | | case (0x03c/2): { cop_43c = data; break; } |
| 2313 | case (0x032/2): { copd2_set_tabledata(data); break; } |
| 2314 | case (0x034/2): { copd2_set_tableoffset(data); break; } |
| 2315 | case (0x038/2): { m_cop_438 = data; break; } |
| 2316 | case (0x03a/2): { m_cop_43a = data; break; } |
| 2317 | case (0x03c/2): { m_cop_43c = data; break; } |
| 2247 | 2318 | case (0x03e/2): |
| 2248 | 2319 | /* |
| 2249 | 2320 | 0 in all 68k based games |
| r26062 | r26063 | |
| 2253 | 2324 | */ |
| 2254 | 2325 | break; |
| 2255 | 2326 | |
| 2256 | | case (0x044/2): { cop_scale = data & 3; break; } |
| 2257 | | case (0x046/2): { cop_rom_addr_unk = data & 0xffff; break; } |
| 2258 | | case (0x048/2): { cop_rom_addr_lo = data & 0xffff; break; } |
| 2259 | | case (0x04a/2): { cop_rom_addr_hi = data & 0xffff; break; } |
| 2327 | case (0x044/2): { m_cop_scale = data & 3; break; } |
| 2328 | case (0x046/2): { m_cop_rom_addr_unk = data & 0xffff; break; } |
| 2329 | case (0x048/2): { m_cop_rom_addr_lo = data & 0xffff; break; } |
| 2330 | case (0x04a/2): { m_cop_rom_addr_hi = data & 0xffff; break; } |
| 2260 | 2331 | |
| 2261 | 2332 | /* brightness control */ |
| 2262 | | case (0x05a/2): pal_brightness_val = data & 0xff; break; |
| 2263 | | case (0x05c/2): pal_brightness_mode = data & 0xff; break; |
| 2333 | case (0x05a/2): m_pal_brightness_val = data & 0xff; break; |
| 2334 | case (0x05c/2): m_pal_brightness_mode = data & 0xff; break; |
| 2264 | 2335 | |
| 2265 | 2336 | /* DMA / layer clearing section */ |
| 2266 | 2337 | case (0x074/2): |
| r26062 | r26063 | |
| 2277 | 2348 | |
| 2278 | 2349 | /* used in palette DMAs, for fading effects */ |
| 2279 | 2350 | case (0x076/2): |
| 2280 | | cop_dma_fade_table = data; |
| 2351 | m_cop_dma_fade_table = data; |
| 2281 | 2352 | break; |
| 2282 | 2353 | |
| 2283 | 2354 | case (0x078/2): /* DMA source address */ |
| 2284 | 2355 | { |
| 2285 | | cop_dma_src[cop_dma_trigger] = data; // << 6 to get actual address |
| 2356 | m_cop_dma_src[m_cop_dma_trigger] = data; // << 6 to get actual address |
| 2286 | 2357 | //seibu_cop_log("%06x: COPX set layer clear address to %04x (actual %08x)\n", space.device().safe_pc(), data, data<<6); |
| 2287 | 2358 | break; |
| 2288 | 2359 | } |
| 2289 | 2360 | |
| 2290 | 2361 | case (0x07a/2): /* DMA length */ |
| 2291 | 2362 | { |
| 2292 | | cop_dma_size[cop_dma_trigger] = data; |
| 2363 | m_cop_dma_size[m_cop_dma_trigger] = data; |
| 2293 | 2364 | //seibu_cop_log("%06x: COPX set layer clear length to %04x (actual %08x)\n", space.device().safe_pc(), data, data<<5); |
| 2294 | 2365 | break; |
| 2295 | 2366 | } |
| 2296 | 2367 | |
| 2297 | 2368 | case (0x07c/2): /* DMA destination */ |
| 2298 | 2369 | { |
| 2299 | | cop_dma_dst[cop_dma_trigger] = data; |
| 2370 | m_cop_dma_dst[m_cop_dma_trigger] = data; |
| 2300 | 2371 | //seibu_cop_log("%06x: COPX set layer clear value to %04x (actual %08x)\n", space.device().safe_pc(), data, data<<6); |
| 2301 | 2372 | break; |
| 2302 | 2373 | } |
| 2303 | 2374 | |
| 2304 | 2375 | case (0x07e/2): /* DMA parameter */ |
| 2305 | 2376 | { |
| 2306 | | cop_dma_trigger = data; |
| 2377 | m_cop_dma_trigger = data; |
| 2307 | 2378 | //seibu_cop_log("%06x: COPX set layer clear trigger? to %04x\n", space.device().safe_pc(), data); |
| 2308 | 2379 | if (data>=0x1ff) |
| 2309 | 2380 | { |
| 2310 | 2381 | seibu_cop_log("invalid DMA trigger!, >0x1ff\n"); |
| 2311 | | cop_dma_trigger = 0; |
| 2382 | m_cop_dma_trigger = 0; |
| 2312 | 2383 | } |
| 2313 | 2384 | |
| 2314 | 2385 | break; |
| 2315 | 2386 | } |
| 2316 | 2387 | |
| 2317 | | case (0x08c/2): cop_sprite_dma_abs_y = (cop_mcu_ram[0x08c/2]); break; |
| 2318 | | case (0x08e/2): cop_sprite_dma_abs_x = (cop_mcu_ram[0x08e/2]); break; |
| 2388 | case (0x08c/2): m_cop_sprite_dma_abs_y = (m_cop_mcu_ram[0x08c/2]); break; |
| 2389 | case (0x08e/2): m_cop_sprite_dma_abs_x = (m_cop_mcu_ram[0x08e/2]); break; |
| 2319 | 2390 | |
| 2320 | 2391 | /* Registers */ |
| 2321 | | case (0x0a0/2): { cop_register[0] = (cop_register[0]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 2322 | | case (0x0c0/2): { cop_register[0] = (cop_register[0]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 2392 | case (0x0a0/2): { m_cop_register[0] = (m_cop_register[0]&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 2393 | case (0x0c0/2): { m_cop_register[0] = (m_cop_register[0]&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 2323 | 2394 | |
| 2324 | | case (0x0a2/2): { cop_register[1] = (cop_register[1]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 2325 | | case (0x0c2/2): { cop_register[1] = (cop_register[1]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 2395 | case (0x0a2/2): { m_cop_register[1] = (m_cop_register[1]&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 2396 | case (0x0c2/2): { m_cop_register[1] = (m_cop_register[1]&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 2326 | 2397 | |
| 2327 | | case (0x0a4/2): { cop_register[2] = (cop_register[2]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 2328 | | case (0x0c4/2): { cop_register[2] = (cop_register[2]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 2398 | case (0x0a4/2): { m_cop_register[2] = (m_cop_register[2]&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 2399 | case (0x0c4/2): { m_cop_register[2] = (m_cop_register[2]&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 2329 | 2400 | |
| 2330 | | case (0x0a6/2): { cop_register[3] = (cop_register[3]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 2331 | | case (0x0c6/2): { cop_register[3] = (cop_register[3]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 2401 | case (0x0a6/2): { m_cop_register[3] = (m_cop_register[3]&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 2402 | case (0x0c6/2): { m_cop_register[3] = (m_cop_register[3]&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 2332 | 2403 | |
| 2333 | | case (0x0a8/2): { cop_register[4] = (cop_register[4]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 2334 | | case (0x0c8/2): { cop_register[4] = (cop_register[4]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 2404 | case (0x0a8/2): { m_cop_register[4] = (m_cop_register[4]&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 2405 | case (0x0c8/2): { m_cop_register[4] = (m_cop_register[4]&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 2335 | 2406 | |
| 2336 | | case (0x0aa/2): { cop_register[5] = (cop_register[5]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 2337 | | case (0x0ca/2): { cop_register[5] = (cop_register[5]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 2407 | case (0x0aa/2): { m_cop_register[5] = (m_cop_register[5]&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 2408 | case (0x0ca/2): { m_cop_register[5] = (m_cop_register[5]&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 2338 | 2409 | |
| 2339 | | case (0x0ac/2): { cop_register[6] = (cop_register[6]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 2340 | | case (0x0cc/2): { cop_register[6] = (cop_register[6]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 2410 | case (0x0ac/2): { m_cop_register[6] = (m_cop_register[6]&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 2411 | case (0x0cc/2): { m_cop_register[6] = (m_cop_register[6]&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 2341 | 2412 | |
| 2342 | 2413 | |
| 2343 | 2414 | case (0x100/2): |
| r26062 | r26063 | |
| 2348 | 2419 | int command; |
| 2349 | 2420 | |
| 2350 | 2421 | #if LOG_CMDS |
| 2351 | | seibu_cop_log("%06x: COPX execute table macro command %04x %04x | regs %08x %08x %08x %08x %08x\n", space.device().safe_pc(), data, cop_mcu_ram[offset], cop_register[0], cop_register[1], cop_register[2], cop_register[3], cop_register[4]); |
| 2422 | seibu_cop_log("%06x: COPX execute table macro command %04x %04x | regs %08x %08x %08x %08x %08x\n", space.device().safe_pc(), data, m_cop_mcu_ram[offset], m_cop_register[0], m_cop_register[1], m_cop_register[2], m_cop_register[3], m_cop_register[4]); |
| 2352 | 2423 | #endif |
| 2353 | 2424 | |
| 2354 | 2425 | command = -1; |
| r26062 | r26063 | |
| 2358 | 2429 | it isn't supposed to do anything, especially in the former case (it definitely NEEDS that sprites have an arc movement when they are knocked down). */ |
| 2359 | 2430 | for (i=0;i<32;i++) |
| 2360 | 2431 | { |
| 2361 | | if ((cop_mcu_ram[offset] & 0xff00) == (copd2_table_4[i] & 0xff00)) |
| 2432 | if ((m_cop_mcu_ram[offset] & 0xff00) == (m_copd2_table_4[i] & 0xff00)) |
| 2362 | 2433 | { |
| 2363 | 2434 | #if LOG_CMDS |
| 2364 | | seibu_cop_log(" Cop Command %04x found in slot %02x with other params %04x %04x\n", cop_mcu_ram[offset], i, copd2_table_2[i], copd2_table_3[i]); |
| 2435 | seibu_cop_log(" Cop Command %04x found in slot %02x with other params %04x %04x\n", m_cop_mcu_ram[offset], i, m_copd2_table_2[i], m_copd2_table_3[i]); |
| 2365 | 2436 | #endif |
| 2366 | 2437 | |
| 2367 | | u1 = copd2_table_2[i] & 0x000f; |
| 2368 | | u2 = copd2_table_3[i] & 0xffff; |
| 2438 | m_u1 = m_copd2_table_2[i] & 0x000f; |
| 2439 | m_u2 = m_copd2_table_3[i] & 0xffff; |
| 2369 | 2440 | command = i; |
| 2370 | 2441 | } |
| 2371 | 2442 | } |
| 2372 | 2443 | |
| 2373 | 2444 | if (command==-1) |
| 2374 | 2445 | { |
| 2375 | | seibu_cop_log(" Cop Command %04x NOT IN TABLE!\n", cop_mcu_ram[offset]); |
| 2446 | seibu_cop_log(" Cop Command %04x NOT IN TABLE!\n", m_cop_mcu_ram[offset]); |
| 2376 | 2447 | break; |
| 2377 | 2448 | } |
| 2378 | 2449 | else |
| r26062 | r26063 | |
| 2384 | 2455 | seibu_cop_log(" Sequence: "); |
| 2385 | 2456 | for (j=0;j<0x8;j++) |
| 2386 | 2457 | { |
| 2387 | | seibu_cop_log("%04x ", copd2_table[command+j]); |
| 2458 | seibu_cop_log("%04x ", m_copd2_table[command+j]); |
| 2388 | 2459 | } |
| 2389 | 2460 | seibu_cop_log("\n"); |
| 2390 | 2461 | } |
| 2391 | 2462 | #endif |
| 2392 | 2463 | } |
| 2393 | 2464 | |
| 2394 | | //printf("%04x %04x %04x\n",cop_mcu_ram[offset],u1,u2); |
| 2465 | //printf("%04x %04x %04x\n",m_cop_mcu_ram[offset],m_u1,m_u2); |
| 2395 | 2466 | |
| 2396 | 2467 | /* |
| 2397 | 2468 | Macro notes: |
| r26062 | r26063 | |
| 2415 | 2486 | |
| 2416 | 2487 | offs = (offset & 3) * 4; |
| 2417 | 2488 | |
| 2418 | | space.write_dword(cop_register[0] + 0x04 + offs, space.read_dword(cop_register[0] + 0x04 + offs) + space.read_dword(cop_register[0] + 0x10 + offs)); |
| 2419 | | space.write_dword(cop_register[0] + 0x1c + offs, space.read_dword(cop_register[0] + 0x10 + offs) + space.read_dword(cop_register[0] + 0x1c + offs)); |
| 2489 | space.write_dword(m_cop_register[0] + 0x04 + offs, space.read_dword(m_cop_register[0] + 0x04 + offs) + space.read_dword(m_cop_register[0] + 0x10 + offs)); |
| 2490 | space.write_dword(m_cop_register[0] + 0x1c + offs, space.read_dword(m_cop_register[0] + 0x10 + offs) + space.read_dword(m_cop_register[0] + 0x1c + offs)); |
| 2420 | 2491 | return; |
| 2421 | 2492 | } |
| 2422 | 2493 | |
| r26062 | r26063 | |
| 2431 | 2502 | /* add 0x10 + offs */ |
| 2432 | 2503 | /* write 0x10 + offs */ |
| 2433 | 2504 | |
| 2434 | | space.write_dword(cop_register[0] + 0x10 + offs, space.read_dword(cop_register[0] + 0x10 + offs) + space.read_dword(cop_register[0] + 0x28 + offs)); |
| 2505 | space.write_dword(m_cop_register[0] + 0x10 + offs, space.read_dword(m_cop_register[0] + 0x10 + offs) + space.read_dword(m_cop_register[0] + 0x28 + offs)); |
| 2435 | 2506 | return; |
| 2436 | 2507 | } |
| 2437 | 2508 | |
| r26062 | r26063 | |
| 2449 | 2520 | */ |
| 2450 | 2521 | if(COP_CMD(0xb9a,0xb88,0x888,0x000,0x000,0x000,0x000,0x000,7,0xfdfb)) |
| 2451 | 2522 | { |
| 2452 | | int raw_angle = (space.read_word(cop_register[0]+(0x34^2)) & 0xff); |
| 2523 | int raw_angle = (space.read_word(m_cop_register[0]+(0x34^2)) & 0xff); |
| 2453 | 2524 | double angle = raw_angle * M_PI / 128; |
| 2454 | | double amp = (65536 >> 5)*(space.read_word(cop_register[0]+(0x36^2)) & 0xff); |
| 2525 | double amp = (65536 >> 5)*(space.read_word(m_cop_register[0]+(0x36^2)) & 0xff); |
| 2455 | 2526 | int res; |
| 2456 | 2527 | |
| 2457 | 2528 | /* TODO: up direction, why? */ |
| 2458 | 2529 | if(raw_angle == 0xc0) |
| 2459 | 2530 | amp*=2; |
| 2460 | 2531 | |
| 2461 | | res = int(amp*sin(angle)) << cop_scale; |
| 2532 | res = int(amp*sin(angle)) << m_cop_scale; |
| 2462 | 2533 | |
| 2463 | | space.write_dword(cop_register[0] + 0x10, res); |
| 2534 | space.write_dword(m_cop_register[0] + 0x10, res); |
| 2464 | 2535 | return; |
| 2465 | 2536 | } |
| 2466 | 2537 | |
| r26062 | r26063 | |
| 2478 | 2549 | */ |
| 2479 | 2550 | if(COP_CMD(0xb9a,0xb8a,0x88a,0x000,0x000,0x000,0x000,0x000,7,0xfdfb)) |
| 2480 | 2551 | { |
| 2481 | | int raw_angle = (space.read_word(cop_register[0]+(0x34^2)) & 0xff); |
| 2552 | int raw_angle = (space.read_word(m_cop_register[0]+(0x34^2)) & 0xff); |
| 2482 | 2553 | double angle = raw_angle * M_PI / 128; |
| 2483 | | double amp = (65536 >> 5)*(space.read_word(cop_register[0]+(0x36^2)) & 0xff); |
| 2554 | double amp = (65536 >> 5)*(space.read_word(m_cop_register[0]+(0x36^2)) & 0xff); |
| 2484 | 2555 | int res; |
| 2485 | 2556 | |
| 2486 | 2557 | /* TODO: left direction, why? */ |
| 2487 | 2558 | if(raw_angle == 0x80) |
| 2488 | 2559 | amp*=2; |
| 2489 | 2560 | |
| 2490 | | res = int(amp*cos(angle)) << cop_scale; |
| 2561 | res = int(amp*cos(angle)) << m_cop_scale; |
| 2491 | 2562 | |
| 2492 | | space.write_dword(cop_register[0] + 20, res); |
| 2563 | space.write_dword(m_cop_register[0] + 20, res); |
| 2493 | 2564 | return; |
| 2494 | 2565 | } |
| 2495 | 2566 | |
| 2496 | 2567 | /* 0x130e / 0x138e */ |
| 2497 | 2568 | if(COP_CMD(0x984,0xaa4,0xd82,0xaa2,0x39b,0xb9a,0xb9a,0xa9a,5,0xbf7f)) |
| 2498 | 2569 | { |
| 2499 | | int dy = space.read_dword(cop_register[1]+4) - space.read_dword(cop_register[0]+4); |
| 2500 | | int dx = space.read_dword(cop_register[1]+8) - space.read_dword(cop_register[0]+8); |
| 2570 | int dy = space.read_dword(m_cop_register[1]+4) - space.read_dword(m_cop_register[0]+4); |
| 2571 | int dx = space.read_dword(m_cop_register[1]+8) - space.read_dword(m_cop_register[0]+8); |
| 2501 | 2572 | |
| 2502 | | cop_status = 7; |
| 2573 | m_cop_status = 7; |
| 2503 | 2574 | if(!dx) { |
| 2504 | | cop_status |= 0x8000; |
| 2505 | | cop_angle = 0; |
| 2575 | m_cop_status |= 0x8000; |
| 2576 | m_cop_angle = 0; |
| 2506 | 2577 | } else { |
| 2507 | | cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI; |
| 2578 | m_cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI; |
| 2508 | 2579 | if(dx<0) |
| 2509 | | cop_angle += 0x80; |
| 2580 | m_cop_angle += 0x80; |
| 2510 | 2581 | } |
| 2511 | 2582 | |
| 2512 | | r0 = dy; |
| 2513 | | r1 = dx; |
| 2583 | m_r0 = dy; |
| 2584 | m_r1 = dx; |
| 2514 | 2585 | |
| 2515 | | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
| 2586 | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,m_cop_angle); |
| 2516 | 2587 | |
| 2517 | | if(cop_mcu_ram[offset] & 0x80) |
| 2518 | | space.write_word(cop_register[0]+(0x34^2), cop_angle); |
| 2588 | if(m_cop_mcu_ram[offset] & 0x80) |
| 2589 | space.write_word(m_cop_register[0]+(0x34^2), m_cop_angle); |
| 2519 | 2590 | return; |
| 2520 | 2591 | } |
| 2521 | 2592 | |
| r26062 | r26063 | |
| 2523 | 2594 | //(heatbrl) | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a b9a |
| 2524 | 2595 | if(COP_CMD(0x984,0xaa4,0xd82,0xaa2,0x39b,0xb9a,0xb9a,0xb9a,5,0xbf7f)) |
| 2525 | 2596 | { |
| 2526 | | int dy = space.read_dword(cop_register[1]+4) - space.read_dword(cop_register[0]+4); |
| 2527 | | int dx = space.read_dword(cop_register[1]+8) - space.read_dword(cop_register[0]+8); |
| 2597 | int dy = space.read_dword(m_cop_register[1]+4) - space.read_dword(m_cop_register[0]+4); |
| 2598 | int dx = space.read_dword(m_cop_register[1]+8) - space.read_dword(m_cop_register[0]+8); |
| 2528 | 2599 | |
| 2529 | | cop_status = 7; |
| 2600 | m_cop_status = 7; |
| 2530 | 2601 | if(!dx) { |
| 2531 | | cop_status |= 0x8000; |
| 2532 | | cop_angle = 0; |
| 2602 | m_cop_status |= 0x8000; |
| 2603 | m_cop_angle = 0; |
| 2533 | 2604 | } else { |
| 2534 | | cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI; |
| 2605 | m_cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI; |
| 2535 | 2606 | if(dx<0) |
| 2536 | | cop_angle += 0x80; |
| 2607 | m_cop_angle += 0x80; |
| 2537 | 2608 | } |
| 2538 | 2609 | |
| 2539 | | r0 = dy; |
| 2540 | | r1 = dx; |
| 2610 | m_r0 = dy; |
| 2611 | m_r1 = dx; |
| 2541 | 2612 | |
| 2542 | | if(cop_mcu_ram[offset] & 0x80) |
| 2543 | | space.write_word(cop_register[0]+(0x34^2), cop_angle); |
| 2613 | if(m_cop_mcu_ram[offset] & 0x80) |
| 2614 | space.write_word(m_cop_register[0]+(0x34^2), m_cop_angle); |
| 2544 | 2615 | return; |
| 2545 | 2616 | } |
| 2546 | 2617 | |
| r26062 | r26063 | |
| 2554 | 2625 | */ |
| 2555 | 2626 | if(COP_CMD(0xf9c,0xb9c,0xb9c,0xb9c,0xb9c,0xb9c,0xb9c,0x99c,4,0x007f)) |
| 2556 | 2627 | { |
| 2557 | | int dy = r0; |
| 2558 | | int dx = r1; |
| 2628 | int dy = m_r0; |
| 2629 | int dx = m_r1; |
| 2559 | 2630 | |
| 2560 | 2631 | dx >>= 16; |
| 2561 | 2632 | dy >>= 16; |
| 2562 | | cop_dist = sqrt((double)(dx*dx+dy*dy)); |
| 2633 | m_cop_dist = sqrt((double)(dx*dx+dy*dy)); |
| 2563 | 2634 | |
| 2564 | | if(cop_mcu_ram[offset] & 0x80) |
| 2565 | | space.write_word(cop_register[0]+(0x38), cop_dist); |
| 2635 | if(m_cop_mcu_ram[offset] & 0x80) |
| 2636 | space.write_word(m_cop_register[0]+(0x38), m_cop_dist); |
| 2566 | 2637 | return; |
| 2567 | 2638 | } |
| 2568 | 2639 | |
| r26062 | r26063 | |
| 2579 | 2650 | */ |
| 2580 | 2651 | if(COP_CMD(0xf9a,0xb9a,0xb9c,0xb9c,0xb9c,0x29c,0x000,0x000,5,0xfcdd)) |
| 2581 | 2652 | { |
| 2582 | | int dy = r0; |
| 2583 | | int dx = r1; |
| 2584 | | int div = space.read_word(cop_register[0]+(0x36^2)); |
| 2653 | int dy = m_r0; |
| 2654 | int dx = m_r1; |
| 2655 | int div = space.read_word(m_cop_register[0]+(0x36^2)); |
| 2585 | 2656 | int res; |
| 2586 | | int cop_dist_raw; |
| 2657 | int m_cop_dist_raw; |
| 2587 | 2658 | |
| 2588 | 2659 | if(!div) |
| 2589 | 2660 | { |
| r26062 | r26063 | |
| 2592 | 2663 | } |
| 2593 | 2664 | |
| 2594 | 2665 | /* TODO: calculation of this one should occur at 0x3b30/0x3bb0 I *think* */ |
| 2595 | | /* TODO: recheck if cop_scale still masks at 3 with this command */ |
| 2596 | | dx >>= 11 + cop_scale; |
| 2597 | | dy >>= 11 + cop_scale; |
| 2598 | | cop_dist_raw = sqrt((double)(dx*dx+dy*dy)); |
| 2666 | /* TODO: recheck if m_cop_scale still masks at 3 with this command */ |
| 2667 | dx >>= 11 + m_cop_scale; |
| 2668 | dy >>= 11 + m_cop_scale; |
| 2669 | m_cop_dist_raw = sqrt((double)(dx*dx+dy*dy)); |
| 2599 | 2670 | |
| 2600 | | res = cop_dist_raw; |
| 2671 | res = m_cop_dist_raw; |
| 2601 | 2672 | res /= div; |
| 2602 | 2673 | |
| 2603 | | cop_dist = (1 << (5 - cop_scale)) / div; |
| 2674 | m_cop_dist = (1 << (5 - m_cop_scale)) / div; |
| 2604 | 2675 | |
| 2605 | 2676 | /* TODO: bits 5-6-15 */ |
| 2606 | | cop_status = 7; |
| 2677 | m_cop_status = 7; |
| 2607 | 2678 | |
| 2608 | | space.write_word(cop_register[0]+(0x38^2), res); |
| 2679 | space.write_word(m_cop_register[0]+(0x38^2), res); |
| 2609 | 2680 | return; |
| 2610 | 2681 | } |
| 2611 | 2682 | |
| 2612 | 2683 | /* |
| 2613 | 2684 | collision detection: |
| 2614 | 2685 | |
| 2615 | | int dy_0 = space.read_dword(cop_register[0]+4); |
| 2616 | | int dx_0 = space.read_dword(cop_register[0]+8); |
| 2617 | | int dy_1 = space.read_dword(cop_register[1]+4); |
| 2618 | | int dx_1 = space.read_dword(cop_register[1]+8); |
| 2619 | | int hitbox_param1 = space.read_dword(cop_register[2]); |
| 2620 | | int hitbox_param2 = space.read_dword(cop_register[3]); |
| 2686 | int dy_0 = space.read_dword(m_cop_register[0]+4); |
| 2687 | int dx_0 = space.read_dword(m_cop_register[0]+8); |
| 2688 | int dy_1 = space.read_dword(m_cop_register[1]+4); |
| 2689 | int dx_1 = space.read_dword(m_cop_register[1]+8); |
| 2690 | int hitbox_param1 = space.read_dword(m_cop_register[2]); |
| 2691 | int hitbox_param2 = space.read_dword(m_cop_register[3]); |
| 2621 | 2692 | |
| 2622 | | TODO: we are ignoring the u1 / u2 params for now |
| 2693 | TODO: we are ignoring the m_u1 / m_u2 params for now |
| 2623 | 2694 | */ |
| 2624 | 2695 | |
| 2625 | | if(COP_CMD(0xb80,0xb82,0xb84,0xb86,0x000,0x000,0x000,0x000,u1,u2)) |
| 2696 | if(COP_CMD(0xb80,0xb82,0xb84,0xb86,0x000,0x000,0x000,0x000,m_u1,m_u2)) |
| 2626 | 2697 | { |
| 2627 | | cop_collision_info[0].y = (space.read_dword(cop_register[0]+4)); |
| 2628 | | cop_collision_info[0].x = (space.read_dword(cop_register[0]+8)); |
| 2698 | m_cop_collision_info[0].y = (space.read_dword(m_cop_register[0]+4)); |
| 2699 | m_cop_collision_info[0].x = (space.read_dword(m_cop_register[0]+8)); |
| 2629 | 2700 | return; |
| 2630 | 2701 | } |
| 2631 | 2702 | |
| 2632 | 2703 | //(heatbrl) | 9 | ffff | b080 | b40 bc0 bc2 |
| 2633 | | if(COP_CMD(0xb40,0xbc0,0xbc2,0x000,0x000,0x000,0x000,0x000,u1,u2)) |
| 2704 | if(COP_CMD(0xb40,0xbc0,0xbc2,0x000,0x000,0x000,0x000,0x000,m_u1,m_u2)) |
| 2634 | 2705 | { |
| 2635 | | cop_collision_info[0].hitbox = space.read_word(cop_register[2]); |
| 2636 | | cop_collision_info[0].hitbox_y = space.read_word((cop_register[2]&0xffff0000)|(cop_collision_info[0].hitbox)); |
| 2637 | | cop_collision_info[0].hitbox_x = space.read_word(((cop_register[2]&0xffff0000)|(cop_collision_info[0].hitbox))+2); |
| 2706 | m_cop_collision_info[0].hitbox = space.read_word(m_cop_register[2]); |
| 2707 | m_cop_collision_info[0].hitbox_y = space.read_word((m_cop_register[2]&0xffff0000)|(m_cop_collision_info[0].hitbox)); |
| 2708 | m_cop_collision_info[0].hitbox_x = space.read_word(((m_cop_register[2]&0xffff0000)|(m_cop_collision_info[0].hitbox))+2); |
| 2638 | 2709 | |
| 2639 | 2710 | /* do the math */ |
| 2640 | 2711 | cop_take_hit_box_params(0); |
| 2641 | | cop_hit_status = cop_calculate_collsion_detection(space.machine()); |
| 2712 | m_cop_hit_status = cop_calculate_collsion_detection(); |
| 2642 | 2713 | |
| 2643 | 2714 | return; |
| 2644 | 2715 | } |
| 2645 | 2716 | |
| 2646 | | if(COP_CMD(0xba0,0xba2,0xba4,0xba6,0x000,0x000,0x000,0x000,u1,u2)) |
| 2717 | if(COP_CMD(0xba0,0xba2,0xba4,0xba6,0x000,0x000,0x000,0x000,m_u1,m_u2)) |
| 2647 | 2718 | { |
| 2648 | | cop_collision_info[1].y = (space.read_dword(cop_register[1]+4)); |
| 2649 | | cop_collision_info[1].x = (space.read_dword(cop_register[1]+8)); |
| 2719 | m_cop_collision_info[1].y = (space.read_dword(m_cop_register[1]+4)); |
| 2720 | m_cop_collision_info[1].x = (space.read_dword(m_cop_register[1]+8)); |
| 2650 | 2721 | return; |
| 2651 | 2722 | } |
| 2652 | 2723 | |
| 2653 | 2724 | //(heatbrl) | 6 | ffff | b880 | b60 be0 be2 |
| 2654 | | if(COP_CMD(0xb60,0xbe0,0xbe2,0x000,0x000,0x000,0x000,0x000,u1,u2)) |
| 2725 | if(COP_CMD(0xb60,0xbe0,0xbe2,0x000,0x000,0x000,0x000,0x000,m_u1,m_u2)) |
| 2655 | 2726 | { |
| 2656 | | cop_collision_info[1].hitbox = space.read_word(cop_register[3]); |
| 2657 | | cop_collision_info[1].hitbox_y = space.read_word((cop_register[3]&0xffff0000)|(cop_collision_info[1].hitbox)); |
| 2658 | | cop_collision_info[1].hitbox_x = space.read_word(((cop_register[3]&0xffff0000)|(cop_collision_info[1].hitbox))+2); |
| 2727 | m_cop_collision_info[1].hitbox = space.read_word(m_cop_register[3]); |
| 2728 | m_cop_collision_info[1].hitbox_y = space.read_word((m_cop_register[3]&0xffff0000)|(m_cop_collision_info[1].hitbox)); |
| 2729 | m_cop_collision_info[1].hitbox_x = space.read_word(((m_cop_register[3]&0xffff0000)|(m_cop_collision_info[1].hitbox))+2); |
| 2659 | 2730 | |
| 2660 | 2731 | /* do the math */ |
| 2661 | 2732 | cop_take_hit_box_params(1); |
| 2662 | | cop_hit_status = cop_calculate_collsion_detection(space.machine()); |
| 2733 | m_cop_hit_status = cop_calculate_collsion_detection(); |
| 2663 | 2734 | return; |
| 2664 | 2735 | } |
| 2665 | 2736 | |
| r26062 | r26063 | |
| 2672 | 2743 | offs = (offset & 3) * 4; |
| 2673 | 2744 | |
| 2674 | 2745 | /* TODO: I really suspect that following two are actually taken from the 0xa180 macro command then internally loaded */ |
| 2675 | | abs_x = space.read_word(cop_register[0] + 8) - cop_sprite_dma_abs_x; |
| 2676 | | abs_y = space.read_word(cop_register[0] + 4) - cop_sprite_dma_abs_y; |
| 2677 | | rel_xy = space.read_word(cop_sprite_dma_src + 4 + offs); |
| 2746 | abs_x = space.read_word(m_cop_register[0] + 8) - m_cop_sprite_dma_abs_x; |
| 2747 | abs_y = space.read_word(m_cop_register[0] + 4) - m_cop_sprite_dma_abs_y; |
| 2748 | rel_xy = space.read_word(m_cop_sprite_dma_src + 4 + offs); |
| 2678 | 2749 | |
| 2679 | 2750 | //if(rel_xy & 0x0706) |
| 2680 | 2751 | // printf("sprite rel_xy = %04x\n",rel_xy); |
| 2681 | 2752 | |
| 2682 | 2753 | if(rel_xy & 1) |
| 2683 | | space.write_word(cop_register[4] + offs + 4,0xc0 + abs_x - (rel_xy & 0xf8)); |
| 2754 | space.write_word(m_cop_register[4] + offs + 4,0xc0 + abs_x - (rel_xy & 0xf8)); |
| 2684 | 2755 | else |
| 2685 | | space.write_word(cop_register[4] + offs + 4,(((rel_xy & 0x78) + (abs_x) - ((rel_xy & 0x80) ? 0x80 : 0)))); |
| 2756 | space.write_word(m_cop_register[4] + offs + 4,(((rel_xy & 0x78) + (abs_x) - ((rel_xy & 0x80) ? 0x80 : 0)))); |
| 2686 | 2757 | |
| 2687 | | space.write_word(cop_register[4] + offs + 6,(((rel_xy & 0x7800) >> 8) + (abs_y) - ((rel_xy & 0x8000) ? 0x80 : 0))); |
| 2758 | space.write_word(m_cop_register[4] + offs + 6,(((rel_xy & 0x7800) >> 8) + (abs_y) - ((rel_xy & 0x8000) ? 0x80 : 0))); |
| 2688 | 2759 | return; |
| 2689 | 2760 | } |
| 2690 | 2761 | |
| r26062 | r26063 | |
| 2695 | 2766 | |
| 2696 | 2767 | offs = (offset & 3) * 4; |
| 2697 | 2768 | |
| 2698 | | space.write_word(cop_register[4] + offs + 0,space.read_word(cop_sprite_dma_src + offs) + (cop_sprite_dma_param & 0x3f)); |
| 2699 | | //space.write_word(cop_register[4] + offs + 2,space.read_word(cop_sprite_dma_src+2 + offs)); |
| 2769 | space.write_word(m_cop_register[4] + offs + 0,space.read_word(m_cop_sprite_dma_src + offs) + (m_cop_sprite_dma_param & 0x3f)); |
| 2770 | //space.write_word(m_cop_register[4] + offs + 2,space.read_word(m_cop_sprite_dma_src+2 + offs)); |
| 2700 | 2771 | return; |
| 2701 | 2772 | } |
| 2702 | 2773 | |
| r26062 | r26063 | |
| 2716 | 2787 | /* 8 + [4] */ |
| 2717 | 2788 | /* 4 + [6] */ |
| 2718 | 2789 | |
| 2719 | | //printf("%08x %08x %08x %08x %08x %08x %08x\n",cop_register[0],cop_register[1],cop_register[2],cop_register[3],cop_register[4],cop_register[5],cop_register[6]); |
| 2790 | //printf("%08x %08x %08x %08x %08x %08x %08x\n",m_cop_register[0],m_cop_register[1],m_cop_register[2],m_cop_register[3],m_cop_register[4],m_cop_register[5],m_cop_register[6]); |
| 2720 | 2791 | |
| 2721 | 2792 | offs = (offset & 3) * 4; |
| 2722 | 2793 | |
| 2723 | | div = space.read_word(cop_register[4] + offs) + 1; |
| 2724 | | // offs_val = space.read_word(cop_register[3] + offs); |
| 2794 | div = space.read_word(m_cop_register[4] + offs) + 1; |
| 2795 | // offs_val = space.read_word(m_cop_register[3] + offs); |
| 2725 | 2796 | //420 / 180 = 500 : 400 = 30 / 50 = 98 / 18 |
| 2726 | 2797 | |
| 2727 | 2798 | if(div == 0) { div = 1; } |
| 2728 | 2799 | |
| 2729 | | space.write_word((cop_register[6] + offs + 4), ((space.read_word(cop_register[5] + offs + 4)) / div)); |
| 2800 | space.write_word((m_cop_register[6] + offs + 4), ((space.read_word(m_cop_register[5] + offs + 4)) / div)); |
| 2730 | 2801 | return; |
| 2731 | 2802 | } |
| 2732 | 2803 | |
| r26062 | r26063 | |
| 2741 | 2812 | /* 0 [1] */ |
| 2742 | 2813 | /* 0xc [1] */ |
| 2743 | 2814 | |
| 2744 | | cur_angle = space.read_byte(cop_register[1] + (0xc ^ 3)); |
| 2745 | | //space.write_byte(cop_register[1] + (0^3),space.read_byte(cop_register[1] + (0^3)) & 0xfb); //correct? |
| 2815 | cur_angle = space.read_byte(m_cop_register[1] + (0xc ^ 3)); |
| 2816 | //space.write_byte(m_cop_register[1] + (0^3),space.read_byte(m_cop_register[1] + (0^3)) & 0xfb); //correct? |
| 2746 | 2817 | |
| 2747 | | if(cur_angle >= cop_angle_compare) |
| 2818 | if(cur_angle >= m_cop_angle_compare) |
| 2748 | 2819 | { |
| 2749 | | cur_angle -= cop_angle_mod_val; |
| 2750 | | if(cur_angle <= cop_angle_compare) |
| 2820 | cur_angle -= m_cop_angle_mod_val; |
| 2821 | if(cur_angle <= m_cop_angle_compare) |
| 2751 | 2822 | { |
| 2752 | | cur_angle = cop_angle_compare; |
| 2753 | | //space.write_byte(cop_register[1] + (0^3),space.read_byte(cop_register[1] + (0^3)) | 2); |
| 2823 | cur_angle = m_cop_angle_compare; |
| 2824 | //space.write_byte(m_cop_register[1] + (0^3),space.read_byte(m_cop_register[1] + (0^3)) | 2); |
| 2754 | 2825 | } |
| 2755 | 2826 | } |
| 2756 | | else if(cur_angle <= cop_angle_compare) |
| 2827 | else if(cur_angle <= m_cop_angle_compare) |
| 2757 | 2828 | { |
| 2758 | | cur_angle += cop_angle_mod_val; |
| 2759 | | if(cur_angle >= cop_angle_compare) |
| 2829 | cur_angle += m_cop_angle_mod_val; |
| 2830 | if(cur_angle >= m_cop_angle_compare) |
| 2760 | 2831 | { |
| 2761 | | cur_angle = cop_angle_compare; |
| 2762 | | //space.write_byte(cop_register[1] + (0^3),space.read_byte(cop_register[1] + (0^3)) | 2); |
| 2832 | cur_angle = m_cop_angle_compare; |
| 2833 | //space.write_byte(m_cop_register[1] + (0^3),space.read_byte(m_cop_register[1] + (0^3)) | 2); |
| 2763 | 2834 | } |
| 2764 | 2835 | } |
| 2765 | 2836 | |
| 2766 | | space.write_byte(cop_register[1] + (0xc ^ 3),cur_angle); |
| 2837 | space.write_byte(m_cop_register[1] + (0xc ^ 3),cur_angle); |
| 2767 | 2838 | return; |
| 2768 | 2839 | } |
| 2769 | 2840 | |
| r26062 | r26063 | |
| 2774 | 2845 | { |
| 2775 | 2846 | INT8 cur_angle; |
| 2776 | 2847 | |
| 2777 | | cur_angle = INT8(space.read_byte(cop_register[0] + (0x34 ^ 3))); |
| 2778 | | //space.write_byte(cop_register[0] + (0^3),space.read_byte(cop_register[0] + (0^3)) & 0xfb); //correct? |
| 2848 | cur_angle = INT8(space.read_byte(m_cop_register[0] + (0x34 ^ 3))); |
| 2849 | //space.write_byte(m_cop_register[0] + (0^3),space.read_byte(m_cop_register[0] + (0^3)) & 0xfb); //correct? |
| 2779 | 2850 | /* |
| 2780 | 2851 | 0x00 0x00 0x60 0x00 |
| 2781 | 2852 | 0x00 0x20 0x60 0x20 |
| r26062 | r26063 | |
| 2787 | 2858 | 0x00 0xe0 0x60 0xe0 |
| 2788 | 2859 | */ |
| 2789 | 2860 | |
| 2790 | | if(cur_angle > cop_angle_compare) |
| 2861 | if(cur_angle > m_cop_angle_compare) |
| 2791 | 2862 | { |
| 2792 | | cur_angle -= cop_angle_mod_val; |
| 2863 | cur_angle -= m_cop_angle_mod_val; |
| 2793 | 2864 | |
| 2794 | | if(cur_angle < cop_angle_compare) |
| 2795 | | cur_angle = cop_angle_compare; |
| 2865 | if(cur_angle < m_cop_angle_compare) |
| 2866 | cur_angle = m_cop_angle_compare; |
| 2796 | 2867 | } |
| 2797 | | else if(cur_angle < cop_angle_compare) |
| 2868 | else if(cur_angle < m_cop_angle_compare) |
| 2798 | 2869 | { |
| 2799 | | cur_angle += cop_angle_mod_val; |
| 2870 | cur_angle += m_cop_angle_mod_val; |
| 2800 | 2871 | |
| 2801 | | if(cur_angle > cop_angle_compare) |
| 2802 | | cur_angle = cop_angle_compare; |
| 2872 | if(cur_angle > m_cop_angle_compare) |
| 2873 | cur_angle = m_cop_angle_compare; |
| 2803 | 2874 | } |
| 2804 | 2875 | |
| 2805 | | space.write_byte(cop_register[0] + (0x34 ^ 3),cur_angle); |
| 2876 | space.write_byte(m_cop_register[0] + (0x34 ^ 3),cur_angle); |
| 2806 | 2877 | return; |
| 2807 | 2878 | } |
| 2808 | 2879 | |
| 2809 | 2880 | //(cupsoc) 1c | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a |
| 2810 | 2881 | if(COP_CMD(0x984,0xac4,0xd82,0xac2,0x39b,0xb9a,0xb9a,0xa9a,5,0xb07f)) |
| 2811 | 2882 | { |
| 2812 | | int dy = space.read_dword(cop_register[2]+4) - space.read_dword(cop_register[0]+4); |
| 2813 | | int dx = space.read_dword(cop_register[2]+8) - space.read_dword(cop_register[0]+8); |
| 2883 | int dy = space.read_dword(m_cop_register[2]+4) - space.read_dword(m_cop_register[0]+4); |
| 2884 | int dx = space.read_dword(m_cop_register[2]+8) - space.read_dword(m_cop_register[0]+8); |
| 2814 | 2885 | |
| 2815 | | cop_status = 7; |
| 2886 | m_cop_status = 7; |
| 2816 | 2887 | if(!dx) { |
| 2817 | | cop_status |= 0x8000; |
| 2818 | | cop_angle = 0; |
| 2888 | m_cop_status |= 0x8000; |
| 2889 | m_cop_angle = 0; |
| 2819 | 2890 | } else { |
| 2820 | | cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI; |
| 2891 | m_cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI; |
| 2821 | 2892 | if(dx<0) |
| 2822 | | cop_angle += 0x80; |
| 2893 | m_cop_angle += 0x80; |
| 2823 | 2894 | } |
| 2824 | 2895 | |
| 2825 | | r0 = dy; |
| 2826 | | r1 = dx; |
| 2896 | m_r0 = dy; |
| 2897 | m_r1 = dx; |
| 2827 | 2898 | |
| 2828 | | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
| 2899 | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,m_cop_angle); |
| 2829 | 2900 | |
| 2830 | | if(cop_mcu_ram[offset] & 0x80) |
| 2831 | | space.write_word(cop_register[0]+(0x34^2), cop_angle); |
| 2901 | if(m_cop_mcu_ram[offset] & 0x80) |
| 2902 | space.write_word(m_cop_register[0]+(0x34^2), m_cop_angle); |
| 2832 | 2903 | return; |
| 2833 | 2904 | } |
| 2834 | 2905 | |
| r26062 | r26063 | |
| 2837 | 2908 | if(COP_CMD(0xac2,0x9e0,0x0a2,0x000,0x000,0x000,0x000,0x000,5,0xfffb)) |
| 2838 | 2909 | { |
| 2839 | 2910 | UINT8 *ROM = space.machine().root_device().memregion("maincpu")->base(); |
| 2840 | | UINT32 rom_addr = (cop_rom_addr_hi << 16 | cop_rom_addr_lo) & ~1; |
| 2911 | UINT32 rom_addr = (m_cop_rom_addr_hi << 16 | m_cop_rom_addr_lo) & ~1; |
| 2841 | 2912 | UINT16 rom_data = (ROM[rom_addr + 0]) | (ROM[rom_addr + 1]<<8); |
| 2842 | 2913 | |
| 2843 | 2914 | /* writes to some unemulated COP registers, then puts the result in here, adding a parameter taken from ROM */ |
| 2844 | | //space.write_word(cop_register[0]+(0x44 + offset * 4), rom_data); |
| 2915 | //space.write_word(m_cop_register[0]+(0x44 + offset * 4), rom_data); |
| 2845 | 2916 | |
| 2846 | | printf("%04x%04x %04x %04x\n",cop_rom_addr_hi,cop_rom_addr_lo,cop_rom_addr_unk,rom_data); |
| 2917 | printf("%04x%04x %04x %04x\n",m_cop_rom_addr_hi,m_cop_rom_addr_lo,m_cop_rom_addr_unk,rom_data); |
| 2847 | 2918 | return; |
| 2848 | 2919 | } |
| 2849 | 2920 | |
| 2850 | | printf("%04x\n",cop_mcu_ram[offset]); |
| 2921 | printf("%04x\n",m_cop_mcu_ram[offset]); |
| 2851 | 2922 | break; |
| 2852 | 2923 | } |
| 2853 | 2924 | |
| r26062 | r26063 | |
| 2856 | 2927 | { |
| 2857 | 2928 | //seibu_cop_log("%06x: COPX execute current layer clear??? %04x\n", space.device().safe_pc(), data); |
| 2858 | 2929 | |
| 2859 | | if (cop_dma_trigger >= 0x80 && cop_dma_trigger <= 0x87) |
| 2930 | if (m_cop_dma_trigger >= 0x80 && m_cop_dma_trigger <= 0x87) |
| 2860 | 2931 | { |
| 2861 | 2932 | UINT32 src,dst,size,i; |
| 2862 | 2933 | |
| 2863 | 2934 | /* |
| 2864 | | Apparently all of those are just different DMA channels, brightness effects are done through a RAM table and the pal_brightness_val / mode |
| 2935 | Apparently all of those are just different DMA channels, brightness effects are done through a RAM table and the m_pal_brightness_val / mode |
| 2865 | 2936 | 0x80 is used by Legionnaire |
| 2866 | 2937 | 0x81 is used by SD Gundam and Godzilla |
| 2867 | 2938 | 0x82 is used by Zero Team and X Se Dae |
| r26062 | r26063 | |
| 2875 | 2946 | */ |
| 2876 | 2947 | |
| 2877 | 2948 | //if(dma_trigger != 0x87) |
| 2878 | | //printf("SRC: %08x %08x DST:%08x SIZE:%08x TRIGGER: %08x %02x %02x\n",cop_dma_src[cop_dma_trigger] << 6,cop_dma_fade_table * 0x400,cop_dma_dst[cop_dma_trigger] << 6,cop_dma_size[cop_dma_trigger] << 5,cop_dma_trigger,pal_brightness_val,pal_brightness_mode); |
| 2949 | //printf("SRC: %08x %08x DST:%08x SIZE:%08x TRIGGER: %08x %02x %02x\n",m_cop_dma_src[m_cop_dma_trigger] << 6,m_cop_dma_fade_table * 0x400,m_cop_dma_dst[m_cop_dma_trigger] << 6,m_cop_dma_size[m_cop_dma_trigger] << 5,m_cop_dma_trigger,m_pal_brightness_val,m_pal_brightness_mode); |
| 2879 | 2950 | |
| 2880 | | src = (cop_dma_src[cop_dma_trigger] << 6); |
| 2881 | | dst = (cop_dma_dst[cop_dma_trigger] << 6); |
| 2882 | | size = ((cop_dma_size[cop_dma_trigger] << 5) - (cop_dma_dst[cop_dma_trigger] << 6) + 0x20)/2; |
| 2951 | src = (m_cop_dma_src[m_cop_dma_trigger] << 6); |
| 2952 | dst = (m_cop_dma_dst[m_cop_dma_trigger] << 6); |
| 2953 | size = ((m_cop_dma_size[m_cop_dma_trigger] << 5) - (m_cop_dma_dst[m_cop_dma_trigger] << 6) + 0x20)/2; |
| 2883 | 2954 | |
| 2884 | 2955 | for(i = 0;i < size;i++) |
| 2885 | 2956 | { |
| r26062 | r26063 | |
| 2887 | 2958 | int r,g,b; |
| 2888 | 2959 | int rt,gt,bt; |
| 2889 | 2960 | |
| 2890 | | if(pal_brightness_mode == 5) |
| 2961 | if(m_pal_brightness_mode == 5) |
| 2891 | 2962 | { |
| 2892 | | bt = ((space.read_word(src + (cop_dma_fade_table * 0x400))) & 0x7c00) >> 5; |
| 2893 | | bt = fade_table(bt|(pal_brightness_val ^ 0)); |
| 2963 | bt = ((space.read_word(src + (m_cop_dma_fade_table * 0x400))) & 0x7c00) >> 5; |
| 2964 | bt = fade_table(bt|(m_pal_brightness_val ^ 0)); |
| 2894 | 2965 | b = ((space.read_word(src)) & 0x7c00) >> 5; |
| 2895 | | b = fade_table(b|(pal_brightness_val ^ 0x1f)); |
| 2966 | b = fade_table(b|(m_pal_brightness_val ^ 0x1f)); |
| 2896 | 2967 | pal_val = ((b + bt) & 0x1f) << 10; |
| 2897 | | gt = ((space.read_word(src + (cop_dma_fade_table * 0x400))) & 0x03e0); |
| 2898 | | gt = fade_table(gt|(pal_brightness_val ^ 0)); |
| 2968 | gt = ((space.read_word(src + (m_cop_dma_fade_table * 0x400))) & 0x03e0); |
| 2969 | gt = fade_table(gt|(m_pal_brightness_val ^ 0)); |
| 2899 | 2970 | g = ((space.read_word(src)) & 0x03e0); |
| 2900 | | g = fade_table(g|(pal_brightness_val ^ 0x1f)); |
| 2971 | g = fade_table(g|(m_pal_brightness_val ^ 0x1f)); |
| 2901 | 2972 | pal_val |= ((g + gt) & 0x1f) << 5; |
| 2902 | | rt = ((space.read_word(src + (cop_dma_fade_table * 0x400))) & 0x001f) << 5; |
| 2903 | | rt = fade_table(rt|(pal_brightness_val ^ 0)); |
| 2973 | rt = ((space.read_word(src + (m_cop_dma_fade_table * 0x400))) & 0x001f) << 5; |
| 2974 | rt = fade_table(rt|(m_pal_brightness_val ^ 0)); |
| 2904 | 2975 | r = ((space.read_word(src)) & 0x001f) << 5; |
| 2905 | | r = fade_table(r|(pal_brightness_val ^ 0x1f)); |
| 2976 | r = fade_table(r|(m_pal_brightness_val ^ 0x1f)); |
| 2906 | 2977 | pal_val |= ((r + rt) & 0x1f); |
| 2907 | 2978 | } |
| 2908 | | else if(pal_brightness_mode == 4) //Denjin Makai |
| 2979 | else if(m_pal_brightness_mode == 4) //Denjin Makai |
| 2909 | 2980 | { |
| 2910 | | bt =(space.read_word(src + (cop_dma_fade_table * 0x400)) & 0x7c00) >> 10; |
| 2981 | bt =(space.read_word(src + (m_cop_dma_fade_table * 0x400)) & 0x7c00) >> 10; |
| 2911 | 2982 | b = (space.read_word(src) & 0x7c00) >> 10; |
| 2912 | | gt =(space.read_word(src + (cop_dma_fade_table * 0x400)) & 0x03e0) >> 5; |
| 2983 | gt =(space.read_word(src + (m_cop_dma_fade_table * 0x400)) & 0x03e0) >> 5; |
| 2913 | 2984 | g = (space.read_word(src) & 0x03e0) >> 5; |
| 2914 | | rt =(space.read_word(src + (cop_dma_fade_table * 0x400)) & 0x001f) >> 0; |
| 2985 | rt =(space.read_word(src + (m_cop_dma_fade_table * 0x400)) & 0x001f) >> 0; |
| 2915 | 2986 | r = (space.read_word(src) & 0x001f) >> 0; |
| 2916 | 2987 | |
| 2917 | | if(pal_brightness_val == 0x10) |
| 2988 | if(m_pal_brightness_val == 0x10) |
| 2918 | 2989 | pal_val = bt << 10 | gt << 5 | rt << 0; |
| 2919 | | else if(pal_brightness_val == 0xff) // TODO: might be the back plane or it still doesn't do any mod, needs PCB tests |
| 2990 | else if(m_pal_brightness_val == 0xff) // TODO: might be the back plane or it still doesn't do any mod, needs PCB tests |
| 2920 | 2991 | pal_val = 0; |
| 2921 | 2992 | else |
| 2922 | 2993 | { |
| 2923 | | bt = fade_table(bt<<5|((pal_brightness_val*2) ^ 0)); |
| 2924 | | b = fade_table(b<<5|((pal_brightness_val*2) ^ 0x1f)); |
| 2994 | bt = fade_table(bt<<5|((m_pal_brightness_val*2) ^ 0)); |
| 2995 | b = fade_table(b<<5|((m_pal_brightness_val*2) ^ 0x1f)); |
| 2925 | 2996 | pal_val = ((b + bt) & 0x1f) << 10; |
| 2926 | | gt = fade_table(gt<<5|((pal_brightness_val*2) ^ 0)); |
| 2927 | | g = fade_table(g<<5|((pal_brightness_val*2) ^ 0x1f)); |
| 2997 | gt = fade_table(gt<<5|((m_pal_brightness_val*2) ^ 0)); |
| 2998 | g = fade_table(g<<5|((m_pal_brightness_val*2) ^ 0x1f)); |
| 2928 | 2999 | pal_val |= ((g + gt) & 0x1f) << 5; |
| 2929 | | rt = fade_table(rt<<5|((pal_brightness_val*2) ^ 0)); |
| 2930 | | r = fade_table(r<<5|((pal_brightness_val*2) ^ 0x1f)); |
| 3000 | rt = fade_table(rt<<5|((m_pal_brightness_val*2) ^ 0)); |
| 3001 | r = fade_table(r<<5|((m_pal_brightness_val*2) ^ 0x1f)); |
| 2931 | 3002 | pal_val |= ((r + rt) & 0x1f); |
| 2932 | 3003 | } |
| 2933 | 3004 | } |
| 2934 | 3005 | else |
| 2935 | 3006 | { |
| 2936 | | printf("Warning: palette DMA used with mode %02x!\n",pal_brightness_mode); |
| 3007 | printf("Warning: palette DMA used with mode %02x!\n",m_pal_brightness_mode); |
| 2937 | 3008 | pal_val = space.read_word(src); |
| 2938 | 3009 | } |
| 2939 | 3010 | |
| r26062 | r26063 | |
| 2946 | 3017 | } |
| 2947 | 3018 | |
| 2948 | 3019 | /* Seibu Cup Soccer trigger this*/ |
| 2949 | | if (cop_dma_trigger == 0x0e) |
| 3020 | if (m_cop_dma_trigger == 0x0e) |
| 2950 | 3021 | { |
| 2951 | 3022 | UINT32 src,dst,size,i; |
| 2952 | 3023 | |
| 2953 | | src = (cop_dma_src[cop_dma_trigger] << 6); |
| 2954 | | dst = (cop_dma_dst[cop_dma_trigger] << 6); |
| 2955 | | size = ((cop_dma_size[cop_dma_trigger] << 5) - (cop_dma_dst[cop_dma_trigger] << 6) + 0x20)/2; |
| 3024 | src = (m_cop_dma_src[m_cop_dma_trigger] << 6); |
| 3025 | dst = (m_cop_dma_dst[m_cop_dma_trigger] << 6); |
| 3026 | size = ((m_cop_dma_size[m_cop_dma_trigger] << 5) - (m_cop_dma_dst[m_cop_dma_trigger] << 6) + 0x20)/2; |
| 2956 | 3027 | |
| 2957 | 3028 | for(i = 0;i < size;i++) |
| 2958 | 3029 | { |
| r26062 | r26063 | |
| 2965 | 3036 | } |
| 2966 | 3037 | |
| 2967 | 3038 | /* do the fill */ |
| 2968 | | if (cop_dma_trigger >= 0x118 && cop_dma_trigger <= 0x11f) |
| 3039 | if (m_cop_dma_trigger >= 0x118 && m_cop_dma_trigger <= 0x11f) |
| 2969 | 3040 | { |
| 2970 | 3041 | UINT32 length, address; |
| 2971 | 3042 | int i; |
| 2972 | | if(cop_dma_dst[cop_dma_trigger] != 0x0000) // Invalid? |
| 3043 | if(m_cop_dma_dst[m_cop_dma_trigger] != 0x0000) // Invalid? |
| 2973 | 3044 | return; |
| 2974 | 3045 | |
| 2975 | | address = (cop_dma_src[cop_dma_trigger] << 6); |
| 2976 | | length = (cop_dma_size[cop_dma_trigger]+1) << 5; |
| 3046 | address = (m_cop_dma_src[m_cop_dma_trigger] << 6); |
| 3047 | length = (m_cop_dma_size[m_cop_dma_trigger]+1) << 5; |
| 2977 | 3048 | |
| 2978 | 3049 | //printf("%08x %08x\n",address,length); |
| 2979 | 3050 | |
| 2980 | 3051 | for (i=address;i<address+length;i+=4) |
| 2981 | 3052 | { |
| 2982 | | space.write_dword(i, fill_val); |
| 3053 | space.write_dword(i, m_fill_val); |
| 2983 | 3054 | } |
| 2984 | 3055 | |
| 2985 | 3056 | return; |
| 2986 | 3057 | } |
| 2987 | 3058 | |
| 2988 | 3059 | /* Godzilla specific */ |
| 2989 | | if (cop_dma_trigger == 0x116) |
| 3060 | if (m_cop_dma_trigger == 0x116) |
| 2990 | 3061 | { |
| 2991 | 3062 | UINT32 length, address; |
| 2992 | 3063 | int i; |
| 2993 | 3064 | |
| 2994 | | //if(cop_dma_dst[cop_dma_trigger] != 0x0000) // Invalid? |
| 3065 | //if(m_cop_dma_dst[m_cop_dma_trigger] != 0x0000) // Invalid? |
| 2995 | 3066 | // return; |
| 2996 | 3067 | |
| 2997 | | address = (cop_dma_src[cop_dma_trigger] << 6); |
| 2998 | | length = ((cop_dma_size[cop_dma_trigger]+1) << 4); |
| 3068 | address = (m_cop_dma_src[m_cop_dma_trigger] << 6); |
| 3069 | length = ((m_cop_dma_size[m_cop_dma_trigger]+1) << 4); |
| 2999 | 3070 | |
| 3000 | 3071 | for (i=address;i<address+length;i+=4) |
| 3001 | 3072 | { |
| 3002 | | space.write_dword(i, fill_val); |
| 3073 | space.write_dword(i, m_fill_val); |
| 3003 | 3074 | } |
| 3004 | 3075 | |
| 3005 | 3076 | return; |
| 3006 | 3077 | } |
| 3007 | 3078 | |
| 3008 | 3079 | /* private buffer copies */ |
| 3009 | | if ((cop_dma_trigger==0x14) || (cop_dma_trigger==0x15)) return; |
| 3080 | if ((m_cop_dma_trigger==0x14) || (m_cop_dma_trigger==0x15)) return; |
| 3010 | 3081 | |
| 3011 | | printf("SRC: %08x %08x DST:%08x SIZE:%08x TRIGGER: %08x\n",cop_dma_src[cop_dma_trigger] << 6,cop_dma_fade_table,cop_dma_dst[cop_dma_trigger] << 6,cop_dma_size[cop_dma_trigger] << 5,cop_dma_trigger); |
| 3082 | printf("SRC: %08x %08x DST:%08x SIZE:%08x TRIGGER: %08x\n",m_cop_dma_src[m_cop_dma_trigger] << 6,m_cop_dma_fade_table,m_cop_dma_dst[m_cop_dma_trigger] << 6,m_cop_dma_size[m_cop_dma_trigger] << 5,m_cop_dma_trigger); |
| 3012 | 3083 | |
| 3013 | 3084 | break; |
| 3014 | 3085 | } |
| 3015 | 3086 | |
| 3016 | 3087 | /* sort-DMA, oh my ... */ |
| 3017 | | case (0x054/2): { cop_sort_lookup = (cop_sort_lookup&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 3018 | | case (0x056/2): { cop_sort_lookup = (cop_sort_lookup&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 3019 | | case (0x050/2): { cop_sort_ram_addr = (cop_sort_ram_addr&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
| 3020 | | case (0x052/2): { cop_sort_ram_addr = (cop_sort_ram_addr&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
| 3021 | | case (0x058/2): { cop_sort_param = cop_mcu_ram[offset]; break; } |
| 3088 | case (0x054/2): { m_cop_sort_lookup = (m_cop_sort_lookup&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 3089 | case (0x056/2): { m_cop_sort_lookup = (m_cop_sort_lookup&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 3090 | case (0x050/2): { m_cop_sort_ram_addr = (m_cop_sort_ram_addr&0x0000ffff)|(m_cop_mcu_ram[offset]<<16); break; } |
| 3091 | case (0x052/2): { m_cop_sort_ram_addr = (m_cop_sort_ram_addr&0xffff0000)|(m_cop_mcu_ram[offset]<<0); break; } |
| 3092 | case (0x058/2): { m_cop_sort_param = m_cop_mcu_ram[offset]; break; } |
| 3022 | 3093 | |
| 3023 | 3094 | case (0x2fe/2): |
| 3024 | 3095 | { |
| 3025 | 3096 | UINT16 sort_size; |
| 3026 | 3097 | |
| 3027 | | sort_size = cop_mcu_ram[offset]; |
| 3098 | sort_size = m_cop_mcu_ram[offset]; |
| 3028 | 3099 | |
| 3029 | 3100 | { |
| 3030 | 3101 | int i,j; |
| r26062 | r26063 | |
| 3037 | 3108 | { |
| 3038 | 3109 | for(j=i-2;j<sort_size;j+=2) |
| 3039 | 3110 | { |
| 3040 | | addri = cop_sort_ram_addr+space.read_word(cop_sort_lookup+i); |
| 3041 | | addrj = cop_sort_ram_addr+space.read_word(cop_sort_lookup+j); |
| 3111 | addri = m_cop_sort_ram_addr+space.read_word(m_cop_sort_lookup+i); |
| 3112 | addrj = m_cop_sort_ram_addr+space.read_word(m_cop_sort_lookup+j); |
| 3042 | 3113 | |
| 3043 | 3114 | vali = space.read_word(addri); |
| 3044 | 3115 | valj = space.read_word(addrj); |
| 3045 | 3116 | |
| 3046 | 3117 | //printf("%08x %08x %04x %04x\n",addri,addrj,vali,valj); |
| 3047 | 3118 | |
| 3048 | | switch(cop_sort_param) |
| 3119 | switch(m_cop_sort_param) |
| 3049 | 3120 | { |
| 3050 | 3121 | case 2: xchg_flag = (vali > valj); break; |
| 3051 | 3122 | case 1: xchg_flag = (vali < valj); break; |
| 3052 | 3123 | case 0: xchg_flag = 0; break; /* ??? */ |
| 3053 | | default: xchg_flag = 0; printf("Warning: sort-DMA used with param %02x\n",cop_sort_param); break; |
| 3124 | default: xchg_flag = 0; printf("Warning: sort-DMA used with param %02x\n",m_cop_sort_param); break; |
| 3054 | 3125 | } |
| 3055 | 3126 | |
| 3056 | 3127 | if(xchg_flag) |
| 3057 | 3128 | { |
| 3058 | 3129 | UINT16 xch_val; |
| 3059 | 3130 | |
| 3060 | | xch_val = space.read_word(cop_sort_lookup+i); |
| 3061 | | space.write_word(cop_sort_lookup+i,space.read_word(cop_sort_lookup+j)); |
| 3062 | | space.write_word(cop_sort_lookup+j,xch_val); |
| 3131 | xch_val = space.read_word(m_cop_sort_lookup+i); |
| 3132 | space.write_word(m_cop_sort_lookup+i,space.read_word(m_cop_sort_lookup+j)); |
| 3133 | space.write_word(m_cop_sort_lookup+j,xch_val); |
| 3063 | 3134 | } |
| 3064 | 3135 | } |
| 3065 | 3136 | } |
| r26062 | r26063 | |
| 3075 | 3146 | Heated Barrel |
| 3076 | 3147 | **********************************************************************************************/ |
| 3077 | 3148 | |
| 3078 | | READ16_HANDLER( heatbrl_mcu_r ) |
| 3149 | READ16_MEMBER( seibu_cop_legacy_device::heatbrl_mcu_r ) |
| 3079 | 3150 | { |
| 3080 | 3151 | if(offset >= 0x3c0/2 && offset <= 0x3df/2) |
| 3081 | 3152 | return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff); |
| r26062 | r26063 | |
| 3090 | 3161 | return generic_cop_r(space, offset, mem_mask); |
| 3091 | 3162 | } |
| 3092 | 3163 | |
| 3093 | | WRITE16_HANDLER( heatbrl_mcu_w ) |
| 3164 | WRITE16_MEMBER( seibu_cop_legacy_device::heatbrl_mcu_w ) |
| 3094 | 3165 | { |
| 3095 | | get_ram(space.machine()); |
| 3096 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 3166 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 3097 | 3167 | |
| 3098 | 3168 | /* external pin register, used for banking */ |
| 3099 | 3169 | if(offset == 0x070/2) |
| 3100 | 3170 | { |
| 3101 | | heatbrl_setgfxbank(space.machine(), cop_mcu_ram[offset]); |
| 3171 | heatbrl_setgfxbank(space.machine(), m_cop_mcu_ram[offset]); |
| 3102 | 3172 | return; |
| 3103 | 3173 | } |
| 3104 | 3174 | |
| r26062 | r26063 | |
| 3107 | 3177 | |
| 3108 | 3178 | if(offset >= 0x240/2 && offset <= 0x28f/2) |
| 3109 | 3179 | { |
| 3110 | | seibu_common_video_regs_w(space,offset-0x240/2,cop_mcu_ram[offset],mem_mask); |
| 3180 | seibu_common_video_regs_w(space,offset-0x240/2,m_cop_mcu_ram[offset],mem_mask); |
| 3111 | 3181 | return; |
| 3112 | 3182 | } |
| 3113 | 3183 | |
| 3114 | 3184 | if(offset >= 0x3c0/2 && offset <= 0x3df/2) |
| 3115 | 3185 | { |
| 3116 | | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff); |
| 3186 | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,m_cop_mcu_ram[offset],0x00ff); |
| 3117 | 3187 | return; |
| 3118 | 3188 | } |
| 3119 | 3189 | |
| r26062 | r26063 | |
| 3126 | 3196 | Seibu Cup Soccer |
| 3127 | 3197 | **********************************************************************************************/ |
| 3128 | 3198 | |
| 3129 | | READ16_HANDLER( cupsoc_mcu_r ) |
| 3199 | READ16_MEMBER( seibu_cop_legacy_device::cupsoc_mcu_r ) |
| 3130 | 3200 | { |
| 3131 | 3201 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3132 | 3202 | return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff); |
| r26062 | r26063 | |
| 3146 | 3216 | return generic_cop_r(space, offset, mem_mask); |
| 3147 | 3217 | } |
| 3148 | 3218 | |
| 3149 | | WRITE16_HANDLER( cupsoc_mcu_w ) |
| 3219 | WRITE16_MEMBER( seibu_cop_legacy_device::cupsoc_mcu_w ) |
| 3150 | 3220 | { |
| 3151 | | get_ram(space.machine()); |
| 3152 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 3221 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 3153 | 3222 | |
| 3154 | 3223 | if(offset == 0x280/2) //irq ack / sprite buffering? |
| 3155 | 3224 | return; |
| 3156 | 3225 | |
| 3157 | 3226 | if(offset >= 0x200/2 && offset <= 0x24f/2) |
| 3158 | 3227 | { |
| 3159 | | seibu_common_video_regs_w(space,offset-0x200/2,cop_mcu_ram[offset],mem_mask); |
| 3228 | seibu_common_video_regs_w(space,offset-0x200/2,m_cop_mcu_ram[offset],mem_mask); |
| 3160 | 3229 | return; |
| 3161 | 3230 | } |
| 3162 | 3231 | |
| 3163 | 3232 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3164 | 3233 | { |
| 3165 | | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff); |
| 3234 | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,m_cop_mcu_ram[offset],0x00ff); |
| 3166 | 3235 | return; |
| 3167 | 3236 | } |
| 3168 | 3237 | |
| 3169 | 3238 | generic_cop_w(space, offset, data, mem_mask); |
| 3170 | 3239 | } |
| 3171 | 3240 | |
| 3172 | | READ16_HANDLER( cupsocs_mcu_r ) |
| 3241 | READ16_MEMBER( seibu_cop_legacy_device::cupsocs_mcu_r ) |
| 3173 | 3242 | { |
| 3174 | 3243 | if(offset >= 0x340/2 && offset <= 0x35f/2) |
| 3175 | 3244 | return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff); |
| r26062 | r26063 | |
| 3189 | 3258 | return generic_cop_r(space, offset, mem_mask); |
| 3190 | 3259 | } |
| 3191 | 3260 | |
| 3192 | | WRITE16_HANDLER( cupsocs_mcu_w ) |
| 3261 | WRITE16_MEMBER( seibu_cop_legacy_device::cupsocs_mcu_w ) |
| 3193 | 3262 | { |
| 3194 | | get_ram(space.machine()); |
| 3195 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 3263 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 3196 | 3264 | |
| 3197 | 3265 | if(offset == 0x280/2) //irq ack / sprite buffering? |
| 3198 | 3266 | return; |
| 3199 | 3267 | |
| 3200 | 3268 | if(offset >= 0x240/2 && offset <= 0x27f/2) |
| 3201 | 3269 | { |
| 3202 | | seibu_common_video_regs_w(space,offset-0x240/2,cop_mcu_ram[offset],mem_mask); |
| 3270 | seibu_common_video_regs_w(space,offset-0x240/2,m_cop_mcu_ram[offset],mem_mask); |
| 3203 | 3271 | return; |
| 3204 | 3272 | } |
| 3205 | 3273 | |
| 3206 | 3274 | if(offset >= 0x200/2 && offset <= 0x20f/2) |
| 3207 | 3275 | { |
| 3208 | | seibu_common_video_regs_w(space,(offset-0x200/2)+(0x40/2),cop_mcu_ram[offset],mem_mask); |
| 3276 | seibu_common_video_regs_w(space,(offset-0x200/2)+(0x40/2),m_cop_mcu_ram[offset],mem_mask); |
| 3209 | 3277 | return; |
| 3210 | 3278 | } |
| 3211 | 3279 | |
| 3212 | 3280 | if(offset >= 0x340/2 && offset <= 0x35f/2) |
| 3213 | 3281 | { |
| 3214 | | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff); |
| 3282 | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,m_cop_mcu_ram[offset],0x00ff); |
| 3215 | 3283 | return; |
| 3216 | 3284 | } |
| 3217 | 3285 | |
| r26062 | r26063 | |
| 3222 | 3290 | Godzilla |
| 3223 | 3291 | **********************************************************************************************/ |
| 3224 | 3292 | |
| 3225 | | READ16_HANDLER( godzilla_mcu_r ) |
| 3293 | READ16_MEMBER( seibu_cop_legacy_device::godzilla_mcu_r ) |
| 3226 | 3294 | { |
| 3227 | 3295 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3228 | 3296 | return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff); |
| r26062 | r26063 | |
| 3237 | 3305 | return generic_cop_r(space, offset, mem_mask); |
| 3238 | 3306 | } |
| 3239 | 3307 | |
| 3240 | | WRITE16_HANDLER( godzilla_mcu_w ) |
| 3308 | WRITE16_MEMBER( seibu_cop_legacy_device::godzilla_mcu_w ) |
| 3241 | 3309 | { |
| 3242 | | get_ram(space.machine()); |
| 3243 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 3310 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 3244 | 3311 | |
| 3245 | 3312 | if(offset == 0x070/2) |
| 3246 | 3313 | { |
| 3247 | | denjinmk_setgfxbank(space.machine(), cop_mcu_ram[offset]); |
| 3314 | denjinmk_setgfxbank(space.machine(), m_cop_mcu_ram[offset]); |
| 3248 | 3315 | return; |
| 3249 | 3316 | } |
| 3250 | 3317 | |
| r26062 | r26063 | |
| 3253 | 3320 | |
| 3254 | 3321 | if(offset >= 0x200/2 && offset <= 0x24f/2) |
| 3255 | 3322 | { |
| 3256 | | seibu_common_video_regs_w(space,offset-0x200/2,cop_mcu_ram[offset],mem_mask); |
| 3323 | seibu_common_video_regs_w(space,offset-0x200/2,m_cop_mcu_ram[offset],mem_mask); |
| 3257 | 3324 | return; |
| 3258 | 3325 | } |
| 3259 | 3326 | |
| 3260 | 3327 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3261 | 3328 | { |
| 3262 | | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff); |
| 3329 | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,m_cop_mcu_ram[offset],0x00ff); |
| 3263 | 3330 | return; |
| 3264 | 3331 | } |
| 3265 | 3332 | |
| r26062 | r26063 | |
| 3270 | 3337 | Denjin Makai |
| 3271 | 3338 | **********************************************************************************************/ |
| 3272 | 3339 | |
| 3273 | | READ16_HANDLER( denjinmk_mcu_r ) |
| 3340 | READ16_MEMBER( seibu_cop_legacy_device::denjinmk_mcu_r ) |
| 3274 | 3341 | { |
| 3275 | 3342 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3276 | 3343 | return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff); |
| r26062 | r26063 | |
| 3290 | 3357 | return generic_cop_r(space, offset, mem_mask); |
| 3291 | 3358 | } |
| 3292 | 3359 | |
| 3293 | | WRITE16_HANDLER( denjinmk_mcu_w ) |
| 3360 | WRITE16_MEMBER( seibu_cop_legacy_device::denjinmk_mcu_w ) |
| 3294 | 3361 | { |
| 3295 | | get_ram(space.machine()); |
| 3296 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 3362 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 3297 | 3363 | |
| 3298 | 3364 | if(offset == 0x280/2) //irq ack / sprite buffering? |
| 3299 | 3365 | return; |
| 3300 | 3366 | |
| 3301 | 3367 | if(offset == 0x070/2) |
| 3302 | 3368 | { |
| 3303 | | denjinmk_setgfxbank(space.machine(), cop_mcu_ram[offset]); |
| 3369 | denjinmk_setgfxbank(space.machine(), m_cop_mcu_ram[offset]); |
| 3304 | 3370 | return; |
| 3305 | 3371 | } |
| 3306 | 3372 | |
| 3307 | 3373 | if(offset >= 0x200/2 && offset <= 0x24f/2) |
| 3308 | 3374 | { |
| 3309 | | seibu_common_video_regs_w(space,offset-0x200/2,cop_mcu_ram[offset],mem_mask); |
| 3375 | seibu_common_video_regs_w(space,offset-0x200/2,m_cop_mcu_ram[offset],mem_mask); |
| 3310 | 3376 | return; |
| 3311 | 3377 | } |
| 3312 | 3378 | |
| 3313 | 3379 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3314 | 3380 | { |
| 3315 | | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff); |
| 3381 | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,m_cop_mcu_ram[offset],0x00ff); |
| 3316 | 3382 | return; |
| 3317 | 3383 | } |
| 3318 | 3384 | |
| r26062 | r26063 | |
| 3323 | 3389 | SD Gundam Sangokushi Rainbow Tairiku Senki |
| 3324 | 3390 | **********************************************************************************************/ |
| 3325 | 3391 | |
| 3326 | | READ16_HANDLER( grainbow_mcu_r ) |
| 3392 | READ16_MEMBER( seibu_cop_legacy_device::grainbow_mcu_r ) |
| 3327 | 3393 | { |
| 3328 | 3394 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3329 | 3395 | return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff); |
| r26062 | r26063 | |
| 3344 | 3410 | } |
| 3345 | 3411 | |
| 3346 | 3412 | |
| 3347 | | WRITE16_HANDLER( grainbow_mcu_w ) |
| 3413 | WRITE16_MEMBER( seibu_cop_legacy_device::grainbow_mcu_w ) |
| 3348 | 3414 | { |
| 3349 | | get_ram(space.machine()); |
| 3350 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 3415 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 3351 | 3416 | |
| 3352 | 3417 | if(offset == 0x280/2) //irq ack / sprite buffering? |
| 3353 | 3418 | return; |
| 3354 | 3419 | |
| 3355 | 3420 | if(offset >= 0x200/2 && offset <= 0x24f/2) |
| 3356 | 3421 | { |
| 3357 | | seibu_common_video_regs_w(space,offset-0x200/2,cop_mcu_ram[offset],mem_mask); |
| 3422 | seibu_common_video_regs_w(space,offset-0x200/2,m_cop_mcu_ram[offset],mem_mask); |
| 3358 | 3423 | return; |
| 3359 | 3424 | } |
| 3360 | 3425 | |
| 3361 | 3426 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3362 | 3427 | { |
| 3363 | | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff); |
| 3428 | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,m_cop_mcu_ram[offset],0x00ff); |
| 3364 | 3429 | return; |
| 3365 | 3430 | } |
| 3366 | 3431 | |
| r26062 | r26063 | |
| 3372 | 3437 | **********************************************************************************************/ |
| 3373 | 3438 | |
| 3374 | 3439 | |
| 3375 | | READ16_HANDLER( legionna_mcu_r ) |
| 3440 | READ16_MEMBER( seibu_cop_legacy_device::legionna_mcu_r ) |
| 3376 | 3441 | { |
| 3377 | 3442 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3378 | 3443 | return space.machine().device<seibu_sound_device>("seibu_sound")->main_word_r(space,(offset >> 1) & 7,0xffff); |
| r26062 | r26063 | |
| 3387 | 3452 | return generic_cop_r(space, offset, mem_mask); |
| 3388 | 3453 | } |
| 3389 | 3454 | |
| 3390 | | WRITE16_HANDLER( legionna_mcu_w ) |
| 3455 | WRITE16_MEMBER( seibu_cop_legacy_device::legionna_mcu_w ) |
| 3391 | 3456 | { |
| 3392 | | get_ram(space.machine()); |
| 3393 | | COMBINE_DATA(&cop_mcu_ram[offset]); |
| 3457 | COMBINE_DATA(&m_cop_mcu_ram[offset]); |
| 3394 | 3458 | |
| 3395 | 3459 | if(offset == 0x070/2) //external pin: puts bit 13 high, delay, reads 0x748, writes bit 13 low |
| 3396 | 3460 | return; |
| r26062 | r26063 | |
| 3400 | 3464 | |
| 3401 | 3465 | if(offset >= 0x200/2 && offset <= 0x24f/2) |
| 3402 | 3466 | { |
| 3403 | | seibu_common_video_regs_w(space,offset-0x200/2,cop_mcu_ram[offset],mem_mask); |
| 3467 | seibu_common_video_regs_w(space,offset-0x200/2,m_cop_mcu_ram[offset],mem_mask); |
| 3404 | 3468 | return; |
| 3405 | 3469 | } |
| 3406 | 3470 | |
| 3407 | 3471 | if(offset >= 0x300/2 && offset <= 0x31f/2) |
| 3408 | 3472 | { |
| 3409 | | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,cop_mcu_ram[offset],0x00ff); |
| 3473 | space.machine().device<seibu_sound_device>("seibu_sound")->main_word_w(space,(offset >> 1) & 7,m_cop_mcu_ram[offset],0x00ff); |
| 3410 | 3474 | return; |
| 3411 | 3475 | } |
| 3412 | 3476 | |