Previous 199869 Revisions Next

r34507 Tuesday 20th January, 2015 at 13:21:05 UTC by David Haywood
using actual Sega 315_5881 decryption for 'astrass' set (not yet working for twcup98)
[src/mame/drivers]stv.c
[src/mame/includes]stv.h
[src/mame/machine]stvprot.c

trunk/src/mame/drivers/stv.c
r243018r243019
18241824   ROM_LOAD16_WORD_SWAP( "mpr20826.1",     0x1800000, 0x0400000, CRC(bdc4b941) SHA1(c5e8b1b186324c2ccab617915f7bdbfe6897ca9f) ) // good (was .17)
18251825   ROM_LOAD16_WORD_SWAP( "mpr20832.8",     0x1c00000, 0x0400000, CRC(af1b0985) SHA1(d7a0e4e0a8b0556915f924bdde8c3d14e5b3423e) ) // good (was .18s)
18261826   ROM_LOAD16_WORD_SWAP( "mpr20833.9",     0x2000000, 0x0400000, CRC(cb6af231) SHA1(4a2e5d7c2fd6179c19cdefa84a03f9a34fbb9e70) ) // good (was .19s)
1827
1828   ROM_REGION32_BE( 0x11ea0, "user2", 0 )
1829   // protection data (text layer tiles) extracted from Saturn version
1830   // stat_t.bin is name of the file from Saturn version CD
1831   ROM_LOAD( "stat_t.bin", 0x0000000, 0x11ea0,  BAD_DUMP CRC(52a0b542) SHA1(2b352dee919d7e7a5d338ece1691577d0b288eca) )
18321827ROM_END
18331828
18341829ROM_START( bakubaku )
trunk/src/mame/includes/stv.h
r243018r243019
701701      : saturn_state(mconfig, type, tag),
702702      m_adsp(*this, "adsp"),
703703      m_adsp_pram(*this, "adsp_pram"),
704      m_cryptdevice(*this, "315_5881")
704      m_cryptdevice(*this, "315_5881"),
705      m_using_crypt_device(0)
705706   {
706707   }
707708
r243018r243019
839840
840841   optional_device<sega_315_5881_crypt_device> m_cryptdevice;
841842   UINT16 crypt_read_callback(UINT32 addr);
843   int m_using_crypt_device;
842844};
843845
844846
trunk/src/mame/machine/stvprot.c
r243018r243019
9292#include "emu.h"
9393#include "includes/stv.h"
9494
95//FILE *fp;
96//FILE *fp2;
9597
9698
9799/************************
r243018r243019
494496   }
495497}
496498
497UINT32 astrass_prot_read_callback( address_space &space, int protaddr, UINT32 key )
498{
499   /* we're reading from a custom region where we've loaded the data from the Saturn version
500      NOT the rom address, so we're based at 0.  The real data likely exists at the given
501      address in encrypted form */
502   int read_offset_hack = 0x4ec260;
503   int useoffset = (protaddr-read_offset_hack);
504   UINT32 data = 0;
505   UINT32 *prot_data = (UINT32 *)space.machine().root_device().memregion("user2")->base();
506   int prot_size = space.machine().root_device().memregion("user2")->bytes();
507499
508   if (useoffset<prot_size)
509   {
510      data = prot_data[useoffset/4];
511      return data;
512   }
513   return 0x00;
514}
515500
516
517501UINT32 elandore_prot_read_callback( address_space &space, int protaddr, UINT32 key )
518502{
519503   UINT32 *ROM = (UINT32 *)space.machine().root_device().memregion("abus")->base();
r243018r243019
585569         #ifdef MAME_DEBUG
586570         popmessage("Prot read at %06x with data = %08x",space.device().safe_pc(),m_abus_protkey);
587571         #endif
588         UINT32 realret = space.read_dword(0x2000000+m_ctrl_index);
589         UINT32 retdata = m_prot_readback(space, m_ctrl_index, m_abus_protkey);
572         if (!m_using_crypt_device) // decrypt using hacks
573         {
574            UINT32 realret = space.read_dword(0x2000000 + m_ctrl_index);
575            UINT32 retdata = m_prot_readback(space, m_ctrl_index, m_abus_protkey);
576            //fwrite(&realret, 1, 4, fp);
577            //fwrite(&retdata, 1, 4, fp2);
590578
591         logerror("A-Bus control protection read at %06x with data = %08x Returning = %08x Would otherwise return = %08x\n",space.device().safe_pc(),m_abus_protkey, retdata, realret);
592
593         //UINT16 res = m_cryptdevice->do_decrypt(base);
594
595         m_ctrl_index += 4;
596         return retdata;
597
579            logerror("A-Bus control protection read at %06x with data = %08x Returning = %08x Would otherwise return = %08x\n", space.device().safe_pc(), m_abus_protkey, retdata, realret);
580            m_ctrl_index += 4;
581            return retdata;
582         }
583         else // decrypt using real decryption device
584         {
585            UINT8* base;
586            UINT16 res = m_cryptdevice->do_decrypt(base);
587            UINT16 res2 = m_cryptdevice->do_decrypt(base);
588            res = ((res & 0xff00) >> 8) | ((res & 0x00ff) << 8);
589            res2 = ((res2 & 0xff00) >> 8) | ((res2 & 0x00ff) << 8);
590           
591            return res2 | (res << 16);
592         }
593         
598594      }
599595      return m_a_bus[offset];
600596   }
r243018r243019
608604
609605UINT16 stv_state::crypt_read_callback(UINT32 addr)
610606{
611   const UINT8 *base = m_cart_reg[0]->base() + 2*addr;
612   return base[1] | (base[0] << 8);
607   UINT16 dat= m_maincpu->space().read_word((0x02000000+2*addr));
608   return ((dat&0xff00)>>8)|((dat&0x00ff)<<8);
613609}
614610
615611WRITE32_MEMBER ( stv_state::common_prot_w )
r243018r243019
640636      a_bus_vector = m_abus_prot_addr >> 16;
641637      a_bus_vector|= (m_abus_prot_addr & 0xffff) << 16;
642638      a_bus_vector<<= 1;
639      /*
640      if (fp)
641      {
642         fclose(fp);
643         fp = 0;
644      }
645      if (fp2)
646      {
647         fclose(fp2);
648         fp2 = 0;
649      }
650      char filename[256];
651      sprintf(filename,"encrypted_%s_key_%04x_address_%08x", machine().system().name, m_abus_protkey>>16, a_bus_vector);
652      fp=fopen(filename, "w+b");
653      sprintf(filename,"not-encrypted_%s_key_%04x_address_%08x", machine().system().name, m_abus_protkey>>16, a_bus_vector);
654      fp2=fopen(filename, "w+b");
655      */
656
643657      //printf("MAIN : %08x  DATA : %08x %08x\n",m_abus_protkey,m_abus_prot_addr,a_bus_vector);
644658
645659      // if you look at the first transfer in ffreveng this is clearly a ROM address from a table |  MAIN : 10d70000  DATA : 0b780013 002616f0
r243018r243019
659673void stv_state::install_common_protection()
660674{
661675   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x4fffff0, 0x4ffffff, read32_delegate(FUNC(stv_state::common_prot_r), this), write32_delegate(FUNC(stv_state::common_prot_w), this));
676
677
662678}
663679
664680void stv_state::install_sss_protection()
r243018r243019
670686void stv_state::install_astrass_protection()
671687{
672688   install_common_protection();
673   m_prot_readback = astrass_prot_read_callback;
674//  m_cryptdevice->set_key(0x00000000);
689//   m_prot_readback = astrass_prot_read_callback;
690   m_cryptdevice->set_key(0x052e2901); // same key as wldkicks / toukon4
691   m_using_crypt_device = 1;
675692}
676693
677694void stv_state::install_ffreveng_protection()
r243018r243019
696713{
697714   install_common_protection();
698715   m_prot_readback = twcup98_prot_read_callback;
699
716   m_cryptdevice->set_key(0x05200913 );
717   m_using_crypt_device = 0; // doesn't currently work
700718}
701719
702720
703721
704722void stv_state::stv_register_protection_savestates()
705723{
724
725
706726   save_item(NAME(m_a_bus));
707727   save_item(NAME(m_ctrl_index));
708728   save_item(NAME(m_internal_counter));


Previous 199869 Revisions Next


© 1997-2024 The MAME Team