Previous 199869 Revisions Next

r34542 Thursday 22nd January, 2015 at 18:57:54 UTC by David Haywood
hooked swtrilgy (model 3) to the 5881 decryption function (stream returned matches simulation)

(currently unhooks the other games from the sims etc. I'll address this shortly)
[src/mame/drivers]model2.c model3.c
[src/mame/includes]model3.h
[src/mame/machine]315-5881_helper.c

trunk/src/mame/drivers/model2.c
r243053r243054
13231323   {
13241324      if (first_read == 1)
13251325      {
1326         // is there a CPU core bug or similar?
1327         // the only way to return the same stream as the previous simulation (for dynamite cop) is to return a
1328         // 0x0000 as the first return value before returning the actual sequence.
1329         // note that even with our simulation code pilot kids crashes in the way it would if the protection failed, so something seems wrong.
1326         // the RAM based schemes expect a dummy value before the start of the stream
1327         // to match the previous simulation (dynamite cop) I use 0x0000 here
13301328         first_read = 0;
13311329         retval = 0;
13321330      }
trunk/src/mame/drivers/model3.c
r243053r243054
17561756
17571757READ64_MEMBER(model3_state::model3_security_r)
17581758{
1759   UINT64 retvalue = U64(0xffffffffffffffff);
1760
17591761   switch(offset)
17601762   {
1761      case 0x00/8:    return 0;       /* status */
1763      case 0x00 / 8:    retvalue = 0; break;       /* status */
17621764      case 0x1c/8:                    /* security board data read */
17631765      {
17641766         if (core_stricmp(machine().system().name, "vs299") == 0 ||
17651767            core_stricmp(machine().system().name, "vs2v991") == 0)
17661768         {
1767            return (UINT64)vs299_prot_data[m_prot_data_ptr++] << 48;
1769            retvalue = (UINT64)vs299_prot_data[m_prot_data_ptr++] << 48;
17681770         }
17691771         else if (core_stricmp(machine().system().name, "swtrilgy") == 0 ||
17701772                  core_stricmp(machine().system().name, "swtrilgya") == 0)
r243053r243054
17741776            {
17751777               m_prot_data_ptr = 0;
17761778            }
1777            return data;
1779            retvalue = data;
17781780         }
17791781         else if (core_stricmp(machine().system().name, "fvipers2") == 0)
17801782         {
r243053r243054
17831785            {
17841786               m_prot_data_ptr = 0;
17851787            }
1786            return data;
1788            retvalue = data;
17871789         }
17881790         else if (core_stricmp(machine().system().name, "spikeout") == 0 ||
17891791                  core_stricmp(machine().system().name, "spikeofe") == 0)
r243053r243054
17931795            {
17941796               m_prot_data_ptr = 0;
17951797            }
1796            return data;
1798            retvalue = data;
17971799         }
17981800         else if (core_stricmp(machine().system().name, "eca") == 0 ||
17991801                  core_stricmp(machine().system().name, "ecax") == 0)
r243053r243054
18031805            {
18041806               m_prot_data_ptr = 0;
18051807            }
1806            return data;
1808            retvalue = data;
18071809         }
18081810         else if (core_stricmp(machine().system().name, "oceanhun") == 0)
18091811         {
r243053r243054
18121814            {
18131815               m_prot_data_ptr = 0;
18141816            }
1815            return data;
1817            retvalue = data;
18161818         }
18171819         else
18181820         {
1819            return 0;
1821            retvalue = 0;
18201822         }
1823         break;
18211824      }
18221825   }
1823   return U64(0xffffffffffffffff);
1826   printf("model3_security_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1827
1828   return retvalue;
18241829}
18251830
1831READ64_MEMBER(model3_state::model3_5881prot_r)
1832{
1833   UINT64 retvalue = U64(0xffffffffffffffff);
1834
1835   if (offset == 0x00 / 8)
1836   {
1837      retvalue = 0;
1838   }
1839   else if (offset == 0x18 / 8)
1840   {
1841      if (first_read == 1)
1842      {
1843         // the RAM based schemes expect a dummy value before the start of the stream
1844         // to match the previous simulation I use 0xffff here
1845         first_read = 0;
1846         retvalue = 0xffff << 16;
1847      }
1848      else
1849      {
1850         UINT8* base;
1851         retvalue = m_cryptdevice->do_decrypt(base);
1852         //   retvalue = ((retvalue & 0xff00) >> 8) | ((retvalue & 0x00ff) << 8); // don't endian swap the return value on this hardware
1853         retvalue <<= 16;
1854      }
1855
1856   //   printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1857   }
1858   else
1859   {
1860      printf("model3_5881prot_r offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(retvalue >> 32), (UINT32)(retvalue & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1861   }
1862
1863   return retvalue;
1864
1865
1866}
1867
1868WRITE64_MEMBER(model3_state::model3_5881prot_w)
1869{
1870   if (offset == 0x10 / 8)
1871   {
1872      // code is copied to RAM first, so base address is always 0
1873      m_cryptdevice->set_addr_low(0);
1874      m_cryptdevice->set_addr_high(0);
1875
1876      if (data != 0)
1877         printf("model3_5881prot_w address isn't 0?\n");
1878
1879      first_read = 1;
1880   }
1881   else if (offset == 0x18 / 8)
1882   {
1883      UINT16 subkey = data >> (32 + 16);
1884      subkey = ((subkey & 0xff00) >> 8) | ((subkey & 0x00ff) << 8); // endian swap the sub-key for this hardware
1885      printf("model3_5881prot_w setting subkey %04x\n", subkey);
1886      m_cryptdevice->set_subkey(subkey);
1887   }
1888   else
1889   {
1890      printf("model3_5881prot_w offset %08x : %08x%08x (%08x%08x)\n", offset * 8, (UINT32)(data >> 32), (UINT32)(data & 0xffffffff), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask & 0xffffffff));
1891   }
1892
1893
1894
1895}
1896
18261897WRITE64_MEMBER(model3_state::daytona2_rombank_w)
18271898{
18281899   if (ACCESSING_BITS_56_63)
r243053r243054
18471918   AM_RANGE(0xf00c0000, 0xf00dffff) AM_MIRROR(0x0e000000) AM_RAM AM_SHARE("backup")    /* backup SRAM */
18481919   AM_RANGE(0xf0100000, 0xf010003f) AM_MIRROR(0x0e000000) AM_READWRITE(model3_sys_r, model3_sys_w )
18491920   AM_RANGE(0xf0140000, 0xf014003f) AM_MIRROR(0x0e000000) AM_READWRITE(model3_rtc_r, model3_rtc_w )
1850   AM_RANGE(0xf0180000, 0xf019ffff) AM_MIRROR(0x0e000000) AM_RAM                           /* Security Board RAM */
1851   AM_RANGE(0xf01a0000, 0xf01a003f) AM_MIRROR(0x0e000000) AM_READ(model3_security_r )  /* Security board */
18521921
18531922   AM_RANGE(0xf1000000, 0xf10f7fff) AM_READWRITE(model3_char_r, model3_char_w )    /* character RAM */
18541923   AM_RANGE(0xf10f8000, 0xf10fffff) AM_READWRITE(model3_tile_r, model3_tile_w )    /* tilemaps */
r243053r243054
55915660   MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
55925661MACHINE_CONFIG_END
55935662
5663UINT16 model3_state::crypt_read_callback(UINT32 addr)
5664{
5665   UINT16 dat = 0;
5666   if (addr < 0x8000)
5667   {
5668      dat = m_maincpu->space().read_word((0xf0180000 + 4 * addr)); // every other word is unused in this RAM, probably 32-bit ram on 64-bit bus?
5669   }
5670
5671//   dat = ((dat & 0xff00) >> 8) | ((dat & 0x00ff) << 8);
5672//   printf("reading %04x\n", dat);
5673   return dat;
5674}
5675
5676static MACHINE_CONFIG_DERIVED( model3_21_5881, model3_21 )
5677   MCFG_DEVICE_ADD("315_5881", SEGA315_5881_CRYPT, 0)
5678   MCFG_SET_READ_CALLBACK(model3_state, crypt_read_callback)
5679MACHINE_CONFIG_END
5680
5681
55945682static void interleave_vroms(running_machine &machine)
55955683{
55965684   model3_state *state = machine.driver_data<model3_state>();
r243053r243054
56225710   }
56235711}
56245712
5713DRIVER_INIT_MEMBER(model3_state, genprot)
5714{
5715   INT64 key = get_315_5881_key(machine());
5716
5717   m_maincpu->space(AS_PROGRAM).install_ram(0xf0180000, 0xf019ffff, 0, 0x0e000000);
5718
5719   if (key != -1)
5720   {
5721//      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this));
5722      m_cryptdevice->set_key(key);
5723      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_5881prot_r), this), write64_delegate(FUNC(model3_state::model3_5881prot_w), this) );                   
5724   }
5725   else
5726   {
5727      m_maincpu->space(AS_PROGRAM).install_read_handler(0xf01a0000, 0xf01a003f, 0, 0x0e000000, read64_delegate(FUNC(model3_state::model3_security_r), this) );                   
5728   }
5729}
5730
56255731DRIVER_INIT_MEMBER(model3_state,model3_10)
56265732{
56275733   interleave_vroms(machine());
r243053r243054
58425948
58435949DRIVER_INIT_MEMBER(model3_state,swtrilgy)
58445950{
5951
58455952   UINT32 *rom = (UINT32*)memregion("user1")->base();
58465953   DRIVER_INIT_CALL(model3_20);
58475954
r243053r243054
58525959
58535960   rom[(0x043dc^4)/4] = 0x48000090;        // skip force feedback setup
58545961   rom[(0xf6e44^4)/4] = 0x60000000;
5962
5963
5964   DRIVER_INIT_CALL(genprot);
5965
58555966}
58565967
58575968DRIVER_INIT_MEMBER(model3_state,swtrilga)
r243053r243054
60036114GAME( 1999, vs299,    vs2v991, model3_20, model3, model3_state,      vs299, ROT0, "Sega", "Virtua Striker 2 '99", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
60046115
60056116/* Model 3 Step 2.1 */
6006GAME( 1998, daytona2,         0, model3_21, daytona2, model3_state, daytona2, ROT0, "Sega", "Daytona USA 2 (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6007GAME( 1998, dayto2pe,         0, model3_21, daytona2, model3_state, dayto2pe, ROT0, "Sega", "Daytona USA 2 Power Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6008GAME( 1998, dirtdvls,         0, model3_21, scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 1) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6009GAME( 1998, dirtdvlsa, dirtdvls, model3_21, scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 2) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6010GAME( 1998, swtrilgy,         0, model3_21, swtrilgy, model3_state, swtrilgy, ROT0, "Sega / LucasArts", "Star Wars Trilogy (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6011GAME( 1998, swtrilgya, swtrilgy, model3_21, swtrilgy, model3_state, swtrilga, ROT0, "Sega / LucasArts", "Star Wars Trilogy", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6012GAME( 1998, spikeout,         0, model3_21, model3, model3_state,   spikeout, ROT0, "Sega", "Spikeout (Revision C)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6013GAME( 1998, spikeofe,         0, model3_21, model3, model3_state,   spikeofe, ROT0, "Sega", "Spikeout Final Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6014GAME( 1998, magtruck,         0, model3_21, eca, model3_state,      magtruck, ROT0, "Sega", "Magical Truck Adventure", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6015GAME( 1999, eca,              0, model3_21, eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6016GAME( 1999, ecax,           eca, model3_21, eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (Export)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6017GAME( 1999, ecap,           eca, model3_21, eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (US location test?)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6117GAME( 1998, daytona2,         0, model3_21,      daytona2, model3_state, daytona2, ROT0, "Sega", "Daytona USA 2 (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6118GAME( 1998, dayto2pe,         0, model3_21,      daytona2, model3_state, dayto2pe, ROT0, "Sega", "Daytona USA 2 Power Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6119GAME( 1998, dirtdvls,         0, model3_21,      scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 1) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6120GAME( 1998, dirtdvlsa, dirtdvls, model3_21,      scud, model3_state,     dirtdvls, ROT0, "Sega", "Dirt Devils (set 2) (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6121GAME( 1998, swtrilgy,         0, model3_21_5881, swtrilgy, model3_state, swtrilgy, ROT0, "Sega / LucasArts", "Star Wars Trilogy (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6122GAME( 1998, swtrilgya, swtrilgy, model3_21_5881, swtrilgy, model3_state, swtrilga, ROT0, "Sega / LucasArts", "Star Wars Trilogy", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6123GAME( 1998, spikeout,         0, model3_21,      model3, model3_state,   spikeout, ROT0, "Sega", "Spikeout (Revision C)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6124GAME( 1998, spikeofe,         0, model3_21,      model3, model3_state,   spikeofe, ROT0, "Sega", "Spikeout Final Edition", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6125GAME( 1998, magtruck,         0, model3_21,      eca, model3_state,      magtruck, ROT0, "Sega", "Magical Truck Adventure", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6126GAME( 1999, eca,              0, model3_21,      eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6127GAME( 1999, ecax,           eca, model3_21,      eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (Export)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
6128GAME( 1999, ecap,           eca, model3_21,      eca, model3_state,           eca, ROT0, "Sega", "Emergency Call Ambulance (US location test?)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
trunk/src/mame/includes/model3.h
r243053r243054
44#include "audio/dsbz80.h"
55#include "machine/eepromser.h"
66#include "sound/scsp.h"
7#include "machine/315-5881_crypt.h"
78
89typedef float MATRIX[4][4];
910typedef float VECTOR[4];
r243053r243054
7778      m_dsbz80(*this, DSBZ80_TAG),
7879      m_soundram(*this, "soundram"),
7980      m_gfxdecode(*this, "gfxdecode"),
80      m_palette(*this, "palette")
81      m_palette(*this, "palette"),
82      m_cryptdevice(*this, "315_5881")
8183   {
8284      m_step15_with_mpc106 = false;
8385      m_step20_with_old_real3d = false;
r243053r243054
9799
98100   required_device<gfxdecode_device> m_gfxdecode;
99101   required_device<palette_device> m_palette;
102   optional_device<sega_315_5881_crypt_device> m_cryptdevice;
100103
101104   tilemap_t *m_layer4[4];
102105   tilemap_t *m_layer8[4];
r243053r243054
232235   DECLARE_WRITE16_MEMBER(model3snd_ctrl);
233236   UINT32 pci_device_get_reg();
234237   void pci_device_set_reg(UINT32 value);
238   DECLARE_DRIVER_INIT(genprot);
235239   DECLARE_DRIVER_INIT(lemans24);
236240   DECLARE_DRIVER_INIT(vs298);
237241   DECLARE_DRIVER_INIT(vs299);
r243053r243054
333337   void tap_write(int tck, int tms, int tdi, int trst);
334338   void tap_reset();
335339   void tap_set_asic_ids();
340
341   DECLARE_READ64_MEMBER(model3_5881prot_r);
342   DECLARE_WRITE64_MEMBER(model3_5881prot_w);
343   int first_read;
344   UINT16 crypt_read_callback(UINT32 addr);
345
336346};
trunk/src/mame/machine/315-5881_helper.c
r243053r243054
137137
138138
139139   { "vs298",           0x09234e96 }, //             ????     317-0237-COM   Model 3
140   { "swt",             0x11272a01 }, //             ????     317-0241-COM   Model 3
140   { "swtrilgy",        0x11272a01 }, //             ????     317-0241-COM   Model 3
141   { "swtrilgya",       0x11272a01 }, //             ????     317-0241-COM   Model 3
141142   { "vs299",           0x09222ac8 }, //             ????     317-0245-COM   Model 3
142143
144
143145   { NULL, 0 }    // end of table
144146};
145147


Previous 199869 Revisions Next


© 1997-2024 The MAME Team