Iterate over devices C++11 style

Replace the old device_iterator and its specialized versions with functionally equivalent classes that use standard operators to yield references to devices/interfaces rather than pointers. With range-based for loops, they no longer have to be stored in named variables, though they can also be reused concurrently since the iteration state is now maintained by a subclass.

Add a few more typical getters to device_t::subdevice_list.
This commit is contained in:
AJR 2016-04-18 18:53:28 -04:00
parent 55d3e544e0
commit 084d3654ca
66 changed files with 1084 additions and 1247 deletions

View File

@ -252,11 +252,9 @@ void abc890_t::device_reset()
void abc890_t::abcbus_cs(UINT8 data) void abc890_t::abcbus_cs(UINT8 data)
{ {
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
slot->cs_w(data); slot.cs_w(data);
} }
} }
@ -269,11 +267,9 @@ UINT8 abc890_t::abcbus_inp()
{ {
UINT8 data = 0xff; UINT8 data = 0xff;
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
data &= slot->inp_r(); data &= slot.inp_r();
} }
return data; return data;
@ -286,11 +282,9 @@ UINT8 abc890_t::abcbus_inp()
void abc890_t::abcbus_out(UINT8 data) void abc890_t::abcbus_out(UINT8 data)
{ {
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
slot->out_w(data); slot.out_w(data);
} }
} }
@ -303,11 +297,9 @@ UINT8 abc890_t::abcbus_stat()
{ {
UINT8 data = 0xff; UINT8 data = 0xff;
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
data &= slot->stat_r(); data &= slot.stat_r();
} }
return data; return data;
@ -320,11 +312,9 @@ UINT8 abc890_t::abcbus_stat()
void abc890_t::abcbus_c1(UINT8 data) void abc890_t::abcbus_c1(UINT8 data)
{ {
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
slot->c1_w(data); slot.c1_w(data);
} }
} }
@ -335,11 +325,9 @@ void abc890_t::abcbus_c1(UINT8 data)
void abc890_t::abcbus_c2(UINT8 data) void abc890_t::abcbus_c2(UINT8 data)
{ {
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
slot->c2_w(data); slot.c2_w(data);
} }
} }
@ -350,11 +338,9 @@ void abc890_t::abcbus_c2(UINT8 data)
void abc890_t::abcbus_c3(UINT8 data) void abc890_t::abcbus_c3(UINT8 data)
{ {
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
slot->c3_w(data); slot.c3_w(data);
} }
} }
@ -365,11 +351,9 @@ void abc890_t::abcbus_c3(UINT8 data)
void abc890_t::abcbus_c4(UINT8 data) void abc890_t::abcbus_c4(UINT8 data)
{ {
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
slot->c4_w(data); slot.c4_w(data);
} }
} }
@ -382,11 +366,9 @@ UINT8 abc890_t::abcbus_xmemfl(offs_t offset)
{ {
UINT8 data = 0xff; UINT8 data = 0xff;
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
data &= slot->xmemfl_r(offset); data &= slot.xmemfl_r(offset);
} }
return data; return data;
@ -399,10 +381,8 @@ UINT8 abc890_t::abcbus_xmemfl(offs_t offset)
void abc890_t::abcbus_xmemw(offs_t offset, UINT8 data) void abc890_t::abcbus_xmemw(offs_t offset, UINT8 data)
{ {
abcbus_slot_device_iterator iter(*this); for (abcbus_slot_t &slot : abcbus_slot_device_iterator(*this))
for (abcbus_slot_t *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
slot->xmemw_w(offset, data); slot.xmemw_w(offset, data);
} }
} }

View File

