trunk/src/mame/machine/stvprot.c
r26341 | r26342 | |
90 | 90 | ****************************************************************************************/ |
91 | 91 | |
92 | 92 | #include "emu.h" |
93 | | #include "stvprot.h" |
94 | 93 | #include "includes/stv.h" |
95 | 94 | |
96 | | // these should become member variables! |
97 | | UINT32 m_abus_protenable; |
98 | | UINT32 m_abus_prot_addr; |
99 | | UINT32 m_abus_protkey; |
100 | 95 | |
101 | | static UINT32 a_bus[4]; |
102 | | static UINT32 ctrl_index; |
103 | | static UINT32 internal_counter; |
104 | | static UINT8 char_offset; //helper to jump the decoding of the NULL chars. |
105 | 96 | |
106 | | static UINT32 (*prot_readback)(address_space&,int,UINT32); |
107 | | |
108 | 97 | /************************ |
109 | 98 | * |
110 | 99 | * Tecmo World Cup '98 |
r26341 | r26342 | |
584 | 573 | * |
585 | 574 | *************************************/ |
586 | 575 | |
587 | | static READ32_HANDLER( common_prot_r ) |
| 576 | READ32_MEMBER( stv_state::common_prot_r ) |
588 | 577 | { |
589 | 578 | UINT32 *ROM = (UINT32 *)space.machine().root_device().memregion("abus")->base(); |
590 | 579 | |
r26341 | r26342 | |
595 | 584 | #ifdef MAME_DEBUG |
596 | 585 | popmessage("Prot read at %06x with data = %08x",space.device().safe_pc(),m_abus_protkey); |
597 | 586 | #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); |
600 | 589 | |
601 | 590 | 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); |
602 | 591 | |
603 | | ctrl_index += 4; |
| 592 | m_ctrl_index += 4; |
604 | 593 | return retdata; |
605 | 594 | |
606 | 595 | } |
607 | | return a_bus[offset]; |
| 596 | return m_a_bus[offset]; |
608 | 597 | } |
609 | 598 | else |
610 | 599 | { |
611 | | if(a_bus[offset] != 0) return a_bus[offset]; |
| 600 | if(m_a_bus[offset] != 0) return m_a_bus[offset]; |
612 | 601 | else return ROM[(0x02fffff0/4)+offset]; |
613 | 602 | } |
614 | 603 | } |
r26341 | r26342 | |
616 | 605 | |
617 | 606 | |
618 | 607 | |
619 | | static WRITE32_HANDLER ( common_prot_w ) |
| 608 | WRITE32_MEMBER ( stv_state::common_prot_w ) |
620 | 609 | { |
621 | | COMBINE_DATA(&a_bus[offset]); |
| 610 | COMBINE_DATA(&m_a_bus[offset]); |
622 | 611 | //printf("A-Bus control protection write at %06x: [%02x] <- %08x\n",space.device().safe_pc(),offset,data); |
623 | 612 | |
624 | 613 | if (offset == 0) |
r26341 | r26342 | |
648 | 637 | // the game reads the number of bytes specified in the length via the protection device, writing them to RAM. This suggests there |
649 | 638 | // is no compression going on, only some form of encryption. |
650 | 639 | |
651 | | ctrl_index = a_bus_vector; |
| 640 | m_ctrl_index = a_bus_vector; |
652 | 641 | } |
653 | 642 | } |
654 | 643 | |
655 | | void install_common_protection(running_machine &machine) |
| 644 | void stv_state::install_common_protection() |
656 | 645 | { |
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)); |
658 | 647 | } |
659 | 648 | |
660 | | void install_sss_protection(running_machine &machine) |
| 649 | void stv_state::install_sss_protection() |
661 | 650 | { |
662 | | install_common_protection(machine); |
663 | | prot_readback = sss_prot_read_callback; |
| 651 | install_common_protection(); |
| 652 | m_prot_readback = sss_prot_read_callback; |
664 | 653 | } |
665 | 654 | |
666 | | void install_astrass_protection(running_machine &machine) |
| 655 | void stv_state::install_astrass_protection() |
667 | 656 | { |
668 | | install_common_protection(machine); |
669 | | prot_readback = astrass_prot_read_callback; |
| 657 | install_common_protection(); |
| 658 | m_prot_readback = astrass_prot_read_callback; |
670 | 659 | } |
671 | 660 | |
672 | | void install_ffreveng_protection(running_machine &machine) |
| 661 | void stv_state::install_ffreveng_protection() |
673 | 662 | { |
674 | | install_common_protection(machine); |
675 | | prot_readback = ffreveng_prot_read_callback; |
| 663 | install_common_protection(); |
| 664 | m_prot_readback = ffreveng_prot_read_callback; |
676 | 665 | } |
677 | 666 | |
678 | | void install_elandore_protection(running_machine &machine) |
| 667 | void stv_state::install_elandore_protection() |
679 | 668 | { |
680 | | install_common_protection(machine); |
681 | | prot_readback = elandore_prot_read_callback; |
| 669 | install_common_protection(); |
| 670 | m_prot_readback = elandore_prot_read_callback; |
682 | 671 | } |
683 | 672 | |
684 | | void install_rsgun_protection(running_machine &machine) |
| 673 | void stv_state::install_rsgun_protection() |
685 | 674 | { |
686 | | install_common_protection(machine); |
687 | | prot_readback = rsgun_prot_read_callback; |
| 675 | install_common_protection(); |
| 676 | m_prot_readback = rsgun_prot_read_callback; |
688 | 677 | } |
689 | 678 | |
690 | | void install_twcup98_protection(running_machine &machine) |
| 679 | void stv_state::install_twcup98_protection() |
691 | 680 | { |
692 | | install_common_protection(machine); |
693 | | prot_readback = twcup98_prot_read_callback; |
| 681 | install_common_protection(); |
| 682 | m_prot_readback = twcup98_prot_read_callback; |
694 | 683 | |
695 | 684 | } |
696 | 685 | |
697 | 686 | |
698 | 687 | |
699 | | void stv_register_protection_savestates(running_machine &machine) |
| 688 | void stv_state::stv_register_protection_savestates() |
700 | 689 | { |
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)); |
705 | 694 | } |
trunk/src/mame/drivers/stv.c
r26341 | r26342 | |
667 | 667 | sh2drc_add_pcflush(m_maincpu, 0x60011ba); |
668 | 668 | sh2drc_add_pcflush(m_maincpu, 0x605b9da); |
669 | 669 | |
670 | | install_astrass_protection(machine()); |
| 670 | install_astrass_protection(); |
671 | 671 | |
672 | 672 | DRIVER_INIT_CALL(stv); |
673 | 673 | } |
r26341 | r26342 | |
761 | 761 | sh2drc_add_pcflush(m_maincpu, 0x6026398); |
762 | 762 | sh2drc_add_pcflush(m_slave, 0x6028cd6); |
763 | 763 | |
764 | | install_sss_protection(machine()); |
| 764 | install_sss_protection(); |
765 | 765 | |
766 | 766 | DRIVER_INIT_CALL(stv); |
767 | 767 | |
r26341 | r26342 | |
824 | 824 | sh2drc_add_pcflush(m_slave, 0x6062bca); |
825 | 825 | |
826 | 826 | DRIVER_INIT_CALL(stv); |
827 | | install_twcup98_protection(machine()); |
| 827 | install_twcup98_protection(); |
828 | 828 | |
829 | 829 | m_minit_boost_timeslice = m_sinit_boost_timeslice = attotime::from_usec(5); |
830 | 830 | } |
r26341 | r26342 | |
881 | 881 | sh2drc_add_pcflush(m_maincpu, 0x604eac0); |
882 | 882 | sh2drc_add_pcflush(m_slave, 0x605340a); |
883 | 883 | |
884 | | install_elandore_protection(machine()); |
| 884 | install_elandore_protection(); |
885 | 885 | |
886 | 886 | DRIVER_INIT_CALL(stv); |
887 | 887 | m_minit_boost_timeslice = m_sinit_boost_timeslice = attotime::from_usec(0); |
r26341 | r26342 | |
892 | 892 | sh2drc_add_pcflush(m_maincpu, 0x6034d04); |
893 | 893 | sh2drc_add_pcflush(m_slave, 0x6036152); |
894 | 894 | |
895 | | install_rsgun_protection(machine()); |
| 895 | install_rsgun_protection(); |
896 | 896 | |
897 | 897 | DRIVER_INIT_CALL(stv); |
898 | 898 | |
r26341 | r26342 | |
901 | 901 | |
902 | 902 | DRIVER_INIT_MEMBER(stv_state,ffreveng) |
903 | 903 | { |
904 | | install_ffreveng_protection(machine()); |
| 904 | install_ffreveng_protection(); |
905 | 905 | DRIVER_INIT_CALL(stv); |
906 | 906 | } |
907 | 907 | |
r26341 | r26342 | |
1332 | 1332 | save_item(NAME(m_mux_data)); |
1333 | 1333 | save_item(NAME(m_scsp_last_line)); |
1334 | 1334 | |
1335 | | stv_register_protection_savestates(machine()); // machine/stvprot.c |
| 1335 | stv_register_protection_savestates(); // machine/stvprot.c |
1336 | 1336 | |
1337 | 1337 | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stv_state::stvcd_exit), this)); |
1338 | 1338 | |