summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2021-02-14 11:05:57 -0500
committer AJR <ajrhacker@users.noreply.github.com>2021-02-14 11:05:57 -0500
commitbc0146c2038c46f789a246d5616afd7c425157f3 (patch)
treeb4d39194034b4c6e56ccd4035d25636034be43ca /src/emu
parent91310bcdeb7ab0ff661738b212017bf836f4e8ad (diff)
Eliminate ARRAY_LENGTH template in favor of C++17's std::size
* osdcomm.h: Move definition of EQUIVALENT_ARRAY to coretmpl.h * sharc.cpp, gt64xxx.cpp, ym2413.cpp, gb_lcd.cpp, snes_ppu.cpp: Use STRUCT_MEMBER for save state registration * gio/newport.cpp, megadrive/svp.cpp, nes_ctrl/bcbattle.cpp, arm7.cpp, tms9995.cpp, pckeybrd.cpp, sa1110.cpp, sa1111.cpp, jangou_blitter.cpp, vic4567.cpp: Use std::fill(_n) instead of memset * emucore.h: Remove obsolete typedef
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/bookkeeping.cpp10
-rw-r--r--src/emu/crsshair.cpp2
-rw-r--r--src/emu/debug/debugcmd.cpp2
-rw-r--r--src/emu/debug/debugcpu.cpp2
-rw-r--r--src/emu/debug/debughlp.cpp4
-rw-r--r--src/emu/debug/dvbpoints.cpp4
-rw-r--r--src/emu/debug/dvwpoints.cpp4
-rw-r--r--src/emu/diexec.cpp6
-rw-r--r--src/emu/diimage.cpp18
-rw-r--r--src/emu/dipalette.cpp2
-rw-r--r--src/emu/diserial.h8
-rw-r--r--src/emu/distate.cpp4
-rw-r--r--src/emu/emucore.h3
-rw-r--r--src/emu/fileio.cpp4
-rw-r--r--src/emu/input.cpp6
-rw-r--r--src/emu/ioport.cpp17
-rw-r--r--src/emu/natkeyboard.cpp6
-rw-r--r--src/emu/profiler.h2
-rw-r--r--src/emu/render.cpp10
-rw-r--r--src/emu/rendfont.cpp6
-rw-r--r--src/emu/softlist_dev.cpp2
-rw-r--r--src/emu/sound.cpp8
-rw-r--r--src/emu/uiinput.cpp6
-rw-r--r--src/emu/validity.cpp2
24 files changed, 65 insertions, 73 deletions
diff --git a/src/emu/bookkeeping.cpp b/src/emu/bookkeeping.cpp
index 439dfe74f6b..a26cf771c7e 100644
--- a/src/emu/bookkeeping.cpp
+++ b/src/emu/bookkeeping.cpp
@@ -157,7 +157,7 @@ void bookkeeping_manager::config_save(config_type cfg_type, util::xml::data_node
void bookkeeping_manager::coin_counter_w(int num, int on)
{
- if (num >= ARRAY_LENGTH(m_coin_count))
+ if (num >= std::size(m_coin_count))
return;
/* Count it only if the data has changed from 0 to non-zero */
@@ -174,7 +174,7 @@ void bookkeeping_manager::coin_counter_w(int num, int on)
int bookkeeping_manager::coin_counter_get_count(int num)
{
- if (num >= ARRAY_LENGTH(m_coin_count))
+ if (num >= std::size(m_coin_count))
return 0;
return m_coin_count[num];
}
@@ -186,7 +186,7 @@ int bookkeeping_manager::coin_counter_get_count(int num)
void bookkeeping_manager::coin_lockout_w(int num,int on)
{
- if (num >= ARRAY_LENGTH(m_coinlockedout))
+ if (num >= std::size(m_coinlockedout))
return;
m_coinlockedout[num] = on;
}
@@ -199,7 +199,7 @@ void bookkeeping_manager::coin_lockout_w(int num,int on)
int bookkeeping_manager::coin_lockout_get_state(int num)
{
- if (num >= ARRAY_LENGTH(m_coinlockedout))
+ if (num >= std::size(m_coinlockedout))
return false;
return m_coinlockedout[num];
}
@@ -212,6 +212,6 @@ int bookkeeping_manager::coin_lockout_get_state(int num)
void bookkeeping_manager::coin_lockout_global_w(int on)
{
- for (int i = 0; i < ARRAY_LENGTH(m_coinlockedout); i++)
+ for (int i = 0; i < std::size(m_coinlockedout); i++)
coin_lockout_w(i, on);
}
diff --git a/src/emu/crsshair.cpp b/src/emu/crsshair.cpp
index 0e570bb9eaf..c8b50afbf4c 100644
--- a/src/emu/crsshair.cpp
+++ b/src/emu/crsshair.cpp
@@ -172,7 +172,7 @@ void render_crosshair::set_default_bitmap()
void render_crosshair::create_bitmap()
{
- rgb_t color = m_player < ARRAY_LENGTH(crosshair_colors) ? crosshair_colors[m_player] : rgb_t::white();
+ rgb_t color = m_player < std::size(crosshair_colors) ? crosshair_colors[m_player] : rgb_t::white();
// if we have a bitmap and texture for this player, kill it
if (!m_bitmap)
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp
index 2b631e99ad3..dc5e2e6539d 100644
--- a/src/emu/debug/debugcmd.cpp
+++ b/src/emu/debug/debugcmd.cpp
@@ -3820,7 +3820,7 @@ void debugger_commands::execute_symlist(int ref, const std::vector<std::string>
if (!entry.second->is_function())
{
namelist[count++] = entry.second->name();
- if (count >= ARRAY_LENGTH(namelist))
+ if (count >= std::size(namelist))
break;
}
}
diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp
index da0a1f72ce1..422ff9fbca4 100644
--- a/src/emu/debug/debugcpu.cpp
+++ b/src/emu/debug/debugcpu.cpp
@@ -1380,7 +1380,7 @@ offs_t device_debug::history_pc(int index) const
index = 0;
if (index <= -HISTORY_SIZE)
index = -HISTORY_SIZE + 1;
- return m_pc_history[(m_pc_history_index + ARRAY_LENGTH(m_pc_history) - 1 + index) % ARRAY_LENGTH(m_pc_history)];
+ return m_pc_history[(m_pc_history_index + std::size(m_pc_history) - 1 + index) % std::size(m_pc_history)];
}
diff --git a/src/emu/debug/debughlp.cpp b/src/emu/debug/debughlp.cpp
index e3106c647e5..473de3249ce 100644
--- a/src/emu/debug/debughlp.cpp
+++ b/src/emu/debug/debughlp.cpp
@@ -1637,7 +1637,7 @@ const char *debug_get_help(const char *tag)
size_t taglen = strlen(tag);
/* find a match */
- for (i = 0; i < ARRAY_LENGTH(static_help_list); i++)
+ for (i = 0; i < std::size(static_help_list); i++)
if (!core_strnicmp(static_help_list[i].tag, tag, taglen))
{
foundcount++;
@@ -1659,7 +1659,7 @@ const char *debug_get_help(const char *tag)
/* otherwise, indicate ambiguous help */
msglen = sprintf(ambig_message, "Ambiguous help request, did you mean:\n");
- for (i = 0; i < ARRAY_LENGTH(static_help_list); i++)
+ for (i = 0; i < std::size(static_help_list); i++)
if (!core_strnicmp(static_help_list[i].tag, tag, taglen))
msglen += sprintf(&ambig_message[msglen], " help %s?\n", static_help_list[i].tag);
return ambig_message;
diff --git a/src/emu/debug/dvbpoints.cpp b/src/emu/debug/dvbpoints.cpp
index ba99c147a72..258d1dff020 100644
--- a/src/emu/debug/dvbpoints.cpp
+++ b/src/emu/debug/dvbpoints.cpp
@@ -217,7 +217,7 @@ void debug_view_breakpoints::view_update()
gather_breakpoints();
// Set the view region so the scroll bars update
- m_total.x = tableBreaks[ARRAY_LENGTH(tableBreaks) - 1];
+ m_total.x = tableBreaks[std::size(tableBreaks) - 1];
m_total.y = m_buffer.size() + 1;
if (m_total.y < 10)
m_total.y = 10;
@@ -225,7 +225,7 @@ void debug_view_breakpoints::view_update()
// Draw
debug_view_char *dest = &m_viewdata[0];
util::ovectorstream linebuf;
- linebuf.reserve(ARRAY_LENGTH(tableBreaks) - 1);
+ linebuf.reserve(std::size(tableBreaks) - 1);
// Header
if (m_visible.y > 0)
diff --git a/src/emu/debug/dvwpoints.cpp b/src/emu/debug/dvwpoints.cpp
index 605dcf8fe42..76e74233988 100644
--- a/src/emu/debug/dvwpoints.cpp
+++ b/src/emu/debug/dvwpoints.cpp
@@ -239,7 +239,7 @@ void debug_view_watchpoints::view_update()
gather_watchpoints();
// Set the view region so the scroll bars update
- m_total.x = tableBreaks[ARRAY_LENGTH(tableBreaks) - 1];
+ m_total.x = tableBreaks[std::size(tableBreaks) - 1];
m_total.y = m_buffer.size() + 1;
if (m_total.y < 10)
m_total.y = 10;
@@ -247,7 +247,7 @@ void debug_view_watchpoints::view_update()
// Draw
debug_view_char *dest = &m_viewdata[0];
util::ovectorstream linebuf;
- linebuf.reserve(ARRAY_LENGTH(tableBreaks) - 1);
+ linebuf.reserve(std::size(tableBreaks) - 1);
// Header
if (m_visible.y > 0)
diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp
index 55613cf90f2..49dee5f650e 100644
--- a/src/emu/diexec.cpp
+++ b/src/emu/diexec.cpp
@@ -416,7 +416,7 @@ void device_execute_interface::interface_post_start()
device().save_item(STRUCT_MEMBER(m_input, m_curstate));
// fill in the input states and IRQ callback information
- for (int line = 0; line < ARRAY_LENGTH(m_input); line++)
+ for (int line = 0; line < std::size(m_input); line++)
m_input[line].start(*this, line);
}
@@ -679,7 +679,7 @@ if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linen
// if we're full of events, flush the queue and log a message
int event_index = m_qindex++;
- if (event_index >= ARRAY_LENGTH(m_queue))
+ if (event_index >= std::size(m_queue))
{
m_qindex--;
empty_event_queue(nullptr,0);
@@ -688,7 +688,7 @@ if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linen
}
// enqueue the event
- if (event_index < ARRAY_LENGTH(m_queue))
+ if (event_index < std::size(m_queue))
{
if (vector == USE_STORED_VECTOR)
vector = m_stored_vector;
diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp
index 0fbee95dce8..3c610e66319 100644
--- a/src/emu/diimage.cpp
+++ b/src/emu/diimage.cpp
@@ -130,17 +130,16 @@ void device_image_interface::interface_config_complete()
//-------------------------------------------------
-// find_device_type - search trough list of
+// find_device_type - search through list of
// device types to extract data
//-------------------------------------------------
const image_device_type_info *device_image_interface::find_device_type(iodevice_t type)
{
- int i;
- for (i = 0; i < ARRAY_LENGTH(device_image_interface::m_device_info_array); i++)
+ for (const image_device_type_info &info : m_device_info_array)
{
- if (m_device_info_array[i].m_type == type)
- return &m_device_info_array[i];
+ if (info.m_type == type)
+ return &info;
}
return nullptr;
}
@@ -172,11 +171,10 @@ const char *device_image_interface::device_brieftypename(iodevice_t type)
iodevice_t device_image_interface::device_typeid(const char *name)
{
- int i;
- for (i = 0; i < ARRAY_LENGTH(device_image_interface::m_device_info_array); i++)
+ for (const image_device_type_info &info : m_device_info_array)
{
- if (!core_stricmp(name, m_device_info_array[i].m_name) || !core_stricmp(name, m_device_info_array[i].m_shortname))
- return m_device_info_array[i].m_type;
+ if (!core_stricmp(name, info.m_name) || !core_stricmp(name, info.m_shortname))
+ return info.m_type;
}
return (iodevice_t)-1;
}
@@ -333,7 +331,7 @@ void device_image_interface::message(const char *format, ...)
/* format the message */
va_start(args, format);
- vsnprintf(buffer, ARRAY_LENGTH(buffer), format, args);
+ vsnprintf(buffer, std::size(buffer), format, args);
va_end(args);
/* display the popup for a standard amount of time */
diff --git a/src/emu/dipalette.cpp b/src/emu/dipalette.cpp
index b5ceeb05d4c..7cd58665a4d 100644
--- a/src/emu/dipalette.cpp
+++ b/src/emu/dipalette.cpp
@@ -491,7 +491,7 @@ void device_palette_interface::configure_rgb_shadows(int mode, float factor)
assert(m_format != BITMAP_FORMAT_IND16);
// verify the shadow table
- assert(mode >= 0 && mode < ARRAY_LENGTH(m_shadow_tables));
+ assert(mode >= 0 && mode < std::size(m_shadow_tables));
shadow_table_data &stable = m_shadow_tables[mode];
assert(stable.base != nullptr);
diff --git a/src/emu/diserial.h b/src/emu/diserial.h
index 7d7717c5158..62b13c028a1 100644
--- a/src/emu/diserial.h
+++ b/src/emu/diserial.h
@@ -201,8 +201,8 @@ protected:
virtual void tra_complete() override
{
assert(!m_empty || (m_head == m_tail));
- assert(m_head < ARRAY_LENGTH(m_fifo));
- assert(m_tail < ARRAY_LENGTH(m_fifo));
+ assert(m_head < std::size(m_fifo));
+ assert(m_tail < std::size(m_fifo));
if (!m_empty)
{
@@ -227,8 +227,8 @@ protected:
void transmit_byte(u8 byte)
{
assert(!m_empty || (m_head == m_tail));
- assert(m_head < ARRAY_LENGTH(m_fifo));
- assert(m_tail < ARRAY_LENGTH(m_fifo));
+ assert(m_head < std::size(m_fifo));
+ assert(m_tail < std::size(m_fifo));
if (m_empty && is_transmit_register_empty())
{
diff --git a/src/emu/distate.cpp b/src/emu/distate.cpp
index cd47948abd2..215f140efd1 100644
--- a/src/emu/distate.cpp
+++ b/src/emu/distate.cpp
@@ -337,12 +337,12 @@ std::string device_state_entry::format(const char *string, bool maxout) const
if (width == 0)
throw emu_fatalerror("Width required for %%u formats\n");
hitnonzero = false;
- while (leadzero && width > ARRAY_LENGTH(k_decimal_divisor))
+ while (leadzero && width > std::size(k_decimal_divisor))
{
dest.append(" ");
width--;
}
- for (int digitnum = ARRAY_LENGTH(k_decimal_divisor) - 1; digitnum >= 0; digitnum--)
+ for (int digitnum = std::size(k_decimal_divisor) - 1; digitnum >= 0; digitnum--)
{
int digit = (result >= k_decimal_divisor[digitnum]) ? (result / k_decimal_divisor[digitnum]) % 10 : 0;
if (digit != 0)
diff --git a/src/emu/emucore.h b/src/emu/emucore.h
index b0df89343ec..a05eab2cd5e 100644
--- a/src/emu/emucore.h
+++ b/src/emu/emucore.h
@@ -80,9 +80,6 @@ using util::iabs;
using util::string_format;
-// genf is a generic function pointer; cast function pointers to this instead of void *
-typedef void genf(void);
-
// pen_t is used to represent pixel values in bitmaps
typedef u32 pen_t;
diff --git a/src/emu/fileio.cpp b/src/emu/fileio.cpp
index 7d5954b2739..293c23045b4 100644
--- a/src/emu/fileio.cpp
+++ b/src/emu/fileio.cpp
@@ -719,12 +719,12 @@ osd_file::error emu_file::attempt_zipped()
{
typedef util::archive_file::error (*open_func)(const std::string &filename, util::archive_file::ptr &result);
char const *const suffixes[] = { ".zip", ".7z" };
- open_func const open_funcs[ARRAY_LENGTH(suffixes)] = { &util::archive_file::open_zip, &util::archive_file::open_7z };
+ open_func const open_funcs[std::size(suffixes)] = { &util::archive_file::open_zip, &util::archive_file::open_7z };
// loop over archive types
std::string const savepath(m_fullpath);
std::string filename;
- for (unsigned i = 0; i < ARRAY_LENGTH(suffixes); i++, m_fullpath = savepath, filename.clear())
+ for (unsigned i = 0; i < std::size(suffixes); i++, m_fullpath = savepath, filename.clear())
{
// loop over directory parts up to the start of filename
while (1)
diff --git a/src/emu/input.cpp b/src/emu/input.cpp
index e22e443cc83..25ecd238d05 100644
--- a/src/emu/input.cpp
+++ b/src/emu/input.cpp
@@ -668,7 +668,7 @@ bool input_manager::code_pressed_once(input_code code)
// look for the code in the memory
bool curvalue = code_pressed(code);
int empty = -1;
- for (int memnum = 0; memnum < ARRAY_LENGTH(m_switch_memory); memnum++)
+ for (int memnum = 0; memnum < std::size(m_switch_memory); memnum++)
{
// were we previous pressed on the last time through here?
if (m_switch_memory[memnum] == code)
@@ -876,7 +876,7 @@ input_code input_manager::code_from_token(std::string_view _token)
// copy the token and break it into pieces
std::string token[6];
int numtokens = 0;
- while (numtokens < ARRAY_LENGTH(token))
+ while (numtokens < std::size(token))
{
// make a token up to the next underscore
std::string_view::size_type score = _token.find('_');
@@ -1327,7 +1327,7 @@ bool input_manager::map_device_to_controller(const devicemap_table_type *devicem
std::string token[2];
int numtokens = 0;
std::string_view _token = controllername;
- while (numtokens < ARRAY_LENGTH(token))
+ while (numtokens < std::size(token))
{
// make a token up to the next underscore
std::string_view::size_type score = _token.find('_');
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp
index 9a220b9c12f..4f3d5b2c7ac 100644
--- a/src/emu/ioport.cpp
+++ b/src/emu/ioport.cpp
@@ -633,7 +633,7 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def
for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype)
m_seq[seqtype].set_default();
- for (int i = 0; i < ARRAY_LENGTH(m_chars); i++)
+ for (int i = 0; i < std::size(m_chars); i++)
std::fill(std::begin(m_chars[i]), std::end(m_chars[i]), char32_t(0));
// for DIP switches and configs, look for a default value from the owner
@@ -782,11 +782,11 @@ ioport_type_class ioport_field::type_class() const noexcept
std::vector<char32_t> ioport_field::keyboard_codes(int which) const
{
- if (which >= ARRAY_LENGTH(m_chars))
+ if (which >= std::size(m_chars))
throw emu_fatalerror("Tried to access keyboard_code with out-of-range index %d\n", which);
std::vector<char32_t> result;
- for (int i = 0; i < ARRAY_LENGTH(m_chars[which]) && m_chars[which][i] != 0; i++)
+ for (int i = 0; i < std::size(m_chars[which]) && m_chars[which][i] != 0; i++)
result.push_back(m_chars[which][i]);
return result;
@@ -3012,12 +3012,9 @@ const char *ioport_configurer::string_from_token(const char *string)
#if false // Set true, If you want to take care missing-token or wrong-sorting
// otherwise, scan the list for a matching string and return it
- {
- int index;
- for (index = 0; index < ARRAY_LENGTH(input_port_default_strings); index++)
+ for (int index = 0; index < std::size(input_port_default_strings); index++)
if (input_port_default_strings[index].id == uintptr_t(string))
return input_port_default_strings[index].string;
- }
return "(Unknown Default)";
#else
@@ -3096,10 +3093,10 @@ ioport_configurer& ioport_configurer::field_alloc(ioport_type type, ioport_value
ioport_configurer& ioport_configurer::field_add_char(std::initializer_list<char32_t> charlist)
{
- for (int index = 0; index < ARRAY_LENGTH(m_curfield->m_chars); index++)
+ for (int index = 0; index < std::size(m_curfield->m_chars); index++)
if (m_curfield->m_chars[index][0] == 0)
{
- const size_t char_count = ARRAY_LENGTH(m_curfield->m_chars[index]);
+ const size_t char_count = std::size(m_curfield->m_chars[index]);
assert(charlist.size() > 0 && charlist.size() <= char_count);
for (size_t i = 0; i < char_count; i++)
@@ -3782,7 +3779,7 @@ std::string ioport_manager::input_type_to_token(ioport_type type, int player)
input_seq_type ioport_manager::token_to_seq_type(const char *string)
{
// look up the string in the table of possible sequence types and return the index
- for (int seqindex = 0; seqindex < ARRAY_LENGTH(seqtypestrings); seqindex++)
+ for (int seqindex = 0; seqindex < std::size(seqtypestrings); seqindex++)
if (!core_stricmp(string, seqtypestrings[seqindex]))
return input_seq_type(seqindex);
return SEQ_TYPE_INVALID;
diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp
index e686e6385a8..e5dcdc93dbc 100644
--- a/src/emu/natkeyboard.cpp
+++ b/src/emu/natkeyboard.cpp
@@ -1066,7 +1066,7 @@ const char_info *char_info::find(char32_t target)
{
// perform a simple binary search to find the proper alternate
int low = 0;
- int high = ARRAY_LENGTH(charinfo);
+ int high = std::size(charinfo);
while (high > low)
{
int middle = (high + low) / 2;
@@ -1096,7 +1096,7 @@ bool validate_natural_keyboard_statics(void)
const char_info *ci;
// check to make sure that charinfo is in order
- for (i = 0; i < ARRAY_LENGTH(charinfo); i++)
+ for (i = 0; i < std::size(charinfo); i++)
{
if (last_char >= charinfo[i].ch)
{
@@ -1107,7 +1107,7 @@ bool validate_natural_keyboard_statics(void)
}
// check to make sure that I can look up everything on alternate_charmap
- for (i = 0; i < ARRAY_LENGTH(charinfo); i++)
+ for (i = 0; i < std::size(charinfo); i++)
{
ci = char_info::find(charinfo[i].ch);
if (ci != &charinfo[i])
diff --git a/src/emu/profiler.h b/src/emu/profiler.h
index cff0801f65c..8341e075eae 100644
--- a/src/emu/profiler.h
+++ b/src/emu/profiler.h
@@ -117,7 +117,7 @@ private:
ATTR_FORCE_INLINE void real_start(profile_type type)
{
// fail if we overflow
- if (m_filoptr >= &m_filo[ARRAY_LENGTH(m_filo) - 1])
+ if (m_filoptr >= &m_filo[std::size(m_filo) - 1])
throw emu_fatalerror("Profiler FILO overflow (type = %d)\n", type);
// get current tick count
diff --git a/src/emu/render.cpp b/src/emu/render.cpp
index 5e2c023bf4e..b7a66b7bd2a 100644
--- a/src/emu/render.cpp
+++ b/src/emu/render.cpp
@@ -442,7 +442,7 @@ void render_texture::get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo
// is it a size we already have?
scaled_texture *scaled = nullptr;
int scalenum;
- for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
+ for (scalenum = 0; scalenum < std::size(m_scaled); scalenum++)
{
scaled = &m_scaled[scalenum];
@@ -452,12 +452,12 @@ void render_texture::get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo
}
// did we get one?
- if (scalenum == ARRAY_LENGTH(m_scaled))
+ if (scalenum == std::size(m_scaled))
{
int lowest = -1;
// didn't find one -- take the entry with the lowest seqnum
- for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
+ for (scalenum = 0; scalenum < std::size(m_scaled); scalenum++)
if ((lowest == -1 || m_scaled[scalenum].seqid < m_scaled[lowest].seqid) && !primlist.has_reference(m_scaled[scalenum].bitmap.get()))
lowest = scalenum;
if (-1 == lowest)
@@ -697,7 +697,7 @@ const rgb_t *render_container::bcg_lookup_table(int texformat, u32 &out_length,
case TEXFORMAT_RGB32:
case TEXFORMAT_ARGB32:
case TEXFORMAT_YUY16:
- out_length = ARRAY_LENGTH(m_bcglookup256);
+ out_length = std::size(m_bcglookup256);
return m_bcglookup256;
default:
@@ -1318,7 +1318,7 @@ render_primitive_list &render_target::get_primitives()
// switch to the next primitive list
render_primitive_list &list = m_primlist[m_listindex];
- m_listindex = (m_listindex + 1) % ARRAY_LENGTH(m_primlist);
+ m_listindex = (m_listindex + 1) % std::size(m_primlist);
list.acquire_lock();
// free any previous primitives
diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp
index 8fa59c20257..c20a7979bbc 100644
--- a/src/emu/rendfont.cpp
+++ b/src/emu/rendfont.cpp
@@ -478,7 +478,7 @@ inline render_font::glyph &render_font::get_char(char32_t chnum)
static glyph dummy_glyph;
unsigned const page(chnum / 256);
- if (page >= ARRAY_LENGTH(m_glyphs))
+ if (page >= std::size(m_glyphs))
{
if ((0 <= m_defchar) && (chnum != m_defchar))
return get_char(m_defchar);
@@ -1292,7 +1292,7 @@ bool render_font::load_bdf()
{
LOG("render_font::load_bdf: ignoring character with negative x advance\n");
}
- else if ((256 * ARRAY_LENGTH(m_glyphs)) <= encoding)
+ else if ((256 * std::size(m_glyphs)) <= encoding)
{
LOG("render_font::load_bdf: ignoring character with encoding outside range\n");
}
@@ -1505,7 +1505,7 @@ bool render_font::save_cached(const char *filename, u64 length, u32 hash)
// loop over all characters
bdc_table_entry table_entry(chartable.empty() ? nullptr : &chartable[0]);
- for (unsigned chnum = 0; chnum < (256 * ARRAY_LENGTH(m_glyphs)); chnum++)
+ for (unsigned chnum = 0; chnum < (256 * std::size(m_glyphs)); chnum++)
{
if (m_glyphs[chnum / 256] && (0 < m_glyphs[chnum / 256][chnum % 256].width))
{
diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp
index e6ee818b449..4da6c9069b0 100644
--- a/src/emu/softlist_dev.cpp
+++ b/src/emu/softlist_dev.cpp
@@ -218,7 +218,7 @@ void software_list_device::display_matches(const machine_config &config, const c
{
// get the top 16 approximate matches for the selected device interface (i.e. only carts for cartslot, etc.)
const software_info *matches[16] = { nullptr };
- swlistdev.find_approx_matches(name, ARRAY_LENGTH(matches), matches, interface);
+ swlistdev.find_approx_matches(name, std::size(matches), matches, interface);
// if we found some, print them
if (matches[0] != nullptr)
diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp
index 625f0e989e6..7ee663aba69 100644
--- a/src/emu/sound.cpp
+++ b/src/emu/sound.cpp
@@ -105,7 +105,7 @@ void stream_buffer::set_sample_rate(u32 rate, bool resample)
// voice when jumping off the edge in Q*Bert; without this extra effort
// it is crackly and/or glitchy at times
sample_t buffer[64];
- int buffered_samples = std::min(m_sample_rate, std::min(rate, u32(ARRAY_LENGTH(buffer))));
+ int buffered_samples = std::min(m_sample_rate, std::min(rate, u32(std::size(buffer))));
// if the new rate is lower, downsample into our holding buffer;
// otherwise just copy into our holding buffer for later upsampling
@@ -203,12 +203,12 @@ void stream_buffer::flush_wav()
// iterate over chunks for conversion
s16 buffer[1024];
- for (int samplebase = 0; samplebase < view.samples(); samplebase += ARRAY_LENGTH(buffer))
+ for (int samplebase = 0; samplebase < view.samples(); samplebase += std::size(buffer))
{
// clamp to the buffer size
int cursamples = view.samples() - samplebase;
- if (cursamples > ARRAY_LENGTH(buffer))
- cursamples = ARRAY_LENGTH(buffer);
+ if (cursamples > std::size(buffer))
+ cursamples = std::size(buffer);
// convert and fill
for (int sampindex = 0; sampindex < cursamples; sampindex++)
diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp
index a5470505f12..497ce3e7030 100644
--- a/src/emu/uiinput.cpp
+++ b/src/emu/uiinput.cpp
@@ -138,11 +138,11 @@ bool ui_input_manager::push_event(ui_event evt)
}
// is the queue filled up?
- if ((m_events_end + 1) % ARRAY_LENGTH(m_events) == m_events_start)
+ if ((m_events_end + 1) % std::size(m_events) == m_events_start)
return false;
m_events[m_events_end++] = evt;
- m_events_end %= ARRAY_LENGTH(m_events);
+ m_events_end %= std::size(m_events);
return true;
}
@@ -156,7 +156,7 @@ bool ui_input_manager::pop_event(ui_event *evt)
if (m_events_start != m_events_end)
{
*evt = m_events[m_events_start++];
- m_events_start %= ARRAY_LENGTH(m_events);
+ m_events_start %= std::size(m_events);
return true;
}
else
diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp
index 710473b85f9..f9523f29411 100644
--- a/src/emu/validity.cpp
+++ b/src/emu/validity.cpp
@@ -1844,7 +1844,7 @@ void validity_checker::validate_dip_settings(ioport_field &field)
if (coin_error)
{
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, " Note proper coin sort order should be:\n");
- for (int entry = 0; entry < ARRAY_LENGTH(coin_list); entry++)
+ for (int entry = 0; entry < std::size(coin_list); entry++)
if (coin_list[entry])
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, " %s\n", ioport_string_from_index(__input_string_coinage_start + entry));
}