neogeo modernize (nw)

This commit is contained in:
Miodrag Milanovic 2013-02-18 07:13:31 +00:00
parent 0966ad663d
commit c2cad72a5c
7 changed files with 780 additions and 768 deletions

View File

@ -9289,324 +9289,324 @@ INPUT_PORTS_END
DRIVER_INIT_MEMBER(neogeo_state,fatfury2) DRIVER_INIT_MEMBER(neogeo_state,fatfury2)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
fatfury2_install_protection(machine()); fatfury2_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,zupapa) DRIVER_INIT_MEMBER(neogeo_state,zupapa)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0xbd); kof99_neogeo_gfx_decrypt(0xbd);
} }
DRIVER_INIT_MEMBER(neogeo_state,kof98) DRIVER_INIT_MEMBER(neogeo_state,kof98)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof98_decrypt_68k(machine()); kof98_decrypt_68k();
install_kof98_protection(machine()); install_kof98_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,mslugx) DRIVER_INIT_MEMBER(neogeo_state,mslugx)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
mslugx_install_protection(machine()); mslugx_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kof99) DRIVER_INIT_MEMBER(neogeo_state,kof99)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof99_decrypt_68k(machine()); kof99_decrypt_68k();
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0x00); kof99_neogeo_gfx_decrypt(0x00);
kof99_install_protection(machine()); kof99_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kof99k) DRIVER_INIT_MEMBER(neogeo_state,kof99k)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0x00); kof99_neogeo_gfx_decrypt(0x00);
} }
DRIVER_INIT_MEMBER(neogeo_state,garou) DRIVER_INIT_MEMBER(neogeo_state,garou)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
garou_decrypt_68k(machine()); garou_decrypt_68k();
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0x06); kof99_neogeo_gfx_decrypt(0x06);
garou_install_protection(machine()); garou_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,garouh) DRIVER_INIT_MEMBER(neogeo_state,garouh)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
garouh_decrypt_68k(machine()); garouh_decrypt_68k();
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0x06); kof99_neogeo_gfx_decrypt(0x06);
garouh_install_protection(machine()); garouh_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,garoubl) DRIVER_INIT_MEMBER(neogeo_state,garoubl)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
neogeo_bootleg_sx_decrypt(machine(), 2); neogeo_bootleg_sx_decrypt(2);
neogeo_bootleg_cx_decrypt(machine()); neogeo_bootleg_cx_decrypt();
} }
DRIVER_INIT_MEMBER(neogeo_state,mslug3) DRIVER_INIT_MEMBER(neogeo_state,mslug3)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
mslug3_decrypt_68k(machine()); mslug3_decrypt_68k();
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0xad); kof99_neogeo_gfx_decrypt(0xad);
mslug3_install_protection(machine()); mslug3_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,mslug3h) DRIVER_INIT_MEMBER(neogeo_state,mslug3h)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0xad); kof99_neogeo_gfx_decrypt(0xad);
} }
DRIVER_INIT_MEMBER(neogeo_state,mslug3b6) DRIVER_INIT_MEMBER(neogeo_state,mslug3b6)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
neogeo_bootleg_sx_decrypt(machine(), 2); neogeo_bootleg_sx_decrypt(2);
cmc42_neogeo_gfx_decrypt(machine(), 0xad); cmc42_neogeo_gfx_decrypt(0xad);
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2000) DRIVER_INIT_MEMBER(neogeo_state,kof2000)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof2000_decrypt_68k(machine()); kof2000_decrypt_68k();
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x00); kof2000_neogeo_gfx_decrypt(0x00);
kof2000_install_protection(machine()); kof2000_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2000n) DRIVER_INIT_MEMBER(neogeo_state,kof2000n)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x00); kof2000_neogeo_gfx_decrypt(0x00);
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2001) DRIVER_INIT_MEMBER(neogeo_state,kof2001)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof2000_neogeo_gfx_decrypt(machine(), 0x1e); kof2000_neogeo_gfx_decrypt(0x1e);
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
} }
DRIVER_INIT_MEMBER(neogeo_state,cthd2003) DRIVER_INIT_MEMBER(neogeo_state,cthd2003)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
decrypt_cthd2003(machine()); decrypt_cthd2003();
patch_cthd2003(machine()); patch_cthd2003();
} }
DRIVER_INIT_MEMBER(neogeo_state,ct2k3sp) DRIVER_INIT_MEMBER(neogeo_state,ct2k3sp)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
decrypt_ct2k3sp(machine()); decrypt_ct2k3sp();
patch_cthd2003(machine()); patch_cthd2003();
} }
DRIVER_INIT_MEMBER(neogeo_state,ct2k3sa) DRIVER_INIT_MEMBER(neogeo_state,ct2k3sa)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
decrypt_ct2k3sa(machine()); decrypt_ct2k3sa();
patch_ct2k3sa(machine()); patch_ct2k3sa();
} }
DRIVER_INIT_MEMBER(neogeo_state,mslug4) DRIVER_INIT_MEMBER(neogeo_state,mslug4)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */ m_fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x31); kof2000_neogeo_gfx_decrypt(0x31);
neo_pcm2_snk_1999(machine(), 8); neo_pcm2_snk_1999(8);
} }
DRIVER_INIT_MEMBER(neogeo_state,ms4plus) DRIVER_INIT_MEMBER(neogeo_state,ms4plus)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
cmc50_neogeo_gfx_decrypt(machine(), 0x31); cmc50_neogeo_gfx_decrypt(0x31);
neo_pcm2_snk_1999(machine(), 8); neo_pcm2_snk_1999(8);
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
} }
DRIVER_INIT_MEMBER(neogeo_state,ganryu) DRIVER_INIT_MEMBER(neogeo_state,ganryu)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0x07); kof99_neogeo_gfx_decrypt(0x07);
} }
DRIVER_INIT_MEMBER(neogeo_state,s1945p) DRIVER_INIT_MEMBER(neogeo_state,s1945p)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0x05); kof99_neogeo_gfx_decrypt(0x05);
} }
DRIVER_INIT_MEMBER(neogeo_state,preisle2) DRIVER_INIT_MEMBER(neogeo_state,preisle2)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0x9f); kof99_neogeo_gfx_decrypt(0x9f);
} }
DRIVER_INIT_MEMBER(neogeo_state,bangbead) DRIVER_INIT_MEMBER(neogeo_state,bangbead)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0xf8); kof99_neogeo_gfx_decrypt(0xf8);
} }
DRIVER_INIT_MEMBER(neogeo_state,nitd) DRIVER_INIT_MEMBER(neogeo_state,nitd)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0xff); kof99_neogeo_gfx_decrypt(0xff);
} }
DRIVER_INIT_MEMBER(neogeo_state,sengoku3) DRIVER_INIT_MEMBER(neogeo_state,sengoku3)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
kof99_neogeo_gfx_decrypt(machine(), 0xfe); kof99_neogeo_gfx_decrypt(0xfe);
} }
DRIVER_INIT_MEMBER(neogeo_state,rotd) DRIVER_INIT_MEMBER(neogeo_state,rotd)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
neo_pcm2_snk_1999(machine(), 16); neo_pcm2_snk_1999(16);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x3f); kof2000_neogeo_gfx_decrypt(0x3f);
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2002) DRIVER_INIT_MEMBER(neogeo_state,kof2002)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof2002_decrypt_68k(machine()); kof2002_decrypt_68k();
neo_pcm2_swap(machine(), 0); neo_pcm2_swap(0);
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0xec); kof2000_neogeo_gfx_decrypt(0xec);
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2002b) DRIVER_INIT_MEMBER(neogeo_state,kof2002b)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof2002_decrypt_68k(machine()); kof2002_decrypt_68k();
neo_pcm2_swap(machine(), 0); neo_pcm2_swap(0);
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2002b_gfx_decrypt(machine(), memregion("sprites")->base(),0x4000000); kof2002b_gfx_decrypt(memregion("sprites")->base(),0x4000000);
kof2002b_gfx_decrypt(machine(), memregion("fixed")->base(),0x20000); kof2002b_gfx_decrypt(memregion("fixed")->base(),0x20000);
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k2pls) DRIVER_INIT_MEMBER(neogeo_state,kf2k2pls)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof2002_decrypt_68k(machine()); kof2002_decrypt_68k();
neo_pcm2_swap(machine(), 0); neo_pcm2_swap(0);
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
cmc50_neogeo_gfx_decrypt(machine(), 0xec); cmc50_neogeo_gfx_decrypt(0xec);
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k2mp) DRIVER_INIT_MEMBER(neogeo_state,kf2k2mp)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kf2k2mp_decrypt(machine()); kf2k2mp_decrypt();
neo_pcm2_swap(machine(), 0); neo_pcm2_swap(0);
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 2); neogeo_bootleg_sx_decrypt(2);
cmc50_neogeo_gfx_decrypt(machine(), 0xec); cmc50_neogeo_gfx_decrypt(0xec);
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k2mp2) DRIVER_INIT_MEMBER(neogeo_state,kf2k2mp2)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kf2k2mp2_px_decrypt(machine()); kf2k2mp2_px_decrypt();
neo_pcm2_swap(machine(), 0); neo_pcm2_swap(0);
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
cmc50_neogeo_gfx_decrypt(machine(), 0xec); cmc50_neogeo_gfx_decrypt(0xec);
} }
DRIVER_INIT_MEMBER(neogeo_state,kof10th) DRIVER_INIT_MEMBER(neogeo_state,kof10th)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
decrypt_kof10th(machine()); decrypt_kof10th();
install_kof10th_protection(machine()); install_kof10th_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kf10thep) DRIVER_INIT_MEMBER(neogeo_state,kf10thep)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
decrypt_kf10thep(machine()); decrypt_kf10thep();
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k5uni) DRIVER_INIT_MEMBER(neogeo_state,kf2k5uni)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
decrypt_kf2k5uni(machine()); decrypt_kf2k5uni();
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2k4se) DRIVER_INIT_MEMBER(neogeo_state,kof2k4se)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
decrypt_kof2k4se_68k(machine()); decrypt_kof2k4se_68k();
} }
DRIVER_INIT_MEMBER(neogeo_state,matrim) DRIVER_INIT_MEMBER(neogeo_state,matrim)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
matrim_decrypt_68k(machine()); matrim_decrypt_68k();
neo_pcm2_swap(machine(), 1); neo_pcm2_swap(1);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x6a); kof2000_neogeo_gfx_decrypt(0x6a);
} }
DRIVER_INIT_MEMBER(neogeo_state,matrimbl) DRIVER_INIT_MEMBER(neogeo_state,matrimbl)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
matrim_decrypt_68k(machine()); matrim_decrypt_68k();
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
matrimbl_decrypt(machine()); matrimbl_decrypt();
neogeo_sfix_decrypt(machine()); /* required for text layer */ neogeo_sfix_decrypt(); /* required for text layer */
} }
DRIVER_INIT_MEMBER(neogeo_state,pnyaa) DRIVER_INIT_MEMBER(neogeo_state,pnyaa)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
neo_pcm2_snk_1999(machine(), 4); neo_pcm2_snk_1999(4);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x2e); kof2000_neogeo_gfx_decrypt(0x2e);
} }
DRIVER_INIT_MEMBER(neogeo_state,mslug5) DRIVER_INIT_MEMBER(neogeo_state,mslug5)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
mslug5_decrypt_68k(machine()); mslug5_decrypt_68k();
neo_pcm2_swap(machine(), 2); neo_pcm2_swap(2);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x19); kof2000_neogeo_gfx_decrypt(0x19);
install_pvc_protection(machine()); install_pvc_protection();
} }
static TIMER_CALLBACK( ms5pcb_bios_timer_callback ) TIMER_CALLBACK_MEMBER(neogeo_state::ms5pcb_bios_timer_callback)
{ {
int harddip3 = machine.root_device().ioport("HARDDIP")->read() & 1; int harddip3 = ioport("HARDDIP")->read() & 1;
machine.root_device().membank(NEOGEO_BANK_BIOS)->set_base(machine.root_device().memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000); membank(NEOGEO_BANK_BIOS)->set_base(memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000);
} }
DRIVER_INIT_MEMBER(neogeo_state,ms5pcb) DRIVER_INIT_MEMBER(neogeo_state,ms5pcb)
@ -9614,34 +9614,34 @@ DRIVER_INIT_MEMBER(neogeo_state,ms5pcb)
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
/* start a timer that will check the BIOS select DIP every second */ /* start a timer that will check the BIOS select DIP every second */
machine().scheduler().timer_set(attotime::zero, FUNC(ms5pcb_bios_timer_callback)); machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(neogeo_state::ms5pcb_bios_timer_callback),this));
machine().scheduler().timer_pulse(attotime::from_msec(1000), FUNC(ms5pcb_bios_timer_callback)); machine().scheduler().timer_pulse(attotime::from_msec(1000), timer_expired_delegate(FUNC(neogeo_state::ms5pcb_bios_timer_callback),this));
mslug5_decrypt_68k(machine()); mslug5_decrypt_68k();
svcpcb_gfx_decrypt(machine()); svcpcb_gfx_decrypt();
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x19); kof2000_neogeo_gfx_decrypt(0x19);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
svcpcb_s1data_decrypt(machine()); svcpcb_s1data_decrypt();
neo_pcm2_swap(machine(), 2); neo_pcm2_swap(2);
install_pvc_protection(machine()); install_pvc_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,ms5plus) DRIVER_INIT_MEMBER(neogeo_state,ms5plus)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
cmc50_neogeo_gfx_decrypt(machine(), 0x19); cmc50_neogeo_gfx_decrypt(0x19);
neo_pcm2_swap(machine(), 2); neo_pcm2_swap(2);
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
install_ms5plus_protection(machine()); install_ms5plus_protection();
} }
static TIMER_CALLBACK( svcpcb_bios_timer_callback ) TIMER_CALLBACK_MEMBER(neogeo_state::svcpcb_bios_timer_callback)
{ {
int harddip3 = machine.root_device().ioport("HARDDIP")->read() & 1; int harddip3 = ioport("HARDDIP")->read() & 1;
machine.root_device().membank(NEOGEO_BANK_BIOS)->set_base(machine.root_device().memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000); membank(NEOGEO_BANK_BIOS)->set_base(memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000);
} }
DRIVER_INIT_MEMBER(neogeo_state,svcpcb) DRIVER_INIT_MEMBER(neogeo_state,svcpcb)
@ -9649,91 +9649,91 @@ DRIVER_INIT_MEMBER(neogeo_state,svcpcb)
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
/* start a timer that will check the BIOS select DIP every second */ /* start a timer that will check the BIOS select DIP every second */
machine().scheduler().timer_set(attotime::zero, FUNC(svcpcb_bios_timer_callback)); machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(neogeo_state::svcpcb_bios_timer_callback),this));
machine().scheduler().timer_pulse(attotime::from_msec(1000), FUNC(svcpcb_bios_timer_callback)); machine().scheduler().timer_pulse(attotime::from_msec(1000), timer_expired_delegate(FUNC(neogeo_state::svcpcb_bios_timer_callback),this));
svc_px_decrypt(machine()); svc_px_decrypt();
svcpcb_gfx_decrypt(machine()); svcpcb_gfx_decrypt();
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x57); kof2000_neogeo_gfx_decrypt(0x57);
svcpcb_s1data_decrypt(machine()); svcpcb_s1data_decrypt();
neo_pcm2_swap(machine(), 3); neo_pcm2_swap(3);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
install_pvc_protection(machine()); install_pvc_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,svc) DRIVER_INIT_MEMBER(neogeo_state,svc)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
svc_px_decrypt(machine()); svc_px_decrypt();
neo_pcm2_swap(machine(), 3); neo_pcm2_swap(3);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x57); kof2000_neogeo_gfx_decrypt(0x57);
install_pvc_protection(machine()); install_pvc_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,svcboot) DRIVER_INIT_MEMBER(neogeo_state,svcboot)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
svcboot_px_decrypt(machine()); svcboot_px_decrypt();
svcboot_cx_decrypt(machine()); svcboot_cx_decrypt();
install_pvc_protection(machine()); install_pvc_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,svcplus) DRIVER_INIT_MEMBER(neogeo_state,svcplus)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
svcplus_px_decrypt(machine()); svcplus_px_decrypt();
svcboot_cx_decrypt(machine()); svcboot_cx_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt( 1);
svcplus_px_hack(machine()); svcplus_px_hack();
} }
DRIVER_INIT_MEMBER(neogeo_state,svcplusa) DRIVER_INIT_MEMBER(neogeo_state,svcplusa)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
svcplusa_px_decrypt(machine()); svcplusa_px_decrypt();
svcboot_cx_decrypt(machine()); svcboot_cx_decrypt();
svcplus_px_hack(machine()); svcplus_px_hack();
} }
DRIVER_INIT_MEMBER(neogeo_state,svcsplus) DRIVER_INIT_MEMBER(neogeo_state,svcsplus)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
svcsplus_px_decrypt(machine()); svcsplus_px_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 2); neogeo_bootleg_sx_decrypt(2);
svcboot_cx_decrypt(machine()); svcboot_cx_decrypt();
svcsplus_px_hack(machine()); svcsplus_px_hack();
install_pvc_protection(machine()); install_pvc_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,samsho5) DRIVER_INIT_MEMBER(neogeo_state,samsho5)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
samsho5_decrypt_68k(machine()); samsho5_decrypt_68k();
neo_pcm2_swap(machine(), 4); neo_pcm2_swap(4);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x0f); kof2000_neogeo_gfx_decrypt(0x0f);
} }
DRIVER_INIT_MEMBER(neogeo_state,samsho5b) DRIVER_INIT_MEMBER(neogeo_state,samsho5b)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
samsho5b_px_decrypt(machine()); samsho5b_px_decrypt();
samsho5b_vx_decrypt(machine()); samsho5b_vx_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
neogeo_bootleg_cx_decrypt(machine()); neogeo_bootleg_cx_decrypt();
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k3pcb) DRIVER_INIT_MEMBER(neogeo_state,kf2k3pcb)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kf2k3pcb_decrypt_68k(machine()); kf2k3pcb_decrypt_68k();
kf2k3pcb_gfx_decrypt(machine()); kf2k3pcb_gfx_decrypt();
kof2003biosdecode(machine()); kof2003biosdecode();
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
/* extra little swap on the m1 - this must be performed AFTER the m1 decrypt /* extra little swap on the m1 - this must be performed AFTER the m1 decrypt
or the m1 checksum (used to generate the key) for decrypting the m1 is or the m1 checksum (used to generate the key) for decrypting the m1 is
@ -9747,81 +9747,81 @@ DRIVER_INIT_MEMBER(neogeo_state,kf2k3pcb)
} }
} }
kof2000_neogeo_gfx_decrypt(machine(), 0x9d); kof2000_neogeo_gfx_decrypt(0x9d);
kf2k3pcb_decrypt_s1data(machine()); kf2k3pcb_decrypt_s1data();
neo_pcm2_swap(machine(), 5); neo_pcm2_swap(5);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
install_pvc_protection(machine()); install_pvc_protection();
machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xc00000, 0xc7ffff, "bios" ); // 512k bios machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xc00000, 0xc7ffff, "bios" ); // 512k bios
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2003) DRIVER_INIT_MEMBER(neogeo_state,kof2003)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof2003_decrypt_68k(machine()); kof2003_decrypt_68k();
neo_pcm2_swap(machine(), 5); neo_pcm2_swap(5);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x9d); kof2000_neogeo_gfx_decrypt(0x9d);
install_pvc_protection(machine()); install_pvc_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kof2003h) DRIVER_INIT_MEMBER(neogeo_state,kof2003h)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
kof2003h_decrypt_68k(machine()); kof2003h_decrypt_68k();
neo_pcm2_swap(machine(), 5); neo_pcm2_swap(5);
m_fixed_layer_bank_type = 2; m_fixed_layer_bank_type = 2;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x9d); kof2000_neogeo_gfx_decrypt(0x9d);
install_pvc_protection(machine()); install_pvc_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k3bl) DRIVER_INIT_MEMBER(neogeo_state,kf2k3bl)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
cmc50_neogeo_gfx_decrypt(machine(), 0x9d); cmc50_neogeo_gfx_decrypt(0x9d);
neo_pcm2_swap(machine(), 5); neo_pcm2_swap(5);
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
kf2k3bl_install_protection(machine()); kf2k3bl_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k3pl) DRIVER_INIT_MEMBER(neogeo_state,kf2k3pl)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
cmc50_neogeo_gfx_decrypt(machine(), 0x9d); cmc50_neogeo_gfx_decrypt(0x9d);
neo_pcm2_swap(machine(), 5); neo_pcm2_swap(5);
kf2k3pl_px_decrypt(machine()); kf2k3pl_px_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
kf2k3pl_install_protection(machine()); kf2k3pl_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,kf2k3upl) DRIVER_INIT_MEMBER(neogeo_state,kf2k3upl)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
cmc50_neogeo_gfx_decrypt(machine(), 0x9d); cmc50_neogeo_gfx_decrypt(0x9d);
neo_pcm2_swap(machine(), 5); neo_pcm2_swap(5);
kf2k3upl_px_decrypt(machine()); kf2k3upl_px_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 2); neogeo_bootleg_sx_decrypt(2);
kf2k3upl_install_protection(machine()); kf2k3upl_install_protection();
} }
DRIVER_INIT_MEMBER(neogeo_state,samsh5sp) DRIVER_INIT_MEMBER(neogeo_state,samsh5sp)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
samsh5sp_decrypt_68k(machine()); samsh5sp_decrypt_68k();
neo_pcm2_swap(machine(), 6); neo_pcm2_swap(6);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0x0d); kof2000_neogeo_gfx_decrypt(0x0d);
} }
DRIVER_INIT_MEMBER(neogeo_state,jockeygp) DRIVER_INIT_MEMBER(neogeo_state,jockeygp)
{ {
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
m_fixed_layer_bank_type = 1; m_fixed_layer_bank_type = 1;
neogeo_cmc50_m1_decrypt(machine()); neogeo_cmc50_m1_decrypt();
kof2000_neogeo_gfx_decrypt(machine(), 0xac); kof2000_neogeo_gfx_decrypt(0xac);
/* install some extra RAM */ /* install some extra RAM */
machine().device("maincpu")->memory().space(AS_PROGRAM).install_ram(0x200000, 0x201fff); machine().device("maincpu")->memory().space(AS_PROGRAM).install_ram(0x200000, 0x201fff);
@ -9842,9 +9842,9 @@ DRIVER_INIT_MEMBER(neogeo_state,vliner)
DRIVER_INIT_MEMBER(neogeo_state,kof97oro) DRIVER_INIT_MEMBER(neogeo_state,kof97oro)
{ {
kof97oro_px_decode(machine()); kof97oro_px_decode();
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
neogeo_bootleg_cx_decrypt(machine()); neogeo_bootleg_cx_decrypt();
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
} }
@ -9853,24 +9853,24 @@ DRIVER_INIT_MEMBER(neogeo_state,kog)
/* overlay cartridge ROM */ /* overlay cartridge ROM */
machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_port(0x0ffffe, 0x0fffff, "JUMPER"); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_port(0x0ffffe, 0x0fffff, "JUMPER");
kog_px_decrypt(machine()); kog_px_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
neogeo_bootleg_cx_decrypt(machine()); neogeo_bootleg_cx_decrypt();
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
} }
DRIVER_INIT_MEMBER(neogeo_state,lans2004) DRIVER_INIT_MEMBER(neogeo_state,lans2004)
{ {
lans2004_decrypt_68k(machine()); lans2004_decrypt_68k();
lans2004_vx_decrypt(machine()); lans2004_vx_decrypt();
neogeo_bootleg_sx_decrypt(machine(), 1); neogeo_bootleg_sx_decrypt(1);
neogeo_bootleg_cx_decrypt(machine()); neogeo_bootleg_cx_decrypt();
DRIVER_INIT_CALL(neogeo); DRIVER_INIT_CALL(neogeo);
} }
static READ16_HANDLER( sbp_lowerrom_r ) READ16_MEMBER( neogeo_state::sbp_lowerrom_r )
{ {
UINT16* rom = (UINT16*)space.machine().root_device().memregion("maincpu")->base(); UINT16* rom = (UINT16*)memregion("maincpu")->base();
UINT16 origdata = rom[(offset+(0x200/2))]; UINT16 origdata = rom[(offset+(0x200/2))];
UINT16 data = BITSWAP16(origdata, 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4); UINT16 data = BITSWAP16(origdata, 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4);
int realoffset = 0x200+(offset*2); int realoffset = 0x200+(offset*2);
@ -9882,7 +9882,7 @@ static READ16_HANDLER( sbp_lowerrom_r )
return data; return data;
} }
static WRITE16_HANDLER( sbp_lowerrom_w ) WRITE16_MEMBER( neogeo_state::sbp_lowerrom_w )
{ {
int realoffset = 0x200+(offset*2); int realoffset = 0x200+(offset*2);
@ -9911,8 +9911,8 @@ DRIVER_INIT_MEMBER(neogeo_state,sbp)
// there are also writes to 0x1080.. // there are also writes to 0x1080..
// //
// other stuff going on as well tho, the main overlay is still missing, and p1 inputs don't work // other stuff going on as well tho, the main overlay is still missing, and p1 inputs don't work
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x00200, 0x001fff, FUNC(sbp_lowerrom_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x00200, 0x001fff, read16_delegate(FUNC(neogeo_state::sbp_lowerrom_r),this));
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x00200, 0x001fff, FUNC(sbp_lowerrom_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x00200, 0x001fff, write16_delegate(FUNC(neogeo_state::sbp_lowerrom_w),this));
/* the game code clears the text overlay used ingame immediately after writing it.. why? protection? sloppy code that the hw ignores? imperfect emulation? */ /* the game code clears the text overlay used ingame immediately after writing it.. why? protection? sloppy code that the hw ignores? imperfect emulation? */
{ {

View File

@ -1051,7 +1051,7 @@ void neogeo_state::machine_reset()
m_maincpu->reset(); m_maincpu->reset();
neogeo_reset_rng(machine()); neogeo_reset_rng();
start_interrupt_timers(); start_interrupt_timers();

View File

@ -263,6 +263,19 @@ public:
void neogeo_set_main_cpu_bank_address( UINT32 bank_address ); void neogeo_set_main_cpu_bank_address( UINT32 bank_address );
// protection data
UINT16 kof2003_tbl[4096];
UINT16 kof10thExtraRAMB[0x01000];
const UINT8 *type0_t03;
const UINT8 *type0_t12;
const UINT8 *type1_t03;
const UINT8 *type1_t12;
const UINT8 *address_8_15_xor1;
const UINT8 *address_8_15_xor2;
const UINT8 *address_16_23_xor1;
const UINT8 *address_16_23_xor2;
const UINT8 *address_0_7_xor;
protected: protected:
required_memory_region m_region_maincpu; required_memory_region m_region_maincpu;
required_memory_region m_region_sprites; required_memory_region m_region_sprites;
@ -319,95 +332,130 @@ protected:
void set_outputs( ); void set_outputs( );
void set_output_latch( UINT8 data ); void set_output_latch( UINT8 data );
void set_output_data( UINT8 data ); void set_output_data( UINT8 data );
TIMER_CALLBACK_MEMBER( ms5pcb_bios_timer_callback );
TIMER_CALLBACK_MEMBER( svcpcb_bios_timer_callback );
// protections implementation
DECLARE_READ16_MEMBER( sbp_lowerrom_r );
DECLARE_WRITE16_MEMBER( sbp_lowerrom_w );
DECLARE_READ16_MEMBER( fatfury2_protection_16_r );
DECLARE_WRITE16_MEMBER( fatfury2_protection_16_w );
void fatfury2_install_protection();
DECLARE_WRITE16_MEMBER ( kof98_prot_w );
void install_kof98_protection();
DECLARE_WRITE16_MEMBER( mslugx_protection_16_w );
DECLARE_READ16_MEMBER( mslugx_protection_16_r );
void mslugx_install_protection();
DECLARE_WRITE16_MEMBER( kof99_bankswitch_w );
DECLARE_WRITE16_MEMBER( garou_bankswitch_w );
DECLARE_WRITE16_MEMBER( garouh_bankswitch_w );
DECLARE_WRITE16_MEMBER( mslug3_bankswitch_w );
DECLARE_WRITE16_MEMBER( kof2000_bankswitch_w );
DECLARE_READ16_MEMBER( prot_9a37_r );
DECLARE_READ16_MEMBER( sma_random_r );
void neogeo_reset_rng();
void sma_install_random_read_handler( int addr1, int addr2 );
void kof99_install_protection();
void garou_install_protection();
void garouh_install_protection();
void mslug3_install_protection();
void kof2000_install_protection();
void pvc_w8( offs_t offset, UINT8 data );
UINT8 pvc_r8( offs_t offset );
void pvc_prot1();
void pvc_prot2(); // on writes to e8/e9/ea/eb
void pvc_write_bankswitch( address_space &space );
DECLARE_READ16_MEMBER( pvc_prot_r );
DECLARE_WRITE16_MEMBER( pvc_prot_w );
void install_pvc_protection();
void neogeo_bootleg_cx_decrypt();
void neogeo_bootleg_sx_decrypt(int value );
void kog_px_decrypt();
void kof97oro_px_decode();
void kof10thBankswitch(address_space &space, UINT16 nBank);
DECLARE_READ16_MEMBER( kof10th_RAMB_r );
DECLARE_WRITE16_MEMBER( kof10th_custom_w );
DECLARE_WRITE16_MEMBER( kof10th_bankswitch_w );
void install_kof10th_protection ();
void decrypt_kof10th();
void decrypt_kf10thep();
void kf2k5uni_px_decrypt();
void kf2k5uni_sx_decrypt();
void kf2k5uni_mx_decrypt();
void decrypt_kf2k5uni();
void kof2002b_gfx_decrypt(UINT8 *src, int size);
void kf2k2mp_decrypt();
void kf2k2mp2_px_decrypt();
void cthd2003_neogeo_gfx_address_fix_do(int start, int end, int bit3shift, int bit2shift, int bit1shift, int bit0shift);
void cthd2003_neogeo_gfx_address_fix(int start, int end);
void cthd2003_c(int pow);
void decrypt_cthd2003();
DECLARE_WRITE16_MEMBER ( cthd2003_bankswitch_w );
void patch_cthd2003();
void ct2k3sp_sx_decrypt();
void decrypt_ct2k3sp();
void decrypt_ct2k3sa();
void patch_ct2k3sa();
void decrypt_kof2k4se_68k();
void lans2004_vx_decrypt();
void lans2004_decrypt_68k();
DECLARE_READ16_MEMBER( mslug5_prot_r );
DECLARE_WRITE16_MEMBER ( ms5plus_bankswitch_w );
void install_ms5plus_protection();
void svcboot_px_decrypt();
void svcboot_cx_decrypt();
void svcplus_px_decrypt();
void svcplus_px_hack();
void svcplusa_px_decrypt();
void svcsplus_px_decrypt();
void svcsplus_px_hack();
DECLARE_READ16_MEMBER( kof2003_r);
DECLARE_WRITE16_MEMBER( kof2003_w );
DECLARE_WRITE16_MEMBER( kof2003p_w );
void kf2k3bl_px_decrypt();
void kf2k3bl_install_protection();
void kf2k3pl_px_decrypt();
void kf2k3pl_install_protection();
void kf2k3upl_px_decrypt();
void kf2k3upl_install_protection();
void samsho5b_px_decrypt();
void samsho5b_vx_decrypt();
void matrimbl_decrypt();
void decrypt(UINT8 *r0, UINT8 *r1,UINT8 c0, UINT8 c1,const UINT8 *table0hi,const UINT8 *table0lo,const UINT8 *table1,int base,int invert);
void neogeo_gfx_decrypt(int extra_xor);
void neogeo_sfix_decrypt();
void kof99_neogeo_gfx_decrypt(int extra_xor);
void kof2000_neogeo_gfx_decrypt(int extra_xor);
void cmc42_neogeo_gfx_decrypt(int extra_xor);
void cmc50_neogeo_gfx_decrypt(int extra_xor);
void svcpcb_gfx_decrypt();
void svcpcb_s1data_decrypt();
void kf2k3pcb_gfx_decrypt();
void kf2k3pcb_decrypt_s1data();
UINT16 generate_cs16(UINT8 *rom, int size);
int m1_address_scramble(int address, UINT16 key);
void neogeo_cmc50_m1_decrypt();
void kof98_decrypt_68k();
void kof99_decrypt_68k();
void garou_decrypt_68k();
void garouh_decrypt_68k();
void mslug3_decrypt_68k();
void kof2000_decrypt_68k();
void kof2002_decrypt_68k();
void matrim_decrypt_68k();
void samsho5_decrypt_68k();
void samsh5sp_decrypt_68k();
void mslug5_decrypt_68k();
void svc_px_decrypt();
void kf2k3pcb_decrypt_68k();
void kof2003_decrypt_68k();
void kof2003h_decrypt_68k();
void neo_pcm2_snk_1999(int value);
void neo_pcm2_swap(int value);
void kof2003biosdecode();
}; };
/*----------- defined in drivers/neogeo.c -----------*/ /*----------- defined in drivers/neogeo.c -----------*/
MACHINE_CONFIG_EXTERN( neogeo_base ); MACHINE_CONFIG_EXTERN( neogeo_base );
/*----------- defined in machine/neocrypt.c -----------*/
void kof99_neogeo_gfx_decrypt(running_machine &machine, int extra_xor);
void kof2000_neogeo_gfx_decrypt(running_machine &machine, int extra_xor);
void cmc42_neogeo_gfx_decrypt(running_machine &machine, int extra_xor);
void cmc50_neogeo_gfx_decrypt(running_machine &machine, int extra_xor);
void neogeo_cmc50_m1_decrypt(running_machine &machine);
void neo_pcm2_snk_1999(running_machine &machine, int value);
void neo_pcm2_swap(running_machine &machine, int value);
void neogeo_sfix_decrypt(running_machine &machine);
void kof99_decrypt_68k(running_machine &machine);
void garou_decrypt_68k(running_machine &machine);
void garouh_decrypt_68k(running_machine &machine);
void mslug3_decrypt_68k(running_machine &machine);
void kof2000_decrypt_68k(running_machine &machine);
void kof98_decrypt_68k(running_machine &machine);
void kof2002_decrypt_68k(running_machine &machine);
void matrim_decrypt_68k(running_machine &machine);
void mslug5_decrypt_68k(running_machine &machine);
void svc_px_decrypt(running_machine &machine);
void svcpcb_gfx_decrypt(running_machine &machine);
void svcpcb_s1data_decrypt(running_machine &machine);
void samsho5_decrypt_68k(running_machine &machine);
void kf2k3pcb_gfx_decrypt(running_machine &machine);
void kf2k3pcb_decrypt_68k(running_machine &machine);
void kf2k3pcb_decrypt_s1data(running_machine &machine);
void kof2003_decrypt_68k(running_machine &machine);
void kof2003h_decrypt_68k(running_machine &machine);
void kof2003biosdecode(running_machine &machine);
void samsh5sp_decrypt_68k(running_machine &machine);
/*----------- defined in machine/neoprot.c -----------*/
void neogeo_reset_rng(running_machine &machine);
void fatfury2_install_protection(running_machine &machine);
void mslugx_install_protection(running_machine &machine);
void kof99_install_protection(running_machine &machine);
void garou_install_protection(running_machine &machine);
void garouh_install_protection(running_machine &machine);
void mslug3_install_protection(running_machine &machine);
void kof2000_install_protection(running_machine &machine);
void install_kof98_protection(running_machine &machine);
void install_pvc_protection(running_machine &machine);
/*----------- defined in machine/neoboot.c -----------*/
void kog_px_decrypt(running_machine &machine);
void kof97oro_px_decode( running_machine &machine );
void neogeo_bootleg_cx_decrypt(running_machine &machine);
void install_kof10th_protection(running_machine &machine);
void decrypt_kof10th(running_machine &machine);
void decrypt_kf10thep(running_machine &machine);
void decrypt_kf2k5uni(running_machine &machine);
void neogeo_bootleg_sx_decrypt(running_machine &machine, int value);
void kof2002b_gfx_decrypt(running_machine &machine, UINT8 *src, int size);
void kf2k2mp_decrypt(running_machine &machine);
void kf2k2mp2_px_decrypt(running_machine &machine);
void decrypt_cthd2003(running_machine &machine);
void patch_cthd2003(running_machine &machine);
void decrypt_ct2k3sp(running_machine &machine);
void decrypt_ct2k3sa(running_machine &machine);
void patch_ct2k3sa(running_machine &machine);
void decrypt_kof2k4se_68k(running_machine &machine);
void lans2004_decrypt_68k(running_machine &machine);
void lans2004_vx_decrypt(running_machine &machine);
void install_ms5plus_protection(running_machine &machine);
void svcboot_px_decrypt(running_machine &machine);
void svcboot_cx_decrypt(running_machine &machine);
void svcplus_px_decrypt(running_machine &machine);
void svcplus_px_hack(running_machine &machine);
void svcplusa_px_decrypt(running_machine &machine);
void svcsplus_px_decrypt(running_machine &machine);
void svcsplus_px_hack(running_machine &machine);
void kf2k3bl_px_decrypt(running_machine &machine);
void kf2k3bl_install_protection(running_machine &machine);
void kf2k3pl_px_decrypt(running_machine &machine);
void kf2k3upl_px_decrypt(running_machine &machine);
void kf2k3upl_install_protection(running_machine &machine);
void kf2k3pl_install_protection(running_machine &machine);
void samsho5b_px_decrypt(running_machine &machine);
void samsho5b_vx_decrypt(running_machine &machine);
void matrimbl_decrypt(running_machine &machine);

File diff suppressed because it is too large Load Diff

View File

@ -108,17 +108,6 @@ analyzed, quickly leading to the algorithm.
***************************************************************************/ ***************************************************************************/
static const UINT8 *type0_t03;
static const UINT8 *type0_t12;
static const UINT8 *type1_t03;
static const UINT8 *type1_t12;
static const UINT8 *address_8_15_xor1;
static const UINT8 *address_8_15_xor2;
static const UINT8 *address_16_23_xor1;
static const UINT8 *address_16_23_xor2;
static const UINT8 *address_0_7_xor;
static const UINT8 kof99_type0_t03[256] = static const UINT8 kof99_type0_t03[256] =
{ {
0xfb, 0x86, 0x9d, 0xf1, 0xbf, 0x80, 0xd5, 0x43, 0xab, 0xb3, 0x9f, 0x6a, 0x33, 0xd9, 0xdb, 0xb6, 0xfb, 0x86, 0x9d, 0xf1, 0xbf, 0x80, 0xd5, 0x43, 0xab, 0xb3, 0x9f, 0x6a, 0x33, 0xd9, 0xdb, 0xb6,
@ -501,7 +490,7 @@ static const UINT8 kof2000_address_0_7_xor[256] =
static void decrypt(UINT8 *r0, UINT8 *r1, void neogeo_state::decrypt(UINT8 *r0, UINT8 *r1,
UINT8 c0, UINT8 c1, UINT8 c0, UINT8 c1,
const UINT8 *table0hi, const UINT8 *table0hi,
const UINT8 *table0lo, const UINT8 *table0lo,
@ -528,18 +517,18 @@ static void decrypt(UINT8 *r0, UINT8 *r1,
} }
static void neogeo_gfx_decrypt(running_machine &machine, int extra_xor) void neogeo_state::neogeo_gfx_decrypt(int extra_xor)
{ {
int rom_size; int rom_size;
UINT8 *buf; UINT8 *buf;
UINT8 *rom; UINT8 *rom;
int rpos; int rpos;
rom_size = machine.root_device().memregion("sprites")->bytes(); rom_size = memregion("sprites")->bytes();
buf = auto_alloc_array(machine, UINT8, rom_size); buf = auto_alloc_array(machine(), UINT8, rom_size);
rom = machine.root_device().memregion("sprites")->base(); rom = memregion("sprites")->base();
// Data xor // Data xor
for (rpos = 0;rpos < rom_size/4;rpos++) for (rpos = 0;rpos < rom_size/4;rpos++)
@ -587,18 +576,18 @@ static void neogeo_gfx_decrypt(running_machine &machine, int extra_xor)
rom[4*rpos+3] = buf[4*baser+3]; rom[4*rpos+3] = buf[4*baser+3];
} }
auto_free(machine, buf); auto_free(machine(), buf);
} }
/* the S data comes from the end of the C data */ /* the S data comes from the end of the C data */
void neogeo_sfix_decrypt(running_machine &machine) void neogeo_state::neogeo_sfix_decrypt()
{ {
int i; int i;
int rom_size = machine.root_device().memregion("sprites")->bytes(); int rom_size = memregion("sprites")->bytes();
int tx_size = machine.root_device().memregion("fixed")->bytes(); int tx_size = memregion("fixed")->bytes();
UINT8 *src = machine.root_device().memregion("sprites")->base()+rom_size-tx_size; UINT8 *src = memregion("sprites")->base()+rom_size-tx_size;
UINT8 *dst = machine.root_device().memregion("fixed")->base(); UINT8 *dst = memregion("fixed")->base();
for (i = 0;i < tx_size;i++) for (i = 0;i < tx_size;i++)
dst[i] = src[(i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4)]; dst[i] = src[(i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4)];
@ -606,7 +595,7 @@ void neogeo_sfix_decrypt(running_machine &machine)
/* CMC42 protection chip */ /* CMC42 protection chip */
void kof99_neogeo_gfx_decrypt(running_machine &machine, int extra_xor) void neogeo_state::kof99_neogeo_gfx_decrypt(int extra_xor)
{ {
type0_t03 = kof99_type0_t03; type0_t03 = kof99_type0_t03;
type0_t12 = kof99_type0_t12; type0_t12 = kof99_type0_t12;
@ -617,13 +606,13 @@ void kof99_neogeo_gfx_decrypt(running_machine &machine, int extra_xor)
address_16_23_xor1 = kof99_address_16_23_xor1; address_16_23_xor1 = kof99_address_16_23_xor1;
address_16_23_xor2 = kof99_address_16_23_xor2; address_16_23_xor2 = kof99_address_16_23_xor2;
address_0_7_xor = kof99_address_0_7_xor; address_0_7_xor = kof99_address_0_7_xor;
neogeo_gfx_decrypt(machine, extra_xor); neogeo_gfx_decrypt(extra_xor);
neogeo_sfix_decrypt(machine); neogeo_sfix_decrypt();
} }
/* CMC50 protection chip */ /* CMC50 protection chip */
void kof2000_neogeo_gfx_decrypt(running_machine &machine, int extra_xor) void neogeo_state::kof2000_neogeo_gfx_decrypt(int extra_xor)
{ {
type0_t03 = kof2000_type0_t03; type0_t03 = kof2000_type0_t03;
type0_t12 = kof2000_type0_t12; type0_t12 = kof2000_type0_t12;
@ -634,13 +623,13 @@ void kof2000_neogeo_gfx_decrypt(running_machine &machine, int extra_xor)
address_16_23_xor1 = kof2000_address_16_23_xor1; address_16_23_xor1 = kof2000_address_16_23_xor1;
address_16_23_xor2 = kof2000_address_16_23_xor2; address_16_23_xor2 = kof2000_address_16_23_xor2;
address_0_7_xor = kof2000_address_0_7_xor; address_0_7_xor = kof2000_address_0_7_xor;
neogeo_gfx_decrypt(machine, extra_xor); neogeo_gfx_decrypt(extra_xor);
neogeo_sfix_decrypt(machine); neogeo_sfix_decrypt();
} }
/* CMC42 protection chip */ /* CMC42 protection chip */
void cmc42_neogeo_gfx_decrypt(running_machine &machine, int extra_xor) void neogeo_state::cmc42_neogeo_gfx_decrypt(int extra_xor)
{ {
type0_t03 = kof99_type0_t03; type0_t03 = kof99_type0_t03;
type0_t12 = kof99_type0_t12; type0_t12 = kof99_type0_t12;
@ -651,12 +640,12 @@ void cmc42_neogeo_gfx_decrypt(running_machine &machine, int extra_xor)
address_16_23_xor1 = kof99_address_16_23_xor1; address_16_23_xor1 = kof99_address_16_23_xor1;
address_16_23_xor2 = kof99_address_16_23_xor2; address_16_23_xor2 = kof99_address_16_23_xor2;
address_0_7_xor = kof99_address_0_7_xor; address_0_7_xor = kof99_address_0_7_xor;
neogeo_gfx_decrypt(machine, extra_xor); neogeo_gfx_decrypt(extra_xor);
} }
/* CMC50 protection chip */ /* CMC50 protection chip */
void cmc50_neogeo_gfx_decrypt(running_machine &machine, int extra_xor) void neogeo_state::cmc50_neogeo_gfx_decrypt(int extra_xor)
{ {
type0_t03 = kof2000_type0_t03; type0_t03 = kof2000_type0_t03;
type0_t12 = kof2000_type0_t12; type0_t12 = kof2000_type0_t12;
@ -667,19 +656,19 @@ void cmc50_neogeo_gfx_decrypt(running_machine &machine, int extra_xor)
address_16_23_xor1 = kof2000_address_16_23_xor1; address_16_23_xor1 = kof2000_address_16_23_xor1;
address_16_23_xor2 = kof2000_address_16_23_xor2; address_16_23_xor2 = kof2000_address_16_23_xor2;
address_0_7_xor = kof2000_address_0_7_xor; address_0_7_xor = kof2000_address_0_7_xor;
neogeo_gfx_decrypt(machine, extra_xor); neogeo_gfx_decrypt(extra_xor);
} }
/* ms5pcb and svcpcb have an additional scramble on top of the standard CMC scrambling */ /* ms5pcb and svcpcb have an additional scramble on top of the standard CMC scrambling */
void svcpcb_gfx_decrypt(running_machine &machine) void neogeo_state::svcpcb_gfx_decrypt()
{ {
static const UINT8 xorval[ 4 ] = { 0x34, 0x21, 0xc4, 0xe9 }; static const UINT8 xorval[ 4 ] = { 0x34, 0x21, 0xc4, 0xe9 };
int i; int i;
int ofst; int ofst;
int rom_size = machine.root_device().memregion( "sprites" )->bytes(); int rom_size = memregion( "sprites" )->bytes();
UINT8 *rom = machine.root_device().memregion( "sprites" )->base(); UINT8 *rom = memregion( "sprites" )->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size );
for( i = 0; i < rom_size; i++ ) for( i = 0; i < rom_size; i++ )
{ {
@ -702,16 +691,16 @@ void svcpcb_gfx_decrypt(running_machine &machine)
ofst += (i & 0xffe00000); ofst += (i & 0xffe00000);
memcpy( &rom[ i * 4 ], &buf[ ofst * 4 ], 0x04 ); memcpy( &rom[ i * 4 ], &buf[ ofst * 4 ], 0x04 );
} }
auto_free( machine, buf ); auto_free( machine(), buf );
} }
/* and a further swap on the s1 data */ /* and a further swap on the s1 data */
void svcpcb_s1data_decrypt(running_machine &machine) void neogeo_state::svcpcb_s1data_decrypt()
{ {
int i; int i;
UINT8 *s1 = machine.root_device().memregion( "fixed" )->base(); UINT8 *s1 = memregion( "fixed" )->base();
size_t s1_size = machine.root_device().memregion( "fixed" )->bytes(); size_t s1_size = memregion( "fixed" )->bytes();
for( i = 0; i < s1_size; i++ ) // Decrypt S for( i = 0; i < s1_size; i++ ) // Decrypt S
{ {
@ -722,14 +711,14 @@ void svcpcb_s1data_decrypt(running_machine &machine)
/* kf2k3pcb has an additional scramble on top of the standard CMC scrambling */ /* kf2k3pcb has an additional scramble on top of the standard CMC scrambling */
/* Thanks to Razoola & Halrin for the info */ /* Thanks to Razoola & Halrin for the info */
void kf2k3pcb_gfx_decrypt(running_machine &machine) void neogeo_state::kf2k3pcb_gfx_decrypt()
{ {
static const UINT8 xorval[ 4 ] = { 0x34, 0x21, 0xc4, 0xe9 }; static const UINT8 xorval[ 4 ] = { 0x34, 0x21, 0xc4, 0xe9 };
int i; int i;
int ofst; int ofst;
int rom_size = machine.root_device().memregion( "sprites" )->bytes(); int rom_size = memregion( "sprites" )->bytes();
UINT8 *rom = machine.root_device().memregion( "sprites" )->base(); UINT8 *rom = memregion( "sprites" )->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size );
for ( i = 0; i < rom_size; i++ ) for ( i = 0; i < rom_size; i++ )
{ {
@ -748,36 +737,36 @@ void kf2k3pcb_gfx_decrypt(running_machine &machine)
ofst += (i & 0xff800000); ofst += (i & 0xff800000);
memcpy( &rom[ ofst ], &buf[ i ], 0x04 ); memcpy( &rom[ ofst ], &buf[ i ], 0x04 );
} }
auto_free( machine, buf ); auto_free( machine(), buf );
} }
/* and a further swap on the s1 data */ /* and a further swap on the s1 data */
void kf2k3pcb_decrypt_s1data(running_machine &machine) void neogeo_state::kf2k3pcb_decrypt_s1data()
{ {
UINT8 *src; UINT8 *src;
UINT8 *dst; UINT8 *dst;
int i; int i;
int tx_size = machine.root_device().memregion( "fixed" )->bytes(); int tx_size = memregion( "fixed" )->bytes();
int srom_size = machine.root_device().memregion( "sprites" )->bytes(); int srom_size = memregion( "sprites" )->bytes();
src = machine.root_device().memregion( "sprites" )->base() + srom_size - 0x1000000 - 0x80000; // Decrypt S src = memregion( "sprites" )->base() + srom_size - 0x1000000 - 0x80000; // Decrypt S
dst = machine.root_device().memregion( "fixed" )->base(); dst = memregion( "fixed" )->base();
for( i = 0; i < tx_size / 2; i++ ) for( i = 0; i < tx_size / 2; i++ )
{ {
dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ]; dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
} }
src = machine.root_device().memregion( "sprites" )->base() + srom_size - 0x80000; src = memregion( "sprites" )->base() + srom_size - 0x80000;
dst = machine.root_device().memregion( "fixed" )->base() + 0x80000; dst = memregion( "fixed" )->base() + 0x80000;
for( i = 0; i < tx_size / 2; i++ ) for( i = 0; i < tx_size / 2; i++ )
{ {
dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ]; dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
} }
dst = machine.root_device().memregion( "fixed" )->base(); dst = memregion( "fixed" )->base();
for( i = 0; i < tx_size; i++ ) for( i = 0; i < tx_size; i++ )
{ {
@ -839,7 +828,7 @@ static const UINT8 m1_address_0_7_xor[256] =
,and uses this checksum as the basis of the key with which to decrypt ,and uses this checksum as the basis of the key with which to decrypt
the rom */ the rom */
static UINT16 generate_cs16(UINT8 *rom, int size) UINT16 neogeo_state::generate_cs16(UINT8 *rom, int size)
{ {
UINT16 cs16; UINT16 cs16;
int i; int i;
@ -852,7 +841,7 @@ static UINT16 generate_cs16(UINT8 *rom, int size)
} }
static int m1_address_scramble(int address, UINT16 key) int neogeo_state::m1_address_scramble(int address, UINT16 key)
{ {
int block; int block;
int aux; int aux;
@ -885,13 +874,13 @@ static int m1_address_scramble(int address, UINT16 key)
} }
void neogeo_cmc50_m1_decrypt(running_machine &machine) void neogeo_state::neogeo_cmc50_m1_decrypt()
{ {
UINT8* rom = machine.root_device().memregion("audiocrypt")->base(); UINT8* rom = memregion("audiocrypt")->base();
size_t rom_size = 0x80000; size_t rom_size = 0x80000;
UINT8* rom2 = machine.root_device().memregion("audiocpu")->base(); UINT8* rom2 = memregion("audiocpu")->base();
UINT8* buffer = auto_alloc_array(machine, UINT8, rom_size); UINT8* buffer = auto_alloc_array(machine(), UINT8, rom_size);
UINT32 i; UINT32 i;
@ -912,7 +901,7 @@ void neogeo_cmc50_m1_decrypt(running_machine &machine)
#if 0 #if 0
{ {
FILE *fp; FILE *fp;
const char *gamename = machine.system().name; const char *gamename = machine().system().name;
char filename[256]; char filename[256];
sprintf(filename, "%s_m1.dump", gamename); sprintf(filename, "%s_m1.dump", gamename);
@ -929,7 +918,7 @@ void neogeo_cmc50_m1_decrypt(running_machine &machine)
#if 0 #if 0
{ {
FILE *fp; FILE *fp;
const char *gamename = machine.system().name; const char *gamename = machine().system().name;
char filename[256]; char filename[256];
sprintf(filename, "%s_m1extra.dump", gamename); sprintf(filename, "%s_m1extra.dump", gamename);
@ -942,7 +931,7 @@ void neogeo_cmc50_m1_decrypt(running_machine &machine)
} }
#endif #endif
auto_free( machine, buffer ); auto_free( machine(), buffer );
} }
@ -954,10 +943,10 @@ NeoGeo 'P' ROM encryption
/* Kof98 uses an early encryption, quite different from the others */ /* Kof98 uses an early encryption, quite different from the others */
void kof98_decrypt_68k(running_machine &machine) void neogeo_state::kof98_decrypt_68k()
{ {
UINT8 *src = machine.root_device().memregion("maincpu")->base(); UINT8 *src = memregion("maincpu")->base();
UINT8 *dst = auto_alloc_array(machine, UINT8, 0x200000); UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x200000);
int i, j, k; int i, j, k;
static const UINT32 sec[]={0x000000,0x100000,0x000004,0x100004,0x10000a,0x00000a,0x10000e,0x00000e}; static const UINT32 sec[]={0x000000,0x100000,0x000004,0x100004,0x10000a,0x00000a,0x10000e,0x00000e};
static const UINT32 pos[]={0x000,0x004,0x00a,0x00e}; static const UINT32 pos[]={0x000,0x004,0x00a,0x00e};
@ -996,17 +985,17 @@ void kof98_decrypt_68k(running_machine &machine)
} }
memmove( &src[0x100000], &src[0x200000], 0x400000 ); memmove( &src[0x100000], &src[0x200000], 0x400000 );
auto_free(machine, dst); auto_free(machine(), dst);
} }
/* kof99, garou, garouh, mslug3 and kof2000 have and SMA chip which contains program code and decrypts the 68k roms */ /* kof99, garou, garouh, mslug3 and kof2000 have and SMA chip which contains program code and decrypts the 68k roms */
void kof99_decrypt_68k(running_machine &machine) void neogeo_state::kof99_decrypt_68k()
{ {
UINT16 *rom; UINT16 *rom;
int i,j; int i,j;
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
/* swap data lines on the whole ROMs */ /* swap data lines on the whole ROMs */
for (i = 0;i < 0x800000/2;i++) for (i = 0;i < 0x800000/2;i++)
{ {
@ -1025,7 +1014,7 @@ void kof99_decrypt_68k(running_machine &machine)
} }
/* swap address lines & relocate fixed part */ /* swap address lines & relocate fixed part */
rom = (UINT16 *)machine.root_device().memregion("maincpu")->base(); rom = (UINT16 *)memregion("maincpu")->base();
for (i = 0;i < 0x0c0000/2;i++) for (i = 0;i < 0x0c0000/2;i++)
{ {
rom[i] = rom[0x700000/2 + BITSWAP24(i,23,22,21,20,19,18,11,6,14,17,16,5,8,10,12,0,4,3,2,7,9,15,13,1)]; rom[i] = rom[0x700000/2 + BITSWAP24(i,23,22,21,20,19,18,11,6,14,17,16,5,8,10,12,0,4,3,2,7,9,15,13,1)];
@ -1033,13 +1022,13 @@ void kof99_decrypt_68k(running_machine &machine)
} }
void garou_decrypt_68k(running_machine &machine) void neogeo_state::garou_decrypt_68k()
{ {
UINT16 *rom; UINT16 *rom;
int i,j; int i,j;
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
/* swap data lines on the whole ROMs */ /* swap data lines on the whole ROMs */
for (i = 0;i < 0x800000/2;i++) for (i = 0;i < 0x800000/2;i++)
{ {
@ -1047,14 +1036,14 @@ void garou_decrypt_68k(running_machine &machine)
} }
/* swap address lines & relocate fixed part */ /* swap address lines & relocate fixed part */
rom = (UINT16 *)machine.root_device().memregion("maincpu")->base(); rom = (UINT16 *)memregion("maincpu")->base();
for (i = 0;i < 0x0c0000/2;i++) for (i = 0;i < 0x0c0000/2;i++)
{ {
rom[i] = rom[0x710000/2 + BITSWAP24(i,23,22,21,20,19,18,4,5,16,14,7,9,6,13,17,15,3,1,2,12,11,8,10,0)]; rom[i] = rom[0x710000/2 + BITSWAP24(i,23,22,21,20,19,18,4,5,16,14,7,9,6,13,17,15,3,1,2,12,11,8,10,0)];
} }
/* swap address lines for the banked part */ /* swap address lines for the banked part */
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
for (i = 0;i < 0x800000/2;i+=0x8000/2) for (i = 0;i < 0x800000/2;i+=0x8000/2)
{ {
UINT16 buffer[0x8000/2]; UINT16 buffer[0x8000/2];
@ -1067,13 +1056,13 @@ void garou_decrypt_68k(running_machine &machine)
} }
void garouh_decrypt_68k(running_machine &machine) void neogeo_state::garouh_decrypt_68k()
{ {
UINT16 *rom; UINT16 *rom;
int i,j; int i,j;
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
/* swap data lines on the whole ROMs */ /* swap data lines on the whole ROMs */
for (i = 0;i < 0x800000/2;i++) for (i = 0;i < 0x800000/2;i++)
{ {
@ -1081,14 +1070,14 @@ void garouh_decrypt_68k(running_machine &machine)
} }
/* swap address lines & relocate fixed part */ /* swap address lines & relocate fixed part */
rom = (UINT16 *)machine.root_device().memregion("maincpu")->base(); rom = (UINT16 *)memregion("maincpu")->base();
for (i = 0;i < 0x0c0000/2;i++) for (i = 0;i < 0x0c0000/2;i++)
{ {
rom[i] = rom[0x7f8000/2 + BITSWAP24(i,23,22,21,20,19,18,5,16,11,2,6,7,17,3,12,8,14,4,0,9,1,10,15,13)]; rom[i] = rom[0x7f8000/2 + BITSWAP24(i,23,22,21,20,19,18,5,16,11,2,6,7,17,3,12,8,14,4,0,9,1,10,15,13)];
} }
/* swap address lines for the banked part */ /* swap address lines for the banked part */
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
for (i = 0;i < 0x800000/2;i+=0x8000/2) for (i = 0;i < 0x800000/2;i+=0x8000/2)
{ {
UINT16 buffer[0x8000/2]; UINT16 buffer[0x8000/2];
@ -1101,13 +1090,13 @@ void garouh_decrypt_68k(running_machine &machine)
} }
void mslug3_decrypt_68k(running_machine &machine) void neogeo_state::mslug3_decrypt_68k()
{ {
UINT16 *rom; UINT16 *rom;
int i,j; int i,j;
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
/* swap data lines on the whole ROMs */ /* swap data lines on the whole ROMs */
for (i = 0;i < 0x800000/2;i++) for (i = 0;i < 0x800000/2;i++)
{ {
@ -1115,14 +1104,14 @@ void mslug3_decrypt_68k(running_machine &machine)
} }
/* swap address lines & relocate fixed part */ /* swap address lines & relocate fixed part */
rom = (UINT16 *)machine.root_device().memregion("maincpu")->base(); rom = (UINT16 *)memregion("maincpu")->base();
for (i = 0;i < 0x0c0000/2;i++) for (i = 0;i < 0x0c0000/2;i++)
{ {
rom[i] = rom[0x5d0000/2 + BITSWAP24(i,23,22,21,20,19,18,15,2,1,13,3,0,9,6,16,4,11,5,7,12,17,14,10,8)]; rom[i] = rom[0x5d0000/2 + BITSWAP24(i,23,22,21,20,19,18,15,2,1,13,3,0,9,6,16,4,11,5,7,12,17,14,10,8)];
} }
/* swap address lines for the banked part */ /* swap address lines for the banked part */
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
for (i = 0;i < 0x800000/2;i+=0x10000/2) for (i = 0;i < 0x800000/2;i+=0x10000/2)
{ {
UINT16 buffer[0x10000/2]; UINT16 buffer[0x10000/2];
@ -1135,13 +1124,13 @@ void mslug3_decrypt_68k(running_machine &machine)
} }
void kof2000_decrypt_68k(running_machine &machine) void neogeo_state::kof2000_decrypt_68k()
{ {
UINT16 *rom; UINT16 *rom;
int i,j; int i,j;
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000);
/* swap data lines on the whole ROMs */ /* swap data lines on the whole ROMs */
for (i = 0;i < 0x800000/2;i++) for (i = 0;i < 0x800000/2;i++)
{ {
@ -1160,7 +1149,7 @@ void kof2000_decrypt_68k(running_machine &machine)
} }
/* swap address lines & relocate fixed part */ /* swap address lines & relocate fixed part */
rom = (UINT16 *)machine.root_device().memregion("maincpu")->base(); rom = (UINT16 *)memregion("maincpu")->base();
for (i = 0;i < 0x0c0000/2;i++) for (i = 0;i < 0x0c0000/2;i++)
{ {
rom[i] = rom[0x73a000/2 + BITSWAP24(i,23,22,21,20,19,18,8,4,15,13,3,14,16,2,6,17,7,12,10,0,5,11,1,9)]; rom[i] = rom[0x73a000/2 + BITSWAP24(i,23,22,21,20,19,18,8,4,15,13,3,14,16,2,6,17,7,12,10,0,5,11,1,9)];
@ -1169,78 +1158,78 @@ void kof2000_decrypt_68k(running_machine &machine)
/* kof2002, matrim, samsho5, samsh5sp have some simple block swapping */ /* kof2002, matrim, samsho5, samsh5sp have some simple block swapping */
void kof2002_decrypt_68k(running_machine &machine) void neogeo_state::kof2002_decrypt_68k()
{ {
int i; int i;
static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000}; static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000};
UINT8 *src = machine.root_device().memregion("maincpu")->base()+0x100000; UINT8 *src = memregion("maincpu")->base()+0x100000;
UINT8 *dst = auto_alloc_array(machine, UINT8, 0x400000); UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x400000);
memcpy( dst, src, 0x400000 ); memcpy( dst, src, 0x400000 );
for( i=0; i<8; ++i ) for( i=0; i<8; ++i )
{ {
memcpy( src+i*0x80000, dst+sec[i], 0x80000 ); memcpy( src+i*0x80000, dst+sec[i], 0x80000 );
} }
auto_free(machine, dst); auto_free(machine(), dst);
} }
void matrim_decrypt_68k(running_machine &machine) void neogeo_state::matrim_decrypt_68k()
{ {
int i; int i;
static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000}; static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000};
UINT8 *src = machine.root_device().memregion("maincpu")->base()+0x100000; UINT8 *src = memregion("maincpu")->base()+0x100000;
UINT8 *dst = auto_alloc_array(machine, UINT8, 0x400000); UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x400000);
memcpy( dst, src, 0x400000); memcpy( dst, src, 0x400000);
for( i=0; i<8; ++i ) for( i=0; i<8; ++i )
{ {
memcpy( src+i*0x80000, dst+sec[i], 0x80000 ); memcpy( src+i*0x80000, dst+sec[i], 0x80000 );
} }
auto_free(machine, dst); auto_free(machine(), dst);
} }
void samsho5_decrypt_68k(running_machine &machine) void neogeo_state::samsho5_decrypt_68k()
{ {
int i; int i;
static const int sec[]={0x000000,0x080000,0x700000,0x680000,0x500000,0x180000,0x200000,0x480000,0x300000,0x780000,0x600000,0x280000,0x100000,0x580000,0x400000,0x380000}; static const int sec[]={0x000000,0x080000,0x700000,0x680000,0x500000,0x180000,0x200000,0x480000,0x300000,0x780000,0x600000,0x280000,0x100000,0x580000,0x400000,0x380000};
UINT8 *src = machine.root_device().memregion("maincpu")->base(); UINT8 *src = memregion("maincpu")->base();
UINT8 *dst = auto_alloc_array(machine, UINT8, 0x800000); UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x800000);
memcpy( dst, src, 0x800000 ); memcpy( dst, src, 0x800000 );
for( i=0; i<16; ++i ) for( i=0; i<16; ++i )
{ {
memcpy( src+i*0x80000, dst+sec[i], 0x80000 ); memcpy( src+i*0x80000, dst+sec[i], 0x80000 );
} }
auto_free(machine, dst); auto_free(machine(), dst);
} }
void samsh5sp_decrypt_68k(running_machine &machine) void neogeo_state::samsh5sp_decrypt_68k()
{ {
int i; int i;
static const int sec[]={0x000000,0x080000,0x500000,0x480000,0x600000,0x580000,0x700000,0x280000,0x100000,0x680000,0x400000,0x780000,0x200000,0x380000,0x300000,0x180000}; static const int sec[]={0x000000,0x080000,0x500000,0x480000,0x600000,0x580000,0x700000,0x280000,0x100000,0x680000,0x400000,0x780000,0x200000,0x380000,0x300000,0x180000};
UINT8 *src = machine.root_device().memregion("maincpu")->base(); UINT8 *src = memregion("maincpu")->base();
UINT8 *dst = auto_alloc_array(machine, UINT8, 0x800000); UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x800000);
memcpy( dst, src, 0x800000 ); memcpy( dst, src, 0x800000 );
for( i=0; i<16; ++i ) for( i=0; i<16; ++i )
{ {
memcpy( src+i*0x80000, dst+sec[i], 0x80000 ); memcpy( src+i*0x80000, dst+sec[i], 0x80000 );
} }
auto_free(machine, dst); auto_free(machine(), dst);
} }
/* kf2k3pcb, kof2003, kof2003h, mslug5 and svc have updated P rom scramble */ /* kf2k3pcb, kof2003, kof2003h, mslug5 and svc have updated P rom scramble */
void mslug5_decrypt_68k(running_machine &machine) void neogeo_state::mslug5_decrypt_68k()
{ {
static const UINT8 xor1[ 0x20 ] = { 0xc2, 0x4b, 0x74, 0xfd, 0x0b, 0x34, 0xeb, 0xd7, 0x10, 0x6d, 0xf9, 0xce, 0x5d, 0xd5, 0x61, 0x29, 0xf5, 0xbe, 0x0d, 0x82, 0x72, 0x45, 0x0f, 0x24, 0xb3, 0x34, 0x1b, 0x99, 0xea, 0x09, 0xf3, 0x03 }; static const UINT8 xor1[ 0x20 ] = { 0xc2, 0x4b, 0x74, 0xfd, 0x0b, 0x34, 0xeb, 0xd7, 0x10, 0x6d, 0xf9, 0xce, 0x5d, 0xd5, 0x61, 0x29, 0xf5, 0xbe, 0x0d, 0x82, 0x72, 0x45, 0x0f, 0x24, 0xb3, 0x34, 0x1b, 0x99, 0xea, 0x09, 0xf3, 0x03 };
static const UINT8 xor2[ 0x20 ] = { 0x36, 0x09, 0xb0, 0x64, 0x95, 0x0f, 0x90, 0x42, 0x6e, 0x0f, 0x30, 0xf6, 0xe5, 0x08, 0x30, 0x64, 0x08, 0x04, 0x00, 0x2f, 0x72, 0x09, 0xa0, 0x13, 0xc9, 0x0b, 0xa0, 0x3e, 0xc2, 0x00, 0x40, 0x2b }; static const UINT8 xor2[ 0x20 ] = { 0x36, 0x09, 0xb0, 0x64, 0x95, 0x0f, 0x90, 0x42, 0x6e, 0x0f, 0x30, 0xf6, 0xe5, 0x08, 0x30, 0x64, 0x08, 0x04, 0x00, 0x2f, 0x72, 0x09, 0xa0, 0x13, 0xc9, 0x0b, 0xa0, 0x3e, 0xc2, 0x00, 0x40, 0x2b };
int i; int i;
int ofst; int ofst;
int rom_size = 0x800000; int rom_size = 0x800000;
UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); UINT8 *rom = memregion( "maincpu" )->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size );
for( i = 0; i < 0x100000; i++ ) for( i = 0; i < 0x100000; i++ )
{ {
@ -1273,19 +1262,19 @@ void mslug5_decrypt_68k(running_machine &machine)
memcpy( buf, rom, rom_size ); memcpy( buf, rom, rom_size );
memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 ); memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 );
memcpy( &rom[ 0x200000 ], &buf[ 0x100000 ], 0x600000 ); memcpy( &rom[ 0x200000 ], &buf[ 0x100000 ], 0x600000 );
auto_free( machine, buf ); auto_free( machine(), buf );
} }
void svc_px_decrypt(running_machine &machine) void neogeo_state::svc_px_decrypt()
{ {
static const UINT8 xor1[ 0x20 ] = { 0x3b, 0x6a, 0xf7, 0xb7, 0xe8, 0xa9, 0x20, 0x99, 0x9f, 0x39, 0x34, 0x0c, 0xc3, 0x9a, 0xa5, 0xc8, 0xb8, 0x18, 0xce, 0x56, 0x94, 0x44, 0xe3, 0x7a, 0xf7, 0xdd, 0x42, 0xf0, 0x18, 0x60, 0x92, 0x9f }; static const UINT8 xor1[ 0x20 ] = { 0x3b, 0x6a, 0xf7, 0xb7, 0xe8, 0xa9, 0x20, 0x99, 0x9f, 0x39, 0x34, 0x0c, 0xc3, 0x9a, 0xa5, 0xc8, 0xb8, 0x18, 0xce, 0x56, 0x94, 0x44, 0xe3, 0x7a, 0xf7, 0xdd, 0x42, 0xf0, 0x18, 0x60, 0x92, 0x9f };
static const UINT8 xor2[ 0x20 ] = { 0x69, 0x0b, 0x60, 0xd6, 0x4f, 0x01, 0x40, 0x1a, 0x9f, 0x0b, 0xf0, 0x75, 0x58, 0x0e, 0x60, 0xb4, 0x14, 0x04, 0x20, 0xe4, 0xb9, 0x0d, 0x10, 0x89, 0xeb, 0x07, 0x30, 0x90, 0x50, 0x0e, 0x20, 0x26 }; static const UINT8 xor2[ 0x20 ] = { 0x69, 0x0b, 0x60, 0xd6, 0x4f, 0x01, 0x40, 0x1a, 0x9f, 0x0b, 0xf0, 0x75, 0x58, 0x0e, 0x60, 0xb4, 0x14, 0x04, 0x20, 0xe4, 0xb9, 0x0d, 0x10, 0x89, 0xeb, 0x07, 0x30, 0x90, 0x50, 0x0e, 0x20, 0x26 };
int i; int i;
int ofst; int ofst;
int rom_size = 0x800000; int rom_size = 0x800000;
UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); UINT8 *rom = memregion( "maincpu" )->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size );
for( i = 0; i < 0x100000; i++ ) for( i = 0; i < 0x100000; i++ )
{ {
@ -1318,18 +1307,18 @@ void svc_px_decrypt(running_machine &machine)
memcpy( buf, rom, rom_size ); memcpy( buf, rom, rom_size );
memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 ); memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 );
memcpy( &rom[ 0x200000 ], &buf[ 0x100000 ], 0x600000 ); memcpy( &rom[ 0x200000 ], &buf[ 0x100000 ], 0x600000 );
auto_free( machine, buf ); auto_free( machine(), buf );
} }
void kf2k3pcb_decrypt_68k(running_machine &machine) void neogeo_state::kf2k3pcb_decrypt_68k()
{ {
static const UINT8 xor2[ 0x20 ] = { 0xb4, 0x0f, 0x40, 0x6c, 0x38, 0x07, 0xd0, 0x3f, 0x53, 0x08, 0x80, 0xaa, 0xbe, 0x07, 0xc0, 0xfa, 0xd0, 0x08, 0x10, 0xd2, 0xf1, 0x03, 0x70, 0x7e, 0x87, 0x0b, 0x40, 0xf6, 0x2a, 0x0a, 0xe0, 0xf9 }; static const UINT8 xor2[ 0x20 ] = { 0xb4, 0x0f, 0x40, 0x6c, 0x38, 0x07, 0xd0, 0x3f, 0x53, 0x08, 0x80, 0xaa, 0xbe, 0x07, 0xc0, 0xfa, 0xd0, 0x08, 0x10, 0xd2, 0xf1, 0x03, 0x70, 0x7e, 0x87, 0x0b, 0x40, 0xf6, 0x2a, 0x0a, 0xe0, 0xf9 };
int i; int i;
int ofst; int ofst;
int rom_size = 0x900000; int rom_size = 0x900000;
UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); UINT8 *rom = memregion( "maincpu" )->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size );
for (i = 0; i < 0x100000; i++) for (i = 0; i < 0x100000; i++)
{ {
@ -1360,19 +1349,19 @@ void kf2k3pcb_decrypt_68k(running_machine &machine)
memcpy (&rom[0x000000], &buf[0x000000], 0x100000); memcpy (&rom[0x000000], &buf[0x000000], 0x100000);
memcpy (&rom[0x100000], &buf[0x800000], 0x100000); memcpy (&rom[0x100000], &buf[0x800000], 0x100000);
memcpy (&rom[0x200000], &buf[0x100000], 0x700000); memcpy (&rom[0x200000], &buf[0x100000], 0x700000);
auto_free( machine, buf ); auto_free( machine(), buf );
} }
void kof2003_decrypt_68k(running_machine &machine) void neogeo_state::kof2003_decrypt_68k()
{ {
static const UINT8 xor1[0x20] = { 0x3b, 0x6a, 0xf7, 0xb7, 0xe8, 0xa9, 0x20, 0x99, 0x9f, 0x39, 0x34, 0x0c, 0xc3, 0x9a, 0xa5, 0xc8, 0xb8, 0x18, 0xce, 0x56, 0x94, 0x44, 0xe3, 0x7a, 0xf7, 0xdd, 0x42, 0xf0, 0x18, 0x60, 0x92, 0x9f }; static const UINT8 xor1[0x20] = { 0x3b, 0x6a, 0xf7, 0xb7, 0xe8, 0xa9, 0x20, 0x99, 0x9f, 0x39, 0x34, 0x0c, 0xc3, 0x9a, 0xa5, 0xc8, 0xb8, 0x18, 0xce, 0x56, 0x94, 0x44, 0xe3, 0x7a, 0xf7, 0xdd, 0x42, 0xf0, 0x18, 0x60, 0x92, 0x9f };
static const UINT8 xor2[0x20] = { 0x2f, 0x02, 0x60, 0xbb, 0x77, 0x01, 0x30, 0x08, 0xd8, 0x01, 0xa0, 0xdf, 0x37, 0x0a, 0xf0, 0x65, 0x28, 0x03, 0xd0, 0x23, 0xd3, 0x03, 0x70, 0x42, 0xbb, 0x06, 0xf0, 0x28, 0xba, 0x0f, 0xf0, 0x7a }; static const UINT8 xor2[0x20] = { 0x2f, 0x02, 0x60, 0xbb, 0x77, 0x01, 0x30, 0x08, 0xd8, 0x01, 0xa0, 0xdf, 0x37, 0x0a, 0xf0, 0x65, 0x28, 0x03, 0xd0, 0x23, 0xd3, 0x03, 0x70, 0x42, 0xbb, 0x06, 0xf0, 0x28, 0xba, 0x0f, 0xf0, 0x7a };
int i; int i;
int ofst; int ofst;
int rom_size = 0x900000; int rom_size = 0x900000;
UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); UINT8 *rom = memregion( "maincpu" )->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size );
for (i = 0; i < 0x100000; i++) for (i = 0; i < 0x100000; i++)
{ {
@ -1407,20 +1396,20 @@ void kof2003_decrypt_68k(running_machine &machine)
memcpy (&rom[0x000000], &buf[0x000000], 0x100000); memcpy (&rom[0x000000], &buf[0x000000], 0x100000);
memcpy (&rom[0x100000], &buf[0x800000], 0x100000); memcpy (&rom[0x100000], &buf[0x800000], 0x100000);
memcpy (&rom[0x200000], &buf[0x100000], 0x700000); memcpy (&rom[0x200000], &buf[0x100000], 0x700000);
auto_free( machine, buf ); auto_free( machine(), buf );
} }
// Thanks to IQ_132 for the info // Thanks to IQ_132 for the info
void kof2003h_decrypt_68k(running_machine &machine) void neogeo_state::kof2003h_decrypt_68k()
{ {
static const UINT8 xor1[0x20] = { 0xc2, 0x4b, 0x74, 0xfd, 0x0b, 0x34, 0xeb, 0xd7, 0x10, 0x6d, 0xf9, 0xce, 0x5d, 0xd5, 0x61, 0x29, 0xf5, 0xbe, 0x0d, 0x82, 0x72, 0x45, 0x0f, 0x24, 0xb3, 0x34, 0x1b, 0x99, 0xea, 0x09, 0xf3, 0x03 }; static const UINT8 xor1[0x20] = { 0xc2, 0x4b, 0x74, 0xfd, 0x0b, 0x34, 0xeb, 0xd7, 0x10, 0x6d, 0xf9, 0xce, 0x5d, 0xd5, 0x61, 0x29, 0xf5, 0xbe, 0x0d, 0x82, 0x72, 0x45, 0x0f, 0x24, 0xb3, 0x34, 0x1b, 0x99, 0xea, 0x09, 0xf3, 0x03 };
static const UINT8 xor2[0x20] = { 0x2b, 0x09, 0xd0, 0x7f, 0x51, 0x0b, 0x10, 0x4c, 0x5b, 0x07, 0x70, 0x9d, 0x3e, 0x0b, 0xb0, 0xb6, 0x54, 0x09, 0xe0, 0xcc, 0x3d, 0x0d, 0x80, 0x99, 0x87, 0x03, 0x90, 0x82, 0xfe, 0x04, 0x20, 0x18 }; static const UINT8 xor2[0x20] = { 0x2b, 0x09, 0xd0, 0x7f, 0x51, 0x0b, 0x10, 0x4c, 0x5b, 0x07, 0x70, 0x9d, 0x3e, 0x0b, 0xb0, 0xb6, 0x54, 0x09, 0xe0, 0xcc, 0x3d, 0x0d, 0x80, 0x99, 0x87, 0x03, 0x90, 0x82, 0xfe, 0x04, 0x20, 0x18 };
int i; int i;
int ofst; int ofst;
int rom_size = 0x900000; int rom_size = 0x900000;
UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); UINT8 *rom = memregion( "maincpu" )->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size );
for (i = 0; i < 0x100000; i++) for (i = 0; i < 0x100000; i++)
{ {
@ -1455,7 +1444,7 @@ void kof2003h_decrypt_68k(running_machine &machine)
memcpy (&rom[0x000000], &buf[0x000000], 0x100000); memcpy (&rom[0x000000], &buf[0x000000], 0x100000);
memcpy (&rom[0x100000], &buf[0x800000], 0x100000); memcpy (&rom[0x100000], &buf[0x800000], 0x100000);
memcpy (&rom[0x200000], &buf[0x100000], 0x700000); memcpy (&rom[0x200000], &buf[0x100000], 0x700000);
auto_free( machine, buf ); auto_free( machine(), buf );
} }
@ -1467,15 +1456,15 @@ NeoGeo 'V' (PCM) ROM encryption
***************************************************************************/ ***************************************************************************/
/* Neo-Pcm2 Drivers for Encrypted V Roms */ /* Neo-Pcm2 Drivers for Encrypted V Roms */
void neo_pcm2_snk_1999(running_machine &machine, int value) void neogeo_state::neo_pcm2_snk_1999(int value)
{ /* thanks to Elsemi for the NEO-PCM2 info */ { /* thanks to Elsemi for the NEO-PCM2 info */
UINT16 *rom = (UINT16 *)machine.root_device().memregion("ymsnd")->base(); UINT16 *rom = (UINT16 *)memregion("ymsnd")->base();
int size = machine.root_device().memregion("ymsnd")->bytes(); int size = memregion("ymsnd")->bytes();
int i, j; int i, j;
if( rom != NULL ) if( rom != NULL )
{ /* swap address lines on the whole ROMs */ { /* swap address lines on the whole ROMs */
UINT16 *buffer = auto_alloc_array(machine, UINT16, value / 2); UINT16 *buffer = auto_alloc_array(machine(), UINT16, value / 2);
for( i = 0; i < size / 2; i += ( value / 2 ) ) for( i = 0; i < size / 2; i += ( value / 2 ) )
{ {
@ -1485,13 +1474,13 @@ void neo_pcm2_snk_1999(running_machine &machine, int value)
rom[ i + j ] = buffer[ j ^ (value/4) ]; rom[ i + j ] = buffer[ j ^ (value/4) ];
} }
} }
auto_free(machine, buffer); auto_free(machine(), buffer);
} }
} }
/* the later PCM2 games have additional scrambling */ /* the later PCM2 games have additional scrambling */
void neo_pcm2_swap(running_machine &machine, int value) void neogeo_state::neo_pcm2_swap(int value)
{ {
static const UINT32 addrs[7][2]={ static const UINT32 addrs[7][2]={
{0x000000,0xa5000}, {0x000000,0xa5000},
@ -1509,8 +1498,8 @@ void neo_pcm2_swap(running_machine &machine, int value)
{0xcb,0x29,0x7d,0x43,0xd2,0x3a,0xc2,0xb4}, {0xcb,0x29,0x7d,0x43,0xd2,0x3a,0xc2,0xb4},
{0x4b,0xa4,0x63,0x46,0xf0,0x91,0xea,0x62}, {0x4b,0xa4,0x63,0x46,0xf0,0x91,0xea,0x62},
{0x4b,0xa4,0x63,0x46,0xf0,0x91,0xea,0x62}}; {0x4b,0xa4,0x63,0x46,0xf0,0x91,0xea,0x62}};
UINT8 *src = machine.root_device().memregion("ymsnd")->base(); UINT8 *src = memregion("ymsnd")->base();
UINT8 *buf = auto_alloc_array(machine, UINT8, 0x1000000); UINT8 *buf = auto_alloc_array(machine(), UINT8, 0x1000000);
int i, j, d; int i, j, d;
memcpy(buf,src,0x1000000); memcpy(buf,src,0x1000000);
@ -1521,7 +1510,7 @@ void neo_pcm2_swap(running_machine &machine, int value)
d=((i+addrs[value][0])&0xffffff); d=((i+addrs[value][0])&0xffffff);
src[j]=buf[d]^xordata[value][j&0x7]; src[j]=buf[d]^xordata[value][j&0x7];
} }
auto_free(machine, buf); auto_free(machine(), buf);
} }
@ -1533,7 +1522,7 @@ NeoGeo 'SP1' (BIOS) ROM encryption
/* only found on kf2k3pcb */ /* only found on kf2k3pcb */
void kof2003biosdecode(running_machine &machine) void neogeo_state::kof2003biosdecode()
{ {
static const UINT8 address[0x80]={ static const UINT8 address[0x80]={
0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3, 0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3,
@ -1553,8 +1542,8 @@ void kof2003biosdecode(running_machine &machine)
0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9, 0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9,
0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9, 0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9,
}; };
UINT16*src= (UINT16*)machine.root_device().memregion( "mainbios" )->base(); UINT16*src= (UINT16*)memregion( "mainbios" )->base();
UINT16*buf= auto_alloc_array(machine, UINT16, 0x80000/2); UINT16*buf= auto_alloc_array(machine(), UINT16, 0x80000/2);
int a,addr; int a,addr;
for (a=0;a<0x80000/2;a++) for (a=0;a<0x80000/2;a++)
@ -1574,5 +1563,5 @@ void kof2003biosdecode(running_machine &machine)
buf[addr]=src[a]; buf[addr]=src[a];
} }
memcpy(src,buf,0x80000); memcpy(src,buf,0x80000);
auto_free(machine, buf); auto_free(machine(), buf);
} }

View File

@ -22,10 +22,9 @@
/************************ Fatal Fury 2 *************************/ /************************ Fatal Fury 2 *************************/
static READ16_HANDLER( fatfury2_protection_16_r ) READ16_MEMBER( neogeo_state::fatfury2_protection_16_r )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>(); UINT16 res = m_fatfury2_prot_data >> 24;
UINT16 res = state->m_fatfury2_prot_data >> 24;
switch (offset) switch (offset)
{ {
@ -48,34 +47,32 @@ static READ16_HANDLER( fatfury2_protection_16_r )
} }
static WRITE16_HANDLER( fatfury2_protection_16_w ) WRITE16_MEMBER( neogeo_state::fatfury2_protection_16_w )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>();
switch (offset) switch (offset)
{ {
case 0x11112/2: /* data == 0x1111; expects 0xff000000 back */ case 0x11112/2: /* data == 0x1111; expects 0xff000000 back */
state->m_fatfury2_prot_data = 0xff000000; m_fatfury2_prot_data = 0xff000000;
break; break;
case 0x33332/2: /* data == 0x3333; expects 0x0000ffff back */ case 0x33332/2: /* data == 0x3333; expects 0x0000ffff back */
state->m_fatfury2_prot_data = 0x0000ffff; m_fatfury2_prot_data = 0x0000ffff;
break; break;
case 0x44442/2: /* data == 0x4444; expects 0x00ff0000 back */ case 0x44442/2: /* data == 0x4444; expects 0x00ff0000 back */
state->m_fatfury2_prot_data = 0x00ff0000; m_fatfury2_prot_data = 0x00ff0000;
break; break;
case 0x55552/2: /* data == 0x5555; read back from 55550, ffff0, 00000, ff000 */ case 0x55552/2: /* data == 0x5555; read back from 55550, ffff0, 00000, ff000 */
state->m_fatfury2_prot_data = 0xff00ff00; m_fatfury2_prot_data = 0xff00ff00;
break; break;
case 0x56782/2: /* data == 0x1234; read back from 36000 *or* 36004 */ case 0x56782/2: /* data == 0x1234; read back from 36000 *or* 36004 */
state->m_fatfury2_prot_data = 0xf05a3601; m_fatfury2_prot_data = 0xf05a3601;
break; break;
case 0x42812/2: /* data == 0x1824; read back from 36008 *or* 3600c */ case 0x42812/2: /* data == 0x1824; read back from 36008 *or* 3600c */
state->m_fatfury2_prot_data = 0x81422418; m_fatfury2_prot_data = 0x81422418;
break; break;
case 0x55550/2: case 0x55550/2:
@ -85,7 +82,7 @@ static WRITE16_HANDLER( fatfury2_protection_16_w )
case 0x36004/2: case 0x36004/2:
case 0x36008/2: case 0x36008/2:
case 0x3600c/2: case 0x3600c/2:
state->m_fatfury2_prot_data <<= 8; m_fatfury2_prot_data <<= 8;
break; break;
default: default:
@ -95,17 +92,15 @@ static WRITE16_HANDLER( fatfury2_protection_16_w )
} }
void fatfury2_install_protection( running_machine &machine ) void neogeo_state::fatfury2_install_protection()
{ {
neogeo_state *state = machine.driver_data<neogeo_state>();
/* the protection involves reading and writing addresses in the */ /* the protection involves reading and writing addresses in the */
/* 0x2xxxxx range. There are several checks all around the code. */ /* 0x2xxxxx range. There are several checks all around the code. */
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x200000, 0x2fffff, FUNC(fatfury2_protection_16_r), FUNC(fatfury2_protection_16_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x200000, 0x2fffff, read16_delegate(FUNC(neogeo_state::fatfury2_protection_16_r),this), write16_delegate(FUNC(neogeo_state::fatfury2_protection_16_w),this));
state->m_fatfury2_prot_data = 0; m_fatfury2_prot_data = 0;
state->save_item(NAME(state->m_fatfury2_prot_data)); save_item(NAME(m_fatfury2_prot_data));
} }
@ -116,10 +111,10 @@ void fatfury2_install_protection( running_machine &machine )
The board has a ALTERA (EPM7128SQC100-15) chip which is tied to 242-P1 The board has a ALTERA (EPM7128SQC100-15) chip which is tied to 242-P1
***************************************************************/ ***************************************************************/
static WRITE16_HANDLER ( kof98_prot_w ) WRITE16_MEMBER( neogeo_state::kof98_prot_w )
{ {
/* info from razoola */ /* info from razoola */
UINT16* mem16 = (UINT16*)space.machine().root_device().memregion("maincpu")->base(); UINT16* mem16 = (UINT16*)memregion("maincpu")->base();
switch (data) switch (data)
{ {
@ -142,11 +137,11 @@ static WRITE16_HANDLER ( kof98_prot_w )
} }
void install_kof98_protection( running_machine &machine ) void neogeo_state::install_kof98_protection()
{ {
/* when 0x20aaaa contains 0x0090 (word) then 0x100 (normally the neogeo header) should return 0x00c200fd worked out using real hw */ /* when 0x20aaaa contains 0x0090 (word) then 0x100 (normally the neogeo header) should return 0x00c200fd worked out using real hw */
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x20aaaa, 0x20aaab, FUNC(kof98_prot_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x20aaaa, 0x20aaab, write16_delegate(FUNC(neogeo_state::kof98_prot_w),this));
} }
@ -156,27 +151,25 @@ void install_kof98_protection( running_machine &machine )
Also found on this special board is a QFP144 labeled with 0103 Also found on this special board is a QFP144 labeled with 0103
***************************************************************/ ***************************************************************/
static WRITE16_HANDLER( mslugx_protection_16_w ) WRITE16_MEMBER( neogeo_state::mslugx_protection_16_w )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>();
switch (offset) switch (offset)
{ {
case 0x0/2: // start new read? case 0x0/2: // start new read?
state->m_mslugx_command = 0; m_mslugx_command = 0;
break; break;
case 0x2/2: // command? These are pulsed with data and then 0 case 0x2/2: // command? These are pulsed with data and then 0
case 0x4/2: case 0x4/2:
state->m_mslugx_command |= data; m_mslugx_command |= data;
break; break;
case 0x6/2: // finished? case 0x6/2: // finished?
break; break;
case 0xa/2: // init? case 0xa/2: // init?
state->m_mslugx_counter = 0; m_mslugx_counter = 0;
state->m_mslugx_command = 0; m_mslugx_command = 0;
break; break;
default: default:
@ -186,17 +179,15 @@ static WRITE16_HANDLER( mslugx_protection_16_w )
} }
static READ16_HANDLER( mslugx_protection_16_r ) READ16_MEMBER( neogeo_state::mslugx_protection_16_r )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>();
UINT16 res = 0; UINT16 res = 0;
switch (state->m_mslugx_command) switch (m_mslugx_command)
{ {
case 0x0001: { // $3bdc(?) and $3c30 (Register D7) case 0x0001: { // $3bdc(?) and $3c30 (Register D7)
res = (space.read_byte(0xdedd2 + ((state->m_mslugx_counter >> 3) & 0xfff)) >> (~state->m_mslugx_counter & 0x07)) & 1; res = (space.read_byte(0xdedd2 + ((m_mslugx_counter >> 3) & 0xfff)) >> (~m_mslugx_counter & 0x07)) & 1;
state->m_mslugx_counter++; m_mslugx_counter++;
} }
break; break;
@ -215,14 +206,12 @@ static READ16_HANDLER( mslugx_protection_16_r )
} }
void mslugx_install_protection( running_machine &machine ) void neogeo_state::mslugx_install_protection()
{ {
neogeo_state *state = machine.driver_data<neogeo_state>(); machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2fffe0, 0x2fffef, read16_delegate(FUNC(neogeo_state::mslugx_protection_16_r),this), write16_delegate(FUNC(neogeo_state::mslugx_protection_16_w),this));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2fffe0, 0x2fffef, FUNC(mslugx_protection_16_r), FUNC(mslugx_protection_16_w)); save_item(NAME(m_mslugx_command));
save_item(NAME(m_mslugx_counter));
state->save_item(NAME(state->m_mslugx_command));
state->save_item(NAME(state->m_mslugx_counter));
} }
@ -230,7 +219,7 @@ void mslugx_install_protection( running_machine &machine )
thanks to Razoola thanks to Razoola
***************************************************************/ ***************************************************************/
static WRITE16_HANDLER( kof99_bankswitch_w ) WRITE16_MEMBER( neogeo_state::kof99_bankswitch_w )
{ {
int bankaddress; int bankaddress;
static const int bankoffset[64] = static const int bankoffset[64] =
@ -257,11 +246,11 @@ static WRITE16_HANDLER( kof99_bankswitch_w )
bankaddress = 0x100000 + bankoffset[data]; bankaddress = 0x100000 + bankoffset[data];
space.machine().driver_data<neogeo_state>()->neogeo_set_main_cpu_bank_address(bankaddress); neogeo_set_main_cpu_bank_address(bankaddress);
} }
static WRITE16_HANDLER( garou_bankswitch_w ) WRITE16_MEMBER( neogeo_state::garou_bankswitch_w )
{ {
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
int bankaddress; int bankaddress;
@ -294,11 +283,11 @@ static WRITE16_HANDLER( garou_bankswitch_w )
bankaddress = 0x100000 + bankoffset[data]; bankaddress = 0x100000 + bankoffset[data];
space.machine().driver_data<neogeo_state>()->neogeo_set_main_cpu_bank_address(bankaddress); neogeo_set_main_cpu_bank_address(bankaddress);
} }
static WRITE16_HANDLER( garouh_bankswitch_w ) WRITE16_MEMBER( neogeo_state::garouh_bankswitch_w )
{ {
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
int bankaddress; int bankaddress;
@ -333,11 +322,11 @@ static WRITE16_HANDLER( garouh_bankswitch_w )
bankaddress = 0x100000 + bankoffset[data]; bankaddress = 0x100000 + bankoffset[data];
space.machine().driver_data<neogeo_state>()->neogeo_set_main_cpu_bank_address(bankaddress); neogeo_set_main_cpu_bank_address(bankaddress);
} }
static WRITE16_HANDLER( mslug3_bankswitch_w ) WRITE16_MEMBER( neogeo_state::mslug3_bankswitch_w )
{ {
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
int bankaddress; int bankaddress;
@ -369,11 +358,11 @@ static WRITE16_HANDLER( mslug3_bankswitch_w )
bankaddress = 0x100000 + bankoffset[data]; bankaddress = 0x100000 + bankoffset[data];
space.machine().driver_data<neogeo_state>()->neogeo_set_main_cpu_bank_address(bankaddress); neogeo_set_main_cpu_bank_address(bankaddress);
} }
static WRITE16_HANDLER( kof2000_bankswitch_w ) WRITE16_MEMBER( neogeo_state::kof2000_bankswitch_w )
{ {
/* thanks to Razoola and Mr K for the info */ /* thanks to Razoola and Mr K for the info */
int bankaddress; int bankaddress;
@ -401,11 +390,11 @@ static WRITE16_HANDLER( kof2000_bankswitch_w )
bankaddress = 0x100000 + bankoffset[data]; bankaddress = 0x100000 + bankoffset[data];
space.machine().driver_data<neogeo_state>()->neogeo_set_main_cpu_bank_address(bankaddress); neogeo_set_main_cpu_bank_address(bankaddress);
} }
static READ16_HANDLER( prot_9a37_r ) READ16_MEMBER( neogeo_state::prot_9a37_r )
{ {
return 0x9a37; return 0x9a37;
} }
@ -414,85 +403,82 @@ static READ16_HANDLER( prot_9a37_r )
/* information about the sma random number generator provided by razoola */ /* information about the sma random number generator provided by razoola */
/* this RNG is correct for KOF99, other games might be different */ /* this RNG is correct for KOF99, other games might be different */
static READ16_HANDLER( sma_random_r ) READ16_MEMBER( neogeo_state::sma_random_r )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>(); UINT16 old = m_neogeo_rng;
UINT16 old = state->m_neogeo_rng;
UINT16 newbit = ((state->m_neogeo_rng >> 2) ^ UINT16 newbit = ((m_neogeo_rng >> 2) ^
(state->m_neogeo_rng >> 3) ^ (m_neogeo_rng >> 3) ^
(state->m_neogeo_rng >> 5) ^ (m_neogeo_rng >> 5) ^
(state->m_neogeo_rng >> 6) ^ (m_neogeo_rng >> 6) ^
(state->m_neogeo_rng >> 7) ^ (m_neogeo_rng >> 7) ^
(state->m_neogeo_rng >>11) ^ (m_neogeo_rng >>11) ^
(state->m_neogeo_rng >>12) ^ (m_neogeo_rng >>12) ^
(state->m_neogeo_rng >>15)) & 1; (m_neogeo_rng >>15)) & 1;
state->m_neogeo_rng = (state->m_neogeo_rng << 1) | newbit; m_neogeo_rng = (m_neogeo_rng << 1) | newbit;
return old; return old;
} }
void neogeo_reset_rng( running_machine &machine ) void neogeo_state::neogeo_reset_rng()
{ {
neogeo_state *state = machine.driver_data<neogeo_state>(); m_neogeo_rng = 0x2345;
state->m_neogeo_rng = 0x2345;
} }
static void sma_install_random_read_handler( running_machine &machine, int addr1, int addr2 ) void neogeo_state::sma_install_random_read_handler(int addr1, int addr2 )
{ {
neogeo_state *state = machine.driver_data<neogeo_state>(); save_item(NAME(m_neogeo_rng));
state->save_item(NAME(state->m_neogeo_rng));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(addr1, addr1 + 1, FUNC(sma_random_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(addr1, addr1 + 1, read16_delegate(FUNC(neogeo_state::sma_random_r),this));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(addr2, addr2 + 1, FUNC(sma_random_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(addr2, addr2 + 1, read16_delegate(FUNC(neogeo_state::sma_random_r),this));
} }
void kof99_install_protection( running_machine &machine ) void neogeo_state::kof99_install_protection()
{ {
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x2ffff0, 0x2ffff1, FUNC(kof99_bankswitch_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x2ffff0, 0x2ffff1, write16_delegate(FUNC(neogeo_state::kof99_bankswitch_w),this));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x2fe446, 0x2fe447, read16_delegate(FUNC(neogeo_state::prot_9a37_r),this));
sma_install_random_read_handler(machine, 0x2ffff8, 0x2ffffa); sma_install_random_read_handler(0x2ffff8, 0x2ffffa);
} }
void garou_install_protection( running_machine &machine ) void neogeo_state::garou_install_protection()
{ {
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x2fffc0, 0x2fffc1, FUNC(garou_bankswitch_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x2fffc0, 0x2fffc1, write16_delegate(FUNC(neogeo_state::garou_bankswitch_w),this));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x2fe446, 0x2fe447, read16_delegate(FUNC(neogeo_state::prot_9a37_r),this));
sma_install_random_read_handler(machine, 0x2fffcc, 0x2ffff0); sma_install_random_read_handler(0x2fffcc, 0x2ffff0);
} }
void garouh_install_protection( running_machine &machine ) void neogeo_state::garouh_install_protection()
{ {
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x2fffc0, 0x2fffc1, FUNC(garouh_bankswitch_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x2fffc0, 0x2fffc1, write16_delegate(FUNC(neogeo_state::garouh_bankswitch_w),this));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x2fe446, 0x2fe447, read16_delegate(FUNC(neogeo_state::prot_9a37_r),this));
sma_install_random_read_handler(machine, 0x2fffcc, 0x2ffff0); sma_install_random_read_handler(0x2fffcc, 0x2ffff0);
} }
void mslug3_install_protection( running_machine &machine ) void neogeo_state::mslug3_install_protection()
{ {
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x2fffe4, 0x2fffe5, FUNC(mslug3_bankswitch_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x2fffe4, 0x2fffe5, write16_delegate(FUNC(neogeo_state::mslug3_bankswitch_w),this));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x2fe446, 0x2fe447, read16_delegate(FUNC(neogeo_state::prot_9a37_r),this));
// sma_install_random_read_handler(machine, 0x2ffff8, 0x2ffffa); // sma_install_random_read_handler(0x2ffff8, 0x2ffffa);
} }
void kof2000_install_protection( running_machine &machine ) void neogeo_state::kof2000_install_protection()
{ {
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x2fffec, 0x2fffed, FUNC(kof2000_bankswitch_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x2fffec, 0x2fffed, write16_delegate(FUNC(neogeo_state::kof2000_bankswitch_w),this));
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x2fe446, 0x2fe447, read16_delegate(FUNC(neogeo_state::prot_9a37_r),this));
sma_install_random_read_handler(machine, 0x2fffd8, 0x2fffda); sma_install_random_read_handler(0x2fffd8, 0x2fffda);
} }
@ -501,85 +487,78 @@ void kof2000_install_protection( running_machine &machine )
mslug5, svcchaos, kof2003 mslug5, svcchaos, kof2003
***************************************************************/ ***************************************************************/
static void pvc_w8( running_machine &machine, offs_t offset, UINT8 data ) void neogeo_state::pvc_w8(offs_t offset, UINT8 data )
{ {
neogeo_state *state = machine.driver_data<neogeo_state>(); *(((UINT8*)m_pvc_cartridge_ram) + BYTE_XOR_LE(offset)) = data;
*(((UINT8*)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(offset)) = data;
} }
static UINT8 pvc_r8( running_machine &machine, offs_t offset ) UINT8 neogeo_state::pvc_r8(offs_t offset )
{ {
neogeo_state *state = machine.driver_data<neogeo_state>(); return *(((UINT8*)m_pvc_cartridge_ram) + BYTE_XOR_LE(offset));
return *(((UINT8*)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(offset));
} }
static void pvc_prot1( running_machine &machine ) void neogeo_state::pvc_prot1()
{ {
UINT8 b1, b2; UINT8 b1, b2;
b1 = pvc_r8(machine, 0x1fe1); b1 = pvc_r8(0x1fe1);
b2 = pvc_r8(machine, 0x1fe0); b2 = pvc_r8(0x1fe0);
pvc_w8(machine, 0x1fe2, (((b2 >> 0) & 0xf) << 1) | ((b1 >> 4) & 1)); pvc_w8(0x1fe2, (((b2 >> 0) & 0xf) << 1) | ((b1 >> 4) & 1));
pvc_w8(machine, 0x1fe3, (((b2 >> 4) & 0xf) << 1) | ((b1 >> 5) & 1)); pvc_w8(0x1fe3, (((b2 >> 4) & 0xf) << 1) | ((b1 >> 5) & 1));
pvc_w8(machine, 0x1fe4, (((b1 >> 0) & 0xf) << 1) | ((b1 >> 6) & 1)); pvc_w8(0x1fe4, (((b1 >> 0) & 0xf) << 1) | ((b1 >> 6) & 1));
pvc_w8(machine, 0x1fe5, (b1 >> 7)); pvc_w8(0x1fe5, (b1 >> 7));
} }
static void pvc_prot2( running_machine &machine ) // on writes to e8/e9/ea/eb void neogeo_state::pvc_prot2() // on writes to e8/e9/ea/eb
{ {
UINT8 b1, b2, b3, b4; UINT8 b1, b2, b3, b4;
b1 = pvc_r8(machine, 0x1fe9); b1 = pvc_r8(0x1fe9);
b2 = pvc_r8(machine, 0x1fe8); b2 = pvc_r8(0x1fe8);
b3 = pvc_r8(machine, 0x1feb); b3 = pvc_r8(0x1feb);
b4 = pvc_r8(machine, 0x1fea); b4 = pvc_r8(0x1fea);
pvc_w8(machine, 0x1fec, (b2 >> 1) | ((b1 >> 1) << 4)); pvc_w8(0x1fec, (b2 >> 1) | ((b1 >> 1) << 4));
pvc_w8(machine, 0x1fed, (b4 >> 1) | ((b2 & 1) << 4) | ((b1 & 1) << 5) | ((b4 & 1) << 6) | ((b3 & 1) << 7)); pvc_w8(0x1fed, (b4 >> 1) | ((b2 & 1) << 4) | ((b1 & 1) << 5) | ((b4 & 1) << 6) | ((b3 & 1) << 7));
} }
static void pvc_write_bankswitch( address_space &space ) void neogeo_state::pvc_write_bankswitch( address_space &space )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>();
UINT32 bankaddress; UINT32 bankaddress;
bankaddress = ((state->m_pvc_cartridge_ram[0xff8] >> 8)|(state->m_pvc_cartridge_ram[0xff9] << 8)); bankaddress = ((m_pvc_cartridge_ram[0xff8] >> 8)|(m_pvc_cartridge_ram[0xff9] << 8));
*(((UINT8 *)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff0)) = 0xa0; *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff0)) = 0xa0;
*(((UINT8 *)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff1)) &= 0xfe; *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff1)) &= 0xfe;
*(((UINT8 *)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff3)) &= 0x7f; *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff3)) &= 0x7f;
state->neogeo_set_main_cpu_bank_address(bankaddress + 0x100000); neogeo_set_main_cpu_bank_address(bankaddress + 0x100000);
} }
static READ16_HANDLER( pvc_prot_r ) READ16_MEMBER( neogeo_state::pvc_prot_r )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>(); return m_pvc_cartridge_ram[offset];
return state->m_pvc_cartridge_ram[offset];
} }
static WRITE16_HANDLER( pvc_prot_w ) WRITE16_MEMBER( neogeo_state::pvc_prot_w )
{ {
neogeo_state *state = space.machine().driver_data<neogeo_state>(); COMBINE_DATA(&m_pvc_cartridge_ram[offset] );
COMBINE_DATA(&state->m_pvc_cartridge_ram[offset] );
if (offset == 0xff0) if (offset == 0xff0)
pvc_prot1(space.machine()); pvc_prot1();
else if(offset >= 0xff4 && offset <= 0xff5) else if(offset >= 0xff4 && offset <= 0xff5)
pvc_prot2(space.machine()); pvc_prot2();
else if(offset >= 0xff8) else if(offset >= 0xff8)
pvc_write_bankswitch(space); pvc_write_bankswitch(space);
} }
void install_pvc_protection( running_machine &machine ) void neogeo_state::install_pvc_protection()
{ {
neogeo_state *state = machine.driver_data<neogeo_state>(); m_pvc_cartridge_ram = auto_alloc_array(machine(), UINT16, 0x2000 / 2);
state->m_pvc_cartridge_ram = auto_alloc_array(machine, UINT16, 0x2000 / 2); save_pointer(NAME(m_pvc_cartridge_ram), 0x2000 / 2);
state->save_pointer(NAME(state->m_pvc_cartridge_ram), 0x2000 / 2);
machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2fe000, 0x2fffff, FUNC(pvc_prot_r), FUNC(pvc_prot_w)); machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2fe000, 0x2fffff, read16_delegate(FUNC(neogeo_state::pvc_prot_r),this), write16_delegate(FUNC(neogeo_state::pvc_prot_w),this));
} }

View File

@ -1175,7 +1175,7 @@ MACHINE_RESET_MEMBER(ng_aes_state,neogeo)
m_maincpu->reset(); m_maincpu->reset();
neogeo_reset_rng(machine()); neogeo_reset_rng();
start_interrupt_timers(); start_interrupt_timers();