From c0407f073bf7afe26407c4add5cfeaf7104913c9 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 11 Nov 2016 18:49:32 +0100 Subject: [PATCH] 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 --- src/emu/config.cpp | 2 +- src/emu/debug/debugcmd.cpp | 2 +- src/emu/debug/dvdisasm.cpp | 2 +- src/emu/debug/express.cpp | 2 +- src/emu/diexec.cpp | 12 ++++++------ src/emu/diimage.cpp | 4 ++-- src/emu/drivenum.cpp | 2 +- src/emu/emumem.cpp | 6 +++--- src/emu/emupal.cpp | 6 +++--- src/emu/fileio.cpp | 6 +++--- src/emu/input.cpp | 4 ++-- src/emu/ioport.cpp | 2 +- src/emu/natkeyboard.cpp | 6 +++--- src/emu/output.cpp | 2 +- src/emu/rendfont.cpp | 6 +++--- src/emu/rendlay.cpp | 6 +++--- src/emu/rendutil.cpp | 2 +- src/emu/screen.cpp | 2 +- src/emu/video.cpp | 2 +- src/emu/video/resnet.cpp | 4 ++-- src/osd/osdcomm.h | 16 ++++++++++++++++ 21 files changed, 56 insertions(+), 40 deletions(-) diff --git a/src/emu/config.cpp b/src/emu/config.cpp index 7402341ad32..a5872416615 100644 --- a/src/emu/config.cpp +++ b/src/emu/config.cpp @@ -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 */ diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 620f83985b5..6c6cbdf0e20 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -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; } /*------------------------------------------------- diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp index 3dab8d13dd3..3e4655a75dc 100644 --- a/src/emu/debug/dvdisasm.cpp +++ b/src/emu/debug/dvdisasm.cpp @@ -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(); diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp index 7c3cc74b3d0..ee5333eb948 100644 --- a/src/emu/debug/express.cpp +++ b/src/emu/debug/express.cpp @@ -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]); diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp index 02c46244c0a..f9548598dbf 100644 --- a/src/emu/diexec.cpp +++ b/src/emu/diexec.cpp @@ -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); diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index cf945be1517..96fabb36db9 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -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; diff --git a/src/emu/drivenum.cpp b/src/emu/drivenum.cpp index 4f111d35f0f..e6585dbedfb 100644 --- a/src/emu/drivenum.cpp +++ b/src/emu/drivenum.cpp @@ -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; } diff --git a/src/emu/emumem.cpp b/src/emu/emumem.cpp index 0deab9d74a4..dafa370b0a6 100644 --- a/src/emu/emumem.cpp +++ b/src/emu/emumem.cpp @@ -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++) diff --git a/src/emu/emupal.cpp b/src/emu/emupal.cpp index 2b4393ee6be..96c8db7e707 100644 --- a/src/emu/emupal.cpp +++ b/src/emu/emupal.cpp @@ -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 diff --git a/src/emu/fileio.cpp b/src/emu/fileio.cpp index 4670fd2b789..c27c809dd7a 100644 --- a/src/emu/fileio.cpp +++ b/src/emu/fileio.cpp @@ -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]); diff --git a/src/emu/input.cpp b/src/emu/input.cpp index 91ff3350750..bf7c812a7b3 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -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(strcopy.c_str()); - while (1) + while (true) { // trim any leading spaces while (*str != 0 && isspace((uint8_t)*str)) diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 8f87d33b592..4ce67c52805 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -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), diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp index fd39bc7b5e0..3eba3b7bc63 100644 --- a/src/emu/natkeyboard.cpp +++ b/src/emu/natkeyboard.cpp @@ -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() : ""); @@ -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 diff --git a/src/emu/output.cpp b/src/emu/output.cpp index 60489cae11e..45b1fcfca80 100644 --- a/src/emu/output.cpp +++ b/src/emu/output.cpp @@ -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 */ diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp index aa43342958c..013cdc675d3 100644 --- a/src/emu/rendfont.cpp +++ b/src/emu/rendfont.cpp @@ -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 diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp index ed800c6d976..3b31f3b3ae3 100644 --- a/src/emu/rendlay.cpp +++ b/src/emu/rendlay.cpp @@ -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()) diff --git a/src/emu/rendutil.cpp b/src/emu/rendutil.cpp index be1eed481d2..ea49e7c2550 100644 --- a/src/emu/rendutil.cpp +++ b/src/emu/rendutil.cpp @@ -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; diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index 4742963d9d3..fc7ccd30fbd 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -813,7 +813,7 @@ void screen_device::device_start() m_svg = std::make_unique(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(); diff --git a/src/emu/video.cpp b/src/emu/video.cpp index f25da887e03..edad002ad40 100644 --- a/src/emu/video.cpp +++ b/src/emu/video.cpp @@ -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) diff --git a/src/emu/video/resnet.cpp b/src/emu/video/resnet.cpp index 1b467d016c4..8213b15e0e9 100644 --- a/src/emu/video/resnet.cpp +++ b/src/emu/video/resnet.cpp @@ -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 ); diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index d6ed9a43a88..c51349612b6 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -137,4 +137,20 @@ using ssize_t = std::make_signed_t; #endif #endif +namespace osdcomm { + template + bool isEnabled() + { + return true; + } + + template<> + inline bool isEnabled() + { + return false; + } +}; + +#define IS_ENABLED(_x) osdcomm::isEnabled() + #endif /* MAME_OSD_OSDCOMM_H */