@ -74,17 +74,13 @@ c64_bn1541_device::c64_bn1541_device(const machine_config &mconfig, const char *
void c64_bn1541_device::device_start() void c64_bn1541_device::device_start()
{ {
device_iterator iter(machine().root_device()); for (device_t &device : device_iterator(machine().root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next())
{ {
device_iterator subiter(*device); for (device_t &subdevice : device_iterator(device))
for (device_t *subdevice = subiter.first(); subdevice != nullptr; subdevice = iter.next())
{ {
if (subdevice->interface(m_other) && subdevice != this) if (subdevice.interface(m_other) && &subdevice != this)
{ {
if (LOG) logerror("Parallel device %s\n", subdevice->tag()); if (LOG) logerror("Parallel device %s\n", subdevice.tag());
// grab the first 1541/1571 and run to the hills // grab the first 1541/1571 and run to the hills
m_other->m_other = this; m_other->m_other = this;

View File

@ -372,7 +372,6 @@ void cassette_image_device::call_display()
int n; int n;
double position, length; double position, length;
cassette_state uistate; cassette_state uistate;
cassette_image_device *dev;
static const UINT8 shapes[8] = { 0x2d, 0x5c, 0x7c, 0x2f, 0x2d, 0x20, 0x20, 0x20 }; static const UINT8 shapes[8] = { 0x2d, 0x5c, 0x7c, 0x2f, 0x2d, 0x20, 0x20, 0x20 };
/* abort if we should not be showing the image */ /* abort if we should not be showing the image */
@ -390,9 +389,7 @@ void cassette_image_device::call_display()
x = 0.2f; x = 0.2f;
y = 0.5f; y = 0.5f;
cassette_device_iterator iter(device().machine().root_device()); y += cassette_device_iterator(device().machine().root_device()).indexof(*this);
for (dev = iter.first(); dev != nullptr && strcmp( dev->tag(), device().tag() ); dev = iter.next())
y += 1;
y *= device().machine().ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER; y *= device().machine().ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
/* choose which frame of the animation we are at */ /* choose which frame of the animation we are at */

View File

@ -5010,12 +5010,11 @@ void voodoo_device::common_start_voodoo(UINT8 type)
} }
/* set the type, and initialize the chip mask */ /* set the type, and initialize the chip mask */
device_iterator iter(machine().root_device());
index = 0; index = 0;
for (device_t *scan = iter.first(); scan != nullptr; scan = iter.next()) for (device_t &scan : device_iterator(machine().root_device()))
if (scan->type() == this->type()) if (scan.type() == this->type())
{ {
if (scan == this) if (&scan == this)
break; break;
index++; index++;
} }

View File

@ -696,11 +696,10 @@ void address_map::map_validity_check(validity_checker &valid, const device_t &de
std::string entry_region = entry.m_devbase.subtag(entry.m_region); std::string entry_region = entry.m_devbase.subtag(entry.m_region);
// look for the region // look for the region
device_iterator deviter(device.mconfig().root_device()); for (device_t &dev : device_iterator(device.mconfig().root_device()))
for (device_t *dev = deviter.first(); dev != nullptr; dev = deviter.next()) for (const rom_entry *romp = rom_first_region(dev); romp != nullptr && !found; romp = rom_next_region(romp))
for (const rom_entry *romp = rom_first_region(*dev); romp != nullptr && !found; romp = rom_next_region(romp))
{ {
if (rom_region_name(*dev, romp) == entry_region) if (rom_region_name(dev, romp) == entry_region)
{ {
// verify the address range is within the region's bounds // verify the address range is within the region's bounds
offs_t length = ROMREGION_GETLENGTH(romp); offs_t length = ROMREGION_GETLENGTH(romp);

View File

@ -54,26 +54,25 @@ const char *driverpath = m_enumerator.config().root_device().searchpath();
int shared_required = 0; int shared_required = 0;
// iterate over devices and regions // iterate over devices and regions
device_iterator deviter(m_enumerator.config().root_device()); for (device_t &device : device_iterator(m_enumerator.config().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
{ {
// determine the search path for this source and iterate through the regions // determine the search path for this source and iterate through the regions
m_searchpath = device->searchpath(); m_searchpath = device.searchpath();
// now iterate over regions and ROMs within // now iterate over regions and ROMs within
for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region))
{ {
// temporary hack: add the driver path & region name // temporary hack: add the driver path & region name
std::string combinedpath = std::string(device->searchpath()).append(";").append(driverpath); std::string combinedpath = std::string(device.searchpath()).append(";").append(driverpath);
if (device->shortname()) if (device.shortname())
combinedpath.append(";").append(device->shortname()); combinedpath.append(";").append(device.shortname());
m_searchpath = combinedpath.c_str(); m_searchpath = combinedpath.c_str();
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{ {
const char *name = ROM_GETNAME(rom); const char *name = ROM_GETNAME(rom);
hash_collection hashes(ROM_GETHASHDATA(rom)); hash_collection hashes(ROM_GETHASHDATA(rom));
device_t *shared_device = find_shared_device(*device, name, hashes, ROM_GETLENGTH(rom)); device_t *shared_device = find_shared_device(device, name, hashes, ROM_GETLENGTH(rom));
// count the number of files with hashes // count the number of files with hashes
if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom)) if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom))
@ -95,7 +94,7 @@ m_searchpath = combinedpath.c_str();
if (record != nullptr) if (record != nullptr)
{ {
// count the number of files that are found. // count the number of files that are found.
if (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && find_shared_device(*device, name, record->actual_hashes(), record->actual_length()) == nullptr)) if (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && find_shared_device(device, name, record->actual_hashes(), record->actual_length()) == nullptr))
{ {
found++; found++;
if (shared_device != nullptr) if (shared_device != nullptr)
@ -124,20 +123,20 @@ m_searchpath = combinedpath.c_str();
// audit_device - audit the device // audit_device - audit the device
//------------------------------------------------- //-------------------------------------------------
media_auditor::summary media_auditor::audit_device(device_t *device, const char *validation) media_auditor::summary media_auditor::audit_device(device_t &device, const char *validation)
{ {
// start fresh // start fresh
m_record_list.reset(); m_record_list.reset();
// store validation for later // store validation for later
m_validation = validation; m_validation = validation;
m_searchpath = device->shortname(); m_searchpath = device.shortname();
int found = 0; int found = 0;
int required = 0; int required = 0;
// now iterate over regions and ROMs within // now iterate over regions and ROMs within
for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region))
{ {
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{ {
@ -173,7 +172,7 @@ media_auditor::summary media_auditor::audit_device(device_t *device, const char
} }
// return a summary // return a summary
return summarize(device->shortname()); return summarize(device.shortname());
} }
@ -270,14 +269,13 @@ media_auditor::summary media_auditor::audit_samples()
int found = 0; int found = 0;
// iterate over sample entries // iterate over sample entries
samples_device_iterator iterator(m_enumerator.config().root_device()); for (samples_device &device : samples_device_iterator(m_enumerator.config().root_device()))
for (samples_device *device = iterator.first(); device != nullptr; device = iterator.next())
{ {
// by default we just search using the driver name // by default we just search using the driver name
std::string searchpath(m_enumerator.driver().name); std::string searchpath(m_enumerator.driver().name);
// add the alternate path if present // add the alternate path if present
samples_iterator iter(*device); samples_iterator iter(device);
if (iter.altbasename() != nullptr) if (iter.altbasename() != nullptr)
searchpath.append(";").append(iter.altbasename()); searchpath.append(";").append(iter.altbasename());
@ -560,15 +558,14 @@ device_t *media_auditor::find_shared_device(device_t &device, const char *name,
// iterate up the parent chain // iterate up the parent chain
for (int drvindex = m_enumerator.find(m_enumerator.driver().parent); drvindex != -1; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent)) for (int drvindex = m_enumerator.find(m_enumerator.driver().parent); drvindex != -1; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent))
{ {
device_iterator deviter(m_enumerator.config(drvindex).root_device()); for (device_t &scandevice : device_iterator(m_enumerator.config(drvindex).root_device()))
for (device_t *scandevice = deviter.first(); scandevice != nullptr; scandevice = deviter.next()) for (const rom_entry *region = rom_first_region(scandevice); region; region = rom_next_region(region))
for (const rom_entry *region = rom_first_region(*scandevice); region; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
if (ROM_GETLENGTH(rom) == romlength) if (ROM_GETLENGTH(rom) == romlength)
{ {
hash_collection hashes(ROM_GETHASHDATA(rom)); hash_collection hashes(ROM_GETHASHDATA(rom));
if ((dumped && hashes == romhashes) || (!dumped && ROM_GETNAME(rom) == name)) if ((dumped && hashes == romhashes) || (!dumped && ROM_GETNAME(rom) == name))
highest_device = scandevice; highest_device = &scandevice;
} }
} }
} }

View File

@ -145,7 +145,7 @@ public:
// audit operations // audit operations
summary audit_media(const char *validation = AUDIT_VALIDATE_FULL); summary audit_media(const char *validation = AUDIT_VALIDATE_FULL);
summary audit_device(device_t *device, const char *validation = AUDIT_VALIDATE_FULL); summary audit_device(device_t &device, const char *validation = AUDIT_VALIDATE_FULL);
summary audit_software(const char *list_name, software_info *swinfo, const char *validation = AUDIT_VALIDATE_FULL); summary audit_software(const char *list_name, software_info *swinfo, const char *validation = AUDIT_VALIDATE_FULL);
summary audit_samples(); summary audit_samples();
summary summarize(const char *name,std::string *output = nullptr); summary summarize(const char *name,std::string *output = nullptr);

View File

@ -1141,22 +1141,21 @@ void cheat_manager::reload()
// load the cheat file, if it's a system that has a software list then try softlist_name/shortname.xml first, // load the cheat file, if it's a system that has a software list then try softlist_name/shortname.xml first,
// if it fails to load then try to load via crc32 - basename/crc32.xml ( eg. 01234567.xml ) // if it fails to load then try to load via crc32 - basename/crc32.xml ( eg. 01234567.xml )
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) if (image.exists())
if (image->exists())
{ {
// if we are loading through a software list, try to load softlist_name/shortname.xml // if we are loading through a software list, try to load softlist_name/shortname.xml
// this allows the coexistence of arcade cheats with cheats for home conversions which // this allows the coexistence of arcade cheats with cheats for home conversions which
// have the same shortname // have the same shortname
if (image->software_entry() != nullptr) if (image.software_entry() != nullptr)
{ {
load_cheats(string_format("%s%s%s", image->software_list_name(), PATH_SEPARATOR, image->basename()).c_str()); load_cheats(string_format("%s%s%s", image.software_list_name(), PATH_SEPARATOR, image.basename()).c_str());
break; break;
} }
// else we are loading outside the software list, try to load machine_basename/crc32.xml // else we are loading outside the software list, try to load machine_basename/crc32.xml
else else
{ {
UINT32 crc = image->crc(); UINT32 crc = image.crc();
if (crc != 0) if (crc != 0)
{ {
load_cheats(string_format("%s%s%08X", machine().basename(), PATH_SEPARATOR, crc).c_str()); load_cheats(string_format("%s%s%08X", machine().basename(), PATH_SEPARATOR, crc).c_str());

View File

@ -123,37 +123,36 @@ int cli_frontend::execute(int argc, char **argv)
throw emu_fatalerror(MAMERR_FATALERROR, "Error: unknown option: %s\n", m_options.software_name()); throw emu_fatalerror(MAMERR_FATALERROR, "Error: unknown option: %s\n", m_options.software_name());
bool found = false; bool found = false;
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) for (software_list_device &swlistdev : iter)
{ {
software_info *swinfo = swlistdev->find(m_options.software_name()); software_info *swinfo = swlistdev.find(m_options.software_name());
if (swinfo != nullptr) if (swinfo != nullptr)
{ {
// loop through all parts // loop through all parts
for (software_part &swpart : swinfo->parts()) for (software_part &swpart : swinfo->parts())
{ {
const char *mount = swpart.feature("automount"); const char *mount = swpart.feature("automount");
if (swpart.is_compatible(*swlistdev)) if (swpart.is_compatible(swlistdev))
{ {
if (mount == nullptr || strcmp(mount,"no") != 0) if (mount == nullptr || strcmp(mount,"no") != 0)
{ {
// search for an image device with the right interface // search for an image device with the right interface
image_interface_iterator imgiter(config.root_device()); for (device_image_interface &image : image_interface_iterator(config.root_device()))
for (device_image_interface *image = imgiter.first(); image != nullptr; image = imgiter.next())
{ {
const char *interface = image->image_interface(); const char *interface = image.image_interface();
if (interface != nullptr) if (interface != nullptr)
{ {
if (swpart.matches_interface(interface)) if (swpart.matches_interface(interface))
{ {
const char *option = m_options.value(image->brief_instance_name()); const char *option = m_options.value(image.brief_instance_name());
// mount only if not already mounted // mount only if not already mounted
if (*option == 0) if (*option == 0)
{ {
std::string val = string_format("%s:%s:%s", swlistdev->list_name(), m_options.software_name(), swpart.name()); std::string val = string_format("%s:%s:%s", swlistdev.list_name(), m_options.software_name(), swpart.name());
// call this in order to set slot devices according to mounting // call this in order to set slot devices according to mounting
m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.c_str(), &swpart); m_options.parse_slot_devices(argc, argv, option_errors, image.instance_name(), val.c_str(), &swpart);
break; break;
} }
} }
@ -434,15 +433,14 @@ void cli_frontend::listcrc(const char *gamename)
// iterate through matches, and then through ROMs // iterate through matches, and then through ROMs
while (drivlist.next()) while (drivlist.next())
{ {
device_iterator deviter(drivlist.config().root_device()); for (device_t &device : device_iterator(drivlist.config().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (const rom_entry *region = rom_first_region(device); region; region = rom_next_region(region))
for (const rom_entry *region = rom_first_region(*device); region; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{ {
// if we have a CRC, display it // if we have a CRC, display it
UINT32 crc; UINT32 crc;
if (hash_collection(ROM_GETHASHDATA(rom)).crc(crc)) if (hash_collection(ROM_GETHASHDATA(rom)).crc(crc))
osd_printf_info("%08x %-16s \t %-8s \t %s\n", crc, ROM_GETNAME(rom), device->shortname(), device->name()); osd_printf_info("%08x %-16s \t %-8s \t %s\n", crc, ROM_GETNAME(rom), device.shortname(), device.name());
} }
} }
} }
@ -472,9 +470,8 @@ void cli_frontend::listroms(const char *gamename)
"Name Size Checksum\n", drivlist.driver().name); "Name Size Checksum\n", drivlist.driver().name);
// iterate through roms // iterate through roms
device_iterator deviter(drivlist.config().root_device()); for (device_t &device : device_iterator(drivlist.config().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (const rom_entry *region = rom_first_region(device); region; region = rom_next_region(region))
for (const rom_entry *region = rom_first_region(*device); region; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
{ {
// accumulate the total length of all chunks // accumulate the total length of all chunks
@ -538,9 +535,9 @@ void cli_frontend::listsamples(const char *gamename)
osd_printf_info("Samples required for driver \"%s\".\n", drivlist.driver().name); osd_printf_info("Samples required for driver \"%s\".\n", drivlist.driver().name);
// iterate over samples devices and print the samples from each one // iterate over samples devices and print the samples from each one
for (samples_device *device = iter.first(); device != nullptr; device = iter.next()) for (samples_device &device : iter)
{ {
samples_iterator sampiter(*device); samples_iterator sampiter(device);
for (const char *samplename = sampiter.first(); samplename != nullptr; samplename = sampiter.next()) for (const char *samplename = sampiter.first(); samplename != nullptr; samplename = sampiter.next())
osd_printf_info("%s\n", samplename); osd_printf_info("%s\n", samplename);
} }
@ -578,10 +575,9 @@ void cli_frontend::listdevices(const char *gamename)
printf("Driver %s (%s):\n", drivlist.driver().name, drivlist.driver().description); printf("Driver %s (%s):\n", drivlist.driver().name, drivlist.driver().description);
// build a list of devices // build a list of devices
device_iterator iter(drivlist.config().root_device());
std::vector<device_t *> device_list; std::vector<device_t *> device_list;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(drivlist.config().root_device()))
device_list.push_back(device); device_list.push_back(&device);
// sort them by tag // sort them by tag
qsort(&device_list[0], device_list.size(), sizeof(device_list[0]), compare_devices); qsort(&device_list[0], device_list.size(), sizeof(device_list[0]), compare_devices);
@ -649,18 +645,17 @@ void cli_frontend::listslots(const char *gamename)
while (drivlist.next()) while (drivlist.next())
{ {
// iterate // iterate
slot_interface_iterator iter(drivlist.config().root_device());
bool first = true; bool first = true;
for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next()) for (const device_slot_interface &slot : slot_interface_iterator(drivlist.config().root_device()))
{ {
if (slot->fixed()) continue; if (slot.fixed()) continue;
// output the line, up to the list of extensions // output the line, up to the list of extensions
printf("%-13s%-10s ", first ? drivlist.driver().name : "", slot->device().tag()+1); printf("%-13s%-10s ", first ? drivlist.driver().name : "", slot.device().tag()+1);
bool first_option = true; bool first_option = true;
// get the options and print them // get the options and print them
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
{ {
if (option.selectable()) if (option.selectable())
{ {
@ -710,21 +705,20 @@ void cli_frontend::listmedia(const char *gamename)
while (drivlist.next()) while (drivlist.next())
{ {
// iterate // iterate
image_interface_iterator iter(drivlist.config().root_device());
bool first = true; bool first = true;
for (const device_image_interface *imagedev = iter.first(); imagedev != nullptr; imagedev = iter.next()) for (const device_image_interface &imagedev : image_interface_iterator(drivlist.config().root_device()))
{ {
if (!imagedev->user_loadable()) if (!imagedev.user_loadable())
continue; continue;
// extract the shortname with parentheses // extract the shortname with parentheses
std::string paren_shortname = string_format("(%s)", imagedev->brief_instance_name()); std::string paren_shortname = string_format("(%s)", imagedev.brief_instance_name());
// output the line, up to the list of extensions // output the line, up to the list of extensions
printf("%-13s%-12s%-8s ", first ? drivlist.driver().name : "", imagedev->instance_name(), paren_shortname.c_str()); printf("%-13s%-12s%-8s ", first ? drivlist.driver().name : "", imagedev.instance_name(), paren_shortname.c_str());
// get the extensions and print them // get the extensions and print them
std::string extensions(imagedev->file_extensions()); std::string extensions(imagedev.file_extensions());
for (int start = 0, end = extensions.find_first_of(',');; start = end + 1, end = extensions.find_first_of(',', start)) for (int start = 0, end = extensions.find_first_of(',');; start = end + 1, end = extensions.find_first_of(',', start))
{ {
std::string curext(extensions, start, (end == -1) ? extensions.length() - start : end - start); std::string curext(extensions, start, (end == -1) ? extensions.length() - start : end - start);
@ -817,11 +811,10 @@ void cli_frontend::verifyroms(const char *gamename)
while (dummy_drivlist.next()) while (dummy_drivlist.next())
{ {
machine_config &config = dummy_drivlist.config(); machine_config &config = dummy_drivlist.config();
device_iterator iter(config.root_device()); for (device_t &dev : device_iterator(config.root_device()))
for (device_t *dev = iter.first(); dev != nullptr; dev = iter.next())
{ {
if (dev->owner() != nullptr && (*(dev->shortname()) != 0) && dev->rom_region() != nullptr && (device_map.insert(dev->shortname()).second)) { if (dev.owner() != nullptr && (*(dev.shortname()) != 0) && dev.rom_region() != nullptr && (device_map.insert(dev.shortname()).second)) {
if (core_strwildcmp(gamename, dev->shortname()) == 0) if (core_strwildcmp(gamename, dev.shortname()) == 0)
{ {
matched++; matched++;
@ -836,11 +829,11 @@ void cli_frontend::verifyroms(const char *gamename)
{ {
// output the summary of the audit // output the summary of the audit
std::string summary_string; std::string summary_string;
auditor.summarize(dev->shortname(),&summary_string); auditor.summarize(dev.shortname(),&summary_string);
osd_printf_info("%s", summary_string.c_str()); osd_printf_info("%s", summary_string.c_str());
// display information about what we discovered // display information about what we discovered
osd_printf_info("romset %s ", dev->shortname()); osd_printf_info("romset %s ", dev.shortname());
// switch off of the result // switch off of the result
switch (summary) switch (summary)
@ -868,20 +861,18 @@ void cli_frontend::verifyroms(const char *gamename)
} }
} }
slot_interface_iterator slotiter(config.root_device()); for (const device_slot_interface &slot : slot_interface_iterator(config.root_device()))
for (const device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next())
{ {
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
{ {
std::string temptag("_"); std::string temptag("_");
temptag.append(option.name()); temptag.append(option.name());
device_t *dev = const_cast<machine_config &>(config).device_add(&config.root_device(), temptag.c_str(), option.devtype(), 0); device_t *dev = const_cast<machine_config &>(config).device_add(&config.root_device(), temptag.c_str(), option.devtype(), 0);
// notify this device and all its subdevices that they are now configured // notify this device and all its subdevices that they are now configured
device_iterator subiter(*dev); for (device_t &device : device_iterator(*dev))
for (device_t *device = subiter.first(); device != nullptr; device = subiter.next()) if (!device.configured())
if (!device->configured()) device.config_complete();
device->config_complete();
if (device_map.insert(dev->shortname()).second) { if (device_map.insert(dev->shortname()).second) {
if (core_strwildcmp(gamename, dev->shortname()) == 0) if (core_strwildcmp(gamename, dev->shortname()) == 0)
@ -890,7 +881,7 @@ void cli_frontend::verifyroms(const char *gamename)
if (dev->rom_region() != nullptr) if (dev->rom_region() != nullptr)
{ {
// audit the ROMs in this set // audit the ROMs in this set
media_auditor::summary summary = auditor.audit_device(dev, AUDIT_VALIDATE_FAST); media_auditor::summary summary = auditor.audit_device(*dev, AUDIT_VALIDATE_FAST);
// if not found, count that and leave it at that // if not found, count that and leave it at that
if (summary == media_auditor::NOTFOUND) if (summary == media_auditor::NOTFOUND)
@ -933,17 +924,15 @@ void cli_frontend::verifyroms(const char *gamename)
} }
} else { } else {
// check for subdevices with ROMs (a few devices are missed otherwise, e.g. MPU401) // check for subdevices with ROMs (a few devices are missed otherwise, e.g. MPU401)
device_iterator subiter(*dev); for (device_t &device : device_iterator(*dev))
for (device_t *device = subiter.first(); device != nullptr; device = subiter.next())
{ {
device_iterator subsubiter(*device); for (device_t &subdev : device_iterator(device))
for (device_t *subdev = subsubiter.first(); subdev != nullptr; subdev = subsubiter.next())
{ {
if (subdev->owner() == device && subdev->rom_region() != nullptr && subdev->shortname() != nullptr && subdev->shortname()[0] != '\0') if (subdev.owner() == &device && subdev.rom_region() != nullptr && subdev.shortname() != nullptr && subdev.shortname()[0] != '\0')
{ {
if (device_map.insert(subdev->shortname()).second) if (device_map.insert(subdev.shortname()).second)
{ {
if (core_strwildcmp(gamename, subdev->shortname()) == 0) if (core_strwildcmp(gamename, subdev.shortname()) == 0)
{ {
matched++; matched++;
@ -959,11 +948,11 @@ void cli_frontend::verifyroms(const char *gamename)
{ {
// output the summary of the audit // output the summary of the audit
std::string summary_string; std::string summary_string;
auditor.summarize(subdev->shortname(),&summary_string); auditor.summarize(subdev.shortname(),&summary_string);
osd_printf_info("%s", summary_string.c_str()); osd_printf_info("%s", summary_string.c_str());
// display information about what we discovered // display information about what we discovered
osd_printf_info("romset %s ", subdev->shortname()); osd_printf_info("romset %s ", subdev.shortname());
// switch off of the result // switch off of the result
switch (summary) switch (summary)
@ -1311,13 +1300,12 @@ void cli_frontend::listsoftware(const char *gamename)
while (drivlist.next()) while (drivlist.next())
{ {
software_list_device_iterator iter(drivlist.config().root_device()); for (software_list_device &swlistdev : software_list_device_iterator(drivlist.config().root_device()))
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (list_map.insert(swlistdev.list_name()).second)
if (list_map.insert(swlistdev->list_name()).second) if (!swlistdev.get_info().empty())
if (!swlistdev->get_info().empty())
{ {
if (isfirst) { fprintf(out, SOFTLIST_XML_BEGIN); isfirst = false; } if (isfirst) { fprintf(out, SOFTLIST_XML_BEGIN); isfirst = false; }
output_single_softlist(out, *swlistdev); output_single_softlist(out, swlistdev);
} }
} }
@ -1354,16 +1342,15 @@ void cli_frontend::verifysoftware(const char *gamename)
{ {
matched++; matched++;
software_list_device_iterator iter(drivlist.config().root_device()); for (software_list_device &swlistdev : software_list_device_iterator(drivlist.config().root_device()))
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (swlistdev.list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) if (list_map.insert(swlistdev.list_name()).second)
if (list_map.insert(swlistdev->list_name()).second) if (!swlistdev.get_info().empty())
if (!swlistdev->get_info().empty())
{ {
nrlists++; nrlists++;
for (software_info &swinfo : swlistdev->get_info()) for (software_info &swinfo : swlistdev.get_info())
{ {
media_auditor::summary summary = auditor.audit_software(swlistdev->list_name(), &swinfo, AUDIT_VALIDATE_FAST); media_auditor::summary summary = auditor.audit_software(swlistdev.list_name(), &swinfo, AUDIT_VALIDATE_FAST);
// if not found, count that and leave it at that // if not found, count that and leave it at that
if (summary == media_auditor::NOTFOUND) if (summary == media_auditor::NOTFOUND)
@ -1379,7 +1366,7 @@ void cli_frontend::verifysoftware(const char *gamename)
osd_printf_info("%s", summary_string.c_str()); osd_printf_info("%s", summary_string.c_str());
// display information about what we discovered // display information about what we discovered
osd_printf_info("romset %s:%s ", swlistdev->list_name(), swinfo.shortname()); osd_printf_info("romset %s:%s ", swlistdev.list_name(), swinfo.shortname());
// switch off of the result // switch off of the result
switch (summary) switch (summary)
@ -1442,13 +1429,12 @@ void cli_frontend::getsoftlist(const char *gamename)
driver_enumerator drivlist(m_options); driver_enumerator drivlist(m_options);
while (drivlist.next()) while (drivlist.next())
{ {
software_list_device_iterator iter(drivlist.config().root_device()); for (software_list_device &swlistdev : software_list_device_iterator(drivlist.config().root_device()))
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (core_strwildcmp(gamename, swlistdev.list_name()) == 0 && list_map.insert(swlistdev.list_name()).second)
if (core_strwildcmp(gamename, swlistdev->list_name()) == 0 && list_map.insert(swlistdev->list_name()).second) if (!swlistdev.get_info().empty())
if (!swlistdev->get_info().empty())
{ {
if (isfirst) { fprintf( out, SOFTLIST_XML_BEGIN); isfirst = FALSE; } if (isfirst) { fprintf( out, SOFTLIST_XML_BEGIN); isfirst = FALSE; }
output_single_softlist(out, *swlistdev); output_single_softlist(out, swlistdev);
} }
} }
@ -1475,17 +1461,16 @@ void cli_frontend::verifysoftlist(const char *gamename)
while (drivlist.next()) while (drivlist.next())
{ {
software_list_device_iterator iter(drivlist.config().root_device()); for (software_list_device &swlistdev : software_list_device_iterator(drivlist.config().root_device()))
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (core_strwildcmp(gamename, swlistdev.list_name()) == 0 && list_map.insert(swlistdev.list_name()).second)
if (core_strwildcmp(gamename, swlistdev->list_name()) == 0 && list_map.insert(swlistdev->list_name()).second) if (!swlistdev.get_info().empty())
if (!swlistdev->get_info().empty())
{ {
matched++; matched++;
// Get the actual software list contents // Get the actual software list contents
for (software_info &swinfo : swlistdev->get_info()) for (software_info &swinfo : swlistdev.get_info())
{ {
media_auditor::summary summary = auditor.audit_software(swlistdev->list_name(), &swinfo, AUDIT_VALIDATE_FAST); media_auditor::summary summary = auditor.audit_software(swlistdev.list_name(), &swinfo, AUDIT_VALIDATE_FAST);
// if not found, count that and leave it at that // if not found, count that and leave it at that
if (summary == media_auditor::NOTFOUND) if (summary == media_auditor::NOTFOUND)
@ -1501,7 +1486,7 @@ void cli_frontend::verifysoftlist(const char *gamename)
osd_printf_info("%s", summary_string.c_str()); osd_printf_info("%s", summary_string.c_str());
// display information about what we discovered // display information about what we discovered
osd_printf_info("romset %s:%s ", swlistdev->list_name(), swinfo.shortname()); osd_printf_info("romset %s:%s ", swlistdev.list_name(), swinfo.shortname());
// switch off of the result // switch off of the result
switch (summary) switch (summary)
@ -1937,13 +1922,12 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
m_drivlist.reset(); m_drivlist.reset();
while (m_drivlist.next()) while (m_drivlist.next())
{ {
// iterate over devices, regions and files within the region */ // iterate over devices, regions and files within the region
device_iterator deviter(m_drivlist.config().root_device()); for (device_t &device : device_iterator(m_drivlist.config().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
{ {
if (shortnames.insert(device->shortname()).second) if (shortnames.insert(device.shortname()).second)
{ {
for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom))
{ {
hash_collection romhashes(ROM_GETHASHDATA(rom)); hash_collection romhashes(ROM_GETHASHDATA(rom));
@ -1962,12 +1946,11 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
} }
// next iterate over softlists // next iterate over softlists
software_list_device_iterator iter(m_drivlist.config().root_device()); for (software_list_device &swlistdev : software_list_device_iterator(m_drivlist.config().root_device()))
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next())
{ {
if (listnames.insert(swlistdev->list_name()).second) if (listnames.insert(swlistdev.list_name()).second)
{ {
for (software_info &swinfo : swlistdev->get_info()) for (software_info &swinfo : swlistdev.get_info())
for (software_part &part : swinfo.parts()) for (software_part &part : swinfo.parts())
for (const rom_entry *region = part.romdata(); region != nullptr; region = rom_next_region(region)) for (const rom_entry *region = part.romdata(); region != nullptr; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom))
@ -1980,7 +1963,7 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
// output information about the match // output information about the match
if (found) if (found)
osd_printf_info(" "); osd_printf_info(" ");
osd_printf_info("= %s%-20s %s:%s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), swlistdev->list_name(), swinfo.shortname(), swinfo.longname()); osd_printf_info("= %s%-20s %s:%s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), swlistdev.list_name(), swinfo.shortname(), swinfo.longname());
found++; found++;
} }
} }

View File

@ -569,19 +569,15 @@ int debug_command_parameter_cpu(running_machine &machine, const char *param, dev
} }
/* if we got a valid one, return */ /* if we got a valid one, return */
const UINT64 original_cpunum = cpunum; device_execute_interface *exec = execute_interface_iterator(machine.root_device()).byindex(cpunum);
execute_interface_iterator iter(machine.root_device()); if (exec != nullptr)
for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next())
{ {
if (cpunum-- == 0) *result = &exec->device();
{ return TRUE;
*result = &exec->device();
return TRUE;
}
} }
/* if out of range, complain */ /* if out of range, complain */
debug_console_printf(machine, "Invalid CPU index %d\n", (UINT32)original_cpunum); debug_console_printf(machine, "Invalid CPU index %d\n", (int)cpunum);
return FALSE; return FALSE;
} }
@ -1009,10 +1005,9 @@ static void execute_focus(running_machine &machine, int ref, int params, const c
cpu->debug()->ignore(false); cpu->debug()->ignore(false);
/* then loop over CPUs and set the ignore flags on all other CPUs */ /* then loop over CPUs and set the ignore flags on all other CPUs */
execute_interface_iterator iter(machine.root_device()); for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) if (&exec.device() != cpu)
if (&exec->device() != cpu) exec.device().debug()->ignore(true);
exec->device().debug()->ignore(true);
debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag()); debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag());
} }
@ -1029,16 +1024,15 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
std::string buffer; std::string buffer;
/* loop over all executable devices */ /* loop over all executable devices */
execute_interface_iterator iter(machine.root_device()); for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next())
/* build up a comma-separated list */ /* build up a comma-separated list */
if (!exec->device().debug()->observing()) if (!exec.device().debug()->observing())
{ {
if (buffer.empty()) if (buffer.empty())
buffer = string_format("Currently ignoring device '%s'", exec->device().tag()); buffer = string_format("Currently ignoring device '%s'", exec.device().tag());
else else
buffer.append(string_format(", '%s'", exec->device().tag())); buffer.append(string_format(", '%s'", exec.device().tag()));
} }
/* special message for none */ /* special message for none */
@ -1061,10 +1055,9 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
for (int paramnum = 0; paramnum < params; paramnum++) for (int paramnum = 0; paramnum < params; paramnum++)
{ {
/* make sure this isn't the last live CPU */ /* make sure this isn't the last live CPU */
execute_interface_iterator iter(machine.root_device());
bool gotone = false; bool gotone = false;
for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
if (&exec->device() != devicelist[paramnum] && exec->device().debug()->observing()) if (&exec.device() != devicelist[paramnum] && exec.device().debug()->observing())
{ {
gotone = true; gotone = true;
break; break;
@ -1094,16 +1087,15 @@ static void execute_observe(running_machine &machine, int ref, int params, const
std::string buffer; std::string buffer;
/* loop over all executable devices */ /* loop over all executable devices */
execute_interface_iterator iter(machine.root_device()); for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next())
/* build up a comma-separated list */ /* build up a comma-separated list */
if (exec->device().debug()->observing()) if (exec.device().debug()->observing())
{ {
if (buffer.empty()) if (buffer.empty())
buffer = string_format("Currently observing CPU '%s'", exec->device().tag()); buffer = string_format("Currently observing CPU '%s'", exec.device().tag());
else else
buffer.append(string_format(", '%s'", exec->device().tag())); buffer.append(string_format(", '%s'", exec.device().tag()));
} }
/* special message for none */ /* special message for none */
@ -1246,9 +1238,8 @@ static void execute_bpclear(running_machine &machine, int ref, int params, const
/* if 0 parameters, clear all */ /* if 0 parameters, clear all */
if (params == 0) if (params == 0)
{ {
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.debug()->breakpoint_clear_all();
device->debug()->breakpoint_clear_all();
debug_console_printf(machine, "Cleared all breakpoints\n"); debug_console_printf(machine, "Cleared all breakpoints\n");
} }
@ -1257,10 +1248,9 @@ static void execute_bpclear(running_machine &machine, int ref, int params, const
return; return;
else else
{ {
device_iterator iter(machine.root_device());
bool found = false; bool found = false;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(machine.root_device()))
if (device->debug()->breakpoint_clear(bpindex)) if (device.debug()->breakpoint_clear(bpindex))
found = true; found = true;
if (found) if (found)
debug_console_printf(machine, "Breakpoint %X cleared\n", (UINT32)bpindex); debug_console_printf(machine, "Breakpoint %X cleared\n", (UINT32)bpindex);
@ -1282,9 +1272,8 @@ static void execute_bpdisenable(running_machine &machine, int ref, int params, c
/* if 0 parameters, clear all */ /* if 0 parameters, clear all */
if (params == 0) if (params == 0)
{ {
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.debug()->breakpoint_enable_all(ref);
device->debug()->breakpoint_enable_all(ref);
if (ref == 0) if (ref == 0)
debug_console_printf(machine, "Disabled all breakpoints\n"); debug_console_printf(machine, "Disabled all breakpoints\n");
else else
@ -1296,10 +1285,9 @@ static void execute_bpdisenable(running_machine &machine, int ref, int params, c
return; return;
else else
{ {
device_iterator iter(machine.root_device());
bool found = false; bool found = false;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(machine.root_device()))
if (device->debug()->breakpoint_enable(bpindex, ref)) if (device.debug()->breakpoint_enable(bpindex, ref))
found = true; found = true;
if (found) if (found)
debug_console_printf(machine, "Breakpoint %X %s\n", (UINT32)bpindex, ref ? "enabled" : "disabled"); debug_console_printf(machine, "Breakpoint %X %s\n", (UINT32)bpindex, ref ? "enabled" : "disabled");
@ -1320,16 +1308,15 @@ static void execute_bplist(running_machine &machine, int ref, int params, const
std::string buffer; std::string buffer;
/* loop over all CPUs */ /* loop over all CPUs */
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device.debug()->breakpoint_first() != nullptr)
if (device->debug()->breakpoint_first() != nullptr)
{ {
debug_console_printf(machine, "Device '%s' breakpoints:\n", device->tag()); debug_console_printf(machine, "Device '%s' breakpoints:\n", device.tag());
/* loop over the breakpoints */ /* loop over the breakpoints */
for (device_debug::breakpoint *bp = device->debug()->breakpoint_first(); bp != nullptr; bp = bp->next()) for (device_debug::breakpoint *bp = device.debug()->breakpoint_first(); bp != nullptr; bp = bp->next())
{ {
buffer = string_format("%c%4X @ %0*X", bp->enabled() ? ' ' : 'D', bp->index(), device->debug()->logaddrchars(), bp->address()); buffer = string_format("%c%4X @ %0*X", bp->enabled() ? ' ' : 'D', bp->index(), device.debug()->logaddrchars(), bp->address());
if (std::string(bp->condition()).compare("1") != 0) if (std::string(bp->condition()).compare("1") != 0)
buffer.append(string_format(" if %s", bp->condition())); buffer.append(string_format(" if %s", bp->condition()));
if (std::string(bp->action()).compare("") != 0) if (std::string(bp->action()).compare("") != 0)
@ -1409,9 +1396,8 @@ static void execute_wpclear(running_machine &machine, int ref, int params, const
/* if 0 parameters, clear all */ /* if 0 parameters, clear all */
if (params == 0) if (params == 0)
{ {
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.debug()->watchpoint_clear_all();
device->debug()->watchpoint_clear_all();
debug_console_printf(machine, "Cleared all watchpoints\n"); debug_console_printf(machine, "Cleared all watchpoints\n");
} }
@ -1420,10 +1406,9 @@ static void execute_wpclear(running_machine &machine, int ref, int params, const
return; return;
else else
{ {
device_iterator iter(machine.root_device());
bool found = false; bool found = false;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(machine.root_device()))
if (device->debug()->watchpoint_clear(wpindex)) if (device.debug()->watchpoint_clear(wpindex))
found = true; found = true;
if (found) if (found)
debug_console_printf(machine, "Watchpoint %X cleared\n", (UINT32)wpindex); debug_console_printf(machine, "Watchpoint %X cleared\n", (UINT32)wpindex);
@ -1445,9 +1430,8 @@ static void execute_wpdisenable(running_machine &machine, int ref, int params, c
/* if 0 parameters, clear all */ /* if 0 parameters, clear all */
if (params == 0) if (params == 0)
{ {
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.debug()->watchpoint_enable_all(ref);
device->debug()->watchpoint_enable_all(ref);
if (ref == 0) if (ref == 0)
debug_console_printf(machine, "Disabled all watchpoints\n"); debug_console_printf(machine, "Disabled all watchpoints\n");
else else
@ -1459,10 +1443,9 @@ static void execute_wpdisenable(running_machine &machine, int ref, int params, c
return; return;
else else
{ {
device_iterator iter(machine.root_device());
bool found = false; bool found = false;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(machine.root_device()))
if (device->debug()->watchpoint_enable(wpindex, ref)) if (device.debug()->watchpoint_enable(wpindex, ref))
found = true; found = true;
if (found) if (found)
debug_console_printf(machine, "Watchpoint %X %s\n", (UINT32)wpindex, ref ? "enabled" : "disabled"); debug_console_printf(machine, "Watchpoint %X %s\n", (UINT32)wpindex, ref ? "enabled" : "disabled");
@ -1483,18 +1466,17 @@ static void execute_wplist(running_machine &machine, int ref, int params, const
std::string buffer; std::string buffer;
/* loop over all CPUs */ /* loop over all CPUs */
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next())
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
if (device->debug()->watchpoint_first(spacenum) != nullptr) if (device.debug()->watchpoint_first(spacenum) != nullptr)
{ {
static const char *const types[] = { "unkn ", "read ", "write", "r/w " }; static const char *const types[] = { "unkn ", "read ", "write", "r/w " };
debug_console_printf(machine, "Device '%s' %s space watchpoints:\n", device->tag(), debug_console_printf(machine, "Device '%s' %s space watchpoints:\n", device.tag(),
device->debug()->watchpoint_first(spacenum)->space().name()); device.debug()->watchpoint_first(spacenum)->space().name());
/* loop over the watchpoints */ /* loop over the watchpoints */
for (device_debug::watchpoint *wp = device->debug()->watchpoint_first(spacenum); wp != nullptr; wp = wp->next()) for (device_debug::watchpoint *wp = device.debug()->watchpoint_first(spacenum); wp != nullptr; wp = wp->next())
{ {
buffer = string_format("%c%4X @ %0*X-%0*X %s", wp->enabled() ? ' ' : 'D', wp->index(), buffer = string_format("%c%4X @ %0*X-%0*X %s", wp->enabled() ? ' ' : 'D', wp->index(),
wp->space().addrchars(), wp->space().byte_to_address(wp->address()), wp->space().addrchars(), wp->space().byte_to_address(wp->address()),
@ -1556,9 +1538,8 @@ static void execute_rpclear(running_machine &machine, int ref, int params, const
/* if 0 parameters, clear all */ /* if 0 parameters, clear all */
if (params == 0) if (params == 0)
{ {
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.debug()->registerpoint_clear_all();
device->debug()->registerpoint_clear_all();
debug_console_printf(machine, "Cleared all registerpoints\n"); debug_console_printf(machine, "Cleared all registerpoints\n");
} }
@ -1567,10 +1548,9 @@ static void execute_rpclear(running_machine &machine, int ref, int params, const
return; return;
else else
{ {
device_iterator iter(machine.root_device());
bool found = false; bool found = false;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(machine.root_device()))
if (device->debug()->registerpoint_clear(rpindex)) if (device.debug()->registerpoint_clear(rpindex))
found = true; found = true;
if (found) if (found)
debug_console_printf(machine, "Registerpoint %X cleared\n", (UINT32)rpindex); debug_console_printf(machine, "Registerpoint %X cleared\n", (UINT32)rpindex);
@ -1592,9 +1572,8 @@ static void execute_rpdisenable(running_machine &machine, int ref, int params, c
/* if 0 parameters, clear all */ /* if 0 parameters, clear all */
if (params == 0) if (params == 0)
{ {
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.debug()->registerpoint_enable_all(ref);
device->debug()->registerpoint_enable_all(ref);
if (ref == 0) if (ref == 0)
debug_console_printf(machine, "Disabled all registerpoints\n"); debug_console_printf(machine, "Disabled all registerpoints\n");
else else
@ -1606,10 +1585,9 @@ static void execute_rpdisenable(running_machine &machine, int ref, int params, c
return; return;
else else
{ {
device_iterator iter(machine.root_device());
bool found = false; bool found = false;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(machine.root_device()))
if (device->debug()->registerpoint_enable(rpindex, ref)) if (device.debug()->registerpoint_enable(rpindex, ref))
found = true; found = true;
if (found) if (found)
debug_console_printf(machine, "Registerpoint %X %s\n", (UINT32)rpindex, ref ? "enabled" : "disabled"); debug_console_printf(machine, "Registerpoint %X %s\n", (UINT32)rpindex, ref ? "enabled" : "disabled");
@ -1630,14 +1608,13 @@ static void execute_rplist(running_machine &machine, int ref, int params, const
std::string buffer; std::string buffer;
/* loop over all CPUs */ /* loop over all CPUs */
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device.debug()->registerpoint_first() != nullptr)
if (device->debug()->registerpoint_first() != nullptr)
{ {
debug_console_printf(machine, "Device '%s' registerpoints:\n", device->tag()); debug_console_printf(machine, "Device '%s' registerpoints:\n", device.tag());
/* loop over the breakpoints */ /* loop over the breakpoints */
for (device_debug::registerpoint *rp = device->debug()->registerpoint_first(); rp != nullptr; rp = rp->next()) for (device_debug::registerpoint *rp = device.debug()->registerpoint_first(); rp != nullptr; rp = rp->next())
{ {
buffer = string_format("%c%4X if %s", rp->enabled() ? ' ' : 'D', rp->index(), rp->condition()); buffer = string_format("%c%4X if %s", rp->enabled() ? ' ' : 'D', rp->index(), rp->condition());
if (rp->action() != nullptr) if (rp->action() != nullptr)
@ -1665,12 +1642,11 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const
bool cleared = false; bool cleared = false;
/* loop over CPUs and find live spots */ /* loop over CPUs and find live spots */
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device.debug()->hotspot_tracking_enabled())
if (device->debug()->hotspot_tracking_enabled())
{ {
device->debug()->hotspot_track(0, 0); device.debug()->hotspot_track(0, 0);
debug_console_printf(machine, "Cleared hotspot tracking on CPU '%s'\n", device->tag()); debug_console_printf(machine, "Cleared hotspot tracking on CPU '%s'\n", device.tag());
cleared = true; cleared = true;
} }
@ -1718,11 +1694,10 @@ static void execute_stateload(running_machine &machine, int ref, int params, con
machine.immediate_load(filename.c_str()); machine.immediate_load(filename.c_str());
// Clear all PC & memory tracks // Clear all PC & memory tracks
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next())
{ {
device->debug()->track_pc_data_clear(); device.debug()->track_pc_data_clear();
device->debug()->track_mem_data_clear(); device.debug()->track_mem_data_clear();
} }
debug_console_printf(machine, "State load attempted. Please refer to window message popup for results.\n"); debug_console_printf(machine, "State load attempted. Please refer to window message popup for results.\n");
} }
@ -3036,13 +3011,10 @@ static void execute_hardreset(running_machine &machine, int ref, int params, con
static void execute_images(running_machine &machine, int ref, int params, const char **param) static void execute_images(running_machine &machine, int ref, int params, const char **param)
{ {
image_interface_iterator iter(machine.root_device()); image_interface_iterator iter(machine.root_device());
for (device_image_interface *img = iter.first(); img != nullptr; img = iter.next()) for (device_image_interface &img : iter)
{ debug_console_printf(machine, "%s: %s\n", img.brief_instance_name(), img.exists() ? img.filename() : "[empty slot]");
debug_console_printf(machine, "%s: %s\n",img->brief_instance_name(),img->exists() ? img->filename() : "[empty slot]"); if (iter.first() == nullptr)
}
if (iter.first() == nullptr) {
debug_console_printf(machine, "No image devices in this driver\n"); debug_console_printf(machine, "No image devices in this driver\n");
}
} }
/*------------------------------------------------- /*-------------------------------------------------
@ -3051,16 +3023,15 @@ static void execute_images(running_machine &machine, int ref, int params, const
static void execute_mount(running_machine &machine, int ref, int params, const char **param) static void execute_mount(running_machine &machine, int ref, int params, const char **param)
{ {
image_interface_iterator iter(machine.root_device());
bool done = false; bool done = false;
for (device_image_interface *img = iter.first(); img != nullptr; img = iter.next()) for (device_image_interface &img : image_interface_iterator(machine.root_device()))
{ {
if (strcmp(img->brief_instance_name(),param[0])==0) { if (strcmp(img.brief_instance_name(),param[0]) == 0)
if (img->load(param[1])==IMAGE_INIT_FAIL) { {
if (img.load(param[1])==IMAGE_INIT_FAIL)
debug_console_printf(machine, "Unable to mount file %s on %s\n",param[1],param[0]); debug_console_printf(machine, "Unable to mount file %s on %s\n",param[1],param[0]);
} else { else
debug_console_printf(machine, "File %s mounted on %s\n",param[1],param[0]); debug_console_printf(machine, "File %s mounted on %s\n",param[1],param[0]);
}
done = true; done = true;
break; break;
} }
@ -3075,12 +3046,12 @@ static void execute_mount(running_machine &machine, int ref, int params, const c
static void execute_unmount(running_machine &machine, int ref, int params, const char **param) static void execute_unmount(running_machine &machine, int ref, int params, const char **param)
{ {
image_interface_iterator iter(machine.root_device());
bool done = false; bool done = false;
for (device_image_interface *img = iter.first(); img != nullptr; img = iter.next()) for (device_image_interface &img : image_interface_iterator(machine.root_device()))
{ {
if (strcmp(img->brief_instance_name(),param[0])==0) { if (strcmp(img.brief_instance_name(),param[0]) == 0)
img->unload(); {
img.unload();
debug_console_printf(machine, "Unmounted file from : %s\n",param[0]); debug_console_printf(machine, "Unmounted file from : %s\n",param[0]);
done = true; done = true;
break; break;

View File

@ -172,10 +172,9 @@ void debug_cpu_flush_traces(running_machine &machine)
{ {
/* this can be called on exit even when no debugging is enabled, so /* this can be called on exit even when no debugging is enabled, so
make sure the devdebug is valid before proceeding */ make sure the devdebug is valid before proceeding */
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device.debug() != nullptr)
if (device->debug() != nullptr) device.debug()->trace_flush();
device->debug()->trace_flush();
} }
@ -311,19 +310,18 @@ bool debug_comment_save(running_machine &machine)
xml_set_attribute(systemnode, "name", machine.system().name); xml_set_attribute(systemnode, "name", machine.system().name);
// for each device // for each device
device_iterator iter(machine.root_device());
bool found_comments = false; bool found_comments = false;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : device_iterator(machine.root_device()))
if (device->debug() && device->debug()->comment_count() > 0) if (device.debug() && device.debug()->comment_count() > 0)
{ {
// create a node for this device // create a node for this device
xml_data_node *curnode = xml_add_child(systemnode, "cpu", nullptr); xml_data_node *curnode = xml_add_child(systemnode, "cpu", nullptr);
if (curnode == nullptr) if (curnode == nullptr)
throw emu_exception(); throw emu_exception();
xml_set_attribute(curnode, "tag", device->tag()); xml_set_attribute(curnode, "tag", device.tag());
// export the comments // export the comments
if (!device->debug()->comment_export(*curnode)) if (!device.debug()->comment_export(*curnode))
throw emu_exception(); throw emu_exception();
found_comments = true; found_comments = true;
} }
@ -1049,9 +1047,8 @@ static void on_vblank(running_machine &machine, screen_device &device, bool vbla
static void reset_transient_flags(running_machine &machine) static void reset_transient_flags(running_machine &machine)
{ {
/* loop over CPUs and reset the transient flags */ /* loop over CPUs and reset the transient flags */
device_iterator iter(machine.root_device()); for (device_t &device : device_iterator(machine.root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.debug()->reset_transient_flag();
device->debug()->reset_transient_flag();
machine.debugcpu_data->m_stop_when_not_device = nullptr; machine.debugcpu_data->m_stop_when_not_device = nullptr;
} }

View File

@ -132,12 +132,11 @@ void debug_view_breakpoints::enumerate_sources()
m_source_list.reset(); m_source_list.reset();
// iterate over devices with disassembly interfaces // iterate over devices with disassembly interfaces
disasm_interface_iterator iter(machine().root_device()); for (device_disasm_interface &dasm : disasm_interface_iterator(machine().root_device()))
for (device_disasm_interface *dasm = iter.first(); dasm != nullptr; dasm = iter.next())
{ {
std::string name; std::string name;
name = string_format("%s '%s'", dasm->device().name(), dasm->device().tag()); name = string_format("%s '%s'", dasm.device().name(), dasm.device().tag());
m_source_list.append(*global_alloc(debug_view_source(name.c_str(), &dasm->device()))); m_source_list.append(*global_alloc(debug_view_source(name.c_str(), &dasm.device())));
} }
// reset the source to a known good entry // reset the source to a known good entry

View File

@ -98,13 +98,12 @@ void debug_view_disasm::enumerate_sources()
m_source_list.reset(); m_source_list.reset();
// iterate over devices with disassembly interfaces // iterate over devices with disassembly interfaces
disasm_interface_iterator iter(machine().root_device());
std::string name; std::string name;
for (device_disasm_interface *dasm = iter.first(); dasm != nullptr; dasm = iter.next()) for (device_disasm_interface &dasm : disasm_interface_iterator(machine().root_device()))
{ {
name = string_format("%s '%s'", dasm->device().name(), dasm->device().tag()); name = string_format("%s '%s'", dasm.device().name(), dasm.device().tag());
if (dasm->device().memory().space_config(AS_PROGRAM)!=nullptr) if (dasm.device().memory().space_config(AS_PROGRAM)!=nullptr)
m_source_list.append(*global_alloc(debug_view_disasm_source(name.c_str(), dasm->device()))); m_source_list.append(*global_alloc(debug_view_disasm_source(name.c_str(), dasm.device())));
} }
// reset the source to a known good entry // reset the source to a known good entry

View File

@ -135,14 +135,13 @@ void debug_view_memory::enumerate_sources()
std::string name; std::string name;
// first add all the devices' address spaces // first add all the devices' address spaces
memory_interface_iterator iter(machine().root_device()); for (device_memory_interface &memintf : memory_interface_iterator(machine().root_device()))
for (device_memory_interface *memintf = iter.first(); memintf != nullptr; memintf = iter.next()) if (&memintf.device() != &machine().root_device())
if (&memintf->device() != &machine().root_device())
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
if (memintf->has_space(spacenum)) if (memintf.has_space(spacenum))
{ {
address_space &space = memintf->space(spacenum); address_space &space = memintf.space(spacenum);
name = string_format("%s '%s' %s space memory", memintf->device().name(), memintf->device().tag(), space.name()); name = string_format("%s '%s' %s space memory", memintf.device().name(), memintf.device().tag(), space.name());
m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), space))); m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), space)));
} }

View File

@ -74,12 +74,11 @@ void debug_view_state::enumerate_sources()
m_source_list.reset(); m_source_list.reset();
// iterate over devices that have state interfaces // iterate over devices that have state interfaces
state_interface_iterator iter(machine().root_device());
std::string name; std::string name;
for (device_state_interface *state = iter.first(); state != nullptr; state = iter.next()) for (device_state_interface &state : state_interface_iterator(machine().root_device()))
{ {
name = string_format("%s '%s'", state->device().name(), state->device().tag()); name = string_format("%s '%s'", state.device().name(), state.device().tag());
m_source_list.append(*global_alloc(debug_view_state_source(name.c_str(), state->device()))); m_source_list.append(*global_alloc(debug_view_state_source(name.c_str(), state.device())));
} }
// reset the source to a known good entry // reset the source to a known good entry

View File

@ -153,12 +153,11 @@ void debug_view_watchpoints::enumerate_sources()
m_source_list.reset(); m_source_list.reset();
// iterate over devices with disassembly interfaces // iterate over devices with disassembly interfaces
disasm_interface_iterator iter(machine().root_device()); for (device_disasm_interface &dasm : disasm_interface_iterator(machine().root_device()))
for (device_disasm_interface *dasm = iter.first(); dasm != nullptr; dasm = iter.next())
{ {
std::string name; std::string name;
name = string_format("%s '%s'", dasm->device().name(), dasm->device().tag()); name = string_format("%s '%s'", dasm.device().name(), dasm.device().tag());
m_source_list.append(*global_alloc(debug_view_source(name.c_str(), &dasm->device()))); m_source_list.append(*global_alloc(debug_view_source(name.c_str(), &dasm.device())));
} }
// reset the source to a known good entry // reset the source to a known good entry

View File

@ -86,16 +86,19 @@ bool finder_base::validate_memregion(size_t bytes, bool required) const
std::string region_fulltag = m_base.subtag(m_tag); std::string region_fulltag = m_base.subtag(m_tag);
// look for the region // look for the region
device_iterator deviter(m_base.mconfig().root_device()); for (device_t &dev : device_iterator(m_base.mconfig().root_device()))
for (device_t *dev = deviter.first(); dev != nullptr && bytes_found == 0; dev = deviter.next()) {
for (const rom_entry *romp = rom_first_region(*dev); romp != nullptr; romp = rom_next_region(romp)) for (const rom_entry *romp = rom_first_region(dev); romp != nullptr; romp = rom_next_region(romp))
{ {
if (rom_region_name(*dev, romp) == region_fulltag) if (rom_region_name(dev, romp) == region_fulltag)
{ {
bytes_found = ROMREGION_GETLENGTH(romp); bytes_found = ROMREGION_GETLENGTH(romp);
break; break;
} }
} }
if (bytes_found != 0)
break;
}
if (bytes_found != 0) if (bytes_found != 0)
{ {

View File

@ -117,6 +117,8 @@ public:
// getters // getters
device_t *first() const { return m_list.first(); } device_t *first() const { return m_list.first(); }
int count() const { return m_list.count(); }
bool empty() const { return m_list.empty(); }
// range iterators // range iterators
using auto_iterator = simple_list<device_t>::auto_iterator; using auto_iterator = simple_list<device_t>::auto_iterator;
@ -418,92 +420,116 @@ protected:
class device_iterator class device_iterator
{ {
public: public:
class auto_iterator
{
public:
// construction
auto_iterator(device_t *devptr, int curdepth, int maxdepth)
: m_curdevice(devptr),
m_curdepth(curdepth),
m_maxdepth(maxdepth) { }
// getters
device_t *current() const { return m_curdevice; }
int depth() const { return m_curdepth; }
// required operator overrides
bool operator!=(const auto_iterator &iter) const { return m_curdevice != iter.m_curdevice; }
device_t &operator*() const { assert(m_curdevice != nullptr); return *m_curdevice; }
const auto_iterator &operator++() { advance(); return *this; }
protected:
// search depth-first for the next device
void advance()
{
// remember our starting position, and end immediately if we're NULL
device_t *start = m_curdevice;
if (start == nullptr)
return;
// search down first
if (m_curdepth < m_maxdepth)
{
m_curdevice = start->subdevices().first();
if (m_curdevice != nullptr)
{
m_curdepth++;
return;
}
}
// search next for neighbors up the ownership chain
while (m_curdepth > 0 && start != nullptr)
{
// found a neighbor? great!
m_curdevice = start->next();
if (m_curdevice != nullptr)
return;
// no? try our parent
start = start->owner();
m_curdepth--;
}
// returned to the top; we're done
m_curdevice = nullptr;
}
// protected state
device_t * m_curdevice;
int m_curdepth;
const int m_maxdepth;
};
// construction // construction
device_iterator(device_t &root, int maxdepth = 255) device_iterator(device_t &root, int maxdepth = 255)
: m_root(&root), : m_root(root), m_maxdepth(maxdepth) { }
m_current(nullptr),
m_curdepth(0),
m_maxdepth(maxdepth) { }
// getters // standard iterators
device_t *current() const { return m_current; } auto_iterator begin() const { return auto_iterator(&m_root, 0, m_maxdepth); }
auto_iterator end() const { return auto_iterator(nullptr, 0, m_maxdepth); }
// reset and return first item // return first item
device_t *first() device_t *first() const { return begin().current(); }
{
m_current = m_root;
return m_current;
}
// advance depth-first
device_t *next()
{
// remember our starting position, and end immediately if we're NULL
device_t *start = m_current;
if (start == nullptr)
return nullptr;
// search down first
if (m_curdepth < m_maxdepth)
{
m_current = start->subdevices().first();
if (m_current != nullptr)
{
m_curdepth++;
return m_current;
}
}
// search next for neighbors up the ownership chain
while (m_curdepth > 0 && start != nullptr)
{
// found a neighbor? great!
m_current = start->next();
if (m_current != nullptr)
return m_current;
// no? try our parent
start = start->owner();
m_curdepth--;
}
// returned to the top; we're done
return m_current = nullptr;
}
// return the number of items available // return the number of items available
int count() int count() const
{ {
int result = 0; int result = 0;
for (device_t *item = first(); item != nullptr; item = next()) for (device_t &item : *this)
{
(void)&item;
result++; result++;
}
return result; return result;
} }
// return the index of a given item in the virtual list // return the index of a given item in the virtual list
int indexof(device_t &device) int indexof(device_t &device) const
{ {
int index = 0; int index = 0;
for (device_t *item = first(); item != nullptr; item = next(), index++) for (device_t &item : *this)
if (item == &device) {
if (&item == &device)
return index; return index;
else
index++;
}
return -1; return -1;
} }
// return the indexed item in the list // return the indexed item in the list
device_t *byindex(int index) device_t *byindex(int index) const
{ {
for (device_t *item = first(); item != nullptr; item = next(), index--) for (device_t &item : *this)
if (index == 0) if (index-- == 0)
return item; return &item;
return nullptr; return nullptr;
} }
private: private:
// internal state // internal state
device_t * m_root; device_t & m_root;
device_t * m_current;
int m_curdepth;
int m_maxdepth; int m_maxdepth;
}; };
@ -514,132 +540,181 @@ private:
template<device_type _DeviceType, class _DeviceClass = device_t> template<device_type _DeviceType, class _DeviceClass = device_t>
class device_type_iterator class device_type_iterator
{ {
public:
class auto_iterator : public device_iterator::auto_iterator
{
public:
// construction
auto_iterator(device_t *devptr, int curdepth, int maxdepth)
: device_iterator::auto_iterator(devptr, curdepth, maxdepth)
{
// make sure the first device is of the specified type
while (m_curdevice != nullptr && m_curdevice->type() != _DeviceType)
advance();
}
// getters returning specified device type
_DeviceClass *current() const { return downcast<_DeviceClass *>(m_curdevice); }
_DeviceClass &operator*() const { assert(m_curdevice != nullptr); return downcast<_DeviceClass &>(*m_curdevice); }
// search for devices of the specified type
const auto_iterator &operator++()
{
advance();
while (m_curdevice != nullptr && m_curdevice->type() != _DeviceType)
advance();
return *this;
}
};
public: public:
// construction // construction
device_type_iterator(device_t &root, int maxdepth = 255) device_type_iterator(device_t &root, int maxdepth = 255)
: m_iterator(root, maxdepth) { } : m_root(root), m_maxdepth(maxdepth) { }
// getters // standard iterators
_DeviceClass *current() const { return downcast<_DeviceClass *>(m_iterator.current()); } auto_iterator begin() const { return auto_iterator(&m_root, 0, m_maxdepth); }
auto_iterator end() const { return auto_iterator(nullptr, 0, m_maxdepth); }
// reset and return first item // return first item
_DeviceClass *first() _DeviceClass *first() const { return begin().current(); }
{
for (device_t *device = m_iterator.first(); device != nullptr; device = m_iterator.next())
if (device->type() == _DeviceType)
return downcast<_DeviceClass *>(device);
return nullptr;
}
// advance depth-first
_DeviceClass *next()
{
for (device_t *device = m_iterator.next(); device != nullptr; device = m_iterator.next())
if (device->type() == _DeviceType)
return downcast<_DeviceClass *>(device);
return nullptr;
}
// return the number of items available // return the number of items available
int count() int count() const
{ {
int result = 0; int result = 0;
for (_DeviceClass *item = first(); item != nullptr; item = next()) for (_DeviceClass &item : *this)
{
(void)&item;
result++; result++;
}
return result; return result;
} }
// return the index of a given item in the virtual list // return the index of a given item in the virtual list
int indexof(_DeviceClass &device) int indexof(_DeviceClass &device) const
{ {
int index = 0; int index = 0;
for (_DeviceClass *item = first(); item != nullptr; item = next(), index++) for (_DeviceClass &item : *this)
if (item == &device) {
if (&item == &device)
return index; return index;
else
index++;
}
return -1; return -1;
} }
// return the indexed item in the list // return the indexed item in the list
_DeviceClass *byindex(int index) _DeviceClass *byindex(int index) const
{ {
for (_DeviceClass *item = first(); item != nullptr; item = next(), index--) for (_DeviceClass &item : *this)
if (index == 0) if (index-- == 0)
return item; return &item;
return nullptr; return nullptr;
} }
private: private:
// internal state // internal state
device_iterator m_iterator; device_t & m_root;
int m_maxdepth;
}; };
// ======================> device_interface_iterator // ======================> device_interface_iterator
// helper class to find devices with a given interface in the device hierarchy // helper class to find devices with a given interface in the device hierarchy
// also works for findnig devices derived from a given subclass // also works for finding devices derived from a given subclass
template<class _InterfaceClass> template<class _InterfaceClass>
class device_interface_iterator class device_interface_iterator
{ {
public:
class auto_iterator : public device_iterator::auto_iterator
{
public:
// construction
auto_iterator(device_t *devptr, int curdepth, int maxdepth)
: device_iterator::auto_iterator(devptr, curdepth, maxdepth)
{
// set the iterator for the first device with the interface
find_interface();
}
// getters returning specified interface type
_InterfaceClass *current() const { return m_interface; }
_InterfaceClass &operator*() const { assert(m_interface != nullptr); return *m_interface; }
// search for devices with the specified interface
const auto_iterator &operator++() { advance(); find_interface(); return *this; }
private:
// private helper
void find_interface()
{
// advance until finding a device with the interface
for ( ; m_curdevice != nullptr; advance())
if (m_curdevice->interface(m_interface))
return;
// if we run out of devices, make sure the interface pointer is null
m_interface = nullptr;
}
// private state
_InterfaceClass *m_interface;
};
public: public:
// construction // construction
device_interface_iterator(device_t &root, int maxdepth = 255) device_interface_iterator(device_t &root, int maxdepth = 255)
: m_iterator(root, maxdepth), : m_root(root), m_maxdepth(maxdepth) { }
m_current(nullptr) { }
// getters // standard iterators
_InterfaceClass *current() const { return m_current; } auto_iterator begin() const { return auto_iterator(&m_root, 0, m_maxdepth); }
auto_iterator end() const { return auto_iterator(nullptr, 0, m_maxdepth); }
// reset and return first item // return first item
_InterfaceClass *first() _InterfaceClass *first() const { return begin().current(); }
{
for (device_t *device = m_iterator.first(); device != nullptr; device = m_iterator.next())
if (device->interface(m_current))
return m_current;
return nullptr;
}
// advance depth-first
_InterfaceClass *next()
{
for (device_t *device = m_iterator.next(); device != nullptr; device = m_iterator.next())
if (device->interface(m_current))
return m_current;
return nullptr;
}
// return the number of items available // return the number of items available
int count() int count() const
{ {
int result = 0; int result = 0;
for (_InterfaceClass *item = first(); item != nullptr; item = next()) for (_InterfaceClass &item : *this)
{
(void)&item;
result++; result++;
}
return result; return result;
} }
// return the index of a given item in the virtual list // return the index of a given item in the virtual list
int indexof(_InterfaceClass &intrf) int indexof(_InterfaceClass &intrf) const
{ {
int index = 0; int index = 0;
for (_InterfaceClass *item = first(); item != nullptr; item = next(), index++) for (_InterfaceClass &item : *this)
if (item == &intrf) {
if (&item == &intrf)
return index; return index;
else
index++;
}
return -1; return -1;
} }
// return the indexed item in the list // return the indexed item in the list
_InterfaceClass *byindex(int index) _InterfaceClass *byindex(int index) const
{ {
for (_InterfaceClass *item = first(); item != nullptr; item = next(), index--) for (_InterfaceClass &item : *this)
if (index == 0) if (index-- == 0)
return item; return &item;
return nullptr; return nullptr;
} }
private: private:
// internal state // internal state
device_iterator m_iterator; device_t & m_root;
_InterfaceClass * m_current; int m_maxdepth;
}; };

View File

@ -476,8 +476,7 @@ void device_execute_interface::interface_pre_start()
m_driver_irq.bind_relative_to(*device().owner()); m_driver_irq.bind_relative_to(*device().owner());
// fill in the initial states // fill in the initial states
device_iterator iter(device().machine().root_device()); int index = device_iterator(device().machine().root_device()).indexof(*this);
int index = iter.indexof(*this);
m_suspend = SUSPEND_REASON_RESET; m_suspend = SUSPEND_REASON_RESET;
m_profiler = profile_type(index + PROFILER_DEVICE_FIRST); m_profiler = profile_type(index + PROFILER_DEVICE_FIRST);
m_inttrigger = index + TRIGGER_INT; m_inttrigger = index + TRIGGER_INT;

View File

@ -1151,14 +1151,13 @@ void device_image_interface::unload()
void device_image_interface::update_names(const device_type device_type, const char *inst, const char *brief) void device_image_interface::update_names(const device_type device_type, const char *inst, const char *brief)
{ {
image_interface_iterator iter(device().mconfig().root_device());
int count = 0; int count = 0;
int index = -1; int index = -1;
for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) for (const device_image_interface &image : image_interface_iterator(device().mconfig().root_device()))
{ {
if (this == image) if (this == &image)
index = count; index = count;
if ((image->image_type() == image_type() && device_type==nullptr) || (device_type==image->device().type())) if ((image.image_type() == image_type() && device_type == nullptr) || (device_type == image.device().type()))
count++; count++;
} }
const char *inst_name = (device_type!=nullptr) ? inst : device_typename(image_type()); const char *inst_name = (device_type!=nullptr) ? inst : device_typename(image_type());
@ -1234,12 +1233,11 @@ software_part *device_image_interface::find_software_item(const char *path, bool
interface = image_interface(); interface = image_interface();
// find the software list if explicitly specified // find the software list if explicitly specified
software_list_device_iterator deviter(device().mconfig().root_device()); for (software_list_device &swlistdev : software_list_device_iterator(device().mconfig().root_device()))
for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next())
{ {
if (swlist_name.compare(swlistdev->list_name())==0 || !(swlist_name.length() > 0)) if (swlist_name.compare(swlistdev.list_name())==0 || !(swlist_name.length() > 0))
{ {
software_info *info = swlistdev->find(swinfo_name.c_str()); software_info *info = swlistdev.find(swinfo_name.c_str());
if (info != nullptr) if (info != nullptr)
{ {
software_part *part = info->find_part(swpart_name.c_str(), interface); software_part *part = info->find_part(swpart_name.c_str(), interface);
@ -1248,13 +1246,13 @@ software_part *device_image_interface::find_software_item(const char *path, bool
} }
} }
if (swinfo_name == swlistdev->list_name()) if (swinfo_name == swlistdev.list_name())
{ {
// ad hoc handling for the case path = swlist_name:swinfo_name (e.g. // ad hoc handling for the case path = swlist_name:swinfo_name (e.g.
// gameboy:sml) which is not handled properly by software_name_split // gameboy:sml) which is not handled properly by software_name_split
// since the function cannot distinguish between this and the case // since the function cannot distinguish between this and the case
// path = swinfo_name:swpart_name // path = swinfo_name:swpart_name
software_info *info = swlistdev->find(swpart_name.c_str()); software_info *info = swlistdev.find(swpart_name.c_str());
if (info != nullptr) if (info != nullptr)
{ {
software_part *part = info->find_part(nullptr, interface); software_part *part = info->find_part(nullptr, interface);
@ -1309,20 +1307,19 @@ bool device_image_interface::load_software_part(const char *path, software_part
software_part *req_swpart = find_software_item(requirement, false); software_part *req_swpart = find_software_item(requirement, false);
if (req_swpart != nullptr) if (req_swpart != nullptr)
{ {
image_interface_iterator imgiter(device().machine().root_device()); for (device_image_interface &req_image : image_interface_iterator(device().machine().root_device()))
for (device_image_interface *req_image = imgiter.first(); req_image != nullptr; req_image = imgiter.next())
{ {
const char *interface = req_image->image_interface(); const char *interface = req_image.image_interface();
if (interface != nullptr) if (interface != nullptr)
{ {
if (req_swpart->matches_interface(interface)) if (req_swpart->matches_interface(interface))
{ {
const char *option = device().mconfig().options().value(req_image->brief_instance_name()); const char *option = device().mconfig().options().value(req_image.brief_instance_name());
// mount only if not already mounted // mount only if not already mounted
if (*option == '\0' && !req_image->filename()) if (*option == '\0' && !req_image.filename())
{ {
req_image->set_init_phase(); req_image.set_init_phase();
req_image->load(requirement); req_image.load(requirement);
} }
break; break;
} }

View File

@ -259,31 +259,31 @@ void device_sound_interface::interface_pre_start()
{ {
// scan all the sound devices // scan all the sound devices
sound_interface_iterator iter(m_device.machine().root_device()); sound_interface_iterator iter(m_device.machine().root_device());
for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) for (device_sound_interface &sound : iter)
{ {
// scan each route on the device // scan each route on the device
for (const sound_route &route : sound->routes()) for (const sound_route &route : sound.routes())
{ {
// see if we are the target of this route; if we are, make sure the source device is started // see if we are the target of this route; if we are, make sure the source device is started
device_t *target_device = sound->device().siblingdevice(route.m_target.c_str()); device_t *target_device = sound.device().siblingdevice(route.m_target.c_str());
if (target_device == &m_device && !sound->device().started()) if (target_device == &m_device && !sound.device().started())
throw device_missing_dependencies(); throw device_missing_dependencies();
} }
} }
// now iterate through devices again and assign any auto-allocated inputs // now iterate through devices again and assign any auto-allocated inputs
m_auto_allocated_inputs = 0; m_auto_allocated_inputs = 0;
for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) for (device_sound_interface &sound : iter)
{ {
// scan each route on the device // scan each route on the device
for (sound_route &route : sound->routes()) for (sound_route &route : sound.routes())
{ {
// see if we are the target of this route // see if we are the target of this route
device_t *target_device = sound->device().siblingdevice(route.m_target.c_str()); device_t *target_device = sound.device().siblingdevice(route.m_target.c_str());
if (target_device == &m_device && route.m_input == AUTO_ALLOC_INPUT) if (target_device == &m_device && route.m_input == AUTO_ALLOC_INPUT)
{ {
route.m_input = m_auto_allocated_inputs; route.m_input = m_auto_allocated_inputs;
m_auto_allocated_inputs += (route.m_output == ALL_OUTPUTS) ? sound->outputs() : 1; m_auto_allocated_inputs += (route.m_output == ALL_OUTPUTS) ? sound.outputs() : 1;
} }
} }
} }
@ -298,25 +298,24 @@ void device_sound_interface::interface_pre_start()
void device_sound_interface::interface_post_start() void device_sound_interface::interface_post_start()
{ {
// iterate over all the sound devices // iterate over all the sound devices
sound_interface_iterator iter(m_device.machine().root_device()); for (device_sound_interface &sound : sound_interface_iterator(m_device.machine().root_device()))
for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next())
{ {
// scan each route on the device // scan each route on the device
for (const sound_route &route : sound->routes()) for (const sound_route &route : sound.routes())
{ {
// if we are the target of this route, hook it up // if we are the target of this route, hook it up
device_t *target_device = sound->device().siblingdevice(route.m_target.c_str()); device_t *target_device = sound.device().siblingdevice(route.m_target.c_str());
if (target_device == &m_device) if (target_device == &m_device)
{ {
// iterate over all outputs, matching any that apply // iterate over all outputs, matching any that apply
int inputnum = route.m_input; int inputnum = route.m_input;
int numoutputs = sound->outputs(); int numoutputs = sound.outputs();
for (int outputnum = 0; outputnum < numoutputs; outputnum++) for (int outputnum = 0; outputnum < numoutputs; outputnum++)
if (route.m_output == outputnum || route.m_output == ALL_OUTPUTS) if (route.m_output == outputnum || route.m_output == ALL_OUTPUTS)
{ {
// find the output stream to connect from // find the output stream to connect from
int streamoutputnum; int streamoutputnum;
sound_stream *outputstream = sound->output_to_stream_output(outputnum, streamoutputnum); sound_stream *outputstream = sound.output_to_stream_output(outputnum, streamoutputnum);
if (outputstream == nullptr) if (outputstream == nullptr)
fatalerror("Sound device '%s' specifies route for non-existant output #%d\n", route.m_target.c_str(), outputnum); fatalerror("Sound device '%s' specifies route for non-existant output #%d\n", route.m_target.c_str(), outputnum);
@ -416,15 +415,14 @@ void device_mixer_interface::interface_pre_start()
m_outputmap.resize(m_auto_allocated_inputs); m_outputmap.resize(m_auto_allocated_inputs);
// iterate through all routes that point to us and note their mixer output // iterate through all routes that point to us and note their mixer output
sound_interface_iterator iter(m_device.machine().root_device()); for (device_sound_interface &sound : sound_interface_iterator(m_device.machine().root_device()))
for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) for (const sound_route &route : sound.routes())
for (const sound_route &route : sound->routes())
{ {
// see if we are the target of this route // see if we are the target of this route
device_t *target_device = sound->device().siblingdevice(route.m_target.c_str()); device_t *target_device = sound.device().siblingdevice(route.m_target.c_str());
if (target_device == &device() && route.m_input < m_auto_allocated_inputs) if (target_device == &device() && route.m_input < m_auto_allocated_inputs)
{ {
int count = (route.m_output == ALL_OUTPUTS) ? sound->outputs() : 1; int count = (route.m_output == ALL_OUTPUTS) ? sound.outputs() : 1;
for (int output = 0; output < count; output++) for (int output = 0; output < count; output++)
m_outputmap[route.m_input + output] = route.m_mixoutput; m_outputmap[route.m_input + output] = route.m_mixoutput;
} }

View File

@ -81,7 +81,7 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c
{ {
screen_device_iterator iter(device().mconfig().root_device()); screen_device_iterator iter(device().mconfig().root_device());
screen = iter.first(); screen = iter.first();
if (iter.next() != nullptr) if (iter.count() > 1)
osd_printf_error("No screen specified for device '%s', but multiple screens found\n", device().tag()); osd_printf_error("No screen specified for device '%s', but multiple screens found\n", device().tag());
} }
} }
@ -115,7 +115,7 @@ void device_video_interface::interface_pre_start()
{ {
screen_device_iterator iter(device().machine().root_device()); screen_device_iterator iter(device().machine().root_device());
m_screen = iter.first(); m_screen = iter.first();
if (iter.next() != nullptr) if (iter.count() > 1)
throw emu_fatalerror("No screen specified for device '%s', but multiple screens found", device().tag()); throw emu_fatalerror("No screen specified for device '%s', but multiple screens found", device().tag());
} }
} }

View File

@ -404,7 +404,6 @@ void driver_enumerator::release_current() const
return; return;
// iterate over software lists in this entry and reset // iterate over software lists in this entry and reset
software_list_device_iterator deviter(m_config[m_current]->root_device()); for (software_list_device &swlistdev : software_list_device_iterator(m_config[m_current]->root_device()))
for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) swlistdev.release();
swlistdev->release();
} }

View File

@ -201,9 +201,8 @@ ioport_constructor driver_device::device_input_ports() const
void driver_device::device_start() void driver_device::device_start()
{ {
// reschedule ourselves to be last // reschedule ourselves to be last
device_iterator iter(*this); for (device_t &test : device_iterator(*this))
for (device_t *test = iter.first(); test != nullptr; test = iter.next()) if (&test != this && !test.started())
if (test != this && !test->started())
throw device_missing_dependencies(); throw device_missing_dependencies();
// call the game-specific init // call the game-specific init

View File

@ -1549,13 +1549,13 @@ void memory_manager::initialize()
{ {
// loop over devices and spaces within each device // loop over devices and spaces within each device
memory_interface_iterator iter(machine().root_device()); memory_interface_iterator iter(machine().root_device());
for (device_memory_interface *memory = iter.first(); memory != nullptr; memory = iter.next()) for (device_memory_interface &memory : iter)
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
{ {
// if there is a configuration for this space, we need an address space // if there is a configuration for this space, we need an address space
const address_space_config *spaceconfig = memory->space_config(spacenum); const address_space_config *spaceconfig = memory.space_config(spacenum);
if (spaceconfig != nullptr) if (spaceconfig != nullptr)
m_spacelist.append(address_space::allocate(*this, *spaceconfig, *memory, spacenum)); m_spacelist.append(address_space::allocate(*this, *spaceconfig, memory, spacenum));
} }
// construct and preprocess the address_map for each space // construct and preprocess the address_map for each space

View File

@ -249,15 +249,14 @@ bool emu_options::add_slot_options(const software_part *swpart)
// iterate through all slot devices // iterate through all slot devices
int starting_count = options_count(); int starting_count = options_count();
slot_interface_iterator iter(config.root_device()); for (const device_slot_interface &slot : slot_interface_iterator(config.root_device()))
for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
// skip fixed slots // skip fixed slots
if (slot->fixed()) if (slot.fixed())
continue; continue;
// retrieve info about the device instance // retrieve info about the device instance
const char *name = slot->device().tag() + 1; const char *name = slot.device().tag() + 1;
if (!exists(name)) if (!exists(name))
{ {
// first device? add the header as to be pretty // first device? add the header as to be pretty
@ -265,7 +264,7 @@ bool emu_options::add_slot_options(const software_part *swpart)
add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
// add the option // add the option
add_entry(name, nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, slot->default_option(), true); add_entry(name, nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, slot.default_option(), true);
} }
// allow software lists to supply their own defaults // allow software lists to supply their own defaults
@ -273,7 +272,7 @@ bool emu_options::add_slot_options(const software_part *swpart)
{ {
std::string featurename = std::string(name).append("_default"); std::string featurename = std::string(name).append("_default");
const char *value = swpart->feature(featurename.c_str()); const char *value = swpart->feature(featurename.c_str());
if (value != nullptr && (*value == '\0' || slot->option(value) != nullptr)) if (value != nullptr && (*value == '\0' || slot.option(value) != nullptr))
{ {
// set priority above INIs but below actual command line // set priority above INIs but below actual command line
std::string error; std::string error;
@ -299,14 +298,13 @@ void emu_options::update_slot_options(const software_part *swpart)
machine_config config(*cursystem, *this); machine_config config(*cursystem, *this);
// iterate through all slot devices // iterate through all slot devices
slot_interface_iterator iter(config.root_device()); for (device_slot_interface &slot : slot_interface_iterator(config.root_device()))
for (device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
// retrieve info about the device instance // retrieve info about the device instance
const char *name = slot->device().tag() + 1; const char *name = slot.device().tag() + 1;
if (exists(name) && !slot->option_list().empty()) if (exists(name) && !slot.option_list().empty())
{ {
std::string defvalue = slot->get_default_card_software(); std::string defvalue = slot.get_default_card_software();
if (defvalue.empty()) if (defvalue.empty())
{ {
// keep any non-default setting // keep any non-default setting
@ -314,13 +312,13 @@ void emu_options::update_slot_options(const software_part *swpart)
continue; continue;
// reinstate the actual default value as configured // reinstate the actual default value as configured
if (slot->default_option() != nullptr) if (slot.default_option() != nullptr)
defvalue.assign(slot->default_option()); defvalue.assign(slot.default_option());
} }
// set the value and hide the option if not selectable // set the value and hide the option if not selectable
set_default_value(name, defvalue.c_str()); set_default_value(name, defvalue.c_str());
const device_slot_option *option = slot->option(defvalue.c_str()); const device_slot_option *option = slot.option(defvalue.c_str());
set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0); set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0);
} }
} }
@ -343,20 +341,19 @@ void emu_options::add_device_options()
machine_config config(*cursystem, *this); machine_config config(*cursystem, *this);
// iterate through all image devices // iterate through all image devices
image_interface_iterator iter(config.root_device()); for (const device_image_interface &image : image_interface_iterator(config.root_device()))
for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
if (!image->user_loadable()) if (!image.user_loadable())
continue; continue;
// retrieve info about the device instance // retrieve info about the device instance
std::ostringstream option_name; std::ostringstream option_name;
util::stream_format(option_name, "%s;%s", image->instance_name(), image->brief_instance_name()); util::stream_format(option_name, "%s;%s", image.instance_name(), image.brief_instance_name());
if (strcmp(image->device_typename(image->image_type()), image->instance_name()) == 0) if (strcmp(image.device_typename(image.image_type()), image.instance_name()) == 0)
util::stream_format(option_name, ";%s1;%s1", image->instance_name(), image->brief_instance_name()); util::stream_format(option_name, ";%s1;%s1", image.instance_name(), image.brief_instance_name());
// add the option // add the option
if (!exists(image->instance_name())) if (!exists(image.instance_name()))
{ {
// first device? add the header as to be pretty // first device? add the header as to be pretty
if (m_device_options++ == 0) if (m_device_options++ == 0)
@ -486,23 +483,22 @@ void emu_options::parse_standard_inis(std::string &error_string, const game_driv
parse_one_ini("othersys", OPTION_PRIORITY_SYSTYPE_INI, &error_string); parse_one_ini("othersys", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
machine_config config(*cursystem, *this); machine_config config(*cursystem, *this);
screen_device_iterator iter(config.root_device()); for (const screen_device &device : screen_device_iterator(config.root_device()))
for (const screen_device *device = iter.first(); device != nullptr; device = iter.next())
{ {
// parse "raster.ini" for raster games // parse "raster.ini" for raster games
if (device->screen_type() == SCREEN_TYPE_RASTER) if (device.screen_type() == SCREEN_TYPE_RASTER)
{ {
parse_one_ini("raster", OPTION_PRIORITY_SCREEN_INI, &error_string); parse_one_ini("raster", OPTION_PRIORITY_SCREEN_INI, &error_string);
break; break;
} }
// parse "vector.ini" for vector games // parse "vector.ini" for vector games
if (device->screen_type() == SCREEN_TYPE_VECTOR) if (device.screen_type() == SCREEN_TYPE_VECTOR)
{ {
parse_one_ini("vector", OPTION_PRIORITY_SCREEN_INI, &error_string); parse_one_ini("vector", OPTION_PRIORITY_SCREEN_INI, &error_string);
break; break;
} }
// parse "lcd.ini" for lcd games // parse "lcd.ini" for lcd games
if (device->screen_type() == SCREEN_TYPE_LCD) if (device.screen_type() == SCREEN_TYPE_LCD)
{ {
parse_one_ini("lcd", OPTION_PRIORITY_SCREEN_INI, &error_string); parse_one_ini("lcd", OPTION_PRIORITY_SCREEN_INI, &error_string);
break; break;

View File

@ -27,38 +27,34 @@
image_manager::image_manager(running_machine &machine) image_manager::image_manager(running_machine &machine)
: m_machine(machine) : m_machine(machine)
{ {
const char *image_name;
/* make sure that any required devices have been allocated */ /* make sure that any required devices have been allocated */
image_interface_iterator iter(machine.root_device()); for (device_image_interface &image : image_interface_iterator(machine.root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
/* is an image specified for this image */ /* is an image specified for this image */
image_name = machine.options().value(image->instance_name()); const char *image_name = machine.options().value(image.instance_name());
if (!image.user_loadable())
if (!image->user_loadable()) continue;
continue;
if ((image_name != nullptr) && (image_name[0] != '\0')) if ((image_name != nullptr) && (image_name[0] != '\0'))
{ {
/* mark init state */ /* mark init state */
image->set_init_phase(); image.set_init_phase();
/* try to load this image */ /* try to load this image */
bool result = image->load(image_name); bool result = image.load(image_name);
/* did the image load fail? */ /* did the image load fail? */
if (result) if (result)
{ {
/* retrieve image error message */ /* retrieve image error message */
std::string image_err = std::string(image->error()); std::string image_err = std::string(image.error());
std::string image_basename(image_name); std::string image_basename(image_name);
/* unload all images */ /* unload all images */
unload_all(); unload_all();
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s", fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
image->device().name(), image.device().name(),
image_basename.c_str(), image_basename.c_str(),
image_err.c_str()); image_err.c_str());
} }
@ -77,11 +73,10 @@ void image_manager::unload_all()
// extract the options // extract the options
options_extract(); options_extract();
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
// unload this image // unload this image
image->unload(); image.unload();
} }
} }
@ -99,13 +94,12 @@ void image_manager::config_load(config_type cfg_type, xml_data_node *parentnode)
if ((dev_instance != nullptr) && (dev_instance[0] != '\0')) if ((dev_instance != nullptr) && (dev_instance[0] != '\0'))
{ {
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
if (!strcmp(dev_instance, image->instance_name())) { if (!strcmp(dev_instance, image.instance_name())) {
working_directory = xml_get_attribute_string(node, "directory", nullptr); working_directory = xml_get_attribute_string(node, "directory", nullptr);
if (working_directory != nullptr) if (working_directory != nullptr)
image->set_working_directory(working_directory); image.set_working_directory(working_directory);
} }
} }
} }
@ -126,16 +120,15 @@ void image_manager::config_save(config_type cfg_type, xml_data_node *parentnode)
/* only care about game-specific data */ /* only care about game-specific data */
if (cfg_type == config_type::CONFIG_TYPE_GAME) if (cfg_type == config_type::CONFIG_TYPE_GAME)
{ {
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
dev_instance = image->instance_name(); dev_instance = image.instance_name();
node = xml_add_child(parentnode, "device", nullptr); node = xml_add_child(parentnode, "device", nullptr);
if (node != nullptr) if (node != nullptr)
{ {
xml_set_attribute(node, "instance", dev_instance); xml_set_attribute(node, "instance", dev_instance);
xml_set_attribute(node, "directory", image->working_directory()); xml_set_attribute(node, "directory", image.working_directory());
} }
} }
} }
@ -180,14 +173,13 @@ void image_manager::options_extract()
{ {
int index = 0; int index = 0;
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
const char *filename = image->filename(); const char *filename = image.filename();
/* and set the option */ /* and set the option */
std::string error; std::string error;
machine().options().set_value(image->instance_name(), filename ? filename : "", OPTION_PRIORITY_CMDLINE, error); machine().options().set_value(image.instance_name(), filename ? filename : "", OPTION_PRIORITY_CMDLINE, error);
index++; index++;
} }
@ -208,11 +200,10 @@ std::string &image_manager::mandatory_scan(std::string &mandatory)
{ {
mandatory.clear(); mandatory.clear();
// make sure that any required image has a mounted file // make sure that any required image has a mounted file
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
if (image->filename() == nullptr && image->must_be_loaded()) if (image.filename() == nullptr && image.must_be_loaded())
mandatory.append("\"").append(image->instance_name()).append("\", "); mandatory.append("\"").append(image.instance_name()).append("\", ");
} }
return mandatory; return mandatory;
} }
@ -225,24 +216,23 @@ std::string &image_manager::mandatory_scan(std::string &mandatory)
void image_manager::postdevice_init() void image_manager::postdevice_init()
{ {
/* make sure that any required devices have been allocated */ /* make sure that any required devices have been allocated */
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
int result = image->finish_load(); int result = image.finish_load();
/* did the image load fail? */ /* did the image load fail? */
if (result) if (result)
{ {
/* retrieve image error message */ /* retrieve image error message */
std::string image_err = std::string(image->error()); std::string image_err = std::string(image.error());
/* unload all images */ /* unload all images */
unload_all(); unload_all();
fatalerror_exitcode(machine(), MAMERR_DEVICE, "Device %s load failed: %s", fatalerror_exitcode(machine(), MAMERR_DEVICE, "Device %s load failed: %s",
image->device().name(), image.device().name(),
image_err.c_str()); image_err.c_str());
} }
} }
/* add a callback for when we shut down */ /* add a callback for when we shut down */
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(image_manager::unload_all), this)); machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(image_manager::unload_all), this));

View File

@ -248,35 +248,36 @@ void info_xml_creator::output_one()
ioport_list portlist; ioport_list portlist;
std::string errors; std::string errors;
device_iterator iter(config.root_device()); device_iterator iter(config.root_device());
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : iter)
portlist.append(*device, errors); portlist.append(device, errors);
// renumber player numbers for controller ports
int player_offset = 0; // renumber player numbers for controller ports
// but treat keyboard count separately from players' number int player_offset = 0;
int kbd_offset = 0; // but treat keyboard count separately from players' number
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) int kbd_offset = 0;
{ for (device_t &device : iter)
int nplayers = 0; {
bool new_kbd = FALSE; int nplayers = 0;
for (ioport_port &port : portlist) bool new_kbd = false;
if (&port.device() == device) for (ioport_port &port : portlist)
for (ioport_field &field : port.fields()) if (&port.device() == &device)
if (field.type() >= IPT_START && field.type() < IPT_ANALOG_LAST) for (ioport_field &field : port.fields())
{ if (field.type() >= IPT_START && field.type() < IPT_ANALOG_LAST)
if (field.type() == IPT_KEYBOARD) {
{ if (field.type() == IPT_KEYBOARD)
if (!new_kbd) new_kbd = TRUE; {
field.set_player(field.player() + kbd_offset); if (!new_kbd) new_kbd = TRUE;
} field.set_player(field.player() + kbd_offset);
else }
{ else
nplayers = MAX(nplayers, field.player() + 1); {
field.set_player(field.player() + player_offset); nplayers = MAX(nplayers, field.player() + 1);
} field.set_player(field.player() + player_offset);
} }
player_offset += nplayers; }
if (new_kbd) kbd_offset++; player_offset += nplayers;
} if (new_kbd) kbd_offset++;
}
// print the header and the game name // print the header and the game name
fprintf(m_output, "\t<%s",XML_TOP); fprintf(m_output, "\t<%s",XML_TOP);
@ -360,9 +361,8 @@ void info_xml_creator::output_one_device(device_t &device, const char *devtag)
// generate input list // generate input list
ioport_list portlist; ioport_list portlist;
std::string errors; std::string errors;
device_iterator iptiter(device); for (device_t &dev : device_iterator(device))
for (device_t *dev = iptiter.first(); dev != nullptr; dev = iptiter.next()) portlist.append(dev, errors);
portlist.append(*dev, errors);
// check if the device adds player inputs (other than dsw and configs) to the system // check if the device adds player inputs (other than dsw and configs) to the system
for (ioport_port &port : portlist) for (ioport_port &port : portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.fields())
@ -424,43 +424,39 @@ void info_xml_creator::output_devices()
while (m_drivlist.next()) while (m_drivlist.next())
{ {
// first, run through devices with roms which belongs to the default configuration // first, run through devices with roms which belongs to the default configuration
device_iterator deviter(m_drivlist.config().root_device()); for (device_t &device : device_iterator(m_drivlist.config().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
{ {
if (device->owner() != nullptr && device->shortname()!= nullptr && device->shortname()[0]!='\0') if (device.owner() != nullptr && device.shortname() != nullptr && device.shortname()[0]!='\0')
{ {
if (shortnames.insert(device->shortname()).second) if (shortnames.insert(device.shortname()).second)
output_one_device(*device, device->tag()); output_one_device(device, device.tag());
} }
} }
// then, run through slot devices // then, run through slot devices
slot_interface_iterator iter(m_drivlist.config().root_device()); for (const device_slot_interface &slot : slot_interface_iterator(m_drivlist.config().root_device()))
for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
{ {
std::string temptag("_"); std::string temptag("_");
temptag.append(option.name()); temptag.append(option.name());
device_t *dev = const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), temptag.c_str(), option.devtype(), 0); device_t *dev = const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), temptag.c_str(), option.devtype(), 0);
// notify this device and all its subdevices that they are now configured // notify this device and all its subdevices that they are now configured
device_iterator subiter(*dev); for (device_t &device : device_iterator(*dev))
for (device_t *device = subiter.first(); device != nullptr; device = subiter.next()) if (!device.configured())
if (!device->configured()) device.config_complete();
device->config_complete();
if (shortnames.insert(dev->shortname()).second) if (shortnames.insert(dev->shortname()).second)
output_one_device(*dev, temptag.c_str()); output_one_device(*dev, temptag.c_str());
// also, check for subdevices with ROMs (a few devices are missed otherwise, e.g. MPU401) // also, check for subdevices with ROMs (a few devices are missed otherwise, e.g. MPU401)
device_iterator deviter2(*dev); for (device_t &device : device_iterator(*dev))
for (device_t *device = deviter2.first(); device != nullptr; device = deviter2.next())
{ {
if (device->owner() == dev && device->shortname()!= nullptr && device->shortname()[0]!='\0') if (device.owner() == dev && device.shortname() != nullptr && device.shortname()[0]!='\0')
{ {
if (shortnames.insert(device->shortname()).second) if (shortnames.insert(device.shortname()).second)
output_one_device(*device, device->tag()); output_one_device(device, device.tag());
} }
} }
@ -478,10 +474,9 @@ void info_xml_creator::output_devices()
void info_xml_creator::output_device_roms() void info_xml_creator::output_device_roms()
{ {
device_iterator deviter(m_drivlist.config().root_device()); for (device_t &device : device_iterator(m_drivlist.config().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) if (device.owner() != nullptr && device.shortname() != nullptr && device.shortname()[0] != '\0')
if (device->owner() != nullptr && device->shortname()!= nullptr && device->shortname()[0]!='\0') fprintf(m_output, "\t\t<device_ref name=\"%s\"/>\n", xml_normalize_string(device.shortname()));
fprintf(m_output, "\t\t<device_ref name=\"%s\"/>\n", xml_normalize_string(device->shortname()));
} }
@ -493,10 +488,9 @@ void info_xml_creator::output_device_roms()
void info_xml_creator::output_sampleof() void info_xml_creator::output_sampleof()
{ {
// iterate over sample devices // iterate over sample devices
samples_device_iterator iter(m_drivlist.config().root_device()); for (samples_device &device : samples_device_iterator(m_drivlist.config().root_device()))
for (samples_device *device = iter.first(); device != nullptr; device = iter.next())
{ {
samples_iterator sampiter(*device); samples_iterator sampiter(device);
if (sampiter.altbasename() != nullptr) if (sampiter.altbasename() != nullptr)
{ {
fprintf(m_output, " sampleof=\"%s\"", xml_normalize_string(sampiter.altbasename())); fprintf(m_output, " sampleof=\"%s\"", xml_normalize_string(sampiter.altbasename()));
@ -650,10 +644,9 @@ void info_xml_creator::output_rom(device_t &device)
void info_xml_creator::output_sample(device_t &device) void info_xml_creator::output_sample(device_t &device)
{ {
// iterate over sample devices // iterate over sample devices
samples_device_iterator sampiter(device); for (samples_device &samples : samples_device_iterator(device))
for (samples_device *samples = sampiter.first(); samples != nullptr; samples = sampiter.next())
{ {
samples_iterator iter(*samples); samples_iterator iter(samples);
std::unordered_set<std::string> already_printed; std::unordered_set<std::string> already_printed;
for (const char *samplename = iter.first(); samplename != nullptr; samplename = iter.next()) for (const char *samplename = iter.first(); samplename != nullptr; samplename = iter.next())
{ {
@ -676,38 +669,36 @@ void info_xml_creator::output_sample(device_t &device)
void info_xml_creator::output_chips(device_t &device, const char *root_tag) void info_xml_creator::output_chips(device_t &device, const char *root_tag)
{ {
// iterate over executable devices // iterate over executable devices
execute_interface_iterator execiter(device); for (device_execute_interface &exec : execute_interface_iterator(device))
for (device_execute_interface *exec = execiter.first(); exec != nullptr; exec = execiter.next())
{ {
if (strcmp(exec->device().tag(), device.tag())) if (strcmp(exec.device().tag(), device.tag()))
{ {
std::string newtag(exec->device().tag()), oldtag(":"); std::string newtag(exec.device().tag()), oldtag(":");
newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length()); newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());
fprintf(m_output, "\t\t<chip"); fprintf(m_output, "\t\t<chip");
fprintf(m_output, " type=\"cpu\""); fprintf(m_output, " type=\"cpu\"");
fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str())); fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str()));
fprintf(m_output, " name=\"%s\"", xml_normalize_string(exec->device().name())); fprintf(m_output, " name=\"%s\"", xml_normalize_string(exec.device().name()));
fprintf(m_output, " clock=\"%d\"", exec->device().clock()); fprintf(m_output, " clock=\"%d\"", exec.device().clock());
fprintf(m_output, "/>\n"); fprintf(m_output, "/>\n");
} }
} }
// iterate over sound devices // iterate over sound devices
sound_interface_iterator sounditer(device); for (device_sound_interface &sound : sound_interface_iterator(device))
for (device_sound_interface *sound = sounditer.first(); sound != nullptr; sound = sounditer.next())
{ {
if (strcmp(sound->device().tag(), device.tag())) if (strcmp(sound.device().tag(), device.tag()))
{ {
std::string newtag(sound->device().tag()), oldtag(":"); std::string newtag(sound.device().tag()), oldtag(":");
newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length()); newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());
fprintf(m_output, "\t\t<chip"); fprintf(m_output, "\t\t<chip");
fprintf(m_output, " type=\"audio\""); fprintf(m_output, " type=\"audio\"");
fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str())); fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str()));
fprintf(m_output, " name=\"%s\"", xml_normalize_string(sound->device().name())); fprintf(m_output, " name=\"%s\"", xml_normalize_string(sound.device().name()));
if (sound->device().clock() != 0) if (sound.device().clock() != 0)
fprintf(m_output, " clock=\"%d\"", sound->device().clock()); fprintf(m_output, " clock=\"%d\"", sound.device().clock());
fprintf(m_output, "/>\n"); fprintf(m_output, "/>\n");
} }
} }
@ -722,18 +713,17 @@ void info_xml_creator::output_chips(device_t &device, const char *root_tag)
void info_xml_creator::output_display(device_t &device, const char *root_tag) void info_xml_creator::output_display(device_t &device, const char *root_tag)
{ {
// iterate over screens // iterate over screens
screen_device_iterator iter(device); for (const screen_device &screendev : screen_device_iterator(device))
for (const screen_device *screendev = iter.first(); screendev != nullptr; screendev = iter.next())
{ {
if (strcmp(screendev->tag(), device.tag())) if (strcmp(screendev.tag(), device.tag()))
{ {
std::string newtag(screendev->tag()), oldtag(":"); std::string newtag(screendev.tag()), oldtag(":");
newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length()); newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());
fprintf(m_output, "\t\t<display"); fprintf(m_output, "\t\t<display");
fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str())); fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str()));
switch (screendev->screen_type()) switch (screendev.screen_type())
{ {
case SCREEN_TYPE_RASTER: fprintf(m_output, " type=\"raster\""); break; case SCREEN_TYPE_RASTER: fprintf(m_output, " type=\"raster\""); break;
case SCREEN_TYPE_VECTOR: fprintf(m_output, " type=\"vector\""); break; case SCREEN_TYPE_VECTOR: fprintf(m_output, " type=\"vector\""); break;
@ -771,29 +761,29 @@ void info_xml_creator::output_display(device_t &device, const char *root_tag)
} }
// output width and height only for games that are not vector // output width and height only for games that are not vector
if (screendev->screen_type() != SCREEN_TYPE_VECTOR) if (screendev.screen_type() != SCREEN_TYPE_VECTOR)
{ {
const rectangle &visarea = screendev->visible_area(); const rectangle &visarea = screendev.visible_area();
fprintf(m_output, " width=\"%d\"", visarea.width()); fprintf(m_output, " width=\"%d\"", visarea.width());
fprintf(m_output, " height=\"%d\"", visarea.height()); fprintf(m_output, " height=\"%d\"", visarea.height());
} }
// output refresh rate // output refresh rate
fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds())); fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev.refresh_attoseconds()));
// output raw video parameters only for games that are not vector // output raw video parameters only for games that are not vector
// and had raw parameters specified // and had raw parameters specified
if (screendev->screen_type() != SCREEN_TYPE_VECTOR && !screendev->oldstyle_vblank_supplied()) if (screendev.screen_type() != SCREEN_TYPE_VECTOR && !screendev.oldstyle_vblank_supplied())
{ {
int pixclock = screendev->width() * screendev->height() * ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds()); int pixclock = screendev.width() * screendev.height() * ATTOSECONDS_TO_HZ(screendev.refresh_attoseconds());
fprintf(m_output, " pixclock=\"%d\"", pixclock); fprintf(m_output, " pixclock=\"%d\"", pixclock);
fprintf(m_output, " htotal=\"%d\"", screendev->width()); fprintf(m_output, " htotal=\"%d\"", screendev.width());
fprintf(m_output, " hbend=\"%d\"", screendev->visible_area().min_x); fprintf(m_output, " hbend=\"%d\"", screendev.visible_area().min_x);
fprintf(m_output, " hbstart=\"%d\"", screendev->visible_area().max_x+1); fprintf(m_output, " hbstart=\"%d\"", screendev.visible_area().max_x+1);
fprintf(m_output, " vtotal=\"%d\"", screendev->height()); fprintf(m_output, " vtotal=\"%d\"", screendev.height());
fprintf(m_output, " vbend=\"%d\"", screendev->visible_area().min_y); fprintf(m_output, " vbend=\"%d\"", screendev.visible_area().min_y);
fprintf(m_output, " vbstart=\"%d\"", screendev->visible_area().max_y+1); fprintf(m_output, " vbstart=\"%d\"", screendev.visible_area().max_y+1);
} }
fprintf(m_output, " />\n"); fprintf(m_output, " />\n");
} }
@ -1430,20 +1420,19 @@ void info_xml_creator::output_driver()
void info_xml_creator::output_images(device_t &device, const char *root_tag) void info_xml_creator::output_images(device_t &device, const char *root_tag)
{ {
image_interface_iterator iter(device); for (const device_image_interface &imagedev : image_interface_iterator(device))
for (const device_image_interface *imagedev = iter.first(); imagedev != nullptr; imagedev = iter.next())
{ {
if (strcmp(imagedev->device().tag(), device.tag())) if (strcmp(imagedev.device().tag(), device.tag()))
{ {
bool loadable = imagedev->user_loadable(); bool loadable = imagedev.user_loadable();
std::string newtag(imagedev->device().tag()), oldtag(":"); std::string newtag(imagedev.device().tag()), oldtag(":");
newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length()); newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());
// print m_output device type // print m_output device type
fprintf(m_output, "\t\t<device type=\"%s\"", xml_normalize_string(imagedev->image_type_name())); fprintf(m_output, "\t\t<device type=\"%s\"", xml_normalize_string(imagedev.image_type_name()));
// does this device have a tag? // does this device have a tag?
if (imagedev->device().tag()) if (imagedev.device().tag())
fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str())); fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag.c_str()));
// is this device available as media switch? // is this device available as media switch?
@ -1451,26 +1440,26 @@ void info_xml_creator::output_images(device_t &device, const char *root_tag)
fprintf(m_output, " fixed_image=\"1\""); fprintf(m_output, " fixed_image=\"1\"");
// is this device mandatory? // is this device mandatory?
if (imagedev->must_be_loaded()) if (imagedev.must_be_loaded())
fprintf(m_output, " mandatory=\"1\""); fprintf(m_output, " mandatory=\"1\"");
if (imagedev->image_interface() && imagedev->image_interface()[0]) if (imagedev.image_interface() && imagedev.image_interface()[0])
fprintf(m_output, " interface=\"%s\"", xml_normalize_string(imagedev->image_interface())); fprintf(m_output, " interface=\"%s\"", xml_normalize_string(imagedev.image_interface()));
// close the XML tag // close the XML tag
fprintf(m_output, ">\n"); fprintf(m_output, ">\n");
if (loadable) if (loadable)
{ {
const char *name = imagedev->instance_name(); const char *name = imagedev.instance_name();
const char *shortname = imagedev->brief_instance_name(); const char *shortname = imagedev.brief_instance_name();
fprintf(m_output, "\t\t\t<instance"); fprintf(m_output, "\t\t\t<instance");
fprintf(m_output, " name=\"%s\"", xml_normalize_string(name)); fprintf(m_output, " name=\"%s\"", xml_normalize_string(name));
fprintf(m_output, " briefname=\"%s\"", xml_normalize_string(shortname)); fprintf(m_output, " briefname=\"%s\"", xml_normalize_string(shortname));
fprintf(m_output, "/>\n"); fprintf(m_output, "/>\n");
std::string extensions(imagedev->file_extensions()); std::string extensions(imagedev.file_extensions());
char *ext = strtok((char *)extensions.c_str(), ","); char *ext = strtok((char *)extensions.c_str(), ",");
while (ext != nullptr) while (ext != nullptr)
@ -1493,25 +1482,24 @@ void info_xml_creator::output_images(device_t &device, const char *root_tag)
void info_xml_creator::output_slots(device_t &device, const char *root_tag) void info_xml_creator::output_slots(device_t &device, const char *root_tag)
{ {
slot_interface_iterator iter(device); for (const device_slot_interface &slot : slot_interface_iterator(device))
for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
if (slot->fixed()) continue; // or shall we list these as non-configurable? if (slot.fixed()) continue; // or shall we list these as non-configurable?
if (strcmp(slot->device().tag(), device.tag())) if (strcmp(slot.device().tag(), device.tag()))
{ {
std::string newtag(slot->device().tag()), oldtag(":"); std::string newtag(slot.device().tag()), oldtag(":");
newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length()); newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());
// print m_output device type // print m_output device type
fprintf(m_output, "\t\t<slot name=\"%s\">\n", xml_normalize_string(newtag.c_str())); fprintf(m_output, "\t\t<slot name=\"%s\">\n", xml_normalize_string(newtag.c_str()));
/* /*
if (slot->slot_interface()[0]) if (slot.slot_interface()[0])
fprintf(m_output, " interface=\"%s\"", xml_normalize_string(slot->slot_interface())); fprintf(m_output, " interface=\"%s\"", xml_normalize_string(slot.slot_interface()));
*/ */
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
{ {
if (option.selectable()) if (option.selectable())
{ {
@ -1522,7 +1510,7 @@ void info_xml_creator::output_slots(device_t &device, const char *root_tag)
fprintf(m_output, "\t\t\t<slotoption"); fprintf(m_output, "\t\t\t<slotoption");
fprintf(m_output, " name=\"%s\"", xml_normalize_string(option.name())); fprintf(m_output, " name=\"%s\"", xml_normalize_string(option.name()));
fprintf(m_output, " devname=\"%s\"", xml_normalize_string(dev->shortname())); fprintf(m_output, " devname=\"%s\"", xml_normalize_string(dev->shortname()));
if (slot->default_option() != nullptr && strcmp(slot->default_option(),option.name())==0) if (slot.default_option() != nullptr && strcmp(slot.default_option(),option.name())==0)
fprintf(m_output, " default=\"yes\""); fprintf(m_output, " default=\"yes\"");
fprintf(m_output, "/>\n"); fprintf(m_output, "/>\n");
const_cast<machine_config &>(m_drivlist.config()).device_remove(&m_drivlist.config().root_device(), "dummy"); const_cast<machine_config &>(m_drivlist.config()).device_remove(&m_drivlist.config().root_device(), "dummy");
@ -1542,14 +1530,12 @@ void info_xml_creator::output_slots(device_t &device, const char *root_tag)
void info_xml_creator::output_software_list() void info_xml_creator::output_software_list()
{ {
software_list_device_iterator iter(m_drivlist.config().root_device()); for (const software_list_device &swlist : software_list_device_iterator(m_drivlist.config().root_device()))
for (const software_list_device *swlist = iter.first(); swlist != nullptr; swlist = iter.next())
{ {
fprintf(m_output, "\t\t<softwarelist name=\"%s\" ", swlist->list_name()); fprintf(m_output, "\t\t<softwarelist name=\"%s\" ", swlist.list_name());
fprintf(m_output, "status=\"%s\" ", (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) ? "original" : "compatible"); fprintf(m_output, "status=\"%s\" ", (swlist.list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) ? "original" : "compatible");
if (swlist->filter()) { if (swlist.filter())
fprintf(m_output, "filter=\"%s\" ", swlist->filter()); fprintf(m_output, "filter=\"%s\" ", swlist.filter());
}
fprintf(m_output, "/>\n"); fprintf(m_output, "/>\n");
} }
} }
@ -1563,14 +1549,13 @@ void info_xml_creator::output_software_list()
void info_xml_creator::output_ramoptions() void info_xml_creator::output_ramoptions()
{ {
ram_device_iterator iter(m_drivlist.config().root_device()); for (const ram_device &ram : ram_device_iterator(m_drivlist.config().root_device()))
for (const ram_device *ram = iter.first(); ram != nullptr; ram = iter.next())
{ {
fprintf(m_output, "\t\t<ramoption default=\"1\">%u</ramoption>\n", ram->default_size()); fprintf(m_output, "\t\t<ramoption default=\"1\">%u</ramoption>\n", ram.default_size());
if (ram->extra_options() != nullptr) if (ram.extra_options() != nullptr)
{ {
std::string options(ram->extra_options()); std::string options(ram.extra_options());
for (int start = 0, end = options.find_first_of(',');; start = end + 1, end = options.find_first_of(',', start)) for (int start = 0, end = options.find_first_of(',');; start = end + 1, end = options.find_first_of(',', start))
{ {
std::string option; std::string option;

View File

@ -2457,22 +2457,22 @@ time_t ioport_manager::initialize()
// if we have a token list, proceed // if we have a token list, proceed
device_iterator iter(machine().root_device()); device_iterator iter(machine().root_device());
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : iter)
{ {
std::string errors; std::string errors;
m_portlist.append(*device, errors); m_portlist.append(device, errors);
if (!errors.empty()) if (!errors.empty())
osd_printf_error("Input port errors:\n%s", errors.c_str()); osd_printf_error("Input port errors:\n%s", errors.c_str());
} }
// renumber player numbers for controller ports // renumber player numbers for controller ports
int player_offset = 0; int player_offset = 0;
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : iter)
{ {
int players = 0; int players = 0;
for (ioport_port &port : m_portlist) for (ioport_port &port : m_portlist)
{ {
if (&port.device() == device) if (&port.device() == &device)
{ {
for (ioport_field &field : port.fields()) for (ioport_field &field : port.fields())
if (field.type_class()==INPUT_CLASS_CONTROLLER) if (field.type_class()==INPUT_CLASS_CONTROLLER)
@ -2532,10 +2532,9 @@ time_t ioport_manager::initialize()
if (field.is_analog()) if (field.is_analog())
m_has_analog = true; m_has_analog = true;
} }
device_iterator deviter(machine().root_device()); for (device_t &device : device_iterator(machine().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) if (device.rom_region())
if (device->rom_region()) for (const rom_entry *rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISSYSTEM_BIOS(rom)) { m_has_bioses= true; break; } if (ROMENTRY_ISSYSTEM_BIOS(rom)) { m_has_bioses= true; break; }
} }

View File

@ -547,10 +547,10 @@ luabridge::LuaRef lua_engine::l_machine_get_images(const running_machine *r)
lua_State *L = luaThis->m_lua_state; lua_State *L = luaThis->m_lua_state;
luabridge::LuaRef image_table = luabridge::LuaRef::newTable(L); luabridge::LuaRef image_table = luabridge::LuaRef::newTable(L);
image_interface_iterator iter(r->root_device()); for (device_image_interface &image : image_interface_iterator(r->root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { {
image_table[image->brief_instance_name()] = image; image_table[image.brief_instance_name()] = &image;
image_table[image->instance_name()] = image; image_table[image.instance_name()] = &image;
} }
return image_table; return image_table;

View File

@ -138,18 +138,17 @@ running_machine::running_machine(const machine_config &_config, machine_manager
// set the machine on all devices // set the machine on all devices
device_iterator iter(root_device()); device_iterator iter(root_device());
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : iter)
device->set_machine(*this); device.set_machine(*this);
// find devices // find devices
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (device_t &device : iter)
if (dynamic_cast<cpu_device *>(device) != nullptr) if (dynamic_cast<cpu_device *>(&device) != nullptr)
{ {
firstcpu = downcast<cpu_device *>(device); firstcpu = downcast<cpu_device *>(&device);
break; break;
} }
screen_device_iterator screeniter(root_device()); primary_screen = screen_device_iterator(root_device()).first();
primary_screen = screeniter.first();
// fetch core options // fetch core options
if (options().debug()) if (options().debug())
@ -554,19 +553,18 @@ std::string running_machine::get_statename(const char *option) const
//printf("check template: %s\n", devname_str.c_str()); //printf("check template: %s\n", devname_str.c_str());
// verify that there is such a device for this system // verify that there is such a device for this system
image_interface_iterator iter(root_device()); for (device_image_interface &image : image_interface_iterator(root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
// get the device name // get the device name
std::string tempdevname(image->brief_instance_name()); std::string tempdevname(image.brief_instance_name());
//printf("check device: %s\n", tempdevname.c_str()); //printf("check device: %s\n", tempdevname.c_str());
if (devname_str.compare(tempdevname) == 0) if (devname_str.compare(tempdevname) == 0)
{ {
// verify that such a device has an image mounted // verify that such a device has an image mounted
if (image->basename_noext() != nullptr) if (image.basename_noext() != nullptr)
{ {
std::string filename(image->basename_noext()); std::string filename(image.basename_noext());
// setup snapname and remove the %d_ // setup snapname and remove the %d_
strreplace(statename_str, devname_str.c_str(), filename.c_str()); strreplace(statename_str, devname_str.c_str(), filename.c_str());
@ -1032,20 +1030,19 @@ void running_machine::start_all_devices()
{ {
// iterate over all devices // iterate over all devices
int failed_starts = 0; int failed_starts = 0;
device_iterator iter(root_device()); for (device_t &device : device_iterator(root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (!device.started())
if (!device->started())
{ {
// attempt to start the device, catching any expected exceptions // attempt to start the device, catching any expected exceptions
try try
{ {
// if the device doesn't have a machine yet, set it first // if the device doesn't have a machine yet, set it first
if (device->m_machine == nullptr) if (device.m_machine == nullptr)
device->set_machine(*this); device.set_machine(*this);
// now start the device // now start the device
osd_printf_verbose("Starting %s '%s'\n", device->name(), device->tag()); osd_printf_verbose("Starting %s '%s'\n", device.name(), device.tag());
device->start(); device.start();
} }
// handle missing dependencies by moving the device to the end // handle missing dependencies by moving the device to the end
@ -1090,9 +1087,8 @@ void running_machine::stop_all_devices()
debug_comment_save(*this); debug_comment_save(*this);
// iterate over devices and stop them // iterate over devices and stop them
device_iterator iter(root_device()); for (device_t &device : device_iterator(root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.stop();
device->stop();
} }
@ -1103,9 +1099,8 @@ void running_machine::stop_all_devices()
void running_machine::presave_all_devices() void running_machine::presave_all_devices()
{ {
device_iterator iter(root_device()); for (device_t &device : device_iterator(root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.pre_save();
device->pre_save();
} }
@ -1116,9 +1111,8 @@ void running_machine::presave_all_devices()
void running_machine::postload_all_devices() void running_machine::postload_all_devices()
{ {
device_iterator iter(root_device()); for (device_t &device : device_iterator(root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device.post_load();
device->post_load();
} }
@ -1170,17 +1164,16 @@ std::string running_machine::nvram_filename(device_t &device) const
void running_machine::nvram_load() void running_machine::nvram_load()
{ {
nvram_interface_iterator iter(root_device()); for (device_nvram_interface &nvram : nvram_interface_iterator(root_device()))
for (device_nvram_interface *nvram = iter.first(); nvram != nullptr; nvram = iter.next())
{ {
emu_file file(options().nvram_directory(), OPEN_FLAG_READ); emu_file file(options().nvram_directory(), OPEN_FLAG_READ);
if (file.open(nvram_filename(nvram->device()).c_str()) == osd_file::error::NONE) if (file.open(nvram_filename(nvram.device()).c_str()) == osd_file::error::NONE)
{ {
nvram->nvram_load(file); nvram.nvram_load(file);
file.close(); file.close();
} }
else else
nvram->nvram_reset(); nvram.nvram_reset();
} }
} }
@ -1191,13 +1184,12 @@ void running_machine::nvram_load()
void running_machine::nvram_save() void running_machine::nvram_save()
{ {
nvram_interface_iterator iter(root_device()); for (device_nvram_interface &nvram : nvram_interface_iterator(root_device()))
for (device_nvram_interface *nvram = iter.first(); nvram != nullptr; nvram = iter.next())
{ {
emu_file file(options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); emu_file file(options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(nvram_filename(nvram->device()).c_str()) == osd_file::error::NONE) if (file.open(nvram_filename(nvram.device()).c_str()) == osd_file::error::NONE)
{ {
nvram->nvram_save(file); nvram.nvram_save(file);
file.close(); file.close();
} }
} }

View File

@ -34,20 +34,20 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
bool is_selected_driver = core_stricmp(gamedrv.name,options.system_name())==0; bool is_selected_driver = core_stricmp(gamedrv.name,options.system_name())==0;
// intialize slot devices - make sure that any required devices have been allocated // intialize slot devices - make sure that any required devices have been allocated
slot_interface_iterator slotiter(root_device());
for (device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next()) for (device_slot_interface &slot : slot_interface_iterator(root_device()))
{ {
device_t &owner = slot->device(); device_t &owner = slot.device();
std::string selval; std::string selval;
bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT); bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT);
if (is_selected_driver && options.exists(owner.tag()+1)) if (is_selected_driver && options.exists(owner.tag()+1))
selval = options.main_value(owner.tag()+1); selval = options.main_value(owner.tag()+1);
else if (slot->default_option() != nullptr) else if (slot.default_option() != nullptr)
selval.assign(slot->default_option()); selval.assign(slot.default_option());
if (!selval.empty()) if (!selval.empty())
{ {
const device_slot_option *option = slot->option(selval.c_str()); const device_slot_option *option = slot.option(selval.c_str());
if (option && (isdefault || option->selectable())) if (option && (isdefault || option->selectable()))
{ {
@ -74,10 +74,9 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
driver_device::static_set_game(*m_root_device, gamedrv); driver_device::static_set_game(*m_root_device, gamedrv);
// then notify all devices that their configuration is complete // then notify all devices that their configuration is complete
device_iterator iter(root_device()); for (device_t &device : device_iterator(root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (!device.configured())
if (!device->configured()) device.config_complete();
device->config_complete();
} }
@ -97,8 +96,7 @@ machine_config::~machine_config()
screen_device *machine_config::first_screen() const screen_device *machine_config::first_screen() const
{ {
screen_device_iterator iter(root_device()); return screen_device_iterator(root_device()).first();
return iter.first();
} }
@ -235,9 +233,8 @@ device_t *machine_config::device_find(device_t *owner, const char *tag)
void machine_config::remove_references(ATTR_UNUSED device_t &device) void machine_config::remove_references(ATTR_UNUSED device_t &device)
{ {
// iterate over all devices and remove any references // iterate over all devices and remove any references
device_iterator iter(root_device()); for (device_t &scan : device_iterator(root_device()))
for (device_t *scan = iter.first(); scan != nullptr; scan = iter.next()) scan.subdevices().m_tagmap.clear(); //remove(&device);
scan->subdevices().m_tagmap.clear(); //remove(&device);
} }

View File

@ -43,19 +43,18 @@ void network_manager::config_load(config_type cfg_type, xml_data_node *parentnod
if ((tag != nullptr) && (tag[0] != '\0')) if ((tag != nullptr) && (tag[0] != '\0'))
{ {
network_interface_iterator iter(machine().root_device()); for (device_network_interface &network : network_interface_iterator(machine().root_device()))
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())
{ {
if (!strcmp(tag, network->device().tag())) { if (!strcmp(tag, network.device().tag())) {
int interface = xml_get_attribute_int(node, "interface", 0); int interface = xml_get_attribute_int(node, "interface", 0);
network->set_interface(interface); network.set_interface(interface);
const char *mac_addr = xml_get_attribute_string(node, "mac", nullptr); const char *mac_addr = xml_get_attribute_string(node, "mac", nullptr);
if (mac_addr != nullptr && strlen(mac_addr) == 17) { if (mac_addr != nullptr && strlen(mac_addr) == 17) {
char mac[7]; char mac[7];
unsigned int mac_num[6]; unsigned int mac_num[6];
sscanf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", &mac_num[0], &mac_num[1], &mac_num[2], &mac_num[3], &mac_num[4], &mac_num[5]); sscanf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", &mac_num[0], &mac_num[1], &mac_num[2], &mac_num[3], &mac_num[4], &mac_num[5]);
for (int i = 0; i<6; i++) mac[i] = mac_num[i]; for (int i = 0; i<6; i++) mac[i] = mac_num[i];
network->set_mac(mac); network.set_mac(mac);
} }
} }
@ -76,15 +75,14 @@ void network_manager::config_save(config_type cfg_type, xml_data_node *parentnod
/* only care about game-specific data */ /* only care about game-specific data */
if (cfg_type == config_type::CONFIG_TYPE_GAME) if (cfg_type == config_type::CONFIG_TYPE_GAME)
{ {
network_interface_iterator iter(machine().root_device()); for (device_network_interface &network : network_interface_iterator(machine().root_device()))
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())
{ {
node = xml_add_child(parentnode, "device", nullptr); node = xml_add_child(parentnode, "device", nullptr);
if (node != nullptr) if (node != nullptr)
{ {
xml_set_attribute(node, "tag", network->device().tag()); xml_set_attribute(node, "tag", network.device().tag());
xml_set_attribute_int(node, "interface", network->get_interface()); xml_set_attribute_int(node, "interface", network.get_interface());
const char *mac = network->get_mac(); const char *mac = network.get_mac();
char mac_addr[6 * 3]; char mac_addr[6 * 3];
sprintf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", (UINT8)mac[0], (UINT8)mac[1], (UINT8)mac[2], (UINT8)mac[3], (UINT8)mac[4], (UINT8)mac[5]); sprintf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", (UINT8)mac[0], (UINT8)mac[1], (UINT8)mac[2], (UINT8)mac[3], (UINT8)mac[4], (UINT8)mac[5]);
xml_set_attribute(node, "mac", mac_addr); xml_set_attribute(node, "mac", mac_addr);

View File

@ -1103,11 +1103,14 @@ int render_target::configured_view(const char *viewname, int targetindex, int nu
break; break;
if (viewscreens.count() >= scrcount) if (viewscreens.count() >= scrcount)
{ {
screen_device *screen; bool has_screen = false;
for (screen = iter.first(); screen != nullptr; screen = iter.next()) for (screen_device &screen : iter)
if (!viewscreens.contains(*screen)) if (!viewscreens.contains(screen))
{
has_screen = true;
break; break;
if (screen == nullptr) }
if (!has_screen)
break; break;
} }
} }
@ -2567,9 +2570,8 @@ render_manager::render_manager(running_machine &machine)
machine.configuration().config_register("video", config_saveload_delegate(FUNC(render_manager::config_load), this), config_saveload_delegate(FUNC(render_manager::config_save), this)); machine.configuration().config_register("video", config_saveload_delegate(FUNC(render_manager::config_load), this), config_saveload_delegate(FUNC(render_manager::config_save), this));
// create one container per screen // create one container per screen
screen_device_iterator iter(machine.root_device()); for (screen_device &screen : screen_device_iterator(machine.root_device()))
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) screen.set_container(*container_alloc(&screen));
screen->set_container(*container_alloc(screen));
} }

View File

@ -164,16 +164,15 @@ static int get_variable_value(running_machine &machine, const char *string, char
char temp[100]; char temp[100];
// screen 0 parameters // screen 0 parameters
screen_device_iterator iter(machine.root_device());
int scrnum = 0; int scrnum = 0;
for (const screen_device *device = iter.first(); device != nullptr; device = iter.next(), scrnum++) for (const screen_device &device : screen_device_iterator(machine.root_device()))
{ {
// native X aspect factor // native X aspect factor
sprintf(temp, "~scr%dnativexaspect~", scrnum); sprintf(temp, "~scr%dnativexaspect~", scrnum);
if (!strncmp(string, temp, strlen(temp))) if (!strncmp(string, temp, strlen(temp)))
{ {
int num = device->visible_area().width(); int num = device.visible_area().width();
int den = device->visible_area().height(); int den = device.visible_area().height();
reduce_fraction(num, den); reduce_fraction(num, den);
*outputptr += sprintf(*outputptr, "%d", num); *outputptr += sprintf(*outputptr, "%d", num);
return strlen(temp); return strlen(temp);
@ -183,8 +182,8 @@ static int get_variable_value(running_machine &machine, const char *string, char
sprintf(temp, "~scr%dnativeyaspect~", scrnum); sprintf(temp, "~scr%dnativeyaspect~", scrnum);
if (!strncmp(string, temp, strlen(temp))) if (!strncmp(string, temp, strlen(temp)))
{ {
int num = device->visible_area().width(); int num = device.visible_area().width();
int den = device->visible_area().height(); int den = device.visible_area().height();
reduce_fraction(num, den); reduce_fraction(num, den);
*outputptr += sprintf(*outputptr, "%d", den); *outputptr += sprintf(*outputptr, "%d", den);
return strlen(temp); return strlen(temp);
@ -194,7 +193,7 @@ static int get_variable_value(running_machine &machine, const char *string, char
sprintf(temp, "~scr%dwidth~", scrnum); sprintf(temp, "~scr%dwidth~", scrnum);
if (!strncmp(string, temp, strlen(temp))) if (!strncmp(string, temp, strlen(temp)))
{ {
*outputptr += sprintf(*outputptr, "%d", device->visible_area().width()); *outputptr += sprintf(*outputptr, "%d", device.visible_area().width());
return strlen(temp); return strlen(temp);
} }
@ -202,9 +201,12 @@ static int get_variable_value(running_machine &machine, const char *string, char
sprintf(temp, "~scr%dheight~", scrnum); sprintf(temp, "~scr%dheight~", scrnum);
if (!strncmp(string, temp, strlen(temp))) if (!strncmp(string, temp, strlen(temp)))
{ {
*outputptr += sprintf(*outputptr, "%d", device->visible_area().height()); *outputptr += sprintf(*outputptr, "%d", device.visible_area().height());
return strlen(temp); return strlen(temp);
} }
// keep count
scrnum++;
} }
// default: copy the first character and continue // default: copy the first character and continue
@ -2401,10 +2403,7 @@ layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simpl
// fetch common data // fetch common data
int index = xml_get_attribute_int_with_subst(machine, itemnode, "index", -1); int index = xml_get_attribute_int_with_subst(machine, itemnode, "index", -1);
if (index != -1) if (index != -1)
{ m_screen = screen_device_iterator(machine.root_device()).byindex(index);
screen_device_iterator iter(machine.root_device());
m_screen = iter.byindex(index);
}
m_input_mask = xml_get_attribute_int_with_subst(machine, itemnode, "inputmask", 0); m_input_mask = xml_get_attribute_int_with_subst(machine, itemnode, "inputmask", 0);
if (m_output_name[0] != 0 && m_element != nullptr) if (m_output_name[0] != 0 && m_element != nullptr)
machine.output().set_value(m_output_name.c_str(), m_element->default_state()); machine.output().set_value(m_output_name.c_str(), m_element->default_state());

View File

@ -265,22 +265,22 @@ int rom_load_manager::set_disk_handle(const char *region, const char *fullpath)
from SystemBios structure and OPTION_BIOS from SystemBios structure and OPTION_BIOS
-------------------------------------------------*/ -------------------------------------------------*/
void rom_load_manager::determine_bios_rom(device_t *device, const char *specbios) void rom_load_manager::determine_bios_rom(device_t &device, const char *specbios)
{ {
const char *defaultname = nullptr; const char *defaultname = nullptr;
const rom_entry *rom; const rom_entry *rom;
int default_no = 1; int default_no = 1;
int bios_count = 0; int bios_count = 0;
device->set_system_bios(0); device.set_system_bios(0);
/* first determine the default BIOS name */ /* first determine the default BIOS name */
for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) for (rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISDEFAULT_BIOS(rom)) if (ROMENTRY_ISDEFAULT_BIOS(rom))
defaultname = ROM_GETNAME(rom); defaultname = ROM_GETNAME(rom);
/* look for a BIOS with a matching name */ /* look for a BIOS with a matching name */
for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) for (rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISSYSTEM_BIOS(rom)) if (ROMENTRY_ISSYSTEM_BIOS(rom))
{ {
const char *biosname = ROM_GETNAME(rom); const char *biosname = ROM_GETNAME(rom);
@ -290,14 +290,14 @@ void rom_load_manager::determine_bios_rom(device_t *device, const char *specbios
/* Allow '-bios n' to still be used */ /* Allow '-bios n' to still be used */
sprintf(bios_number, "%d", bios_flags - 1); sprintf(bios_number, "%d", bios_flags - 1);
if (core_stricmp(bios_number, specbios) == 0 || core_stricmp(biosname, specbios) == 0) if (core_stricmp(bios_number, specbios) == 0 || core_stricmp(biosname, specbios) == 0)
device->set_system_bios(bios_flags); device.set_system_bios(bios_flags);
if (defaultname != nullptr && core_stricmp(biosname, defaultname) == 0) if (defaultname != nullptr && core_stricmp(biosname, defaultname) == 0)
default_no = bios_flags; default_no = bios_flags;
bios_count++; bios_count++;
} }
/* if none found, use the default */ /* if none found, use the default */
if (device->system_bios() == 0 && bios_count > 0) if (device.system_bios() == 0 && bios_count > 0)
{ {
/* if we got neither an empty string nor 'default' then warn the user */ /* if we got neither an empty string nor 'default' then warn the user */
if (specbios[0] != 0 && strcmp(specbios, "default") != 0) if (specbios[0] != 0 && strcmp(specbios, "default") != 0)
@ -307,10 +307,10 @@ void rom_load_manager::determine_bios_rom(device_t *device, const char *specbios
} }
/* set to default */ /* set to default */
device->set_system_bios(default_no); device.set_system_bios(default_no);
} }
device->set_default_bios(default_no); device.set_default_bios(default_no);
LOG(("For \"%s\" using System BIOS: %d\n", device->tag(), device->system_bios())); LOG(("For \"%s\" using System BIOS: %d\n", device.tag(), device.system_bios()));
} }
@ -328,11 +328,10 @@ void rom_load_manager::count_roms()
m_romstotalsize = 0; m_romstotalsize = 0;
/* loop over regions, then over files */ /* loop over regions, then over files */
device_iterator deviter(machine().config().root_device()); for (device_t &device : device_iterator(machine().config().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (region = rom_first_region(device); region != nullptr; region = rom_next_region(region))
for (region = rom_first_region(*device); region != nullptr; region = rom_next_region(region))
for (rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) for (rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom))
if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == device->system_bios()) if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == device.system_bios())
{ {
m_romstotal++; m_romstotal++;
m_romstotalsize += rom_file_size(rom); m_romstotalsize += rom_file_size(rom);
@ -1062,9 +1061,8 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_
for (int drv = driver_list::find(*gamedrv); drv != -1; drv = driver_list::clone(drv)) for (int drv = driver_list::find(*gamedrv); drv != -1; drv = driver_list::clone(drv))
{ {
machine_config config(driver_list::driver(drv), options); machine_config config(driver_list::driver(drv), options);
device_iterator deviter(config.root_device()); for (device_t &device : device_iterator(config.root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (region = rom_first_region(device); region != nullptr; region = rom_next_region(region))
for (region = rom_first_region(*device); region != nullptr; region = rom_next_region(region))
if (ROMREGION_ISDISKDATA(region)) if (ROMREGION_ISDISKDATA(region))
for (rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) for (rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom))
@ -1380,12 +1378,12 @@ void rom_load_manager::process_region_list()
/* loop until we hit the end */ /* loop until we hit the end */
device_iterator deviter(machine().root_device()); device_iterator deviter(machine().root_device());
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (device_t &device : deviter)
for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region))
{ {
UINT32 regionlength = ROMREGION_GETLENGTH(region); UINT32 regionlength = ROMREGION_GETLENGTH(region);
regiontag = rom_region_name(*device, region); regiontag = rom_region_name(device, region);
LOG(("Processing region \"%s\" (length=%X)\n", regiontag.c_str(), regionlength)); LOG(("Processing region \"%s\" (length=%X)\n", regiontag.c_str(), regionlength));
/* the first entry must be a region */ /* the first entry must be a region */
@ -1418,25 +1416,25 @@ void rom_load_manager::process_region_list()
#endif #endif
/* now process the entries in the region */ /* now process the entries in the region */
process_rom_entries(device->shortname(), region, region + 1, device, FALSE); process_rom_entries(device.shortname(), region, region + 1, &device, FALSE);
} }
else if (ROMREGION_ISDISKDATA(region)) else if (ROMREGION_ISDISKDATA(region))
process_disk_entries(regiontag.c_str(), region, region + 1, nullptr); process_disk_entries(regiontag.c_str(), region, region + 1, nullptr);
} }
/* now go back and post-process all the regions */ /* now go back and post-process all the regions */
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (device_t &device : deviter)
for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region))
{ {
regiontag = rom_region_name(*device, region); regiontag = rom_region_name(device, region);
region_post_process(regiontag.c_str(), ROMREGION_ISINVERTED(region)); region_post_process(regiontag.c_str(), ROMREGION_ISINVERTED(region));
} }
/* and finally register all per-game parameters */ /* and finally register all per-game parameters */
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (device_t &device : deviter)
for (const rom_entry *param = rom_first_parameter(*device); param != nullptr; param = rom_next_parameter(param)) for (const rom_entry *param = rom_first_parameter(device); param != nullptr; param = rom_next_parameter(param))
{ {
regiontag = rom_parameter_name(*device, param); regiontag = rom_parameter_name(device, param);
machine().parameters().add(regiontag, rom_parameter_value(param)); machine().parameters().add(regiontag, rom_parameter_value(param));
} }
} }
@ -1451,17 +1449,19 @@ rom_load_manager::rom_load_manager(running_machine &machine)
: m_machine(machine) : m_machine(machine)
{ {
/* figure out which BIOS we are using */ /* figure out which BIOS we are using */
device_iterator deviter(machine.config().root_device());
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { for (device_t &device : device_iterator(machine.config().root_device()))
if (device->rom_region()) { {
if (device.rom_region())
{
std::string specbios; std::string specbios;
if (device->owner() == nullptr) { if (device.owner() == nullptr)
specbios.assign(machine.options().bios()); specbios.assign(machine.options().bios());
} else { else
specbios = machine.options().sub_value(device->owner()->tag()+1,"bios"); {
if (specbios.empty()) { specbios = machine.options().sub_value(device.owner()->tag()+1,"bios");
specbios = device->default_bios_tag(); if (specbios.empty())
} specbios = device.default_bios_tag();
} }
determine_bios_rom(device, specbios.c_str()); determine_bios_rom(device, specbios.c_str());
} }

View File

@ -305,7 +305,7 @@ public:
void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region); void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region);
private: private:
void determine_bios_rom(device_t *device, const char *specbios); void determine_bios_rom(device_t &device, const char *specbios);
void count_roms(); void count_roms();
void fill_random(UINT8 *base, UINT32 length); void fill_random(UINT8 *base, UINT32 length);
void handle_missing_file(const rom_entry *romp, std::string tried_file_names, chd_error chderr); void handle_missing_file(const rom_entry *romp, std::string tried_file_names, chd_error chderr);

View File

@ -781,20 +781,19 @@ void device_scheduler::rebuild_execute_list()
device_execute_interface **suspend_tailptr = &suspend_list; device_execute_interface **suspend_tailptr = &suspend_list;
// iterate over all devices // iterate over all devices
execute_interface_iterator iter(machine().root_device()); for (device_execute_interface &exec : execute_interface_iterator(machine().root_device()))
for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next())
{ {
// append to the appropriate list // append to the appropriate list
exec->m_nextexec = nullptr; exec.m_nextexec = nullptr;
if (exec->m_suspend == 0) if (exec.m_suspend == 0)
{ {
*active_tailptr = exec; *active_tailptr = &exec;
active_tailptr = &exec->m_nextexec; active_tailptr = &exec.m_nextexec;
} }
else else
{ {
*suspend_tailptr = exec; *suspend_tailptr = &exec;
suspend_tailptr = &exec->m_nextexec; suspend_tailptr = &exec.m_nextexec;
} }
} }

View File

@ -391,10 +391,9 @@ void software_list_device::release()
software_list_device *software_list_device::find_by_name(const machine_config &config, const char *name) software_list_device *software_list_device::find_by_name(const machine_config &config, const char *name)
{ {
// iterate over each device in the system and find a match // iterate over each device in the system and find a match
software_list_device_iterator deviter(config.root_device()); for (software_list_device &swlistdev : software_list_device_iterator(config.root_device()))
for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) if (strcmp(swlistdev.list_name(), name) == 0)
if (strcmp(swlistdev->list_name(), name) == 0) return &swlistdev;
return swlistdev;
return nullptr; return nullptr;
} }
@ -409,25 +408,25 @@ void software_list_device::display_matches(const machine_config &config, const c
{ {
// check if there is at least one software list // check if there is at least one software list
software_list_device_iterator deviter(config.root_device()); software_list_device_iterator deviter(config.root_device());
if (deviter.first()) if (deviter.first() != nullptr)
osd_printf_error("\n\"%s\" approximately matches the following\n" osd_printf_error("\n\"%s\" approximately matches the following\n"
"supported software items (best match first):\n\n", name); "supported software items (best match first):\n\n", name);
// iterate through lists // iterate through lists
for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) for (software_list_device &swlistdev : deviter)
{ {
// get the top 16 approximate matches for the selected device interface (i.e. only carts for cartslot, etc.) // get the top 16 approximate matches for the selected device interface (i.e. only carts for cartslot, etc.)
software_info *matches[16] = { nullptr }; software_info *matches[16] = { nullptr };
swlistdev->find_approx_matches(name, ARRAY_LENGTH(matches), matches, interface); swlistdev.find_approx_matches(name, ARRAY_LENGTH(matches), matches, interface);
// if we found some, print them // if we found some, print them
if (matches[0] != nullptr) if (matches[0] != nullptr)
{ {
// different output depending on original system or compatible // different output depending on original system or compatible
if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) if (swlistdev.list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
osd_printf_error("* Software list \"%s\" (%s) matches: \n", swlistdev->list_name(), swlistdev->description()); osd_printf_error("* Software list \"%s\" (%s) matches: \n", swlistdev.list_name(), swlistdev.description());
else else
osd_printf_error("* Compatible software list \"%s\" (%s) matches: \n", swlistdev->list_name(), swlistdev->description()); osd_printf_error("* Compatible software list \"%s\" (%s) matches: \n", swlistdev.list_name(), swlistdev.description());
// print them out // print them out
for (auto & matche : matches) for (auto & matche : matches)

View File

@ -899,19 +899,20 @@ void sound_manager::set_attenuation(int attenuation)
bool sound_manager::indexed_mixer_input(int index, mixer_input &info) const bool sound_manager::indexed_mixer_input(int index, mixer_input &info) const
{ {
// scan through the mixers until we find the indexed input // scan through the mixers until we find the indexed input
mixer_interface_iterator iter(machine().root_device()); for (device_mixer_interface &mixer : mixer_interface_iterator(machine().root_device()))
for (info.mixer = iter.first(); info.mixer != nullptr; info.mixer = iter.next())
{ {
if (index < info.mixer->inputs()) if (index < mixer.inputs())
{ {
info.stream = info.mixer->input_to_stream_input(index, info.inputnum); info.mixer = &mixer;
info.stream = mixer.input_to_stream_input(index, info.inputnum);
assert(info.stream != nullptr); assert(info.stream != nullptr);
return true; return true;
} }
index -= info.mixer->inputs(); index -= mixer.inputs();
} }
// didn't locate // didn't locate
info.mixer = nullptr;
return false; return false;
} }
@ -937,9 +938,8 @@ void sound_manager::mute(bool mute, UINT8 reason)
void sound_manager::reset() void sound_manager::reset()
{ {
// reset all the sound chips // reset all the sound chips
sound_interface_iterator iter(machine().root_device()); for (device_sound_interface &sound : sound_interface_iterator(machine().root_device()))
for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) sound.device().reset();
sound->device().reset();
} }
@ -1039,9 +1039,8 @@ void sound_manager::update(void *ptr, int param)
// force all the speaker streams to generate the proper number of samples // force all the speaker streams to generate the proper number of samples
int samples_this_update = 0; int samples_this_update = 0;
speaker_device_iterator iter(machine().root_device()); for (speaker_device &speaker : speaker_device_iterator(machine().root_device()))
for (speaker_device *speaker = iter.first(); speaker != nullptr; speaker = iter.next()) speaker.mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM));
speaker->mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM));
// now downmix the final result // now downmix the final result
UINT32 finalmix_step = machine().video().speed_factor(); UINT32 finalmix_step = machine().video().speed_factor();

View File

@ -158,8 +158,7 @@ ui_menu_cheat::~ui_menu_cheat()
ui_menu_autofire::ui_menu_autofire(running_machine &machine, render_container *container) : ui_menu(machine, container) ui_menu_autofire::ui_menu_autofire(running_machine &machine, render_container *container) : ui_menu(machine, container)
{ {
screen_device_iterator iter(machine.root_device()); const screen_device *screen = machine.first_screen();
const screen_device *screen = iter.first();
if (screen == nullptr) if (screen == nullptr)
{ {

View File

@ -29,15 +29,14 @@ ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container
, m_issoft(false) , m_issoft(false)
{ {
image_interface_iterator iter(machine.root_device()); for (device_image_interface &image : image_interface_iterator(machine.root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
if (image->filename()) if (image.filename())
{ {
m_list = strensure(image->software_list_name()); m_list = strensure(image.software_list_name());
m_short = strensure(image->software_entry()->shortname()); m_short = strensure(image.software_entry()->shortname());
m_long = strensure(image->software_entry()->longname()); m_long = strensure(image.software_entry()->longname());
m_parent = strensure(image->software_entry()->parentname()); m_parent = strensure(image.software_entry()->parentname());
} }
} }

View File

@ -20,21 +20,9 @@
ui_menu_device_config::ui_menu_device_config(running_machine &machine, render_container *container, device_slot_interface *slot, device_slot_option *option) : ui_menu(machine, container) ui_menu_device_config::ui_menu_device_config(running_machine &machine, render_container *container, device_slot_interface *slot, device_slot_option *option) : ui_menu(machine, container)
{ {
std::string tmp_tag;
tmp_tag.assign(slot->device().tag()).append(":").append(option->name());
m_option = option; m_option = option;
m_owner = slot; m_owner = slot;
m_mounted = false; m_mounted = slot->device().subdevice(option->name()) != nullptr;
device_iterator deviter(machine.config().root_device());
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
{
if (strcmp(device->tag(), tmp_tag.c_str()) == 0)
{
m_mounted = true;
break;
}
}
} }
void ui_menu_device_config::populate() void ui_menu_device_config::populate()
@ -59,22 +47,21 @@ void ui_menu_device_config::populate()
{ {
str << "* CPU:\n"; str << "* CPU:\n";
std::unordered_set<std::string> exectags; std::unordered_set<std::string> exectags;
for (device_execute_interface *exec = execiter.first(); exec != nullptr; exec = execiter.next()) for (device_execute_interface &exec : execiter)
{ {
if (!exectags.insert(exec->device().tag()).second) if (!exectags.insert(exec.device().tag()).second)
continue; continue;
// get cpu specific clock that takes internal multiplier/dividers into account // get cpu specific clock that takes internal multiplier/dividers into account
int clock = exec->device().clock(); int clock = exec.device().clock();
// count how many identical CPUs we have // count how many identical CPUs we have
int count = 1; int count = 1;
const char *name = exec->device().name(); const char *name = exec.device().name();
execute_interface_iterator execinneriter(*dev); for (device_execute_interface &scan : execiter)
for (device_execute_interface *scan = execinneriter.first(); scan != nullptr; scan = execinneriter.next())
{ {
if (exec->device().type() == scan->device().type() && strcmp(name, scan->device().name()) == 0 && exec->device().clock() == scan->device().clock()) if (exec.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && exec.device().clock() == scan.device().clock())
if (exectags.insert(scan->device().tag()).second) if (exectags.insert(scan.device().tag()).second)
count++; count++;
} }
@ -98,20 +85,20 @@ void ui_menu_device_config::populate()
if (scriter.count() > 0) if (scriter.count() > 0)
{ {
str << "* Video:\n"; str << "* Video:\n";
for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) for (screen_device &screen : scriter)
{ {
util::stream_format(str, " Screen '%s': ", screen->tag()); util::stream_format(str, " Screen '%s': ", screen.tag());
if (screen->screen_type() == SCREEN_TYPE_VECTOR) if (screen.screen_type() == SCREEN_TYPE_VECTOR)
str << "Vector\n"; str << "Vector\n";
else else
{ {
const rectangle &visarea = screen->visible_area(); const rectangle &visarea = screen.visible_area();
util::stream_format(str, "%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n", util::stream_format(str, "%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
visarea.width(), visarea.height(), visarea.width(), visarea.height(),
(machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H", (machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds())); ATTOSECONDS_TO_HZ(screen.frame_period().attoseconds()));
} }
} }
} }
@ -122,18 +109,17 @@ void ui_menu_device_config::populate()
{ {
str << "* Sound:\n"; str << "* Sound:\n";
std::unordered_set<std::string> soundtags; std::unordered_set<std::string> soundtags;
for (device_sound_interface *sound = snditer.first(); sound != nullptr; sound = snditer.next()) for (device_sound_interface &sound : snditer)
{ {
if (!soundtags.insert(sound->device().tag()).second) if (!soundtags.insert(sound.device().tag()).second)
continue; continue;
// count how many identical sound chips we have // count how many identical sound chips we have
int count = 1; int count = 1;
sound_interface_iterator sndinneriter(*dev); for (device_sound_interface &scan : snditer)
for (device_sound_interface *scan = sndinneriter.first(); scan != nullptr; scan = sndinneriter.next())
{ {
if (sound->device().type() == scan->device().type() && sound->device().clock() == scan->device().clock()) if (sound.device().type() == scan.device().type() && sound.device().clock() == scan.device().clock())
if (soundtags.insert(scan->device().tag()).second) if (soundtags.insert(scan.device().tag()).second)
count++; count++;
} }
// if more than one, prepend a #x in front of the CPU name // if more than one, prepend a #x in front of the CPU name
@ -141,10 +127,10 @@ void ui_menu_device_config::populate()
util::stream_format(str," %d" UTF8_MULTIPLY, count); util::stream_format(str," %d" UTF8_MULTIPLY, count);
else else
str << " "; str << " ";
str << sound->device().name(); str << sound.device().name();
// display clock in kHz or MHz // display clock in kHz or MHz
int clock = sound->device().clock(); int clock = sound.device().clock();
if (clock >= 1000000) if (clock >= 1000000)
util::stream_format(str," %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000); util::stream_format(str," %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
else if (clock != 0) else if (clock != 0)
@ -184,9 +170,8 @@ void ui_menu_device_config::populate()
std::string errors; std::string errors;
std::ostringstream dips_opt, confs_opt; std::ostringstream dips_opt, confs_opt;
ioport_list portlist; ioport_list portlist;
device_iterator iptiter(*dev); for (device_t &iptdev : device_iterator(*dev))
for (device_t *iptdev = iptiter.first(); iptdev != nullptr; iptdev = iptiter.next()) portlist.append(iptdev, errors);
portlist.append(*iptdev, errors);
// check if the device adds inputs to the system // check if the device adds inputs to the system
for (ioport_port &port : portlist) for (ioport_port &port : portlist)
@ -263,16 +248,16 @@ void ui_menu_device_config::populate()
if (imgiter.count() > 0) if (imgiter.count() > 0)
{ {
str << "* Media Options:\n"; str << "* Media Options:\n";
for (const device_image_interface *imagedev = imgiter.first(); imagedev != nullptr; imagedev = imgiter.next()) for (const device_image_interface &imagedev : imgiter)
util::stream_format(str, " %s [tag: %s]\n", imagedev->image_type_name(), imagedev->device().tag()); util::stream_format(str, " %s [tag: %s]\n", imagedev.image_type_name(), imagedev.device().tag());
} }
slot_interface_iterator slotiter(*dev); slot_interface_iterator slotiter(*dev);
if (slotiter.count() > 0) if (slotiter.count() > 0)
{ {
str << "* Slot Options:\n"; str << "* Slot Options:\n";
for (const device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next()) for (const device_slot_interface &slot : slotiter)
util::stream_format(str, " %s [default: %s]\n", slot->device().tag(), slot->default_option() ? slot->default_option() : "----"); util::stream_format(str, " %s [default: %s]\n", slot.device().tag(), slot.default_option() ? slot.default_option() : "----");
} }
if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + bios + dips + confs if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + bios + dips + confs

View File

@ -113,28 +113,26 @@ void ui_menu_file_manager::populate()
} }
// cycle through all devices for this system // cycle through all devices for this system
device_iterator iter(machine().root_device());
std::unordered_set<std::string> devtags; std::unordered_set<std::string> devtags;
for (device_t *dev = iter.first(); dev != nullptr; dev = iter.next()) for (device_t &dev : device_iterator(machine().root_device()))
{ {
bool tag_appended = false; bool tag_appended = false;
if (!devtags.insert(dev->tag()).second) if (!devtags.insert(dev.tag()).second)
continue; continue;
// check whether it owns an image interface // check whether it owns an image interface
image_interface_iterator subiter(*dev); image_interface_iterator subiter(dev);
if (subiter.count() > 0) if (subiter.first() != nullptr)
{ {
// if so, cycle through all its image interfaces // if so, cycle through all its image interfaces
image_interface_iterator subiterator(*dev); for (device_image_interface &scan : subiter)
for (device_image_interface *scan = subiterator.first(); scan != nullptr; scan = subiterator.next())
{ {
if (!scan->user_loadable()) if (!scan.user_loadable())
continue; continue;
// if it is a children device, and not something further down the device tree, we want it in the menu! // if it is a children device, and not something further down the device tree, we want it in the menu!
if (strcmp(scan->device().owner()->tag(), dev->tag()) == 0) if (strcmp(scan.device().owner()->tag(), dev.tag()) == 0)
if (devtags.insert(scan->device().tag()).second) if (devtags.insert(scan.device().tag()).second)
{ {
// check whether we already had some devices with the same owner: if not, output the owner tag! // check whether we already had some devices with the same owner: if not, output the owner tag!
if (!tag_appended) if (!tag_appended)
@ -143,12 +141,12 @@ void ui_menu_file_manager::populate()
first_entry = false; first_entry = false;
else else
item_append(ui_menu_item_type::SEPARATOR); item_append(ui_menu_item_type::SEPARATOR);
item_append(string_format("[root%s]", dev->tag()).c_str(), nullptr, 0, nullptr); item_append(string_format("[root%s]", dev.tag()).c_str(), nullptr, 0, nullptr);
tag_appended = true; tag_appended = true;
} }
// finally, append the image interface to the menu // finally, append the image interface to the menu
fill_image_line(scan, tmp_inst, tmp_name); fill_image_line(&scan, tmp_inst, tmp_name);
item_append(tmp_inst.c_str(), tmp_name.c_str(), 0, (void *)scan); item_append(tmp_inst.c_str(), tmp_name.c_str(), 0, (void *)&scan);
} }
} }
} }

View File

@ -36,14 +36,10 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach
{ {
image = _image; image = _image;
sld = nullptr; if (image->software_list_name())
if (image->software_list_name()) { sld = software_list_device::find_by_name(machine.config(), image->software_list_name());
software_list_device_iterator iter(machine.config().root_device()); else
for (software_list_device *swlist = iter.first(); swlist != nullptr; swlist = iter.next()) sld = nullptr;
{
if (strcmp(swlist->list_name(),image->software_list_name())==0) sld = swlist;
}
}
swi = image->software_entry(); swi = image->software_entry();
swp = image->part_entry(); swp = image->part_entry();

View File

@ -58,9 +58,8 @@ void ui_menu_image_info::populate()
item_append(machine().system().description, nullptr, MENU_FLAG_DISABLE, nullptr); item_append(machine().system().description, nullptr, MENU_FLAG_DISABLE, nullptr);
item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); item_append("", nullptr, MENU_FLAG_DISABLE, nullptr);
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) image_info(&image);
image_info(image);
} }
void ui_menu_image_info::handle() void ui_menu_image_info::handle()

View File

@ -26,14 +26,13 @@ void ui_menu_pty_info::populate()
item_append(_("Pseudo terminals"), nullptr, MENU_FLAG_DISABLE, nullptr); item_append(_("Pseudo terminals"), nullptr, MENU_FLAG_DISABLE, nullptr);
item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); item_append("", nullptr, MENU_FLAG_DISABLE, nullptr);
pty_interface_iterator iter(machine().root_device()); for (device_pty_interface &pty : pty_interface_iterator(machine().root_device()))
for (device_pty_interface *pty = iter.first(); pty != nullptr; pty = iter.next()) { {
const char *port_name = pty->device().owner()->tag() + 1; const char *port_name = pty.device().owner()->tag() + 1;
if (pty->is_open()) { if (pty.is_open())
item_append(port_name , pty->slave_name() , MENU_FLAG_DISABLE , nullptr); item_append(port_name, pty.slave_name(), MENU_FLAG_DISABLE, nullptr);
} else { else
item_append(port_name , _("[failed]") , MENU_FLAG_DISABLE , nullptr); item_append(port_name, _("[failed]"), MENU_FLAG_DISABLE, nullptr);
}
item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); item_append("", nullptr, MENU_FLAG_DISABLE, nullptr);
} }
} }

View File

@ -207,30 +207,29 @@ void favorite_manager::add_favorite_game()
} }
bool software_avail = false; bool software_avail = false;
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
if (image->exists() && image->software_entry()) if (image.exists() && image.software_entry())
{ {
const software_info *swinfo = image->software_entry(); const software_info *swinfo = image.software_entry();
const software_part *part = image->part_entry(); const software_part *part = image.part_entry();
ui_software_info tmpmatches; ui_software_info tmpmatches;
tmpmatches.shortname = strensure(swinfo->shortname()); tmpmatches.shortname = strensure(swinfo->shortname());
tmpmatches.longname = strensure(image->longname()); tmpmatches.longname = strensure(image.longname());
tmpmatches.parentname = strensure(swinfo->parentname()); tmpmatches.parentname = strensure(swinfo->parentname());
tmpmatches.year = strensure(image->year()); tmpmatches.year = strensure(image.year());
tmpmatches.publisher = strensure(image->manufacturer()); tmpmatches.publisher = strensure(image.manufacturer());
tmpmatches.supported = image->supported(); tmpmatches.supported = image.supported();
tmpmatches.part = strensure(part->name()); tmpmatches.part = strensure(part->name());
tmpmatches.driver = &machine().system(); tmpmatches.driver = &machine().system();
tmpmatches.listname = strensure(image->software_list_name()); tmpmatches.listname = strensure(image.software_list_name());
tmpmatches.interface = strensure(part->interface()); tmpmatches.interface = strensure(part->interface());
tmpmatches.instance = strensure(image->instance_name()); tmpmatches.instance = strensure(image.instance_name());
tmpmatches.startempty = 0; tmpmatches.startempty = 0;
tmpmatches.parentlongname.clear(); tmpmatches.parentlongname.clear();
if (swinfo->parentname()) if (swinfo->parentname())
{ {
software_list_device *swlist = software_list_device::find_by_name(machine().config(), image->software_list_name()); software_list_device *swlist = software_list_device::find_by_name(machine().config(), image.software_list_name());
for (software_info &c_swinfo : swlist->get_info()) for (software_info &c_swinfo : swlist->get_info())
{ {
std::string c_parent(c_swinfo.parentname()); std::string c_parent(c_swinfo.parentname());
@ -247,7 +246,7 @@ void favorite_manager::add_favorite_game()
if (!strcmp(flist.name(), "usage")) if (!strcmp(flist.name(), "usage"))
tmpmatches.usage = flist.value(); tmpmatches.usage = flist.value();
tmpmatches.devicetype = strensure(image->image_type_name()); tmpmatches.devicetype = strensure(image.image_type_name());
tmpmatches.available = true; tmpmatches.available = true;
software_avail = true; software_avail = true;
m_list.push_back(tmpmatches); m_list.push_back(tmpmatches);
@ -288,18 +287,17 @@ bool favorite_manager::isgame_favorite()
if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0) if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0)
return isgame_favorite(&machine().system()); return isgame_favorite(&machine().system());
image_interface_iterator iter(machine().root_device());
bool image_loaded = false; bool image_loaded = false;
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) for (device_image_interface &image : image_interface_iterator(machine().root_device()))
{ {
const software_info *swinfo = image->software_entry(); const software_info *swinfo = image.software_entry();
if (image->exists() && swinfo != nullptr) if (image.exists() && swinfo != nullptr)
{ {
image_loaded = true; image_loaded = true;
for (size_t current = 0; current < m_list.size(); current++) for (size_t current = 0; current < m_list.size(); current++)
if (m_list[current].shortname == swinfo->shortname() && if (m_list[current].shortname == swinfo->shortname() &&
m_list[current].listname == image->software_list_name()) m_list[current].listname == image.software_list_name())
{ {
m_current = current; m_current = current;
return true; return true;

View File

@ -71,46 +71,40 @@ void ui_menu_main::populate()
/* add game info menu */ /* add game info menu */
item_append(_("Machine Information"), nullptr, 0, (void *)GAME_INFO); item_append(_("Machine Information"), nullptr, 0, (void *)GAME_INFO);
image_interface_iterator imgiter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = imgiter.first(); image != nullptr; image = imgiter.next()) {
{ if (image.user_loadable())
if (image->user_loadable()) {
{ /* add image info menu */
/* add image info menu */ item_append(_("Image Information"), nullptr, 0, (void *)IMAGE_MENU_IMAGE_INFO);
item_append(_("Image Information"), nullptr, 0, (void *)IMAGE_MENU_IMAGE_INFO);
/* add file manager menu */
item_append(_("File Manager"), nullptr, 0, (void *)IMAGE_MENU_FILE_MANAGER);
break;
}
}
/* add tape control menu */ /* add file manager menu */
cassette_device_iterator cassiter(machine().root_device()); item_append(_("File Manager"), nullptr, 0, (void *)IMAGE_MENU_FILE_MANAGER);
if (cassiter.first() != nullptr)
item_append(_("Tape Control"), nullptr, 0, (void *)TAPE_CONTROL);
pty_interface_iterator ptyiter(machine().root_device()); break;
if (ptyiter.first() != nullptr) }
item_append(_("Pseudo terminals"), nullptr, 0, (void *)PTY_INFO); }
if (machine().ioport().has_bioses()) /* add tape control menu */
if (cassette_device_iterator(machine().root_device()).first() != nullptr)
item_append(_("Tape Control"), nullptr, 0, (void *)TAPE_CONTROL);
if (pty_interface_iterator(machine().root_device()).first() != nullptr)
item_append(_("Pseudo terminals"), nullptr, 0, (void *)PTY_INFO);
if (machine().ioport().has_bioses())
item_append(_("Bios Selection"), nullptr, 0, (void *)BIOS_SELECTION); item_append(_("Bios Selection"), nullptr, 0, (void *)BIOS_SELECTION);
/* add slot info menu */ /* add slot info menu */
slot_interface_iterator slotiter(machine().root_device()); if (slot_interface_iterator(machine().root_device()).first() != nullptr)
if (slotiter.first() != nullptr)
item_append(_("Slot Devices"), nullptr, 0, (void *)SLOT_DEVICES); item_append(_("Slot Devices"), nullptr, 0, (void *)SLOT_DEVICES);
/* add Barcode reader menu */ /* add Barcode reader menu */
barcode_reader_device_iterator bcriter(machine().root_device()); if (barcode_reader_device_iterator(machine().root_device()).first() != nullptr)
if (bcriter.first() != nullptr)
item_append(_("Barcode Reader"), nullptr, 0, (void *)BARCODE_READ); item_append(_("Barcode Reader"), nullptr, 0, (void *)BARCODE_READ);
/* add network info menu */ /* add network info menu */
network_interface_iterator netiter(machine().root_device()); if (network_interface_iterator(machine().root_device()).first() != nullptr)
if (netiter.first() != nullptr)
item_append(_("Network Devices"), nullptr, 0, (void*)NETWORK_DEVICES); item_append(_("Network Devices"), nullptr, 0, (void*)NETWORK_DEVICES);
/* add keyboard mode menu */ /* add keyboard mode menu */

View File

@ -72,19 +72,19 @@ ui_menu_bios_selection::ui_menu_bios_selection(running_machine &machine, render_
void ui_menu_bios_selection::populate() void ui_menu_bios_selection::populate()
{ {
/* cycle through all devices for this system */ /* cycle through all devices for this system */
device_iterator deviter(machine().root_device()); for (device_t &device : device_iterator(machine().root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
{ {
if (device->rom_region()) { if (device.rom_region())
{
const char *val = "default"; const char *val = "default";
for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) for (const rom_entry *rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
{ {
if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom)==device->system_bios()) if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom) == device.system_bios())
{ {
val = ROM_GETHASHDATA(rom); val = ROM_GETHASHDATA(rom);
} }
} }
item_append(strcmp(device->tag(),":")==0 ? "driver" : device->tag()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)device); item_append(device.owner() == nullptr ? "driver" : device.tag()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)&device);
} }
} }
@ -154,10 +154,9 @@ ui_menu_network_devices::~ui_menu_network_devices()
void ui_menu_network_devices::populate() void ui_menu_network_devices::populate()
{ {
/* cycle through all devices for this system */ /* cycle through all devices for this system */
network_interface_iterator iter(machine().root_device()); for (device_network_interface &network : network_interface_iterator(machine().root_device()))
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())
{ {
int curr = network->get_interface(); int curr = network.get_interface();
const char *title = nullptr; const char *title = nullptr;
const osd_netdev::entry_t *entry = netdev_first(); const osd_netdev::entry_t *entry = netdev_first();
while(entry) { while(entry) {
@ -168,7 +167,7 @@ void ui_menu_network_devices::populate()
entry = entry->m_next; entry = entry->m_next;
} }
item_append(network->device().tag(), (title) ? title : "------", MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)network); item_append(network.device().tag(), (title) ? title : "------", MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)network);
} }
} }

View File

@ -1048,9 +1048,8 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event)
{ {
if ((driver->flags & MACHINE_TYPE_ARCADE) == 0) if ((driver->flags & MACHINE_TYPE_ARCADE) == 0)
{ {
software_list_device_iterator iter(enumerator.config().root_device()); for (software_list_device &swlistdev : software_list_device_iterator(enumerator.config().root_device()))
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (!swlistdev.get_info().empty())
if (!swlistdev->get_info().empty())
{ {
ui_menu::stack_push(global_alloc_clear<ui_menu_select_software>(machine(), container, driver)); ui_menu::stack_push(global_alloc_clear<ui_menu_select_software>(machine(), container, driver));
return; return;

View File

@ -430,9 +430,8 @@ void ui_menu_select_software::populate()
int old_software = -1; int old_software = -1;
machine_config config(*m_driver, machine().options()); machine_config config(*m_driver, machine().options());
image_interface_iterator iter(config.root_device()); for (device_image_interface &image : image_interface_iterator(config.root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) if (image.filename() == nullptr && image.must_be_loaded())
if (image->filename() == nullptr && image->must_be_loaded())
{ {
m_has_empty_start = false; m_has_empty_start = false;
break; break;
@ -528,32 +527,30 @@ void ui_menu_select_software::build_software_list()
m_swinfo.emplace_back(m_driver->name, m_driver->description, "", "", "", 0, "", m_driver, "", "", "", 1, "", "", "", true); m_swinfo.emplace_back(m_driver->name, m_driver->description, "", "", "", 0, "", m_driver, "", "", "", 1, "", "", "", true);
machine_config config(*m_driver, machine().options()); machine_config config(*m_driver, machine().options());
software_list_device_iterator deviter(config.root_device());
// iterate thru all software lists // iterate thru all software lists
for (software_list_device *swlist = deviter.first(); swlist != nullptr; swlist = deviter.next()) for (software_list_device &swlist : software_list_device_iterator(config.root_device()))
{ {
m_filter.swlist.name.push_back(swlist->list_name()); m_filter.swlist.name.push_back(swlist.list_name());
m_filter.swlist.description.push_back(swlist->description()); m_filter.swlist.description.push_back(swlist.description());
for (software_info &swinfo : swlist->get_info()) for (software_info &swinfo : swlist.get_info())
{ {
software_part *part = swinfo.first_part(); software_part *part = swinfo.first_part();
if (part->is_compatible(*swlist)) if (part->is_compatible(swlist))
{ {
const char *instance_name = nullptr; const char *instance_name = nullptr;
const char *type_name = nullptr; const char *type_name = nullptr;
ui_software_info tmpmatches; ui_software_info tmpmatches;
image_interface_iterator imgiter(config.root_device()); for (device_image_interface &image : image_interface_iterator(config.root_device()))
for (device_image_interface *image = imgiter.first(); image != nullptr; image = imgiter.next())
{ {
const char *interface = image->image_interface(); const char *interface = image.image_interface();
if (interface != nullptr && part->matches_interface(interface)) if (interface != nullptr && part->matches_interface(interface))
{ {
instance_name = image->instance_name(); instance_name = image.instance_name();
if (instance_name != nullptr) if (instance_name != nullptr)
tmpmatches.instance = image->instance_name(); tmpmatches.instance = image.instance_name();
type_name = image->image_type_name(); type_name = image.image_type_name();
if (type_name != nullptr) if (type_name != nullptr)
tmpmatches.devicetype = type_name; tmpmatches.devicetype = type_name;
break; break;
@ -571,7 +568,7 @@ void ui_menu_select_software::build_software_list()
tmpmatches.supported = swinfo.supported(); tmpmatches.supported = swinfo.supported();
tmpmatches.part = strensure(part->name()); tmpmatches.part = strensure(part->name());
tmpmatches.driver = m_driver; tmpmatches.driver = m_driver;
tmpmatches.listname = strensure(swlist->list_name()); tmpmatches.listname = strensure(swlist.list_name());
tmpmatches.interface = strensure(part->interface()); tmpmatches.interface = strensure(part->interface());
tmpmatches.startempty = 0; tmpmatches.startempty = 0;
tmpmatches.parentlongname.clear(); tmpmatches.parentlongname.clear();

View File

@ -19,33 +19,33 @@
/*------------------------------------------------- /*-------------------------------------------------
ui_slot_get_current_option - returns ui_slot_get_current_option - returns
-------------------------------------------------*/ -------------------------------------------------*/
device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_interface *slot) device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_interface &slot)
{ {
std::string current; std::string current;
if (slot->fixed()) if (slot.fixed())
{ {
if (slot->default_option() == nullptr) return nullptr; if (slot.default_option() == nullptr) return nullptr;
current.assign(slot->default_option()); current.assign(slot.default_option());
} }
else else
{ {
current = machine().options().main_value(slot->device().tag() + 1); current = machine().options().main_value(slot.device().tag() + 1);
} }
return slot->option(current.c_str()); return slot.option(current.c_str());
} }
/*------------------------------------------------- /*-------------------------------------------------
ui_slot_get_current_index - returns ui_slot_get_current_index - returns
-------------------------------------------------*/ -------------------------------------------------*/
int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot) int ui_menu_slot_devices::slot_get_current_index(device_slot_interface &slot)
{ {
const device_slot_option *current = slot_get_current_option(slot); const device_slot_option *current = slot_get_current_option(slot);
if (current != nullptr) if (current != nullptr)
{ {
int val = 0; int val = 0;
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
{ {
if (&option == current) if (&option == current)
return val; return val;
@ -61,10 +61,10 @@ int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot)
/*------------------------------------------------- /*-------------------------------------------------
ui_slot_get_length - returns ui_slot_get_length - returns
-------------------------------------------------*/ -------------------------------------------------*/
int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot) int ui_menu_slot_devices::slot_get_length(device_slot_interface &slot)
{ {
int val = 0; int val = 0;
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
if (option.selectable()) if (option.selectable())
val++; val++;
@ -74,7 +74,7 @@ int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot)
/*------------------------------------------------- /*-------------------------------------------------
ui_slot_get_next - returns ui_slot_get_next - returns
-------------------------------------------------*/ -------------------------------------------------*/
const char *ui_menu_slot_devices::slot_get_next(device_slot_interface *slot) const char *ui_menu_slot_devices::slot_get_next(device_slot_interface &slot)
{ {
int idx = slot_get_current_index(slot); int idx = slot_get_current_index(slot);
if (idx < 0) if (idx < 0)
@ -91,7 +91,7 @@ const char *ui_menu_slot_devices::slot_get_next(device_slot_interface *slot)
/*------------------------------------------------- /*-------------------------------------------------
ui_slot_get_prev - returns ui_slot_get_prev - returns
-------------------------------------------------*/ -------------------------------------------------*/
const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface *slot) const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface &slot)
{ {
int idx = slot_get_current_index(slot); int idx = slot_get_current_index(slot);
if (idx < 0) if (idx < 0)
@ -108,12 +108,12 @@ const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface *slot)
/*------------------------------------------------- /*-------------------------------------------------
ui_slot_get_option - returns ui_slot_get_option - returns
-------------------------------------------------*/ -------------------------------------------------*/
const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, int index) const char *ui_menu_slot_devices::slot_get_option(device_slot_interface &slot, int index)
{ {
if (index >= 0) if (index >= 0)
{ {
int val = 0; int val = 0;
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
{ {
if (val == index) if (val == index)
return option.name(); return option.name();
@ -132,10 +132,10 @@ const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, i
whether the natural keyboard is active whether the natural keyboard is active
-------------------------------------------------*/ -------------------------------------------------*/
void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const char *val) void ui_menu_slot_devices::set_slot_device(device_slot_interface &slot, const char *val)
{ {
std::string error; std::string error;
machine().options().set_value(slot->device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error); machine().options().set_value(slot.device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error);
assert(error.empty()); assert(error.empty());
} }
@ -151,8 +151,7 @@ ui_menu_slot_devices::ui_menu_slot_devices(running_machine &machine, render_cont
void ui_menu_slot_devices::populate() void ui_menu_slot_devices::populate()
{ {
/* cycle through all devices for this system */ /* cycle through all devices for this system */
slot_interface_iterator iter(machine().root_device()); for (device_slot_interface &slot : slot_interface_iterator(machine().root_device()))
for (device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next())
{ {
/* record the menu item */ /* record the menu item */
const device_slot_option *option = slot_get_current_option(slot); const device_slot_option *option = slot_get_current_option(slot);
@ -162,11 +161,11 @@ void ui_menu_slot_devices::populate()
else else
{ {
opt_name.assign(option->name()); opt_name.assign(option->name());
if (slot->fixed() || slot_get_length(slot) == 0) if (slot.fixed() || slot_get_length(slot) == 0)
opt_name.append(_(" [internal]")); opt_name.append(_(" [internal]"));
} }
item_append(slot->device().tag() + 1, opt_name.c_str(), (slot->fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)slot); item_append(slot.device().tag() + 1, opt_name.c_str(), (slot.fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)&slot);
} }
item_append(ui_menu_item_type::SEPARATOR); item_append(ui_menu_item_type::SEPARATOR);
item_append(_("Reset"), nullptr, 0, (void *)1); item_append(_("Reset"), nullptr, 0, (void *)1);
@ -195,14 +194,14 @@ void ui_menu_slot_devices::handle()
else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
{ {
device_slot_interface *slot = (device_slot_interface *)menu_event->itemref; device_slot_interface *slot = (device_slot_interface *)menu_event->itemref;
const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(slot) : slot_get_next(slot); const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(*slot) : slot_get_next(*slot);
set_slot_device(slot, val); set_slot_device(*slot, val);
reset(UI_MENU_RESET_REMEMBER_REF); reset(UI_MENU_RESET_REMEMBER_REF);
} }
else if (menu_event->iptkey == IPT_UI_SELECT) else if (menu_event->iptkey == IPT_UI_SELECT)
{ {
device_slot_interface *slot = (device_slot_interface *)menu_event->itemref; device_slot_interface *slot = (device_slot_interface *)menu_event->itemref;
device_slot_option *option = slot_get_current_option(slot); device_slot_option *option = slot_get_current_option(*slot);
if (option) if (option)
ui_menu::stack_push(global_alloc_clear<ui_menu_device_config>(machine(), container, slot, option)); ui_menu::stack_push(global_alloc_clear<ui_menu_device_config>(machine(), container, slot, option));
} }

View File

@ -23,13 +23,13 @@ public:
virtual void handle() override; virtual void handle() override;
private: private:
device_slot_option *slot_get_current_option(device_slot_interface *slot); device_slot_option *slot_get_current_option(device_slot_interface &slot);
int slot_get_current_index(device_slot_interface *slot); int slot_get_current_index(device_slot_interface &slot);
int slot_get_length(device_slot_interface *slot); int slot_get_length(device_slot_interface &slot);
const char *slot_get_next(device_slot_interface *slot); const char *slot_get_next(device_slot_interface &slot);
const char *slot_get_prev(device_slot_interface *slot); const char *slot_get_prev(device_slot_interface &slot);
const char *slot_get_option(device_slot_interface *slot, int index); const char *slot_get_option(device_slot_interface &slot, int index);
void set_slot_device(device_slot_interface *slot, const char *val); void set_slot_device(device_slot_interface &slot, const char *val);
}; };
#endif /* __UI_SLOTOPT_H__ */ #endif /* __UI_SLOTOPT_H__ */

View File

@ -409,32 +409,32 @@ void ui_menu_software::populate()
// Add original software lists for this system // Add original software lists for this system
software_list_device_iterator iter(machine().config().root_device()); software_list_device_iterator iter(machine().config().root_device());
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) for (software_list_device &swlistdev : iter)
if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) if (swlistdev.list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
if (!swlistdev->get_info().empty() && m_interface != nullptr) if (!swlistdev.get_info().empty() && m_interface != nullptr)
{ {
bool found = false; bool found = false;
for (const software_info &swinfo : swlistdev->get_info()) for (const software_info &swinfo : swlistdev.get_info())
if (swinfo.first_part()->matches_interface(m_interface)) if (swinfo.first_part()->matches_interface(m_interface))
found = true; found = true;
if (found) if (found)
item_append(swlistdev->description(), nullptr, 0, (void *)swlistdev); item_append(swlistdev.description(), nullptr, 0, (void *)&swlistdev);
} }
// add compatible software lists for this system // add compatible software lists for this system
for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) for (software_list_device &swlistdev : iter)
if (swlistdev->list_type() == SOFTWARE_LIST_COMPATIBLE_SYSTEM) if (swlistdev.list_type() == SOFTWARE_LIST_COMPATIBLE_SYSTEM)
if (!swlistdev->get_info().empty() && m_interface != nullptr) if (!swlistdev.get_info().empty() && m_interface != nullptr)
{ {
bool found = false; bool found = false;
for (const software_info &swinfo : swlistdev->get_info()) for (const software_info &swinfo : swlistdev.get_info())
if (swinfo.first_part()->matches_interface(m_interface)) if (swinfo.first_part()->matches_interface(m_interface))
found = true; found = true;
if (found) if (found)
{ {
if (!have_compatible) if (!have_compatible)
item_append(_("[compatible lists]"), nullptr, MENU_FLAG_DISABLE, nullptr); item_append(_("[compatible lists]"), nullptr, MENU_FLAG_DISABLE, nullptr);
item_append(swlistdev->description(), nullptr, 0, (void *)swlistdev); item_append(swlistdev.description(), nullptr, 0, (void *)&swlistdev);
} }
have_compatible = true; have_compatible = true;
} }

View File

@ -1188,21 +1188,20 @@ std::string &ui_manager::game_info_astring(std::string &str)
// loop over all CPUs // loop over all CPUs
execute_interface_iterator execiter(machine().root_device()); execute_interface_iterator execiter(machine().root_device());
std::unordered_set<std::string> exectags; std::unordered_set<std::string> exectags;
for (device_execute_interface *exec = execiter.first(); exec != nullptr; exec = execiter.next()) for (device_execute_interface &exec : execiter)
{ {
if (!exectags.insert(exec->device().tag()).second) if (!exectags.insert(exec.device().tag()).second)
continue; continue;
// get cpu specific clock that takes internal multiplier/dividers into account // get cpu specific clock that takes internal multiplier/dividers into account
int clock = exec->device().clock(); int clock = exec.device().clock();
// count how many identical CPUs we have // count how many identical CPUs we have
int count = 1; int count = 1;
const char *name = exec->device().name(); const char *name = exec.device().name();
execute_interface_iterator execinneriter(machine().root_device()); for (device_execute_interface &scan : execiter)
for (device_execute_interface *scan = execinneriter.first(); scan != nullptr; scan = execinneriter.next())
{ {
if (exec->device().type() == scan->device().type() && strcmp(name, scan->device().name()) == 0 && exec->device().clock() == scan->device().clock()) if (exec.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && exec.device().clock() == scan.device().clock())
if (exectags.insert(scan->device().tag()).second) if (exectags.insert(scan.device().tag()).second)
count++; count++;
} }
@ -1222,9 +1221,9 @@ std::string &ui_manager::game_info_astring(std::string &str)
sound_interface_iterator snditer(machine().root_device()); sound_interface_iterator snditer(machine().root_device());
std::unordered_set<std::string> soundtags; std::unordered_set<std::string> soundtags;
bool found_sound = false; bool found_sound = false;
for (device_sound_interface *sound = snditer.first(); sound != nullptr; sound = snditer.next()) for (device_sound_interface &sound : snditer)
{ {
if (!soundtags.insert(sound->device().tag()).second) if (!soundtags.insert(sound.device().tag()).second)
continue; continue;
// append the Sound: string // append the Sound: string
@ -1234,23 +1233,22 @@ std::string &ui_manager::game_info_astring(std::string &str)
// count how many identical sound chips we have // count how many identical sound chips we have
int count = 1; int count = 1;
sound_interface_iterator sndinneriter(machine().root_device()); for (device_sound_interface &scan : snditer)
for (device_sound_interface *scan = sndinneriter.first(); scan != nullptr; scan = sndinneriter.next())
{ {
if (sound->device().type() == scan->device().type() && sound->device().clock() == scan->device().clock()) if (sound.device().type() == scan.device().type() && sound.device().clock() == scan.device().clock())
if (soundtags.insert(scan->device().tag()).second) if (soundtags.insert(scan.device().tag()).second)
count++; count++;
} }
// if more than one, prepend a #x in front of the CPU name // if more than one, prepend a #x in front of the CPU name
// display clock in kHz or MHz // display clock in kHz or MHz
int clock = sound->device().clock(); int clock = sound.device().clock();
util::stream_format(buf, util::stream_format(buf,
(count > 1) (count > 1)
? ((clock != 0) ? "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s\n" : "%1$d" UTF8_MULTIPLY "%2$s\n") ? ((clock != 0) ? "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s\n" : "%1$d" UTF8_MULTIPLY "%2$s\n")
: ((clock != 0) ? "%2$s %3$d.%4$0*5$d%6$s\n" : "%2$s\n"), : ((clock != 0) ? "%2$s %3$d.%4$0*5$d%6$s\n" : "%2$s\n"),
count, count,
sound->device().name(), sound.device().name(),
(clock >= 1000000) ? (clock / 1000000) : (clock / 1000), (clock >= 1000000) ? (clock / 1000000) : (clock / 1000),
(clock >= 1000000) ? (clock % 1000000) : (clock % 1000), (clock >= 1000000) ? (clock % 1000000) : (clock % 1000),
(clock >= 1000000) ? 6 : 3, (clock >= 1000000) ? 6 : 3,
@ -1265,23 +1263,23 @@ std::string &ui_manager::game_info_astring(std::string &str)
buf << _("None\n"); buf << _("None\n");
else else
{ {
for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) for (screen_device &screen : scriter)
{ {
std::string detail; std::string detail;
if (screen->screen_type() == SCREEN_TYPE_VECTOR) if (screen.screen_type() == SCREEN_TYPE_VECTOR)
detail = _("Vector"); detail = _("Vector");
else else
{ {
const rectangle &visarea = screen->visible_area(); const rectangle &visarea = screen.visible_area();
detail = string_format("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz", detail = string_format("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz",
visarea.width(), visarea.height(), visarea.width(), visarea.height(),
(machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H", (machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds())); ATTOSECONDS_TO_HZ(screen.frame_period().attoseconds()));
} }
util::stream_format(buf, util::stream_format(buf,
(scrcount > 1) ? _("%1$s: %2$s\n") : _("%2$s\n"), (scrcount > 1) ? _("%1$s: %2$s\n") : _("%2$s\n"),
slider_get_screen_desc(*screen), detail); slider_get_screen_desc(screen), detail);
} }
} }
@ -1467,11 +1465,8 @@ void ui_manager::image_handler_ingame()
{ {
// run display routine for devices // run display routine for devices
if (machine().phase() == MACHINE_PHASE_RUNNING) if (machine().phase() == MACHINE_PHASE_RUNNING)
{ for (device_image_interface &image : image_interface_iterator(machine().root_device()))
image_interface_iterator iter(machine().root_device()); image.call_display();
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
image->call_display();
}
} }
@ -1605,19 +1600,17 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co
// handle a tape control key // handle a tape control key
if (machine.ui_input().pressed(IPT_UI_TAPE_START)) if (machine.ui_input().pressed(IPT_UI_TAPE_START))
{ {
cassette_device_iterator cassiter(machine.root_device()); for (cassette_image_device &cass : cassette_device_iterator(machine.root_device()))
for (cassette_image_device *cass = cassiter.first(); cass != nullptr; cass = cassiter.next())
{ {
cass->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE); cass.change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
return 0; return 0;
} }
} }
if (machine.ui_input().pressed(IPT_UI_TAPE_STOP)) if (machine.ui_input().pressed(IPT_UI_TAPE_STOP))
{ {
cassette_device_iterator cassiter(machine.root_device()); for (cassette_image_device &cass : cassette_device_iterator(machine.root_device()))
for (cassette_image_device *cass = cassiter.first(); cass != nullptr; cass = cassiter.next())
{ {
cass->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE); cass.change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
return 0; return 0;
} }
} }
@ -1939,25 +1932,24 @@ std::vector<ui_menu_item> ui_manager::slider_init(running_machine &machine)
// add CPU overclocking (cheat only) // add CPU overclocking (cheat only)
if (machine.options().cheat()) if (machine.options().cheat())
{ {
execute_interface_iterator iter(machine.root_device()); for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next())
{ {
void *param = (void *)&exec->device(); void *param = (void *)&exec.device();
std::string str = string_format(_("Overclock CPU %1$s"), exec->device().tag()); std::string str = string_format(_("Overclock CPU %1$s"), exec.device().tag());
sliders.push_back(slider_alloc(machine, str.c_str(), 10, 1000, 2000, 1, slider_overclock, param)); sliders.push_back(slider_alloc(machine, str.c_str(), 10, 1000, 2000, 1, slider_overclock, param));
} }
} }
// add screen parameters // add screen parameters
screen_device_iterator scriter(machine.root_device()); screen_device_iterator scriter(machine.root_device());
for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) for (screen_device &screen : scriter)
{ {
int defxscale = floor(screen->xscale() * 1000.0f + 0.5f); int defxscale = floor(screen.xscale() * 1000.0f + 0.5f);
int defyscale = floor(screen->yscale() * 1000.0f + 0.5f); int defyscale = floor(screen.yscale() * 1000.0f + 0.5f);
int defxoffset = floor(screen->xoffset() * 1000.0f + 0.5f); int defxoffset = floor(screen.xoffset() * 1000.0f + 0.5f);
int defyoffset = floor(screen->yoffset() * 1000.0f + 0.5f); int defyoffset = floor(screen.yoffset() * 1000.0f + 0.5f);
void *param = (void *)screen; void *param = (void *)&screen;
std::string screen_desc = slider_get_screen_desc(*screen); std::string screen_desc = slider_get_screen_desc(screen);
// add refresh rate tweaker // add refresh rate tweaker
if (machine.options().cheat()) if (machine.options().cheat())
@ -1985,34 +1977,33 @@ std::vector<ui_menu_item> ui_manager::slider_init(running_machine &machine)
sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_yoffset, param)); sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_yoffset, param));
} }
laserdisc_device_iterator lditer(machine.root_device()); for (laserdisc_device &laserdisc : laserdisc_device_iterator(machine.root_device()))
for (laserdisc_device *laserdisc = lditer.first(); laserdisc != nullptr; laserdisc = lditer.next())
{ {
if (laserdisc->overlay_configured()) if (laserdisc.overlay_configured())
{ {
laserdisc_overlay_config config; laserdisc_overlay_config config;
laserdisc->get_overlay_config(config); laserdisc.get_overlay_config(config);
int defxscale = floor(config.m_overscalex * 1000.0f + 0.5f); int defxscale = floor(config.m_overscalex * 1000.0f + 0.5f);
int defyscale = floor(config.m_overscaley * 1000.0f + 0.5f); int defyscale = floor(config.m_overscaley * 1000.0f + 0.5f);
int defxoffset = floor(config.m_overposx * 1000.0f + 0.5f); int defxoffset = floor(config.m_overposx * 1000.0f + 0.5f);
int defyoffset = floor(config.m_overposy * 1000.0f + 0.5f); int defyoffset = floor(config.m_overposy * 1000.0f + 0.5f);
void *param = (void *)laserdisc; void *param = (void *)&laserdisc;
// add scale and offset controls per-overlay // add scale and offset controls per-overlay
std::string str = string_format(_("Laserdisc '%1$s' Horiz Stretch"), laserdisc->tag()); std::string str = string_format(_("Laserdisc '%1$s' Horiz Stretch"), laserdisc.tag());
sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_overxscale, param)); sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_overxscale, param));
str = string_format(_("Laserdisc '%1$s' Horiz Position"), laserdisc->tag()); str = string_format(_("Laserdisc '%1$s' Horiz Position"), laserdisc.tag());
sliders.push_back(slider_alloc(machine, str.c_str(), -500, defxoffset, 500, 2, slider_overxoffset, param)); sliders.push_back(slider_alloc(machine, str.c_str(), -500, defxoffset, 500, 2, slider_overxoffset, param));
str = string_format(_("Laserdisc '%1$s' Vert Stretch"), laserdisc->tag()); str = string_format(_("Laserdisc '%1$s' Vert Stretch"), laserdisc.tag());
sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_overyscale, param)); sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_overyscale, param));
str = string_format(_("Laserdisc '%1$s' Vert Position"), laserdisc->tag()); str = string_format(_("Laserdisc '%1$s' Vert Position"), laserdisc.tag());
sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_overyoffset, param)); sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_overyoffset, param));
} }
} }
for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) for (screen_device &screen : scriter)
{ {
if (screen->screen_type() == SCREEN_TYPE_VECTOR) if (screen.screen_type() == SCREEN_TYPE_VECTOR)
{ {
// add vector control // add vector control
sliders.push_back(slider_alloc(machine, _("Vector Flicker"), 0, 0, 1000, 10, slider_flicker, nullptr)); sliders.push_back(slider_alloc(machine, _("Vector Flicker"), 0, 0, 1000, 10, slider_flicker, nullptr));
@ -2462,10 +2453,7 @@ static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, i
static std::string slider_get_screen_desc(screen_device &screen) static std::string slider_get_screen_desc(screen_device &screen)
{ {
screen_device_iterator iter(screen.machine().root_device()); if (screen_device_iterator(screen.machine().root_device()).count() > 1)
int scrcount = iter.count();
if (scrcount > 1)
return string_format(_("Screen '%1$s'"), screen.tag()); return string_format(_("Screen '%1$s'"), screen.tag());
else else
return _("Screen"); return _("Screen");

View File

@ -168,11 +168,8 @@ void ui_gfx_init(running_machine &machine)
static void ui_gfx_count_devices(running_machine &machine, ui_gfx_state &state) static void ui_gfx_count_devices(running_machine &machine, ui_gfx_state &state)
{ {
palette_device_iterator pal_iter(machine.root_device());
gfx_interface_iterator gfx_iter(machine.root_device());
// count the palette devices // count the palette devices
state.palette.devcount = pal_iter.count(); state.palette.devcount = palette_device_iterator(machine.root_device()).count();
// set the pointer to the first palette // set the pointer to the first palette
if (state.palette.devcount > 0) if (state.palette.devcount > 0)
@ -180,27 +177,20 @@ static void ui_gfx_count_devices(running_machine &machine, ui_gfx_state &state)
// count the gfx devices // count the gfx devices
state.gfxset.devcount = 0; state.gfxset.devcount = 0;
int tempcount = gfx_iter.count(); for (device_gfx_interface &interface : gfx_interface_iterator(machine.root_device()))
// count the gfx sets in each device, skipping devices with none
if (tempcount > 0)
{ {
device_gfx_interface *interface; // count the gfx sets in each device, skipping devices with none
int i, count; int count = 0;
while (count < MAX_GFX_ELEMENTS && interface.gfx(count) != nullptr)
count++;
for (i = 0, interface = gfx_iter.first(); // count = index of first NULL
i < tempcount && state.gfxset.devcount < MAX_GFX_DECODERS; if (count > 0)
i++, interface = gfx_iter.next())
{ {
for (count = 0; count < MAX_GFX_ELEMENTS && interface->gfx(count) != nullptr; count++) { } state.gfxdev[state.gfxset.devcount].interface = &interface;
state.gfxdev[state.gfxset.devcount].setcount = count;
// count = index of first NULL if (++state.gfxset.devcount == MAX_GFX_DECODERS)
if (count > 0) break;
{
state.gfxdev[state.gfxset.devcount].interface = interface;
state.gfxdev[state.gfxset.devcount].setcount = count;
state.gfxset.devcount++;
}
} }
} }

View File

@ -570,11 +570,10 @@ void validity_checker::validate_driver()
void validity_checker::validate_roms() void validity_checker::validate_roms()
{ {
// iterate, starting with the driver's ROMs and continuing with device ROMs // iterate, starting with the driver's ROMs and continuing with device ROMs
device_iterator deviter(m_current_config->root_device()); for (device_t &device : device_iterator(m_current_config->root_device()))
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
{ {
// track the current device // track the current device
m_current_device = device; m_current_device = &device;
// scan the ROM entries for this device // scan the ROM entries for this device
const char *last_region_name = "???"; const char *last_region_name = "???";
@ -583,7 +582,7 @@ void validity_checker::validate_roms()
int items_since_region = 1; int items_since_region = 1;
int last_bios = 0; int last_bios = 0;
int total_files = 0; int total_files = 0;
for (const rom_entry *romp = rom_first_region(*device); romp != nullptr && !ROMENTRY_ISEND(romp); romp++) for (const rom_entry *romp = rom_first_region(device); romp != nullptr && !ROMENTRY_ISEND(romp); romp++)
{ {
// if this is a region, make sure it's valid, and record the length // if this is a region, make sure it's valid, and record the length
if (ROMENTRY_ISREGION(romp)) if (ROMENTRY_ISREGION(romp))
@ -608,7 +607,7 @@ void validity_checker::validate_roms()
validate_tag(basetag); validate_tag(basetag);
// generate the full tag // generate the full tag
std::string fulltag = rom_region_name(*device, romp); std::string fulltag = rom_region_name(device, romp);
// attempt to add it to the map, reporting duplicates as errors // attempt to add it to the map, reporting duplicates as errors
current_length = ROMREGION_GETLENGTH(romp); current_length = ROMREGION_GETLENGTH(romp);
@ -831,20 +830,19 @@ void validity_checker::validate_inputs()
std::unordered_set<std::string> port_map; std::unordered_set<std::string> port_map;
// iterate over devices // iterate over devices
device_iterator iter(m_current_config->root_device()); for (device_t &device : device_iterator(m_current_config->root_device()))
for (device_t *device = iter.first(); device != nullptr; device = iter.next())
{ {
// see if this device has ports; if not continue // see if this device has ports; if not continue
if (device->input_ports() == nullptr) if (device.input_ports() == nullptr)
continue; continue;
// track the current device // track the current device
m_current_device = device; m_current_device = &device;
// allocate the input ports // allocate the input ports
ioport_list portlist; ioport_list portlist;
std::string errorbuf; std::string errorbuf;
portlist.append(*device, errorbuf); portlist.append(device, errorbuf);
// report any errors during construction // report any errors during construction
if (!errorbuf.empty()) if (!errorbuf.empty())
@ -904,12 +902,12 @@ void validity_checker::validate_inputs()
// verify conditions on the field // verify conditions on the field
if (!field.condition().none()) if (!field.condition().none())
validate_condition(field.condition(), *device, port_map); validate_condition(field.condition(), device, port_map);
// verify conditions on the settings // verify conditions on the settings
for (ioport_setting &setting : field.settings()) for (ioport_setting &setting : field.settings())
if (!setting.condition().none()) if (!setting.condition().none())
validate_condition(setting.condition(), *device, port_map); validate_condition(setting.condition(), device, port_map);
} }
// done with this port // done with this port
@ -931,32 +929,31 @@ void validity_checker::validate_devices()
{ {
std::unordered_set<std::string> device_map; std::unordered_set<std::string> device_map;
device_iterator iter_find(m_current_config->root_device()); for (device_t &device : device_iterator(m_current_config->root_device()))
for (const device_t *device = iter_find.first(); device != nullptr; device = iter_find.next())
{ {
// track the current device // track the current device
m_current_device = device; m_current_device = &device;
// validate auto-finders // validate auto-finders
device->findit(true); device.findit(true);
// validate the device tag // validate the device tag
validate_tag(device->basetag()); validate_tag(device.basetag());
// look for duplicates // look for duplicates
if (!device_map.insert(device->tag()).second) if (!device_map.insert(device.tag()).second)
osd_printf_error("Multiple devices with the same tag '%s' defined\n", device->tag()); osd_printf_error("Multiple devices with the same tag '%s' defined\n", device.tag());
// all devices must have a shortname // all devices must have a shortname
if (strcmp(device->shortname(), "") == 0) if (strcmp(device.shortname(), "") == 0)
osd_printf_error("Device does not have short name defined\n"); osd_printf_error("Device does not have short name defined\n");
// all devices must have a source file defined // all devices must have a source file defined
if (strcmp(device->source(), "") == 0) if (strcmp(device.source(), "") == 0)
osd_printf_error("Device does not have source file location defined\n"); osd_printf_error("Device does not have source file location defined\n");
// check for device-specific validity check // check for device-specific validity check
device->validity_check(*this); device.validity_check(*this);
// done with this device // done with this device
m_current_device = nullptr; m_current_device = nullptr;
@ -964,24 +961,22 @@ void validity_checker::validate_devices()
// if device is slot cart device, we must have a shortname // if device is slot cart device, we must have a shortname
std::unordered_set<std::string> slot_device_map; std::unordered_set<std::string> slot_device_map;
slot_interface_iterator slotiter(m_current_config->root_device()); for (const device_slot_interface &slot : slot_interface_iterator(m_current_config->root_device()))
for (const device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next())
{ {
for (const device_slot_option &option : slot->option_list()) for (const device_slot_option &option : slot.option_list())
{ {
std::string temptag("_"); std::string temptag("_");
temptag.append(option.name()); temptag.append(option.name());
device_t *dev = const_cast<machine_config &>(*m_current_config).device_add(&m_current_config->root_device(), temptag.c_str(), option.devtype(), 0); device_t *dev = const_cast<machine_config &>(*m_current_config).device_add(&m_current_config->root_device(), temptag.c_str(), option.devtype(), 0);
// notify this device and all its subdevices that they are now configured // notify this device and all its subdevices that they are now configured
device_iterator subiter(*dev); for (device_t &device : device_iterator(*dev))
for (device_t *device = subiter.first(); device != nullptr; device = subiter.next()) if (!device.configured())
if (!device->configured()) device.config_complete();
device->config_complete();
if (strcmp(dev->shortname(), "") == 0) { if (strcmp(dev->shortname(), "") == 0) {
if (slot_device_map.insert(dev->name()).second) if (slot_device_map.insert(dev->name()).second)
osd_printf_error("Device '%s' is slot cart device but does not have short name defined\n",dev->name()); osd_printf_error("Device '%s' is slot cart device but does not have short name defined\n", dev->name());
} }
const_cast<machine_config &>(*m_current_config).device_remove(&m_current_config->root_device(), temptag.c_str()); const_cast<machine_config &>(*m_current_config).device_remove(&m_current_config->root_device(), temptag.c_str());

View File

@ -292,9 +292,8 @@ std::string video_manager::speed_text()
// display the number of partial updates as well // display the number of partial updates as well
int partials = 0; int partials = 0;
screen_device_iterator iter(machine().root_device()); for (screen_device &screen : screen_device_iterator(machine().root_device()))
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) partials += screen.partial_updates();
partials += screen->partial_updates();
if (partials > 1) if (partials > 1)
util::stream_format(str, "\n%d partial updates", partials); util::stream_format(str, "\n%d partial updates", partials);
@ -345,14 +344,13 @@ void video_manager::save_active_screen_snapshots()
if (m_snap_native) if (m_snap_native)
{ {
// write one snapshot per visible screen // write one snapshot per visible screen
screen_device_iterator iter(machine().root_device()); for (screen_device &screen : screen_device_iterator(machine().root_device()))
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) if (machine().render().is_live(screen))
if (machine().render().is_live(*screen))
{ {
emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
osd_file::error filerr = open_next(file, "png"); osd_file::error filerr = open_next(file, "png");
if (filerr == osd_file::error::NONE) if (filerr == osd_file::error::NONE)
save_snapshot(screen, file); save_snapshot(&screen, file);
} }
} }
@ -699,14 +697,14 @@ bool video_manager::finish_screen_updates()
// finish updating the screens // finish updating the screens
screen_device_iterator iter(machine().root_device()); screen_device_iterator iter(machine().root_device());
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) for (screen_device &screen : iter)
screen->update_partial(screen->visible_area().max_y); screen.update_partial(screen.visible_area().max_y);
// now add the quads for all the screens // now add the quads for all the screens
bool anything_changed = m_output_changed; bool anything_changed = m_output_changed;
m_output_changed = false; m_output_changed = false;
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) for (screen_device &screen : iter)
if (screen->update_quads()) if (screen.update_quads())
anything_changed = true; anything_changed = true;
// draw HUD from LUA callback (if any) // draw HUD from LUA callback (if any)
@ -718,13 +716,13 @@ bool video_manager::finish_screen_updates()
record_frame(); record_frame();
// iterate over screens and update the burnin for the ones that care // iterate over screens and update the burnin for the ones that care
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) for (screen_device &screen : iter)
screen->update_burnin(); screen.update_burnin();
} }
// draw any crosshairs // draw any crosshairs
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) for (screen_device &screen : iter)
machine().crosshair().render(*screen); machine().crosshair().render(screen);
return anything_changed; return anything_changed;
} }
@ -1008,10 +1006,9 @@ void video_manager::update_refresh_speed()
// find the screen with the shortest frame period (max refresh rate) // find the screen with the shortest frame period (max refresh rate)
// note that we first check the token since this can get called before all screens are created // note that we first check the token since this can get called before all screens are created
attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND; attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND;
screen_device_iterator iter(machine().root_device()); for (screen_device &screen : screen_device_iterator(machine().root_device()))
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next())
{ {
attoseconds_t period = screen->frame_period().attoseconds(); attoseconds_t period = screen.frame_period().attoseconds();
if (period != 0) if (period != 0)
min_frame_period = MIN(min_frame_period, period); min_frame_period = MIN(min_frame_period, period);
} }
@ -1202,19 +1199,18 @@ osd_file::error video_manager::open_next(emu_file &file, const char *extension)
//printf("check template: %s\n", snapdevname.c_str()); //printf("check template: %s\n", snapdevname.c_str());
// verify that there is such a device for this system // verify that there is such a device for this system
image_interface_iterator iter(machine().root_device()); for (device_image_interface &image : image_interface_iterator(machine().root_device()))
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{ {
// get the device name // get the device name
std::string tempdevname(image->brief_instance_name()); std::string tempdevname(image.brief_instance_name());
//printf("check device: %s\n", tempdevname.c_str()); //printf("check device: %s\n", tempdevname.c_str());
if (snapdevname.compare(tempdevname) == 0) if (snapdevname.compare(tempdevname) == 0)
{ {
// verify that such a device has an image mounted // verify that such a device has an image mounted
if (image->basename() != nullptr) if (image.basename() != nullptr)
{ {
std::string filename(image->basename()); std::string filename(image.basename());
// strip extension // strip extension
filename = filename.substr(0, filename.find_last_of('.')); filename = filename.substr(0, filename.find_last_of('.'));

View File

@ -970,17 +970,15 @@ atarigen_state::atarigen_state(const machine_config &mconfig, device_type type,
void atarigen_state::machine_start() void atarigen_state::machine_start()
{ {
screen_device *screen;
int i;
// allocate timers for all screens // allocate timers for all screens
screen_device_iterator iter(*this); int i = 0;
assert(iter.count() <= ARRAY_LENGTH(m_screen_timer)); for (screen_device &screen : screen_device_iterator(*this))
for (i = 0, screen = iter.first(); screen != nullptr; i++, screen = iter.next())
{ {
m_screen_timer[i].screen = screen; assert(i <= ARRAY_LENGTH(m_screen_timer));
m_screen_timer[i].scanline_interrupt_timer = timer_alloc(TID_SCANLINE_INTERRUPT, (void *)screen); m_screen_timer[i].screen = &screen;
m_screen_timer[i].scanline_timer = timer_alloc(TID_SCANLINE_TIMER, (void *)screen); m_screen_timer[i].scanline_interrupt_timer = timer_alloc(TID_SCANLINE_INTERRUPT, (void *)&screen);
m_screen_timer[i].scanline_timer = timer_alloc(TID_SCANLINE_TIMER, (void *)&screen);
i++;
} }
save_item(NAME(m_scanline_int_state)); save_item(NAME(m_scanline_int_state));

View File

@ -130,12 +130,9 @@ VIDEO_START_MEMBER(cyberbal_state,cyberbal2p)
void cyberbal_state::scanline_update(screen_device &screen, int scanline) void cyberbal_state::scanline_update(screen_device &screen, int scanline)
{ {
int i;
screen_device *update_screen;
/* loop over screens */ /* loop over screens */
screen_device_iterator iter(*this); int i = 0;
for (i = 0, update_screen = iter.first(); update_screen != nullptr; i++, update_screen = iter.next()) for (screen_device &update_screen : screen_device_iterator(*this))
{ {
/* need explicit target() because one is optional_device and other is required_device */ /* need explicit target() because one is optional_device and other is required_device */
tilemap_t *curplayfield = i ? m_playfield2_tilemap.target() : m_playfield_tilemap.target(); tilemap_t *curplayfield = i ? m_playfield2_tilemap.target() : m_playfield_tilemap.target();
@ -155,7 +152,7 @@ void cyberbal_state::scanline_update(screen_device &screen, int scanline)
if (((word >> 1) & 7) != m_playfield_palette_bank[i]) if (((word >> 1) & 7) != m_playfield_palette_bank[i])
{ {
if (scanline > 0) if (scanline > 0)
update_screen->update_partial(scanline - 1); update_screen.update_partial(scanline - 1);
m_playfield_palette_bank[i] = (word >> 1) & 7; m_playfield_palette_bank[i] = (word >> 1) & 7;
curplayfield->set_palette_offset(m_playfield_palette_bank[i] << 8); curplayfield->set_palette_offset(m_playfield_palette_bank[i] << 8);
} }
@ -167,7 +164,7 @@ void cyberbal_state::scanline_update(screen_device &screen, int scanline)
if (newscroll != m_playfield_xscroll[i]) if (newscroll != m_playfield_xscroll[i])
{ {
if (scanline > 0) if (scanline > 0)
update_screen->update_partial(scanline - 1); update_screen.update_partial(scanline - 1);
curplayfield->set_scrollx(0, newscroll); curplayfield->set_scrollx(0, newscroll);
m_playfield_xscroll[i] = newscroll; m_playfield_xscroll[i] = newscroll;
} }
@ -180,7 +177,7 @@ void cyberbal_state::scanline_update(screen_device &screen, int scanline)
if (newscroll != m_playfield_yscroll[i]) if (newscroll != m_playfield_yscroll[i])
{ {
if (scanline > 0) if (scanline > 0)
update_screen->update_partial(scanline - 1); update_screen.update_partial(scanline - 1);
curplayfield->set_scrolly(0, newscroll); curplayfield->set_scrolly(0, newscroll);
m_playfield_yscroll[i] = newscroll; m_playfield_yscroll[i] = newscroll;
} }
@ -191,10 +188,11 @@ void cyberbal_state::scanline_update(screen_device &screen, int scanline)
if (m_current_slip[i] != word) if (m_current_slip[i] != word)
{ {
if (scanline > 0) if (scanline > 0)
update_screen->update_partial(scanline - 1); update_screen.update_partial(scanline - 1);
m_current_slip[i] = word; m_current_slip[i] = word;
} }
} }
i++;
} }
} }

View File

@ -91,14 +91,7 @@ int DevicesWindowModel::rowCount(const QModelIndex &parent) const
return 1; return 1;
device_t *dparent = static_cast<device_t *>(parent.internalPointer()); device_t *dparent = static_cast<device_t *>(parent.internalPointer());
int count = 0; return dparent->subdevices().count();
for (device_t &child : dparent->subdevices())
{
(void)child;
count++;
}
return count;
} }
int DevicesWindowModel::columnCount(const QModelIndex &parent) const int DevicesWindowModel::columnCount(const QModelIndex &parent) const

View File

@ -469,13 +469,12 @@ void MainWindow::createImagesMenu()
QMenu* imagesMenu = menuBar()->addMenu("&Images"); QMenu* imagesMenu = menuBar()->addMenu("&Images");
int interfaceIndex = 0; int interfaceIndex = 0;
image_interface_iterator iter(m_machine->root_device()); for (device_image_interface &img : image_interface_iterator(m_machine->root_device()))
for (device_image_interface *img = iter.first(); img != NULL; img = iter.next())
{ {
std::string menuName = string_format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[empty slot]"); std::string menuName = string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[empty slot]");
QMenu* interfaceMenu = imagesMenu->addMenu(menuName.c_str()); QMenu* interfaceMenu = imagesMenu->addMenu(menuName.c_str());
interfaceMenu->setObjectName(img->device().name()); interfaceMenu->setObjectName(img.device().name());
QAction* mountAct = new QAction("Mount...", interfaceMenu); QAction* mountAct = new QAction("Mount...", interfaceMenu);
QAction* unmountAct = new QAction("Unmount", interfaceMenu); QAction* unmountAct = new QAction("Unmount", interfaceMenu);
@ -486,7 +485,7 @@ void MainWindow::createImagesMenu()
connect(mountAct, &QAction::triggered, this, &MainWindow::mountImage); connect(mountAct, &QAction::triggered, this, &MainWindow::mountImage);
connect(unmountAct, &QAction::triggered, this, &MainWindow::unmountImage); connect(unmountAct, &QAction::triggered, this, &MainWindow::unmountImage);
if (!img->exists()) if (!img.exists())
unmountAct->setEnabled(false); unmountAct->setEnabled(false);
interfaceMenu->addAction(mountAct); interfaceMenu->addAction(mountAct);

View File

@ -37,13 +37,12 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) :
{ {
// Add image menu only if image devices exist // Add image menu only if image devices exist
image_interface_iterator iter(machine().root_device()); image_interface_iterator iter(machine().root_device());
device_image_interface *img = iter.first(); if (iter.first() != nullptr)
if (img != NULL)
{ {
m_devices_menu = CreatePopupMenu(); m_devices_menu = CreatePopupMenu();
for ( ; img != NULL; img = iter.next()) for (device_image_interface &img : iter)
{ {
TCHAR *tc_buf = tstring_from_utf8(string_format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[no image]").c_str()); TCHAR *tc_buf = tstring_from_utf8(string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[no image]").c_str());
if (tc_buf != NULL) if (tc_buf != NULL)
{ {
AppendMenu(m_devices_menu, MF_ENABLED, 0, tc_buf); AppendMenu(m_devices_menu, MF_ENABLED, 0, tc_buf);
@ -163,32 +162,30 @@ void consolewin_info::update_menu()
if (m_devices_menu != NULL) if (m_devices_menu != NULL)
{ {
// create the image menu // create the image menu
image_interface_iterator iter(machine().root_device()); UINT32 cnt = 0;
device_image_interface *img; for (device_image_interface &img : image_interface_iterator(machine().root_device()))
UINT32 cnt;
for (img = iter.first(), cnt = 0; img != NULL; img = iter.next(), cnt++)
{ {
HMENU const devicesubmenu = CreatePopupMenu(); HMENU const devicesubmenu = CreatePopupMenu();
UINT_PTR const new_item = ID_DEVICE_OPTIONS + (cnt * DEVOPTION_MAX); UINT_PTR const new_item = ID_DEVICE_OPTIONS + (cnt * DEVOPTION_MAX);
UINT flags_for_exists = MF_ENABLED | MF_STRING; UINT flags_for_exists = MF_ENABLED | MF_STRING;
if (!img->exists()) if (!img.exists())
flags_for_exists |= MF_GRAYED; flags_for_exists |= MF_GRAYED;
UINT flags_for_writing = flags_for_exists; UINT flags_for_writing = flags_for_exists;
if (img->is_readonly()) if (img.is_readonly())
flags_for_writing |= MF_GRAYED; flags_for_writing |= MF_GRAYED;
AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_OPEN, TEXT("Mount...")); AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_OPEN, TEXT("Mount..."));
//if (img->is_creatable()) //if (img.is_creatable())
//AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_CREATE, TEXT("Create...")); //AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_CREATE, TEXT("Create..."));
AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CLOSE, TEXT("Unmount")); AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CLOSE, TEXT("Unmount"));
if (img->device().type() == CASSETTE) if (img.device().type() == CASSETTE)
{ {
cassette_state const state = (cassette_state)(img->exists() ? (downcast<cassette_image_device *>(&img->device())->get_state() & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED); cassette_state const state = (cassette_state)(img.exists() ? (downcast<cassette_image_device *>(&img.device())->get_state() & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED);
AppendMenu(devicesubmenu, MF_SEPARATOR, 0, NULL); AppendMenu(devicesubmenu, MF_SEPARATOR, 0, NULL);
AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, TEXT("Pause/Stop")); AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, TEXT("Pause/Stop"));
AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, TEXT("Play")); AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, TEXT("Play"));
@ -197,12 +194,14 @@ void consolewin_info::update_menu()
AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, TEXT("Fast Forward")); AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, TEXT("Fast Forward"));
} }
TCHAR *tc_buf = tstring_from_utf8(string_format("%s :%s", img->device().name(), img->exists() ? img->filename() : "[empty slot]").c_str()); TCHAR *tc_buf = tstring_from_utf8(string_format("%s :%s", img.device().name(), img.exists() ? img.filename() : "[empty slot]").c_str());
if (tc_buf != NULL) if (tc_buf != NULL)
{ {
ModifyMenu(m_devices_menu, cnt, MF_BYPOSITION | MF_POPUP, (UINT_PTR)devicesubmenu, tc_buf); ModifyMenu(m_devices_menu, cnt, MF_BYPOSITION | MF_POPUP, (UINT_PTR)devicesubmenu, tc_buf);
osd_free(tc_buf); osd_free(tc_buf);
} }
cnt++;
} }
} }
} }

View File

@ -1372,11 +1372,7 @@ int shaders::post_pass(d3d_render_target *rt, int source_index, poly_info *poly,
int next_index = source_index; int next_index = source_index;
screen_device_iterator screen_iterator(machine->root_device()); screen_device_iterator screen_iterator(machine->root_device());
screen_device *screen = screen_iterator.first(); screen_device *screen = screen_iterator.byindex(curr_screen);
for (int i = 0; i < curr_screen; i++)
{
screen = screen_iterator.next();
}
render_container &screen_container = screen->container(); render_container &screen_container = screen->container();
float xscale = screen_container.xscale(); float xscale = screen_container.xscale();

View File

@ -1073,22 +1073,8 @@ OSDWORK_CALLBACK( sdl_window_info::draw_video_contents_wt )
{ {
#if 1 #if 1
int scrnum = 0; const screen_device *screen = screen_device_iterator(window->machine().root_device()).byindex(window->m_index);
int is_vector = 0; if ((screen != nullptr) && (screen->screen_type() == SCREEN_TYPE_VECTOR))
screen_device_iterator iter(window->machine().root_device());
for (const screen_device *screen = iter.first(); screen != nullptr; screen = iter.next())
{
if (scrnum == window->m_index)
{
is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0;
break;
}
else
{
scrnum++;
}
}
if (is_vector)
window->renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN); window->renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN);
else else
window->renderer().clear_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN); window->renderer().clear_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN);