Previous 199869 Revisions Next

r31969 Sunday 7th September, 2014 at 14:30:22 UTC by O. Galibert
collision rework (nw)
[src/mame/drivers]raiden2.c
[src/mame/includes]raiden2.h

trunk/src/mame/includes/raiden2.h
r31968r31969
133133   UINT16 sprite_prot_x,sprite_prot_y,dst1,cop_spr_maxx,cop_spr_off;
134134   UINT16 sprite_prot_src_addr[2];
135135
136   struct
137   {
138      int x,y;
139      int min_x,min_y,max_x,max_y;
140      UINT16 hitbox;
141      UINT16 hitbox_x,hitbox_y;
142   }cop_collision_info[2];
136   struct {
137      int x, y;
138      int min_x, min_y, max_x, max_y;
139   } cop_collision_info[2];
143140
144   UINT16 cop_hit_status;
145   INT16 cop_hit_val_x,cop_hit_val_y,cop_hit_val_z,cop_hit_val_unk;
141   UINT16 cop_hit_status, cop_hit_baseadr;
142   INT16 cop_hit_val_x, cop_hit_val_y, cop_hit_val_z, cop_hit_val_unk;
146143
147144   void draw_sprites(const rectangle &cliprect);
148   UINT8 cop_calculate_collsion_detection();
149   void cop_take_hit_box_params(UINT8 offs);
150145
146   void cop_collision_read_xy(address_space &space, int slot, UINT32 spradr);
147   void cop_collision_update_hitbox(address_space &space, int slot, UINT32 hitadr);
148
149   DECLARE_WRITE16_MEMBER(cop_hitbox_baseadr_w);
151150   DECLARE_WRITE16_MEMBER(cop_sort_lookup_hi_w);
152151   DECLARE_WRITE16_MEMBER(cop_sort_lookup_lo_w);
153152   DECLARE_WRITE16_MEMBER(cop_sort_ram_addr_hi_w);
trunk/src/mame/drivers/raiden2.c
r31968r31969
135135 High Priority
136136
137137 Protection
138 - raiden2 doesn't detect hits on stage 2 boss;
139138 - zeroteam has bogus collision detection;
140139 - raiden2 has a weird movement after that the ship completes animation from the aircraft. Probably 42c2 should be floating point rounded ...
141140 - (and probably more)
r31968r31969
520519   cop_regs[offset] = (cop_regs[offset] & ~UINT32(mem_mask)) | (data & mem_mask);
521520}
522521
523void raiden2_state::cop_take_hit_box_params(UINT8 offs)
522WRITE16_MEMBER(raiden2_state::cop_hitbox_baseadr_w)
524523{
525   INT16 start_x,start_y,end_x,end_y;
524   COMBINE_DATA(&cop_hit_baseadr);
525}
526526
527   start_x = INT8(cop_collision_info[offs].hitbox_x);
528   start_y = INT8(cop_collision_info[offs].hitbox_y);
529
530   end_x = INT8(cop_collision_info[offs].hitbox_x >> 8);
531   end_y = INT8(cop_collision_info[offs].hitbox_y >> 8);
532
533   cop_collision_info[offs].min_x = start_x + (cop_collision_info[offs].x >> 16);
534   cop_collision_info[offs].min_y = start_y + (cop_collision_info[offs].y >> 16);
535   cop_collision_info[offs].max_x = end_x + (cop_collision_info[offs].x >> 16);
536   cop_collision_info[offs].max_y = end_y + (cop_collision_info[offs].y >> 16);
527void raiden2_state::cop_collision_read_xy(address_space &space, int slot, UINT32 spradr)
528{
529   cop_collision_info[slot].y = space.read_dword(spradr+4);
530   cop_collision_info[slot].x = space.read_dword(spradr+8);
537531}
538532
539
540UINT8 raiden2_state::cop_calculate_collsion_detection()
533void raiden2_state::cop_collision_update_hitbox(address_space &space, int slot, UINT32 hitadr)
541534{
542   static UINT8 res;
535   UINT32 hitadr2 = space.read_dword(hitadr) + (cop_hit_baseadr << 16);
536   UINT32 hitbox_raw = space.read_dword(hitadr2);
543537
544   res = 3;
538   INT8 hx = hitbox_raw;
539   UINT8 hw = hitbox_raw >> 8;
540   INT8 hy = hitbox_raw >> 16;
541   UINT8 hh = hitbox_raw >> 24;
545542
543   cop_collision_info[slot].min_x = (cop_collision_info[slot].x >> 16) + hx;
544   cop_collision_info[slot].min_y = (cop_collision_info[slot].y >> 16) + hy;
545   cop_collision_info[slot].max_x = cop_collision_info[slot].min_x + hw;
546   cop_collision_info[slot].max_y = cop_collision_info[slot].min_y + hh;
547
548   cop_hit_status = 3;
549
546550   /* outbound X check */
547551   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)
548      res &= ~2;
552      cop_hit_status &= ~2;
549553
550554   /* outbound Y check */
551555   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)
552      res &= ~1;
556      cop_hit_status &= ~1;
553557
554558   cop_hit_val_x = (cop_collision_info[0].x - cop_collision_info[1].x) >> 16;
555559   cop_hit_val_y = (cop_collision_info[0].y - cop_collision_info[1].y) >> 16;
556560   cop_hit_val_z = 1;
557   cop_hit_val_unk = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning
558
559   return res;
561   cop_hit_val_unk = cop_hit_status; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning
560562}
561563
562/*
563TODO:
5642a05: first boss
5652208/2288: first enemies when they crash on the ground (collision direction?)
56639b0: purple laser when it's fired up (variation of 3bb0?) - 0205: if you comment out the line that also makes zeroteam crash, triggering purple laser doesn't crash anymore, but laser isn't visible
567*/
568564WRITE16_MEMBER(raiden2_state::cop_cmd_w)
569565{
570566   cop_status &= 0x7fff;
r31968r31969
758754
759755   case 0xa100:
760756   case 0xa180:
761      cop_collision_info[0].y = (space.read_dword(cop_regs[0]+4));
762      cop_collision_info[0].x = (space.read_dword(cop_regs[0]+8));
757      cop_collision_read_xy(space, 0, cop_regs[0]);
763758      break;
764759
765760   case 0xa900:
766761   case 0xa980:
767      cop_collision_info[1].y = (space.read_dword(cop_regs[1]+4));
768      cop_collision_info[1].x = (space.read_dword(cop_regs[1]+8));
762      cop_collision_read_xy(space, 1, cop_regs[1]);
769763      break;
770764
771765   case 0xb100:
772      cop_collision_info[0].hitbox = space.read_word(cop_regs[2]);
773      cop_collision_info[0].hitbox_y = space.read_word((cop_regs[2]&0xffff0000)|(cop_collision_info[0].hitbox));
774      cop_collision_info[0].hitbox_x = space.read_word(((cop_regs[2]&0xffff0000)|(cop_collision_info[0].hitbox))+2);
775
776      /* do the math */
777      cop_take_hit_box_params(0);
778      cop_hit_status = cop_calculate_collsion_detection();
766      cop_collision_update_hitbox(space, 0, cop_regs[2]);
779767      break;
780768
781769   case 0xb900:
782      cop_collision_info[1].hitbox = space.read_word(cop_regs[3]);
783      cop_collision_info[1].hitbox_y = space.read_word((cop_regs[3]&0xffff0000)|(cop_collision_info[1].hitbox));
784      cop_collision_info[1].hitbox_x = space.read_word(((cop_regs[3]&0xffff0000)|(cop_collision_info[1].hitbox))+2);
785
786      /* do the math */
787      cop_take_hit_box_params(1);
788      cop_hit_status = cop_calculate_collsion_detection();
770      cop_collision_update_hitbox(space, 1, cop_regs[3]);
789771      break;
790772
791773   default:
r31968r31969
793775   }
794776}
795777
796//  case 0x6ca:
797//      logerror("select bank %d %04x\n", (data >> 15) & 1, data);
798//      space.membank("bank1")->set_entry((data >> 15) & 1);
799778
800
801779void raiden2_state::combine32(UINT32 *val, int offset, UINT16 data, UINT16 mem_mask)
802780{
803781   UINT16 *dest = (UINT16 *)val + BYTE_XOR_LE(offset);
r31968r31969
15591537   AM_RANGE(0x0042a, 0x0042b) AM_WRITE(cop_dma_v2_w)
15601538   AM_RANGE(0x00432, 0x00433) AM_WRITE(cop_pgm_data_w)
15611539   AM_RANGE(0x00434, 0x00435) AM_WRITE(cop_pgm_addr_w)
1540   AM_RANGE(0x00436, 0x00437) AM_WRITE(cop_hitbox_baseadr_w)
15621541   AM_RANGE(0x00438, 0x00439) AM_WRITE(cop_pgm_value_w)
15631542   AM_RANGE(0x0043a, 0x0043b) AM_WRITE(cop_pgm_mask_w)
15641543   AM_RANGE(0x0043c, 0x0043d) AM_WRITE(cop_pgm_trigger_w)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team