From 5a9fb4c34030492adbaf690627d8f612000db550 Mon Sep 17 00:00:00 2001 From: "therealmogminer@gmail.com" Date: Mon, 16 Nov 2015 00:31:47 +0100 Subject: [PATCH] Remove this==NULL comps, nw --- src/devices/sound/sn76477.cpp | 452 +++++++--------------------------- src/devices/sound/sn76477.h | 25 -- src/emu/device.cpp | 16 -- src/emu/device.h | 10 +- src/emu/memory.h | 10 +- src/emu/screen.h | 2 +- 6 files changed, 89 insertions(+), 426 deletions(-) diff --git a/src/devices/sound/sn76477.cpp b/src/devices/sound/sn76477.cpp index ba31190b5ce..f94bf98d1e3 100644 --- a/src/devices/sound/sn76477.cpp +++ b/src/devices/sound/sn76477.cpp @@ -76,27 +76,10 @@ #define LOG(n,x) do { if (VERBOSE >= (n)) logerror x; } while (0) -#define CHECK_CHIP_NUM assert(this != NULL) -#define CHECK_CHIP_NUM_AND_BOOLEAN CHECK_CHIP_NUM; assert((state & 0x01) == state) -#define CHECK_CHIP_NUM_AND_POSITIVE CHECK_CHIP_NUM; assert(data >= 0.0) -#define CHECK_CHIP_NUM_AND_VOLTAGE CHECK_CHIP_NUM; assert((data >= 0.0) && (data <= 5.0)) -#define CHECK_CHIP_NUM_AND_CAP_VOLTAGE CHECK_CHIP_NUM; assert(((data >= 0.0) && (data <= 5.0)) || (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT)) - - - -/***************************************************************************** - * - * Test Mode - * - * in test mode, calls by the driver to - * the input setter functions are ignored. - * Interface values can be set in device_start - * to any desired test value. - * Use the space bar to enable/disable the chip. - * - *****************************************************************************/ - -#define TEST_MODE 0 +#define CHECK_BOOLEAN assert((state & 0x01) == state) +#define CHECK_POSITIVE assert(data >= 0.0) +#define CHECK_VOLTAGE assert((data >= 0.0) && (data <= 5.0)) +#define CHECK_CAP_VOLTAGE assert(((data >= 0.0) && (data <= 5.0)) || (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT)) /***************************************************************************** * @@ -233,11 +216,11 @@ void sn76477_device::device_start() intialize_noise(); // set up mixer and envelope modes, based on interface values - _SN76477_mixer_a_w(m_mixer_a); - _SN76477_mixer_b_w(m_mixer_b); - _SN76477_mixer_c_w(m_mixer_c); - _SN76477_envelope_1_w(m_envelope_1); - _SN76477_envelope_2_w(m_envelope_2); + mixer_a_w(m_mixer_a); + mixer_b_w(m_mixer_b); + mixer_c_w(m_mixer_c); + envelope_1_w(m_envelope_1); + envelope_2_w(m_envelope_2); m_one_shot_cap_voltage = ONE_SHOT_CAP_VOLTAGE_MIN; m_slf_cap_voltage = SLF_CAP_VOLTAGE_MIN; @@ -966,45 +949,31 @@ inline UINT32 sn76477_device::generate_next_real_noise_bit() * *****************************************************************************/ -void sn76477_device::_SN76477_enable_w(UINT32 data) +WRITE_LINE_MEMBER(sn76477_device::enable_w) { - m_enable = data; + CHECK_BOOLEAN; - /* if falling edge */ - if (!m_enable) - { - /* start the attack phase */ - m_attack_decay_cap_voltage = AD_CAP_VOLTAGE_MIN; - - /* one-shot runs regardless of envelope mode */ - m_one_shot_running_ff = 1; - } -} - - -void sn76477_device::SN76477_test_enable_w(UINT32 data) -{ - if (data != m_enable) + if (state != m_enable) { m_channel->update(); - _SN76477_enable_w(data); + m_enable = state; + + /* if falling edge */ + if (!m_enable) + { + /* start the attack phase */ + m_attack_decay_cap_voltage = AD_CAP_VOLTAGE_MIN; + + /* one-shot runs regardless of envelope mode */ + m_one_shot_running_ff = 1; + } log_enable_line(); } } -WRITE_LINE_MEMBER( sn76477_device::enable_w ) -{ -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; - - SN76477_test_enable_w(state); -#endif -} - - /***************************************************************************** * @@ -1012,219 +981,142 @@ WRITE_LINE_MEMBER( sn76477_device::enable_w ) * *****************************************************************************/ -void sn76477_device::_SN76477_mixer_a_w(UINT32 data) -{ - m_mixer_mode = (m_mixer_mode & ~0x01) | (data << 0); -} - - WRITE_LINE_MEMBER( sn76477_device::mixer_a_w ) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; + CHECK_BOOLEAN; if (state != ((m_mixer_mode >> 0) & 0x01)) { m_channel->update(); - _SN76477_mixer_a_w(state); + m_mixer_mode = (m_mixer_mode & ~0x01) | state; log_mixer_mode(); } -#endif } - -void sn76477_device::_SN76477_mixer_b_w(UINT32 data) -{ - m_mixer_mode = (m_mixer_mode & ~0x02) | (data << 1); -} - - WRITE_LINE_MEMBER( sn76477_device::mixer_b_w ) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; + CHECK_BOOLEAN; if (state != ((m_mixer_mode >> 1) & 0x01)) { m_channel->update(); - _SN76477_mixer_b_w(state); + m_mixer_mode = (m_mixer_mode & ~0x02) | (state << 1); log_mixer_mode(); } -#endif } - -void sn76477_device::_SN76477_mixer_c_w(UINT32 data) -{ - m_mixer_mode = (m_mixer_mode & ~0x04) | (data << 2); -} - - WRITE_LINE_MEMBER( sn76477_device::mixer_c_w ) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; + CHECK_BOOLEAN; if (state != ((m_mixer_mode >> 2) & 0x01)) { m_channel->update(); - _SN76477_mixer_c_w(state); + m_mixer_mode = (m_mixer_mode & ~0x04) | (state << 2); log_mixer_mode(); } -#endif } - - /***************************************************************************** * * Set envelope select inputs * *****************************************************************************/ -void sn76477_device::_SN76477_envelope_1_w(UINT32 data) -{ - m_envelope_mode = (m_envelope_mode & ~0x01) | (data << 0); -} - - WRITE_LINE_MEMBER( sn76477_device::envelope_1_w ) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; + CHECK_BOOLEAN; if (state != ((m_envelope_mode >> 0) & 0x01)) { m_channel->update(); - _SN76477_envelope_1_w(state); + m_envelope_mode = (m_envelope_mode & ~0x01) | state; log_envelope_mode(); } -#endif } - -void sn76477_device::_SN76477_envelope_2_w(UINT32 data) -{ - m_envelope_mode = (m_envelope_mode & ~0x02) | (data << 1); -} - - WRITE_LINE_MEMBER( sn76477_device::envelope_2_w ) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; + CHECK_BOOLEAN; if (state != ((m_envelope_mode >> 1) & 0x01)) { m_channel->update(); - _SN76477_envelope_2_w(state); + m_envelope_mode = (m_envelope_mode & ~0x02) | (state << 1); log_envelope_mode(); } -#endif } - - /***************************************************************************** * * Set VCO select input * *****************************************************************************/ -void sn76477_device::_SN76477_vco_w(UINT32 data) -{ - m_vco_mode = data; -} - - WRITE_LINE_MEMBER( sn76477_device::vco_w ) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; + CHECK_BOOLEAN; if (state != m_vco_mode) { m_channel->update(); - _SN76477_vco_w(state); + m_vco_mode = state; log_vco_mode(); } -#endif } - - /***************************************************************************** * * Set one-shot resistor * *****************************************************************************/ -void sn76477_device::_SN76477_one_shot_res_w(double data) -{ - m_one_shot_res = data; -} - - void sn76477_device::one_shot_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_one_shot_res) { m_channel->update(); - _SN76477_one_shot_res_w(data); + m_one_shot_res = data; log_one_shot_time(); } -#endif } - - /***************************************************************************** * * Set one-shot capacitor * *****************************************************************************/ -void sn76477_device::_SN76477_one_shot_cap_w(double data) -{ - m_one_shot_cap = data; -} - - void sn76477_device::one_shot_cap_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_one_shot_cap) { m_channel->update(); - _SN76477_one_shot_cap_w(data); + m_one_shot_cap = data; log_one_shot_time(); } -#endif } - - /***************************************************************************** * * Set the voltage on the one-shot capacitor @@ -1233,8 +1125,7 @@ void sn76477_device::one_shot_cap_w(double data) void sn76477_device::one_shot_cap_voltage_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_CAP_VOLTAGE; + CHECK_CAP_VOLTAGE; if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT) { @@ -1261,71 +1152,48 @@ void sn76477_device::one_shot_cap_voltage_w(double data) log_one_shot_time(); } } -#endif } - - /***************************************************************************** * * Set SLF resistor * *****************************************************************************/ -void sn76477_device::_SN76477_slf_res_w(double data) -{ - m_slf_res = data; -} - - void sn76477_device::slf_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_slf_res) { m_channel->update(); - _SN76477_slf_res_w(data); + m_slf_res = data; log_slf_freq(); } -#endif } - - /***************************************************************************** * * Set SLF capacitor * *****************************************************************************/ -void sn76477_device::_SN76477_slf_cap_w(double data) -{ - m_slf_cap = data; -} - - void sn76477_device::slf_cap_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_slf_cap) { m_channel->update(); - _SN76477_slf_cap_w(data); + m_slf_cap = data; log_slf_freq(); } -#endif } - - /***************************************************************************** * * Set the voltage on the SLF capacitor @@ -1336,8 +1204,7 @@ void sn76477_device::slf_cap_w(double data) void sn76477_device::slf_cap_voltage_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_CAP_VOLTAGE; + CHECK_CAP_VOLTAGE; if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT) { @@ -1364,71 +1231,48 @@ void sn76477_device::slf_cap_voltage_w(double data) log_slf_freq(); } } -#endif } - - /***************************************************************************** * * Set VCO resistor * *****************************************************************************/ -void sn76477_device::_SN76477_vco_res_w(double data) -{ - m_vco_res = data; -} - - void sn76477_device::vco_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_vco_res) { m_channel->update(); - _SN76477_vco_res_w(data); + m_vco_res = data; log_vco_freq(); } -#endif } - - /***************************************************************************** * * Set VCO capacitor * *****************************************************************************/ -void sn76477_device::_SN76477_vco_cap_w(double data) -{ - m_vco_cap = data; -} - - void sn76477_device::vco_cap_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_vco_cap) { m_channel->update(); - _SN76477_vco_cap_w(data); + m_vco_cap = data; log_vco_freq(); } -#endif } - - /***************************************************************************** * * Set the voltage on the VCO capacitor @@ -1437,8 +1281,7 @@ void sn76477_device::vco_cap_w(double data) void sn76477_device::vco_cap_voltage_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_CAP_VOLTAGE; + CHECK_CAP_VOLTAGE; if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT) { @@ -1465,73 +1308,50 @@ void sn76477_device::vco_cap_voltage_w(double data) log_vco_freq(); } } -#endif } - - /***************************************************************************** * * Set VCO voltage * *****************************************************************************/ -void sn76477_device::_SN76477_vco_voltage_w(double data) -{ - m_vco_voltage = data; -} - - void sn76477_device::vco_voltage_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_VOLTAGE; + CHECK_VOLTAGE; if (data != m_vco_voltage) { m_channel->update(); - _SN76477_vco_voltage_w(data); + m_vco_voltage = data; log_vco_ext_voltage(); log_vco_duty_cycle(); } -#endif } - - /***************************************************************************** * * Set pitch voltage * *****************************************************************************/ -void sn76477_device::_SN76477_pitch_voltage_w(double data) -{ - m_pitch_voltage = data; -} - - void sn76477_device::pitch_voltage_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_VOLTAGE; + CHECK_VOLTAGE; if (data != m_pitch_voltage) { m_channel->update(); - _SN76477_pitch_voltage_w(data); + m_pitch_voltage = data; log_vco_pitch_voltage(); log_vco_duty_cycle(); } -#endif } - - /***************************************************************************** * * Set noise external clock @@ -1540,8 +1360,7 @@ void sn76477_device::pitch_voltage_w(double data) WRITE_LINE_MEMBER( sn76477_device::noise_clock_w ) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_BOOLEAN; + CHECK_BOOLEAN; if (state != m_noise_clock) { @@ -1556,111 +1375,78 @@ WRITE_LINE_MEMBER( sn76477_device::noise_clock_w ) m_real_noise_bit_ff = generate_next_real_noise_bit(); } } -#endif } - - /***************************************************************************** * * Set noise clock resistor * *****************************************************************************/ -void sn76477_device::_SN76477_noise_clock_res_w(double data) -{ - if (data == 0) - { - m_noise_clock_ext = 1; - } - else - { - m_noise_clock_ext = 0; - - m_noise_clock_res = data; - } -} - - void sn76477_device::noise_clock_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (((data == 0) && !m_noise_clock_ext) || ((data != 0) && (data != m_noise_clock_res))) { m_channel->update(); - _SN76477_noise_clock_res_w(data); + if (data == 0) + { + m_noise_clock_ext = 1; + } + else + { + m_noise_clock_ext = 0; + + m_noise_clock_res = data; + } log_noise_gen_freq(); } -#endif } - - /***************************************************************************** * * Set noise filter resistor * *****************************************************************************/ -void sn76477_device::_SN76477_noise_filter_res_w(double data) -{ - m_noise_filter_res = data; -} - - void sn76477_device::noise_filter_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_noise_filter_res) { m_channel->update(); - _SN76477_noise_filter_res_w(data); + m_noise_filter_res = data; log_noise_filter_freq(); } -#endif } - - /***************************************************************************** * * Set noise filter capacitor * *****************************************************************************/ -void sn76477_device::_SN76477_noise_filter_cap_w(double data) -{ - m_noise_filter_cap = data; -} - - void sn76477_device::noise_filter_cap_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_noise_filter_cap) { m_channel->update(); - _SN76477_noise_filter_cap_w(data); + m_noise_filter_cap = data; log_noise_filter_freq(); } -#endif } - - /***************************************************************************** * * Set the voltage on the noise filter capacitor @@ -1669,8 +1455,7 @@ void sn76477_device::noise_filter_cap_w(double data) void sn76477_device::noise_filter_cap_voltage_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_CAP_VOLTAGE; + CHECK_CAP_VOLTAGE; if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT) { @@ -1697,102 +1482,69 @@ void sn76477_device::noise_filter_cap_voltage_w(double data) log_noise_filter_freq(); } } -#endif } - - /***************************************************************************** * * Set attack resistor * *****************************************************************************/ -void sn76477_device::_SN76477_attack_res_w(double data) -{ - m_attack_res = data; -} - - void sn76477_device::attack_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_attack_res) { m_channel->update(); - _SN76477_attack_res_w(data); + m_attack_res = data; log_attack_time(); } -#endif } - - /***************************************************************************** * * Set decay resistor * *****************************************************************************/ -void sn76477_device::_SN76477_decay_res_w(double data) -{ - m_decay_res = data; -} - - void sn76477_device::decay_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_decay_res) { m_channel->update(); - _SN76477_decay_res_w(data); + m_decay_res = data; log_decay_time(); } -#endif } - - /***************************************************************************** * * Set attack/decay capacitor * *****************************************************************************/ -void sn76477_device::_SN76477_attack_decay_cap_w(double data) -{ - m_attack_decay_cap = data; -} - - void sn76477_device::attack_decay_cap_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_attack_decay_cap) { m_channel->update(); - _SN76477_attack_decay_cap_w(data); + m_attack_decay_cap = data; log_attack_time(); log_decay_time(); } -#endif } - - /***************************************************************************** * * Set the voltage on the attack/decay capacitor @@ -1801,8 +1553,7 @@ void sn76477_device::attack_decay_cap_w(double data) void sn76477_device::attack_decay_cap_voltage_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_CAP_VOLTAGE; + CHECK_CAP_VOLTAGE; if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT) { @@ -1831,70 +1582,48 @@ void sn76477_device::attack_decay_cap_voltage_w(double data) log_decay_time(); } } -#endif } - - /***************************************************************************** * * Set amplitude resistor * *****************************************************************************/ -void sn76477_device::_SN76477_amplitude_res_w(double data) -{ - m_amplitude_res = data; -} - - void sn76477_device::amplitude_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_amplitude_res) { m_channel->update(); - _SN76477_amplitude_res_w(data); + m_amplitude_res = data; log_voltage_out(); } -#endif } - - /***************************************************************************** * * Set feedback resistor * *****************************************************************************/ -void sn76477_device::_SN76477_feedback_res_w(double data) -{ - m_feedback_res = data; -} - - void sn76477_device::feedback_res_w(double data) { -#if TEST_MODE == 0 - CHECK_CHIP_NUM_AND_POSITIVE; + CHECK_POSITIVE; if (data != m_feedback_res) { m_channel->update(); - _SN76477_feedback_res_w(data); + m_feedback_res = data; log_voltage_out(); } -#endif } - /***************************************************************************** * * State saving @@ -1982,22 +1711,7 @@ void sn76477_device::sound_stream_update(sound_stream &stream, stream_sample_t * stream_sample_t *buffer = outputs[0]; - -#if TEST_MODE - static int recursing = 0; /* we need to prevent recursion since enable_w calls machine().input().code_pressed_once(KEYCODE_SPACE->update */ - - if () && !recursing) - { - recursing = 1; - - machine().sound().system_enable(); - SN76477_test_enable_w(!m_enable); - } - - recursing = 0; -#endif - - /* compute charging values, doing it here ensures that we always use the latest values */ + /* compute charging values, doing it here ensures that we always use the latest values */ one_shot_cap_charging_step = compute_one_shot_cap_charging_rate() / m_our_sample_rate; one_shot_cap_discharging_step = compute_one_shot_cap_discharging_rate() / m_our_sample_rate; diff --git a/src/devices/sound/sn76477.h b/src/devices/sound/sn76477.h index 6c582c74b09..849229c22d7 100644 --- a/src/devices/sound/sn76477.h +++ b/src/devices/sound/sn76477.h @@ -304,31 +304,6 @@ private: inline UINT32 generate_next_real_noise_bit(); void state_save_register(); - - void _SN76477_enable_w(UINT32 data); - void _SN76477_vco_w(UINT32 data); - void _SN76477_mixer_a_w(UINT32 data); - void _SN76477_mixer_b_w(UINT32 data); - void _SN76477_mixer_c_w(UINT32 data); - void _SN76477_envelope_1_w(UINT32 data); - void _SN76477_envelope_2_w(UINT32 data); - void _SN76477_one_shot_res_w(double data); - void _SN76477_one_shot_cap_w(double data); - void _SN76477_slf_res_w(double data); - void _SN76477_slf_cap_w(double data); - void _SN76477_vco_res_w(double data); - void _SN76477_vco_cap_w(double data); - void _SN76477_vco_voltage_w(double data); - void _SN76477_noise_clock_res_w(double data); - void _SN76477_noise_filter_res_w(double data); - void _SN76477_noise_filter_cap_w(double data); - void _SN76477_decay_res_w(double data); - void _SN76477_attack_res_w(double data); - void _SN76477_attack_decay_cap_w(double data); - void _SN76477_amplitude_res_w(double data); - void _SN76477_feedback_res_w(double data); - void _SN76477_pitch_voltage_w(double data); - void SN76477_test_enable_w(UINT32 data); }; extern const device_type SN76477; diff --git a/src/emu/device.cpp b/src/emu/device.cpp index 8400d87ddbd..c2f98dba611 100644 --- a/src/emu/device.cpp +++ b/src/emu/device.cpp @@ -84,10 +84,6 @@ device_t::~device_t() memory_region *device_t::memregion(const char *_tag) const { - // safety first - if (this == nullptr) - return nullptr; - // build a fully-qualified name and look it up return machine().memory().region(subtag(_tag).c_str()); } @@ -100,10 +96,6 @@ memory_region *device_t::memregion(const char *_tag) const memory_share *device_t::memshare(const char *_tag) const { - // safety first - if (this == nullptr) - return nullptr; - // build a fully-qualified name and look it up return machine().memory().shared(subtag(_tag).c_str()); } @@ -132,10 +124,6 @@ memory_bank *device_t::membank(const char *_tag) const ioport_port *device_t::ioport(const char *tag) const { - // safety first - if (this == nullptr) - return nullptr; - // build a fully-qualified name and look it up return machine().ioport().port(subtag(tag).c_str()); } @@ -148,10 +136,6 @@ ioport_port *device_t::ioport(const char *tag) const std::string device_t::parameter(const char *tag) const { - // safety first - if (this == nullptr) - return nullptr; - // build a fully-qualified name and look it up return machine().parameters().lookup(subtag(tag)); } diff --git a/src/emu/device.h b/src/emu/device.h index d6e0311af66..2b807d58d94 100644 --- a/src/emu/device.h +++ b/src/emu/device.h @@ -151,7 +151,7 @@ public: // owned object helpers device_t *first_subdevice() const { return m_subdevice_list.first(); } std::string subtag(const char *tag) const; - std::string siblingtag(const char *tag) const { return (this != nullptr && m_owner != nullptr) ? m_owner->subtag(tag) : std::string(tag); } + std::string siblingtag(const char *tag) const { return (m_owner != nullptr) ? m_owner->subtag(tag) : std::string(tag); } memory_region *memregion(const char *tag) const; memory_share *memshare(const char *tag) const; memory_bank *membank(const char *tag) const; @@ -589,10 +589,6 @@ private: inline device_t *device_t::subdevice(const char *tag) const { - // safety first - if (this == nullptr) - return nullptr; - // empty string or NULL means this device if (tag == nullptr || *tag == 0) return const_cast(this); @@ -610,10 +606,6 @@ inline device_t *device_t::subdevice(const char *tag) const inline device_t *device_t::siblingdevice(const char *tag) const { - // safety first - if (this == nullptr) - return nullptr; - // empty string or NULL means this device if (tag == nullptr || *tag == 0) return const_cast(this); diff --git a/src/emu/memory.h b/src/emu/memory.h index e04ac52f1b4..3b46ac33449 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -641,9 +641,7 @@ public: // getters memory_share *next() const { return m_next; } - // NOTE: this being NULL in a C++ member function can lead to undefined behavior. - // However, it is relied on throughout MAME, so will remain for now. - void *ptr() const { if (this == nullptr) return nullptr; return m_ptr; } + void *ptr() const { return m_ptr; } size_t bytes() const { return m_bytes; } endianness_t endianness() const { return m_endianness; } UINT8 bitwidth() const { return m_bitwidth; } @@ -682,9 +680,9 @@ public: // getters running_machine &machine() const { return m_machine; } memory_region *next() const { return m_next; } - UINT8 *base() { return (this != nullptr) ? &m_buffer[0] : nullptr; } - UINT8 *end() { return (this != nullptr) ? base() + m_buffer.size() : nullptr; } - UINT32 bytes() const { return (this != nullptr) ? m_buffer.size() : 0; } + UINT8 *base() { return &m_buffer[0]; } + UINT8 *end() { return base() + m_buffer.size(); } + UINT32 bytes() const { return m_buffer.size(); } const char *name() const { return m_name.c_str(); } // flag expansion diff --git a/src/emu/screen.h b/src/emu/screen.h index 31487c7d4ea..c66dc126d17 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -218,7 +218,7 @@ public: attotime time_until_vblank_end() const; attotime time_until_update() const { return (m_video_attributes & VIDEO_UPDATE_AFTER_VBLANK) ? time_until_vblank_end() : time_until_vblank_start(); } attotime scan_period() const { return attotime(0, m_scantime); } - attotime frame_period() const { return (this == nullptr) ? DEFAULT_FRAME_PERIOD : attotime(0, m_frame_period); }; + attotime frame_period() const { return attotime(0, m_frame_period); } UINT64 frame_number() const { return m_frame_number; } // updating