trunk/src/mame/drivers/raiden2.c
r17980 | r17981 | |
532 | 532 | |
533 | 533 | case 0x3b30: |
534 | 534 | case 0x3bb0: { // 3bb0 0004 007f 0038 - 0f9c 0b9c 0b9c 0b9c 0b9c 0b9c 0b9c 099c |
535 | | /* TODO: these are actually internally loaded */ |
| 535 | /* TODO: these are actually internally loaded via 0x130e command */ |
536 | 536 | int dx = space.read_dword(cop_regs[1]+4) - space.read_dword(cop_regs[0]+4); |
537 | 537 | int dy = space.read_dword(cop_regs[1]+8) - space.read_dword(cop_regs[0]+8); |
538 | 538 | |
r17980 | r17981 | |
546 | 546 | } |
547 | 547 | |
548 | 548 | case 0x42c2: { // 42c2 0005 fcdd 0040 - 0f9a 0b9a 0b9c 0b9c 0b9c 029c 0000 0000 |
549 | | int div = space.read_word(cop_regs[0]+0x36); |
| 549 | /* TODO: these are actually internally loaded via 0x130e command */ |
| 550 | int dx = space.read_dword(cop_regs[1]+4) - space.read_dword(cop_regs[0]+4); |
| 551 | int dy = space.read_dword(cop_regs[1]+8) - space.read_dword(cop_regs[0]+8); |
| 552 | int div = space.read_word(cop_regs[0]+(0x36)); |
550 | 553 | int res; |
| 554 | int cop_dist_raw; |
| 555 | |
551 | 556 | if(!div) |
552 | 557 | { |
553 | 558 | printf("divide by zero?\n"); |
554 | 559 | div = 1; |
555 | 560 | } |
556 | | res = space.read_word(cop_regs[0]+(0x38)) / div; |
557 | | res <<= cop_scale + 2; /* TODO: check this */ |
558 | | space.write_word(cop_regs[0]+0x38, res); |
| 561 | |
| 562 | /* TODO: calculation of this one should occur at 0x3b30/0x3bb0 I *think* */ |
| 563 | /* TODO: recheck if cop_scale still masks at 3 with this command */ |
| 564 | dx >>= 11 + cop_scale; |
| 565 | dy >>= 11 + cop_scale; |
| 566 | cop_dist_raw = sqrt((double)(dx*dx+dy*dy)); |
| 567 | |
| 568 | res = cop_dist_raw; |
| 569 | res /= div; |
| 570 | |
| 571 | cop_dist = (1 << (5 - cop_scale)) / div; |
| 572 | |
| 573 | /* TODO: bits 5-6-15 */ |
| 574 | cop_status = 7; |
| 575 | |
| 576 | space.write_word(cop_regs[0]+(0x38), res); |
559 | 577 | break; |
560 | 578 | } |
561 | 579 | |