Previous 199869 Revisions Next

r17885 Friday 14th September, 2012 at 12:49:07 UTC by Angelo Salese
Made accurate trigonometry maths in Seibu COP [Angelo Salese, Smitdogg]
[src/mame/drivers]raiden2.c
[src/mame/machine]seicop.c

trunk/src/mame/machine/seicop.c
r17884r17885
140014000x470
14011401???? ???? ???? ???? External pin register, used by some games for prg/gfx banking (per-game specific)
14021402
1403
1404---
1405
1406commands 0x8100/0x8900:
1407
1408status always 0x8007 (doesn't seem to care)
1409raw | amp | scale | sin       | cos      |
1410------------------------------------------
1411y     0x00     x    0x00000000 0x00000000 (i.e. if amp is 0 then sin/cos are zero too)
14120     0x40     0    0x00000000 0x00020000
14130     0x40     1    0x00000000 0x00040000
14140     0x40     2    0x00000000 0x00080000
14150     0x40     3    0x00000000 0x00100000
14160x40  0x40     0    0x00020000 0x00000000
14170x40  0x40     1    0x00040000 0x00000000
14180x40  0x40     2    0x00080000 0x00000000
14190x40  0x40     3    0x00100000 0x00000000
14200x80  0x40     0    0x00000000 0xfffc0000
14210x80  0x40     1    0x00000000 0xfff80000
14220x80  0x40     2    0x00000000 0xfff00000
14230x80  0x40     3    0x00000000 0xffe00000
14240xc0  0x40     0    0xfffc0000 0x00000000
14250xc0  0x40     1    0xfff80000 0x00000000
14260xc0  0x40     2    0xfff00000 0x00000000
14270xc0  0x40     3    0xffe00000 0x00000000
14280     0x80     0    0x00000000 0x00040000
14290     0x80     1    0x00000000 0x00080000
14300     0x80     2    0x00000000 0x00100000
14310     0x80     3    0x00000000 0x00200000
14320x40  0x80     0    0x00040000 0x00000000
14330x40  0x80     1    0x00080000 0x00000000
14340x40  0x80     2    0x00100000 0x00000000
14350x40  0x80     3    0x00200000 0x00000000
14360x80  0x80     0    0x00000000 0xfff80000
14370x80  0x80     1    0x00000000 0xfff00000
14380x80  0x80     2    0x00000000 0xffe00000
14390x80  0x80     3    0x00000000 0xffc00000
14400xc0  0x80     0    0xfff80000 0x00000000
14410xc0  0x80     1    0xfff00000 0x00000000
14420xc0  0x80     2    0xffe00000 0x00000000
14430xc0  0x80     3    0xffc00000 0x00000000
14440     0xc0     0    0x00000000 0x00060000
14450     0xc0     1    0x00000000 0x000c0000
14460     0xc0     2    0x00000000 0x00180000
14470     0xc0     3    0x00000000 0x00300000
14480x40  0xc0     0    0x00060000 0x00000000
14490x40  0xc0     1    0x000c0000 0x00000000
14500x40  0xc0     2    0x00180000 0x00000000
14510x40  0xc0     3    0x00300000 0x00000000
14520x80  0xc0     0    0x00000000 0xfff40000
14530x80  0xc0     1    0x00000000 0xffe80000
14540x80  0xc0     2    0x00000000 0xffd00000
14550x80  0xc0     3    0x00000000 0xffa00000
14560xc0  0xc0     0    0xfff40000 0x00000000
14570xc0  0xc0     1    0xffe80000 0x00000000
14580xc0  0xc0     2    0xffd00000 0x00000000
14590xc0  0xc0     3    0xffa00000 0x00000000
14031460*/
14041461
14051462#include "emu.h"
r17884r17885
20402097
20412098      case (0x044/2):
20422099      {
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;
20472101         break;
20482102      }
20492103
r17884r17885
21812235         {
21822236            int raw_angle = (space->read_word(cop_register[0]+(0x34^2)) & 0xff);
21832237            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;
21852240
21862241            /* TODO: up direction, why? */
21872242            if(raw_angle == 0xc0)
21882243               amp*=2;
21892244
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);
21912248            return;
21922249         }
21932250
r17884r17885
22082265         {
22092266            int raw_angle = (space->read_word(cop_register[0]+(0x34^2)) & 0xff);
22102267            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;
22122270
22132271            /* TODO: left direction, why? */
22142272            if(raw_angle == 0x80)
22152273               amp*=2;
22162274
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);
22182278            return;
22192279         }
22202280
r17884r17885
22952355         if(COP_CMD(0xf9a,0xb9a,0xb9c,0xb9c,0xb9c,0x29c,0x000,0x000,5,0xfcdd))
22962356         {
22972357            int div = space->read_word(cop_register[0]+(0x36^2));
2358            int res;
2359
22982360            if(!div)
2361            {
2362               printf("divide by zero?\n");
22992363               div = 1;
2364            }
23002365
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);
23022370            return;
23032371         }
23042372
trunk/src/mame/drivers/raiden2.c
r17884r17885
428428WRITE16_MEMBER(raiden2_state::cop_scale_w)
429429{
430430   COMBINE_DATA(&cop_scale);
431   cop_scale &= 3;
431432}
432433
433434READ16_MEMBER(raiden2_state::cop_reg_high_r)
r17884r17885
540541
541542   case 0x42c2: { // 42c2 0005 fcdd 0040 - 0f9a 0b9a 0b9c 0b9c 0b9c 029c 0000 0000
542543      int div = space.read_word(cop_regs[0]+0x36);
544      int res;
543545      if(!div)
546      {
547         printf("divide by zero?\n");
544548         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);
546553      break;
547554   }
548555
549556   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);
551558      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;
553561      /* TODO: up direction, why? (check machine/seicop.c) */
554562      if(raw_angle == 0xc0)
555563         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);
557566      break;
558567   }
559568
560569   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);
562571      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;
564574      /* TODO: left direction, why? (check machine/seicop.c) */
565575      if(raw_angle == 0x80)
566576         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);
568579      break;
569580   }
570581

Previous 199869 Revisions Next


© 1997-2024 The MAME Team