From a291e77b2cfc4ce1b780db0d8fa664fb8094d365 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 21 Oct 2016 11:54:18 +0200 Subject: [PATCH] some bool <-> int not needed conversions, also cleaned drivenum.* was using memset for clearing vector (nw) --- src/emu/debug/debugcpu.h | 4 ++-- src/emu/diserial.cpp | 4 ++-- src/emu/diserial.h | 2 +- src/emu/distate.h | 2 +- src/emu/drivenum.cpp | 8 +------- src/emu/drivenum.h | 4 ++-- src/emu/ioport.cpp | 2 +- src/emu/render.cpp | 16 ++++++++-------- src/emu/rendutil.cpp | 22 +++++++++++----------- src/emu/rendutil.h | 4 ++-- src/emu/screen.cpp | 2 +- src/emu/sound.cpp | 2 +- src/emu/uiinput.cpp | 2 +- src/emu/video.cpp | 26 +++++++++++++------------- src/emu/video.h | 2 +- src/lib/util/flac.cpp | 2 +- src/lib/util/options.h | 2 +- src/lib/util/unzip.cpp | 18 +++++++++--------- src/lib/util/vecstream.h | 4 ++-- 19 files changed, 61 insertions(+), 67 deletions(-) diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 66bbe48e1f2..7ec39ba4863 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -80,7 +80,7 @@ public: const device_debug * m_debugInterface; // the interface we were created from breakpoint * m_next; // next in the list int m_index; // user reported index - UINT8 m_enabled; // enabled? + bool m_enabled; // enabled? offs_t m_address; // execution address parsed_expression m_condition; // condition std::string m_action; // action @@ -156,7 +156,7 @@ public: registerpoint * m_next; // next in the list int m_index; // user reported index - UINT8 m_enabled; // enabled? + bool m_enabled; // enabled? parsed_expression m_condition; // condition std::string m_action; // action }; diff --git a/src/emu/diserial.cpp b/src/emu/diserial.cpp index 4613da0d4ad..182360fab3a 100644 --- a/src/emu/diserial.cpp +++ b/src/emu/diserial.cpp @@ -454,12 +454,12 @@ UINT8 device_serial_interface::transmit_register_get_data_bit() bool device_serial_interface::is_receive_register_full() { - return m_rcv_flags & RECEIVE_REGISTER_FULL; + return (m_rcv_flags & RECEIVE_REGISTER_FULL)!=0; } bool device_serial_interface::is_transmit_register_empty() { - return m_tra_flags & TRANSMIT_REGISTER_EMPTY; + return (m_tra_flags & TRANSMIT_REGISTER_EMPTY)!=0; } const char *device_serial_interface::parity_tostring(parity_t parity) diff --git a/src/emu/diserial.h b/src/emu/diserial.h index 12c2479234b..1d4d957a041 100644 --- a/src/emu/diserial.h +++ b/src/emu/diserial.h @@ -109,7 +109,7 @@ protected: bool is_receive_register_full(); bool is_transmit_register_empty(); - bool is_receive_register_synchronized() const { return m_rcv_flags & RECEIVE_REGISTER_SYNCHRONISED; } + bool is_receive_register_synchronized() const { return (m_rcv_flags & RECEIVE_REGISTER_SYNCHRONISED)!=0; } bool is_receive_register_shifting() const { return m_rcv_bit_count_received > 0; } bool is_receive_framing_error() const { return m_rcv_framing_error; } bool is_receive_parity_error() const { return m_rcv_parity_error; } diff --git a/src/emu/distate.h b/src/emu/distate.h index f4558129bbd..c608e832775 100644 --- a/src/emu/distate.h +++ b/src/emu/distate.h @@ -63,7 +63,7 @@ public: void *dataptr() const { return m_dataptr.v; } const char *symbol() const { return m_symbol.c_str(); } bool visible() const { return ((m_flags & DSF_NOSHOW) == 0); } - bool divider() const { return m_flags & DSF_DIVIDER; } + bool divider() const { return ((m_flags & DSF_DIVIDER) != 0); } device_state_interface *parent_state() const {return m_device_state;} protected: diff --git a/src/emu/drivenum.cpp b/src/emu/drivenum.cpp index 450790eb55a..5f67013c603 100644 --- a/src/emu/drivenum.cpp +++ b/src/emu/drivenum.cpp @@ -135,8 +135,6 @@ driver_enumerator::driver_enumerator(emu_options &options) m_included(s_driver_count), m_config(s_driver_count) { - memset(&m_included[0], 0, s_driver_count); - memset(&m_config[0], 0, s_driver_count*sizeof(m_config[0])); include_all(); } @@ -148,8 +146,6 @@ driver_enumerator::driver_enumerator(emu_options &options, const char *string) m_included(s_driver_count), m_config(s_driver_count) { - memset(&m_included[0], 0, s_driver_count); - memset(&m_config[0], 0, s_driver_count*sizeof(m_config[0])); filter(string); } @@ -161,8 +157,6 @@ driver_enumerator::driver_enumerator(emu_options &options, const game_driver &dr m_included(s_driver_count), m_config(s_driver_count) { - memset(&m_included[0], 0, s_driver_count); - memset(&m_config[0], 0, s_driver_count*sizeof(m_config[0])); filter(driver); } @@ -247,7 +241,7 @@ int driver_enumerator::filter(const game_driver &driver) void driver_enumerator::include_all() { - memset(&m_included[0], 1, sizeof(m_included[0]) * s_driver_count); + std::fill(m_included.begin(), m_included.end(), true); m_filtered_count = s_driver_count; // always exclude the empty driver diff --git a/src/emu/drivenum.h b/src/emu/drivenum.h index cc3bad554bf..3732915b46a 100644 --- a/src/emu/drivenum.h +++ b/src/emu/drivenum.h @@ -113,7 +113,7 @@ public: int filter(const char *string = nullptr); int filter(const game_driver &driver); void include_all(); - void exclude_all() { memset(&m_included[0], 0, sizeof(m_included[0]) * s_driver_count); m_filtered_count = 0; } + void exclude_all() { std::fill(m_included.begin(), m_included.end(), false); m_filtered_count = 0; } void reset() { m_current = -1; } bool next(); bool next_excluded(); @@ -132,7 +132,7 @@ private: int m_current; int m_filtered_count; emu_options & m_options; - std::vector m_included; + std::vector m_included; mutable std::vector> m_config; mutable std::vector m_config_cache; }; diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 7ecf6fe5c1e..c110bc9719f 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -2516,7 +2516,7 @@ bool ioport_manager::playback_read(bool &result) { UINT8 temp; playback_read(temp); - return result = bool(temp); + return result = temp!=0; } diff --git a/src/emu/render.cpp b/src/emu/render.cpp index 0e28f3c0494..891ed88470e 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -967,7 +967,7 @@ render_target::render_target(render_manager &manager, const internal_layout *lay m_layerconfig = m_base_layerconfig; // load the layout files - load_layout_files(layoutfile, flags & RENDER_CREATE_SINGLE_FILE); + load_layout_files(layoutfile, (flags & RENDER_CREATE_SINGLE_FILE)!=0); // set the current view to the first one set_view(0); @@ -1219,7 +1219,7 @@ void render_target::compute_visible_area(INT32 target_width, INT32 target_height int scale_mode = m_scale_mode; if (m_scale_mode == SCALE_FRACTIONAL_AUTO) { - bool is_rotated = (m_manager.machine().system().flags & ORIENTATION_SWAP_XY) ^ (target_orientation & ORIENTATION_SWAP_XY); + bool is_rotated = ((m_manager.machine().system().flags & ORIENTATION_SWAP_XY) ^ (target_orientation & ORIENTATION_SWAP_XY))!=0; scale_mode = is_rotated ^ target_is_portrait ? SCALE_FRACTIONAL_Y : SCALE_FRACTIONAL_X; } @@ -2235,27 +2235,27 @@ void render_target::config_load(xml_data_node &targetnode) // modify the artwork config int tmpint = xml_get_attribute_int(&targetnode, "backdrops", -1); if (tmpint == 0 || tmpint == 1) - set_backdrops_enabled(tmpint); + set_backdrops_enabled(tmpint != 0); tmpint = xml_get_attribute_int(&targetnode, "overlays", -1); if (tmpint == 0 || tmpint == 1) - set_overlays_enabled(tmpint); + set_overlays_enabled(tmpint != 0); tmpint = xml_get_attribute_int(&targetnode, "bezels", -1); if (tmpint == 0 || tmpint == 1) - set_bezels_enabled(tmpint); + set_bezels_enabled(tmpint != 0); tmpint = xml_get_attribute_int(&targetnode, "cpanels", -1); if (tmpint == 0 || tmpint == 1) - set_cpanels_enabled(tmpint); + set_cpanels_enabled(tmpint != 0); tmpint = xml_get_attribute_int(&targetnode, "marquees", -1); if (tmpint == 0 || tmpint == 1) - set_marquees_enabled(tmpint); + set_marquees_enabled(tmpint != 0); tmpint = xml_get_attribute_int(&targetnode, "zoom", -1); if (tmpint == 0 || tmpint == 1) - set_zoom_to_screen(tmpint); + set_zoom_to_screen(tmpint != 0); // apply orientation tmpint = xml_get_attribute_int(&targetnode, "rotate", -1); diff --git a/src/emu/rendutil.cpp b/src/emu/rendutil.cpp index c356a1d0abd..1d59c92db0b 100644 --- a/src/emu/rendutil.cpp +++ b/src/emu/rendutil.cpp @@ -262,7 +262,7 @@ static void resample_argb_bitmap_bilinear(UINT32 *dest, UINT32 drowpixels, UINT3 render_clip_line - clip a line to a rectangle -------------------------------------------------*/ -int render_clip_line(render_bounds *bounds, const render_bounds *clip) +bool render_clip_line(render_bounds *bounds, const render_bounds *clip) { /* loop until we get a final result */ while (1) @@ -291,13 +291,13 @@ int render_clip_line(render_bounds *bounds, const render_bounds *clip) if (bounds->x1 < clip->x0) code1 |= 8; - /* trivial accept: just return FALSE */ + /* trivial accept: just return false */ if ((code0 | code1) == 0) - return FALSE; + return false; - /* trivial reject: just return TRUE */ + /* trivial reject: just return true */ if ((code0 & code1) != 0) - return TRUE; + return true; /* fix one of the OOB cases */ thiscode = code0 ? code0 : code1; @@ -349,7 +349,7 @@ int render_clip_line(render_bounds *bounds, const render_bounds *clip) render_clip_quad - clip a quad to a rectangle -------------------------------------------------*/ -int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_quad_texuv *texcoords) +bool render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_quad_texuv *texcoords) { /* ensure our assumptions about the bounds are correct */ assert(bounds->x0 <= bounds->x1); @@ -357,13 +357,13 @@ int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_qu /* trivial reject */ if (bounds->y1 < clip->y0) - return TRUE; + return true; if (bounds->y0 > clip->y1) - return TRUE; + return true; if (bounds->x1 < clip->x0) - return TRUE; + return true; if (bounds->x0 > clip->x1) - return TRUE; + return true; /* clip top (x0,y0)-(x1,y1) */ if (bounds->y0 < clip->y0) @@ -420,7 +420,7 @@ int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_qu texcoords->br.v -= (texcoords->br.v - texcoords->bl.v) * frac; } } - return FALSE; + return false; } diff --git a/src/emu/rendutil.h b/src/emu/rendutil.h index 2aa898ac470..9d3bb526c6d 100644 --- a/src/emu/rendutil.h +++ b/src/emu/rendutil.h @@ -22,8 +22,8 @@ /* ----- render utilities ----- */ void render_resample_argb_bitmap_hq(bitmap_argb32 &dest, bitmap_argb32 &source, const render_color &color, bool force = false); -int render_clip_line(render_bounds *bounds, const render_bounds *clip); -int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_quad_texuv *texcoords); +bool render_clip_line(render_bounds *bounds, const render_bounds *clip); +bool render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_quad_texuv *texcoords); void render_line_to_quad(const render_bounds *bounds, float width, float length_extension, render_bounds *bounds0, render_bounds *bounds1); void render_load_jpeg(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, const char *filename); bool render_load_png(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, const char *filename, bool load_as_alpha_to_existing = false); diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index 1d10b515f43..21616086280 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -248,7 +248,7 @@ void screen_device_svg_renderer::output_change(const char *outname, INT32 value) auto l = m_key_ids.find(outname); if (l == m_key_ids.end()) return; - m_key_state[l->second] = value; + m_key_state[l->second] = value!=0; } void screen_device_svg_renderer::compute_initial_bboxes(std::vector &bboxes) diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index cafd6fbfde9..70415f7532f 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -1060,7 +1060,7 @@ void sound_manager::update(void *ptr, int param) // force all the speaker streams to generate the proper number of samples int samples_this_update = 0; for (speaker_device &speaker : speaker_device_iterator(machine().root_device())) - speaker.mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM)); + speaker.mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM)!=0); // now downmix the final result UINT32 finalmix_step = machine().video().speed_factor(); diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp index 9707793b2a3..0523decc27d 100644 --- a/src/emu/uiinput.cpp +++ b/src/emu/uiinput.cpp @@ -244,7 +244,7 @@ bool ui_input_manager::pressed(int code) bool ui_input_manager::pressed_repeat(int code, int speed) { - int pressed; + bool pressed; g_profiler.start(PROFILER_INPUT); diff --git a/src/emu/video.cpp b/src/emu/video.cpp index abd1bd24066..627b2f1f6da 100644 --- a/src/emu/video.cpp +++ b/src/emu/video.cpp @@ -35,20 +35,20 @@ //************************************************************************** // frameskipping tables -const UINT8 video_manager::s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS] = +const bool video_manager::s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS] = { - { 0,0,0,0,0,0,0,0,0,0,0,0 }, - { 0,0,0,0,0,0,0,0,0,0,0,1 }, - { 0,0,0,0,0,1,0,0,0,0,0,1 }, - { 0,0,0,1,0,0,0,1,0,0,0,1 }, - { 0,0,1,0,0,1,0,0,1,0,0,1 }, - { 0,1,0,0,1,0,1,0,0,1,0,1 }, - { 0,1,0,1,0,1,0,1,0,1,0,1 }, - { 0,1,0,1,1,0,1,0,1,1,0,1 }, - { 0,1,1,0,1,1,0,1,1,0,1,1 }, - { 0,1,1,1,0,1,1,1,0,1,1,1 }, - { 0,1,1,1,1,1,0,1,1,1,1,1 }, - { 0,1,1,1,1,1,1,1,1,1,1,1 } + { false,false,false,false,false,false,false,false,false,false,false,false }, + { false,false,false,false,false,false,false,false,false,false,false,true }, + { false,false,false,false,false,true ,false,false,false,false,false,true }, + { false,false,false,true ,false,false,false,true ,false,false,false,true }, + { false,false,true ,false,false,true ,false,false,true ,false,false,true }, + { false,true ,false,false,true ,false,true ,false,false,true ,false,true }, + { false,true ,false,true ,false,true ,false,true ,false,true ,false,true }, + { false,true ,false,true ,true ,false,true ,false,true ,true ,false,true }, + { false,true ,true ,false,true ,true ,false,true ,true ,false,true ,true }, + { false,true ,true ,true ,false,true ,true ,true ,false,true ,true ,true }, + { false,true ,true ,true ,true ,true ,false,true ,true ,true ,true ,true }, + { false,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true } }; diff --git a/src/emu/video.h b/src/emu/video.h index cf6a1a05017..64536083764 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -194,7 +194,7 @@ private: // movie recording - dummy bool m_dummy_recording; // indicates if snapshot should be created of every frame - static const UINT8 s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS]; + static const bool s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS]; static const attoseconds_t ATTOSECONDS_PER_SPEED_UPDATE = ATTOSECONDS_PER_SECOND / 4; static const int PAUSED_REFRESH_RATE = 30; diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp index 085eaacffef..46d349c3452 100644 --- a/src/lib/util/flac.cpp +++ b/src/lib/util/flac.cpp @@ -355,7 +355,7 @@ bool flac_decoder::reset() &flac_decoder::metadata_callback_static, &flac_decoder::error_callback_static, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK) return false; - return FLAC__stream_decoder_process_until_end_of_metadata(m_decoder); + return FLAC__stream_decoder_process_until_end_of_metadata(m_decoder)!=0; } diff --git a/src/lib/util/options.h b/src/lib/util/options.h index b669000e59f..d25a29ef1db 100644 --- a/src/lib/util/options.h +++ b/src/lib/util/options.h @@ -86,7 +86,7 @@ public: UINT32 flags() const { return m_flags; } bool is_header() const { return type() == OPTION_HEADER; } bool is_command() const { return type() == OPTION_COMMAND; } - bool is_internal() const { return m_flags & OPTION_FLAG_INTERNAL; } + bool is_internal() const { return (m_flags & OPTION_FLAG_INTERNAL)!=0; } bool has_range() const { return (!m_minimum.empty() && !m_maximum.empty()); } int priority() const { return m_priority; } bool is_changed() const { return m_changed; } diff --git a/src/lib/util/unzip.cpp b/src/lib/util/unzip.cpp index fe6ec9cb975..a65bda9a99c 100644 --- a/src/lib/util/unzip.cpp +++ b/src/lib/util/unzip.cpp @@ -620,16 +620,16 @@ class general_flag_reader public: general_flag_reader(std::uint16_t val) : m_value(val) { } - bool encrypted() const { return bool(m_value & 0x0001); } - bool implode_8k_dict() const { return bool(m_value & 0x0002); } - bool implode_3_trees() const { return bool(m_value & 0x0004); } + bool encrypted() const { return (m_value & 0x0001) !=0; } + bool implode_8k_dict() const { return (m_value & 0x0002) != 0; } + bool implode_3_trees() const { return (m_value & 0x0004) != 0; } unsigned deflate_option() const { return unsigned((m_value >> 1) & 0x0003); } - bool lzma_eos_mark() const { return bool(m_value & 0x0002); } - bool use_descriptor() const { return bool(m_value & 0x0008); } - bool patch_data() const { return bool(m_value & 0x0020); } - bool strong_encryption() const { return bool(m_value & 0x0040); } - bool utf8_encoding() const { return bool(m_value & 0x0800); } - bool directory_encryption() const { return bool(m_value & 0x2000); } + bool lzma_eos_mark() const { return (m_value & 0x0002) != 0; } + bool use_descriptor() const { return (m_value & 0x0008) != 0; } + bool patch_data() const { return (m_value & 0x0020) != 0; } + bool strong_encryption() const { return (m_value & 0x0040) != 0; } + bool utf8_encoding() const { return (m_value & 0x0800) != 0; } + bool directory_encryption() const { return (m_value & 0x2000) != 0; } private: std::uint16_t m_value; diff --git a/src/lib/util/vecstream.h b/src/lib/util/vecstream.h index 1af7dd0cd86..faf8b73c669 100644 --- a/src/lib/util/vecstream.h +++ b/src/lib/util/vecstream.h @@ -148,8 +148,8 @@ public: protected: virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override { - bool const in(which & std::ios_base::in); - bool const out(which & std::ios_base::out); + bool const in((which & std::ios_base::in)!=0); + bool const out((which & std::ios_base::out)!=0); if ((!in && !out) || (in && out && (std::ios_base::cur == dir)) || (in && !(m_mode & std::ios_base::in)) ||