src/mess/messopts.c
| r1045 | r1046 | |
| 13 | 13 | #include "messopts.h" |
| 14 | 14 | #include "osdmess.h" |
| 15 | 15 | |
| 16 | #define OPTION_ADDED_DEVICE_OPTIONS "added_device_options" |
| 16 | 17 | |
| 17 | 18 | |
| 18 | 19 | /*************************************************************************** |
| 19 | 20 | LOCAL VARIABLES |
| 20 | 21 | ***************************************************************************/ |
| 21 | 22 | |
| 22 | | static int added_device_options; |
| 23 | | |
| 24 | 23 | const options_entry mess_core_options[] = |
| 25 | 24 | { |
| 26 | | { NULL, NULL, OPTION_HEADER, "MESS SPECIFIC OPTIONS" }, |
| 27 | | { "ramsize;ram", NULL, 0, "size of RAM (if supported by driver)" }, |
| 28 | | { "writeconfig;wc", "0", OPTION_BOOLEAN, "writes configuration to (driver).ini on exit" }, |
| 29 | | { OPTION_SKIP_WARNINGS, "0", OPTION_BOOLEAN, "skip displaying the warnings screen" }, |
| 25 | { NULL, NULL, OPTION_HEADER, "MESS SPECIFIC OPTIONS" }, |
| 26 | { "ramsize;ram", NULL, 0, "size of RAM (if supported by driver)" }, |
| 27 | { "writeconfig;wc", "0", OPTION_BOOLEAN, "writes configuration to (driver).ini on exit" }, |
| 28 | { OPTION_SKIP_WARNINGS, "0", OPTION_BOOLEAN, "skip displaying the warnings screen" }, |
| 29 | { OPTION_ADDED_DEVICE_OPTIONS, "0", OPTION_BOOLEAN | OPTION_INTERNAL, "device-specific options have been added" }, |
| 30 | 30 | { NULL } |
| 31 | 31 | }; |
| 32 | 32 | |
| r1045 | r1046 | |
| 46 | 46 | const char *result = NULL; |
| 47 | 47 | const char *dev_name; |
| 48 | 48 | |
| 49 | | if (added_device_options) |
| 49 | if (options_get_bool(mame_options(), OPTION_ADDED_DEVICE_OPTIONS)) |
| 50 | 50 | { |
| 51 | 51 | /* identify the option name */ |
| 52 | 52 | dev_name = device_instancename(devclass, device_index); |
| r1045 | r1046 | |
| 146 | 146 | |
| 147 | 147 | void mess_add_device_options(core_options *opts, const game_driver *driver) |
| 148 | 148 | { |
| 149 | /* enumerate our callback for every device */ |
| 149 | 150 | mess_enumerate_devices(opts, driver, add_device_options_for_device); |
| 151 | |
| 152 | /* record that we've added device options */ |
| 153 | options_set_bool(opts, OPTION_ADDED_DEVICE_OPTIONS, TRUE, OPTION_PRIORITY_CMDLINE); |
| 150 | 154 | } |
| 151 | 155 | |
| 152 | 156 | |
| r1045 | r1046 | |
| 162 | 166 | const game_driver *driver; |
| 163 | 167 | |
| 164 | 168 | /* only add these options if we have not yet added them */ |
| 165 | | if (!added_device_options) |
| 169 | if (!options_get_bool(opts, OPTION_ADDED_DEVICE_OPTIONS)) |
| 166 | 170 | { |
| 167 | 171 | driver = driver_get_name(arg); |
| 168 | 172 | if (driver != NULL) |
| 169 | 173 | { |
| 170 | 174 | mess_add_device_options(opts, driver); |
| 171 | 175 | } |
| 172 | | added_device_options = TRUE; |
| 173 | 176 | } |
| 174 | 177 | } |
| 175 | 178 | |
| r1045 | r1046 | |
| 188 | 191 | /* add OSD-MESS specific options (hack!) */ |
| 189 | 192 | osd_mess_options_init(opts); |
| 190 | 193 | |
| 191 | | /* hacky global variable to track whether we have added device options */ |
| 192 | | added_device_options = FALSE; |
| 193 | | |
| 194 | 194 | /* we need to dynamically add options when the device name is parsed */ |
| 195 | 195 | options_set_option_callback(opts, OPTION_GAMENAME, mess_driver_name_callback); |
| 196 | 196 | } |
| r1045 | r1046 | |
| 211 | 211 | const char *dev_name; |
| 212 | 212 | const char *filename; |
| 213 | 213 | |
| 214 | | assert_always(added_device_options, "extract_device_options_for_device() called without device options"); |
| 214 | assert_always(options_get_bool(opts, OPTION_ADDED_DEVICE_OPTIONS), "extract_device_options_for_device() called without device options"); |
| 215 | 215 | |
| 216 | 216 | /* identify the correct image */ |
| 217 | 217 | dev_tag = device_get_info_string(devclass, DEVINFO_STR_DEV_TAG); |
| r1045 | r1046 | |
| 278 | 278 | void mess_options_extract(void) |
| 279 | 279 | { |
| 280 | 280 | /* only extract the device options if we've added them */ |
| 281 | | if (added_device_options) |
| 281 | if (options_get_bool(mame_options(), OPTION_ADDED_DEVICE_OPTIONS)) |
| 282 | 282 | mess_enumerate_devices(mame_options(), Machine->gamedrv, extract_device_options_for_device); |
| 283 | 283 | |
| 284 | 284 | /* write the config, if appropriate */ |