From 3f9fa672a4e20533a44abc795706c7697ad75c9c Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 1 Jan 2023 20:12:47 -0500 Subject: diimage.h: Move a few macro and delegate definitions down into subclasses --- src/devices/bus/generic/slot.h | 20 +++++++++++++++++--- src/devices/bus/ti99x/990_hd.cpp | 4 ++-- src/devices/bus/ti99x/990_hd.h | 4 ++-- src/devices/imagedev/diablo.h | 3 +++ src/devices/imagedev/harddriv.h | 3 +++ src/emu/diimage.h | 14 -------------- src/mame/nintendo/n64.cpp | 16 ++-------------- 7 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/devices/bus/generic/slot.h b/src/devices/bus/generic/slot.h index c6f506a03bf..c6c5c7d0b1f 100644 --- a/src/devices/bus/generic/slot.h +++ b/src/devices/bus/generic/slot.h @@ -10,9 +10,20 @@ #include -/*************************************************************************** - 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 { public: + typedef device_delegate load_delegate; + typedef device_delegate unload_delegate; + virtual ~generic_slot_device(); template void set_device_load(T &&... args) { m_device_image_load.set(std::forward(args)...); } diff --git a/src/devices/bus/ti99x/990_hd.cpp b/src/devices/bus/ti99x/990_hd.cpp index d9a35d67b30..c3b3300e1d7 100644 --- a/src/devices/bus/ti99x/990_hd.cpp +++ b/src/devices/bus/ti99x/990_hd.cpp @@ -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; diff --git a/src/devices/bus/ti99x/990_hd.h b/src/devices/bus/ti99x/990_hd.h index f934775654e..32322b20965 100644 --- a/src/devices/bus/ti99x/990_hd.h +++ b/src/devices/bus/ti99x/990_hd.h @@ -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 void set_memory_space(T &&tag, int spacenum) { m_memory_space.set_tag(std::forward(tag), spacenum); } auto int_cb() { return m_interrupt_callback.bind(); } diff --git a/src/devices/imagedev/diablo.h b/src/devices/imagedev/diablo.h index 2b483bf8388..d1eaaa2908e 100644 --- a/src/devices/imagedev/diablo.h +++ b/src/devices/imagedev/diablo.h @@ -23,6 +23,9 @@ class diablo_image_device : public harddisk_image_base_device { public: + typedef device_delegate load_delegate; + typedef device_delegate unload_delegate; + // construction/destruction diablo_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); virtual ~diablo_image_device(); diff --git a/src/devices/imagedev/harddriv.h b/src/devices/imagedev/harddriv.h index 6ed01bafc08..0b043e48cee 100644 --- a/src/devices/imagedev/harddriv.h +++ b/src/devices/imagedev/harddriv.h @@ -41,6 +41,9 @@ protected: class harddisk_image_device : public harddisk_image_base_device { public: + typedef device_delegate load_delegate; + typedef device_delegate 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) diff --git a/src/emu/diimage.h b/src/emu/diimage.h index 08d48020cc3..2248f6b522f 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -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 load_delegate; - typedef device_delegate unload_delegate; - typedef std::vector> formatlist_type; // construction/destruction diff --git a/src/mame/nintendo/n64.cpp b/src/mame/nintendo/n64.cpp index 08d8ff090a7..480b42e4902 100644 --- a/src/mame/nintendo/n64.cpp +++ b/src/mame/nintendo/n64.cpp @@ -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"); -- cgit v1.2.3