From 1b0ec08af5cd3b3268b5889ba4e30409431434e2 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 4 Dec 2015 10:29:21 +0100 Subject: clang-modernize part 6 --- src/devices/bus/a2bus/a2bus.cpp | 4 +- src/devices/bus/a2bus/a2mcms.cpp | 4 +- src/devices/bus/a7800/a78_slot.cpp | 12 ++-- src/devices/bus/a800/a800_slot.cpp | 12 ++-- src/devices/bus/amiga/zorro/a2232.cpp | 4 +- src/devices/bus/apf/slot.cpp | 12 ++-- src/devices/bus/arcadia/slot.cpp | 6 +- src/devices/bus/astrocde/slot.cpp | 12 ++-- src/devices/bus/bml3/bml3bus.cpp | 4 +- src/devices/bus/cbmiec/cbmiec.cpp | 8 +-- src/devices/bus/chanf/slot.cpp | 12 ++-- src/devices/bus/comx35/expbox.cpp | 24 +++---- src/devices/bus/crvision/slot.cpp | 12 ++-- src/devices/bus/ecbbus/ecbbus.cpp | 28 ++++---- src/devices/bus/econet/econet.cpp | 8 +-- src/devices/bus/gameboy/gb_slot.cpp | 12 ++-- src/devices/bus/gba/gba_slot.cpp | 20 +++--- src/devices/bus/ieee488/ieee488.cpp | 8 +-- src/devices/bus/intv/slot.cpp | 12 ++-- src/devices/bus/isa/cga.cpp | 4 +- src/devices/bus/kc/d002.cpp | 16 ++--- src/devices/bus/lpci/pci.cpp | 4 +- src/devices/bus/megadrive/md_slot.cpp | 12 ++-- src/devices/bus/msx_cart/ascii.cpp | 20 +++--- src/devices/bus/msx_cart/crossblaim.cpp | 4 +- src/devices/bus/msx_cart/halnote.cpp | 4 +- src/devices/bus/msx_cart/holy_quran.cpp | 4 +- src/devices/bus/msx_cart/konami.cpp | 32 ++++----- src/devices/bus/msx_cart/korean.cpp | 4 +- src/devices/bus/msx_cart/majutsushi.cpp | 8 +-- src/devices/bus/msx_cart/rtype.cpp | 4 +- src/devices/bus/msx_slot/cartridge.cpp | 12 ++-- src/devices/bus/nes/mmc5.cpp | 4 +- src/devices/bus/nes/nes_pcb.inc | 12 ++-- src/devices/bus/odyssey2/slot.cpp | 12 ++-- src/devices/bus/pce/pce_slot.cpp | 12 ++-- src/devices/bus/scv/slot.cpp | 12 ++-- src/devices/bus/sega8/sega8_slot.cpp | 12 ++-- src/devices/bus/snes/sdd1.cpp | 12 ++-- src/devices/bus/snes/snes_slot.cpp | 12 ++-- src/devices/bus/snes/spc7110.cpp | 10 +-- src/devices/bus/ti99_peb/bwg.cpp | 8 +-- src/devices/bus/ti99_peb/hfdc.cpp | 4 +- src/devices/bus/ti99_peb/memex.cpp | 4 +- src/devices/bus/ti99_peb/pcode.cpp | 4 +- src/devices/bus/ti99_peb/samsmem.cpp | 2 +- src/devices/bus/ti99_peb/ti_fdc.cpp | 4 +- src/devices/bus/ti99x/990_dk.cpp | 8 +-- src/devices/bus/ti99x/998board.cpp | 4 +- src/devices/bus/ti99x/genboard.cpp | 2 +- src/devices/bus/ti99x/gromport.cpp | 22 +++--- src/devices/bus/vboy/slot.cpp | 6 +- src/devices/bus/vc4000/slot.cpp | 12 ++-- src/devices/bus/vcs/dpc.cpp | 8 +-- src/devices/bus/vcs/vcs_slot.cpp | 16 ++--- src/devices/bus/vectrex/slot.cpp | 6 +- src/devices/bus/vic20/vic1010.cpp | 12 ++-- src/devices/bus/vip/vp575.cpp | 52 +++++++------- src/devices/bus/wswan/slot.cpp | 12 ++-- src/devices/cpu/arcompact/arcompact.cpp | 4 +- src/devices/cpu/arm/arm.cpp | 8 +-- src/devices/cpu/avr8/avr8.cpp | 4 +- src/devices/cpu/cosmac/cosmac.cpp | 4 +- src/devices/cpu/drcbex64.cpp | 4 +- src/devices/cpu/drcbex86.cpp | 4 +- src/devices/cpu/h6280/h6280.cpp | 4 +- src/devices/cpu/h8/h8_timer8.cpp | 14 ++-- src/devices/cpu/hcd62121/hcd62121.cpp | 4 +- src/devices/cpu/hd61700/hd61700.cpp | 4 +- src/devices/cpu/i8089/i8089_channel.cpp | 6 +- src/devices/cpu/i86/i186.cpp | 18 ++--- src/devices/cpu/m6502/m3745x.cpp | 4 +- src/devices/cpu/m68000/m68kcpu.cpp | 8 +-- src/devices/cpu/mcs51/mcs51.cpp | 4 +- src/devices/cpu/pdp1/pdp1.cpp | 4 +- src/devices/cpu/pdp1/tx0.cpp | 4 +- src/devices/cpu/rsp/rspcp2.cpp | 10 +-- src/devices/cpu/se3208/se3208.cpp | 4 +- src/devices/cpu/sh2/sh2drc.cpp | 14 ++-- src/devices/cpu/sharc/sharc.cpp | 54 +++++++-------- src/devices/cpu/sm8500/sm8500.cpp | 4 +- src/devices/cpu/ssp1601/ssp1601.cpp | 4 +- src/devices/cpu/superfx/superfx.cpp | 4 +- src/devices/cpu/upd7725/upd7725.cpp | 4 +- src/devices/cpu/z8/z8.cpp | 12 ++-- src/devices/imagedev/floppy.cpp | 2 +- src/devices/machine/53c810.cpp | 4 +- src/devices/machine/6525tpi.cpp | 4 +- src/devices/machine/68307tmu.cpp | 4 +- src/devices/machine/6840ptm.cpp | 10 +-- src/devices/machine/74148.cpp | 4 +- src/devices/machine/74153.cpp | 12 ++-- src/devices/machine/am9517a.cpp | 12 ++-- src/devices/machine/ataintf.cpp | 42 ++++++------ src/devices/machine/ay31015.cpp | 8 +-- src/devices/machine/ds1302.cpp | 4 +- src/devices/machine/ds2404.cpp | 10 +-- src/devices/machine/hdc92x4.cpp | 8 +-- src/devices/machine/i8257.cpp | 14 ++-- src/devices/machine/i8271.cpp | 12 ++-- src/devices/machine/kb3600.cpp | 4 +- src/devices/machine/laserdsc.cpp | 12 ++-- src/devices/machine/m6m80011ap.cpp | 4 +- src/devices/machine/mc6843.cpp | 4 +- src/devices/machine/mc6854.cpp | 4 +- src/devices/machine/mos8722.cpp | 4 +- src/devices/machine/msm5832.cpp | 4 +- src/devices/machine/msm58321.cpp | 4 +- src/devices/machine/netlist.h | 4 +- src/devices/machine/pci.cpp | 4 +- src/devices/machine/pla.cpp | 8 +-- src/devices/machine/rtc9701.cpp | 4 +- src/devices/machine/s2636.cpp | 4 +- src/devices/machine/s3c24xx.inc | 16 ++--- src/devices/machine/s3c44b0.cpp | 24 +++---- src/devices/machine/upd1990a.cpp | 4 +- src/devices/machine/upd71071.cpp | 4 +- src/devices/machine/upd765.cpp | 12 ++-- src/devices/machine/wd7600.cpp | 4 +- src/devices/machine/z80ctc.cpp | 4 +- src/devices/machine/z80dart.cpp | 20 +++--- src/devices/machine/z80scc.cpp | 12 ++-- src/devices/machine/z80sio.cpp | 12 ++-- src/devices/machine/z80sti.cpp | 4 +- src/devices/machine/z8536.cpp | 4 +- src/devices/sound/es5503.cpp | 22 +++--- src/devices/sound/es5506.cpp | 4 +- src/devices/sound/i5000.cpp | 4 +- src/devices/sound/ics2115.cpp | 42 ++++++------ src/devices/sound/k007232.cpp | 4 +- src/devices/sound/k053260.cpp | 12 ++-- src/devices/sound/k054539.cpp | 4 +- src/devices/sound/nes_apu.cpp | 16 ++--- src/devices/sound/nes_defs.h | 16 ++--- src/devices/sound/okim6295.cpp | 8 +-- src/devices/sound/okim9810.cpp | 8 +-- src/devices/sound/qs1000.cpp | 8 +-- src/devices/sound/qsound.cpp | 30 ++++---- src/devices/sound/sp0250.cpp | 14 ++-- src/devices/sound/spu.cpp | 8 +-- src/devices/sound/ymf271.cpp | 6 +- src/devices/sound/ymz280b.cpp | 8 +-- src/devices/sound/ymz770.cpp | 102 ++++++++++++++-------------- src/devices/sound/zsg2.cpp | 26 +++---- src/devices/video/crt9007.cpp | 4 +- src/devices/video/hd66421.cpp | 4 +- src/devices/video/mos6566.cpp | 4 +- src/devices/video/snes_ppu.cpp | 48 ++++++------- src/devices/video/tms9928a.cpp | 4 +- src/devices/video/upd7220.cpp | 4 +- src/emu/dispatch.h | 4 +- src/emu/input.cpp | 4 +- src/lib/formats/ap2_dsk.cpp | 20 +++--- src/lib/formats/ap_dsk35.cpp | 4 +- src/lib/formats/cassimg.cpp | 4 +- src/lib/formats/flopimg.cpp | 12 ++-- src/mame/audio/dave.cpp | 32 ++++----- src/mame/audio/exidy440.cpp | 8 +-- src/mame/audio/flower.cpp | 4 +- src/mame/audio/lynx.cpp | 4 +- src/mame/audio/mea8000.cpp | 16 ++--- src/mame/audio/turrett.cpp | 4 +- src/mame/drivers/atarist.cpp | 4 +- src/mame/drivers/bfm_sc45_helper.cpp | 60 ++++++++-------- src/mame/drivers/esq1.cpp | 4 +- src/mame/drivers/famibox.cpp | 12 ++-- src/mame/drivers/hyperscan.cpp | 16 ++--- src/mame/drivers/iq151.cpp | 20 +++--- src/mame/drivers/jack.cpp | 4 +- src/mame/drivers/joystand.cpp | 6 +- src/mame/drivers/lethal.cpp | 4 +- src/mame/drivers/microvsn.cpp | 18 ++--- src/mame/drivers/monty.cpp | 4 +- src/mame/drivers/mz3500.cpp | 6 +- src/mame/drivers/nakajies.cpp | 4 +- src/mame/drivers/namcoic.cpp | 8 +-- src/mame/drivers/namcos22.cpp | 4 +- src/mame/drivers/pcfx.cpp | 6 +- src/mame/drivers/psikyo4.cpp | 4 +- src/mame/drivers/raiden2.cpp | 4 +- src/mame/drivers/segaxbd.cpp | 4 +- src/mame/drivers/stratos.cpp | 4 +- src/mame/drivers/subsino2.cpp | 4 +- src/mame/drivers/x07.cpp | 8 +-- src/mame/includes/msx.h | 4 +- src/mame/includes/tandy2k.h | 4 +- src/mame/machine/315-5838_317-0229_comp.cpp | 20 +++--- src/mame/machine/315_5296.cpp | 4 +- src/mame/machine/asic65.cpp | 4 +- src/mame/machine/balsente.cpp | 4 +- src/mame/machine/cdi070.cpp | 4 +- src/mame/machine/cdislave.cpp | 16 ++--- src/mame/machine/decocass_tape.cpp | 4 +- src/mame/machine/fd1094.cpp | 8 +-- src/mame/machine/gb.cpp | 4 +- src/mame/machine/kc.cpp | 16 ++--- src/mame/machine/megacdcd.cpp | 8 +-- src/mame/machine/micropolis.cpp | 14 ++-- src/mame/machine/model3.cpp | 8 +-- src/mame/machine/msx.cpp | 18 ++--- src/mame/machine/namcoio.cpp | 4 +- src/mame/machine/naomim1.cpp | 4 +- src/mame/machine/pce.cpp | 4 +- src/mame/machine/pgmprot_igs027a_type1.cpp | 4 +- src/mame/machine/pgmprot_igs027a_type3.cpp | 4 +- src/mame/machine/rx01.cpp | 8 +-- src/mame/machine/segaic16.cpp | 12 ++-- src/mame/machine/snes.cpp | 20 +++--- src/mame/machine/st0016.cpp | 4 +- src/mame/machine/tait8741.cpp | 14 ++-- src/mame/machine/taitoio.cpp | 12 ++-- src/mame/machine/vectrex.cpp | 4 +- src/mame/video/abc806.cpp | 4 +- src/mame/video/antic.cpp | 4 +- src/mame/video/bfm_dm01.cpp | 8 +-- src/mame/video/chihiro.cpp | 12 ++-- src/mame/video/gauntlet.cpp | 4 +- src/mame/video/hng64.cpp | 8 +-- src/mame/video/k053244_k053245.cpp | 4 +- src/mame/video/k053246_k053247_k055673.cpp | 8 +-- src/mame/video/k057714.cpp | 8 +-- src/mame/video/kaneko16.cpp | 4 +- src/mame/video/maria.cpp | 8 +-- src/mame/video/mcd212.cpp | 60 ++++++++-------- src/mame/video/nemesis.cpp | 4 +- src/mame/video/pc080sn.cpp | 4 +- src/mame/video/powervr2.cpp | 6 +- src/mame/video/ppu2c0x.cpp | 4 +- src/mame/video/psikyosh.cpp | 2 +- src/mame/video/rdptpipe.h | 4 +- src/mame/video/stic.cpp | 4 +- src/mame/video/tc0100scn.cpp | 4 +- src/mame/video/tc0360pri.cpp | 4 +- src/mame/video/tc0480scp.cpp | 4 +- src/tools/chdman.cpp | 24 +++---- src/tools/src2html.cpp | 6 +- 236 files changed, 1171 insertions(+), 1171 deletions(-) (limited to 'src') diff --git a/src/devices/bus/a2bus/a2bus.cpp b/src/devices/bus/a2bus/a2bus.cpp index eec06d8bdb8..5fd03495c87 100644 --- a/src/devices/bus/a2bus/a2bus.cpp +++ b/src/devices/bus/a2bus/a2bus.cpp @@ -168,9 +168,9 @@ void a2bus_device::device_start() m_out_inh_cb.resolve_safe(); // clear slots - for (int i = 0; i < 8; i++) + for (auto & elem : m_device_list) { - m_device_list[i] = nullptr; + elem = nullptr; } m_slot_irq_mask = m_slot_nmi_mask = 0; diff --git a/src/devices/bus/a2bus/a2mcms.cpp b/src/devices/bus/a2bus/a2mcms.cpp index 93a62a6d03d..ad7f621d6c8 100644 --- a/src/devices/bus/a2bus/a2mcms.cpp +++ b/src/devices/bus/a2bus/a2mcms.cpp @@ -232,9 +232,9 @@ void mcms_device::device_start() memset(m_acc, 0, sizeof(m_acc)); // the card detect programs volumes and wavetable page but not freq and expects the accumulator to increment - for (int i = 0; i < 16; i++) + for (auto & elem : m_freq) { - m_freq[i] = 0x0040; + elem = 0x0040; } save_item(NAME(m_enabled)); diff --git a/src/devices/bus/a7800/a78_slot.cpp b/src/devices/bus/a7800/a78_slot.cpp index 78c4cece478..7fda107b70c 100644 --- a/src/devices/bus/a7800/a78_slot.cpp +++ b/src/devices/bus/a7800/a78_slot.cpp @@ -322,10 +322,10 @@ static const a78_slot slot_list[] = static int a78_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -333,10 +333,10 @@ static int a78_get_pcb_id(const char *slot) static const char *a78_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "a78_rom"; diff --git a/src/devices/bus/a800/a800_slot.cpp b/src/devices/bus/a800/a800_slot.cpp index 973be0eb899..148ab38ed03 100644 --- a/src/devices/bus/a800/a800_slot.cpp +++ b/src/devices/bus/a800/a800_slot.cpp @@ -216,10 +216,10 @@ static const a800_slot slot_list[] = static int a800_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -227,10 +227,10 @@ static int a800_get_pcb_id(const char *slot) static const char *a800_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "a800_8k"; diff --git a/src/devices/bus/amiga/zorro/a2232.cpp b/src/devices/bus/amiga/zorro/a2232.cpp index 60f5b96ac53..4cf44853c46 100644 --- a/src/devices/bus/amiga/zorro/a2232.cpp +++ b/src/devices/bus/amiga/zorro/a2232.cpp @@ -206,9 +206,9 @@ void a2232_device::device_reset_after_children() void a2232_device::update_irqs() { // look for any active irq - for (int i = 0; i < IRQ_SOURCE_COUNT; i++) + for (auto & elem : m_irqs) { - if (m_irqs[i]) + if (elem) { m_iocpu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE); return; diff --git a/src/devices/bus/apf/slot.cpp b/src/devices/bus/apf/slot.cpp index 4a89673a9d0..b94f286798c 100644 --- a/src/devices/bus/apf/slot.cpp +++ b/src/devices/bus/apf/slot.cpp @@ -131,10 +131,10 @@ static const apf_slot slot_list[] = static int apf_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -142,10 +142,10 @@ static int apf_get_pcb_id(const char *slot) static const char *apf_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "std"; diff --git a/src/devices/bus/arcadia/slot.cpp b/src/devices/bus/arcadia/slot.cpp index c2cddcc8488..eec8c412775 100644 --- a/src/devices/bus/arcadia/slot.cpp +++ b/src/devices/bus/arcadia/slot.cpp @@ -120,10 +120,10 @@ static const arcadia_slot slot_list[] = static int arcadia_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; diff --git a/src/devices/bus/astrocde/slot.cpp b/src/devices/bus/astrocde/slot.cpp index 74071506c90..877df4773a0 100644 --- a/src/devices/bus/astrocde/slot.cpp +++ b/src/devices/bus/astrocde/slot.cpp @@ -121,10 +121,10 @@ static const astrocade_slot slot_list[] = static int astrocade_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -132,10 +132,10 @@ static int astrocade_get_pcb_id(const char *slot) static const char *astrocade_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "std"; diff --git a/src/devices/bus/bml3/bml3bus.cpp b/src/devices/bus/bml3/bml3bus.cpp index b06ac50e5d2..0438cc58997 100644 --- a/src/devices/bus/bml3/bml3bus.cpp +++ b/src/devices/bus/bml3/bml3bus.cpp @@ -139,9 +139,9 @@ void bml3bus_device::device_start() m_out_firq_cb.resolve_safe(); // clear slots - for (int i = 0; i < BML3BUS_MAX_SLOTS; i++) + for (auto & elem : m_device_list) { - m_device_list[i] = nullptr; + elem = nullptr; } } diff --git a/src/devices/bus/cbmiec/cbmiec.cpp b/src/devices/bus/cbmiec/cbmiec.cpp index bcfc9318860..7e893614f3f 100644 --- a/src/devices/bus/cbmiec/cbmiec.cpp +++ b/src/devices/bus/cbmiec/cbmiec.cpp @@ -290,9 +290,9 @@ cbm_iec_device::cbm_iec_device(const machine_config &mconfig, const char *tag, d m_write_data(*this), m_write_reset(*this) { - for (int i = 0; i < SIGNAL_COUNT; i++) + for (auto & elem : m_line) { - m_line[i] = 1; + elem = 1; } } @@ -357,9 +357,9 @@ cbm_iec_device::daisy_entry::daisy_entry(device_t *device) m_device(device), m_interface(nullptr) { - for (int i = 0; i < SIGNAL_COUNT; i++) + for (auto & elem : m_line) { - m_line[i] = 1; + elem = 1; } device->interface(m_interface); diff --git a/src/devices/bus/chanf/slot.cpp b/src/devices/bus/chanf/slot.cpp index ad6eae7bde8..f46abf3b7c3 100644 --- a/src/devices/bus/chanf/slot.cpp +++ b/src/devices/bus/chanf/slot.cpp @@ -134,10 +134,10 @@ static const chanf_slot slot_list[] = static int chanf_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -145,10 +145,10 @@ static int chanf_get_pcb_id(const char *slot) static const char *chanf_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "chess"; diff --git a/src/devices/bus/comx35/expbox.cpp b/src/devices/bus/comx35/expbox.cpp index be5bc3bee73..ce0dec61006 100644 --- a/src/devices/bus/comx35/expbox.cpp +++ b/src/devices/bus/comx35/expbox.cpp @@ -149,9 +149,9 @@ void comx_eb_device::device_start() m_expansion_slot[2] = dynamic_cast(subdevice(SLOT3_TAG)); m_expansion_slot[3] = dynamic_cast(subdevice(SLOT4_TAG)); - for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + for (auto & elem : m_irq) { - m_irq[slot] = CLEAR_LINE; + elem = CLEAR_LINE; } } @@ -162,12 +162,12 @@ void comx_eb_device::device_start() void comx_eb_device::device_reset() { - for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + for (auto & elem : m_expansion_slot) { - if (m_expansion_slot[slot] != nullptr) + if (elem != nullptr) { - m_expansion_slot[slot]->device().reset(); - m_expansion_slot[slot]->ds_w(0); + elem->device().reset(); + elem->ds_w(0); } } } @@ -181,11 +181,11 @@ int comx_eb_device::comx_ef4_r() { int state = CLEAR_LINE; - for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + for (auto & elem : m_expansion_slot) { - if (m_expansion_slot[slot] != nullptr) + if (elem != nullptr) { - state |= m_expansion_slot[slot]->ef4_r(); + state |= elem->ef4_r(); } } @@ -199,11 +199,11 @@ int comx_eb_device::comx_ef4_r() void comx_eb_device::comx_q_w(int state) { - for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + for (auto & elem : m_expansion_slot) { - if (m_expansion_slot[slot] != nullptr) + if (elem != nullptr) { - m_expansion_slot[slot]->q_w(state); + elem->q_w(state); } } } diff --git a/src/devices/bus/crvision/slot.cpp b/src/devices/bus/crvision/slot.cpp index df7caa51f95..207105ea1d6 100644 --- a/src/devices/bus/crvision/slot.cpp +++ b/src/devices/bus/crvision/slot.cpp @@ -125,10 +125,10 @@ static const crvision_slot slot_list[] = static int crvision_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -136,10 +136,10 @@ static int crvision_get_pcb_id(const char *slot) static const char *crvision_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "crv_rom4k"; diff --git a/src/devices/bus/ecbbus/ecbbus.cpp b/src/devices/bus/ecbbus/ecbbus.cpp index 100af329b10..c96d49da103 100644 --- a/src/devices/bus/ecbbus/ecbbus.cpp +++ b/src/devices/bus/ecbbus/ecbbus.cpp @@ -95,8 +95,8 @@ ecbbus_device::ecbbus_device(const machine_config &mconfig, const char *tag, dev m_write_irq(*this), m_write_nmi(*this) { - for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) - m_ecbbus_device[i] = nullptr; + for (auto & elem : m_ecbbus_device) + elem = nullptr; } @@ -130,11 +130,11 @@ READ8_MEMBER( ecbbus_device::mem_r ) { UINT8 data = 0; - for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) + for (auto & elem : m_ecbbus_device) { - if (m_ecbbus_device[i] != nullptr) + if (elem != nullptr) { - data |= m_ecbbus_device[i]->ecbbus_mem_r(offset); + data |= elem->ecbbus_mem_r(offset); } } @@ -148,11 +148,11 @@ READ8_MEMBER( ecbbus_device::mem_r ) WRITE8_MEMBER( ecbbus_device::mem_w ) { - for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) + for (auto & elem : m_ecbbus_device) { - if (m_ecbbus_device[i] != nullptr) + if (elem != nullptr) { - m_ecbbus_device[i]->ecbbus_mem_w(offset, data); + elem->ecbbus_mem_w(offset, data); } } } @@ -166,11 +166,11 @@ READ8_MEMBER( ecbbus_device::io_r ) { UINT8 data = 0; - for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) + for (auto & elem : m_ecbbus_device) { - if (m_ecbbus_device[i] != nullptr) + if (elem != nullptr) { - data |= m_ecbbus_device[i]->ecbbus_io_r(offset); + data |= elem->ecbbus_io_r(offset); } } @@ -184,11 +184,11 @@ READ8_MEMBER( ecbbus_device::io_r ) WRITE8_MEMBER( ecbbus_device::io_w ) { - for (int i = 0; i < MAX_ECBBUS_SLOTS; i++) + for (auto & elem : m_ecbbus_device) { - if (m_ecbbus_device[i] != nullptr) + if (elem != nullptr) { - m_ecbbus_device[i]->ecbbus_io_w(offset, data); + elem->ecbbus_io_w(offset, data); } } } diff --git a/src/devices/bus/econet/econet.cpp b/src/devices/bus/econet/econet.cpp index f1a2ff110e0..e56d843db32 100644 --- a/src/devices/bus/econet/econet.cpp +++ b/src/devices/bus/econet/econet.cpp @@ -198,9 +198,9 @@ econet_device::econet_device(const machine_config &mconfig, const char *tag, dev m_write_clk(*this), m_write_data(*this) { - for (int i = 0; i < SIGNAL_COUNT; i++) + for (auto & elem : m_line) { - m_line[i] = 1; + elem = 1; } } @@ -251,9 +251,9 @@ econet_device::daisy_entry::daisy_entry(device_t *device) : m_device(device), m_interface(nullptr) { - for (int i = 0; i < SIGNAL_COUNT; i++) + for (auto & elem : m_line) { - m_line[i] = 1; + elem = 1; } device->interface(m_interface); diff --git a/src/devices/bus/gameboy/gb_slot.cpp b/src/devices/bus/gameboy/gb_slot.cpp index 19ddda4601b..e70eb07c6d2 100644 --- a/src/devices/bus/gameboy/gb_slot.cpp +++ b/src/devices/bus/gameboy/gb_slot.cpp @@ -232,10 +232,10 @@ static const gb_slot slot_list[] = static int gb_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -243,10 +243,10 @@ static int gb_get_pcb_id(const char *slot) static const char *gb_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "rom"; diff --git a/src/devices/bus/gba/gba_slot.cpp b/src/devices/bus/gba/gba_slot.cpp index 2618b7ad09f..fc8f09f30a0 100644 --- a/src/devices/bus/gba/gba_slot.cpp +++ b/src/devices/bus/gba/gba_slot.cpp @@ -138,10 +138,10 @@ static const gba_slot slot_list[] = static int gba_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -149,10 +149,10 @@ static int gba_get_pcb_id(const char *slot) static const char *gba_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "gba_rom"; @@ -324,9 +324,9 @@ int gba_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len) chip &= ~(GBA_CHIP_EEPROM | GBA_CHIP_EEPROM_4K | GBA_CHIP_EEPROM_64K | GBA_CHIP_FLASH | GBA_CHIP_FLASH_1M | GBA_CHIP_FLASH_512 | GBA_CHIP_SRAM); // search if it is one of the known titles with NVRAM conflicts - for (int i = 0; i < sizeof(gba_chip_fix_conflict_list) / sizeof(gba_chip_fix_conflict_item); i++) + for (auto & elem : gba_chip_fix_conflict_list) { - const gba_chip_fix_conflict_item *item = &gba_chip_fix_conflict_list[i]; + const gba_chip_fix_conflict_item *item = &elem; if (!strcmp(game_code, item->game_code)) { chip |= item->chip; @@ -348,9 +348,9 @@ int gba_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len) osd_printf_info("GBA: Game Code \"%s\"\n", game_code); - for (int i = 0; i < sizeof(gba_chip_fix_eeprom_list) / sizeof(gba_chip_fix_eeprom_item); i++) + for (auto & elem : gba_chip_fix_eeprom_list) { - const gba_chip_fix_eeprom_item *item = &gba_chip_fix_eeprom_list[i]; + const gba_chip_fix_eeprom_item *item = &elem; if (!strcmp(game_code, item->game_code)) { chip = (chip & ~GBA_CHIP_EEPROM) | GBA_CHIP_EEPROM_64K; diff --git a/src/devices/bus/ieee488/ieee488.cpp b/src/devices/bus/ieee488/ieee488.cpp index c217407d49e..38a1f538404 100644 --- a/src/devices/bus/ieee488/ieee488.cpp +++ b/src/devices/bus/ieee488/ieee488.cpp @@ -112,9 +112,9 @@ ieee488_device::ieee488_device(const machine_config &mconfig, const char *tag, d m_write_ren(*this), m_dio(0xff) { - for (int i = 0; i < SIGNAL_COUNT; i++) + for (auto & elem : m_line) { - m_line[i] = 1; + elem = 1; } } @@ -172,9 +172,9 @@ ieee488_device::daisy_entry::daisy_entry(device_t *device) m_interface(nullptr), m_dio(0xff) { - for (int i = 0; i < SIGNAL_COUNT; i++) + for (auto & elem : m_line) { - m_line[i] = 1; + elem = 1; } device->interface(m_interface); diff --git a/src/devices/bus/intv/slot.cpp b/src/devices/bus/intv/slot.cpp index 342a40964f4..05e55e49318 100644 --- a/src/devices/bus/intv/slot.cpp +++ b/src/devices/bus/intv/slot.cpp @@ -207,10 +207,10 @@ static const intv_slot slot_list[] = static int intv_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -219,10 +219,10 @@ static int intv_get_pcb_id(const char *slot) #if 1 static const char *intv_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "intv_rom"; diff --git a/src/devices/bus/isa/cga.cpp b/src/devices/bus/isa/cga.cpp index 3c1cd22cab7..8f99ddc0792 100644 --- a/src/devices/bus/isa/cga.cpp +++ b/src/devices/bus/isa/cga.cpp @@ -1593,9 +1593,9 @@ void isa8_cga_pc1512_device::device_reset() m_write = 0x0f; m_read = 0; m_mc6845_address = 0; - for ( int i = 0; i < 31; i++ ) + for (auto & elem : m_mc6845_locked_register) { - m_mc6845_locked_register[i] = 0; + elem = 0; } membank("bank1")->set_base(&m_vram[isa8_cga_pc1512_device::vram_offset[0]]); diff --git a/src/devices/bus/kc/d002.cpp b/src/devices/bus/kc/d002.cpp index 7abf3aa6b47..fdb36a8c34d 100644 --- a/src/devices/bus/kc/d002.cpp +++ b/src/devices/bus/kc/d002.cpp @@ -161,8 +161,8 @@ ioport_constructor kc_d002_device::device_input_ports() const void kc_d002_device::read(offs_t offset, UINT8 &data) { - for (int i=0; i<5; i++) - m_expansions[i]->read(offset, data); + for (auto & elem : m_expansions) + elem->read(offset, data); } //------------------------------------------------- @@ -171,8 +171,8 @@ void kc_d002_device::read(offs_t offset, UINT8 &data) void kc_d002_device::write(offs_t offset, UINT8 data) { - for (int i=0; i<5; i++) - m_expansions[i]->write(offset, data); + for (auto & elem : m_expansions) + elem->write(offset, data); } //------------------------------------------------- @@ -192,8 +192,8 @@ void kc_d002_device::io_read(offs_t offset, UINT8 &data) } else { - for (int i=0; i<5; i++) - m_expansions[i]->io_read(offset, data); + for (auto & elem : m_expansions) + elem->io_read(offset, data); } } @@ -214,8 +214,8 @@ void kc_d002_device::io_write(offs_t offset, UINT8 data) } else { - for (int i=0; i<5; i++) - m_expansions[i]->io_write(offset, data); + for (auto & elem : m_expansions) + elem->io_write(offset, data); } } diff --git a/src/devices/bus/lpci/pci.cpp b/src/devices/bus/lpci/pci.cpp index 90e13e9eb22..aa095a8cd4e 100644 --- a/src/devices/bus/lpci/pci.cpp +++ b/src/devices/bus/lpci/pci.cpp @@ -93,8 +93,8 @@ pci_bus_device::pci_bus_device(const machine_config &mconfig, const char *tag, d device_t(mconfig, PCI_BUS, "PCI Bus", tag, owner, clock, "pci_bus", __FILE__), m_busnum(0), m_father(nullptr), m_address(0), m_devicenum(0), m_busnumber(0), m_busnumaddr(nullptr) { - for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++) { - m_devtag[i]= nullptr; + for (auto & elem : m_devtag) { + elem= nullptr; } m_siblings_count = 0; } diff --git a/src/devices/bus/megadrive/md_slot.cpp b/src/devices/bus/megadrive/md_slot.cpp index 45fc6b75030..2d0ff90acb6 100644 --- a/src/devices/bus/megadrive/md_slot.cpp +++ b/src/devices/bus/megadrive/md_slot.cpp @@ -289,10 +289,10 @@ static const md_slot slot_list[] = static int md_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return SEGA_STD; @@ -300,10 +300,10 @@ static int md_get_pcb_id(const char *slot) static const char *md_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "rom"; diff --git a/src/devices/bus/msx_cart/ascii.cpp b/src/devices/bus/msx_cart/ascii.cpp index 07da54de8b7..04ef820e7d9 100644 --- a/src/devices/bus/msx_cart/ascii.cpp +++ b/src/devices/bus/msx_cart/ascii.cpp @@ -43,9 +43,9 @@ void msx_cart_ascii8::restore_banks() void msx_cart_ascii8::device_reset() { - for (int i = 0; i < 4; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } } @@ -127,9 +127,9 @@ void msx_cart_ascii16::restore_banks() void msx_cart_ascii16::device_reset() { - for (int i = 0; i < 2; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } } @@ -237,9 +237,9 @@ void msx_cart_ascii8_sram::restore_banks() void msx_cart_ascii8_sram::device_reset() { - for (int i = 0; i < 4; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } } @@ -362,9 +362,9 @@ void msx_cart_ascii16_sram::restore_banks() void msx_cart_ascii16_sram::device_reset() { - for (int i = 0; i < 2; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } } @@ -477,9 +477,9 @@ void msx_cart_msxwrite::restore_banks() void msx_cart_msxwrite::device_reset() { - for (int i = 0; i < 2; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } } diff --git a/src/devices/bus/msx_cart/crossblaim.cpp b/src/devices/bus/msx_cart/crossblaim.cpp index 24116832469..f36f7b4b8cc 100644 --- a/src/devices/bus/msx_cart/crossblaim.cpp +++ b/src/devices/bus/msx_cart/crossblaim.cpp @@ -11,9 +11,9 @@ msx_cart_crossblaim::msx_cart_crossblaim(const machine_config &mconfig, const ch , msx_cart_interface(mconfig, *this) , m_selected_bank(1) { - for (int i = 0; i < 4; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } } diff --git a/src/devices/bus/msx_cart/halnote.cpp b/src/devices/bus/msx_cart/halnote.cpp index 63b298e67b0..d37354dd0a5 100644 --- a/src/devices/bus/msx_cart/halnote.cpp +++ b/src/devices/bus/msx_cart/halnote.cpp @@ -69,9 +69,9 @@ void msx_cart_halnote::restore_banks() void msx_cart_halnote::device_reset() { - for (int i = 0; i < 8; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } } diff --git a/src/devices/bus/msx_cart/holy_quran.cpp b/src/devices/bus/msx_cart/holy_quran.cpp index fbb7068da02..7671e8624de 100644 --- a/src/devices/bus/msx_cart/holy_quran.cpp +++ b/src/devices/bus/msx_cart/holy_quran.cpp @@ -50,9 +50,9 @@ void msx_cart_holy_quran::restore_banks() void msx_cart_holy_quran::device_reset() { - for (int i = 0; i < 4; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } } diff --git a/src/devices/bus/msx_cart/konami.cpp b/src/devices/bus/msx_cart/konami.cpp index ee0abcda095..d9d129888fd 100644 --- a/src/devices/bus/msx_cart/konami.cpp +++ b/src/devices/bus/msx_cart/konami.cpp @@ -21,9 +21,9 @@ msx_cart_konami::msx_cart_konami(const machine_config &mconfig, const char *tag, { m_selected_bank[i] = i; } - for (int i = 0; i < 8; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } } @@ -130,9 +130,9 @@ msx_cart_konami_scc::msx_cart_konami_scc(const machine_config &mconfig, const ch { m_selected_bank[i] = i; } - for (int i = 0; i < 8; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } } @@ -299,13 +299,13 @@ msx_cart_gamemaster2::msx_cart_gamemaster2(const machine_config &mconfig, const : device_t(mconfig, MSX_CART_GAMEMASTER2, "MSX Cartridge - GAMEMASTER2", tag, owner, clock, "msx_cart_gamemaster2", __FILE__) , msx_cart_interface(mconfig, *this) { - for (int i = 0; i < 3; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } - for (int i = 0; i < 8; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } } @@ -533,21 +533,21 @@ msx_cart_konami_sound::msx_cart_konami_sound(const machine_config &mconfig, devi , m_sccplus_active(false) , m_scc_mode(0) { - for (int i = 0; i < 4; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } - for (int i = 0; i < 8; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } - for (int i = 0; i < 16; i++) + for (auto & elem : m_ram_bank) { - m_ram_bank[i] = nullptr; + elem = nullptr; } - for (int i = 0; i < 4; i++) + for (auto & elem : m_ram_enabled) { - m_ram_enabled[i] = false; + elem = false; } } diff --git a/src/devices/bus/msx_cart/korean.cpp b/src/devices/bus/msx_cart/korean.cpp index 0fb2e1bb6b4..f1dedeb9874 100644 --- a/src/devices/bus/msx_cart/korean.cpp +++ b/src/devices/bus/msx_cart/korean.cpp @@ -107,9 +107,9 @@ msx_cart_korean_90in1::msx_cart_korean_90in1(const machine_config &mconfig, cons , m_bank_mask(0) , m_selected_bank(0) { - for (int i = 0; i < 4; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } } diff --git a/src/devices/bus/msx_cart/majutsushi.cpp b/src/devices/bus/msx_cart/majutsushi.cpp index eca7aa44f6c..23091c1fb4b 100644 --- a/src/devices/bus/msx_cart/majutsushi.cpp +++ b/src/devices/bus/msx_cart/majutsushi.cpp @@ -11,13 +11,13 @@ msx_cart_majutsushi::msx_cart_majutsushi(const machine_config &mconfig, const ch , msx_cart_interface(mconfig, *this) , m_dac(*this, "dac") { - for (int i = 0; i < 4; i++) + for (auto & elem : m_selected_bank) { - m_selected_bank[i] = 0; + elem = 0; } - for (int i = 0; i < 8; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } } diff --git a/src/devices/bus/msx_cart/rtype.cpp b/src/devices/bus/msx_cart/rtype.cpp index ec430b6e2fb..ffe7d56cfba 100644 --- a/src/devices/bus/msx_cart/rtype.cpp +++ b/src/devices/bus/msx_cart/rtype.cpp @@ -11,9 +11,9 @@ msx_cart_rtype::msx_cart_rtype(const machine_config &mconfig, const char *tag, d , msx_cart_interface(mconfig, *this) , m_selected_bank(0) { - for (int i = 0; i < 2; i++) + for (auto & elem : m_bank_base) { - m_bank_base[i] = nullptr; + elem = nullptr; } } diff --git a/src/devices/bus/msx_slot/cartridge.cpp b/src/devices/bus/msx_slot/cartridge.cpp index 22e4e6c11ec..43a92a94906 100644 --- a/src/devices/bus/msx_slot/cartridge.cpp +++ b/src/devices/bus/msx_slot/cartridge.cpp @@ -85,10 +85,10 @@ static const struct static const char *msx_cart_get_slot_option(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return slot_list[0].slot_option; @@ -315,11 +315,11 @@ void msx_slot_cartridge_device::get_default_card_software(std::string &result) { 17, KOREAN_126IN1 } }; - for (int i = 0; i < ARRAY_LENGTH(extrainfo_map); i++) + for (auto & elem : extrainfo_map) { - if (extrainfo_map[i].extrainfo == extrainfo_type) + if (elem.extrainfo == extrainfo_type) { - type = extrainfo_map[i].mapper; + type = elem.mapper; } } } diff --git a/src/devices/bus/nes/mmc5.cpp b/src/devices/bus/nes/mmc5.cpp index c3a82e02c8e..4fcc50282d3 100644 --- a/src/devices/bus/nes/mmc5.cpp +++ b/src/devices/bus/nes/mmc5.cpp @@ -122,8 +122,8 @@ void nes_exrom_device::pcb_reset() m_ex1_bank = 0; m_vcount = 0; - for (int i = 0; i < 12; i++) - m_vrom_bank[i] = 0x3ff; + for (auto & elem : m_vrom_bank) + elem = 0x3ff; m_prg_regs[0] = 0xfc; m_prg_regs[1] = 0xfd; diff --git a/src/devices/bus/nes/nes_pcb.inc b/src/devices/bus/nes/nes_pcb.inc index fdaceb3c1ba..b7af5aeefd4 100644 --- a/src/devices/bus/nes/nes_pcb.inc +++ b/src/devices/bus/nes/nes_pcb.inc @@ -325,20 +325,20 @@ static const nes_pcb pcb_list[] = static const nes_pcb *nes_pcb_lookup( const char *slot ) { - for (int i = 0; i < ARRAY_LENGTH(pcb_list); i++) + for (auto & elem : pcb_list) { - if (!core_stricmp(pcb_list[i].slot_opt, slot)) - return &pcb_list[i]; + if (!core_stricmp(elem.slot_opt, slot)) + return &elem; } return nullptr; } static const nes_pcb *nes_id_lookup( int id ) { - for (int i = 0; i < ARRAY_LENGTH(pcb_list); i++) + for (auto & elem : pcb_list) { - if (pcb_list[i].pcb_id == id) - return &pcb_list[i]; + if (elem.pcb_id == id) + return &elem; } return nullptr; } diff --git a/src/devices/bus/odyssey2/slot.cpp b/src/devices/bus/odyssey2/slot.cpp index 69473618b04..e4d3f4c8d3c 100644 --- a/src/devices/bus/odyssey2/slot.cpp +++ b/src/devices/bus/odyssey2/slot.cpp @@ -133,10 +133,10 @@ static const o2_slot slot_list[] = static int o2_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -144,10 +144,10 @@ static int o2_get_pcb_id(const char *slot) static const char *o2_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "o2_rom"; diff --git a/src/devices/bus/pce/pce_slot.cpp b/src/devices/bus/pce/pce_slot.cpp index fb145d1a6a6..254993a4714 100644 --- a/src/devices/bus/pce/pce_slot.cpp +++ b/src/devices/bus/pce/pce_slot.cpp @@ -197,10 +197,10 @@ static const pce_slot slot_list[] = static int pce_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -208,10 +208,10 @@ static int pce_get_pcb_id(const char *slot) static const char *pce_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "rom"; diff --git a/src/devices/bus/scv/slot.cpp b/src/devices/bus/scv/slot.cpp index 733c8258ea0..e29221b411a 100644 --- a/src/devices/bus/scv/slot.cpp +++ b/src/devices/bus/scv/slot.cpp @@ -135,10 +135,10 @@ static const scv_slot slot_list[] = static int scv_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -146,10 +146,10 @@ static int scv_get_pcb_id(const char *slot) static const char *scv_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "rom8k"; diff --git a/src/devices/bus/sega8/sega8_slot.cpp b/src/devices/bus/sega8/sega8_slot.cpp index a1be24b7f2e..c88be013d3f 100644 --- a/src/devices/bus/sega8/sega8_slot.cpp +++ b/src/devices/bus/sega8/sega8_slot.cpp @@ -188,10 +188,10 @@ static const sega8_slot slot_list[] = static int sega8_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -199,10 +199,10 @@ static int sega8_get_pcb_id(const char *slot) static const char *sega8_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "rom"; diff --git a/src/devices/bus/snes/sdd1.cpp b/src/devices/bus/snes/sdd1.cpp index ccfed10ebe1..56376641705 100644 --- a/src/devices/bus/snes/sdd1.cpp +++ b/src/devices/bus/snes/sdd1.cpp @@ -188,10 +188,10 @@ static const SDD1_PEM_state PEM_evolution_table[33] = void SDD1_PEM::PEM_prepareDecomp() { - for (int i = 0; i < 32; i++) + for (auto & elem : m_contextInfo) { - m_contextInfo[i].status = 0; - m_contextInfo[i].MPS = 0; + elem.status = 0; + elem.MPS = 0; } } @@ -459,10 +459,10 @@ void sns_rom_sdd1_device::device_reset() m_mmc[2] = 2 << 20; m_mmc[3] = 3 << 20; - for(int i = 0; i < 8; i++) + for(auto & elem : m_dma) { - m_dma[i].addr = 0; - m_dma[i].size = 0; + elem.addr = 0; + elem.size = 0; } } diff --git a/src/devices/bus/snes/snes_slot.cpp b/src/devices/bus/snes/snes_slot.cpp index 5f439459bfc..10add2da1cc 100644 --- a/src/devices/bus/snes/snes_slot.cpp +++ b/src/devices/bus/snes/snes_slot.cpp @@ -289,10 +289,10 @@ static const sns_slot slot_list[] = static int sns_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -300,10 +300,10 @@ static int sns_get_pcb_id(const char *slot) static const char *sns_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "lorom"; diff --git a/src/devices/bus/snes/spc7110.cpp b/src/devices/bus/snes/spc7110.cpp index 156b26c0df4..a6ebbdab2df 100644 --- a/src/devices/bus/snes/spc7110.cpp +++ b/src/devices/bus/snes/spc7110.cpp @@ -389,10 +389,10 @@ void SPC7110_Decomp::init(running_machine &machine, UINT8 *ROM, UINT32 len, UINT m_decomp_buffer_length = 0; //reset context states - for (int i = 0; i < 32; i++) + for (auto & elem : m_context) { - m_context[i].index = 0; - m_context[i].invert = 0; + elem.index = 0; + elem.invert = 0; } switch (m_decomp_mode) @@ -873,9 +873,9 @@ void SPC7110_Decomp::mode2(UINT8 init, UINT8 *ROM, UINT32 len) if (m_m2_buffer_index == 16) { - for (int i = 0; i < 16; i++) + for (auto & elem : m_m2_bitplanebuffer) { - write(m_m2_bitplanebuffer[i]); + write(elem); } m_m2_buffer_index = 0; } diff --git a/src/devices/bus/ti99_peb/bwg.cpp b/src/devices/bus/ti99_peb/bwg.cpp index 0f5f338bda0..cc1cedaf45b 100644 --- a/src/devices/bus/ti99_peb/bwg.cpp +++ b/src/devices/bus/ti99_peb/bwg.cpp @@ -547,8 +547,8 @@ void snug_bwg_device::set_floppy_motors_running(bool run) m_wd1773->set_force_ready(run); // Set all motors - for (int i=0; i < 4; i++) - if (m_floppy[i] != nullptr) m_floppy[i]->mon_w((run)? 0 : 1); + for (auto & elem : m_floppy) + if (elem != nullptr) elem->mon_w((run)? 0 : 1); // The motor-on line also connects to the wait state logic operate_ready_line(); @@ -621,8 +621,8 @@ void snug_bwg_device::device_reset() void snug_bwg_device::device_config_complete() { - for (int i=0; i < 4; i++) - m_floppy[i] = nullptr; + for (auto & elem : m_floppy) + elem = nullptr; // Seems to be null when doing a "-listslots" if (subdevice("0")!=nullptr) m_floppy[0] = static_cast(subdevice("0")->first_subdevice()); diff --git a/src/devices/bus/ti99_peb/hfdc.cpp b/src/devices/bus/ti99_peb/hfdc.cpp index e1def78eedb..dddc49a4aeb 100644 --- a/src/devices/bus/ti99_peb/hfdc.cpp +++ b/src/devices/bus/ti99_peb/hfdc.cpp @@ -802,8 +802,8 @@ void myarc_hfdc_device::set_floppy_motors_running(bool run) } // Set all motors - for (int i=0; i < 4; i++) - if (m_floppy_unit[i] != nullptr) m_floppy_unit[i]->mon_w((run)? 0 : 1); + for (auto & elem : m_floppy_unit) + if (elem != nullptr) elem->mon_w((run)? 0 : 1); } /* diff --git a/src/devices/bus/ti99_peb/memex.cpp b/src/devices/bus/ti99_peb/memex.cpp index 21ddf1a860a..4f1bbd56a0f 100644 --- a/src/devices/bus/ti99_peb/memex.cpp +++ b/src/devices/bus/ti99_peb/memex.cpp @@ -125,9 +125,9 @@ void geneve_memex_device::device_reset() { UINT8 dips = ioport("MEMEXDIPS")->read(); if (VERBOSE>5) LOG("geneve: memex dips = %02x\n", dips); - for (int i=0; i < 8; i++) + for (auto & elem : m_dip_switch) { - m_dip_switch[i] = ((dips & 0x01)!=0x00); + elem = ((dips & 0x01)!=0x00); dips = dips >> 1; } } diff --git a/src/devices/bus/ti99_peb/pcode.cpp b/src/devices/bus/ti99_peb/pcode.cpp index 9baff162ac7..e16baa7145c 100644 --- a/src/devices/bus/ti99_peb/pcode.cpp +++ b/src/devices/bus/ti99_peb/pcode.cpp @@ -107,7 +107,7 @@ READ8Z_MEMBER( ti_pcode_card_device::readz ) // GROM access if ((offset & GROMMASK)==GROMREAD) { - for (int i=0; i < 8; i++) m_grom[i]->readz(space, offset, value, mem_mask); + for (auto & elem : m_grom) elem->readz(space, offset, value, mem_mask); if (VERBOSE>5) LOG("ti99_pcode: read from grom %04x: %02x\n", offset&0xffff, *value); } else @@ -148,7 +148,7 @@ WRITE8_MEMBER( ti_pcode_card_device::write ) // 0101 1111 1111 11x0 if ((offset & GROMMASK) == GROMWRITE) { - for (int i=0; i < 8; i++) m_grom[i]->write(space, offset, data, mem_mask); + for (auto & elem : m_grom) elem->write(space, offset, data, mem_mask); } } } diff --git a/src/devices/bus/ti99_peb/samsmem.cpp b/src/devices/bus/ti99_peb/samsmem.cpp index aeb39aa92af..4f8cd48189c 100644 --- a/src/devices/bus/ti99_peb/samsmem.cpp +++ b/src/devices/bus/ti99_peb/samsmem.cpp @@ -122,7 +122,7 @@ void sams_memory_expansion_device::device_reset() // Resetting values m_map_mode = false; m_access_mapper = false; - for (int i=0; i < 16; i++) m_mapper[i] = 0; + for (auto & elem : m_mapper) elem = 0; } const rom_entry *sams_memory_expansion_device::device_rom_region() const diff --git a/src/devices/bus/ti99_peb/ti_fdc.cpp b/src/devices/bus/ti99_peb/ti_fdc.cpp index c595bcea1e8..82585c424ce 100644 --- a/src/devices/bus/ti99_peb/ti_fdc.cpp +++ b/src/devices/bus/ti99_peb/ti_fdc.cpp @@ -333,8 +333,8 @@ void ti_fdc_device::set_floppy_motors_running(bool run) m_fd1771->set_force_ready(run); // Set all motors - for (int i=0; i < 3; i++) - if (m_floppy[i] != nullptr) m_floppy[i]->mon_w((run)? 0 : 1); + for (auto & elem : m_floppy) + if (elem != nullptr) elem->mon_w((run)? 0 : 1); // The motor-on line also connects to the wait state logic operate_ready_line(); diff --git a/src/devices/bus/ti99x/990_dk.cpp b/src/devices/bus/ti99x/990_dk.cpp index 058d3f7665f..16fd5920d7c 100644 --- a/src/devices/bus/ti99x/990_dk.cpp +++ b/src/devices/bus/ti99x/990_dk.cpp @@ -874,12 +874,12 @@ void fd800_legacy_device::device_start(void) logerror("fd800: start\n"); m_int_line.resolve(); - for (int i=0; iwrite(space, offset, data, mem_mask); + elem->write(space, offset, data, mem_mask); } } } @@ -539,9 +539,9 @@ void multi_conn_device::device_start() { m_next_free_slot = 0; m_active_slot = 0; - for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) + for (auto & elem : m_cartridge) { - m_cartridge[i] = nullptr; + elem = nullptr; } } @@ -1474,22 +1474,22 @@ void ti99_cartridge_pcb::set_cartridge(ti99_cartridge_device *cart) READ8Z_MEMBER(ti99_cartridge_pcb::gromreadz) { - for (int i=0; i < 5; i++) + for (auto & elem : m_grom) { - if (m_grom[i] != nullptr) + if (elem != nullptr) { - m_grom[i]->readz(space, offset, value, mem_mask); + elem->readz(space, offset, value, mem_mask); } } } WRITE8_MEMBER(ti99_cartridge_pcb::gromwrite) { - for (int i=0; i < 5; i++) + for (auto & elem : m_grom) { - if (m_grom[i] != nullptr) + if (elem != nullptr) { - m_grom[i]->write(space, offset, data, mem_mask); + elem->write(space, offset, data, mem_mask); } } } diff --git a/src/devices/bus/vboy/slot.cpp b/src/devices/bus/vboy/slot.cpp index 863a0ff9ad0..88ef2ce7a2f 100644 --- a/src/devices/bus/vboy/slot.cpp +++ b/src/devices/bus/vboy/slot.cpp @@ -132,10 +132,10 @@ static const vboy_slot slot_list[] = static int vboy_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; diff --git a/src/devices/bus/vc4000/slot.cpp b/src/devices/bus/vc4000/slot.cpp index a7c8fc23ec4..ecfc63b42dd 100644 --- a/src/devices/bus/vc4000/slot.cpp +++ b/src/devices/bus/vc4000/slot.cpp @@ -145,10 +145,10 @@ static const vc4000_slot slot_list[] = static int vc4000_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -156,10 +156,10 @@ static int vc4000_get_pcb_id(const char *slot) static const char *vc4000_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "std"; diff --git a/src/devices/bus/vcs/dpc.cpp b/src/devices/bus/vcs/dpc.cpp index 87a2ee34424..fac776fabb1 100644 --- a/src/devices/bus/vcs/dpc.cpp +++ b/src/devices/bus/vcs/dpc.cpp @@ -55,11 +55,11 @@ void dpc_device::device_start() void dpc_device::device_reset() { - for (int data_fetcher = 0; data_fetcher < 8; data_fetcher++) + for (auto & elem : m_df) { - m_df[data_fetcher].osc_clk = 0; - m_df[data_fetcher].flag = 0; - m_df[data_fetcher].music_mode = 0; + elem.osc_clk = 0; + elem.flag = 0; + elem.music_mode = 0; } m_oscillator->adjust(attotime::from_hz(18400), 0, attotime::from_hz(18400)); diff --git a/src/devices/bus/vcs/vcs_slot.cpp b/src/devices/bus/vcs/vcs_slot.cpp index 1b12824f6ab..caa46ef358b 100755 --- a/src/devices/bus/vcs/vcs_slot.cpp +++ b/src/devices/bus/vcs/vcs_slot.cpp @@ -162,10 +162,10 @@ static const vcs_slot slot_list[] = static int vcs_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -173,10 +173,10 @@ static int vcs_get_pcb_id(const char *slot) static const char *vcs_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "a26_4k"; @@ -671,9 +671,9 @@ int vcs_cart_slot_device::detect_super_chip(UINT8 *cart, UINT32 len) { for (int i = 0; i < len - sizeof signatures[0]; i++) { - for (int j = 0; j < (sizeof signatures/sizeof signatures[0]); j++) + for (auto & signature : signatures) { - if (!memcmp(&cart[i], &signatures[j], sizeof signatures[0])) + if (!memcmp(&cart[i], &signature, sizeof signatures[0])) { return 1; } diff --git a/src/devices/bus/vectrex/slot.cpp b/src/devices/bus/vectrex/slot.cpp index fb9e9577ddd..a7322b0b994 100644 --- a/src/devices/bus/vectrex/slot.cpp +++ b/src/devices/bus/vectrex/slot.cpp @@ -135,10 +135,10 @@ static int vectrex_get_pcb_id(const char *slot) static const char *vectrex_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "vec_rom"; diff --git a/src/devices/bus/vic20/vic1010.cpp b/src/devices/bus/vic20/vic1010.cpp index 98fd3552afa..5aa981edb5a 100644 --- a/src/devices/bus/vic20/vic1010.cpp +++ b/src/devices/bus/vic20/vic1010.cpp @@ -86,9 +86,9 @@ void vic1010_device::device_start() void vic1010_device::device_reset() { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->reset(); + elem->reset(); } } @@ -99,9 +99,9 @@ void vic1010_device::device_reset() UINT8 vic1010_device::vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto elem : m_expansion_slot) { - UINT8 slot_data = m_expansion_slot[i]->cd_r(space, offset, data, ram1, ram2, ram3, blk1, blk2, blk3, blk5, io2, io3); + UINT8 slot_data = elem->cd_r(space, offset, data, ram1, ram2, ram3, blk1, blk2, blk3, blk5, io2, io3); if (data != slot_data) { @@ -119,8 +119,8 @@ UINT8 vic1010_device::vic20_cd_r(address_space &space, offs_t offset, UINT8 data void vic1010_device::vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->cd_w(space, offset, data, ram1, ram2, ram3, blk1, blk2, blk3, blk5, io2, io3); + elem->cd_w(space, offset, data, ram1, ram2, ram3, blk1, blk2, blk3, blk5, io2, io3); } } diff --git a/src/devices/bus/vip/vp575.cpp b/src/devices/bus/vip/vp575.cpp index 9037498a664..680a2a14369 100644 --- a/src/devices/bus/vip/vp575.cpp +++ b/src/devices/bus/vip/vp575.cpp @@ -128,9 +128,9 @@ UINT8 vp575_device::vip_program_r(address_space &space, offs_t offset, int cs, i { UINT8 data = 0xff; - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - data &= m_expansion_slot[i]->program_r(space, offset, cs, cdef, minh); + data &= elem->program_r(space, offset, cs, cdef, minh); } return data; @@ -143,9 +143,9 @@ UINT8 vp575_device::vip_program_r(address_space &space, offs_t offset, int cs, i void vp575_device::vip_program_w(address_space &space, offs_t offset, UINT8 data, int cdef, int *minh) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->program_w(space, offset, data, cdef, minh); + elem->program_w(space, offset, data, cdef, minh); } } @@ -158,9 +158,9 @@ UINT8 vp575_device::vip_io_r(address_space &space, offs_t offset) { UINT8 data = 0xff; - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - data &= m_expansion_slot[i]->io_r(space, offset); + data &= elem->io_r(space, offset); } return data; @@ -173,9 +173,9 @@ UINT8 vp575_device::vip_io_r(address_space &space, offs_t offset) void vp575_device::vip_io_w(address_space &space, offs_t offset, UINT8 data) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->io_w(space, offset, data); + elem->io_w(space, offset, data); } } @@ -188,9 +188,9 @@ UINT8 vp575_device::vip_dma_r(address_space &space, offs_t offset) { UINT8 data = 0xff; - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - data &= m_expansion_slot[i]->dma_r(space, offset); + data &= elem->dma_r(space, offset); } return data; @@ -203,9 +203,9 @@ UINT8 vp575_device::vip_dma_r(address_space &space, offs_t offset) void vp575_device::vip_dma_w(address_space &space, offs_t offset, UINT8 data) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->dma_w(space, offset, data); + elem->dma_w(space, offset, data); } } @@ -218,9 +218,9 @@ UINT32 vp575_device::vip_screen_update(screen_device &screen, bitmap_rgb32 &bitm { UINT32 data = 0; - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - data |= m_expansion_slot[i]->screen_update(screen, bitmap, cliprect); + data |= elem->screen_update(screen, bitmap, cliprect); } return data; @@ -235,9 +235,9 @@ int vp575_device::vip_ef1_r() { int state = CLEAR_LINE; - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - state |= m_expansion_slot[i]->ef1_r(); + state |= elem->ef1_r(); } return state; @@ -252,9 +252,9 @@ int vp575_device::vip_ef3_r() { int state = CLEAR_LINE; - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - state |= m_expansion_slot[i]->ef3_r(); + state |= elem->ef3_r(); } return state; @@ -269,9 +269,9 @@ int vp575_device::vip_ef4_r() { int state = CLEAR_LINE; - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - state |= m_expansion_slot[i]->ef4_r(); + state |= elem->ef4_r(); } return state; @@ -284,9 +284,9 @@ int vp575_device::vip_ef4_r() void vp575_device::vip_sc_w(int data) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->sc_w(data); + elem->sc_w(data); } } @@ -297,9 +297,9 @@ void vp575_device::vip_sc_w(int data) void vp575_device::vip_q_w(int state) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->q_w(state); + elem->q_w(state); } } @@ -310,8 +310,8 @@ void vp575_device::vip_q_w(int state) void vp575_device::vip_run_w(int state) { - for (int i = 0; i < MAX_SLOTS; i++) + for (auto & elem : m_expansion_slot) { - m_expansion_slot[i]->run_w(state); + elem->run_w(state); } } diff --git a/src/devices/bus/wswan/slot.cpp b/src/devices/bus/wswan/slot.cpp index 7547be9357d..749f82596e1 100644 --- a/src/devices/bus/wswan/slot.cpp +++ b/src/devices/bus/wswan/slot.cpp @@ -135,10 +135,10 @@ static const ws_slot slot_list[] = static int ws_get_pcb_id(const char *slot) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (!core_stricmp(slot_list[i].slot_option, slot)) - return slot_list[i].pcb_id; + if (!core_stricmp(elem.slot_option, slot)) + return elem.pcb_id; } return 0; @@ -146,10 +146,10 @@ static int ws_get_pcb_id(const char *slot) static const char *ws_get_slot(int type) { - for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + for (auto & elem : slot_list) { - if (slot_list[i].pcb_id == type) - return slot_list[i].slot_option; + if (elem.pcb_id == type) + return elem.slot_option; } return "std"; diff --git a/src/devices/cpu/arcompact/arcompact.cpp b/src/devices/cpu/arcompact/arcompact.cpp index dca1bf9fd91..7c56a774601 100644 --- a/src/devices/cpu/arcompact/arcompact.cpp +++ b/src/devices/cpu/arcompact/arcompact.cpp @@ -175,8 +175,8 @@ void arcompact_device::device_reset() m_delayactive = 0; m_delayjump = 0x00000000; - for (int i = 0; i < 0x40; i++) - m_regs[i] = 0; + for (auto & elem : m_regs) + elem = 0; m_status32 = 0; m_LP_START = 0; diff --git a/src/devices/cpu/arm/arm.cpp b/src/devices/cpu/arm/arm.cpp index b8025a438b9..aa07ddcfecb 100644 --- a/src/devices/cpu/arm/arm.cpp +++ b/src/devices/cpu/arm/arm.cpp @@ -318,13 +318,13 @@ void arm_cpu_device::SetModeRegister( int mode, int rIndex, UINT32 value ) void arm_cpu_device::device_reset() { - for ( int i = 0; i < 27; i++ ) + for (auto & elem : m_sArmRegister) { - m_sArmRegister[i] = 0; + elem = 0; } - for ( int i = 0; i < 16; i++ ) + for (auto & elem : m_coproRegister) { - m_coproRegister[i] = 0; + elem = 0; } m_pendingIrq = 0; m_pendingFiq = 0; diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp index ebc61fec9ae..7ebafca65a1 100644 --- a/src/devices/cpu/avr8/avr8.cpp +++ b/src/devices/cpu/avr8/avr8.cpp @@ -855,9 +855,9 @@ void avr8_device::device_reset() logerror("AVR Boot loader section size: %d words\n", m_boot_size); } - for (int i = 0; i < 0x200; i++) + for (auto & elem : m_r) { - m_r[i] = 0; + elem = 0; } m_spi_active = false; diff --git a/src/devices/cpu/cosmac/cosmac.cpp b/src/devices/cpu/cosmac/cosmac.cpp index a868e604e9f..73170762cbf 100644 --- a/src/devices/cpu/cosmac/cosmac.cpp +++ b/src/devices/cpu/cosmac/cosmac.cpp @@ -292,8 +292,8 @@ cosmac_device::cosmac_device(const machine_config &mconfig, device_type type, co m_io(nullptr), m_direct(nullptr) { - for (int i = 0; i < 4; i++) - m_ef[i] = CLEAR_LINE; + for (auto & elem : m_ef) + elem = CLEAR_LINE; } diff --git a/src/devices/cpu/drcbex64.cpp b/src/devices/cpu/drcbex64.cpp index 38cb9fbcc25..b14e4cd189d 100644 --- a/src/devices/cpu/drcbex64.cpp +++ b/src/devices/cpu/drcbex64.cpp @@ -648,8 +648,8 @@ drcbe_x64::drcbe_x64(drcuml_state &drcuml, device_t &device, drc_cache &cache, U } // build the opcode table (static but it doesn't hurt to regenerate it) - for (int opnum = 0; opnum < ARRAY_LENGTH(s_opcode_table_source); opnum++) - s_opcode_table[s_opcode_table_source[opnum].opcode] = s_opcode_table_source[opnum].func; + for (auto & elem : s_opcode_table_source) + s_opcode_table[elem.opcode] = elem.func; // create the log if (device.machine().options().drc_log_native()) diff --git a/src/devices/cpu/drcbex86.cpp b/src/devices/cpu/drcbex86.cpp index e1f2b1830cb..846d054bf14 100644 --- a/src/devices/cpu/drcbex86.cpp +++ b/src/devices/cpu/drcbex86.cpp @@ -562,8 +562,8 @@ drcbe_x86::drcbe_x86(drcuml_state &drcuml, device_t &device, drc_cache &cache, U } // build the opcode table (static but it doesn't hurt to regenerate it) - for (int opnum = 0; opnum < ARRAY_LENGTH(s_opcode_table_source); opnum++) - s_opcode_table[s_opcode_table_source[opnum].opcode] = s_opcode_table_source[opnum].func; + for (auto & elem : s_opcode_table_source) + s_opcode_table[elem.opcode] = elem.func; // create the log if (device.machine().options().drc_log_native()) diff --git a/src/devices/cpu/h6280/h6280.cpp b/src/devices/cpu/h6280/h6280.cpp index f92e0520a12..d1be228e732 100644 --- a/src/devices/cpu/h6280/h6280.cpp +++ b/src/devices/cpu/h6280/h6280.cpp @@ -263,9 +263,9 @@ void h6280_device::device_start() m_icount = 0; /* clear pending interrupts */ - for (int i = 0; i < 3; i++) + for (auto & elem : m_irq_state) { - m_irq_state[i] = CLEAR_LINE; + elem = CLEAR_LINE; } m_nmi_state = CLEAR_LINE; } diff --git a/src/devices/cpu/h8/h8_timer8.cpp b/src/devices/cpu/h8/h8_timer8.cpp index dcb21adeb31..29e156edfee 100644 --- a/src/devices/cpu/h8/h8_timer8.cpp +++ b/src/devices/cpu/h8/h8_timer8.cpp @@ -278,16 +278,16 @@ void h8_timer8_channel_device::recalc_event(UINT64 cur_time) event_delay = counter_cycle; } - for(int i=0; i<2; i++) { + for(auto & elem : tcor) { UINT32 new_delay = 0xffffffff; - if(tcor[i] > tcnt) { - if(tcnt >= counter_cycle || tcor[i] <= counter_cycle) - new_delay = tcor[i] - tcnt; - } else if(tcor[i] <= counter_cycle) { + if(elem > tcnt) { + if(tcnt >= counter_cycle || elem <= counter_cycle) + new_delay = elem - tcnt; + } else if(elem <= counter_cycle) { if(tcnt < counter_cycle) - new_delay = (counter_cycle - tcnt) + tcor[i]; + new_delay = (counter_cycle - tcnt) + elem; else - new_delay = (0x100 - tcnt) + tcor[i]; + new_delay = (0x100 - tcnt) + elem; } if(event_delay > new_delay) event_delay = new_delay; diff --git a/src/devices/cpu/hcd62121/hcd62121.cpp b/src/devices/cpu/hcd62121/hcd62121.cpp index 4371edc8407..692297048c0 100644 --- a/src/devices/cpu/hcd62121/hcd62121.cpp +++ b/src/devices/cpu/hcd62121/hcd62121.cpp @@ -493,9 +493,9 @@ void hcd62121_cpu_device::device_reset() m_f = 0; m_dsize = 0; - for( int i = 0; i < 0x80; i++ ) + for(auto & elem : m_reg) { - m_reg[i] = 0; + elem = 0; } } diff --git a/src/devices/cpu/hd61700/hd61700.cpp b/src/devices/cpu/hd61700/hd61700.cpp index 30cf3f6a425..777a23de894 100644 --- a/src/devices/cpu/hd61700/hd61700.cpp +++ b/src/devices/cpu/hd61700/hd61700.cpp @@ -215,8 +215,8 @@ void hd61700_cpu_device::device_reset() memset(m_reg16bit, 0, sizeof(m_reg16bit)); memset(m_regmain, 0, sizeof(m_regmain)); - for (int i=0;i<6; i++) - m_lines_status[i] = CLEAR_LINE; + for (auto & elem : m_lines_status) + elem = CLEAR_LINE; } diff --git a/src/devices/cpu/i8089/i8089_channel.cpp b/src/devices/cpu/i8089/i8089_channel.cpp index 63e4262abf2..932d59ff229 100644 --- a/src/devices/cpu/i8089/i8089_channel.cpp +++ b/src/devices/cpu/i8089/i8089_channel.cpp @@ -96,10 +96,10 @@ void i8089_channel::device_reset() m_xfer_pending = false; // initialize registers - for (int i = 0; i < ARRAY_LENGTH(m_r); i++) + for (auto & elem : m_r) { - m_r[i].w = 0; - m_r[i].t = 0; + elem.w = 0; + elem.t = 0; } m_prio = PRIO_IDLE; } diff --git a/src/devices/cpu/i86/i186.cpp b/src/devices/cpu/i86/i186.cpp index 1cb501cbaaf..7d30f5b9771 100644 --- a/src/devices/cpu/i86/i186.cpp +++ b/src/devices/cpu/i86/i186.cpp @@ -636,19 +636,19 @@ void i80186_cpu_device::device_reset() m_intr.ext_state = 0x00; m_reloc = 0x20ff; - for (int i = 0; i < ARRAY_LENGTH(m_dma); i++) + for (auto & elem : m_dma) { - m_dma[i].drq_state = false; - m_dma[i].control = 0; + elem.drq_state = false; + elem.control = 0; } - for (int i = 0; i < ARRAY_LENGTH(m_timer); i++) + for (auto & elem : m_timer) { - m_timer[i].control = 0; - m_timer[i].maxA = 0; - m_timer[i].maxB = 0; - m_timer[i].active_count = false; - m_timer[i].count = 0; + elem.control = 0; + elem.maxA = 0; + elem.maxB = 0; + elem.active_count = false; + elem.count = 0; } } diff --git a/src/devices/cpu/m6502/m3745x.cpp b/src/devices/cpu/m6502/m3745x.cpp index 46cfdf37fba..a7f40fa7ada 100644 --- a/src/devices/cpu/m6502/m3745x.cpp +++ b/src/devices/cpu/m6502/m3745x.cpp @@ -123,9 +123,9 @@ void m3745x_device::device_reset() SP = 0x01ff; // we have the "traditional" stack in page 1, not 0 like some M740 derivatives - for (int i = 0; i < NUM_TIMERS; i++) + for (auto & elem : m_timers) { - m_timers[i]->adjust(attotime::never); + elem->adjust(attotime::never); } // all ports reset to input on startup diff --git a/src/devices/cpu/m68000/m68kcpu.cpp b/src/devices/cpu/m68000/m68kcpu.cpp index 42b59863abb..a8f52a6cdcd 100644 --- a/src/devices/cpu/m68000/m68kcpu.cpp +++ b/src/devices/cpu/m68000/m68kcpu.cpp @@ -2335,12 +2335,12 @@ void m68000_base_device::clear_all() { cpu_type= 0; // dasm_type= 0; - for (int i=0;i<16;i++) - dar[i]= 0; + for (auto & elem : dar) + elem= 0; ppc= 0; pc= 0; - for (int i=0;i<7;i++) - sp[i]= 0; + for (auto & elem : sp) + elem= 0; vbr= 0; sfc= 0; dfc= 0; diff --git a/src/devices/cpu/mcs51/mcs51.cpp b/src/devices/cpu/mcs51/mcs51.cpp index cfd4c334d00..0fc5d9449be 100644 --- a/src/devices/cpu/mcs51/mcs51.cpp +++ b/src/devices/cpu/mcs51/mcs51.cpp @@ -279,8 +279,8 @@ mcs51_cpu_device::mcs51_cpu_device(const machine_config &mconfig, device_type ty /* default to standard cmos interfacing */ - for (int i=0; i < ARRAY_LENGTH(m_forced_inputs); i++) - m_forced_inputs[i] = 0; + for (auto & elem : m_forced_inputs) + elem = 0; } diff --git a/src/devices/cpu/pdp1/pdp1.cpp b/src/devices/cpu/pdp1/pdp1.cpp index 97ac5e703f5..b36e7242967 100644 --- a/src/devices/cpu/pdp1/pdp1.cpp +++ b/src/devices/cpu/pdp1/pdp1.cpp @@ -404,9 +404,9 @@ void pdp1_device::device_config_complete() hw_mul_div = 0; type_20_sbs = 0; - for (int i = 0; i < 64; i++) + for (auto & elem : extern_iot) { - memset(&extern_iot[i], 0, sizeof(extern_iot[i])); + memset(&elem, 0, sizeof(elem)); } } } diff --git a/src/devices/cpu/pdp1/tx0.cpp b/src/devices/cpu/pdp1/tx0.cpp index c0ad2e9de3c..3a4fd7f1fb1 100644 --- a/src/devices/cpu/pdp1/tx0.cpp +++ b/src/devices/cpu/pdp1/tx0.cpp @@ -116,9 +116,9 @@ void tx0_device::device_start() m_pf = 0; m_tbr = 0; m_tac = 0; - for ( int i = 0; i < 16; i++ ) + for (auto & elem : m_tss) { - m_tss[i] = 0; + elem = 0; } m_cm_sel = 0; m_lr_sel = 0; diff --git a/src/devices/cpu/rsp/rspcp2.cpp b/src/devices/cpu/rsp/rspcp2.cpp index ab6afed4cbc..fe6d3b243e8 100644 --- a/src/devices/cpu/rsp/rspcp2.cpp +++ b/src/devices/cpu/rsp/rspcp2.cpp @@ -725,10 +725,10 @@ void rsp_cop2::init() void rsp_cop2::start() { - for(int regIdx = 0; regIdx < 32; regIdx++ ) + for(auto & elem : m_v) { - m_v[regIdx].d[0] = 0; - m_v[regIdx].d[1] = 0; + elem.d[0] = 0; + elem.d[1] = 0; } CLEAR_CARRY_FLAGS(); @@ -740,9 +740,9 @@ void rsp_cop2::start() m_reciprocal_high = 0; // Accumulators do not power on to a random state - for(int accumIdx = 0; accumIdx < 8; accumIdx++ ) + for(auto & elem : m_accum) { - m_accum[accumIdx].q = 0; + elem.q = 0; } } diff --git a/src/devices/cpu/se3208/se3208.cpp b/src/devices/cpu/se3208/se3208.cpp index 36a26cd603b..b37a8e09f5f 100644 --- a/src/devices/cpu/se3208/se3208.cpp +++ b/src/devices/cpu/se3208/se3208.cpp @@ -1715,9 +1715,9 @@ void se3208_device::BuildTable(void) void se3208_device::device_reset() { - for ( int i = 0; i < 8; i++ ) + for (auto & elem : m_R) { - m_R[i] = 0; + elem = 0; } m_SP = 0; m_ER = 0; diff --git a/src/devices/cpu/sh2/sh2drc.cpp b/src/devices/cpu/sh2/sh2drc.cpp index edf02fe421d..6f112eb0db5 100644 --- a/src/devices/cpu/sh2/sh2drc.cpp +++ b/src/devices/cpu/sh2/sh2drc.cpp @@ -935,20 +935,20 @@ void sh2_device::static_generate_memory_accessor(int size, int iswrite, const ch UML_LABEL(block, label++); // label: - for (int ramnum = 0; ramnum < SH2_MAX_FASTRAM; ramnum++) + for (auto & elem : m_fastram) { - if (m_fastram[ramnum].base != nullptr && (!iswrite || !m_fastram[ramnum].readonly)) + if (elem.base != nullptr && (!iswrite || !elem.readonly)) { - void *fastbase = (UINT8 *)m_fastram[ramnum].base - m_fastram[ramnum].start; + void *fastbase = (UINT8 *)elem.base - elem.start; UINT32 skip = label++; - if (m_fastram[ramnum].end != 0xffffffff) + if (elem.end != 0xffffffff) { - UML_CMP(block, I0, m_fastram[ramnum].end); // cmp i0,end + UML_CMP(block, I0, elem.end); // cmp i0,end UML_JMPc(block, COND_A, skip); // ja skip } - if (m_fastram[ramnum].start != 0x00000000) + if (elem.start != 0x00000000) { - UML_CMP(block, I0, m_fastram[ramnum].start);// cmp i0,fastram_start + UML_CMP(block, I0, elem.start);// cmp i0,fastram_start UML_JMPc(block, COND_B, skip); // jb skip } diff --git a/src/devices/cpu/sharc/sharc.cpp b/src/devices/cpu/sharc/sharc.cpp index 702f36ebe4c..bee241441ca 100644 --- a/src/devices/cpu/sharc/sharc.cpp +++ b/src/devices/cpu/sharc/sharc.cpp @@ -326,19 +326,19 @@ void adsp21062_device::device_start() m_delayed_iop_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(adsp21062_device::sharc_iop_delayed_write_callback), this)); - for (int i=0; i < 12; i++) + for (auto & elem : m_dma_op) { - m_dma_op[i].src = 0; - m_dma_op[i].dst = 0; - m_dma_op[i].chain_ptr = 0; - m_dma_op[i].src_modifier = 0; - m_dma_op[i].dst_modifier = 0; - m_dma_op[i].src_count = 0; - m_dma_op[i].dst_count = 0; - m_dma_op[i].pmode = 0; - m_dma_op[i].chained_direction = 0; - m_dma_op[i].active = false; - m_dma_op[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(adsp21062_device::sharc_dma_callback), this)); + elem.src = 0; + elem.dst = 0; + elem.chain_ptr = 0; + elem.src_modifier = 0; + elem.dst_modifier = 0; + elem.src_count = 0; + elem.dst_count = 0; + elem.pmode = 0; + elem.chained_direction = 0; + elem.active = false; + elem.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(adsp21062_device::sharc_dma_callback), this)); } for (int i=0; i < 16; i++) @@ -348,9 +348,9 @@ void adsp21062_device::device_start() } m_mrf = 0; m_mrb = 0; - for (int i=0; i < 32; i++) + for (auto & elem : m_pcstack) { - m_pcstack[i] = 0; + elem = 0; } for (int i=0; i < 6; i++) { @@ -368,17 +368,17 @@ void adsp21062_device::device_start() m_dag1_alt.i[i] = m_dag1_alt.m[i] = m_dag1_alt.b[i] = m_dag1_alt.l[i] = 0; m_dag2_alt.i[i] = m_dag2_alt.m[i] = m_dag2_alt.b[i] = m_dag2_alt.l[i] = 0; } - for (int i=0; i < 12; i++) + for (auto & elem : m_dma) { - m_dma[i].control = 0; - m_dma[i].int_index = 0; - m_dma[i].int_modifier = 0; - m_dma[i].int_count = 0; - m_dma[i].chain_ptr = 0; - m_dma[i].gen_purpose = 0; - m_dma[i].ext_index = 0; - m_dma[i].ext_modifier = 0; - m_dma[i].ext_count = 0; + elem.control = 0; + elem.int_index = 0; + elem.int_modifier = 0; + elem.int_count = 0; + elem.chain_ptr = 0; + elem.gen_purpose = 0; + elem.ext_index = 0; + elem.ext_modifier = 0; + elem.ext_count = 0; } m_mode1 = 0; m_mode2 = 0; @@ -391,10 +391,10 @@ void adsp21062_device::device_start() m_flag[0] = m_flag[1] = m_flag[2] = m_flag[3] = 0; m_syscon = 0; m_sysstat = 0; - for (int i=0; i < 5; i++) + for (auto & elem : m_status_stack) { - m_status_stack[i].mode1 = 0; - m_status_stack[i].astat = 0; + elem.mode1 = 0; + elem.astat = 0; } m_status_stkp = 0; m_px = 0; diff --git a/src/devices/cpu/sm8500/sm8500.cpp b/src/devices/cpu/sm8500/sm8500.cpp index 13b32447714..11fc61132fc 100644 --- a/src/devices/cpu/sm8500/sm8500.cpp +++ b/src/devices/cpu/sm8500/sm8500.cpp @@ -198,9 +198,9 @@ void sm8500_cpu_device::state_string_export(const device_state_entry &entry, std void sm8500_cpu_device::device_reset() { - for ( int i = 0; i < 0x108; i++ ) + for (auto & elem : m_register_ram) { - m_register_ram[i] = 0; + elem = 0; } m_PC = 0x1020; diff --git a/src/devices/cpu/ssp1601/ssp1601.cpp b/src/devices/cpu/ssp1601/ssp1601.cpp index 0f44256945e..945eb7d4499 100644 --- a/src/devices/cpu/ssp1601/ssp1601.cpp +++ b/src/devices/cpu/ssp1601/ssp1601.cpp @@ -504,9 +504,9 @@ void ssp1601_device::device_start() m_r[i] = 0; } memset( m_RAM, 0, sizeof(m_RAM)); - for ( int i = 0; i < 6; i++ ) + for (auto & elem : m_stack) { - m_stack[i] = 0; + elem = 0; } m_ppc.d = 0; m_g_cycles = 0; diff --git a/src/devices/cpu/superfx/superfx.cpp b/src/devices/cpu/superfx/superfx.cpp index ecdae33a1b0..eb5f04278d3 100644 --- a/src/devices/cpu/superfx/superfx.cpp +++ b/src/devices/cpu/superfx/superfx.cpp @@ -573,9 +573,9 @@ void superfx_device::add_clocks(INT32 clocks) void superfx_device::device_start() { - for(int i = 0; i < 16; i++) + for(auto & elem : m_r) { - m_r[i] = 0; + elem = 0; } m_sfr = 0; diff --git a/src/devices/cpu/upd7725/upd7725.cpp b/src/devices/cpu/upd7725/upd7725.cpp index 3d26780ae2e..5820d6fe4e0 100644 --- a/src/devices/cpu/upd7725/upd7725.cpp +++ b/src/devices/cpu/upd7725/upd7725.cpp @@ -139,9 +139,9 @@ void necdsp_device::device_start() void necdsp_device::device_reset() { - for (unsigned i = 0; i < 2048; i++) + for (auto & elem : dataRAM) { - dataRAM[i] = 0x0000; + elem = 0x0000; } regs.pc = 0x0000; diff --git a/src/devices/cpu/z8/z8.cpp b/src/devices/cpu/z8/z8.cpp index 7db38eaf500..3d8c6746c5b 100644 --- a/src/devices/cpu/z8/z8.cpp +++ b/src/devices/cpu/z8/z8.cpp @@ -693,17 +693,17 @@ void z8_device::device_start() m_t1_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z8_device::t1_tick), this)); /* Clear state */ - for ( int i = 0; i < 6; i++ ) - m_irq[i] = 0; - for ( int i = 0; i < 256; i++ ) - m_r[i] = 0; + for (auto & elem : m_irq) + elem = 0; + for (auto & elem : m_r) + elem = 0; for ( int i = 0; i < 4; i++ ) { m_input[i] = 0; m_output[i] = 0; } - for ( int i = 0; i < 16; i++ ) - m_fake_r[i] = 0; + for (auto & elem : m_fake_r) + elem = 0; m_fake_sp = 0; m_t0 = 0; m_t1 = 0; diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 319e000e626..786a44e2916 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -1171,7 +1171,7 @@ void floppy_sound_device::device_start() m_samplesize_motor_start = 0; m_samplesize_motor_loop = 0; m_samplesize_motor_end = 0; - for (int i = 0; i < MAX_STEP_SAMPLES; ++i) m_samplesize_step[i] = 0; + for (auto & elem : m_samplesize_step) elem = 0; // Read audio samples. The samples are stored in the list m_samples. m_loaded = load_samples(); diff --git a/src/devices/machine/53c810.cpp b/src/devices/machine/53c810.cpp index e11dbae70a3..1323e822d69 100644 --- a/src/devices/machine/53c810.cpp +++ b/src/devices/machine/53c810.cpp @@ -634,9 +634,9 @@ void lsi53c810_device::device_start() m_dma_cb.bind_relative_to(*owner()); m_fetch_cb.bind_relative_to(*owner()); - for (int i = 0; i < 256; i++) + for (auto & elem : dma_opcode) { - dma_opcode[i] = opcode_handler_delegate(FUNC(lsi53c810_device::dmaop_invalid), this); + elem = opcode_handler_delegate(FUNC(lsi53c810_device::dmaop_invalid), this); } add_opcode(0x00, 0xc0, opcode_handler_delegate(FUNC( lsi53c810_device::dmaop_block_move ), this)); diff --git a/src/devices/machine/6525tpi.cpp b/src/devices/machine/6525tpi.cpp index 038440e29d3..8d5a43a2b35 100644 --- a/src/devices/machine/6525tpi.cpp +++ b/src/devices/machine/6525tpi.cpp @@ -132,9 +132,9 @@ tpi6525_device::tpi6525_device(const machine_config &mconfig, const char *tag, d m_cr(0), m_air(0) { - for (int i = 0; i < 5; i++) + for (auto & elem : m_irq_level) { - m_irq_level[i] = 0; + elem = 0; } } diff --git a/src/devices/machine/68307tmu.cpp b/src/devices/machine/68307tmu.cpp index 21f709c3b00..6f5c33687cd 100644 --- a/src/devices/machine/68307tmu.cpp +++ b/src/devices/machine/68307tmu.cpp @@ -223,9 +223,9 @@ void m68307_timer::write_trr(UINT16 data, UINT16 mem_mask, int which) void m68307_timer::reset(void) { - for (int i=0;i<2;i++) + for (auto & elem : singletimer) { - m68307_single_timer* tptr = &singletimer[i]; + m68307_single_timer* tptr = &elem; tptr->regs[m68307TIMER_TMR] = 0x0000; tptr->regs[m68307TIMER_TRR] = 0xffff; diff --git a/src/devices/machine/6840ptm.cpp b/src/devices/machine/6840ptm.cpp index 239498f681c..bbf9a57ce18 100644 --- a/src/devices/machine/6840ptm.cpp +++ b/src/devices/machine/6840ptm.cpp @@ -92,19 +92,19 @@ void ptm6840_device::device_start() m_out2_cb.resolve_safe(); m_irq_cb.resolve_safe(); - for (int i = 0; i < 3; i++) + for (auto & elem : m_external_clock) { - if ( m_external_clock[i] == 0 ) - m_external_clock[i] = 1; + if ( elem == 0 ) + elem = 1; } m_timer[0] = timer_alloc(0); m_timer[1] = timer_alloc(1); m_timer[2] = timer_alloc(2); - for (int i = 0; i < 3; i++) + for (auto & elem : m_timer) { - m_timer[i]->enable(false); + elem->enable(false); } // register for state saving diff --git a/src/devices/machine/74148.cpp b/src/devices/machine/74148.cpp index 02d1be3927a..71520535f63 100644 --- a/src/devices/machine/74148.cpp +++ b/src/devices/machine/74148.cpp @@ -56,8 +56,8 @@ ttl74148_device::ttl74148_device(const machine_config &mconfig, const char *tag, m_last_output_valid(0), m_last_enable_output(0) { - for (int i = 0; i < 8; i++) - m_input_lines[i] = 0; + for (auto & elem : m_input_lines) + elem = 0; } //------------------------------------------------- diff --git a/src/devices/machine/74153.cpp b/src/devices/machine/74153.cpp index e38194f5d6e..d5b8ad37634 100644 --- a/src/devices/machine/74153.cpp +++ b/src/devices/machine/74153.cpp @@ -55,14 +55,14 @@ ttl74153_device::ttl74153_device(const machine_config &mconfig, const char *tag, m_input_lines[1][2] = 0; m_input_lines[1][3] = 0; - for (int i = 0; i < 2; i++) - m_enable[i] = 0; + for (auto & elem : m_enable) + elem = 0; - for (int i = 0; i < 2; i++) - m_output[i] = 0; + for (auto & elem : m_output) + elem = 0; - for (int i = 0; i < 2; i++) - m_last_output[i] = 0; + for (auto & elem : m_last_output) + elem = 0; } //------------------------------------------------- diff --git a/src/devices/machine/am9517a.cpp b/src/devices/machine/am9517a.cpp index 734d542e37d..7f2ecb7e37f 100644 --- a/src/devices/machine/am9517a.cpp +++ b/src/devices/machine/am9517a.cpp @@ -557,13 +557,13 @@ void am9517a_device::device_start() m_out_dack_2_cb.resolve_safe(); m_out_dack_3_cb.resolve_safe(); - for (int i = 0; i < 4; i++) + for (auto & elem : m_channel) { - m_channel[i].m_address = 0; - m_channel[i].m_count = 0; - m_channel[i].m_base_address = 0; - m_channel[i].m_base_count = 0; - m_channel[i].m_mode = 0; + elem.m_address = 0; + elem.m_count = 0; + elem.m_base_address = 0; + elem.m_base_count = 0; + elem.m_mode = 0; } // state saving diff --git a/src/devices/machine/ataintf.cpp b/src/devices/machine/ataintf.cpp index 59b1d6ddebf..b9c51351e71 100644 --- a/src/devices/machine/ataintf.cpp +++ b/src/devices/machine/ataintf.cpp @@ -125,9 +125,9 @@ WRITE_LINE_MEMBER( ata_interface_device::pdiag1_write_line ) UINT16 ata_interface_device::read_dma() { UINT16 result = 0xffff; - for (int i = 0; i < 2; i++) - if (m_slot[i]->dev() != nullptr) - result &= m_slot[i]->dev()->read_dma(); + for (auto & elem : m_slot) + if (elem->dev() != nullptr) + result &= elem->dev()->read_dma(); // printf( "%s: read_dma %04x\n", machine().describe_context(), result ); return result; @@ -136,9 +136,9 @@ UINT16 ata_interface_device::read_dma() READ16_MEMBER( ata_interface_device::read_cs0 ) { UINT16 result = mem_mask; - for (int i = 0; i < 2; i++) - if (m_slot[i]->dev() != nullptr) - result &= m_slot[i]->dev()->read_cs0(space, offset, mem_mask); + for (auto & elem : m_slot) + if (elem->dev() != nullptr) + result &= elem->dev()->read_cs0(space, offset, mem_mask); // { static int last_status = -1; if (offset == 7 ) { if( result == last_status ) return last_status; last_status = result; } else last_status = -1; } @@ -150,9 +150,9 @@ READ16_MEMBER( ata_interface_device::read_cs0 ) READ16_MEMBER( ata_interface_device::read_cs1 ) { UINT16 result = mem_mask; - for (int i = 0; i < 2; i++) - if (m_slot[i]->dev() != nullptr) - result &= m_slot[i]->dev()->read_cs1(space, offset, mem_mask); + for (auto & elem : m_slot) + if (elem->dev() != nullptr) + result &= elem->dev()->read_cs1(space, offset, mem_mask); // printf( "%s: read cs1 %04x %04x %04x\n", machine().describe_context(), offset, result, mem_mask ); @@ -170,36 +170,36 @@ void ata_interface_device::write_dma( UINT16 data ) { // printf( "%s: write_dma %04x\n", machine().describe_context(), data ); - for (int i = 0; i < 2; i++) - if (m_slot[i]->dev() != nullptr) - m_slot[i]->dev()->write_dma(data); + for (auto & elem : m_slot) + if (elem->dev() != nullptr) + elem->dev()->write_dma(data); } WRITE16_MEMBER( ata_interface_device::write_cs0 ) { // printf( "%s: write cs0 %04x %04x %04x\n", machine().describe_context(), offset, data, mem_mask ); - for (int i = 0; i < 2; i++) - if (m_slot[i]->dev() != nullptr) - m_slot[i]->dev()->write_cs0(space, offset, data, mem_mask); + for (auto & elem : m_slot) + if (elem->dev() != nullptr) + elem->dev()->write_cs0(space, offset, data, mem_mask); } WRITE16_MEMBER( ata_interface_device::write_cs1 ) { // printf( "%s: write cs1 %04x %04x %04x\n", machine().describe_context(), offset, data, mem_mask ); - for (int i = 0; i < 2; i++) - if (m_slot[i]->dev() != nullptr) - m_slot[i]->dev()->write_cs1(space, offset, data, mem_mask); + for (auto & elem : m_slot) + if (elem->dev() != nullptr) + elem->dev()->write_cs1(space, offset, data, mem_mask); } WRITE_LINE_MEMBER( ata_interface_device::write_dmack ) { // printf( "%s: write_dmack %04x\n", machine().describe_context(), state ); - for (int i = 0; i < 2; i++) - if (m_slot[i]->dev() != nullptr) - m_slot[i]->dev()->write_dmack(state); + for (auto & elem : m_slot) + if (elem->dev() != nullptr) + elem->dev()->write_dmack(state); } SLOT_INTERFACE_START(ata_devices) diff --git a/src/devices/machine/ay31015.cpp b/src/devices/machine/ay31015.cpp index 08b136043ad..f1db92a19d8 100644 --- a/src/devices/machine/ay31015.cpp +++ b/src/devices/machine/ay31015.cpp @@ -121,8 +121,8 @@ ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, m_write_so_cb(*this), m_status_changed_cb(*this) { - for (int i = 0; i < 41; i++) - m_pins[i] = 0; + for (auto & elem : m_pins) + elem = 0; } ay31015_device::ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -149,8 +149,8 @@ ay31015_device::ay31015_device(const machine_config &mconfig, const char *tag, d m_write_so_cb(*this), m_status_changed_cb(*this) { - for (int i = 0; i < 41; i++) - m_pins[i] = 0; + for (auto & elem : m_pins) + elem = 0; } ay51013_device::ay51013_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) diff --git a/src/devices/machine/ds1302.cpp b/src/devices/machine/ds1302.cpp index c254690cae0..c2cd23b560f 100644 --- a/src/devices/machine/ds1302.cpp +++ b/src/devices/machine/ds1302.cpp @@ -90,8 +90,8 @@ void ds1302_device::device_start() m_clock_timer = timer_alloc(); m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768)); - for (int i = 0; i < 9; i++) - m_reg[i] = 0; + for (auto & elem : m_reg) + elem = 0; // state saving save_item(NAME(m_ce)); diff --git a/src/devices/machine/ds2404.cpp b/src/devices/machine/ds2404.cpp index 9ba913c7250..68082389cee 100644 --- a/src/devices/machine/ds2404.cpp +++ b/src/devices/machine/ds2404.cpp @@ -99,8 +99,8 @@ void ds2404_device::device_start() m_rtc[3] = (current_time >> 16) & 0xff; m_rtc[4] = (current_time >> 24) & 0xff; - for (int i = 0; i < 8; i++) - m_state[i] = DS2404_STATE_IDLE; + for (auto & elem : m_state) + elem = DS2404_STATE_IDLE; m_tick_timer = timer_alloc(0); m_tick_timer->adjust(attotime::from_hz(256), 0, attotime::from_hz(256)); @@ -353,10 +353,10 @@ void ds2404_device::device_timer(emu_timer &timer, device_timer_id id, int param case 0: { // tick - for(int i = 0; i < 5; i++) + for(auto & elem : m_rtc) { - m_rtc[ i ]++; - if(m_rtc[ i ] != 0) + elem++; + if(elem != 0) { break; } diff --git a/src/devices/machine/hdc92x4.cpp b/src/devices/machine/hdc92x4.cpp index 685ee90015f..f433a7a2edd 100644 --- a/src/devices/machine/hdc92x4.cpp +++ b/src/devices/machine/hdc92x4.cpp @@ -2721,8 +2721,8 @@ void hdc92x4_device::live_run_until(attotime limit) m_out_dip(ASSERT_LINE); // Write the header via DMA - for (int slot = 0; slot < 6; slot++) - m_out_dma(0, m_register_r[id_field[slot]], 0xff); + for (auto & elem : id_field) + m_out_dma(0, m_register_r[elem], 0xff); m_out_dip(CLEAR_LINE); m_out_dmarq(CLEAR_LINE); @@ -3296,8 +3296,8 @@ void hdc92x4_device::live_run_hd_until(attotime limit) m_out_dip(ASSERT_LINE); // Write the header via DMA - for (int slot = 0; slot < 6; slot++) - m_out_dma(0, m_register_r[id_field[slot]], 0xff); + for (auto & elem : id_field) + m_out_dma(0, m_register_r[elem], 0xff); // Continue with reading the sector data m_live_state.state = SEARCH_DAM; diff --git a/src/devices/machine/i8257.cpp b/src/devices/machine/i8257.cpp index 23abcc3915c..a54d21697cc 100644 --- a/src/devices/machine/i8257.cpp +++ b/src/devices/machine/i8257.cpp @@ -364,11 +364,11 @@ void i8257_device::device_reset() m_hreq = -1; m_tc = 0; - for (int i = 0; i < 4; i++) + for (auto & elem : m_channel) { - m_channel[i].m_address = 0; - m_channel[i].m_count = 0; - m_channel[i].m_mode = 0; + elem.m_address = 0; + elem.m_count = 0; + elem.m_mode = 0; } set_hreq(0); set_dack(); @@ -390,11 +390,11 @@ bool i8257_device::next_channel() } } - for (int channel = 0; channel < 4; channel++) + for (auto & elem : priority) { - if (is_request_active(priority[channel])) + if (is_request_active(elem)) { - m_current_channel = m_last_channel = priority[channel]; + m_current_channel = m_last_channel = elem; return true; } } diff --git a/src/devices/machine/i8271.cpp b/src/devices/machine/i8271.cpp index a0bcfd01ff9..3d1d602dd74 100644 --- a/src/devices/machine/i8271.cpp +++ b/src/devices/machine/i8271.cpp @@ -119,10 +119,10 @@ bool i8271_device::get_ready(int fid) void i8271_device::set_floppy(floppy_image_device *flop) { - for(int fid=0; fid<2; fid++) { - if(flopi[fid].dev) - flopi[fid].dev->setup_index_pulse_cb(floppy_image_device::index_pulse_cb()); - flopi[fid].dev = flop; + for(auto & elem : flopi) { + if(elem.dev) + elem.dev->setup_index_pulse_cb(floppy_image_device::index_pulse_cb()); + elem.dev = flop; } if(flop) flop->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(i8271_device::index_callback), this)); @@ -1540,8 +1540,8 @@ void i8271_device::device_timer(emu_timer &timer, device_timer_id id, int param, void i8271_device::index_callback(floppy_image_device *floppy, int state) { - for(int fid=0; fid<2; fid++) { - floppy_info &fi = flopi[fid]; + for(auto & fi : flopi) { + if(fi.dev != floppy) continue; diff --git a/src/devices/machine/kb3600.cpp b/src/devices/machine/kb3600.cpp index f83ba9c46d8..ca5fb5e7e76 100644 --- a/src/devices/machine/kb3600.cpp +++ b/src/devices/machine/kb3600.cpp @@ -58,9 +58,9 @@ ay3600_device::ay3600_device(const machine_config &mconfig, const char *tag, dev m_write_data_ready(*this), m_write_ako(*this) { - for (int i = 0; i < 9; i++) + for (auto & elem : m_x_mask) { - m_x_mask[i] = 0; + elem = 0; } } diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp index 44d5e72c99d..b8ecf53611c 100644 --- a/src/devices/machine/laserdsc.cpp +++ b/src/devices/machine/laserdsc.cpp @@ -802,10 +802,10 @@ void laserdisc_device::init_video() m_videopalette->entry_set_color(index, rgb_t(index, index, index)); // allocate video frames - for (int index = 0; index < ARRAY_LENGTH(m_frame); index++) + for (auto & frame : m_frame) { // first allocate a YUY16 bitmap at 2x the height - frame_data &frame = m_frame[index]; + frame.m_bitmap.allocate(m_width, m_height * 2); frame.m_bitmap.set_palette(m_videopalette); fillbitmap_yuy16(frame.m_bitmap, 40, 109, 240); @@ -842,12 +842,12 @@ void laserdisc_device::init_video() texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTEA16 : TEXFORMAT_ARGB32; // allocate overlay bitmaps - for (int index = 0; index < ARRAY_LENGTH(m_overbitmap); index++) + for (auto & elem : m_overbitmap) { - m_overbitmap[index].set_format(format, texformat); + elem.set_format(format, texformat); if (format==BITMAP_FORMAT_IND16) - m_overbitmap[index].set_palette(m_overlay_palette->palette()); - m_overbitmap[index].resize(m_overwidth, m_overheight); + elem.set_palette(m_overlay_palette->palette()); + elem.resize(m_overwidth, m_overheight); } // allocate overlay texture diff --git a/src/devices/machine/m6m80011ap.cpp b/src/devices/machine/m6m80011ap.cpp index 39fbd526235..a8dea68d6ef 100644 --- a/src/devices/machine/m6m80011ap.cpp +++ b/src/devices/machine/m6m80011ap.cpp @@ -68,8 +68,8 @@ void m6m80011ap_device::device_reset() void m6m80011ap_device::nvram_default() { - for (offs_t offs = 0; offs < 0x80; offs++) - m_eeprom_data[offs] = 0xffff; + for (auto & elem : m_eeprom_data) + elem = 0xffff; } diff --git a/src/devices/machine/mc6843.cpp b/src/devices/machine/mc6843.cpp index bec088ff829..04a7b6a0906 100644 --- a/src/devices/machine/mc6843.cpp +++ b/src/devices/machine/mc6843.cpp @@ -95,9 +95,9 @@ mc6843_device::mc6843_device(const machine_config &mconfig, const char *tag, dev m_index_pulse(0), m_timer_cont(nullptr) { - for (int i = 0; i < 128; i++) + for (auto & elem : m_data) { - m_data[i] = 0; + elem = 0; } } diff --git a/src/devices/machine/mc6854.cpp b/src/devices/machine/mc6854.cpp index 9da624c850e..3461d58dde5 100644 --- a/src/devices/machine/mc6854.cpp +++ b/src/devices/machine/mc6854.cpp @@ -197,9 +197,9 @@ mc6854_device::mc6854_device(const machine_config &mconfig, const char *tag, dev m_rfifo[i] = 0; } - for (int i = 0; i < MAX_FRAME_LENGTH; i++) + for (auto & elem : m_frame) { - m_frame[i] = 0; + elem = 0; } } diff --git a/src/devices/machine/mos8722.cpp b/src/devices/machine/mos8722.cpp index 31b2beb1f27..214a52faa21 100644 --- a/src/devices/machine/mos8722.cpp +++ b/src/devices/machine/mos8722.cpp @@ -100,9 +100,9 @@ void mos8722_device::device_start() void mos8722_device::device_reset() { - for (int i = 0; i < 16; i++) + for (auto & elem : m_reg) { - m_reg[i] = 0; + elem = 0; } m_reg[P1L] = 0x01; diff --git a/src/devices/machine/msm5832.cpp b/src/devices/machine/msm5832.cpp index 7bc6fa70bfa..21fdeb3ba63 100644 --- a/src/devices/machine/msm5832.cpp +++ b/src/devices/machine/msm5832.cpp @@ -96,8 +96,8 @@ msm5832_device::msm5832_device(const machine_config &mconfig, const char *tag, d m_write(0), m_cs(0) { - for (int i = 0; i < 13; i++) - m_reg[i] = 0; + for (auto & elem : m_reg) + elem = 0; } diff --git a/src/devices/machine/msm58321.cpp b/src/devices/machine/msm58321.cpp index 679b85584ff..7bdd77713ea 100644 --- a/src/devices/machine/msm58321.cpp +++ b/src/devices/machine/msm58321.cpp @@ -298,8 +298,8 @@ void msm58321_device::rtc_clock_updated(int year, int month, int day, int day_of void msm58321_device::nvram_default() { - for (int i = 0; i < 13; i++) - m_reg[i] = 0; + for (auto & elem : m_reg) + elem = 0; if (m_default_24h) m_reg[REGISTER_H10] = H10_24; diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index 583a9d5fd26..94c9c29e36e 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -658,8 +658,8 @@ public: ATTR_COLD void reset() { m_pos = 0; - for (int i = 0; i < MAX_INPUT_CHANNELS; i++) - m_buffer[i] = nullptr; + for (auto & elem : m_buffer) + elem = nullptr; } ATTR_COLD int resolve() diff --git a/src/devices/machine/pci.cpp b/src/devices/machine/pci.cpp index c5191e984f6..f41eaea2e20 100644 --- a/src/devices/machine/pci.cpp +++ b/src/devices/machine/pci.cpp @@ -431,8 +431,8 @@ void pci_bridge_device::device_start() { pci_device::device_start(); - for(int i=0; i<32*8; i++) - sub_devices[i] = nullptr; + for(auto & elem : sub_devices) + elem = nullptr; for(device_t *d = bus_root()->first_subdevice(); d != nullptr; d = d->next()) { const char *t = d->tag(); diff --git a/src/devices/machine/pla.cpp b/src/devices/machine/pla.cpp index 286b7805e81..417fb4e6c3f 100644 --- a/src/devices/machine/pla.cpp +++ b/src/devices/machine/pla.cpp @@ -48,8 +48,8 @@ void pla_device::device_start() // initialize cache m_cache2_ptr = 0; - for (int i = 0; i < CACHE2_SIZE; i++) - m_cache2[i] = 0x80000000; + for (auto & elem : m_cache2) + elem = 0x80000000; m_cache_size = 0; int csize = 1 << ((m_inputs > MAX_CACHE_BITS) ? MAX_CACHE_BITS : m_inputs); @@ -146,9 +146,9 @@ UINT32 pla_device::read(UINT32 input) if (input < m_cache_size) return m_cache[input]; - for (int i = 0; i < CACHE2_SIZE; ++i) + for (auto cache2_entry : m_cache2) { - UINT64 cache2_entry = m_cache2[i]; + if ((UINT32)cache2_entry == input) { diff --git a/src/devices/machine/rtc9701.cpp b/src/devices/machine/rtc9701.cpp index ee7cff625c7..7c92ddc53e7 100644 --- a/src/devices/machine/rtc9701.cpp +++ b/src/devices/machine/rtc9701.cpp @@ -129,8 +129,8 @@ void rtc9701_device::device_reset() void rtc9701_device::nvram_default() { - for (offs_t offs = 0; offs < 0x100; offs++) - rtc9701_data[offs] = 0xffff; + for (auto & elem : rtc9701_data) + elem = 0xffff; } diff --git a/src/devices/machine/s2636.cpp b/src/devices/machine/s2636.cpp index e6c440fcddc..142514d8a19 100644 --- a/src/devices/machine/s2636.cpp +++ b/src/devices/machine/s2636.cpp @@ -97,8 +97,8 @@ s2636_device::s2636_device(const machine_config &mconfig, const char *tag, devic m_y_offset(0), m_x_offset(0) { - for (int i = 0; i < 1; i++) - m_reg[i] = 0; + for (auto & elem : m_reg) + elem = 0; } //------------------------------------------------- diff --git a/src/devices/machine/s3c24xx.inc b/src/devices/machine/s3c24xx.inc index 6bf7a49f71c..07193f890a4 100644 --- a/src/devices/machine/s3c24xx.inc +++ b/src/devices/machine/s3c24xx.inc @@ -1481,9 +1481,9 @@ TIMER_CALLBACK_MEMBER( S3C24_CLASS_NAME::s3c24xx_pwm_timer_exp ) void S3C24_CLASS_NAME::s3c24xx_dma_reset() { - for (int i = 0; i < S3C24XX_DMA_COUNT; i++) + for (auto & elem : m_dma) { - s3c24xx_dma_t *dma = &m_dma[i]; + s3c24xx_dma_t *dma = &elem; memset( &dma->regs, 0, sizeof( dma->regs)); dma->timer->adjust( attotime::never); } @@ -2012,9 +2012,9 @@ WRITE32_MEMBER( S3C24_CLASS_NAME::s3c24xx_usb_host_w ) void S3C24_CLASS_NAME::s3c24xx_uart_reset() { - for (int i = 0; i < S3C24XX_UART_COUNT; i++) + for (auto & elem : m_uart) { - s3c24xx_uart_t *uart = &m_uart[i]; + s3c24xx_uart_t *uart = &elem; memset( &uart->regs, 0, sizeof( uart->regs)); uart->regs.utrstat = 6; } @@ -2860,9 +2860,9 @@ void S3C24_CLASS_NAME::s3c24xx_touch_screen(int state) void S3C24_CLASS_NAME::s3c24xx_spi_reset() { - for (int i = 0; i < S3C24XX_SPI_COUNT; i++) + for (auto & elem : m_spi) { - s3c24xx_spi_t *spi = &m_spi[i]; + s3c24xx_spi_t *spi = &elem; memset( &spi->regs, 0, sizeof( spi->regs)); spi->regs.spsta = 1; #if defined(DEVICE_S3C2400) || defined(DEVICE_S3C2410) @@ -3496,9 +3496,9 @@ void S3C24_CLASS_NAME::s3c24xx_device_start() { m_pwm.timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_pwm_timer_exp), this)); } - for (int i = 0; i < S3C24XX_DMA_COUNT; i++) + for (auto & elem : m_dma) { - m_dma[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_dma_timer_exp), this)); + elem.timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_dma_timer_exp), this)); } m_iic.timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_iic_timer_exp), this)); m_iis.timer = machine().scheduler().timer_alloc(timer_expired_delegate( FUNC(S3C24_CLASS_NAME::s3c24xx_iis_timer_exp), this)); diff --git a/src/devices/machine/s3c44b0.cpp b/src/devices/machine/s3c44b0.cpp index 22d895fb5d9..56e9ee32e3b 100644 --- a/src/devices/machine/s3c44b0.cpp +++ b/src/devices/machine/s3c44b0.cpp @@ -76,9 +76,9 @@ void s3c44b0_device::device_start() for (int i = 0; i < 6; i++) m_pwm.timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::pwm_timer_exp),this)); - for (int i = 0; i < 2; i++) m_uart[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::uart_timer_exp),this)); - for (int i = 0; i < 2; i++) m_zdma[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::zdma_timer_exp),this)); - for (int i = 0; i < 2; i++) m_bdma[i].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::bdma_timer_exp),this)); + for (auto & elem : m_uart) elem.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::uart_timer_exp),this)); + for (auto & elem : m_zdma) elem.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::zdma_timer_exp),this)); + for (auto & elem : m_bdma) elem.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::bdma_timer_exp),this)); m_lcd.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::lcd_timer_exp),this)); m_wdt.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::wdt_timer_exp),this)); @@ -390,12 +390,12 @@ void s3c44b0_device::lcd_render_stn_04() UINT8 *bitmap = m_lcd.bitmap + ((m_lcd.vpos - m_lcd.vpos_min) * (m_lcd.hpos_max - m_lcd.hpos_min + 1)) + (m_lcd.hpos - m_lcd.hpos_min); UINT8 data[16]; lcd_dma_read(16, data); - for (int i = 0; i < 16; i++) + for (auto & elem : data) { for (int j = 0; j < 2; j++) { - *bitmap++ = lcd_get_color_stn_04((data[i] >> 4) & 0x0F); - data[i] = data[i] << 4; + *bitmap++ = lcd_get_color_stn_04((elem >> 4) & 0x0F); + elem = elem << 4; m_lcd.hpos++; if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max << 2)) { @@ -416,15 +416,15 @@ void s3c44b0_device::lcd_render_stn_08() UINT8 *bitmap = m_lcd.bitmap + ((m_lcd.vpos - m_lcd.vpos_min) * (m_lcd.hpos_max - m_lcd.hpos_min + 1)) + (m_lcd.hpos - m_lcd.hpos_min); UINT8 data[16]; lcd_dma_read(16, data); - for (int i = 0; i < 16; i++) + for (auto & elem : data) { UINT8 xxx[3]; - xxx[0] = lcd_get_color_stn_08_r(data[i]); - xxx[1] = lcd_get_color_stn_08_g(data[i]); - xxx[2] = lcd_get_color_stn_08_b(data[i]); - for (int j = 0; j < 3; j++) + xxx[0] = lcd_get_color_stn_08_r(elem); + xxx[1] = lcd_get_color_stn_08_g(elem); + xxx[2] = lcd_get_color_stn_08_b(elem); + for (auto & xxx_j : xxx) { - *bitmap++ = xxx[j]; + *bitmap++ = xxx_j; m_lcd.hpos++; if (m_lcd.hpos >= m_lcd.hpos_min + (m_lcd.pagewidth_max * 6)) { diff --git a/src/devices/machine/upd1990a.cpp b/src/devices/machine/upd1990a.cpp index f40bb30af48..59f85d9c4ca 100644 --- a/src/devices/machine/upd1990a.cpp +++ b/src/devices/machine/upd1990a.cpp @@ -86,8 +86,8 @@ void upd1990a_device::device_start() // initialize set_current_time(machine()); - for (int i = 0; i < 7; i++) - m_shift_reg[i] = 0; + for (auto & elem : m_shift_reg) + elem = 0; m_oe = 0; m_cs = 0; diff --git a/src/devices/machine/upd71071.cpp b/src/devices/machine/upd71071.cpp index 59965256bc5..921c0bcc7a4 100644 --- a/src/devices/machine/upd71071.cpp +++ b/src/devices/machine/upd71071.cpp @@ -133,9 +133,9 @@ void upd71071_device::device_start() m_out_dack_1_cb.resolve_safe(); m_out_dack_2_cb.resolve_safe(); m_out_dack_3_cb.resolve_safe(); - for (int x = 0; x < 4; x++) + for (auto & elem : m_timer) { - m_timer[x] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(upd71071_device::dma_transfer_timer),this)); + elem = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(upd71071_device::dma_transfer_timer),this)); } m_selected_channel = 0; diff --git a/src/devices/machine/upd765.cpp b/src/devices/machine/upd765.cpp index 34a01b21ac7..54c1119d4e7 100644 --- a/src/devices/machine/upd765.cpp +++ b/src/devices/machine/upd765.cpp @@ -260,10 +260,10 @@ bool upd765_family_device::get_ready(int fid) void upd765_family_device::set_floppy(floppy_image_device *flop) { - for(int fid=0; fid<4; fid++) { - if(flopi[fid].dev) - flopi[fid].dev->setup_index_pulse_cb(floppy_image_device::index_pulse_cb()); - flopi[fid].dev = flop; + for(auto & elem : flopi) { + if(elem.dev) + elem.dev->setup_index_pulse_cb(floppy_image_device::index_pulse_cb()); + elem.dev = flop; } if(flop) flop->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(upd765_family_device::index_callback), this)); @@ -2246,8 +2246,8 @@ void upd765_family_device::run_drive_ready_polling() void upd765_family_device::index_callback(floppy_image_device *floppy, int state) { - for(int fid=0; fid<4; fid++) { - floppy_info &fi = flopi[fid]; + for(auto & fi : flopi) { + if(fi.dev != floppy) continue; diff --git a/src/devices/machine/wd7600.cpp b/src/devices/machine/wd7600.cpp index 26873553e14..63586c3d858 100644 --- a/src/devices/machine/wd7600.cpp +++ b/src/devices/machine/wd7600.cpp @@ -201,8 +201,8 @@ void wd7600_device::device_reset() m_memory_ctrl = 0; m_diagnostic = 0xe080; - for(int x=0;x<4;x++) - m_bank_start[x] = 0; + for(auto & elem : m_bank_start) + elem = 0; // initialize dma controller clocks m_dma1->set_unscaled_clock(clock()); diff --git a/src/devices/machine/z80ctc.cpp b/src/devices/machine/z80ctc.cpp index 23487d5120c..13c4844c9e3 100644 --- a/src/devices/machine/z80ctc.cpp +++ b/src/devices/machine/z80ctc.cpp @@ -183,9 +183,9 @@ int z80ctc_device::z80daisy_irq_state() // loop over all channels int state = 0; - for (int ch = 0; ch < 4; ch++) + for (auto & channel : m_channel) { - ctc_channel &channel = m_channel[ch]; + // if we're servicing a request, don't indicate more interrupts if (channel.m_int_state & Z80_DAISY_IEO) diff --git a/src/devices/machine/z80dart.cpp b/src/devices/machine/z80dart.cpp index 6254d1d81f1..e976080881f 100644 --- a/src/devices/machine/z80dart.cpp +++ b/src/devices/machine/z80dart.cpp @@ -112,8 +112,8 @@ z80dart_device::z80dart_device(const machine_config &mconfig, device_type type, m_out_txdrqb_cb(*this), m_variant(variant) { - for (int i = 0; i < 8; i++) - m_int_state[i] = 0; + for (auto & elem : m_int_state) + elem = 0; } z80dart_device::z80dart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -142,8 +142,8 @@ z80dart_device::z80dart_device(const machine_config &mconfig, const char *tag, d m_out_txdrqb_cb(*this), m_variant(TYPE_DART) { - for (int i = 0; i < 8; i++) - m_int_state[i] = 0; + for (auto & elem : m_int_state) + elem = 0; } z80sio0_device::z80sio0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -338,9 +338,9 @@ void z80dart_device::check_interrupts() void z80dart_device::reset_interrupts() { - for (int i = 0; i < 8; i++) + for (auto & elem : m_int_state) { - m_int_state[i] = 0; + elem = 0; } check_interrupts(); @@ -518,11 +518,11 @@ z80dart_channel::z80dart_channel(const machine_config &mconfig, const char *tag, m_rts(0), m_sync(0) { - for (int i = 0; i < 3; i++) - m_rr[i] = 0; + for (auto & elem : m_rr) + elem = 0; - for (int i = 0; i < 6; i++) - m_wr[i] = 0; + for (auto & elem : m_wr) + elem = 0; for (int i = 0; i < 3; i++) { diff --git a/src/devices/machine/z80scc.cpp b/src/devices/machine/z80scc.cpp index 1abc94fec86..3c6a17f6fbb 100644 --- a/src/devices/machine/z80scc.cpp +++ b/src/devices/machine/z80scc.cpp @@ -154,8 +154,8 @@ z80scc_device::z80scc_device(const machine_config &mconfig, device_type type, co m_out_txdrqb_cb(*this), m_variant(variant), m_wr0_ptrbits(0){ - for (int i = 0; i < 6; i++) - m_int_state[i] = 0; + for (auto & elem : m_int_state) + elem = 0; } z80scc_device::z80scc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -184,8 +184,8 @@ z80scc_device::z80scc_device(const machine_config &mconfig, const char *tag, dev m_out_txdrqb_cb(*this), m_variant(TYPE_Z80SCC) { - for (int i = 0; i < 6; i++) - m_int_state[i] = 0; + for (auto & elem : m_int_state) + elem = 0; } scc8030_device::scc8030_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -379,9 +379,9 @@ void z80scc_device::reset_interrupts() { LOG(("%s %s \n",FUNCNAME, tag())); // reset internal interrupt sources - for (int i = 0; i < 6; i++) + for (auto & elem : m_int_state) { - m_int_state[i] = 0; + elem = 0; } // check external interrupt sources diff --git a/src/devices/machine/z80sio.cpp b/src/devices/machine/z80sio.cpp index 00f65a8e6b4..64d9480dfbf 100644 --- a/src/devices/machine/z80sio.cpp +++ b/src/devices/machine/z80sio.cpp @@ -129,8 +129,8 @@ z80sio_device::z80sio_device(const machine_config &mconfig, device_type type, co m_out_txdrqb_cb(*this), m_variant(variant) { - for (int i = 0; i < 8; i++) - m_int_state[i] = 0; + for (auto & elem : m_int_state) + elem = 0; } z80sio_device::z80sio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -159,8 +159,8 @@ z80sio_device::z80sio_device(const machine_config &mconfig, const char *tag, dev m_out_txdrqb_cb(*this), m_variant(TYPE_Z80SIO) { - for (int i = 0; i < 8; i++) - m_int_state[i] = 0; + for (auto & elem : m_int_state) + elem = 0; } //------------------------------------------------- @@ -317,9 +317,9 @@ void z80sio_device::reset_interrupts() { LOG(("%s %s \n",FUNCNAME, tag())); // reset internal interrupt sources - for (int i = 0; i < 8; i++) + for (auto & elem : m_int_state) { - m_int_state[i] = 0; + elem = 0; } check_interrupts(); diff --git a/src/devices/machine/z80sti.cpp b/src/devices/machine/z80sti.cpp index a27295f6ff1..e8900abd021 100644 --- a/src/devices/machine/z80sti.cpp +++ b/src/devices/machine/z80sti.cpp @@ -103,9 +103,9 @@ z80sti_device::z80sti_device(const machine_config &mconfig, const char *tag, dev m_isr(0), m_imr(0) { - for (int i = 0; i < 16; i++) + for (auto & elem : m_int_state) { - m_int_state[i] = 0; + elem = 0; } } diff --git a/src/devices/machine/z8536.cpp b/src/devices/machine/z8536.cpp index fc5e770b15a..60d5e46f05f 100644 --- a/src/devices/machine/z8536.cpp +++ b/src/devices/machine/z8536.cpp @@ -905,9 +905,9 @@ void z8536_device::device_reset() { m_state = STATE_RESET; - for (int i = 0; i < 48; i++) + for (auto & elem : m_register) { - m_register[i] = 0; + elem = 0; } m_register[MASTER_INTERRUPT_CONTROL] = MICR_RESET; diff --git a/src/devices/sound/es5503.cpp b/src/devices/sound/es5503.cpp index cd69d5deee6..8103ffbc456 100644 --- a/src/devices/sound/es5503.cpp +++ b/src/devices/sound/es5503.cpp @@ -260,18 +260,18 @@ void es5503_device::device_reset() { rege0 = 0xff; - for (int osc = 0; osc < 32; osc++) + for (auto & elem : oscillators) { - oscillators[osc].freq = 0; - oscillators[osc].wtsize = 0; - oscillators[osc].control = 0; - oscillators[osc].vol = 0; - oscillators[osc].data = 0x80; - oscillators[osc].wavetblpointer = 0; - oscillators[osc].wavetblsize = 0; - oscillators[osc].resolution = 0; - oscillators[osc].accumulator = 0; - oscillators[osc].irqpend = 0; + elem.freq = 0; + elem.wtsize = 0; + elem.control = 0; + elem.vol = 0; + elem.data = 0x80; + elem.wavetblpointer = 0; + elem.wavetblsize = 0; + elem.resolution = 0; + elem.accumulator = 0; + elem.irqpend = 0; } oscsenabled = 1; diff --git a/src/devices/sound/es5506.cpp b/src/devices/sound/es5506.cpp index e29edc5f0ce..6e47ed7977d 100644 --- a/src/devices/sound/es5506.cpp +++ b/src/devices/sound/es5506.cpp @@ -157,9 +157,9 @@ es550x_device::es550x_device(const machine_config &mconfig, device_type type, co m_irq_cb(*this), m_read_port_cb(*this) { - for (int i = 0; i < 4; i++) + for (auto & elem : m_region_base) { - m_region_base[i] = nullptr; + elem = nullptr; } } diff --git a/src/devices/sound/i5000.cpp b/src/devices/sound/i5000.cpp index 22d390cc89c..11dc147f0b0 100644 --- a/src/devices/sound/i5000.cpp +++ b/src/devices/sound/i5000.cpp @@ -35,9 +35,9 @@ void i5000snd_device::device_start() // fill volume table double div = 1.032; double vol = 2047.0; - for (int i = 0; i < 0x100; i++) + for (auto & elem : m_lut_volume) { - m_lut_volume[i] = vol + 0.5; + elem = vol + 0.5; vol /= div; } m_lut_volume[0xff] = 0; diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp index c76e043f8ac..9dabc41d334 100644 --- a/src/devices/sound/ics2115.cpp +++ b/src/devices/sound/ics2115.cpp @@ -108,29 +108,29 @@ void ics2115_device::device_reset() m_vmode = 0; m_irq_on = false; memset(m_voice, 0, sizeof(m_voice)); - for(int i = 0; i < 2; ++i) + for(auto & elem : m_timer) { - m_timer[i].timer->adjust(attotime::never); - m_timer[i].period = 0; - m_timer[i].scale = 0; - m_timer[i].preset = 0; + elem.timer->adjust(attotime::never); + elem.period = 0; + elem.scale = 0; + elem.preset = 0; } - for(int i = 0; i < 32; i++) { - m_voice[i].osc_conf.value = 2; - m_voice[i].osc.fc = 0; - m_voice[i].osc.acc = 0; - m_voice[i].osc.start = 0; - m_voice[i].osc.end = 0; - m_voice[i].osc.ctl = 0; - m_voice[i].osc.saddr = 0; - m_voice[i].vol.acc = 0; - m_voice[i].vol.incr = 0; - m_voice[i].vol.start = 0; - m_voice[i].vol.end = 0; - m_voice[i].vol.pan = 0x7F; - m_voice[i].vol_ctrl.value = 1; - m_voice[i].vol.mode = 0; - m_voice[i].state.value = 0; + for(auto & elem : m_voice) { + elem.osc_conf.value = 2; + elem.osc.fc = 0; + elem.osc.acc = 0; + elem.osc.start = 0; + elem.osc.end = 0; + elem.osc.ctl = 0; + elem.osc.saddr = 0; + elem.vol.acc = 0; + elem.vol.incr = 0; + elem.vol.start = 0; + elem.vol.end = 0; + elem.vol.pan = 0x7F; + elem.vol_ctrl.value = 1; + elem.vol.mode = 0; + elem.state.value = 0; } } diff --git a/src/devices/sound/k007232.cpp b/src/devices/sound/k007232.cpp index 6f5286b951f..767cd904357 100644 --- a/src/devices/sound/k007232.cpp +++ b/src/devices/sound/k007232.cpp @@ -179,8 +179,8 @@ void k007232_device::device_start() m_vol[1][0] = 0; m_vol[1][1] = 255; /* channel B output to output B */ - for (int i = 0; i < 0x10; i++) - m_wreg[i] = 0; + for (auto & elem : m_wreg) + elem = 0; m_stream = machine().sound().stream_alloc(*this, 0 , 2, clock()/128); diff --git a/src/devices/sound/k053260.cpp b/src/devices/sound/k053260.cpp index fcf35089747..434d352635c 100644 --- a/src/devices/sound/k053260.cpp +++ b/src/devices/sound/k053260.cpp @@ -115,8 +115,8 @@ void k053260_device::device_start() void k053260_device::device_reset() { - for (int i = 0; i < 4; i++) - m_voice[i].voice_reset(); + for (auto & elem : m_voice) + elem.voice_reset(); } @@ -208,9 +208,9 @@ WRITE8_MEMBER( k053260_device::write ) // 0x29 is a read register case 0x2a: // loop and pcm/adpcm select - for (int i = 0; i < 4; i++) + for (auto & elem : m_voice) { - m_voice[i].set_loop_kadpcm(data); + elem.set_loop_kadpcm(data); data >>= 1; } break; @@ -272,9 +272,9 @@ void k053260_device::sound_stream_update(sound_stream &stream, stream_sample_t * { stream_sample_t buffer[2] = {0, 0}; - for (int i = 0; i < 4; i++) + for (auto & voice : m_voice) { - KDSC_Voice &voice = m_voice[i]; + if (voice.playing()) voice.play(buffer); } diff --git a/src/devices/sound/k054539.cpp b/src/devices/sound/k054539.cpp index ed1699e6fd1..ba38b750b08 100644 --- a/src/devices/sound/k054539.cpp +++ b/src/devices/sound/k054539.cpp @@ -499,8 +499,8 @@ void k054539_device::device_start() m_timer_handler.resolve_safe(); m_apan_cb.bind_relative_to(*owner()); - for (int i = 0; i < 8; i++) - gain[i] = 1.0; + for (auto & elem : gain) + elem = 1.0; flags = RESET_FLAGS; diff --git a/src/devices/sound/nes_apu.cpp b/src/devices/sound/nes_apu.cpp index 5a5ee87fa26..0c42deb0fca 100644 --- a/src/devices/sound/nes_apu.cpp +++ b/src/devices/sound/nes_apu.cpp @@ -113,24 +113,24 @@ nesapu_device::nesapu_device(const machine_config &mconfig, const char *tag, dev m_stream(nullptr), m_cpu_tag("") { - for (int i = 0; i < NOISE_LONG; i++) + for (auto & elem : m_noise_lut) { - m_noise_lut[i] = 0; + elem = 0; } - for (int i = 0; i < 0X20; i++) + for (auto & elem : m_vbl_times) { - m_vbl_times[i] = 0; + elem = 0; } - for (int i = 0; i < SYNCS_MAX1; i++) + for (auto & elem : m_sync_times1) { - m_sync_times1[i] = 0; + elem = 0; } - for (int i = 0; i < SYNCS_MAX2; i++) + for (auto & elem : m_sync_times2) { - m_sync_times2[i] = 0; + elem = 0; } } diff --git a/src/devices/sound/nes_defs.h b/src/devices/sound/nes_defs.h index a3ed9203500..b225b1e60a6 100644 --- a/src/devices/sound/nes_defs.h +++ b/src/devices/sound/nes_defs.h @@ -96,9 +96,9 @@ struct square_t { square_t() { - for (int i = 0; i < 4; i++) + for (auto & elem : regs) { - regs[i] = 0; + elem = 0; } vbl_length =0; freq = 0; @@ -128,9 +128,9 @@ struct triangle_t { triangle_t() { - for (int i = 0; i < 4; i++) + for (auto & elem : regs) { - regs[i] = 0; + elem = 0; } linear_length =0; vbl_length =0; @@ -158,9 +158,9 @@ struct noise_t { noise_t() { - for (int i = 0; i < 4; i++) + for (auto & elem : regs) { - regs[i] = 0; + elem = 0; } cur_pos =0; vbl_length =0; @@ -186,9 +186,9 @@ struct dpcm_t { dpcm_t() { - for (int i = 0; i < 4; i++) + for (auto & elem : regs) { - regs[i] = 0; + elem = 0; } address = 0; length = 0; diff --git a/src/devices/sound/okim6295.cpp b/src/devices/sound/okim6295.cpp index 27ff90adb2b..7e97d04e916 100644 --- a/src/devices/sound/okim6295.cpp +++ b/src/devices/sound/okim6295.cpp @@ -150,8 +150,8 @@ void okim6295_device::device_start() void okim6295_device::device_reset() { m_stream->update(); - for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++) - m_voice[voicenum].m_playing = false; + for (auto & elem : m_voice) + elem.m_playing = false; } @@ -200,8 +200,8 @@ void okim6295_device::sound_stream_update(sound_stream &stream, stream_sample_t memset(outputs[0], 0, samples * sizeof(*outputs[0])); // iterate over voices and accumulate sample data - for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++) - m_voice[voicenum].generate_adpcm(*m_direct, outputs[0], samples); + for (auto & elem : m_voice) + elem.generate_adpcm(*m_direct, outputs[0], samples); } diff --git a/src/devices/sound/okim9810.cpp b/src/devices/sound/okim9810.cpp index d59ae3d82fa..cd89d77a3e0 100644 --- a/src/devices/sound/okim9810.cpp +++ b/src/devices/sound/okim9810.cpp @@ -144,8 +144,8 @@ void okim9810_device::device_start() void okim9810_device::device_reset() { m_stream->update(); - for (int voicenum = 0; voicenum < OKIM9810_VOICES; voicenum++) - m_voice[voicenum].m_playing = false; + for (auto & elem : m_voice) + elem.m_playing = false; } @@ -191,8 +191,8 @@ void okim9810_device::sound_stream_update(sound_stream &stream, stream_sample_t memset(outputs[1], 0, samples * sizeof(*outputs[1])); // iterate over voices and accumulate sample data - for (int voicenum = 0; voicenum < OKIM9810_VOICES; voicenum++) - m_voice[voicenum].generate_audio(*m_direct, outputs, samples, m_global_volume, clock(), m_filter_type); + for (auto & elem : m_voice) + elem.generate_audio(*m_direct, outputs, samples, m_global_volume, clock(), m_filter_type); } diff --git a/src/devices/sound/qs1000.cpp b/src/devices/sound/qs1000.cpp index 866b48ec615..44ff9017ea4 100644 --- a/src/devices/sound/qs1000.cpp +++ b/src/devices/sound/qs1000.cpp @@ -305,9 +305,9 @@ READ8_MEMBER(qs1000_device::data_to_i8052) //------------------------------------------------- void qs1000_device::device_reset() { - for (int ch = 0; ch < QS1000_CHANNELS; ++ch) + for (auto & elem : m_channels) { - m_channels[ch].m_flags = 0; + elem.m_flags = 0; } } @@ -486,9 +486,9 @@ void qs1000_device::sound_stream_update(sound_stream &stream, stream_sample_t ** memset(outputs[1], 0x0, samples * sizeof(*outputs[1])); // Iterate over voices and accumulate sample data - for (int ch = 0; ch < QS1000_CHANNELS; ch++) + for (auto & chan : m_channels) { - qs1000_channel &chan = m_channels[ch]; + UINT8 lvol = chan.m_regs[6]; UINT8 rvol = chan.m_regs[7]; diff --git a/src/devices/sound/qsound.cpp b/src/devices/sound/qsound.cpp index 977a459e1dd..c9bd30d3e74 100644 --- a/src/devices/sound/qsound.cpp +++ b/src/devices/sound/qsound.cpp @@ -147,9 +147,9 @@ void qsound_device::sound_stream_update(sound_stream &stream, stream_sample_t ** memset(outputs[0], 0, samples * sizeof(*outputs[0])); memset(outputs[1], 0, samples * sizeof(*outputs[1])); - for (int ch = 0; ch < 16; ch++) + for (auto & elem : m_channel) { - if (m_channel[ch].enabled) + if (elem.enabled) { stream_sample_t *lmix=outputs[0]; stream_sample_t *rmix=outputs[1]; @@ -157,34 +157,34 @@ void qsound_device::sound_stream_update(sound_stream &stream, stream_sample_t ** // Go through the buffer and add voice contributions for (int i = 0; i < samples; i++) { - m_channel[ch].address += (m_channel[ch].step_ptr >> 12); - m_channel[ch].step_ptr &= 0xfff; - m_channel[ch].step_ptr += m_channel[ch].freq; + elem.address += (elem.step_ptr >> 12); + elem.step_ptr &= 0xfff; + elem.step_ptr += elem.freq; - if (m_channel[ch].address >= m_channel[ch].end) + if (elem.address >= elem.end) { - if (m_channel[ch].loop) + if (elem.loop) { // Reached the end, restart the loop - m_channel[ch].address -= m_channel[ch].loop; + elem.address -= elem.loop; // Make sure we don't overflow (what does the real chip do in this case?) - if (m_channel[ch].address >= m_channel[ch].end) - m_channel[ch].address = m_channel[ch].end - m_channel[ch].loop; + if (elem.address >= elem.end) + elem.address = elem.end - elem.loop; - m_channel[ch].address &= 0xffff; + elem.address &= 0xffff; } else { // Reached the end of a non-looped sample - m_channel[ch].enabled = false; + elem.enabled = false; break; } } - INT8 sample = read_sample(m_channel[ch].bank | m_channel[ch].address); - *lmix++ += ((sample * m_channel[ch].lvol * m_channel[ch].vol) >> 14); - *rmix++ += ((sample * m_channel[ch].rvol * m_channel[ch].vol) >> 14); + INT8 sample = read_sample(elem.bank | elem.address); + *lmix++ += ((sample * elem.lvol * elem.vol) >> 14); + *rmix++ += ((sample * elem.rvol * elem.vol) >> 14); } } } diff --git a/src/devices/sound/sp0250.cpp b/src/devices/sound/sp0250.cpp index 0ff76fb13c1..004cd6d6921 100644 --- a/src/devices/sound/sp0250.cpp +++ b/src/devices/sound/sp0250.cpp @@ -51,17 +51,17 @@ sp0250_device::sp0250_device(const machine_config &mconfig, const char *tag, dev m_fifo_pos(0), m_drq(*this) { - for (int i = 0; i < 15; i++) + for (auto & elem : m_fifo) { - m_fifo[i] = 0; + elem = 0; } - for (int i = 0; i < 6; i++) + for (auto & elem : m_filter) { - m_filter[i].F = 0; - m_filter[i].B = 0; - m_filter[i].z1 = 0; - m_filter[i].z2 = 0; + elem.F = 0; + elem.B = 0; + elem.z1 = 0; + elem.z2 = 0; } } diff --git a/src/devices/sound/spu.cpp b/src/devices/sound/spu.cpp index 714d6750e28..31d04be95d6 100644 --- a/src/devices/sound/spu.cpp +++ b/src/devices/sound/spu.cpp @@ -1048,8 +1048,8 @@ void spu_device::device_reset() memset(cache,0,(spu_ram_size>>4)*sizeof(sample_cache *)); - for (unsigned int i=0; i<4; i++) - output_buf[i]=new unsigned char [output_buffer_size]; + for (auto & elem : output_buf) + elem=new unsigned char [output_buffer_size]; output_head=output_tail=output_size=0; noise_t=0; @@ -1082,8 +1082,8 @@ void spu_device::device_post_load() // void spu_device::device_stop() { - for (unsigned int i=0; i<4; i++) - global_free_array(output_buf[i]); + for (auto & elem : output_buf) + global_free_array(elem); kill_stream(); diff --git a/src/devices/sound/ymf271.cpp b/src/devices/sound/ymf271.cpp index c10420af8a4..1d0eec4fa5d 100644 --- a/src/devices/sound/ymf271.cpp +++ b/src/devices/sound/ymf271.cpp @@ -1726,10 +1726,10 @@ void ymf271_device::device_start() void ymf271_device::device_reset() { - for (int i = 0; i < 48; i++) + for (auto & elem : m_slots) { - m_slots[i].active = 0; - m_slots[i].volume = 0; + elem.active = 0; + elem.volume = 0; } // reset timers and IRQ diff --git a/src/devices/sound/ymz280b.cpp b/src/devices/sound/ymz280b.cpp index 9d07f057739..c9c19277780 100644 --- a/src/devices/sound/ymz280b.cpp +++ b/src/devices/sound/ymz280b.cpp @@ -138,9 +138,9 @@ void ymz280b_device::update_volumes(struct YMZ280BVoice *voice) void ymz280b_device::device_post_load() { - for (int j = 0; j < 8; j++) + for (auto & elem : m_voice) { - struct YMZ280BVoice *voice = &m_voice[j]; + struct YMZ280BVoice *voice = &elem; update_step(voice); if(voice->irq_schedule) voice->timer->adjust(attotime::zero); @@ -660,9 +660,9 @@ void ymz280b_device::device_reset() m_ext_mem_address = 0; /* clear other voice parameters */ - for (int i = 0; i < 8; i++) + for (auto & elem : m_voice) { - struct YMZ280BVoice *voice = &m_voice[i]; + struct YMZ280BVoice *voice = &elem; voice->curr_sample = 0; voice->last_sample = 0; diff --git a/src/devices/sound/ymz770.cpp b/src/devices/sound/ymz770.cpp index f5ca4eab23f..6456c346ffd 100644 --- a/src/devices/sound/ymz770.cpp +++ b/src/devices/sound/ymz770.cpp @@ -54,11 +54,11 @@ void ymz770_device::device_start() m_rom_base = region()->base(); m_rom_limit = region()->bytes() * 8; - for (int i = 0; i < 8; i++) + for (auto & elem : m_channels) { - m_channels[i].is_playing = false; - m_channels[i].is_seq_playing = false; - m_channels[i].decoder = new mpeg_audio(m_rom_base, mpeg_audio::AMM, false, 0); + elem.is_playing = false; + elem.is_seq_playing = false; + elem.decoder = new mpeg_audio(m_rom_base, mpeg_audio::AMM, false, 0); } // register for save states @@ -96,19 +96,19 @@ void ymz770_device::device_start() void ymz770_device::device_reset() { - for (int ch = 0; ch < 8; ch++) + for (auto & elem : m_channels) { - m_channels[ch].phrase = 0; - m_channels[ch].pan = 8; - m_channels[ch].volume = 0; - m_channels[ch].control = 0; - m_channels[ch].sequence = 0; - m_channels[ch].seqcontrol = 0; - m_channels[ch].seqdelay = 0; - m_channels[ch].is_playing = false; - m_channels[ch].is_seq_playing = false; - m_channels[ch].output_remaining = 0; - m_channels[ch].decoder->clear(); + elem.phrase = 0; + elem.pan = 8; + elem.volume = 0; + elem.control = 0; + elem.sequence = 0; + elem.seqcontrol = 0; + elem.seqdelay = 0; + elem.is_playing = false; + elem.is_seq_playing = false; + elem.output_remaining = 0; + elem.decoder->clear(); } } @@ -128,35 +128,35 @@ void ymz770_device::sound_stream_update(sound_stream &stream, stream_sample_t ** for (int i = 0; i < samples; i++) { // run sequencers (should probably be in separate timer callbacks) - for (int ch = 0; ch < 8; ch++) + for (auto & elem : m_channels) { - if (m_channels[ch].is_seq_playing) + if (elem.is_seq_playing) { - if (m_channels[ch].seqdelay > 0) + if (elem.seqdelay > 0) { - m_channels[ch].seqdelay--; + elem.seqdelay--; } else { - int reg = *m_channels[ch].seqdata++; - UINT8 data = *m_channels[ch].seqdata++; + int reg = *elem.seqdata++; + UINT8 data = *elem.seqdata++; switch (reg) { case 0x0f: - if (m_channels[ch].seqcontrol & 1) + if (elem.seqcontrol & 1) { // loop sequence - UINT8 sqn = m_channels[ch].sequence; + UINT8 sqn = elem.sequence; UINT32 pptr = m_rom_base[(4*sqn)+1+0x400]<<16 | m_rom_base[(4*sqn)+2+0x400]<<8 | m_rom_base[(4*sqn)+3+0x400]; - m_channels[ch].seqdata = &m_rom_base[pptr]; + elem.seqdata = &m_rom_base[pptr]; } else { - m_channels[ch].is_seq_playing = false; + elem.is_seq_playing = false; } break; case 0x0e: - m_channels[ch].seqdelay = 32 - 1; + elem.seqdelay = 32 - 1; break; default: internal_reg_write(reg, data); @@ -169,55 +169,55 @@ void ymz770_device::sound_stream_update(sound_stream &stream, stream_sample_t ** // process channels INT32 mix = 0; - for (int ch = 0; ch < 8; ch++) + for (auto & elem : m_channels) { - if (m_channels[ch].output_remaining > 0) + if (elem.output_remaining > 0) { // force finish current block - mix += (m_channels[ch].output_data[m_channels[ch].output_ptr++]*m_channels[ch].volume); - m_channels[ch].output_remaining--; + mix += (elem.output_data[elem.output_ptr++]*elem.volume); + elem.output_remaining--; - if (m_channels[ch].output_remaining == 0 && !m_channels[ch].is_playing) - m_channels[ch].decoder->clear(); + if (elem.output_remaining == 0 && !elem.is_playing) + elem.decoder->clear(); } - else if (m_channels[ch].is_playing) + else if (elem.is_playing) { retry: - if (m_channels[ch].last_block) + if (elem.last_block) { - if (m_channels[ch].control & 1) + if (elem.control & 1) { // loop sample - UINT8 phrase = m_channels[ch].phrase; - m_channels[ch].atbl = m_rom_base[(4*phrase)+0] >> 4 & 7; - m_channels[ch].pptr = 8*(m_rom_base[(4*phrase)+1]<<16 | m_rom_base[(4*phrase)+2]<<8 | m_rom_base[(4*phrase)+3]); + UINT8 phrase = elem.phrase; + elem.atbl = m_rom_base[(4*phrase)+0] >> 4 & 7; + elem.pptr = 8*(m_rom_base[(4*phrase)+1]<<16 | m_rom_base[(4*phrase)+2]<<8 | m_rom_base[(4*phrase)+3]); } else { - m_channels[ch].is_playing = false; - m_channels[ch].output_remaining = 0; - m_channels[ch].decoder->clear(); + elem.is_playing = false; + elem.output_remaining = 0; + elem.decoder->clear(); } } - if (m_channels[ch].is_playing) + if (elem.is_playing) { // next block int sample_rate, channel_count; - if (!m_channels[ch].decoder->decode_buffer(m_channels[ch].pptr, m_rom_limit, m_channels[ch].output_data, m_channels[ch].output_remaining, sample_rate, channel_count) || m_channels[ch].output_remaining == 0) + if (!elem.decoder->decode_buffer(elem.pptr, m_rom_limit, elem.output_data, elem.output_remaining, sample_rate, channel_count) || elem.output_remaining == 0) { - m_channels[ch].is_playing = !m_channels[ch].last_block; // detect infinite retry loop - m_channels[ch].last_block = true; - m_channels[ch].output_remaining = 0; + elem.is_playing = !elem.last_block; // detect infinite retry loop + elem.last_block = true; + elem.output_remaining = 0; goto retry; } - m_channels[ch].last_block = m_channels[ch].output_remaining < 1152; - m_channels[ch].output_remaining--; - m_channels[ch].output_ptr = 1; + elem.last_block = elem.output_remaining < 1152; + elem.output_remaining--; + elem.output_ptr = 1; - mix += (m_channels[ch].output_data[0]*m_channels[ch].volume); + mix += (elem.output_data[0]*elem.volume); } } } diff --git a/src/devices/sound/zsg2.cpp b/src/devices/sound/zsg2.cpp index 4f3f1a42ca9..f7f7f53ae16 100644 --- a/src/devices/sound/zsg2.cpp +++ b/src/devices/sound/zsg2.cpp @@ -206,33 +206,33 @@ void zsg2_device::sound_stream_update(sound_stream &stream, stream_sample_t **in INT32 mix_r = 0; // loop over all channels - for (int ch = 0; ch < 48; ch++) + for (auto & elem : m_chan) { - if (!m_chan[ch].is_playing) + if (!elem.is_playing) continue; - m_chan[ch].step_ptr += m_chan[ch].step; - if (m_chan[ch].step_ptr & 0x10000) + elem.step_ptr += elem.step; + if (elem.step_ptr & 0x10000) { - m_chan[ch].step_ptr &= 0xffff; - if (++m_chan[ch].cur_pos >= m_chan[ch].end_pos) + elem.step_ptr &= 0xffff; + if (++elem.cur_pos >= elem.end_pos) { // loop sample - m_chan[ch].cur_pos = m_chan[ch].loop_pos; - if ((m_chan[ch].cur_pos + 1) >= m_chan[ch].end_pos) + elem.cur_pos = elem.loop_pos; + if ((elem.cur_pos + 1) >= elem.end_pos) { // end of sample - m_chan[ch].is_playing = false; + elem.is_playing = false; continue; } } - m_chan[ch].samples = prepare_samples(m_chan[ch].page | m_chan[ch].cur_pos); + elem.samples = prepare_samples(elem.page | elem.cur_pos); } - INT32 sample = (m_chan[ch].samples[m_chan[ch].step_ptr >> 14 & 3] * m_chan[ch].vol) >> 16; + INT32 sample = (elem.samples[elem.step_ptr >> 14 & 3] * elem.vol) >> 16; - mix_l += (sample * m_chan[ch].panl + sample * (0x1f - m_chan[ch].panr)) >> 5; - mix_r += (sample * m_chan[ch].panr + sample * (0x1f - m_chan[ch].panl)) >> 5; + mix_l += (sample * elem.panl + sample * (0x1f - elem.panr)) >> 5; + mix_r += (sample * elem.panr + sample * (0x1f - elem.panl)) >> 5; } outputs[0][i] = mix_l; diff --git a/src/devices/video/crt9007.cpp b/src/devices/video/crt9007.cpp index 0b2a30894c3..84ec673ec8b 100644 --- a/src/devices/video/crt9007.cpp +++ b/src/devices/video/crt9007.cpp @@ -466,8 +466,8 @@ crt9007_t::crt9007_t(const machine_config &mconfig, const char *tag, device_t *o m_write_slg(*this), m_write_sld(*this) { - for (int i = 0; i < 0x3d; i++) - m_reg[i] = 0; + for (auto & elem : m_reg) + elem = 0; } diff --git a/src/devices/video/hd66421.cpp b/src/devices/video/hd66421.cpp index 1eda616225c..513b028336f 100644 --- a/src/devices/video/hd66421.cpp +++ b/src/devices/video/hd66421.cpp @@ -125,9 +125,9 @@ hd66421_device::hd66421_device(const machine_config &mconfig, const char *tag, d m_y(0), m_palette(*this, "palette") { - for (int i = 0; i < 32; i++) + for (auto & elem : m_reg) { - m_reg[i] = 0; + elem = 0; } } diff --git a/src/devices/video/mos6566.cpp b/src/devices/video/mos6566.cpp index 77196b0d85e..d39e8cb041a 100644 --- a/src/devices/video/mos6566.cpp +++ b/src/devices/video/mos6566.cpp @@ -773,8 +773,8 @@ void mos6566_device::device_reset() { memset(m_reg, 0, sizeof(m_reg)); - for (int i = 0; i < ARRAY_LENGTH(m_mc); i++) - m_mc[i] = 63; + for (auto & elem : m_mc) + elem = 63; // from 0 to 311 (0 first, PAL) or from 0 to 261 (? first, NTSC 6567R56A) or from 0 to 262 (? first, NTSC 6567R8) m_rasterline = 0; // VIC2_LINES - 1; diff --git a/src/devices/video/snes_ppu.cpp b/src/devices/video/snes_ppu.cpp index ce33d0a7dae..134f3e84a97 100644 --- a/src/devices/video/snes_ppu.cpp +++ b/src/devices/video/snes_ppu.cpp @@ -409,14 +409,14 @@ void snes_ppu_device::device_reset() memset(&m_oam, 0, sizeof(m_oam)); memset(&m_mode7, 0, sizeof(m_mode7)); - for (int i = 0; i < 2; i++) + for (auto & elem : m_scanlines) { - m_scanlines[i].enable = 0; - m_scanlines[i].clip = 0; - memset(m_scanlines[i].buffer, 0, SNES_SCR_WIDTH); - memset(m_scanlines[i].priority, 0, SNES_SCR_WIDTH); - memset(m_scanlines[i].layer, 0, SNES_SCR_WIDTH); - memset(m_scanlines[i].blend_exception, 0, SNES_SCR_WIDTH); + elem.enable = 0; + elem.clip = 0; + memset(elem.buffer, 0, SNES_SCR_WIDTH); + memset(elem.priority, 0, SNES_SCR_WIDTH); + memset(elem.layer, 0, SNES_SCR_WIDTH); + memset(elem.blend_exception, 0, SNES_SCR_WIDTH); } for (int i = 0; i < 6; i++) @@ -442,27 +442,27 @@ void snes_ppu_device::device_reset() memset(m_clipmasks[i], 0, SNES_SCR_WIDTH); } - for (int i = 0; i < ARRAY_LENGTH(m_oam_spritelist); i++) + for (auto & elem : m_oam_spritelist) { - m_oam_spritelist[i].tile = 0; - m_oam_spritelist[i].x = 0; - m_oam_spritelist[i].y = 0; - m_oam_spritelist[i].size = 0; - m_oam_spritelist[i].vflip = 0; - m_oam_spritelist[i].hflip = 0; - m_oam_spritelist[i].priority_bits = 0; - m_oam_spritelist[i].pal = 0; - m_oam_spritelist[i].height = 0; - m_oam_spritelist[i].width = 0; + elem.tile = 0; + elem.x = 0; + elem.y = 0; + elem.size = 0; + elem.vflip = 0; + elem.hflip = 0; + elem.priority_bits = 0; + elem.pal = 0; + elem.height = 0; + elem.width = 0; } - for (int i = 0; i < ARRAY_LENGTH(m_oam_tilelist); i++) + for (auto & elem : m_oam_tilelist) { - m_oam_tilelist[i].x = 0; - m_oam_tilelist[i].priority = 0; - m_oam_tilelist[i].pal = 0; - m_oam_tilelist[i].tileaddr = 0; - m_oam_tilelist[i].hflip = 0; + elem.x = 0; + elem.priority = 0; + elem.pal = 0; + elem.tileaddr = 0; + elem.hflip = 0; } } diff --git a/src/devices/video/tms9928a.cpp b/src/devices/video/tms9928a.cpp index 7fd22263776..ba7a40a4b6e 100644 --- a/src/devices/video/tms9928a.cpp +++ b/src/devices/video/tms9928a.cpp @@ -709,8 +709,8 @@ void tms9928a_device::device_start() void tms9928a_device::device_reset() { - for ( int i = 0; i < 8; i++ ) - m_Regs[i] = 0; + for (auto & elem : m_Regs) + elem = 0; m_StatusReg = 0; m_FifthSprite = 31; diff --git a/src/devices/video/upd7220.cpp b/src/devices/video/upd7220.cpp index e80cef73745..cc892d66b33 100644 --- a/src/devices/video/upd7220.cpp +++ b/src/devices/video/upd7220.cpp @@ -653,9 +653,9 @@ upd7220_device::upd7220_device(const machine_config &mconfig, const char *tag, d m_ra[i] = 0; } - for (int i = 0; i < 17; i++) + for (auto & elem : m_pr) { - m_pr[i] = 0; + elem = 0; } memset(&m_figs, 0x00, sizeof(m_figs)); diff --git a/src/emu/dispatch.h b/src/emu/dispatch.h index 47e742c86b3..f9442a658da 100644 --- a/src/emu/dispatch.h +++ b/src/emu/dispatch.h @@ -40,8 +40,8 @@ public: template static devcb_base &set_fwd_cb(device_t &device, int entry, _Object object) { return downcast &>(device).fwd_cb[entry]->set_callback(object); } WRITE_LINE_MEMBER( in_w ) { - for(int i=0; iget_actual_geometry(g_tracks, g_heads); @@ -822,8 +822,8 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image) if(hb == 4) { UINT8 h[11]; - for(int i=0; i<11; i++) - h[i] = gb(buf, ts, pos, wrap); + for(auto & elem : h) + elem = gb(buf, ts, pos, wrap); //UINT8 v2 = gcr6bw_tb[h[2]]; UINT8 vl = gcr4_decode(h[0],h[1]); UINT8 tr = gcr4_decode(h[2],h[3]); @@ -1140,9 +1140,9 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image) #define DATAGOOD 8 // data postamble is good #define DATAPOST 16 - for (int i = 0; i < 18; i++) { + for (auto & elem : visualgrid) { for (int j = 0; j < 35; j++) { - visualgrid[i][j] = 0; + elem[j] = 0; } } image->get_actual_geometry(g_tracks, g_heads); @@ -1182,8 +1182,8 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image) if(hb == 4) { UINT8 h[11]; - for(int i=0; i<11; i++) - h[i] = gb(buf, ts, pos, wrap); + for(auto & elem : h) + elem = gb(buf, ts, pos, wrap); //UINT8 v2 = gcr6bw_tb[h[2]]; UINT8 vl = gcr4_decode(h[0],h[1]); UINT8 tr = gcr4_decode(h[2],h[3]); @@ -1345,8 +1345,8 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image) oldpos=pos; UINT8 h[7]; // grab exactly 7 bytes: should be Track, Sector, Checksum, AA, FF and FF and the Br0derbund Title ID - for(int i=0; i<7; i++) - h[i] = gb(buf, ts, pos, wrap); + for(auto & elem : h) + elem = gb(buf, ts, pos, wrap); UINT8 tr = gcr6bw_tb[h[0]]; UINT8 se = gcr6bw_tb[h[1]]; UINT8 chk = gcr6bw_tb[h[2]]; diff --git a/src/lib/formats/ap_dsk35.cpp b/src/lib/formats/ap_dsk35.cpp index 385ff326047..ff8cef2e08a 100644 --- a/src/lib/formats/ap_dsk35.cpp +++ b/src/lib/formats/ap_dsk35.cpp @@ -1410,8 +1410,8 @@ bool dc42_format::save(io_generic *io, floppy_image *image) if(hb == 4) { UINT8 h[7]; - for(int i=0; i<7; i++) - h[i] = gb(buf, ts, pos, wrap); + for(auto & elem : h) + elem = gb(buf, ts, pos, wrap); UINT8 v2 = gcr6bw_tb[h[2]]; UINT8 v3 = gcr6bw_tb[h[3]]; UINT8 tr = gcr6bw_tb[h[0]] | (v2 & 1 ? 0x40 : 0x00); diff --git a/src/lib/formats/cassimg.cpp b/src/lib/formats/cassimg.cpp index aabc13ee393..7fe1bcec81b 100644 --- a/src/lib/formats/cassimg.cpp +++ b/src/lib/formats/cassimg.cpp @@ -278,8 +278,8 @@ void cassette_close(cassette_image *cassette) { if ((cassette->flags & CASSETTE_FLAG_DIRTY) && (cassette->flags & CASSETTE_FLAG_SAVEONEXIT)) cassette_save(cassette); - for (unsigned int i = 0; i < cassette->blocks.size(); i++) - global_free(cassette->blocks[i]); + for (auto & elem : cassette->blocks) + global_free(elem); global_free(cassette); } } diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp index fa10ab3e4a9..57281fcda0e 100644 --- a/src/lib/formats/flopimg.cpp +++ b/src/lib/formats/flopimg.cpp @@ -1763,8 +1763,8 @@ void floppy_image_format_t::generate_track_from_levels(int track, int head, std: // Also check if all MG values are valid int transition_count = 0; - for(unsigned int i=0; iadjust(period, 0, period); /* reset all the voices */ - for (int i = 0; i < 8; i++) + for (auto & elem : m_channel_list) { - voice = &m_channel_list[i]; + voice = &elem; voice->freq = 0; voice->pos = 0; diff --git a/src/mame/audio/lynx.cpp b/src/mame/audio/lynx.cpp index 2e17abde91f..ba31b88ba06 100644 --- a/src/mame/audio/lynx.cpp +++ b/src/mame/audio/lynx.cpp @@ -212,9 +212,9 @@ void lynx2_sound_device::device_start() void lynx_sound_device::device_reset() { - for (int i = 0; i < LYNX_AUDIO_CHANNELS; i++) + for (auto & elem : m_audio) { - reset_channel(&m_audio[i]); + reset_channel(&elem); } } diff --git a/src/mame/audio/mea8000.cpp b/src/mame/audio/mea8000.cpp index 6936205b79f..306fec1ac3e 100644 --- a/src/mame/audio/mea8000.cpp +++ b/src/mame/audio/mea8000.cpp @@ -174,10 +174,10 @@ void mea8000_device::device_reset() m_roe = 0; m_state = MEA8000_STOPPED; update_req(); - for (int i = 0; i < 4; i++) + for (auto & elem : m_f) { - m_f[i].last_output = 0; - m_f[i].output = 0; + elem.last_output = 0; + elem.output = 0; } } @@ -215,8 +215,8 @@ void mea8000_device::init_tables() m_exp_table[i] = exp(-M_PI * f) * QUANT; m_exp2_table[i] = exp(-2 * M_PI * f) * QUANT; } - for (int i = 0; i < NOISE_LEN; i++) - m_noise_table[i] = (machine().rand() % (2 * QUANT)) - QUANT; + for (auto & elem : m_noise_table) + elem = (machine().rand() % (2 * QUANT)) - QUANT; } @@ -371,10 +371,10 @@ int mea8000_device::compute_sample() void mea8000_device::shift_frame() { m_last_pitch = m_pitch; - for (int i = 0; i < 4; i++) + for (auto & elem : m_f) { - m_f[i].last_bw = m_f[i].bw; - m_f[i].last_fm = m_f[i].fm; + elem.last_bw = elem.bw; + elem.last_fm = elem.fm; } m_last_ampl = m_ampl; } diff --git a/src/mame/audio/turrett.cpp b/src/mame/audio/turrett.cpp index 69c8b784c3f..bb1fee907b4 100644 --- a/src/mame/audio/turrett.cpp +++ b/src/mame/audio/turrett.cpp @@ -69,8 +69,8 @@ void turrett_device::device_start() void turrett_device::device_reset() { - for (int ch = 0; ch < SOUND_CHANNELS; ++ch) - m_channels[ch].m_playing = false; + for (auto & elem : m_channels) + elem.m_playing = false; } diff --git a/src/mame/drivers/atarist.cpp b/src/mame/drivers/atarist.cpp index 46dcf99df03..053d68c4b61 100644 --- a/src/mame/drivers/atarist.cpp +++ b/src/mame/drivers/atarist.cpp @@ -760,9 +760,9 @@ void ste_state::dmasound_tick() { UINT8 *RAM = m_ram->pointer(); - for (int i = 0; i < 8; i++) + for (auto & elem : m_dmasnd_fifo) { - m_dmasnd_fifo[i] = RAM[m_dmasnd_cntr]; + elem = RAM[m_dmasnd_cntr]; m_dmasnd_cntr++; m_dmasnd_samples++; diff --git a/src/mame/drivers/bfm_sc45_helper.cpp b/src/mame/drivers/bfm_sc45_helper.cpp index 991f3894e59..264f9dbe71f 100644 --- a/src/mame/drivers/bfm_sc45_helper.cpp +++ b/src/mame/drivers/bfm_sc45_helper.cpp @@ -388,16 +388,16 @@ lampinfo lamps[16][16]; void set_clickable_temp(running_machine &machine, const std::string &teststring, int clickport, int clickmask) { - for (int y = 0; y < 16; y++) + for (auto & lamp : lamps) { for (int x = 0; x < 16; x++) { - if (!strcmp(teststring.c_str(), lamps[y][x].lampname_alt.c_str())) + if (!strcmp(teststring.c_str(), lamp[x].lampname_alt.c_str())) { - lamps[y][x].clickport = clickport; - lamps[y][x].clickmask = clickmask; + lamp[x].clickport = clickport; + lamp[x].clickmask = clickmask; - lamps[y][x].lamptypename = "buttonlamp"; + lamp[x].lamptypename = "buttonlamp"; } } @@ -518,12 +518,12 @@ int find_lamp_strings(running_machine &machine) // layout elements for each of the text labels int d = 0; - for (int y = 0; y < 16; y++) + for (auto & lamp : lamps) { //sc45helperlog("---ROW %02d---\n", y); for (int x = 0; x < 16; x++) { - sc45helperlog("\n", d, lamps[y][x].lampname.c_str()); + sc45helperlog("\n", d, lamp[x].lampname.c_str()); d++; } } @@ -589,17 +589,17 @@ int find_lamp_strings(running_machine &machine) // copy the button strings so we can modify some for easier comparisons d = 0; - for (int y = 0; y < 16; y++) + for (auto & lamp : lamps) { for (int x = 0; x < 16; x++) { - lamps[y][x].lampname_alt = lamps[y][x].lampname; + lamp[x].lampname_alt = lamp[x].lampname; - if (!strcmp(lamps[y][x].lampname_alt.c_str(), "hold2/hi")) lamps[y][x].lampname_alt = "hold2"; - if (!strcmp(lamps[y][x].lampname_alt.c_str(), "hold3/lo")) lamps[y][x].lampname_alt = "hold3"; - if (!strcmp(lamps[y][x].lampname_alt.c_str(), "chg stake")) lamps[y][x].lampname_alt = "chnge stk"; - if (!strcmp(lamps[y][x].lampname_alt.c_str(), "canc/coll")) lamps[y][x].lampname_alt = "cancel"; - if (!strcmp(lamps[y][x].lampname_alt.c_str(), "start")) lamps[y][x].lampname_alt = "strt exch"; + if (!strcmp(lamp[x].lampname_alt.c_str(), "hold2/hi")) lamp[x].lampname_alt = "hold2"; + if (!strcmp(lamp[x].lampname_alt.c_str(), "hold3/lo")) lamp[x].lampname_alt = "hold3"; + if (!strcmp(lamp[x].lampname_alt.c_str(), "chg stake")) lamp[x].lampname_alt = "chnge stk"; + if (!strcmp(lamp[x].lampname_alt.c_str(), "canc/coll")) lamp[x].lampname_alt = "cancel"; + if (!strcmp(lamp[x].lampname_alt.c_str(), "start")) lamp[x].lampname_alt = "strt exch"; } } @@ -623,20 +623,20 @@ int find_lamp_strings(running_machine &machine) if (pos == 2) sprintf(tempname2, "%sbot", tempname); - for (int y = 0; y < 16; y++) + for (auto & lamp : lamps) { for (int x = 0; x < 16; x++) { - if (!strcmp(tempname2, lamps[y][x].lampname_alt.c_str())) + if (!strcmp(tempname2, lamp[x].lampname_alt.c_str())) { //sc45helperlog("%s found\n", tempname2); - lamps[y][x].draw_label = false; + lamp[x].draw_label = false; - lamps[y][x].x = 0 + (50 * reel); - lamps[y][x].y = 300 + (17 * pos); - lamps[y][x].width = 50; - lamps[y][x].height = 17; - lamps[y][x].lamptypename = "reellamp"; + lamp[x].x = 0 + (50 * reel); + lamp[x].y = 300 + (17 * pos); + lamp[x].width = 50; + lamp[x].height = 17; + lamp[x].lamptypename = "reellamp"; } @@ -676,17 +676,17 @@ int find_lamp_strings(running_machine &machine) // dump out basic matrix stuff in layout format d = 0; - for (int y = 0; y < 16; y++) + for (auto & lamp : lamps) { //sc45helperlog("---ROW %02d---\n", y); for (int x = 0; x < 16; x++) { - if (lamps[y][x].clickport== -1) sc45helperlog("\n", d, lamps[y][x].lamptypename.c_str(), lamps[y][x].x, lamps[y][x].y, lamps[y][x].width, lamps[y][x].height); - else sc45helperlog("\n", d, lamps[y][x].lamptypename.c_str(), lamps[y][x].clickport, lamps[y][x].clickmask, lamps[y][x].x, lamps[y][x].y, lamps[y][x].width, lamps[y][x].height); + if (lamp[x].clickport== -1) sc45helperlog("\n", d, lamp[x].lamptypename.c_str(), lamp[x].x, lamp[x].y, lamp[x].width, lamp[x].height); + else sc45helperlog("\n", d, lamp[x].lamptypename.c_str(), lamp[x].clickport, lamp[x].clickmask, lamp[x].x, lamp[x].y, lamp[x].width, lamp[x].height); - if (lamps[y][x].draw_label == false) sc45helperlog("\n"); + if (lamp[x].draw_label == false) sc45helperlog("\n"); d++; } @@ -830,9 +830,9 @@ int find_reel_strings(running_machine &machine) int total_reel_symbols = 0; - for (unsigned int i = 0; i < reelsizes.size(); i++) + for (auto & reelsize : reelsizes) { - total_reel_symbols += reelsizes[i]; + total_reel_symbols += reelsize; } endblock = startblock + 4 * (total_reel_symbols); diff --git a/src/mame/drivers/esq1.cpp b/src/mame/drivers/esq1.cpp index b37f26185aa..4edb38303cf 100644 --- a/src/mame/drivers/esq1.cpp +++ b/src/mame/drivers/esq1.cpp @@ -332,8 +332,8 @@ void esq1_filters::device_start() { stream = stream_alloc(8, 2, 44100); memset(filters, 0, sizeof(filters)); - for(int i=0; i<8; i++) - recalc_filter(filters[i]); + for(auto & elem : filters) + recalc_filter(elem); } void esq1_filters::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) diff --git a/src/mame/drivers/famibox.cpp b/src/mame/drivers/famibox.cpp index 023cd64486b..6f93c9bb930 100644 --- a/src/mame/drivers/famibox.cpp +++ b/src/mame/drivers/famibox.cpp @@ -254,14 +254,14 @@ void famibox_state::famicombox_bankswitch(UINT8 bank) }; - for (int i = 0; i < ARRAY_LENGTH(famicombox_banks); i++ ) + for (auto & famicombox_bank : famicombox_banks) { - if ( bank == famicombox_banks[i].bank || - famicombox_banks[i].bank == 0 ) + if ( bank == famicombox_bank.bank || + famicombox_bank.bank == 0 ) { - membank("cpubank1")->set_base(memregion(famicombox_banks[i].memory_region)->base() + famicombox_banks[i].bank1_offset); - membank("cpubank2")->set_base(memregion(famicombox_banks[i].memory_region)->base() + famicombox_banks[i].bank2_offset); - membank("ppubank1")->set_base(memregion(famicombox_banks[i].memory_region)->base() + famicombox_banks[i].ppubank_offset); + membank("cpubank1")->set_base(memregion(famicombox_bank.memory_region)->base() + famicombox_bank.bank1_offset); + membank("cpubank2")->set_base(memregion(famicombox_bank.memory_region)->base() + famicombox_bank.bank2_offset); + membank("ppubank1")->set_base(memregion(famicombox_bank.memory_region)->base() + famicombox_bank.ppubank_offset); break; } } diff --git a/src/mame/drivers/hyperscan.cpp b/src/mame/drivers/hyperscan.cpp index baa1c767773..d5cc9d804e5 100644 --- a/src/mame/drivers/hyperscan.cpp +++ b/src/mame/drivers/hyperscan.cpp @@ -523,22 +523,22 @@ UINT32 hyperscan_state::spg290_screen_update(screen_device &screen, bitmap_rgb32 void hyperscan_state::spg290_timers_update() { - for(int i=0; i<6; i++) - if (m_timers[i].control & 0x80000000) + for(auto & elem : m_timers) + if (elem.control & 0x80000000) { - if (((m_timers[i].control2 >> 30) & 0x03) == 0x00) + if (((elem.control2 >> 30) & 0x03) == 0x00) { - if (m_timers[i].counter == 0xffff) + if (elem.counter == 0xffff) { - m_timers[i].counter = m_timers[i].preload; - if (m_timers[i].control & 0x08000000) + elem.counter = elem.preload; + if (elem.control & 0x08000000) { - m_timers[i].control |= 0x04000000; + elem.control |= 0x04000000; m_maincpu->set_input_line_and_vector(0, HOLD_LINE, 56); } } else - m_timers[i].counter++; + elem.counter++; } else { diff --git a/src/mame/drivers/iq151.cpp b/src/mame/drivers/iq151.cpp index afee4573fcd..e4cbe4a504c 100644 --- a/src/mame/drivers/iq151.cpp +++ b/src/mame/drivers/iq151.cpp @@ -170,32 +170,32 @@ READ8_MEMBER(iq151_state::cartslot_r) { UINT8 data = 0xff; - for (int i=0; i<5; i++) - m_carts[i]->read(offset, data); + for (auto & elem : m_carts) + elem->read(offset, data); return data; } WRITE8_MEMBER(iq151_state::cartslot_w) { - for (int i=0; i<5; i++) - m_carts[i]->write(offset, data); + for (auto & elem : m_carts) + elem->write(offset, data); } READ8_MEMBER(iq151_state::cartslot_io_r) { UINT8 data = 0xff; - for (int i=0; i<5; i++) - m_carts[i]->io_read(offset, data); + for (auto & elem : m_carts) + elem->io_read(offset, data); return data; } WRITE8_MEMBER(iq151_state::cartslot_io_w) { - for (int i=0; i<5; i++) - m_carts[i]->io_write(offset, data); + for (auto & elem : m_carts) + elem->io_write(offset, data); } static ADDRESS_MAP_START(iq151_mem, AS_PROGRAM, 8, iq151_state) @@ -355,8 +355,8 @@ UINT32 iq151_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c { bitmap.fill(0, cliprect); - for (int i=0; i<5; i++) - m_carts[i]->video_update(bitmap, cliprect); + for (auto & elem : m_carts) + elem->video_update(bitmap, cliprect); return 0; } diff --git a/src/mame/drivers/jack.cpp b/src/mame/drivers/jack.cpp index 01f1c88a2a7..952915820c1 100644 --- a/src/mame/drivers/jack.cpp +++ b/src/mame/drivers/jack.cpp @@ -878,8 +878,8 @@ MACHINE_RESET_MEMBER(jack_state,striv) m_question_address = 0; m_question_rom = 0; - for (int i = 0; i < 16; i++) - m_remap_address[i] = 0; + for (auto & elem : m_remap_address) + elem = 0; } diff --git a/src/mame/drivers/joystand.cpp b/src/mame/drivers/joystand.cpp index a9e4a9e097c..4a17628eae4 100644 --- a/src/mame/drivers/joystand.cpp +++ b/src/mame/drivers/joystand.cpp @@ -306,10 +306,10 @@ void joystand_state::video_start() m_bg1_tmap->set_transparent_pen(0xf); m_bg2_tmap->set_transparent_pen(0xf); - for (int i = 0; i < 2; ++i) + for (auto & elem : m_bg15_bitmap) { - m_bg15_bitmap[i].allocate(0x200, 0x200); - m_bg15_bitmap[i].fill(BG15_TRANSPARENT); + elem.allocate(0x200, 0x200); + elem.fill(BG15_TRANSPARENT); } bg15_tiles_dirty = true; diff --git a/src/mame/drivers/lethal.cpp b/src/mame/drivers/lethal.cpp index 59015da3704..30f82d8195c 100644 --- a/src/mame/drivers/lethal.cpp +++ b/src/mame/drivers/lethal.cpp @@ -481,8 +481,8 @@ void lethal_state::machine_start() void lethal_state::machine_reset() { - for (int i = 0; i < 4; i++) - m_layer_colorbase[i] = 0; + for (auto & elem : m_layer_colorbase) + elem = 0; m_sprite_colorbase = 0; m_back_colorbase = 0; diff --git a/src/mame/drivers/microvsn.cpp b/src/mame/drivers/microvsn.cpp index f82725bc43e..f15bfd8c0a6 100644 --- a/src/mame/drivers/microvsn.cpp +++ b/src/mame/drivers/microvsn.cpp @@ -163,16 +163,16 @@ MACHINE_START_MEMBER(microvision_state, microvision) MACHINE_RESET_MEMBER(microvision_state, microvision) { - for( int i = 0; i < 8; i++ ) + for(auto & elem : m_lcd_latch) { - m_lcd_latch[i] = 0; + elem = 0; } - for( int i = 0; i < 16; i++ ) + for(auto & elem : m_lcd) { for ( int j = 0; j < 16; j++ ) { - m_lcd[i][j] = 0; + elem[j] = 0; } } @@ -225,11 +225,11 @@ void microvision_state::update_lcd() { UINT16 temp = row; - for ( int j = 0; j < 16; j++ ) + for (auto & elem : m_lcd) { if ( ( temp & col ) & 0x8000 ) { - m_lcd[j][i] = 15; + elem[i] = 15; } temp <<= 1; } @@ -256,13 +256,13 @@ void microvision_state::screen_vblank(screen_device &screen, bool state) { if ( state ) { - for ( int i = 0; i < 16; i++ ) + for (auto & elem : m_lcd) { for ( int j= 0; j < 16; j++ ) { - if ( m_lcd[i][j] ) + if ( elem[j] ) { - m_lcd[i][j]--; + elem[j]--; } } } diff --git a/src/mame/drivers/monty.cpp b/src/mame/drivers/monty.cpp index 3ec54712777..0167938503b 100644 --- a/src/mame/drivers/monty.cpp +++ b/src/mame/drivers/monty.cpp @@ -44,8 +44,8 @@ public: , m_sed0(*this, "sed1520_0") , m_writeUpper(false) { - for (int i = 0; i < 42*32; i++) - m_pixels[i] = 0xff000000; + for (auto & elem : m_pixels) + elem = 0xff000000; } DECLARE_WRITE8_MEMBER(sound_w); diff --git a/src/mame/drivers/mz3500.cpp b/src/mame/drivers/mz3500.cpp index 8a5828e0401..9f480c08563 100644 --- a/src/mame/drivers/mz3500.cpp +++ b/src/mame/drivers/mz3500.cpp @@ -770,10 +770,10 @@ void mz3500_state::machine_reset() { m_fdd_sel = 0; { - for(int i=0;i<4;i++) + for(auto & elem : m_floppy_connector) { - m_floppy_connector[i]->get_device()->mon_w(ASSERT_LINE); - m_floppy_connector[i]->get_device()->set_rpm(300); + elem->get_device()->mon_w(ASSERT_LINE); + elem->get_device()->set_rpm(300); } machine().device("upd765a")->set_rate(250000); diff --git a/src/mame/drivers/nakajies.cpp b/src/mame/drivers/nakajies.cpp index 29b2ba35af8..bcf43ef4071 100644 --- a/src/mame/drivers/nakajies.cpp +++ b/src/mame/drivers/nakajies.cpp @@ -649,9 +649,9 @@ void nakajies_state::machine_reset() m_matrix = 0; /* Initialize banks */ - for ( int i = 0; i < 8; i++ ) + for (auto & elem : m_bank) { - m_bank[i] = 0; + elem = 0; } memset(m_ram_base, 0, m_ram_size); update_banks(); diff --git a/src/mame/drivers/namcoic.cpp b/src/mame/drivers/namcoic.cpp index 422756fb48f..1cc553b93eb 100644 --- a/src/mame/drivers/namcoic.cpp +++ b/src/mame/drivers/namcoic.cpp @@ -1165,8 +1165,8 @@ WRITE16_MEMBER( namcos2_shared_state::c169_roz_bank_w ) UINT16 old_data = m_c169_roz_bank[offset]; COMBINE_DATA(&m_c169_roz_bank[offset]); if (m_c169_roz_bank[offset] != old_data) - for (int i = 0; i < ROZ_TILEMAP_COUNT; i++) - m_c169_roz_tilemap[i]->mark_all_dirty(); + for (auto & elem : m_c169_roz_tilemap) + elem->mark_all_dirty(); } READ16_MEMBER( namcos2_shared_state::c169_roz_videoram_r ) @@ -1177,6 +1177,6 @@ READ16_MEMBER( namcos2_shared_state::c169_roz_videoram_r ) WRITE16_MEMBER( namcos2_shared_state::c169_roz_videoram_w ) { COMBINE_DATA(&m_c169_roz_videoram[offset]); - for (int i = 0; i < ROZ_TILEMAP_COUNT; i++) - m_c169_roz_tilemap[i]->mark_tile_dirty(offset); + for (auto & elem : m_c169_roz_tilemap) + elem->mark_tile_dirty(offset); } diff --git a/src/mame/drivers/namcos22.cpp b/src/mame/drivers/namcos22.cpp index cbc60e9fca9..64000211811 100644 --- a/src/mame/drivers/namcos22.cpp +++ b/src/mame/drivers/namcos22.cpp @@ -3874,8 +3874,8 @@ MACHINE_START_MEMBER(namcos22_state,adillor) { machine_start(); - for (int axis = 0; axis < 2; axis++) - m_ar_tb_interrupt[axis] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos22_state::adillor_trackball_interrupt),this)); + for (auto & elem : m_ar_tb_interrupt) + elem = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos22_state::adillor_trackball_interrupt),this)); } static MACHINE_CONFIG_DERIVED( adillor, namcos22s ) diff --git a/src/mame/drivers/pcfx.cpp b/src/mame/drivers/pcfx.cpp index d2faa292087..f80150959e6 100644 --- a/src/mame/drivers/pcfx.cpp +++ b/src/mame/drivers/pcfx.cpp @@ -380,13 +380,13 @@ inline void pcfx_state::check_irqs() UINT16 active_irqs = m_irq_pending & ~m_irq_mask; int highest_prio = -1; - for ( int i = 0; i < 8; i++ ) + for (auto & elem : m_irq_priority) { if ( active_irqs & 0x80 ) { - if ( m_irq_priority[i] >= highest_prio ) + if ( elem >= highest_prio ) { - highest_prio = m_irq_priority[i]; + highest_prio = elem; } } active_irqs <<= 1; diff --git a/src/mame/drivers/psikyo4.cpp b/src/mame/drivers/psikyo4.cpp index de33dbeb935..b1c04ab7ae8 100644 --- a/src/mame/drivers/psikyo4.cpp +++ b/src/mame/drivers/psikyo4.cpp @@ -296,13 +296,13 @@ WRITE32_MEMBER(psikyo4_state::io_select_w) { UINT32 bankdata = data >> 16; UINT32 bankmask = mem_mask >> 16; - for (int i = 0; i < 4; i++) + for (auto & elem : m_ymf_bank) { if (bankmask & 0x0f) { int banknum = bankdata & 0x0f; if (banknum < m_ymf_max_bank) - m_ymf_bank[i]->set_entry(banknum); + elem->set_entry(banknum); } bankdata >>= 4; bankmask >>= 4; diff --git a/src/mame/drivers/raiden2.cpp b/src/mame/drivers/raiden2.cpp index dce9db01f60..661f7fd9e27 100644 --- a/src/mame/drivers/raiden2.cpp +++ b/src/mame/drivers/raiden2.cpp @@ -2988,8 +2988,8 @@ const UINT16 raiden2_state::raiden_blended_colors[] = { void raiden2_state::init_blending(const UINT16 *table) { - for(int i=0; i<0x800; i++) - blend_active[i] = false; + for(auto & elem : blend_active) + elem = false; while(*table != 0xffff) blend_active[*table++] = true; } diff --git a/src/mame/drivers/segaxbd.cpp b/src/mame/drivers/segaxbd.cpp index 8b26b9149b5..5758c0957c2 100644 --- a/src/mame/drivers/segaxbd.cpp +++ b/src/mame/drivers/segaxbd.cpp @@ -369,9 +369,9 @@ public: : segaxbd_new_state(mconfig, type, tag), m_subpcb(*this, "subpcb") { - for (int i = 0; i < 0x800; i++) + for (auto & elem : shareram) { - shareram[i] = 0x0000; + elem = 0x0000; } rampage1 = 0x0000; rampage2 = 0x0000; diff --git a/src/mame/drivers/stratos.cpp b/src/mame/drivers/stratos.cpp index 3af3d8ed6b8..733f62b979f 100644 --- a/src/mame/drivers/stratos.cpp +++ b/src/mame/drivers/stratos.cpp @@ -320,8 +320,8 @@ WRITE8_MEMBER(stratos_state::lcd_w) idx++; if(idx == 18*2) { logerror("lcd"); - for(int i=0; i<18; i++) - logerror(" %02x", vals[i]); + for(auto & val : vals) + logerror(" %02x", val); logerror("\n"); } } diff --git a/src/mame/drivers/subsino2.cpp b/src/mame/drivers/subsino2.cpp index a521bc00b92..fda484cd19e 100644 --- a/src/mame/drivers/subsino2.cpp +++ b/src/mame/drivers/subsino2.cpp @@ -712,9 +712,9 @@ UINT32 subsino2_state::screen_update_subsino2(screen_device &screen, bitmap_ind1 l->tmap->set_scroll_rows(1); l->tmap->set_scroll_cols(1); - for (int r = 0; r < 3; r++) + for (auto visible : m_ss9601_reelrects) { - rectangle visible = m_ss9601_reelrects[r]; + for (int x = 0; x < 0x40; x++) { diff --git a/src/mame/drivers/x07.cpp b/src/mame/drivers/x07.cpp index 08daaa4d696..4cb0db32f25 100644 --- a/src/mame/drivers/x07.cpp +++ b/src/mame/drivers/x07.cpp @@ -156,8 +156,8 @@ void x07_state::t6834_cmd (UINT8 cmd) case 0x0c: //ALM$ write { - for(int i = 0; i < 8; i++) - m_alarm[i] = m_in.data[m_in.read++]; + for(auto & elem : m_alarm) + elem = m_in.data[m_in.read++]; } break; @@ -500,8 +500,8 @@ void x07_state::t6834_cmd (UINT8 cmd) case 0x36: //alarm read { - for(int i = 0; i < 8; i++) - m_out.data[m_out.write++] = m_alarm[i]; + for(auto & elem : m_alarm) + m_out.data[m_out.write++] = elem; } break; diff --git a/src/mame/includes/msx.h b/src/mame/includes/msx.h index c52d8d7bef7..ba8e3e6064f 100644 --- a/src/mame/includes/msx.h +++ b/src/mame/includes/msx.h @@ -159,9 +159,9 @@ public: } m_mouse[0] = m_mouse[1] = 0; m_mouse_stat[0] = m_mouse_stat[1] = 0; - for (int i = 0; i < ARRAY_LENGTH(m_irq_state); i++) + for (auto & elem : m_irq_state) { - m_irq_state[i] = CLEAR_LINE; + elem = CLEAR_LINE; } } diff --git a/src/mame/includes/tandy2k.h b/src/mame/includes/tandy2k.h index 761d2f0cb37..e9949ad3443 100644 --- a/src/mame/includes/tandy2k.h +++ b/src/mame/includes/tandy2k.h @@ -96,9 +96,9 @@ public: m_centronics_perror(0), m_centronics_busy(0) { - for (int i = 0; i < 4; i++) + for (auto & elem : m_busdmarq) { - m_busdmarq[i] = CLEAR_LINE; + elem = CLEAR_LINE; } } diff --git a/src/mame/machine/315-5838_317-0229_comp.cpp b/src/mame/machine/315-5838_317-0229_comp.cpp index d7c33c5afad..cfd38aa7c88 100644 --- a/src/mame/machine/315-5838_317-0229_comp.cpp +++ b/src/mame/machine/315-5838_317-0229_comp.cpp @@ -49,24 +49,24 @@ sega_315_5838_comp_device::sega_315_5838_comp_device(const machine_config &mconf void sega_315_5838_comp_device::device_start() { - for (int i = 0; i < 2; i++) + for (auto & elem : m_channel) { - m_channel[i].m_decathlt_lastcount = 0; - m_channel[i].m_decathlt_prot_uploadmode = 0; - m_channel[i].m_decathlt_prot_uploadoffset = 0; - m_channel[i].m_read_ch.bind_relative_to(*owner()); + elem.m_decathlt_lastcount = 0; + elem.m_decathlt_prot_uploadmode = 0; + elem.m_decathlt_prot_uploadoffset = 0; + elem.m_read_ch.bind_relative_to(*owner()); } } void sega_315_5838_comp_device::device_reset() { - for (int i = 0; i < 2; i++) + for (auto & elem : m_channel) { - m_channel[i].m_srcoffset = 0; - m_channel[i].m_decathlt_lastcount = 0; - m_channel[i].m_decathlt_prot_uploadmode = 0; - m_channel[i].m_decathlt_prot_uploadoffset = 0; + elem.m_srcoffset = 0; + elem.m_decathlt_lastcount = 0; + elem.m_decathlt_prot_uploadmode = 0; + elem.m_decathlt_prot_uploadoffset = 0; } m_protstate = 0; diff --git a/src/mame/machine/315_5296.cpp b/src/mame/machine/315_5296.cpp index 18551b95f23..34aa0da1d22 100644 --- a/src/mame/machine/315_5296.cpp +++ b/src/mame/machine/315_5296.cpp @@ -105,8 +105,8 @@ void sega_315_5296_device::device_reset() for (int i = 0; i < 8; i++) (*m_out_port_cb[i])((offs_t)i, 0); - for (int i = 0; i < 3; i++) - (*m_out_cnt_cb[i])(0); + for (auto & elem : m_out_cnt_cb) + (*elem)(0); } diff --git a/src/mame/machine/asic65.cpp b/src/mame/machine/asic65.cpp index 5674adfd49e..3ad34f5e32a 100644 --- a/src/mame/machine/asic65.cpp +++ b/src/mame/machine/asic65.cpp @@ -102,9 +102,9 @@ asic65_device::asic65_device(const machine_config &mconfig, const char *tag, dev m_tdata(0), m_log(nullptr) { - for (int i = 0; i < 32; i++) + for (auto & elem : m_param) { - m_param[i] = 0; + elem = 0; } } diff --git a/src/mame/machine/balsente.cpp b/src/mame/machine/balsente.cpp index d9bde8cb7ae..8eceeffa417 100644 --- a/src/mame/machine/balsente.cpp +++ b/src/mame/machine/balsente.cpp @@ -925,8 +925,8 @@ WRITE8_MEMBER(balsente_state::balsente_counter_control_w) /* bit D0 enables/disables audio */ if (diff_counter_control & 0x01) { - for (int ch = 0; ch < 6; ch++) - m_cem_device[ch]->set_output_gain(0, (data & 0x01) ? 1.0 : 0); + for (auto & elem : m_cem_device) + elem->set_output_gain(0, (data & 0x01) ? 1.0 : 0); } /* bit D1 is hooked to counter 0's gate */ diff --git a/src/mame/machine/cdi070.cpp b/src/mame/machine/cdi070.cpp index 36b41333b7d..cc8f377d76a 100644 --- a/src/mame/machine/cdi070.cpp +++ b/src/mame/machine/cdi070.cpp @@ -426,9 +426,9 @@ void cdi68070_device::mcu_frame() { quizard_calculate_state(); uart_rx(0x5a); - for(int index = 0; index < 8; index++) + for(auto & elem : m_state) { - uart_rx(m_state[index]); + uart_rx(elem); } } } diff --git a/src/mame/machine/cdislave.cpp b/src/mame/machine/cdislave.cpp index fea5c7ef2ac..ac9d4fe706f 100644 --- a/src/mame/machine/cdislave.cpp +++ b/src/mame/machine/cdislave.cpp @@ -484,15 +484,15 @@ void cdislave_device::device_start() void cdislave_device::device_reset() { - for(INT32 index = 0; index < 4; index++) + for(auto & elem : m_channel) { - m_channel[index].m_out_buf[0] = 0; - m_channel[index].m_out_buf[1] = 0; - m_channel[index].m_out_buf[2] = 0; - m_channel[index].m_out_buf[3] = 0; - m_channel[index].m_out_index = 0; - m_channel[index].m_out_count = 0; - m_channel[index].m_out_cmd = 0; + elem.m_out_buf[0] = 0; + elem.m_out_buf[1] = 0; + elem.m_out_buf[2] = 0; + elem.m_out_buf[3] = 0; + elem.m_out_index = 0; + elem.m_out_count = 0; + elem.m_out_cmd = 0; } memset(m_in_buf, 0, 17); diff --git a/src/mame/machine/decocass_tape.cpp b/src/mame/machine/decocass_tape.cpp index 48c9fd310ee..8b3f2785032 100644 --- a/src/mame/machine/decocass_tape.cpp +++ b/src/mame/machine/decocass_tape.cpp @@ -67,8 +67,8 @@ decocass_tape_device::decocass_tape_device(const machine_config &mconfig, const m_clockpos(0), m_numclocks(0) { - for (int i = 0; i < 256; i++) - m_crc16[i] = 0; + for (auto & elem : m_crc16) + elem = 0; } //------------------------------------------------- diff --git a/src/mame/machine/fd1094.cpp b/src/mame/machine/fd1094.cpp index 4d0992ef30e..6fb0f8b866e 100644 --- a/src/mame/machine/fd1094.cpp +++ b/src/mame/machine/fd1094.cpp @@ -500,8 +500,8 @@ fd1094_decryption_cache::fd1094_decryption_cache(fd1094_device &fd1094) void fd1094_decryption_cache::reset() { // reset all allocated cache buffers - for (int cache = 0; cache < 256; cache++) - m_decrypted_opcodes[cache].clear(); + for (auto & elem : m_decrypted_opcodes) + elem.clear(); } @@ -570,9 +570,9 @@ fd1094_device::fd1094_device(const machine_config &mconfig, const char *tag, dev // create the initial masked opcode table memset(m_masked_opcodes_lookup, 0, sizeof(m_masked_opcodes_lookup)); - for (int index = 0; index < ARRAY_LENGTH(s_masked_opcodes); index++) + for (auto opcode : s_masked_opcodes) { - UINT16 opcode = s_masked_opcodes[index]; + m_masked_opcodes_lookup[0][opcode >> 4] |= 1 << ((opcode >> 1) & 7); m_masked_opcodes_lookup[1][opcode >> 4] |= 1 << ((opcode >> 1) & 7); } diff --git a/src/mame/machine/gb.cpp b/src/mame/machine/gb.cpp index 187cea04d72..3b77d56b403 100644 --- a/src/mame/machine/gb.cpp +++ b/src/mame/machine/gb.cpp @@ -226,8 +226,8 @@ MACHINE_RESET_MEMBER(gb_state,gbc) /* Enable BIOS rom */ m_bios_disable = 0; - for (int i = 0; i < 8; i++) - memset(m_gbc_rammap[i], 0, 0x1000); + for (auto & elem : m_gbc_rammap) + memset(elem, 0, 0x1000); } MACHINE_RESET_MEMBER(gb_state,sgb) diff --git a/src/mame/machine/kc.cpp b/src/mame/machine/kc.cpp index 1f8c0d95ed2..d4374e31c45 100644 --- a/src/mame/machine/kc.cpp +++ b/src/mame/machine/kc.cpp @@ -84,8 +84,8 @@ READ8_MEMBER( kc_state::expansion_read ) // assert MEI line of first slot m_expansions[0]->mei_w(ASSERT_LINE); - for (int i=0; i<3; i++) - m_expansions[i]->read(offset, result); + for (auto & elem : m_expansions) + elem->read(offset, result); return result; } @@ -95,8 +95,8 @@ WRITE8_MEMBER( kc_state::expansion_write ) // assert MEI line of first slot m_expansions[0]->mei_w(ASSERT_LINE); - for (int i=0; i<3; i++) - m_expansions[i]->write(offset, data); + for (auto & elem : m_expansions) + elem->write(offset, data); } /* @@ -129,8 +129,8 @@ READ8_MEMBER( kc_state::expansion_io_read ) } else { - for (int i=0; i<3; i++) - m_expansions[i]->io_read(offset, result); + for (auto & elem : m_expansions) + elem->io_read(offset, result); } return result; @@ -152,8 +152,8 @@ WRITE8_MEMBER( kc_state::expansion_io_write ) } else { - for (int i=0; i<3; i++) - m_expansions[i]->io_write(offset, data); + for (auto & elem : m_expansions) + elem->io_write(offset, data); } } diff --git a/src/mame/machine/megacdcd.cpp b/src/mame/machine/megacdcd.cpp index 54c7d3c81a2..0fd65a3d2c0 100644 --- a/src/mame/machine/megacdcd.cpp +++ b/src/mame/machine/megacdcd.cpp @@ -23,10 +23,10 @@ lc89510_temp_device::lc89510_temp_device(const machine_config &mconfig, const ch is_neoCD = false; nff0002 = 0; - for (int i=0;i<10;i++) - CDD_TX[i] = 0; - for (int i=0;i<10;i++) - CDD_RX[i] = 0; + for (auto & elem : CDD_TX) + elem = 0; + for (auto & elem : CDD_RX) + elem = 0; NeoCDCommsWordCount = 0; NeoCD_StatusHack = 0; SCD_CURLBA = 0; diff --git a/src/mame/machine/micropolis.cpp b/src/mame/machine/micropolis.cpp index 9cf03159e18..a42c692718c 100644 --- a/src/mame/machine/micropolis.cpp +++ b/src/mame/machine/micropolis.cpp @@ -82,11 +82,11 @@ micropolis_device::micropolis_device(const machine_config &mconfig, const char * m_sector_length(0), m_drive(nullptr) { - for (int i = 0; i < 6144; i++) - m_buffer[i] = 0; + for (auto & elem : m_buffer) + elem = 0; - for (int i = 0; i < 4; i++) - m_floppy_drive_tags[i] = nullptr; + for (auto & elem : m_floppy_drive_tags) + elem = nullptr; } //------------------------------------------------- @@ -118,11 +118,11 @@ void micropolis_device::device_start() void micropolis_device::device_reset() { - for (int i = 0; i < 4; i++) + for (auto & elem : m_floppy_drive_tags) { - if (m_floppy_drive_tags[i]) + if (elem) { - legacy_floppy_image_device *img = siblingdevice(m_floppy_drive_tags[i]); + legacy_floppy_image_device *img = siblingdevice(elem); if (img) { diff --git a/src/mame/machine/model3.cpp b/src/mame/machine/model3.cpp index 12826528efe..1cfb25e48f8 100644 --- a/src/mame/machine/model3.cpp +++ b/src/mame/machine/model3.cpp @@ -154,9 +154,9 @@ void model3_state::tap_write(int tck, int tms, int tdi, int trst) if (m_ir == U64(0x000023fffffffffe)) { - for (int i=0; i < 32; i++) + for (auto & elem : m_id_data) { - m_id_data[i] = 0; + elem = 0; } m_id_size = 41; @@ -237,9 +237,9 @@ void model3_state::tap_set_asic_ids() * data on TAP reset and when the instruction is issued. */ - for (int i=0; i < 32; i++) + for (auto & elem : m_id_data) { - m_id_data[i] = 0; + elem = 0; } if (m_m3_step == 0x10) diff --git a/src/mame/machine/msx.cpp b/src/mame/machine/msx.cpp index 11402a50c40..b881ad38d4d 100644 --- a/src/mame/machine/msx.cpp +++ b/src/mame/machine/msx.cpp @@ -31,9 +31,9 @@ void msx_state::check_irq() { int state = CLEAR_LINE; - for (int i = 0; i < ARRAY_LENGTH(m_irq_state); i++) + for (auto & elem : m_irq_state) { - if (m_irq_state[i] != CLEAR_LINE) + if (elem != CLEAR_LINE) { state = ASSERT_LINE; } @@ -47,9 +47,9 @@ void msx_state::machine_reset() { msx_memory_reset (); msx_memory_map_all (); - for (int i = 0; i < ARRAY_LENGTH(m_irq_state); i++) + for (auto & elem : m_irq_state) { - m_irq_state[i] = CLEAR_LINE; + elem = CLEAR_LINE; } check_irq(); } @@ -401,15 +401,15 @@ void msx_state::msx_memory_init() int count_populated_pages = 0; // Populate all unpopulated slots with the dummy interface - for ( int prim = 0; prim < 4; prim++ ) + for (auto & elem : m_all_slots) { for ( int sec = 0; sec < 4; sec++ ) { for ( int page = 0; page < 4; page++ ) { - if ( m_all_slots[prim][sec][page] == nullptr ) + if ( elem[sec][page] == nullptr ) { - m_all_slots[prim][sec][page] = &m_empty_slot; + elem[sec][page] = &m_empty_slot; } else { @@ -428,9 +428,9 @@ void msx_state::msx_memory_reset () { m_primary_slot = 0; - for (int prim=0; prim<4; prim++) + for (auto & elem : m_secondary_slot) { - m_secondary_slot[prim] = 0; + elem = 0; } } diff --git a/src/mame/machine/namcoio.cpp b/src/mame/machine/namcoio.cpp index b8fb22fef40..4ac534279ce 100644 --- a/src/mame/machine/namcoio.cpp +++ b/src/mame/machine/namcoio.cpp @@ -181,8 +181,8 @@ void namcoio_device::device_start() void namcoio_device::device_reset() { - for (int i = 0; i < 16; i++) - m_ram[i] = 0; + for (auto & elem : m_ram) + elem = 0; set_reset_line(PULSE_LINE); } diff --git a/src/mame/machine/naomim1.cpp b/src/mame/machine/naomim1.cpp index 5b16f278fb7..c9e5bc1c359 100644 --- a/src/mame/machine/naomim1.cpp +++ b/src/mame/machine/naomim1.cpp @@ -159,8 +159,8 @@ void naomi_m1_board::enc_reset() has_history = false; buffer_actual_size = 0; - for(int i=0; i<111; i++) - dict[i] = getb(8); + for(auto & elem : dict) + elem = getb(8); } void naomi_m1_board::wb(UINT8 byte) diff --git a/src/mame/machine/pce.cpp b/src/mame/machine/pce.cpp index 6aeba853933..ad5d712367c 100644 --- a/src/mame/machine/pce.cpp +++ b/src/mame/machine/pce.cpp @@ -110,8 +110,8 @@ MACHINE_START_MEMBER(pce_state,pce) MACHINE_RESET_MEMBER(pce_state,mess_pce) { - for (int joy_i = 0; joy_i < 5; joy_i++) - m_joy_6b_packet[joy_i] = 0; + for (auto & elem : m_joy_6b_packet) + elem = 0; /* Note: Arcade Card BIOS contents are the same as System 3, only internal HW differs. We use a category to select between modes (some games can be run in either S-CD or A-CD modes) */ diff --git a/src/mame/machine/pgmprot_igs027a_type1.cpp b/src/mame/machine/pgmprot_igs027a_type1.cpp index 096d1135c2b..84b7bfc5de6 100644 --- a/src/mame/machine/pgmprot_igs027a_type1.cpp +++ b/src/mame/machine/pgmprot_igs027a_type1.cpp @@ -881,9 +881,9 @@ void pgm_arm_type1_state::command_handler_puzzli2(int pc) m_valueresponse = 0x36<<16; // clear the return structure - for (int columns=0;columns<8;columns++) + for (auto & elem : level_structure) for (int rows=0;rows<10;rows++) - level_structure[columns][rows] = 0x0000; + elem[rows] = 0x0000; break; diff --git a/src/mame/machine/pgmprot_igs027a_type3.cpp b/src/mame/machine/pgmprot_igs027a_type3.cpp index 8faa5fc4432..24fc0c19ccd 100644 --- a/src/mame/machine/pgmprot_igs027a_type3.cpp +++ b/src/mame/machine/pgmprot_igs027a_type3.cpp @@ -566,10 +566,10 @@ void pgm_arm_type3_state::pgm_patch_external_arm_rom_jumptable_theglada(int base */ - for (int i = 0; i < 131; i++) + for (auto & subroutine_addresse : subroutine_addresses) { // UINT32 addr = extprot[(base/2)] | (extprot[(base/2) + 1] << 16); - extprot[(base / 2)] = subroutine_addresses[i]; + extprot[(base / 2)] = subroutine_addresse; base += 4; // printf("%04x (%08x)\n", subroutine_addresses[i], addr ); diff --git a/src/mame/machine/rx01.cpp b/src/mame/machine/rx01.cpp index c1889eb6a8b..b4cb85869ea 100644 --- a/src/mame/machine/rx01.cpp +++ b/src/mame/machine/rx01.cpp @@ -80,11 +80,11 @@ void rx01_device::device_start() void rx01_device::device_reset() { - for(int i=0;i<2;i++) + for(auto & elem : m_image) { - m_image[i]->floppy_mon_w(0); // turn it on - m_image[i]->floppy_drive_set_controller(this); - m_image[i]->floppy_drive_set_rpm(360.); + elem->floppy_mon_w(0); // turn it on + elem->floppy_drive_set_controller(this); + elem->floppy_drive_set_rpm(360.); } m_rxes = 0; m_rxcs = 0; diff --git a/src/mame/machine/segaic16.cpp b/src/mame/machine/segaic16.cpp index ee171e9af70..3d807412a56 100644 --- a/src/mame/machine/segaic16.cpp +++ b/src/mame/machine/segaic16.cpp @@ -487,8 +487,8 @@ void sega_315_5195_mapper_device::configure_explicit(const UINT8 *map_data) void sega_315_5195_mapper_device::fd1094_state_change(UINT8 state) { // iterate over regions and set the decrypted address of any ROM banks - for (int index = 0; index < ARRAY_LENGTH(m_banks); index++) - m_banks[index].update(); + for (auto & elem : m_banks) + elem.update(); } @@ -511,16 +511,16 @@ void sega_315_5195_mapper_device::device_start() // if we are mapping an FD1089, tell all the banks fd1089_base_device *fd1089 = dynamic_cast(m_cpu); if (fd1089 != nullptr) - for (int banknum = 0; banknum < ARRAY_LENGTH(m_banks); banknum++) - m_banks[banknum].set_decrypt(fd1089); + for (auto & elem : m_banks) + elem.set_decrypt(fd1089); // if we are mapping an FD1094, register for state change notifications and tell all the banks fd1094_device *fd1094 = dynamic_cast(m_cpu); if (fd1094 != nullptr) { fd1094->notify_state_change(fd1094_device::state_change_delegate(FUNC(sega_315_5195_mapper_device::fd1094_state_change), this)); - for (int banknum = 0; banknum < ARRAY_LENGTH(m_banks); banknum++) - m_banks[banknum].set_decrypt(fd1094); + for (auto & elem : m_banks) + elem.set_decrypt(fd1094); } // find the address space that is to be mapped diff --git a/src/mame/machine/snes.cpp b/src/mame/machine/snes.cpp index 30b125f94fa..9c4253906e2 100644 --- a/src/mame/machine/snes.cpp +++ b/src/mame/machine/snes.cpp @@ -1123,17 +1123,17 @@ void snes_state::machine_reset() snes_init_ram(); /* init DMA regs to be 0xff */ - for (int i = 0; i < 8; i++) + for (auto & elem : m_dma_channel) { - m_dma_channel[i].dmap = 0xff; - m_dma_channel[i].dest_addr = 0xff; - m_dma_channel[i].src_addr = 0xffff; - m_dma_channel[i].bank = 0xff; - m_dma_channel[i].trans_size = 0xffff; - m_dma_channel[i].ibank = 0xff; - m_dma_channel[i].hdma_addr = 0xffff; - m_dma_channel[i].hdma_line_counter = 0xff; - m_dma_channel[i].unk = 0xff; + elem.dmap = 0xff; + elem.dest_addr = 0xff; + elem.src_addr = 0xffff; + elem.bank = 0xff; + elem.trans_size = 0xffff; + elem.ibank = 0xff; + elem.hdma_addr = 0xffff; + elem.hdma_line_counter = 0xff; + elem.unk = 0xff; } /* Set STAT78 to NTSC or PAL */ diff --git a/src/mame/machine/st0016.cpp b/src/mame/machine/st0016.cpp index 3abdc4eafaf..08959876e99 100644 --- a/src/mame/machine/st0016.cpp +++ b/src/mame/machine/st0016.cpp @@ -49,8 +49,8 @@ st0016_cpu_device::st0016_cpu_device(const machine_config &mconfig, const char * m_palette(*this, "palette") { - for (int i = 0; i < 0xc0; i++) - st0016_vregs[i] = 0; + for (auto & elem : st0016_vregs) + elem = 0; } diff --git a/src/mame/machine/tait8741.cpp b/src/mame/machine/tait8741.cpp index 58df20ca4ed..5e568fbd6f1 100644 --- a/src/mame/machine/tait8741.cpp +++ b/src/mame/machine/tait8741.cpp @@ -381,15 +381,15 @@ void josvolly8741_4pack_device::device_reset() { m_nmi_enable = 0; - for(int i=0;i<4;i++) + for(auto & elem : m_i8741) { - m_i8741[i].cmd = 0; - m_i8741[i].sts = 0; // 0xf0; /* init flag */ - m_i8741[i].txd = 0; - m_i8741[i].outport = 0xff; - m_i8741[i].rxd = 0; + elem.cmd = 0; + elem.sts = 0; // 0xf0; /* init flag */ + elem.txd = 0; + elem.outport = 0xff; + elem.rxd = 0; - m_i8741[i].rst = 1; + elem.rst = 1; } } diff --git a/src/mame/machine/taitoio.cpp b/src/mame/machine/taitoio.cpp index 4b15fa06932..6d2bcadd9b0 100644 --- a/src/mame/machine/taitoio.cpp +++ b/src/mame/machine/taitoio.cpp @@ -90,8 +90,8 @@ void tc0220ioc_device::device_reset() { m_port = 0; - for (int i = 0; i < 8; i++) - m_regs[i] = 0; + for (auto & elem : m_regs) + elem = 0; } /***************************************************************************** @@ -213,8 +213,8 @@ void tc0510nio_device::device_start() void tc0510nio_device::device_reset() { - for (int i = 0; i < 8; i++) - m_regs[i] = 0; + for (auto & elem : m_regs) + elem = 0; } /***************************************************************************** @@ -340,8 +340,8 @@ void tc0640fio_device::device_start() void tc0640fio_device::device_reset() { - for (int i = 0; i < 8; i++) - m_regs[i] = 0; + for (auto & elem : m_regs) + elem = 0; } diff --git a/src/mame/machine/vectrex.cpp b/src/mame/machine/vectrex.cpp index ca64a1cd23c..4959c3de5f1 100644 --- a/src/mame/machine/vectrex.cpp +++ b/src/mame/machine/vectrex.cpp @@ -306,8 +306,8 @@ DRIVER_INIT_MEMBER(vectrex_state,vectrex) { m_imager_angles = unknown_game_angles; m_beam_color = rgb_t::white; - for (int i = 0; i < ARRAY_LENGTH(m_imager_colors); i++) - m_imager_colors[i] = rgb_t::white; + for (auto & elem : m_imager_colors) + elem = rgb_t::white; /* * Minestorm's PRNG doesn't work with a 0 seed (mines in the first diff --git a/src/mame/video/abc806.cpp b/src/mame/video/abc806.cpp index f958b025b1c..4e8ff8ba854 100644 --- a/src/mame/video/abc806.cpp +++ b/src/mame/video/abc806.cpp @@ -413,9 +413,9 @@ void abc806_state::hr_update(bitmap_rgb32 &bitmap, const rectangle &cliprect) void abc806_state::video_start() { // initialize variables - for (int i = 0; i < 16; i++) + for (auto & elem : m_hrc) { - m_hrc[i] = 0; + elem = 0; } m_sync = 10; diff --git a/src/mame/video/antic.cpp b/src/mame/video/antic.cpp index 1a8979abf6a..b01b7ba259e 100644 --- a/src/mame/video/antic.cpp +++ b/src/mame/video/antic.cpp @@ -96,8 +96,8 @@ void antic_device::device_start() LOG(("atari cclk_init\n")); cclk_init(); - for (int i = 0; i < 64; i++) - m_prio_table[i] = auto_alloc_array_clear(machine(), UINT8, 8*256); + for (auto & elem : m_prio_table) + elem = auto_alloc_array_clear(machine(), UINT8, 8*256); LOG(("atari prio_init\n")); prio_init(); diff --git a/src/mame/video/bfm_dm01.cpp b/src/mame/video/bfm_dm01.cpp index 4c9f8e31825..19911ee5654 100644 --- a/src/mame/video/bfm_dm01.cpp +++ b/src/mame/video/bfm_dm01.cpp @@ -62,11 +62,11 @@ bfmdm01_device::bfmdm01_device(const machine_config &mconfig, const char *tag, d m_comdata(0), m_busy_cb(*this) { - for (int i = 0; i < 65; i++) - m_segbuffer[i] = 0; + for (auto & elem : m_segbuffer) + elem = 0; - for (int i = 0; i < DM_BYTESPERROW; i++) - m_scanline[i] = 0; + for (auto & elem : m_scanline) + elem = 0; } //------------------------------------------------- diff --git a/src/mame/video/chihiro.cpp b/src/mame/video/chihiro.cpp index 5aa59cf0493..8e59ed253a9 100644 --- a/src/mame/video/chihiro.cpp +++ b/src/mame/video/chihiro.cpp @@ -433,8 +433,8 @@ int vertex_program_disassembler::disassemble(unsigned int *instruction, char *li vertex_program_simulator::vertex_program_simulator() { - for (int i = 0; i < 256; i++) - op[i].modified = 0; + for (auto & elem : op) + elem.modified = 0; initialize_constants(); } @@ -674,17 +674,17 @@ void vertex_program_simulator::initialize_outputs() void vertex_program_simulator::initialize_temps() { - for (int n = 0; n < 32; n++) { + for (auto & elem : r_temp) { for (int m = 0; m < 4; m++) - r_temp[n].fv[m] = 0; + elem.fv[m] = 0; } } void vertex_program_simulator::initialize_constants() { - for (int n = 0; n < 192; n++) { + for (auto & elem : c_constant) { for (int m = 0; m < 4;m++) - c_constant[n].fv[m] = 0; + elem.fv[m] = 0; } } diff --git a/src/mame/video/gauntlet.cpp b/src/mame/video/gauntlet.cpp index 0d7120a627b..c9430f4f0ef 100644 --- a/src/mame/video/gauntlet.cpp +++ b/src/mame/video/gauntlet.cpp @@ -83,8 +83,8 @@ VIDEO_START_MEMBER(gauntlet_state,gauntlet) { /* modify the motion object code lookup table to account for the code XOR */ std::vector &codelookup = m_mob->code_lookup(); - for (unsigned int i = 0; i < codelookup.size(); i++) - codelookup[i] ^= 0x800; + for (auto & elem : codelookup) + elem ^= 0x800; /* set up the base color for the playfield */ m_playfield_color_bank = m_vindctr2_screen_refresh ? 0 : 1; diff --git a/src/mame/video/hng64.cpp b/src/mame/video/hng64.cpp index 01a5709085c..ac7084687b6 100644 --- a/src/mame/video/hng64.cpp +++ b/src/mame/video/hng64.cpp @@ -1274,11 +1274,11 @@ void hng64_state::video_start() m_tilemap[3].m_tilemap_16x16 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_16x16_info),this), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); /* 128x128x4 = 0x10000 */ m_tilemap[3].m_tilemap_16x16_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hng64_state::get_hng64_tile3_16x16_info),this), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); /* 128x128x4 = 0x10000 */ - for (int i = 0; i < 4; i++) + for (auto & elem : m_tilemap) { - m_tilemap[i].m_tilemap_8x8->set_transparent_pen(0); - m_tilemap[i].m_tilemap_16x16->set_transparent_pen(0); - m_tilemap[i].m_tilemap_16x16_alt->set_transparent_pen(0); + elem.m_tilemap_8x8->set_transparent_pen(0); + elem.m_tilemap_16x16->set_transparent_pen(0); + elem.m_tilemap_16x16_alt->set_transparent_pen(0); } // Debug switch, turn on / off additive blending on a per-tilemap basis diff --git a/src/mame/video/k053244_k053245.cpp b/src/mame/video/k053244_k053245.cpp index 23227fede07..8596af1ce54 100644 --- a/src/mame/video/k053244_k053245.cpp +++ b/src/mame/video/k053244_k053245.cpp @@ -152,8 +152,8 @@ void k05324x_device::device_reset() { m_rombank = 0; - for (int i = 0; i < 0x10; i++) - m_regs[i] = 0; + for (auto & elem : m_regs) + elem = 0; } /***************************************************************************** diff --git a/src/mame/video/k053246_k053247_k055673.cpp b/src/mame/video/k053246_k053247_k055673.cpp index 27636d19001..b97fc461e63 100644 --- a/src/mame/video/k053246_k053247_k055673.cpp +++ b/src/mame/video/k053246_k053247_k055673.cpp @@ -52,11 +52,11 @@ void k053247_device::clear_all() m_ram = nullptr; m_gfx = nullptr; - for (int i=0;i<8;i++) - m_kx46_regs[i] = 0; + for (auto & elem : m_kx46_regs) + elem = 0; - for (int i=0;i<16;i++) - m_kx47_regs[i] = 0; + for (auto & elem : m_kx47_regs) + elem = 0; m_objcha_line = 0; m_z_rejection = 0; diff --git a/src/mame/video/k057714.cpp b/src/mame/video/k057714.cpp index 2ab8685cf56..405f0e722c2 100644 --- a/src/mame/video/k057714.cpp +++ b/src/mame/video/k057714.cpp @@ -35,11 +35,11 @@ void k057714_device::device_reset() m_vram_fifo0_addr = 0; m_vram_fifo1_addr = 0; - for (int i=0; i < 4; i++) + for (auto & elem : m_frame) { - m_frame[i].base = 0; - m_frame[i].width = 0; - m_frame[i].height = 0; + elem.base = 0; + elem.width = 0; + elem.height = 0; } } diff --git a/src/mame/video/kaneko16.cpp b/src/mame/video/kaneko16.cpp index 18d1e602511..47dc6e209d9 100644 --- a/src/mame/video/kaneko16.cpp +++ b/src/mame/video/kaneko16.cpp @@ -116,8 +116,8 @@ VIDEO_START_MEMBER(kaneko16_berlwall_state,berlwall) /* Render the hi-color static backgrounds held in the ROMs */ - for (int screen = 0; screen < 32; screen++) - m_bg15_bitmap[screen].allocate(256, 256); + for (auto & elem : m_bg15_bitmap) + elem.allocate(256, 256); /* 8aba is used as background color diff --git a/src/mame/video/maria.cpp b/src/mame/video/maria.cpp index b2514770e82..a5501989e4b 100644 --- a/src/mame/video/maria.cpp +++ b/src/mame/video/maria.cpp @@ -93,12 +93,12 @@ void atari_maria_device::device_start() void atari_maria_device::device_reset() { - for (int i = 0; i < 32; i++) - m_maria_palette[i] = 0; + for (auto & elem : m_maria_palette) + elem = 0; - for (int i = 0; i < 2; i++) + for (auto & elem : m_line_ram) for (int j = 0; j < 160; j++) - m_line_ram[i][j] = 0; + elem[j] = 0; m_active_buffer = 0; diff --git a/src/mame/video/mcd212.cpp b/src/mame/video/mcd212.cpp index 5476e0a5030..aec55056c8f 100644 --- a/src/mame/video/mcd212.cpp +++ b/src/mame/video/mcd212.cpp @@ -1470,37 +1470,37 @@ TIMER_CALLBACK_MEMBER( mcd212_device::perform_scan ) void mcd212_device::device_reset() { - for(int index = 0; index < 2; index++) + for(auto & elem : m_channel) { - m_channel[index].csrr = 0; - m_channel[index].csrw = 0; - m_channel[index].dcr = 0; - m_channel[index].vsr = 0; - m_channel[index].ddr = 0; - m_channel[index].dcp = 0; - m_channel[index].dca = 0; - memset(m_channel[index].clut_r, 0, 256); - memset(m_channel[index].clut_g, 0, 256); - memset(m_channel[index].clut_b, 0, 256); - m_channel[index].image_coding_method = 0; - m_channel[index].transparency_control = 0; - m_channel[index].plane_order = 0; - m_channel[index].clut_bank = 0; - m_channel[index].transparent_color_a = 0; - m_channel[index].transparent_color_b = 0; - m_channel[index].mask_color_a = 0; - m_channel[index].mask_color_b = 0; - m_channel[index].dyuv_abs_start_a = 0; - m_channel[index].dyuv_abs_start_b = 0; - m_channel[index].cursor_position = 0; - m_channel[index].cursor_control = 0; - memset((UINT8*)&m_channel[index].cursor_pattern, 0, 16 * sizeof(UINT32)); - memset((UINT8*)&m_channel[index].region_control, 0, 8 * sizeof(UINT32)); - m_channel[index].backdrop_color = 0; - m_channel[index].mosaic_hold_a = 0; - m_channel[index].mosaic_hold_b = 0; - memset(m_channel[index].weight_factor_a, 0, 768); - memset(m_channel[index].weight_factor_b, 0, 768); + elem.csrr = 0; + elem.csrw = 0; + elem.dcr = 0; + elem.vsr = 0; + elem.ddr = 0; + elem.dcp = 0; + elem.dca = 0; + memset(elem.clut_r, 0, 256); + memset(elem.clut_g, 0, 256); + memset(elem.clut_b, 0, 256); + elem.image_coding_method = 0; + elem.transparency_control = 0; + elem.plane_order = 0; + elem.clut_bank = 0; + elem.transparent_color_a = 0; + elem.transparent_color_b = 0; + elem.mask_color_a = 0; + elem.mask_color_b = 0; + elem.dyuv_abs_start_a = 0; + elem.dyuv_abs_start_b = 0; + elem.cursor_position = 0; + elem.cursor_control = 0; + memset((UINT8*)&elem.cursor_pattern, 0, 16 * sizeof(UINT32)); + memset((UINT8*)&elem.region_control, 0, 8 * sizeof(UINT32)); + elem.backdrop_color = 0; + elem.mosaic_hold_a = 0; + elem.mosaic_hold_b = 0; + memset(elem.weight_factor_a, 0, 768); + memset(elem.weight_factor_b, 0, 768); } memset(m_region_flag_0, 0, 768); memset(m_region_flag_1, 0, 768); diff --git a/src/mame/video/nemesis.cpp b/src/mame/video/nemesis.cpp index f5b15c30794..191f5e20d59 100644 --- a/src/mame/video/nemesis.cpp +++ b/src/mame/video/nemesis.cpp @@ -188,8 +188,8 @@ void nemesis_state::create_palette_lookups() // normalize black/white levels double black = m_palette_lookup[0]; double white = 255.0 / (m_palette_lookup[31] - black); - for (int i = 0; i < 32; i++) - m_palette_lookup[i] = (m_palette_lookup[i] - black) * white + 0.5; + for (auto & elem : m_palette_lookup) + elem = (elem - black) * white + 0.5; } diff --git a/src/mame/video/pc080sn.cpp b/src/mame/video/pc080sn.cpp index 449cd97351a..55c67ed2bfa 100644 --- a/src/mame/video/pc080sn.cpp +++ b/src/mame/video/pc080sn.cpp @@ -61,8 +61,8 @@ pc080sn_device::pc080sn_device(const machine_config &mconfig, const char *tag, d m_gfxdecode(*this), m_palette(*this) { - for (int i = 0; i < 8; i++) - m_ctrl[i] = 0; + for (auto & elem : m_ctrl) + elem = 0; for (int i = 0; i < 2; i++) { diff --git a/src/mame/video/powervr2.cpp b/src/mame/video/powervr2.cpp index bea1e3fca36..a0db91d6b62 100644 --- a/src/mame/video/powervr2.cpp +++ b/src/mame/video/powervr2.cpp @@ -921,9 +921,9 @@ WRITE32_MEMBER( powervr2_device::softreset_w ) logerror("%s: Core Pipeline soft reset\n", tag()); #endif if (start_render_received == 1) { - for (int a=0;a < NUM_BUFFERS;a++) - if (grab[a].busy == 1) - grab[a].busy = 0; + for (auto & elem : grab) + if (elem.busy == 1) + elem.busy = 0; start_render_received = 0; } } diff --git a/src/mame/video/ppu2c0x.cpp b/src/mame/video/ppu2c0x.cpp index 17f17178d75..d6511dbb245 100644 --- a/src/mame/video/ppu2c0x.cpp +++ b/src/mame/video/ppu2c0x.cpp @@ -144,8 +144,8 @@ ppu2c0x_device::ppu2c0x_device(const machine_config &mconfig, device_type type, m_draw_phase(0), m_use_sprite_write_limitation(true) { - for (int i = 0; i < PPU_MAX_REG; i++) - m_regs[i] = 0; + for (auto & elem : m_regs) + elem = 0; memset(m_palette_ram, 0, ARRAY_LENGTH(m_palette_ram)); diff --git a/src/mame/video/psikyosh.cpp b/src/mame/video/psikyosh.cpp index 0eb703853cd..24b51d9e375 100644 --- a/src/mame/video/psikyosh.cpp +++ b/src/mame/video/psikyosh.cpp @@ -260,7 +260,7 @@ void psikyosh_state::draw_bglayerscroll( int layer, bitmap_rgb32 &bitmap, const /* cache rendered bitmap */ int last_bank[32]; // corresponds to bank of bitmap in m_bg_bitmap. bg_bitmap is split into 16/32-rows of one-tile high each - for(int ii = 0; ii < 32; ii++) last_bank[ii] = -1; + for(auto & elem : last_bank) elem = -1; int scr_width = cliprect.width(); int scr_height = cliprect.height(); diff --git a/src/mame/video/rdptpipe.h b/src/mame/video/rdptpipe.h index e47f6f17130..201b15d63c1 100644 --- a/src/mame/video/rdptpipe.h +++ b/src/mame/video/rdptpipe.h @@ -34,9 +34,9 @@ class n64_texture_pipe_t } m_start_span = false; - for (int idx = 0; idx < 80; idx++) + for (auto & elem : m_texel_fetch) { - m_texel_fetch[idx] = &n64_texture_pipe_t::fetch_nop; + elem = &n64_texture_pipe_t::fetch_nop; } m_texel_fetch[ 8] = &n64_texture_pipe_t::fetch_rgba16_raw; diff --git a/src/mame/video/stic.cpp b/src/mame/video/stic.cpp index b5b8dbfb6a4..350544e8f90 100644 --- a/src/mame/video/stic.cpp +++ b/src/mame/video/stic.cpp @@ -760,8 +760,8 @@ void stic_device::screenrefresh() render_background(m_bitmap); // Render the sprites into their buffers render_sprites(); - for (int i = 0; i < STIC_MOBS; i++) - m_sprite[i].collision = 0; + for (auto & elem : m_sprite) + elem.collision = 0; // Copy the sprites to the background copy_sprites_to_background(m_bitmap); determine_sprite_collisions(); diff --git a/src/mame/video/tc0100scn.cpp b/src/mame/video/tc0100scn.cpp index 3ecbc3623d8..e63bd9b0c25 100644 --- a/src/mame/video/tc0100scn.cpp +++ b/src/mame/video/tc0100scn.cpp @@ -318,8 +318,8 @@ void tc0100scn_device::device_reset() m_dblwidth = 0; m_gfxbank = 0; /* Mjnquest uniquely banks tiles */ - for (int i = 0; i < 8; i++) - m_ctrl[i] = 0; + for (auto & elem : m_ctrl) + elem = 0; } diff --git a/src/mame/video/tc0360pri.cpp b/src/mame/video/tc0360pri.cpp index 43bf42ee1ef..e3620cb74ac 100644 --- a/src/mame/video/tc0360pri.cpp +++ b/src/mame/video/tc0360pri.cpp @@ -65,8 +65,8 @@ void tc0360pri_device::device_start() void tc0360pri_device::device_reset() { - for (int i = 0; i < 16; i++) - m_regs[i] = 0; + for (auto & elem : m_regs) + elem = 0; } diff --git a/src/mame/video/tc0480scp.cpp b/src/mame/video/tc0480scp.cpp index d50a77c6ace..df66f8afb3b 100644 --- a/src/mame/video/tc0480scp.cpp +++ b/src/mame/video/tc0480scp.cpp @@ -317,8 +317,8 @@ void tc0480scp_device::device_reset() { m_dblwidth = 0; - for (int i = 0; i < 0x18; i++) - m_ctrl[i] = 0; + for (auto & elem : m_ctrl) + elem = 0; } diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp index 691fc71b47b..91e40c51b5b 100644 --- a/src/tools/chdman.cpp +++ b/src/tools/chdman.cpp @@ -772,9 +772,9 @@ static int print_help(const char *argv0, const char *error = nullptr) // print a summary of each command printf("Usage:\n"); - for (int cmdnum = 0; cmdnum < ARRAY_LENGTH(s_commands); cmdnum++) + for (auto & desc : s_commands) { - const command_description &desc = s_commands[cmdnum]; + printf(" %s %s%s\n", argv0, desc.name, desc.description); } printf("\nFor help with any command, run:\n"); @@ -808,10 +808,10 @@ static int print_help(const char *argv0, const command_description &desc, const option++; // find the option - for (int optnum = 0; optnum < ARRAY_LENGTH(s_options); optnum++) - if (strcmp(option, s_options[optnum].name) == 0) + for (auto & s_option : s_options) + if (strcmp(option, s_option.name) == 0) { - const option_description &odesc = s_options[optnum]; + const option_description &odesc = s_option; printf(" --%s", odesc.name); if (odesc.shortname != nullptr) printf(", -%s", odesc.shortname); @@ -1391,10 +1391,10 @@ static void do_info(parameters_t ¶ms) // determine our index UINT32 metaindex = ~0; - for (unsigned int cur = 0; cur < info.size(); cur++) - if (info[cur].tag == metatag) + for (auto & elem : info) + if (elem.tag == metatag) { - metaindex = ++info[cur].index; + metaindex = ++elem.index; break; } @@ -2858,10 +2858,10 @@ int CLIB_DECL main(int argc, char *argv[]) } // iterate over commands to find our match - for (int cmdnum = 0; cmdnum < ARRAY_LENGTH(s_commands); cmdnum++) - if (strcmp(command, s_commands[cmdnum].name) == 0) + for (auto & s_command : s_commands) + if (strcmp(command, s_command.name) == 0) { - const command_description &desc = s_commands[cmdnum]; + const command_description &desc = s_command; // print help if that was requested if (help) @@ -2933,7 +2933,7 @@ int CLIB_DECL main(int argc, char *argv[]) // all clear, run the command try { - (*s_commands[cmdnum].handler)(parameters); + (*s_command.handler)(parameters); return 0; } catch (chd_error &err) diff --git a/src/tools/src2html.cpp b/src/tools/src2html.cpp index 62eefb4da56..e5d2f8f496c 100644 --- a/src/tools/src2html.cpp +++ b/src/tools/src2html.cpp @@ -410,10 +410,10 @@ static int recurse_dir(int srcrootlen, int dstrootlen, std::string &srcdir, std: { // make sure we care, first file_type type = FILE_TYPE_INVALID; - for (int extnum = 0; extnum < ARRAY_LENGTH(extension_lookup); extnum++) - if (core_filename_ends_with(curlist->name.c_str(), extension_lookup[extnum].extension)) + for (auto & elem : extension_lookup) + if (core_filename_ends_with(curlist->name.c_str(), elem.extension)) { - type = extension_lookup[extnum].type; + type = elem.type; break; } -- cgit v1.2.3