~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/emu/emuopts.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
    emuopts.c
4
 
 
5
 
    Options file and command line management.
6
 
 
7
 
****************************************************************************
8
 
 
9
 
    Copyright Aaron Giles
10
 
    All rights reserved.
11
 
 
12
 
    Redistribution and use in source and binary forms, with or without
13
 
    modification, are permitted provided that the following conditions are
14
 
    met:
15
 
 
16
 
        * Redistributions of source code must retain the above copyright
17
 
          notice, this list of conditions and the following disclaimer.
18
 
        * Redistributions in binary form must reproduce the above copyright
19
 
          notice, this list of conditions and the following disclaimer in
20
 
          the documentation and/or other materials provided with the
21
 
          distribution.
22
 
        * Neither the name 'MAME' nor the names of its contributors may be
23
 
          used to endorse or promote products derived from this software
24
 
          without specific prior written permission.
25
 
 
26
 
    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27
 
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28
 
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
 
    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30
 
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31
 
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
 
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33
 
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34
 
    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35
 
    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
 
    POSSIBILITY OF SUCH DAMAGE.
37
 
 
38
 
***************************************************************************/
39
 
 
40
 
#include "emu.h"
41
 
#include "emuopts.h"
42
 
 
43
 
#include <ctype.h>
44
 
 
45
 
 
46
 
 
47
 
//**************************************************************************
48
 
//  CORE EMULATOR OPTIONS
49
 
//**************************************************************************
50
 
 
51
 
const options_entry emu_options::s_option_entries[] =
52
 
