// license:BSD-3-Clause // copyright-holders:David Haywood, ElSemi /*********************************************************************** PGM 022 + 025 PGM protection emulation this file contains the game / pgm specifc hookups for the IGS022/IGS025 protection chips, actual simulation is in igs025_igs022.c sed by The Killing Blade Dragon World 3 Dragon World 3 EX ---- ***********************************************************************/ #include "emu.h" #include "includes/pgm.h" #include "machine/pgmprot_igs025_igs022.h" /* The IGS022 is an MCU which performs encrypted DMA used by - The Killing Blade - Dragon World 3 - Dragon World 3 Ex There is also an automatic transfer which happens on startup using params stored in the data ROM. This has been verified on real hardware running without any 68k game program. */ /* NON-device stuff, game specific, keep here */ void pgm_022_025_state::pgm_dw3_decrypt() { int i; uint16_t *src = (uint16_t *) (memregion("maincpu")->base()+0x100000); int rom_size = 0x100000; for(i=0; ibase()+0x100000); int rom_size = 0x200000; for(i=0; iread()) & 0xff; m_igs025->m_kb_region = region - 0x16; m_igs025->m_kb_game_id = 0x89911400 | region; MACHINE_RESET_CALL_MEMBER(pgm); } MACHINE_RESET_MEMBER(pgm_022_025_state, dw3) { int region = (ioport(":Region")->read()) & 0xff; m_igs025->m_kb_region = region; m_igs025->m_kb_game_id = 0x00060000 | region; MACHINE_RESET_CALL_MEMBER(pgm); } void pgm_022_025_state::igs025_to_igs022_callback( void ) { // printf("igs025_to_igs022_callback\n"); m_igs022->IGS022_handle_command(); } void pgm_022_025_state::init_killbld() { pgm_basic_init(); pgm_killbld_decrypt(); // install and configure protection device(s) m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xd40000, 0xd40003, read16_delegate(FUNC(igs025_device::killbld_igs025_prot_r), (igs025_device*)m_igs025), write16_delegate(FUNC(igs025_device::killbld_igs025_prot_w), (igs025_device*)m_igs025)); m_igs022->m_sharedprotram = m_sharedprotram; m_igs025->m_kb_source_data = killbld_source_data; } void pgm_022_025_state::init_drgw3() { pgm_basic_init(); pgm_dw3_decrypt(); // install and configure protection device(s) m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xda5610, 0xda5613, read16_delegate(FUNC(igs025_device::killbld_igs025_prot_r), (igs025_device*)m_igs025), write16_delegate(FUNC(igs025_device::killbld_igs025_prot_w), (igs025_device*)m_igs025)); m_igs022->m_sharedprotram = m_sharedprotram; m_igs025->m_kb_source_data = dw3_source_data; } void pgm_022_025_state::killbld_mem(address_map &map) { pgm_mem(map); map(0x100000, 0x2fffff).bankr("bank1"); /* Game ROM */ map(0x300000, 0x303fff).ram().share("sharedprotram"); // Shared with protection device } MACHINE_CONFIG_START(pgm_022_025_state::pgm_022_025) pgmbase(config); MCFG_DEVICE_MODIFY("maincpu") MCFG_DEVICE_PROGRAM_MAP(killbld_mem) MCFG_DEVICE_ADD("igs025", IGS025, 0) MCFG_IGS025_SET_EXTERNAL_EXECUTE( pgm_022_025_state, igs025_to_igs022_callback ) MCFG_DEVICE_ADD("igs022", IGS022, 0) MACHINE_CONFIG_END MACHINE_CONFIG_START(pgm_022_025_state::pgm_022_025_dw3) pgm_022_025(config); MCFG_MACHINE_RESET_OVERRIDE(pgm_022_025_state, dw3) MACHINE_CONFIG_END MACHINE_CONFIG_START(pgm_022_025_state::pgm_022_025_killbld) pgm_022_025(config); MCFG_MACHINE_RESET_OVERRIDE(pgm_022_025_state, killbld) MACHINE_CONFIG_END INPUT_PORTS_START( killbld ) PORT_INCLUDE ( pgm ) PORT_MODIFY("Region") /* Region - supplied by protection device */ PORT_DIPNAME( 0x00ff, 0x0021, "Region" ) PORT_DIPSETTING( 0x0016, DEF_STR( Taiwan ) ) PORT_DIPSETTING( 0x0017, DEF_STR( China ) ) PORT_DIPSETTING( 0x0018, DEF_STR( Hong_Kong ) ) PORT_DIPSETTING( 0x0019, DEF_STR( Japan ) ) // PORT_DIPSETTING( 0x001a, "1a" ) // invalid // PORT_DIPSETTING( 0x001b, "1b" ) // invalid // PORT_DIPSETTING( 0x001c, "1c" ) // invalid // PORT_DIPSETTING( 0x001d, "1d" ) // invalid // PORT_DIPSETTING( 0x001e, "1e" ) // invalid // PORT_DIPSETTING( 0x001f, "1f" ) // invalid PORT_DIPSETTING( 0x0020, DEF_STR( Korea ) ) PORT_DIPSETTING( 0x0021, DEF_STR( World ) ) INPUT_PORTS_END INPUT_PORTS_START( dw3 ) PORT_INCLUDE ( pgm ) PORT_MODIFY("Region") /* Region - supplied by protection device */ PORT_CONFNAME( 0x000f, 0x0006, DEF_STR( Region ) ) // PORT_CONFSETTING( 0x0000, "0" ) PORT_CONFSETTING( 0x0001, DEF_STR( Japan ) ) PORT_CONFSETTING( 0x0002, DEF_STR( Korea )) PORT_CONFSETTING( 0x0003, DEF_STR( Taiwan ) ) PORT_CONFSETTING( 0x0004, DEF_STR( Hong_Kong ) ) // typo Hokg Kong PORT_CONFSETTING( 0x0005, DEF_STR( China ) ) PORT_CONFSETTING( 0x0006, DEF_STR( World ) ) PORT_CONFSETTING( 0x0007, "Singapore" ) INPUT_PORTS_END INPUT_PORTS_START( dw3j ) // for dw3100 set PORT_INCLUDE ( pgm ) PORT_MODIFY("Region") /* Region - supplied by protection device */ PORT_CONFNAME( 0x000f, 0x0001, DEF_STR( Region ) ) // PORT_CONFSETTING( 0x0000, "0" ) PORT_CONFSETTING( 0x0001, DEF_STR( Japan ) ) // PORT_CONFSETTING( 0x0002, DEF_STR( Korea )) // PORT_CONFSETTING( 0x0003, DEF_STR( Taiwan ) ) // PORT_CONFSETTING( 0x0004, DEF_STR( Hong_Kong ) ) // typo Hokg Kong // PORT_CONFSETTING( 0x0005, DEF_STR( China ) ) // PORT_CONFSETTING( 0x0006, DEF_STR( World ) ) // PORT_CONFSETTING( 0x0007, "Singapore" ) INPUT_PORTS_END