trunk/src/mame/machine/seicop.c
| r17799 | r17800 | |
| 1736 | 1736 | static struct |
| 1737 | 1737 | { |
| 1738 | 1738 | int x,y; |
| 1739 | | int min_x,min_y,max_x,max_y; |
| 1739 | INT16 min_x,min_y,max_x,max_y; |
| 1740 | 1740 | UINT16 hitbox; |
| 1741 | 1741 | UINT16 hitbox_x,hitbox_y; |
| 1742 | 1742 | }cop_collision_info[2]; |
| r17799 | r17800 | |
| 1759 | 1759 | |
| 1760 | 1760 | |
| 1761 | 1761 | /* |
| 1762 | | Godzilla 0x12c0 height 50m |
| 1763 | | Megaron 0x12d0 height 55m |
| 1764 | | King Ghidorah 0x12c8 100m |
| 1765 | | Mecha Ghidorah 0x12dc 140m |
| 1766 | | Mecha Godzilla 0x12d4 50m |
| 1767 | | Gigan 0x12cc 55m |
| 1762 | Godzilla 0x12c0 X = 0x21ed Y = 0x57da |
| 1763 | Megaron 0x12d0 X = 0x1ef1 Y = 0x55db |
| 1764 | King Ghidorah 0x12c8 X = 0x26eb Y = 0x55dc |
| 1765 | Mecha Ghidorah 0x12dc X = 0x24ec Y = 0x55dc |
| 1766 | Mecha Godzilla 0x12d4 X = 0x1cf1 Y = 0x52dc |
| 1767 | Gigan 0x12cc X = 0x23e8 Y = 0x55db |
| 1768 | 1768 | */ |
| 1769 | static void cop_take_hit_box_params(UINT8 offs) |
| 1770 | { |
| 1771 | INT16 start_x,start_y,end_x,end_y; |
| 1772 | |
| 1773 | start_x = INT8(cop_collision_info[offs].hitbox_x); |
| 1774 | start_y = INT8(cop_collision_info[offs].hitbox_y); |
| 1775 | |
| 1776 | end_x = INT8(cop_collision_info[offs].hitbox_x >> 8); |
| 1777 | end_y = INT8(cop_collision_info[offs].hitbox_y >> 8); |
| 1778 | |
| 1779 | cop_collision_info[offs].min_x = start_x + (cop_collision_info[offs].x >> 16); |
| 1780 | cop_collision_info[offs].min_y = start_y + (cop_collision_info[offs].y >> 16); |
| 1781 | cop_collision_info[offs].max_x = end_x + (cop_collision_info[offs].x >> 16); |
| 1782 | cop_collision_info[offs].max_y = end_y + (cop_collision_info[offs].y >> 16); |
| 1783 | } |
| 1784 | |
| 1785 | |
| 1769 | 1786 | static UINT8 cop_calculate_collsion_detection(running_machine &machine) |
| 1770 | 1787 | { |
| 1771 | 1788 | static UINT8 res; |
| r17799 | r17800 | |
| 1780 | 1797 | 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) |
| 1781 | 1798 | res &= ~1; |
| 1782 | 1799 | |
| 1783 | | cop_hit_val_x = (cop_collision_info[0].min_x - cop_collision_info[1].min_x) >> 16; |
| 1784 | | cop_hit_val_y = (cop_collision_info[0].min_y - cop_collision_info[1].min_y) >> 16; |
| 1800 | cop_hit_val_x = (cop_collision_info[0].x - cop_collision_info[1].x) >> 16; |
| 1801 | cop_hit_val_y = (cop_collision_info[0].y - cop_collision_info[1].y) >> 16; |
| 1785 | 1802 | cop_hit_val_z = 1; |
| 1786 | | cop_hit_val_unk = res;//((cop_collision_info[0].min_y >> 16) != (cop_collision_info[1].min_y >> 16)); |
| 1803 | cop_hit_val_unk = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning |
| 1787 | 1804 | |
| 1805 | |
| 1806 | //popmessage("%d %d %04x %04x %04x %04x",cop_hit_val_x,cop_hit_val_y,cop_collision_info[0].hitbox_x,cop_collision_info[0].hitbox_y,cop_collision_info[1].hitbox_x,cop_collision_info[1].hitbox_y); |
| 1807 | |
| 1788 | 1808 | //if(res == 0) |
| 1789 | 1809 | //popmessage("0:%08x %08x %08x 1:%08x %08x %08x\n",cop_collision_info[0].x,cop_collision_info[0].y,cop_collision_info[0].hitbox,cop_collision_info[1].x,cop_collision_info[1].y,cop_collision_info[1].hitbox); |
| 1790 | 1810 | |
| 1791 | 1811 | return res; |
| 1792 | 1812 | } |
| 1793 | 1813 | |
| 1794 | | |
| 1795 | 1814 | static READ16_HANDLER( generic_cop_r ) |
| 1796 | 1815 | { |
| 1797 | 1816 | UINT16 retvalue; |
| r17799 | r17800 | |
| 2296 | 2315 | //(heatbrl) | 9 | ffff | b080 | b40 bc0 bc2 |
| 2297 | 2316 | if(COP_CMD(0xb40,0xbc0,0xbc2,0x000,0x000,0x000,0x000,0x000,u1,u2)) |
| 2298 | 2317 | { |
| 2299 | | UINT8 start_x,end_x,end_y; |
| 2300 | | //UINT8 start_y; |
| 2301 | 2318 | cop_collision_info[0].hitbox = space->read_word(cop_register[2]); |
| 2302 | 2319 | cop_collision_info[0].hitbox_y = space->read_word((cop_register[2]&0xffff0000)|(cop_collision_info[0].hitbox)); |
| 2303 | 2320 | cop_collision_info[0].hitbox_x = space->read_word(((cop_register[2]&0xffff0000)|(cop_collision_info[0].hitbox))+2); |
| 2304 | | // TODO: z |
| 2305 | 2321 | |
| 2306 | | start_x = (cop_collision_info[0].hitbox_x & 0xff); |
| 2307 | | //start_y = (cop_collision_info[0].hitbox_y & 0xff); |
| 2308 | | end_x = (cop_collision_info[0].hitbox_x >> 8); |
| 2309 | | end_y = (cop_collision_info[0].hitbox_y >> 8); |
| 2310 | | |
| 2311 | | /* TODO: understand this one */ |
| 2312 | | if(start_x == 0) |
| 2313 | | cop_collision_info[0].min_x = cop_collision_info[0].x - ((0x10) << 16); |
| 2314 | | else |
| 2315 | | cop_collision_info[0].min_x = cop_collision_info[0].x + ((0) << 16); |
| 2316 | | |
| 2317 | | cop_collision_info[0].min_y = cop_collision_info[0].y + ((0) << 16); |
| 2318 | | cop_collision_info[0].max_x = cop_collision_info[0].x + ((end_x) << 16); |
| 2319 | | cop_collision_info[0].max_y = cop_collision_info[0].y + ((end_y) << 16); |
| 2320 | | |
| 2321 | 2322 | /* do the math */ |
| 2323 | cop_take_hit_box_params(0); |
| 2322 | 2324 | cop_hit_status = cop_calculate_collsion_detection(space->machine()); |
| 2323 | 2325 | |
| 2324 | 2326 | return; |
| r17799 | r17800 | |
| 2334 | 2336 | //(heatbrl) | 6 | ffff | b880 | b60 be0 be2 |
| 2335 | 2337 | if(COP_CMD(0xb60,0xbe0,0xbe2,0x000,0x000,0x000,0x000,0x000,u1,u2)) |
| 2336 | 2338 | { |
| 2337 | | UINT8 start_x, end_x,end_y; |
| 2338 | | //UINT8 start_y; |
| 2339 | | |
| 2340 | | /* Take hitbox param, TODO */ |
| 2341 | 2339 | cop_collision_info[1].hitbox = space->read_word(cop_register[3]); |
| 2342 | 2340 | cop_collision_info[1].hitbox_y = space->read_word((cop_register[3]&0xffff0000)|(cop_collision_info[1].hitbox)); |
| 2343 | 2341 | cop_collision_info[1].hitbox_x = space->read_word(((cop_register[3]&0xffff0000)|(cop_collision_info[1].hitbox))+2); |
| 2344 | | // TODO: z |
| 2345 | 2342 | |
| 2346 | | start_x = (cop_collision_info[0].hitbox_x & 0xff); |
| 2347 | | //start_y = (cop_collision_info[0].hitbox_y & 0xff); |
| 2348 | | end_x = (cop_collision_info[0].hitbox_x >> 8); |
| 2349 | | end_y = (cop_collision_info[0].hitbox_y >> 8); |
| 2350 | | |
| 2351 | | /* TODO: understand this one */ |
| 2352 | | if(start_x == 0) |
| 2353 | | cop_collision_info[1].min_x = cop_collision_info[1].x - ((0x10) << 16); |
| 2354 | | else |
| 2355 | | cop_collision_info[1].min_x = cop_collision_info[1].x + ((0) << 16); |
| 2356 | | |
| 2357 | | cop_collision_info[1].min_y = cop_collision_info[1].y + ((0) << 16); |
| 2358 | | cop_collision_info[1].max_x = cop_collision_info[1].x + ((end_x) << 16); |
| 2359 | | cop_collision_info[1].max_y = cop_collision_info[1].y + ((end_y) << 16); |
| 2360 | | |
| 2361 | | //if(cop_collision_info[0].x || cop_collision_info[1].x) |
| 2362 | | |
| 2363 | 2343 | /* do the math */ |
| 2344 | cop_take_hit_box_params(1); |
| 2364 | 2345 | cop_hit_status = cop_calculate_collsion_detection(space->machine()); |
| 2365 | 2346 | return; |
| 2366 | 2347 | } |