trunk/src/mame/machine/seicop.c
| r17884 | r17885 | |
| 1400 | 1400 | 0x470 |
| 1401 | 1401 | ???? ???? ???? ???? External pin register, used by some games for prg/gfx banking (per-game specific) |
| 1402 | 1402 | |
| 1403 | |
| 1404 | --- |
| 1405 | |
| 1406 | commands 0x8100/0x8900: |
| 1407 | |
| 1408 | status always 0x8007 (doesn't seem to care) |
| 1409 | raw | amp | scale | sin | cos | |
| 1410 | ------------------------------------------ |
| 1411 | y 0x00 x 0x00000000 0x00000000 (i.e. if amp is 0 then sin/cos are zero too) |
| 1412 | 0 0x40 0 0x00000000 0x00020000 |
| 1413 | 0 0x40 1 0x00000000 0x00040000 |
| 1414 | 0 0x40 2 0x00000000 0x00080000 |
| 1415 | 0 0x40 3 0x00000000 0x00100000 |
| 1416 | 0x40 0x40 0 0x00020000 0x00000000 |
| 1417 | 0x40 0x40 1 0x00040000 0x00000000 |
| 1418 | 0x40 0x40 2 0x00080000 0x00000000 |
| 1419 | 0x40 0x40 3 0x00100000 0x00000000 |
| 1420 | 0x80 0x40 0 0x00000000 0xfffc0000 |
| 1421 | 0x80 0x40 1 0x00000000 0xfff80000 |
| 1422 | 0x80 0x40 2 0x00000000 0xfff00000 |
| 1423 | 0x80 0x40 3 0x00000000 0xffe00000 |
| 1424 | 0xc0 0x40 0 0xfffc0000 0x00000000 |
| 1425 | 0xc0 0x40 1 0xfff80000 0x00000000 |
| 1426 | 0xc0 0x40 2 0xfff00000 0x00000000 |
| 1427 | 0xc0 0x40 3 0xffe00000 0x00000000 |
| 1428 | 0 0x80 0 0x00000000 0x00040000 |
| 1429 | 0 0x80 1 0x00000000 0x00080000 |
| 1430 | 0 0x80 2 0x00000000 0x00100000 |
| 1431 | 0 0x80 3 0x00000000 0x00200000 |
| 1432 | 0x40 0x80 0 0x00040000 0x00000000 |
| 1433 | 0x40 0x80 1 0x00080000 0x00000000 |
| 1434 | 0x40 0x80 2 0x00100000 0x00000000 |
| 1435 | 0x40 0x80 3 0x00200000 0x00000000 |
| 1436 | 0x80 0x80 0 0x00000000 0xfff80000 |
| 1437 | 0x80 0x80 1 0x00000000 0xfff00000 |
| 1438 | 0x80 0x80 2 0x00000000 0xffe00000 |
| 1439 | 0x80 0x80 3 0x00000000 0xffc00000 |
| 1440 | 0xc0 0x80 0 0xfff80000 0x00000000 |
| 1441 | 0xc0 0x80 1 0xfff00000 0x00000000 |
| 1442 | 0xc0 0x80 2 0xffe00000 0x00000000 |
| 1443 | 0xc0 0x80 3 0xffc00000 0x00000000 |
| 1444 | 0 0xc0 0 0x00000000 0x00060000 |
| 1445 | 0 0xc0 1 0x00000000 0x000c0000 |
| 1446 | 0 0xc0 2 0x00000000 0x00180000 |
| 1447 | 0 0xc0 3 0x00000000 0x00300000 |
| 1448 | 0x40 0xc0 0 0x00060000 0x00000000 |
| 1449 | 0x40 0xc0 1 0x000c0000 0x00000000 |
| 1450 | 0x40 0xc0 2 0x00180000 0x00000000 |
| 1451 | 0x40 0xc0 3 0x00300000 0x00000000 |
| 1452 | 0x80 0xc0 0 0x00000000 0xfff40000 |
| 1453 | 0x80 0xc0 1 0x00000000 0xffe80000 |
| 1454 | 0x80 0xc0 2 0x00000000 0xffd00000 |
| 1455 | 0x80 0xc0 3 0x00000000 0xffa00000 |
| 1456 | 0xc0 0xc0 0 0xfff40000 0x00000000 |
| 1457 | 0xc0 0xc0 1 0xffe80000 0x00000000 |
| 1458 | 0xc0 0xc0 2 0xffd00000 0x00000000 |
| 1459 | 0xc0 0xc0 3 0xffa00000 0x00000000 |
| 1403 | 1460 | */ |
| 1404 | 1461 | |
| 1405 | 1462 | #include "emu.h" |
| r17884 | r17885 | |
| 2040 | 2097 | |
| 2041 | 2098 | case (0x044/2): |
| 2042 | 2099 | { |
| 2043 | | /*TODO: this appears to control trigonometry maths, but all games here doesn't seem to like current implementation ... */ |
| 2044 | | cop_scale = 1; |
| 2045 | | if(data == 4) |
| 2046 | | cop_scale = 0; |
| 2100 | cop_scale = data & 3; |
| 2047 | 2101 | break; |
| 2048 | 2102 | } |
| 2049 | 2103 | |
| r17884 | r17885 | |
| 2181 | 2235 | { |
| 2182 | 2236 | int raw_angle = (space->read_word(cop_register[0]+(0x34^2)) & 0xff); |
| 2183 | 2237 | double angle = raw_angle * M_PI / 128; |
| 2184 | | double amp = 65536*(space->read_word(cop_register[0]+(0x36^2)) & 0xff); |
| 2238 | double amp = (65536 >> 5)*(space->read_word(cop_register[0]+(0x36^2)) & 0xff); |
| 2239 | int res; |
| 2185 | 2240 | |
| 2186 | 2241 | /* TODO: up direction, why? */ |
| 2187 | 2242 | if(raw_angle == 0xc0) |
| 2188 | 2243 | amp*=2; |
| 2189 | 2244 | |
| 2190 | | space->write_dword(cop_register[0] + 16, int(amp*sin(angle)) >> (5-cop_scale)); |
| 2245 | res = int(amp*sin(angle)) << cop_scale; |
| 2246 | |
| 2247 | space->write_dword(cop_register[0] + 16, res); |
| 2191 | 2248 | return; |
| 2192 | 2249 | } |
| 2193 | 2250 | |
| r17884 | r17885 | |
| 2208 | 2265 | { |
| 2209 | 2266 | int raw_angle = (space->read_word(cop_register[0]+(0x34^2)) & 0xff); |
| 2210 | 2267 | double angle = raw_angle * M_PI / 128; |
| 2211 | | double amp = 65536*(space->read_word(cop_register[0]+(0x36^2)) & 0xff); |
| 2268 | double amp = (65536 >> 5)*(space->read_word(cop_register[0]+(0x36^2)) & 0xff); |
| 2269 | int res; |
| 2212 | 2270 | |
| 2213 | 2271 | /* TODO: left direction, why? */ |
| 2214 | 2272 | if(raw_angle == 0x80) |
| 2215 | 2273 | amp*=2; |
| 2216 | 2274 | |
| 2217 | | space->write_dword(cop_register[0] + 20, int(amp*cos(angle)) >> (5-cop_scale)); |
| 2275 | res = int(amp*cos(angle)) << cop_scale; |
| 2276 | |
| 2277 | space->write_dword(cop_register[0] + 20, res); |
| 2218 | 2278 | return; |
| 2219 | 2279 | } |
| 2220 | 2280 | |
| r17884 | r17885 | |
| 2295 | 2355 | if(COP_CMD(0xf9a,0xb9a,0xb9c,0xb9c,0xb9c,0x29c,0x000,0x000,5,0xfcdd)) |
| 2296 | 2356 | { |
| 2297 | 2357 | int div = space->read_word(cop_register[0]+(0x36^2)); |
| 2358 | int res; |
| 2359 | |
| 2298 | 2360 | if(!div) |
| 2361 | { |
| 2362 | printf("divide by zero?\n"); |
| 2299 | 2363 | div = 1; |
| 2364 | } |
| 2300 | 2365 | |
| 2301 | | space->write_word(cop_register[0]+(0x38^2), (space->read_word(cop_register[0]+(0x38^2)) << (5-cop_scale)) / div); |
| 2366 | res = space->read_word(cop_register[0]+(0x38^2)) / div; |
| 2367 | res <<= cop_scale + 2; /* TODO: check this */ |
| 2368 | |
| 2369 | space->write_word(cop_register[0]+(0x38^2), res); |
| 2302 | 2370 | return; |
| 2303 | 2371 | } |
| 2304 | 2372 | |
trunk/src/mame/drivers/raiden2.c
| r17884 | r17885 | |
| 428 | 428 | WRITE16_MEMBER(raiden2_state::cop_scale_w) |
| 429 | 429 | { |
| 430 | 430 | COMBINE_DATA(&cop_scale); |
| 431 | cop_scale &= 3; |
| 431 | 432 | } |
| 432 | 433 | |
| 433 | 434 | READ16_MEMBER(raiden2_state::cop_reg_high_r) |
| r17884 | r17885 | |
| 540 | 541 | |
| 541 | 542 | case 0x42c2: { // 42c2 0005 fcdd 0040 - 0f9a 0b9a 0b9c 0b9c 0b9c 029c 0000 0000 |
| 542 | 543 | int div = space.read_word(cop_regs[0]+0x36); |
| 544 | int res; |
| 543 | 545 | if(!div) |
| 546 | { |
| 547 | printf("divide by zero?\n"); |
| 544 | 548 | div = 1; |
| 545 | | space.write_word(cop_regs[0]+0x38, (space.read_word(cop_regs[0]+0x38) << (5-cop_scale)) / div); |
| 549 | } |
| 550 | res = space.read_word(cop_regs[0]+(0x38)) / div; |
| 551 | res <<= cop_scale + 2; /* TODO: check this */ |
| 552 | space.write_word(cop_regs[0]+0x38, res); |
| 546 | 553 | break; |
| 547 | 554 | } |
| 548 | 555 | |
| 549 | 556 | case 0x8100: { // 8100 0007 fdfb 0080 - 0b9a 0b88 0888 0000 0000 0000 0000 0000 |
| 550 | | int raw_angle = (space.read_word(cop_regs[0]+0x34) & 0xff); |
| 557 | int raw_angle = (space.read_word(cop_regs[0]+(0x34)) & 0xff); |
| 551 | 558 | double angle = raw_angle * M_PI / 128; |
| 552 | | double amp = 65536*(space.read_word(cop_regs[0]+0x36) & 0xff); |
| 559 | double amp = (65536 >> 5)*(space.read_word(cop_regs[0]+(0x36)) & 0xff); |
| 560 | int res; |
| 553 | 561 | /* TODO: up direction, why? (check machine/seicop.c) */ |
| 554 | 562 | if(raw_angle == 0xc0) |
| 555 | 563 | amp*=2; |
| 556 | | space.write_dword(cop_regs[0] + 16, int(amp*sin(angle)) >> (5-cop_scale)); |
| 564 | res = int(amp*sin(angle)) << cop_scale; |
| 565 | space.write_dword(cop_regs[0] + 16, res); |
| 557 | 566 | break; |
| 558 | 567 | } |
| 559 | 568 | |
| 560 | 569 | case 0x8900: { // 8900 0007 fdfb 0088 - 0b9a 0b8a 088a 0000 0000 0000 0000 0000 |
| 561 | | int raw_angle = (space.read_word(cop_regs[0]+0x34) & 0xff); |
| 570 | int raw_angle = (space.read_word(cop_regs[0]+(0x34)) & 0xff); |
| 562 | 571 | double angle = raw_angle * M_PI / 128; |
| 563 | | double amp = 65536*(space.read_word(cop_regs[0]+0x36) & 0xff); |
| 572 | double amp = (65536 >> 5)*(space.read_word(cop_regs[0]+(0x36)) & 0xff); |
| 573 | int res; |
| 564 | 574 | /* TODO: left direction, why? (check machine/seicop.c) */ |
| 565 | 575 | if(raw_angle == 0x80) |
| 566 | 576 | amp*=2; |
| 567 | | space.write_dword(cop_regs[0] + 20, int(amp*cos(angle)) >> (5-cop_scale)); |
| 577 | res = int(amp*cos(angle)) << cop_scale; |
| 578 | space.write_dword(cop_regs[0] + 20, res); |
| 568 | 579 | break; |
| 569 | 580 | } |
| 570 | 581 | |