diff --git a/src/mame/drivers/raiden2.c b/src/mame/drivers/raiden2.c index 666c5414753..3725990b3e0 100644 --- a/src/mame/drivers/raiden2.c +++ b/src/mame/drivers/raiden2.c @@ -381,6 +381,25 @@ WRITE16_MEMBER(raiden2_state::cop_reg_low_w) cop_regs[offset] = (cop_regs[offset] & ~UINT32(mem_mask)) | (data & mem_mask); } +UINT8 raiden2_state::cop_calculate_collsion_detection(running_machine *machine) +{ + static UINT8 res; + + res = 3; + + /* outbound X check */ + 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) + res &= ~1; + + /* outbound Y check */ + 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) + res &= ~2; + + /* TODO: special collision detection for Zero Team */ + + return res; +} + WRITE16_MEMBER(raiden2_state::cop_cmd_w) { cop_status &= 0x7fff; @@ -477,6 +496,42 @@ WRITE16_MEMBER(raiden2_state::cop_cmd_w) // And probably 8 bytes too, but they zero all the rest break; + case 0xa100: + cop_collision_info[0].y = (space.read_dword(cop_regs[0]+4)); + cop_collision_info[0].x = (space.read_dword(cop_regs[0]+8)); + break; + + case 0xa900: + cop_collision_info[1].y = (space.read_dword(cop_regs[1]+4)); + cop_collision_info[1].x = (space.read_dword(cop_regs[1]+8)); + break; + + case 0xb100: + /* Take hitbox param, TODO */ + cop_collision_info[0].hitbox = space.read_word(cop_regs[2]); + + cop_collision_info[0].min_x = cop_collision_info[0].x + (0 << 16); + cop_collision_info[0].min_y = cop_collision_info[0].y + (0 << 16); + cop_collision_info[0].max_x = cop_collision_info[0].x + (0x10 << 16); + cop_collision_info[0].max_y = cop_collision_info[0].y + (0x10 << 16); + + /* do the math */ + cop_hit_status = cop_calculate_collsion_detection(space.machine); + break; + + case 0xb900: + /* Take hitbox param, TODO */ + cop_collision_info[1].hitbox = space.read_word(cop_regs[3]); + + cop_collision_info[1].min_x = cop_collision_info[1].x + (0 << 16); + cop_collision_info[1].min_y = cop_collision_info[1].y + (0 << 16); + cop_collision_info[1].max_x = cop_collision_info[1].x + (0x10 << 16); + cop_collision_info[1].max_y = cop_collision_info[1].y + (0x10 << 16); + + /* do the math */ + cop_hit_status = cop_calculate_collsion_detection(space.machine); + break; + default: logerror("pcall %04x (%04x:%04x) [%x %x %x %x]\n", data, rps(space.machine), rpc(space.machine), cop_regs[0], cop_regs[1], cop_regs[2], cop_regs[3]); } @@ -999,7 +1054,7 @@ WRITE16_MEMBER(raiden2_state::raiden2_bank_w) READ16_MEMBER(raiden2_state::cop_collision_status_r) { - return 3; + return cop_hit_status; } WRITE16_MEMBER(raiden2_state::sprite_prot_x_w) diff --git a/src/mame/includes/raiden2.h b/src/mame/includes/raiden2.h index 20b35f393ec..d05462dafe6 100644 --- a/src/mame/includes/raiden2.h +++ b/src/mame/includes/raiden2.h @@ -100,7 +100,18 @@ public: UINT16 sprite_prot_x,sprite_prot_y,dst1,dst2; UINT16 sprite_prot_src_addr[2]; + struct + { + int x,y; + int min_x,min_y,max_x,max_y; + UINT16 hitbox; + }cop_collision_info[2]; + + UINT16 cop_hit_status; + void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ,int pri_mask ); + UINT8 cop_calculate_collsion_detection(running_machine *machine); + };