summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/vcs/vcs_slot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/vcs/vcs_slot.cpp')
-rw-r--r--src/devices/bus/vcs/vcs_slot.cpp133
1 files changed, 51 insertions, 82 deletions
diff --git a/src/devices/bus/vcs/vcs_slot.cpp b/src/devices/bus/vcs/vcs_slot.cpp
index 3d0fe0e4fb9..344071724e9 100644
--- a/src/devices/bus/vcs/vcs_slot.cpp
+++ b/src/devices/bus/vcs/vcs_slot.cpp
@@ -23,6 +23,34 @@
DEFINE_DEVICE_TYPE(VCS_CART_SLOT, vcs_cart_slot_device, "vcs_cart_slot", "Atari VCS 2600 Cartridge Slot")
+/* PCB */
+enum
+{
+ A26_2K_4K = 0,
+ A26_F4,
+ A26_F6,
+ A26_F8,
+ A26_F8SW,
+ A26_FA,
+ A26_FE,
+ A26_3E, // to test
+ A26_3F,
+ A26_E0,
+ A26_E7,
+ A26_UA,
+ A26_DC,
+ A26_CV,
+ A26_FV,
+ A26_JVP, // to test
+ A26_32IN1,
+ A26_8IN1,
+ A26_4IN1,
+ A26_DPC,
+ A26_SS,
+ A26_CM,
+ A26_X07,
+ A26_HARMONY,
+};
//-------------------------------------------------
// device_vcs_cart_interface - constructor
@@ -52,7 +80,7 @@ void device_vcs_cart_interface::rom_alloc(uint32_t size, const char *tag)
{
if (m_rom == nullptr)
{
- m_rom = device().machine().memory().region_alloc(std::string(tag).append(A26SLOT_ROM_REGION_TAG).c_str(), size, 1, ENDIANNESS_LITTLE)->base();
+ m_rom = device().machine().memory().region_alloc(std::string(tag).append(":cart:rom"), size, 1, ENDIANNESS_LITTLE)->base();
m_rom_size = size;
}
}
@@ -78,9 +106,11 @@ void device_vcs_cart_interface::ram_alloc(uint32_t size)
//-------------------------------------------------
vcs_cart_slot_device::vcs_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, VCS_CART_SLOT, tag, owner, clock),
- device_image_interface(mconfig, *this),
+ device_cartrom_image_interface(mconfig, *this),
device_single_card_slot_interface<device_vcs_cart_interface>(mconfig, *this),
- m_cart(nullptr), m_type(0)
+ m_cart(nullptr),
+ m_type(0),
+ m_address_space(*this, finder_base::DUMMY_TAG, -1, 8)
{
}
@@ -121,8 +151,7 @@ struct vcs_slot
// Here, we take the feature attribute from .xml (i.e. the PCB name) and we assign a unique ID to it
static const vcs_slot slot_list[] =
{
- { A26_2K, "a26_2k" },
- { A26_4K, "a26_4k" },
+ { A26_2K_4K, "a26_2k_4k" },
{ A26_F4, "a26_f4" },
{ A26_F6, "a26_f6" },
{ A26_F8, "a26_f8" },
@@ -167,22 +196,14 @@ static const char *vcs_get_slot(int type)
return elem.slot_option;
}
- return "a26_4k";
+ return "a26_2k_4k";
}
-image_init_result vcs_cart_slot_device::call_load()
+std::pair<std::error_condition, std::string> vcs_cart_slot_device::call_load()
{
if (m_cart)
{
- uint8_t *ROM;
- uint32_t len;
-
- if (loaded_through_softlist())
- len = get_software_region_length("rom");
- else
- len = length();
-
- //printf("Size: 0x%X\n", len);
+ const uint32_t len = loaded_through_softlist() ? get_software_region_length("rom") : length();
// check that filesize is among the supported ones
switch (len)
@@ -200,20 +221,18 @@ image_init_result vcs_cart_slot_device::call_load()
break;
default:
- seterror(image_error::INVALIDIMAGE, "Invalid ROM file size" );
- return image_init_result::FAIL;
+ return std::make_pair(image_error::INVALIDLENGTH, "Unsupported cartridge ROM file size");
}
m_cart->rom_alloc(len, tag());
- ROM = m_cart->get_rom_base();
+ uint8_t *const ROM = m_cart->get_rom_base();
if (loaded_through_softlist())
{
- const char *pcb_name;
- bool has_ram = get_software_region("ram") ? true : false;
memcpy(ROM, get_software_region("rom"), len);
+ const char *pcb_name = get_feature("slot");
- if ((pcb_name = get_feature("slot")) != nullptr)
+ if (pcb_name != nullptr)
m_type = vcs_get_pcb_id(pcb_name);
else
{
@@ -221,10 +240,8 @@ image_init_result vcs_cart_slot_device::call_load()
switch (len)
{
case 0x800:
- m_type = A26_2K;
- break;
case 0x1000:
- m_type = A26_4K;
+ m_type = A26_2K_4K;
break;
case 0x2000:
m_type = A26_F8;
@@ -249,13 +266,13 @@ image_init_result vcs_cart_slot_device::call_load()
m_type = A26_3F;
break;
default:
- m_type = A26_4K;
+ m_type = A26_2K_4K;
printf("Unrecognized cart type!\n");
break;
}
}
- if (has_ram)
+ if (get_software_region("ram"))
m_cart->ram_alloc(get_software_region_length("ram"));
}
else
@@ -263,17 +280,12 @@ image_init_result vcs_cart_slot_device::call_load()
fread(ROM, len);
m_type = identify_cart_type(ROM, len);
- // check for Special Chip (128bytes of RAM)
+ // check for Super Chip (128bytes of RAM)
if (len == 0x2000 || len == 0x4000 || len == 0x8000)
if (detect_super_chip(ROM, len))
{
m_cart->ram_alloc(0x80);
- //printf("Super Chip detected!\n");
}
- // Super chip games:
- // dig dig, crystal castles, millipede, stargate, defender ii, jr. Pac Man,
- // desert falcon, dark chambers, super football, sprintmaster, fatal run,
- // off the wall, shooting arcade, secret quest, radar lock, save mary, klax
// add CBS RAM+ (256bytes of RAM)
if (m_type == A26_FA)
@@ -292,16 +304,14 @@ image_init_result vcs_cart_slot_device::call_load()
m_cart->ram_alloc(0x8000);
}
- //printf("Type: %s\n", vcs_get_slot(m_type));
-
// pass a pointer to the now allocated ROM for the DPC chip
if (m_type == A26_DPC)
m_cart->setup_addon_ptr((uint8_t *)m_cart->get_rom_base() + 0x2000);
- return image_init_result::PASS;
+ m_cart->install_memory_handlers(m_address_space.target());
}
- return image_init_result::PASS;
+ return std::make_pair(std::error_condition(), std::string());
}
@@ -717,10 +727,8 @@ int vcs_cart_slot_device::identify_cart_type(const uint8_t *ROM, uint32_t len)
switch (len)
{
case 0x800:
- type = A26_2K;
- break;
case 0x1000:
- type = A26_4K;
+ type = A26_2K_4K;
break;
case 0x2000:
type = A26_F8;
@@ -745,7 +753,7 @@ int vcs_cart_slot_device::identify_cart_type(const uint8_t *ROM, uint32_t len)
type = A26_3F;
break;
default:
- type = A26_4K;
+ type = A26_2K_4K;
printf("Unrecognized cart type!\n");
break;
}
@@ -766,8 +774,7 @@ std::string vcs_cart_slot_device::get_default_card_software(get_default_card_sof
hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- size_t actual;
- hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
+ read(*hook.image_file(), &rom[0], len); // FIXME: check error return or read returning short
int const type = identify_cart_type(&rom[0], len);
char const *const slot_string = vcs_get_slot(type);
@@ -775,43 +782,5 @@ std::string vcs_cart_slot_device::get_default_card_software(get_default_card_sof
return std::string(slot_string);
}
else
- return software_get_default_slot("a26_4k");
-}
-
-
-/*-------------------------------------------------
- read
- -------------------------------------------------*/
-
-uint8_t vcs_cart_slot_device::read_rom(offs_t offset)
-{
- if (m_cart)
- return m_cart->read_rom(offset);
- else
- return 0xff;
-}
-
-uint8_t vcs_cart_slot_device::read_bank(address_space &space, offs_t offset)
-{
- if (m_cart)
- return m_cart->read_bank(space, offset);
- else
- return 0xff;
-}
-
-
-/*-------------------------------------------------
- write
- -------------------------------------------------*/
-
-void vcs_cart_slot_device::write_bank(address_space &space, offs_t offset, uint8_t data)
-{
- if (m_cart)
- m_cart->write_bank(space, offset, data);
-}
-
-void vcs_cart_slot_device::write_ram(offs_t offset, uint8_t data)
-{
- if (m_cart)
- m_cart->write_ram(offset, data);
+ return software_get_default_slot("a26_2k_4k");
}