Fixed reading default card and throw exception now on wrong slot item name (no whatsnew)

This commit is contained in:
Miodrag Milanovic 2011-11-13 15:28:56 +00:00
parent 35762c3186
commit 1d9a61aa09
2 changed files with 14 additions and 3 deletions

View File

@ -30,8 +30,13 @@ void device_slot_interface::static_set_slot_info(device_t &device, const slot_in
device_t* device_slot_interface::get_card_device() device_t* device_slot_interface::get_card_device()
{ {
const char *subtag = device().mconfig().options().value(device().tag()); const char *subtag;
device_t *dev = NULL; device_t *dev = NULL;
if (!device().mconfig().options().exists(device().tag())) {
subtag = m_default_card;
} else {
subtag = device().mconfig().options().value(device().tag());
}
if (subtag) { if (subtag) {
device_slot_card_interface *intf = NULL; device_slot_card_interface *intf = NULL;
dev = device().subdevice(subtag); dev = device().subdevice(subtag);

View File

@ -79,14 +79,20 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
if (!options.exists(owner.tag())) if (!options.exists(owner.tag()))
selval = slot->get_default_card(devicelist(), options); selval = slot->get_default_card(devicelist(), options);
if (selval != NULL) if (selval != NULL && strlen(selval)!=0) {
for (int i = 0; intf[i].name != NULL; i++) bool found = false;
for (int i = 0; intf[i].name != NULL; i++) {
if (strcmp(selval, intf[i].name) == 0) { if (strcmp(selval, intf[i].name) == 0) {
device_t *new_dev = device_add(&owner, intf[i].name, intf[i].devtype, 0); device_t *new_dev = device_add(&owner, intf[i].name, intf[i].devtype, 0);
found = true;
if (!options.exists(owner.tag())) if (!options.exists(owner.tag()))
device_t::static_set_input_default(*new_dev, slot->input_ports_defaults()); device_t::static_set_input_default(*new_dev, slot->input_ports_defaults());
} }
} }
if (!found)
throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval, owner.tag());
}
}
} }
// when finished, set the game driver // when finished, set the game driver