Ported the collision detection code from machine/seicop.c ... now you can mess around with Raiden 2 - Invisible Edition ^^'

This commit is contained in:
Angelo Salese 2011-01-07 15:54:23 +00:00
parent 442c8f6c9b
commit 1bb513b2f4
2 changed files with 67 additions and 1 deletions

View File

@ -381,6 +381,25 @@ WRITE16_MEMBER(raiden2_state::cop_reg_low_w)
cop_regs[offset] = (cop_regs[offset] & ~UINT32(mem_mask)) | (data & mem_mask); 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) WRITE16_MEMBER(raiden2_state::cop_cmd_w)
{ {
cop_status &= 0x7fff; 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 // And probably 8 bytes too, but they zero all the rest
break; 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: 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]); 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) READ16_MEMBER(raiden2_state::cop_collision_status_r)
{ {
return 3; return cop_hit_status;
} }
WRITE16_MEMBER(raiden2_state::sprite_prot_x_w) WRITE16_MEMBER(raiden2_state::sprite_prot_x_w)

View File

@ -100,7 +100,18 @@ public:
UINT16 sprite_prot_x,sprite_prot_y,dst1,dst2; UINT16 sprite_prot_x,sprite_prot_y,dst1,dst2;
UINT16 sprite_prot_src_addr[2]; 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 ); void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ,int pri_mask );
UINT8 cop_calculate_collsion_detection(running_machine *machine);
}; };