trunk/src/mame/machine/seicop.c
r17978 | r17979 | |
1478 | 1478 | 0x1c0 0x00 0x71 |
1479 | 1479 | 0x1e0 0x00 0x72 |
1480 | 1480 | |
| 1481 | |
| 1482 | command 0x3bb0 |
| 1483 | dx dy | dist |
| 1484 | -----------|----- |
| 1485 | 0x00 0x00 | 0xb5 |
| 1486 | 0x20 0x00 | 0xa0 |
| 1487 | 0x40 0x00 | 0x8f |
| 1488 | 0x60 0x00 | 0x83 |
| 1489 | 0x80 0x00 | 0x80 |
| 1490 | 0xa0 0x00 | 0x83 |
| 1491 | 0xc0 0x00 | 0x8f |
| 1492 | 0xe0 0x00 | 0xa0 |
| 1493 | |
| 1494 | command 0x42c2 |
| 1495 | dx dy | stat dist angle scale r34(r) r36 r38* r3a |
| 1496 | -----------|----------------------------------------------------- |
| 1497 | 0x00 0x00 | 0x0067 0x20 0x20 0x0000 0x0001 0x0020 0xb5 0x16a0 |
| 1498 | 0x20 0x00 | 0x0027 0x20 0x26 0x0000 0x0001 0x0026 0xa0 0x1400 |
| 1499 | 0x40 0x00 | 0x0067 0x20 0x2d 0x0000 0x0001 0x002d 0x8f 0x11e3 |
| 1500 | 0x60 0x00 | 0x0067 0x20 0x36 0x0000 0x0001 0x0036 0x83 0x107e |
| 1501 | 0x80 0x00 | 0x0027 0x20 0x00 0x0000 0x0001 0x0000 0x80 0x1000 |
| 1502 | 0xa0 0x00 | 0x0067 0x20 0x4a 0x0000 0x0001 0x004a 0x83 0x107e |
| 1503 | 0xc0 0x00 | 0x0067 0x20 0x53 0x0000 0x0001 0x0053 0x8f 0x11e3 |
| 1504 | 0xe0 0x00 | 0x0027 0x20 0x5a 0x0000 0x0001 0x005a 0xa0 0x1400 |
| 1505 | |
| 1506 | 0x00 0x00 | ****** 0x10 0x20 0x0000 0x0002 0x0020 0xb5 0x0b50 |
| 1507 | 0x20 0x00 | ****** 0x10 0x26 0x0000 0x0002 0x0026 0xa0 0x0a00 |
| 1508 | 0x40 0x00 | ****** 0x10 0x2d 0x0000 0x0002 0x002d 0x8f 0x08f1 |
| 1509 | 0x60 0x00 | ****** 0x10 0x36 0x0000 0x0002 0x0036 0x83 0x083f |
| 1510 | 0x80 0x00 | ****** 0x10 0x00 0x0000 0x0002 0x0000 0x80 0x0800 |
| 1511 | 0xa0 0x00 | ****** 0x10 0x4a 0x0000 0x0002 0x004a 0x83 0x083f |
| 1512 | 0xc0 0x00 | ****** 0x10 0x53 0x0000 0x0002 0x0053 0x8f 0x08f1 |
| 1513 | 0xe0 0x00 | ****** 0x10 0x5a 0x0000 0x0002 0x005a 0xa0 0x0a00 |
| 1514 | |
| 1515 | 0x00 0x00 | ****** 0x08 0x20 0x0000 0x0004 0x0020 0xb5 0x05a8 |
| 1516 | 0x20 0x00 | ****** 0x08 0x26 0x0000 0x0004 0x0026 0xa0 0x0500 |
| 1517 | |
| 1518 | 0x20 0x00 | ****** 0x02 0x26 0x0000 0x0010 0x0026 0xa0 0x0140 |
| 1519 | |
| 1520 | 0xc0 0x00 | 0x0047 0x01 0x53 0x0000 0x0020 0x0053 0x8f 0x008f |
| 1521 | |
| 1522 | 0x60 0x00 | 0x0047 0x00 0x36 0x0000 0x0040 0x0036 0x83 0x0041 |
| 1523 | |
| 1524 | 0x40 0x00 | 0x0047 0x00 0x2d 0x0000 0x0080 0x002d 0x8f 0x0023 |
| 1525 | |
| 1526 | 0x40 0x00 | 0x8007 0x00 0x2d 0x0000 0x0400 0x008f 0x8f 0x0000 |
| 1527 | |
| 1528 | 0x00 0x00 | 0x0067 0x10 0x2d 0x0000 0x0001 0x0020 0xb5 0x0b50 |
| 1529 | |
| 1530 | |
| 1531 | *same as 0x3bb0 |
1481 | 1532 | */ |
1482 | 1533 | |
1483 | 1534 | #include "emu.h" |
r17978 | r17979 | |
1865 | 1916 | { |
1866 | 1917 | INT16 start_x,start_y,end_x,end_y; |
1867 | 1918 | |
1868 | | end_y = INT8(cop_collision_info[offs].hitbox_y >> 8); |
1869 | | start_y = INT8(cop_collision_info[offs].hitbox_y); |
1870 | | end_x = INT8(cop_collision_info[offs].hitbox_x >> 8); |
1871 | | start_x = INT8(cop_collision_info[offs].hitbox_x); |
| 1919 | /* TODO: hack for SD Gundam */ |
| 1920 | #if 0 |
| 1921 | if(cop_collision_info[offs].hitbox_y == 0x2800 && cop_collision_info[offs].hitbox_x == 0xa000) |
| 1922 | { |
| 1923 | end_y = 0xff; |
| 1924 | start_y = -16; |
| 1925 | end_x = 0xff; |
| 1926 | start_x = 0; |
| 1927 | } |
| 1928 | else |
| 1929 | #endif |
| 1930 | { |
| 1931 | end_y = INT8(cop_collision_info[offs].hitbox_y >> 8); |
| 1932 | start_y = INT8(cop_collision_info[offs].hitbox_y); |
| 1933 | end_x = INT8(cop_collision_info[offs].hitbox_x >> 8); |
| 1934 | start_x = INT8(cop_collision_info[offs].hitbox_x); |
| 1935 | } |
1872 | 1936 | |
1873 | 1937 | cop_collision_info[offs].min_x = start_x + (cop_collision_info[offs].x >> 16); |
1874 | 1938 | cop_collision_info[offs].min_y = start_y + (cop_collision_info[offs].y >> 16); |
r17978 | r17979 | |
1887 | 1951 | if(cop_collision_info[0].max_x >= cop_collision_info[1].min_x && cop_collision_info[0].min_x <= cop_collision_info[1].max_x) |
1888 | 1952 | res &= ~2; |
1889 | 1953 | |
| 1954 | if(cop_collision_info[1].max_x >= cop_collision_info[0].min_x && cop_collision_info[1].min_x <= cop_collision_info[0].max_x) |
| 1955 | res &= ~2; |
| 1956 | |
1890 | 1957 | /* outbound Y check */ |
1891 | 1958 | if(cop_collision_info[0].max_y >= cop_collision_info[1].min_y && cop_collision_info[0].min_y <= cop_collision_info[1].max_y) |
1892 | 1959 | res &= ~1; |
1893 | 1960 | |
| 1961 | if(cop_collision_info[1].max_y >= cop_collision_info[0].min_y && cop_collision_info[1].min_y <= cop_collision_info[0].max_y) |
| 1962 | res &= ~1; |
| 1963 | |
1894 | 1964 | cop_hit_val_x = (cop_collision_info[0].x - cop_collision_info[1].x) >> 16; |
1895 | 1965 | cop_hit_val_y = (cop_collision_info[0].y - cop_collision_info[1].y) >> 16; |
1896 | 1966 | cop_hit_val_z = 1; |
1897 | 1967 | cop_hit_val_unk = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning |
1898 | 1968 | |
1899 | | |
1900 | 1969 | //popmessage("%d %d %04x %04x %04x %04x",cop_hit_val_x,cop_hit_val_y,cop_collision_info[0].hitbox_x,cop_collision_info[0].hitbox_y,cop_collision_info[1].hitbox_x,cop_collision_info[1].hitbox_y); |
1901 | 1970 | |
1902 | 1971 | //if(res == 0) |
1903 | 1972 | //popmessage("0:%08x %08x %08x 1:%08x %08x %08x\n",cop_collision_info[0].x,cop_collision_info[0].y,cop_collision_info[0].hitbox,cop_collision_info[1].x,cop_collision_info[1].y,cop_collision_info[1].hitbox); |
| 1973 | // popmessage("0:%08x %08x %08x %08x 1:%08x %08x %08x %08x\n",cop_collision_info[0].min_x,cop_collision_info[0].max_x,cop_collision_info[0].min_y, cop_collision_info[0].max_y, |
| 1974 | // cop_collision_info[1].min_x,cop_collision_info[1].max_x,cop_collision_info[1].min_y, cop_collision_info[1].max_y); |
1904 | 1975 | |
1905 | 1976 | return res; |
1906 | 1977 | } |
r17978 | r17979 | |
2228 | 2299 | |
2229 | 2300 | offs = (offset & 3) * 4; |
2230 | 2301 | |
2231 | | /* TODO: 0x1c operation? */ |
2232 | | |
2233 | 2302 | space.write_dword(cop_register[0] + 0x04 + offs, space.read_dword(cop_register[0] + 0x04 + offs) + space.read_dword(cop_register[0] + 0x10 + offs)); |
| 2303 | space.write_dword(cop_register[0] + 0x1c + offs, space.read_dword(cop_register[0] + 0x10 + offs) + space.read_dword(cop_register[0] + 0x1c + offs)); |
2234 | 2304 | return; |
2235 | 2305 | } |
2236 | 2306 | |
r17978 | r17979 | |
2323 | 2393 | cop_angle += 0x80; |
2324 | 2394 | } |
2325 | 2395 | |
| 2396 | r0 = dy; |
| 2397 | r1 = dx; |
| 2398 | |
2326 | 2399 | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
2327 | 2400 | |
2328 | 2401 | if(cop_mcu_ram[offset] & 0x80) |
r17978 | r17979 | |
2368 | 2441 | int dy = r0; |
2369 | 2442 | int dx = r1; |
2370 | 2443 | |
2371 | | dx = dx >> 16; |
2372 | | dy = dy >> 16; |
| 2444 | dx >>= 16; |
| 2445 | dy >>= 16; |
2373 | 2446 | cop_dist = sqrt((double)(dx*dx+dy*dy)); |
2374 | 2447 | |
2375 | 2448 | if(cop_mcu_ram[offset] & 0x80) |
2376 | | space.write_word(cop_register[0]+(0x38^2), cop_dist); |
| 2449 | space.write_word(cop_register[0]+(0x38), cop_dist); |
2377 | 2450 | return; |
2378 | 2451 | } |
2379 | 2452 | |
r17978 | r17979 | |
2388 | 2461 | v2 = (x & 1023)*32 |
2389 | 2462 | val = !v1 ? 32767 : trunc(v2/v1+0.5) |
2390 | 2463 | */ |
2391 | | /* TODO: this is WRONG! */ |
2392 | 2464 | if(COP_CMD(0xf9a,0xb9a,0xb9c,0xb9c,0xb9c,0x29c,0x000,0x000,5,0xfcdd)) |
2393 | 2465 | { |
2394 | 2466 | int div = space.read_word(cop_register[0]+(0x36^2)); |
r17978 | r17979 | |
2400 | 2472 | div = 1; |
2401 | 2473 | } |
2402 | 2474 | |
2403 | | res = space.read_word(cop_register[0]+(0x38^2)) / div; |
2404 | | res <<= cop_scale + 2; /* TODO: check this */ |
| 2475 | /* TODO: not yet accurate (throws some bits away while converting) */ |
| 2476 | res = cop_dist; |
| 2477 | res <<= 5 - cop_scale; |
| 2478 | res /= div; |
2405 | 2479 | |
| 2480 | cop_dist = (1 << (5 - cop_scale)) / div; |
| 2481 | |
| 2482 | /* TODO: bits 5-6-15 */ |
| 2483 | cop_status = 7; |
| 2484 | |
2406 | 2485 | space.write_word(cop_register[0]+(0x38^2), res); |
2407 | 2486 | return; |
2408 | 2487 | } |
trunk/src/mame/drivers/raiden2.c
r17978 | r17979 | |
497 | 497 | |
498 | 498 | switch(data) { |
499 | 499 | case 0x0205: // 0205 0006 ffeb 0000 - 0188 0282 0082 0b8e 098e 0000 0000 0000 |
500 | | space.write_dword(cop_regs[0] + 4 + offset*4, space.read_dword(cop_regs[0] + 4 + offset*4) + space.read_dword(cop_regs[0] + 16 + offset*4)); |
| 500 | printf("%08x %08x\n",space.read_dword(cop_regs[0] + 0x1c + offset*4),space.read_dword(cop_regs[0] + 0x10 + offset*4)); |
| 501 | |
| 502 | space.write_dword(cop_regs[0] + 4 + offset*4, space.read_dword(cop_regs[0] + 4 + offset*4) + space.read_dword(cop_regs[0] + 0x10 + offset*4)); |
501 | 503 | /* TODO: check the following, makes Zero Team to crash as soon as this command is triggered. */ |
502 | | //space.write_word(cop_regs[0] + 0x1c + offset*4, space.read_word(cop_regs[0] + 0x1c + offset*4) + space.read_word(cop_regs[0] + 16 + offset*4)); |
| 504 | space.write_dword(cop_regs[0] + 0x1c + offset*4, space.read_dword(cop_regs[0] + 0x1c + offset*4) + space.read_dword(cop_regs[0] + 0x10 + offset*4)); |
503 | 505 | break; |
504 | 506 | |
505 | 507 | case 0x0904: { /* X Se Dae and Zero Team uses this variant */ |
r17978 | r17979 | |
523 | 525 | if(dy<0) |
524 | 526 | cop_angle += 0x80; |
525 | 527 | } |
526 | | dx = dx >> 16; |
527 | | dy = dy >> 16; |
528 | | cop_dist = sqrt((double)(dx*dx+dy*dy)); |
529 | 528 | |
530 | 529 | if(data & 0x0080) { |
531 | 530 | space.write_byte(cop_regs[0]+0x34, cop_angle); |
532 | | space.write_word(cop_regs[0]+0x38, cop_dist); |
533 | 531 | } |
534 | 532 | break; |
535 | 533 | } |
536 | 534 | |
| 535 | case 0x3b30: |
537 | 536 | case 0x3bb0: { // 3bb0 0004 007f 0038 - 0f9c 0b9c 0b9c 0b9c 0b9c 0b9c 0b9c 099c |
538 | | // called systematically after 130e/138e, no results expected it seems |
| 537 | /* TODO: these are actually internally loaded */ |
| 538 | int dx = space.read_dword(cop_regs[1]+4) - space.read_dword(cop_regs[0]+4); |
| 539 | int dy = space.read_dword(cop_regs[1]+8) - space.read_dword(cop_regs[0]+8); |
| 540 | |
| 541 | dx = dx >> 16; |
| 542 | dy = dy >> 16; |
| 543 | cop_dist = sqrt((double)(dx*dx+dy*dy)); |
| 544 | |
| 545 | if(data & 0x0080) |
| 546 | space.write_word(cop_regs[0]+0x38, cop_dist); |
539 | 547 | break; |
540 | 548 | } |
541 | 549 | |
r17978 | r17979 | |
1867 | 1875 | MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK) |
1868 | 1876 | |
1869 | 1877 | MCFG_SCREEN_ADD("screen", RASTER) |
1870 | | MCFG_SCREEN_REFRESH_RATE(55.47) /* verified on pcb */ |
1871 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate *//2) |
1872 | | MCFG_SCREEN_SIZE(64*8, 64*8) |
1873 | | MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0, 32*8-1) |
| 1878 | // MCFG_SCREEN_REFRESH_RATE(55.47) /* verified on pcb */ |
| 1879 | MCFG_SCREEN_RAW_PARAMS(XTAL_32MHz/4,546,0,40*8,264,0,32*8) /* hand-tuned to match ~55.47 */ |
1874 | 1880 | MCFG_SCREEN_UPDATE_DRIVER(raiden2_state, screen_update_raiden2) |
1875 | 1881 | MCFG_GFXDECODE(raiden2) |
1876 | 1882 | MCFG_PALETTE_LENGTH(2048) |