summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/c64/exp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/c64/exp.cpp')
-rw-r--r--src/devices/bus/c64/exp.cpp113
1 files changed, 61 insertions, 52 deletions
diff --git a/src/devices/bus/c64/exp.cpp b/src/devices/bus/c64/exp.cpp
index 2a996728adf..7a53fadbf14 100644
--- a/src/devices/bus/c64/exp.cpp
+++ b/src/devices/bus/c64/exp.cpp
@@ -9,6 +9,10 @@
#include "emu.h"
#include "exp.h"
+#include "formats/cbm_crt.h"
+
+#include <tuple>
+
//**************************************************************************
@@ -28,11 +32,9 @@ DEFINE_DEVICE_TYPE(C64_EXPANSION_SLOT, c64_expansion_slot_device, "c64_expansion
//-------------------------------------------------
device_c64_expansion_card_interface::device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device) :
- device_slot_card_interface(mconfig, device),
- m_roml(*this, "roml"),
- m_romh(*this, "romh"),
- m_romx(*this, "romx"),
- m_nvram(*this, "nvram"),
+ device_interface(device, "c64exp"),
+ m_roml_size(0),
+ m_romh_size(0),
m_game(1),
m_exrom(1)
{
@@ -60,9 +62,9 @@ device_c64_expansion_card_interface::~device_c64_expansion_card_interface()
c64_expansion_slot_device::c64_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, C64_EXPANSION_SLOT, tag, owner, clock),
- device_slot_interface(mconfig, *this),
- device_image_interface(mconfig, *this),
- m_read_dma_cd(*this),
+ device_single_card_slot_interface<device_c64_expansion_card_interface>(mconfig, *this),
+ device_cartrom_image_interface(mconfig, *this),
+ m_read_dma_cd(*this, 0),
m_write_dma_cd(*this),
m_write_irq(*this),
m_write_nmi(*this),
@@ -73,35 +75,12 @@ c64_expansion_slot_device::c64_expansion_slot_device(const machine_config &mconf
//-------------------------------------------------
-// device_validity_check -
-//-------------------------------------------------
-
-void c64_expansion_slot_device::device_validity_check(validity_checker &valid) const
-{
- device_t *const carddev = get_card_device();
- if (carddev && !dynamic_cast<device_c64_expansion_card_interface *>(carddev))
- osd_printf_error("Card device %s (%s) does not implement device_c64_expansion_card_interface\n", carddev->tag(), carddev->name());
-}
-
-
-//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void c64_expansion_slot_device::device_start()
{
- device_t *const carddev = get_card_device();
- m_card = dynamic_cast<device_c64_expansion_card_interface *>(carddev);
- if (carddev && !m_card)
- fatalerror("Card device %s (%s) does not implement device_c64_expansion_card_interface\n", carddev->tag(), carddev->name());
-
- // resolve callbacks
- m_read_dma_cd.resolve_safe(0);
- m_write_dma_cd.resolve_safe();
- m_write_irq.resolve_safe();
- m_write_nmi.resolve_safe();
- m_write_dma.resolve_safe();
- m_write_reset.resolve_safe();
+ m_card = get_card_device();
}
@@ -118,20 +97,33 @@ void c64_expansion_slot_device::device_reset()
// call_load -
//-------------------------------------------------
-image_init_result c64_expansion_slot_device::call_load()
+std::pair<std::error_condition, std::string> c64_expansion_slot_device::call_load()
{
+ std::error_condition err;
+
if (m_card)
{
+ m_card->m_roml_size = 0;
+ m_card->m_romh_size = 0;
+ m_card->m_exrom = 1;
+ m_card->m_game = 1;
+
size_t size;
if (!loaded_through_softlist())
{
+ util::core_file &file = image_core_file();
size = length();
if (is_filetype("80"))
{
- fread(m_card->m_roml, size);
- m_card->m_exrom = (0);
+ std::size_t actual;
+ std::tie(err, m_card->m_roml, actual) = read(file, size);
+ if (!err && (actual != size))
+ err = std::errc::io_error;
+
+ m_card->m_roml_size = size;
+ m_card->m_exrom = 0;
if (size == 0x4000)
{
@@ -140,40 +132,46 @@ image_init_result c64_expansion_slot_device::call_load()
}
else if (is_filetype("a0"))
{
- fread(m_card->m_romh, 0x2000);
+ std::size_t actual;
+ std::tie(err, m_card->m_roml, actual) = read(file, 0x2000);
+ if (!err && (actual != 0x2000))
+ err = std::errc::io_error;
+
+ m_card->m_romh_size = 0x2000;
m_card->m_exrom = 0;
m_card->m_game = 0;
}
else if (is_filetype("e0"))
{
- fread(m_card->m_romh, 0x2000);
+ std::size_t actual;
+ std::tie(err, m_card->m_roml, actual) = read(file, 0x2000);
+ if (!err && (actual != 0x2000))
+ err = std::errc::io_error;
+
+ m_card->m_romh_size = 0x2000;
m_card->m_game = 0;
}
else if (is_filetype("crt"))
{
- size_t roml_size = 0;
- size_t romh_size = 0;
- int exrom = 1;
- int game = 1;
-
- if (cbm_crt_read_header(image_core_file(), &roml_size, &romh_size, &exrom, &game))
+ if (cbm_crt_read_header(file, &m_card->m_roml_size, &m_card->m_romh_size, &m_card->m_exrom, &m_card->m_game))
{
uint8_t *roml = nullptr;
uint8_t *romh = nullptr;
- m_card->m_roml.allocate(roml_size);
- m_card->m_romh.allocate(romh_size);
+ m_card->m_roml = std::make_unique<uint8_t[]>(m_card->m_roml_size);
+ m_card->m_romh = std::make_unique<uint8_t[]>(m_card->m_romh_size);
- if (roml_size) roml = m_card->m_roml;
- if (romh_size) romh = m_card->m_roml;
+ if (m_card->m_roml_size) roml = m_card->m_roml.get();
+ if (m_card->m_romh_size) romh = m_card->m_romh.get();
- cbm_crt_read_data(image_core_file(), roml, romh);
+ cbm_crt_read_data(file, roml, romh);
}
-
- m_card->m_exrom = exrom;
- m_card->m_game = game;
+ }
+ else
+ {
+ err = image_error::INVALIDIMAGE;
}
}
else
@@ -185,6 +183,8 @@ image_init_result c64_expansion_slot_device::call_load()
// Ultimax (VIC-10) cartridge
load_software_region("lorom", m_card->m_roml);
load_software_region("uprom", m_card->m_romh);
+ m_card->m_roml_size = get_software_region_length("lorom");
+ m_card->m_romh_size = get_software_region_length("uprom");
m_card->m_exrom = 1;
m_card->m_game = 0;
@@ -196,14 +196,19 @@ image_init_result c64_expansion_slot_device::call_load()
load_software_region("romh", m_card->m_romh);
load_software_region("romx", m_card->m_romx);
load_software_region("nvram", m_card->m_nvram);
+ m_card->m_roml_size = get_software_region_length("roml");
+ m_card->m_romh_size = get_software_region_length("romh");
if (get_feature("exrom") != nullptr) m_card->m_exrom = atol(get_feature("exrom"));
if (get_feature("game") != nullptr) m_card->m_game = atol(get_feature("game"));
}
}
+
+ if ((m_card->m_roml_size & (m_card->m_roml_size - 1)) || (m_card->m_romh_size & (m_card->m_romh_size - 1)))
+ return std::make_pair(image_error::INVALIDLENGTH, "ROM size must be power of 2");
}
- return image_init_result::PASS;
+ return std::make_pair(err, std::string());
}
@@ -367,6 +372,7 @@ void c64_expansion_slot_device::set_passthrough()
#include "sw8k.h"
#include "swiftlink.h"
#include "system3.h"
+#include "tibdd001.h"
#include "tdos.h"
#include "turbo232.h"
#include "vizastar.h"
@@ -375,6 +381,7 @@ void c64_expansion_slot_device::set_passthrough()
#include "westermann.h"
#include "xl80.h"
#include "zaxxon.h"
+#include "z80videopak.h"
void c64_expansion_cards(device_slot_interface &device)
{
@@ -398,6 +405,7 @@ void c64_expansion_cards(device_slot_interface &device)
device.option_add("speakez", C64_SPEAKEASY);
device.option_add("supercpu", C64_SUPERCPU);
device.option_add("swiftlink", C64_SWIFTLINK);
+ device.option_add("tibdd001", C64_TIB_DD_001);
device.option_add("turbo232", C64_TURBO232);
device.option_add("buscard", C64_BUSCARD);
device.option_add("buscard2", C64_BUSCARD2);
@@ -450,4 +458,5 @@ void c64_expansion_cards(device_slot_interface &device)
device.option_add_internal("westermann", C64_WESTERMANN);
device.option_add_internal("zaxxon", C64_ZAXXON);
device.option_add_internal("xl80", C64_XL80);
+ device.option_add_internal("z80videopak", C64_Z80VIDEOPAK);
}