trunk/src/mame/includes/raiden2.h
| r31968 | r31969 | |
| 133 | 133 | UINT16 sprite_prot_x,sprite_prot_y,dst1,cop_spr_maxx,cop_spr_off; |
| 134 | 134 | UINT16 sprite_prot_src_addr[2]; |
| 135 | 135 | |
| 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]; |
| 143 | 140 | |
| 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; |
| 146 | 143 | |
| 147 | 144 | void draw_sprites(const rectangle &cliprect); |
| 148 | | UINT8 cop_calculate_collsion_detection(); |
| 149 | | void cop_take_hit_box_params(UINT8 offs); |
| 150 | 145 | |
| 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); |
| 151 | 150 | DECLARE_WRITE16_MEMBER(cop_sort_lookup_hi_w); |
| 152 | 151 | DECLARE_WRITE16_MEMBER(cop_sort_lookup_lo_w); |
| 153 | 152 | DECLARE_WRITE16_MEMBER(cop_sort_ram_addr_hi_w); |
trunk/src/mame/drivers/raiden2.c
| r31968 | r31969 | |
| 135 | 135 | High Priority |
| 136 | 136 | |
| 137 | 137 | Protection |
| 138 | | - raiden2 doesn't detect hits on stage 2 boss; |
| 139 | 138 | - zeroteam has bogus collision detection; |
| 140 | 139 | - raiden2 has a weird movement after that the ship completes animation from the aircraft. Probably 42c2 should be floating point rounded ... |
| 141 | 140 | - (and probably more) |
| r31968 | r31969 | |
| 520 | 519 | cop_regs[offset] = (cop_regs[offset] & ~UINT32(mem_mask)) | (data & mem_mask); |
| 521 | 520 | } |
| 522 | 521 | |
| 523 | | void raiden2_state::cop_take_hit_box_params(UINT8 offs) |
| 522 | WRITE16_MEMBER(raiden2_state::cop_hitbox_baseadr_w) |
| 524 | 523 | { |
| 525 | | INT16 start_x,start_y,end_x,end_y; |
| 524 | COMBINE_DATA(&cop_hit_baseadr); |
| 525 | } |
| 526 | 526 | |
| 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); |
| 527 | void 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); |
| 537 | 531 | } |
| 538 | 532 | |
| 539 | | |
| 540 | | UINT8 raiden2_state::cop_calculate_collsion_detection() |
| 533 | void raiden2_state::cop_collision_update_hitbox(address_space &space, int slot, UINT32 hitadr) |
| 541 | 534 | { |
| 542 | | static UINT8 res; |
| 535 | UINT32 hitadr2 = space.read_dword(hitadr) + (cop_hit_baseadr << 16); |
| 536 | UINT32 hitbox_raw = space.read_dword(hitadr2); |
| 543 | 537 | |
| 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; |
| 545 | 542 | |
| 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 | |
| 546 | 550 | /* outbound X check */ |
| 547 | 551 | 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; |
| 549 | 553 | |
| 550 | 554 | /* outbound Y check */ |
| 551 | 555 | 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; |
| 553 | 557 | |
| 554 | 558 | cop_hit_val_x = (cop_collision_info[0].x - cop_collision_info[1].x) >> 16; |
| 555 | 559 | cop_hit_val_y = (cop_collision_info[0].y - cop_collision_info[1].y) >> 16; |
| 556 | 560 | 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 |
| 560 | 562 | } |
| 561 | 563 | |
| 562 | | /* |
| 563 | | TODO: |
| 564 | | 2a05: first boss |
| 565 | | 2208/2288: first enemies when they crash on the ground (collision direction?) |
| 566 | | 39b0: 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 | | */ |
| 568 | 564 | WRITE16_MEMBER(raiden2_state::cop_cmd_w) |
| 569 | 565 | { |
| 570 | 566 | cop_status &= 0x7fff; |
| r31968 | r31969 | |
| 758 | 754 | |
| 759 | 755 | case 0xa100: |
| 760 | 756 | 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]); |
| 763 | 758 | break; |
| 764 | 759 | |
| 765 | 760 | case 0xa900: |
| 766 | 761 | 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]); |
| 769 | 763 | break; |
| 770 | 764 | |
| 771 | 765 | 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]); |
| 779 | 767 | break; |
| 780 | 768 | |
| 781 | 769 | 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]); |
| 789 | 771 | break; |
| 790 | 772 | |
| 791 | 773 | default: |
| r31968 | r31969 | |
| 793 | 775 | } |
| 794 | 776 | } |
| 795 | 777 | |
| 796 | | // case 0x6ca: |
| 797 | | // logerror("select bank %d %04x\n", (data >> 15) & 1, data); |
| 798 | | // space.membank("bank1")->set_entry((data >> 15) & 1); |
| 799 | 778 | |
| 800 | | |
| 801 | 779 | void raiden2_state::combine32(UINT32 *val, int offset, UINT16 data, UINT16 mem_mask) |
| 802 | 780 | { |
| 803 | 781 | UINT16 *dest = (UINT16 *)val + BYTE_XOR_LE(offset); |
| r31968 | r31969 | |
| 1559 | 1537 | AM_RANGE(0x0042a, 0x0042b) AM_WRITE(cop_dma_v2_w) |
| 1560 | 1538 | AM_RANGE(0x00432, 0x00433) AM_WRITE(cop_pgm_data_w) |
| 1561 | 1539 | AM_RANGE(0x00434, 0x00435) AM_WRITE(cop_pgm_addr_w) |
| 1540 | AM_RANGE(0x00436, 0x00437) AM_WRITE(cop_hitbox_baseadr_w) |
| 1562 | 1541 | AM_RANGE(0x00438, 0x00439) AM_WRITE(cop_pgm_value_w) |
| 1563 | 1542 | AM_RANGE(0x0043a, 0x0043b) AM_WRITE(cop_pgm_mask_w) |
| 1564 | 1543 | AM_RANGE(0x0043c, 0x0043d) AM_WRITE(cop_pgm_trigger_w) |