use ARRAY_LENGTH (nw)

This commit is contained in:
Oliver Stöneberg 2014-04-03 22:48:35 +00:00
parent 9b0b211a79
commit f2de945ef9
33 changed files with 301 additions and 304 deletions

View File

@ -257,7 +257,7 @@ static const char *const Formats[] = {
NULL
};
#define MAX_OPS (((sizeof(Formats) / sizeof(Formats[0])) - 1) / PTRS_PER_FORMAT)
#define MAX_OPS ((ARRAY_LENGTH(Formats) - 1) / PTRS_PER_FORMAT)
struct AD8201Opcode {
byte mask;

View File

@ -582,9 +582,9 @@ static const opcodeinfo *const hd6309_pgpointers[3] =
static const int hd6309_numops[3] =
{
sizeof(hd6309_pg0opcodes) / sizeof(hd6309_pg0opcodes[0]),
sizeof(hd6309_pg1opcodes) / sizeof(hd6309_pg1opcodes[0]),
sizeof(hd6309_pg2opcodes) / sizeof(hd6309_pg2opcodes[0])
ARRAY_LENGTH(hd6309_pg0opcodes),
ARRAY_LENGTH(hd6309_pg1opcodes),
ARRAY_LENGTH(hd6309_pg2opcodes)
};
static const char *const hd6309_regs[5] = { "X", "Y", "U", "S", "PC" };

View File

@ -351,9 +351,9 @@ static const opcodeinfo *const m6809_pgpointers[3] =
static const int m6809_numops[3] =
{
sizeof(m6809_pg0opcodes) / sizeof(m6809_pg0opcodes[0]),
sizeof(m6809_pg1opcodes) / sizeof(m6809_pg1opcodes[0]),
sizeof(m6809_pg2opcodes) / sizeof(m6809_pg2opcodes[0])
ARRAY_LENGTH(m6809_pg0opcodes),
ARRAY_LENGTH(m6809_pg1opcodes),
ARRAY_LENGTH(m6809_pg2opcodes)
};
static const char *const m6809_regs[5] = { "X", "Y", "U", "S", "PC" };

View File

@ -84,7 +84,7 @@ static const char *const PIC16C5xFormats[] = {
NULL
};
#define MAX_OPS (((sizeof(PIC16C5xFormats) / sizeof(PIC16C5xFormats[0])) - 1) / PTRS_PER_FORMAT)
#define MAX_OPS ((ARRAY_LENGTH(PIC16C5xFormats) - 1) / PTRS_PER_FORMAT)
struct PIC16C5xOpcode {
word mask; /* instruction mask */

View File

@ -94,7 +94,7 @@ static const char *const PIC16C62xFormats[] = {
NULL
};
#define MAX_OPS (((sizeof(PIC16C62xFormats) / sizeof(PIC16C62xFormats[0])) - 1) / PTRS_PER_FORMAT)
#define MAX_OPS ((ARRAY_LENGTH(PIC16C62xFormats) - 1) / PTRS_PER_FORMAT)
struct PIC16C62xOpcode {
word mask; /* instruction mask */

View File

@ -975,7 +975,7 @@ static const char *const ir_names[] = {
const char *tlcs90_device::internal_registers_names(UINT16 x)
{
int ir = x - T90_IOBASE;
if ( ir >= 0 && ir < sizeof(ir_names)/sizeof(ir_names[0]) )
if ( ir >= 0 && ir < ARRAY_LENGTH(ir_names) )
return ir_names[ir];
return NULL;
}

View File

@ -154,7 +154,7 @@ static const char *const TMS32010Formats[] = {
NULL
};
#define MAX_OPS (((sizeof(TMS32010Formats) / sizeof(TMS32010Formats[0])) - 1) / PTRS_PER_FORMAT)
#define MAX_OPS ((ARRAY_LENGTH(TMS32010Formats) - 1) / PTRS_PER_FORMAT)
struct TMS32010Opcode {
word mask; /* instruction mask */

View File

@ -314,7 +314,7 @@ static const char *const TMS32025Formats[] = {
NULL
};
#define MAX_OPS (((sizeof(TMS32025Formats) / sizeof(TMS32025Formats[0])) - 1) / PTRS_PER_FORMAT)
#define MAX_OPS ((ARRAY_LENGTH(TMS32025Formats) - 1) / PTRS_PER_FORMAT)
struct TMS32025Opcode {
word mask; /* instruction mask */

View File

@ -1481,7 +1481,7 @@ const char *debug_get_help(const char *tag)
tagcopy[i] = tolower((UINT8)tag[i]);
/* find a match */
for (i = 0; i < sizeof(static_help_list) / sizeof(static_help_list[0]); i++)
for (i = 0; i < ARRAY_LENGTH(static_help_list); i++)
if (!strncmp(static_help_list[i].tag, tagcopy, taglen))
{
foundcount++;
@ -1503,7 +1503,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 < sizeof(static_help_list) / sizeof(static_help_list[0]); i++)
for (i = 0; i < ARRAY_LENGTH(static_help_list); i++)
if (!strncmp(static_help_list[i].tag, tagcopy, taglen))
msglen += sprintf(&ambig_message[msglen], " help %s?\n", static_help_list[i].tag);
return ambig_message;

View File

@ -759,7 +759,7 @@ unsigned lsi53c810_device::lsi53c810_dasm(char *buf, UINT32 pc)
buf += sprintf(buf, "%s ", op_mnemonic);
need_cojunction = FALSE;
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
for (i = 0; i < ARRAY_LENGTH(flags); i++)
{
if (op & flags[i].flag)
{

View File

@ -169,7 +169,7 @@ void legacy_mos6526_device::device_start()
m_flag = 1;
/* setup ports */
for (int p = 0; p < (sizeof(m_port) / sizeof(m_port[0])); p++)
for (int p = 0; p < ARRAY_LENGTH(m_port); p++)
{
m_port[p].m_mask_value = 0xff;
}
@ -177,7 +177,7 @@ void legacy_mos6526_device::device_start()
/* setup timers */
m_pc_timer = timer_alloc(TIMER_PC);
for (int t = 0; t < (sizeof(m_timer) / sizeof(m_timer[0])); t++)
for (int t = 0; t < ARRAY_LENGTH(m_timer); t++)
{
cia_timer *timer = &m_timer[t];
timer->m_timer = machine().scheduler().timer_alloc(FUNC(timer_proc), (void*)this);

View File

@ -447,7 +447,7 @@ bool nscsi_full_device::command_done()
nscsi_full_device::control *nscsi_full_device::buf_control_push()
{
if(buf_control_wpos == int(sizeof(buf_control)/sizeof(buf_control[0])))
if(buf_control_wpos == int(ARRAY_LENGTH(buf_control)))
throw emu_fatalerror("%s: buf_control overflow\n", tag());
control *c = buf_control + buf_control_wpos;

View File

@ -393,7 +393,7 @@ void pc_keyboard_device::queue_insert(UINT8 data)
m_queue[m_head] = data;
m_head++;
m_head %= (sizeof(m_queue) / sizeof(m_queue[0]));
m_head %= ARRAY_LENGTH(m_queue);
}
@ -402,7 +402,7 @@ int pc_keyboard_device::queue_size(void)
int queue_size;
queue_size = m_head - m_tail;
if (queue_size < 0)
queue_size += sizeof(m_queue) / sizeof(m_queue[0]);
queue_size += ARRAY_LENGTH(m_queue);
return queue_size;
}
@ -669,7 +669,7 @@ READ8_MEMBER(pc_keyboard_device::read)
logerror("read(): Keyboard Read 0x%02x\n",data);
m_tail++;
m_tail %= sizeof(m_queue) / sizeof(m_queue[0]);
m_tail %= ARRAY_LENGTH(m_queue);
return data;
}

View File

@ -2901,7 +2901,7 @@ address_table::address_table(address_space &space, bool large)
{
// make our static table all watchpoints
if (s_watchpoint_table[0] != STATIC_WATCHPOINT)
for (unsigned int i=0; i != sizeof(s_watchpoint_table)/sizeof(s_watchpoint_table[0]); i++)
for (unsigned int i=0; i != ARRAY_LENGTH(s_watchpoint_table); i++)
s_watchpoint_table[i] = STATIC_WATCHPOINT;
// initialize everything to unmapped

View File

@ -123,7 +123,7 @@ static float linear_rate[]=
s_to_rate(6080.0f)
};
static const int num_linear_rates=sizeof(linear_rate)/sizeof(linear_rate[0]);
static const int num_linear_rates=ARRAY_LENGTH(linear_rate);
static const float pos_exp_rate[]=
{
@ -229,7 +229,7 @@ static const float pos_exp_rate[]=
s_to_rate(2664.0f)
};
static const int num_pos_exp_rates=sizeof(linear_rate)/sizeof(linear_rate[0]);
static const int num_pos_exp_rates=ARRAY_LENGTH(linear_rate);
static const float neg_exp_rate[]=
{
@ -343,7 +343,7 @@ static const float neg_exp_rate[]=
s_to_rate(11200.0f)
};
static const int num_neg_exp_rates=sizeof(linear_rate)/sizeof(linear_rate[0]);
static const int num_neg_exp_rates=ARRAY_LENGTH(linear_rate);
static const float decay_rate[16]=
{
@ -396,7 +396,7 @@ static const float linear_release_rate[]=
s_to_rate(3040.0f)
};
static const int num_linear_release_rates=sizeof(linear_release_rate)/sizeof(linear_release_rate[0]);
static const int num_linear_release_rates=ARRAY_LENGTH(linear_release_rate);
static const float exp_release_rate[]=
{
@ -429,7 +429,7 @@ static const float exp_release_rate[]=
s_to_rate(7008.0f)
};
static const int num_exp_release_rates=sizeof(exp_release_rate)/sizeof(exp_release_rate[0]);
static const int num_exp_release_rates=ARRAY_LENGTH(exp_release_rate);
//
//

View File

@ -929,7 +929,7 @@ mc6847_friend_device::character_map::character_map(const UINT8 *text_fontdata, b
}
// loop through all modes
for (mode = 0; mode < sizeof(m_entries) / sizeof(m_entries[0]); mode++)
for (mode = 0; mode < ARRAY_LENGTH(m_entries); mode++)
{
const UINT8 *fontdata;
UINT8 character_mask;

View File

@ -151,7 +151,7 @@ protected:
UINT8 character = data[i];
// based on the mode, determine which entry to use
const entry *e = &m_entries[mode % (sizeof(m_entries) / sizeof(m_entries[0]))];
const entry *e = &m_entries[mode % ARRAY_LENGTH(m_entries)];
// identify the character in the font data
const UINT8 *font_character = e->m_fontdata + (character & e->m_character_mask) * 12;

View File

@ -272,7 +272,7 @@ void famibox_state::famicombox_bankswitch(UINT8 bank)
};
for (int i = 0; i < sizeof(famicombox_banks)/sizeof(famicombox_banks[0]); i++ )
for (int i = 0; i < ARRAY_LENGTH(famicombox_banks); i++ )
{
if ( bank == famicombox_banks[i].bank ||
famicombox_banks[i].bank == 0 )

View File

@ -1762,7 +1762,7 @@ READ16_MEMBER(jalmah_state::urashima_mcu_r)
int res;
res = resp[m_respcount++];
if (m_respcount >= sizeof(resp)/sizeof(resp[0])) m_respcount = 0;
if (m_respcount >= ARRAY_LENGTH(resp)) m_respcount = 0;
// logerror("%04x: mcu_r %02x\n",space.device().safe_pc(),res);
@ -1980,7 +1980,7 @@ READ16_MEMBER(jalmah_state::daireika_mcu_r)
int res;
res = resp[m_respcount++];
if (m_respcount >= sizeof(resp)/sizeof(resp[0])) m_respcount = 0;
if (m_respcount >= ARRAY_LENGTH(resp)) m_respcount = 0;
// logerror("%04x: mcu_r %02x\n",space.device().safe_pc(),res);
@ -2259,7 +2259,7 @@ READ16_MEMBER(jalmah_state::mjzoomin_mcu_r)
int res;
res = resp[m_respcount++];
if (m_respcount >= sizeof(resp)/sizeof(resp[0])) m_respcount = 0;
if (m_respcount >= ARRAY_LENGTH(resp)) m_respcount = 0;
// logerror("%04x: mcu_r %02x\n",space.device().safe_pc(),res);
@ -2396,7 +2396,7 @@ READ16_MEMBER(jalmah_state::kakumei_mcu_r)
int res;
res = resp[m_respcount++];
if (m_respcount >= sizeof(resp)/sizeof(resp[0])) m_respcount = 0;
if (m_respcount >= ARRAY_LENGTH(resp)) m_respcount = 0;
// popmessage("%04x: mcu_r %02x",space.device().safe_pc(),res);
@ -2417,7 +2417,7 @@ READ16_MEMBER(jalmah_state::suchipi_mcu_r)
int res;
res = resp[m_respcount++];
if (m_respcount >= sizeof(resp)/sizeof(resp[0])) m_respcount = 0;
if (m_respcount >= ARRAY_LENGTH(resp)) m_respcount = 0;
// popmessage("%04x: mcu_r %02x",space.device().safe_pc(),res);

View File

@ -464,12 +464,12 @@ P1KEY11 29|30 P2KEY11
// HACK: read IPT_START1 from "INPUTS" to avoid listing it twice or having two independent STARTs listed
int start_depressed = ~value & 0x01000000;
keys |= start_depressed ? 1 << (sizeof(key_codes)/sizeof(key_codes[0]) - 1) : 0; // and bung it in at the end
keys |= start_depressed ? 1 << (ARRAY_LENGTH(key_codes) - 1) : 0; // and bung it in at the end
value |= 0xFFFF0000; // set top word
do {
// since we can't handle multiple keys, just return the first one depressed
if((keys & which_key) && (count < sizeof(key_codes)/sizeof(key_codes[0]))) {
if((keys & which_key) && (count < ARRAY_LENGTH(key_codes))) {
value &= ~((UINT32)(key_codes[count]) << 16); // mask in selected word as IP_ACTIVE_LOW
break;
}

View File

@ -116,7 +116,7 @@ PALETTE_INIT_MEMBER(skydiver_state, skydiver)
{
int i;
for (i = 0; i < sizeof(colortable_source) / sizeof(colortable_source[0]); i++)
for (i = 0; i < ARRAY_LENGTH(colortable_source); i++)
{
rgb_t color;
@ -389,7 +389,7 @@ static MACHINE_CONFIG_START( skydiver, skydiver_state )
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", skydiver)
MCFG_PALETTE_ADD("palette", sizeof(colortable_source) / sizeof(colortable_source[0]))
MCFG_PALETTE_ADD("palette", ARRAY_LENGTH(colortable_source))
MCFG_PALETTE_INIT_OWNER(skydiver_state, skydiver)

View File

@ -2394,7 +2394,7 @@ DRIVER_INIT_MEMBER(snowbros_state,cookbib2)
//for (i = 0;i < sizeof(cookbib2_mcu68k)/sizeof(cookbib2_mcu68k[0]);i++)
//for (i = 0;i < ARRAY_LENGTH(cookbib2_mcu68k);i++)
// m_hyperpac_ram[0xf000/2 + i] = cookbib2_mcu68k[i];
// for (i = 0;i < 0x200/2;i++)

View File

@ -242,7 +242,7 @@ PALETTE_INIT_MEMBER(spcforce_state, spcforce)
{
int i;
for (i = 0; i < sizeof(colortable_source) / sizeof(colortable_source[0]); i++)
for (i = 0; i < ARRAY_LENGTH(colortable_source); i++)
{
int data = colortable_source[i];
rgb_t color = rgb_t(pal1bit(data >> 0), pal1bit(data >> 1), pal1bit(data >> 2));
@ -280,7 +280,7 @@ static MACHINE_CONFIG_START( spcforce, spcforce_state )
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", spcforce)
MCFG_PALETTE_ADD("palette", sizeof(colortable_source) / sizeof(colortable_source[0]))
MCFG_PALETTE_ADD("palette", ARRAY_LENGTH(colortable_source))
MCFG_PALETTE_INIT_OWNER(spcforce_state, spcforce)
/* sound hardware */

View File

@ -174,7 +174,7 @@ float lordgun_crosshair_mapper(ioport_field *field, float linear_value)
{
int x = linear_value - 0x3c;
if ( (x < 0) || (x > sizeof(lordgun_gun_x_table)/sizeof(lordgun_gun_x_table[0])) )
if ( (x < 0) || (x > ARRAY_LENGTH(lordgun_gun_x_table)) )
x = 0;
return lordgun_gun_x_table[x] * 1.0f / 0x1BF;
@ -186,7 +186,7 @@ void lordgun_state::lorddgun_calc_gun_scr(int i)
int x = ioport(gunnames[i])->read() - 0x3c;
if ( (x < 0) || (x > sizeof(lordgun_gun_x_table)/sizeof(lordgun_gun_x_table[0])) )
if ( (x < 0) || (x > ARRAY_LENGTH(lordgun_gun_x_table)) )
x = 0;
m_gun[i].scr_x = lordgun_gun_x_table[x];

View File

@ -37,7 +37,7 @@ PALETTE_INIT_MEMBER(starshp1_state, starshp1)
5, 7 /* 0x11 - circle */
};
for (i = 0; i < sizeof(colortable_source) / sizeof(colortable_source[0]); i++)
for (i = 0; i < ARRAY_LENGTH(colortable_source); i++)
palette.set_pen_indirect(i, colortable_source[i]);
}

View File

@ -300,7 +300,7 @@ static MACHINE_CONFIG_START( gmaster, gmaster_state )
MCFG_SCREEN_UPDATE_DRIVER(gmaster_state, screen_update_gmaster)
MCFG_SCREEN_PALETTE("palette")
MCFG_PALETTE_ADD("palette", sizeof(gmaster_palette)/sizeof(gmaster_palette[0]))
MCFG_PALETTE_ADD("palette", ARRAY_LENGTH(gmaster_palette))
MCFG_PALETTE_INIT_OWNER(gmaster_state, gmaster)
MCFG_DEFAULT_LAYOUT(layout_lcd)

View File

@ -142,7 +142,7 @@ void sam6883_device::configure_bank(int bank, read8_delegate rhandler, write8_de
void sam6883_device::configure_bank(int bank, UINT8 *memory, UINT32 memory_size, bool is_read_only, read8_delegate rhandler, write8_delegate whandler)
{
assert((bank >= 0) && (bank < sizeof(m_banks) / sizeof(m_banks[0])));
assert((bank >= 0) && (bank < ARRAY_LENGTH(m_banks)));
m_banks[bank].m_memory = memory;
m_banks[bank].m_memory_size = memory_size;
m_banks[bank].m_memory_read_only = is_read_only;

View File

@ -120,10 +120,10 @@ void coco_state::device_start()
driver_device::device_start();
/* look up keyboard ports */
for (int i = 0; i < sizeof(m_keyboard) / sizeof(m_keyboard[0]); i++)
for (int i = 0; i < ARRAY_LENGTH(m_keyboard); i++)
{
char name[32];
snprintf(name, sizeof(name) / sizeof(name[0]), "row%d", i);
snprintf(name, ARRAY_LENGTH(name), "row%d", i);
m_keyboard[i] = ioport(name);
}
@ -850,7 +850,7 @@ void coco_state::poll_keyboard(void)
UINT8 pia0_pa_z = 0x7F;
/* poll the keyboard, and update PA6-PA0 accordingly*/
for (int i = 0; i < sizeof(m_keyboard) / sizeof(m_keyboard[0]); i++)
for (int i = 0; i < ARRAY_LENGTH(m_keyboard); i++)
{
int value = m_keyboard[i]->read();
if ((value | pia0_pb) != 0xFF)

View File

@ -70,7 +70,7 @@ void CLIB_DECL ATTR_PRINTF(1,2) logerror(const char *format, ...)
va_end(arg);
}
enum { FORMAT_COUNT = sizeof(floppy_formats)/sizeof(floppy_formats[0]) };
enum { FORMAT_COUNT = ARRAY_LENGTH(floppy_formats) };
static floppy_image_format_t *formats[FORMAT_COUNT];

View File

@ -49,8 +49,7 @@ imgtoolerr_t imgtool_create_cannonical_library(int omit_untested, imgtool_librar
imgtool_library_add(lib, modules[i]);
/* remove irrelevant modules */
for (i = 0; i < sizeof(irrelevant_modules)
/ sizeof(irrelevant_modules[0]); i++)
for (i = 0; i < ARRAY_LENGTH(irrelevant_modules); i++)
{
imgtool_library_unlink(lib, irrelevant_modules[i]);
}

View File

@ -1830,7 +1830,7 @@ static int dsk_read_catalog(struct ti99_lvl2_imgref *l2_img, int aphysrec, ti99_
|| ((dest->files[i].fdr_ptr && dest->files[i+1].fdr_ptr) && (memcmp(dest->files[i].name, dest->files[i+1].name, 10) >= 0)))
{
/* if the catalog is not sorted, we repair it */
qsort(dest->files, sizeof(dest->files)/sizeof(dest->files[0]), sizeof(dest->files[0]),
qsort(dest->files, ARRAY_LENGTH(dest->files), sizeof(dest->files[0]),
cat_file_compare_qsort);
break;
}

View File

@ -952,7 +952,7 @@ WRITE16_MEMBER( stic_device::write )
break;
}
if (offset < sizeof(m_stic_registers) / sizeof(m_stic_registers[0]))
if (offset < ARRAY_LENGTH(m_stic_registers))
m_stic_registers[offset] = data;
}

File diff suppressed because it is too large Load Diff