Previous 199869 Revisions Next

r18027 Wednesday 19th September, 2012 at 19:31:11 UTC by Angelo Salese
Seibu COP: Added 0xe38e command, used by Seibu Cup Soccer to follow the ball [Angelo Salese]
[src/mame/machine]seicop.c

trunk/src/mame/machine/seicop.c
r18026r18027
19381938}cop_collision_info[2];
19391939static int r0, r1;
19401940
1941static UINT16 cop_rom_addr_lo,cop_rom_addr_hi,cop_rom_addr_unk;
1942
19411943/* RE from Seibu Cup Soccer bootleg */
19421944static const UINT8 fade_table(int v)
19431945{
r18026r18027
21542156      case (0x01c/2): cop_angle_compare = INT8(cop_mcu_ram[0x1c/2]);   break;
21552157      case (0x01e/2): cop_angle_mod_val = INT8(cop_mcu_ram[0x1e/2]); break;
21562158
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
21602159      /* BCD Protection */
21612160      case (0x020/2):
21622161      case (0x022/2):
r18026r18027
21812180         fill_val = (cop_mcu_ram[0x028/2]) | (cop_mcu_ram[0x02a/2] << 16);
21822181         break;
21832182
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
21842186      /* Command tables for 0x500 / 0x502 commands */
21852187      case (0x032/2): { copd2_set_tabledata(space.machine(), data); break; }
21862188      case (0x034/2): { copd2_set_tableoffset(space.machine(), data); break; }
r18026r18027
21962198            */
21972199         break;
21982200
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
21992206      /* brightness control */
22002207      case (0x05a/2): pal_brightness_val = data & 0xff; break;
22012208      case (0x05c/2): pal_brightness_mode = data & 0xff; break;
r18026r18027
22522259         break;
22532260      }
22542261
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;
22572264
2258      case (0x044/2):
2259      {
2260         cop_scale = data & 3;
2261         break;
2262      }
2263
22642265      /* Registers */
22652266      case (0x0a0/2): { cop_register[0] = (cop_register[0]&0x0000ffff)|(cop_mcu_ram[offset]<<16); break; }
22662267      case (0x0c0/2): { cop_register[0] = (cop_register[0]&0xffff0000)|(cop_mcu_ram[offset]<<0);  break; }
r18026r18027
27502751            return;
27512752         }
27522753
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
27532795         printf("%04x\n",cop_mcu_ram[offset]);
27542796         break;
27552797      }
r18026r18027
29522994                  {
29532995                     case 2:   xchg_flag = (vali > valj); break;
29542996                     case 1: xchg_flag = (vali < valj); break;
2997                     case 0:   xchg_flag = 0; break; /* ??? */
29552998                     default: xchg_flag = 0; printf("Warning: sort-DMA used with param %02x\n",cop_sort_param); break;
29562999                  }
29573000

Previous 199869 Revisions Next


© 1997-2024 The MAME Team