trunk/src/mame/machine/seicop.c
r18026 | r18027 | |
1938 | 1938 | }cop_collision_info[2]; |
1939 | 1939 | static int r0, r1; |
1940 | 1940 | |
| 1941 | static UINT16 cop_rom_addr_lo,cop_rom_addr_hi,cop_rom_addr_unk; |
| 1942 | |
1941 | 1943 | /* RE from Seibu Cup Soccer bootleg */ |
1942 | 1944 | static const UINT8 fade_table(int v) |
1943 | 1945 | { |
r18026 | r18027 | |
2154 | 2156 | case (0x01c/2): cop_angle_compare = INT8(cop_mcu_ram[0x1c/2]); break; |
2155 | 2157 | case (0x01e/2): cop_angle_mod_val = INT8(cop_mcu_ram[0x1e/2]); break; |
2156 | 2158 | |
2157 | | case (0x08c/2): cop_sprite_dma_abs_y = (cop_mcu_ram[0x08c/2]); break; |
2158 | | case (0x08e/2): cop_sprite_dma_abs_x = (cop_mcu_ram[0x08e/2]); break; |
2159 | | |
2160 | 2159 | /* BCD Protection */ |
2161 | 2160 | case (0x020/2): |
2162 | 2161 | case (0x022/2): |
r18026 | r18027 | |
2181 | 2180 | fill_val = (cop_mcu_ram[0x028/2]) | (cop_mcu_ram[0x02a/2] << 16); |
2182 | 2181 | break; |
2183 | 2182 | |
| 2183 | /* max possible value returned by the RNG at 0x5a*, trusted */ |
| 2184 | case (0x02c/2): cop_rng_max_value = cop_mcu_ram[0x2c/2] & 0xff; break; |
| 2185 | |
2184 | 2186 | /* Command tables for 0x500 / 0x502 commands */ |
2185 | 2187 | case (0x032/2): { copd2_set_tabledata(space.machine(), data); break; } |
2186 | 2188 | case (0x034/2): { copd2_set_tableoffset(space.machine(), data); break; } |
r18026 | r18027 | |
2196 | 2198 | */ |
2197 | 2199 | break; |
2198 | 2200 | |
| 2201 | case (0x044/2): { cop_scale = data & 3; break; } |
| 2202 | case (0x046/2): { cop_rom_addr_unk = data & 0xffff; break; } |
| 2203 | case (0x048/2): { cop_rom_addr_lo = data & 0xffff; break; } |
| 2204 | case (0x04a/2): { cop_rom_addr_hi = data & 0xffff; break; } |
| 2205 | |
2199 | 2206 | /* brightness control */ |
2200 | 2207 | case (0x05a/2): pal_brightness_val = data & 0xff; break; |
2201 | 2208 | case (0x05c/2): pal_brightness_mode = data & 0xff; break; |
r18026 | r18027 | |
2252 | 2259 | break; |
2253 | 2260 | } |
2254 | 2261 | |
2255 | | /* max possible value returned by the RNG at 0x5a*, trusted */ |
2256 | | case (0x02c/2): cop_rng_max_value = cop_mcu_ram[0x2c/2] & 0xff; break; |
| 2262 | case (0x08c/2): cop_sprite_dma_abs_y = (cop_mcu_ram[0x08c/2]); break; |
| 2263 | case (0x08e/2): cop_sprite_dma_abs_x = (cop_mcu_ram[0x08e/2]); break; |
2257 | 2264 | |
2258 | | case (0x044/2): |
2259 | | { |
2260 | | cop_scale = data & 3; |
2261 | | break; |
2262 | | } |
2263 | | |
2264 | 2265 | /* Registers */ |
2265 | 2266 | case (0x0a0/2): { cop_register[0] = (cop_register[0]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; } |
2266 | 2267 | case (0x0c0/2): { cop_register[0] = (cop_register[0]&0xffff0000)|(cop_mcu_ram[offset]<<0); break; } |
r18026 | r18027 | |
2750 | 2751 | return; |
2751 | 2752 | } |
2752 | 2753 | |
| 2754 | //(cupsoc) 1c | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a |
| 2755 | if(COP_CMD(0x984,0xac4,0xd82,0xac2,0x39b,0xb9a,0xb9a,0xa9a,5,0xb07f)) |
| 2756 | { |
| 2757 | int dy = space.read_dword(cop_register[2]+4) - space.read_dword(cop_register[0]+4); |
| 2758 | int dx = space.read_dword(cop_register[2]+8) - space.read_dword(cop_register[0]+8); |
| 2759 | |
| 2760 | cop_status = 7; |
| 2761 | if(!dx) { |
| 2762 | cop_status |= 0x8000; |
| 2763 | cop_angle = 0; |
| 2764 | } else { |
| 2765 | cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI; |
| 2766 | if(dx<0) |
| 2767 | cop_angle += 0x80; |
| 2768 | } |
| 2769 | |
| 2770 | r0 = dy; |
| 2771 | r1 = dx; |
| 2772 | |
| 2773 | //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle); |
| 2774 | |
| 2775 | if(cop_mcu_ram[offset] & 0x80) |
| 2776 | space.write_word(cop_register[0]+(0x34^2), cop_angle); |
| 2777 | return; |
| 2778 | } |
| 2779 | |
| 2780 | //(cupsoc) 1a | 5 | fffb | d104 | ac2 9e0 0a2 |
| 2781 | /* controls player vs. player collision detection, 0xf105 controls player vs. ball */ |
| 2782 | if(COP_CMD(0xac2,0x9e0,0x0a2,0x000,0x000,0x000,0x000,0x000,5,0xfffb)) |
| 2783 | { |
| 2784 | UINT8 *ROM = space.machine().root_device().memregion("maincpu")->base(); |
| 2785 | UINT32 rom_addr = (cop_rom_addr_hi << 16 | cop_rom_addr_lo) & ~1; |
| 2786 | UINT16 rom_data = (ROM[rom_addr + 0]) | (ROM[rom_addr + 1]<<8); |
| 2787 | |
| 2788 | /* writes to some unemulated COP registers, then puts the result in here, adding a parameter taken from ROM */ |
| 2789 | space.write_word(cop_register[0]+(0x44 + offset * 4), rom_data); |
| 2790 | |
| 2791 | printf("%04x%04x %04x %04x\n",cop_rom_addr_hi,cop_rom_addr_lo,cop_rom_addr_unk,rom_data); |
| 2792 | return; |
| 2793 | } |
| 2794 | |
2753 | 2795 | printf("%04x\n",cop_mcu_ram[offset]); |
2754 | 2796 | break; |
2755 | 2797 | } |
r18026 | r18027 | |
2952 | 2994 | { |
2953 | 2995 | case 2: xchg_flag = (vali > valj); break; |
2954 | 2996 | case 1: xchg_flag = (vali < valj); break; |
| 2997 | case 0: xchg_flag = 0; break; /* ??? */ |
2955 | 2998 | default: xchg_flag = 0; printf("Warning: sort-DMA used with param %02x\n",cop_sort_param); break; |
2956 | 2999 | } |
2957 | 3000 | |