Added IS_ENABLED, so we have compiler check for non used part, it is checked but not compiled in (nw)

false and true now used instead of integer where used as bool
This commit is contained in:
Miodrag Milanovic 2016-11-11 18:49:32 +01:00
parent cef6cd4a25
commit c0407f073b
21 changed files with 56 additions and 40 deletions

View File

@ -200,7 +200,7 @@ int configuration_manager::load_xml(emu_file &file, config_type which_type)
}
/* log that we are processing this entry */
if (DEBUG_CONFIG)
if (IS_ENABLED(DEBUG_CONFIG))
osd_printf_debug("Entry: %s -- processing\n", name);
/* loop over all registrants and call their load function */

View File

@ -529,7 +529,7 @@ bool debugger_commands::debug_command_parameter_command(const char *param)
m_console.printf("Error in command: %s\n", param);
m_console.printf(" %*s^", CMDERR_ERROR_OFFSET(err), "");
m_console.printf("%s\n", debugger_console::cmderr_to_string(err));
return 0;
return false;
}
/*-------------------------------------------------

View File

@ -246,7 +246,7 @@ offs_t debug_view_disasm::find_pc_backwards(offs_t targetpc, int numinstrs)
offs_t targetpcbyte = source.m_space.address_to_byte(targetpc) & source.m_space.logbytemask();
offs_t fillpcbyte = targetpcbyte;
offs_t lastgoodpc = targetpc;
while (1)
while (true)
{
// fill the buffer up to the target
offs_t curpcbyte = source.m_space.address_to_byte(curpc) & source.m_space.logbytemask();

View File

@ -862,7 +862,7 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *&
// accumulate a lower-case version of the symbol
const char *stringstart = string;
std::string buffer;
while (1)
while (true)
{
static const char valid[] = "abcdefghijklmnopqrstuvwxyz0123456789_$#.:";
char val = tolower((uint8_t)string[0]);

View File

@ -237,7 +237,7 @@ void device_execute_interface::suspend_resume_changed()
void device_execute_interface::suspend(uint32_t reason, bool eatcycles)
{
if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason);
if (IS_ENABLED(TEMPLOG)) printf("suspend %s (%X)\n", device().tag(), reason);
// set the suspend reason and eat cycles flag
m_nextsuspend |= reason;
m_nexteatcycles = eatcycles;
@ -252,7 +252,7 @@ if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason);
void device_execute_interface::resume(uint32_t reason)
{
if (TEMPLOG) printf("resume %s (%X)\n", device().tag(), reason);
if (IS_ENABLED(TEMPLOG)) printf("resume %s (%X)\n", device().tag(), reason);
// clear the suspend reason and eat cycles flag
m_nextsuspend &= ~reason;
suspend_resume_changed();
@ -614,7 +614,7 @@ int device_execute_interface::standard_irq_callback(int irqline)
// get the default vector and acknowledge the interrupt if needed
int vector = m_input[irqline].default_irq_callback();
if (VERBOSE) device().logerror("standard_irq_callback('%s', %d) $%04x\n", device().tag(), irqline, vector);
if (IS_ENABLED(VERBOSE)) device().logerror("standard_irq_callback('%s', %d) $%04x\n", device().tag(), irqline, vector);
// if there's a driver callback, run it to get the vector
if (!m_driver_irq.isnull())
@ -754,7 +754,7 @@ void device_execute_interface::device_input::set_state_synced(int state, int vec
{
LOG(("set_state_synced('%s',%d,%d,%02x)\n", m_execute->device().tag(), m_linenum, state, vector));
if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linenum, state, (vector == USE_STORED_VECTOR) ? 0 : vector);
if (IS_ENABLED(TEMPLOG)) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linenum, state, (vector == USE_STORED_VECTOR) ? 0 : vector);
assert(state == ASSERT_LINE || state == HOLD_LINE || state == CLEAR_LINE || state == PULSE_LINE);
// treat PULSE_LINE as ASSERT+CLEAR
@ -799,7 +799,7 @@ if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linen
TIMER_CALLBACK_MEMBER(device_execute_interface::device_input::empty_event_queue)
{
if (TEMPLOG) printf("empty_queue(%s,%d,%d)\n", m_execute->device().tag(), m_linenum, m_qindex);
if (IS_ENABLED(TEMPLOG)) printf("empty_queue(%s,%d,%d)\n", m_execute->device().tag(), m_linenum, m_qindex);
// loop over all events
for (int curevent = 0; curevent < m_qindex; curevent++)
{
@ -808,7 +808,7 @@ if (TEMPLOG) printf("empty_queue(%s,%d,%d)\n", m_execute->device().tag(), m_line
// set the input line state and vector
m_curstate = input_event & 0xff;
m_curvector = input_event >> 8;
if (TEMPLOG) printf(" (%d,%d)\n", m_curstate, m_curvector);
if (IS_ENABLED(TEMPLOG)) printf(" (%d,%d)\n", m_curstate, m_curvector);
assert(m_curstate == ASSERT_LINE || m_curstate == HOLD_LINE || m_curstate == CLEAR_LINE);

View File

@ -773,8 +773,8 @@ int device_image_interface::reopen_for_write(const std::string &path)
return image_error_from_file_error(filerr);
// success!
m_readonly = 0;
m_created = 1;
m_readonly = false;
m_created = true;
set_image_filename(revised_path);
return IMAGE_ERROR_SUCCESS;

View File

@ -247,7 +247,7 @@ void driver_enumerator::include_all()
// always exclude the empty driver
int empty = find("___empty");
assert(empty != -1);
m_included[empty] = 0;
m_included[empty] = false;
}

View File

@ -3410,7 +3410,7 @@ uint16_t address_table::derive_range(offs_t byteaddress, offs_t &bytestart, offs
uint16_t curl1entry = l1entry;
uint16_t curentry = entry;
bytestart = byteaddress;
while (1)
while (true)
{
// if we need to scan the subtable, do it
if (curentry != curl1entry)
@ -3448,7 +3448,7 @@ uint16_t address_table::derive_range(offs_t byteaddress, offs_t &bytestart, offs
curl1entry = l1entry;
curentry = entry;
byteend = byteaddress;
while (1)
while (true)
{
// if we need to scan the subtable, do it
if (curentry != curl1entry)
@ -3512,7 +3512,7 @@ void address_table::mask_all_handlers(offs_t mask)
uint16_t address_table::subtable_alloc()
{
// loop
while (1)
while (true)
{
// find a subtable with a usecount of 0
for (uint16_t subindex = 0; subindex < SUBTABLE_COUNT; subindex++)

View File

@ -23,8 +23,8 @@ palette_device::palette_device(const machine_config &mconfig, const char *tag, d
: device_t(mconfig, PALETTE, "palette", tag, owner, clock, "palette", __FILE__),
m_entries(0),
m_indirect_entries(0),
m_enable_shadows(0),
m_enable_hilights(0),
m_enable_shadows(false),
m_enable_hilights(false),
m_membits(0),
m_membits_supplied(false),
m_endianness(),
@ -249,7 +249,7 @@ void palette_device::set_shadow_dRGB32(int mode, int dr, int dg, int db, bool no
stable.db = db;
stable.noclip = noclip;
if (VERBOSE)
if (IS_ENABLED(VERBOSE))
popmessage("shadow %d recalc %d %d %d %02x", mode, dr, dg, db, noclip);
// regenerate the table

View File

@ -473,13 +473,13 @@ bool emu_file::eof()
{
// load the ZIP file now if we haven't yet
if (compressed_file_ready())
return 0;
return false;
// return EOF if we can
if (m_file)
return m_file->eof();
return 0;
return false;
}
@ -657,7 +657,7 @@ osd_file::error emu_file::attempt_zipped()
for (unsigned i = 0; i < ARRAY_LENGTH(suffixes); i++, m_fullpath = savepath, filename.clear())
{
// loop over directory parts up to the start of filename
while (1)
while (true)
{
// find the final path separator
auto const dirsep = m_fullpath.find_last_of(PATH_SEPARATOR[0]);

View File

@ -652,7 +652,7 @@ int32_t input_manager::code_value(input_code code)
break;
}
}
} while (0);
} while (false);
// stop the profiler before exiting
g_profiler.stop();
@ -1562,7 +1562,7 @@ void input_manager::seq_from_tokens(input_seq &seq, const char *string)
// loop until we're done
std::string strcopy = string;
char *str = const_cast<char *>(strcopy.c_str());
while (1)
while (true)
{
// trim any leading spaces
while (*str != 0 && isspace((uint8_t)*str))

View File

@ -1346,7 +1346,7 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog)
joystick(nullptr),
value(field.defvalue()),
impulse(0),
last(0),
last(false),
toggle(field.toggle()),
joydir(digital_joystick::JOYDIR_COUNT),
autofire(false),

View File

@ -397,7 +397,7 @@ void natural_keyboard::post(char32_t ch)
m_last_cr = (ch == '\r');
// logging
if (LOG_NATURAL_KEYBOARD)
if (IS_ENABLED(LOG_NATURAL_KEYBOARD))
{
const keycode_map_entry *code = find_code(ch);
machine().logerror("natural_keyboard::post(): code=%i (%s) field.name='%s'\n", int(ch), unicode_to_string(ch).c_str(), (code != nullptr && code->field[0] != nullptr) ? code->field[0]->name() : "<null>");
@ -601,7 +601,7 @@ void natural_keyboard::build_codes(ioport_manager &manager)
newcode.ch = code;
m_keycode_map.push_back(newcode);
if (LOG_NATURAL_KEYBOARD)
if (IS_ENABLED(LOG_NATURAL_KEYBOARD))
{
machine().logerror("natural_keyboard: code=%i (%s) port=%p field.name='%s'\n", int(code), unicode_to_string(code).c_str(), (void *)&port, field.name());
}
@ -686,7 +686,7 @@ void natural_keyboard::internal_post(char32_t ch)
if (empty())
{
m_timer->adjust(choose_delay(ch));
m_status_keydown = 0;
m_status_keydown = false;
}
// add to the buffer, resizing if necessary

View File

@ -105,7 +105,7 @@ void output_manager::set_value(const char *outname, int32_t value)
/* if the value is different, signal the notifier */
if (oldval != value)
{
if (OUTPUT_VERBOSE)
if (IS_ENABLED(OUTPUT_VERBOSE))
machine().logerror("Output %s = %d (was %d)\n", outname, value, oldval);
/* call the local notifiers first */

View File

@ -595,7 +595,7 @@ bool render_font::load_bdf()
if (strncmp(ptr, "ENCODING ", 9) == 0)
{
if (sscanf(ptr + 9, "%d", &charnum) != 1)
return 1;
return true;
}
// DWIDTH tells us the width to the next character
@ -603,14 +603,14 @@ bool render_font::load_bdf()
{
int dummy1;
if (sscanf(ptr + 7, "%d %d", &width, &dummy1) != 2)
return 1;
return true;
}
// BBX tells us the height/width of the bitmap and the offsets
else if (strncmp(ptr, "BBX ", 4) == 0)
{
if (sscanf(ptr + 4, "%d %d %d %d", &bmwidth, &bmheight, &xoffs, &yoffs) != 4)
return 1;
return true;
}
// BITMAP is the start of the data

View File

@ -906,7 +906,7 @@ void layout_element::reel_component::draw(running_machine &machine, bitmap_argb3
// only render the symbol / text if it's atually in view because the code is SLOW
if ((endpos >= bounds.min_y) && (basey <= bounds.max_y))
{
while (1)
while (true)
{
width = font->string_width(ourheight / num_shown, aspect, m_stopnames[fruit].c_str());
if (width < bounds.width())
@ -1064,7 +1064,7 @@ void layout_element::reel_component::draw_beltreel(running_machine &machine, bit
// only render the symbol / text if it's atually in view because the code is SLOW
if ((endpos >= bounds.min_x) && (basex <= bounds.max_x))
{
while (1)
while (true)
{
width = font->string_width(dest.height(), aspect, m_stopnames[fruit].c_str());
if (width < bounds.width())
@ -1933,7 +1933,7 @@ void layout_element::component::draw_text(render_font &font, bitmap_argb32 &dest
float aspect = 1.0f;
int32_t width;
while (1)
while (true)
{
width = font.string_width(bounds.height(), aspect, str);
if (width < bounds.width())

View File

@ -265,7 +265,7 @@ static void resample_argb_bitmap_bilinear(uint32_t *dest, uint32_t drowpixels, u
bool render_clip_line(render_bounds *bounds, const render_bounds *clip)
{
/* loop until we get a final result */
while (1)
while (true)
{
uint8_t code0 = 0, code1 = 0;
uint8_t thiscode;

View File

@ -813,7 +813,7 @@ void screen_device::device_start()
m_svg = std::make_unique<screen_device_svg_renderer>(reg);
machine().output().set_notifier(nullptr, screen_device_svg_renderer::output_notifier, m_svg.get());
if (0)
if (IS_ENABLED(0))
{
// The osd picks up the size before start is called, so that's useless
m_width = m_svg->width();

View File

@ -783,7 +783,7 @@ void video_manager::update_throttle(attotime emutime)
};
// outer scope so we can break out in case of a resync
while (1)
while (true)
{
// apply speed factor to emu time
if (m_speed != 0 && m_speed != 1000)

View File

@ -201,7 +201,7 @@ double compute_resistor_weights(
}
/* debug code */
if (VERBOSE)
if (IS_ENABLED(VERBOSE))
{
osd_printf_info("compute_resistor_weights(): scaler = %15.10f\n",scale);
osd_printf_info("min val :%i max val:%i Total number of networks :%i\n", minval, maxval, networks_no );
@ -391,7 +391,7 @@ double compute_resistor_net_outputs(
}
/* debug code */
if (VERBOSE)
if (IS_ENABLED(VERBOSE))
{
osd_printf_info("compute_resistor_net_outputs(): scaler = %15.10f\n",scale);
osd_printf_info("min val :%i max val:%i Total number of networks :%i\n", minval, maxval, networks_no );

View File

@ -137,4 +137,20 @@ using ssize_t = std::make_signed_t<size_t>;
#endif
#endif
namespace osdcomm {
template<bool>
bool isEnabled()
{
return true;
}
template<>
inline bool isEnabled<false>()
{
return false;
}
};
#define IS_ENABLED(_x) osdcomm::isEnabled<!!(_x)>()
#endif /* MAME_OSD_OSDCOMM_H */