Previous 199869 Revisions Next

r26342 Thursday 21st November, 2013 at 20:19:35 UTC by Osso
Moved stv protection related functions into the driver class. (nw)
[src/mame/drivers]stv.c
[src/mame/includes]stv.h
[src/mame/machine]stvprot.c stvprot.h

trunk/src/mame/machine/stvprot.c
r26341r26342
9090****************************************************************************************/
9191
9292#include "emu.h"
93#include "stvprot.h"
9493#include "includes/stv.h"
9594
96// these should become member variables!
97UINT32 m_abus_protenable;
98UINT32 m_abus_prot_addr;
99UINT32 m_abus_protkey;
10095
101static UINT32 a_bus[4];
102static UINT32 ctrl_index;
103static UINT32 internal_counter;
104static UINT8 char_offset; //helper to jump the decoding of the NULL chars.
10596
106static UINT32 (*prot_readback)(address_space&,int,UINT32);
107
10897/************************
10998*
11099* Tecmo World Cup '98
r26341r26342
584573*
585574*************************************/
586575
587static READ32_HANDLER( common_prot_r )
576READ32_MEMBER( stv_state::common_prot_r )
588577{
589578   UINT32 *ROM = (UINT32 *)space.machine().root_device().memregion("abus")->base();
590579
r26341r26342
595584         #ifdef MAME_DEBUG
596585         popmessage("Prot read at %06x with data = %08x",space.device().safe_pc(),m_abus_protkey);
597586         #endif
598         UINT32 realret = space.read_dword(0x2000000+ctrl_index);
599         UINT32 retdata = prot_readback(space, ctrl_index, m_abus_protkey);
587         UINT32 realret = space.read_dword(0x2000000+m_ctrl_index);
588         UINT32 retdata = m_prot_readback(space, m_ctrl_index, m_abus_protkey);
600589
601590         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);
602591
603         ctrl_index += 4;
592         m_ctrl_index += 4;
604593         return retdata;
605594
606595      }
607      return a_bus[offset];
596      return m_a_bus[offset];
608597   }
609598   else
610599   {
611      if(a_bus[offset] != 0) return a_bus[offset];
600      if(m_a_bus[offset] != 0) return m_a_bus[offset];
612601      else return ROM[(0x02fffff0/4)+offset];
613602   }
614603}
r26341r26342
616605
617606
618607
619static WRITE32_HANDLER ( common_prot_w )
608WRITE32_MEMBER ( stv_state::common_prot_w )
620609{
621   COMBINE_DATA(&a_bus[offset]);
610   COMBINE_DATA(&m_a_bus[offset]);
622611   //printf("A-Bus control protection write at %06x: [%02x] <- %08x\n",space.device().safe_pc(),offset,data);
623612
624613   if (offset == 0)
r26341r26342
648637      // the game reads the number of bytes specified in the length via the protection device, writing them to RAM.  This suggests there
649638      // is no compression going on, only some form of encryption.
650639
651      ctrl_index = a_bus_vector;
640      m_ctrl_index = a_bus_vector;
652641   }
653642}
654643
655void install_common_protection(running_machine &machine)
644void stv_state::install_common_protection()
656645{
657   machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x4fffff0, 0x4ffffff, FUNC(common_prot_r), FUNC(common_prot_w));
646   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));
658647}
659648
660void install_sss_protection(running_machine &machine)
649void stv_state::install_sss_protection()
661650{
662   install_common_protection(machine);
663   prot_readback = sss_prot_read_callback;
651   install_common_protection();
652   m_prot_readback = sss_prot_read_callback;
664653}
665654
666void install_astrass_protection(running_machine &machine)
655void stv_state::install_astrass_protection()
667656{
668   install_common_protection(machine);
669   prot_readback = astrass_prot_read_callback;
657   install_common_protection();
658   m_prot_readback = astrass_prot_read_callback;
670659}
671660
672void install_ffreveng_protection(running_machine &machine)
661void stv_state::install_ffreveng_protection()
673662{
674   install_common_protection(machine);
675   prot_readback = ffreveng_prot_read_callback;
663   install_common_protection();
664   m_prot_readback = ffreveng_prot_read_callback;
676665}
677666
678void install_elandore_protection(running_machine &machine)
667void stv_state::install_elandore_protection()
679668{
680   install_common_protection(machine);
681   prot_readback = elandore_prot_read_callback;
669   install_common_protection();
670   m_prot_readback = elandore_prot_read_callback;
682671}
683672
684void install_rsgun_protection(running_machine &machine)
673void stv_state::install_rsgun_protection()
685674{
686   install_common_protection(machine);
687   prot_readback = rsgun_prot_read_callback;
675   install_common_protection();
676   m_prot_readback = rsgun_prot_read_callback;
688677}
689678
690void install_twcup98_protection(running_machine &machine)
679void stv_state::install_twcup98_protection()
691680{
692   install_common_protection(machine);
693   prot_readback = twcup98_prot_read_callback;
681   install_common_protection();
682   m_prot_readback = twcup98_prot_read_callback;
694683
695684}
696685
697686
698687
699void stv_register_protection_savestates(running_machine &machine)
688void stv_state::stv_register_protection_savestates()
700689{
701   machine.save().save_item(NAME(a_bus));
702   machine.save().save_item(NAME(ctrl_index));
703   machine.save().save_item(NAME(internal_counter));
704   machine.save().save_item(NAME(char_offset));
690   save_item(NAME(m_a_bus));
691   save_item(NAME(m_ctrl_index));
692   save_item(NAME(m_internal_counter));
693   save_item(NAME(m_char_offset));
705694}
trunk/src/mame/machine/stvprot.h
r26341r26342
11/* stvprot.h */
22
3void install_twcup98_protection(running_machine &machine);
4void install_sss_protection(running_machine &machine);
53void install_decathlt_protection(running_machine &machine);
6void install_astrass_protection(running_machine &machine);
7void install_rsgun_protection(running_machine &machine);
8void install_elandore_protection(running_machine &machine);
9void install_ffreveng_protection(running_machine &machine);
10
11void stv_register_protection_savestates(running_machine &machine);
trunk/src/mame/includes/stv.h
r26341r26342
739739   DECLARE_READ16_MEMBER( adsp_control_r );
740740   DECLARE_WRITE16_MEMBER( adsp_control_w );
741741   DECLARE_WRITE32_MEMBER(batmanfr_sound_comms_w);
742   
743   // protection specific variables and functions (see machine/stvprot.c)
744   UINT32 m_abus_protenable;
745   UINT32 m_abus_prot_addr;
746   UINT32 m_abus_protkey;
747
748   UINT32 m_a_bus[4];
749   UINT32 m_ctrl_index;
750   UINT32 m_internal_counter;
751   UINT8 m_char_offset; //helper to jump the decoding of the NULL chars.
752
753   UINT32 (*m_prot_readback)(address_space&,int,UINT32);
754   
755   DECLARE_READ32_MEMBER( common_prot_r );
756   DECLARE_WRITE32_MEMBER( common_prot_w );
757     
758   void install_common_protection();
759   
760   void install_twcup98_protection();
761   void install_sss_protection();
762   void install_astrass_protection();
763   void install_rsgun_protection();
764   void install_elandore_protection();
765   void install_ffreveng_protection();
766
767   void stv_register_protection_savestates();   
742768};
743769
744770
trunk/src/mame/drivers/stv.c
r26341r26342
667667   sh2drc_add_pcflush(m_maincpu, 0x60011ba);
668668   sh2drc_add_pcflush(m_maincpu, 0x605b9da);
669669
670   install_astrass_protection(machine());
670   install_astrass_protection();
671671
672672   DRIVER_INIT_CALL(stv);
673673}
r26341r26342
761761   sh2drc_add_pcflush(m_maincpu, 0x6026398);
762762   sh2drc_add_pcflush(m_slave, 0x6028cd6);
763763
764   install_sss_protection(machine());
764   install_sss_protection();
765765
766766   DRIVER_INIT_CALL(stv);
767767
r26341r26342
824824   sh2drc_add_pcflush(m_slave, 0x6062bca);
825825
826826   DRIVER_INIT_CALL(stv);
827   install_twcup98_protection(machine());
827   install_twcup98_protection();
828828
829829   m_minit_boost_timeslice = m_sinit_boost_timeslice = attotime::from_usec(5);
830830}
r26341r26342
881881   sh2drc_add_pcflush(m_maincpu, 0x604eac0);
882882   sh2drc_add_pcflush(m_slave, 0x605340a);
883883
884   install_elandore_protection(machine());
884   install_elandore_protection();
885885
886886   DRIVER_INIT_CALL(stv);
887887   m_minit_boost_timeslice = m_sinit_boost_timeslice = attotime::from_usec(0);
r26341r26342
892892   sh2drc_add_pcflush(m_maincpu, 0x6034d04);
893893   sh2drc_add_pcflush(m_slave, 0x6036152);
894894
895   install_rsgun_protection(machine());
895   install_rsgun_protection();
896896
897897   DRIVER_INIT_CALL(stv);
898898
r26341r26342
901901
902902DRIVER_INIT_MEMBER(stv_state,ffreveng)
903903{
904   install_ffreveng_protection(machine());
904   install_ffreveng_protection();
905905   DRIVER_INIT_CALL(stv);
906906}
907907
r26341r26342
13321332   save_item(NAME(m_mux_data));
13331333   save_item(NAME(m_scsp_last_line));
13341334
1335   stv_register_protection_savestates(machine()); // machine/stvprot.c
1335   stv_register_protection_savestates(); // machine/stvprot.c
13361336
13371337   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stv_state::stvcd_exit), this));
13381338

Previous 199869 Revisions Next


© 1997-2024 The MAME Team