summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author mamehaze <mamehaze@users.noreply.github.com>2015-01-26 15:47:06 +0000
committer mamehaze <mamehaze@users.noreply.github.com>2015-01-26 15:47:06 +0000
commitb6078e07afb66b4e4ae55b5447c9f1014d8b9c2b (patch)
tree8b00b17196a2ac03591d94b707d733f1347169a0
parentc0c1fe2f74c29e19c293621123415452dd2c01ee (diff)
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)
-rw-r--r--src/mame/drivers/model2.c141
-rw-r--r--src/mame/drivers/stv.c30
-rw-r--r--src/mame/includes/model2.h15
-rw-r--r--src/mame/includes/stv.h20
-rw-r--r--src/mame/machine/315-5838_317-0229_comp.c343
-rw-r--r--src/mame/machine/315-5838_317-0229_comp.h61
-rw-r--r--src/mame/mame.mak2
7 files changed, 451 insertions, 161 deletions
diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c
index 10eff60e155..a4df80b88b6 100644
--- a/src/mame/drivers/model2.c
+++ b/src/mame/drivers/model2.c
@@ -1235,80 +1235,6 @@ static const UINT8 ZGUNProt[] =
};
-READ32_MEMBER(model2_state::model2_prot_r)
-{
- UINT32 retval = 0;
-
- if (offset == 0x10000/4)
- {
- // status: bit 0 = 1 for busy, 0 for ready
- retval = 0; // we're always ready
- }
- else if (offset == 0x1000e/4)
- {
- retval = m_protram[m_protstate+1] | m_protram[m_protstate+0]<<8;
- retval <<= 16;
- m_protstate+=2;
- }
- else logerror("Unhandled Protection READ @ %x mask %x (PC=%x)\n", offset, mem_mask, space.device().safe_pc());
-
- printf("model2_prot_r %08x: %08x (%08x)\n", offset*4, retval, mem_mask);
-
- return retval;
-}
-
-WRITE32_MEMBER(model2_state::model2_prot_w)
-{
- printf("model2_prot_w %08x: %08x (%08x)\n", offset*4, data, mem_mask);
-
- if (mem_mask == 0xffff0000)
- {
- data >>= 16;
- }
-
- if (offset == 0x10008/4)
- {
- m_protpos = data;
- }
- else if (offset == 0x1000c/4)
- {
- switch (data)
- {
- // zerogun
- case 0xA1BC:
- case 0xAD23:
- case 0x13CD:
- case 0x4D53:
- case 0x234D:
- case 0x113D:
- case 0x1049:
- case 0x993D:
- case 0x983C:
- case 0x935:
- case 0x9845:
- case 0x556D:
- case 0x98CC:
- case 0x3422:
- case 0x10:
- m_protstate = 0;
- memcpy(m_protram+2, ZGUNProt+((2*m_protpos)/12)*8, sizeof(ZGUNProt));
- break;
-
- // pltkids
- case 0x7140:
- m_protstate = 0;
- strcpy((char *)m_protram+2, "98-PILOT ");
- break;
-
- default:
- m_protstate = 0;
- break;
- }
- }
- else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc());
-
-}
-
READ32_MEMBER(model2_state::model2_5881prot_r)
{
@@ -1372,41 +1298,6 @@ WRITE32_MEMBER(model2_state::model2_5881prot_w)
}
-READ32_MEMBER(model2_state::doa_prot_r)
-{
- UINT32 retval = 0;
-
- if (offset == 0x7ff8/4)
- {
- retval = m_protram[m_protstate+1] | m_protram[m_protstate]<<8;
- m_protstate+=2;
- }
- else if (offset == 0x400c/4)
- {
- m_prot_a = !m_prot_a;
- if (m_prot_a)
- retval = 0xffff;
- else
- retval = 0xfff0;
- }
- else logerror("Unhandled Protection READ @ %x mask %x (PC=%x)\n", offset, mem_mask, space.device().safe_pc());
-
- return retval;
-}
-
-
-WRITE32_MEMBER(model2_state::doa_prot_w)
-{
- if (offset == 0x7ff2 / 4)
- {
- if (data == 0)
- {
- m_protstate = 0;
- strcpy((char *)m_protram, " TECMO LTD. DEAD OR ALIVE 1996.10.22 VER. 1.00");
- }
- }
- else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc());
-}
/* Daytona "To The MAXX" PIC protection simulation */
@@ -2611,6 +2502,11 @@ static MACHINE_CONFIG_DERIVED( model2a_5881, model2a )
MCFG_SET_READ_CALLBACK(model2_state, crypt_read_callback)
MACHINE_CONFIG_END
+static MACHINE_CONFIG_DERIVED( model2a_0229, model2a )
+ MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0)
+// MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
+MACHINE_CONFIG_END
+
READ8_MEMBER(model2_state::driveio_port_r)
{
return m_driveio_comm_data;
@@ -2714,6 +2610,12 @@ static MACHINE_CONFIG_DERIVED( model2b_5881, model2b )
MCFG_SET_READ_CALLBACK(model2_state, crypt_read_callback)
MACHINE_CONFIG_END
+static MACHINE_CONFIG_DERIVED( model2b_0229, model2b )
+ MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0)
+// MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback)
+MACHINE_CONFIG_END
+
+
static ADDRESS_MAP_START( copro_tgpx4_map, AS_PROGRAM, 32, model2_state )
AM_RANGE(0x00000000, 0x00007fff) AM_RAM AM_SHARE("tgpx4_program")
ADDRESS_MAP_END
@@ -6004,16 +5906,9 @@ DRIVER_INIT_MEMBER(model2_state,genprot)
{
astring key = parameter(":315_5881:key");
- if (key)
- {
- m_maincpu->space(AS_PROGRAM).install_ram(0x01d80000, 0x01d8ffff);
- 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));
- }
- else
- {
- 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));
- m_protstate = m_protpos = 0;
- }
+ m_maincpu->space(AS_PROGRAM).install_ram(0x01d80000, 0x01d8ffff);
+ 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));
+
}
DRIVER_INIT_MEMBER(model2_state,pltkids)
@@ -6084,9 +5979,7 @@ DRIVER_INIT_MEMBER(model2_state,overrev)
DRIVER_INIT_MEMBER(model2_state,doa)
{
- 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));
- m_protstate = m_protpos = 0;
-
+ m_0229crypt->install_doa_protection();
UINT32 *ROM = (UINT32 *)memregion("maincpu")->base();
ROM[0x630/4] = 0x08000004;
@@ -6128,7 +6021,7 @@ GAME( 1995, vf2a, vf2, model2a, model2, driver_device, 0, R
GAME( 1995, vf2o, vf2, model2a, model2, driver_device, 0, ROT0, "Sega", "Virtua Fighter 2", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1995, vcop2, 0, model2a, vcop2, driver_device, 0, ROT0, "Sega", "Virtua Cop 2", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1995, skytargt, 0, model2a, skytargt,driver_device, 0, ROT0, "Sega", "Sky Target", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
-GAME( 1996, doaa, doa, model2a, model2, model2_state, doa, ROT0, "Sega", "Dead or Alive (Model 2A, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
+GAME( 1996, doaa, doa, model2a_0229, model2, model2_state, doa, ROT0, "Sega", "Dead or Alive (Model 2A, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1997, zeroguna, zerogun, model2a_5881, model2, model2_state, zerogun, ROT0, "Psikyo", "Zero Gunner (Export, Model 2A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1997, zerogunaj, zerogun, model2a_5881, model2, model2_state, zerogun, ROT0, "Psikyo", "Zero Gunner (Japan, Model 2A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1997, motoraid, 0, model2a, manxtt, driver_device, 0, ROT0, "Sega", "Motor Raid - Twin", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
@@ -6149,7 +6042,7 @@ GAME( 1996, sfight, schamp, model2b, model2, driver_device, 0, R
GAME( 1996, lastbrnx, 0, model2b, model2, driver_device, 0, ROT0, "Sega", "Last Bronx (Export, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1996, lastbrnxu,lastbrnx, model2b, model2, driver_device, 0, ROT0, "Sega", "Last Bronx (USA, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1996, lastbrnxj,lastbrnx, model2b, model2, driver_device, 0, ROT0, "Sega", "Last Bronx (Japan, Revision A)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
-GAME( 1996, doa, 0, model2b, model2, model2_state, doa, ROT0, "Sega", "Dead or Alive (Model 2B, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
+GAME( 1996, doa, 0, model2b_0229, model2, model2_state, doa, ROT0, "Sega", "Dead or Alive (Model 2B, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1996, sgt24h, 0, model2b, srallyc, model2_state, sgt24h, ROT0, "Jaleco", "Super GT 24h", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1996, von, 0, model2b, model2, driver_device, 0, ROT0, "Sega", "Cyber Troopers Virtual-On (USA, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
GAME( 1996, vonj, von, model2b, model2, driver_device, 0, ROT0, "Sega", "Cyber Troopers Virtual-On (Japan, Revision B)", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS )
diff --git a/src/mame/drivers/stv.c b/src/mame/drivers/stv.c
index 0cb390080a5..1577eceebcc 100644
--- a/src/mame/drivers/stv.c
+++ b/src/mame/drivers/stv.c
@@ -912,10 +912,7 @@ DRIVER_INIT_MEMBER(stv_state,ffreveng)
DRIVER_INIT_MEMBER(stv_state,decathlt)
{
- m_decathlt_lastcount = 0;
- m_decathlt_prot_uploadmode = 0;
- m_decathlt_prot_uploadoffset = 0;
- install_decathlt_protection();
+ m_5838crypt->install_decathlt_protection();
DRIVER_INIT_CALL(stv);
}
@@ -1022,10 +1019,19 @@ static MACHINE_CONFIG_START( stv, stv_state )
MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
+MACHINE_CONFIG_END
+
+static MACHINE_CONFIG_DERIVED( stv_5881, stv )
MCFG_DEVICE_ADD("315_5881", SEGA315_5881_CRYPT, 0)
MCFG_SET_READ_CALLBACK(stv_state, crypt_read_callback)
MACHINE_CONFIG_END
+static MACHINE_CONFIG_DERIVED( stv_5838, stv )
+ MCFG_DEVICE_ADD("315_5838", SEGA315_5838_COMP, 0)
+// MCFG_SET_5838_READ_CALLBACK(stv_state, crypt_read_callback)
+MACHINE_CONFIG_END
+
+
/*
Batman Forever has an extra ADSP, used for sound.
Similar if not the same as Magic the Gathering, probably needs merging.
@@ -3025,7 +3031,7 @@ GAME( 1996, stvbios, 0, stv_slot, stv, stv_state, stv, ROT0
//GAME YEAR, NAME, PARENT, MACH, INP, INIT, MONITOR
/* Playable */
-GAME( 1998, astrass, stvbios, stv, stv6b, stv_state, astrass, ROT0, "Sunsoft", "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
+GAME( 1998, astrass, stvbios, stv_5881, stv6b, stv_state, astrass, ROT0, "Sunsoft", "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
GAME( 1995, bakubaku, stvbios, stv, stv, stv_state, stv, ROT0, "Sega", "Baku Baku Animal (J 950407 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 1996, batmanfr, stvbios, batmanfr, stv, stv_state, batmanfr, ROT0, "Acclaim", "Batman Forever (JUE 960507 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 1996, colmns97, stvbios, stv, stv, stv_state, colmns97, ROT0, "Sega", "Columns '97 (JET 961209 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
@@ -3037,8 +3043,8 @@ GAME( 2000, danchiq, stvbios, stv, stv, stv_state, danchiq, ROT
GAME( 1996, diehard, stvbios, stv, stv, stv_state, diehard, ROT0, "Sega", "Die Hard Arcade (UET 960515 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
GAME( 1996, dnmtdeka, diehard, stv, stv, stv_state, dnmtdeka, ROT0, "Sega", "Dynamite Deka (J 960515 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
GAME( 1995, ejihon, stvbios, stv, stv, stv_state, stv, ROT0, "Sega", "Ejihon Tantei Jimusyo (J 950613 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
-GAME( 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 )
-GAME( 1999, ffreveng, stvbios, stv, stv, stv_state, ffreveng, ROT0, "Capcom", "Final Fight Revenge (JUET 990714 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
+GAME( 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 )
+GAME( 1999, ffreveng, stvbios, stv_5881, stv, stv_state, ffreveng, ROT0, "Capcom", "Final Fight Revenge (JUET 990714 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 1995, fhboxers, stvbios, stv, stv, stv_state, fhboxers, ROT0, "Sega", "Funky Head Boxers (JUETBKAL 951218 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 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 )
GAME( 1994, gaxeduel, stvbios, stv, stv6b, stv_state, gaxeduel, ROT0, "Sega", "Golden Axe - The Duel (JUETL 950117 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS)
@@ -3054,17 +3060,17 @@ GAME( 1998, othellos, stvbios, stv, stv, stv_state, othellos, ROT
GAME( 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 )
GAME( 1996, prikura, stvbios, stv, stv, stv_state, prikura, ROT0, "Atlus", "Princess Clara Daisakusen (J 960910 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 1996, puyosun, stvbios, stv, stv, stv_state, puyosun, ROT0, "Compile", "Puyo Puyo Sun (J 961115 V0.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
-GAME( 1998, rsgun, stvbios, stv, stv, stv_state, rsgun, ROT0, "Treasure", "Radiant Silvergun (JUET 980523 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
+GAME( 1998, rsgun, stvbios, stv_5881, stv, stv_state, rsgun, ROT0, "Treasure", "Radiant Silvergun (JUET 980523 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
GAME( 1998, sasissu, stvbios, stv, stv, stv_state, sasissu, ROT0, "Sega", "Taisen Tanto-R Sashissu!! (J 980216 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 1999, sanjeon, sasissu, stv, stv, stv_state, sanjeon, ROT0, "Sega / Deniam", "DaeJeon! SanJeon SuJeon (AJTUE 990412 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 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 )
GAME( 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 )
GAME( 1997, shienryu, stvbios, stv, stv, stv_state, shienryu, ROT270, "Warashi", "Shienryu (JUET 961226 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
-GAME( 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 )
+GAME( 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 )
GAME( 1995, sandor, stvbios, stv, stv, stv_state, sandor, ROT0, "Sega", "Puzzle & Action: Sando-R (J 951114 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 1997, thunt, sandor, stv, stv, stv_state, thunt, ROT0, "Sega", "Puzzle & Action: Treasure Hunt (JUET 970901 V2.00E)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
GAME( 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 )
-GAME( 1998, twcup98, stvbios, stv, stv, stv_state, twcup98, ROT0, "Tecmo", "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
+GAME( 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 )
GAME( 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 )
GAME( 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 )
GAME( 1996, sokyugrt, stvbios, stv, stv, stv_state, sokyugrt, ROT0, "Raizing / Eighting", "Soukyugurentai / Terra Diver (JUET 960821 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
@@ -3092,8 +3098,8 @@ GAME( 1997, pclb2elk, stvbios, stv, stv, stv_state, stv, ROT0
/* Doing something.. but not enough yet */
GAME( 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 )
-GAME( 1996, decathlt, stvbios, stv, stv, stv_state, decathlt, ROT0, "Sega", "Decathlete (JUET 960709 V1.001)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
-GAME( 1996, decathlto, decathlt,stv, stv, stv_state, decathlt, ROT0, "Sega", "Decathlete (JUET 960424 V1.000)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
+GAME( 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 )
+GAME( 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 )
/* Gives I/O errors */
GAME( 1996, magzun, stvbios, stv, stv, stv_state, magzun, ROT0, "Sega", "Magical Zunou Power (J 961031 V1.000)", GAME_NOT_WORKING )
diff --git a/src/mame/includes/model2.h b/src/mame/includes/model2.h
index b5efe3a8007..9a52ddb22a6 100644
--- a/src/mame/includes/model2.h
+++ b/src/mame/includes/model2.h
@@ -5,6 +5,7 @@
#include "cpu/i960/i960.h"
#include "sound/scsp.h"
#include "machine/315-5881_crypt.h"
+#include "machine/315-5838_317-0229_comp.h"
struct raster_state;
struct geo_state;
@@ -36,7 +37,9 @@ public:
m_screen(*this, "screen"),
m_palette(*this, "palette"),
m_scsp(*this, "scsp"),
- m_cryptdevice(*this, "315_5881")
+ m_cryptdevice(*this, "315_5881"),
+ m_0229crypt(*this, "317_0229")
+
{ }
required_shared_ptr<UINT32> m_workram;
@@ -63,6 +66,7 @@ public:
required_device<palette_device> m_palette;
optional_device<scsp_device> m_scsp;
optional_device<sega_315_5881_crypt_device> m_cryptdevice;
+ optional_device<sega_315_5838_comp_device> m_0229crypt;
UINT32 m_intreq;
UINT32 m_intena;
@@ -92,10 +96,7 @@ public:
int m_geo_iop_write_num;
UINT32 m_geo_iop_data;
int m_to_68k;
- int m_protstate;
- int m_protpos;
- UINT8 m_protram[256];
- int m_prot_a;
+
int m_maxxstate;
UINT32 m_netram[0x8000/4];
int m_zflagi;
@@ -158,10 +159,6 @@ public:
DECLARE_READ32_MEMBER(model2_serial_r);
DECLARE_WRITE32_MEMBER(model2o_serial_w);
DECLARE_WRITE32_MEMBER(model2_serial_w);
- DECLARE_READ32_MEMBER(model2_prot_r);
- DECLARE_WRITE32_MEMBER(model2_prot_w);
- DECLARE_READ32_MEMBER(doa_prot_r);
- DECLARE_WRITE32_MEMBER(doa_prot_w);
DECLARE_READ32_MEMBER(model2_5881prot_r);
DECLARE_WRITE32_MEMBER(model2_5881prot_w);
int first_read;
diff --git a/src/mame/includes/stv.h b/src/mame/includes/stv.h
index b53f082c349..81cddb85137 100644
--- a/src/mame/includes/stv.h
+++ b/src/mame/includes/stv.h
@@ -10,6 +10,7 @@
#include "bus/generic/carts.h"
#include "machine/315-5881_crypt.h"
+#include "machine/315-5838_317-0229_comp.h"
#define MAX_FILTERS (24)
#define MAX_BLOCKS (200)
@@ -701,7 +702,8 @@ public:
: saturn_state(mconfig, type, tag),
m_adsp(*this, "adsp"),
m_adsp_pram(*this, "adsp_pram"),
- m_cryptdevice(*this, "315_5881")
+ m_cryptdevice(*this, "315_5881"),
+ m_5838crypt(*this, "315_5838")
{
}
@@ -808,22 +810,10 @@ public:
void install_common_protection();
void stv_register_protection_savestates();
- // Decathlete specific variables and functions (see machine/decathlt.c)
- UINT32 m_decathlt_protregs[4];
- UINT32 m_decathlt_lastcount;
- UINT32 m_decathlt_part;
- UINT32 m_decathlt_prot_uploadmode;
- UINT32 m_decathlt_prot_uploadoffset;
- UINT16 m_decathlt_prottable1[24];
- UINT16 m_decathlt_prottable2[128];
-
- DECLARE_READ32_MEMBER( decathlt_prot_r );
- DECLARE_WRITE32_MEMBER( decathlt_prot1_w );
- DECLARE_WRITE32_MEMBER( decathlt_prot2_w );
- void write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which);
- void install_decathlt_protection();
+
optional_device<sega_315_5881_crypt_device> m_cryptdevice;
+ optional_device<sega_315_5838_comp_device> m_5838crypt;
UINT16 crypt_read_callback(UINT32 addr);
};
diff --git a/src/mame/machine/315-5838_317-0229_comp.c b/src/mame/machine/315-5838_317-0229_comp.c
new file mode 100644
index 00000000000..22cac97cb79
--- /dev/null
+++ b/src/mame/machine/315-5838_317-0229_comp.c
@@ -0,0 +1,343 @@
+/* Sega Compression (and possibly encryption) device
+
+ 315-5838 - Decathlete (ST-V)
+ 317-0229 - Dead or Alive (Model 2A)
+
+ Package Type: TQFP100
+
+ This appears to be a dual channel compression chip, used in 1996, predating the 5881.
+ Decathlete uses it to compress ALL the game graphics, Dead or Alive uses it for a
+ dumb security check, decompressing a single string.
+
+ Dead of Alive only uses a single channel, and has the source data in RAM, not ROM.
+ This is similar to how some 5881 games were set up, with the ST-V versions decrypting
+ data directly from ROM and the Model 2 ones using a RAM source buffer.
+
+*/
+
+#include "emu.h"
+#include "machine/315-5838_317-0229_comp.h"
+
+extern const device_type SEGA315_5838_COMP = &device_creator<sega_315_5838_comp_device>;
+
+
+sega_315_5838_comp_device::sega_315_5838_comp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, SEGA315_5838_COMP, "Sega 315-5838 / 317-0029 Compression (Encryption?)", tag, owner, clock, "SEGA315_5838", __FILE__)
+{
+}
+
+
+
+void sega_315_5838_comp_device::device_start()
+{
+ m_decathlt_lastcount = 0;
+ m_decathlt_prot_uploadmode = 0;
+ m_decathlt_prot_uploadoffset = 0;
+}
+
+void sega_315_5838_comp_device::device_reset()
+{
+ memset(m_decathlt_protregs, 0, sizeof(m_decathlt_protregs));
+ m_decathlt_lastcount = 0;
+ m_decathlt_prot_uploadmode = 0;
+ m_decathlt_prot_uploadoffset = 0;
+ m_decathlt_part = 1;
+
+ m_protstate = 0;
+}
+
+
+/**************************
+*
+* Decathlete
+*
+**************************/
+
+READ32_MEMBER( sega_315_5838_comp_device::decathlt_prot_r )
+{
+ // the offsets written to the protection device definitely only refer to 2 of the roms
+ // it's a fair assumption to say that only those 2 are connected to the protection device
+ UINT8 *ROM = (UINT8 *)memregion(":abus")->base()+0x1000000;
+ UINT32 *fake0 = (UINT32*)memregion( ":fake0" )->base();
+
+ if (offset==2)
+ {
+ UINT32 retvalue = 0xffff;
+
+ switch (m_decathlt_protregs[0])
+ {
+ default:
+ retvalue = ROM[(m_decathlt_protregs[0]*2)-2];
+ retvalue <<= 8;
+ retvalue |= ROM[((m_decathlt_protregs[0]+1)*2)+1-2];
+ retvalue <<= 8;
+ retvalue |= ROM[((m_decathlt_protregs[0]+1)*2)-2];
+ retvalue <<= 8;
+ retvalue |= ROM[((m_decathlt_protregs[0]+2)*2)+1-2];
+ m_decathlt_lastcount++;
+ logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0], retvalue, m_decathlt_lastcount*4);
+ m_decathlt_protregs[0]+=2;
+ return retvalue;
+
+ case 0x03228e4:
+ if (fake0) retvalue = fake0[(((0x20080/4)+m_decathlt_lastcount))];
+ m_decathlt_lastcount++;
+ return retvalue;
+
+ case 0x00a9f3a:
+ if (fake0) retvalue = fake0[(((0x00000/4)+m_decathlt_lastcount))];
+ m_decathlt_lastcount++;
+ return retvalue;
+
+ case 0x0213ab4:
+ if (fake0) retvalue = fake0[(((0x40000/4)+m_decathlt_lastcount))];
+ m_decathlt_lastcount++;
+ return retvalue;
+
+ case 0x01efaf0:
+ if (fake0) retvalue = fake0[(((0x60000/4)+m_decathlt_lastcount))];
+ m_decathlt_lastcount++;
+ return retvalue;
+
+ case 0x033f16c:
+ case 0x038929c:
+
+
+
+ case 0x00de05a:
+ case 0x0334258:
+ case 0x019fb82:
+ case 0x033dbf6:
+ case 0x0011ac6:
+ case 0x00060dc:
+ case 0x0000002:
+ case 0x0008c90:
+ case 0x035cdc8:
+ case 0x0327960:
+ case 0x0329b8c:
+ case 0x00d6e92:
+ case 0x000081e:
+ case 0x00035d6:
+ case 0x00089a6:
+ case 0x03315f4:
+ case 0x0023fe0:
+ case 0x001e290:
+ case 0x0026e86:
+ case 0x0012494:
+ case 0x001b35a:
+ case 0x0018424:
+
+ return retvalue;
+ }
+
+
+ }
+ else
+ {
+ 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]);
+ }
+
+ return m_decathlt_protregs[offset];
+}
+
+
+void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which)
+{
+
+ printf("write_prot_data %08x %08x %08x\n", offset, data, mem_mask);
+
+ m_decathlt_protregs[offset] = (data&mem_mask)|(m_decathlt_protregs[offset]&~mem_mask);
+// m_decathlt_protregs[0] = 0x0c00000/4;
+
+ if (offset==0) // seems to set a source address
+ {
+ m_decathlt_part ^=1;
+
+ //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",which, m_decathlt_lastcount*4);
+ m_decathlt_lastcount = 0;
+ 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]);
+ }
+
+ if (offset==1) // uploads 2 tables...
+ {
+ if (mem_mask==0xffff0000)
+ {
+ if (data == 0x80000000)
+ {
+ // logerror("changed to upload mode 1\n");
+ m_decathlt_prot_uploadmode = 1;
+ m_decathlt_prot_uploadoffset = 0;
+ }
+ else if (data == 0x80800000)
+ {
+ // logerror("changed to upload mode 2\n");
+ m_decathlt_prot_uploadmode = 2;
+ m_decathlt_prot_uploadoffset = 0;
+ }
+ else
+ {
+ // logerror("unknown upload mode\n");
+ m_decathlt_prot_uploadmode = 2;
+ m_decathlt_prot_uploadoffset = 0;
+ }
+
+// logerror("ARGH! %08x %08x\n",mem_mask,data);
+ }
+ else if (mem_mask==0x0000ffff)
+ {
+ if (m_decathlt_prot_uploadmode==1)
+ {
+ if (m_decathlt_prot_uploadoffset>=24)
+ {
+ // logerror("upload mode 1 error, too big\n");
+ return;
+ }
+
+ //logerror("uploading table 1 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff);
+ m_decathlt_prottable1[m_decathlt_prot_uploadoffset]=data&0xffff;
+ m_decathlt_prot_uploadoffset++;
+
+ printf("table 1 %04x\n", data & 0xffff);
+
+ {
+ /* 0x18 (24) values in this table, rom data is 0x1800000 long, maybe it has
+ something to do with that? or 24-address b its?
+
+ uploaded values appear to be 12-bit, some are repeated
+ */
+
+ {
+ FILE* fp;
+ if (which==1) fp = fopen("table1x","wb");
+ else fp = fopen("table1","wb");
+
+ {
+ fwrite(&m_decathlt_prottable1,24,2,fp);
+ }
+ fclose(fp);
+ }
+ }
+
+ }
+ else if (m_decathlt_prot_uploadmode==2)
+ {
+ if (m_decathlt_prot_uploadoffset>=128)
+ {
+ //logerror("upload mode 2 error, too big\n");
+ return;
+ }
+
+ //logerror("uploading table 2 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff);
+ m_decathlt_prottable2[m_decathlt_prot_uploadoffset]=data&0xffff;
+ m_decathlt_prot_uploadoffset++;
+
+ printf("dictionary %04x\n", data & 0xffff);
+
+
+ {
+ /* the table uploaded here is a 256 byte table with 256 unique values, remaps something? */
+
+ {
+ FILE* fp;
+ if (which==1) fp = fopen("table2x","wb");
+ else fp = fopen("table2","wb");
+
+ {
+ fwrite(&m_decathlt_prottable2,128,2,fp);
+ }
+ fclose(fp);
+ }
+ }
+ }
+ else
+ {
+ // logerror("unknown upload mode!\n");
+ }
+ }
+ }
+
+ if (offset>1)
+ {
+ // logerror("higher offset write\n");
+ }
+
+}
+
+WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w )
+{
+ write_prot_data(data,mem_mask, offset, 0);
+
+}
+
+WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w )
+{
+ write_prot_data(data,mem_mask, offset, 1);
+
+
+}
+
+void sega_315_5838_comp_device::install_decathlt_protection()
+{
+ /* It uploads 2 tables here, then performs what looks like a number of transfers, setting
+ a source address of some kind (scrambled?) and then making many reads from a single address */
+
+ //todo, install these in the driver, they differ between games
+ cpu_device* cpu = (cpu_device*)machine().device(":maincpu");
+
+
+ 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));
+ /* 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? */
+ 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));
+}
+
+
+READ32_MEMBER(sega_315_5838_comp_device::doa_prot_r)
+{
+ UINT32 retval = 0;
+
+ if (offset == 0x7ff8/4)
+ {
+ retval = m_protram[m_protstate+1] | m_protram[m_protstate]<<8;
+ m_protstate+=2;
+ printf("doa_prot_read %08x %08x %08x\n", offset*4, retval, mem_mask);
+ }
+ 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.
+ {
+ m_prot_a = !m_prot_a;
+ if (m_prot_a)
+ retval = 0xffff;
+ else
+ retval = 0xfff0;
+ }
+ else
+ {
+ printf("doa_prot_read %08x %08x %08x\n", offset*4, retval, mem_mask);
+ logerror("Unhandled Protection READ @ %x mask %x (PC=%x)\n", offset, mem_mask, space.device().safe_pc());
+ }
+
+ return retval;
+}
+
+
+WRITE32_MEMBER(sega_315_5838_comp_device::doa_prot_w)
+{
+ printf("doa_prot_w %08x %08x %08x\n", offset*4, data, mem_mask);
+
+ if (offset == 0x7ff2 / 4)
+ {
+ if (data == 0)
+ {
+ m_protstate = 0;
+ strcpy((char *)m_protram, " TECMO LTD. DEAD OR ALIVE 1996.10.22 VER. 1.00"); // this is the single decompressed string DOA needs
+ }
+ }
+ else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc());
+}
+
+
+void sega_315_5838_comp_device::install_doa_protection()
+{
+ //todo, install these in the driver, they differ between games
+ cpu_device* cpu = (cpu_device*)machine().device(":maincpu");
+ 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));
+} \ No newline at end of file
diff --git a/src/mame/machine/315-5838_317-0229_comp.h b/src/mame/machine/315-5838_317-0229_comp.h
new file mode 100644
index 00000000000..7f1677bc581
--- /dev/null
+++ b/src/mame/machine/315-5838_317-0229_comp.h
@@ -0,0 +1,61 @@
+
+#pragma once
+
+#ifndef __SEGA315_5838_COMP__
+#define __SEGA315_5838_COMP__
+
+typedef device_delegate<UINT16 (UINT32)> sega_m2_read_delegate;
+
+extern const device_type SEGA315_5838_COMP;
+
+#define MCFG_SET_5838_READ_CALLBACK( _class, _method) \
+ sega_315_5838_comp_device::set_read_cb(*device, sega_m2_read_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0));
+
+
+class sega_315_5838_comp_device : public device_t
+{
+public:
+ // construction/destruction
+ sega_315_5838_comp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ sega_m2_read_delegate m_read;
+
+ static void set_read_cb(device_t &device,sega_m2_read_delegate readcb)
+ {
+ sega_315_5838_comp_device &dev = downcast<sega_315_5838_comp_device &>(device);
+ dev.m_read = readcb;
+ }
+
+ DECLARE_READ32_MEMBER(decathlt_prot_r);
+ void write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which);
+ DECLARE_WRITE32_MEMBER(decathlt_prot1_w);
+ DECLARE_WRITE32_MEMBER(decathlt_prot2_w);
+ void install_decathlt_protection();
+ void install_doa_protection();
+
+ DECLARE_READ32_MEMBER(doa_prot_r);
+ DECLARE_WRITE32_MEMBER(doa_prot_w);
+
+protected:
+ virtual void device_start();
+ virtual void device_reset();
+
+private:
+
+ // Decathlete specific variables and functions (see machine/decathlt.c)
+ UINT32 m_decathlt_protregs[4];
+ UINT32 m_decathlt_lastcount;
+ UINT32 m_decathlt_part;
+ UINT32 m_decathlt_prot_uploadmode;
+ UINT32 m_decathlt_prot_uploadoffset;
+ UINT16 m_decathlt_prottable1[24];
+ UINT16 m_decathlt_prottable2[128];
+
+ // Doa
+ int m_protstate;
+ int m_protpos;
+ int m_prot_a;
+ UINT8 m_protram[256];
+};
+
+#endif
diff --git a/src/mame/mame.mak b/src/mame/mame.mak
index 7bf393a5727..6193ab61f7e 100644
--- a/src/mame/mame.mak
+++ b/src/mame/mame.mak
@@ -1747,7 +1747,7 @@ $(MAMEOBJ)/sega.a: \
$(DRIVERS)/segaybd.o $(VIDEO)/segaybd.o \
$(DRIVERS)/sg1000a.o \
$(DRIVERS)/stactics.o $(VIDEO)/stactics.o \
- $(DRIVERS)/stv.o $(MACHINE)/stvprot.o $(MACHINE)/decathlt.o \
+ $(DRIVERS)/stv.o $(MACHINE)/stvprot.o $(MACHINE)/315-5838_317-0229_comp.o \
$(DRIVERS)/suprloco.o $(VIDEO)/suprloco.o \
$(DRIVERS)/system1.o $(VIDEO)/system1.o \
$(DRIVERS)/system16.o $(VIDEO)/system16.o \