trunk/src/mame/machine/raiden2cop.c
| r32349 | r32350 | |
| 754 | 754 | ## - trig (masked) : (sq0, sq1, sq2, sq3, sq4, sq5, sq6, sq7) valu mask |
| 755 | 755 | 00 - 0205 (0205 ) : (188, 282, 082, b8e, 98e, 000, 000, 000) 6 ffeb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 756 | 756 | 00 - 0105 (0105 ) : (180, 2e0, 0a0, 000, 000, 000, 000, 000) 6 fffb (zeroteamsr) |
| 757 | */ |
| 758 | void raiden2cop_device::execute_0205(address_space &space, int offset, UINT16 data) |
| 759 | { |
| 760 | int ppos = space.read_dword(cop_regs[0] + 4 + offset * 4); |
| 761 | int npos = ppos + space.read_dword(cop_regs[0] + 0x10 + offset * 4); |
| 762 | int delta = (npos >> 16) - (ppos >> 16); |
| 763 | space.write_dword(cop_regs[0] + 4 + offset * 4, npos); |
| 764 | space.write_word(cop_regs[0] + 0x1e + offset * 4, space.read_word(cop_regs[0] + 0x1e + offset * 4) + delta); |
| 765 | } |
| 757 | 766 | |
| 767 | /* |
| 758 | 768 | 01 - 0905 (0905 ) : (194, 288, 088, 000, 000, 000, 000, 000) 6 fbfb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 759 | 769 | 01 - 0b05 (0b05 ) : (180, 2e0, 0a0, 182, 2e0, 0c0, 000, 000) 6 ffdb (zeroteamsr) |
| 770 | */ |
| 760 | 771 | |
| 772 | // triggered with 0904 0905 |
| 773 | /* X Se Dae and Zero Team uses this variant */ |
| 774 | void raiden2cop_device::execute_0904(address_space &space, int offset, UINT16 data) |
| 775 | { |
| 776 | space.write_dword(cop_regs[0] + 16 + offset * 4, space.read_dword(cop_regs[0] + 16 + offset * 4) - space.read_dword(cop_regs[0] + 0x28 + offset * 4)); |
| 777 | } |
| 778 | |
| 779 | void raiden2cop_device::execute_0905(address_space &space, int offset, UINT16 data) |
| 780 | { |
| 781 | space.write_dword(cop_regs[0] + 16 + offset * 4, space.read_dword(cop_regs[0] + 16 + offset * 4) + space.read_dword(cop_regs[0] + 0x28 + offset * 4)); |
| 782 | } |
| 783 | |
| 784 | |
| 785 | /* |
| 761 | 786 | 02 - 138e (130e ) : (984, aa4, d82, aa2, 39b, b9a, b9a, b9a) 5 bf7f (heatbrl, legionna) |
| 762 | 787 | 02 - 138e (130e ) : (984, aa4, d82, aa2, 39b, b9a, b9a, a9a) 5 bf7f (cupsoc, godzilla, grainbow, denjinmk) |
| 763 | 788 | 02 - 130e (130e ) : (984, aa4, d82, aa2, 39b, b9a, b9a, a9a) 5 bf7f (raiden2, raidendx, zeroteam, xsedae) |
| 789 | */ |
| 764 | 790 | |
| 791 | // triggered with 130e, 138e |
| 792 | void raiden2cop_device::execute_130e(address_space &space, int offset, UINT16 data) |
| 793 | { |
| 794 | // this can't be right |
| 795 | execute_338e(space, offset, data); |
| 796 | } |
| 797 | |
| 798 | /* |
| 765 | 799 | 03 - 1905 (1905 ) : (994, a88, 088, 000, 000, 000, 000, 000) 6 fbfb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 800 | */ |
| 766 | 801 | |
| 802 | /* |
| 767 | 803 | 04 - 2288 (2208 ) : (f8a, b8a, 388, b9c, b9a, a9a, 000, 000) 5 f5df (heatbrl, legionna) |
| 768 | 804 | 04 - 2288 (2208 ) : (f8a, b8a, 388, b9a, b9a, a9a, 000, 000) 5 f5df (cupsoc, godzilla, grainbow, denjinmk) |
| 769 | 805 | 04 - 2208 (2208 ) : (f8a, b8a, 388, b9a, b9a, a9a, 000, 000) 5 f5df (raiden2, raidendx, zeroteam, xsedae) |
| 806 | */ |
| 770 | 807 | |
| 808 | // also triggered with 0x2208 |
| 809 | void raiden2cop_device::execute_2288(address_space &space, int offset, UINT16 data) |
| 810 | { |
| 811 | int dx = space.read_word(cop_regs[0] + 0x12); |
| 812 | int dy = space.read_word(cop_regs[0] + 0x16); |
| 813 | |
| 814 | if (!dy) { |
| 815 | cop_status |= 0x8000; |
| 816 | cop_angle = 0; |
| 817 | } |
| 818 | else { |
| 819 | cop_angle = atan(double(dx) / double(dy)) * 128 / M_PI; |
| 820 | if (dy < 0) |
| 821 | cop_angle += 0x80; |
| 822 | } |
| 823 | |
| 824 | if (data & 0x0080) { |
| 825 | space.write_byte(cop_regs[0] + 0x34, cop_angle); |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | /* |
| 771 | 830 | 05 - 2a05 (2a05 ) : (9af, a82, 082, a8f, 18e, 000, 000, 000) 6 ebeb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 831 | */ |
| 772 | 832 | |
| 833 | void raiden2cop_device::execute_2a05(address_space &space, int offset, UINT16 data) |
| 834 | { |
| 835 | int delta = space.read_word(cop_regs[1] + 0x1e + offset * 4); |
| 836 | space.write_dword(cop_regs[0] + 4 + 2 + offset * 4, space.read_word(cop_regs[0] + 4 + 2 + offset * 4) + delta); |
| 837 | space.write_dword(cop_regs[0] + 0x1e + offset * 4, space.read_word(cop_regs[0] + 0x1e + offset * 4) + delta); |
| 838 | } |
| 839 | |
| 840 | |
| 841 | /* |
| 773 | 842 | 06 - 338e (330e ) : (984, aa4, d82, aa2, 39c, b9c, b9c, a9a) 5 bf7f (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx) |
| 774 | 843 | 06 - 330e (330e ) : (984, aa4, d82, aa2, 39c, b9c, b9c, a9a) 5 bf7f (zeroteam, xsedae) |
| 844 | */ |
| 845 | void raiden2cop_device::execute_338e(address_space &space, int offset, UINT16 data) |
| 846 | { |
| 847 | int dx = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4); |
| 848 | int dy = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8); |
| 775 | 849 | |
| 850 | if (!dy) { |
| 851 | cop_status |= 0x8000; |
| 852 | cop_angle = 0; |
| 853 | } |
| 854 | else { |
| 855 | cop_angle = atan(double(dx) / double(dy)) * 128 / M_PI; |
| 856 | if (dy < 0) |
| 857 | cop_angle += 0x80; |
| 858 | } |
| 859 | |
| 860 | if (data & 0x0080) { |
| 861 | space.write_byte(cop_regs[0] + 0x34, cop_angle); |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | /* |
| 776 | 866 | 07 - 3bb0 (3b30 ) : (f9c, b9c, b9c, b9c, b9c, b9c, b9c, 99c) 4 007f (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx) |
| 777 | 867 | 07 - 3b30 (3b30 ) : (f9c, b9c, b9c, b9c, b9c, b9c, b9c, 99c) 4 007f (zeroteam, xsedae) |
| 868 | */ |
| 778 | 869 | |
| 870 | // triggered with 0x39b0, 0x3b30, 0x3bb0 |
| 871 | |
| 872 | void raiden2cop_device::execute_3b30(address_space &space, int offset, UINT16 data) |
| 873 | { |
| 874 | /* TODO: these are actually internally loaded via 0x130e command */ |
| 875 | int dx, dy; |
| 876 | |
| 877 | dx = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4); |
| 878 | dy = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8); |
| 879 | |
| 880 | dx = dx >> 16; |
| 881 | dy = dy >> 16; |
| 882 | cop_dist = sqrt((double)(dx*dx + dy*dy)); |
| 883 | |
| 884 | if (data & 0x0080) |
| 885 | space.write_word(cop_regs[0] + (data & 0x200 ? 0x3a : 0x38), cop_dist); |
| 886 | } |
| 887 | |
| 888 | |
| 889 | /* |
| 779 | 890 | 08 - 42c2 (4242 ) : (f9a, b9a, b9c, b9c, b9c, 29c, 000, 000) 5 fcdd (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 891 | */ |
| 892 | void raiden2cop_device::execute_42c2(address_space &space, int offset, UINT16 data) |
| 893 | { |
| 894 | int div = space.read_word(cop_regs[0] + (0x36)); |
| 895 | if (!div) |
| 896 | div = 1; |
| 780 | 897 | |
| 898 | /* TODO: bits 5-6-15 */ |
| 899 | cop_status = 7; |
| 900 | |
| 901 | space.write_word(cop_regs[0] + (0x38), (cop_dist << (5 - cop_scale)) / div); |
| 902 | } |
| 903 | |
| 904 | |
| 905 | /* |
| 781 | 906 | 09 - 4aa0 (4a20 ) : (f9a, b9a, b9c, b9c, b9c, 99b, 000, 000) 5 fcdd (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 907 | */ |
| 908 | void raiden2cop_device::execute_4aa0(address_space &space, int offset, UINT16 data) |
| 909 | { |
| 910 | int div = space.read_word(cop_regs[0] + (0x38)); |
| 911 | if (!div) |
| 912 | div = 1; |
| 782 | 913 | |
| 914 | /* TODO: bits 5-6-15 */ |
| 915 | cop_status = 7; |
| 916 | |
| 917 | space.write_word(cop_regs[0] + (0x36), (cop_dist << (5 - cop_scale)) / div); |
| 918 | } |
| 919 | |
| 920 | /* |
| 783 | 921 | 0a - 5105 (5105 ) : (a80, 984, 082, 000, 000, 000, 000, 000) 5 fefb (cupsoc, grainbow) |
| 784 | 922 | 0a - 5205 (5205 ) : (180, 2e0, 3a0, 0a0, 3a0, 000, 000, 000) 6 fff7 (raiden2, raidendx) |
| 785 | 923 | 0a - 5105 (5105 ) : (180, 2e0, 0a0, 000, 000, 000, 000, 000) 6 fffb (zeroteam, xsedae) |
| 786 | | |
| 924 | */ |
| 925 | void raiden2cop_device::execute_5205(address_space &space, int offset, UINT16 data) |
| 926 | { |
| 927 | space.write_dword(cop_regs[1], space.read_dword(cop_regs[0])); |
| 928 | } |
| 929 | /* |
| 787 | 930 | 0b - 5905 (5905 ) : (9c8, a84, 0a2, 000, 000, 000, 000, 000) 5 fffb (cupsoc, grainbow) |
| 788 | 931 | 0b - 5a05 (5a05 ) : (180, 2e0, 3a0, 0a0, 3a0, 000, 000, 000) 6 fff7 (raiden2, raidendx) |
| 789 | 932 | 0b - 5a85 (5a05 ) : (180, 2e0, 0a0, 182, 2e0, 0c0, 3c0, 3c0) 6 ffdb (zeroteam, xsedae) |
| 933 | */ |
| 934 | void raiden2cop_device::execute_5a05(address_space &space, int offset, UINT16 data) |
| 935 | { |
| 936 | space.write_dword(cop_regs[1], space.read_dword(cop_regs[0])); |
| 937 | } |
| 790 | 938 | |
| 939 | /* |
| 791 | 940 | 0c - 6200 (6200 ) : (380, 39a, 380, a80, 29a, 000, 000, 000) 8 f3e7 (heatbrl, legionna, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 792 | 941 | 0c - 6200 (6200 ) : (3a0, 3a6, 380, aa0, 2a6, 000, 000, 000) 8 f3e7 (cupsoc) |
| 793 | 942 | |
| 943 | */ |
| 944 | void raiden2cop_device::execute_6200(address_space &space, int offset, UINT16 data) |
| 945 | { |
| 946 | UINT8 angle = space.read_byte(cop_regs[0] + 0x34); |
| 947 | UINT16 flags = space.read_word(cop_regs[0]); |
| 948 | cop_angle_target &= 0xff; |
| 949 | cop_angle_step &= 0xff; |
| 950 | flags &= ~0x0004; |
| 951 | int delta = angle - cop_angle_target; |
| 952 | if (delta >= 128) |
| 953 | delta -= 256; |
| 954 | else if (delta < -128) |
| 955 | delta += 256; |
| 956 | if (delta < 0) { |
| 957 | if (delta >= -cop_angle_step) { |
| 958 | angle = cop_angle_target; |
| 959 | flags |= 0x0004; |
| 960 | } |
| 961 | else |
| 962 | angle += cop_angle_step; |
| 963 | } |
| 964 | else { |
| 965 | if (delta <= cop_angle_step) { |
| 966 | angle = cop_angle_target; |
| 967 | flags |= 0x0004; |
| 968 | } |
| 969 | else |
| 970 | angle -= cop_angle_step; |
| 971 | } |
| 972 | space.write_word(cop_regs[0], flags); |
| 973 | space.write_byte(cop_regs[0] + 0x34, angle); |
| 974 | } |
| 975 | |
| 976 | /* |
| 977 | |
| 794 | 978 | 0d - 6880 (6800 ) : (b80, ba0, 000, 000, 000, 000, 000, 000) a fff3 (heatbrl, legionna, cupsoc, godzilla, denjinmk) |
| 795 | 979 | 0d - 6980 (6900 ) : (b80, ba0, 000, 000, 000, 000, 000, 000) a fff3 (grainbow, zeroteam, xsedae) |
| 796 | 980 | |
| r32349 | r32350 | |
| 800 | 984 | 0f - 7e05 (7e05 ) : (180, 282, 080, 180, 282, 000, 000, 000) 6 fffb (raidendx) |
| 801 | 985 | */ |
| 802 | 986 | |
| 987 | void raiden2cop_device::execute_7e05(address_space &space, int offset, UINT16 data) // raidendx |
| 988 | { |
| 989 | space.write_byte(0x470, space.read_byte(cop_regs[4])); |
| 990 | } |
| 991 | |
| 803 | 992 | /* |
| 804 | 993 | 10 - 8100 (8100 ) : (b9a, b88, 888, 000, 000, 000, 000, 000) 7 fdfb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 805 | 994 | */ |
| r32349 | r32350 | |
| 845 | 1034 | |
| 846 | 1035 | // x |
| 847 | 1036 | |
| 1037 | */ |
| 1038 | |
| 1039 | /* |
| 848 | 1040 | 14 - a100 (a100 ) : (b80, b82, b84, b86, 000, 000, 000, 000) 0 ffff (heatbrl, zeroteam, xsedae) |
| 849 | 1041 | 14 - a180 (a100 ) : (b80, b82, b84, b86, 000, 000, 000, 000) 0 ffff (legionna, cupsoc, godzilla, denjinmk) |
| 850 | 1042 | 14 - a180 (a100 ) : (b80, b82, b84, b86, 000, 000, 000, 000) 0 02ff (grainbow) |
| 851 | 1043 | 14 - a100 (a100 ) : (b80, b82, b84, b86, 000, 000, 000, 000) 0 00ff (raiden2, raidendx) |
| 852 | | |
| 1044 | */ |
| 1045 | void raiden2cop_device::execute_a100(address_space &space, int offset, UINT16 data) |
| 1046 | { |
| 1047 | cop_collision_read_pos(space, 0, cop_regs[0], data & 0x0080); |
| 1048 | } |
| 1049 | /* |
| 853 | 1050 | 15 - a900 (a900 ) : (ba0, ba2, ba4, ba6, 000, 000, 000, 000) f ffff (heatbrl, zeroteam, xsedae) |
| 854 | 1051 | 15 - a980 (a900 ) : (ba0, ba2, ba4, ba6, 000, 000, 000, 000) f ffff (legionna, cupsoc, godzilla, denjinmk) |
| 855 | 1052 | 15 - a980 (a900 ) : (ba0, ba2, ba4, ba6, 000, 000, 000, 000) f 02ff (grainbow) |
| 856 | 1053 | 15 - a900 (a900 ) : (ba0, ba2, ba4, ba6, 000, 000, 000, 000) f 00ff (raiden2, raidendx) |
| 857 | | |
| 1054 | */ |
| 1055 | void raiden2cop_device::execute_a900(address_space &space, int offset, UINT16 data) |
| 1056 | { |
| 1057 | cop_collision_read_pos(space, 1, cop_regs[1], data & 0x0080); |
| 1058 | } |
| 1059 | /* |
| 858 | 1060 | 16 - b080 (b000 ) : (b40, bc0, bc2, 000, 000, 000, 000, 000) 9 ffff (heatbrl) |
| 859 | 1061 | 16 - b100 (b100 ) : (b40, bc0, bc2, 000, 000, 000, 000, 000) 9 ffff (legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 860 | | |
| 1062 | */ |
| 1063 | void raiden2cop_device::execute_b100(address_space &space, int offset, UINT16 data) |
| 1064 | { |
| 1065 | cop_collision_update_hitbox(space, 0, cop_regs[2]); |
| 1066 | } |
| 1067 | /* |
| 861 | 1068 | 17 - b880 (b800 ) : (b60, be0, be2, 000, 000, 000, 000, 000) 6 ffff (heatbrl) |
| 862 | 1069 | 17 - b900 (b900 ) : (b60, be0, be2, 000, 000, 000, 000, 000) 6 ffff (legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 1070 | */ |
| 1071 | void raiden2cop_device::execute_b900(address_space &space, int offset, UINT16 data) |
| 1072 | { |
| 1073 | cop_collision_update_hitbox(space, 1, cop_regs[3]); |
| 1074 | } |
| 863 | 1075 | |
| 1076 | /* |
| 864 | 1077 | 18 - c480 (c400 ) : (080, 882, 000, 000, 000, 000, 000, 000) a ff00 (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk) |
| 865 | 1078 | 18 - 7c80 (7c00 ) : (080, 882, 000, 000, 000, 000, 000, 000) a ff00 (zeroteam, xsedae) |
| 866 | 1079 | |
| r32349 | r32350 | |
| 879 | 1092 | 1e - f105 (f105 ) : (a88, 994, 088, 000, 000, 000, 000, 000) 5 fefb (cupsoc, grainbow) |
| 880 | 1093 | 1e - f205 (f205 ) : (182, 2e0, 3c0, 0c0, 3c0, 000, 000, 000) 6 fff7 (raiden2, raidendx) |
| 881 | 1094 | 1e - f790 (f710 ) : (f80, b84, b84, b84, b84, b84, b84, b84) 4 00ff (zeroteam, xsedae) |
| 1095 | */ |
| 882 | 1096 | |
| 1097 | void raiden2cop_device::execute_f205(address_space &space, int offset, UINT16 data) |
| 1098 | { |
| 1099 | space.write_dword(cop_regs[2], space.read_dword(cop_regs[0]+4)); |
| 1100 | } |
| 1101 | |
| 1102 | /* |
| 883 | 1103 | 1f - fc84 (fc04 ) : (182, 280, 000, 000, 000, 000, 000, 000) 6 00ff (zeroteam, xsedae) |
| 884 | | |
| 885 | 1104 | */ |
| 886 | 1105 | |
| 887 | 1106 | READ16_MEMBER( raiden2cop_device::cop_status_r) |
| r32349 | r32350 | |
| 985 | 1204 | |
| 986 | 1205 | switch(data) { |
| 987 | 1206 | case 0x0205: { // 0205 0006 ffeb 0000 - 0188 0282 0082 0b8e 098e 0000 0000 0000 |
| 988 | | int ppos = space.read_dword(cop_regs[0] + 4 + offset*4); |
| 989 | | int npos = ppos + space.read_dword(cop_regs[0] + 0x10 + offset*4); |
| 990 | | int delta = (npos >> 16) - (ppos >> 16); |
| 991 | | space.write_dword(cop_regs[0] + 4 + offset*4, npos); |
| 992 | | space.write_word(cop_regs[0] + 0x1e + offset*4, space.read_word(cop_regs[0] + 0x1e + offset*4) + delta); |
| 1207 | execute_0205(space, offset, data); // angle from dx/dy |
| 993 | 1208 | break; |
| 994 | 1209 | } |
| 995 | 1210 | |
| 996 | | case 0x0904: { /* X Se Dae and Zero Team uses this variant */ |
| 997 | | space.write_dword(cop_regs[0] + 16 + offset*4, space.read_dword(cop_regs[0] + 16 + offset*4) - space.read_dword(cop_regs[0] + 0x28 + offset*4)); |
| 1211 | case 0x0904: /* X Se Dae and Zero Team uses this variant */ |
| 1212 | execute_0904(space, offset, data); |
| 998 | 1213 | break; |
| 999 | | } |
| 1214 | |
| 1000 | 1215 | case 0x0905: // 0905 0006 fbfb 0008 - 0194 0288 0088 0000 0000 0000 0000 0000 |
| 1001 | | space.write_dword(cop_regs[0] + 16 + offset*4, space.read_dword(cop_regs[0] + 16 + offset*4) + space.read_dword(cop_regs[0] + 0x28 + offset*4)); |
| 1216 | execute_0905(space, offset, data); |
| 1002 | 1217 | break; |
| 1003 | 1218 | |
| 1004 | 1219 | case 0x130e: // 130e 0005 bf7f 0010 - 0984 0aa4 0d82 0aa2 039b 0b9a 0b9a 0a9a |
| 1005 | 1220 | case 0x138e: |
| 1221 | execute_130e(space, offset, data); // angle from dx/dy |
| 1222 | break; |
| 1223 | |
| 1006 | 1224 | case 0x338e: { // 338e 0005 bf7f 0030 - 0984 0aa4 0d82 0aa2 039c 0b9c 0b9c 0a9a |
| 1007 | | int dx = space.read_dword(cop_regs[1]+4) - space.read_dword(cop_regs[0]+4); |
| 1008 | | int dy = space.read_dword(cop_regs[1]+8) - space.read_dword(cop_regs[0]+8); |
| 1009 | | |
| 1010 | | if(!dy) { |
| 1011 | | cop_status |= 0x8000; |
| 1012 | | cop_angle = 0; |
| 1013 | | } else { |
| 1014 | | cop_angle = atan(double(dx)/double(dy)) * 128 / M_PI; |
| 1015 | | if(dy<0) |
| 1016 | | cop_angle += 0x80; |
| 1017 | | } |
| 1018 | | |
| 1019 | | if(data & 0x0080) { |
| 1020 | | space.write_byte(cop_regs[0]+0x34, cop_angle); |
| 1021 | | } |
| 1225 | execute_338e(space, offset, data); // angle from dx/dy |
| 1022 | 1226 | break; |
| 1023 | 1227 | } |
| 1024 | 1228 | |
| 1025 | 1229 | case 0x2208: |
| 1026 | 1230 | case 0x2288: { // 2208 0005 f5df 0020 - 0f8a 0b8a 0388 0b9a 0b9a 0a9a 0000 0000 |
| 1027 | | int dx = space.read_word(cop_regs[0]+0x12); |
| 1028 | | int dy = space.read_word(cop_regs[0]+0x16); |
| 1029 | | |
| 1030 | | if(!dy) { |
| 1031 | | cop_status |= 0x8000; |
| 1032 | | cop_angle = 0; |
| 1033 | | } else { |
| 1034 | | cop_angle = atan(double(dx)/double(dy)) * 128 / M_PI; |
| 1035 | | if(dy<0) |
| 1036 | | cop_angle += 0x80; |
| 1037 | | } |
| 1038 | | |
| 1039 | | if(data & 0x0080) { |
| 1040 | | space.write_byte(cop_regs[0]+0x34, cop_angle); |
| 1041 | | } |
| 1231 | execute_2288(space, offset, data); // angle from dx/dy |
| 1042 | 1232 | break; |
| 1043 | 1233 | } |
| 1044 | 1234 | |
| 1045 | 1235 | case 0x2a05: { // 2a05 0006 ebeb 0028 - 09af 0a82 0082 0a8f 018e 0000 0000 0000 |
| 1046 | | int delta = space.read_word(cop_regs[1] + 0x1e + offset*4); |
| 1047 | | space.write_dword(cop_regs[0] + 4+2 + offset*4, space.read_word(cop_regs[0] + 4+2 + offset*4) + delta); |
| 1048 | | space.write_dword(cop_regs[0] + 0x1e + offset*4, space.read_word(cop_regs[0] + 0x1e + offset*4) + delta); |
| 1236 | execute_2a05(space, offset, data); |
| 1049 | 1237 | break; |
| 1050 | 1238 | } |
| 1051 | 1239 | |
| 1052 | 1240 | case 0x39b0: |
| 1053 | 1241 | case 0x3b30: |
| 1054 | 1242 | case 0x3bb0: { // 3bb0 0004 007f 0038 - 0f9c 0b9c 0b9c 0b9c 0b9c 0b9c 0b9c 099c |
| 1055 | | /* TODO: these are actually internally loaded via 0x130e command */ |
| 1056 | | int dx,dy; |
| 1243 | execute_3b30(space, offset, data); |
| 1057 | 1244 | |
| 1058 | | dx = space.read_dword(cop_regs[1]+4) - space.read_dword(cop_regs[0]+4); |
| 1059 | | dy = space.read_dword(cop_regs[1]+8) - space.read_dword(cop_regs[0]+8); |
| 1060 | | |
| 1061 | | dx = dx >> 16; |
| 1062 | | dy = dy >> 16; |
| 1063 | | cop_dist = sqrt((double)(dx*dx+dy*dy)); |
| 1064 | | |
| 1065 | | if(data & 0x0080) |
| 1066 | | space.write_word(cop_regs[0]+(data & 0x200 ? 0x3a : 0x38), cop_dist); |
| 1067 | 1245 | break; |
| 1068 | 1246 | } |
| 1069 | 1247 | |
| 1070 | 1248 | case 0x42c2: { // 42c2 0005 fcdd 0040 - 0f9a 0b9a 0b9c 0b9c 0b9c 029c 0000 0000 |
| 1071 | | int div = space.read_word(cop_regs[0]+(0x36)); |
| 1072 | | if(!div) |
| 1073 | | div = 1; |
| 1074 | | |
| 1075 | | /* TODO: bits 5-6-15 */ |
| 1076 | | cop_status = 7; |
| 1077 | | |
| 1078 | | space.write_word(cop_regs[0]+(0x38), (cop_dist << (5 - cop_scale)) / div); |
| 1249 | execute_42c2(space, offset, data); // DIVIDE |
| 1079 | 1250 | break; |
| 1080 | 1251 | } |
| 1081 | 1252 | |
| 1082 | 1253 | case 0x4aa0: { // 4aa0 0005 fcdd 0048 - 0f9a 0b9a 0b9c 0b9c 0b9c 099b 0000 0000 |
| 1083 | | int div = space.read_word(cop_regs[0]+(0x38)); |
| 1084 | | if(!div) |
| 1085 | | div = 1; |
| 1086 | | |
| 1087 | | /* TODO: bits 5-6-15 */ |
| 1088 | | cop_status = 7; |
| 1089 | | |
| 1090 | | space.write_word(cop_regs[0]+(0x36), (cop_dist << (5 - cop_scale)) / div); |
| 1254 | execute_4aa0(space, offset, data); // DIVIDE |
| 1091 | 1255 | break; |
| 1092 | 1256 | } |
| 1093 | 1257 | |
| 1094 | 1258 | case 0x6200: { |
| 1095 | | UINT8 angle = space.read_byte(cop_regs[0]+0x34); |
| 1096 | | UINT16 flags = space.read_word(cop_regs[0]); |
| 1097 | | cop_angle_target &= 0xff; |
| 1098 | | cop_angle_step &= 0xff; |
| 1099 | | flags &= ~0x0004; |
| 1100 | | int delta = angle - cop_angle_target; |
| 1101 | | if(delta >= 128) |
| 1102 | | delta -= 256; |
| 1103 | | else if(delta < -128) |
| 1104 | | delta += 256; |
| 1105 | | if(delta < 0) { |
| 1106 | | if(delta >= -cop_angle_step) { |
| 1107 | | angle = cop_angle_target; |
| 1108 | | flags |= 0x0004; |
| 1109 | | } else |
| 1110 | | angle += cop_angle_step; |
| 1111 | | } else { |
| 1112 | | if(delta <= cop_angle_step) { |
| 1113 | | angle = cop_angle_target; |
| 1114 | | flags |= 0x0004; |
| 1115 | | } else |
| 1116 | | angle -= cop_angle_step; |
| 1117 | | } |
| 1118 | | space.write_word(cop_regs[0], flags); |
| 1119 | | space.write_byte(cop_regs[0]+0x34, angle); |
| 1259 | execute_6200(space, offset, data); // Target Angle calcs |
| 1120 | 1260 | break; |
| 1121 | 1261 | } |
| 1122 | 1262 | |
| r32349 | r32350 | |
| 1132 | 1272 | |
| 1133 | 1273 | case 0x5205: // 5205 0006 fff7 0050 - 0180 02e0 03a0 00a0 03a0 0000 0000 0000 |
| 1134 | 1274 | // fprintf(stderr, "sprcpt 5205 %04x %04x %04x %08x %08x\n", cop_regs[0], cop_regs[1], cop_regs[3], space.read_dword(cop_regs[0]), space.read_dword(cop_regs[3])); |
| 1135 | | space.write_dword(cop_regs[1], space.read_dword(cop_regs[0])); |
| 1275 | execute_5205(space, offset, data); |
| 1136 | 1276 | break; |
| 1137 | 1277 | |
| 1138 | 1278 | case 0x5a05: // 5a05 0006 fff7 0058 - 0180 02e0 03a0 00a0 03a0 0000 0000 0000 |
| 1139 | 1279 | // fprintf(stderr, "sprcpt 5a05 %04x %04x %04x %08x %08x\n", cop_regs[0], cop_regs[1], cop_regs[3], space.read_dword(cop_regs[0]), space.read_dword(cop_regs[3])); |
| 1140 | | space.write_dword(cop_regs[1], space.read_dword(cop_regs[0])); |
| 1280 | execute_5a05(space, offset, data); |
| 1281 | |
| 1141 | 1282 | break; |
| 1142 | 1283 | |
| 1143 | 1284 | case 0xf205: // f205 0006 fff7 00f0 - 0182 02e0 03c0 00c0 03c0 0000 0000 0000 |
| 1144 | 1285 | // fprintf(stderr, "sprcpt f205 %04x %04x %04x %08x %08x\n", cop_regs[0]+4, cop_regs[1], cop_regs[3], space.read_dword(cop_regs[0]+4), space.read_dword(cop_regs[3])); |
| 1145 | | space.write_dword(cop_regs[2], space.read_dword(cop_regs[0]+4)); |
| 1286 | execute_f205(space, offset, data); |
| 1146 | 1287 | break; |
| 1147 | 1288 | |
| 1148 | 1289 | // raidendx only |
| 1149 | 1290 | case 0x7e05: |
| 1150 | | space.write_byte(0x470, space.read_byte(cop_regs[4])); |
| 1291 | execute_7e05(space, offset, data); |
| 1151 | 1292 | break; |
| 1152 | 1293 | |
| 1153 | 1294 | case 0xa100: |
| 1154 | 1295 | case 0xa180: |
| 1155 | | cop_collision_read_pos(space, 0, cop_regs[0], data & 0x0080); |
| 1296 | execute_a100(space, offset, data); // collisions |
| 1156 | 1297 | break; |
| 1157 | 1298 | |
| 1158 | 1299 | case 0xa900: |
| 1159 | 1300 | case 0xa980: |
| 1160 | | cop_collision_read_pos(space, 1, cop_regs[1], data & 0x0080); |
| 1301 | execute_a900(space, offset, data); // collisions |
| 1161 | 1302 | break; |
| 1162 | 1303 | |
| 1163 | 1304 | case 0xb100: { |
| 1164 | | cop_collision_update_hitbox(space, 0, cop_regs[2]); |
| 1305 | execute_b100(space, offset, data); // collisions |
| 1165 | 1306 | break; |
| 1166 | 1307 | } |
| 1167 | 1308 | |
| 1168 | 1309 | case 0xb900: { |
| 1169 | | cop_collision_update_hitbox(space, 1, cop_regs[3]); |
| 1310 | execute_b900(space, offset, data); // collisions |
| 1170 | 1311 | break; |
| 1171 | 1312 | } |
| 1172 | 1313 | |