Previous 199869 Revisions Next

r17801 Tuesday 11th September, 2012 at 17:49:49 UTC by Angelo Salese
Converted raiden2.c to use the collision detection routines
[src/mame/drivers]raiden2.c
[src/mame/includes]raiden2.h

trunk/src/mame/includes/raiden2.h
r17800r17801
3333   DECLARE_WRITE16_MEMBER( cop_cmd_w );
3434   DECLARE_READ16_MEMBER ( cop_itoa_digits_r );
3535   DECLARE_READ16_MEMBER ( cop_collision_status_r );
36   DECLARE_READ16_MEMBER (cop_collision_status_y_r);
37   DECLARE_READ16_MEMBER (cop_collision_status_x_r);
38   DECLARE_READ16_MEMBER (cop_collision_status_z_r);
39   DECLARE_READ16_MEMBER (cop_collision_status_unk_r);
40
3641   DECLARE_READ16_MEMBER ( cop_status_r );
3742   DECLARE_READ16_MEMBER ( cop_dist_r );
3843   DECLARE_READ16_MEMBER ( cop_angle_r );
r17800r17801
110115      int x,y;
111116      int min_x,min_y,max_x,max_y;
112117      UINT16 hitbox;
118      UINT16 hitbox_x,hitbox_y;
113119   }cop_collision_info[2];
114120
115121   UINT16 cop_hit_status;
122   INT16 cop_hit_val_x,cop_hit_val_y,cop_hit_val_z,cop_hit_val_unk;
116123
117124   void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ,int pri_mask );
118125   UINT8 cop_calculate_collsion_detection(running_machine &machine);
126   void cop_take_hit_box_params(UINT8 offs);
119127
120128   DECLARE_DRIVER_INIT(raidendx);
121129   DECLARE_DRIVER_INIT(xsedae);
trunk/src/mame/drivers/raiden2.c
r17800r17801
450450   cop_regs[offset] = (cop_regs[offset] & ~UINT32(mem_mask)) | (data & mem_mask);
451451}
452452
453void raiden2_state::cop_take_hit_box_params(UINT8 offs)
454{
455   INT16 start_x,start_y,end_x,end_y;
456
457   start_x = INT8(cop_collision_info[offs].hitbox_x);
458   start_y = INT8(cop_collision_info[offs].hitbox_y);
459
460   end_x = INT8(cop_collision_info[offs].hitbox_x >> 8);
461   end_y = INT8(cop_collision_info[offs].hitbox_y >> 8);
462
463   cop_collision_info[offs].min_x = start_x + (cop_collision_info[offs].x >> 16);
464   cop_collision_info[offs].min_y = start_y + (cop_collision_info[offs].y >> 16);
465   cop_collision_info[offs].max_x = end_x + (cop_collision_info[offs].x >> 16);
466   cop_collision_info[offs].max_y = end_y + (cop_collision_info[offs].y >> 16);
467}
468
469
453470UINT8 raiden2_state::cop_calculate_collsion_detection(running_machine &machine)
454471{
455472   static UINT8 res;
r17800r17801
458475
459476   /* outbound X check */
460477   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)
461      res &= ~1;
478      res &= ~2;
462479
463480   /* outbound Y check */
464481   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)
465      res &= ~2;
482      res &= ~1;
466483
467   /* TODO: special collision detection for Zero Team */
484   cop_hit_val_x = (cop_collision_info[0].x - cop_collision_info[1].x) >> 16;
485   cop_hit_val_y = (cop_collision_info[0].y - cop_collision_info[1].y) >> 16;
486   cop_hit_val_z = 1;
487   cop_hit_val_unk = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning
468488
489
469490   return res;
470491}
471492
r17800r17801
570591      break;
571592
572593   case 0xa100:
594   case 0xa180:
573595      cop_collision_info[0].y = (space.read_dword(cop_regs[0]+4));
574596      cop_collision_info[0].x = (space.read_dword(cop_regs[0]+8));
575597      break;
576598
577599   case 0xa900:
600   case 0xa980:
578601      cop_collision_info[1].y = (space.read_dword(cop_regs[1]+4));
579602      cop_collision_info[1].x = (space.read_dword(cop_regs[1]+8));
580603      break;
581604
582605   case 0xb100:
583      /* Take hitbox param, TODO */
584606      cop_collision_info[0].hitbox = space.read_word(cop_regs[2]);
607      cop_collision_info[0].hitbox_y = space.read_word((cop_regs[2]&0xffff0000)|(cop_collision_info[0].hitbox));
608      cop_collision_info[0].hitbox_x = space.read_word(((cop_regs[2]&0xffff0000)|(cop_collision_info[0].hitbox))+2);
585609
586      cop_collision_info[0].min_x = cop_collision_info[0].x + (0 << 16);
587      cop_collision_info[0].min_y = cop_collision_info[0].y + (0 << 16);
588      cop_collision_info[0].max_x = cop_collision_info[0].x + (0x10 << 16);
589      cop_collision_info[0].max_y = cop_collision_info[0].y + (0x10 << 16);
590
591610      /* do the math */
611      cop_take_hit_box_params(0);
592612      cop_hit_status = cop_calculate_collsion_detection(space.machine());
593613      break;
594614
595615   case 0xb900:
596      /* Take hitbox param, TODO */
597616      cop_collision_info[1].hitbox = space.read_word(cop_regs[3]);
617      cop_collision_info[1].hitbox_y = space.read_word((cop_regs[3]&0xffff0000)|(cop_collision_info[1].hitbox));
618      cop_collision_info[1].hitbox_x = space.read_word(((cop_regs[3]&0xffff0000)|(cop_collision_info[1].hitbox))+2);
598619
599      cop_collision_info[1].min_x = cop_collision_info[1].x + (0 << 16);
600      cop_collision_info[1].min_y = cop_collision_info[1].y + (0 << 16);
601      cop_collision_info[1].max_x = cop_collision_info[1].x + (0x10 << 16);
602      cop_collision_info[1].max_y = cop_collision_info[1].y + (0x10 << 16);
603
604620      /* do the math */
621      cop_take_hit_box_params(1);
605622      cop_hit_status = cop_calculate_collsion_detection(space.machine());
606623      break;
607624
r17800r17801
11811198   dst2 = data;
11821199}
11831200
1201READ16_MEMBER(raiden2_state::cop_collision_status_y_r)
1202{
1203   return cop_hit_val_y;
1204}
1205
1206READ16_MEMBER(raiden2_state::cop_collision_status_x_r)
1207{
1208   return cop_hit_val_x;
1209}
1210
1211READ16_MEMBER(raiden2_state::cop_collision_status_z_r)
1212{
1213   return cop_hit_val_z;
1214}
1215
1216READ16_MEMBER(raiden2_state::cop_collision_status_unk_r)
1217{
1218   return cop_hit_val_unk;
1219}
1220
11841221/* MEMORY MAPS */
11851222static ADDRESS_MAP_START( raiden2_cop_mem, AS_PROGRAM, 16, raiden2_state )
11861223//  AM_RANGE(0x0041c, 0x0041d) AM_WRITENOP // angle compare (for 0x6200 COP macro)
r17800r17801
12101247   AM_RANGE(0x004c0, 0x004c9) AM_READWRITE(cop_reg_low_r, cop_reg_low_w)
12111248   AM_RANGE(0x00500, 0x00505) AM_WRITE(cop_cmd_w)
12121249   AM_RANGE(0x00580, 0x00581) AM_READ(cop_collision_status_r)
1213//  AM_RANGE(0x00588, 0x00589) AM_READ(cop_collision_status2_r) // used by Zero Team (only this, why?)
1250   AM_RANGE(0x00582, 0x00583) AM_READ(cop_collision_status_y_r)
1251   AM_RANGE(0x00584, 0x00585) AM_READ(cop_collision_status_x_r)
1252   AM_RANGE(0x00586, 0x00587) AM_READ(cop_collision_status_z_r)
1253   AM_RANGE(0x00588, 0x00589) AM_READ(cop_collision_status_unk_r)
12141254   AM_RANGE(0x00590, 0x00599) AM_READ(cop_itoa_digits_r)
12151255   AM_RANGE(0x005b0, 0x005b1) AM_READ(cop_status_r)
12161256   AM_RANGE(0x005b2, 0x005b3) AM_READ(cop_dist_r)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team