1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// license:BSD-3-Clause
// copyright-holders:Nathan Woods, Miodrag Milanovic
/*********************************************************************
snapquik.h
Snapshots and quickloads
*********************************************************************/
#ifndef MAME_DEVICES_IMAGEDEV_SNAPQUIK_H
#define MAME_DEVICES_IMAGEDEV_SNAPQUIK_H
#include "softlist_dev.h"
typedef delegate<image_init_result (device_image_interface &,const char *, int)> snapquick_load_delegate;
// ======================> snapshot_image_device
class snapshot_image_device : public device_t,
public device_image_interface
{
public:
// construction/destruction
snapshot_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~snapshot_image_device();
void set_interface(const char *interface) { m_interface = interface; }
// image-level overrides
virtual image_init_result call_load() override;
virtual const software_list_loader &get_software_list_loader() const override { return image_software_list_loader::instance(); }
virtual iodevice_t image_type() const override { return IO_SNAPSHOT; }
virtual bool is_readable() const override { return 1; }
virtual bool is_writeable() const override { return 0; }
virtual bool is_creatable() const override { return 0; }
virtual bool must_be_loaded() const override { return 0; }
virtual bool is_reset_on_load() const override { return 0; }
virtual const char *image_interface() const override { return m_interface; }
virtual const char *file_extensions() const override { return m_file_extensions; }
TIMER_CALLBACK_MEMBER(process_snapshot_or_quickload);
void set_handler(snapquick_load_delegate load, const char *ext, seconds_t sec) { m_load = load; m_file_extensions = ext; m_delay_seconds = sec; };
protected:
snapshot_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
virtual void device_start() override;
snapquick_load_delegate m_load; /* loading function */
const char * m_file_extensions; /* file extensions */
const char * m_interface;
seconds_t m_delay_seconds; /* loading delay (seconds) */
attoseconds_t m_delay_attoseconds; /* loading delay (attoseconds) */
emu_timer *m_timer;
};
// device type definition
DECLARE_DEVICE_TYPE(SNAPSHOT, snapshot_image_device)
// ======================> quickload_image_device
class quickload_image_device : public snapshot_image_device
{
public:
// construction/destruction
quickload_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual iodevice_t image_type() const override { return IO_QUICKLOAD; }
};
// device type definition
DECLARE_DEVICE_TYPE(QUICKLOAD, quickload_image_device)
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define SNAPSHOT_LOAD_MEMBER_NAME(_name) snapshot_load_##_name
#define SNAPSHOT_LOAD_NAME(_class,_name) _class::SNAPSHOT_LOAD_MEMBER_NAME(_name)
#define DECLARE_SNAPSHOT_LOAD_MEMBER(_name) image_init_result SNAPSHOT_LOAD_MEMBER_NAME(_name)(device_image_interface &image, const char *file_type, int snapshot_size)
#define SNAPSHOT_LOAD_MEMBER(_class,_name) image_init_result SNAPSHOT_LOAD_NAME(_class,_name)(device_image_interface &image, const char *file_type, int snapshot_size)
#define SNAPSHOT_LOAD_DELEGATE(_class,_name) snapquick_load_delegate(&SNAPSHOT_LOAD_NAME(_class,_name), downcast<_class *>(device->owner()))
#define QUICKLOAD_LOAD_MEMBER_NAME(_name) quickload_load##_name
#define QUICKLOAD_LOAD_NAME(_class,_name) _class::QUICKLOAD_LOAD_MEMBER_NAME(_name)
#define DECLARE_QUICKLOAD_LOAD_MEMBER(_name) image_init_result QUICKLOAD_LOAD_MEMBER_NAME(_name)(device_image_interface &image, const char *file_type, int quickload_size)
#define QUICKLOAD_LOAD_MEMBER(_class,_name) image_init_result QUICKLOAD_LOAD_NAME(_class,_name)(device_image_interface &image, const char *file_type, int quickload_size)
#define QUICKLOAD_LOAD_DELEGATE(_class,_name) snapquick_load_delegate(&QUICKLOAD_LOAD_NAME(_class,_name), downcast<_class *>(device->owner()))
#define MCFG_SNAPSHOT_ADD(_tag, _class, _load, _file_extensions, _delay) \
MCFG_DEVICE_ADD(_tag, SNAPSHOT, 0) \
static_cast<snapshot_image_device *>(device)->set_handler(SNAPSHOT_LOAD_DELEGATE(_class,_load), _file_extensions, _delay);
#define MCFG_SNAPSHOT_INTERFACE(_interface) \
downcast<snapshot_image_device &>(*device).set_interface(_interface);
#define MCFG_QUICKLOAD_ADD(_tag, _class, _load, _file_extensions, _delay) \
MCFG_DEVICE_ADD(_tag, QUICKLOAD, 0) \
static_cast<quickload_image_device *>(device)->set_handler(QUICKLOAD_LOAD_DELEGATE(_class,_load), _file_extensions, _delay);
#define MCFG_QUICKLOAD_INTERFACE(_interface) \
downcast<quickload_image_device &>(*device).set_interface(_interface);
#endif // MAME_DEVICES_IMAGEDEV_SNAPQUIK_H
|