Previous 199869 Revisions Next

r34619 Monday 26th January, 2015 at 15:47:06 UTC by David Haywood
move decathlete protection in a device, moved the doa protection sim there too, added devices to driver (preparation for refactoring, they're the same device, just underused by Doa)
[src/mame]mame.mak
[src/mame/drivers]model2.c stv.c
[src/mame/includes]model2.h stv.h
[src/mame/machine]315-5838_317-0229_comp.c* 315-5838_317-0229_comp.h*

trunk/src/mame/drivers/model2.c
r243130r243131
12351235};
12361236
12371237
1238READ32_MEMBER(model2_state::model2_prot_r)
1239{
1240   UINT32 retval = 0;
12411238
1242   if (offset == 0x10000/4)
1243   {
1244      // status: bit 0 = 1 for busy, 0 for ready
1245      retval = 0;   // we're always ready
1246   }
1247   else if (offset == 0x1000e/4)
1248   {
1249      retval = m_protram[m_protstate+1] | m_protram[m_protstate+0]<<8;
1250      retval <<= 16;
1251      m_protstate+=2;
1252   }
1253   else logerror("Unhandled Protection READ @ %x mask %x (PC=%x)\n", offset, mem_mask, space.device().safe_pc());
1254
1255   printf("model2_prot_r %08x: %08x (%08x)\n", offset*4, retval, mem_mask);
1256
1257   return retval;
1258}
1259
1260WRITE32_MEMBER(model2_state::model2_prot_w)
1261{
1262   printf("model2_prot_w %08x: %08x (%08x)\n", offset*4, data, mem_mask);
1263
1264   if (mem_mask == 0xffff0000)
1265   {
1266      data >>= 16;
1267   }
1268
1269   if (offset == 0x10008/4)
1270   {
1271      m_protpos = data;
1272   }
1273   else if (offset == 0x1000c/4)
1274   {
1275      switch (data)
1276      {
1277         // zerogun
1278         case 0xA1BC:
1279         case 0xAD23:
1280         case 0x13CD:
1281         case 0x4D53:
1282         case 0x234D:
1283         case 0x113D:
1284         case 0x1049:
1285         case 0x993D:
1286         case 0x983C:
1287         case 0x935:
1288         case 0x9845:
1289         case 0x556D:
1290         case 0x98CC:
1291         case 0x3422:
1292         case 0x10:
1293            m_protstate = 0;
1294            memcpy(m_protram+2, ZGUNProt+((2*m_protpos)/12)*8, sizeof(ZGUNProt));
1295            break;
1296
1297         // pltkids
1298         case 0x7140:
1299            m_protstate = 0;
1300            strcpy((char *)m_protram+2, "98-PILOT  ");
1301            break;
1302
1303         default:
1304            m_protstate = 0;
1305            break;
1306      }
1307   }
1308   else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc());
1309
1310}
1311
1312
13131239READ32_MEMBER(model2_state::model2_5881prot_r)
13141240{
13151241   UINT32 retval = 0;
r243130r243131
13721298}
13731299
13741300
1375READ32_MEMBER(model2_state::doa_prot_r)
1376{
1377   UINT32 retval = 0;
13781301
1379   if (offset == 0x7ff8/4)
1380   {
1381      retval = m_protram[m_protstate+1] | m_protram[m_protstate]<<8;
1382      m_protstate+=2;
1383   }
1384   else if (offset == 0x400c/4)
1385   {
1386      m_prot_a = !m_prot_a;
1387      if (m_prot_a)
1388         retval = 0xffff;
1389      else
1390         retval = 0xfff0;
1391   }
1392   else logerror("Unhandled Protection READ @ %x mask %x (PC=%x)\n", offset, mem_mask, space.device().safe_pc());
1393
1394   return retval;
1395}
1396
1397
1398WRITE32_MEMBER(model2_state::doa_prot_w)
1399{
1400   if (offset == 0x7ff2 / 4)
1401   {
1402      if (data == 0)
1403      {
1404         m_protstate = 0;
1405         strcpy((char *)m_protram, "  TECMO LTD.  DEAD OR ALIVE  1996.10.22  VER. 1.00");
1406      }
1407   }
1408   else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc());
1409}
1410
14111302/* Daytona "To The MAXX" PIC protection simulation */
14121303
14131304
r243130r243131
26112502   MCFG_SET_READ_CALLBACK(model2_state, crypt_read_callback)
26122503MACHINE_CONFIG_END
26132504
2505static MACHINE_CONFIG_DERIVED( model2a_0229, model2a )
2506   MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0)
2507//   MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
2508MACHINE_CONFIG_END
2509
26142510READ8_MEMBER(model2_state::driveio_port_r)
26152511{
26162512   return m_driveio_comm_data;
r243130r243131
27142610   MCFG_SET_READ_CALLBACK(model2_state, crypt_read_callback)
27152611MACHINE_CONFIG_END
27162612
2613static MACHINE_CONFIG_DERIVED( model2b_0229, model2b )
2614   MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0)
2615//   MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
2616MACHINE_CONFIG_END
2617
2618
27172619static ADDRESS_MAP_START( copro_tgpx4_map, AS_PROGRAM, 32, model2_state )
27182620   AM_RANGE(0x00000000, 0x00007fff) AM_RAM AM_SHARE("tgpx4_program")
27192621ADDRESS_MAP_END
r243130r243131
60045906{   
60055907   astring key = parameter(":315_5881:key");
60065908
6007   if (key)
6008   {
6009      m_maincpu->space(AS_PROGRAM).install_ram(0x01d80000, 0x01d8ffff);
6010      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x01d90000, 0x01d9ffff, read32_delegate(FUNC(model2_state::model2_5881prot_r), this), write32_delegate(FUNC(model2_state::model2_5881prot_w), this));
6011   }
6012   else
6013   {
6014      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x01d80000, 0x01dfffff, read32_delegate(FUNC(model2_state::model2_prot_r), this), write32_delegate(FUNC(model2_state::model2_prot_w), this));                   
6015      m_protstate = m_protpos = 0;
6016   }
5909   m_maincpu->space(AS_PROGRAM).install_ram(0x01d80000, 0x01d8ffff);
5910   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x01d90000, 0x01d9ffff, read32_delegate(FUNC(model2_state::model2_5881prot_r), this), write32_delegate(FUNC(model2_state::model2_5881prot_w), this));
5911
60175912}
60185913
60195914DRIVER_INIT_MEMBER(model2_state,pltkids)
r243130r243131
60845979
60855980DRIVER_INIT_MEMBER(model2_state,doa)
60865981{
6087   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x01d80000, 0x01dfffff, read32_delegate(FUNC(model2_state::doa_prot_r),this),  write32_delegate(FUNC(model2_state::doa_prot_w),this));
6088   m_protstate = m_protpos = 0;
6089
5982   m_0229crypt->install_doa_protection();
60905983   
60915984   UINT32 *ROM = (UINT32 *)memregion("maincpu")->base();
60925985   ROM[0x630/4] = 0x08000004;
r243130r243131
61286021GAME( 1995, vf2o,          vf2, model2a,      model2,  driver_device, 0,       ROT0, "Sega",   "Virtua Fighter 2", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61296022GAME( 1995, vcop2,           0, model2a,      vcop2,   driver_device, 0,       ROT0, "Sega",   "Virtua Cop 2", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61306023GAME( 1995, skytargt,        0, model2a,      skytargt,driver_device, 0,       ROT0, "Sega",   "Sky Target", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
6131GAME( 1996, doaa,          doa, model2a,      model2,  model2_state,  doa,     ROT0, "Sega",   "Dead or Alive (Model 2A, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
6024GAME( 1996, doaa,          doa, model2a_0229,  model2,  model2_state,  doa,     ROT0, "Sega",   "Dead or Alive (Model 2A, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61326025GAME( 1997, zeroguna,  zerogun, model2a_5881, model2,  model2_state,  zerogun, ROT0, "Psikyo", "Zero Gunner (Export, Model 2A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61336026GAME( 1997, zerogunaj, zerogun, model2a_5881, model2,  model2_state,  zerogun, ROT0, "Psikyo", "Zero Gunner (Japan, Model 2A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61346027GAME( 1997, motoraid,        0, model2a,      manxtt,  driver_device, 0,       ROT0, "Sega",   "Motor Raid - Twin", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
r243130r243131
61496042GAME( 1996, lastbrnx,        0, model2b,      model2,  driver_device, 0,       ROT0, "Sega",   "Last Bronx (Export, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61506043GAME( 1996, lastbrnxu,lastbrnx, model2b,      model2,  driver_device, 0,       ROT0, "Sega",   "Last Bronx (USA, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61516044GAME( 1996, lastbrnxj,lastbrnx, model2b,      model2,  driver_device, 0,       ROT0, "Sega",   "Last Bronx (Japan, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
6152GAME( 1996, doa,             0, model2b,      model2,  model2_state,  doa,     ROT0, "Sega",   "Dead or Alive (Model 2B, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
6045GAME( 1996, doa,             0, model2b_0229, model2,  model2_state,  doa,     ROT0, "Sega",   "Dead or Alive (Model 2B, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61536046GAME( 1996, sgt24h,          0, model2b,      srallyc, model2_state,  sgt24h,  ROT0, "Jaleco", "Super GT 24h", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61546047GAME( 1996, von,             0, model2b,      model2,  driver_device, 0,       ROT0, "Sega",   "Cyber Troopers Virtual-On (USA, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
61556048GAME( 1996, vonj,          von, model2b,      model2,  driver_device, 0,       ROT0, "Sega",   "Cyber Troopers Virtual-On (Japan, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
trunk/src/mame/drivers/stv.c
r243130r243131
912912
913913DRIVER_INIT_MEMBER(stv_state,decathlt)
914914{
915   m_decathlt_lastcount = 0;
916   m_decathlt_prot_uploadmode = 0;
917   m_decathlt_prot_uploadoffset = 0;
918   install_decathlt_protection();
915   m_5838crypt->install_decathlt_protection();
919916   DRIVER_INIT_CALL(stv);
920917}
921918
r243130r243131
10221019   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
10231020   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
10241021
1022MACHINE_CONFIG_END
1023
1024static MACHINE_CONFIG_DERIVED( stv_5881, stv )
10251025   MCFG_DEVICE_ADD("315_5881", SEGA315_5881_CRYPT, 0)
10261026   MCFG_SET_READ_CALLBACK(stv_state, crypt_read_callback)
10271027MACHINE_CONFIG_END
10281028
1029static MACHINE_CONFIG_DERIVED( stv_5838, stv )
1030   MCFG_DEVICE_ADD("315_5838", SEGA315_5838_COMP, 0)
1031//   MCFG_SET_5838_READ_CALLBACK(stv_state, crypt_read_callback)
1032MACHINE_CONFIG_END
1033
1034
10291035/*
10301036    Batman Forever has an extra ADSP, used for sound.
10311037    Similar if not the same as Magic the Gathering, probably needs merging.
r243130r243131
30253031
30263032//GAME YEAR, NAME,     PARENT,  MACH, INP, INIT,      MONITOR
30273033/* Playable */
3028GAME( 1998, astrass,   stvbios, stv,      stv6b, stv_state,      astrass,    ROT0,   "Sunsoft",                      "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3034GAME( 1998, astrass,   stvbios, stv_5881, stv6b, stv_state,      astrass,    ROT0,   "Sunsoft",                      "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
30293035GAME( 1995, bakubaku,  stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Baku Baku Animal (J 950407 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30303036GAME( 1996, batmanfr,  stvbios, batmanfr, stv, stv_state,        batmanfr,   ROT0,   "Acclaim",                      "Batman Forever (JUE 960507 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
30313037GAME( 1996, colmns97,  stvbios, stv,      stv, stv_state,        colmns97,   ROT0,   "Sega",                         "Columns '97 (JET 961209 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
r243130r243131
30373043GAME( 1996, diehard,   stvbios, stv,      stv, stv_state,        diehard,    ROT0,   "Sega",                         "Die Hard Arcade (UET 960515 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND  )
30383044GAME( 1996, dnmtdeka,  diehard, stv,      stv, stv_state,        dnmtdeka,   ROT0,   "Sega",                         "Dynamite Deka (J 960515 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND  )
30393045GAME( 1995, ejihon,    stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Sega",                         "Ejihon Tantei Jimusyo (J 950613 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3040GAME( 1998, elandore,  stvbios, stv,      stv6b, stv_state,      elandore,   ROT0,   "Sai-Mate",                     "Touryuu Densetsu Elan-Doree / Elan Doree - Legend of Dragoon (JUET 980922 V1.006)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3041GAME( 1999, ffreveng,  stvbios, stv,      stv, stv_state,        ffreveng,   ROT0,   "Capcom",                       "Final Fight Revenge (JUET 990714 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3046GAME( 1998, elandore,  stvbios, stv_5881, stv6b, stv_state,      elandore,   ROT0,   "Sai-Mate",                     "Touryuu Densetsu Elan-Doree / Elan Doree - Legend of Dragoon (JUET 980922 V1.006)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3047GAME( 1999, ffreveng,  stvbios, stv_5881, stv, stv_state,        ffreveng,   ROT0,   "Capcom",                       "Final Fight Revenge (JUET 990714 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30423048GAME( 1995, fhboxers,  stvbios, stv,      stv, stv_state,        fhboxers,   ROT0,   "Sega",                         "Funky Head Boxers (JUETBKAL 951218 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30433049GAME( 1997, findlove,  stvbios, stv,      stv, stv_state,        stv,        ROT0,   "Daiki / FCF",                  "Zenkoku Seifuku Bishoujo Grand Prix Find Love (J 971212 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30443050GAME( 1994, gaxeduel,  stvbios, stv,      stv6b, stv_state,      gaxeduel,   ROT0,   "Sega",                         "Golden Axe - The Duel (JUETL 950117 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS)
r243130r243131
30543060GAME( 1995, pblbeach,  stvbios, stv,      stv, stv_state,        pblbeach,   ROT0,   "T&E Soft",                     "Pebble Beach - The Great Shot (JUE 950913 V0.990)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30553061GAME( 1996, prikura,   stvbios, stv,      stv, stv_state,        prikura,    ROT0,   "Atlus",                        "Princess Clara Daisakusen (J 960910 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30563062GAME( 1996, puyosun,   stvbios, stv,      stv, stv_state,        puyosun,    ROT0,   "Compile",                      "Puyo Puyo Sun (J 961115 V0.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3057GAME( 1998, rsgun,     stvbios, stv,      stv, stv_state,        rsgun,      ROT0,   "Treasure",                     "Radiant Silvergun (JUET 980523 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3063GAME( 1998, rsgun,     stvbios, stv_5881, stv, stv_state,        rsgun,      ROT0,   "Treasure",                     "Radiant Silvergun (JUET 980523 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
30583064GAME( 1998, sasissu,   stvbios, stv,      stv, stv_state,        sasissu,    ROT0,   "Sega",                         "Taisen Tanto-R Sashissu!! (J 980216 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30593065GAME( 1999, sanjeon,   sasissu, stv,      stv, stv_state,        sanjeon,    ROT0,   "Sega / Deniam",                "DaeJeon! SanJeon SuJeon (AJTUE 990412 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30603066GAME( 1997, seabass,   stvbios, stv,      stv, stv_state,        seabass,    ROT0,   "A wave inc. (Able license)",   "Sea Bass Fishing (JUET 971110 V0.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30613067GAME( 1995, shanhigw,  stvbios, stv,      stv, stv_state,        shanhigw,   ROT0,   "Sunsoft / Activision",         "Shanghai - The Great Wall / Shanghai Triple Threat (JUE 950623 V1.005)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30623068GAME( 1997, shienryu,  stvbios, stv,      stv, stv_state,        shienryu,   ROT270, "Warashi",                      "Shienryu (JUET 961226 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3063GAME( 1998, sss,       stvbios, stv,      stv, stv_state,        sss,        ROT0,   "Capcom / Cave / Victor",       "Steep Slope Sliders (JUET 981110 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3069GAME( 1998, sss,       stvbios, stv_5881, stv, stv_state,        sss,        ROT0,   "Capcom / Cave / Victor",       "Steep Slope Sliders (JUET 981110 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30643070GAME( 1995, sandor,    stvbios, stv,      stv, stv_state,        sandor,     ROT0,   "Sega",                         "Puzzle & Action: Sando-R (J 951114 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30653071GAME( 1997, thunt,     sandor,  stv,      stv, stv_state,        thunt,      ROT0,   "Sega",                         "Puzzle & Action: Treasure Hunt (JUET 970901 V2.00E)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30663072GAME( 1997, thuntk,    sandor,  stv,      stv, stv_state,        sandor,     ROT0,   "Sega / Deniam",                "Puzzle & Action: BoMulEul Chajara (JUET 970125 V2.00K)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3067GAME( 1998, twcup98,   stvbios, stv,      stv, stv_state,        twcup98,    ROT0,   "Tecmo",                        "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3073GAME( 1998, twcup98,   stvbios, stv_5881, stv, stv_state,        twcup98,    ROT0,   "Tecmo",                        "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30683074GAME( 1995, smleague,  stvbios, stv,      stv, stv_state,        smleague,   ROT0,   "Sega",                         "Super Major League (U 960108 V1.000)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30693075GAME( 1995, finlarch,  smleague,stv,      stv, stv_state,        finlarch,   ROT0,   "Sega",                         "Final Arch (J 950714 V1.001)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
30703076GAME( 1996, sokyugrt,  stvbios, stv,      stv, stv_state,        sokyugrt,   ROT0,   "Raizing / Eighting",           "Soukyugurentai / Terra Diver (JUET 960821 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
r243130r243131
30923098
30933099/* Doing something.. but not enough yet */
30943100GAME( 1995, vfremix,   stvbios, stv,      stv, stv_state,        vfremix,    ROT0,   "Sega",                         "Virtua Fighter Remix (JUETBKAL 950428 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
3095GAME( 1996, decathlt,  stvbios, stv,      stv, stv_state,        decathlt,   ROT0,   "Sega",                         "Decathlete (JUET 960709 V1.001)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3096GAME( 1996, decathlto, decathlt,stv,      stv, stv_state,        decathlt,   ROT0,   "Sega",                         "Decathlete (JUET 960424 V1.000)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3101GAME( 1996, decathlt,  stvbios, stv_5838, stv, stv_state,        decathlt,   ROT0,   "Sega",                         "Decathlete (JUET 960709 V1.001)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3102GAME( 1996, decathlto, decathlt,stv_5838, stv, stv_state,        decathlt,   ROT0,   "Sega",                         "Decathlete (JUET 960424 V1.000)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
30973103
30983104/* Gives I/O errors */
30993105GAME( 1996, magzun,    stvbios, stv,      stv, stv_state,        magzun,     ROT0,   "Sega",                         "Magical Zunou Power (J 961031 V1.000)", GAME_NOT_WORKING )
trunk/src/mame/includes/model2.h
r243130r243131
55#include "cpu/i960/i960.h"
66#include "sound/scsp.h"
77#include "machine/315-5881_crypt.h"
8#include "machine/315-5838_317-0229_comp.h"
89
910struct raster_state;
1011struct geo_state;
r243130r243131
3637      m_screen(*this, "screen"),
3738      m_palette(*this, "palette"),
3839      m_scsp(*this, "scsp"),
39      m_cryptdevice(*this, "315_5881")
40      m_cryptdevice(*this, "315_5881"),
41      m_0229crypt(*this, "317_0229")
42
4043      { }
4144
4245   required_shared_ptr<UINT32> m_workram;
r243130r243131
6366   required_device<palette_device> m_palette;
6467   optional_device<scsp_device> m_scsp;
6568   optional_device<sega_315_5881_crypt_device> m_cryptdevice;
69   optional_device<sega_315_5838_comp_device> m_0229crypt;
6670
6771   UINT32 m_intreq;
6872   UINT32 m_intena;
r243130r243131
9296   int m_geo_iop_write_num;
9397   UINT32 m_geo_iop_data;
9498   int m_to_68k;
95   int m_protstate;
96   int m_protpos;
97   UINT8 m_protram[256];
98   int m_prot_a;
99
99100   int m_maxxstate;
100101   UINT32 m_netram[0x8000/4];
101102   int m_zflagi;
r243130r243131
158159   DECLARE_READ32_MEMBER(model2_serial_r);
159160   DECLARE_WRITE32_MEMBER(model2o_serial_w);
160161   DECLARE_WRITE32_MEMBER(model2_serial_w);
161   DECLARE_READ32_MEMBER(model2_prot_r);
162   DECLARE_WRITE32_MEMBER(model2_prot_w);
163   DECLARE_READ32_MEMBER(doa_prot_r);
164   DECLARE_WRITE32_MEMBER(doa_prot_w);
165162   DECLARE_READ32_MEMBER(model2_5881prot_r);
166163   DECLARE_WRITE32_MEMBER(model2_5881prot_w);
167164   int first_read;
trunk/src/mame/includes/stv.h
r243130r243131
1010#include "bus/generic/carts.h"
1111
1212#include "machine/315-5881_crypt.h"
13#include "machine/315-5838_317-0229_comp.h"
1314
1415#define MAX_FILTERS (24)
1516#define MAX_BLOCKS  (200)
r243130r243131
701702      : saturn_state(mconfig, type, tag),
702703      m_adsp(*this, "adsp"),
703704      m_adsp_pram(*this, "adsp_pram"),
704      m_cryptdevice(*this, "315_5881")
705      m_cryptdevice(*this, "315_5881"),
706      m_5838crypt(*this, "315_5838")
705707   {
706708   }
707709
r243130r243131
808810   void install_common_protection();
809811   void stv_register_protection_savestates();
810812
811   // Decathlete specific variables and functions (see machine/decathlt.c)
812   UINT32 m_decathlt_protregs[4];
813   UINT32 m_decathlt_lastcount;
814   UINT32 m_decathlt_part;
815   UINT32 m_decathlt_prot_uploadmode;
816   UINT32 m_decathlt_prot_uploadoffset;
817   UINT16 m_decathlt_prottable1[24];
818   UINT16 m_decathlt_prottable2[128];
819813
820   DECLARE_READ32_MEMBER( decathlt_prot_r );
821   DECLARE_WRITE32_MEMBER( decathlt_prot1_w );
822   DECLARE_WRITE32_MEMBER( decathlt_prot2_w );
823   void write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which);
824   void install_decathlt_protection();
825814
826815   optional_device<sega_315_5881_crypt_device> m_cryptdevice;
816   optional_device<sega_315_5838_comp_device> m_5838crypt;
827817   UINT16 crypt_read_callback(UINT32 addr);
828818};
829819
trunk/src/mame/machine/315-5838_317-0229_comp.c
r0r243131
1/* Sega Compression (and possibly encryption) device
2
3   315-5838 - Decathlete (ST-V)
4   317-0229 - Dead or Alive (Model 2A)
5
6   Package Type: TQFP100
7
8   This appears to be a dual channel compression chip, used in 1996, predating the 5881.
9   Decathlete uses it to compress ALL the game graphics, Dead or Alive uses it for a
10   dumb security check, decompressing a single string.
11
12   Dead of Alive only uses a single channel, and has the source data in RAM, not ROM.
13   This is similar to how some 5881 games were set up, with the ST-V versions decrypting
14   data directly from ROM and the Model 2 ones using a RAM source buffer.
15
16*/
17
18#include "emu.h"
19#include "machine/315-5838_317-0229_comp.h"
20
21extern const device_type SEGA315_5838_COMP = &device_creator<sega_315_5838_comp_device>;
22
23
24sega_315_5838_comp_device::sega_315_5838_comp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
25   : device_t(mconfig, SEGA315_5838_COMP, "Sega 315-5838 / 317-0029 Compression (Encryption?)", tag, owner, clock, "SEGA315_5838", __FILE__)
26{
27}
28
29
30
31void sega_315_5838_comp_device::device_start()
32{
33   m_decathlt_lastcount = 0;
34   m_decathlt_prot_uploadmode = 0;
35   m_decathlt_prot_uploadoffset = 0;
36}
37
38void sega_315_5838_comp_device::device_reset()
39{
40   memset(m_decathlt_protregs, 0, sizeof(m_decathlt_protregs));
41   m_decathlt_lastcount = 0;
42   m_decathlt_prot_uploadmode = 0;
43   m_decathlt_prot_uploadoffset = 0;
44   m_decathlt_part = 1;
45
46   m_protstate = 0;
47}
48
49
50/**************************
51*
52* Decathlete
53*
54**************************/
55
56READ32_MEMBER( sega_315_5838_comp_device::decathlt_prot_r )
57{
58   // the offsets written to the protection device definitely only refer to 2 of the roms
59   //  it's a fair assumption to say that only those 2 are connected to the protection device
60   UINT8 *ROM = (UINT8 *)memregion(":abus")->base()+0x1000000;
61   UINT32 *fake0 = (UINT32*)memregion( ":fake0" )->base();
62
63   if (offset==2)
64   {
65      UINT32 retvalue = 0xffff;
66
67      switch (m_decathlt_protregs[0])
68      {
69         default:
70         retvalue = ROM[(m_decathlt_protregs[0]*2)-2];
71         retvalue <<= 8;
72         retvalue |= ROM[((m_decathlt_protregs[0]+1)*2)+1-2];
73         retvalue <<= 8;
74         retvalue |= ROM[((m_decathlt_protregs[0]+1)*2)-2];
75         retvalue <<= 8;
76         retvalue |= ROM[((m_decathlt_protregs[0]+2)*2)+1-2];
77         m_decathlt_lastcount++;
78         logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0], retvalue, m_decathlt_lastcount*4);
79         m_decathlt_protregs[0]+=2;
80         return retvalue;
81
82         case 0x03228e4:
83            if (fake0) retvalue = fake0[(((0x20080/4)+m_decathlt_lastcount))];
84            m_decathlt_lastcount++;
85            return retvalue;
86
87         case 0x00a9f3a:
88            if (fake0) retvalue = fake0[(((0x00000/4)+m_decathlt_lastcount))];
89            m_decathlt_lastcount++;
90            return retvalue;
91
92         case 0x0213ab4:
93            if (fake0) retvalue = fake0[(((0x40000/4)+m_decathlt_lastcount))];
94            m_decathlt_lastcount++;
95            return retvalue;
96
97         case 0x01efaf0:
98            if (fake0) retvalue = fake0[(((0x60000/4)+m_decathlt_lastcount))];
99            m_decathlt_lastcount++;
100            return retvalue;
101
102         case 0x033f16c:
103         case 0x038929c:
104
105
106
107         case 0x00de05a:
108         case 0x0334258:
109         case 0x019fb82:
110         case 0x033dbf6:
111         case 0x0011ac6:
112         case 0x00060dc:
113         case 0x0000002:
114         case 0x0008c90:
115         case 0x035cdc8:
116         case 0x0327960:
117         case 0x0329b8c:
118         case 0x00d6e92:
119         case 0x000081e:
120         case 0x00035d6:
121         case 0x00089a6:
122         case 0x03315f4:
123         case 0x0023fe0:
124         case 0x001e290:
125         case 0x0026e86:
126         case 0x0012494:
127         case 0x001b35a:
128         case 0x0018424:
129
130            return retvalue;
131      }
132
133
134   }
135   else
136   {
137      logerror("%06x Decathlete prot R offset %04x mask %08x regs %08x, %08x, %08x, %08x\n", safe_pc(), offset, mem_mask, m_decathlt_protregs[0], m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]);
138   }
139
140   return m_decathlt_protregs[offset];
141}
142
143
144void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which)
145{
146
147   printf("write_prot_data %08x %08x %08x\n", offset, data, mem_mask);
148
149   m_decathlt_protregs[offset] = (data&mem_mask)|(m_decathlt_protregs[offset]&~mem_mask);
150//  m_decathlt_protregs[0] = 0x0c00000/4;
151
152   if (offset==0) // seems to set a source address
153   {
154      m_decathlt_part ^=1;
155
156      //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",which, m_decathlt_lastcount*4);
157      m_decathlt_lastcount = 0;
158      if (m_decathlt_part==1) logerror("%d Decathlete prot W offset %04x data %08x, %08x, >>> regs %08x <<<<, %08x, %08x, %08x\n",which, offset, data, m_decathlt_protregs[0], m_decathlt_protregs[0]*4, m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]);
159   }
160
161   if (offset==1) // uploads 2 tables...
162   {
163      if (mem_mask==0xffff0000)
164      {
165         if (data == 0x80000000)
166         {
167         //  logerror("changed to upload mode 1\n");
168            m_decathlt_prot_uploadmode = 1;
169            m_decathlt_prot_uploadoffset = 0;
170         }
171         else if (data == 0x80800000)
172         {
173         //  logerror("changed to upload mode 2\n");
174            m_decathlt_prot_uploadmode = 2;
175            m_decathlt_prot_uploadoffset = 0;
176         }
177         else
178         {
179         //  logerror("unknown upload mode\n");
180            m_decathlt_prot_uploadmode = 2;
181            m_decathlt_prot_uploadoffset = 0;
182         }
183
184//          logerror("ARGH! %08x %08x\n",mem_mask,data);
185      }
186      else if (mem_mask==0x0000ffff)
187      {
188         if (m_decathlt_prot_uploadmode==1)
189         {
190            if (m_decathlt_prot_uploadoffset>=24)
191            {
192            //  logerror("upload mode 1 error, too big\n");
193               return;
194            }
195
196            //logerror("uploading table 1 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff);
197            m_decathlt_prottable1[m_decathlt_prot_uploadoffset]=data&0xffff;
198            m_decathlt_prot_uploadoffset++;
199
200            printf("table 1 %04x\n", data & 0xffff);
201
202            {
203               /* 0x18 (24) values in this table, rom data is 0x1800000 long, maybe it has
204                  something to do with that? or 24-address b    its?
205
206                  uploaded values appear to be 12-bit, some are repeated
207               */
208
209               {
210                  FILE* fp;
211                  if (which==1) fp = fopen("table1x","wb");
212                  else fp = fopen("table1","wb");
213
214                  {
215                     fwrite(&m_decathlt_prottable1,24,2,fp);
216                  }
217                  fclose(fp);
218               }
219            }
220
221         }
222         else if (m_decathlt_prot_uploadmode==2)
223         {
224            if (m_decathlt_prot_uploadoffset>=128)
225            {
226               //logerror("upload mode 2 error, too big\n");
227               return;
228            }
229
230            //logerror("uploading table 2 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff);
231            m_decathlt_prottable2[m_decathlt_prot_uploadoffset]=data&0xffff;
232            m_decathlt_prot_uploadoffset++;
233
234            printf("dictionary %04x\n", data & 0xffff);
235
236
237            {
238               /* the table uploaded here is a 256 byte table with 256 unique values, remaps something? */
239
240               {
241                  FILE* fp;
242                  if (which==1) fp = fopen("table2x","wb");
243                  else fp = fopen("table2","wb");
244
245                  {
246                     fwrite(&m_decathlt_prottable2,128,2,fp);
247                  }
248                  fclose(fp);
249               }
250            }
251         }
252         else
253         {
254         //  logerror("unknown upload mode!\n");
255         }
256      }
257   }
258
259   if (offset>1)
260   {
261   //  logerror("higher offset write\n");
262   }
263
264}
265
266WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w )
267{
268   write_prot_data(data,mem_mask, offset, 0);
269
270}
271
272WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w )
273{
274   write_prot_data(data,mem_mask, offset, 1);
275
276
277}
278
279void sega_315_5838_comp_device::install_decathlt_protection()
280{
281   /* It uploads 2 tables here, then performs what looks like a number of transfers, setting
282      a source address of some kind (scrambled?) and then making many reads from a single address */
283
284   //todo, install these in the driver, they differ between games
285   cpu_device* cpu = (cpu_device*)machine().device(":maincpu");
286
287
288   cpu->space(AS_PROGRAM).install_readwrite_handler(0x37FFFF0, 0x37FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w), this));
289   /* It accesses the device at this address too, with different tables, for the game textures, should it just act like a mirror, or a secondary device? */
290   cpu->space(AS_PROGRAM).install_readwrite_handler(0x27FFFF0, 0x27FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_w), this));
291}
292
293
294READ32_MEMBER(sega_315_5838_comp_device::doa_prot_r)
295{
296   UINT32 retval = 0;
297
298   if (offset == 0x7ff8/4)
299   {
300      retval = m_protram[m_protstate+1] | m_protram[m_protstate]<<8;
301      m_protstate+=2;
302      printf("doa_prot_read %08x %08x %08x\n", offset*4, retval, mem_mask);
303   }
304   else if (offset == 0x400c/4) // todo, is this actually part of the protection? it's in the address range, but decathlete doesn't have it afaik.
305   {
306      m_prot_a = !m_prot_a;
307      if (m_prot_a)
308         retval = 0xffff;
309      else
310         retval = 0xfff0;
311   }
312   else
313   {
314      printf("doa_prot_read %08x %08x %08x\n", offset*4, retval, mem_mask);
315      logerror("Unhandled Protection READ @ %x mask %x (PC=%x)\n", offset, mem_mask, space.device().safe_pc());
316   }
317
318   return retval;
319}
320
321
322WRITE32_MEMBER(sega_315_5838_comp_device::doa_prot_w)
323{
324   printf("doa_prot_w %08x %08x %08x\n", offset*4, data, mem_mask);
325
326   if (offset == 0x7ff2 / 4)
327   {
328      if (data == 0)
329      {
330         m_protstate = 0;
331         strcpy((char *)m_protram, "  TECMO LTD.  DEAD OR ALIVE  1996.10.22  VER. 1.00"); // this is the single decompressed string DOA needs
332      }
333   }
334   else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc());
335}
336
337
338void sega_315_5838_comp_device::install_doa_protection()
339{
340   //todo, install these in the driver, they differ between games
341   cpu_device* cpu = (cpu_device*)machine().device(":maincpu");
342   cpu->space(AS_PROGRAM).install_readwrite_handler(0x01d80000, 0x01dfffff, read32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_w), this));
343}
No newline at end of file
trunk/src/mame/machine/315-5838_317-0229_comp.h
r0r243131
1
2#pragma once
3
4#ifndef __SEGA315_5838_COMP__
5#define __SEGA315_5838_COMP__
6
7typedef device_delegate<UINT16 (UINT32)> sega_m2_read_delegate;
8
9extern const device_type SEGA315_5838_COMP;
10
11#define MCFG_SET_5838_READ_CALLBACK( _class, _method) \
12   sega_315_5838_comp_device::set_read_cb(*device, sega_m2_read_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0));
13
14
15class sega_315_5838_comp_device :  public device_t
16{
17public:
18   // construction/destruction
19   sega_315_5838_comp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
20
21   sega_m2_read_delegate m_read;
22
23   static void set_read_cb(device_t &device,sega_m2_read_delegate readcb)
24   {
25      sega_315_5838_comp_device &dev = downcast<sega_315_5838_comp_device &>(device);
26      dev.m_read = readcb;
27   }
28
29   DECLARE_READ32_MEMBER(decathlt_prot_r);
30   void write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which);
31   DECLARE_WRITE32_MEMBER(decathlt_prot1_w);
32   DECLARE_WRITE32_MEMBER(decathlt_prot2_w);
33   void install_decathlt_protection();
34   void install_doa_protection();
35
36   DECLARE_READ32_MEMBER(doa_prot_r);
37   DECLARE_WRITE32_MEMBER(doa_prot_w);
38
39protected:
40   virtual void device_start();
41   virtual void device_reset();
42
43private:
44
45   // Decathlete specific variables and functions (see machine/decathlt.c)
46   UINT32 m_decathlt_protregs[4];
47   UINT32 m_decathlt_lastcount;
48   UINT32 m_decathlt_part;
49   UINT32 m_decathlt_prot_uploadmode;
50   UINT32 m_decathlt_prot_uploadoffset;
51   UINT16 m_decathlt_prottable1[24];
52   UINT16 m_decathlt_prottable2[128];
53
54   // Doa
55   int m_protstate;
56   int m_protpos;
57   int m_prot_a;
58   UINT8 m_protram[256];
59};
60
61#endif
trunk/src/mame/mame.mak
r243130r243131
17471747   $(DRIVERS)/segaybd.o $(VIDEO)/segaybd.o \
17481748   $(DRIVERS)/sg1000a.o \
17491749   $(DRIVERS)/stactics.o $(VIDEO)/stactics.o \
1750   $(DRIVERS)/stv.o $(MACHINE)/stvprot.o $(MACHINE)/decathlt.o \
1750   $(DRIVERS)/stv.o $(MACHINE)/stvprot.o $(MACHINE)/315-5838_317-0229_comp.o \
17511751   $(DRIVERS)/suprloco.o $(VIDEO)/suprloco.o \
17521752   $(DRIVERS)/system1.o $(VIDEO)/system1.o \
17531753   $(DRIVERS)/system16.o $(VIDEO)/system16.o \


Previous 199869 Revisions Next


© 1997-2024 The MAME Team