some bool <-> int not needed conversions, also cleaned drivenum.* was using memset for clearing vector (nw)

This commit is contained in:
Miodrag Milanovic 2016-10-21 11:54:18 +02:00
parent 5bdb4f7a89
commit a291e77b2c
19 changed files with 61 additions and 67 deletions

View File

@ -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
};

View File

@ -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)

View File

@ -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; }

View File

@ -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:

View File

@ -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

View File

@ -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<UINT8> m_included;
std::vector<bool> m_included;
mutable std::vector<std::unique_ptr<machine_config>> m_config;
mutable std::vector<int> m_config_cache;
};

View File

@ -2516,7 +2516,7 @@ bool ioport_manager::playback_read<bool>(bool &result)
{
UINT8 temp;
playback_read(temp);
return result = bool(temp);
return result = temp!=0;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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<bbox> &bboxes)

View File

@ -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();

View File

@ -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);

View File

@ -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 }
};

View File

@ -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;

View File

@ -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;
}

View File

@ -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; }

View File

@ -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;

View File

@ -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)) ||