diimage.h: Move a few macro and delegate definitions down into subclasses

This commit is contained in:
AJR 2023-01-01 20:12:47 -05:00
parent 9f99b27d05
commit 3f9fa672a4
7 changed files with 29 additions and 35 deletions

View File

@ -10,9 +10,20 @@
#include <cassert>
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
//**************************************************************************
// MACROS
//**************************************************************************
#define DEVICE_IMAGE_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image)
#define DECLARE_DEVICE_IMAGE_LOAD_MEMBER(_name) DEVICE_IMAGE_LOAD_MEMBER(_name)
#define DEVICE_IMAGE_UNLOAD_MEMBER(_name) void _name(device_image_interface &image)
#define DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER(_name) DEVICE_IMAGE_UNLOAD_MEMBER(_name)
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
class device_generic_cart_interface : public device_interface
{
@ -138,6 +149,9 @@ class generic_slot_device : public device_t,
public device_single_card_slot_interface<device_generic_cart_interface>
{
public:
typedef device_delegate<image_init_result (device_image_interface &)> load_delegate;
typedef device_delegate<void (device_image_interface &)> unload_delegate;
virtual ~generic_slot_device();
template <typename... T> void set_device_load(T &&... args) { m_device_image_load.set(std::forward<T>(args)...); }

View File

@ -162,7 +162,7 @@ int ti990_hdc_device::get_id_from_device( device_t *device )
/*
Initialize hard disk unit and open a hard disk image
*/
DEVICE_IMAGE_LOAD_MEMBER( ti990_hdc_device::load_hd )
image_init_result ti990_hdc_device::load_hd(device_image_interface &image)
{
int id = get_id_from_device( &image.device() );
hd_unit_t *d;
@ -237,7 +237,7 @@ DEVICE_IMAGE_LOAD_MEMBER( ti990_hdc_device::load_hd )
/*
close a hard disk image
*/
DEVICE_IMAGE_UNLOAD_MEMBER( ti990_hdc_device::unload_hd )
void ti990_hdc_device::unload_hd(device_image_interface &image)
{
int id = get_id_from_device(&image.device());
hd_unit_t *d;

View File

@ -18,8 +18,8 @@ public:
uint16_t read(offs_t offset);
void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( load_hd );
DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( unload_hd );
image_init_result load_hd(device_image_interface &image);
void unload_hd(device_image_interface &image);
template <typename T> void set_memory_space(T &&tag, int spacenum) { m_memory_space.set_tag(std::forward<T>(tag), spacenum); }
auto int_cb() { return m_interrupt_callback.bind(); }

View File

@ -23,6 +23,9 @@
class diablo_image_device : public harddisk_image_base_device
{
public:
typedef device_delegate<image_init_result (device_image_interface &)> load_delegate;
typedef device_delegate<void (device_image_interface &)> unload_delegate;
// construction/destruction
diablo_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~diablo_image_device();

View File

@ -41,6 +41,9 @@ protected:
class harddisk_image_device : public harddisk_image_base_device
{
public:
typedef device_delegate<image_init_result (device_image_interface &)> load_delegate;
typedef device_delegate<void (device_image_interface &)> unload_delegate;
// construction/destruction
harddisk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, const char *intf)
: harddisk_image_device(mconfig, tag, owner, (uint32_t)0)

View File

@ -64,26 +64,12 @@ private:
enum class image_init_result { PASS, FAIL };
enum class image_verify_result { PASS, FAIL };
//**************************************************************************
// MACROS
//**************************************************************************
#define DEVICE_IMAGE_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image)
#define DECLARE_DEVICE_IMAGE_LOAD_MEMBER(_name) DEVICE_IMAGE_LOAD_MEMBER(_name)
#define DEVICE_IMAGE_UNLOAD_MEMBER(_name) void _name(device_image_interface &image)
#define DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER(_name) DEVICE_IMAGE_UNLOAD_MEMBER(_name)
// ======================> device_image_interface
// class representing interface-specific live image
class device_image_interface : public device_interface
{
public:
typedef device_delegate<image_init_result (device_image_interface &)> load_delegate;
typedef device_delegate<void (device_image_interface &)> unload_delegate;
typedef std::vector<std::unique_ptr<image_device_format>> formatlist_type;
// construction/destruction

View File

@ -41,8 +41,6 @@ private:
void mempak_format(uint8_t* pak);
image_init_result disk_load(device_image_interface &image);
void disk_unload(device_image_interface &image);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(load_n64dd);
DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER(unload_n64dd);
void n64_map(address_map &map);
void n64dd_map(address_map &map);
void rsp_imem_map(address_map &map);
@ -402,16 +400,6 @@ MACHINE_START_MEMBER(n64_mess_state,n64dd)
}
}
DEVICE_IMAGE_LOAD_MEMBER(n64_mess_state::load_n64dd)
{
return disk_load(image);
}
DEVICE_IMAGE_UNLOAD_MEMBER(n64_mess_state::unload_n64dd)
{
disk_unload(image);
}
image_init_result n64_mess_state::disk_load(device_image_interface &image)
{
image.fseek(0, SEEK_SET);
@ -491,8 +479,8 @@ void n64_mess_state::n64dd(machine_config &config)
cartslot.set_device_load(FUNC(n64_mess_state::cart_load));
harddisk_image_device &hdd(HARDDISK(config, "n64disk"));
hdd.set_device_load(FUNC(n64_mess_state::load_n64dd));
hdd.set_device_unload(FUNC(n64_mess_state::unload_n64dd));
hdd.set_device_load(FUNC(n64_mess_state::disk_load));
hdd.set_device_unload(FUNC(n64_mess_state::disk_unload));
hdd.set_interface("n64dd_disk");
SOFTWARE_LIST(config, "dd_list").set_original("n64dd");