trunk/src/mame/machine/raiden2cop.c
| r32459 | r32460 | |
| 201 | 201 | else space.write_word(address, data); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | void raiden2cop_device::cop_write_byte(address_space &space, int address, UINT8 data) |
| 205 | { |
| 206 | if (m_cpu_is_68k) space.write_byte(address ^ 3, data); |
| 207 | else space.write_byte(address, data); |
| 208 | } |
| 204 | 209 | |
| 210 | |
| 205 | 211 | /*** Command Table uploads ***/ |
| 206 | 212 | |
| 207 | 213 | |
| r32459 | r32460 | |
| 1192 | 1198 | */ |
| 1193 | 1199 | void raiden2cop_device::execute_6200(address_space &space, int offset, UINT16 data) |
| 1194 | 1200 | { |
| 1195 | | UINT8 angle = cop_read_byte(space, cop_regs[0] + 0x34); |
| 1196 | | UINT16 flags = cop_read_word(space, cop_regs[0]); |
| 1201 | int primary_reg = 0; |
| 1202 | int primary_offset = 0x34; |
| 1203 | |
| 1204 | UINT8 angle = cop_read_byte(space, cop_regs[primary_reg] + primary_offset); |
| 1205 | UINT16 flags = cop_read_word(space, cop_regs[primary_reg]); |
| 1197 | 1206 | cop_angle_target &= 0xff; |
| 1198 | 1207 | cop_angle_step &= 0xff; |
| 1199 | 1208 | flags &= ~0x0004; |
| r32459 | r32460 | |
| 1218 | 1227 | else |
| 1219 | 1228 | angle -= cop_angle_step; |
| 1220 | 1229 | } |
| 1221 | | space.write_word(cop_regs[0], flags); |
| 1222 | | space.write_byte(cop_regs[0] + 0x34, angle); |
| 1223 | | } |
| 1230 | |
| 1231 | cop_write_word(space, cop_regs[primary_reg], flags); |
| 1224 | 1232 | |
| 1233 | if (!m_cpu_is_68k) |
| 1234 | cop_write_byte(space, cop_regs[primary_reg] + primary_offset, angle); |
| 1235 | else // angle is a byte, but grainbow (cave mid-boss) is only happy with write-word, could be more endian weirdness, or it always writes a word? |
| 1236 | cop_write_word(space, cop_regs[primary_reg] + primary_offset, angle); |
| 1225 | 1237 | |
| 1226 | | void raiden2cop_device::LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data) |
| 1227 | | { |
| 1228 | | UINT8 cur_angle; |
| 1229 | | UINT16 flags; |
| 1230 | | |
| 1231 | | cur_angle = cop_read_byte(space,cop_regs[0] + 0x34); |
| 1232 | | flags = cop_read_word(space, cop_regs[0]); |
| 1233 | | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 1234 | | |
| 1235 | | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 1236 | | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 1237 | | |
| 1238 | | tempangle_compare &= 0xff; |
| 1239 | | tempangle_mod_val &= 0xff; |
| 1240 | | |
| 1241 | | cop_angle_target = tempangle_compare; |
| 1242 | | cop_angle_step = tempangle_mod_val; |
| 1243 | | |
| 1244 | | |
| 1245 | | flags &= ~0x0004; |
| 1246 | | |
| 1247 | | int delta = cur_angle - tempangle_compare; |
| 1248 | | if (delta >= 128) |
| 1249 | | delta -= 256; |
| 1250 | | else if (delta < -128) |
| 1251 | | delta += 256; |
| 1252 | | if (delta < 0) |
| 1253 | | { |
| 1254 | | if (delta >= -tempangle_mod_val) |
| 1255 | | { |
| 1256 | | cur_angle = tempangle_compare; |
| 1257 | | flags |= 0x0004; |
| 1258 | | } |
| 1259 | | else |
| 1260 | | cur_angle += tempangle_mod_val; |
| 1261 | | } |
| 1262 | | else |
| 1263 | | { |
| 1264 | | if (delta <= tempangle_mod_val) |
| 1265 | | { |
| 1266 | | cur_angle = tempangle_compare; |
| 1267 | | flags |= 0x0004; |
| 1268 | | } |
| 1269 | | else |
| 1270 | | cur_angle -= tempangle_mod_val; |
| 1271 | | } |
| 1272 | | |
| 1273 | | space.write_byte(cop_regs[0] + (0 ^ 3), flags); // this is a word in the avoce |
| 1274 | | space.write_word(cop_regs[0] + (0x34 ^ 3), cur_angle); // why ^3 on a word? should it be a byte, it is in the above |
| 1275 | 1238 | } |
| 1276 | 1239 | |
| 1277 | 1240 | |
| 1278 | 1241 | void raiden2cop_device::LEGACY_execute_6200(address_space &space, int offset, UINT16 data) // this is for cupsoc, different sequence, works on different registers |
| 1279 | 1242 | { |
| 1280 | | UINT8 cur_angle; |
| 1281 | | UINT16 flags; |
| 1243 | int primary_reg = 1; |
| 1244 | int primary_offset = 0xc; |
| 1282 | 1245 | |
| 1283 | | /* 0 [1] */ |
| 1284 | | /* 0xc [1] */ |
| 1285 | | /* 0 [0] */ |
| 1286 | | /* 0 [1] */ |
| 1287 | | /* 0xc [1] */ |
| 1288 | | |
| 1289 | | cur_angle = space.read_byte(cop_regs[1] + (0xc ^ 3)); |
| 1290 | | flags = space.read_word(cop_regs[1]); |
| 1291 | | //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct? |
| 1292 | | |
| 1293 | | INT8 tempangle_compare = (INT8)cop_angle_target; |
| 1294 | | INT8 tempangle_mod_val = (INT8)cop_angle_step; |
| 1295 | | |
| 1296 | | tempangle_compare &= 0xff; |
| 1297 | | tempangle_mod_val &= 0xff; |
| 1298 | | |
| 1299 | | cop_angle_target = tempangle_compare; |
| 1300 | | cop_angle_step = tempangle_mod_val; |
| 1301 | | |
| 1246 | UINT8 angle = cop_read_byte(space, cop_regs[primary_reg] + primary_offset); |
| 1247 | UINT16 flags = cop_read_word(space, cop_regs[primary_reg]); |
| 1248 | cop_angle_target &= 0xff; |
| 1249 | cop_angle_step &= 0xff; |
| 1302 | 1250 | flags &= ~0x0004; |
| 1303 | | |
| 1304 | | int delta = cur_angle - tempangle_compare; |
| 1251 | int delta = angle - cop_angle_target; |
| 1305 | 1252 | if (delta >= 128) |
| 1306 | 1253 | delta -= 256; |
| 1307 | 1254 | else if (delta < -128) |
| 1308 | 1255 | delta += 256; |
| 1309 | | if (delta < 0) |
| 1310 | | { |
| 1311 | | if (delta >= -tempangle_mod_val) |
| 1312 | | { |
| 1313 | | cur_angle = tempangle_compare; |
| 1256 | if (delta < 0) { |
| 1257 | if (delta >= -cop_angle_step) { |
| 1258 | angle = cop_angle_target; |
| 1314 | 1259 | flags |= 0x0004; |
| 1315 | 1260 | } |
| 1316 | 1261 | else |
| 1317 | | cur_angle += tempangle_mod_val; |
| 1262 | angle += cop_angle_step; |
| 1318 | 1263 | } |
| 1319 | | else |
| 1320 | | { |
| 1321 | | if (delta <= tempangle_mod_val) |
| 1322 | | { |
| 1323 | | cur_angle = tempangle_compare; |
| 1264 | else { |
| 1265 | if (delta <= cop_angle_step) { |
| 1266 | angle = cop_angle_target; |
| 1324 | 1267 | flags |= 0x0004; |
| 1325 | 1268 | } |
| 1326 | 1269 | else |
| 1327 | | cur_angle -= tempangle_mod_val; |
| 1270 | angle -= cop_angle_step; |
| 1328 | 1271 | } |
| 1272 | |
| 1273 | cop_write_word(space, cop_regs[primary_reg], flags); |
| 1329 | 1274 | |
| 1330 | | space.write_byte(cop_regs[1] + (0 ^ 2), flags); |
| 1331 | | space.write_byte(cop_regs[1] + (0xc ^ 3), cur_angle); |
| 1275 | if (!m_cpu_is_68k) |
| 1276 | cop_write_byte(space, cop_regs[primary_reg] + primary_offset, angle); |
| 1277 | else // angle is a byte, but grainbow (cave mid-boss) is only happy with write-word, could be more endian weirdness, or it always writes a word? |
| 1278 | cop_write_word(space, cop_regs[primary_reg] + primary_offset, angle); |
| 1332 | 1279 | } |
| 1333 | 1280 | |
| 1334 | 1281 | /* |
| r32459 | r32460 | |
| 2305 | 2252 | if (check_command_matches(command, 0x380, 0x39a, 0x380, 0xa80, 0x29a, 0x000, 0x000, 0x000, 8, 0xf3e7)) |
| 2306 | 2253 | { |
| 2307 | 2254 | executed = 1; |
| 2308 | | LEGACY_execute_6200_grainbow(space, offset, data); |
| 2255 | execute_6200(space, offset, data); |
| 2309 | 2256 | return; |
| 2310 | 2257 | } |
| 2311 | 2258 | |
trunk/src/mame/machine/raiden2cop.h
| r32459 | r32460 | |
| 193 | 193 | void LEGACY_execute_42c2(address_space &space, int offset, UINT16 data); |
| 194 | 194 | void LEGACY_execute_e30e(address_space &space, int offset, UINT16 data); |
| 195 | 195 | void LEGACY_execute_6200(address_space &space, int offset, UINT16 data); |
| 196 | | void LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data); |
| 197 | 196 | void LEGACY_execute_dde5(address_space &space, int offset, UINT16 data); |
| 198 | 197 | void LEGACY_execute_d104(address_space &space, int offset, UINT16 data); |
| 199 | 198 | void LEGACY_execute_6980(address_space &space, int offset, UINT16 data); |
| r32459 | r32460 | |
| 252 | 251 | UINT16 cop_read_word(address_space &space, int address); |
| 253 | 252 | UINT8 cop_read_byte(address_space &space, int address); |
| 254 | 253 | void cop_write_word(address_space &space, int address, UINT16 data); |
| 254 | void cop_write_byte(address_space &space, int address, UINT8 data); |
| 255 | 255 | |
| 256 | 256 | // DEBUG |
| 257 | 257 | void dump_table(); |