From 27d1b900e2715d67ea2633d6b64f2efbb8c5b7f5 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 20 Aug 2022 03:39:36 +1000 Subject: bus: Get rid of some dubious tag manipulation. The implementation details of how the cartridges allocate storage for memory really shouldn't be part of the interface. Having tags in the headers encourages people to depend on these implementation details. This gets rid of it in most of the headers. A few particularly leaky abstractions (bbc/rom, electron/cart, gba, generic, jakks_gamekey, m5) depend on this, so it can't be removed in those cases without further refactoring to encapsulate the slot devices better. This doesn't change behaviour, it just mechanically removes stuff from the headers and uses device_t::subtag rather than string manipulation on tags. Most of the cartridge devices shouldn't have rom_alloc member functions at all - the region created by the software list loader can be used directly when loading from the software list, and the slot can allocate a region with the same tag when loading loose software. This avoids creating an extra region and copying the data when loading from the software list. See vboy for an example that doesn't allocate a superfluous region. --- src/devices/bus/vc4000/slot.cpp | 6 +++--- src/devices/bus/vc4000/slot.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/devices/bus/vc4000') diff --git a/src/devices/bus/vc4000/slot.cpp b/src/devices/bus/vc4000/slot.cpp index ce8acfcbf43..4c8f2dd77c4 100644 --- a/src/devices/bus/vc4000/slot.cpp +++ b/src/devices/bus/vc4000/slot.cpp @@ -45,11 +45,11 @@ device_vc4000_cart_interface::~device_vc4000_cart_interface() // rom_alloc - alloc the space for the cart //------------------------------------------------- -void device_vc4000_cart_interface::rom_alloc(uint32_t size, const char *tag) +void device_vc4000_cart_interface::rom_alloc(uint32_t size) { if (m_rom == nullptr) { - m_rom = device().machine().memory().region_alloc(std::string(tag).append(VC4000SLOT_ROM_REGION_TAG).c_str(), size, 1, ENDIANNESS_LITTLE)->base(); + m_rom = device().machine().memory().region_alloc(device().subtag("^cart:rom"), size, 1, ENDIANNESS_LITTLE)->base(); m_rom_size = size; } } @@ -180,7 +180,7 @@ image_init_result vc4000_cart_slot_device::call_load() return image_init_result::FAIL; } - m_cart->rom_alloc(size, tag()); + m_cart->rom_alloc(size); if (!loaded_through_softlist()) fread(m_cart->get_rom_base(), size); diff --git a/src/devices/bus/vc4000/slot.h b/src/devices/bus/vc4000/slot.h index 39de8414d0b..90f75232699 100644 --- a/src/devices/bus/vc4000/slot.h +++ b/src/devices/bus/vc4000/slot.h @@ -6,8 +6,6 @@ #include "imagedev/cartrom.h" -#define VC4000SLOT_ROM_REGION_TAG ":cart:rom" - /* PCB */ enum { @@ -32,7 +30,7 @@ public: virtual uint8_t read_ram(offs_t offset) { return 0xff; } virtual void write_ram(offs_t offset, uint8_t data) { } - void rom_alloc(uint32_t size, const char *tag); + void rom_alloc(uint32_t size); void ram_alloc(uint32_t size); uint8_t* get_rom_base() { return m_rom; } uint8_t* get_ram_base() { return &m_ram[0]; } -- cgit v1.2.3-70-g09d2