diff --git a/src/mame/drivers/neodrvr.c b/src/mame/drivers/neodrvr.c index 3aa44f13e86..6adc221258d 100644 --- a/src/mame/drivers/neodrvr.c +++ b/src/mame/drivers/neodrvr.c @@ -9289,324 +9289,324 @@ INPUT_PORTS_END DRIVER_INIT_MEMBER(neogeo_state,fatfury2) { DRIVER_INIT_CALL(neogeo); - fatfury2_install_protection(machine()); + fatfury2_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,zupapa) { DRIVER_INIT_CALL(neogeo); 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_CALL(neogeo); - kof98_decrypt_68k(machine()); - install_kof98_protection(machine()); + kof98_decrypt_68k(); + install_kof98_protection(); } DRIVER_INIT_MEMBER(neogeo_state,mslugx) { DRIVER_INIT_CALL(neogeo); - mslugx_install_protection(machine()); + mslugx_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kof99) { DRIVER_INIT_CALL(neogeo); - kof99_decrypt_68k(machine()); + kof99_decrypt_68k(); m_fixed_layer_bank_type = 1; - kof99_neogeo_gfx_decrypt(machine(), 0x00); - kof99_install_protection(machine()); + kof99_neogeo_gfx_decrypt(0x00); + kof99_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kof99k) { DRIVER_INIT_CALL(neogeo); 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_CALL(neogeo); - garou_decrypt_68k(machine()); + garou_decrypt_68k(); m_fixed_layer_bank_type = 1; - kof99_neogeo_gfx_decrypt(machine(), 0x06); - garou_install_protection(machine()); + kof99_neogeo_gfx_decrypt(0x06); + garou_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,garouh) { DRIVER_INIT_CALL(neogeo); - garouh_decrypt_68k(machine()); + garouh_decrypt_68k(); m_fixed_layer_bank_type = 1; - kof99_neogeo_gfx_decrypt(machine(), 0x06); - garouh_install_protection(machine()); + kof99_neogeo_gfx_decrypt(0x06); + garouh_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,garoubl) { DRIVER_INIT_CALL(neogeo); - neogeo_bootleg_sx_decrypt(machine(), 2); - neogeo_bootleg_cx_decrypt(machine()); + neogeo_bootleg_sx_decrypt(2); + neogeo_bootleg_cx_decrypt(); } DRIVER_INIT_MEMBER(neogeo_state,mslug3) { DRIVER_INIT_CALL(neogeo); - mslug3_decrypt_68k(machine()); + mslug3_decrypt_68k(); m_fixed_layer_bank_type = 1; - kof99_neogeo_gfx_decrypt(machine(), 0xad); - mslug3_install_protection(machine()); + kof99_neogeo_gfx_decrypt(0xad); + mslug3_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,mslug3h) { DRIVER_INIT_CALL(neogeo); 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_CALL(neogeo); - neogeo_bootleg_sx_decrypt(machine(), 2); - cmc42_neogeo_gfx_decrypt(machine(), 0xad); + neogeo_bootleg_sx_decrypt(2); + cmc42_neogeo_gfx_decrypt(0xad); } DRIVER_INIT_MEMBER(neogeo_state,kof2000) { DRIVER_INIT_CALL(neogeo); - kof2000_decrypt_68k(machine()); + kof2000_decrypt_68k(); m_fixed_layer_bank_type = 2; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x00); - kof2000_install_protection(machine()); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x00); + kof2000_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kof2000n) { DRIVER_INIT_CALL(neogeo); m_fixed_layer_bank_type = 2; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x00); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x00); } DRIVER_INIT_MEMBER(neogeo_state,kof2001) { DRIVER_INIT_CALL(neogeo); m_fixed_layer_bank_type = 1; - kof2000_neogeo_gfx_decrypt(machine(), 0x1e); - neogeo_cmc50_m1_decrypt(machine()); + kof2000_neogeo_gfx_decrypt(0x1e); + neogeo_cmc50_m1_decrypt(); } DRIVER_INIT_MEMBER(neogeo_state,cthd2003) { DRIVER_INIT_CALL(neogeo); - decrypt_cthd2003(machine()); - patch_cthd2003(machine()); + decrypt_cthd2003(); + patch_cthd2003(); } DRIVER_INIT_MEMBER(neogeo_state,ct2k3sp) { DRIVER_INIT_CALL(neogeo); - decrypt_ct2k3sp(machine()); - patch_cthd2003(machine()); + decrypt_ct2k3sp(); + patch_cthd2003(); } DRIVER_INIT_MEMBER(neogeo_state,ct2k3sa) { DRIVER_INIT_CALL(neogeo); - decrypt_ct2k3sa(machine()); - patch_ct2k3sa(machine()); + decrypt_ct2k3sa(); + patch_ct2k3sa(); } DRIVER_INIT_MEMBER(neogeo_state,mslug4) { DRIVER_INIT_CALL(neogeo); m_fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */ - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x31); - neo_pcm2_snk_1999(machine(), 8); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x31); + neo_pcm2_snk_1999(8); } DRIVER_INIT_MEMBER(neogeo_state,ms4plus) { DRIVER_INIT_CALL(neogeo); - cmc50_neogeo_gfx_decrypt(machine(), 0x31); - neo_pcm2_snk_1999(machine(), 8); - neogeo_cmc50_m1_decrypt(machine()); + cmc50_neogeo_gfx_decrypt(0x31); + neo_pcm2_snk_1999(8); + neogeo_cmc50_m1_decrypt(); } DRIVER_INIT_MEMBER(neogeo_state,ganryu) { DRIVER_INIT_CALL(neogeo); 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_CALL(neogeo); 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_CALL(neogeo); 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_CALL(neogeo); 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_CALL(neogeo); 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_CALL(neogeo); 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_CALL(neogeo); - neo_pcm2_snk_1999(machine(), 16); + neo_pcm2_snk_1999(16); m_fixed_layer_bank_type = 1; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x3f); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x3f); } DRIVER_INIT_MEMBER(neogeo_state,kof2002) { DRIVER_INIT_CALL(neogeo); - kof2002_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 0); - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0xec); + kof2002_decrypt_68k(); + neo_pcm2_swap(0); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0xec); } DRIVER_INIT_MEMBER(neogeo_state,kof2002b) { DRIVER_INIT_CALL(neogeo); - kof2002_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 0); - neogeo_cmc50_m1_decrypt(machine()); - kof2002b_gfx_decrypt(machine(), memregion("sprites")->base(),0x4000000); - kof2002b_gfx_decrypt(machine(), memregion("fixed")->base(),0x20000); + kof2002_decrypt_68k(); + neo_pcm2_swap(0); + neogeo_cmc50_m1_decrypt(); + kof2002b_gfx_decrypt(memregion("sprites")->base(),0x4000000); + kof2002b_gfx_decrypt(memregion("fixed")->base(),0x20000); } DRIVER_INIT_MEMBER(neogeo_state,kf2k2pls) { DRIVER_INIT_CALL(neogeo); - kof2002_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 0); - neogeo_cmc50_m1_decrypt(machine()); - cmc50_neogeo_gfx_decrypt(machine(), 0xec); + kof2002_decrypt_68k(); + neo_pcm2_swap(0); + neogeo_cmc50_m1_decrypt(); + cmc50_neogeo_gfx_decrypt(0xec); } DRIVER_INIT_MEMBER(neogeo_state,kf2k2mp) { DRIVER_INIT_CALL(neogeo); - kf2k2mp_decrypt(machine()); - neo_pcm2_swap(machine(), 0); - neogeo_cmc50_m1_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 2); - cmc50_neogeo_gfx_decrypt(machine(), 0xec); + kf2k2mp_decrypt(); + neo_pcm2_swap(0); + neogeo_cmc50_m1_decrypt(); + neogeo_bootleg_sx_decrypt(2); + cmc50_neogeo_gfx_decrypt(0xec); } DRIVER_INIT_MEMBER(neogeo_state,kf2k2mp2) { DRIVER_INIT_CALL(neogeo); - kf2k2mp2_px_decrypt(machine()); - neo_pcm2_swap(machine(), 0); - neogeo_cmc50_m1_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 1); - cmc50_neogeo_gfx_decrypt(machine(), 0xec); + kf2k2mp2_px_decrypt(); + neo_pcm2_swap(0); + neogeo_cmc50_m1_decrypt(); + neogeo_bootleg_sx_decrypt(1); + cmc50_neogeo_gfx_decrypt(0xec); } DRIVER_INIT_MEMBER(neogeo_state,kof10th) { DRIVER_INIT_CALL(neogeo); - decrypt_kof10th(machine()); - install_kof10th_protection(machine()); + decrypt_kof10th(); + install_kof10th_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kf10thep) { DRIVER_INIT_CALL(neogeo); - decrypt_kf10thep(machine()); + decrypt_kf10thep(); } DRIVER_INIT_MEMBER(neogeo_state,kf2k5uni) { DRIVER_INIT_CALL(neogeo); - decrypt_kf2k5uni(machine()); + decrypt_kf2k5uni(); } DRIVER_INIT_MEMBER(neogeo_state,kof2k4se) { DRIVER_INIT_CALL(neogeo); - decrypt_kof2k4se_68k(machine()); + decrypt_kof2k4se_68k(); } DRIVER_INIT_MEMBER(neogeo_state,matrim) { DRIVER_INIT_CALL(neogeo); - matrim_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 1); + matrim_decrypt_68k(); + neo_pcm2_swap(1); m_fixed_layer_bank_type = 2; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x6a); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x6a); } DRIVER_INIT_MEMBER(neogeo_state,matrimbl) { DRIVER_INIT_CALL(neogeo); - matrim_decrypt_68k(machine()); + matrim_decrypt_68k(); m_fixed_layer_bank_type = 2; - matrimbl_decrypt(machine()); - neogeo_sfix_decrypt(machine()); /* required for text layer */ + matrimbl_decrypt(); + neogeo_sfix_decrypt(); /* required for text layer */ } DRIVER_INIT_MEMBER(neogeo_state,pnyaa) { DRIVER_INIT_CALL(neogeo); - neo_pcm2_snk_1999(machine(), 4); + neo_pcm2_snk_1999(4); m_fixed_layer_bank_type = 1; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x2e); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x2e); } DRIVER_INIT_MEMBER(neogeo_state,mslug5) { DRIVER_INIT_CALL(neogeo); - mslug5_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 2); + mslug5_decrypt_68k(); + neo_pcm2_swap(2); m_fixed_layer_bank_type = 1; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x19); - install_pvc_protection(machine()); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x19); + 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; - machine.root_device().membank(NEOGEO_BANK_BIOS)->set_base(machine.root_device().memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000); + int harddip3 = ioport("HARDDIP")->read() & 1; + membank(NEOGEO_BANK_BIOS)->set_base(memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000); } DRIVER_INIT_MEMBER(neogeo_state,ms5pcb) @@ -9614,34 +9614,34 @@ DRIVER_INIT_MEMBER(neogeo_state,ms5pcb) DRIVER_INIT_CALL(neogeo); /* 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_pulse(attotime::from_msec(1000), 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), timer_expired_delegate(FUNC(neogeo_state::ms5pcb_bios_timer_callback),this)); - mslug5_decrypt_68k(machine()); - svcpcb_gfx_decrypt(machine()); - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x19); + mslug5_decrypt_68k(); + svcpcb_gfx_decrypt(); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x19); m_fixed_layer_bank_type = 2; - svcpcb_s1data_decrypt(machine()); - neo_pcm2_swap(machine(), 2); - install_pvc_protection(machine()); + svcpcb_s1data_decrypt(); + neo_pcm2_swap(2); + install_pvc_protection(); } DRIVER_INIT_MEMBER(neogeo_state,ms5plus) { DRIVER_INIT_CALL(neogeo); - cmc50_neogeo_gfx_decrypt(machine(), 0x19); - neo_pcm2_swap(machine(), 2); - neogeo_bootleg_sx_decrypt(machine(), 1); + cmc50_neogeo_gfx_decrypt(0x19); + neo_pcm2_swap(2); + neogeo_bootleg_sx_decrypt(1); m_fixed_layer_bank_type = 1; - neogeo_cmc50_m1_decrypt(machine()); - install_ms5plus_protection(machine()); + neogeo_cmc50_m1_decrypt(); + 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; - machine.root_device().membank(NEOGEO_BANK_BIOS)->set_base(machine.root_device().memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000); + int harddip3 = ioport("HARDDIP")->read() & 1; + membank(NEOGEO_BANK_BIOS)->set_base(memregion("mainbios")->base() + 0x20000 + harddip3 * 0x20000); } DRIVER_INIT_MEMBER(neogeo_state,svcpcb) @@ -9649,91 +9649,91 @@ DRIVER_INIT_MEMBER(neogeo_state,svcpcb) DRIVER_INIT_CALL(neogeo); /* 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_pulse(attotime::from_msec(1000), 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), timer_expired_delegate(FUNC(neogeo_state::svcpcb_bios_timer_callback),this)); - svc_px_decrypt(machine()); - svcpcb_gfx_decrypt(machine()); - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x57); - svcpcb_s1data_decrypt(machine()); - neo_pcm2_swap(machine(), 3); + svc_px_decrypt(); + svcpcb_gfx_decrypt(); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x57); + svcpcb_s1data_decrypt(); + neo_pcm2_swap(3); m_fixed_layer_bank_type = 2; - install_pvc_protection(machine()); + install_pvc_protection(); } DRIVER_INIT_MEMBER(neogeo_state,svc) { DRIVER_INIT_CALL(neogeo); - svc_px_decrypt(machine()); - neo_pcm2_swap(machine(), 3); + svc_px_decrypt(); + neo_pcm2_swap(3); m_fixed_layer_bank_type = 2; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x57); - install_pvc_protection(machine()); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x57); + install_pvc_protection(); } DRIVER_INIT_MEMBER(neogeo_state,svcboot) { DRIVER_INIT_CALL(neogeo); - svcboot_px_decrypt(machine()); - svcboot_cx_decrypt(machine()); - install_pvc_protection(machine()); + svcboot_px_decrypt(); + svcboot_cx_decrypt(); + install_pvc_protection(); } DRIVER_INIT_MEMBER(neogeo_state,svcplus) { DRIVER_INIT_CALL(neogeo); - svcplus_px_decrypt(machine()); - svcboot_cx_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 1); - svcplus_px_hack(machine()); + svcplus_px_decrypt(); + svcboot_cx_decrypt(); + neogeo_bootleg_sx_decrypt( 1); + svcplus_px_hack(); } DRIVER_INIT_MEMBER(neogeo_state,svcplusa) { DRIVER_INIT_CALL(neogeo); - svcplusa_px_decrypt(machine()); - svcboot_cx_decrypt(machine()); - svcplus_px_hack(machine()); + svcplusa_px_decrypt(); + svcboot_cx_decrypt(); + svcplus_px_hack(); } DRIVER_INIT_MEMBER(neogeo_state,svcsplus) { DRIVER_INIT_CALL(neogeo); - svcsplus_px_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 2); - svcboot_cx_decrypt(machine()); - svcsplus_px_hack(machine()); - install_pvc_protection(machine()); + svcsplus_px_decrypt(); + neogeo_bootleg_sx_decrypt(2); + svcboot_cx_decrypt(); + svcsplus_px_hack(); + install_pvc_protection(); } DRIVER_INIT_MEMBER(neogeo_state,samsho5) { DRIVER_INIT_CALL(neogeo); - samsho5_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 4); + samsho5_decrypt_68k(); + neo_pcm2_swap(4); m_fixed_layer_bank_type = 1; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x0f); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x0f); } DRIVER_INIT_MEMBER(neogeo_state,samsho5b) { DRIVER_INIT_CALL(neogeo); - samsho5b_px_decrypt(machine()); - samsho5b_vx_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 1); - neogeo_bootleg_cx_decrypt(machine()); + samsho5b_px_decrypt(); + samsho5b_vx_decrypt(); + neogeo_bootleg_sx_decrypt(1); + neogeo_bootleg_cx_decrypt(); } DRIVER_INIT_MEMBER(neogeo_state,kf2k3pcb) { DRIVER_INIT_CALL(neogeo); - kf2k3pcb_decrypt_68k(machine()); - kf2k3pcb_gfx_decrypt(machine()); - kof2003biosdecode(machine()); - neogeo_cmc50_m1_decrypt(machine()); + kf2k3pcb_decrypt_68k(); + kf2k3pcb_gfx_decrypt(); + kof2003biosdecode(); + neogeo_cmc50_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 @@ -9747,81 +9747,81 @@ DRIVER_INIT_MEMBER(neogeo_state,kf2k3pcb) } } - kof2000_neogeo_gfx_decrypt(machine(), 0x9d); - kf2k3pcb_decrypt_s1data(machine()); - neo_pcm2_swap(machine(), 5); + kof2000_neogeo_gfx_decrypt(0x9d); + kf2k3pcb_decrypt_s1data(); + neo_pcm2_swap(5); 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 } DRIVER_INIT_MEMBER(neogeo_state,kof2003) { DRIVER_INIT_CALL(neogeo); - kof2003_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 5); + kof2003_decrypt_68k(); + neo_pcm2_swap(5); m_fixed_layer_bank_type = 2; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x9d); - install_pvc_protection(machine()); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x9d); + install_pvc_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kof2003h) { DRIVER_INIT_CALL(neogeo); - kof2003h_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 5); + kof2003h_decrypt_68k(); + neo_pcm2_swap(5); m_fixed_layer_bank_type = 2; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x9d); - install_pvc_protection(machine()); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x9d); + install_pvc_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kf2k3bl) { DRIVER_INIT_CALL(neogeo); - cmc50_neogeo_gfx_decrypt(machine(), 0x9d); - neo_pcm2_swap(machine(), 5); - neogeo_bootleg_sx_decrypt(machine(), 1); - kf2k3bl_install_protection(machine()); + cmc50_neogeo_gfx_decrypt(0x9d); + neo_pcm2_swap(5); + neogeo_bootleg_sx_decrypt(1); + kf2k3bl_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kf2k3pl) { DRIVER_INIT_CALL(neogeo); - cmc50_neogeo_gfx_decrypt(machine(), 0x9d); - neo_pcm2_swap(machine(), 5); - kf2k3pl_px_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 1); - kf2k3pl_install_protection(machine()); + cmc50_neogeo_gfx_decrypt(0x9d); + neo_pcm2_swap(5); + kf2k3pl_px_decrypt(); + neogeo_bootleg_sx_decrypt(1); + kf2k3pl_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,kf2k3upl) { DRIVER_INIT_CALL(neogeo); - cmc50_neogeo_gfx_decrypt(machine(), 0x9d); - neo_pcm2_swap(machine(), 5); - kf2k3upl_px_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 2); - kf2k3upl_install_protection(machine()); + cmc50_neogeo_gfx_decrypt(0x9d); + neo_pcm2_swap(5); + kf2k3upl_px_decrypt(); + neogeo_bootleg_sx_decrypt(2); + kf2k3upl_install_protection(); } DRIVER_INIT_MEMBER(neogeo_state,samsh5sp) { DRIVER_INIT_CALL(neogeo); - samsh5sp_decrypt_68k(machine()); - neo_pcm2_swap(machine(), 6); + samsh5sp_decrypt_68k(); + neo_pcm2_swap(6); m_fixed_layer_bank_type = 1; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0x0d); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0x0d); } DRIVER_INIT_MEMBER(neogeo_state,jockeygp) { DRIVER_INIT_CALL(neogeo); m_fixed_layer_bank_type = 1; - neogeo_cmc50_m1_decrypt(machine()); - kof2000_neogeo_gfx_decrypt(machine(), 0xac); + neogeo_cmc50_m1_decrypt(); + kof2000_neogeo_gfx_decrypt(0xac); /* install some extra RAM */ 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) { - kof97oro_px_decode(machine()); - neogeo_bootleg_sx_decrypt(machine(), 1); - neogeo_bootleg_cx_decrypt(machine()); + kof97oro_px_decode(); + neogeo_bootleg_sx_decrypt(1); + neogeo_bootleg_cx_decrypt(); DRIVER_INIT_CALL(neogeo); } @@ -9853,24 +9853,24 @@ DRIVER_INIT_MEMBER(neogeo_state,kog) /* overlay cartridge ROM */ machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_port(0x0ffffe, 0x0fffff, "JUMPER"); - kog_px_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 1); - neogeo_bootleg_cx_decrypt(machine()); + kog_px_decrypt(); + neogeo_bootleg_sx_decrypt(1); + neogeo_bootleg_cx_decrypt(); DRIVER_INIT_CALL(neogeo); } DRIVER_INIT_MEMBER(neogeo_state,lans2004) { - lans2004_decrypt_68k(machine()); - lans2004_vx_decrypt(machine()); - neogeo_bootleg_sx_decrypt(machine(), 1); - neogeo_bootleg_cx_decrypt(machine()); + lans2004_decrypt_68k(); + lans2004_vx_decrypt(); + neogeo_bootleg_sx_decrypt(1); + neogeo_bootleg_cx_decrypt(); 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 data = BITSWAP16(origdata, 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4); int realoffset = 0x200+(offset*2); @@ -9882,7 +9882,7 @@ static READ16_HANDLER( sbp_lowerrom_r ) return data; } -static WRITE16_HANDLER( sbp_lowerrom_w ) +WRITE16_MEMBER( neogeo_state::sbp_lowerrom_w ) { int realoffset = 0x200+(offset*2); @@ -9911,8 +9911,8 @@ DRIVER_INIT_MEMBER(neogeo_state,sbp) // 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 - 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_legacy_write_handler(0x00200, 0x001fff, FUNC(sbp_lowerrom_w)); + 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_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? */ { diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index f78fe3f4362..2e6fd813bc7 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -1051,7 +1051,7 @@ void neogeo_state::machine_reset() m_maincpu->reset(); - neogeo_reset_rng(machine()); + neogeo_reset_rng(); start_interrupt_timers(); diff --git a/src/mame/includes/neogeo.h b/src/mame/includes/neogeo.h index 90c4de31269..f6986c87a83 100644 --- a/src/mame/includes/neogeo.h +++ b/src/mame/includes/neogeo.h @@ -263,6 +263,19 @@ public: 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: required_memory_region m_region_maincpu; required_memory_region m_region_sprites; @@ -319,95 +332,130 @@ protected: void set_outputs( ); void set_output_latch( 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 -----------*/ 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); - diff --git a/src/mame/machine/neoboot.c b/src/mame/machine/neoboot.c index 4c7004f1448..06e43417176 100644 --- a/src/mame/machine/neoboot.c +++ b/src/mame/machine/neoboot.c @@ -19,12 +19,12 @@ /* General Bootleg Functions - used by more than 1 game */ -void neogeo_bootleg_cx_decrypt( running_machine &machine ) +void neogeo_state::neogeo_bootleg_cx_decrypt() { int i; - int cx_size = machine.root_device().memregion( "sprites" )->bytes(); - UINT8 *rom = machine.root_device().memregion( "sprites" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, cx_size ); + int cx_size = memregion( "sprites" )->bytes(); + UINT8 *rom = memregion( "sprites" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, cx_size ); memcpy( buf, rom, cx_size ); @@ -32,19 +32,19 @@ void neogeo_bootleg_cx_decrypt( running_machine &machine ) memcpy( &rom[ i * 0x40 ], &buf[ (i ^ 1) * 0x40 ], 0x40 ); } - auto_free( machine, buf ); + auto_free( machine(), buf ); } -void neogeo_bootleg_sx_decrypt( running_machine &machine, int value ) +void neogeo_state::neogeo_bootleg_sx_decrypt(int value ) { - int sx_size = machine.root_device().memregion( "fixed" )->bytes(); - UINT8 *rom = machine.root_device().memregion( "fixed" )->base(); + int sx_size = memregion( "fixed" )->bytes(); + UINT8 *rom = memregion( "fixed" )->base(); int i; if (value == 1) { - UINT8 *buf = auto_alloc_array(machine, UINT8, sx_size ); + UINT8 *buf = auto_alloc_array(machine(), UINT8, sx_size ); memcpy( buf, rom, sx_size ); for( i = 0; i < sx_size; i += 0x10 ) @@ -52,7 +52,7 @@ void neogeo_bootleg_sx_decrypt( running_machine &machine, int value ) memcpy( &rom[ i ], &buf[ i + 8 ], 8 ); memcpy( &rom[ i + 8 ], &buf[ i ], 8 ); } - auto_free( machine, buf ); + auto_free( machine(), buf ); } else if (value == 2) { @@ -68,12 +68,12 @@ void neogeo_bootleg_sx_decrypt( running_machine &machine, int value ) /* The protection patching here may be incomplete Thanks to Razoola for the info */ -void kog_px_decrypt( running_machine &machine ) +void neogeo_state::kog_px_decrypt() { /* the protection chip does some *very* strange things to the rom */ - UINT8 *src = machine.root_device().memregion("maincpu")->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x600000 ); - UINT16 *rom = (UINT16 *)machine.root_device().memregion("maincpu")->base(); + UINT8 *src = memregion("maincpu")->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x600000 ); + UINT16 *rom = (UINT16 *)memregion("maincpu")->base(); int i; static const int sec[] = { 0x3, 0x8, 0x7, 0xC, 0x1, 0xA, 0x6, 0xD }; @@ -87,7 +87,7 @@ void kog_px_decrypt( running_machine &machine ) memcpy (dst + 0x090000, src + 0x040000, 0x004000); memcpy (dst + 0x100000, src + 0x200000, 0x400000); memcpy (src, dst, 0x600000); - auto_free (machine, dst); + auto_free (machine(), dst); for (i = 0x90000/2; i < 0x94000/2; i++){ if (((rom[i]&0xFFBF) == 0x4EB9 || rom[i] == 0x43F9) && !rom[i + 1]) @@ -132,11 +132,11 @@ void kog_px_decrypt( running_machine &machine ) /* The King of Fighters '97 Oroshi Plus 2003 (bootleg) */ -void kof97oro_px_decode( running_machine &machine ) +void neogeo_state::kof97oro_px_decode() { int i; - UINT16 *tmp = auto_alloc_array(machine, UINT16, 0x500000 ); - UINT16 *src = (UINT16*)machine.root_device().memregion("maincpu")->base(); + UINT16 *tmp = auto_alloc_array(machine(), UINT16, 0x500000 ); + UINT16 *src = (UINT16*)memregion("maincpu")->base(); for (i = 0; i < 0x500000/2; i++) { tmp[i] = src[i ^ 0x7ffef]; @@ -144,7 +144,7 @@ void kof97oro_px_decode( running_machine &machine ) memcpy (src, tmp, 0x500000); - auto_free (machine, tmp); + auto_free (machine(), tmp); } @@ -155,57 +155,55 @@ void kof97oro_px_decode( running_machine &machine ) is incomplete, at the moment the S data is copied from the program rom on start-up instead */ -static UINT16 kof10thExtraRAMB[0x01000]; - -static void kof10thBankswitch(address_space &space, UINT16 nBank) +void neogeo_state::kof10thBankswitch(address_space &space, UINT16 nBank) { UINT32 bank = 0x100000 + ((nBank & 7) << 20); if (bank >= 0x700000) bank = 0x100000; - space.machine().driver_data()->neogeo_set_main_cpu_bank_address(bank); + neogeo_set_main_cpu_bank_address(bank); } -static READ16_HANDLER( kof10th_RAMB_r ) +READ16_MEMBER( neogeo_state::kof10th_RAMB_r ) { return kof10thExtraRAMB[offset]; } -static WRITE16_HANDLER( kof10th_custom_w ) +WRITE16_MEMBER( neogeo_state::kof10th_custom_w ) { if (!kof10thExtraRAMB[0xFFE]) { // Write to RAM bank A - UINT16 *prom = (UINT16*)space.machine().root_device().memregion( "maincpu" )->base(); + UINT16 *prom = (UINT16*)memregion( "maincpu" )->base(); COMBINE_DATA(&prom[(0xE0000/2) + (offset & 0xFFFF)]); } else { // Write S data on-the-fly - UINT8 *srom = space.machine().root_device().memregion( "fixed" )->base(); + UINT8 *srom = memregion( "fixed" )->base(); srom[offset] = BITSWAP8(data,7,6,0,4,3,2,1,5); } } -static WRITE16_HANDLER( kof10th_bankswitch_w ) +WRITE16_MEMBER( neogeo_state::kof10th_bankswitch_w ) { if (offset >= 0x5F000) { if (offset == 0x5FFF8) { // Standard bankswitch kof10thBankswitch(space, data); } else if (offset == 0x5FFFC && kof10thExtraRAMB[0xFFC] != data) { // Special bankswitch - UINT8 *src = space.machine().root_device().memregion( "maincpu" )->base(); + UINT8 *src = memregion( "maincpu" )->base(); memcpy (src + 0x10000, src + ((data & 1) ? 0x810000 : 0x710000), 0xcffff); } COMBINE_DATA(&kof10thExtraRAMB[offset & 0xFFF]); } } -void install_kof10th_protection ( running_machine &machine ) +void neogeo_state::install_kof10th_protection () { - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x2fe000, 0x2fffff, FUNC(kof10th_RAMB_r)); - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x200000, 0x23ffff, FUNC(kof10th_custom_w)); - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x240000, 0x2fffff, FUNC(kof10th_bankswitch_w)); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x2fe000, 0x2fffff, read16_delegate(FUNC(neogeo_state::kof10th_RAMB_r),this)); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x200000, 0x23ffff, write16_delegate(FUNC(neogeo_state::kof10th_custom_w),this)); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x240000, 0x2fffff, write16_delegate(FUNC(neogeo_state::kof10th_bankswitch_w),this)); } -void decrypt_kof10th(running_machine &machine) +void neogeo_state::decrypt_kof10th() { int i, j; - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x900000); - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x900000); + UINT8 *src = memregion( "maincpu" )->base(); memcpy(dst + 0x000000, src + 0x700000, 0x100000); // Correct (Verified in Uni-bios) memcpy(dst + 0x100000, src + 0x000000, 0x800000); @@ -215,7 +213,7 @@ void decrypt_kof10th(running_machine &machine) src[j] = dst[i]; } - auto_free(machine, dst); + auto_free(machine(), dst); // Altera protection chip patches these over P ROM ((UINT16*)src)[0x0124/2] = 0x000d; // Enables XOR for RAM moves, forces SoftDIPs, and USA region @@ -230,16 +228,16 @@ void decrypt_kof10th(running_machine &machine) /* The King of Fighters 10th Anniversary Extra Plus (The King of Fighters 2002 bootleg) */ -void decrypt_kf10thep(running_machine &machine) +void neogeo_state::decrypt_kf10thep() { int i; - UINT16 *rom = (UINT16*)machine.root_device().memregion("maincpu")->base(); - UINT8 *src = machine.root_device().memregion("maincpu")->base(); - UINT16 *buf = (UINT16*)machine.root_device().memregion("audiocrypt")->base(); - UINT8 *srom = (UINT8*)machine.root_device().memregion("fixed")->base(); - UINT8 *sbuf = auto_alloc_array(machine, UINT8, 0x20000); + UINT16 *rom = (UINT16*)memregion("maincpu")->base(); + UINT8 *src = memregion("maincpu")->base(); + UINT16 *buf = (UINT16*)memregion("audiocrypt")->base(); + UINT8 *srom = (UINT8*)memregion("fixed")->base(); + UINT8 *sbuf = auto_alloc_array(machine(), UINT8, 0x20000); - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x200000); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x200000); memcpy(dst,buf,0x200000); memcpy(src+0x000000,dst+0x060000,0x20000); @@ -258,24 +256,24 @@ void decrypt_kf10thep(running_machine &machine) if (rom[i+0] == 0x4ef9 && rom[i+1] == 0x0000) rom[i+1] = 0x000F; // correct JMP in moved code } rom[0x00342/2] = 0x000f; - auto_free(machine, dst); + auto_free(machine(), dst); for (i=0;i<0x20000;i++) sbuf[i]=srom[i^0x8]; memcpy(srom,sbuf,0x20000); - auto_free(machine, sbuf); + auto_free(machine(), sbuf); } /* The King of Fighters 10th Anniversary 2005 Unique (The King of Fighters 2002 bootleg) */ -static void kf2k5uni_px_decrypt( running_machine &machine ) +void neogeo_state::kf2k5uni_px_decrypt() { int i, j, ofst; - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x80); + UINT8 *src = memregion( "maincpu" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x80); for (i = 0; i < 0x800000; i+=0x80) { @@ -286,34 +284,34 @@ static void kf2k5uni_px_decrypt( running_machine &machine ) } memcpy(src + i, dst, 0x80); } - auto_free(machine, dst); + auto_free(machine(), dst); memcpy(src, src + 0x600000, 0x100000); // Seems to be the same as kof10th } -static void kf2k5uni_sx_decrypt( running_machine &machine ) +void neogeo_state::kf2k5uni_sx_decrypt() { int i; - UINT8 *srom = machine.root_device().memregion( "fixed" )->base(); + UINT8 *srom = memregion( "fixed" )->base(); for (i = 0; i < 0x20000; i++) srom[i] = BITSWAP8(srom[i], 4, 5, 6, 7, 0, 1, 2, 3); } -static void kf2k5uni_mx_decrypt( running_machine &machine ) +void neogeo_state::kf2k5uni_mx_decrypt() { int i; - UINT8 *mrom = machine.root_device().memregion( "audiocpu" )->base(); + UINT8 *mrom = memregion( "audiocpu" )->base(); for (i = 0; i < 0x30000; i++) mrom[i] = BITSWAP8(mrom[i], 4, 5, 6, 7, 0, 1, 2, 3); } -void decrypt_kf2k5uni( running_machine &machine ) +void neogeo_state::decrypt_kf2k5uni() { - kf2k5uni_px_decrypt(machine); - kf2k5uni_sx_decrypt(machine); - kf2k5uni_mx_decrypt(machine); + kf2k5uni_px_decrypt(); + kf2k5uni_sx_decrypt(); + kf2k5uni_mx_decrypt(); } @@ -321,7 +319,7 @@ void decrypt_kf2k5uni( running_machine &machine ) // Thanks to IQ_132 for the info -void kof2002b_gfx_decrypt(running_machine &machine, UINT8 *src, int size) +void neogeo_state::kof2002b_gfx_decrypt(UINT8 *src, int size) { int i, j; int t[ 8 ][ 10 ] = @@ -336,7 +334,7 @@ void kof2002b_gfx_decrypt(running_machine &machine, UINT8 *src, int size) { 8, 0, 7, 3, 4, 5, 6, 2, 1 }, }; - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x10000 ); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x10000 ); for ( i = 0; i < size; i+=0x10000 ) { @@ -350,19 +348,19 @@ void kof2002b_gfx_decrypt(running_machine &machine, UINT8 *src, int size) memcpy( src+i+ofst*128, dst+j*128, 128 ); } } - auto_free( machine, dst ); + auto_free( machine(), dst ); } /* The King of Fighters 2002 Magic Plus (bootleg) */ -void kf2k2mp_decrypt( running_machine &machine ) +void neogeo_state::kf2k2mp_decrypt() { int i,j; - UINT8 *src = machine.root_device().memregion("maincpu")->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x80); + UINT8 *src = memregion("maincpu")->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x80); memmove(src, src + 0x300000, 0x500000); @@ -375,24 +373,24 @@ void kf2k2mp_decrypt( running_machine &machine ) } memcpy(src + i, dst, 0x80); } - auto_free(machine, dst); + auto_free(machine(), dst); } /* The King of Fighters 2002 Magic Plus II (bootleg) */ -void kf2k2mp2_px_decrypt( running_machine &machine ) +void neogeo_state::kf2k2mp2_px_decrypt() { - UINT8 *src = machine.root_device().memregion("maincpu")->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x600000); + UINT8 *src = memregion("maincpu")->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x600000); memcpy (dst + 0x000000, src + 0x1C0000, 0x040000); memcpy (dst + 0x040000, src + 0x140000, 0x080000); memcpy (dst + 0x0C0000, src + 0x100000, 0x040000); memcpy (dst + 0x100000, src + 0x200000, 0x400000); memcpy (src + 0x000000, dst + 0x000000, 0x600000); - auto_free (machine, dst); + auto_free (machine(), dst); } @@ -400,13 +398,13 @@ void kf2k2mp2_px_decrypt( running_machine &machine ) /* descrambling information from razoola */ -static void cthd2003_neogeo_gfx_address_fix_do(running_machine &machine, int start, int end, int bit3shift, int bit2shift, int bit1shift, int bit0shift) +void neogeo_state::cthd2003_neogeo_gfx_address_fix_do(int start, int end, int bit3shift, int bit2shift, int bit1shift, int bit0shift) { int i,j; int tilesize=128; - UINT8* rom = auto_alloc_array(machine, UINT8, 16*tilesize); // 16 tiles buffer - UINT8* realrom = machine.root_device().memregion("sprites")->base() + start*tilesize; + UINT8* rom = auto_alloc_array(machine(), UINT8, 16*tilesize); // 16 tiles buffer + UINT8* realrom = memregion("sprites")->base() + start*tilesize; for (i = 0; i < (end-start)/16; i++) { for (j = 0; j < 16; j++) { @@ -420,47 +418,47 @@ static void cthd2003_neogeo_gfx_address_fix_do(running_machine &machine, int sta memcpy(realrom,rom,tilesize*16); realrom+=16*tilesize; } - auto_free(machine, rom); + auto_free(machine(), rom); } -static void cthd2003_neogeo_gfx_address_fix(running_machine &machine, int start, int end) +void neogeo_state::cthd2003_neogeo_gfx_address_fix(int start, int end) { - cthd2003_neogeo_gfx_address_fix_do(machine, start+512*0, end+512*0, 0,3,2,1); - cthd2003_neogeo_gfx_address_fix_do(machine, start+512*1, end+512*1, 1,0,3,2); - cthd2003_neogeo_gfx_address_fix_do(machine, start+512*2, end+512*2, 2,1,0,3); + cthd2003_neogeo_gfx_address_fix_do(start+512*0, end+512*0, 0,3,2,1); + cthd2003_neogeo_gfx_address_fix_do(start+512*1, end+512*1, 1,0,3,2); + cthd2003_neogeo_gfx_address_fix_do(start+512*2, end+512*2, 2,1,0,3); // skip 3 & 4 - cthd2003_neogeo_gfx_address_fix_do(machine, start+512*5, end+512*5, 0,1,2,3); - cthd2003_neogeo_gfx_address_fix_do(machine, start+512*6, end+512*6, 0,1,2,3); - cthd2003_neogeo_gfx_address_fix_do(machine, start+512*7, end+512*7, 0,2,3,1); + cthd2003_neogeo_gfx_address_fix_do(start+512*5, end+512*5, 0,1,2,3); + cthd2003_neogeo_gfx_address_fix_do(start+512*6, end+512*6, 0,1,2,3); + cthd2003_neogeo_gfx_address_fix_do(start+512*7, end+512*7, 0,2,3,1); } -static void cthd2003_c(running_machine &machine, int pow) +void neogeo_state::cthd2003_c(int pow) { int i; for (i=0; i<=192; i+=8) - cthd2003_neogeo_gfx_address_fix(machine, i*512,i*512+512); + cthd2003_neogeo_gfx_address_fix(i*512,i*512+512); for (i=200; i<=392; i+=8) - cthd2003_neogeo_gfx_address_fix(machine, i*512,i*512+512); + cthd2003_neogeo_gfx_address_fix(i*512,i*512+512); for (i=400; i<=592; i+=8) - cthd2003_neogeo_gfx_address_fix(machine, i*512,i*512+512); + cthd2003_neogeo_gfx_address_fix(i*512,i*512+512); for (i=600; i<=792; i+=8) - cthd2003_neogeo_gfx_address_fix(machine, i*512,i*512+512); + cthd2003_neogeo_gfx_address_fix(i*512,i*512+512); for (i=800; i<=992; i+=8) - cthd2003_neogeo_gfx_address_fix(machine, i*512,i*512+512); + cthd2003_neogeo_gfx_address_fix(i*512,i*512+512); for (i=1000; i<=1016; i+=8) - cthd2003_neogeo_gfx_address_fix(machine, i*512,i*512+512); + cthd2003_neogeo_gfx_address_fix(i*512,i*512+512); } -void decrypt_cthd2003( running_machine &machine ) +void neogeo_state::decrypt_cthd2003() { - UINT8 *romdata = machine.root_device().memregion("fixed")->base(); - UINT8 *tmp = auto_alloc_array(machine, UINT8, 8*128*128); + UINT8 *romdata = memregion("fixed")->base(); + UINT8 *tmp = auto_alloc_array(machine(), UINT8, 8*128*128); memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); @@ -468,21 +466,21 @@ void decrypt_cthd2003( running_machine &machine ) memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); memcpy(romdata, tmp, 8*128*128); - romdata = machine.root_device().memregion("audiocpu")->base()+0x10000; + romdata = memregion("audiocpu")->base()+0x10000; memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128); memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); memcpy(romdata, tmp, 8*128*128); - auto_free(machine, tmp); + auto_free(machine(), tmp); memcpy(romdata-0x10000,romdata,0x10000); - cthd2003_c(machine, 0); + cthd2003_c(0); } -static WRITE16_HANDLER ( cthd2003_bankswitch_w ) +WRITE16_MEMBER( neogeo_state::cthd2003_bankswitch_w ) { int bankaddress; static const int cthd2003_banks[8] = @@ -492,18 +490,18 @@ static WRITE16_HANDLER ( cthd2003_bankswitch_w ) if (offset == 0) { bankaddress = 0x100000 + cthd2003_banks[data&7]*0x100000; - space.machine().driver_data()->neogeo_set_main_cpu_bank_address(bankaddress); + neogeo_set_main_cpu_bank_address(bankaddress); } } -void patch_cthd2003( running_machine &machine ) +void neogeo_state::patch_cthd2003() { /* patches thanks to razoola */ int i; - UINT16 *mem16 = (UINT16 *)machine.root_device().memregion("maincpu")->base(); + UINT16 *mem16 = (UINT16 *)memregion("maincpu")->base(); /* special ROM banking handler */ - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x2ffff0, 0x2fffff, FUNC(cthd2003_bankswitch_w)); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x2ffff0, 0x2fffff, write16_delegate(FUNC(neogeo_state::cthd2003_bankswitch_w),this)); // theres still a problem on the character select screen but it seems to be related to cpu core timing issues, // overclocking the 68k prevents it. @@ -541,11 +539,11 @@ void patch_cthd2003( running_machine &machine ) /* Crouching Tiger Hidden Dragon 2003 Super Plus (bootleg of King of Fighters 2001) */ -static void ct2k3sp_sx_decrypt( running_machine &machine ) +void neogeo_state::ct2k3sp_sx_decrypt() { - int rom_size = machine.root_device().memregion( "fixed" )->bytes(); - UINT8 *rom = machine.root_device().memregion( "fixed" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + int rom_size = memregion( "fixed" )->bytes(); + UINT8 *rom = memregion( "fixed" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); int i; int ofst; @@ -568,49 +566,49 @@ static void ct2k3sp_sx_decrypt( running_machine &machine ) memcpy( &rom[ 0x28000 ], &buf[ 0x30000 ], 0x8000 ); memcpy( &rom[ 0x30000 ], &buf[ 0x28000 ], 0x8000 ); - auto_free( machine, buf ); + auto_free( machine(), buf ); } -void decrypt_ct2k3sp( running_machine &machine ) +void neogeo_state::decrypt_ct2k3sp() { - UINT8 *romdata = machine.root_device().memregion("audiocpu")->base()+0x10000; - UINT8*tmp = auto_alloc_array(machine, UINT8, 8*128*128); + UINT8 *romdata = memregion("audiocpu")->base()+0x10000; + UINT8*tmp = auto_alloc_array(machine(), UINT8, 8*128*128); memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128); memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); memcpy(romdata, tmp, 8*128*128); - auto_free(machine, tmp); + auto_free(machine(), tmp); memcpy(romdata-0x10000,romdata,0x10000); - ct2k3sp_sx_decrypt(machine); - cthd2003_c(machine, 0); + ct2k3sp_sx_decrypt(); + cthd2003_c(0); } /* Crouching Tiger Hidden Dragon 2003 Super Plus alternate (bootleg of King of Fighters 2001) */ -void decrypt_ct2k3sa( running_machine &machine ) +void neogeo_state::decrypt_ct2k3sa() { - UINT8 *romdata = machine.root_device().memregion("audiocpu")->base()+0x10000; - UINT8*tmp = auto_alloc_array(machine, UINT8, 8*128*128); + UINT8 *romdata = memregion("audiocpu")->base()+0x10000; + UINT8*tmp = auto_alloc_array(machine(), UINT8, 8*128*128); memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128); memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128); memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128); memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128); memcpy(romdata, tmp, 8*128*128); - auto_free(machine, tmp); + auto_free(machine(), tmp); memcpy(romdata-0x10000,romdata,0x10000); - cthd2003_c(machine, 0); + cthd2003_c(0); } -void patch_ct2k3sa( running_machine &machine ) +void neogeo_state::patch_ct2k3sa() { /* patches thanks to razoola - same as for cthd2003*/ int i; - UINT16 *mem16 = (UINT16 *)machine.root_device().memregion("maincpu")->base(); + UINT16 *mem16 = (UINT16 *)memregion("maincpu")->base(); // theres still a problem on the character select screen but it seems to be related to cpu core timing issues, // overclocking the 68k prevents it. @@ -649,10 +647,10 @@ void patch_ct2k3sa( running_machine &machine ) /* King of Fighters Special Edition 2004 (bootleg of King of Fighters 2002) */ -void decrypt_kof2k4se_68k( running_machine &machine ) +void neogeo_state::decrypt_kof2k4se_68k() { - UINT8 *src = machine.root_device().memregion("maincpu")->base()+0x100000; - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x400000); + UINT8 *src = memregion("maincpu")->base()+0x100000; + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x400000); int i; static const int sec[] = {0x300000,0x200000,0x100000,0x000000}; memcpy(dst,src,0x400000); @@ -661,28 +659,28 @@ void decrypt_kof2k4se_68k( running_machine &machine ) { memcpy(src+i*0x100000,dst+sec[i],0x100000); } - auto_free(machine, dst); + auto_free(machine(), dst); } /* Lansquenet 2004 (Shock Troopers - 2nd Squad bootleg) */ -void lans2004_vx_decrypt( running_machine &machine ) +void neogeo_state::lans2004_vx_decrypt() { int i; - UINT8 *rom = machine.root_device().memregion( "ymsnd" )->base(); + UINT8 *rom = memregion( "ymsnd" )->base(); for (i = 0; i < 0xA00000; i++) rom[i] = BITSWAP8(rom[i], 0, 1, 5, 4, 3, 2, 6, 7); } -void lans2004_decrypt_68k( running_machine &machine ) +void neogeo_state::lans2004_decrypt_68k() { /* Descrambling P ROMs - Thanks to Razoola for the info */ int i; - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); - UINT16 *rom = (UINT16*)machine.root_device().memregion( "maincpu" )->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x600000); + UINT8 *src = memregion( "maincpu" )->base(); + UINT16 *rom = (UINT16*)memregion( "maincpu" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x600000); { static const int sec[] = { 0x3, 0x8, 0x7, 0xC, 0x1, 0xA, 0x6, 0xD }; @@ -694,7 +692,7 @@ void lans2004_decrypt_68k( running_machine &machine ) memcpy (dst + 0x02FFF0, src + 0x1A92BE, 0x000010); memcpy (dst + 0x100000, src + 0x200000, 0x400000); memcpy (src, dst, 0x600000); - auto_free (machine, dst); + auto_free (machine(), dst); } for (i = 0xBBB00/2; i < 0xBE000/2; i++) { @@ -718,20 +716,20 @@ void lans2004_decrypt_68k( running_machine &machine ) /* Metal Slug 5 Plus (bootleg) */ -static READ16_HANDLER( mslug5_prot_r ) +READ16_MEMBER( neogeo_state::mslug5_prot_r ) { logerror("PC %06x: access protected\n",space.device().safe_pc()); return 0xa0; } -static WRITE16_HANDLER ( ms5plus_bankswitch_w ) +WRITE16_MEMBER( neogeo_state::ms5plus_bankswitch_w ) { int bankaddress; logerror("offset: %06x PC %06x: set banking %04x\n",offset,space.device().safe_pc(),data); if ((offset == 0)&&(data == 0xa0)) { bankaddress=0xa0; - space.machine().driver_data()->neogeo_set_main_cpu_bank_address(bankaddress); + neogeo_set_main_cpu_bank_address(bankaddress); logerror("offset: %06x PC %06x: set banking %04x\n\n",offset,space.device().safe_pc(),bankaddress); } else if(offset == 2) @@ -739,30 +737,30 @@ static WRITE16_HANDLER ( ms5plus_bankswitch_w ) data=data>>4; //data=data&7; bankaddress=data*0x100000; - space.machine().driver_data()->neogeo_set_main_cpu_bank_address(bankaddress); + neogeo_set_main_cpu_bank_address(bankaddress); logerror("offset: %06x PC %06x: set banking %04x\n\n",offset,space.device().safe_pc(),bankaddress); } } -void install_ms5plus_protection(running_machine &machine) +void neogeo_state::install_ms5plus_protection() { // special ROM banking handler / additional protection - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2ffff0, 0x2fffff,FUNC(mslug5_prot_r), FUNC(ms5plus_bankswitch_w)); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2ffff0, 0x2fffff,read16_delegate(FUNC(neogeo_state::mslug5_prot_r),this), write16_delegate(FUNC(neogeo_state::ms5plus_bankswitch_w),this)); } /* SNK vs. CAPCOM SVC CHAOS (bootleg) */ -void svcboot_px_decrypt( running_machine &machine ) +void neogeo_state::svcboot_px_decrypt() { static const UINT8 sec[] = { 0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 }; int i; - int size = machine.root_device().memregion( "maincpu" )->bytes(); - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, size ); + int size = memregion( "maincpu" )->bytes(); + UINT8 *src = memregion( "maincpu" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, size ); int ofst; for( i = 0; i < size / 0x100000; i++ ){ memcpy( &dst[ i * 0x100000 ], &src[ sec[ i ] * 0x100000 ], 0x100000 ); @@ -772,10 +770,10 @@ void svcboot_px_decrypt( running_machine &machine ) ofst += (i & 0xffff00); memcpy( &src[ i * 2 ], &dst[ ofst * 2 ], 0x02 ); } - auto_free( machine, dst ); + auto_free( machine(), dst ); } -void svcboot_cx_decrypt( running_machine &machine ) +void neogeo_state::svcboot_cx_decrypt() { static const UINT8 idx_tbl[ 0x10 ] = { 0, 1, 0, 1, 2, 3, 2, 3, 3, 4, 3, 4, 4, 5, 4, 5, @@ -789,9 +787,9 @@ void svcboot_cx_decrypt( running_machine &machine ) { 3, 0, 2, 1 }, }; int i; - int size = machine.root_device().memregion( "sprites" )->bytes(); - UINT8 *src = machine.root_device().memregion( "sprites" )->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, size ); + int size = memregion( "sprites" )->bytes(); + UINT8 *src = memregion( "sprites" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, size ); int ofst; memcpy( dst, src, size ); for( i = 0; i < size / 0x80; i++ ){ @@ -804,21 +802,21 @@ void svcboot_cx_decrypt( running_machine &machine ) ofst += (i & 0xfffff00); memcpy( &src[ i * 0x80 ], &dst[ ofst * 0x80 ], 0x80 ); } - auto_free( machine, dst ); + auto_free( machine(), dst ); } /* SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 1) */ -void svcplus_px_decrypt( running_machine &machine ) +void neogeo_state::svcplus_px_decrypt() { static const int sec[] = { 0x00, 0x03, 0x02, 0x05, 0x04, 0x01 }; - int size = machine.root_device().memregion( "maincpu" )->bytes(); - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, size ); + int size = memregion( "maincpu" )->bytes(); + UINT8 *src = memregion( "maincpu" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, size ); int i; int ofst; memcpy( dst, src, size ); @@ -834,13 +832,13 @@ void svcplus_px_decrypt( running_machine &machine ) for( i = 0; i < 6; i++ ){ memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); } - auto_free( machine, dst ); + auto_free( machine(), dst ); } -void svcplus_px_hack( running_machine &machine ) +void neogeo_state::svcplus_px_hack() { /* patched by the protection chip? */ - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); + UINT8 *src = memregion( "maincpu" )->base(); src[ 0x0f8010 ] = 0x40; src[ 0x0f8011 ] = 0x04; src[ 0x0f8012 ] = 0x00; @@ -855,34 +853,34 @@ void svcplus_px_hack( running_machine &machine ) /* SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 2) */ -void svcplusa_px_decrypt( running_machine &machine ) +void neogeo_state::svcplusa_px_decrypt() { int i; static const int sec[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 }; - int size = machine.root_device().memregion( "maincpu" )->bytes(); - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, size ); + int size = memregion( "maincpu" )->bytes(); + UINT8 *src = memregion( "maincpu" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, size ); memcpy( dst, src, size ); for( i = 0; i < 6; i++ ){ memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 ); } - auto_free( machine, dst ); + auto_free( machine(), dst ); } /* SNK vs. CAPCOM SVC CHAOS Super Plus (bootleg) */ -void svcsplus_px_decrypt( running_machine &machine ) +void neogeo_state::svcsplus_px_decrypt() { static const int sec[] = { 0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 }; - int size = machine.root_device().memregion( "maincpu" )->bytes(); - UINT8 *src = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, size ); + int size = memregion( "maincpu" )->bytes(); + UINT8 *src = memregion( "maincpu" )->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, size ); int i; int ofst; memcpy( dst, src, size ); @@ -894,13 +892,13 @@ void svcsplus_px_decrypt( running_machine &machine ) ofst += sec[ (i & 0xf80000) >> 19 ] << 19; memcpy( &src[ i * 2 ], &dst[ ofst * 2 ], 0x02 ); } - auto_free( machine, dst ); + auto_free( machine(), dst ); } -void svcsplus_px_hack( running_machine &machine ) +void neogeo_state::svcsplus_px_hack() { /* patched by the protection chip? */ - UINT16 *mem16 = (UINT16 *)machine.root_device().memregion("maincpu")->base(); + UINT16 *mem16 = (UINT16 *)memregion("maincpu")->base(); mem16[0x9e90/2] = 0x000f; mem16[0x9e92/2] = 0xc9c0; mem16[0xa10c/2] = 0x4eb9; @@ -909,18 +907,18 @@ void svcsplus_px_hack( running_machine &machine ) } #ifdef UNUSED_FUNCTION -static UINT16 mv0_bank_ram[ 0x10/2 ]; +UINT16 mv0_bank_ram[ 0x10/2 ]; -static READ16_HANDLER( mv0_bankswitch_r ) +READ16_MEMBER( neogeo_state::mv0_bankswitch_r ) { return mv0_bank_ram[ offset ]; } -static WRITE16_HANDLER( mv0_bankswitch_w ) +WRITE16_MEMBER( neogeo_state::mv0_bankswitch_w ) { UINT32 bankaddress = (mv0_bank_ram[ 0 ] >> 8) + (mv0_bank_ram[ 1 ] << 8) + 0x100000; COMBINE_DATA( &mv0_bank_ram[ offset ] ); - space.machine().driver_data()->neogeo_set_main_cpu_bank_address( bankaddress ); + neogeo_set_main_cpu_bank_address( bankaddress ); } #endif @@ -928,49 +926,47 @@ static WRITE16_HANDLER( mv0_bankswitch_w ) /* The King of Fighters 2003 (bootleg set 1) */ -static UINT16 kof2003_tbl[4096]; - -static READ16_HANDLER( kof2003_r) +READ16_MEMBER( neogeo_state::kof2003_r) { return kof2003_tbl[offset]; } -static WRITE16_HANDLER( kof2003_w ) +WRITE16_MEMBER( neogeo_state::kof2003_w ) { data = COMBINE_DATA(&kof2003_tbl[offset]); if (offset == 0x1ff0/2 || offset == 0x1ff2/2) { UINT8* cr = (UINT8 *)kof2003_tbl; UINT32 address = (cr[BYTE_XOR_LE(0x1ff3)]<<16)|(cr[BYTE_XOR_LE(0x1ff2)]<<8)|cr[BYTE_XOR_LE(0x1ff1)]; UINT8 prt = cr[BYTE_XOR_LE(0x1ff2)]; - UINT8* mem = (UINT8 *)space.machine().root_device().memregion("maincpu")->base(); + UINT8* mem = (UINT8 *)memregion("maincpu")->base(); cr[BYTE_XOR_LE(0x1ff0)] = 0xa0; cr[BYTE_XOR_LE(0x1ff1)] &= 0xfe; cr[BYTE_XOR_LE(0x1ff3)] &= 0x7f; - space.machine().driver_data()->neogeo_set_main_cpu_bank_address(address+0x100000); + neogeo_set_main_cpu_bank_address(address+0x100000); mem[BYTE_XOR_LE(0x58196)] = prt; } } -static WRITE16_HANDLER( kof2003p_w ) +WRITE16_MEMBER( neogeo_state::kof2003p_w ) { data = COMBINE_DATA(&kof2003_tbl[offset]); if (offset == 0x1ff0/2 || offset == 0x1ff2/2) { UINT8* cr = (UINT8 *)kof2003_tbl; UINT32 address = (cr[BYTE_XOR_LE(0x1ff3)]<<16)|(cr[BYTE_XOR_LE(0x1ff2)]<<8)|cr[BYTE_XOR_LE(0x1ff0)]; UINT8 prt = cr[BYTE_XOR_LE(0x1ff2)]; - UINT8* mem = (UINT8 *)space.machine().root_device().memregion("maincpu")->base(); + UINT8* mem = (UINT8 *)memregion("maincpu")->base(); cr[BYTE_XOR_LE(0x1ff0)] &= 0xfe; cr[BYTE_XOR_LE(0x1ff3)] &= 0x7f; - space.machine().driver_data()->neogeo_set_main_cpu_bank_address(address+0x100000); + neogeo_set_main_cpu_bank_address(address+0x100000); mem[BYTE_XOR_LE(0x58196)] = prt; } } -void kf2k3bl_px_decrypt( running_machine &machine ) +void neogeo_state::kf2k3bl_px_decrypt() { int i; static const UINT8 sec[] = { @@ -978,29 +974,29 @@ void kf2k3bl_px_decrypt( running_machine &machine ) }; int rom_size = 0x800000; - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + UINT8 *rom = memregion( "maincpu" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); memcpy( buf, rom, rom_size ); for( i = 0; i < rom_size / 0x100000; i++ ){ memcpy( &rom[ i * 0x100000 ], &buf[ sec[ i ] * 0x100000 ], 0x100000 ); } - auto_free( machine, buf ); + auto_free( machine(), buf ); } -void kf2k3bl_install_protection(running_machine &machine) +void neogeo_state::kf2k3bl_install_protection() { - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2fe000, 0x2fffff, FUNC(kof2003_r), FUNC(kof2003_w) ); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2fe000, 0x2fffff, read16_delegate(FUNC(neogeo_state::kof2003_r),this), write16_delegate(FUNC(neogeo_state::kof2003_w),this) ); } /* The King of Fighters 2004 Plus / Hero (The King of Fighters 2003 bootleg) */ -void kf2k3pl_px_decrypt( running_machine &machine ) +void neogeo_state::kf2k3pl_px_decrypt() { - UINT16*tmp = auto_alloc_array(machine, UINT16, 0x100000/2); - UINT16*rom = (UINT16*)machine.root_device().memregion( "maincpu" )->base(); + UINT16*tmp = auto_alloc_array(machine(), UINT16, 0x100000/2); + UINT16*rom = (UINT16*)memregion( "maincpu" )->base(); int j; int i; @@ -1010,25 +1006,25 @@ void kf2k3pl_px_decrypt( running_machine &machine ) for (j = 0;j < 0x100000/2;j++) rom[i+j] = tmp[BITSWAP24(j,23,22,21,20,19,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)]; } - auto_free(machine, tmp); + auto_free(machine(), tmp); /* patched by Altera protection chip on PCB */ rom[0xf38ac/2] = 0x4e75; } -void kf2k3pl_install_protection(running_machine &machine) +void neogeo_state::kf2k3pl_install_protection() { - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2fe000, 0x2fffff, FUNC(kof2003_r), FUNC(kof2003p_w) ); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2fe000, 0x2fffff, read16_delegate(FUNC(neogeo_state::kof2003_r),this), write16_delegate(FUNC(neogeo_state::kof2003p_w),this) ); } /* The King of Fighters 2004 Ultra Plus (The King of Fighters 2003 bootleg) */ -void kf2k3upl_px_decrypt( running_machine &machine ) +void neogeo_state::kf2k3upl_px_decrypt() { { - UINT8 *src = machine.root_device().memregion("maincpu")->base(); + UINT8 *src = memregion("maincpu")->base(); memmove(src+0x100000, src, 0x600000); memmove(src, src+0x700000, 0x100000); } @@ -1036,8 +1032,8 @@ void kf2k3upl_px_decrypt( running_machine &machine ) { int ofst; int i; - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base() + 0xfe000; - UINT8 *buf = machine.root_device().memregion( "maincpu" )->base() + 0xd0610; + UINT8 *rom = memregion( "maincpu" )->base() + 0xfe000; + UINT8 *buf = memregion( "maincpu" )->base() + 0xd0610; for( i = 0; i < 0x2000 / 2; i++ ){ ofst = (i & 0xff00) + BITSWAP8( (i & 0x00ff), 7, 6, 0, 4, 3, 2, 1, 5 ); @@ -1046,20 +1042,20 @@ void kf2k3upl_px_decrypt( running_machine &machine ) } } -void kf2k3upl_install_protection(running_machine &machine) +void neogeo_state::kf2k3upl_install_protection() { - machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2fe000, 0x2fffff, FUNC(kof2003_r), FUNC(kof2003_w) ); + machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2fe000, 0x2fffff, read16_delegate(FUNC(neogeo_state::kof2003_r),this), write16_delegate(FUNC(neogeo_state::kof2003_w),this) ); } /* Samurai Shodown V / Samurai Spirits Zero (bootleg) */ -void samsho5b_px_decrypt( running_machine &machine ) +void neogeo_state::samsho5b_px_decrypt() { - int px_size = machine.root_device().memregion( "maincpu" )->bytes(); - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, px_size ); + int px_size = memregion( "maincpu" )->bytes(); + UINT8 *rom = memregion( "maincpu" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, px_size ); int ofst; int i; @@ -1078,14 +1074,14 @@ void samsho5b_px_decrypt( running_machine &machine ) memcpy( &rom[ 0x000000 ], &buf[ 0x700000 ], 0x100000 ); memcpy( &rom[ 0x100000 ], &buf[ 0x000000 ], 0x700000 ); - auto_free( machine, buf ); + auto_free( machine(), buf ); } -void samsho5b_vx_decrypt( running_machine &machine ) +void neogeo_state::samsho5b_vx_decrypt() { - int vx_size = machine.root_device().memregion( "ymsnd" )->bytes(); - UINT8 *rom = machine.root_device().memregion( "ymsnd" )->base(); + int vx_size = memregion( "ymsnd" )->bytes(); + UINT8 *rom = memregion( "ymsnd" )->base(); int i; for( i = 0; i < vx_size; i++ ) @@ -1098,11 +1094,11 @@ void samsho5b_vx_decrypt( running_machine &machine ) #define MATRIMBLZ80( i ) ( i^(BITSWAP8(i&0x3,4,3,1,2,0,7,6,5)<<8) ) -void matrimbl_decrypt( running_machine &machine ) +void neogeo_state::matrimbl_decrypt() { /* decrypt Z80 */ - UINT8 *rom = machine.root_device().memregion( "audiocpu" )->base()+0x10000; - UINT8 *buf = auto_alloc_array(machine, UINT8, 0x20000 ); + UINT8 *rom = memregion( "audiocpu" )->base()+0x10000; + UINT8 *buf = auto_alloc_array(machine(), UINT8, 0x20000 ); int i, j=0; memcpy( buf, rom, 0x20000 ); for( i=0x00000; i<0x20000; i++ ) @@ -1133,9 +1129,9 @@ void matrimbl_decrypt( running_machine &machine ) } rom[ j ]=buf[ i ]; } - auto_free( machine, buf ); + auto_free( machine(), buf ); memcpy( rom-0x10000, rom, 0x10000 ); /* decrypt gfx */ - cthd2003_c( machine, 0 ); + cthd2003_c( 0 ); } diff --git a/src/mame/machine/neocrypt.c b/src/mame/machine/neocrypt.c index f5162fcdc04..a3fc5451f86 100644 --- a/src/mame/machine/neocrypt.c +++ b/src/mame/machine/neocrypt.c @@ -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] = { 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, const UINT8 *table0hi, 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; UINT8 *buf; UINT8 *rom; 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 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]; } - auto_free(machine, buf); + auto_free(machine(), buf); } /* 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 rom_size = machine.root_device().memregion("sprites")->bytes(); - int tx_size = machine.root_device().memregion("fixed")->bytes(); - UINT8 *src = machine.root_device().memregion("sprites")->base()+rom_size-tx_size; - UINT8 *dst = machine.root_device().memregion("fixed")->base(); + int rom_size = memregion("sprites")->bytes(); + int tx_size = memregion("fixed")->bytes(); + UINT8 *src = memregion("sprites")->base()+rom_size-tx_size; + UINT8 *dst = memregion("fixed")->base(); for (i = 0;i < tx_size;i++) 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 */ -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_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_xor2 = kof99_address_16_23_xor2; address_0_7_xor = kof99_address_0_7_xor; - neogeo_gfx_decrypt(machine, extra_xor); - neogeo_sfix_decrypt(machine); + neogeo_gfx_decrypt(extra_xor); + neogeo_sfix_decrypt(); } /* 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_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_xor2 = kof2000_address_16_23_xor2; address_0_7_xor = kof2000_address_0_7_xor; - neogeo_gfx_decrypt(machine, extra_xor); - neogeo_sfix_decrypt(machine); + neogeo_gfx_decrypt(extra_xor); + neogeo_sfix_decrypt(); } /* 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_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_xor2 = kof99_address_16_23_xor2; address_0_7_xor = kof99_address_0_7_xor; - neogeo_gfx_decrypt(machine, extra_xor); + neogeo_gfx_decrypt(extra_xor); } /* 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_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_xor2 = kof2000_address_16_23_xor2; 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 */ -void svcpcb_gfx_decrypt(running_machine &machine) +void neogeo_state::svcpcb_gfx_decrypt() { static const UINT8 xorval[ 4 ] = { 0x34, 0x21, 0xc4, 0xe9 }; int i; int ofst; - int rom_size = machine.root_device().memregion( "sprites" )->bytes(); - UINT8 *rom = machine.root_device().memregion( "sprites" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + int rom_size = memregion( "sprites" )->bytes(); + UINT8 *rom = memregion( "sprites" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); for( i = 0; i < rom_size; i++ ) { @@ -702,16 +691,16 @@ void svcpcb_gfx_decrypt(running_machine &machine) ofst += (i & 0xffe00000); memcpy( &rom[ i * 4 ], &buf[ ofst * 4 ], 0x04 ); } - auto_free( machine, buf ); + auto_free( machine(), buf ); } /* and a further swap on the s1 data */ -void svcpcb_s1data_decrypt(running_machine &machine) +void neogeo_state::svcpcb_s1data_decrypt() { int i; - UINT8 *s1 = machine.root_device().memregion( "fixed" )->base(); - size_t s1_size = machine.root_device().memregion( "fixed" )->bytes(); + UINT8 *s1 = memregion( "fixed" )->base(); + size_t s1_size = memregion( "fixed" )->bytes(); 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 */ /* 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 }; int i; int ofst; - int rom_size = machine.root_device().memregion( "sprites" )->bytes(); - UINT8 *rom = machine.root_device().memregion( "sprites" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + int rom_size = memregion( "sprites" )->bytes(); + UINT8 *rom = memregion( "sprites" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); for ( i = 0; i < rom_size; i++ ) { @@ -748,36 +737,36 @@ void kf2k3pcb_gfx_decrypt(running_machine &machine) ofst += (i & 0xff800000); memcpy( &rom[ ofst ], &buf[ i ], 0x04 ); } - auto_free( machine, buf ); + auto_free( machine(), buf ); } /* and a further swap on the s1 data */ -void kf2k3pcb_decrypt_s1data(running_machine &machine) +void neogeo_state::kf2k3pcb_decrypt_s1data() { UINT8 *src; UINT8 *dst; int i; - int tx_size = machine.root_device().memregion( "fixed" )->bytes(); - int srom_size = machine.root_device().memregion( "sprites" )->bytes(); + int tx_size = memregion( "fixed" )->bytes(); + int srom_size = memregion( "sprites" )->bytes(); - src = machine.root_device().memregion( "sprites" )->base() + srom_size - 0x1000000 - 0x80000; // Decrypt S - dst = machine.root_device().memregion( "fixed" )->base(); + src = memregion( "sprites" )->base() + srom_size - 0x1000000 - 0x80000; // Decrypt S + dst = memregion( "fixed" )->base(); for( i = 0; i < tx_size / 2; i++ ) { dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ]; } - src = machine.root_device().memregion( "sprites" )->base() + srom_size - 0x80000; - dst = machine.root_device().memregion( "fixed" )->base() + 0x80000; + src = memregion( "sprites" )->base() + srom_size - 0x80000; + dst = memregion( "fixed" )->base() + 0x80000; for( i = 0; i < tx_size / 2; i++ ) { 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++ ) { @@ -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 the rom */ -static UINT16 generate_cs16(UINT8 *rom, int size) +UINT16 neogeo_state::generate_cs16(UINT8 *rom, int size) { UINT16 cs16; 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 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; - 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; @@ -912,7 +901,7 @@ void neogeo_cmc50_m1_decrypt(running_machine &machine) #if 0 { FILE *fp; - const char *gamename = machine.system().name; + const char *gamename = machine().system().name; char filename[256]; sprintf(filename, "%s_m1.dump", gamename); @@ -929,7 +918,7 @@ void neogeo_cmc50_m1_decrypt(running_machine &machine) #if 0 { FILE *fp; - const char *gamename = machine.system().name; + const char *gamename = machine().system().name; char filename[256]; sprintf(filename, "%s_m1extra.dump", gamename); @@ -942,7 +931,7 @@ void neogeo_cmc50_m1_decrypt(running_machine &machine) } #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 */ -void kof98_decrypt_68k(running_machine &machine) +void neogeo_state::kof98_decrypt_68k() { - UINT8 *src = machine.root_device().memregion("maincpu")->base(); - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x200000); + UINT8 *src = memregion("maincpu")->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x200000); int i, j, k; static const UINT32 sec[]={0x000000,0x100000,0x000004,0x100004,0x10000a,0x00000a,0x10000e,0x00000e}; 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 ); - 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 */ -void kof99_decrypt_68k(running_machine &machine) +void neogeo_state::kof99_decrypt_68k() { UINT16 *rom; 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 */ for (i = 0;i < 0x800000/2;i++) { @@ -1025,7 +1014,7 @@ void kof99_decrypt_68k(running_machine &machine) } /* 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++) { 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; int i,j; /* 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 */ for (i = 0;i < 0x800000/2;i++) { @@ -1047,14 +1036,14 @@ void garou_decrypt_68k(running_machine &machine) } /* 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++) { 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 */ - rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); + rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000); for (i = 0;i < 0x800000/2;i+=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; int i,j; /* 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 */ for (i = 0;i < 0x800000/2;i++) { @@ -1081,14 +1070,14 @@ void garouh_decrypt_68k(running_machine &machine) } /* 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++) { 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 */ - rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); + rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000); for (i = 0;i < 0x800000/2;i+=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; int i,j; /* 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 */ for (i = 0;i < 0x800000/2;i++) { @@ -1115,14 +1104,14 @@ void mslug3_decrypt_68k(running_machine &machine) } /* 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++) { 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 */ - rom = (UINT16 *)(machine.root_device().memregion("maincpu")->base() + 0x100000); + rom = (UINT16 *)(memregion("maincpu")->base() + 0x100000); for (i = 0;i < 0x800000/2;i+=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; int i,j; /* 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 */ for (i = 0;i < 0x800000/2;i++) { @@ -1160,7 +1149,7 @@ void kof2000_decrypt_68k(running_machine &machine) } /* 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++) { 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 */ -void kof2002_decrypt_68k(running_machine &machine) +void neogeo_state::kof2002_decrypt_68k() { int i; static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000}; - UINT8 *src = machine.root_device().memregion("maincpu")->base()+0x100000; - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x400000); + UINT8 *src = memregion("maincpu")->base()+0x100000; + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x400000); memcpy( dst, src, 0x400000 ); for( i=0; i<8; ++i ) { 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; static const int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000}; - UINT8 *src = machine.root_device().memregion("maincpu")->base()+0x100000; - UINT8 *dst = auto_alloc_array(machine, UINT8, 0x400000); + UINT8 *src = memregion("maincpu")->base()+0x100000; + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x400000); memcpy( dst, src, 0x400000); for( i=0; i<8; ++i ) { 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; 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 *dst = auto_alloc_array(machine, UINT8, 0x800000); + UINT8 *src = memregion("maincpu")->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x800000); memcpy( dst, src, 0x800000 ); for( i=0; i<16; ++i ) { 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; 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 *dst = auto_alloc_array(machine, UINT8, 0x800000); + UINT8 *src = memregion("maincpu")->base(); + UINT8 *dst = auto_alloc_array(machine(), UINT8, 0x800000); memcpy( dst, src, 0x800000 ); for( i=0; i<16; ++i ) { 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 */ -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 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 ofst; int rom_size = 0x800000; - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + UINT8 *rom = memregion( "maincpu" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); for( i = 0; i < 0x100000; i++ ) { @@ -1273,19 +1262,19 @@ void mslug5_decrypt_68k(running_machine &machine) memcpy( buf, rom, rom_size ); memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 ); 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 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 ofst; int rom_size = 0x800000; - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + UINT8 *rom = memregion( "maincpu" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); for( i = 0; i < 0x100000; i++ ) { @@ -1318,18 +1307,18 @@ void svc_px_decrypt(running_machine &machine) memcpy( buf, rom, rom_size ); memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 ); 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 }; int i; int ofst; int rom_size = 0x900000; - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + UINT8 *rom = memregion( "maincpu" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); 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[0x100000], &buf[0x800000], 0x100000); 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 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 ofst; int rom_size = 0x900000; - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + UINT8 *rom = memregion( "maincpu" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); 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[0x100000], &buf[0x800000], 0x100000); memcpy (&rom[0x200000], &buf[0x100000], 0x700000); - auto_free( machine, buf ); + auto_free( machine(), buf ); } // 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 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 ofst; int rom_size = 0x900000; - UINT8 *rom = machine.root_device().memregion( "maincpu" )->base(); - UINT8 *buf = auto_alloc_array(machine, UINT8, rom_size ); + UINT8 *rom = memregion( "maincpu" )->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, rom_size ); 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[0x100000], &buf[0x800000], 0x100000); 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 */ -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 */ - UINT16 *rom = (UINT16 *)machine.root_device().memregion("ymsnd")->base(); - int size = machine.root_device().memregion("ymsnd")->bytes(); + UINT16 *rom = (UINT16 *)memregion("ymsnd")->base(); + int size = memregion("ymsnd")->bytes(); int i, j; if( rom != NULL ) { /* 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 ) ) { @@ -1485,13 +1474,13 @@ void neo_pcm2_snk_1999(running_machine &machine, int value) rom[ i + j ] = buffer[ j ^ (value/4) ]; } } - auto_free(machine, buffer); + auto_free(machine(), buffer); } } /* 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]={ {0x000000,0xa5000}, @@ -1509,8 +1498,8 @@ void neo_pcm2_swap(running_machine &machine, int value) {0xcb,0x29,0x7d,0x43,0xd2,0x3a,0xc2,0xb4}, {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 *buf = auto_alloc_array(machine, UINT8, 0x1000000); + UINT8 *src = memregion("ymsnd")->base(); + UINT8 *buf = auto_alloc_array(machine(), UINT8, 0x1000000); int i, j, d; memcpy(buf,src,0x1000000); @@ -1521,7 +1510,7 @@ void neo_pcm2_swap(running_machine &machine, int value) d=((i+addrs[value][0])&0xffffff); 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 */ -void kof2003biosdecode(running_machine &machine) +void neogeo_state::kof2003biosdecode() { static const UINT8 address[0x80]={ 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, }; - UINT16*src= (UINT16*)machine.root_device().memregion( "mainbios" )->base(); - UINT16*buf= auto_alloc_array(machine, UINT16, 0x80000/2); + UINT16*src= (UINT16*)memregion( "mainbios" )->base(); + UINT16*buf= auto_alloc_array(machine(), UINT16, 0x80000/2); int a,addr; for (a=0;a<0x80000/2;a++) @@ -1574,5 +1563,5 @@ void kof2003biosdecode(running_machine &machine) buf[addr]=src[a]; } memcpy(src,buf,0x80000); - auto_free(machine, buf); + auto_free(machine(), buf); } diff --git a/src/mame/machine/neoprot.c b/src/mame/machine/neoprot.c index bd88056f27f..75161edaa81 100644 --- a/src/mame/machine/neoprot.c +++ b/src/mame/machine/neoprot.c @@ -22,10 +22,9 @@ /************************ Fatal Fury 2 *************************/ -static READ16_HANDLER( fatfury2_protection_16_r ) -{ - neogeo_state *state = space.machine().driver_data(); - UINT16 res = state->m_fatfury2_prot_data >> 24; +READ16_MEMBER( neogeo_state::fatfury2_protection_16_r ) +{ + UINT16 res = m_fatfury2_prot_data >> 24; 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(); - switch (offset) { case 0x11112/2: /* data == 0x1111; expects 0xff000000 back */ - state->m_fatfury2_prot_data = 0xff000000; + m_fatfury2_prot_data = 0xff000000; break; case 0x33332/2: /* data == 0x3333; expects 0x0000ffff back */ - state->m_fatfury2_prot_data = 0x0000ffff; + m_fatfury2_prot_data = 0x0000ffff; break; case 0x44442/2: /* data == 0x4444; expects 0x00ff0000 back */ - state->m_fatfury2_prot_data = 0x00ff0000; + m_fatfury2_prot_data = 0x00ff0000; break; case 0x55552/2: /* data == 0x5555; read back from 55550, ffff0, 00000, ff000 */ - state->m_fatfury2_prot_data = 0xff00ff00; + m_fatfury2_prot_data = 0xff00ff00; break; case 0x56782/2: /* data == 0x1234; read back from 36000 *or* 36004 */ - state->m_fatfury2_prot_data = 0xf05a3601; + m_fatfury2_prot_data = 0xf05a3601; break; case 0x42812/2: /* data == 0x1824; read back from 36008 *or* 3600c */ - state->m_fatfury2_prot_data = 0x81422418; + m_fatfury2_prot_data = 0x81422418; break; case 0x55550/2: @@ -85,7 +82,7 @@ static WRITE16_HANDLER( fatfury2_protection_16_w ) case 0x36004/2: case 0x36008/2: case 0x3600c/2: - state->m_fatfury2_prot_data <<= 8; + m_fatfury2_prot_data <<= 8; break; default: @@ -95,17 +92,15 @@ static WRITE16_HANDLER( fatfury2_protection_16_w ) } -void fatfury2_install_protection( running_machine &machine ) -{ - neogeo_state *state = machine.driver_data(); - +void neogeo_state::fatfury2_install_protection() +{ /* the protection involves reading and writing addresses in the */ /* 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 ***************************************************************/ -static WRITE16_HANDLER ( kof98_prot_w ) +WRITE16_MEMBER( neogeo_state::kof98_prot_w ) { /* info from razoola */ - UINT16* mem16 = (UINT16*)space.machine().root_device().memregion("maincpu")->base(); + UINT16* mem16 = (UINT16*)memregion("maincpu")->base(); 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 */ - 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 ***************************************************************/ -static WRITE16_HANDLER( mslugx_protection_16_w ) +WRITE16_MEMBER( neogeo_state::mslugx_protection_16_w ) { - neogeo_state *state = space.machine().driver_data(); - switch (offset) { case 0x0/2: // start new read? - state->m_mslugx_command = 0; + m_mslugx_command = 0; break; case 0x2/2: // command? These are pulsed with data and then 0 case 0x4/2: - state->m_mslugx_command |= data; + m_mslugx_command |= data; break; case 0x6/2: // finished? break; case 0xa/2: // init? - state->m_mslugx_counter = 0; - state->m_mslugx_command = 0; + m_mslugx_counter = 0; + m_mslugx_command = 0; break; 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(); - UINT16 res = 0; - switch (state->m_mslugx_command) + switch (m_mslugx_command) { case 0x0001: { // $3bdc(?) and $3c30 (Register D7) - res = (space.read_byte(0xdedd2 + ((state->m_mslugx_counter >> 3) & 0xfff)) >> (~state->m_mslugx_counter & 0x07)) & 1; - state->m_mslugx_counter++; + res = (space.read_byte(0xdedd2 + ((m_mslugx_counter >> 3) & 0xfff)) >> (~m_mslugx_counter & 0x07)) & 1; + m_mslugx_counter++; } 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(); + 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)); - - state->save_item(NAME(state->m_mslugx_command)); - state->save_item(NAME(state->m_mslugx_counter)); + save_item(NAME(m_mslugx_command)); + save_item(NAME(m_mslugx_counter)); } @@ -230,7 +219,7 @@ void mslugx_install_protection( running_machine &machine ) thanks to Razoola ***************************************************************/ -static WRITE16_HANDLER( kof99_bankswitch_w ) +WRITE16_MEMBER( neogeo_state::kof99_bankswitch_w ) { int bankaddress; static const int bankoffset[64] = @@ -257,11 +246,11 @@ static WRITE16_HANDLER( kof99_bankswitch_w ) bankaddress = 0x100000 + bankoffset[data]; - space.machine().driver_data()->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 */ int bankaddress; @@ -294,11 +283,11 @@ static WRITE16_HANDLER( garou_bankswitch_w ) bankaddress = 0x100000 + bankoffset[data]; - space.machine().driver_data()->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 */ int bankaddress; @@ -333,11 +322,11 @@ static WRITE16_HANDLER( garouh_bankswitch_w ) bankaddress = 0x100000 + bankoffset[data]; - space.machine().driver_data()->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 */ int bankaddress; @@ -369,11 +358,11 @@ static WRITE16_HANDLER( mslug3_bankswitch_w ) bankaddress = 0x100000 + bankoffset[data]; - space.machine().driver_data()->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 */ int bankaddress; @@ -401,11 +390,11 @@ static WRITE16_HANDLER( kof2000_bankswitch_w ) bankaddress = 0x100000 + bankoffset[data]; - space.machine().driver_data()->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; } @@ -414,85 +403,82 @@ static READ16_HANDLER( prot_9a37_r ) /* information about the sma random number generator provided by razoola */ /* 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(); - UINT16 old = state->m_neogeo_rng; + UINT16 old = m_neogeo_rng; - UINT16 newbit = ((state->m_neogeo_rng >> 2) ^ - (state->m_neogeo_rng >> 3) ^ - (state->m_neogeo_rng >> 5) ^ - (state->m_neogeo_rng >> 6) ^ - (state->m_neogeo_rng >> 7) ^ - (state->m_neogeo_rng >>11) ^ - (state->m_neogeo_rng >>12) ^ - (state->m_neogeo_rng >>15)) & 1; + UINT16 newbit = ((m_neogeo_rng >> 2) ^ + (m_neogeo_rng >> 3) ^ + (m_neogeo_rng >> 5) ^ + (m_neogeo_rng >> 6) ^ + (m_neogeo_rng >> 7) ^ + (m_neogeo_rng >>11) ^ + (m_neogeo_rng >>12) ^ + (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; } -void neogeo_reset_rng( running_machine &machine ) +void neogeo_state::neogeo_reset_rng() { - neogeo_state *state = machine.driver_data(); - state->m_neogeo_rng = 0x2345; + 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(); - state->save_item(NAME(state->m_neogeo_rng)); + save_item(NAME(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_legacy_read_handler(addr2, addr2 + 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_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_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); + 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_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_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); + 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_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_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); + 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_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_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); + 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_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_legacy_read_handler(0x2fe446, 0x2fe447, FUNC(prot_9a37_r)); + 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_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 ***************************************************************/ -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(); - *(((UINT8*)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(offset)) = data; + *(((UINT8*)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(); - return *(((UINT8*)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(offset)); + return *(((UINT8*)m_pvc_cartridge_ram) + BYTE_XOR_LE(offset)); } -static void pvc_prot1( running_machine &machine ) +void neogeo_state::pvc_prot1() { UINT8 b1, b2; - b1 = pvc_r8(machine, 0x1fe1); - b2 = pvc_r8(machine, 0x1fe0); - pvc_w8(machine, 0x1fe2, (((b2 >> 0) & 0xf) << 1) | ((b1 >> 4) & 1)); - pvc_w8(machine, 0x1fe3, (((b2 >> 4) & 0xf) << 1) | ((b1 >> 5) & 1)); - pvc_w8(machine, 0x1fe4, (((b1 >> 0) & 0xf) << 1) | ((b1 >> 6) & 1)); - pvc_w8(machine, 0x1fe5, (b1 >> 7)); + b1 = pvc_r8(0x1fe1); + b2 = pvc_r8(0x1fe0); + pvc_w8(0x1fe2, (((b2 >> 0) & 0xf) << 1) | ((b1 >> 4) & 1)); + pvc_w8(0x1fe3, (((b2 >> 4) & 0xf) << 1) | ((b1 >> 5) & 1)); + pvc_w8(0x1fe4, (((b1 >> 0) & 0xf) << 1) | ((b1 >> 6) & 1)); + 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; - b1 = pvc_r8(machine, 0x1fe9); - b2 = pvc_r8(machine, 0x1fe8); - b3 = pvc_r8(machine, 0x1feb); - b4 = pvc_r8(machine, 0x1fea); - pvc_w8(machine, 0x1fec, (b2 >> 1) | ((b1 >> 1) << 4)); - pvc_w8(machine, 0x1fed, (b4 >> 1) | ((b2 & 1) << 4) | ((b1 & 1) << 5) | ((b4 & 1) << 6) | ((b3 & 1) << 7)); + b1 = pvc_r8(0x1fe9); + b2 = pvc_r8(0x1fe8); + b3 = pvc_r8(0x1feb); + b4 = pvc_r8(0x1fea); + pvc_w8(0x1fec, (b2 >> 1) | ((b1 >> 1) << 4)); + 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(); UINT32 bankaddress; - bankaddress = ((state->m_pvc_cartridge_ram[0xff8] >> 8)|(state->m_pvc_cartridge_ram[0xff9] << 8)); - *(((UINT8 *)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff0)) = 0xa0; - *(((UINT8 *)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff1)) &= 0xfe; - *(((UINT8 *)state->m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff3)) &= 0x7f; - state->neogeo_set_main_cpu_bank_address(bankaddress + 0x100000); + bankaddress = ((m_pvc_cartridge_ram[0xff8] >> 8)|(m_pvc_cartridge_ram[0xff9] << 8)); + *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff0)) = 0xa0; + *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff1)) &= 0xfe; + *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff3)) &= 0x7f; + 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(); - return state->m_pvc_cartridge_ram[offset]; + return 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(); - - COMBINE_DATA(&state->m_pvc_cartridge_ram[offset] ); + COMBINE_DATA(&m_pvc_cartridge_ram[offset] ); if (offset == 0xff0) - pvc_prot1(space.machine()); + pvc_prot1(); else if(offset >= 0xff4 && offset <= 0xff5) - pvc_prot2(space.machine()); + pvc_prot2(); else if(offset >= 0xff8) pvc_write_bankswitch(space); } -void install_pvc_protection( running_machine &machine ) +void neogeo_state::install_pvc_protection() { - neogeo_state *state = machine.driver_data(); - state->m_pvc_cartridge_ram = auto_alloc_array(machine, UINT16, 0x2000 / 2); - state->save_pointer(NAME(state->m_pvc_cartridge_ram), 0x2000 / 2); + m_pvc_cartridge_ram = auto_alloc_array(machine(), UINT16, 0x2000 / 2); + save_pointer(NAME(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)); } diff --git a/src/mess/drivers/ng_aes.c b/src/mess/drivers/ng_aes.c index 1dae38ce624..f12d16ae15e 100644 --- a/src/mess/drivers/ng_aes.c +++ b/src/mess/drivers/ng_aes.c @@ -1175,7 +1175,7 @@ MACHINE_RESET_MEMBER(ng_aes_state,neogeo) m_maincpu->reset(); - neogeo_reset_rng(machine()); + neogeo_reset_rng(); start_interrupt_timers();