From ced971745390f198aaf849f941ad608338f61a4a Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Fri, 4 Apr 2014 17:23:15 +0000 Subject: [PATCH] (MESS) bbc.c: fixed external cart slot -cart1 for the BBC Master (demo cart runs properly now), added second external slot -cart2 (same functionality as -cart1). Expansion ROM slots, which are handled as internal cart slot, are now accessible via -cart3/-cart6 media switch, until they are converted to proper slot devices. [Fabio Priuli] --- hash/bbcm_cart.xml | 6 +- src/mess/drivers/bbc.c | 27 +++++--- src/mess/includes/bbc.h | 3 +- src/mess/machine/bbc.c | 148 ++++++++++++++++++---------------------- 4 files changed, 87 insertions(+), 97 deletions(-) diff --git a/hash/bbcm_cart.xml b/hash/bbcm_cart.xml index c9a48d80930..7c42ea04a3a 100644 --- a/hash/bbcm_cart.xml +++ b/hash/bbcm_cart.xml @@ -15,11 +15,9 @@ 198? Acorn - + - - - + diff --git a/src/mess/drivers/bbc.c b/src/mess/drivers/bbc.c index 169080b1517..54c6f6362bb 100644 --- a/src/mess/drivers/bbc.c +++ b/src/mess/drivers/bbc.c @@ -639,25 +639,29 @@ WRITE_LINE_MEMBER(bbc_state::econet_clk_w) } static MACHINE_CONFIG_FRAGMENT( bbc_cartslot ) - MCFG_CARTSLOT_ADD("cart1") + MCFG_CARTSLOT_ADD("exp_rom1") MCFG_CARTSLOT_EXTENSION_LIST("rom") MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_LOAD(bbc_state, bbcb_cart) + MCFG_CARTSLOT_LOAD(bbc_state, bbc_exp_rom) + MCFG_CARTSLOT_INTERFACE("bbc_cart") - MCFG_CARTSLOT_ADD("cart2") + MCFG_CARTSLOT_ADD("exp_rom2") MCFG_CARTSLOT_EXTENSION_LIST("rom") MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_LOAD(bbc_state, bbcb_cart) + MCFG_CARTSLOT_LOAD(bbc_state, bbc_exp_rom) + MCFG_CARTSLOT_INTERFACE("bbc_cart") - MCFG_CARTSLOT_ADD("cart3") + MCFG_CARTSLOT_ADD("exp_rom3") MCFG_CARTSLOT_EXTENSION_LIST("rom") MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_LOAD(bbc_state, bbcb_cart) + MCFG_CARTSLOT_LOAD(bbc_state, bbc_exp_rom) + MCFG_CARTSLOT_INTERFACE("bbc_cart") - MCFG_CARTSLOT_ADD("cart4") + MCFG_CARTSLOT_ADD("exp_rom4") MCFG_CARTSLOT_EXTENSION_LIST("rom") MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_LOAD(bbc_state, bbcb_cart) + MCFG_CARTSLOT_LOAD(bbc_state, bbc_exp_rom) + MCFG_CARTSLOT_INTERFACE("bbc_cart") MACHINE_CONFIG_END @@ -929,7 +933,12 @@ static MACHINE_CONFIG_START( bbcm, bbc_state ) MCFG_CASSETTE_ADD( "cassette", bbc_cassette_interface ) /* cartridges */ - MCFG_CARTSLOT_ADD("cart") + MCFG_CARTSLOT_ADD("cart1") + MCFG_CARTSLOT_EXTENSION_LIST("bin") + MCFG_CARTSLOT_NOT_MANDATORY + MCFG_CARTSLOT_LOAD(bbc_state, bbcm_cart) + MCFG_CARTSLOT_INTERFACE("bbcm_cart") + MCFG_CARTSLOT_ADD("cart2") MCFG_CARTSLOT_EXTENSION_LIST("bin") MCFG_CARTSLOT_NOT_MANDATORY MCFG_CARTSLOT_LOAD(bbc_state, bbcm_cart) diff --git a/src/mess/includes/bbc.h b/src/mess/includes/bbc.h index b08b1792895..0a2de809fb9 100644 --- a/src/mess/includes/bbc.h +++ b/src/mess/includes/bbc.h @@ -155,7 +155,8 @@ public: DECLARE_WRITE_LINE_MEMBER(bbc_i8271_interrupt); - DECLARE_DEVICE_IMAGE_LOAD_MEMBER( bbcb_cart ); + int exp_rom_load(device_image_interface &image, int index); + DECLARE_DEVICE_IMAGE_LOAD_MEMBER( bbc_exp_rom ); DECLARE_DEVICE_IMAGE_LOAD_MEMBER( bbcm_cart ); private: diff --git a/src/mess/machine/bbc.c b/src/mess/machine/bbc.c index b657e6d24b7..fc47168e996 100644 --- a/src/mess/machine/bbc.c +++ b/src/mess/machine/bbc.c @@ -1959,116 +1959,98 @@ WRITE8_MEMBER(bbc_state::bbc_disc_w) /************************************** BBC B Rom loading functions ***************************************/ -DEVICE_IMAGE_LOAD_MEMBER( bbc_state, bbcb_cart ) + +int bbc_state::exp_rom_load(device_image_interface &image, int index) { UINT8 *RAM = m_region_user1->base(); int size, read_; - int addr = 0; - int index = 0; - - size = image.length(); - - if (strcmp(image.device().tag(),":cart1") == 0) + int addr = 0x8000 + (0x4000 * index); + + if (image.software_entry() == NULL) { - index = 0; - } - if (strcmp(image.device().tag(),":cart2") == 0) - { - index = 1; - } - if (strcmp(image.device().tag(),":cart3") == 0) - { - index = 2; - } - if (strcmp(image.device().tag(),":cart4") == 0) - { - index = 3; - } - addr = 0x8000 + (0x4000 * index); - - - logerror("loading rom %s at %.4x size:%.4x\n", image.filename(), addr, size); - - - switch (size) - { - case 0x2000: - read_ = image.fread(RAM + addr, size); + size = image.length(); + logerror("loading rom %s, at %.4x size:%.4x\n", image.filename(), addr, size); + + switch (size) + { + case 0x2000: + read_ = image.fread(RAM + addr, size); + if (read_ != size) + return 1; + image.fseek(0, SEEK_SET); + read_ = image.fread(RAM + addr + 0x2000, size); + break; + case 0x4000: + read_ = image.fread(RAM + addr, size); + break; + default: + read_ = 0; + logerror("bad rom file size of %.4x\n", size); + break; + } + if (read_ != size) - return 1; - image.fseek(0, SEEK_SET); - read_ = image.fread(RAM + addr + 0x2000, size); - break; - case 0x4000: - read_ = image.fread(RAM + addr, size); - break; - default: - read_ = 0; - logerror("bad rom file size of %.4x\n", size); - break; + return IMAGE_INIT_FAIL; } + return IMAGE_INIT_PASS; +} - if (read_ != size) - return 1; - return 0; +DEVICE_IMAGE_LOAD_MEMBER( bbc_state, bbc_exp_rom ) +{ + if (strcmp(image.device().tag(),":exp_rom1") == 0) + return exp_rom_load(image, 0); + + if (strcmp(image.device().tag(),":exp_rom2") == 0) + return exp_rom_load(image, 1); + + if (strcmp(image.device().tag(),":exp_rom3") == 0) + return exp_rom_load(image, 2); + + if (strcmp(image.device().tag(),":exp_rom4") == 0) + return exp_rom_load(image, 3); + + return IMAGE_INIT_FAIL; } /************************************** BBC Master Rom loading functions ***************************************/ + DEVICE_IMAGE_LOAD_MEMBER( bbc_state, bbcm_cart ) { UINT8 *RAM = m_region_user1->base(); - int size, read_; - int addr = 0; - int index = 0; - - size = image.length(); + UINT32 size; + int addr = 0, index = 0; if (strcmp(image.device().tag(),":cart1") == 0) - { index = 0; - } if (strcmp(image.device().tag(),":cart2") == 0) - { index = 1; - } - if (strcmp(image.device().tag(),":cart3") == 0) + addr += index * 0x8000; + + if (image.software_entry() == NULL) { - index = 2; + size = image.length(); + logerror("loading rom %s, size:%.4x\n", image.filename(), size); + + if (size != 0x8000) + { + image.seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid rom file size"); + return IMAGE_INIT_FAIL; + } + + image.fread(RAM + addr, size); } - if (strcmp(image.device().tag(),":cart4") == 0) + else { - index = 3; - } - addr = 0x8000 + (0x4000 * index); + size = image.get_software_region_length("rom"); + logerror("loading rom %s, size:%.4x\n", image.filename(), size); - - logerror("loading rom %s at %.4x size:%.4x\n", image.filename(), addr, size); - - - switch (size) - { - case 0x2000: - read_ = image.fread(RAM + addr, size); - if (read_ != size) - return 1; - image.fseek(0, SEEK_SET); - read_ = image.fread(RAM + addr + 0x2000, size); - break; - case 0x4000: - read_ = image.fread(RAM + addr, size); - break; - default: - read_ = 0; - logerror("bad rom file size of %.4x\n", size); - break; + memcpy(RAM + addr, image.get_software_region("rom"), size); } - if (read_ != size) - return 1; - return 0; + return IMAGE_INIT_PASS; }