trunk/src/mame/machine/raiden2cop.c
| r32351 | r32352 | |
| 749 | 749 | /* Main COP functionality */ |
| 750 | 750 | |
| 751 | 751 | /* |
| 752 | | (masked) just assumes 0x0080 masked out, actual masking / command selection is more complex, sometimes needs 0x2000 masked out too, but that would cause clashes in some tables |
| 752 | (masked) just assumes 0x0080 masked out, actual masking / command selection is more complex, it seems bit 0x0001 is masked too (used for sign in 0904 / 0905) and more |
| 753 | 753 | |
| 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) |
| r32351 | r32352 | |
| 764 | 764 | space.write_word(cop_regs[0] + 0x1e + offset * 4, space.read_word(cop_regs[0] + 0x1e + offset * 4) + delta); |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | void raiden2cop_device::LEGACY_execute_0205(address_space &space, int offset, UINT16 data) |
| 768 | { |
| 769 | UINT8 offs; |
| 770 | |
| 771 | offs = (offset & 3) * 4; |
| 772 | int ppos = space.read_dword(cop_regs[0] + 4 + offs); |
| 773 | int npos = ppos + space.read_dword(cop_regs[0] + 0x10 + offs); |
| 774 | int delta = (npos >> 16) - (ppos >> 16); |
| 775 | |
| 776 | space.write_dword(cop_regs[0] + 4 + offs, npos); |
| 777 | space.write_word(cop_regs[0] + 0x1c + offs, space.read_word(cop_regs[0] + 0x1c + offs) + delta); |
| 778 | } |
| 779 | |
| 767 | 780 | /* |
| 768 | 781 | 01 - 0905 (0905 ) : (194, 288, 088, 000, 000, 000, 000, 000) 6 fbfb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 769 | 782 | 01 - 0b05 (0b05 ) : (180, 2e0, 0a0, 182, 2e0, 0c0, 000, 000) 6 ffdb (zeroteamsr) |
| r32351 | r32352 | |
| 781 | 794 | 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 | 795 | } |
| 783 | 796 | |
| 797 | void raiden2cop_device::LEGACY_execute_0905(address_space &space, int offset, UINT16 data) |
| 798 | { |
| 799 | UINT8 offs; |
| 784 | 800 | |
| 801 | offs = (offset & 3) * 4; |
| 802 | |
| 803 | /* read 0x28 + offs */ |
| 804 | /* add 0x10 + offs */ |
| 805 | /* write 0x10 + offs */ |
| 806 | |
| 807 | space.write_dword(cop_regs[0] + 0x10 + offs, space.read_dword(cop_regs[0] + 0x10 + offs) + space.read_dword(cop_regs[0] + 0x28 + offs)); |
| 808 | |
| 809 | } |
| 810 | |
| 785 | 811 | /* |
| 786 | 812 | 02 - 138e (130e ) : (984, aa4, d82, aa2, 39b, b9a, b9a, b9a) 5 bf7f (heatbrl, legionna) |
| 787 | 813 | 02 - 138e (130e ) : (984, aa4, d82, aa2, 39b, b9a, b9a, a9a) 5 bf7f (cupsoc, godzilla, grainbow, denjinmk) |
| r32351 | r32352 | |
| 795 | 821 | execute_338e(space, offset, data); |
| 796 | 822 | } |
| 797 | 823 | |
| 824 | void raiden2cop_device::LEGACY_execute_130e(address_space &space, int offset, UINT16 data) |
| 825 | { |
| 826 | int dy = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4); |
| 827 | int dx = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8); |
| 828 | |
| 829 | cop_status = 7; |
| 830 | if (!dx) { |
| 831 | cop_status |= 0x8000; |
| 832 | cop_angle = 0; |
| 833 | } |
| 834 | else { |
| 835 | cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI; |
| 836 | if (dx < 0) |
| 837 | cop_angle += 0x80; |
| 838 | } |
| 839 | |
| 840 | cop_angle -= 0x80; |
| 841 | m_LEGACY_r0 = dy; |
| 842 | m_LEGACY_r1 = dx; |
| 843 | |
| 844 | if (data & 0x80) |
| 845 | space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle); |
| 846 | } |
| 847 | |
| 848 | void raiden2cop_device::LEGACY_execute_130e_cupsoc(address_space &space, int offset, UINT16 data) |
| 849 | { |
| 850 | int dy = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4); |
| 851 | int dx = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8); |
| 852 | |
| 853 | cop_status = 7; |
| 854 | if (!dx) { |
| 855 | cop_status |= 0x8000; |
| 856 | cop_angle = 0; |
| 857 | } |
| 858 | else { |
| 859 | cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI; |
| 860 | if (dx < 0) |
| 861 | cop_angle += 0x80; |
| 862 | } |
| 863 | |
| 864 | m_LEGACY_r0 = dy; |
| 865 | m_LEGACY_r1 = dx; |
| 866 | |
| 867 | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
| 868 | |
| 869 | if (data & 0x80) |
| 870 | space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle); |
| 871 | } |
| 872 | |
| 798 | 873 | /* |
| 799 | 874 | 03 - 1905 (1905 ) : (994, a88, 088, 000, 000, 000, 000, 000) 6 fbfb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 800 | 875 | */ |
| r32351 | r32352 | |
| 885 | 960 | space.write_word(cop_regs[0] + (data & 0x200 ? 0x3a : 0x38), cop_dist); |
| 886 | 961 | } |
| 887 | 962 | |
| 963 | void raiden2cop_device::LEGACY_execute_3b30(address_space &space, int offset, UINT16 data) |
| 964 | { |
| 965 | int dy = m_LEGACY_r0; |
| 966 | int dx = m_LEGACY_r1; |
| 888 | 967 | |
| 968 | dx >>= 16; |
| 969 | dy >>= 16; |
| 970 | cop_dist = sqrt((double)(dx*dx + dy*dy)); |
| 971 | |
| 972 | if (data & 0x80) |
| 973 | space.write_word(cop_regs[0] + (0x38), cop_dist); |
| 974 | } |
| 975 | |
| 889 | 976 | /* |
| 890 | 977 | 08 - 42c2 (4242 ) : (f9a, b9a, b9c, b9c, b9c, 29c, 000, 000) 5 fcdd (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 891 | 978 | */ |
| r32351 | r32352 | |
| 901 | 988 | space.write_word(cop_regs[0] + (0x38), (cop_dist << (5 - cop_scale)) / div); |
| 902 | 989 | } |
| 903 | 990 | |
| 991 | void raiden2cop_device::LEGACY_execute_42c2(address_space &space, int offset, UINT16 data) |
| 992 | { |
| 993 | int dy = m_LEGACY_r0; |
| 994 | int dx = m_LEGACY_r1; |
| 995 | int div = space.read_word(cop_regs[0] + (0x36 ^ 2)); |
| 996 | int res; |
| 997 | int cop_dist_raw; |
| 904 | 998 | |
| 999 | if (!div) |
| 1000 | { |
| 1001 | printf("divide by zero?\n"); |
| 1002 | div = 1; |
| 1003 | } |
| 1004 | |
| 1005 | /* TODO: calculation of this one should occur at 0x3b30/0x3bb0 I *think* */ |
| 1006 | /* TODO: recheck if cop_scale still masks at 3 with this command */ |
| 1007 | dx >>= 11 + cop_scale; |
| 1008 | dy >>= 11 + cop_scale; |
| 1009 | cop_dist_raw = sqrt((double)(dx*dx + dy*dy)); |
| 1010 | |
| 1011 | res = cop_dist_raw; |
| 1012 | res /= div; |
| 1013 | |
| 1014 | cop_dist = (1 << (5 - cop_scale)) / div; |
| 1015 | |
| 1016 | /* TODO: bits 5-6-15 */ |
| 1017 | cop_status = 7; |
| 1018 | |
| 1019 | space.write_word(cop_regs[0] + (0x38 ^ 2), res); |
| 1020 | |
| 1021 | } |
| 1022 | |
| 905 | 1023 | /* |
| 906 | 1024 | 09 - 4aa0 (4a20 ) : (f9a, b9a, b9c, b9c, b9c, 99b, 000, 000) 5 fcdd (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| 907 | 1025 | */ |
| r32351 | r32352 | |
| 973 | 1091 | space.write_byte(cop_regs[0] + 0x34, angle); |
| 974 | 1092 | } |
| 975 | 1093 | |
| 1094 | void raiden2cop_device::LEGACY_execute_6200(address_space &space, int offset, UINT16 data) |
| 1095 | { |
| 1096 | UINT8 cur_angle; |
| 1097 | UINT16 flags; |
| 1098 | |
| 1099 | /* 0 [1] */ |
| 1100 | /* 0xc [1] */ |
| 1101 | /* 0 [0] */ |
| 1102 | /* 0 [1] */ |
| 1103 | /* 0xc [1] */ |
| 1104 | |
| 1105 | cur_angle = space.read_byte(cop_regs[1] + (0xc ^ 3)); |
| 1106 | flags = space.read_word(cop_regs[1]); |
| 1107 | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 1108 | |
| 1109 | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 1110 | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 1111 | |
| 1112 | tempangle_compare &= 0xff; |
| 1113 | tempangle_mod_val &= 0xff; |
| 1114 | |
| 1115 | cop_angle_target = tempangle_compare; |
| 1116 | cop_angle_step = tempangle_mod_val; |
| 1117 | |
| 1118 | flags &= ~0x0004; |
| 1119 | |
| 1120 | int delta = cur_angle - tempangle_compare; |
| 1121 | if (delta >= 128) |
| 1122 | delta -= 256; |
| 1123 | else if (delta < -128) |
| 1124 | delta += 256; |
| 1125 | if (delta < 0) |
| 1126 | { |
| 1127 | if (delta >= -tempangle_mod_val) |
| 1128 | { |
| 1129 | cur_angle = tempangle_compare; |
| 1130 | flags |= 0x0004; |
| 1131 | } |
| 1132 | else |
| 1133 | cur_angle += tempangle_mod_val; |
| 1134 | } |
| 1135 | else |
| 1136 | { |
| 1137 | if (delta <= tempangle_mod_val) |
| 1138 | { |
| 1139 | cur_angle = tempangle_compare; |
| 1140 | flags |= 0x0004; |
| 1141 | } |
| 1142 | else |
| 1143 | cur_angle -= tempangle_mod_val; |
| 1144 | } |
| 1145 | |
| 1146 | space.write_byte(cop_regs[1] + (0 ^ 2), flags); |
| 1147 | space.write_byte(cop_regs[1] + (0xc ^ 3), cur_angle); |
| 1148 | } |
| 1149 | |
| 1150 | void raiden2cop_device::LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data) |
| 1151 | { |
| 1152 | UINT8 cur_angle; |
| 1153 | UINT16 flags; |
| 1154 | |
| 1155 | cur_angle = space.read_byte(cop_regs[0] + (0x34 ^ 3)); |
| 1156 | flags = space.read_word(cop_regs[0] + (0 ^ 2)); |
| 1157 | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 1158 | |
| 1159 | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 1160 | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 1161 | |
| 1162 | tempangle_compare &= 0xff; |
| 1163 | tempangle_mod_val &= 0xff; |
| 1164 | |
| 1165 | cop_angle_target = tempangle_compare; |
| 1166 | cop_angle_step = tempangle_mod_val; |
| 1167 | |
| 1168 | |
| 1169 | flags &= ~0x0004; |
| 1170 | |
| 1171 | int delta = cur_angle - tempangle_compare; |
| 1172 | if (delta >= 128) |
| 1173 | delta -= 256; |
| 1174 | else if (delta < -128) |
| 1175 | delta += 256; |
| 1176 | if (delta < 0) |
| 1177 | { |
| 1178 | if (delta >= -tempangle_mod_val) |
| 1179 | { |
| 1180 | cur_angle = tempangle_compare; |
| 1181 | flags |= 0x0004; |
| 1182 | } |
| 1183 | else |
| 1184 | cur_angle += tempangle_mod_val; |
| 1185 | } |
| 1186 | else |
| 1187 | { |
| 1188 | if (delta <= tempangle_mod_val) |
| 1189 | { |
| 1190 | cur_angle = tempangle_compare; |
| 1191 | flags |= 0x0004; |
| 1192 | } |
| 1193 | else |
| 1194 | cur_angle -= tempangle_mod_val; |
| 1195 | } |
| 1196 | |
| 1197 | space.write_byte(cop_regs[0] + (0 ^ 3), flags); |
| 1198 | space.write_word(cop_regs[0] + (0x34 ^ 3), cur_angle); |
| 1199 | } |
| 1200 | |
| 976 | 1201 | /* |
| 977 | 1202 | |
| 978 | 1203 | 0d - 6880 (6800 ) : (b80, ba0, 000, 000, 000, 000, 000, 000) a fff3 (heatbrl, legionna, cupsoc, godzilla, denjinmk) |
| 979 | 1204 | 0d - 6980 (6900 ) : (b80, ba0, 000, 000, 000, 000, 000, 000) a fff3 (grainbow, zeroteam, xsedae) |
| 1205 | */ |
| 1206 | void raiden2cop_device::LEGACY_execute_6980(address_space &space, int offset, UINT16 data) |
| 1207 | { |
| 1208 | UINT8 offs; |
| 1209 | int abs_x, abs_y, rel_xy; |
| 980 | 1210 | |
| 1211 | offs = (offset & 3) * 4; |
| 1212 | |
| 1213 | /* TODO: I really suspect that following two are actually taken from the 0xa180 macro command then internally loaded */ |
| 1214 | abs_x = space.read_word(cop_regs[0] + 8) - m_cop_sprite_dma_abs_x; |
| 1215 | abs_y = space.read_word(cop_regs[0] + 4) - m_cop_sprite_dma_abs_y; |
| 1216 | rel_xy = space.read_word(m_cop_sprite_dma_src + 4 + offs); |
| 1217 | |
| 1218 | //if(rel_xy & 0x0706) |
| 1219 | // printf("sprite rel_xy = %04x\n",rel_xy); |
| 1220 | |
| 1221 | if (rel_xy & 1) |
| 1222 | space.write_word(cop_regs[4] + offs + 4, 0xc0 + abs_x - (rel_xy & 0xf8)); |
| 1223 | else |
| 1224 | space.write_word(cop_regs[4] + offs + 4, (((rel_xy & 0x78) + (abs_x)-((rel_xy & 0x80) ? 0x80 : 0)))); |
| 1225 | |
| 1226 | space.write_word(cop_regs[4] + offs + 6, (((rel_xy & 0x7800) >> 8) + (abs_y)-((rel_xy & 0x8000) ? 0x80 : 0))); |
| 1227 | } |
| 1228 | |
| 1229 | /* |
| 1230 | |
| 981 | 1231 | 0e - 7100 (7100 ) : (b80, a80, b80, 000, 000, 000, 000, 000) 8 fdfd (zeroteam, xsedae) |
| 982 | 1232 | |
| 983 | 1233 | 0f - 7905 (7905 ) : (1a2, 2c2, 0a2, 000, 000, 000, 000, 000) 6 fffb (cupsoc, grainbow) |
| r32351 | r32352 | |
| 1046 | 1296 | { |
| 1047 | 1297 | cop_collision_read_pos(space, 0, cop_regs[0], data & 0x0080); |
| 1048 | 1298 | } |
| 1299 | |
| 1300 | void raiden2cop_device::LEGACY_execute_a100(address_space &space, int offset, UINT16 data) |
| 1301 | { |
| 1302 | m_LEGACY_cop_collision_info[0].y = (space.read_dword(cop_regs[0] + 4)); |
| 1303 | m_LEGACY_cop_collision_info[0].x = (space.read_dword(cop_regs[0] + 8)); |
| 1304 | } |
| 1305 | |
| 1049 | 1306 | /* |
| 1050 | 1307 | 15 - a900 (a900 ) : (ba0, ba2, ba4, ba6, 000, 000, 000, 000) f ffff (heatbrl, zeroteam, xsedae) |
| 1051 | 1308 | 15 - a980 (a900 ) : (ba0, ba2, ba4, ba6, 000, 000, 000, 000) f ffff (legionna, cupsoc, godzilla, denjinmk) |
| r32351 | r32352 | |
| 1056 | 1313 | { |
| 1057 | 1314 | cop_collision_read_pos(space, 1, cop_regs[1], data & 0x0080); |
| 1058 | 1315 | } |
| 1316 | |
| 1317 | void raiden2cop_device::LEGACY_execute_a900(address_space &space, int offset, UINT16 data) |
| 1318 | { |
| 1319 | m_LEGACY_cop_collision_info[1].y = (space.read_dword(cop_regs[1] + 4)); |
| 1320 | m_LEGACY_cop_collision_info[1].x = (space.read_dword(cop_regs[1] + 8)); |
| 1321 | } |
| 1322 | |
| 1059 | 1323 | /* |
| 1060 | 1324 | 16 - b080 (b000 ) : (b40, bc0, bc2, 000, 000, 000, 000, 000) 9 ffff (heatbrl) |
| 1061 | 1325 | 16 - b100 (b100 ) : (b40, bc0, bc2, 000, 000, 000, 000, 000) 9 ffff (legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| r32351 | r32352 | |
| 1064 | 1328 | { |
| 1065 | 1329 | cop_collision_update_hitbox(space, 0, cop_regs[2]); |
| 1066 | 1330 | } |
| 1331 | |
| 1332 | void raiden2cop_device::LEGACY_execute_b100(address_space &space, int offset, UINT16 data) |
| 1333 | { |
| 1334 | m_LEGACY_cop_collision_info[0].hitbox = space.read_word(cop_regs[2]); |
| 1335 | m_LEGACY_cop_collision_info[0].hitbox_y = space.read_word((cop_regs[2] & 0xffff0000) | (m_LEGACY_cop_collision_info[0].hitbox)); |
| 1336 | m_LEGACY_cop_collision_info[0].hitbox_x = space.read_word(((cop_regs[2] & 0xffff0000) | (m_LEGACY_cop_collision_info[0].hitbox)) + 2); |
| 1337 | |
| 1338 | /* do the math */ |
| 1339 | LEGACY_cop_take_hit_box_params(0); |
| 1340 | cop_hit_status = LEGACY_cop_calculate_collsion_detection(); |
| 1341 | } |
| 1342 | |
| 1067 | 1343 | /* |
| 1068 | 1344 | 17 - b880 (b800 ) : (b60, be0, be2, 000, 000, 000, 000, 000) 6 ffff (heatbrl) |
| 1069 | 1345 | 17 - b900 (b900 ) : (b60, be0, be2, 000, 000, 000, 000, 000) 6 ffff (legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae) |
| r32351 | r32352 | |
| 1073 | 1349 | cop_collision_update_hitbox(space, 1, cop_regs[3]); |
| 1074 | 1350 | } |
| 1075 | 1351 | |
| 1352 | void raiden2cop_device::LEGACY_execute_b900(address_space &space, int offset, UINT16 data) |
| 1353 | { |
| 1354 | m_LEGACY_cop_collision_info[1].hitbox = space.read_word(cop_regs[3]); |
| 1355 | m_LEGACY_cop_collision_info[1].hitbox_y = space.read_word((cop_regs[3] & 0xffff0000) | (m_LEGACY_cop_collision_info[1].hitbox)); |
| 1356 | m_LEGACY_cop_collision_info[1].hitbox_x = space.read_word(((cop_regs[3] & 0xffff0000) | (m_LEGACY_cop_collision_info[1].hitbox)) + 2); |
| 1357 | |
| 1358 | /* do the math */ |
| 1359 | LEGACY_cop_take_hit_box_params(1); |
| 1360 | cop_hit_status = LEGACY_cop_calculate_collsion_detection(); |
| 1361 | } |
| 1362 | |
| 1076 | 1363 | /* |
| 1077 | 1364 | 18 - c480 (c400 ) : (080, 882, 000, 000, 000, 000, 000, 000) a ff00 (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk) |
| 1078 | 1365 | 18 - 7c80 (7c00 ) : (080, 882, 000, 000, 000, 000, 000, 000) a ff00 (zeroteam, xsedae) |
| 1366 | */ |
| 1079 | 1367 | |
| 1368 | void raiden2cop_device::LEGACY_execute_c480(address_space &space, int offset, UINT16 data) |
| 1369 | { |
| 1370 | UINT8 offs; |
| 1371 | |
| 1372 | offs = (offset & 3) * 4; |
| 1373 | |
| 1374 | space.write_word(cop_regs[4] + offs + 0, space.read_word(m_cop_sprite_dma_src + offs) + (m_cop_sprite_dma_param & 0x3f)); |
| 1375 | //space.write_word(cop_regs[4] + offs + 2,space.read_word(m_cop_sprite_dma_src+2 + offs)); |
| 1376 | |
| 1377 | } |
| 1378 | |
| 1379 | /* |
| 1080 | 1380 | 19 - cb8f (cb0f ) : (984, aa4, d82, aa2, 39b, b9a, b9a, a9f) 5 bf7f (cupsoc, grainbow) |
| 1081 | 1381 | |
| 1082 | 1382 | 1a - d104 (d104 ) : (ac2, 9e0, 0a2, 000, 000, 000, 000, 000) 5 fffb (cupsoc, grainbow) |
| 1383 | */ |
| 1384 | void raiden2cop_device::LEGACY_execute_d104(address_space &space, int offset, UINT16 data) |
| 1385 | { |
| 1386 | UINT8 *ROM = space.machine().root_device().memregion("maincpu")->base(); |
| 1387 | UINT32 rom_addr = (m_cop_rom_addr_hi << 16 | m_cop_rom_addr_lo) & ~1; |
| 1388 | UINT16 rom_data = (ROM[rom_addr + 0]) | (ROM[rom_addr + 1] << 8); |
| 1083 | 1389 | |
| 1390 | /* writes to some unemulated COP registers, then puts the result in here, adding a parameter taken from ROM */ |
| 1391 | //space.write_word(cop_regs[0]+(0x44 + offset * 4), rom_data); |
| 1392 | |
| 1393 | logerror("%04x%04x %04x %04x\n", m_cop_rom_addr_hi, m_cop_rom_addr_lo, m_cop_rom_addr_unk, rom_data); |
| 1394 | } |
| 1395 | /* |
| 1084 | 1396 | 1b - dde5 (dd65 ) : (f80, aa2, 984, 0c2, 000, 000, 000, 000) 5 7ff7 (cupsoc, grainbow) |
| 1397 | */ |
| 1085 | 1398 | |
| 1399 | void raiden2cop_device::LEGACY_execute_dde5(address_space &space, int offset, UINT16 data) |
| 1400 | { |
| 1401 | UINT8 offs; |
| 1402 | int div; |
| 1403 | INT16 dir_offset; |
| 1404 | // INT16 offs_val; |
| 1405 | |
| 1406 | /* TODO: [4-7] could be mirrors of [0-3] (this is the only command so far that uses 4-7 actually)*/ |
| 1407 | /* ? 0 + [4] */ |
| 1408 | /* sub32 4 + [5] */ |
| 1409 | /* write16h 8 + [4] */ |
| 1410 | /* addmem16 4 + [6] */ |
| 1411 | |
| 1412 | // these two are obvious ... |
| 1413 | // 0xf x 16 = 240 |
| 1414 | // 0x14 x 16 = 320 |
| 1415 | // what are these two instead? scale factor? offsets? (edit: offsets to apply from the initial sprite data) |
| 1416 | // 0xfc69 ? |
| 1417 | // 0x7f4 ? |
| 1418 | //printf("%08x %08x %08x %08x %08x %08x %08x\n",cop_regs[0],cop_regs[1],cop_regs[2],cop_regs[3],cop_regs[4],cop_regs[5],cop_regs[6]); |
| 1419 | |
| 1420 | offs = (offset & 3) * 4; |
| 1421 | |
| 1422 | div = space.read_word(cop_regs[4] + offs); |
| 1423 | dir_offset = space.read_word(cop_regs[4] + offs + 8); |
| 1424 | // offs_val = space.read_word(cop_regs[3] + offs); |
| 1425 | //420 / 180 = 500 : 400 = 30 / 50 = 98 / 18 |
| 1426 | |
| 1427 | /* TODO: this probably trips a cop status flag */ |
| 1428 | if (div == 0) { div = 1; } |
| 1429 | |
| 1430 | |
| 1431 | space.write_word((cop_regs[6] + offs + 4), ((space.read_word(cop_regs[5] + offs + 4) + dir_offset) / div)); |
| 1432 | } |
| 1433 | |
| 1434 | /* |
| 1086 | 1435 | 1c - e38e (e30e ) : (984, ac4, d82, ac2, 39b, b9a, b9a, a9a) 5 b07f (cupsoc, grainbow) |
| 1087 | 1436 | 1c - e105 (e105 ) : (a88, 994, 088, 000, 000, 000, 000, 000) 5 06fb (zeroteam, xsedae) |
| 1437 | */ |
| 1088 | 1438 | |
| 1439 | void raiden2cop_device::LEGACY_execute_e30e(address_space &space, int offset, UINT16 data) |
| 1440 | { |
| 1441 | int dy = space.read_dword(cop_regs[2] + 4) - space.read_dword(cop_regs[0] + 4); |
| 1442 | int dx = space.read_dword(cop_regs[2] + 8) - space.read_dword(cop_regs[0] + 8); |
| 1443 | |
| 1444 | cop_status = 7; |
| 1445 | if (!dx) { |
| 1446 | cop_status |= 0x8000; |
| 1447 | cop_angle = 0; |
| 1448 | } |
| 1449 | else { |
| 1450 | cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI; |
| 1451 | if (dx < 0) |
| 1452 | cop_angle += 0x80; |
| 1453 | } |
| 1454 | |
| 1455 | m_LEGACY_r0 = dy; |
| 1456 | m_LEGACY_r1 = dx; |
| 1457 | |
| 1458 | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
| 1459 | |
| 1460 | if (data & 0x80) |
| 1461 | space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle); |
| 1462 | } |
| 1463 | |
| 1464 | /* |
| 1089 | 1465 | 1d - eb8e (eb0e ) : (984, ac4, d82, ac2, 39b, b9a, b9a, a9f) 5 b07f (cupsoc, grainbow) |
| 1090 | 1466 | 1d - ede5 (ed65 ) : (f88, a84, 986, 08a, 000, 000, 000, 000) 5 05f7 (zeroteam, xsedae) |
| 1091 | 1467 | |
| r32351 | r32352 | |
| 1606 | 1982 | dword ^= 0 |
| 1607 | 1983 | word ^= 2 |
| 1608 | 1984 | byte ^= 3 |
| 1609 | | - some macro commands here have a commented algorithm, it's how Seibu Cup Bootleg version handles maths inside the 14/15 roms. |
| 1985 | - some macro commands here have a commented algorithm, it's how Seibu Cup **BOOTLEG** version handles maths inside the 14/15 roms. |
| 1610 | 1986 | The ROMs map tables in the following arrangement: |
| 1611 | 1987 | 0x00000 - 0x1ffff Sine math results |
| 1612 | 1988 | 0x20000 - 0x3ffff Cosine math results |
| r32351 | r32352 | |
| 1621 | 1997 | if (check_command_matches(command, 0x188, 0x282, 0x082, 0xb8e, 0x98e, 0x000, 0x000, 0x000, 6, 0xffeb)) |
| 1622 | 1998 | { |
| 1623 | 1999 | executed = 1; |
| 1624 | | UINT8 offs; |
| 1625 | | |
| 1626 | | offs = (offset & 3) * 4; |
| 1627 | | int ppos = space.read_dword(cop_regs[0] + 4 + offs); |
| 1628 | | int npos = ppos + space.read_dword(cop_regs[0] + 0x10 + offs); |
| 1629 | | int delta = (npos >> 16) - (ppos >> 16); |
| 1630 | | |
| 1631 | | space.write_dword(cop_regs[0] + 4 + offs, npos); |
| 1632 | | space.write_word(cop_regs[0] + 0x1c + offs, space.read_word(cop_regs[0] + 0x1c + offs) + delta); |
| 2000 | LEGACY_execute_0205(space, offset, data); |
| 1633 | 2001 | return; |
| 1634 | 2002 | } |
| 1635 | 2003 | |
| r32351 | r32352 | |
| 1637 | 2005 | if (check_command_matches(command, 0x194, 0x288, 0x088, 0x000, 0x000, 0x000, 0x000, 0x000, 6, 0xfbfb)) |
| 1638 | 2006 | { |
| 1639 | 2007 | executed = 1; |
| 1640 | | UINT8 offs; |
| 1641 | | |
| 1642 | | offs = (offset & 3) * 4; |
| 1643 | | |
| 1644 | | /* read 0x28 + offs */ |
| 1645 | | /* add 0x10 + offs */ |
| 1646 | | /* write 0x10 + offs */ |
| 1647 | | |
| 1648 | | space.write_dword(cop_regs[0] + 0x10 + offs, space.read_dword(cop_regs[0] + 0x10 + offs) + space.read_dword(cop_regs[0] + 0x28 + offs)); |
| 2008 | LEGACY_execute_0905(space, offset, data); |
| 1649 | 2009 | return; |
| 1650 | 2010 | } |
| 1651 | 2011 | |
| r32351 | r32352 | |
| 1691 | 2051 | if (check_command_matches(command, 0x984, 0xaa4, 0xd82, 0xaa2, 0x39b, 0xb9a, 0xb9a, 0xa9a, 5, 0xbf7f)) |
| 1692 | 2052 | { |
| 1693 | 2053 | executed = 1; |
| 1694 | | int dy = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4); |
| 1695 | | int dx = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8); |
| 1696 | | |
| 1697 | | cop_status = 7; |
| 1698 | | if (!dx) { |
| 1699 | | cop_status |= 0x8000; |
| 1700 | | cop_angle = 0; |
| 1701 | | } |
| 1702 | | else { |
| 1703 | | cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI; |
| 1704 | | if (dx < 0) |
| 1705 | | cop_angle += 0x80; |
| 1706 | | } |
| 1707 | | |
| 1708 | | m_LEGACY_r0 = dy; |
| 1709 | | m_LEGACY_r1 = dx; |
| 1710 | | |
| 1711 | | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
| 1712 | | |
| 1713 | | if (data & 0x80) |
| 1714 | | space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle); |
| 2054 | LEGACY_execute_130e_cupsoc(space, offset, data); |
| 1715 | 2055 | return; |
| 1716 | 2056 | } |
| 1717 | 2057 | |
| r32351 | r32352 | |
| 1720 | 2060 | if (check_command_matches(command, 0x984, 0xaa4, 0xd82, 0xaa2, 0x39b, 0xb9a, 0xb9a, 0xb9a, 5, 0xbf7f)) |
| 1721 | 2061 | { |
| 1722 | 2062 | executed = 1; |
| 1723 | | int dy = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4); |
| 1724 | | int dx = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8); |
| 1725 | | |
| 1726 | | cop_status = 7; |
| 1727 | | if (!dx) { |
| 1728 | | cop_status |= 0x8000; |
| 1729 | | cop_angle = 0; |
| 1730 | | } |
| 1731 | | else { |
| 1732 | | cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI; |
| 1733 | | if (dx < 0) |
| 1734 | | cop_angle += 0x80; |
| 1735 | | } |
| 1736 | | |
| 1737 | | cop_angle -= 0x80; |
| 1738 | | m_LEGACY_r0 = dy; |
| 1739 | | m_LEGACY_r1 = dx; |
| 1740 | | |
| 1741 | | if (data & 0x80) |
| 1742 | | space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle); |
| 2063 | LEGACY_execute_130e(space, offset, data); |
| 1743 | 2064 | return; |
| 1744 | 2065 | } |
| 1745 | 2066 | |
| r32351 | r32352 | |
| 1754 | 2075 | if (check_command_matches(command, 0xf9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0x99c, 4, 0x007f)) |
| 1755 | 2076 | { |
| 1756 | 2077 | executed = 1; |
| 1757 | | int dy = m_LEGACY_r0; |
| 1758 | | int dx = m_LEGACY_r1; |
| 1759 | | |
| 1760 | | dx >>= 16; |
| 1761 | | dy >>= 16; |
| 1762 | | cop_dist = sqrt((double)(dx*dx + dy*dy)); |
| 1763 | | |
| 1764 | | if (data & 0x80) |
| 1765 | | space.write_word(cop_regs[0] + (0x38), cop_dist); |
| 2078 | LEGACY_execute_3b30(space, offset, data); |
| 1766 | 2079 | return; |
| 1767 | 2080 | } |
| 1768 | 2081 | |
| r32351 | r32352 | |
| 1780 | 2093 | if (check_command_matches(command, 0xf9a, 0xb9a, 0xb9c, 0xb9c, 0xb9c, 0x29c, 0x000, 0x000, 5, 0xfcdd)) |
| 1781 | 2094 | { |
| 1782 | 2095 | executed = 1; |
| 1783 | | int dy = m_LEGACY_r0; |
| 1784 | | int dx = m_LEGACY_r1; |
| 1785 | | int div = space.read_word(cop_regs[0] + (0x36 ^ 2)); |
| 1786 | | int res; |
| 1787 | | int cop_dist_raw; |
| 1788 | | |
| 1789 | | if (!div) |
| 1790 | | { |
| 1791 | | printf("divide by zero?\n"); |
| 1792 | | div = 1; |
| 1793 | | } |
| 1794 | | |
| 1795 | | /* TODO: calculation of this one should occur at 0x3b30/0x3bb0 I *think* */ |
| 1796 | | /* TODO: recheck if cop_scale still masks at 3 with this command */ |
| 1797 | | dx >>= 11 + cop_scale; |
| 1798 | | dy >>= 11 + cop_scale; |
| 1799 | | cop_dist_raw = sqrt((double)(dx*dx + dy*dy)); |
| 1800 | | |
| 1801 | | res = cop_dist_raw; |
| 1802 | | res /= div; |
| 1803 | | |
| 1804 | | cop_dist = (1 << (5 - cop_scale)) / div; |
| 1805 | | |
| 1806 | | /* TODO: bits 5-6-15 */ |
| 1807 | | cop_status = 7; |
| 1808 | | |
| 1809 | | space.write_word(cop_regs[0] + (0x38 ^ 2), res); |
| 2096 | LEGACY_execute_42c2(space, offset, data); |
| 1810 | 2097 | return; |
| 1811 | 2098 | } |
| 1812 | 2099 | |
| r32351 | r32352 | |
| 1825 | 2112 | |
| 1826 | 2113 | if (check_command_matches(command, 0xb80, 0xb82, 0xb84, 0xb86, 0x000, 0x000, 0x000, 0x000, funcval, funcmask)) |
| 1827 | 2114 | { |
| 2115 | LEGACY_execute_a100(space, offset, data); |
| 1828 | 2116 | executed = 1; |
| 1829 | | m_LEGACY_cop_collision_info[0].y = (space.read_dword(cop_regs[0] + 4)); |
| 1830 | | m_LEGACY_cop_collision_info[0].x = (space.read_dword(cop_regs[0] + 8)); |
| 1831 | 2117 | return; |
| 1832 | 2118 | } |
| 1833 | 2119 | |
| r32351 | r32352 | |
| 1835 | 2121 | if (check_command_matches(command, 0xb40, 0xbc0, 0xbc2, 0x000, 0x000, 0x000, 0x000, 0x000, funcval, funcmask)) |
| 1836 | 2122 | { |
| 1837 | 2123 | executed = 1; |
| 1838 | | m_LEGACY_cop_collision_info[0].hitbox = space.read_word(cop_regs[2]); |
| 1839 | | m_LEGACY_cop_collision_info[0].hitbox_y = space.read_word((cop_regs[2] & 0xffff0000) | (m_LEGACY_cop_collision_info[0].hitbox)); |
| 1840 | | m_LEGACY_cop_collision_info[0].hitbox_x = space.read_word(((cop_regs[2] & 0xffff0000) | (m_LEGACY_cop_collision_info[0].hitbox)) + 2); |
| 1841 | | |
| 1842 | | /* do the math */ |
| 1843 | | LEGACY_cop_take_hit_box_params(0); |
| 1844 | | cop_hit_status = LEGACY_cop_calculate_collsion_detection(); |
| 1845 | | |
| 2124 | LEGACY_execute_b100(space, offset, data); |
| 1846 | 2125 | return; |
| 1847 | 2126 | } |
| 1848 | 2127 | |
| 1849 | 2128 | if (check_command_matches(command, 0xba0, 0xba2, 0xba4, 0xba6, 0x000, 0x000, 0x000, 0x000, funcval, funcmask)) |
| 1850 | 2129 | { |
| 1851 | 2130 | executed = 1; |
| 1852 | | m_LEGACY_cop_collision_info[1].y = (space.read_dword(cop_regs[1] + 4)); |
| 1853 | | m_LEGACY_cop_collision_info[1].x = (space.read_dword(cop_regs[1] + 8)); |
| 2131 | LEGACY_execute_a900(space, offset, data); |
| 1854 | 2132 | return; |
| 1855 | 2133 | } |
| 1856 | 2134 | |
| r32351 | r32352 | |
| 1858 | 2136 | if (check_command_matches(command, 0xb60, 0xbe0, 0xbe2, 0x000, 0x000, 0x000, 0x000, 0x000, funcval, funcmask)) |
| 1859 | 2137 | { |
| 1860 | 2138 | executed = 1; |
| 1861 | | m_LEGACY_cop_collision_info[1].hitbox = space.read_word(cop_regs[3]); |
| 1862 | | m_LEGACY_cop_collision_info[1].hitbox_y = space.read_word((cop_regs[3] & 0xffff0000) | (m_LEGACY_cop_collision_info[1].hitbox)); |
| 1863 | | m_LEGACY_cop_collision_info[1].hitbox_x = space.read_word(((cop_regs[3] & 0xffff0000) | (m_LEGACY_cop_collision_info[1].hitbox)) + 2); |
| 1864 | | |
| 1865 | | /* do the math */ |
| 1866 | | LEGACY_cop_take_hit_box_params(1); |
| 1867 | | cop_hit_status = LEGACY_cop_calculate_collsion_detection(); |
| 2139 | LEGACY_execute_b900(space, offset, data); |
| 1868 | 2140 | return; |
| 1869 | 2141 | } |
| 1870 | 2142 | |
| r32351 | r32352 | |
| 1872 | 2144 | if (check_command_matches(command, 0xb80, 0xba0, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 10, 0xfff3)) |
| 1873 | 2145 | { |
| 1874 | 2146 | executed = 1; |
| 1875 | | UINT8 offs; |
| 1876 | | int abs_x, abs_y, rel_xy; |
| 1877 | | |
| 1878 | | offs = (offset & 3) * 4; |
| 1879 | | |
| 1880 | | /* TODO: I really suspect that following two are actually taken from the 0xa180 macro command then internally loaded */ |
| 1881 | | abs_x = space.read_word(cop_regs[0] + 8) - m_cop_sprite_dma_abs_x; |
| 1882 | | abs_y = space.read_word(cop_regs[0] + 4) - m_cop_sprite_dma_abs_y; |
| 1883 | | rel_xy = space.read_word(m_cop_sprite_dma_src + 4 + offs); |
| 1884 | | |
| 1885 | | //if(rel_xy & 0x0706) |
| 1886 | | // printf("sprite rel_xy = %04x\n",rel_xy); |
| 1887 | | |
| 1888 | | if (rel_xy & 1) |
| 1889 | | space.write_word(cop_regs[4] + offs + 4, 0xc0 + abs_x - (rel_xy & 0xf8)); |
| 1890 | | else |
| 1891 | | space.write_word(cop_regs[4] + offs + 4, (((rel_xy & 0x78) + (abs_x)-((rel_xy & 0x80) ? 0x80 : 0)))); |
| 1892 | | |
| 1893 | | space.write_word(cop_regs[4] + offs + 6, (((rel_xy & 0x7800) >> 8) + (abs_y)-((rel_xy & 0x8000) ? 0x80 : 0))); |
| 2147 | LEGACY_execute_6980(space, offset, data); |
| 1894 | 2148 | return; |
| 1895 | 2149 | } |
| 1896 | 2150 | |
| r32351 | r32352 | |
| 1898 | 2152 | if (check_command_matches(command, 0x080, 0x882, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 10, 0xff00)) |
| 1899 | 2153 | { |
| 1900 | 2154 | executed = 1; |
| 1901 | | UINT8 offs; |
| 1902 | | |
| 1903 | | offs = (offset & 3) * 4; |
| 1904 | | |
| 1905 | | space.write_word(cop_regs[4] + offs + 0, space.read_word(m_cop_sprite_dma_src + offs) + (m_cop_sprite_dma_param & 0x3f)); |
| 1906 | | //space.write_word(cop_regs[4] + offs + 2,space.read_word(m_cop_sprite_dma_src+2 + offs)); |
| 2155 | LEGACY_execute_c480(space, offset, data); |
| 1907 | 2156 | return; |
| 1908 | 2157 | } |
| 1909 | 2158 | |
| r32351 | r32352 | |
| 1914 | 2163 | if (check_command_matches(command, 0xf80, 0xaa2, 0x984, 0x0c2, 0x000, 0x000, 0x000, 0x000, 5, 0x7ff7)) |
| 1915 | 2164 | { |
| 1916 | 2165 | executed = 1; |
| 1917 | | UINT8 offs; |
| 1918 | | int div; |
| 1919 | | INT16 dir_offset; |
| 1920 | | // INT16 offs_val; |
| 1921 | | |
| 1922 | | /* TODO: [4-7] could be mirrors of [0-3] (this is the only command so far that uses 4-7 actually)*/ |
| 1923 | | /* ? 0 + [4] */ |
| 1924 | | /* sub32 4 + [5] */ |
| 1925 | | /* write16h 8 + [4] */ |
| 1926 | | /* addmem16 4 + [6] */ |
| 1927 | | |
| 1928 | | // these two are obvious ... |
| 1929 | | // 0xf x 16 = 240 |
| 1930 | | // 0x14 x 16 = 320 |
| 1931 | | // what are these two instead? scale factor? offsets? (edit: offsets to apply from the initial sprite data) |
| 1932 | | // 0xfc69 ? |
| 1933 | | // 0x7f4 ? |
| 1934 | | //printf("%08x %08x %08x %08x %08x %08x %08x\n",cop_regs[0],cop_regs[1],cop_regs[2],cop_regs[3],cop_regs[4],cop_regs[5],cop_regs[6]); |
| 1935 | | |
| 1936 | | offs = (offset & 3) * 4; |
| 1937 | | |
| 1938 | | div = space.read_word(cop_regs[4] + offs); |
| 1939 | | dir_offset = space.read_word(cop_regs[4] + offs + 8); |
| 1940 | | // offs_val = space.read_word(cop_regs[3] + offs); |
| 1941 | | //420 / 180 = 500 : 400 = 30 / 50 = 98 / 18 |
| 1942 | | |
| 1943 | | /* TODO: this probably trips a cop status flag */ |
| 1944 | | if (div == 0) { div = 1; } |
| 1945 | | |
| 1946 | | |
| 1947 | | space.write_word((cop_regs[6] + offs + 4), ((space.read_word(cop_regs[5] + offs + 4) + dir_offset) / div)); |
| 2166 | LEGACY_execute_dde5(space, offset, data); |
| 1948 | 2167 | return; |
| 1949 | 2168 | } |
| 1950 | 2169 | |
| r32351 | r32352 | |
| 1952 | 2171 | if (check_command_matches(command, 0x3a0, 0x3a6, 0x380, 0xaa0, 0x2a6, 0x000, 0x000, 0x000, 8, 0xf3e7)) |
| 1953 | 2172 | { |
| 1954 | 2173 | executed = 1; |
| 1955 | | UINT8 cur_angle; |
| 1956 | | UINT16 flags; |
| 1957 | | |
| 1958 | | /* 0 [1] */ |
| 1959 | | /* 0xc [1] */ |
| 1960 | | /* 0 [0] */ |
| 1961 | | /* 0 [1] */ |
| 1962 | | /* 0xc [1] */ |
| 1963 | | |
| 1964 | | cur_angle = space.read_byte(cop_regs[1] + (0xc ^ 3)); |
| 1965 | | flags = space.read_word(cop_regs[1]); |
| 1966 | | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 1967 | | |
| 1968 | | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 1969 | | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 1970 | | |
| 1971 | | tempangle_compare &= 0xff; |
| 1972 | | tempangle_mod_val &= 0xff; |
| 1973 | | |
| 1974 | | cop_angle_target = tempangle_compare; |
| 1975 | | cop_angle_step = tempangle_mod_val; |
| 1976 | | |
| 1977 | | flags &= ~0x0004; |
| 1978 | | |
| 1979 | | int delta = cur_angle - tempangle_compare; |
| 1980 | | if (delta >= 128) |
| 1981 | | delta -= 256; |
| 1982 | | else if (delta < -128) |
| 1983 | | delta += 256; |
| 1984 | | if (delta < 0) |
| 1985 | | { |
| 1986 | | if (delta >= -tempangle_mod_val) |
| 1987 | | { |
| 1988 | | cur_angle = tempangle_compare; |
| 1989 | | flags |= 0x0004; |
| 1990 | | } |
| 1991 | | else |
| 1992 | | cur_angle += tempangle_mod_val; |
| 1993 | | } |
| 1994 | | else |
| 1995 | | { |
| 1996 | | if (delta <= tempangle_mod_val) |
| 1997 | | { |
| 1998 | | cur_angle = tempangle_compare; |
| 1999 | | flags |= 0x0004; |
| 2000 | | } |
| 2001 | | else |
| 2002 | | cur_angle -= tempangle_mod_val; |
| 2003 | | } |
| 2004 | | |
| 2005 | | space.write_byte(cop_regs[1] + (0 ^ 2), flags); |
| 2006 | | space.write_byte(cop_regs[1] + (0xc ^ 3), cur_angle); |
| 2174 | LEGACY_execute_6200(space, offset, data); |
| 2007 | 2175 | return; |
| 2008 | 2176 | } |
| 2009 | 2177 | |
| r32351 | r32352 | |
| 2013 | 2181 | if (check_command_matches(command, 0x380, 0x39a, 0x380, 0xa80, 0x29a, 0x000, 0x000, 0x000, 8, 0xf3e7)) |
| 2014 | 2182 | { |
| 2015 | 2183 | executed = 1; |
| 2016 | | UINT8 cur_angle; |
| 2017 | | UINT16 flags; |
| 2018 | | |
| 2019 | | cur_angle = space.read_byte(cop_regs[0] + (0x34 ^ 3)); |
| 2020 | | flags = space.read_word(cop_regs[0] + (0 ^ 2)); |
| 2021 | | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 2022 | | |
| 2023 | | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 2024 | | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 2025 | | |
| 2026 | | tempangle_compare &= 0xff; |
| 2027 | | tempangle_mod_val &= 0xff; |
| 2028 | | |
| 2029 | | cop_angle_target = tempangle_compare; |
| 2030 | | cop_angle_step = tempangle_mod_val; |
| 2031 | | |
| 2032 | | |
| 2033 | | flags &= ~0x0004; |
| 2034 | | |
| 2035 | | int delta = cur_angle - tempangle_compare; |
| 2036 | | if (delta >= 128) |
| 2037 | | delta -= 256; |
| 2038 | | else if (delta < -128) |
| 2039 | | delta += 256; |
| 2040 | | if (delta < 0) |
| 2041 | | { |
| 2042 | | if (delta >= -tempangle_mod_val) |
| 2043 | | { |
| 2044 | | cur_angle = tempangle_compare; |
| 2045 | | flags |= 0x0004; |
| 2046 | | } |
| 2047 | | else |
| 2048 | | cur_angle += tempangle_mod_val; |
| 2049 | | } |
| 2050 | | else |
| 2051 | | { |
| 2052 | | if (delta <= tempangle_mod_val) |
| 2053 | | { |
| 2054 | | cur_angle = tempangle_compare; |
| 2055 | | flags |= 0x0004; |
| 2056 | | } |
| 2057 | | else |
| 2058 | | cur_angle -= tempangle_mod_val; |
| 2059 | | } |
| 2060 | | |
| 2061 | | space.write_byte(cop_regs[0] + (0 ^ 3), flags); |
| 2062 | | space.write_word(cop_regs[0] + (0x34 ^ 3), cur_angle); |
| 2184 | LEGACY_execute_6200_grainbow(space, offset, data); |
| 2063 | 2185 | return; |
| 2064 | 2186 | } |
| 2065 | 2187 | |
| r32351 | r32352 | |
| 2067 | 2189 | if (check_command_matches(command, 0x984, 0xac4, 0xd82, 0xac2, 0x39b, 0xb9a, 0xb9a, 0xa9a, 5, 0xb07f)) |
| 2068 | 2190 | { |
| 2069 | 2191 | executed = 1; |
| 2070 | | int dy = space.read_dword(cop_regs[2] + 4) - space.read_dword(cop_regs[0] + 4); |
| 2071 | | int dx = space.read_dword(cop_regs[2] + 8) - space.read_dword(cop_regs[0] + 8); |
| 2072 | | |
| 2073 | | cop_status = 7; |
| 2074 | | if (!dx) { |
| 2075 | | cop_status |= 0x8000; |
| 2076 | | cop_angle = 0; |
| 2077 | | } |
| 2078 | | else { |
| 2079 | | cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI; |
| 2080 | | if (dx < 0) |
| 2081 | | cop_angle += 0x80; |
| 2082 | | } |
| 2083 | | |
| 2084 | | m_LEGACY_r0 = dy; |
| 2085 | | m_LEGACY_r1 = dx; |
| 2086 | | |
| 2087 | | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
| 2088 | | |
| 2089 | | if (data & 0x80) |
| 2090 | | space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle); |
| 2192 | LEGACY_execute_e30e(space, offset, data); |
| 2091 | 2193 | return; |
| 2092 | 2194 | } |
| 2093 | 2195 | |
| r32351 | r32352 | |
| 2096 | 2198 | if (check_command_matches(command, 0xac2, 0x9e0, 0x0a2, 0x000, 0x000, 0x000, 0x000, 0x000, 5, 0xfffb)) |
| 2097 | 2199 | { |
| 2098 | 2200 | executed = 1; |
| 2099 | | UINT8 *ROM = space.machine().root_device().memregion("maincpu")->base(); |
| 2100 | | UINT32 rom_addr = (m_cop_rom_addr_hi << 16 | m_cop_rom_addr_lo) & ~1; |
| 2101 | | UINT16 rom_data = (ROM[rom_addr + 0]) | (ROM[rom_addr + 1] << 8); |
| 2102 | | |
| 2103 | | /* writes to some unemulated COP registers, then puts the result in here, adding a parameter taken from ROM */ |
| 2104 | | //space.write_word(cop_regs[0]+(0x44 + offset * 4), rom_data); |
| 2105 | | |
| 2106 | | printf("%04x%04x %04x %04x\n", m_cop_rom_addr_hi, m_cop_rom_addr_lo, m_cop_rom_addr_unk, rom_data); |
| 2201 | LEGACY_execute_d104(space, offset, data); |
| 2107 | 2202 | return; |
| 2108 | 2203 | } |
| 2109 | 2204 | |
| 2110 | | if (executed == 0) printf("did not execute %04x\n", data); |
| 2205 | if (executed == 0) |
| 2206 | if (data!=0xf105) printf("did not execute %04x\n", data); // cup soccer triggers this a lot (and others) |
| 2111 | 2207 | } |
| 2112 | 2208 | |
| 2113 | 2209 | |