Previous 199869 Revisions Next

r17981 Tuesday 18th September, 2012 at 01:46:35 UTC by Angelo Salese
Ported 0x42c2 to raiden2.c, helps with ship entry, respawn and power-up movements
[src/mame/drivers]raiden2.c

trunk/src/mame/drivers/raiden2.c
r17980r17981
532532
533533   case 0x3b30:
534534   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 */
536536      int dx = space.read_dword(cop_regs[1]+4) - space.read_dword(cop_regs[0]+4);
537537      int dy = space.read_dword(cop_regs[1]+8) - space.read_dword(cop_regs[0]+8);
538538
r17980r17981
546546   }
547547
548548   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));
550553      int res;
554      int cop_dist_raw;
555
551556      if(!div)
552557      {
553558         printf("divide by zero?\n");
554559         div = 1;
555560      }
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);
559577      break;
560578   }
561579

Previous 199869 Revisions Next


© 1997-2024 The MAME Team