From be9039c3e09bd4d6f758360a147ef4ba23d373e8 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Sat, 11 Oct 2014 04:00:14 +0000 Subject: [PATCH] and a last bunch of generic cart slots. nw. --- src/mame/drivers/jaguar.c | 28 ++---- src/mess/drivers/megadriv.c | 39 ++++---- src/mess/drivers/microvsn.c | 52 ++++------ src/mess/drivers/n64.c | 21 ++-- src/mess/drivers/ngp.c | 194 ++++++++++++++++++------------------ src/mess/drivers/thomson.c | 38 +++---- src/mess/includes/thomson.h | 4 +- 7 files changed, 185 insertions(+), 191 deletions(-) diff --git a/src/mame/drivers/jaguar.c b/src/mame/drivers/jaguar.c index 1c722bcaa21..2cbf76e0dd6 100644 --- a/src/mame/drivers/jaguar.c +++ b/src/mame/drivers/jaguar.c @@ -340,13 +340,14 @@ Notes: #include "sound/dac.h" #include "includes/jaguar.h" #include "emuopts.h" -#include "imagedev/cartslot.h" #include "imagedev/snapquik.h" #include "sound/dac.h" #include "machine/eepromser.h" #include "sound/cdda.h" #include "cdrom.h" #include "imagedev/chd_cd.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" #define COJAG_CLOCK XTAL_52MHz @@ -1880,10 +1881,9 @@ static MACHINE_CONFIG_START( jaguar, jaguar_state ) MCFG_QUICKLOAD_ADD("quickload", jaguar_state, jaguar, "abs,bin,cof,jag,prg", 2) /* cartridge */ - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("j64,rom") - MCFG_CARTSLOT_INTERFACE("jaguar_cart") - MCFG_CARTSLOT_LOAD(jaguar_state,jaguar_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "jaguar_cart") + MCFG_GENERIC_EXTENSIONS("j64,rom,bin") + MCFG_GENERIC_LOAD(jaguar_state, jaguar_cart) /* software lists */ MCFG_SOFTWARE_LIST_ADD("cart_list","jaguar") @@ -2045,15 +2045,10 @@ void jaguar_state::cart_start() { /* Initialize for no cartridge present */ m_using_cart = false; - memset( m_cart_base, 0, memshare("cart")->bytes() ); + memset(m_cart_base, 0, memshare("cart")->bytes()); } DEVICE_IMAGE_LOAD_MEMBER( jaguar_state, jaguar_cart ) -{ - return cart_load(image); -} - -int jaguar_state::cart_load(device_image_interface &image) { UINT32 size, load_offset = 0; @@ -2064,12 +2059,12 @@ int jaguar_state::cart_load(device_image_interface &image) /* .rom files load & run at 802000 */ if (!core_stricmp(image.filetype(), "rom")) { - load_offset = 0x2000; // fix load address - m_cart_base[0x101]=0x802000; // fix exec address + load_offset = 0x2000; // fix load address + m_cart_base[0x101] = 0x802000; // fix exec address } /* Load cart into memory */ - image.fread( &memregion("maincpu")->base()[0x800000+load_offset], size); + image.fread(&memregion("maincpu")->base()[0x800000 + load_offset], size); } else { @@ -2084,7 +2079,7 @@ int jaguar_state::cart_load(device_image_interface &image) /* Skip the logo */ m_using_cart = true; -// m_cart_base[0x102] = 1; + // m_cart_base[0x102] = 1; /* Transfer control to the bios */ m_maincpu->set_pc(m_rom_base[1]); @@ -2106,7 +2101,6 @@ int jaguar_state::cart_load(device_image_interface &image) ROM_START( jaguar ) ROM_REGION( 0x1000000, "maincpu", 0 ) /* 4MB for RAM at 0 */ ROM_LOAD16_WORD( "jagboot.rom", 0xe00000, 0x020000, CRC(fb731aaa) SHA1(f8991b0c385f4e5002fa2a7e2f5e61e8c5213356) ) - ROM_CART_LOAD("cart", 0x800000, 0x600000, ROM_NOMIRROR) ROM_REGION16_BE( 0x1000, "waverom", 0 ) ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) ) @@ -2115,7 +2109,7 @@ ROM_END ROM_START( jaguarcd ) ROM_REGION( 0x1000000, "maincpu", 0 ) ROM_LOAD16_WORD( "jagboot.rom", 0xe00000, 0x020000, CRC(fb731aaa) SHA1(f8991b0c385f4e5002fa2a7e2f5e61e8c5213356) ) - ROM_CART_LOAD("cart", 0x800000, 0x600000, ROM_NOMIRROR) // TODO: needs to be removed (CD BIOS runs in the cart space) + // TODO: cart needs to be removed (CD BIOS runs in the cart space) ROM_REGION(0x40000, "cdbios", 0 ) ROM_SYSTEM_BIOS( 0, "default", "Jaguar CD" ) diff --git a/src/mess/drivers/megadriv.c b/src/mess/drivers/megadriv.c index 1d15d3ef560..0527f2345d0 100644 --- a/src/mess/drivers/megadriv.c +++ b/src/mess/drivers/megadriv.c @@ -4,7 +4,9 @@ #include "sound/sn76496.h" #include "imagedev/chd_cd.h" -#include "imagedev/cartslot.h" + +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" #include "formats/imageutl.h" @@ -465,8 +467,6 @@ DRIVER_INIT_MEMBER(md_cons_state, md_jpn) /****************************************** 32X emulation ****************************************/ -// FIXME: non-softlist loading should keep using ROM_CART_LOAD in the ROM definitions, -// once we better integrate softlist with the old loading procedures DEVICE_IMAGE_LOAD_MEMBER( md_cons_state, _32x_cart ) { UINT32 length; @@ -555,11 +555,10 @@ static MACHINE_CONFIG_START( genesis_32x, md_cons_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", (0.25)/2) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", (0.25)/2) - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("32x,bin") - MCFG_CARTSLOT_MANDATORY - MCFG_CARTSLOT_INTERFACE("_32x_cart") - MCFG_CARTSLOT_LOAD(md_cons_state, _32x_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "_32x_cart") + MCFG_GENERIC_EXTENSIONS("32x,bin") + MCFG_GENERIC_MANDATORY + MCFG_GENERIC_LOAD(md_cons_state, _32x_cart) MCFG_SOFTWARE_LIST_ADD("cart_list","32x") MCFG_SOFTWARE_LIST_FILTER("cart_list","NTSC-U") @@ -597,11 +596,10 @@ static MACHINE_CONFIG_START( mdj_32x, md_cons_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", (0.25)/2) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", (0.25)/2) - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("32x,bin") - MCFG_CARTSLOT_MANDATORY - MCFG_CARTSLOT_INTERFACE("_32x_cart") - MCFG_CARTSLOT_LOAD(md_cons_state, _32x_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "_32x_cart") + MCFG_GENERIC_EXTENSIONS("32x,bin") + MCFG_GENERIC_MANDATORY + MCFG_GENERIC_LOAD(md_cons_state, _32x_cart) MCFG_SOFTWARE_LIST_ADD("cart_list","32x") MCFG_SOFTWARE_LIST_FILTER("cart_list","NTSC-J") @@ -639,11 +637,10 @@ static MACHINE_CONFIG_START( md_32x, md_cons_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", (0.25)/2) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", (0.25)/2) - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("32x,bin") - MCFG_CARTSLOT_MANDATORY - MCFG_CARTSLOT_INTERFACE("_32x_cart") - MCFG_CARTSLOT_LOAD(md_cons_state, _32x_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "_32x_cart") + MCFG_GENERIC_EXTENSIONS("32x,bin") + MCFG_GENERIC_MANDATORY + MCFG_GENERIC_LOAD(md_cons_state, _32x_cart) MCFG_SOFTWARE_LIST_ADD("cart_list","32x") MCFG_SOFTWARE_LIST_FILTER("cart_list","PAL") @@ -748,8 +745,10 @@ static MACHINE_CONFIG_DERIVED( genesis_32x_scd, genesis_32x ) MCFG_MACHINE_START_OVERRIDE(md_cons_state, ms_megacd) - MCFG_DEVICE_MODIFY("cart") - MCFG_CARTSLOT_NOT_MANDATORY + MCFG_DEVICE_REMOVE("cartslot") + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "_32x_cart") + MCFG_GENERIC_EXTENSIONS("32x,bin") + MCFG_GENERIC_LOAD(md_cons_state, _32x_cart) //MCFG_QUANTUM_PERFECT_CPU("32x_master_sh2") MACHINE_CONFIG_END diff --git a/src/mess/drivers/microvsn.c b/src/mess/drivers/microvsn.c index ae82cc1a260..6b73f81c454 100644 --- a/src/mess/drivers/microvsn.c +++ b/src/mess/drivers/microvsn.c @@ -17,9 +17,11 @@ of the games were clocked at around 500KHz, 550KHz, or 300KHz. #include "cpu/mcs48/mcs48.h" #include "cpu/tms0980/tms0980.h" #include "sound/dac.h" -#include "imagedev/cartslot.h" #include "rendlay.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" + #define LOG 0 @@ -31,7 +33,9 @@ public: : driver_device(mconfig, type, tag), m_dac( *this, "dac" ), m_i8021( *this, "maincpu1" ), - m_tms1100( *this, "maincpu2" ) { } + m_tms1100( *this, "maincpu2" ), + m_cart(*this, "cartslot") + { } UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -40,7 +44,7 @@ public: DECLARE_MACHINE_RESET(microvision); void screen_vblank(screen_device &screen, bool state); - DECLARE_DEVICE_IMAGE_LOAD_MEMBER( microvision_cart ); + DECLARE_DEVICE_IMAGE_LOAD_MEMBER( microvsn_cart ); // i8021 interface DECLARE_WRITE8_MEMBER(i8021_p0_write); @@ -86,6 +90,7 @@ protected: required_device m_dac; required_device m_i8021; required_device m_tms1100; + required_device m_cart; // Timers static const device_timer_id TIMER_PADDLE = 0; @@ -507,22 +512,13 @@ static const UINT16 microvision_output_pla_1[0x20] = }; -DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) +DEVICE_IMAGE_LOAD_MEMBER(microvision_state, microvsn_cart) { UINT8 *rom1 = memregion("maincpu1")->base(); UINT8 *rom2 = memregion("maincpu2")->base(); - UINT32 file_size; + UINT32 file_size = m_cart->common_get_size("rom"); m_pla = 0; - if (image.software_entry() == NULL) - { - file_size = image.length(); - } - else - { - file_size = image.get_software_region_length("rom"); - } - if ( file_size != 1024 && file_size != 2048 ) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid rom file size"); @@ -532,7 +528,7 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) /* Read cartridge */ if (image.software_entry() == NULL) { - if (image.fread( rom1, file_size) != file_size) + if (image.fread(rom1, file_size) != file_size) { image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file"); return IMAGE_INIT_FAIL; @@ -546,12 +542,10 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) // Get PLA type const char *pla = image.get_feature("pla"); - if ( pla ) - { + if (pla) m_pla = 1; - } - tms1xxx_cpu_device::set_output_pla( m_tms1100, m_pla ? microvision_output_pla_1 : microvision_output_pla_0 ); + tms1xxx_cpu_device::set_output_pla(m_tms1100, m_pla ? microvision_output_pla_1 : microvision_output_pla_0); // Set default setting for PCB type and RC type m_pcb_type = microvision_state::PCB_TYPE_UNKNOWN; @@ -560,7 +554,7 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) // Detect settings for PCB type const char *pcb = image.get_feature("pcb"); - if ( pcb != NULL ) + if (pcb) { static const struct { const char *pcb_name; microvision_state::pcb_type pcbtype; } pcb_types[] = { @@ -570,7 +564,7 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) { "7924952D02", microvision_state::PCB_TYPE_7924952D02 } }; - for (int i = 0; i < ARRAY_LENGTH(pcb_types) && m_pcb_type == microvision_state::PCB_TYPE_UNKNOWN; i++ ) + for (int i = 0; i < ARRAY_LENGTH(pcb_types) && m_pcb_type == microvision_state::PCB_TYPE_UNKNOWN; i++) { if (!core_stricmp(pcb, pcb_types[i].pcb_name)) { @@ -582,7 +576,7 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) // Detect settings for RC types const char *rc = image.get_feature("rc"); - if ( rc != NULL ) + if (rc) { static const struct { const char *rc_name; microvision_state::rc_type rctype; } rc_types[] = { @@ -591,7 +585,7 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) { "100pf/39.4K", microvision_state::RC_TYPE_100PF_39_4K } }; - for ( int i = 0; i < ARRAY_LENGTH(rc_types) && m_rc_type == microvision_state::RC_TYPE_UNKNOWN; i++ ) + for (int i = 0; i < ARRAY_LENGTH(rc_types) && m_rc_type == microvision_state::RC_TYPE_UNKNOWN; i++) { if (!core_stricmp(rc, rc_types[i].rc_name)) { @@ -602,13 +596,13 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state,microvision_cart) } // Mirror rom data to maincpu2 region - memcpy( rom2, rom1, file_size ); + memcpy(rom2, rom1, file_size); // Based on file size select cpu: // - 1024 -> I8021 // - 2048 -> TI TMS1100 - switch ( file_size ) + switch (file_size) { case 1024: m_cpu_type = microvision_state::CPU_TYPE_I8021; @@ -689,11 +683,9 @@ static MACHINE_CONFIG_START( microvision, microvision_state ) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("bin") - MCFG_CARTSLOT_MANDATORY - MCFG_CARTSLOT_INTERFACE("microvision_cart") - MCFG_CARTSLOT_LOAD(microvision_state,microvision_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "microvision_cart") + MCFG_GENERIC_MANDATORY + MCFG_GENERIC_LOAD(microvision_state, microvsn_cart) /* Software lists */ MCFG_SOFTWARE_LIST_ADD("cart_list","microvision") diff --git a/src/mess/drivers/n64.c b/src/mess/drivers/n64.c index 71fc634c845..a25a2780689 100644 --- a/src/mess/drivers/n64.c +++ b/src/mess/drivers/n64.c @@ -13,8 +13,9 @@ #include "cpu/rsp/rsp.h" #include "cpu/mips/mips3.h" #include "sound/dmadac.h" -#include "imagedev/cartslot.h" #include "includes/n64.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" class n64_mess_state : public n64_state { @@ -185,7 +186,7 @@ DEVICE_IMAGE_LOAD_MEMBER(n64_mess_state,n64_cart) if (image.software_entry() == NULL) { - length = image.fread( cart, 0x4000000); + length = image.fread(cart, 0x4000000); } else { @@ -315,11 +316,10 @@ static MACHINE_CONFIG_START( n64, n64_mess_state ) MCFG_N64_PERIPHS_ADD("rcp"); /* cartridge */ - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("v64,z64,rom,n64,bin") - MCFG_CARTSLOT_MANDATORY - MCFG_CARTSLOT_INTERFACE("n64_cart") - MCFG_CARTSLOT_LOAD(n64_mess_state,n64_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "n64_cart") + MCFG_GENERIC_EXTENSIONS("v64,z64,rom,n64,bin") + MCFG_GENERIC_MANDATORY + MCFG_GENERIC_LOAD(n64_mess_state, n64_cart) /* software lists */ MCFG_SOFTWARE_LIST_ADD("cart_list","n64") @@ -331,8 +331,11 @@ static MACHINE_CONFIG_DERIVED( n64dd, n64 ) MCFG_MACHINE_START_OVERRIDE(n64_mess_state, n64dd) - MCFG_CARTSLOT_MODIFY("cart") - MCFG_CARTSLOT_NOT_MANDATORY + MCFG_DEVICE_REMOVE("cartslot") + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "n64_cart") + MCFG_GENERIC_EXTENSIONS("v64,z64,rom,n64,bin") + MCFG_GENERIC_LOAD(n64_mess_state, n64_cart) + MACHINE_CONFIG_END ROM_START( n64 ) diff --git a/src/mess/drivers/ngp.c b/src/mess/drivers/ngp.c index 16fbfd223a4..00dafbee343 100644 --- a/src/mess/drivers/ngp.c +++ b/src/mess/drivers/ngp.c @@ -98,12 +98,14 @@ the Neogeo Pocket. #include "emu.h" #include "cpu/tlcs900/tlcs900.h" #include "cpu/z80/z80.h" -#include "imagedev/cartslot.h" #include "sound/t6w28.h" #include "sound/dac.h" #include "video/k1ge.h" #include "rendlay.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" + enum flash_state { F_READ, /* xxxx F0 or 5555 AA 2AAA 55 5555 F0 */ @@ -124,16 +126,18 @@ public: ngp_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), device_nvram_interface(mconfig, *this), - m_tlcs900( *this, "maincpu" ), - m_z80( *this, "soundcpu" ), - m_t6w28( *this, "t6w28" ), - m_dac_l( *this, "dac_l" ), - m_dac_r( *this, "dac_r" ), - m_mainram( *this, "mainram" ), - m_k1ge( *this, "k1ge" ), - m_io_controls( *this, "Controls" ), - m_io_power( *this, "Power" ) , - m_maincpu(*this, "maincpu") { + m_tlcs900(*this, "maincpu"), + m_z80(*this, "soundcpu"), + m_t6w28(*this, "t6w28"), + m_dac_l(*this, "dac_l"), + m_dac_r(*this, "dac_r"), + m_cart(*this, "cartslot"), + m_mainram(*this, "mainram"), + m_k1ge(*this, "k1ge"), + m_io_controls(*this, "Controls"), + m_io_power(*this, "Power") , + m_maincpu(*this, "maincpu") + { m_flash_chip[0].present = 0; m_flash_chip[0].state = F_READ; m_flash_chip[0].data = NULL; @@ -167,6 +171,7 @@ public: required_device m_t6w28; required_device m_dac_l; required_device m_dac_r; + required_device m_cart; required_shared_ptr m_mainram; required_device m_k1ge; @@ -542,8 +547,8 @@ static ADDRESS_MAP_START( ngp_mem, AS_PROGRAM, 8, ngp_state ) AM_RANGE( 0x004000, 0x006fff ) AM_RAM AM_SHARE("mainram") /* work ram */ AM_RANGE( 0x007000, 0x007fff ) AM_RAM AM_SHARE("share1") /* shared with sound cpu */ AM_RANGE( 0x008000, 0x00bfff ) AM_DEVREADWRITE("k1ge", k1ge_device, read, write) /* video chip */ - AM_RANGE( 0x200000, 0x3fffff ) AM_ROM AM_WRITE(flash0_w) AM_REGION("cart", 0) /* cart area #1 */ - AM_RANGE( 0x800000, 0x9fffff ) AM_ROM AM_WRITE(flash1_w) AM_REGION("cart", 0x200000) /* cart area #2 */ + AM_RANGE( 0x200000, 0x3fffff ) AM_WRITE(flash0_w) /* cart area #1 */ + AM_RANGE( 0x800000, 0x9fffff ) AM_WRITE(flash1_w) /* cart area #2 */ AM_RANGE( 0xff0000, 0xffffff ) AM_ROM AM_REGION("maincpu", 0) /* system rom */ ADDRESS_MAP_END @@ -637,43 +642,57 @@ WRITE8_MEMBER( ngp_state::ngp_tlcs900_porta ) void ngp_state::machine_start() { - UINT8 *cart = memregion("cart")->base(); + if (m_cart->exists()) + { + astring region_tag; + UINT8 *cart = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG))->base(); - m_flash_chip[0].data = cart; - m_flash_chip[0].org_data[0] = m_flash_chip[0].data[0]; - m_flash_chip[0].org_data[1] = m_flash_chip[0].data[1]; - m_flash_chip[0].org_data[2] = m_flash_chip[0].data[2]; - m_flash_chip[0].org_data[3] = m_flash_chip[0].data[3]; - m_flash_chip[0].org_data[4] = m_flash_chip[0].data[0x7c000]; - m_flash_chip[0].org_data[5] = m_flash_chip[0].data[0x7c001]; - m_flash_chip[0].org_data[6] = m_flash_chip[0].data[0x7c002]; - m_flash_chip[0].org_data[7] = m_flash_chip[0].data[0x7c003]; - m_flash_chip[0].org_data[8] = m_flash_chip[0].data[0xfc000]; - m_flash_chip[0].org_data[9] = m_flash_chip[0].data[0xfc001]; - m_flash_chip[0].org_data[10] = m_flash_chip[0].data[0xfc002]; - m_flash_chip[0].org_data[11] = m_flash_chip[0].data[0xfc003]; - m_flash_chip[0].org_data[12] = m_flash_chip[0].data[0x1fc000]; - m_flash_chip[0].org_data[13] = m_flash_chip[0].data[0x1fc001]; - m_flash_chip[0].org_data[14] = m_flash_chip[0].data[0x1fc002]; - m_flash_chip[0].org_data[15] = m_flash_chip[0].data[0x1fc003]; - - m_flash_chip[1].data = cart + 0x200000; - m_flash_chip[1].org_data[0] = m_flash_chip[1].data[0]; - m_flash_chip[1].org_data[1] = m_flash_chip[1].data[1]; - m_flash_chip[1].org_data[2] = m_flash_chip[1].data[2]; - m_flash_chip[1].org_data[3] = m_flash_chip[1].data[3]; - m_flash_chip[1].org_data[4] = m_flash_chip[1].data[0x7c000]; - m_flash_chip[1].org_data[5] = m_flash_chip[1].data[0x7c001]; - m_flash_chip[1].org_data[6] = m_flash_chip[1].data[0x7c002]; - m_flash_chip[1].org_data[7] = m_flash_chip[1].data[0x7c003]; - m_flash_chip[1].org_data[8] = m_flash_chip[1].data[0xfc000]; - m_flash_chip[1].org_data[9] = m_flash_chip[1].data[0xfc001]; - m_flash_chip[1].org_data[10] = m_flash_chip[1].data[0xfc002]; - m_flash_chip[1].org_data[11] = m_flash_chip[1].data[0xfc003]; - m_flash_chip[1].org_data[12] = m_flash_chip[1].data[0x1fc000]; - m_flash_chip[1].org_data[13] = m_flash_chip[1].data[0x1fc001]; - m_flash_chip[1].org_data[14] = m_flash_chip[1].data[0x1fc002]; - m_flash_chip[1].org_data[15] = m_flash_chip[1].data[0x1fc003]; + m_maincpu->space(AS_PROGRAM).install_read_bank(0x200000, 0x3fffff, "flash0"); + m_maincpu->space(AS_PROGRAM).install_read_bank(0x800000, 0x9fffff, "flash1"); + membank("flash0")->set_base(cart); + membank("flash1")->set_base(cart + 0x200000); + + m_flash_chip[0].data = cart; + m_flash_chip[0].org_data[0] = m_flash_chip[0].data[0]; + m_flash_chip[0].org_data[1] = m_flash_chip[0].data[1]; + m_flash_chip[0].org_data[2] = m_flash_chip[0].data[2]; + m_flash_chip[0].org_data[3] = m_flash_chip[0].data[3]; + m_flash_chip[0].org_data[4] = m_flash_chip[0].data[0x7c000]; + m_flash_chip[0].org_data[5] = m_flash_chip[0].data[0x7c001]; + m_flash_chip[0].org_data[6] = m_flash_chip[0].data[0x7c002]; + m_flash_chip[0].org_data[7] = m_flash_chip[0].data[0x7c003]; + m_flash_chip[0].org_data[8] = m_flash_chip[0].data[0xfc000]; + m_flash_chip[0].org_data[9] = m_flash_chip[0].data[0xfc001]; + m_flash_chip[0].org_data[10] = m_flash_chip[0].data[0xfc002]; + m_flash_chip[0].org_data[11] = m_flash_chip[0].data[0xfc003]; + m_flash_chip[0].org_data[12] = m_flash_chip[0].data[0x1fc000]; + m_flash_chip[0].org_data[13] = m_flash_chip[0].data[0x1fc001]; + m_flash_chip[0].org_data[14] = m_flash_chip[0].data[0x1fc002]; + m_flash_chip[0].org_data[15] = m_flash_chip[0].data[0x1fc003]; + + m_flash_chip[1].data = cart + 0x200000; + m_flash_chip[1].org_data[0] = m_flash_chip[1].data[0]; + m_flash_chip[1].org_data[1] = m_flash_chip[1].data[1]; + m_flash_chip[1].org_data[2] = m_flash_chip[1].data[2]; + m_flash_chip[1].org_data[3] = m_flash_chip[1].data[3]; + m_flash_chip[1].org_data[4] = m_flash_chip[1].data[0x7c000]; + m_flash_chip[1].org_data[5] = m_flash_chip[1].data[0x7c001]; + m_flash_chip[1].org_data[6] = m_flash_chip[1].data[0x7c002]; + m_flash_chip[1].org_data[7] = m_flash_chip[1].data[0x7c003]; + m_flash_chip[1].org_data[8] = m_flash_chip[1].data[0xfc000]; + m_flash_chip[1].org_data[9] = m_flash_chip[1].data[0xfc001]; + m_flash_chip[1].org_data[10] = m_flash_chip[1].data[0xfc002]; + m_flash_chip[1].org_data[11] = m_flash_chip[1].data[0xfc003]; + m_flash_chip[1].org_data[12] = m_flash_chip[1].data[0x1fc000]; + m_flash_chip[1].org_data[13] = m_flash_chip[1].data[0x1fc001]; + m_flash_chip[1].org_data[14] = m_flash_chip[1].data[0x1fc002]; + m_flash_chip[1].org_data[15] = m_flash_chip[1].data[0x1fc003]; + } + else + { + m_maincpu->space(AS_PROGRAM).unmap_read(0x200000, 0x3fffff); + m_maincpu->space(AS_PROGRAM).unmap_read(0x800000, 0x9fffff); + } m_seconds_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ngp_state::ngp_seconds_callback),this)); m_seconds_timer->adjust( attotime::from_seconds(1), 0, attotime::from_seconds(1) ); @@ -719,35 +738,25 @@ UINT32 ngp_state::screen_update_ngp(screen_device &screen, bitmap_ind16 &bitmap, DEVICE_IMAGE_LOAD_MEMBER( ngp_state, ngp_cart ) { - UINT8 *cart = memregion("cart")->base(); - UINT32 filesize; - - if (image.software_entry() == NULL) + UINT32 size = m_cart->common_get_size("rom"); + + if (size != 0x8000 && size != 0x80000 && size != 0x100000 && size != 0x200000 && size != 0x400000) { - filesize = image.length(); - - if (filesize != 0x8000 && filesize != 0x80000 && filesize != 0x100000 && filesize != 0x200000 && filesize != 0x400000) - { - image.seterror(IMAGE_ERROR_UNSPECIFIED, "Incorrect or not support cartridge size"); - return IMAGE_INIT_FAIL; - } - - if (image.fread( cart, filesize) != filesize) - { - image.seterror(IMAGE_ERROR_UNSPECIFIED, "Error loading file"); - return IMAGE_INIT_FAIL; - } + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); + return IMAGE_INIT_FAIL; } - else - { - filesize = image.get_software_region_length("rom"); - memcpy(cart, image.get_software_region("rom"), filesize); - } - + + // alloc 0x400000 ROM to simplify mapping in the address map + m_cart->rom_alloc(0x400000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + //printf("%2x%2x - %x - %x\n", (unsigned int) memregion("cart")->u8(0x20), (unsigned int) memregion("cart")->u8(0x21), // (unsigned int) memregion("cart")->u8(0x22), (unsigned int) memregion("cart")->u8(0x23)); m_flash_chip[0].manufacturer_id = 0x98; - switch( filesize ) + m_flash_chip[0].present = 1; + m_flash_chip[0].state = F_READ; + + switch (size) { case 0x8000: case 0x80000: @@ -757,19 +766,18 @@ DEVICE_IMAGE_LOAD_MEMBER( ngp_state, ngp_cart ) m_flash_chip[0].device_id = 0x2c; break; case 0x200000: - m_flash_chip[0].device_id = 0x2f; - break; case 0x400000: m_flash_chip[0].device_id = 0x2f; - m_flash_chip[1].manufacturer_id = 0x98; - m_flash_chip[1].device_id = 0x2f; - m_flash_chip[1].present = 0; - m_flash_chip[1].state = F_READ; break; } - m_flash_chip[0].present = 1; - m_flash_chip[0].state = F_READ; + if (size == 0x400000) + { + m_flash_chip[1].manufacturer_id = 0x98; + m_flash_chip[1].device_id = 0x2f; + m_flash_chip[1].present = 1; + m_flash_chip[1].state = F_READ; + } return IMAGE_INIT_PASS; } @@ -841,12 +849,10 @@ static MACHINE_CONFIG_DERIVED( ngp, ngp_common ) MCFG_SCREEN_MODIFY("screen") MCFG_SCREEN_PALETTE("k1ge:palette") - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("bin,ngp,npc,ngc") - MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_LOAD(ngp_state, ngp_cart) - MCFG_CARTSLOT_INTERFACE("ngp_cart") - MCFG_CARTSLOT_UNLOAD(ngp_state, ngp_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "ngp_cart") + MCFG_GENERIC_EXTENSIONS("bin,ngp,npc,ngc") + MCFG_GENERIC_LOAD(ngp_state, ngp_cart) + MCFG_GENERIC_UNLOAD(ngp_state, ngp_cart) /* software lists */ MCFG_SOFTWARE_LIST_ADD("cart_list","ngp") @@ -860,12 +866,10 @@ static MACHINE_CONFIG_DERIVED( ngpc, ngp_common ) MCFG_SCREEN_MODIFY("screen") MCFG_SCREEN_PALETTE("k1ge:palette") - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("bin,ngp,npc,ngc") - MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_LOAD(ngp_state,ngp_cart) - MCFG_CARTSLOT_INTERFACE("ngp_cart") - MCFG_CARTSLOT_UNLOAD(ngp_state,ngp_cart) + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "ngp_cart") + MCFG_GENERIC_EXTENSIONS("bin,ngp,npc,ngc") + MCFG_GENERIC_LOAD(ngp_state, ngp_cart) + MCFG_GENERIC_UNLOAD(ngp_state, ngp_cart) /* software lists */ MCFG_SOFTWARE_LIST_ADD("cart_list","ngpc") @@ -876,16 +880,12 @@ MACHINE_CONFIG_END ROM_START( ngp ) ROM_REGION( 0x10000, "maincpu" , 0 ) ROM_LOAD( "ngp_bios.ngp", 0x0000, 0x10000, CRC(6232df8d) SHA1(2f6429b68446536d8b03f35d02f1e98beb6460a0) ) - - ROM_REGION( 0x400000, "cart", ROMREGION_ERASEFF ) ROM_END ROM_START( ngpc ) ROM_REGION( 0x10000, "maincpu", 0 ) ROM_LOAD( "ngpcbios.rom", 0x0000, 0x10000, CRC(6eeb6f40) SHA1(edc13192054a59be49c6d55f83b70e2510968e86) ) - - ROM_REGION( 0x400000, "cart", ROMREGION_ERASEFF ) ROM_END diff --git a/src/mess/drivers/thomson.c b/src/mess/drivers/thomson.c index 696ab3ed17a..1ad8eacabce 100644 --- a/src/mess/drivers/thomson.c +++ b/src/mess/drivers/thomson.c @@ -715,11 +715,10 @@ static MACHINE_CONFIG_START( to7, thomson_state ) /* cartridge */ - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("m7,rom") - MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_LOAD(thomson_state,to7_cartridge) - MCFG_CARTSLOT_INTERFACE("to7_cart") + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "to7_cart") + MCFG_GENERIC_EXTENSIONS("m7,rom") + MCFG_GENERIC_LOAD(thomson_state, to7_cartridge) + MCFG_SOFTWARE_LIST_ADD("cart_list","to7_cart") /* internal ram */ @@ -906,8 +905,11 @@ static MACHINE_CONFIG_DERIVED( to770, to7 ) MCFG_DEVICE_MODIFY("mc6846") MCFG_MC6846_OUT_PORT_CB(WRITE8(thomson_state, to770_timer_port_out)) - MCFG_CARTSLOT_MODIFY("cart") - MCFG_CARTSLOT_INTERFACE("to770_cart") + MCFG_DEVICE_REMOVE("cartslot") + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "to770_cart") + MCFG_GENERIC_EXTENSIONS("m7,rom") + MCFG_GENERIC_LOAD(thomson_state, to7_cartridge) + MCFG_DEVICE_REMOVE("cart_list") MCFG_SOFTWARE_LIST_ADD("cart_list","to770_cart") @@ -1103,10 +1105,10 @@ static MACHINE_CONFIG_DERIVED( mo5, to7 ) MCFG_PIA_CB2_HANDLER(NULL) MCFG_PIA_IRQB_HANDLER(WRITELINE(thomson_state, thom_irq_1)) /* WARNING: differs from TO7 ! */ - MCFG_CARTSLOT_MODIFY("cart") - MCFG_CARTSLOT_EXTENSION_LIST("m5,rom") - MCFG_CARTSLOT_LOAD(thomson_state,mo5_cartridge) - MCFG_CARTSLOT_INTERFACE("mo5_cart") + MCFG_DEVICE_REMOVE("cartslot") + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "mo5_cart") + MCFG_GENERIC_EXTENSIONS("m5,rom") + MCFG_GENERIC_LOAD(thomson_state, mo5_cartridge) MCFG_DEVICE_REMOVE("cart_list") MCFG_SOFTWARE_LIST_ADD("cart_list","mo5_cart") @@ -2179,9 +2181,10 @@ static MACHINE_CONFIG_DERIVED( mo6, to7 ) MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics") - MCFG_CARTSLOT_MODIFY("cart") - MCFG_CARTSLOT_EXTENSION_LIST("m5,rom") - MCFG_CARTSLOT_LOAD(thomson_state, mo5_cartridge) + MCFG_DEVICE_REMOVE("cartslot") + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "mo5_cart") + MCFG_GENERIC_EXTENSIONS("m5,rom") + MCFG_GENERIC_LOAD(thomson_state, mo5_cartridge) /* internal ram */ MCFG_RAM_MODIFY(RAM_TAG) @@ -2420,9 +2423,10 @@ static MACHINE_CONFIG_DERIVED( mo5nr, to7 ) MCFG_DEVICE_ADD("cent_data_in", INPUT_BUFFER, 0) MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics") - MCFG_CARTSLOT_MODIFY("cart") - MCFG_CARTSLOT_EXTENSION_LIST("m5,rom") - MCFG_CARTSLOT_LOAD(thomson_state, mo5_cartridge) + MCFG_DEVICE_REMOVE("cartslot") + MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "mo5_cart") + MCFG_GENERIC_EXTENSIONS("m5,rom") + MCFG_GENERIC_LOAD(thomson_state, mo5_cartridge) /* internal ram */ MCFG_RAM_MODIFY(RAM_TAG) diff --git a/src/mess/includes/thomson.h b/src/mess/includes/thomson.h index 9faf935d146..75254b3961d 100644 --- a/src/mess/includes/thomson.h +++ b/src/mess/includes/thomson.h @@ -19,7 +19,6 @@ #include "sound/dac.h" #include "audio/mea8000.h" #include "bus/centronics/ctronics.h" -#include "imagedev/cartslot.h" #include "imagedev/cassette.h" #include "machine/mc6843.h" #include "machine/mc6846.h" @@ -29,6 +28,9 @@ #include "machine/thomflop.h" #include "machine/ram.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" + /* 6821 PIAs */ #define THOM_PIA_SYS "pia_0" /* system PIA */