{
53
 
        // unadorned options - only a single one supported at the moment
54
 
        { OPTION_SYSTEMNAME,                                 NULL,        OPTION_STRING,     NULL },
55
 
        { OPTION_SOFTWARENAME,                               NULL,        OPTION_STRING,     NULL },
56
 
 
57
 
        // config options
58
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE CONFIGURATION OPTIONS" },
59
 
        { OPTION_READCONFIG ";rc",                           "1",         OPTION_BOOLEAN,    "enable loading of configuration files" },
60
 
        { OPTION_WRITECONFIG ";wc",                          "0",         OPTION_BOOLEAN,    "writes configuration to (driver).ini on exit" },
61
 
 
62
 
        // seach path options
63
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE SEARCH PATH OPTIONS" },
64
 
        { OPTION_MEDIAPATH ";rp;biospath;bp",                "roms",      OPTION_STRING,     "path to ROMsets and hard disk images" },
65
 
        { OPTION_HASHPATH ";hash_directory;hash",            "hash",      OPTION_STRING,     "path to hash files" },
66
 
        { OPTION_SAMPLEPATH ";sp",                           "samples",   OPTION_STRING,     "path to samplesets" },
67
 
        { OPTION_ARTPATH,                                    "artwork",   OPTION_STRING,     "path to artwork files" },
68
 
        { OPTION_CTRLRPATH,                                  "ctrlr",     OPTION_STRING,     "path to controller definitions" },
69
 
        { OPTION_INIPATH,                                    ".;ini",     OPTION_STRING,     "path to ini files" },
70
 
        { OPTION_FONTPATH,                                   ".",         OPTION_STRING,     "path to font files" },
71
 
        { OPTION_CHEATPATH,                                  "cheat",     OPTION_STRING,     "path to cheat files" },
72
 
        { OPTION_CROSSHAIRPATH,                              "crosshair", OPTION_STRING,     "path to crosshair files" },
73
 
 
74
 
        // output directory options
75
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE OUTPUT DIRECTORY OPTIONS" },
76
 
        { OPTION_CFG_DIRECTORY,                              "cfg",       OPTION_STRING,     "directory to save configurations" },
77
 
        { OPTION_NVRAM_DIRECTORY,                            "nvram",     OPTION_STRING,     "directory to save nvram contents" },
78
 
        { OPTION_MEMCARD_DIRECTORY,                          "memcard",   OPTION_STRING,     "directory to save memory card contents" },
79
 
        { OPTION_INPUT_DIRECTORY,                            "inp",       OPTION_STRING,     "directory to save input device logs" },
80
 
        { OPTION_STATE_DIRECTORY,                            "sta",       OPTION_STRING,     "directory to save states" },
81
 
        { OPTION_SNAPSHOT_DIRECTORY,                         "snap",      OPTION_STRING,     "directory to save screenshots" },
82
 
        { OPTION_DIFF_DIRECTORY,                             "diff",      OPTION_STRING,     "directory to save hard drive image difference files" },
83
 
        { OPTION_COMMENT_DIRECTORY,                          "comments",  OPTION_STRING,     "directory to save debugger comments" },
84
 
 
85
 
        // state/playback options
86
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE STATE/PLAYBACK OPTIONS" },
87
 
        { OPTION_STATE,                                      NULL,        OPTION_STRING,     "saved state to load" },
88
 
        { OPTION_AUTOSAVE,                                   "0",         OPTION_BOOLEAN,    "enable automatic restore at startup, and automatic save at exit time" },
89
 
        { OPTION_PLAYBACK ";pb",                             NULL,        OPTION_STRING,     "playback an input file" },
90
 
        { OPTION_RECORD ";rec",                              NULL,        OPTION_STRING,     "record an input file" },
91
 
        { OPTION_MNGWRITE,                                   NULL,        OPTION_STRING,     "optional filename to write a MNG movie of the current session" },
92
 
        { OPTION_AVIWRITE,                                   NULL,        OPTION_STRING,     "optional filename to write an AVI movie of the current session" },
93
 
        { OPTION_WAVWRITE,                                   NULL,        OPTION_STRING,     "optional filename to write a WAV file of the current session" },
94
 
        { OPTION_SNAPNAME,                                   "%g/%i",     OPTION_STRING,     "override of the default snapshot/movie naming; %g == gamename, %i == index" },
95
 
        { OPTION_SNAPSIZE,                                   "auto",      OPTION_STRING,     "specify snapshot/movie resolution (<width>x<height>) or 'auto' to use minimal size " },
96
 
        { OPTION_SNAPVIEW,                                   "internal",  OPTION_STRING,     "specify snapshot/movie view or 'internal' to use internal pixel-aspect views" },
97
 
        { OPTION_BURNIN,                                     "0",         OPTION_BOOLEAN,    "create burn-in snapshots for each screen" },
98
 
 
99
 
        // performance options
100
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE PERFORMANCE OPTIONS" },
101
 
        { OPTION_AUTOFRAMESKIP ";afs",                       "0",         OPTION_BOOLEAN,    "enable automatic frameskip selection" },
102
 
        { OPTION_FRAMESKIP ";fs(0-10)",                      "0",         OPTION_INTEGER,    "set frameskip to fixed value, 0-10 (autoframeskip must be disabled)" },
103
 
        { OPTION_SECONDS_TO_RUN ";str",                      "0",         OPTION_INTEGER,    "number of emulated seconds to run before automatically exiting" },
104
 
        { OPTION_THROTTLE,                                   "1",         OPTION_BOOLEAN,    "enable throttling to keep game running in sync with real time" },
105
 
        { OPTION_SLEEP,                                      "1",         OPTION_BOOLEAN,    "enable sleeping, which gives time back to other applications when idle" },
106
 
        { OPTION_SPEED "(0.01-100)",                         "1.0",       OPTION_FLOAT,      "controls the speed of gameplay, relative to realtime; smaller numbers are slower" },
107
 
        { OPTION_REFRESHSPEED ";rs",                         "0",         OPTION_BOOLEAN,    "automatically adjusts the speed of gameplay to keep the refresh rate lower than the screen" },
108
 
 
109
 
        // rotation options
110
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE ROTATION OPTIONS" },
111
 
        { OPTION_ROTATE,                                     "1",         OPTION_BOOLEAN,    "rotate the game screen according to the game's orientation needs it" },
112
 
        { OPTION_ROR,                                        "0",         OPTION_BOOLEAN,    "rotate screen clockwise 90 degrees" },
113
 
        { OPTION_ROL,                                        "0",         OPTION_BOOLEAN,    "rotate screen counterclockwise 90 degrees" },
114
 
        { OPTION_AUTOROR,                                    "0",         OPTION_BOOLEAN,    "automatically rotate screen clockwise 90 degrees if vertical" },
115
 
        { OPTION_AUTOROL,                                    "0",         OPTION_BOOLEAN,    "automatically rotate screen counterclockwise 90 degrees if vertical" },
116
 
        { OPTION_FLIPX,                                      "0",         OPTION_BOOLEAN,    "flip screen left-right" },
117
 
        { OPTION_FLIPY,                                      "0",         OPTION_BOOLEAN,    "flip screen upside-down" },
118
 
 
119
 
        // artwork options
120
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE ARTWORK OPTIONS" },
121
 
        { OPTION_ARTWORK_CROP ";artcrop",                    "0",         OPTION_BOOLEAN,    "crop artwork to game screen size" },
122
 
        { OPTION_USE_BACKDROPS ";backdrop",                  "1",         OPTION_BOOLEAN,    "enable backdrops if artwork is enabled and available" },
123
 
        { OPTION_USE_OVERLAYS ";overlay",                    "1",         OPTION_BOOLEAN,    "enable overlays if artwork is enabled and available" },
124
 
        { OPTION_USE_BEZELS ";bezel",                        "1",         OPTION_BOOLEAN,    "enable bezels if artwork is enabled and available" },
125
 
        { OPTION_USE_CPANELS ";cpanel",                      "1",         OPTION_BOOLEAN,    "enable cpanels if artwork is enabled and available" },
126
 
        { OPTION_USE_MARQUEES ";marquee",                    "1",         OPTION_BOOLEAN,    "enable marquees if artwork is enabled and available" },
127
 
 
128
 
        // screen options
129
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE SCREEN OPTIONS" },
130
 
        { OPTION_BRIGHTNESS "(0.1-2.0)",                     "1.0",       OPTION_FLOAT,      "default game screen brightness correction" },
131
 
        { OPTION_CONTRAST "(0.1-2.0)",                       "1.0",       OPTION_FLOAT,      "default game screen contrast correction" },
132
 
        { OPTION_GAMMA "(0.1-3.0)",                          "1.0",       OPTION_FLOAT,      "default game screen gamma correction" },
133
 
        { OPTION_PAUSE_BRIGHTNESS "(0.0-1.0)",               "0.65",      OPTION_FLOAT,      "amount to scale the screen brightness when paused" },
134
 
        { OPTION_EFFECT,                                     "none",      OPTION_STRING,     "name of a PNG file to use for visual effects, or 'none'" },
135
 
 
136
 
        // vector options
137
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE VECTOR OPTIONS" },
138
 
        { OPTION_ANTIALIAS ";aa",                            "1",         OPTION_BOOLEAN,    "use antialiasing when drawing vectors" },
139
 
        { OPTION_BEAM,                                       "1.0",       OPTION_FLOAT,      "set vector beam width" },
140
 
        { OPTION_FLICKER,                                    "0",         OPTION_FLOAT,      "set vector flicker effect" },
141
 
 
142
 
        // sound options
143
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE SOUND OPTIONS" },
144
 
        { OPTION_SOUND,                                      "1",         OPTION_BOOLEAN,    "enable sound output" },
145
 
        { OPTION_SAMPLERATE ";sr(1000-1000000)",             "48000",     OPTION_INTEGER,    "set sound output sample rate" },
146
 
        { OPTION_SAMPLES,                                    "1",         OPTION_BOOLEAN,    "enable the use of external samples if available" },
147
 
        { OPTION_VOLUME ";vol",                              "0",         OPTION_INTEGER,    "sound volume in decibels (-32 min, 0 max)" },
148
 
 
149
 
        // input options
150
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE INPUT OPTIONS" },
151
 
        { OPTION_COIN_LOCKOUT ";coinlock",                   "1",         OPTION_BOOLEAN,    "enable coin lockouts to actually lock out coins" },
152
 
        { OPTION_CTRLR,                                      NULL,        OPTION_STRING,     "preconfigure for specified controller" },
153
 
        { OPTION_MOUSE,                                      "0",         OPTION_BOOLEAN,    "enable mouse input" },
154
 
        { OPTION_JOYSTICK ";joy",                            "1",         OPTION_BOOLEAN,    "enable joystick input" },
155
 
        { OPTION_LIGHTGUN ";gun",                            "0",         OPTION_BOOLEAN,    "enable lightgun input" },
156
 
        { OPTION_MULTIKEYBOARD ";multikey",                  "0",         OPTION_BOOLEAN,    "enable separate input from each keyboard device (if present)" },
157
 
        { OPTION_MULTIMOUSE,                                 "0",         OPTION_BOOLEAN,    "enable separate input from each mouse device (if present)" },
158
 
        { OPTION_STEADYKEY ";steady",                        "0",         OPTION_BOOLEAN,    "enable steadykey support" },
159
 
        { OPTION_OFFSCREEN_RELOAD ";reload",                 "0",         OPTION_BOOLEAN,    "convert lightgun button 2 into offscreen reload" },
160
 
        { OPTION_JOYSTICK_MAP ";joymap",                     "auto",      OPTION_STRING,     "explicit joystick map, or auto to auto-select" },
161
 
        { OPTION_JOYSTICK_DEADZONE ";joy_deadzone;jdz",      "0.3",       OPTION_FLOAT,      "center deadzone range for joystick where change is ignored (0.0 center, 1.0 end)" },
162
 
        { OPTION_JOYSTICK_SATURATION ";joy_saturation;jsat", "0.85",      OPTION_FLOAT,      "end of axis saturation range for joystick where change is ignored (0.0 center, 1.0 end)" },
163
 
        { OPTION_NATURAL_KEYBOARD ";nat",                    "0",         OPTION_BOOLEAN,    "specifies whether to use a natural keyboard or not" },
164
 
 
165
 
        // input autoenable options
166
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE INPUT AUTOMATIC ENABLE OPTIONS" },
167
 
        { OPTION_PADDLE_DEVICE ";paddle",                    "keyboard",  OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if a paddle control is present" },
168
 
        { OPTION_ADSTICK_DEVICE ";adstick",                  "keyboard",  OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if an analog joystick control is present" },
169
 
        { OPTION_PEDAL_DEVICE ";pedal",                      "keyboard",  OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if a pedal control is present" },
170
 
        { OPTION_DIAL_DEVICE ";dial",                        "keyboard",  OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if a dial control is present" },
171
 
        { OPTION_TRACKBALL_DEVICE ";trackball",              "keyboard",  OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if a trackball control is present" },
172
 
        { OPTION_LIGHTGUN_DEVICE,                            "keyboard",  OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if a lightgun control is present" },
173
 
        { OPTION_POSITIONAL_DEVICE,                          "keyboard",  OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if a positional control is present" },
174
 
        { OPTION_MOUSE_DEVICE,                               "mouse",     OPTION_STRING,     "enable (none|keyboard|mouse|lightgun|joystick) if a mouse control is present" },
175
 
 
176
 
        // debugging options
177
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE DEBUGGING OPTIONS" },
178
 
        { OPTION_LOG,                                        "0",         OPTION_BOOLEAN,    "generate an error.log file" },
179
 
        { OPTION_VERBOSE ";v",                               "0",         OPTION_BOOLEAN,    "display additional diagnostic information" },
180
 
        { OPTION_UPDATEINPAUSE,                              "0",         OPTION_BOOLEAN,    "keep calling video updates while in pause" },
181
 
        { OPTION_DEBUG ";d",                                 "0",         OPTION_BOOLEAN,    "enable/disable debugger" },
182
 
        { OPTION_DEBUGSCRIPT,                                NULL,        OPTION_STRING,     "script for debugger" },
183
 
        { OPTION_DEBUG_INTERNAL ";di",                       "0",         OPTION_BOOLEAN,    "use the internal debugger for debugging" },
184
 
 
185
 
        // misc options
186
 
        { NULL,                                              NULL,        OPTION_HEADER,     "CORE MISC OPTIONS" },
187
 
        { OPTION_BIOS,                                       NULL,        OPTION_STRING,     "select the system BIOS to use" },
188
 
        { OPTION_CHEAT ";c",                                 "0",         OPTION_BOOLEAN,    "enable cheat subsystem" },
189
 
        { OPTION_SKIP_GAMEINFO,                              "0",         OPTION_BOOLEAN,    "skip displaying the information screen at startup" },
190
 
        { OPTION_UI_FONT,                                    "default",   OPTION_STRING,     "specify a font to use" },
191
 
        { OPTION_RAMSIZE ";ram",                             NULL,        OPTION_STRING,     "size of RAM (if supported by driver)" },
192
 
        { OPTION_CONFIRM_QUIT,                               "0",         OPTION_BOOLEAN,    "display confirm quit screen on exit" },
193
 
        { NULL }
194
 
};
195
 
 
196
 
 
197
 
 
198
 
//**************************************************************************
199
 
//  EMU OPTIONS
200
 
//**************************************************************************
201
 
 
202
 
//-------------------------------------------------
203
 
//  emu_options - constructor
204
 
//-------------------------------------------------
205
 
 
206
 
emu_options::emu_options()
207
 
{
208
 
        add_entries(s_option_entries);
209
 
}
210
 
 
211
 
 
212
 
//-------------------------------------------------
213
 
//  add_slot_options - add all of the slot
214
 
//  options for the configured system
215
 
//-------------------------------------------------
216
 
 
217
 
bool emu_options::add_slot_options(bool isfirst)
218
 
{
219
 
        // look up the system configured by name; if no match, do nothing
220
 
        const game_driver *cursystem = system();
221
 
        if (cursystem == NULL)
222
 
                return false;
223
 
 
224
 
        // iterate through all slot devices
225
 
        options_entry entry[2] = { { 0 }, { 0 } };
226
 
        bool first = true;
227
 
        const device_slot_interface *slot = NULL;
228
 
        // create the configuration
229
 
        machine_config config(*cursystem, *this);
230
 
        bool added = false;
231
 
        for (bool gotone = config.devicelist().first(slot); gotone; gotone = slot->next(slot))
232
 
        {
233
 
                // first device? add the header as to be pretty
234
 
                if (first && isfirst)
235
 
                {
236
 
                        entry[0].name = NULL;
237
 
                        entry[0].description = "SLOT DEVICES";
238
 
                        entry[0].flags = OPTION_HEADER | OPTION_FLAG_DEVICE;
239
 
                        entry[0].defvalue = NULL;
240
 
                        add_entries(entry);
241
 
                }
242
 
                first = false;
243
 
 
244
 
                // retrieve info about the device instance
245
 
                astring option_name;
246
 
                option_name.printf("%s;%s", slot->device().tag(), slot->device().tag());
247
 
 
248
 
                if (!exists(slot->device().tag())) {
249
 
 
250
 
                        // add the option
251
 
                        entry[0].name = slot->device().tag();
252
 
                        entry[0].description = NULL;
253
 
                        entry[0].flags = OPTION_STRING | OPTION_FLAG_DEVICE;
254
 
                        entry[0].defvalue = (slot->get_slot_interfaces() != NULL) ? slot->get_default_card() : NULL;
255
 
                        add_entries(entry, true);
256
 
 
257
 
                        added = true;
258
 
                }
259
 
        }
260
 
        return added;
261
 
}
262
 
 
263
 
//-------------------------------------------------
264
 
//  add_device_options - add all of the device
265
 
//  options for the configured system
266
 
//-------------------------------------------------
267
 
 
268
 
void emu_options::add_device_options(bool isfirst)
269
 
{
270
 
        // look up the system configured by name; if no match, do nothing
271
 
        const game_driver *cursystem = system();
272
 
        if (cursystem == NULL)
273
 
                return;
274
 
 
275
 
        // iterate through all slot devices
276
 
        options_entry entry[2] = { { 0 }, { 0 } };
277
 
        bool first = true;
278
 
        // iterate through all image devices
279
 
        const device_image_interface *image = NULL;
280
 
        machine_config config(*cursystem, *this);
281
 
        for (bool gotone = config.devicelist().first(image); gotone; gotone = image->next(image))
282
 
        {
283
 
                // first device? add the header as to be pretty
284
 
                if (first && isfirst)
285
 
                {
286
 
                        entry[0].name = NULL;
287
 
                        entry[0].description = "IMAGE DEVICES";
288
 
                        entry[0].flags = OPTION_HEADER | OPTION_FLAG_DEVICE;
289
 
                        entry[0].defvalue = NULL;
290
 
                        add_entries(entry);
291
 
                }
292
 
                first = false;
293
 
 
294
 
                // retrieve info about the device instance
295
 
                astring option_name;
296
 
                option_name.printf("%s;%s", image->instance_name(), image->brief_instance_name());
297
 
 
298
 
                // add the option
299
 
                entry[0].name = option_name;
300
 
                entry[0].description = NULL;
301
 
                entry[0].flags = OPTION_STRING | OPTION_FLAG_DEVICE;
302
 
                entry[0].defvalue = NULL;
303
 
                add_entries(entry, true);
304
 
        }
305
 
}
306
 
 
307
 
 
308
 
//-------------------------------------------------
309
 
//  remove_device_options - remove device options
310
 
//-------------------------------------------------
311
 
 
312
 
void emu_options::remove_device_options()
313
 
{
314
 
        // iterate through options and remove interesting ones
315
 
        entry *nextentry;
316
 
        for (entry *curentry = first(); curentry != NULL; curentry = nextentry)
317
 
        {
318
 
                // pre-fetch the next entry in case we delete this one
319
 
                nextentry = curentry->next();
320
 
 
321
 
                // if this is a device option, nuke it
322
 
                if ((curentry->flags() & OPTION_FLAG_DEVICE) != 0)
323
 
                        remove_entry(*curentry);
324
 
        }
325
 
}
326
 
 
327
 
 
328
 
//-------------------------------------------------
329
 
//  parse_command_line - parse the command line
330
 
//  and update the devices
331
 
//-------------------------------------------------
332
 
 
333
 
bool emu_options::parse_command_line(int argc, char *argv[], astring &error_string)
334
 
{
335
 
        // remember the original system name
336
 
        astring old_system_name(system_name());
337
 
 
338
 
        // parse as normal
339
 
        bool result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
340
 
 
341
 
        // if the system name changed, fix up the device options
342
 
        if (old_system_name != system_name())
343
 
        {
344
 
                // remove any existing device options
345
 
                remove_device_options();
346
 
                add_device_options(true);
347
 
                bool isfirst = true;
348
 
                while (add_slot_options(isfirst)) {
349
 
                        result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
350
 
                        add_device_options(false);
351
 
                        isfirst = false;
352
 
                }
353
 
                // if we failed the first time, try parsing again with the new options in place
354
 
                if (!result)
355
 
                        result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
356
 
        }
357
 
        return result;
358
 
}
359
 
 
360
 
 
361
 
//-------------------------------------------------
362
 
//  parse_standard_inis - parse the standard set
363
 
//  of INI files
364
 
//-------------------------------------------------
365
 
 
366
 
void emu_options::parse_standard_inis(astring &error_string)
367
 
{
368
 
        // start with an empty string
369
 
        error_string.reset();
370
 
 
371
 
        // parse the INI file defined by the platform (e.g., "mame.ini")
372
 
        // we do this twice so that the first file can change the INI path
373
 
        parse_one_ini(CONFIGNAME, OPTION_PRIORITY_MAME_INI);
374
 
        parse_one_ini(CONFIGNAME, OPTION_PRIORITY_MAME_INI, &error_string);
375
 
 
376
 
        // debug mode: parse "debug.ini" as well
377
 
        if (debug())
378
 
                parse_one_ini("debug", OPTION_PRIORITY_DEBUG_INI, &error_string);
379
 
 
380
 
        // if we have a valid system driver, parse system-specific INI files
381
 
        const game_driver *cursystem = system();
382
 
        if (cursystem == NULL)
383
 
                return;
384
 
 
385
 
        // parse "vertical.ini" or "horizont.ini"
386
 
        if (cursystem->flags & ORIENTATION_SWAP_XY)
387
 
                parse_one_ini("vertical", OPTION_PRIORITY_ORIENTATION_INI, &error_string);
388
 
        else
389
 
                parse_one_ini("horizont", OPTION_PRIORITY_ORIENTATION_INI, &error_string);
390
 
 
391
 
        // parse "vector.ini" for vector games
392
 
        {
393
 
                machine_config config(*cursystem, *this);
394
 
                for (const screen_device *device = config.first_screen(); device != NULL; device = device->next_screen())
395
 
                        if (device->screen_type() == SCREEN_TYPE_VECTOR)
396
 
                        {
397
 
                                parse_one_ini("vector", OPTION_PRIORITY_VECTOR_INI, &error_string);
398
 
                                break;
399
 
                        }
400
 
        }
401
 
 
402
 
        // next parse "source/<sourcefile>.ini"; if that doesn't exist, try <sourcefile>.ini
403
 
        astring sourcename;
404
 
        core_filename_extract_base(&sourcename, cursystem->source_file, TRUE)->ins(0, "source" PATH_SEPARATOR);
405
 
        if (!parse_one_ini(sourcename, OPTION_PRIORITY_SOURCE_INI, &error_string))
406
 
        {
407
 
                core_filename_extract_base(&sourcename, cursystem->source_file, TRUE);
408
 
                parse_one_ini(sourcename, OPTION_PRIORITY_SOURCE_INI, &error_string);
409
 
        }
410
 
 
411
 
        // then parse the grandparent, parent, and system-specific INIs
412
 
        int parent = driver_list::clone(*cursystem);
413
 
        int gparent = (parent != -1) ? driver_list::clone(parent) : -1;
414
 
        if (gparent != -1)
415
 
                parse_one_ini(driver_list::driver(gparent).name, OPTION_PRIORITY_GPARENT_INI, &error_string);
416
 
        if (parent != -1)
417
 
                parse_one_ini(driver_list::driver(parent).name, OPTION_PRIORITY_PARENT_INI, &error_string);
418
 
        parse_one_ini(cursystem->name, OPTION_PRIORITY_DRIVER_INI, &error_string);
419
 
}
420
 
 
421
 
 
422
 
//-------------------------------------------------
423
 
//  system - return a pointer to the specified
424
 
//  system driver, or NULL if no match
425
 
//-------------------------------------------------
426
 
 
427
 
const game_driver *emu_options::system() const
428
 
{
429
 
        astring tempstr;
430
 
        int index = driver_list::find(*core_filename_extract_base(&tempstr, system_name(), TRUE));
431
 
        return (index != -1) ? &driver_list::driver(index) : NULL;
432
 
}
433
 
 
434
 
 
435
 
//-------------------------------------------------
436
 
//  set_system_name - set a new system name
437
 
//-------------------------------------------------
438
 
 
439
 
void emu_options::set_system_name(const char *name)
440
 
{
441
 
        // remember the original system name
442
 
        astring old_system_name(system_name());
443
 
 
444
 
        // if the system name changed, fix up the device options
445
 
        if (old_system_name != name)
446
 
        {
447
 
                // first set the new name
448
 
                astring error;
449
 
                set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
450
 
                assert(!error);
451
 
                // remove any existing device options
452
 
                remove_device_options();
453
 
                // then add the options
454
 
                add_device_options(true);
455
 
        }
456
 
}
457
 
 
458
 
 
459
 
//-------------------------------------------------
460
 
//  device_option - return the value of the
461
 
//  device-specific option
462
 
//-------------------------------------------------
463
 
 
464
 
const char *emu_options::device_option(device_image_interface &image)
465
 
{
466
 
        return value(image.instance_name());
467
 
}
468
 
 
469
 
 
470
 
//-------------------------------------------------
471
 
//  parse_one_ini - parse a single INI file
472
 
//-------------------------------------------------
473
 
 
474
 
bool emu_options::parse_one_ini(const char *basename, int priority, astring *error_string)
475
 
{
476
 
        // don't parse if it has been disabled
477
 
        if (!read_config())
478
 
                return false;
479
 
 
480
 
        // open the file; if we fail, that's ok
481
 
        emu_file file(ini_path(), OPEN_FLAG_READ);
482
 
        file_error filerr = file.open(basename, ".ini");
483
 
        if (filerr != FILERR_NONE)
484
 
                return false;
485
 
 
486
 
        // parse the file
487
 
        mame_printf_verbose("Parsing %s.ini\n", basename);
488
 
        astring error;
489
 
        bool result = parse_ini_file(file, priority, OPTION_PRIORITY_DRIVER_INI, error);
490
 
 
491
 
        // append errors if requested
492
 
        if (error && error_string != NULL)
493
 
                error_string->catprintf("While parsing %s:\n%s\n", file.fullpath(), error.cstr());
494
 
 
495
 
        return result;
496
 
}