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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
mconfig.h
Machine configuration macros and functions.
***************************************************************************/
#pragma once
#ifndef __EMU_H__
#error Dont include this file directly; include emu.h instead.
#endif
#ifndef __MCONFIG_H__
#define __MCONFIG_H__
//**************************************************************************
// CONSTANTS
//**************************************************************************
// by convention, tags should all lowercase and between 1-15 characters
#define MIN_TAG_LENGTH 1
#define MAX_TAG_LENGTH 15
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// forward references
struct gfx_decode_entry;
class driver_device;
class screen_device;
// ======================> machine_config
// machine configuration definition
class machine_config
{
DISABLE_COPYING(machine_config);
friend class running_machine;
public:
// construction/destruction
machine_config(const game_driver &gamedrv, emu_options &options);
~machine_config();
// getters
const game_driver &gamedrv() const { return m_gamedrv; }
device_t &root_device() const { assert(m_root_device != NULL); return *m_root_device; }
screen_device *first_screen() const;
emu_options &options() const { return m_options; }
inline device_t *device(const char *tag) const { return root_device().subdevice(tag); }
template<class _DeviceClass> inline _DeviceClass *device(const char *tag) const { return downcast<_DeviceClass *>(device(tag)); }
// public state
attotime m_minimum_quantum; // minimum scheduling quantum
std::string m_perfect_cpu_quantum; // tag of CPU to use for "perfect" scheduling
INT32 m_watchdog_vblank_count; // number of VBLANKs until the watchdog kills us
attotime m_watchdog_time; // length of time until the watchdog kills us
// other parameters
const char * m_default_layout; // default layout for this machine
// helpers during configuration; not for general use
device_t *device_add(device_t *owner, const char *tag, device_type type, UINT32 clock);
device_t *device_replace(device_t *owner, const char *tag, device_type type, UINT32 clock);
device_t *device_remove(device_t *owner, const char *tag);
device_t *device_find(device_t *owner, const char *tag);
private:
// internal state
const game_driver & m_gamedrv;
emu_options & m_options;
auto_pointer<device_t> m_root_device;
};
//**************************************************************************
// MACHINE CONFIG MACROS
//**************************************************************************
// start/end tags for the machine driver
#define MACHINE_CONFIG_NAME(_name) construct_machine_config_##_name
#define MACHINE_CONFIG_START(_name, _class) \
ATTR_COLD device_t *MACHINE_CONFIG_NAME(_name)(machine_config &config, device_t *owner, device_t *device) \
{ \
devcb_base *devcb = NULL; \
(void)devcb; \
if (owner == NULL) owner = config.device_add(NULL, "root", &driver_device_creator<_class>, 0);
#define MACHINE_CONFIG_FRAGMENT(_name) \
ATTR_COLD device_t *MACHINE_CONFIG_NAME(_name)(machine_config &config, device_t *owner, device_t *device) \
{ \
devcb_base *devcb = NULL; \
(void)devcb; \
assert(owner != NULL);
#define MACHINE_CONFIG_DERIVED(_name, _base) \
ATTR_COLD device_t *MACHINE_CONFIG_NAME(_name)(machine_config &config, device_t *owner, device_t *device) \
{ \
devcb_base *devcb = NULL; \
(void)devcb; \
owner = MACHINE_CONFIG_NAME(_base)(config, owner, device); \
assert(owner != NULL);
#define MACHINE_CONFIG_DERIVED_CLASS(_name, _base, _class) \
ATTR_COLD device_t *MACHINE_CONFIG_NAME(_name)(machine_config &config, device_t *owner, device_t *device) \
{ \
devcb_base *devcb = NULL; \
(void)devcb; \
if (owner == NULL) owner = config.device_add(NULL, "root", &driver_device_creator<_class>, 0); \
owner = MACHINE_CONFIG_NAME(_base)(config, owner, device);
#define MACHINE_CONFIG_END \
return owner; \
}
// use this to declare external references to a machine driver
#define MACHINE_CONFIG_EXTERN(_name) \
extern device_t *MACHINE_CONFIG_NAME(_name)(machine_config &config, device_t *owner, device_t *device)
// importing data from other machine drivers
#define MCFG_FRAGMENT_ADD(_name) \
MACHINE_CONFIG_NAME(_name)(config, owner, device);
// scheduling parameters
#define MCFG_QUANTUM_TIME(_time) \
config.m_minimum_quantum = _time;
#define MCFG_QUANTUM_PERFECT_CPU(_cputag) \
config.m_perfect_cpu_quantum = owner->subtag(_cputag);
// watchdog configuration
#define MCFG_WATCHDOG_VBLANK_INIT(_count) \
config.m_watchdog_vblank_count = _count;
#define MCFG_WATCHDOG_TIME_INIT(_time) \
config.m_watchdog_time = _time;
// core video parameters
#define MCFG_DEFAULT_LAYOUT(_layout) \
config.m_default_layout = &(_layout)[0];
// add/remove devices
#define MCFG_DEVICE_ADD(_tag, _type, _clock) \
device = config.device_add(owner, _tag, _type, _clock);
#define MCFG_DEVICE_REPLACE(_tag, _type, _clock) \
device = config.device_replace(owner, _tag, _type, _clock);
#define MCFG_DEVICE_REMOVE(_tag) \
device = config.device_remove(owner, _tag);
#define MCFG_DEVICE_MODIFY(_tag) \
device = config.device_find(owner, _tag);
#endif /* __MCONFIG_H__ */
|