trunk/src/mame/drivers/legionna.c
| r32339 | r32340 | |
| 97 | 97 | AM_RANGE(0x100412, 0x100413) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sprite_dma_src_hi_w) // grainbow |
| 98 | 98 | AM_RANGE(0x100414, 0x100415) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sprite_dma_src_lo_w) // grainbow |
| 99 | 99 | |
| 100 | | // AM_RANGE(0x10041c, 0x10041d) AM_WRITE(cop_angle_target_w) // angle target (for 0x6200 COP macro) // ADD ME |
| 101 | | // AM_RANGE(0x10041e, 0x10041f) AM_WRITE(cop_angle_step_w) // angle step (for 0x6200 COP macro) // ADD ME |
| 102 | | AM_RANGE(0x10041c, 0x10041d) AM_DEVWRITE("raiden2cop", raiden2cop_device, LEGACY_cop_angle_compare_w) // angle target (for 0x6200 COP macro) // REMOVE ME |
| 103 | | AM_RANGE(0x10041e, 0x10041f) AM_DEVWRITE("raiden2cop", raiden2cop_device, LEGACY_cop_angle_mod_val_w) // angle step (for 0x6200 COP macro) // REMOVE ME |
| 100 | AM_RANGE(0x10041c, 0x10041d) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_angle_target_w) // angle target (for 0x6200 COP macro) |
| 101 | AM_RANGE(0x10041e, 0x10041f) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_angle_step_w) // angle step (for 0x6200 COP macro) |
| 104 | 102 | |
| 105 | 103 | AM_RANGE(0x100420, 0x100421) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_low_w) |
| 106 | 104 | AM_RANGE(0x100422, 0x100423) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_high_w) |
trunk/src/mame/machine/raiden2cop.c
| r32339 | r32340 | |
| 56 | 56 | m_cop_sprite_dma_abs_x(0), |
| 57 | 57 | m_cop_sprite_dma_abs_y(0), |
| 58 | 58 | |
| 59 | | m_LEGACY_cop_angle_compare(0), |
| 60 | | m_LEGACY_cop_angle_mod_val(0), |
| 61 | 59 | m_LEGACY_cop_hit_val_x(0), |
| 62 | 60 | m_LEGACY_cop_hit_val_y(0), |
| 63 | 61 | m_LEGACY_m_cop_hit_val_z(0), |
| r32339 | r32340 | |
| 163 | 161 | save_item(NAME(m_cop_sprite_dma_abs_y)); |
| 164 | 162 | |
| 165 | 163 | // legacy |
| 166 | | save_item(NAME(m_LEGACY_cop_angle_compare)); |
| 167 | | save_item(NAME(m_LEGACY_cop_angle_mod_val)); |
| 168 | 164 | save_item(NAME(m_LEGACY_cop_hit_val_x)); |
| 169 | 165 | save_item(NAME(m_LEGACY_cop_hit_val_y)); |
| 170 | 166 | save_item(NAME(m_LEGACY_m_cop_hit_val_z)); |
| r32339 | r32340 | |
| 1206 | 1202 | /*------------------------------------------------------------------------------------------------------------------------------------------------*/ |
| 1207 | 1203 | |
| 1208 | 1204 | |
| 1209 | | WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_angle_compare_w) |
| 1210 | | { |
| 1211 | | m_LEGACY_cop_angle_compare = UINT16(data); |
| 1212 | | } |
| 1213 | 1205 | |
| 1214 | | WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_angle_mod_val_w) |
| 1215 | | { |
| 1216 | | m_LEGACY_cop_angle_mod_val = UINT16(data); |
| 1217 | | } |
| 1218 | | |
| 1219 | 1206 | READ16_MEMBER( raiden2cop_device::LEGACY_cop_collision_status_val_r) |
| 1220 | 1207 | { |
| 1221 | 1208 | /* these two controls facing direction in Godzilla opponents (only vs.) - x value compare? */ |
| r32339 | r32340 | |
| 1704 | 1691 | flags = space.read_word(cop_regs[1]); |
| 1705 | 1692 | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 1706 | 1693 | |
| 1707 | | m_LEGACY_cop_angle_compare &= 0xff; |
| 1708 | | m_LEGACY_cop_angle_mod_val &= 0xff; |
| 1694 | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 1695 | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 1696 | |
| 1697 | tempangle_compare &= 0xff; |
| 1698 | tempangle_mod_val &= 0xff; |
| 1699 | |
| 1700 | cop_angle_target = tempangle_compare; |
| 1701 | cop_angle_step = tempangle_mod_val; |
| 1702 | |
| 1709 | 1703 | flags &= ~0x0004; |
| 1710 | 1704 | |
| 1711 | | int delta = cur_angle - m_LEGACY_cop_angle_compare; |
| 1705 | int delta = cur_angle - tempangle_compare; |
| 1712 | 1706 | if (delta >= 128) |
| 1713 | 1707 | delta -= 256; |
| 1714 | 1708 | else if (delta < -128) |
| 1715 | 1709 | delta += 256; |
| 1716 | 1710 | if (delta < 0) |
| 1717 | 1711 | { |
| 1718 | | if (delta >= -m_LEGACY_cop_angle_mod_val) |
| 1712 | if (delta >= -tempangle_mod_val) |
| 1719 | 1713 | { |
| 1720 | | cur_angle = m_LEGACY_cop_angle_compare; |
| 1714 | cur_angle = tempangle_compare; |
| 1721 | 1715 | flags |= 0x0004; |
| 1722 | 1716 | } |
| 1723 | 1717 | else |
| 1724 | | cur_angle += m_LEGACY_cop_angle_mod_val; |
| 1718 | cur_angle += tempangle_mod_val; |
| 1725 | 1719 | } |
| 1726 | 1720 | else |
| 1727 | 1721 | { |
| 1728 | | if (delta <= m_LEGACY_cop_angle_mod_val) |
| 1722 | if (delta <= tempangle_mod_val) |
| 1729 | 1723 | { |
| 1730 | | cur_angle = m_LEGACY_cop_angle_compare; |
| 1724 | cur_angle = tempangle_compare; |
| 1731 | 1725 | flags |= 0x0004; |
| 1732 | 1726 | } |
| 1733 | 1727 | else |
| 1734 | | cur_angle -= m_LEGACY_cop_angle_mod_val; |
| 1728 | cur_angle -= tempangle_mod_val; |
| 1735 | 1729 | } |
| 1736 | 1730 | |
| 1737 | 1731 | space.write_byte(cop_regs[1] + (0 ^ 2), flags); |
| r32339 | r32340 | |
| 1752 | 1746 | flags = space.read_word(cop_regs[0] + (0 ^ 2)); |
| 1753 | 1747 | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 1754 | 1748 | |
| 1755 | | m_LEGACY_cop_angle_compare &= 0xff; |
| 1756 | | m_LEGACY_cop_angle_mod_val &= 0xff; |
| 1749 | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 1750 | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 1751 | |
| 1752 | tempangle_compare &= 0xff; |
| 1753 | tempangle_mod_val &= 0xff; |
| 1754 | |
| 1755 | cop_angle_target = tempangle_compare; |
| 1756 | cop_angle_step = tempangle_mod_val; |
| 1757 | |
| 1758 | |
| 1757 | 1759 | flags &= ~0x0004; |
| 1758 | 1760 | |
| 1759 | | int delta = cur_angle - m_LEGACY_cop_angle_compare; |
| 1761 | int delta = cur_angle - tempangle_compare; |
| 1760 | 1762 | if (delta >= 128) |
| 1761 | 1763 | delta -= 256; |
| 1762 | 1764 | else if (delta < -128) |
| 1763 | 1765 | delta += 256; |
| 1764 | 1766 | if (delta < 0) |
| 1765 | 1767 | { |
| 1766 | | if (delta >= -m_LEGACY_cop_angle_mod_val) |
| 1768 | if (delta >= -tempangle_mod_val) |
| 1767 | 1769 | { |
| 1768 | | cur_angle = m_LEGACY_cop_angle_compare; |
| 1770 | cur_angle = tempangle_compare; |
| 1769 | 1771 | flags |= 0x0004; |
| 1770 | 1772 | } |
| 1771 | 1773 | else |
| 1772 | | cur_angle += m_LEGACY_cop_angle_mod_val; |
| 1774 | cur_angle += tempangle_mod_val; |
| 1773 | 1775 | } |
| 1774 | 1776 | else |
| 1775 | 1777 | { |
| 1776 | | if (delta <= m_LEGACY_cop_angle_mod_val) |
| 1778 | if (delta <= tempangle_mod_val) |
| 1777 | 1779 | { |
| 1778 | | cur_angle = m_LEGACY_cop_angle_compare; |
| 1780 | cur_angle = tempangle_compare; |
| 1779 | 1781 | flags |= 0x0004; |
| 1780 | 1782 | } |
| 1781 | 1783 | else |
| 1782 | | cur_angle -= m_LEGACY_cop_angle_mod_val; |
| 1784 | cur_angle -= tempangle_mod_val; |
| 1783 | 1785 | } |
| 1784 | 1786 | |
| 1785 | 1787 | space.write_byte(cop_regs[0] + (0 ^ 3), flags); |