From 92f81361d64c720addf5d7e2528b3d1c675f65a4 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 3 Dec 2015 11:40:45 +0100 Subject: Initial conversion of core to C++14. Note that compilers are now limited to GCC 4.9.0 and up, Clang 3.4.0 and up, and VS2013 and up [Miodrag Milanovic] --- src/emu/render.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/emu/render.cpp') diff --git a/src/emu/render.cpp b/src/emu/render.cpp index a90c727e39a..712c8287a32 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -722,9 +722,9 @@ const rgb_t *render_container::bcg_lookup_table(int texformat, palette_t *palett { case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTEA16: - if (m_palclient == NULL) // if adjusted palette hasn't been created yet, create it + if (m_palclient == nullptr) // if adjusted palette hasn't been created yet, create it { - m_palclient.reset(global_alloc(palette_client(*palette))); + m_palclient = std::make_unique(*palette); m_bcglookup.resize(palette->max_index()); recompute_lookups(); } @@ -813,7 +813,7 @@ void render_container::recompute_lookups() } // recompute the palette entries - if (m_palclient != NULL) + if (m_palclient != nullptr) { palette_t &palette = m_palclient->palette(); const rgb_t *adjusted_palette = palette.entry_list_adjusted(); -- cgit v1.2.3-70-g09d2 From 91605d3f4df9b9fb1490c276053ff274fb728816 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 3 Dec 2015 18:17:25 +0100 Subject: clang-modernize part 1 (nw) --- src/devices/cpu/drccache.h | 4 +- src/devices/cpu/drcuml.h | 6 +- src/devices/cpu/mcs48/mcs48.h | 46 +- src/devices/cpu/powerpc/ppc.h | 36 +- src/devices/cpu/uml.h | 2 +- src/devices/cpu/z80/z80.h | 40 +- src/devices/cpu/z80/z80daisy.h | 2 +- src/devices/imagedev/cassette.h | 36 +- src/devices/imagedev/floppy.h | 50 +-- src/devices/machine/bcreader.h | 2 +- src/devices/machine/laserdsc.h | 12 +- src/devices/machine/ram.h | 4 +- src/devices/sound/samples.h | 20 +- src/emu/addrmap.cpp | 26 +- src/emu/addrmap.h | 4 +- src/emu/audit.cpp | 74 ++-- src/emu/audit.h | 4 +- src/emu/cheat.cpp | 140 +++--- src/emu/cheat.h | 22 +- src/emu/clifront.cpp | 134 +++--- src/emu/cliopts.cpp | 8 +- src/emu/config.cpp | 20 +- src/emu/crsshair.cpp | 28 +- src/emu/debug/debugcmd.cpp | 192 ++++----- src/emu/debug/debugcon.cpp | 14 +- src/emu/debug/debugcpu.cpp | 304 ++++++------- src/emu/debug/debugcpu.h | 24 +- src/emu/debug/debughlp.cpp | 2 +- src/emu/debug/debugvw.cpp | 28 +- src/emu/debug/debugvw.h | 2 +- src/emu/debug/dvbpoints.cpp | 6 +- src/emu/debug/dvbpoints.h | 4 +- src/emu/debug/dvdisasm.cpp | 12 +- src/emu/debug/dvdisasm.h | 8 +- src/emu/debug/dvmemory.cpp | 34 +- src/emu/debug/dvmemory.h | 8 +- src/emu/debug/dvstate.cpp | 26 +- src/emu/debug/dvstate.h | 4 +- src/emu/debug/dvtext.cpp | 2 +- src/emu/debug/dvtext.h | 4 +- src/emu/debug/dvwpoints.cpp | 6 +- src/emu/debug/dvwpoints.h | 4 +- src/emu/debug/express.cpp | 122 +++--- src/emu/debug/express.h | 10 +- src/emu/debug/textbuf.cpp | 8 +- src/emu/debugger.cpp | 4 +- src/emu/devcb.cpp | 32 +- src/emu/devcb.h | 20 +- src/emu/devdelegate.cpp | 4 +- src/emu/devdelegate.h | 8 +- src/emu/devfind.cpp | 12 +- src/emu/devfind.h | 26 +- src/emu/device.cpp | 114 ++--- src/emu/device.h | 102 ++--- src/emu/diexec.cpp | 28 +- src/emu/diexec.h | 14 +- src/emu/digfx.cpp | 38 +- src/emu/digfx.h | 12 +- src/emu/diimage.cpp | 122 +++--- src/emu/diimage.h | 18 +- src/emu/dimemory.cpp | 46 +- src/emu/dimemory.h | 16 +- src/emu/dioutput.cpp | 2 +- src/emu/dipty.cpp | 4 +- src/emu/diserial.cpp | 4 +- src/emu/diserial.h | 2 +- src/emu/dislot.cpp | 20 +- src/emu/dislot.h | 2 +- src/emu/disound.cpp | 52 +-- src/emu/disound.h | 14 +- src/emu/dispatch.h | 14 +- src/emu/distate.cpp | 30 +- src/emu/distate.h | 6 +- src/emu/divideo.cpp | 22 +- src/emu/divideo.h | 4 +- src/emu/drawgfx.cpp | 52 +-- src/emu/drawgfx.h | 2 +- src/emu/drivenum.cpp | 16 +- src/emu/drivenum.h | 2 +- src/emu/driver.cpp | 12 +- src/emu/driver.h | 14 +- src/emu/drivers/empty.cpp | 2 +- src/emu/drivers/testcpu.cpp | 10 +- src/emu/emualloc.cpp | 34 +- src/emu/emualloc.h | 6 +- src/emu/emucore.cpp | 8 +- src/emu/emucore.h | 4 +- src/emu/emuopts.cpp | 102 ++--- src/emu/emuopts.h | 2 +- src/emu/emupal.cpp | 26 +- src/emu/emupal.h | 12 +- src/emu/fileio.cpp | 108 ++--- src/emu/fileio.h | 6 +- src/emu/hash.cpp | 22 +- src/emu/hash.h | 4 +- src/emu/hashfile.cpp | 32 +- src/emu/image.cpp | 38 +- src/emu/info.cpp | 134 +++--- src/emu/inpttype.h | 46 +- src/emu/input.cpp | 122 +++--- src/emu/input.h | 12 +- src/emu/ioport.cpp | 932 ++++++++++++++++++++-------------------- src/emu/ioport.h | 16 +- src/emu/luaengine.cpp | 40 +- src/emu/luaengine.h | 4 +- src/emu/machine.cpp | 66 +-- src/emu/machine.h | 4 +- src/emu/machine/generic.cpp | 12 +- src/emu/mame.cpp | 16 +- src/emu/mconfig.cpp | 42 +- src/emu/memarray.cpp | 8 +- src/emu/memory.cpp | 362 ++++++++-------- src/emu/memory.h | 52 +-- src/emu/network.cpp | 18 +- src/emu/output.cpp | 30 +- src/emu/profiler.cpp | 8 +- src/emu/profiler.h | 2 +- src/emu/render.cpp | 266 ++++++------ src/emu/render.h | 34 +- src/emu/rendersw.inc | 36 +- src/emu/rendfont.cpp | 54 +-- src/emu/rendfont.h | 4 +- src/emu/rendlay.cpp | 126 +++--- src/emu/rendutil.cpp | 10 +- src/emu/romload.cpp | 132 +++--- src/emu/save.cpp | 46 +- src/emu/save.h | 2 +- src/emu/schedule.cpp | 116 ++--- src/emu/schedule.h | 22 +- src/emu/screen.cpp | 44 +- src/emu/screen.h | 32 +- src/emu/softlist.cpp | 242 +++++------ src/emu/softlist.h | 16 +- src/emu/sound.cpp | 106 ++--- src/emu/sound.h | 2 +- src/emu/sound/filter.cpp | 4 +- src/emu/sound/wavwrite.cpp | 4 +- src/emu/speaker.cpp | 2 +- src/emu/speaker.h | 2 +- src/emu/sprite.cpp | 10 +- src/emu/sprite.h | 8 +- src/emu/tilemap.cpp | 50 +-- src/emu/tilemap.h | 6 +- src/emu/timer.cpp | 16 +- src/emu/timer.h | 8 +- src/emu/ui/barcode.cpp | 6 +- src/emu/ui/barcode.h | 4 +- src/emu/ui/cheatopt.cpp | 16 +- src/emu/ui/cheatopt.h | 4 +- src/emu/ui/devctrl.h | 4 +- src/emu/ui/devopt.cpp | 28 +- src/emu/ui/devopt.h | 4 +- src/emu/ui/filemngr.cpp | 34 +- src/emu/ui/filemngr.h | 6 +- src/emu/ui/filesel.cpp | 112 ++--- src/emu/ui/filesel.h | 24 +- src/emu/ui/imgcntrl.cpp | 20 +- src/emu/ui/imgcntrl.h | 4 +- src/emu/ui/info.cpp | 22 +- src/emu/ui/info.h | 8 +- src/emu/ui/info_pty.cpp | 12 +- src/emu/ui/info_pty.h | 4 +- src/emu/ui/inputmap.cpp | 110 ++--- src/emu/ui/inputmap.h | 24 +- src/emu/ui/mainmenu.cpp | 66 +-- src/emu/ui/mainmenu.h | 4 +- src/emu/ui/menu.cpp | 56 +-- src/emu/ui/miscmenu.cpp | 24 +- src/emu/ui/miscmenu.h | 24 +- src/emu/ui/selgame.cpp | 34 +- src/emu/ui/selgame.h | 6 +- src/emu/ui/sliders.cpp | 18 +- src/emu/ui/sliders.h | 6 +- src/emu/ui/slotopt.cpp | 18 +- src/emu/ui/slotopt.h | 4 +- src/emu/ui/swlist.cpp | 74 ++-- src/emu/ui/swlist.h | 12 +- src/emu/ui/tapectrl.cpp | 18 +- src/emu/ui/tapectrl.h | 4 +- src/emu/ui/ui.cpp | 132 +++--- src/emu/ui/ui.h | 2 +- src/emu/ui/videoopt.cpp | 14 +- src/emu/ui/videoopt.h | 8 +- src/emu/ui/viewgfx.cpp | 10 +- src/emu/uiinput.cpp | 10 +- src/emu/validity.cpp | 94 ++-- src/emu/validity.h | 2 +- src/emu/video.cpp | 84 ++-- src/emu/video.h | 2 +- src/emu/video/vector.cpp | 4 +- src/emu/video/vector.h | 2 +- src/lib/formats/cqm_dsk.h | 16 +- src/lib/formats/d88_dsk.h | 16 +- src/lib/formats/dfi_dsk.h | 12 +- src/lib/formats/dsk_dsk.h | 12 +- src/lib/formats/hxcmfm_dsk.h | 16 +- src/lib/formats/imd_dsk.h | 12 +- src/lib/formats/ipf_dsk.h | 12 +- src/lib/formats/mfi_dsk.h | 16 +- src/lib/formats/td0_dsk.h | 14 +- src/lib/util/avhuff.cpp | 20 +- src/lib/util/avhuff.h | 8 +- src/lib/util/aviio.cpp | 124 +++--- src/lib/util/bitmap.cpp | 24 +- src/lib/util/bitmap.h | 2 +- src/lib/util/cdrom.cpp | 48 +-- src/lib/util/chd.cpp | 114 ++--- src/lib/util/chd.h | 16 +- src/lib/util/chdcd.cpp | 30 +- src/lib/util/chdcd.h | 2 +- src/lib/util/chdcodec.cpp | 80 ++-- src/lib/util/chdcodec.h | 2 +- src/lib/util/corealloc.cpp | 66 +-- src/lib/util/corefile.cpp | 52 +-- src/lib/util/corestr.cpp | 14 +- src/lib/util/coretmpl.h | 54 +-- src/lib/util/cstrpool.cpp | 12 +- src/lib/util/delegate.h | 36 +- src/lib/util/flac.cpp | 48 +-- src/lib/util/flac.h | 4 +- src/lib/util/harddisk.cpp | 12 +- src/lib/util/hashing.cpp | 16 +- src/lib/util/huffman.cpp | 4 +- src/lib/util/huffman.h | 4 +- src/lib/util/opresolv.cpp | 34 +- src/lib/util/options.cpp | 62 +-- src/lib/util/options.h | 8 +- src/lib/util/palette.cpp | 14 +- src/lib/util/png.cpp | 90 ++-- src/lib/util/pool.cpp | 66 +-- src/lib/util/tagmap.h | 31 +- src/lib/util/un7z.cpp | 48 +-- src/lib/util/unicode.cpp | 4 +- src/lib/util/unzip.cpp | 44 +- src/lib/util/vbiparse.cpp | 2 +- src/lib/util/xmlfile.cpp | 144 +++---- src/lib/util/zippath.cpp | 104 ++--- src/osd/osdcore.h | 4 +- 238 files changed, 4465 insertions(+), 4462 deletions(-) (limited to 'src/emu/render.cpp') diff --git a/src/devices/cpu/drccache.h b/src/devices/cpu/drccache.h index cf5a41e41dd..129a54e6936 100644 --- a/src/devices/cpu/drccache.h +++ b/src/devices/cpu/drccache.h @@ -53,7 +53,7 @@ public: // pointer checking bool contains_pointer(const void *ptr) const { return ((const drccodeptr)ptr >= m_near && (const drccodeptr)ptr < m_near + m_size); } bool contains_near_pointer(const void *ptr) const { return ((const drccodeptr)ptr >= m_near && (const drccodeptr)ptr < m_neartop); } - bool generating_code() const { return (m_codegen != NULL); } + bool generating_code() const { return (m_codegen != nullptr); } // memory management void flush(); @@ -65,7 +65,7 @@ public: // codegen helpers drccodeptr *begin_codegen(UINT32 reserve_bytes); drccodeptr end_codegen(); - void request_oob_codegen(drc_oob_delegate callback, void *param1 = NULL, void *param2 = NULL); + void request_oob_codegen(drc_oob_delegate callback, void *param1 = nullptr, void *param2 = nullptr); private: // largest block of code that can be generated at once diff --git a/src/devices/cpu/drcuml.h b/src/devices/cpu/drcuml.h index 10652a224cc..cb24396c655 100644 --- a/src/devices/cpu/drcuml.h +++ b/src/devices/cpu/drcuml.h @@ -189,10 +189,10 @@ public: // symbol management void symbol_add(void *base, UINT32 length, const char *name); - const char *symbol_find(void *base, UINT32 *offset = NULL); + const char *symbol_find(void *base, UINT32 *offset = nullptr); // logging - bool logging() const { return (m_umllog != NULL); } + bool logging() const { return (m_umllog != nullptr); } void log_printf(const char *format, ...) ATTR_PRINTF(2,3); void log_flush() { if (logging()) fflush(m_umllog); } bool logging_native() const { return m_beintf.logging(); } @@ -206,7 +206,7 @@ private: // construction/destruction symbol(void *base, UINT32 length, const char *name) - : m_next(NULL), + : m_next(nullptr), m_base(drccodeptr(base)), m_length(length), m_name(name) { } diff --git a/src/devices/cpu/mcs48/mcs48.h b/src/devices/cpu/mcs48/mcs48.h index a8184bcbd34..ed994d1030e 100644 --- a/src/devices/cpu/mcs48/mcs48.h +++ b/src/devices/cpu/mcs48/mcs48.h @@ -130,34 +130,34 @@ public: protected: // device-level overrides - virtual void device_start(); - virtual void device_reset(); + virtual void device_start() override; + virtual void device_reset() override; // device_execute_interface overrides - virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 15 - 1) / 15; } - virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 15); } - virtual UINT32 execute_min_cycles() const { return 1; } - virtual UINT32 execute_max_cycles() const { return 3; } - virtual UINT32 execute_input_lines() const { return 2; } - virtual UINT32 execute_default_irq_vector() const { return MCS48_INPUT_IRQ; } - virtual void execute_run(); - virtual void execute_set_input(int inputnum, int state); + virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const override { return (clocks + 15 - 1) / 15; } + virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const override { return (cycles * 15); } + virtual UINT32 execute_min_cycles() const override { return 1; } + virtual UINT32 execute_max_cycles() const override { return 3; } + virtual UINT32 execute_input_lines() const override { return 2; } + virtual UINT32 execute_default_irq_vector() const override { return MCS48_INPUT_IRQ; } + virtual void execute_run() override; + virtual void execute_set_input(int inputnum, int state) override; // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override { - return (spacenum == AS_PROGRAM) ? &m_program_config : ( (spacenum == AS_IO) ? &m_io_config : ( (spacenum == AS_DATA) ? &m_data_config : NULL ) ); + return (spacenum == AS_PROGRAM) ? &m_program_config : ( (spacenum == AS_IO) ? &m_io_config : ( (spacenum == AS_DATA) ? &m_data_config : nullptr ) ); } // device_state_interface overrides - virtual void state_import(const device_state_entry &entry); - virtual void state_export(const device_state_entry &entry); - void state_string_export(const device_state_entry &entry, std::string &str); + virtual void state_import(const device_state_entry &entry) override; + virtual void state_export(const device_state_entry &entry) override; + void state_string_export(const device_state_entry &entry, std::string &str) override; // device_disasm_interface overrides - virtual UINT32 disasm_min_opcode_bytes() const { return 1; } - virtual UINT32 disasm_max_opcode_bytes() const { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); + virtual UINT32 disasm_min_opcode_bytes() const override { return 1; } + virtual UINT32 disasm_max_opcode_bytes() const override { return 2; } + virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) override; protected: address_space_config m_program_config; @@ -487,8 +487,8 @@ public: protected: // device_execute_interface overrides - virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 30 - 1) / 30; } - virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 30); } + virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const override { return (clocks + 30 - 1) / 30; } + virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const override { return (cycles * 30); } }; class i8022_device : public mcs48_cpu_device @@ -499,8 +499,8 @@ public: protected: // device_execute_interface overrides - virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 30 - 1) / 30; } - virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 30); } + virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const override { return (clocks + 30 - 1) / 30; } + virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const override { return (cycles * 30); } }; class i8035_device : public mcs48_cpu_device @@ -599,7 +599,7 @@ public: DECLARE_WRITE8_MEMBER(upi41_master_w); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); + virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) override; TIMER_CALLBACK_MEMBER( master_callback ); }; diff --git a/src/devices/cpu/powerpc/ppc.h b/src/devices/cpu/powerpc/ppc.h index 73bcb0b470b..a683f1f5fd4 100644 --- a/src/devices/cpu/powerpc/ppc.h +++ b/src/devices/cpu/powerpc/ppc.h @@ -249,30 +249,30 @@ public: protected: // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_stop(); + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_stop() override; // device_execute_interface overrides - virtual UINT32 execute_min_cycles() const { return 1; } - virtual UINT32 execute_max_cycles() const { return 40; } - virtual UINT32 execute_input_lines() const { return 1; } - virtual void execute_run(); - virtual void execute_set_input(int inputnum, int state); + virtual UINT32 execute_min_cycles() const override { return 1; } + virtual UINT32 execute_max_cycles() const override { return 40; } + virtual UINT32 execute_input_lines() const override { return 1; } + virtual void execute_run() override; + virtual void execute_set_input(int inputnum, int state) override; // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : NULL; } - virtual bool memory_translate(address_spacenum spacenum, int intention, offs_t &address); + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override { return (spacenum == AS_PROGRAM) ? &m_program_config : nullptr; } + virtual bool memory_translate(address_spacenum spacenum, int intention, offs_t &address) override; // device_state_interface overrides - virtual void state_export(const device_state_entry &entry); - virtual void state_import(const device_state_entry &entry); - virtual void state_string_export(const device_state_entry &entry, std::string &str); + virtual void state_export(const device_state_entry &entry) override; + virtual void state_import(const device_state_entry &entry) override; + virtual void state_string_export(const device_state_entry &entry, std::string &str) override; // device_disasm_interface overrides - virtual UINT32 disasm_min_opcode_bytes() const { return 4; } - virtual UINT32 disasm_max_opcode_bytes() const { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); + virtual UINT32 disasm_min_opcode_bytes() const override { return 4; } + virtual UINT32 disasm_max_opcode_bytes() const override { return 4; } + virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) override; /* exception types */ enum @@ -770,8 +770,8 @@ public: DECLARE_WRITE8_MEMBER( ppc4xx_spu_w ); protected: - virtual UINT32 execute_input_lines() const { return 5; } - virtual void execute_set_input(int inputnum, int state); + virtual UINT32 execute_input_lines() const override { return 5; } + virtual void execute_set_input(int inputnum, int state) override; }; diff --git a/src/devices/cpu/uml.h b/src/devices/cpu/uml.h index 96960bd910e..6086320cf99 100644 --- a/src/devices/cpu/uml.h +++ b/src/devices/cpu/uml.h @@ -409,7 +409,7 @@ namespace uml void set_mapvar(int paramnum, UINT32 value) { assert(paramnum < m_numparams); assert(m_param[paramnum].is_mapvar()); m_param[paramnum] = value; } // misc - const char *disasm(std::string &str, drcuml_state *drcuml = NULL) const; + const char *disasm(std::string &str, drcuml_state *drcuml = nullptr) const; UINT8 input_flags() const; UINT8 output_flags() const; UINT8 modified_flags() const; diff --git a/src/devices/cpu/z80/z80.h b/src/devices/cpu/z80/z80.h index 40cc67222dd..679e7444435 100644 --- a/src/devices/cpu/z80/z80.h +++ b/src/devices/cpu/z80/z80.h @@ -51,29 +51,29 @@ protected: z80_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); // device-level overrides - virtual void device_start(); - virtual void device_reset(); + virtual void device_start() override; + virtual void device_reset() override; // device_execute_interface overrides - virtual UINT32 execute_min_cycles() const { return 2; } - virtual UINT32 execute_max_cycles() const { return 16; } - virtual UINT32 execute_input_lines() const { return 4; } - virtual UINT32 execute_default_irq_vector() const { return 0xff; } - virtual void execute_run(); - virtual void execute_set_input(int inputnum, int state); + virtual UINT32 execute_min_cycles() const override { return 2; } + virtual UINT32 execute_max_cycles() const override { return 16; } + virtual UINT32 execute_input_lines() const override { return 4; } + virtual UINT32 execute_default_irq_vector() const override { return 0xff; } + virtual void execute_run() override; + virtual void execute_set_input(int inputnum, int state) override; // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override; // device_state_interface overrides - virtual void state_import(const device_state_entry &entry); - virtual void state_export(const device_state_entry &entry); - virtual void state_string_export(const device_state_entry &entry, std::string &str); + virtual void state_import(const device_state_entry &entry) override; + virtual void state_export(const device_state_entry &entry) override; + virtual void state_string_export(const device_state_entry &entry, std::string &str) override; // device_disasm_interface overrides - virtual UINT32 disasm_min_opcode_bytes() const { return 1; } - virtual UINT32 disasm_max_opcode_bytes() const { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); + virtual UINT32 disasm_min_opcode_bytes() const override { return 1; } + virtual UINT32 disasm_max_opcode_bytes() const override { return 4; } + virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) override; #undef PROTOTYPES #define PROTOTYPES(prefix) \ @@ -302,13 +302,13 @@ public: protected: // device-level overrides - virtual void device_start(); - virtual void device_reset(); + virtual void device_start() override; + virtual void device_reset() override; // device_execute_interface overrides - virtual UINT32 execute_input_lines() const { return 7; } - virtual void execute_run(); - virtual void execute_set_input(int inputnum, int state); + virtual UINT32 execute_input_lines() const override { return 7; } + virtual void execute_run() override; + virtual void execute_set_input(int inputnum, int state) override; void take_interrupt_nsc800(); UINT8 m_nsc800_irq_state[4]; /* state of NSC800 restart interrupts A, B, C */ diff --git a/src/devices/cpu/z80/z80daisy.h b/src/devices/cpu/z80/z80daisy.h index b4651649a20..258df6cd017 100644 --- a/src/devices/cpu/z80/z80daisy.h +++ b/src/devices/cpu/z80/z80daisy.h @@ -64,7 +64,7 @@ public: z80_daisy_chain(); void init(device_t *cpudevice, const z80_daisy_config *daisy); - bool present() const { return (m_daisy_list != NULL); } + bool present() const { return (m_daisy_list != nullptr); } void reset(); int update_irq_state(); diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h index 188670922cc..e7edd0acef2 100644 --- a/src/devices/imagedev/cassette.h +++ b/src/devices/imagedev/cassette.h @@ -55,22 +55,22 @@ public: static void static_set_interface(device_t &device, const char *_interface) { downcast(device).m_interface = _interface; } // image-level overrides - virtual bool call_load(); - virtual bool call_create(int format_type, option_resolution *format_options); - virtual void call_unload(); - virtual void call_display(); - virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return load_software(swlist, swname, start_entry); } - - virtual iodevice_t image_type() const { return IO_CASSETTE; } - - virtual bool is_readable() const { return 1; } - virtual bool is_writeable() const { return 1; } - virtual bool is_creatable() const { return 1; } - virtual bool must_be_loaded() const { return 0; } - virtual bool is_reset_on_load() const { return 0; } - virtual const char *image_interface() const { return m_interface; } - virtual const char *file_extensions() const { return m_extension_list; } - virtual const option_guide *create_option_guide() const { return NULL; } + virtual bool call_load() override; + virtual bool call_create(int format_type, option_resolution *format_options) override; + virtual void call_unload() override; + virtual void call_display() override; + virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { return load_software(swlist, swname, start_entry); } + + virtual iodevice_t image_type() const override { return IO_CASSETTE; } + + virtual bool is_readable() const override { return 1; } + virtual bool is_writeable() const override { return 1; } + virtual bool is_creatable() const override { return 1; } + virtual bool must_be_loaded() const override { return 0; } + virtual bool is_reset_on_load() const override { return 0; } + virtual const char *image_interface() const override { return m_interface; } + virtual const char *file_extensions() const override { return m_extension_list; } + virtual const option_guide *create_option_guide() const override { return nullptr; } // specific implementation cassette_state get_state() { return m_state; } @@ -94,8 +94,8 @@ protected: void update(); // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); + virtual void device_config_complete() override; + virtual void device_start() override; private: cassette_image *m_cassette; cassette_state m_state; diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index 15b1095571f..dd1465ba6bf 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -79,20 +79,20 @@ public: void set_rpm(float rpm); // image-level overrides - virtual bool call_load(); - virtual void call_unload(); - virtual bool call_create(int format_type, option_resolution *format_options); - virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return load_software(swlist, swname, start_entry); } + virtual bool call_load() override; + virtual void call_unload() override; + virtual bool call_create(int format_type, option_resolution *format_options) override; + virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { return load_software(swlist, swname, start_entry); } virtual const char *image_interface() const = 0; - virtual iodevice_t image_type() const { return IO_FLOPPY; } - - virtual bool is_readable() const { return true; } - virtual bool is_writeable() const { return true; } - virtual bool is_creatable() const { return true; } - virtual bool must_be_loaded() const { return false; } - virtual bool is_reset_on_load() const { return false; } - virtual const char *file_extensions() const { return extension_list; } - virtual const option_guide *create_option_guide() const { return NULL; } + virtual iodevice_t image_type() const override { return IO_FLOPPY; } + + virtual bool is_readable() const override { return true; } + virtual bool is_writeable() const override { return true; } + virtual bool is_creatable() const override { return true; } + virtual bool must_be_loaded() const override { return false; } + virtual bool is_reset_on_load() const override { return false; } + virtual const char *file_extensions() const override { return extension_list; } + virtual const option_guide *create_option_guide() const override { return nullptr; } void setup_write(floppy_image_format_t *output_format); void setup_load_cb(load_cb cb); @@ -131,7 +131,7 @@ public: UINT32 get_form_factor() const; UINT32 get_variant() const; - virtual ui_menu *get_selection_menu(running_machine &machine, class render_container *container); + virtual ui_menu *get_selection_menu(running_machine &machine, class render_container *container) override; static const floppy_format_type default_floppy_formats[]; @@ -140,12 +140,12 @@ public: protected: // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + virtual void device_config_complete() override; + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; - virtual machine_config_constructor device_mconfig_additions() const; + virtual machine_config_constructor device_mconfig_additions() const override; virtual void setup_characteristics() = 0; @@ -209,7 +209,7 @@ public: ui_menu_control_floppy_image(running_machine &machine, render_container *container, device_image_interface *image); virtual ~ui_menu_control_floppy_image(); - virtual void handle(); + virtual void handle() override; protected: enum { SELECT_FORMAT = LAST_ID, SELECT_MEDIA, SELECT_RW }; @@ -219,7 +219,7 @@ protected: std::string input_filename, output_filename; void do_load_create(); - virtual void hook_load(std::string filename, bool softlist); + virtual void hook_load(std::string filename, bool softlist) override; }; @@ -283,11 +283,11 @@ public: void register_for_save_states(); protected: - void device_start(); + void device_start() override; private: // device_sound_interface overrides - void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); + void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; sound_stream* m_sound; bool m_loaded; @@ -323,8 +323,8 @@ public: void enable_sound(bool doit) { m_enable_sound = doit; } protected: - virtual void device_start(); - virtual void device_config_complete(); + virtual void device_start() override; + virtual void device_config_complete() override; private: const floppy_format_type *formats; diff --git a/src/devices/machine/bcreader.h b/src/devices/machine/bcreader.h index 23b80ddab70..ecb6908e0ae 100644 --- a/src/devices/machine/bcreader.h +++ b/src/devices/machine/bcreader.h @@ -38,7 +38,7 @@ public: protected: // device-level overrides - virtual void device_start(); + virtual void device_start() override; UINT8 m_byte_data[13]; UINT8 m_pixel_data[100]; diff --git a/src/devices/machine/laserdsc.h b/src/devices/machine/laserdsc.h index 55d4aeda1b3..0980bbb9f13 100644 --- a/src/devices/machine/laserdsc.h +++ b/src/devices/machine/laserdsc.h @@ -237,14 +237,14 @@ protected: virtual void player_overlay(bitmap_yuy16 &bitmap) = 0; // device-level overrides - virtual void device_start(); - virtual void device_stop(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - virtual void device_validity_check(validity_checker &valid) const; + virtual void device_start() override; + virtual void device_stop() override; + virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + virtual void device_validity_check(validity_checker &valid) const override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); + virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; // subclass helpers void set_audio_squelch(bool squelchleft, bool squelchright) { m_stream->update(); m_audiosquelch = (squelchleft ? 1 : 0) | (squelchright ? 2 : 0); } diff --git a/src/devices/machine/ram.h b/src/devices/machine/ram.h index c17832dff16..7d3f054895f 100644 --- a/src/devices/machine/ram.h +++ b/src/devices/machine/ram.h @@ -71,8 +71,8 @@ public: static void static_set_default_value(device_t &device, UINT8 default_value) { downcast(device).m_default_value = default_value; } protected: - virtual void device_start(void); - virtual void device_validity_check(validity_checker &valid) const; + virtual void device_start(void) override; + virtual void device_validity_check(validity_checker &valid) const override; private: // device state diff --git a/src/devices/sound/samples.h b/src/devices/sound/samples.h index 24bb4541766..f1512853a6a 100644 --- a/src/devices/sound/samples.h +++ b/src/devices/sound/samples.h @@ -85,12 +85,12 @@ protected: samples_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_post_load(); + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_post_load() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); + virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; // internal classes struct channel_t @@ -137,13 +137,13 @@ public: m_current(-1) { } // getters - const char *altbasename() const { return (m_samples.m_names != NULL && m_samples.m_names[0] != NULL && m_samples.m_names[0][0] == '*') ? &m_samples.m_names[0][1] : NULL; } + const char *altbasename() const { return (m_samples.m_names != nullptr && m_samples.m_names[0] != nullptr && m_samples.m_names[0][0] == '*') ? &m_samples.m_names[0][1] : nullptr; } // iteration const char *first() { - if (m_samples.m_names == NULL || m_samples.m_names[0] == NULL) - return NULL; + if (m_samples.m_names == nullptr || m_samples.m_names[0] == nullptr) + return nullptr; m_current = 0; if (m_samples.m_names[0][0] == '*') m_current++; @@ -152,8 +152,8 @@ public: const char *next() { - if (m_current == -1 || m_samples.m_names[m_current] == NULL) - return NULL; + if (m_current == -1 || m_samples.m_names[m_current] == nullptr) + return nullptr; return m_samples.m_names[m_current++]; } @@ -162,7 +162,7 @@ public: { int save = m_current; int result = 0; - for (const char *scan = first(); scan != NULL; scan = next()) + for (const char *scan = first(); scan != nullptr; scan = next()) result++; m_current = save; return result; diff --git a/src/emu/addrmap.cpp b/src/emu/addrmap.cpp index 0179dc0e7ac..708caf5d3ee 100644 --- a/src/emu/addrmap.cpp +++ b/src/emu/addrmap.cpp @@ -20,18 +20,18 @@ //------------------------------------------------- address_map_entry::address_map_entry(device_t &device, address_map &map, offs_t start, offs_t end) - : m_next(NULL), + : m_next(nullptr), m_map(map), m_devbase(device), m_addrstart((map.m_globalmask == 0) ? start : start & map.m_globalmask), m_addrend((map.m_globalmask == 0) ? end : end & map.m_globalmask), m_addrmirror(0), m_addrmask(0), - m_share(NULL), - m_region(NULL), + m_share(nullptr), + m_region(nullptr), m_rgnoffs(0), m_submap_bits(0), - m_memory(NULL), + m_memory(nullptr), m_bytestart(0), m_byteend(0), m_bytemirror(0), @@ -336,18 +336,18 @@ address_map::address_map(device_t &device, address_spacenum spacenum) throw emu_fatalerror("No memory address space configuration found for device '%s', space %d\n", device.tag(), spacenum); // construct the internal device map (first so it takes priority) - if (spaceconfig->m_internal_map != NULL) + if (spaceconfig->m_internal_map != nullptr) (*spaceconfig->m_internal_map)(*this, device); if (!spaceconfig->m_internal_map_delegate.isnull()) spaceconfig->m_internal_map_delegate(*this, device); // append the map provided by the owner - if (memintf->address_map(spacenum) != NULL) + if (memintf->address_map(spacenum) != nullptr) (*memintf->address_map(spacenum))(*this, *device.owner()); else { // if the owner didn't provide a map, use the default device map - if (spaceconfig->m_default_map != NULL) + if (spaceconfig->m_default_map != nullptr) (*spaceconfig->m_default_map)(*this, device); if (!spaceconfig->m_default_map_delegate.isnull()) spaceconfig->m_default_map_delegate(*this, device); @@ -386,16 +386,16 @@ address_map::address_map(const address_space &space, offs_t start, offs_t end, i address_map_entry *e; switch(m_databits) { case 8: - e = add(device, start, end, (address_map_entry8 *)NULL); + e = add(device, start, end, (address_map_entry8 *)nullptr); break; case 16: - e = add(device, start, end, (address_map_entry16 *)NULL); + e = add(device, start, end, (address_map_entry16 *)nullptr); break; case 32: - e = add(device, start, end, (address_map_entry32 *)NULL); + e = add(device, start, end, (address_map_entry32 *)nullptr); break; case 64: - e = add(device, start, end, (address_map_entry64 *)NULL); + e = add(device, start, end, (address_map_entry64 *)nullptr); break; default: throw emu_fatalerror("Trying to dynamically map a device on a space with a corrupt databits width"); @@ -485,7 +485,7 @@ address_map_entry64 *address_map::add(device_t &device, offs_t start, offs_t end void address_map::uplift_submaps(running_machine &machine, device_t &device, device_t &owner, endianness_t endian) { - address_map_entry *prev = 0; + address_map_entry *prev = nullptr; address_map_entry *entry = m_entrylist.first(); while (entry) { @@ -493,7 +493,7 @@ void address_map::uplift_submaps(running_machine &machine, device_t &device, dev { std::string tag = owner.subtag(entry->m_read.m_tag); device_t *mapdevice = machine.device(tag.c_str()); - if (mapdevice == NULL) { + if (mapdevice == nullptr) { throw emu_fatalerror("Attempted to submap a non-existent device '%s' in space %d of device '%s'\n", tag.c_str(), m_spacenum, device.basetag()); } // Grab the submap diff --git a/src/emu/addrmap.h b/src/emu/addrmap.h index 60776fadda2..0e767570b05 100644 --- a/src/emu/addrmap.h +++ b/src/emu/addrmap.h @@ -51,8 +51,8 @@ public: : m_type(AMH_NONE), m_bits(0), m_mask(0), - m_name(NULL), - m_tag(NULL) { } + m_name(nullptr), + m_tag(nullptr) { } map_handler_type m_type; // type of the handler UINT8 m_bits; // width of the handler in bits, or 0 for default diff --git a/src/emu/audit.cpp b/src/emu/audit.cpp index 758bb508db0..714fadcc32e 100644 --- a/src/emu/audit.cpp +++ b/src/emu/audit.cpp @@ -26,7 +26,7 @@ media_auditor::media_auditor(const driver_enumerator &enumerator) : m_enumerator(enumerator), m_validation(AUDIT_VALIDATE_FULL), - m_searchpath(NULL) + m_searchpath(nullptr) { } @@ -55,13 +55,13 @@ const char *driverpath = m_enumerator.config().root_device().searchpath(); // iterate over devices and regions device_iterator deviter(m_enumerator.config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { // determine the search path for this source and iterate through the regions m_searchpath = device->searchpath(); // now iterate over regions and ROMs within - for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) + for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) { // temporary hack: add the driver path & region name std::string combinedpath = std::string(device->searchpath()).append(";").append(driverpath); @@ -79,12 +79,12 @@ m_searchpath = combinedpath.c_str(); if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom)) { required++; - if (shared_device != NULL) + if (shared_device != nullptr) shared_required++; } // audit a file - audit_record *record = NULL; + audit_record *record = nullptr; if (ROMREGION_ISROMDATA(region)) record = audit_one_rom(rom); @@ -92,13 +92,13 @@ m_searchpath = combinedpath.c_str(); else if (ROMREGION_ISDISKDATA(region)) record = audit_one_disk(rom); - if (record != NULL) + if (record != nullptr) { // count the number of files that are found. - if (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && find_shared_device(*device, name, record->actual_hashes(), record->actual_length()) == NULL)) + if (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && find_shared_device(*device, name, record->actual_hashes(), record->actual_length()) == nullptr)) { found++; - if (shared_device != NULL) + if (shared_device != nullptr) shared_found++; } @@ -137,7 +137,7 @@ media_auditor::summary media_auditor::audit_device(device_t *device, const char int required = 0; // now iterate over regions and ROMs within - for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) + for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) { for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { @@ -150,7 +150,7 @@ media_auditor::summary media_auditor::audit_device(device_t *device, const char } // audit a file - audit_record *record = NULL; + audit_record *record = nullptr; if (ROMREGION_ISROMDATA(region)) record = audit_one_rom(rom); @@ -159,7 +159,7 @@ media_auditor::summary media_auditor::audit_device(device_t *device, const char record = audit_one_disk(rom); // count the number of files that are found. - if (record != NULL && (record->status() == audit_record::STATUS_GOOD || record->status() == audit_record::STATUS_FOUND_INVALID)) + if (record != nullptr && (record->status() == audit_record::STATUS_GOOD || record->status() == audit_record::STATUS_FOUND_INVALID)) { found++; } @@ -197,7 +197,7 @@ media_auditor::summary media_auditor::audit_software(const char *list_name, soft locationtag.append("%"); locationtag.append(swinfo->shortname()); locationtag.append("%"); - if (swinfo->parentname() != NULL) + if (swinfo->parentname() != nullptr) { locationtag.append(swinfo->parentname()); combinedpath.append(";").append(swinfo->parentname()).append(";").append(list_name).append(PATH_SEPARATOR).append(swinfo->parentname()); @@ -208,7 +208,7 @@ media_auditor::summary media_auditor::audit_software(const char *list_name, soft int required = 0; // now iterate over software parts - for ( software_part *part = swinfo->first_part(); part != NULL; part = part->next() ) + for ( software_part *part = swinfo->first_part(); part != nullptr; part = part->next() ) { // now iterate over regions for ( const rom_entry *region = part->romdata(); region; region = rom_next_region( region ) ) @@ -225,7 +225,7 @@ media_auditor::summary media_auditor::audit_software(const char *list_name, soft } // audit a file - audit_record *record = NULL; + audit_record *record = nullptr; if (ROMREGION_ISROMDATA(region)) { record = audit_one_rom(rom); @@ -237,7 +237,7 @@ media_auditor::summary media_auditor::audit_software(const char *list_name, soft } // count the number of files that are found. - if (record != NULL && (record->status() == audit_record::STATUS_GOOD || record->status() == audit_record::STATUS_FOUND_INVALID)) + if (record != nullptr && (record->status() == audit_record::STATUS_GOOD || record->status() == audit_record::STATUS_FOUND_INVALID)) { found++; } @@ -271,18 +271,18 @@ media_auditor::summary media_auditor::audit_samples() // iterate over sample entries samples_device_iterator iterator(m_enumerator.config().root_device()); - for (samples_device *device = iterator.first(); device != NULL; device = iterator.next()) + for (samples_device *device = iterator.first(); device != nullptr; device = iterator.next()) { // by default we just search using the driver name std::string searchpath(m_enumerator.driver().name); // add the alternate path if present samples_iterator iter(*device); - if (iter.altbasename() != NULL) + if (iter.altbasename() != nullptr) searchpath.append(";").append(iter.altbasename()); // iterate over samples in this entry - for (const char *samplename = iter.first(); samplename != NULL; samplename = iter.next()) + for (const char *samplename = iter.first(); samplename != nullptr; samplename = iter.next()) { required++; @@ -336,7 +336,7 @@ media_auditor::summary media_auditor::summarize(const char *name, std::string *o // loop over records summary overall_status = CORRECT; - for (audit_record *record = m_record_list.first(); record != NULL; record = record->next()) + for (audit_record *record = m_record_list.first(); record != nullptr; record = record->next()) { summary best_new_status = INCORRECT; @@ -345,7 +345,7 @@ media_auditor::summary media_auditor::summarize(const char *name, std::string *o continue; // output the game name, file name, and length (if applicable) - if (output != NULL) + if (output != nullptr) { strcatprintf(*output,"%-12s: %s", name, record->name()); if (record->expected_length() > 0) @@ -357,17 +357,17 @@ media_auditor::summary media_auditor::summarize(const char *name, std::string *o switch (record->substatus()) { case audit_record::SUBSTATUS_GOOD_NEEDS_REDUMP: - if (output != NULL) strcatprintf(*output,"NEEDS REDUMP\n"); + if (output != nullptr) strcatprintf(*output,"NEEDS REDUMP\n"); best_new_status = BEST_AVAILABLE; break; case audit_record::SUBSTATUS_FOUND_NODUMP: - if (output != NULL) strcatprintf(*output,"NO GOOD DUMP KNOWN\n"); + if (output != nullptr) strcatprintf(*output,"NO GOOD DUMP KNOWN\n"); best_new_status = BEST_AVAILABLE; break; case audit_record::SUBSTATUS_FOUND_BAD_CHECKSUM: - if (output != NULL) + if (output != nullptr) { std::string tempstr; strcatprintf(*output,"INCORRECT CHECKSUM:\n"); @@ -377,14 +377,14 @@ media_auditor::summary media_auditor::summarize(const char *name, std::string *o break; case audit_record::SUBSTATUS_FOUND_WRONG_LENGTH: - if (output != NULL) strcatprintf(*output,"INCORRECT LENGTH: %" I64FMT "d bytes\n", record->actual_length()); + if (output != nullptr) strcatprintf(*output,"INCORRECT LENGTH: %" I64FMT "d bytes\n", record->actual_length()); break; case audit_record::SUBSTATUS_NOT_FOUND: - if (output != NULL) + if (output != nullptr) { device_t *shared_device = record->shared_device(); - if (shared_device == NULL) + if (shared_device == nullptr) strcatprintf(*output,"NOT FOUND\n"); else strcatprintf(*output,"NOT FOUND (%s)\n", shared_device->shortname()); @@ -393,12 +393,12 @@ media_auditor::summary media_auditor::summarize(const char *name, std::string *o break; case audit_record::SUBSTATUS_NOT_FOUND_NODUMP: - if (output != NULL) strcatprintf(*output,"NOT FOUND - NO GOOD DUMP KNOWN\n"); + if (output != nullptr) strcatprintf(*output,"NOT FOUND - NO GOOD DUMP KNOWN\n"); best_new_status = BEST_AVAILABLE; break; case audit_record::SUBSTATUS_NOT_FOUND_OPTIONAL: - if (output != NULL) strcatprintf(*output,"NOT FOUND BUT OPTIONAL\n"); + if (output != nullptr) strcatprintf(*output,"NOT FOUND BUT OPTIONAL\n"); best_new_status = BEST_AVAILABLE; break; @@ -545,11 +545,11 @@ device_t *media_auditor::find_shared_device(device_t &device, const char *name, bool dumped = !romhashes.flag(hash_collection::FLAG_NO_DUMP); // special case for non-root devices - device_t *highest_device = NULL; - if (device.owner() != NULL) + device_t *highest_device = nullptr; + if (device.owner() != nullptr) { - for (const rom_entry *region = rom_first_region(device); region != NULL; region = rom_next_region(region)) - for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) + for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region)) + for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) if (ROM_GETLENGTH(rom) == romlength) { hash_collection hashes(ROM_GETHASHDATA(rom)); @@ -563,7 +563,7 @@ device_t *media_auditor::find_shared_device(device_t &device, const char *name, for (int drvindex = m_enumerator.find(m_enumerator.driver().parent); drvindex != -1; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent)) { device_iterator deviter(m_enumerator.config(drvindex).root_device()); - for (device_t *scandevice = deviter.first(); scandevice != NULL; scandevice = deviter.next()) + for (device_t *scandevice = deviter.first(); scandevice != nullptr; scandevice = deviter.next()) for (const rom_entry *region = rom_first_region(*scandevice); region; region = rom_next_region(region)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) if (ROM_GETLENGTH(rom) == romlength) @@ -584,26 +584,26 @@ device_t *media_auditor::find_shared_device(device_t &device, const char *name, //------------------------------------------------- audit_record::audit_record(const rom_entry &media, media_type type) - : m_next(NULL), + : m_next(nullptr), m_type(type), m_status(STATUS_ERROR), m_substatus(SUBSTATUS_ERROR), m_name(ROM_GETNAME(&media)), m_explength(rom_file_size(&media)), m_length(0), - m_shared_device(NULL) + m_shared_device(nullptr) { m_exphashes.from_internal_string(ROM_GETHASHDATA(&media)); } audit_record::audit_record(const char *name, media_type type) - : m_next(NULL), + : m_next(nullptr), m_type(type), m_status(STATUS_ERROR), m_substatus(SUBSTATUS_ERROR), m_name(name), m_explength(0), m_length(0), - m_shared_device(NULL) + m_shared_device(nullptr) { } diff --git a/src/emu/audit.h b/src/emu/audit.h index 5989fe5a10e..d39ecbb3a91 100644 --- a/src/emu/audit.h +++ b/src/emu/audit.h @@ -149,12 +149,12 @@ public: summary audit_device(device_t *device, const char *validation = AUDIT_VALIDATE_FULL); summary audit_software(const char *list_name, software_info *swinfo, const char *validation = AUDIT_VALIDATE_FULL); summary audit_samples(); - summary summarize(const char *name,std::string *output = NULL); + summary summarize(const char *name,std::string *output = nullptr); private: // internal helpers audit_record *audit_one_rom(const rom_entry *rom); - audit_record *audit_one_disk(const rom_entry *rom, const char *locationtag = NULL); + audit_record *audit_one_disk(const rom_entry *rom, const char *locationtag = nullptr); void compute_status(audit_record &record, const rom_entry *rom, bool found); device_t *find_shared_device(device_t &device, const char *name, const hash_collection &romhashes, UINT64 romlength); diff --git a/src/emu/cheat.cpp b/src/emu/cheat.cpp index b9bf7432770..8b1584bbd2a 100644 --- a/src/emu/cheat.cpp +++ b/src/emu/cheat.cpp @@ -145,14 +145,14 @@ cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, m_stepval = number_and_format(xml_get_attribute_int(¶mnode, "step", 1), xml_get_attribute_int_format(¶mnode, "step")); // iterate over items - for (xml_data_node *itemnode = xml_get_sibling(paramnode.child, "item"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "item")) + for (xml_data_node *itemnode = xml_get_sibling(paramnode.child, "item"); itemnode != nullptr; itemnode = xml_get_sibling(itemnode->next, "item")) { // check for NULL text - if (itemnode->value == NULL || itemnode->value[0] == 0) + if (itemnode->value == nullptr || itemnode->value[0] == 0) throw emu_fatalerror("%s.xml(%d): item is missing text\n", filename, itemnode->line); // check for non-existant value - if (xml_get_attribute(itemnode, "value") == NULL) + if (xml_get_attribute(itemnode, "value") == nullptr) throw emu_fatalerror("%s.xml(%d): item is value\n", filename, itemnode->line); // extract the parameters @@ -185,7 +185,7 @@ const char *cheat_parameter::text() else { strprintf(m_curtext, "??? (%d)", UINT32(m_value)); - for (item *curitem = m_itemlist.first(); curitem != NULL; curitem = curitem->next()) + for (item *curitem = m_itemlist.first(); curitem != nullptr; curitem = curitem->next()) if (curitem->value() == m_value) { m_curtext.assign(curitem->text()); @@ -221,7 +221,7 @@ void cheat_parameter::save(emu_file &cheatfile) const // iterate over items else { - for (const item *curitem = m_itemlist.first(); curitem != NULL; curitem = curitem->next()) + for (const item *curitem = m_itemlist.first(); curitem != nullptr; curitem = curitem->next()) cheatfile.printf("\t\t\t%s\n", curitem->value().format(str), curitem->text()); cheatfile.printf("\t\t\n"); } @@ -263,11 +263,11 @@ bool cheat_parameter::set_prev_state() // if not, we're an item cheat else { - item *curitem, *previtem = NULL; - for (curitem = m_itemlist.first(); curitem != NULL; previtem = curitem, curitem = curitem->next()) + item *curitem, *previtem = nullptr; + for (curitem = m_itemlist.first(); curitem != nullptr; previtem = curitem, curitem = curitem->next()) if (curitem->value() == m_value) break; - if (previtem != NULL) + if (previtem != nullptr) m_value = previtem->value(); } @@ -296,10 +296,10 @@ bool cheat_parameter::set_next_state() else { item *curitem; - for (curitem = m_itemlist.first(); curitem != NULL; curitem = curitem->next()) + for (curitem = m_itemlist.first(); curitem != nullptr; curitem = curitem->next()) if (curitem->value() == m_value) break; - if (curitem != NULL && curitem->next() != NULL) + if (curitem != nullptr && curitem->next() != nullptr) m_value = curitem->next()->value(); } @@ -331,7 +331,7 @@ cheat_script::cheat_script(cheat_manager &manager, symbol_table &symbols, const throw emu_fatalerror("%s.xml(%d): invalid script state '%s'\n", filename, scriptnode.line, state); // iterate over nodes within the script - for (xml_data_node *entrynode = scriptnode.child; entrynode != NULL; entrynode = entrynode->next) + for (xml_data_node *entrynode = scriptnode.child; entrynode != nullptr; entrynode = entrynode->next) { // handle action nodes if (strcmp(entrynode->name, "action") == 0) @@ -362,7 +362,7 @@ void cheat_script::execute(cheat_manager &manager, UINT64 &argindex) return; // iterate over entries - for (script_entry *entry = m_entrylist.first(); entry != NULL; entry = entry->next()) + for (script_entry *entry = m_entrylist.first(); entry != nullptr; entry = entry->next()) entry->execute(manager, argindex); } @@ -386,7 +386,7 @@ void cheat_script::save(emu_file &cheatfile) const cheatfile.printf(">\n"); // output entries - for (const script_entry *entry = m_entrylist.first(); entry != NULL; entry = entry->next()) + for (const script_entry *entry = m_entrylist.first(); entry != nullptr; entry = entry->next()) entry->save(cheatfile); // close the tag @@ -399,23 +399,23 @@ void cheat_script::save(emu_file &cheatfile) const //------------------------------------------------- cheat_script::script_entry::script_entry(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node &entrynode, bool isaction) - : m_next(NULL), + : m_next(nullptr), m_condition(&symbols), m_expression(&symbols) { - const char *expression = NULL; + const char *expression = nullptr; try { // read the condition if present - expression = xml_get_attribute_string(&entrynode, "condition", NULL); - if (expression != NULL) + expression = xml_get_attribute_string(&entrynode, "condition", nullptr); + if (expression != nullptr) m_condition.parse(expression); // if this is an action, parse the expression if (isaction) { expression = entrynode.value; - if (expression == NULL || expression[0] == 0) + if (expression == nullptr || expression[0] == 0) throw emu_fatalerror("%s.xml(%d): missing expression in action tag\n", filename, entrynode.line); m_expression.parse(expression); } @@ -424,8 +424,8 @@ cheat_script::script_entry::script_entry(cheat_manager &manager, symbol_table &s else { // extract format - const char *format = xml_get_attribute_string(&entrynode, "format", NULL); - if (format == NULL || format[0] == 0) + const char *format = xml_get_attribute_string(&entrynode, "format", nullptr); + if (format == nullptr || format[0] == 0) throw emu_fatalerror("%s.xml(%d): missing format in output tag\n", filename, entrynode.line); m_format.assign(format); @@ -442,7 +442,7 @@ cheat_script::script_entry::script_entry(cheat_manager &manager, symbol_table &s // then parse arguments int totalargs = 0; - for (xml_data_node *argnode = xml_get_sibling(entrynode.child, "argument"); argnode != NULL; argnode = xml_get_sibling(argnode->next, "argument")) + for (xml_data_node *argnode = xml_get_sibling(entrynode.child, "argument"); argnode != nullptr; argnode = xml_get_sibling(argnode->next, "argument")) { output_argument &curarg = m_arglist.append(*global_alloc(output_argument(manager, symbols, filename, *argnode))); @@ -504,7 +504,7 @@ void cheat_script::script_entry::execute(cheat_manager &manager, UINT64 &arginde // iterate over arguments and evaluate them UINT64 params[MAX_ARGUMENTS]; int curarg = 0; - for (output_argument *arg = m_arglist.first(); arg != NULL; arg = arg->next()) + for (output_argument *arg = m_arglist.first(); arg != nullptr; arg = arg->next()) curarg += arg->values(argindex, ¶ms[curarg]); // generate the astring @@ -557,7 +557,7 @@ void cheat_script::script_entry::save(emu_file &cheatfile) const else { cheatfile.printf(">\n"); - for (const output_argument *curarg = m_arglist.first(); curarg != NULL; curarg = curarg->next()) + for (const output_argument *curarg = m_arglist.first(); curarg != nullptr; curarg = curarg->next()) curarg->save(cheatfile); cheatfile.printf("\t\t\t\n"); } @@ -574,21 +574,21 @@ void cheat_script::script_entry::validate_format(const char *filename, int line) { // first count arguments int argsprovided = 0; - for (const output_argument *curarg = m_arglist.first(); curarg != NULL; curarg = curarg->next()) + for (const output_argument *curarg = m_arglist.first(); curarg != nullptr; curarg = curarg->next()) argsprovided += curarg->count(); // now scan the string for valid argument usage const char *p = strchr(m_format.c_str(), '%'); int argscounted = 0; - while (p != NULL) + while (p != nullptr) { // skip past any valid attributes p++; - while (strchr("lh0123456789.-+ #", *p) != NULL) + while (strchr("lh0123456789.-+ #", *p) != nullptr) p++; // look for a valid type - if (strchr("cdiouxX", *p) == NULL) + if (strchr("cdiouxX", *p) == nullptr) throw emu_fatalerror("%s.xml(%d): invalid format specification \"%s\"\n", filename, line, m_format.c_str()); argscounted++; @@ -609,7 +609,7 @@ void cheat_script::script_entry::validate_format(const char *filename, int line) //------------------------------------------------- cheat_script::script_entry::output_argument::output_argument(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node &argnode) - : m_next(NULL), + : m_next(nullptr), m_expression(&symbols), m_count(0) { @@ -618,7 +618,7 @@ cheat_script::script_entry::output_argument::output_argument(cheat_manager &mana // read the expression const char *expression = argnode.value; - if (expression == NULL || expression[0] == 0) + if (expression == nullptr || expression[0] == 0) throw emu_fatalerror("%s.xml(%d): missing expression in argument tag\n", filename, argnode.line); // parse it @@ -681,7 +681,7 @@ void cheat_script::script_entry::output_argument::save(emu_file &cheatfile) cons cheat_entry::cheat_entry(cheat_manager &manager, symbol_table &globaltable, const char *filename, xml_data_node &cheatnode) : m_manager(manager), - m_next(NULL), + m_next(nullptr), m_symbols(&manager.machine(), &globaltable), m_state(SCRIPT_STATE_OFF), m_numtemp(DEFAULT_TEMP_VARIABLES), @@ -699,8 +699,8 @@ cheat_entry::cheat_entry(cheat_manager &manager, symbol_table &globaltable, cons m_numtemp = tempcount; // get the description - const char *description = xml_get_attribute_string(&cheatnode, "desc", NULL); - if (description == NULL || description[0] == 0) + const char *description = xml_get_attribute_string(&cheatnode, "desc", nullptr); + if (description == nullptr || description[0] == 0) throw emu_fatalerror("%s.xml(%d): empty or missing desc attribute on cheat\n", filename, cheatnode.line); m_description = description; @@ -714,36 +714,36 @@ cheat_entry::cheat_entry(cheat_manager &manager, symbol_table &globaltable, cons // read the first comment node xml_data_node *commentnode = xml_get_sibling(cheatnode.child, "comment"); - if (commentnode != NULL) + if (commentnode != nullptr) { // set the value if not NULL - if (commentnode->value != NULL && commentnode->value[0] != 0) + if (commentnode->value != nullptr && commentnode->value[0] != 0) m_comment.assign(commentnode->value); // only one comment is kept commentnode = xml_get_sibling(commentnode->next, "comment"); - if (commentnode != NULL) + if (commentnode != nullptr) osd_printf_warning("%s.xml(%d): only one comment node is retained; ignoring additional nodes\n", filename, commentnode->line); } // read the first parameter node xml_data_node *paramnode = xml_get_sibling(cheatnode.child, "parameter"); - if (paramnode != NULL) + if (paramnode != nullptr) { // load this parameter m_parameter.reset(global_alloc(cheat_parameter(manager, m_symbols, filename, *paramnode))); // only one parameter allowed paramnode = xml_get_sibling(paramnode->next, "parameter"); - if (paramnode != NULL) + if (paramnode != nullptr) osd_printf_warning("%s.xml(%d): only one parameter node allowed; ignoring additional nodes\n", filename, paramnode->line); } // read the script nodes - for (xml_data_node *scriptnode = xml_get_sibling(cheatnode.child, "script"); scriptnode != NULL; scriptnode = xml_get_sibling(scriptnode->next, "script")) + for (xml_data_node *scriptnode = xml_get_sibling(cheatnode.child, "script"); scriptnode != nullptr; scriptnode = xml_get_sibling(scriptnode->next, "script")) { // load this entry - cheat_script *curscript = global_alloc(cheat_script(manager, m_symbols, filename, *scriptnode)); + auto curscript = global_alloc(cheat_script(manager, m_symbols, filename, *scriptnode)); // if we have a script already for this slot, it is an error std::unique_ptr &slot = script_for_state(curscript->state()); @@ -778,13 +778,13 @@ cheat_entry::~cheat_entry() void cheat_entry::save(emu_file &cheatfile) const { // determine if we have scripts - bool has_scripts = (m_off_script != NULL || m_on_script != NULL || m_run_script != NULL || m_change_script != NULL); + bool has_scripts = (m_off_script != nullptr || m_on_script != nullptr || m_run_script != nullptr || m_change_script != nullptr); // output the cheat tag cheatfile.printf("\t\n"); else { @@ -795,17 +795,17 @@ void cheat_entry::save(emu_file &cheatfile) const cheatfile.printf("\t\t\n", m_comment.c_str()); // output the parameter, if present - if (m_parameter != NULL) + if (m_parameter != nullptr) m_parameter->save(cheatfile); // output the script nodes - if (m_on_script != NULL) + if (m_on_script != nullptr) m_on_script->save(cheatfile); - if (m_off_script != NULL) + if (m_off_script != nullptr) m_off_script->save(cheatfile); - if (m_change_script != NULL) + if (m_change_script != nullptr) m_change_script->save(cheatfile); - if (m_run_script != NULL) + if (m_run_script != nullptr) m_run_script->save(cheatfile); // close the cheat tag @@ -885,7 +885,7 @@ bool cheat_entry::select_previous_state() changed = set_state(SCRIPT_STATE_OFF); // if we have a parameter, set the previous state - else if (m_parameter != NULL) + else if (m_parameter != nullptr) { // if we're at our minimum, turn off if (m_parameter->is_minimum()) @@ -924,7 +924,7 @@ bool cheat_entry::select_next_state() changed = set_state(SCRIPT_STATE_RUN); // if we have a parameter, set the next state - else if (m_parameter != NULL) + else if (m_parameter != nullptr) { // if we're off, switch on to the minimum state if (m_state == SCRIPT_STATE_OFF) @@ -981,7 +981,7 @@ void cheat_entry::menu_text(std::string &description, std::string &state, UINT32 } // if we have a value parameter, compute it - else if (m_parameter != NULL) + else if (m_parameter != nullptr) { if (m_state == SCRIPT_STATE_OFF) { @@ -1060,8 +1060,8 @@ cheat_manager::cheat_manager(running_machine &machine) // create a global symbol table m_symtable.add("frame", symbol_table::READ_ONLY, &m_framecount); - m_symtable.add("frombcd", NULL, 1, 1, execute_frombcd); - m_symtable.add("tobcd", NULL, 1, 1, execute_tobcd); + m_symtable.add("frombcd", nullptr, 1, 1, execute_frombcd); + m_symtable.add("tobcd", nullptr, 1, 1, execute_tobcd); // we rely on the debugger expression callbacks; if the debugger isn't // enabled, we must jumpstart them manually @@ -1091,7 +1091,7 @@ void cheat_manager::set_enable(bool enable) if (!m_disabled && !enable) { // iterate over running cheats and execute any OFF Scripts - for (cheat_entry *cheat = m_cheatlist.first(); cheat != NULL; cheat = cheat->next()) + for (cheat_entry *cheat = m_cheatlist.first(); cheat != nullptr; cheat = cheat->next()) if (cheat->state() == SCRIPT_STATE_RUN) cheat->execute_off_script(); machine().popmessage("Cheats Disabled"); @@ -1103,7 +1103,7 @@ void cheat_manager::set_enable(bool enable) { // iterate over running cheats and execute any ON Scripts m_disabled = false; - for (cheat_entry *cheat = m_cheatlist.first(); cheat != NULL; cheat = cheat->next()) + for (cheat_entry *cheat = m_cheatlist.first(); cheat != nullptr; cheat = cheat->next()) if (cheat->state() == SCRIPT_STATE_RUN) cheat->execute_on_script(); machine().popmessage("Cheats Enabled"); @@ -1134,13 +1134,13 @@ void cheat_manager::reload() // load the cheat file, if it's a system that has a software list then try softlist_name/shortname.xml first, // if it fails to load then try to load via crc32 - basename/crc32.xml ( eg. 01234567.xml ) image_interface_iterator iter(machine().root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) if (image->exists()) { // if we are loading through a software list, try to load softlist_name/shortname.xml // this allows the coexistence of arcade cheats with cheats for home conversions which // have the same shortname - if (image->software_entry() != NULL) + if (image->software_entry() != nullptr) { std::string filename; strprintf(filename, "%s%s%s", image->software_list_name(), PATH_SEPARATOR, image->basename()); @@ -1195,7 +1195,7 @@ bool cheat_manager::save_all(const char *filename) cheatfile.printf("\n", CHEAT_VERSION); // iterate over cheats in the list and save them - for (cheat_entry *cheat = m_cheatlist.first(); cheat != NULL; cheat = cheat->next()) + for (cheat_entry *cheat = m_cheatlist.first(); cheat != nullptr; cheat = cheat->next()) cheat->save(cheatfile); // close out the file @@ -1228,7 +1228,7 @@ void cheat_manager::render_text(render_container &container) machine().ui().draw_text_full(&container, m_output[linenum].c_str(), 0.0f, (float)linenum * machine().ui().get_line_height(), 1.0f, m_justify[linenum], WRAP_NEVER, DRAW_OPAQUE, - ARGB_WHITE, ARGB_BLACK, NULL, NULL); + ARGB_WHITE, ARGB_BLACK, nullptr, nullptr); } } @@ -1350,11 +1350,11 @@ void cheat_manager::frame_update() m_lastline = 0; m_numlines = floor(1.0f / machine().ui().get_line_height()); m_numlines = MIN(m_numlines, ARRAY_LENGTH(m_output)); - for (int linenum = 0; linenum < ARRAY_LENGTH(m_output); linenum++) - m_output[linenum].clear(); + for (auto & elem : m_output) + elem.clear(); // iterate over running cheats and execute them - for (cheat_entry *cheat = m_cheatlist.first(); cheat != NULL; cheat = cheat->next()) + for (cheat_entry *cheat = m_cheatlist.first(); cheat != nullptr; cheat = cheat->next()) cheat->frame_update(); // increment the frame counter @@ -1369,7 +1369,7 @@ void cheat_manager::frame_update() void cheat_manager::load_cheats(const char *filename) { - xml_data_node *rootnode = NULL; + xml_data_node *rootnode = nullptr; emu_file cheatfile(machine().options().cheat_path(), OPEN_FLAG_READ); try { @@ -1382,18 +1382,18 @@ void cheat_manager::load_cheats(const char *filename) osd_printf_verbose("Loading cheats file from %s\n", cheatfile.fullpath()); // read the XML file into internal data structures - xml_parse_options options = { 0 }; + xml_parse_options options = { nullptr }; xml_parse_error error; options.error = &error; rootnode = xml_file_read(cheatfile, &options); // if unable to parse the file, just bail - if (rootnode == NULL) + if (rootnode == nullptr) throw emu_fatalerror("%s.xml(%d): error parsing XML (%s)\n", filename, error.error_line, error.error_message); // find the layout node xml_data_node *mamecheatnode = xml_get_sibling(rootnode->child, "mamecheat"); - if (mamecheatnode == NULL) + if (mamecheatnode == nullptr) throw emu_fatalerror("%s.xml: missing mamecheatnode node", filename); // validate the config data version @@ -1402,15 +1402,15 @@ void cheat_manager::load_cheats(const char *filename) throw emu_fatalerror("%s.xml(%d): Invalid cheat XML file: unsupported version", filename, mamecheatnode->line); // parse all the elements - for (xml_data_node *cheatnode = xml_get_sibling(mamecheatnode->child, "cheat"); cheatnode != NULL; cheatnode = xml_get_sibling(cheatnode->next, "cheat")) + for (xml_data_node *cheatnode = xml_get_sibling(mamecheatnode->child, "cheat"); cheatnode != nullptr; cheatnode = xml_get_sibling(cheatnode->next, "cheat")) { // load this entry - cheat_entry *curcheat = global_alloc(cheat_entry(*this, m_symtable, filename, *cheatnode)); + auto curcheat = global_alloc(cheat_entry(*this, m_symtable, filename, *cheatnode)); // make sure we're not a duplicate - cheat_entry *scannode = NULL; + cheat_entry *scannode = nullptr; if (REMOVE_DUPLICATE_CHEATS) - for (scannode = m_cheatlist.first(); scannode != NULL; scannode = scannode->next()) + for (scannode = m_cheatlist.first(); scannode != nullptr; scannode = scannode->next()) if (strcmp(scannode->description(), curcheat->description()) == 0) { osd_printf_verbose("Ignoring duplicate cheat '%s' from file %s\n", curcheat->description(), cheatfile.fullpath()); @@ -1418,7 +1418,7 @@ void cheat_manager::load_cheats(const char *filename) } // add to the end of the list - if (scannode == NULL) + if (scannode == nullptr) m_cheatlist.append(*curcheat); else global_free(curcheat); @@ -1437,7 +1437,7 @@ void cheat_manager::load_cheats(const char *filename) { osd_printf_error("%s\n", err.string()); m_cheatlist.reset(); - if (rootnode != NULL) + if (rootnode != nullptr) xml_file_free(rootnode); } } diff --git a/src/emu/cheat.h b/src/emu/cheat.h index a8094b3d189..197de382cd3 100644 --- a/src/emu/cheat.h +++ b/src/emu/cheat.h @@ -97,7 +97,7 @@ private: public: // construction/destruction item(const char *text, UINT64 value, int valformat) - : m_next(NULL), + : m_next(nullptr), m_text(text), m_value(value, valformat) { } @@ -225,10 +225,10 @@ public: const char *comment() const { return m_comment.c_str(); } // script detection - bool has_run_script() const { return (m_run_script != NULL); } - bool has_on_script() const { return (m_on_script != NULL); } - bool has_off_script() const { return (m_off_script != NULL); } - bool has_change_script() const { return (m_change_script != NULL); } + bool has_run_script() const { return (m_run_script != nullptr); } + bool has_on_script() const { return (m_on_script != nullptr); } + bool has_off_script() const { return (m_off_script != nullptr); } + bool has_change_script() const { return (m_change_script != nullptr); } // script execution void execute_off_script() { if (has_off_script()) m_off_script->execute(m_manager, m_argindex); } @@ -237,12 +237,12 @@ public: void execute_change_script() { if (has_change_script()) m_change_script->execute(m_manager, m_argindex); } // cheat classification - bool is_text_only() const { return (m_parameter == NULL && !has_run_script() && !has_off_script() && !has_on_script()); } - bool is_oneshot() const { return (m_parameter == NULL && !has_run_script() && !has_off_script() && has_on_script()); } - bool is_onoff() const { return (m_parameter == NULL && (has_run_script() || (has_off_script() && has_on_script()))); } - bool is_value_parameter() const { return (m_parameter != NULL && !m_parameter->has_itemlist()); } - bool is_itemlist_parameter() const { return (m_parameter != NULL && m_parameter->has_itemlist()); } - bool is_oneshot_parameter() const { return (m_parameter != NULL && !has_run_script() && !has_off_script() && has_change_script()); } + bool is_text_only() const { return (m_parameter == nullptr && !has_run_script() && !has_off_script() && !has_on_script()); } + bool is_oneshot() const { return (m_parameter == nullptr && !has_run_script() && !has_off_script() && has_on_script()); } + bool is_onoff() const { return (m_parameter == nullptr && (has_run_script() || (has_off_script() && has_on_script()))); } + bool is_value_parameter() const { return (m_parameter != nullptr && !m_parameter->has_itemlist()); } + bool is_itemlist_parameter() const { return (m_parameter != nullptr && m_parameter->has_itemlist()); } + bool is_oneshot_parameter() const { return (m_parameter != nullptr && !has_run_script() && !has_off_script() && has_change_script()); } // actions bool activate(); diff --git a/src/emu/clifront.cpp b/src/emu/clifront.cpp index dcb557687f9..8df0df626b3 100644 --- a/src/emu/clifront.cpp +++ b/src/emu/clifront.cpp @@ -116,7 +116,7 @@ int cli_frontend::execute(int argc, char **argv) if (*(m_options.software_name()) != 0) { const game_driver *system = m_options.system(); - if (system == NULL && *(m_options.system_name()) != 0) + if (system == nullptr && *(m_options.system_name()) != 0) throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); machine_config config(*system, m_options); @@ -125,25 +125,25 @@ int cli_frontend::execute(int argc, char **argv) throw emu_fatalerror(MAMERR_FATALERROR, "Error: unknown option: %s\n", m_options.software_name()); bool found = false; - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) { software_info *swinfo = swlistdev->find(m_options.software_name()); - if (swinfo != NULL) + if (swinfo != nullptr) { // loop through all parts - for (software_part *swpart = swinfo->first_part(); swpart != NULL; swpart = swpart->next()) + for (software_part *swpart = swinfo->first_part(); swpart != nullptr; swpart = swpart->next()) { const char *mount = swpart->feature("automount"); if (swpart->is_compatible(*swlistdev)) { - if (mount == NULL || strcmp(mount,"no") != 0) + if (mount == nullptr || strcmp(mount,"no") != 0) { // search for an image device with the right interface image_interface_iterator imgiter(config.root_device()); - for (device_image_interface *image = imgiter.first(); image != NULL; image = imgiter.next()) + for (device_image_interface *image = imgiter.first(); image != nullptr; image = imgiter.next()) { const char *interface = image->image_interface(); - if (interface != NULL) + if (interface != nullptr) { if (swpart->matches_interface(interface)) { @@ -173,8 +173,8 @@ int cli_frontend::execute(int argc, char **argv) } if (!found) { - software_list_device::display_matches(config, NULL, m_options.software_name()); - throw emu_fatalerror(MAMERR_FATALERROR, NULL); + software_list_device::display_matches(config, nullptr, m_options.software_name()); + throw emu_fatalerror(MAMERR_FATALERROR, nullptr); } } @@ -182,7 +182,7 @@ int cli_frontend::execute(int argc, char **argv) if (!m_options.parse_command_line(argc, argv, option_errors)) { // if we failed, check for no command and a system name first; in that case error on the name - if (*(m_options.command()) == 0 && m_options.system() == NULL && *(m_options.system_name()) != 0) + if (*(m_options.command()) == 0 && m_options.system() == nullptr && *(m_options.system_name()) != 0) throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); // otherwise, error on the options @@ -214,7 +214,7 @@ int cli_frontend::execute(int argc, char **argv) // if we can't find it, give an appropriate error const game_driver *system = m_options.system(); - if (system == NULL && *(m_options.system_name()) != 0) + if (system == nullptr && *(m_options.system_name()) != 0) throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); // otherwise just run the game @@ -234,7 +234,7 @@ int cli_frontend::execute(int argc, char **argv) // if a game was specified, wasn't a wildcard, and our error indicates this was the // reason for failure, offer some suggestions - if (m_result == MAMERR_NO_SUCH_GAME && *(m_options.system_name()) != 0 && strchr(m_options.system_name(), '*') == NULL && m_options.system() == NULL) + if (m_result == MAMERR_NO_SUCH_GAME && *(m_options.system_name()) != 0 && strchr(m_options.system_name(), '*') == nullptr && m_options.system() == nullptr) { // get the top 16 approximate matches driver_enumerator drivlist(m_options); @@ -244,9 +244,9 @@ int cli_frontend::execute(int argc, char **argv) // print them out osd_printf_error("\n\"%s\" approximately matches the following\n" "supported %s (best match first):\n\n", m_options.system_name(),emulator_info::get_gamesnoun()); - for (int matchnum = 0; matchnum < ARRAY_LENGTH(matches); matchnum++) - if (matches[matchnum] != -1) - osd_printf_error("%-18s%s\n", drivlist.driver(matches[matchnum]).name, drivlist.driver(matches[matchnum]).description); + for (auto & matche : matches) + if (matche != -1) + osd_printf_error("%-18s%s\n", drivlist.driver(matche).name, drivlist.driver(matche).description); } } catch (emu_exception &) @@ -442,7 +442,7 @@ void cli_frontend::listcrc(const char *gamename) while (drivlist.next()) { device_iterator deviter(drivlist.config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (const rom_entry *region = rom_first_region(*device); region; region = rom_next_region(region)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { @@ -481,7 +481,7 @@ void cli_frontend::listroms(const char *gamename) // iterate through roms device_iterator deviter(drivlist.config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (const rom_entry *region = rom_first_region(*device); region; region = rom_next_region(region)) for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { @@ -546,10 +546,10 @@ void cli_frontend::listsamples(const char *gamename) osd_printf_info("Samples required for driver \"%s\".\n", drivlist.driver().name); // iterate over samples devices and print the samples from each one - for (samples_device *device = iter.first(); device != NULL; device = iter.next()) + for (samples_device *device = iter.first(); device != nullptr; device = iter.next()) { samples_iterator sampiter(*device); - for (const char *samplename = sampiter.first(); samplename != NULL; samplename = sampiter.next()) + for (const char *samplename = sampiter.first(); samplename != nullptr; samplename = sampiter.next()) osd_printf_info("%s\n", samplename); } } @@ -588,16 +588,16 @@ void cli_frontend::listdevices(const char *gamename) // build a list of devices device_iterator iter(drivlist.config().root_device()); std::vector device_list; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device_list.push_back(device); // sort them by tag qsort(&device_list[0], device_list.size(), sizeof(device_list[0]), compare_devices); // dump the results - for (unsigned int index = 0; index < device_list.size(); index++) + for (auto device : device_list) { - device_t *device = device_list[index]; + // extract the tag, stripping the leading colon const char *tag = device->tag(); @@ -661,7 +661,7 @@ void cli_frontend::listslots(const char *gamename) // iterate slot_interface_iterator iter(drivlist.config().root_device()); bool first = true; - for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next()) + for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next()) { if (slot->fixed()) continue; // output the line, up to the list of extensions @@ -670,7 +670,7 @@ void cli_frontend::listslots(const char *gamename) bool first_option = true; // get the options and print them - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) { if (option->selectable()) { @@ -722,7 +722,7 @@ void cli_frontend::listmedia(const char *gamename) // iterate image_interface_iterator iter(drivlist.config().root_device()); bool first = true; - for (const device_image_interface *imagedev = iter.first(); imagedev != NULL; imagedev = iter.next()) + for (const device_image_interface *imagedev = iter.first(); imagedev != nullptr; imagedev = iter.next()) { // extract the shortname with parentheses std::string paren_shortname; @@ -826,9 +826,9 @@ void cli_frontend::verifyroms(const char *gamename) { machine_config &config = dummy_drivlist.config(); device_iterator iter(config.root_device()); - for (device_t *dev = iter.first(); dev != NULL; dev = iter.next()) + for (device_t *dev = iter.first(); dev != nullptr; dev = iter.next()) { - if (dev->owner() != NULL && (*(dev->shortname()) != 0) && dev->rom_region() != NULL && (device_map.add(dev->shortname(), 0, false) != TMERR_DUPLICATE)) { + if (dev->owner() != nullptr && (*(dev->shortname()) != 0) && dev->rom_region() != nullptr && (device_map.add(dev->shortname(), 0, false) != TMERR_DUPLICATE)) { if (core_strwildcmp(gamename, dev->shortname()) == 0) { matched++; @@ -877,9 +877,9 @@ void cli_frontend::verifyroms(const char *gamename) } slot_interface_iterator slotiter(config.root_device()); - for (const device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next()) + for (const device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next()) { - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) { std::string temptag("_"); temptag.append(option->name()); @@ -887,7 +887,7 @@ void cli_frontend::verifyroms(const char *gamename) // notify this device and all its subdevices that they are now configured device_iterator subiter(*dev); - for (device_t *device = subiter.first(); device != NULL; device = subiter.next()) + for (device_t *device = subiter.first(); device != nullptr; device = subiter.next()) if (!device->configured()) device->config_complete(); @@ -895,7 +895,7 @@ void cli_frontend::verifyroms(const char *gamename) if (core_strwildcmp(gamename, dev->shortname()) == 0) { matched++; - if (dev->rom_region() != NULL) + if (dev->rom_region() != nullptr) { // audit the ROMs in this set media_auditor::summary summary = auditor.audit_device(dev, AUDIT_VALIDATE_FAST); @@ -1126,10 +1126,10 @@ void cli_frontend::output_single_softlist(FILE *out, software_list_device &swlis std::string tempstr; fprintf(out, "\t\n", swlistdev.list_name(), xml_normalize_string(swlistdev.description())); - for (software_info *swinfo = swlistdev.first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (software_info *swinfo = swlistdev.first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) { fprintf( out, "\t\tshortname() ); - if ( swinfo->parentname() != NULL ) + if ( swinfo->parentname() != nullptr ) fprintf( out, " cloneof=\"%s\"", swinfo->parentname() ); if ( swinfo->supported() == SOFTWARE_SUPPORTED_PARTIAL ) fprintf( out, " supported=\"partial\"" ); @@ -1140,18 +1140,18 @@ void cli_frontend::output_single_softlist(FILE *out, software_list_device &swlis fprintf( out, "\t\t\t%s\n", xml_normalize_string( swinfo->year() ) ); fprintf( out, "\t\t\t%s\n", xml_normalize_string( swinfo->publisher() ) ); - for (feature_list_item *flist = swinfo->other_info(); flist != NULL; flist = flist->next()) + for (feature_list_item *flist = swinfo->other_info(); flist != nullptr; flist = flist->next()) fprintf( out, "\t\t\t\n", flist->name(), xml_normalize_string( flist->value() ) ); - for ( software_part *part = swinfo->first_part(); part != NULL; part = part->next() ) + for ( software_part *part = swinfo->first_part(); part != nullptr; part = part->next() ) { fprintf( out, "\t\t\tname() ); - if ( part->interface() != NULL ) + if ( part->interface() != nullptr ) fprintf( out, " interface=\"%s\"", part->interface() ); fprintf( out, ">\n"); - for (feature_list_item *flist = part->featurelist(); flist != NULL; flist = flist->next()) + for (feature_list_item *flist = part->featurelist(); flist != nullptr; flist = flist->next()) fprintf( out, "\t\t\t\t\n", flist->name(), xml_normalize_string(flist->value()) ); /* TODO: display rom region information */ @@ -1261,9 +1261,9 @@ void cli_frontend::listsoftware(const char *gamename) while (drivlist.next()) { software_list_device_iterator iter(drivlist.config().root_device()); - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE) - if (swlistdev->first_software_info() != NULL) + if (swlistdev->first_software_info() != nullptr) { if (isfirst) { fprintf(out, SOFTLIST_XML_BEGIN); isfirst = false; } output_single_softlist(out, *swlistdev); @@ -1304,13 +1304,13 @@ void cli_frontend::verifysoftware(const char *gamename) matched++; software_list_device_iterator iter(drivlist.config().root_device()); - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) if (list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE) - if (swlistdev->first_software_info() != NULL) + if (swlistdev->first_software_info() != nullptr) { nrlists++; - for (software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (software_info *swinfo = swlistdev->first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) { media_auditor::summary summary = auditor.audit_software(swlistdev->list_name(), swinfo, AUDIT_VALIDATE_FAST); @@ -1392,9 +1392,9 @@ void cli_frontend::getsoftlist(const char *gamename) while (drivlist.next()) { software_list_device_iterator iter(drivlist.config().root_device()); - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (core_strwildcmp(gamename, swlistdev->list_name()) == 0 && list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE) - if (swlistdev->first_software_info() != NULL) + if (swlistdev->first_software_info() != nullptr) { if (isfirst) { fprintf( out, SOFTLIST_XML_BEGIN); isfirst = FALSE; } output_single_softlist(out, *swlistdev); @@ -1425,14 +1425,14 @@ void cli_frontend::verifysoftlist(const char *gamename) while (drivlist.next()) { software_list_device_iterator iter(drivlist.config().root_device()); - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (core_strwildcmp(gamename, swlistdev->list_name()) == 0 && list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE) - if (swlistdev->first_software_info() != NULL) + if (swlistdev->first_software_info() != nullptr) { matched++; // Get the actual software list contents - for (software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (software_info *swinfo = swlistdev->first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) { media_auditor::summary summary = auditor.audit_software(swlistdev->list_name(), swinfo, AUDIT_VALIDATE_FAST); @@ -1614,12 +1614,12 @@ void cli_frontend::execute_commands(const char *exename) }; // find the command - for (int cmdindex = 0; cmdindex < ARRAY_LENGTH(info_commands); cmdindex++) - if (strcmp(m_options.command(), info_commands[cmdindex].option) == 0) + for (auto & info_command : info_commands) + if (strcmp(m_options.command(), info_command.option) == 0) { // parse any relevant INI files before proceeding const char *sysname = m_options.system_name(); - (this->*info_commands[cmdindex].function)((sysname[0] == 0) ? "*" : sysname); + (this->*info_command.function)((sysname[0] == 0) ? "*" : sysname); return; } @@ -1685,10 +1685,10 @@ void media_identifier::identify(const char *filename) { // first try to open as a directory osd_directory *directory = osd_opendir(filename); - if (directory != NULL) + if (directory != nullptr) { // iterate over all files in the directory - for (const osd_directory_entry *entry = osd_readdir(directory); entry != NULL; entry = osd_readdir(directory)) + for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory)) if (entry->type == ENTTYPE_FILE) { std::string curfile = std::string(filename).append(PATH_SEPARATOR).append(entry->name); @@ -1703,16 +1703,16 @@ void media_identifier::identify(const char *filename) if (core_filename_ends_with(filename, ".7z")) { // first attempt to examine it as a valid _7Z file - _7z_file *_7z = NULL; + _7z_file *_7z = nullptr; _7z_error _7zerr = _7z_file_open(filename, &_7z); - if (_7zerr == _7ZERR_NONE && _7z != NULL) + if (_7zerr == _7ZERR_NONE && _7z != nullptr) { // loop over entries in the .7z, skipping empty files and directories for (int i = 0; i < _7z->db.db.NumFiles; i++) { const CSzFileItem *f = _7z->db.db.Files + i; _7z->curr_file_idx = i; - int namelen = SzArEx_GetFileNameUtf16(&_7z->db, i, NULL); + int namelen = SzArEx_GetFileNameUtf16(&_7z->db, i, nullptr); std::vector temp(namelen); dynamic_buffer temp2(namelen+1); UINT8* temp3 = &temp2[0]; @@ -1744,12 +1744,12 @@ void media_identifier::identify(const char *filename) else if (core_filename_ends_with(filename, ".zip")) { // first attempt to examine it as a valid ZIP file - zip_file *zip = NULL; + zip_file *zip = nullptr; zip_error ziperr = zip_file_open(filename, &zip); - if (ziperr == ZIPERR_NONE && zip != NULL) + if (ziperr == ZIPERR_NONE && zip != nullptr) { // loop over entries in the ZIP, skipping empty files and directories - for (const zip_file_header *entry = zip_file_first_file(zip); entry != NULL; entry = zip_file_next_file(zip)) + for (const zip_file_header *entry = zip_file_first_file(zip); entry != nullptr; entry = zip_file_next_file(zip)) if (entry->uncompressed_length != 0) { // decompress data into RAM and identify it @@ -1847,7 +1847,7 @@ void media_identifier::identify_data(const char *name, const UINT8 *data, int le if (core_filename_ends_with(name, ".jed") && jed_parse(data, length, &jed) == JEDERR_NONE) { // now determine the new data length and allocate temporary memory for it - length = jedbin_output(&jed, NULL, 0); + length = jedbin_output(&jed, nullptr, 0); tempjed.resize(length); jedbin_output(&jed, &tempjed[0], length); data = &tempjed[0]; @@ -1894,12 +1894,12 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length) { // iterate over devices, regions and files within the region */ device_iterator deviter(m_drivlist.config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { if (shortnames.add(device->shortname(), 0, FALSE) != TMERR_DUPLICATE) { - for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) - for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) + for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) + for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) { hash_collection romhashes(ROM_GETHASHDATA(rom)); if (!romhashes.flag(hash_collection::FLAG_NO_DUMP) && hashes == romhashes) @@ -1918,14 +1918,14 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length) // next iterate over softlists software_list_device_iterator iter(m_drivlist.config().root_device()); - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) { if (listnames.add(swlistdev->list_name(), 0, FALSE) != TMERR_DUPLICATE) { - for (software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) - for (software_part *part = swinfo->first_part(); part != NULL; part = part->next()) - for (const rom_entry *region = part->romdata(); region != NULL; region = rom_next_region(region)) - for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) + for (software_info *swinfo = swlistdev->first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) + for (software_part *part = swinfo->first_part(); part != nullptr; part = part->next()) + for (const rom_entry *region = part->romdata(); region != nullptr; region = rom_next_region(region)) + for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) { hash_collection romhashes(ROM_GETHASHDATA(rom)); if (hashes == romhashes) diff --git a/src/emu/cliopts.cpp b/src/emu/cliopts.cpp index cfe55972844..ba2cb33afe9 100644 --- a/src/emu/cliopts.cpp +++ b/src/emu/cliopts.cpp @@ -16,18 +16,18 @@ const options_entry cli_options::s_option_entries[] = { /* core commands */ - { NULL, NULL, OPTION_HEADER, "CORE COMMANDS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE COMMANDS" }, { CLICOMMAND_HELP ";h;?", "0", OPTION_COMMAND, "show help message" }, { CLICOMMAND_VALIDATE ";valid", "0", OPTION_COMMAND, "perform driver validation on all game drivers" }, /* configuration commands */ - { NULL, NULL, OPTION_HEADER, "CONFIGURATION COMMANDS" }, + { nullptr, nullptr, OPTION_HEADER, "CONFIGURATION COMMANDS" }, { CLICOMMAND_CREATECONFIG ";cc", "0", OPTION_COMMAND, "create the default configuration file" }, { CLICOMMAND_SHOWCONFIG ";sc", "0", OPTION_COMMAND, "display running parameters" }, { CLICOMMAND_SHOWUSAGE ";su", "0", OPTION_COMMAND, "show this help" }, /* frontend commands */ - { NULL, NULL, OPTION_HEADER, "FRONTEND COMMANDS" }, + { nullptr, nullptr, OPTION_HEADER, "FRONTEND COMMANDS" }, { CLICOMMAND_LISTXML ";lx", "0", OPTION_COMMAND, "all available info on driver in XML format" }, { CLICOMMAND_LISTFULL ";ll", "0", OPTION_COMMAND, "short name, full name" }, { CLICOMMAND_LISTSOURCE ";ls", "0", OPTION_COMMAND, "driver sourcefile" }, @@ -46,7 +46,7 @@ const options_entry cli_options::s_option_entries[] = { CLICOMMAND_VERIFYSOFTWARE ";vsoft", "0", OPTION_COMMAND, "verify known software for the system" }, { CLICOMMAND_GETSOFTLIST ";glist", "0", OPTION_COMMAND, "retrieve software list by name" }, { CLICOMMAND_VERIFYSOFTLIST ";vlist", "0", OPTION_COMMAND, "verify software list by name" }, - { NULL } + { nullptr } }; //************************************************************************** diff --git a/src/emu/config.cpp b/src/emu/config.cpp index 7eb77de9cfd..65dbea7ce38 100644 --- a/src/emu/config.cpp +++ b/src/emu/config.cpp @@ -61,7 +61,7 @@ static int config_save_xml(running_machine &machine, emu_file &file, int type); void config_init(running_machine &machine) { - typelist = NULL; + typelist = nullptr; } @@ -80,7 +80,7 @@ void config_register(running_machine &machine, const char *nodename, config_save /* allocate a new type */ newtype = auto_alloc(machine, config_type); - newtype->next = NULL; + newtype->next = nullptr; newtype->name = nodename; newtype->load = load; newtype->save = save; @@ -106,7 +106,7 @@ int config_load_settings(running_machine &machine) /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) - type->load(CONFIG_TYPE_INIT, NULL); + type->load(CONFIG_TYPE_INIT, nullptr); /* now load the controller file */ if (controller[0] != 0) @@ -136,7 +136,7 @@ int config_load_settings(running_machine &machine) /* loop over all registrants and call their final function */ for (type = typelist; type; type = type->next) - type->load(CONFIG_TYPE_FINAL, NULL); + type->load(CONFIG_TYPE_FINAL, nullptr); /* if we didn't find a saved config, return 0 so the main core knows that it */ /* is the first time the game is run and it should diplay the disclaimer. */ @@ -150,7 +150,7 @@ void config_save_settings(running_machine &machine) /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) - type->save(CONFIG_TYPE_INIT, NULL); + type->save(CONFIG_TYPE_INIT, nullptr); /* save the defaults file */ emu_file file(machine.options().cfg_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -165,7 +165,7 @@ void config_save_settings(running_machine &machine) /* loop over all registrants and call their final function */ for (type = typelist; type; type = type->next) - type->save(CONFIG_TYPE_FINAL, NULL); + type->save(CONFIG_TYPE_FINAL, nullptr); } @@ -184,7 +184,7 @@ static int config_load_xml(running_machine &machine, emu_file &file, int which_t int version, count; /* read the file */ - root = xml_file_read(file, NULL); + root = xml_file_read(file, nullptr); if (!root) goto error; @@ -288,13 +288,13 @@ static int config_save_xml(running_machine &machine, emu_file &file, int which_t return 0; /* create a config node */ - confignode = xml_add_child(root, "mameconfig", NULL); + confignode = xml_add_child(root, "mameconfig", nullptr); if (!confignode) goto error; xml_set_attribute_int(confignode, "version", CONFIG_VERSION); /* create a system node */ - systemnode = xml_add_child(confignode, "system", NULL); + systemnode = xml_add_child(confignode, "system", nullptr); if (!systemnode) goto error; xml_set_attribute(systemnode, "name", (which_type == CONFIG_TYPE_DEFAULT) ? "default" : machine.system().name); @@ -303,7 +303,7 @@ static int config_save_xml(running_machine &machine, emu_file &file, int which_t /* loop over all registrants and call their save function */ for (type = typelist; type; type = type->next) { - xml_data_node *curnode = xml_add_child(systemnode, type->name, NULL); + xml_data_node *curnode = xml_add_child(systemnode, type->name, nullptr); if (!curnode) goto error; type->save(which_type, curnode); diff --git a/src/emu/crsshair.cpp b/src/emu/crsshair.cpp index 8244d7692d5..88cfb8dac02 100644 --- a/src/emu/crsshair.cpp +++ b/src/emu/crsshair.cpp @@ -152,7 +152,7 @@ static void create_bitmap(running_machine &machine, int player) rgb_t color = crosshair_colors[player]; /* if we have a bitmap and texture for this player, kill it */ - if (global.bitmap[player] == NULL) { + if (global.bitmap[player] == nullptr) { global.bitmap[player] = global_alloc(bitmap_argb32); global.texture[player] = machine.render().texture_alloc(render_texture::hq_scale); } @@ -162,7 +162,7 @@ static void create_bitmap(running_machine &machine, int player) { /* look for user specified file */ sprintf(filename, "%s.png", global.name[player]); - render_load_png(*global.bitmap[player], crossfile, NULL, filename); + render_load_png(*global.bitmap[player], crossfile, nullptr, filename); } else { @@ -172,7 +172,7 @@ static void create_bitmap(running_machine &machine, int player) /* look for default cross?.png in crsshair dir */ if (!global.bitmap[player]->valid()) - render_load_png(*global.bitmap[player], crossfile, NULL, filename); + render_load_png(*global.bitmap[player], crossfile, nullptr, filename); } /* if that didn't work, use the built-in one */ @@ -218,8 +218,8 @@ void crosshair_init(running_machine &machine) global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; /* determine who needs crosshairs */ - for (ioport_port *port = machine.ioport().first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = machine.ioport().first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->crosshair_axis() != CROSSHAIR_AXIS_NONE) { int player = field->player(); @@ -243,7 +243,7 @@ void crosshair_init(running_machine &machine) config_register(machine, "crosshairs", config_saveload_delegate(FUNC(crosshair_load), &machine), config_saveload_delegate(FUNC(crosshair_save), &machine)); /* register the animation callback */ - if (machine.first_screen() != NULL) + if (machine.first_screen() != nullptr) machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(animate), &machine)); } @@ -259,10 +259,10 @@ static void crosshair_exit(running_machine &machine) for (int player = 0; player < MAX_PLAYERS; player++) { machine.render().texture_free(global.texture[player]); - global.texture[player] = NULL; + global.texture[player] = nullptr; global_free(global.bitmap[player]); - global.bitmap[player] = NULL; + global.bitmap[player] = nullptr; } } @@ -424,7 +424,7 @@ static void crosshair_load(running_machine &machine, int config_type, xml_data_n return; /* might not have any data */ - if (parentnode == NULL) + if (parentnode == nullptr) return; /* loop and get player crosshair info */ @@ -457,7 +457,7 @@ static void crosshair_load(running_machine &machine, int config_type, xml_data_n /* get, check, and store auto visibility time */ crosshairnode = xml_get_sibling(parentnode->child, "autotime"); - if (crosshairnode != NULL) + if (crosshairnode != nullptr) { auto_time = xml_get_attribute_int(crosshairnode, "val", CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT); if ((auto_time >= CROSSHAIR_VISIBILITY_AUTOTIME_MIN) && (auto_time <= CROSSHAIR_VISIBILITY_AUTOTIME_MAX)) @@ -487,9 +487,9 @@ static void crosshair_save(running_machine &machine, int config_type, xml_data_n if (global.used[player]) { /* create a node */ - crosshairnode = xml_add_child(parentnode, "crosshair", NULL); + crosshairnode = xml_add_child(parentnode, "crosshair", nullptr); - if (crosshairnode != NULL) + if (crosshairnode != nullptr) { int changed = FALSE; @@ -519,9 +519,9 @@ static void crosshair_save(running_machine &machine, int config_type, xml_data_n if (global.auto_time != CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT) { /* create a node */ - crosshairnode = xml_add_child(parentnode, "autotime", NULL); + crosshairnode = xml_add_child(parentnode, "autotime", nullptr); - if (crosshairnode != NULL) + if (crosshairnode != nullptr) xml_set_attribute_int(crosshairnode, "val", global.auto_time); } diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 60b25df1928..08eec1307bd 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -170,7 +170,7 @@ static void execute_dumpkbd(running_machine &machine, int ref, int params, const INLINE int cheat_address_is_valid(address_space &space, offs_t address) { - return debug_cpu_translate(space, TRANSLATE_READ, &address) && (space.get_write_ptr(address) != NULL); + return debug_cpu_translate(space, TRANSLATE_READ, &address) && (space.get_write_ptr(address) != nullptr); } @@ -240,9 +240,9 @@ void debug_command_init(running_machine &machine) int itemnum; /* add a few simple global functions */ - symtable->add("min", NULL, 2, 2, execute_min); - symtable->add("max", NULL, 2, 2, execute_max); - symtable->add("if", NULL, 3, 3, execute_if); + symtable->add("min", nullptr, 2, 2, execute_min); + symtable->add("max", nullptr, 2, 2, execute_max); + symtable->add("if", nullptr, 3, 3, execute_if); /* add all single-entry save state globals */ for (itemnum = 0; itemnum < MAX_GLOBALS; itemnum++) @@ -252,7 +252,7 @@ void debug_command_init(running_machine &machine) /* stop when we run out of items */ name = machine.save().indexed_item(itemnum, base, valsize, valcount); - if (name == NULL) + if (name == nullptr) break; /* if this is a single-entry global, add it */ @@ -510,7 +510,7 @@ static void global_set(symbol_table &table, void *ref, UINT64 value) int debug_command_parameter_number(running_machine &machine, const char *param, UINT64 *result) { /* NULL parameter does nothing and returns no error */ - if (param == NULL) + if (param == nullptr) return TRUE; /* evaluate the expression; success if no error */ @@ -540,10 +540,10 @@ int debug_command_parameter_cpu(running_machine &machine, const char *param, dev UINT64 cpunum; /* if no parameter, use the visible CPU */ - if (param == NULL) + if (param == nullptr) { *result = debug_cpu_get_visible_cpu(machine); - if (*result == NULL) + if (*result == nullptr) { debug_console_printf(machine, "No valid CPU is currently selected\n"); return FALSE; @@ -553,7 +553,7 @@ int debug_command_parameter_cpu(running_machine &machine, const char *param, dev /* first look for a tag match */ *result = machine.device(param); - if (*result != NULL) + if (*result != nullptr) return TRUE; /* then evaluate as an expression; on an error assume it was a tag */ @@ -570,7 +570,7 @@ int debug_command_parameter_cpu(running_machine &machine, const char *param, dev /* if we got a valid one, return */ const UINT64 original_cpunum = cpunum; execute_interface_iterator iter(machine.root_device()); - for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next()) + for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) { if (cpunum-- == 0) { @@ -618,7 +618,7 @@ int debug_command_parameter_cpu_space(running_machine &machine, const char *para static int debug_command_parameter_expression(running_machine &machine, const char *param, parsed_expression &result) { /* NULL parameter does nothing and returns no error */ - if (param == NULL) + if (param == nullptr) return TRUE; /* parse the expression; success if no error */ @@ -648,7 +648,7 @@ static int debug_command_parameter_command(running_machine &machine, const char CMDERR err; /* NULL parameter does nothing and returns no error */ - if (param == NULL) + if (param == nullptr) return TRUE; /* validate the comment; success if no error */ @@ -1009,7 +1009,7 @@ static void execute_focus(running_machine &machine, int ref, int params, const c /* then loop over CPUs and set the ignore flags on all other CPUs */ execute_interface_iterator iter(machine.root_device()); - for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next()) + for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) if (&exec->device() != cpu) exec->device().debug()->ignore(true); debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag()); @@ -1029,7 +1029,7 @@ static void execute_ignore(running_machine &machine, int ref, int params, const /* loop over all executable devices */ execute_interface_iterator iter(machine.root_device()); - for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next()) + for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) /* build up a comma-separated list */ if (!exec->device().debug()->observing()) @@ -1062,7 +1062,7 @@ static void execute_ignore(running_machine &machine, int ref, int params, const /* make sure this isn't the last live CPU */ execute_interface_iterator iter(machine.root_device()); bool gotone = false; - for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next()) + for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) if (&exec->device() != devicelist[paramnum] && exec->device().debug()->observing()) { gotone = true; @@ -1094,7 +1094,7 @@ static void execute_observe(running_machine &machine, int ref, int params, const /* loop over all executable devices */ execute_interface_iterator iter(machine.root_device()); - for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next()) + for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) /* build up a comma-separated list */ if (exec->device().debug()->observing()) @@ -1145,7 +1145,7 @@ static void execute_comment(running_machine &machine, int ref, int params, const return; /* CPU parameter is implicit */ - if (!debug_command_parameter_cpu(machine, NULL, &cpu)) + if (!debug_command_parameter_cpu(machine, nullptr, &cpu)) return; /* make sure param 2 exists */ @@ -1175,7 +1175,7 @@ static void execute_comment_del(running_machine &machine, int ref, int params, c return; /* CPU parameter is implicit */ - if (!debug_command_parameter_cpu(machine, NULL, &cpu)) + if (!debug_command_parameter_cpu(machine, nullptr, &cpu)) return; /* If it's a number, it must be an address */ @@ -1206,12 +1206,12 @@ static void execute_comment_save(running_machine &machine, int ref, int params, static void execute_bpset(running_machine &machine, int ref, int params, const char *param[]) { device_t *cpu; - const char *action = NULL; + const char *action = nullptr; UINT64 address; int bpnum; /* CPU is implicit */ - if (!debug_command_parameter_cpu(machine, NULL, &cpu)) + if (!debug_command_parameter_cpu(machine, nullptr, &cpu)) return; /* param 1 is the address */ @@ -1228,7 +1228,7 @@ static void execute_bpset(running_machine &machine, int ref, int params, const c return; /* set the breakpoint */ - bpnum = cpu->debug()->breakpoint_set(address, (condition.is_empty()) ? NULL : condition.original_string(), action); + bpnum = cpu->debug()->breakpoint_set(address, (condition.is_empty()) ? nullptr : condition.original_string(), action); debug_console_printf(machine, "Breakpoint %X set\n", bpnum); } @@ -1246,7 +1246,7 @@ static void execute_bpclear(running_machine &machine, int ref, int params, const if (params == 0) { device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->debug()->breakpoint_clear_all(); debug_console_printf(machine, "Cleared all breakpoints\n"); } @@ -1258,7 +1258,7 @@ static void execute_bpclear(running_machine &machine, int ref, int params, const { device_iterator iter(machine.root_device()); bool found = false; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug()->breakpoint_clear(bpindex)) found = true; if (found) @@ -1282,7 +1282,7 @@ static void execute_bpdisenable(running_machine &machine, int ref, int params, c if (params == 0) { device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->debug()->breakpoint_enable_all(ref); if (ref == 0) debug_console_printf(machine, "Disabled all breakpoints\n"); @@ -1297,7 +1297,7 @@ static void execute_bpdisenable(running_machine &machine, int ref, int params, c { device_iterator iter(machine.root_device()); bool found = false; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug()->breakpoint_enable(bpindex, ref)) found = true; if (found) @@ -1320,13 +1320,13 @@ static void execute_bplist(running_machine &machine, int ref, int params, const /* loop over all CPUs */ device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) - if (device->debug()->breakpoint_first() != NULL) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) + if (device->debug()->breakpoint_first() != nullptr) { debug_console_printf(machine, "Device '%s' breakpoints:\n", device->tag()); /* loop over the breakpoints */ - for (device_debug::breakpoint *bp = device->debug()->breakpoint_first(); bp != NULL; bp = bp->next()) + for (device_debug::breakpoint *bp = device->debug()->breakpoint_first(); bp != nullptr; bp = bp->next()) { strprintf(buffer, "%c%4X @ %s", bp->enabled() ? ' ' : 'D', bp->index(), core_i64_hex_format(bp->address(), device->debug()->logaddrchars())); if (std::string(bp->condition()).compare("1") != 0) @@ -1351,13 +1351,13 @@ static void execute_bplist(running_machine &machine, int ref, int params, const static void execute_wpset(running_machine &machine, int ref, int params, const char *param[]) { address_space *space; - const char *action = NULL; + const char *action = nullptr; UINT64 address, length; int type; int wpnum; /* CPU is implicit */ - if (!debug_command_parameter_cpu_space(machine, NULL, ref, space)) + if (!debug_command_parameter_cpu_space(machine, nullptr, ref, space)) return; /* param 1 is the address */ @@ -1391,7 +1391,7 @@ static void execute_wpset(running_machine &machine, int ref, int params, const c return; /* set the watchpoint */ - wpnum = space->device().debug()->watchpoint_set(*space, type, address, length, (condition.is_empty()) ? NULL : condition.original_string(), action); + wpnum = space->device().debug()->watchpoint_set(*space, type, address, length, (condition.is_empty()) ? nullptr : condition.original_string(), action); debug_console_printf(machine, "Watchpoint %X set\n", wpnum); } @@ -1409,7 +1409,7 @@ static void execute_wpclear(running_machine &machine, int ref, int params, const if (params == 0) { device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->debug()->watchpoint_clear_all(); debug_console_printf(machine, "Cleared all watchpoints\n"); } @@ -1421,7 +1421,7 @@ static void execute_wpclear(running_machine &machine, int ref, int params, const { device_iterator iter(machine.root_device()); bool found = false; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug()->watchpoint_clear(wpindex)) found = true; if (found) @@ -1445,7 +1445,7 @@ static void execute_wpdisenable(running_machine &machine, int ref, int params, c if (params == 0) { device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->debug()->watchpoint_enable_all(ref); if (ref == 0) debug_console_printf(machine, "Disabled all watchpoints\n"); @@ -1460,7 +1460,7 @@ static void execute_wpdisenable(running_machine &machine, int ref, int params, c { device_iterator iter(machine.root_device()); bool found = false; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug()->watchpoint_enable(wpindex, ref)) found = true; if (found) @@ -1483,9 +1483,9 @@ static void execute_wplist(running_machine &machine, int ref, int params, const /* loop over all CPUs */ device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) - if (device->debug()->watchpoint_first(spacenum) != NULL) + if (device->debug()->watchpoint_first(spacenum) != nullptr) { static const char *const types[] = { "unkn ", "read ", "write", "r/w " }; @@ -1493,7 +1493,7 @@ static void execute_wplist(running_machine &machine, int ref, int params, const device->debug()->watchpoint_first(spacenum)->space().name()); /* loop over the watchpoints */ - for (device_debug::watchpoint *wp = device->debug()->watchpoint_first(spacenum); wp != NULL; wp = wp->next()) + for (device_debug::watchpoint *wp = device->debug()->watchpoint_first(spacenum); wp != nullptr; wp = wp->next()) { strprintf(buffer, "%c%4X @ %s-%s %s", wp->enabled() ? ' ' : 'D', wp->index(), core_i64_hex_format(wp->space().byte_to_address(wp->address()), wp->space().addrchars()), @@ -1521,11 +1521,11 @@ static void execute_wplist(running_machine &machine, int ref, int params, const static void execute_rpset(running_machine &machine, int ref, int params, const char *param[]) { device_t *cpu; - const char *action = NULL; + const char *action = nullptr; int bpnum; /* CPU is implicit */ - if (!debug_command_parameter_cpu(machine, NULL, &cpu)) + if (!debug_command_parameter_cpu(machine, nullptr, &cpu)) return; /* param 1 is the condition */ @@ -1556,7 +1556,7 @@ static void execute_rpclear(running_machine &machine, int ref, int params, const if (params == 0) { device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->debug()->registerpoint_clear_all(); debug_console_printf(machine, "Cleared all registerpoints\n"); } @@ -1568,7 +1568,7 @@ static void execute_rpclear(running_machine &machine, int ref, int params, const { device_iterator iter(machine.root_device()); bool found = false; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug()->registerpoint_clear(rpindex)) found = true; if (found) @@ -1592,7 +1592,7 @@ static void execute_rpdisenable(running_machine &machine, int ref, int params, c if (params == 0) { device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->debug()->registerpoint_enable_all(ref); if (ref == 0) debug_console_printf(machine, "Disabled all registerpoints\n"); @@ -1607,7 +1607,7 @@ static void execute_rpdisenable(running_machine &machine, int ref, int params, c { device_iterator iter(machine.root_device()); bool found = false; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug()->registerpoint_enable(rpindex, ref)) found = true; if (found) @@ -1630,17 +1630,17 @@ static void execute_rplist(running_machine &machine, int ref, int params, const /* loop over all CPUs */ device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) - if (device->debug()->registerpoint_first() != NULL) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) + if (device->debug()->registerpoint_first() != nullptr) { debug_console_printf(machine, "Device '%s' registerpoints:\n", device->tag()); /* loop over the breakpoints */ - for (device_debug::registerpoint *rp = device->debug()->registerpoint_first(); rp != NULL; rp = rp->next()) + for (device_debug::registerpoint *rp = device->debug()->registerpoint_first(); rp != nullptr; rp = rp->next()) { strprintf(buffer, "%c%4X ", rp->enabled() ? ' ' : 'D', rp->index()); strcatprintf(buffer, "if %s", rp->condition()); - if (rp->action() != NULL) + if (rp->action() != nullptr) strcatprintf(buffer, " do %s", rp->action()); debug_console_printf(machine, "%s\n", buffer.c_str()); printed++; @@ -1666,7 +1666,7 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const /* loop over CPUs and find live spots */ device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug()->hotspot_tracking_enabled()) { device->debug()->hotspot_track(0, 0); @@ -1680,8 +1680,8 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const } /* extract parameters */ - device_t *device = NULL; - if (!debug_command_parameter_cpu(machine, (params > 0) ? param[0] : NULL, &device)) + device_t *device = nullptr; + if (!debug_command_parameter_cpu(machine, (params > 0) ? param[0] : nullptr, &device)) return; UINT64 count = 64; if (!debug_command_parameter_number(machine, param[1], &count)) @@ -1719,7 +1719,7 @@ static void execute_stateload(running_machine &machine, int ref, int params, con // Clear all PC & memory tracks device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) { device->debug()->track_pc_data_clear(); device->debug()->track_mem_data_clear(); @@ -1744,7 +1744,7 @@ static void execute_save(running_machine &machine, int ref, int params, const ch return; if (!debug_command_parameter_number(machine, param[2], &length)) return; - if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : NULL, ref, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : nullptr, ref, space)) return; /* determine the addresses to write */ @@ -1788,7 +1788,7 @@ static void execute_load(running_machine &machine, int ref, int params, const ch return; if (!debug_command_parameter_number(machine, param[2], &length)) return; - if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : NULL, ref, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : nullptr, ref, space)) return; /* determine the addresses to read */ @@ -1842,7 +1842,7 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch return; if (!debug_command_parameter_number(machine, param[4], &ascii)) return; - if (!debug_command_parameter_cpu_space(machine, (params > 5) ? param[5] : NULL, ref, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 5) ? param[5] : nullptr, ref, space)) return; /* further validation */ @@ -1938,7 +1938,7 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con memset(cheat_region, 0, sizeof(cheat_region)); /* validate parameters */ - if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : NULL, AS_PROGRAM, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : nullptr, AS_PROGRAM, space)) return; if (ref == 0) @@ -1984,7 +1984,7 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con /* initialize entire memory by default */ if (params <= 1) { - for (entry = space->map()->m_entrylist.first(); entry != NULL; entry = entry->next()) + for (entry = space->map()->m_entrylist.first(); entry != nullptr; entry = entry->next()) { cheat_region[region_count].offset = space->address_to_byte(entry->m_addrstart) & space->bytemask(); cheat_region[region_count].endoffset = space->address_to_byte(entry->m_addrend) & space->bytemask(); @@ -1992,9 +1992,9 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con cheat_region[region_count].disabled = (entry->m_write.m_type == AMH_RAM) ? FALSE : TRUE; /* disable double share regions */ - if (entry->m_share != NULL) + if (entry->m_share != nullptr) for (i = 0; i < region_count; i++) - if (cheat_region[i].share != NULL) + if (cheat_region[i].share != nullptr) if (strcmp(cheat_region[i].share, entry->m_share) == 0) cheat_region[region_count].disabled = TRUE; @@ -2012,7 +2012,7 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con /* force region to the specified range */ cheat_region[region_count].offset = space->address_to_byte(offset) & space->bytemask(); cheat_region[region_count].endoffset = space->address_to_byte(offset + length - 1) & space->bytemask(); - cheat_region[region_count].share = NULL; + cheat_region[region_count].share = nullptr; cheat_region[region_count].disabled = FALSE; region_count++; } @@ -2068,7 +2068,7 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con } /* give a detailed init message to avoid searches being mistakingly carried out on the wrong CPU */ - device_t *cpu = NULL; + device_t *cpu = nullptr; debug_command_parameter_cpu(machine, cheat.cpu, &cpu); debug_console_printf(machine, "%u cheat initialized for CPU index %s ( aka %s )\n", active_cheat, cheat.cpu, cpu->tag()); } @@ -2245,7 +2245,7 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con } if (active_cheat <= 5) - execute_cheatlist(machine, 0, 0, NULL); + execute_cheatlist(machine, 0, 0, nullptr); debug_console_printf(machine, "%u cheats found\n", active_cheat); } @@ -2263,7 +2263,7 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con UINT32 active_cheat = 0; UINT64 cheatindex; UINT64 sizemask; - FILE *f = NULL; + FILE *f = nullptr; if (!debug_command_parameter_cpu_space(machine, cheat.cpu, AS_PROGRAM, space)) return; @@ -2366,7 +2366,7 @@ static void execute_find(running_machine &machine, int ref, int params, const ch return; if (!debug_command_parameter_number(machine, param[1], &length)) return; - if (!debug_command_parameter_cpu_space(machine, NULL, ref, space)) + if (!debug_command_parameter_cpu_space(machine, nullptr, ref, space)) return; /* further validation */ @@ -2464,9 +2464,9 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch return; if (!debug_command_parameter_number(machine, param[3], &bytes)) return; - if (!debug_command_parameter_cpu_space(machine, (params > 4) ? param[4] : NULL, AS_PROGRAM, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 4) ? param[4] : nullptr, AS_PROGRAM, space)) return; - if (!debug_command_parameter_cpu_space(machine, (params > 4) ? param[4] : NULL, AS_DECRYPTED_OPCODES, decrypted_space)) + if (!debug_command_parameter_cpu_space(machine, (params > 4) ? param[4] : nullptr, AS_DECRYPTED_OPCODES, decrypted_space)) decrypted_space = space; /* determine the width of the bytes */ @@ -2535,7 +2535,7 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch /* attempt to add the comment */ comment = space->device().debug()->comment_text(tempaddr); - if (comment != NULL) + if (comment != nullptr) { /* somewhat arbitrary guess as to how long most disassembly lines will be [column 60] */ if (strlen(output) < 60) @@ -2568,9 +2568,9 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch static void execute_trace_internal(running_machine &machine, int ref, int params, const char *param[], int trace_over) { - const char *action = NULL; + const char *action = nullptr; device_t *cpu; - FILE *f = NULL; + FILE *f = nullptr; const char *mode; std::string filename = param[0]; @@ -2578,7 +2578,7 @@ static void execute_trace_internal(running_machine &machine, int ref, int params strreplace(filename, "{game}", machine.basename()); /* validate parameters */ - if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : NULL, &cpu)) + if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu)) return; if (!debug_command_parameter_command(machine, action = param[2])) return; @@ -2650,9 +2650,9 @@ static void execute_history(running_machine &machine, int ref, int params, const { /* validate parameters */ address_space *space, *decrypted_space; - if (!debug_command_parameter_cpu_space(machine, (params > 0) ? param[0] : NULL, AS_PROGRAM, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 0) ? param[0] : nullptr, AS_PROGRAM, space)) return; - if (!debug_command_parameter_cpu_space(machine, (params > 0) ? param[0] : NULL, AS_DECRYPTED_OPCODES, decrypted_space)) + if (!debug_command_parameter_cpu_space(machine, (params > 0) ? param[0] : nullptr, AS_DECRYPTED_OPCODES, decrypted_space)) decrypted_space = space; UINT64 count = device_debug::HISTORY_SIZE; @@ -2700,8 +2700,8 @@ static void execute_trackpc(running_machine &machine, int ref, int params, const return; // Gather the cpu id (if present) - device_t *cpu = NULL; - if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : NULL, &cpu)) + device_t *cpu = nullptr; + if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu)) return; // Should we clear the existing data? @@ -2742,8 +2742,8 @@ static void execute_trackmem(running_machine &machine, int ref, int params, cons return; // Gather the cpu id (if present) - device_t *cpu = NULL; - if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : NULL, &cpu)) + device_t *cpu = nullptr; + if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu)) return; // Should we clear the existing data? @@ -2753,7 +2753,7 @@ static void execute_trackmem(running_machine &machine, int ref, int params, cons // Get the address space for the given cpu address_space *space; - if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : NULL, AS_PROGRAM, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : nullptr, AS_PROGRAM, space)) return; // Inform the CPU it's time to start tracking memory writes @@ -2780,13 +2780,13 @@ static void execute_pcatmem(running_machine &machine, int ref, int params, const return; // Gather the cpu id (if present) - device_t *cpu = NULL; - if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : NULL, &cpu)) + device_t *cpu = nullptr; + if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu)) return; // Get the address space for the given cpu address_space *space; - if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : NULL, ref, space)) + if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : nullptr, ref, space)) return; // Get the value of memory at the address @@ -2828,7 +2828,7 @@ static void execute_snap(running_machine &machine, int ref, int params, const ch screen_device_iterator iter(machine.root_device()); screen_device *screen = iter.byindex(scrnum); - if ((screen == NULL) || !machine.render().is_live(*screen)) + if ((screen == nullptr) || !machine.render().is_live(*screen)) { debug_console_printf(machine, "Invalid screen number '%d'\n", scrnum); return; @@ -2878,7 +2878,7 @@ static void execute_map(running_machine &machine, int ref, int params, const cha return; /* CPU is implicit */ - if (!debug_command_parameter_cpu_space(machine, NULL, ref, space)) + if (!debug_command_parameter_cpu_space(machine, nullptr, ref, space)) return; /* do the translation first */ @@ -2932,13 +2932,13 @@ static int CLIB_DECL symbol_sort_compare(const void *item1, const void *item2) static void execute_symlist(running_machine &machine, int ref, int params, const char **param) { - device_t *cpu = NULL; + device_t *cpu = nullptr; const char *namelist[1000]; symbol_table *symtable; int symnum, count = 0; - if (param[0] != NULL) + if (param[0] != nullptr) { /* validate parameters */ if (!debug_command_parameter_cpu(machine, param[0], &cpu)) @@ -2953,7 +2953,7 @@ static void execute_symlist(running_machine &machine, int ref, int params, const } /* gather names for all symbols */ - for (symbol_entry *entry = symtable->first(); entry != NULL; entry = entry->next()) + for (symbol_entry *entry = symtable->first(); entry != nullptr; entry = entry->next()) { /* only display "register" type symbols */ if (!entry->is_function()) @@ -2972,7 +2972,7 @@ static void execute_symlist(running_machine &machine, int ref, int params, const for (symnum = 0; symnum < count; symnum++) { const symbol_entry *entry = symtable->find(namelist[symnum]); - assert(entry != NULL); + assert(entry != nullptr); UINT64 value = entry->value(); /* only display "register" type symbols */ @@ -3011,11 +3011,11 @@ static void execute_hardreset(running_machine &machine, int ref, int params, con static void execute_images(running_machine &machine, int ref, int params, const char **param) { image_interface_iterator iter(machine.root_device()); - for (device_image_interface *img = iter.first(); img != NULL; img = iter.next()) + for (device_image_interface *img = iter.first(); img != nullptr; img = iter.next()) { debug_console_printf(machine, "%s: %s\n",img->brief_instance_name(),img->exists() ? img->filename() : "[empty slot]"); } - if (iter.first() == NULL) { + if (iter.first() == nullptr) { debug_console_printf(machine, "No image devices in this driver\n"); } } @@ -3028,7 +3028,7 @@ static void execute_mount(running_machine &machine, int ref, int params, const c { image_interface_iterator iter(machine.root_device()); bool done = false; - for (device_image_interface *img = iter.first(); img != NULL; img = iter.next()) + for (device_image_interface *img = iter.first(); img != nullptr; img = iter.next()) { if (strcmp(img->brief_instance_name(),param[0])==0) { if (img->load(param[1])==IMAGE_INIT_FAIL) { @@ -3052,7 +3052,7 @@ static void execute_unmount(running_machine &machine, int ref, int params, const { image_interface_iterator iter(machine.root_device()); bool done = false; - for (device_image_interface *img = iter.first(); img != NULL; img = iter.next()) + for (device_image_interface *img = iter.first(); img != nullptr; img = iter.next()) { if (strcmp(img->brief_instance_name(),param[0])==0) { img->unload(); @@ -3085,13 +3085,13 @@ static void execute_input(running_machine &machine, int ref, int params, const c static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param) { // was there a file specified? - const char *filename = (params > 0) ? param[0] : NULL; - FILE *file = NULL; - if (filename != NULL) + const char *filename = (params > 0) ? param[0] : nullptr; + FILE *file = nullptr; + if (filename != nullptr) { // if so, open it file = fopen(filename, "w"); - if (file == NULL) + if (file == nullptr) { debug_console_printf(machine, "Cannot open \"%s\"\n", filename); return; @@ -3102,12 +3102,12 @@ static void execute_dumpkbd(running_machine &machine, int ref, int params, const std::string buffer = machine.ioport().natkeyboard().dump(); // and output it as appropriate - if (file != NULL) + if (file != nullptr) fprintf(file, "%s\n", buffer.c_str()); else debug_console_printf(machine, "%s\n", buffer.c_str()); // cleanup - if (file != NULL) + if (file != nullptr) fclose(file); } diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp index 06a878b3367..b35d4afc690 100644 --- a/src/emu/debug/debugcon.cpp +++ b/src/emu/debug/debugcon.cpp @@ -110,14 +110,14 @@ static void debug_console_exit(running_machine &machine) /* free allocated memory */ if (console_textbuf) text_buffer_free(console_textbuf); - console_textbuf = NULL; + console_textbuf = nullptr; if (errorlog_textbuf) text_buffer_free(errorlog_textbuf); - errorlog_textbuf = NULL; + errorlog_textbuf = nullptr; /* free the command list */ - commandlist = NULL; + commandlist = nullptr; } @@ -192,7 +192,7 @@ static void trim_parameter(char **paramptr, int keep_quotes) static CMDERR internal_execute_command(running_machine &machine, int execute, int params, char **param) { - debug_command *cmd, *found = NULL; + debug_command *cmd, *found = nullptr; int i, foundcount = 0; char *p, *command; size_t len; @@ -216,12 +216,12 @@ static CMDERR internal_execute_command(running_machine &machine, int execute, in else { params = 0; - param[0] = NULL; + param[0] = nullptr; } /* search the command list */ len = strlen(command); - for (cmd = commandlist; cmd != NULL; cmd = cmd->next) + for (cmd = commandlist; cmd != nullptr; cmd = cmd->next) if (!strncmp(command, cmd->command, len)) { foundcount++; @@ -268,7 +268,7 @@ static CMDERR internal_execute_command(running_machine &machine, int execute, in static CMDERR internal_parse_command(running_machine &machine, const char *original_command, int execute) { char command[MAX_COMMAND_LENGTH], parens[MAX_COMMAND_LENGTH]; - char *params[MAX_COMMAND_PARAMS] = { 0 }; + char *params[MAX_COMMAND_PARAMS] = { nullptr }; CMDERR result; char *command_start; char *p, c = 0; diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index 8f399a1117a..3a95a823594 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -131,7 +131,7 @@ void debug_cpu_init(running_machine &machine) /* add "wpaddr", "wpdata", "cycles", "cpunum", "logunmap" to the global symbol table */ global->symtable->add("wpaddr", symbol_table::READ_ONLY, &global->wpaddr); global->symtable->add("wpdata", symbol_table::READ_ONLY, &global->wpdata); - global->symtable->add("cpunum", NULL, get_cpunum); + global->symtable->add("cpunum", nullptr, get_cpunum); global->symtable->add("beamx", (void *)first_screen, get_beamx); global->symtable->add("beamy", (void *)first_screen, get_beamy); global->symtable->add("frame", (void *)first_screen, get_frame); @@ -148,7 +148,7 @@ void debug_cpu_init(running_machine &machine) global->visiblecpu = machine.firstcpu; /* add callback for breaking on VBLANK */ - if (machine.first_screen() != NULL) + if (machine.first_screen() != nullptr) machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(on_vblank), &machine)); machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_cpu_exit), &machine)); @@ -172,8 +172,8 @@ void debug_cpu_flush_traces(running_machine &machine) /* this can be called on exit even when no debugging is enabled, so make sure the devdebug is valid before proceeding */ device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) - if (device->debug() != NULL) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) + if (device->debug() != nullptr) device->debug()->trace_flush(); } @@ -213,7 +213,7 @@ int debug_cpu_within_instruction_hook(running_machine &machine) int debug_cpu_is_stopped(running_machine &machine) { debugcpu_private *global = machine.debugcpu_data; - return (global != NULL) ? (global->execution_state == EXECUTION_STATE_STOPPED) : false; + return (global != nullptr) ? (global->execution_state == EXECUTION_STATE_STOPPED) : false; } @@ -254,14 +254,14 @@ void debug_cpu_source_script(running_machine &machine, const char *file) debugcpu_private *global = machine.debugcpu_data; /* close any existing source file */ - if (global->source_file != NULL) + if (global->source_file != nullptr) { fclose(global->source_file); - global->source_file = NULL; + global->source_file = nullptr; } /* open a new one if requested */ - if (file != NULL) + if (file != nullptr) { global->source_file = fopen(file, "r"); if (!global->source_file) @@ -291,33 +291,33 @@ bool debug_comment_save(running_machine &machine) // if we don't have a root, bail xml_data_node *root = xml_file_create(); - if (root == NULL) + if (root == nullptr) return false; // wrap in a try/catch to handle errors try { // create a comment node - xml_data_node *commentnode = xml_add_child(root, "mamecommentfile", NULL); - if (commentnode == NULL) + xml_data_node *commentnode = xml_add_child(root, "mamecommentfile", nullptr); + if (commentnode == nullptr) throw emu_exception(); xml_set_attribute_int(commentnode, "version", COMMENT_VERSION); // create a system node - xml_data_node *systemnode = xml_add_child(commentnode, "system", NULL); - if (systemnode == NULL) + xml_data_node *systemnode = xml_add_child(commentnode, "system", nullptr); + if (systemnode == nullptr) throw emu_exception(); xml_set_attribute(systemnode, "name", machine.system().name); // for each device device_iterator iter(machine.root_device()); bool found_comments = false; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (device->debug() && device->debug()->comment_count() > 0) { // create a node for this device - xml_data_node *curnode = xml_add_child(systemnode, "cpu", NULL); - if (curnode == NULL) + xml_data_node *curnode = xml_add_child(systemnode, "cpu", nullptr); + if (curnode == nullptr) throw emu_exception(); xml_set_attribute(curnode, "tag", device->tag()); @@ -367,16 +367,16 @@ bool debug_comment_load(running_machine &machine) return false; // wrap in a try/catch to handle errors - xml_data_node *root = xml_file_read(file, NULL); + xml_data_node *root = xml_file_read(file, nullptr); try { // read the file - if (root == NULL) + if (root == nullptr) throw emu_exception(); // find the config node xml_data_node *commentnode = xml_get_sibling(root->child, "mamecommentfile"); - if (commentnode == NULL) + if (commentnode == nullptr) throw emu_exception(); // validate the config data version @@ -394,7 +394,7 @@ bool debug_comment_load(running_machine &machine) for (xml_data_node *cpunode = xml_get_sibling(systemnode->child, "cpu"); cpunode; cpunode = xml_get_sibling(cpunode->next, "cpu")) { device_t *device = machine.device(xml_get_attribute_string(cpunode, "tag", "")); - if (device != NULL) + if (device != nullptr) if (!device->debug()->comment_import(*cpunode)) throw emu_exception(); } @@ -402,7 +402,7 @@ bool debug_comment_load(running_machine &machine) catch (emu_exception &) { // clean up in case of error - if (root != NULL) + if (root != nullptr) xml_file_free(root); return false; } @@ -1023,7 +1023,7 @@ static void debug_cpu_exit(running_machine &machine) debugcpu_private *global = machine.debugcpu_data; /* free the global symbol table */ - if (global != NULL) + if (global != nullptr) global_free(global->symtable); } @@ -1049,9 +1049,9 @@ static void reset_transient_flags(running_machine &machine) { /* loop over CPUs and reset the transient flags */ device_iterator iter(machine.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->debug()->reset_transient_flag(); - machine.debugcpu_data->m_stop_when_not_device = NULL; + machine.debugcpu_data->m_stop_when_not_device = nullptr; } @@ -1065,7 +1065,7 @@ static void process_source_file(running_machine &machine) debugcpu_private *global = machine.debugcpu_data; /* loop until the file is exhausted or until we are executing again */ - while (global->source_file != NULL && global->execution_state == EXECUTION_STATE_STOPPED) + while (global->source_file != nullptr && global->execution_state == EXECUTION_STATE_STOPPED) { char buf[512]; int i; @@ -1075,7 +1075,7 @@ static void process_source_file(running_machine &machine) if (feof(global->source_file)) { fclose(global->source_file); - global->source_file = NULL; + global->source_file = nullptr; return; } @@ -1129,7 +1129,7 @@ static UINT64 expression_read_memory(void *param, const char *name, expression_s { running_machine &machine = *(running_machine *)param; UINT64 result = ~(UINT64)0 >> (64 - 8*size); - device_t *device = NULL; + device_t *device = nullptr; switch (spacenum) { @@ -1137,9 +1137,9 @@ static UINT64 expression_read_memory(void *param, const char *name, expression_s case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: - if (name != NULL) + if (name != nullptr) device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL))) { @@ -1152,9 +1152,9 @@ static UINT64 expression_read_memory(void *param, const char *name, expression_s case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: - if (name != NULL) + if (name != nullptr) device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL))) { @@ -1165,15 +1165,15 @@ static UINT64 expression_read_memory(void *param, const char *name, expression_s case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: - if (name != NULL) + if (name != nullptr) device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); result = expression_read_program_direct(device->memory().space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size); break; case EXPSPACE_REGION: - if (name == NULL) + if (name == nullptr) break; result = expression_read_memory_region(machine, name, address, size); break; @@ -1226,7 +1226,7 @@ static UINT64 expression_read_program_direct(address_space &space, int opcode, o base = (UINT8 *)space.get_read_ptr(address & ~lowmask); /* if we have a valid base, return the appropriate byte */ - if (base != NULL) + if (base != nullptr) { if (space.endianness() == ENDIANNESS_LITTLE) result = base[BYTE8_XOR_LE(address) & lowmask]; @@ -1249,7 +1249,7 @@ static UINT64 expression_read_memory_region(running_machine &machine, const char UINT64 result = ~(UINT64)0 >> (64 - 8*size); /* make sure we get a valid base before proceeding */ - if (region != NULL) + if (region != nullptr) { /* call ourself recursively until we are byte-sized */ if (size > 1) @@ -1295,7 +1295,7 @@ static UINT64 expression_read_memory_region(running_machine &machine, const char static void expression_write_memory(void *param, const char *name, expression_space spacenum, UINT32 address, int size, UINT64 data) { running_machine &machine = *(running_machine *)param; - device_t *device = NULL; + device_t *device = nullptr; switch (spacenum) { @@ -1303,9 +1303,9 @@ static void expression_write_memory(void *param, const char *name, expression_sp case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: - if (name != NULL) + if (name != nullptr) device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL))) { @@ -1318,9 +1318,9 @@ static void expression_write_memory(void *param, const char *name, expression_sp case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: - if (name != NULL) + if (name != nullptr) device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL))) { @@ -1331,15 +1331,15 @@ static void expression_write_memory(void *param, const char *name, expression_sp case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: - if (name != NULL) + if (name != nullptr) device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); expression_write_program_direct(device->memory().space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data); break; case EXPSPACE_REGION: - if (name == NULL) + if (name == nullptr) break; expression_write_memory_region(machine, name, address, size, data); break; @@ -1398,7 +1398,7 @@ static void expression_write_program_direct(address_space &space, int opcode, of base = (UINT8 *)space.get_read_ptr(address & ~lowmask); /* if we have a valid base, write the appropriate byte */ - if (base != NULL) + if (base != nullptr) { if (space.endianness() == ENDIANNESS_LITTLE) base[BYTE8_XOR_LE(address) & lowmask] = data; @@ -1421,7 +1421,7 @@ static void expression_write_memory_region(running_machine &machine, const char memory_region *region = machine.root_device().memregion(rgntag); /* make sure we get a valid base before proceeding */ - if (region != NULL) + if (region != nullptr) { /* call ourself recursively until we are byte-sized */ if (size > 1) @@ -1474,7 +1474,7 @@ static void expression_write_memory_region(running_machine &machine, const char static expression_error::error_code expression_validate(void *param, const char *name, expression_space space) { running_machine &machine = *(running_machine *)param; - device_t *device = NULL; + device_t *device = nullptr; switch (space) { @@ -1482,13 +1482,13 @@ static expression_error::error_code expression_validate(void *param, const char case EXPSPACE_DATA_LOGICAL: case EXPSPACE_IO_LOGICAL: case EXPSPACE_SPACE3_LOGICAL: - if (name != NULL) + if (name != nullptr) { device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) return expression_error::INVALID_MEMORY_NAME; } - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); if (!device->memory().has_space(AS_PROGRAM + (space - EXPSPACE_PROGRAM_LOGICAL))) return expression_error::NO_SUCH_MEMORY_SPACE; @@ -1498,13 +1498,13 @@ static expression_error::error_code expression_validate(void *param, const char case EXPSPACE_DATA_PHYSICAL: case EXPSPACE_IO_PHYSICAL: case EXPSPACE_SPACE3_PHYSICAL: - if (name != NULL) + if (name != nullptr) { device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) return expression_error::INVALID_MEMORY_NAME; } - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); if (!device->memory().has_space(AS_PROGRAM + (space - EXPSPACE_PROGRAM_PHYSICAL))) return expression_error::NO_SUCH_MEMORY_SPACE; @@ -1512,22 +1512,22 @@ static expression_error::error_code expression_validate(void *param, const char case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: - if (name != NULL) + if (name != nullptr) { device = expression_get_device(machine, name); - if (device == NULL) + if (device == nullptr) return expression_error::INVALID_MEMORY_NAME; } - if (device == NULL) + if (device == nullptr) device = debug_cpu_get_visible_cpu(machine); if (!device->memory().has_space(AS_PROGRAM)) return expression_error::NO_SUCH_MEMORY_SPACE; break; case EXPSPACE_REGION: - if (name == NULL) + if (name == nullptr) return expression_error::MISSING_MEMORY_NAME; - if (machine.root_device().memregion(name)->base() == NULL) + if (machine.root_device().memregion(name)->base() == nullptr) return expression_error::INVALID_MEMORY_NAME; break; @@ -1550,7 +1550,7 @@ static expression_error::error_code expression_validate(void *param, const char static UINT64 get_beamx(symbol_table &table, void *ref) { screen_device *screen = reinterpret_cast(ref); - return (screen != NULL) ? screen->hpos() : 0; + return (screen != nullptr) ? screen->hpos() : 0; } @@ -1561,7 +1561,7 @@ static UINT64 get_beamx(symbol_table &table, void *ref) static UINT64 get_beamy(symbol_table &table, void *ref) { screen_device *screen = reinterpret_cast(ref); - return (screen != NULL) ? screen->vpos() : 0; + return (screen != nullptr) ? screen->vpos() : 0; } @@ -1572,7 +1572,7 @@ static UINT64 get_beamy(symbol_table &table, void *ref) static UINT64 get_frame(symbol_table &table, void *ref) { screen_device *screen = reinterpret_cast(ref); - return (screen != NULL) ? screen->frame_number() : 0; + return (screen != nullptr) ? screen->frame_number() : 0; } @@ -1602,14 +1602,14 @@ static UINT64 get_cpunum(symbol_table &table, void *ref) device_debug::device_debug(device_t &device) : m_device(device), - m_exec(NULL), - m_memory(NULL), - m_state(NULL), - m_disasm(NULL), + m_exec(nullptr), + m_memory(nullptr), + m_state(nullptr), + m_disasm(nullptr), m_flags(0), m_symtable(&device, debug_cpu_get_global_symtable(device.machine())), - m_instrhook(NULL), - m_dasm_override(NULL), + m_instrhook(nullptr), + m_dasm_override(nullptr), m_opwidth(0), m_stepaddr(0), m_stepsleft(0), @@ -1621,9 +1621,9 @@ device_debug::device_debug(device_t &device) m_total_cycles(0), m_last_total_cycles(0), m_pc_history_index(0), - m_bplist(NULL), - m_rplist(NULL), - m_trace(NULL), + m_bplist(nullptr), + m_rplist(nullptr), + m_trace(nullptr), m_hotspot_threshhold(0), m_track_pc_set(), m_track_pc(false), @@ -1642,18 +1642,18 @@ device_debug::device_debug(device_t &device) device.interface(m_disasm); // set up state-related stuff - if (m_state != NULL) + if (m_state != nullptr) { // add global symbol for cycles and totalcycles - if (m_exec != NULL) + if (m_exec != nullptr) { - m_symtable.add("cycles", NULL, get_cycles); - m_symtable.add("totalcycles", NULL, get_totalcycles); - m_symtable.add("lastinstructioncycles", NULL, get_lastinstructioncycles); + m_symtable.add("cycles", nullptr, get_cycles); + m_symtable.add("totalcycles", nullptr, get_totalcycles); + m_symtable.add("lastinstructioncycles", nullptr, get_lastinstructioncycles); } // add entries to enable/disable unmap reporting for each space - if (m_memory != NULL) + if (m_memory != nullptr) { if (m_memory->has_space(AS_PROGRAM)) m_symtable.add("logunmap", (void *)&m_memory->space(AS_PROGRAM), get_logunmap, set_logunmap); @@ -1665,21 +1665,21 @@ device_debug::device_debug(device_t &device) // add all registers into it std::string tempstr; - for (const device_state_entry *entry = m_state->state_first(); entry != NULL; entry = entry->next()) { + for (const device_state_entry *entry = m_state->state_first(); entry != nullptr; entry = entry->next()) { strmakelower(tempstr.assign(entry->symbol())); m_symtable.add(tempstr.c_str(), (void *)(FPTR)entry->index(), get_state, set_state); } } // set up execution-related stuff - if (m_exec != NULL) + if (m_exec != nullptr) { m_flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; m_opwidth = min_opcode_bytes(); // if no curpc, add one - if (m_state != NULL && m_symtable.find("curpc") == NULL) - m_symtable.add("curpc", NULL, get_current_pc); + if (m_state != nullptr && m_symtable.find("curpc") == nullptr) + m_symtable.add("curpc", nullptr, get_current_pc); } } @@ -1711,13 +1711,13 @@ void device_debug::start_hook(const attotime &endtime) assert((m_device.machine().debug_flags & DEBUG_FLAG_ENABLED) != 0); // stash a pointer to the current live CPU - assert(global->livecpu == NULL); + assert(global->livecpu == nullptr); global->livecpu = &m_device; // if we're a new device, stop now - if (global->m_stop_when_not_device != NULL && global->m_stop_when_not_device != &m_device) + if (global->m_stop_when_not_device != nullptr && global->m_stop_when_not_device != &m_device) { - global->m_stop_when_not_device = NULL; + global->m_stop_when_not_device = nullptr; global->execution_state = EXECUTION_STATE_STOPPED; reset_transient_flags(m_device.machine()); } @@ -1740,7 +1740,7 @@ void device_debug::start_hook(const attotime &endtime) else if (&m_device == global->breakcpu) { global->execution_state = EXECUTION_STATE_STOPPED; - global->breakcpu = NULL; + global->breakcpu = nullptr; } // if a VBLANK occurred, check on things @@ -1777,7 +1777,7 @@ void device_debug::stop_hook() assert(global->livecpu == &m_device); // clear the live CPU - global->livecpu = NULL; + global->livecpu = nullptr; } @@ -1847,7 +1847,7 @@ void device_debug::instruction_hook(offs_t curpc) } // are we tracing? - if (m_trace != NULL) + if (m_trace != nullptr) m_trace->update(curpc); // per-instruction hook? @@ -1914,7 +1914,7 @@ void device_debug::instruction_hook(offs_t curpc) // reset any transient state reset_transient_flags(m_device.machine()); - global->breakcpu = NULL; + global->breakcpu = nullptr; // remember the last visible CPU in the debugger global->visiblecpu = &m_device; @@ -2010,7 +2010,7 @@ void device_debug::set_instruction_hook(debug_instruction_hook_func hook) { // set the hook and also the CPU's flag for fast knowledge of the hook m_instrhook = hook; - if (hook != NULL) + if (hook != nullptr) m_flags |= DEBUG_FLAG_HOOKED; else m_flags &= ~DEBUG_FLAG_HOOKED; @@ -2027,17 +2027,17 @@ offs_t device_debug::disassemble(char *buffer, offs_t pc, const UINT8 *oprom, co offs_t result = 0; // check for disassembler override - if (m_dasm_override != NULL) + if (m_dasm_override != nullptr) result = (*m_dasm_override)(m_device, buffer, pc, oprom, opram, 0); // if we have a disassembler, run it - if (result == 0 && m_disasm != NULL) + if (result == 0 && m_disasm != nullptr) result = m_disasm->disassemble(buffer, pc, oprom, opram, 0); // make sure we get good results assert((result & DASMFLAG_LENGTHMASK) != 0); #ifdef MAME_DEBUG - if (m_memory != NULL && m_disasm != NULL) + if (m_memory != nullptr && m_disasm != nullptr) { address_space &space = m_memory->space(AS_PROGRAM); int bytes = space.address_to_byte(result & DASMFLAG_LENGTHMASK); @@ -2059,7 +2059,7 @@ void device_debug::ignore(bool ignore) { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); if (ignore) m_flags &= ~DEBUG_FLAG_OBSERVING; @@ -2080,7 +2080,7 @@ void device_debug::single_step(int numsteps) { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); m_stepsleft = numsteps; m_stepaddr = ~0; @@ -2098,7 +2098,7 @@ void device_debug::single_step_over(int numsteps) { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); m_stepsleft = numsteps; m_stepaddr = ~0; @@ -2116,7 +2116,7 @@ void device_debug::single_step_out() { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); m_stepsleft = 100; m_stepaddr = ~0; @@ -2134,7 +2134,7 @@ void device_debug::go(offs_t targetpc) { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); m_stopaddr = targetpc; m_flags |= DEBUG_FLAG_STOP_PC; @@ -2150,7 +2150,7 @@ void device_debug::go_vblank() { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); global->vblank_occurred = false; m_flags |= DEBUG_FLAG_STOP_VBLANK; @@ -2167,7 +2167,7 @@ void device_debug::go_interrupt(int irqline) { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); m_stopirq = irqline; m_flags |= DEBUG_FLAG_STOP_INTERRUPT; @@ -2184,7 +2184,7 @@ void device_debug::go_exception(int exception) { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); m_stopexception = exception; m_flags |= DEBUG_FLAG_STOP_EXCEPTION; @@ -2201,7 +2201,7 @@ void device_debug::go_milliseconds(UINT64 milliseconds) { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); m_stoptime = m_device.machine().time() + attotime::from_msec(milliseconds); m_flags |= DEBUG_FLAG_STOP_TIME; @@ -2218,7 +2218,7 @@ void device_debug::go_next_device() { debugcpu_private *global = m_device.machine().debugcpu_data; - assert(m_exec != NULL); + assert(m_exec != nullptr); global->m_stop_when_not_device = &m_device; global->execution_state = EXECUTION_STATE_RUNNING; @@ -2235,7 +2235,7 @@ void device_debug::halt_on_next_instruction(const char *fmt, ...) debugcpu_private *global = m_device.machine().debugcpu_data; va_list arg; - assert(m_exec != NULL); + assert(m_exec != nullptr); // if something is pending on this CPU already, ignore this request if (&m_device == global->breakcpu) @@ -2250,7 +2250,7 @@ void device_debug::halt_on_next_instruction(const char *fmt, ...) if (&m_device == global->livecpu) { global->execution_state = EXECUTION_STATE_STOPPED; - if (global->livecpu != NULL) + if (global->livecpu != nullptr) global->livecpu->debug()->compute_debug_flags(); } else @@ -2286,7 +2286,7 @@ int device_debug::breakpoint_set(offs_t address, const char *condition, const ch bool device_debug::breakpoint_clear(int index) { // scan the list to see if we own this breakpoint - for (breakpoint **bp = &m_bplist; *bp != NULL; bp = &(*bp)->m_next) + for (breakpoint **bp = &m_bplist; *bp != nullptr; bp = &(*bp)->m_next) if ((*bp)->m_index == index) { breakpoint *deleteme = *bp; @@ -2308,7 +2308,7 @@ bool device_debug::breakpoint_clear(int index) void device_debug::breakpoint_clear_all() { // clear the head until we run out - while (m_bplist != NULL) + while (m_bplist != nullptr) breakpoint_clear(m_bplist->index()); } @@ -2321,7 +2321,7 @@ void device_debug::breakpoint_clear_all() bool device_debug::breakpoint_enable(int index, bool enable) { // scan the list to see if we own this breakpoint - for (breakpoint *bp = m_bplist; bp != NULL; bp = bp->next()) + for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->next()) if (bp->m_index == index) { bp->m_enabled = enable; @@ -2342,7 +2342,7 @@ bool device_debug::breakpoint_enable(int index, bool enable) void device_debug::breakpoint_enable_all(bool enable) { // apply the enable to all breakpoints we own - for (breakpoint *bp = m_bplist; bp != NULL; bp = bp->next()) + for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->next()) breakpoint_enable(bp->index(), enable); } @@ -2378,7 +2378,7 @@ bool device_debug::watchpoint_clear(int index) { // scan the list to see if we own this breakpoint for (address_spacenum spacenum = AS_0; spacenum < ARRAY_LENGTH(m_wplist); ++spacenum) - for (watchpoint **wp = &m_wplist[spacenum]; *wp != NULL; wp = &(*wp)->m_next) + for (watchpoint **wp = &m_wplist[spacenum]; *wp != nullptr; wp = &(*wp)->m_next) if ((*wp)->m_index == index) { watchpoint *deleteme = *wp; @@ -2402,7 +2402,7 @@ void device_debug::watchpoint_clear_all() { // clear the head until we run out for (address_spacenum spacenum = AS_0; spacenum < ARRAY_LENGTH(m_wplist); ++spacenum) - while (m_wplist[spacenum] != NULL) + while (m_wplist[spacenum] != nullptr) watchpoint_clear(m_wplist[spacenum]->index()); } @@ -2416,7 +2416,7 @@ bool device_debug::watchpoint_enable(int index, bool enable) { // scan the list to see if we own this watchpoint for (address_spacenum spacenum = AS_0; spacenum < ARRAY_LENGTH(m_wplist); ++spacenum) - for (watchpoint *wp = m_wplist[spacenum]; wp != NULL; wp = wp->next()) + for (watchpoint *wp = m_wplist[spacenum]; wp != nullptr; wp = wp->next()) if (wp->m_index == index) { wp->m_enabled = enable; @@ -2438,7 +2438,7 @@ void device_debug::watchpoint_enable_all(bool enable) { // apply the enable to all watchpoints we own for (address_spacenum spacenum = AS_0; spacenum < ARRAY_LENGTH(m_wplist); ++spacenum) - for (watchpoint *wp = m_wplist[spacenum]; wp != NULL; wp = wp->next()) + for (watchpoint *wp = m_wplist[spacenum]; wp != nullptr; wp = wp->next()) watchpoint_enable(wp->index(), enable); } @@ -2471,7 +2471,7 @@ int device_debug::registerpoint_set(const char *condition, const char *action) bool device_debug::registerpoint_clear(int index) { // scan the list to see if we own this registerpoint - for (registerpoint **rp = &m_rplist; *rp != NULL; rp = &(*rp)->m_next) + for (registerpoint **rp = &m_rplist; *rp != nullptr; rp = &(*rp)->m_next) if ((*rp)->m_index == index) { registerpoint *deleteme = *rp; @@ -2493,7 +2493,7 @@ bool device_debug::registerpoint_clear(int index) void device_debug::registerpoint_clear_all() { // clear the head until we run out - while (m_rplist != NULL) + while (m_rplist != nullptr) registerpoint_clear(m_rplist->index()); } @@ -2506,7 +2506,7 @@ void device_debug::registerpoint_clear_all() bool device_debug::registerpoint_enable(int index, bool enable) { // scan the list to see if we own this conditionpoint - for (registerpoint *rp = m_rplist; rp != NULL; rp = rp->next()) + for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->next()) if (rp->m_index == index) { rp->m_enabled = enable; @@ -2527,7 +2527,7 @@ bool device_debug::registerpoint_enable(int index, bool enable) void device_debug::registerpoint_enable_all(bool enable) { // apply the enable to all registerpoints we own - for (registerpoint *rp = m_rplist; rp != NULL; rp = rp->next()) + for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->next()) registerpoint_enable(rp->index(), enable); } @@ -2554,7 +2554,7 @@ void device_debug::hotspot_track(int numspots, int threshhold) } // update the watchpoint flags to include us - if (m_memory != NULL && m_memory->has_space(AS_PROGRAM)) + if (m_memory != nullptr && m_memory->has_space(AS_PROGRAM)) watchpoint_update_flags(m_memory->space(AS_PROGRAM)); } @@ -2665,8 +2665,8 @@ bool device_debug::comment_remove(offs_t addr) const char *device_debug::comment_text(offs_t addr) const { const UINT32 crc = compute_opcode_crc32(addr); - std::set::iterator comment = m_comment_set.find(dasm_comment(addr, crc, "", 0)); - if (comment == m_comment_set.end()) return NULL; + auto comment = m_comment_set.find(dasm_comment(addr, crc, "", 0)); + if (comment == m_comment_set.end()) return nullptr; return comment->m_text.c_str(); } @@ -2680,14 +2680,14 @@ bool device_debug::comment_export(xml_data_node &curnode) { // iterate through the comments std::string crc_buf; - for (std::set::iterator item = m_comment_set.begin(); item != m_comment_set.end(); ++item) + for (const auto & elem : m_comment_set) { - xml_data_node *datanode = xml_add_child(&curnode, "comment", xml_normalize_string(item->m_text.c_str())); - if (datanode == NULL) + xml_data_node *datanode = xml_add_child(&curnode, "comment", xml_normalize_string(elem.m_text.c_str())); + if (datanode == nullptr) return false; - xml_set_attribute_int(datanode, "address", item->m_address); - xml_set_attribute_int(datanode, "color", item->m_color); - strprintf(crc_buf,"%08X", item->m_crc); + xml_set_attribute_int(datanode, "address", elem.m_address); + xml_set_attribute_int(datanode, "color", elem.m_color); + strprintf(crc_buf,"%08X", elem.m_crc); xml_set_attribute(datanode, "crc", crc_buf.c_str()); } return true; @@ -2709,7 +2709,7 @@ bool device_debug::comment_import(xml_data_node &cpunode) rgb_t color = xml_get_attribute_int(datanode, "color", 0); UINT32 crc; - sscanf(xml_get_attribute_string(datanode, "crc", 0), "%08X", &crc); + sscanf(xml_get_attribute_string(datanode, "crc", nullptr), "%08X", &crc); // add the new comment m_comment_set.insert(dasm_comment(address, crc, datanode->value, color)); @@ -2726,7 +2726,7 @@ bool device_debug::comment_import(xml_data_node &cpunode) UINT32 device_debug::compute_opcode_crc32(offs_t pc) const { // Basically the same thing as dasm_wrapped, but with some tiny savings - assert(m_memory != NULL); + assert(m_memory != nullptr); // determine the adjusted PC address_space &decrypted_space = m_memory->has_space(AS_DECRYPTED_OPCODES) ? m_memory->space(AS_DECRYPTED_OPCODES) : m_memory->space(AS_PROGRAM); @@ -2760,10 +2760,10 @@ void device_debug::trace(FILE *file, bool trace_over, const char *action) { // delete any existing tracers auto_free(m_device.machine(), m_trace); - m_trace = NULL; + m_trace = nullptr; // if we have a new file, make a new tracer - if (file != NULL) + if (file != nullptr) m_trace = auto_alloc(m_device.machine(), tracer(*this, *file, trace_over, action)); } @@ -2775,7 +2775,7 @@ void device_debug::trace(FILE *file, bool trace_over, const char *action) void device_debug::trace_printf(const char *fmt, ...) { - if (m_trace != NULL) + if (m_trace != nullptr) { va_list va; va_start(va, fmt); @@ -2813,7 +2813,7 @@ void device_debug::compute_debug_flags() machine.debug_flags |= DEBUG_FLAG_CALL_HOOK; // also call if we are tracing - if (m_trace != NULL) + if (m_trace != nullptr) machine.debug_flags |= DEBUG_FLAG_CALL_HOOK; // if we are stopping at a particular time and that time is within the current timeslice, we need to be called @@ -2865,7 +2865,7 @@ void device_debug::breakpoint_update_flags() { // see if there are any enabled breakpoints m_flags &= ~DEBUG_FLAG_LIVE_BP; - for (breakpoint *bp = m_bplist; bp != NULL; bp = bp->m_next) + for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->m_next) if (bp->m_enabled) { m_flags |= DEBUG_FLAG_LIVE_BP; @@ -2875,7 +2875,7 @@ void device_debug::breakpoint_update_flags() if ( ! ( m_flags & DEBUG_FLAG_LIVE_BP ) ) { // see if there are any enabled registerpoints - for (registerpoint *rp = m_rplist; rp != NULL; rp = rp->m_next) + for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->m_next) { if (rp->m_enabled) { @@ -2886,7 +2886,7 @@ void device_debug::breakpoint_update_flags() // push the flags out globally debugcpu_private *global = m_device.machine().debugcpu_data; - if (global->livecpu != NULL) + if (global->livecpu != nullptr) global->livecpu->debug()->compute_debug_flags(); } @@ -2899,7 +2899,7 @@ void device_debug::breakpoint_update_flags() void device_debug::breakpoint_check(offs_t pc) { // see if we match - for (breakpoint *bp = m_bplist; bp != NULL; bp = bp->m_next) + for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->m_next) if (bp->hit(pc)) { // halt in the debugger by default @@ -2917,7 +2917,7 @@ void device_debug::breakpoint_check(offs_t pc) } // see if we have any matching registerpoints - for (registerpoint *rp = m_rplist; rp != NULL; rp = rp->m_next) + for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->m_next) { if (rp->hit()) { @@ -2956,7 +2956,7 @@ void device_debug::watchpoint_update_flags(address_space &space) // see if there are any enabled breakpoints bool enablewrite = false; - for (watchpoint *wp = m_wplist[space.spacenum()]; wp != NULL; wp = wp->m_next) + for (watchpoint *wp = m_wplist[space.spacenum()]; wp != nullptr; wp = wp->m_next) if (wp->m_enabled) { if (wp->m_type & WATCHPOINT_READ) @@ -3029,7 +3029,7 @@ void device_debug::watchpoint_check(address_space &space, int type, offs_t addre global->wpdata = value_to_write; // see if we match - for (watchpoint *wp = m_wplist[space.spacenum()]; wp != NULL; wp = wp->m_next) + for (watchpoint *wp = m_wplist[space.spacenum()]; wp != nullptr; wp = wp->m_next) if (wp->hit(type, address, size)) { // halt in the debugger by default @@ -3046,7 +3046,7 @@ void device_debug::watchpoint_check(address_space &space, int type, offs_t addre { "0bytes", "byte", "word", "3bytes", "dword", "5bytes", "6bytes", "7bytes", "qword" }; - offs_t pc = (space.device().debug()->m_state != NULL) ? space.device().debug()->m_state->pc() : 0; + offs_t pc = (space.device().debug()->m_state != nullptr) ? space.device().debug()->m_state->pc() : 0; std::string buffer; if (type & WATCHPOINT_WRITE) @@ -3122,7 +3122,7 @@ void device_debug::hotspot_check(address_space &space, offs_t address) UINT32 device_debug::dasm_wrapped(std::string &buffer, offs_t pc) { - assert(m_memory != NULL && m_disasm != NULL); + assert(m_memory != nullptr && m_disasm != nullptr); // determine the adjusted PC address_space &decrypted_space = m_memory->has_space(AS_DECRYPTED_OPCODES) ? m_memory->space(AS_DECRYPTED_OPCODES) : m_memory->space(AS_PROGRAM); @@ -3260,12 +3260,12 @@ device_debug::breakpoint::breakpoint(device_debug* debugInterface, const char *condition, const char *action) : m_debugInterface(debugInterface), - m_next(NULL), + m_next(nullptr), m_index(index), m_enabled(true), m_address(address), - m_condition(&symbols, (condition != NULL) ? condition : "1"), - m_action((action != NULL) ? action : "") + m_condition(&symbols, (condition != nullptr) ? condition : "1"), + m_action((action != nullptr) ? action : "") { } @@ -3320,15 +3320,15 @@ device_debug::watchpoint::watchpoint(device_debug* debugInterface, const char *condition, const char *action) : m_debugInterface(debugInterface), - m_next(NULL), + m_next(nullptr), m_space(space), m_index(index), m_enabled(true), m_type(type), m_address(space.address_to_byte(address) & space.bytemask()), m_length(space.address_to_byte(length)), - m_condition(&symbols, (condition != NULL) ? condition : "1"), - m_action((action != NULL) ? action : "") + m_condition(&symbols, (condition != nullptr) ? condition : "1"), + m_action((action != nullptr) ? action : "") { } @@ -3377,11 +3377,11 @@ bool device_debug::watchpoint::hit(int type, offs_t address, int size) //------------------------------------------------- device_debug::registerpoint::registerpoint(symbol_table &symbols, int index, const char *condition, const char *action) - : m_next(NULL), + : m_next(nullptr), m_index(index), m_enabled(true), - m_condition(&symbols, (condition != NULL) ? condition : "1"), - m_action((action != NULL) ? action : "") + m_condition(&symbols, (condition != nullptr) ? condition : "1"), + m_action((action != nullptr) ? action : "") { } @@ -3425,7 +3425,7 @@ bool device_debug::registerpoint::hit() device_debug::tracer::tracer(device_debug &debug, FILE &file, bool trace_over, const char *action) : m_debug(debug), m_file(file), - m_action((action != NULL) ? action : ""), + m_action((action != nullptr) ? action : ""), m_loops(0), m_nextdex(0), m_trace_over(trace_over), @@ -3463,8 +3463,8 @@ void device_debug::tracer::update(offs_t pc) // check for a loop condition int count = 0; - for (int index = 0; index < ARRAY_LENGTH(m_history); index++) - if (m_history[index] == pc) + for (auto & elem : m_history) + if (elem == pc) count++; // if more than 1 hit, just up the loop count and get out @@ -3569,6 +3569,6 @@ device_debug::dasm_memory_access::dasm_memory_access(const address_spacenum& add device_debug::dasm_comment::dasm_comment(offs_t address, UINT32 crc, const char *text, rgb_t color) : dasm_pc_tag(address, crc), m_text(text), - m_color(color) + m_color(std::move(color)) { } diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index d337a7103f7..33c17253354 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -58,8 +58,8 @@ public: symbol_table &symbols, int index, offs_t address, - const char *condition = NULL, - const char *action = NULL); + const char *condition = nullptr, + const char *action = nullptr); // getters const device_debug *debugInterface() const { return m_debugInterface; } @@ -100,8 +100,8 @@ public: int type, offs_t address, offs_t length, - const char *condition = NULL, - const char *action = NULL); + const char *condition = nullptr, + const char *action = nullptr); // getters const device_debug *debugInterface() const { return m_debugInterface; } @@ -141,7 +141,7 @@ public: public: // construction/destruction - registerpoint(symbol_table &symbols, int index, const char *condition, const char *action = NULL); + registerpoint(symbol_table &symbols, int index, const char *condition, const char *action = nullptr); // getters registerpoint *next() const { return m_next; } @@ -170,10 +170,10 @@ public: symbol_table &symtable() { return m_symtable; } // commonly-used pass-throughs - offs_t pc() const { return (m_state != NULL) ? m_state->pc() : 0; } - int logaddrchars(address_spacenum spacenum = AS_0) const { return (m_memory != NULL && m_memory->has_space(spacenum)) ? m_memory->space(spacenum).logaddrchars() : 8; } - int min_opcode_bytes() const { return (m_disasm != NULL) ? m_disasm->max_opcode_bytes() : 1; } - int max_opcode_bytes() const { return (m_disasm != NULL) ? m_disasm->max_opcode_bytes() : 1; } + offs_t pc() const { return (m_state != nullptr) ? m_state->pc() : 0; } + int logaddrchars(address_spacenum spacenum = AS_0) const { return (m_memory != nullptr && m_memory->has_space(spacenum)) ? m_memory->space(spacenum).logaddrchars() : 8; } + int min_opcode_bytes() const { return (m_disasm != nullptr) ? m_disasm->max_opcode_bytes() : 1; } + int max_opcode_bytes() const { return (m_disasm != nullptr) ? m_disasm->max_opcode_bytes() : 1; } device_t& device() const { return m_device; } @@ -213,7 +213,7 @@ public: // breakpoints breakpoint *breakpoint_first() const { return m_bplist; } - int breakpoint_set(offs_t address, const char *condition = NULL, const char *action = NULL); + int breakpoint_set(offs_t address, const char *condition = nullptr, const char *action = nullptr); bool breakpoint_clear(int index); void breakpoint_clear_all(); bool breakpoint_enable(int index, bool enable = true); @@ -229,7 +229,7 @@ public: // registerpoints registerpoint *registerpoint_first() const { return m_rplist; } - int registerpoint_set(const char *condition, const char *action = NULL); + int registerpoint_set(const char *condition, const char *action = nullptr); bool registerpoint_clear(int index); void registerpoint_clear_all(); bool registerpoint_enable(int index, bool enable = true); @@ -268,7 +268,7 @@ public: // tracing void trace(FILE *file, bool trace_over, const char *action); void trace_printf(const char *fmt, ...) ATTR_PRINTF(2,3); - void trace_flush() { if (m_trace != NULL) m_trace->flush(); } + void trace_flush() { if (m_trace != nullptr) m_trace->flush(); } void reset_transient_flag() { m_flags &= ~DEBUG_FLAG_TRANSIENT; } diff --git a/src/emu/debug/debughlp.cpp b/src/emu/debug/debughlp.cpp index 1dcb7a31477..fcfaeacd29f 100644 --- a/src/emu/debug/debughlp.cpp +++ b/src/emu/debug/debughlp.cpp @@ -1469,7 +1469,7 @@ static const help_item static_help_list[] = const char *debug_get_help(const char *tag) { static char ambig_message[1024]; - const help_item *found = NULL; + const help_item *found = nullptr; int i, msglen, foundcount = 0; int taglen = (int)strlen(tag); char tagcopy[256]; diff --git a/src/emu/debug/debugvw.cpp b/src/emu/debug/debugvw.cpp index 9c6c76aba10..eea867f3a63 100644 --- a/src/emu/debug/debugvw.cpp +++ b/src/emu/debug/debugvw.cpp @@ -31,7 +31,7 @@ //------------------------------------------------- debug_view_source::debug_view_source(const char *name, device_t *device) - : m_next(NULL), + : m_next(nullptr), m_name(name), m_device(device), m_is_octal(false) @@ -67,9 +67,9 @@ debug_view_source::~debug_view_source() //------------------------------------------------- debug_view::debug_view(running_machine &machine, debug_view_type type, debug_view_osd_update_func osdupdate, void *osdprivate) - : m_next(NULL), + : m_next(nullptr), m_type(type), - m_source(NULL), + m_source(nullptr), m_osdupdate(osdupdate), m_osdprivate(osdprivate), m_visible(80,10), @@ -133,7 +133,7 @@ void debug_view::end_update() void debug_view::flush_osd_updates() { - if (m_osd_update_pending && m_osdupdate != NULL) + if (m_osd_update_pending && m_osdupdate != nullptr) (*m_osdupdate)(*this, m_osdprivate); m_osd_update_pending = false; } @@ -236,7 +236,7 @@ void debug_view::set_source(const debug_view_source &source) const debug_view_source *debug_view::source_for_device(device_t *device) const { - for (debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) + for (debug_view_source *source = m_source_list.first(); source != nullptr; source = source->next()) if (device == source->device()) return source; return m_source_list.first(); @@ -316,7 +316,7 @@ void debug_view::view_click(const int button, const debug_view_xy& pos) debug_view_manager::debug_view_manager(running_machine &machine) : m_machine(machine), - m_viewlist(NULL) + m_viewlist(nullptr) { } @@ -327,7 +327,7 @@ debug_view_manager::debug_view_manager(running_machine &machine) debug_view_manager::~debug_view_manager() { - while (m_viewlist != NULL) + while (m_viewlist != nullptr) { debug_view *oldhead = m_viewlist; m_viewlist = oldhead->m_next; @@ -374,7 +374,7 @@ debug_view *debug_view_manager::alloc_view(debug_view_type type, debug_view_osd_ default: fatalerror("Attempt to create invalid debug view type %d\n", type); } - return NULL; + return nullptr; } @@ -385,7 +385,7 @@ debug_view *debug_view_manager::alloc_view(debug_view_type type, debug_view_osd_ void debug_view_manager::free_view(debug_view &view) { // free us but only if we're in the list - for (debug_view **viewptr = &m_viewlist; *viewptr != NULL; viewptr = &(*viewptr)->m_next) + for (debug_view **viewptr = &m_viewlist; *viewptr != nullptr; viewptr = &(*viewptr)->m_next) if (*viewptr == &view) { *viewptr = view.m_next; @@ -403,7 +403,7 @@ void debug_view_manager::free_view(debug_view &view) void debug_view_manager::update_all_except(debug_view_type type) { // loop over each view and force an update - for (debug_view *view = m_viewlist; view != NULL; view = view->next()) + for (debug_view *view = m_viewlist; view != nullptr; view = view->next()) if (type == DVT_NONE || type != view->type()) view->force_update(); } @@ -416,7 +416,7 @@ void debug_view_manager::update_all_except(debug_view_type type) void debug_view_manager::update_all(debug_view_type type) { // loop over each view and force an update - for (debug_view *view = m_viewlist; view != NULL; view = view->next()) + for (debug_view *view = m_viewlist; view != nullptr; view = view->next()) if (type == DVT_NONE || type == view->type()) view->force_update(); } @@ -429,7 +429,7 @@ void debug_view_manager::update_all(debug_view_type type) void debug_view_manager::flush_osd_updates() { - for (debug_view *view = m_viewlist; view != NULL; view = view->m_next) + for (debug_view *view = m_viewlist; view != nullptr; view = view->m_next) view->flush_osd_updates(); } @@ -441,7 +441,7 @@ void debug_view_manager::flush_osd_updates() debug_view *debug_view_manager::append(debug_view *view) { debug_view **viewptr; - for (viewptr = &m_viewlist; *viewptr != NULL; viewptr = &(*viewptr)->m_next) { } + for (viewptr = &m_viewlist; *viewptr != nullptr; viewptr = &(*viewptr)->m_next) { } *viewptr = view; return view; } @@ -482,7 +482,7 @@ debug_view_expression::~debug_view_expression() void debug_view_expression::set_context(symbol_table *context) { - m_parsed.set_symbols((context != NULL) ? context : debug_cpu_get_global_symtable(machine())); + m_parsed.set_symbols((context != nullptr) ? context : debug_cpu_get_global_symtable(machine())); m_dirty = true; } diff --git a/src/emu/debug/debugvw.h b/src/emu/debug/debugvw.h index c813619aaa1..437e68d68f6 100644 --- a/src/emu/debug/debugvw.h +++ b/src/emu/debug/debugvw.h @@ -117,7 +117,7 @@ class debug_view_source public: // construction/destruction - debug_view_source(const char *name, device_t *device = NULL); + debug_view_source(const char *name, device_t *device = nullptr); virtual ~debug_view_source(); // getters diff --git a/src/emu/debug/dvbpoints.cpp b/src/emu/debug/dvbpoints.cpp index 2e4e16de68f..919f352842f 100644 --- a/src/emu/debug/dvbpoints.cpp +++ b/src/emu/debug/dvbpoints.cpp @@ -130,7 +130,7 @@ void debug_view_breakpoints::enumerate_sources() // iterate over devices with disassembly interfaces disasm_interface_iterator iter(machine().root_device()); - for (device_disasm_interface *dasm = iter.first(); dasm != NULL; dasm = iter.next()) + for (device_disasm_interface *dasm = iter.first(); dasm != nullptr; dasm = iter.next()) { std::string name; strprintf(name, "%s '%s'", dasm->device().name(), dasm->device().tag()); @@ -203,11 +203,11 @@ void debug_view_breakpoints::pad_astring_to_length(std::string& str, int len) void debug_view_breakpoints::gather_breakpoints() { m_buffer.resize(0); - for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) + for (const debug_view_source *source = m_source_list.first(); source != nullptr; source = source->next()) { // Collect device_debug &debugInterface = *source->device()->debug(); - for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next()) + for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != nullptr; bp = bp->next()) m_buffer.push_back(bp); } diff --git a/src/emu/debug/dvbpoints.h b/src/emu/debug/dvbpoints.h index 1ee3cdcb510..1867dcf2b6f 100644 --- a/src/emu/debug/dvbpoints.h +++ b/src/emu/debug/dvbpoints.h @@ -40,8 +40,8 @@ public: protected: // view overrides - virtual void view_update(); - virtual void view_click(const int button, const debug_view_xy& pos); + virtual void view_update() override; + virtual void view_click(const int button, const debug_view_xy& pos) override; private: // internal helpers diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp index afcd40dd0ef..e873b0be8bb 100644 --- a/src/emu/debug/dvdisasm.cpp +++ b/src/emu/debug/dvdisasm.cpp @@ -47,8 +47,8 @@ debug_view_disasm::debug_view_disasm(running_machine &machine, debug_view_osd_up m_right_column(DASM_RIGHTCOL_RAW), m_backwards_steps(3), m_dasm_width(DEFAULT_DASM_WIDTH), - m_last_direct_raw(NULL), - m_last_direct_decrypted(NULL), + m_last_direct_raw(nullptr), + m_last_direct_decrypted(nullptr), m_last_change_count(0), m_last_pcbyte(0), m_divider1(0), @@ -63,7 +63,7 @@ debug_view_disasm::debug_view_disasm(running_machine &machine, debug_view_osd_up // count the number of comments int total_comments = 0; - for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) + for (const debug_view_source *source = m_source_list.first(); source != nullptr; source = source->next()) { const debug_view_disasm_source &dasmsource = downcast(*source); total_comments += dasmsource.m_device.debug()->comment_count(); @@ -97,7 +97,7 @@ void debug_view_disasm::enumerate_sources() // iterate over devices with disassembly interfaces disasm_interface_iterator iter(machine().root_device()); std::string name; - for (device_disasm_interface *dasm = iter.first(); dasm != NULL; dasm = iter.next()) + for (device_disasm_interface *dasm = iter.first(); dasm != nullptr; dasm = iter.next()) { strprintf(name,"%s '%s'", dasm->device().name(), dasm->device().tag()); m_source_list.append(*global_alloc(debug_view_disasm_source(name.c_str(), dasm->device()))); @@ -420,7 +420,7 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines) // get and add the comment, if present offs_t comment_address = source.m_space.byte_to_address(m_byteaddress[instr]); const char *text = source.m_device.debug()->comment_text(comment_address); - if (text != NULL) + if (text != nullptr) sprintf(&destbuf[m_divider2], "// %.*s", row_width - m_divider2 - 4, text); } @@ -560,7 +560,7 @@ recompute: // if we're on a line with a breakpoint, tag it changed else { - for (device_debug::breakpoint *bp = source.m_device.debug()->breakpoint_first(); bp != NULL; bp = bp->next()) + for (device_debug::breakpoint *bp = source.m_device.debug()->breakpoint_first(); bp != nullptr; bp = bp->next()) if (m_byteaddress[effrow] == (source.m_space.address_to_byte(bp->address()) & source.m_space.logbytemask())) attrib = DCA_CHANGED; } diff --git a/src/emu/debug/dvdisasm.h b/src/emu/debug/dvdisasm.h index 202ffbe4d8c..29bb724b5a2 100644 --- a/src/emu/debug/dvdisasm.h +++ b/src/emu/debug/dvdisasm.h @@ -82,10 +82,10 @@ public: protected: // view overrides - virtual void view_update(); - virtual void view_notify(debug_view_notification type); - virtual void view_char(int chval); - virtual void view_click(const int button, const debug_view_xy& pos); + virtual void view_update() override; + virtual void view_notify(debug_view_notification type) override; + virtual void view_char(int chval) override; + virtual void view_click(const int button, const debug_view_xy& pos) override; private: // internal helpers diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp index c874de58053..88062c9209a 100644 --- a/src/emu/debug/dvmemory.cpp +++ b/src/emu/debug/dvmemory.cpp @@ -47,7 +47,7 @@ debug_view_memory_source::debug_view_memory_source(const char *name, address_spa : debug_view_source(name, &space.device()), m_space(&space), m_memintf(dynamic_cast(&space.device())), - m_base(NULL), + m_base(nullptr), m_length(0), m_offsetxor(0), m_endianness(space.endianness()), @@ -57,8 +57,8 @@ debug_view_memory_source::debug_view_memory_source(const char *name, address_spa debug_view_memory_source::debug_view_memory_source(const char *name, memory_region ®ion) : debug_view_source(name), - m_space(NULL), - m_memintf(NULL), + m_space(nullptr), + m_memintf(nullptr), m_base(region.base()), m_length(region.bytes()), m_offsetxor(ENDIAN_VALUE_NE_NNE(region.endianness(), 0, region.bytewidth() - 1)), @@ -69,8 +69,8 @@ debug_view_memory_source::debug_view_memory_source(const char *name, memory_regi debug_view_memory_source::debug_view_memory_source(const char *name, void *base, int element_size, int num_elements) : debug_view_source(name), - m_space(NULL), - m_memintf(NULL), + m_space(nullptr), + m_memintf(nullptr), m_base(base), m_length(element_size * num_elements), m_offsetxor(0), @@ -133,7 +133,7 @@ void debug_view_memory::enumerate_sources() // first add all the devices' address spaces memory_interface_iterator iter(machine().root_device()); - for (device_memory_interface *memintf = iter.first(); memintf != NULL; memintf = iter.next()) + for (device_memory_interface *memintf = iter.first(); memintf != nullptr; memintf = iter.next()) if (&memintf->device() != &machine().root_device()) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) if (memintf->has_space(spacenum)) @@ -144,7 +144,7 @@ void debug_view_memory::enumerate_sources() } // then add all the memory regions - for (memory_region *region = machine().memory().first_region(); region != NULL; region = region->next()) + for (memory_region *region = machine().memory().first_region(); region != nullptr; region = region->next()) { strprintf(name, "Region '%s'", region->name()); m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), *region))); @@ -157,7 +157,7 @@ void debug_view_memory::enumerate_sources() UINT32 valsize, valcount; void *base; const char *itemname = machine().save().indexed_item(itemnum, base, valsize, valcount); - if (itemname == NULL) + if (itemname == nullptr) break; // add pretty much anything that's not a timer (we may wish to cull other items later) @@ -195,10 +195,10 @@ void debug_view_memory::view_notify(debug_view_notification type) if (m_bytes_per_chunk > 8) m_bytes_per_chunk = 8; m_data_format = m_bytes_per_chunk; - if (source.m_space != NULL) + if (source.m_space != nullptr) m_expression.set_context(&source.m_space->device().debug()->symtable()); else - m_expression.set_context(NULL); + m_expression.set_context(nullptr); } } @@ -262,7 +262,7 @@ void debug_view_memory::view_update() if (effrow < m_total.y) { offs_t addrbyte = m_byte_offset + effrow * m_bytes_per_row; - offs_t address = (source.m_space != NULL) ? source.m_space->byte_to_address(addrbyte) : addrbyte; + offs_t address = (source.m_space != nullptr) ? source.m_space->byte_to_address(addrbyte) : addrbyte; char addrtext[20]; // generate the address @@ -409,7 +409,7 @@ void debug_view_memory::view_char(int chval) { static const char hexvals[] = "0123456789abcdef"; char *hexchar = (char *)strchr(hexvals, tolower(chval)); - if (hexchar == NULL) + if (hexchar == nullptr) break; UINT64 data; @@ -492,7 +492,7 @@ void debug_view_memory::recompute() // determine the maximum address and address format string from the raw information int addrchars; - if (source.m_space != NULL) + if (source.m_space != nullptr) { m_maxaddr = m_no_translation ? source.m_space->bytemask() : source.m_space->logbytemask(); addrchars = m_no_translation ? source.m_space->addrchars() : source.m_space->logaddrchars(); @@ -510,7 +510,7 @@ void debug_view_memory::recompute() strprintf(m_addrformat, "%%0%dX%*s", addrchars, 8 - addrchars, ""); // if we are viewing a space with a minimum chunk size, clamp the bytes per chunk - if (source.m_space != NULL && source.m_space->byte_to_address(1) > 1) + if (source.m_space != nullptr && source.m_space->byte_to_address(1) > 1) { UINT32 min_bytes_per_chunk = source.m_space->byte_to_address(1); while (m_bytes_per_chunk < min_bytes_per_chunk) @@ -576,7 +576,7 @@ bool debug_view_memory::needs_recompute() const debug_view_memory_source &source = downcast(*m_source); offs_t resultbyte; - if (source.m_space != NULL) + if (source.m_space != nullptr) resultbyte = source.m_space->address_to_byte(m_expression.value()) & source.m_space->logbytemask(); else resultbyte = m_expression.value(); @@ -697,7 +697,7 @@ bool debug_view_memory::read(UINT8 size, offs_t offs, UINT64 &data) const debug_view_memory_source &source = downcast(*m_source); // if no raw data, just use the standard debug routines - if (source.m_space != NULL) + if (source.m_space != nullptr) { offs_t dummyaddr = offs; @@ -750,7 +750,7 @@ void debug_view_memory::write(UINT8 size, offs_t offs, UINT64 data) const debug_view_memory_source &source = downcast(*m_source); // if no raw data, just use the standard debug routines - if (source.m_space != NULL) + if (source.m_space != nullptr) { switch (size) { diff --git a/src/emu/debug/dvmemory.h b/src/emu/debug/dvmemory.h index c170a2cf617..4039136e558 100644 --- a/src/emu/debug/dvmemory.h +++ b/src/emu/debug/dvmemory.h @@ -67,10 +67,10 @@ public: protected: // view overrides - virtual void view_notify(debug_view_notification type); - virtual void view_update(); - virtual void view_char(int chval); - virtual void view_click(const int button, const debug_view_xy& pos); + virtual void view_notify(debug_view_notification type) override; + virtual void view_update() override; + virtual void view_char(int chval) override; + virtual void view_click(const int button, const debug_view_xy& pos) override; private: struct cursor_pos diff --git a/src/emu/debug/dvstate.cpp b/src/emu/debug/dvstate.cpp index 8e5906be416..dd3f3d33f9c 100644 --- a/src/emu/debug/dvstate.cpp +++ b/src/emu/debug/dvstate.cpp @@ -44,7 +44,7 @@ debug_view_state::debug_view_state(running_machine &machine, debug_view_osd_upda : debug_view(machine, DVT_STATE, osdupdate, osdprivate), m_divider(0), m_last_update(0), - m_state_list(NULL) + m_state_list(nullptr) { // fail if no available sources enumerate_sources(); @@ -76,7 +76,7 @@ void debug_view_state::enumerate_sources() // iterate over devices that have state interfaces state_interface_iterator iter(machine().root_device()); std::string name; - for (device_state_interface *state = iter.first(); state != NULL; state = iter.next()) + for (device_state_interface *state = iter.first(); state != nullptr; state = iter.next()) { strprintf(name,"%s '%s'", state->device().name(), state->device().tag()); m_source_list.append(*global_alloc(debug_view_state_source(name.c_str(), state->device()))); @@ -94,7 +94,7 @@ void debug_view_state::enumerate_sources() void debug_view_state::reset() { // free all items in the state list - while (m_state_list != NULL) + while (m_state_list != nullptr) { state_item *oldhead = m_state_list; m_state_list = oldhead->m_next; @@ -141,7 +141,7 @@ void debug_view_state::recompute() tailptr = &(*tailptr)->m_next; // add all registers into it - for (const device_state_entry *entry = source.m_stateintf->state_first(); entry != NULL; entry = entry->next()) + for (const device_state_entry *entry = source.m_stateintf->state_first(); entry != nullptr; entry = entry->next()) if (entry->divider()) { *tailptr = auto_alloc(machine(), state_item(REG_DIVIDER, "", 0)); @@ -157,7 +157,7 @@ void debug_view_state::recompute() int count = 0; int maxtaglen = 0; int maxvallen = 0; - for (state_item *item = m_state_list; item != NULL; item = item->m_next) + for (state_item *item = m_state_list; item != nullptr; item = item->m_next) { count++; maxtaglen = MAX(maxtaglen, item->m_symbol.length()); @@ -202,12 +202,12 @@ void debug_view_state::view_update() // get cycle count if we have an execute interface const debug_view_state_source &source = downcast(*m_source); UINT64 total_cycles = 0; - if (source.m_execintf != NULL) + if (source.m_execintf != nullptr) total_cycles = source.m_execintf->total_cycles(); // find the first entry state_item *curitem = m_state_list; - for (int index = 0; curitem != NULL && index < m_topleft.y; index++) + for (int index = 0; curitem != nullptr && index < m_topleft.y; index++) curitem = curitem->m_next; // loop over visible rows @@ -218,7 +218,7 @@ void debug_view_state::view_update() UINT32 col = 0; // if this visible row is valid, add it to the buffer - if (curitem != NULL) + if (curitem != nullptr) { UINT32 effcol = m_topleft.x; UINT8 attrib = DCA_NORMAL; @@ -239,7 +239,7 @@ void debug_view_state::view_update() break; case REG_CYCLES: - if (source.m_execintf != NULL) + if (source.m_execintf != nullptr) { curitem->m_currval = source.m_execintf->cycles_remaining(); strprintf(valstr, "%-8d", (UINT32)curitem->m_currval); @@ -247,7 +247,7 @@ void debug_view_state::view_update() break; case REG_BEAMX: - if (screen != NULL) + if (screen != nullptr) { curitem->m_currval = screen->hpos(); strprintf(valstr, "%4d", (UINT32)curitem->m_currval); @@ -255,7 +255,7 @@ void debug_view_state::view_update() break; case REG_BEAMY: - if (screen != NULL) + if (screen != nullptr) { curitem->m_currval = screen->vpos(); strprintf(valstr, "%4d", (UINT32)curitem->m_currval); @@ -263,7 +263,7 @@ void debug_view_state::view_update() break; case REG_FRAME: - if (screen != NULL) + if (screen != nullptr) { curitem->m_currval = screen->frame_number(); strprintf(valstr, "%6d", (UINT32)curitem->m_currval); @@ -336,7 +336,7 @@ void debug_view_state::view_update() //------------------------------------------------- debug_view_state::state_item::state_item(int index, const char *name, UINT8 valuechars) - : m_next(NULL), + : m_next(nullptr), m_lastval(0), m_currval(0), m_index(index), diff --git a/src/emu/debug/dvstate.h b/src/emu/debug/dvstate.h index 88930587d7b..909526ee5f6 100644 --- a/src/emu/debug/dvstate.h +++ b/src/emu/debug/dvstate.h @@ -50,8 +50,8 @@ class debug_view_state : public debug_view protected: // view overrides - virtual void view_update(); - virtual void view_notify(debug_view_notification type); + virtual void view_update() override; + virtual void view_notify(debug_view_notification type) override; private: struct state_item diff --git a/src/emu/debug/dvtext.cpp b/src/emu/debug/dvtext.cpp index 80f1aa7982c..ce1d8abdb1b 100644 --- a/src/emu/debug/dvtext.cpp +++ b/src/emu/debug/dvtext.cpp @@ -79,7 +79,7 @@ void debug_view_textbuf::view_update() UINT32 col = 0; // if this visible row is valid, add it to the buffer - if (line != NULL) + if (line != nullptr) { size_t len = strlen(line); UINT32 effcol = m_topleft.x; diff --git a/src/emu/debug/dvtext.h b/src/emu/debug/dvtext.h index 12181e6c0e1..8ec67c3158c 100644 --- a/src/emu/debug/dvtext.h +++ b/src/emu/debug/dvtext.h @@ -31,8 +31,8 @@ protected: protected: // view overrides - virtual void view_update(); - virtual void view_notify(debug_view_notification type); + virtual void view_update() override; + virtual void view_notify(debug_view_notification type) override; private: // internal state diff --git a/src/emu/debug/dvwpoints.cpp b/src/emu/debug/dvwpoints.cpp index c09cff91bf3..c1e346c62b2 100644 --- a/src/emu/debug/dvwpoints.cpp +++ b/src/emu/debug/dvwpoints.cpp @@ -152,7 +152,7 @@ void debug_view_watchpoints::enumerate_sources() // iterate over devices with disassembly interfaces disasm_interface_iterator iter(machine().root_device()); - for (device_disasm_interface *dasm = iter.first(); dasm != NULL; dasm = iter.next()) + for (device_disasm_interface *dasm = iter.first(); dasm != nullptr; dasm = iter.next()) { std::string name; strprintf(name, "%s '%s'", dasm->device().name(), dasm->device().tag()); @@ -227,13 +227,13 @@ void debug_view_watchpoints::pad_astring_to_length(std::string& str, int len) void debug_view_watchpoints::gather_watchpoints() { m_buffer.resize(0); - for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) + for (const debug_view_source *source = m_source_list.first(); source != nullptr; source = source->next()) { // Collect device_debug &debugInterface = *source->device()->debug(); for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) { - for (device_debug::watchpoint *wp = debugInterface.watchpoint_first(spacenum); wp != NULL; wp = wp->next()) + for (device_debug::watchpoint *wp = debugInterface.watchpoint_first(spacenum); wp != nullptr; wp = wp->next()) m_buffer.push_back(wp); } } diff --git a/src/emu/debug/dvwpoints.h b/src/emu/debug/dvwpoints.h index e56c992cb8d..b7d899e7717 100644 --- a/src/emu/debug/dvwpoints.h +++ b/src/emu/debug/dvwpoints.h @@ -36,8 +36,8 @@ class debug_view_watchpoints : public debug_view protected: // view overrides - virtual void view_update(); - virtual void view_click(const int button, const debug_view_xy& pos); + virtual void view_update() override; + virtual void view_click(const int button, const debug_view_xy& pos) override; private: // internal helpers diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp index 4dbe76202b7..62324092a28 100644 --- a/src/emu/debug/express.cpp +++ b/src/emu/debug/express.cpp @@ -112,14 +112,14 @@ class integer_symbol_entry : public symbol_entry { public: // construction/destruction - integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, UINT64 *ptr = NULL); + integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, UINT64 *ptr = nullptr); integer_symbol_entry(symbol_table &table, const char *name, UINT64 constval); integer_symbol_entry(symbol_table &table, const char *name, void *ref, symbol_table::getter_func getter, symbol_table::setter_func setter); // symbol access - virtual bool is_lval() const; - virtual UINT64 value() const; - virtual void set_value(UINT64 newvalue); + virtual bool is_lval() const override; + virtual UINT64 value() const override; + virtual void set_value(UINT64 newvalue) override; private: // internal helpers @@ -141,9 +141,9 @@ public: function_symbol_entry(symbol_table &table, const char *name, void *ref, int minparams, int maxparams, symbol_table::execute_func execute); // symbol access - virtual bool is_lval() const; - virtual UINT64 value() const; - virtual void set_value(UINT64 newvalue); + virtual bool is_lval() const override; + virtual UINT64 value() const override; + virtual void set_value(UINT64 newvalue) override; // execution helper virtual UINT64 execute(int numparams, const UINT64 *paramlist); @@ -204,7 +204,7 @@ const char *expression_error::code_string() const //------------------------------------------------- symbol_entry::symbol_entry(symbol_table &table, symbol_type type, const char *name, void *ref) - : m_next(NULL), + : m_next(nullptr), m_table(table), m_type(type), m_name(name), @@ -232,9 +232,9 @@ symbol_entry::~symbol_entry() //------------------------------------------------- integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, UINT64 *ptr) - : symbol_entry(table, SMT_INTEGER, name, (ptr == NULL) ? &m_value : ptr), + : symbol_entry(table, SMT_INTEGER, name, (ptr == nullptr) ? &m_value : ptr), m_getter(internal_getter), - m_setter((rw == symbol_table::READ_ONLY) ? NULL : internal_setter), + m_setter((rw == symbol_table::READ_ONLY) ? nullptr : internal_setter), m_value(0) { } @@ -243,7 +243,7 @@ integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, UINT64 constval) : symbol_entry(table, SMT_INTEGER, name, &m_value), m_getter(internal_getter), - m_setter(NULL), + m_setter(nullptr), m_value(constval) { } @@ -264,7 +264,7 @@ integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name bool integer_symbol_entry::is_lval() const { - return (m_setter != NULL); + return (m_setter != nullptr); } @@ -284,7 +284,7 @@ UINT64 integer_symbol_entry::value() const void integer_symbol_entry::set_value(UINT64 newvalue) { - if (m_setter != NULL) + if (m_setter != nullptr) (*m_setter)(m_table, m_ref, newvalue); else throw emu_fatalerror("Symbol '%s' is read-only", m_name.c_str()); @@ -387,10 +387,10 @@ UINT64 function_symbol_entry::execute(int numparams, const UINT64 *paramlist) symbol_table::symbol_table(void *globalref, symbol_table *parent) : m_parent(parent), m_globalref(globalref), - m_memory_param(NULL), - m_memory_valid(NULL), - m_memory_read(NULL), - m_memory_write(NULL) + m_memory_param(nullptr), + m_memory_valid(nullptr), + m_memory_read(nullptr), + m_memory_write(nullptr) { } @@ -460,13 +460,13 @@ void symbol_table::add(const char *name, void *ref, int minparams, int maxparams symbol_entry *symbol_table::find_deep(const char *symbol) { // walk up the table hierarchy to find the owner - for (symbol_table *symtable = this; symtable != NULL; symtable = symtable->m_parent) + for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent) { symbol_entry *entry = symtable->find(symbol); - if (entry != NULL) + if (entry != nullptr) return entry; } - return NULL; + return nullptr; } @@ -477,7 +477,7 @@ symbol_entry *symbol_table::find_deep(const char *symbol) UINT64 symbol_table::value(const char *symbol) { symbol_entry *entry = find_deep(symbol); - return (entry != NULL) ? entry->value() : 0; + return (entry != nullptr) ? entry->value() : 0; } @@ -488,7 +488,7 @@ UINT64 symbol_table::value(const char *symbol) void symbol_table::set_value(const char *symbol, UINT64 value) { symbol_entry *entry = find_deep(symbol); - if (entry != NULL) + if (entry != nullptr) entry->set_value(value); } @@ -501,8 +501,8 @@ void symbol_table::set_value(const char *symbol, UINT64 value) expression_error::error_code symbol_table::memory_valid(const char *name, expression_space space) { // walk up the table hierarchy to find the owner - for (symbol_table *symtable = this; symtable != NULL; symtable = symtable->m_parent) - if (symtable->m_memory_valid != NULL) + for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent) + if (symtable->m_memory_valid != nullptr) { expression_error::error_code err = (*symtable->m_memory_valid)(symtable->m_memory_param, name, space); if (err != expression_error::NO_SUCH_MEMORY_SPACE) @@ -519,11 +519,11 @@ expression_error::error_code symbol_table::memory_valid(const char *name, expres UINT64 symbol_table::memory_value(const char *name, expression_space space, UINT32 offset, int size) { // walk up the table hierarchy to find the owner - for (symbol_table *symtable = this; symtable != NULL; symtable = symtable->m_parent) - if (symtable->m_memory_valid != NULL) + for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent) + if (symtable->m_memory_valid != nullptr) { expression_error::error_code err = (*symtable->m_memory_valid)(symtable->m_memory_param, name, space); - if (err != expression_error::NO_SUCH_MEMORY_SPACE && symtable->m_memory_read != NULL) + if (err != expression_error::NO_SUCH_MEMORY_SPACE && symtable->m_memory_read != nullptr) return (*symtable->m_memory_read)(symtable->m_memory_param, name, space, offset, size); return 0; } @@ -538,11 +538,11 @@ UINT64 symbol_table::memory_value(const char *name, expression_space space, UINT void symbol_table::set_memory_value(const char *name, expression_space space, UINT32 offset, int size, UINT64 value) { // walk up the table hierarchy to find the owner - for (symbol_table *symtable = this; symtable != NULL; symtable = symtable->m_parent) - if (symtable->m_memory_valid != NULL) + for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent) + if (symtable->m_memory_valid != nullptr) { expression_error::error_code err = (*symtable->m_memory_valid)(symtable->m_memory_param, name, space); - if (err != expression_error::NO_SUCH_MEMORY_SPACE && symtable->m_memory_write != NULL) + if (err != expression_error::NO_SUCH_MEMORY_SPACE && symtable->m_memory_write != nullptr) (*symtable->m_memory_write)(symtable->m_memory_param, name, space, offset, size, value); return; } @@ -563,11 +563,11 @@ parsed_expression::parsed_expression(symbol_table *symtable, const char *express m_token_stack_ptr(0) { // if we got an expression parse it - if (expression != NULL) + if (expression != nullptr) parse(expression); // if we get a result pointer, execute it - if (result != NULL) + if (result != nullptr) *result = execute(); } @@ -866,7 +866,7 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& { static const char valid[] = "abcdefghijklmnopqrstuvwxyz0123456789_$#.:"; char val = tolower((UINT8)string[0]); - if (val == 0 || strchr(valid, val) == NULL) + if (val == 0 || strchr(valid, val) == nullptr) break; buffer.append(&val, 1); string++; @@ -939,7 +939,7 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& // check for a symbol match symbol_entry *symbol = m_symtable->find_deep(buffer.c_str()); - if (symbol != NULL) + if (symbol != nullptr) { token.configure_symbol(*symbol); @@ -971,7 +971,7 @@ void parsed_expression::parse_number(parse_token &token, const char *string, int // look up the number's value, stopping if not valid static const char numbers[] = "0123456789abcdef"; const char *ptr = strchr(numbers, tolower((UINT8)*string)); - if (ptr == NULL) + if (ptr == nullptr) break; // if outside of the base, we also stop @@ -1065,9 +1065,9 @@ void parsed_expression::parse_memory_operator(parse_token &token, const char *st { // if there is a '.', it means we have a name const char *startstring = string; - const char *namestring = NULL; + const char *namestring = nullptr; const char *dot = strrchr(string, '.'); - if (dot != NULL) + if (dot != nullptr) { namestring = m_stringlist.append(*global_alloc(expression_string(string, dot - string))); string = dot + 1; @@ -1130,7 +1130,7 @@ void parsed_expression::parse_memory_operator(parse_token &token, const char *st } // validate the name - if (m_symtable != NULL) + if (m_symtable != nullptr) { expression_error::error_code err = m_symtable->memory_valid(namestring, memspace); if (err != expression_error::NONE) @@ -1154,15 +1154,15 @@ void parsed_expression::normalize_operator(parse_token *prevtoken, parse_token & { // Determine if an open paren is part of a function or not case TVL_LPAREN: - if (prevtoken != NULL && prevtoken->is_operator(TVL_EXECUTEFUNC)) + if (prevtoken != nullptr && prevtoken->is_operator(TVL_EXECUTEFUNC)) thistoken.set_function_separator(); break; // Determine if ++ is a pre or post increment case TVL_PLUSPLUS: - if (nexttoken != NULL && (nexttoken->is_symbol() || (nexttoken->is_operator(TVL_MEMORYAT)))) + if (nexttoken != nullptr && (nexttoken->is_symbol() || (nexttoken->is_operator(TVL_MEMORYAT)))) thistoken.configure_operator(TVL_PREINCREMENT, 2); - else if (prevtoken != NULL && (prevtoken->is_symbol() || (prevtoken->is_operator(TVL_MEMORYAT)))) + else if (prevtoken != nullptr && (prevtoken->is_symbol() || (prevtoken->is_operator(TVL_MEMORYAT)))) thistoken.configure_operator(TVL_POSTINCREMENT, 1); else throw expression_error(expression_error::SYNTAX, thistoken.offset()); @@ -1170,9 +1170,9 @@ void parsed_expression::normalize_operator(parse_token *prevtoken, parse_token & // Determine if -- is a pre or post decrement case TVL_MINUSMINUS: - if (nexttoken != NULL && (nexttoken->is_symbol() || (nexttoken->is_operator(TVL_MEMORYAT)))) + if (nexttoken != nullptr && (nexttoken->is_symbol() || (nexttoken->is_operator(TVL_MEMORYAT)))) thistoken.configure_operator(TVL_PREDECREMENT, 2); - else if (prevtoken != NULL && (prevtoken->is_symbol() || (prevtoken->is_operator(TVL_MEMORYAT)))) + else if (prevtoken != nullptr && (prevtoken->is_symbol() || (prevtoken->is_operator(TVL_MEMORYAT)))) thistoken.configure_operator(TVL_POSTDECREMENT, 1); else throw expression_error(expression_error::SYNTAX, thistoken.offset()); @@ -1183,7 +1183,7 @@ void parsed_expression::normalize_operator(parse_token *prevtoken, parse_token & case TVL_SUBTRACT: // Assume we're unary if we are the first token, or if the previous token is not // a symbol, a number, or a right parenthesis - if (prevtoken == NULL || (!prevtoken->is_symbol() && !prevtoken->is_number() && !prevtoken->is_operator(TVL_RPAREN))) + if (prevtoken == nullptr || (!prevtoken->is_symbol() && !prevtoken->is_number() && !prevtoken->is_operator(TVL_RPAREN))) thistoken.configure_operator(thistoken.is_operator(TVL_ADD) ? TVL_UPLUS : TVL_UMINUS, 2); break; @@ -1192,7 +1192,7 @@ void parsed_expression::normalize_operator(parse_token *prevtoken, parse_token & for (int lookback = 0; lookback < MAX_STACK_DEPTH; lookback++) { parse_token *peek = peek_token(lookback); - if (peek == NULL) + if (peek == nullptr) break; // if we hit an execute function operator, or else a left parenthesis that is @@ -1218,9 +1218,9 @@ void parsed_expression::infix_to_postfix() simple_list stack; // loop over all the original tokens - parse_token *prev = NULL; + parse_token *prev = nullptr; parse_token *next; - for (parse_token *token = m_tokenlist.detach_all(); token != NULL; prev = token, token = next) + for (parse_token *token = m_tokenlist.detach_all(); token != nullptr; prev = token, token = next) { // pre-determine our next token next = token->next(); @@ -1246,7 +1246,7 @@ void parsed_expression::infix_to_postfix() { // loop until we find our matching opener parse_token *popped; - while ((popped = stack.detach_head()) != NULL) + while ((popped = stack.detach_head()) != nullptr) { if (popped->is_operator(TVL_LPAREN)) break; @@ -1254,7 +1254,7 @@ void parsed_expression::infix_to_postfix() } // if we didn't find an open paren, it's an error - if (popped == NULL) + if (popped == nullptr) throw expression_error(expression_error::UNBALANCED_PARENS, token->offset()); // free ourself and our matching opening parenthesis @@ -1271,7 +1271,7 @@ void parsed_expression::infix_to_postfix() // loop until we can't peek at the stack anymore parse_token *peek; - while ((peek = stack.first()) != NULL) + while ((peek = stack.first()) != nullptr) { // break if any of the above conditions are true if (peek->is_operator(TVL_LPAREN)) @@ -1292,7 +1292,7 @@ void parsed_expression::infix_to_postfix() // finish popping the stack parse_token *popped; - while ((popped = stack.detach_head()) != NULL) + while ((popped = stack.detach_head()) != nullptr) { // it is an error to have a left parenthesis still on the stack if (popped->is_operator(TVL_LPAREN)) @@ -1342,7 +1342,7 @@ inline void parsed_expression::pop_token(parse_token &token) inline parsed_expression::parse_token *parsed_expression::peek_token(int count) { if (m_token_stack_ptr <= count) - return NULL; + return nullptr; return &m_token_stack[m_token_stack_ptr - count - 1]; } @@ -1395,7 +1395,7 @@ UINT64 parsed_expression::execute_tokens() // loop over the entire sequence parse_token t1, t2, result; - for (parse_token *token = m_tokenlist.first(); token != NULL; token = token->next()) + for (parse_token *token = m_tokenlist.first(); token != nullptr; token = token->next()) { // symbols/numbers/strings just get pushed if (!token->is_operator()) @@ -1641,7 +1641,7 @@ UINT64 parsed_expression::execute_tokens() pop_token_rval(result); // error if our stack isn't empty - if (peek_token(0) != NULL) + if (peek_token(0) != nullptr) throw expression_error(expression_error::SYNTAX, 0); return result.value(); @@ -1658,13 +1658,13 @@ UINT64 parsed_expression::execute_tokens() //------------------------------------------------- parsed_expression::parse_token::parse_token(int offset) - : m_next(NULL), + : m_next(nullptr), m_type(INVALID), m_offset(offset), m_value(0), m_flags(0), - m_string(NULL), - m_symbol(NULL) + m_string(nullptr), + m_symbol(nullptr) { } @@ -1681,7 +1681,7 @@ UINT64 parsed_expression::parse_token::get_lval_value(symbol_table *table) return m_symbol->value(); // or get the value from the memory callbacks - else if (is_memory() && table != NULL) + else if (is_memory() && table != nullptr) return table->memory_value(m_string, memory_space(), address(), 1 << memory_size()); return 0; @@ -1700,7 +1700,7 @@ inline void parsed_expression::parse_token::set_lval_value(symbol_table *table, m_symbol->set_value(value); // or set the value via the memory callbacks - else if (is_memory() && table != NULL) + else if (is_memory() && table != nullptr) table->set_memory_value(m_string, memory_space(), address(), 1 << memory_size(), value); } @@ -1714,13 +1714,13 @@ void parsed_expression::execute_function(parse_token &token) { // pop off all pushed parameters UINT64 funcparams[MAX_FUNCTION_PARAMS]; - symbol_entry *symbol = NULL; + symbol_entry *symbol = nullptr; int paramcount = 0; while (paramcount < MAX_FUNCTION_PARAMS) { // peek at the next token on the stack parse_token *peek = peek_token(0); - if (peek == NULL) + if (peek == nullptr) throw expression_error(expression_error::INVALID_PARAM_COUNT, token.offset()); // if it is a function symbol, break out of the loop diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h index 37f357b0830..fad3e478cf8 100644 --- a/src/emu/debug/express.h +++ b/src/emu/debug/express.h @@ -166,7 +166,7 @@ public: }; // construction/destruction - symbol_table(void *globalref, symbol_table *parent = NULL); + symbol_table(void *globalref, symbol_table *parent = nullptr); // getters symbol_entry *first() const { return m_symlist.first(); } @@ -177,9 +177,9 @@ public: void configure_memory(void *param, valid_func valid, read_func read, write_func write); // symbol access - void add(const char *name, read_write rw, UINT64 *ptr = NULL); + void add(const char *name, read_write rw, UINT64 *ptr = nullptr); void add(const char *name, UINT64 constvalue); - void add(const char *name, void *ref, getter_func getter, setter_func setter = NULL); + void add(const char *name, void *ref, getter_func getter, setter_func setter = nullptr); void add(const char *name, void *ref, int minparams, int maxparams, execute_func execute); symbol_entry *find(const char *name) { return m_symlist.find(name); } symbol_entry *find_deep(const char *name); @@ -214,7 +214,7 @@ class parsed_expression public: // construction/destruction parsed_expression(const parsed_expression &src) { copy(src); } - parsed_expression(symbol_table *symtable = NULL, const char *expression = NULL, UINT64 *result = NULL); + parsed_expression(symbol_table *symtable = nullptr, const char *expression = nullptr, UINT64 *result = nullptr); // operators parsed_expression &operator=(const parsed_expression &src) { copy(src); return *this; } @@ -331,7 +331,7 @@ private: public: // construction/destruction expression_string(const char *string, int length = 0) - : m_next(NULL), + : m_next(nullptr), m_string(string, (length == 0) ? strlen(string) : length) { } // operators diff --git a/src/emu/debug/textbuf.cpp b/src/emu/debug/textbuf.cpp index 52fd669a997..cd96be9cd5a 100644 --- a/src/emu/debug/textbuf.cpp +++ b/src/emu/debug/textbuf.cpp @@ -88,14 +88,14 @@ text_buffer *text_buffer_alloc(UINT32 bytes, UINT32 lines) /* allocate memory for the text buffer object */ text = (text_buffer *)global_alloc(text_buffer); if (!text) - return NULL; + return nullptr; /* allocate memory for the buffer itself */ text->buffer = (char *)global_alloc_array(char, bytes); if (!text->buffer) { global_free(text); - return NULL; + return nullptr; } /* allocate memory for the lines array */ @@ -104,7 +104,7 @@ text_buffer *text_buffer_alloc(UINT32 bytes, UINT32 lines) { global_free_array(text->buffer); global_free(text); - return NULL; + return nullptr; } /* initialize the buffer description */ @@ -319,6 +319,6 @@ const char *text_buffer_get_seqnum_line(text_buffer *text, UINT32 seqnum) UINT32 numlines = text_buffer_num_lines(text); UINT32 index = seqnum - text->linestartseq; if (index >= numlines) - return NULL; + return nullptr; return &text->buffer[text->lineoffs[(text->linestart + index) % text->linesize]]; } diff --git a/src/emu/debugger.cpp b/src/emu/debugger.cpp index d4ddd241389..b21e4ca779b 100644 --- a/src/emu/debugger.cpp +++ b/src/emu/debugger.cpp @@ -110,7 +110,7 @@ static void debugger_exit(running_machine &machine) machine_entry **entryptr; /* remove this machine from the list; it came down cleanly */ - for (entryptr = &machine_list; *entryptr != NULL; entryptr = &(*entryptr)->next) + for (entryptr = &machine_list; *entryptr != nullptr; entryptr = &(*entryptr)->next) if ((*entryptr)->machine == &machine) { machine_entry *deleteme = *entryptr; @@ -130,7 +130,7 @@ static void debugger_exit(running_machine &machine) void debugger_flush_all_traces_on_abnormal_exit(void) { /* clear out the machine list and flush traces on each one */ - while (machine_list != NULL) + while (machine_list != nullptr) { machine_entry *deleteme = machine_list; debug_cpu_flush_traces(*deleteme->machine); diff --git a/src/emu/devcb.cpp b/src/emu/devcb.cpp index 8a05625aabd..d54c25e530b 100644 --- a/src/emu/devcb.cpp +++ b/src/emu/devcb.cpp @@ -37,12 +37,12 @@ devcb_base::devcb_base(device_t &device, UINT64 defmask) void devcb_base::reset(callback_type type) { m_type = type; - m_target_tag = NULL; + m_target_tag = nullptr; m_target_int = 0; - m_space_tag = NULL; + m_space_tag = nullptr; m_space_num = AS_0; - m_space = NULL; - m_target.ptr = NULL; + m_space = nullptr; + m_target.ptr = nullptr; m_rshift = 0; m_mask = ~U64(0); } @@ -56,8 +56,8 @@ void devcb_base::reset(callback_type type) void devcb_base::resolve_ioport() { // attempt to resolve, fatal error if fail - m_target.ioport = (m_target_tag != NULL) ? m_device.owner()->ioport(m_target_tag) : NULL; - if (m_target.ioport == NULL) + m_target.ioport = (m_target_tag != nullptr) ? m_device.owner()->ioport(m_target_tag) : nullptr; + if (m_target.ioport == nullptr) throw emu_fatalerror("Unable to resolve I/O port callback reference to '%s' in device '%s'\n", m_target_tag, m_device.tag()); } @@ -70,8 +70,8 @@ void devcb_base::resolve_ioport() void devcb_base::resolve_inputline() { // attempt to resolve, fatal error if fail - m_target.device = (m_target_tag != NULL) ? m_device.owner()->subdevice(m_target_tag) : NULL; - if (m_target.device == NULL) + m_target.device = (m_target_tag != nullptr) ? m_device.owner()->subdevice(m_target_tag) : nullptr; + if (m_target.device == nullptr) throw emu_fatalerror("Unable to resolve device reference to '%s' in device '%s'\n", m_target_tag, m_device.tag()); // make sure we have an execute interface @@ -89,8 +89,8 @@ void devcb_base::resolve_inputline() void devcb_base::resolve_space() { // attempt to resolve, fatal error if fail - device_t *spacedev = (m_space_tag != NULL) ? m_device.owner()->subdevice(m_space_tag) : NULL; - if (spacedev == NULL) + device_t *spacedev = (m_space_tag != nullptr) ? m_device.owner()->subdevice(m_space_tag) : nullptr; + if (spacedev == nullptr) throw emu_fatalerror("Unable to resolve device reference to '%s' in device '%s'\n", m_space_tag, m_device.tag()); if (!spacedev->memory().has_space(m_space_num)) throw emu_fatalerror("Unable to resolve device address space %d on '%s' in device '%s'\n", m_space_num, m_space_tag, m_device.tag()); @@ -109,7 +109,7 @@ void devcb_base::resolve_space() devcb_read_base::devcb_read_base(device_t &device, UINT64 defmask) : devcb_base(device, defmask), - m_adapter(NULL) + m_adapter(nullptr) { } @@ -141,7 +141,7 @@ void devcb_read_base::reset(callback_type type) void devcb_read_base::resolve() { // first resolve any address spaces - if (m_space_tag != NULL) + if (m_space_tag != nullptr) resolve_space(); else m_space = &downcast(m_device.machine().root_device()).generic_space(); @@ -193,7 +193,7 @@ void devcb_read_base::resolve() case CALLBACK_IOPORT: resolve_ioport(); m_target_int = 0; - m_adapter = (m_target.ioport == NULL) ? &devcb_read_base::read_constant_adapter : &devcb_read_base::read_ioport_adapter; + m_adapter = (m_target.ioport == nullptr) ? &devcb_read_base::read_constant_adapter : &devcb_read_base::read_ioport_adapter; break; case CALLBACK_LOG: @@ -337,7 +337,7 @@ UINT64 devcb_read_base::read_constant_adapter(address_space &space, offs_t offse devcb_write_base::devcb_write_base(device_t &device, UINT64 defmask) : devcb_base(device, defmask), - m_adapter(NULL) + m_adapter(nullptr) { } @@ -369,7 +369,7 @@ void devcb_write_base::reset(callback_type type) void devcb_write_base::resolve() { // first resolve any address spaces - if (m_space_tag != NULL) + if (m_space_tag != nullptr) resolve_space(); else m_space = &downcast(m_device.machine().root_device()).generic_space(); @@ -415,7 +415,7 @@ void devcb_write_base::resolve() case CALLBACK_IOPORT: resolve_ioport(); - m_adapter = (m_target.ioport == NULL) ? &devcb_write_base::write_noop_adapter : &devcb_write_base::write_ioport_adapter; + m_adapter = (m_target.ioport == nullptr) ? &devcb_write_base::write_noop_adapter : &devcb_write_base::write_ioport_adapter; break; case CALLBACK_LOG: diff --git a/src/emu/devcb.h b/src/emu/devcb.h index 9db94a78699..5aefb2b3429 100644 --- a/src/emu/devcb.h +++ b/src/emu/devcb.h @@ -296,7 +296,7 @@ class devcb_read_line : public devcb_read_base public: devcb_read_line(device_t &device) : devcb_read_base(device, 0xff) { } int operator()() { return (this->*m_adapter)(*m_space, 0, U64(0xff)) & 1; } - int operator()(address_space &space) { return (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, 0, U64(0xff)) & 1; } + int operator()(address_space &space) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, 0, U64(0xff)) & 1; } }; @@ -307,7 +307,7 @@ class devcb_read8 : public devcb_read_base public: devcb_read8(device_t &device) : devcb_read_base(device, 0xff) { } UINT8 operator()(offs_t offset = 0, UINT8 mask = 0xff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - UINT8 operator()(address_space &space, offs_t offset = 0, UINT8 mask = 0xff) { return (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, mask) & mask; } + UINT8 operator()(address_space &space, offs_t offset = 0, UINT8 mask = 0xff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -318,7 +318,7 @@ class devcb_read16 : public devcb_read_base public: devcb_read16(device_t &device) : devcb_read_base(device, 0xffff) { } UINT16 operator()(offs_t offset = 0, UINT16 mask = 0xffff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - UINT16 operator()(address_space &space, offs_t offset = 0, UINT16 mask = 0xffff) { return (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, mask) & mask; } + UINT16 operator()(address_space &space, offs_t offset = 0, UINT16 mask = 0xffff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -329,7 +329,7 @@ class devcb_read32 : public devcb_read_base public: devcb_read32(device_t &device) : devcb_read_base(device, 0xffffffff) { } UINT32 operator()(offs_t offset = 0, UINT32 mask = 0xffffffff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - UINT32 operator()(address_space &space, offs_t offset = 0, UINT32 mask = 0xffffffff) { return (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, mask) & mask; } + UINT32 operator()(address_space &space, offs_t offset = 0, UINT32 mask = 0xffffffff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -340,7 +340,7 @@ class devcb_read64 : public devcb_read_base public: devcb_read64(device_t &device) : devcb_read_base(device, U64(0xffffffffffffffff)) { } UINT64 operator()(offs_t offset = 0, UINT64 mask = U64(0xffffffffffffffff)) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - UINT64 operator()(address_space &space, offs_t offset = 0, UINT64 mask = U64(0xffffffffffffffff)) { return (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, mask) & mask; } + UINT64 operator()(address_space &space, offs_t offset = 0, UINT64 mask = U64(0xffffffffffffffff)) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -351,7 +351,7 @@ class devcb_write_line : public devcb_write_base public: devcb_write_line(device_t &device) : devcb_write_base(device, 0xff) { } void operator()(int state) { (this->*m_adapter)(*m_space, 0, state & 1, U64(0xff)); } - void operator()(address_space &space, int state) { (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, 0, state & 1, U64(0xff)); } + void operator()(address_space &space, int state) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, 0, state & 1, U64(0xff)); } }; @@ -363,7 +363,7 @@ public: devcb_write8(device_t &device) : devcb_write_base(device, 0xff) { } void operator()(UINT8 data, UINT8 mask = 0xff) { (this->*m_adapter)(*m_space, 0, data, mask); } void operator()(offs_t offset, UINT8 data, UINT8 mask = 0xff) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, UINT8 data, UINT8 mask = 0xff) { (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, UINT8 data, UINT8 mask = 0xff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; @@ -375,7 +375,7 @@ public: devcb_write16(device_t &device) : devcb_write_base(device, 0xffff) { } void operator()(UINT16 data, UINT16 mask = 0xffff) { (this->*m_adapter)(*m_space, 0, data, mask); } void operator()(offs_t offset, UINT16 data, UINT16 mask = 0xffff) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, UINT16 data, UINT16 mask = 0xffff) { (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, UINT16 data, UINT16 mask = 0xffff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; @@ -387,7 +387,7 @@ public: devcb_write32(device_t &device) : devcb_write_base(device, 0xffffffff) { } void operator()(UINT32 data, UINT32 mask = 0xffffffff) { (this->*m_adapter)(*m_space, 0, data, mask); } void operator()(offs_t offset, UINT32 data, UINT32 mask = 0xffffffff) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, UINT32 data, UINT32 mask = 0xffffffff) { (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, UINT32 data, UINT32 mask = 0xffffffff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; @@ -399,7 +399,7 @@ public: devcb_write64(device_t &device) : devcb_write_base(device, U64(0xffffffffffffffff)) { } void operator()(UINT64 data, UINT64 mask = U64(0xffffffffffffffff)) { (this->*m_adapter)(*m_space, 0, data, mask); } void operator()(offs_t offset, UINT64 data, UINT64 mask = U64(0xffffffffffffffff)) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, UINT64 data, UINT64 mask = U64(0xffffffffffffffff)) { (this->*m_adapter)((m_space_tag != NULL) ? *m_space : space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, UINT64 data, UINT64 mask = U64(0xffffffffffffffff)) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; diff --git a/src/emu/devdelegate.cpp b/src/emu/devdelegate.cpp index 53a03763e4a..8917d5dfc3f 100644 --- a/src/emu/devdelegate.cpp +++ b/src/emu/devdelegate.cpp @@ -20,7 +20,7 @@ delegate_late_bind &device_delegate_helper::bound_object(device_t &search_root) { device_t *device = search_root.subdevice(m_device_name); - if (device == NULL) + if (device == nullptr) throw emu_fatalerror("Unable to locate device '%s' relative to '%s'\n", m_device_name, search_root.tag()); return *device; } @@ -33,5 +33,5 @@ delegate_late_bind &device_delegate_helper::bound_object(device_t &search_root) const char *device_delegate_helper::safe_tag(device_t *object) { - return (object != NULL) ? object->tag() : "(unknown)"; + return (object != nullptr) ? object->tag() : "(unknown)"; } diff --git a/src/emu/devdelegate.h b/src/emu/devdelegate.h index ba1b82ab8ee..ca4eae7b236 100644 --- a/src/emu/devdelegate.h +++ b/src/emu/devdelegate.h @@ -50,7 +50,7 @@ class device_delegate : public delegate<_Signature>, device_delegate_helper public: // provide the same constructors as the base class - device_delegate() : basetype(), device_delegate_helper(NULL) { } + device_delegate() : basetype(), device_delegate_helper(nullptr) { } device_delegate(const basetype &src) : basetype(src), device_delegate_helper(src.m_device_name) { } device_delegate(const basetype &src, delegate_late_bind &object) : basetype(src, object), device_delegate_helper(src.m_device_name) { } template device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, _FunctionClass *object) : basetype(funcptr, name, object), device_delegate_helper(safe_tag(dynamic_cast(object))) { } @@ -62,12 +62,12 @@ public: // provide additional constructors that take a device name string template device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, const char *devname) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { } - template device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { } + template device_delegate(typename basetype::template traits<_FunctionClass>::member_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)nullptr), device_delegate_helper(devname) { } #ifdef USE_STATIC_DELEGATE template device_delegate(typename basetype::template traits<_FunctionClass>::static_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { } template device_delegate(typename basetype::template traits<_FunctionClass>::static_ref_func_type funcptr, const char *name, const char *devname, _FunctionClass *object) : basetype(funcptr, name, (_FunctionClass *)0), device_delegate_helper(devname) { } - device_delegate(typename basetype::template traits::static_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)0), device_delegate_helper(NULL) { } - device_delegate(typename basetype::template traits::static_ref_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)0), device_delegate_helper(NULL) { } + device_delegate(typename basetype::template traits::static_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)nullptr), device_delegate_helper(NULL) { } + device_delegate(typename basetype::template traits::static_ref_func_type funcptr, const char *name) : basetype(funcptr, name, (device_t *)nullptr), device_delegate_helper(NULL) { } #endif // and constructors that provide a search root diff --git a/src/emu/devfind.cpp b/src/emu/devfind.cpp index 0f6ee0a3a77..d251e56ce0b 100644 --- a/src/emu/devfind.cpp +++ b/src/emu/devfind.cpp @@ -44,15 +44,15 @@ void *finder_base::find_memregion(UINT8 width, size_t &length, bool required) co { // look up the region and return NULL if not found memory_region *region = m_base.memregion(m_tag); - if (region == NULL) - return NULL; + if (region == nullptr) + return nullptr; // check the width and warn if not correct if (region->bytewidth() != width) { if (required) osd_printf_warning("Region '%s' found but is width %d, not %d as requested\n", m_tag, region->bitwidth(), width*8); - return NULL; + return nullptr; } // return results @@ -69,15 +69,15 @@ void *finder_base::find_memshare(UINT8 width, size_t &bytes, bool required) { // look up the share and return NULL if not found memory_share *share = m_base.memshare(m_tag); - if (share == NULL) - return NULL; + if (share == nullptr) + return nullptr; // check the width and warn if not correct if (width != 0 && share->bitwidth() != width) { if (required) osd_printf_warning("Shared ptr '%s' found but is width %d, not %d as requested\n", m_tag, share->bitwidth(), width); - return NULL; + return nullptr; } // return results diff --git a/src/emu/devfind.h b/src/emu/devfind.h index f18e8343588..d16d7649e89 100644 --- a/src/emu/devfind.h +++ b/src/emu/devfind.h @@ -76,12 +76,12 @@ public: // construction/destruction object_finder_base(device_t &base, const char *tag) : finder_base(base, tag), - m_target(NULL) { } + m_target(nullptr) { } // operators to make use transparent operator _ObjectClass *() const { return m_target; } - virtual _ObjectClass *operator->() const { assert(m_target != NULL); return m_target; } + virtual _ObjectClass *operator->() const { assert(m_target != nullptr); return m_target; } // getter for explicit fetching _ObjectClass *target() const { return m_target; } @@ -107,18 +107,18 @@ public: : object_finder_base<_DeviceClass>(base, tag) { } // make reference use transparent as well - operator _DeviceClass &() { assert(object_finder_base<_DeviceClass>::m_target != NULL); return *object_finder_base<_DeviceClass>::m_target; } + operator _DeviceClass &() { assert(object_finder_base<_DeviceClass>::m_target != nullptr); return *object_finder_base<_DeviceClass>::m_target; } // finder virtual bool findit(bool isvalidation = false) { device_t *device = this->m_base.subdevice(this->m_tag); this->m_target = dynamic_cast<_DeviceClass *>(device); - if (device != NULL && this->m_target == NULL) + if (device != nullptr && this->m_target == nullptr) { this->printf_warning("Device '%s' found but is of incorrect type (actual type is %s)\n", this->m_tag, device->name()); } - return this->report_missing(this->m_target != NULL, "device", _Required); + return this->report_missing(this->m_target != nullptr, "device", _Required); } }; @@ -154,11 +154,11 @@ public: operator memory_region &() { assert(object_finder_base::m_target != NULL); return *object_finder_base::m_target; } // finder - virtual bool findit(bool isvalidation = false) + virtual bool findit(bool isvalidation = false) override { if (isvalidation) return true; m_target = m_base.memregion(m_tag); - return this->report_missing(m_target != NULL, "memory region", _Required); + return this->report_missing(m_target != nullptr, "memory region", _Required); } }; @@ -192,11 +192,11 @@ public: operator memory_bank &() { assert(object_finder_base::m_target != NULL); return *object_finder_base::m_target; } // finder - virtual bool findit(bool isvalidation = false) + virtual bool findit(bool isvalidation = false) override { if (isvalidation) return true; m_target = m_base.membank(m_tag); - return this->report_missing(m_target != NULL, "memory bank", _Required); + return this->report_missing(m_target != nullptr, "memory bank", _Required); } }; @@ -230,14 +230,14 @@ public: operator ioport_port &() { assert(object_finder_base::m_target != NULL); return *object_finder_base::m_target; } // allow dereference even when target is NULL so read_safe() can be used - ioport_port *operator->() const { return object_finder_base::m_target; } + ioport_port *operator->() const override { return object_finder_base::m_target; } // finder - virtual bool findit(bool isvalidation = false) + virtual bool findit(bool isvalidation = false) override { if (isvalidation) return true; m_target = m_base.ioport(m_tag); - return this->report_missing(m_target != NULL, "I/O port", _Required); + return this->report_missing(m_target != nullptr, "I/O port", _Required); } }; @@ -400,7 +400,7 @@ public: { if (isvalidation) return true; this->m_target = reinterpret_cast<_PointerType *>(this->find_memshare(m_width, m_bytes, _Required)); - return this->report_missing(this->m_target != NULL, "shared pointer", _Required); + return this->report_missing(this->m_target != nullptr, "shared pointer", _Required); } protected: diff --git a/src/emu/device.cpp b/src/emu/device.cpp index 5983c7f665d..b29466d8875 100644 --- a/src/emu/device.cpp +++ b/src/emu/device.cpp @@ -31,12 +31,12 @@ device_t::device_t(const machine_config &mconfig, device_type type, const char * m_searchpath(shortname), m_source(source), m_owner(owner), - m_next(NULL), + m_next(nullptr), - m_interface_list(NULL), - m_execute(NULL), - m_memory(NULL), - m_state(NULL), + m_interface_list(nullptr), + m_execute(nullptr), + m_memory(nullptr), + m_state(nullptr), m_configured_clock(clock), m_unscaled_clock(clock), @@ -44,21 +44,21 @@ device_t::device_t(const machine_config &mconfig, device_type type, const char * m_clock_scale(1.0), m_attoseconds_per_clock((clock == 0) ? 0 : HZ_TO_ATTOSECONDS(clock)), - m_region(NULL), + m_region(nullptr), m_machine_config(mconfig), - m_static_config(NULL), - m_input_defaults(NULL), + m_static_config(nullptr), + m_input_defaults(nullptr), m_default_bios_tag(""), - m_machine(NULL), - m_save(NULL), + m_machine(nullptr), + m_save(nullptr), m_basetag(tag), m_config_complete(false), m_started(false), - m_auto_finder_list(NULL) + m_auto_finder_list(nullptr) { - if (owner != NULL) - m_tag.assign((owner->owner() == NULL) ? "" : owner->tag()).append(":").append(tag); + if (owner != nullptr) + m_tag.assign((owner->owner() == nullptr) ? "" : owner->tag()).append(":").append(tag); else m_tag.assign(":"); static_set_clock(*this, clock); @@ -85,8 +85,8 @@ device_t::~device_t() memory_region *device_t::memregion(const char *_tag) const { // safety first - if (this == NULL) - return NULL; + if (this == nullptr) + return nullptr; // build a fully-qualified name and look it up return machine().memory().region(subtag(_tag).c_str()); @@ -101,8 +101,8 @@ memory_region *device_t::memregion(const char *_tag) const memory_share *device_t::memshare(const char *_tag) const { // safety first - if (this == NULL) - return NULL; + if (this == nullptr) + return nullptr; // build a fully-qualified name and look it up return machine().memory().shared(subtag(_tag).c_str()); @@ -117,8 +117,8 @@ memory_share *device_t::memshare(const char *_tag) const memory_bank *device_t::membank(const char *_tag) const { // safety first - if (this == NULL) - return NULL; + if (this == nullptr) + return nullptr; // build a fully-qualified name and look it up return machine().memory().bank(subtag(_tag).c_str()); @@ -133,8 +133,8 @@ memory_bank *device_t::membank(const char *_tag) const ioport_port *device_t::ioport(const char *tag) const { // safety first - if (this == NULL) - return NULL; + if (this == nullptr) + return nullptr; // build a fully-qualified name and look it up return machine().ioport().port(subtag(tag).c_str()); @@ -149,8 +149,8 @@ ioport_port *device_t::ioport(const char *tag) const std::string device_t::parameter(const char *tag) const { // safety first - if (this == NULL) - return NULL; + if (this == nullptr) + return nullptr; // build a fully-qualified name and look it up return machine().parameters().lookup(subtag(tag)); @@ -167,7 +167,7 @@ void device_t::static_set_clock(device_t &device, UINT32 clock) // derive the clock from our owner if requested if ((clock & 0xff000000) == 0xff000000) { - assert(device.m_owner != NULL); + assert(device.m_owner != nullptr); clock = device.m_owner->m_configured_clock * ((clock >> 12) & 0xfff) / ((clock >> 0) & 0xfff); } @@ -184,7 +184,7 @@ void device_t::static_set_clock(device_t &device, UINT32 clock) void device_t::config_complete() { // first notify the interfaces - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_config_complete(); // then notify the device itself @@ -203,7 +203,7 @@ void device_t::config_complete() void device_t::validity_check(validity_checker &valid) const { // validate via the interfaces - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_validity_check(valid); // let the device itself validate @@ -218,21 +218,21 @@ void device_t::validity_check(validity_checker &valid) const void device_t::reset() { // let the interfaces do their pre-work - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_pre_reset(); // reset the device device_reset(); // reset all child devices - for (device_t *child = m_subdevice_list.first(); child != NULL; child = child->next()) + for (device_t *child = m_subdevice_list.first(); child != nullptr; child = child->next()) child->reset(); // now allow for some post-child reset action device_reset_after_children(); // let the interfaces do their post-work - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_post_reset(); } @@ -335,7 +335,7 @@ void device_t::set_machine(running_machine &machine) bool device_t::findit(bool isvalidation) const { bool allfound = true; - for (finder_base *autodev = m_auto_finder_list; autodev != NULL; autodev = autodev->m_next) + for (finder_base *autodev = m_auto_finder_list; autodev != nullptr; autodev = autodev->m_next) allfound &= autodev->findit(isvalidation); return allfound; } @@ -354,7 +354,7 @@ void device_t::start() throw emu_fatalerror("Missing some required objects, unable to proceed"); // let the interfaces do their pre-work - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_pre_start(); // remember the number of state registrations @@ -375,7 +375,7 @@ void device_t::start() } // let the interfaces do their post-work - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_post_start(); // force an update of the clock @@ -405,14 +405,14 @@ void device_t::start() void device_t::stop() { // let the interfaces do their pre-work - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_pre_stop(); // stop the device device_stop(); // let the interfaces do their post-work - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_post_stop(); // free any debugging info @@ -420,7 +420,7 @@ void device_t::stop() // we're now officially stopped, and the machine is off-limits m_started = false; - m_machine = NULL; + m_machine = nullptr; } @@ -431,7 +431,7 @@ void device_t::stop() void device_t::debug_setup() { // notify the interface - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_debug_setup(); // notify the device @@ -447,7 +447,7 @@ void device_t::debug_setup() void device_t::pre_save() { // notify the interface - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_pre_save(); // notify the device @@ -463,7 +463,7 @@ void device_t::pre_save() void device_t::post_load() { // notify the interface - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_post_load(); // notify the device @@ -479,7 +479,7 @@ void device_t::post_load() void device_t::notify_clock_changed() { // first notify interfaces - for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + for (device_interface *intf = m_interface_list; intf != nullptr; intf = intf->interface_next()) intf->interface_clock_changed(); // then notify the device @@ -518,7 +518,7 @@ void device_t::device_validity_check(validity_checker &valid) const const rom_entry *device_t::device_rom_region() const { // none by default - return NULL; + return nullptr; } @@ -531,7 +531,7 @@ const rom_entry *device_t::device_rom_region() const machine_config_constructor device_t::device_mconfig_additions() const { // none by default - return NULL; + return nullptr; } @@ -543,7 +543,7 @@ machine_config_constructor device_t::device_mconfig_additions() const ioport_constructor device_t::device_input_ports() const { // none by default - return NULL; + return nullptr; } @@ -660,16 +660,16 @@ device_t *device_t::subdevice_slow(const char *tag) const // walk the device list to the final path device_t *curdevice = &mconfig().root_device(); if (fulltag.length() > 1) - for (int start = 1, end = fulltag.find_first_of(':', start); start != 0 && curdevice != NULL; start = end + 1, end = fulltag.find_first_of(':', start)) + for (int start = 1, end = fulltag.find_first_of(':', start); start != 0 && curdevice != nullptr; start = end + 1, end = fulltag.find_first_of(':', start)) { std::string part(fulltag, start, (end == -1) ? -1 : end - start); - for (curdevice = curdevice->m_subdevice_list.first(); curdevice != NULL; curdevice = curdevice->next()) + for (curdevice = curdevice->m_subdevice_list.first(); curdevice != nullptr; curdevice = curdevice->next()) if (part.compare(curdevice->m_basetag)==0) break; } // if we got a match, add to the fast map - if (curdevice != NULL) + if (curdevice != nullptr) m_device_map.add(tag, curdevice); return curdevice; } @@ -700,7 +700,7 @@ std::string device_t::subtag(const char *tag) const // iterate over the tag, look for special path characters to resolve const char *caret; - while ((caret = strchr(tag, '^')) != NULL) + while ((caret = strchr(tag, '^')) != nullptr) { // copy everything up to there result.append(tag, caret - tag); @@ -744,8 +744,8 @@ device_t *device_t::add_subdevice(device_type type, const char *tag, UINT32 cloc // apply any machine configuration owned by the device now machine_config_constructor additions = device->machine_config_additions(); - if (additions != NULL) - (*additions)(const_cast(mconfig()), device, NULL); + if (additions != nullptr) + (*additions)(const_cast(mconfig()), device, nullptr); return device; } @@ -759,7 +759,7 @@ device_t *device_t::replace_subdevice(device_t &old, device_type type, const cha { // iterate over all devices and remove any references to the old device device_iterator iter(mconfig().root_device()); - for (device_t *scan = iter.first(); scan != NULL; scan = iter.next()) + for (device_t *scan = iter.first(); scan != nullptr; scan = iter.next()) scan->m_device_map.reset(); //remove(&old); // create a new device, and substitute it for the old one @@ -768,8 +768,8 @@ device_t *device_t::replace_subdevice(device_t &old, device_type type, const cha // apply any machine configuration owned by the device now machine_config_constructor additions = device->machine_config_additions(); - if (additions != NULL) - (*additions)(const_cast(mconfig()), device, NULL); + if (additions != nullptr) + (*additions)(const_cast(mconfig()), device, nullptr); return device; } @@ -782,7 +782,7 @@ void device_t::remove_subdevice(device_t &device) { // iterate over all devices and remove any references device_iterator iter(mconfig().root_device()); - for (device_t *scan = iter.first(); scan != NULL; scan = iter.next()) + for (device_t *scan = iter.first(); scan != nullptr; scan = iter.next()) scan->m_device_map.reset(); //remove(&device); // remove from our list @@ -806,7 +806,7 @@ finder_base *device_t::register_auto_finder(finder_base &autodev) void device_t::popmessage(const char *format, ...) const { // if the format is NULL, it is a signal to clear the popmessage - if (format == NULL) + if (format == nullptr) machine().ui().popup_time(0, " "); // otherwise, generate the buffer and call the UI to display the message @@ -821,7 +821,7 @@ void device_t::popmessage(const char *format, ...) const va_end(arg); // pop it in the UI - if (m_machine!=NULL) machine().ui().popup_time(temp.length() / 40 + 2, "%s", temp.c_str()); + if (m_machine!=nullptr) machine().ui().popup_time(temp.length() / 40 + 2, "%s", temp.c_str()); } } @@ -836,7 +836,7 @@ void device_t::vlogerror(const char *format, va_list args) const { std::string fmt("["); fmt += tag() + std::string("] ") + format; - if (m_machine!=NULL) machine().vlogerror(fmt.c_str(), args); + if (m_machine!=nullptr) machine().vlogerror(fmt.c_str(), args); } //************************************************************************** @@ -848,12 +848,12 @@ void device_t::vlogerror(const char *format, va_list args) const //------------------------------------------------- device_interface::device_interface(device_t &device, const char *type) - : m_interface_next(NULL), + : m_interface_next(nullptr), m_device(device), m_type(type) { device_interface **tailptr; - for (tailptr = &device.m_interface_list; *tailptr != NULL; tailptr = &(*tailptr)->m_interface_next) { } + for (tailptr = &device.m_interface_list; *tailptr != nullptr; tailptr = &(*tailptr)->m_interface_next) { } *tailptr = this; } diff --git a/src/emu/device.h b/src/emu/device.h index 0d23d253866..3047adbcea0 100644 --- a/src/emu/device.h +++ b/src/emu/device.h @@ -134,24 +134,24 @@ public: // interface helpers device_interface *first_interface() const { return m_interface_list; } - template bool interface(_DeviceClass *&intf) { intf = dynamic_cast<_DeviceClass *>(this); return (intf != NULL); } - template bool interface(_DeviceClass *&intf) const { intf = dynamic_cast(this); return (intf != NULL); } + template bool interface(_DeviceClass *&intf) { intf = dynamic_cast<_DeviceClass *>(this); return (intf != nullptr); } + template bool interface(_DeviceClass *&intf) const { intf = dynamic_cast(this); return (intf != nullptr); } // specialized helpers for common core interfaces - bool interface(device_execute_interface *&intf) { intf = m_execute; return (intf != NULL); } - bool interface(device_execute_interface *&intf) const { intf = m_execute; return (intf != NULL); } - bool interface(device_memory_interface *&intf) { intf = m_memory; return (intf != NULL); } - bool interface(device_memory_interface *&intf) const { intf = m_memory; return (intf != NULL); } - bool interface(device_state_interface *&intf) { intf = m_state; return (intf != NULL); } - bool interface(device_state_interface *&intf) const { intf = m_state; return (intf != NULL); } - device_execute_interface &execute() const { assert(m_execute != NULL); return *m_execute; } - device_memory_interface &memory() const { assert(m_memory != NULL); return *m_memory; } - device_state_interface &state() const { assert(m_state != NULL); return *m_state; } + bool interface(device_execute_interface *&intf) { intf = m_execute; return (intf != nullptr); } + bool interface(device_execute_interface *&intf) const { intf = m_execute; return (intf != nullptr); } + bool interface(device_memory_interface *&intf) { intf = m_memory; return (intf != nullptr); } + bool interface(device_memory_interface *&intf) const { intf = m_memory; return (intf != nullptr); } + bool interface(device_state_interface *&intf) { intf = m_state; return (intf != nullptr); } + bool interface(device_state_interface *&intf) const { intf = m_state; return (intf != nullptr); } + device_execute_interface &execute() const { assert(m_execute != nullptr); return *m_execute; } + device_memory_interface &memory() const { assert(m_memory != nullptr); return *m_memory; } + device_state_interface &state() const { assert(m_state != nullptr); return *m_state; } // 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 != NULL && m_owner != NULL) ? m_owner->subtag(tag) : std::string(tag); } + std::string siblingtag(const char *tag) const { return (this != nullptr && 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; @@ -185,16 +185,16 @@ public: UINT64 attotime_to_clocks(const attotime &duration) const; // timer interfaces - emu_timer *timer_alloc(device_timer_id id = 0, void *ptr = NULL); - void timer_set(const attotime &duration, device_timer_id id = 0, int param = 0, void *ptr = NULL); - void synchronize(device_timer_id id = 0, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, id, param, ptr); } + emu_timer *timer_alloc(device_timer_id id = 0, void *ptr = nullptr); + void timer_set(const attotime &duration, device_timer_id id = 0, int param = 0, void *ptr = nullptr); + void synchronize(device_timer_id id = 0, int param = 0, void *ptr = nullptr) { timer_set(attotime::zero, id, param, ptr); } void timer_expired(emu_timer &timer, device_timer_id id, int param, void *ptr) { device_timer(timer, id, param, ptr); } // state saving interfaces template - void ATTR_COLD save_item(_ItemType &value, const char *valname, int index = 0) { assert(m_save != NULL); m_save->save_item(this, name(), tag(), index, value, valname); } + void ATTR_COLD save_item(_ItemType &value, const char *valname, int index = 0) { assert(m_save != nullptr); m_save->save_item(this, name(), tag(), index, value, valname); } template - void ATTR_COLD save_pointer(_ItemType *value, const char *valname, UINT32 count, int index = 0) { assert(m_save != NULL); m_save->save_pointer(this, name(), tag(), index, value, valname, count); } + void ATTR_COLD save_pointer(_ItemType *value, const char *valname, UINT32 count, int index = 0) { assert(m_save != nullptr); m_save->save_pointer(this, name(), tag(), index, value, valname, count); } // debugging device_debug *debug() const { return m_debug.get(); } @@ -355,7 +355,7 @@ public: // construction device_iterator(device_t &root, int maxdepth = 255) : m_root(&root), - m_current(NULL), + m_current(nullptr), m_curdepth(0), m_maxdepth(maxdepth) { } @@ -374,14 +374,14 @@ public: { // remember our starting position, and end immediately if we're NULL device_t *start = m_current; - if (start == NULL) - return NULL; + if (start == nullptr) + return nullptr; // search down first if (m_curdepth < m_maxdepth) { m_current = start->first_subdevice(); - if (m_current != NULL) + if (m_current != nullptr) { m_curdepth++; return m_current; @@ -393,7 +393,7 @@ public: { // found a neighbor? great! m_current = start->next(); - if (m_current != NULL) + if (m_current != nullptr) return m_current; // no? try our parent @@ -402,14 +402,14 @@ public: } // returned to the top; we're done - return m_current = NULL; + return m_current = nullptr; } // return the number of items available int count() { int result = 0; - for (device_t *item = first(); item != NULL; item = next()) + for (device_t *item = first(); item != nullptr; item = next()) result++; return result; } @@ -418,7 +418,7 @@ public: int indexof(device_t &device) { int index = 0; - for (device_t *item = first(); item != NULL; item = next(), index++) + for (device_t *item = first(); item != nullptr; item = next(), index++) if (item == &device) return index; return -1; @@ -427,10 +427,10 @@ public: // return the indexed item in the list device_t *byindex(int index) { - for (device_t *item = first(); item != NULL; item = next(), index--) + for (device_t *item = first(); item != nullptr; item = next(), index--) if (index == 0) return item; - return NULL; + return nullptr; } private: @@ -459,26 +459,26 @@ public: // reset and return first item _DeviceClass *first() { - for (device_t *device = m_iterator.first(); device != NULL; device = m_iterator.next()) + for (device_t *device = m_iterator.first(); device != nullptr; device = m_iterator.next()) if (device->type() == _DeviceType) return downcast<_DeviceClass *>(device); - return NULL; + return nullptr; } // advance depth-first _DeviceClass *next() { - for (device_t *device = m_iterator.next(); device != NULL; device = m_iterator.next()) + for (device_t *device = m_iterator.next(); device != nullptr; device = m_iterator.next()) if (device->type() == _DeviceType) return downcast<_DeviceClass *>(device); - return NULL; + return nullptr; } // return the number of items available int count() { int result = 0; - for (_DeviceClass *item = first(); item != NULL; item = next()) + for (_DeviceClass *item = first(); item != nullptr; item = next()) result++; return result; } @@ -487,7 +487,7 @@ public: int indexof(_DeviceClass &device) { int index = 0; - for (_DeviceClass *item = first(); item != NULL; item = next(), index++) + for (_DeviceClass *item = first(); item != nullptr; item = next(), index++) if (item == &device) return index; return -1; @@ -496,10 +496,10 @@ public: // return the indexed item in the list _DeviceClass *byindex(int index) { - for (_DeviceClass *item = first(); item != NULL; item = next(), index--) + for (_DeviceClass *item = first(); item != nullptr; item = next(), index--) if (index == 0) return item; - return NULL; + return nullptr; } private: @@ -519,7 +519,7 @@ public: // construction device_interface_iterator(device_t &root, int maxdepth = 255) : m_iterator(root, maxdepth), - m_current(NULL) { } + m_current(nullptr) { } // getters _InterfaceClass *current() const { return m_current; } @@ -527,26 +527,26 @@ public: // reset and return first item _InterfaceClass *first() { - for (device_t *device = m_iterator.first(); device != NULL; device = m_iterator.next()) + for (device_t *device = m_iterator.first(); device != nullptr; device = m_iterator.next()) if (device->interface(m_current)) return m_current; - return NULL; + return nullptr; } // advance depth-first _InterfaceClass *next() { - for (device_t *device = m_iterator.next(); device != NULL; device = m_iterator.next()) + for (device_t *device = m_iterator.next(); device != nullptr; device = m_iterator.next()) if (device->interface(m_current)) return m_current; - return NULL; + return nullptr; } // return the number of items available int count() { int result = 0; - for (_InterfaceClass *item = first(); item != NULL; item = next()) + for (_InterfaceClass *item = first(); item != nullptr; item = next()) result++; return result; } @@ -555,7 +555,7 @@ public: int indexof(_InterfaceClass &intrf) { int index = 0; - for (_InterfaceClass *item = first(); item != NULL; item = next(), index++) + for (_InterfaceClass *item = first(); item != nullptr; item = next(), index++) if (item == &intrf) return index; return -1; @@ -590,16 +590,16 @@ private: inline device_t *device_t::subdevice(const char *tag) const { // safety first - if (this == NULL) - return NULL; + if (this == nullptr) + return nullptr; // empty string or NULL means this device - if (tag == NULL || *tag == 0) + if (tag == nullptr || *tag == 0) return const_cast(this); // do a quick lookup and return that if possible device_t *quick = m_device_map.find(tag); - return (quick != NULL) ? quick : subdevice_slow(tag); + return (quick != nullptr) ? quick : subdevice_slow(tag); } @@ -611,22 +611,22 @@ inline device_t *device_t::subdevice(const char *tag) const inline device_t *device_t::siblingdevice(const char *tag) const { // safety first - if (this == NULL) - return NULL; + if (this == nullptr) + return nullptr; // empty string or NULL means this device - if (tag == NULL || *tag == 0) + if (tag == nullptr || *tag == 0) return const_cast(this); // leading caret implies the owner, just skip it if (tag[0] == '^') tag++; // query relative to the parent, if we have one - if (m_owner != NULL) + if (m_owner != nullptr) return m_owner->subdevice(tag); // otherwise, it's NULL unless the tag is absolute - return (tag[0] == ':') ? subdevice(tag) : NULL; + return (tag[0] == ':') ? subdevice(tag) : nullptr; } #endif /* __DEVICE_H__ */ diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp index 1e9e6d487a9..7b4b530f75b 100644 --- a/src/emu/diexec.cpp +++ b/src/emu/diexec.cpp @@ -44,13 +44,13 @@ const int TRIGGER_SUSPENDTIME = -4000; device_execute_interface::device_execute_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "execute"), m_disabled(false), - m_vblank_interrupt_screen(NULL), + m_vblank_interrupt_screen(nullptr), m_timed_interrupt_period(attotime::zero), m_is_octal(false), - m_nextexec(NULL), - m_timedint_timer(NULL), + m_nextexec(nullptr), + m_timedint_timer(nullptr), m_profiler(PROFILER_IDLE), - m_icountptr(NULL), + m_icountptr(nullptr), m_cycles_running(0), m_cycles_stolen(0), m_suspend(0), @@ -208,7 +208,7 @@ void device_execute_interface::abort_timeslice() return; // swallow the remaining cycles - if (m_icountptr != NULL) + if (m_icountptr != nullptr) { int delta = *m_icountptr; m_cycles_stolen += delta; @@ -449,9 +449,9 @@ void device_execute_interface::interface_validity_check(validity_checker &valid) if (!m_vblank_interrupt.isnull()) { screen_device_iterator iter(device().mconfig().root_device()); - if (iter.first() == NULL) + if (iter.first() == nullptr) osd_printf_error("VBLANK interrupt specified, but the driver is screenless\n"); - else if (m_vblank_interrupt_screen != NULL && device().siblingdevice(m_vblank_interrupt_screen) == NULL) + else if (m_vblank_interrupt_screen != nullptr && device().siblingdevice(m_vblank_interrupt_screen) == nullptr) osd_printf_error("VBLANK interrupt references a non-existant screen tag '%s'\n", m_vblank_interrupt_screen); } @@ -497,7 +497,7 @@ void device_execute_interface::interface_pre_start() void device_execute_interface::interface_post_start() { // make sure somebody set us up the icount - assert_always(m_icountptr != NULL, "m_icountptr never initialized!"); + assert_always(m_icountptr != nullptr, "m_icountptr never initialized!"); // register for save states device().save_item(NAME(m_suspend)); @@ -540,16 +540,16 @@ void device_execute_interface::interface_pre_reset() void device_execute_interface::interface_post_reset() { // reset the interrupt vectors and queues - for (int line = 0; line < ARRAY_LENGTH(m_input); line++) - m_input[line].reset(); + for (auto & elem : m_input) + elem.reset(); // reconfingure VBLANK interrupts - if (m_vblank_interrupt_screen != NULL) + if (m_vblank_interrupt_screen != nullptr) { // get the screen that will trigger the VBLANK screen_device *screen = downcast(device().machine().device(device().siblingtag(m_vblank_interrupt_screen).c_str())); - assert(screen != NULL); + assert(screen != nullptr); screen->register_vblank_callback(vblank_state_delegate(FUNC(device_execute_interface::on_vblank), this)); } @@ -557,7 +557,7 @@ void device_execute_interface::interface_post_reset() if (m_timed_interrupt_period != attotime::zero) { attotime timedint_period = m_timed_interrupt_period; - assert(m_timedint_timer != NULL); + assert(m_timedint_timer != nullptr); m_timedint_timer->adjust(timedint_period, 0, timedint_period); } } @@ -712,7 +712,7 @@ void device_execute_interface::trigger_periodic_interrupt() //------------------------------------------------- device_execute_interface::device_input::device_input() - : m_execute(NULL), + : m_execute(nullptr), m_linenum(0), m_stored_vector(0), m_curvector(0), diff --git a/src/emu/diexec.h b/src/emu/diexec.h index cd0e0f947e4..7f9eb41bfcf 100644 --- a/src/emu/diexec.h +++ b/src/emu/diexec.h @@ -155,7 +155,7 @@ public: static void static_set_irq_acknowledge_callback(device_t &device, device_irq_acknowledge_delegate callback); // execution management - device_scheduler &scheduler() const { assert(m_scheduler != NULL); return *m_scheduler; } + device_scheduler &scheduler() const { assert(m_scheduler != nullptr); return *m_scheduler; } bool executing() const; INT32 cycles_remaining() const; void eat_cycles(int cycles); @@ -211,12 +211,12 @@ protected: virtual void execute_set_input(int linenum, int state); // interface-level overrides - virtual void interface_validity_check(validity_checker &valid) const; - virtual void interface_pre_start(); - virtual void interface_post_start(); - virtual void interface_pre_reset(); - virtual void interface_post_reset(); - virtual void interface_clock_changed(); + virtual void interface_validity_check(validity_checker &valid) const override; + virtual void interface_pre_start() override; + virtual void interface_post_start() override; + virtual void interface_pre_reset() override; + virtual void interface_post_reset() override; + virtual void interface_clock_changed() override; // for use by devcpu for now... IRQ_CALLBACK_MEMBER(standard_irq_callback_member); diff --git a/src/emu/digfx.cpp b/src/emu/digfx.cpp index 65e1224c061..bed430e64f0 100644 --- a/src/emu/digfx.cpp +++ b/src/emu/digfx.cpp @@ -23,10 +23,10 @@ device_gfx_interface::device_gfx_interface(const machine_config &mconfig, device_t &device, const gfx_decode_entry *gfxinfo, const char *palette_tag) : device_interface(device, "gfx"), - m_palette(NULL), + m_palette(nullptr), m_gfxdecodeinfo(gfxinfo), m_palette_tag(palette_tag), - m_palette_is_sibling(palette_tag == NULL), + m_palette_is_sibling(palette_tag == nullptr), m_decoded(false) { } @@ -78,7 +78,7 @@ void device_gfx_interface::static_set_palette(device_t &device, const char *tag) void device_gfx_interface::interface_pre_start() { - if (m_palette_tag == NULL) + if (m_palette_tag == nullptr) fatalerror("No palette specified for device '%s'\n", device().tag()); // find our palette device, either as a sibling device or subdevice @@ -87,7 +87,7 @@ void device_gfx_interface::interface_pre_start() else m_palette = device().subdevice(m_palette_tag); - if (m_palette == NULL) + if (m_palette == nullptr) fatalerror("Device '%s' specifies nonexistent %sdevice '%s' as palette\n", device().tag(), (m_palette_is_sibling ? "sibling " : "sub"), @@ -119,7 +119,7 @@ void device_gfx_interface::interface_post_start() void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) { // skip if nothing to do - if (gfxdecodeinfo == NULL) + if (gfxdecodeinfo == nullptr) return; // local variables to hold mutable copies of gfx layout data @@ -128,7 +128,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) std::vector extyoffs(0); // loop over all elements - for (int curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != NULL; curgfx++) + for (int curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != nullptr; curgfx++) { const gfx_decode_entry &gfx = gfxdecodeinfo[curgfx]; @@ -143,13 +143,13 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) UINT8 region_width; endianness_t region_endianness; - if (gfx.memory_region != NULL) + if (gfx.memory_region != nullptr) { device_t &basedevice = (GFXENTRY_ISDEVICE(gfx.flags)) ? device() : *device().owner(); if (GFXENTRY_ISRAM(gfx.flags)) { memory_share *share = basedevice.memshare(gfx.memory_region); - assert(share != NULL); + assert(share != nullptr); region_length = 8 * share->bytes(); region_base = reinterpret_cast(share->ptr()); region_width = share->bytewidth(); @@ -158,7 +158,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) else { memory_region *region = basedevice.memregion(gfx.memory_region); - assert(region != NULL); + assert(region != nullptr); region_length = 8 * region->bytes(); region_base = region->base(); region_width = region->bytewidth(); @@ -168,7 +168,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) else { region_length = 0; - region_base = NULL; + region_base = nullptr; region_width = 1; region_endianness = ENDIANNESS_NATIVE; } @@ -205,8 +205,8 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) // copy the X and Y offsets into our temporary arrays extxoffs.resize(glcopy.width * xscale); extyoffs.resize(glcopy.height * yscale); - memcpy(&extxoffs[0], (glcopy.extxoffs != NULL) ? glcopy.extxoffs : glcopy.xoffset, glcopy.width * sizeof(UINT32)); - memcpy(&extyoffs[0], (glcopy.extyoffs != NULL) ? glcopy.extyoffs : glcopy.yoffset, glcopy.height * sizeof(UINT32)); + memcpy(&extxoffs[0], (glcopy.extxoffs != nullptr) ? glcopy.extxoffs : glcopy.xoffset, glcopy.width * sizeof(UINT32)); + memcpy(&extyoffs[0], (glcopy.extyoffs != nullptr) ? glcopy.extyoffs : glcopy.yoffset, glcopy.height * sizeof(UINT32)); // always use the extended offsets here glcopy.extxoffs = &extxoffs[0]; @@ -276,7 +276,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) } // allocate the graphics - m_gfx[curgfx] = std::make_unique(m_palette, glcopy, (region_base != NULL) ? region_base + gfx.start : NULL, xormask, gfx.total_color_codes, gfx.color_codes_start); + m_gfx[curgfx] = std::make_unique(m_palette, glcopy, (region_base != nullptr) ? region_base + gfx.start : nullptr, xormask, gfx.total_color_codes, gfx.color_codes_start); } m_decoded = true; @@ -291,7 +291,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) void device_gfx_interface::interface_validity_check(validity_checker &valid) const { // validate palette tag - if (m_palette_tag == NULL) + if (m_palette_tag == nullptr) osd_printf_error("No palette specified for device '%s'\n", device().tag()); else { @@ -301,7 +301,7 @@ void device_gfx_interface::interface_validity_check(validity_checker &valid) con else palette = device().subdevice(m_palette_tag); - if (palette == NULL) + if (palette == nullptr) osd_printf_error("Device '%s' specifies nonexistent %sdevice '%s' as palette\n", device().tag(), (m_palette_is_sibling ? "sibling " : "sub"), @@ -312,14 +312,14 @@ void device_gfx_interface::interface_validity_check(validity_checker &valid) con return; // validate graphics decoding entries - for (int gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && m_gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++) + for (int gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && m_gfxdecodeinfo[gfxnum].gfxlayout != nullptr; gfxnum++) { const gfx_decode_entry &gfx = m_gfxdecodeinfo[gfxnum]; const gfx_layout &layout = *gfx.gfxlayout; // currently we are unable to validate RAM-based entries const char *region = gfx.memory_region; - if (region != NULL && GFXENTRY_ISROM(gfx.flags)) + if (region != nullptr && GFXENTRY_ISROM(gfx.flags)) { // resolve the region std::string gfxregion; @@ -372,9 +372,9 @@ void device_gfx_interface::interface_validity_check(validity_checker &valid) con { if (layout.planes > MAX_GFX_PLANES) osd_printf_error("gfx[%d] planes > %d\n", gfxnum, MAX_GFX_PLANES); - if (layout.width > MAX_GFX_SIZE && layout.extxoffs == NULL) + if (layout.width > MAX_GFX_SIZE && layout.extxoffs == nullptr) osd_printf_error("gfx[%d] width > %d but missing extended xoffset info\n", gfxnum, MAX_GFX_SIZE); - if (layout.height > MAX_GFX_SIZE && layout.extyoffs == NULL) + if (layout.height > MAX_GFX_SIZE && layout.extyoffs == nullptr) osd_printf_error("gfx[%d] height > %d but missing extended yoffset info\n", gfxnum, MAX_GFX_SIZE); } } diff --git a/src/emu/digfx.h b/src/emu/digfx.h index 63f84d09c89..3dfe042f3f1 100644 --- a/src/emu/digfx.h +++ b/src/emu/digfx.h @@ -159,8 +159,8 @@ class palette_device; struct gfx_layout { - UINT32 xoffs(int x) const { return (extxoffs != NULL) ? extxoffs[x] : xoffset[x]; } - UINT32 yoffs(int y) const { return (extyoffs != NULL) ? extyoffs[y] : yoffset[y]; } + UINT32 xoffs(int x) const { return (extxoffs != nullptr) ? extxoffs[x] : xoffset[x]; } + UINT32 yoffs(int y) const { return (extyoffs != nullptr) ? extyoffs[y] : yoffset[y]; } UINT16 width; // pixel width of each element UINT16 height; // pixel height of each element @@ -191,7 +191,7 @@ class device_gfx_interface : public device_interface public: // construction/destruction device_gfx_interface(const machine_config &mconfig, device_t &device, - const gfx_decode_entry *gfxinfo = NULL, const char *palette_tag = NULL); + const gfx_decode_entry *gfxinfo = nullptr, const char *palette_tag = nullptr); virtual ~device_gfx_interface(); // static configuration @@ -210,9 +210,9 @@ public: protected: // interface-level overrides - virtual void interface_validity_check(validity_checker &valid) const; - virtual void interface_pre_start(); - virtual void interface_post_start(); + virtual void interface_validity_check(validity_checker &valid) const override; + virtual void interface_pre_start() override; + virtual void interface_post_start() override; palette_device * m_palette; // pointer to the palette device std::unique_ptr m_gfx[MAX_GFX_ELEMENTS]; // array of pointers to graphic sets diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index 57a73dc66a8..c0104da34e2 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -56,17 +56,17 @@ const image_device_type_info device_image_interface::m_device_info_array[] = device_image_interface::device_image_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "image"), m_err(), - m_file(NULL), - m_mame_file(NULL), - m_software_info_ptr(NULL), - m_software_part_ptr(NULL), + m_file(nullptr), + m_mame_file(nullptr), + m_software_info_ptr(nullptr), + m_software_part_ptr(nullptr), m_supported(0), m_readonly(false), m_created(false), m_init_phase(false), m_from_swlist(false), m_create_format(0), - m_create_args(NULL), + m_create_args(nullptr), m_is_loading(FALSE) { } @@ -93,7 +93,7 @@ const image_device_type_info *device_image_interface::find_device_type(iodevice_ if (m_device_info_array[i].m_type == type) return &m_device_info_array[i]; } - return NULL; + return nullptr; } //------------------------------------------------- @@ -103,7 +103,7 @@ const image_device_type_info *device_image_interface::find_device_type(iodevice_ const char *device_image_interface::device_typename(iodevice_t type) { const image_device_type_info *info = find_device_type(type); - return (info != NULL) ? info->m_name : NULL; + return (info != nullptr) ? info->m_name : nullptr; } //------------------------------------------------- @@ -114,7 +114,7 @@ const char *device_image_interface::device_typename(iodevice_t type) const char *device_image_interface::device_brieftypename(iodevice_t type) { const image_device_type_info *info = find_device_type(type); - return (info != NULL) ? info->m_shortname : NULL; + return (info != nullptr) ? info->m_shortname : nullptr; } //------------------------------------------------- @@ -200,10 +200,10 @@ image_error_t device_image_interface::set_image_filename(const char *filename) const image_device_format *device_image_interface::device_get_named_creatable_format(const char *format_name) { - for (const image_device_format *format = m_formatlist.first(); format != NULL; format = format->next()) + for (const image_device_format *format = m_formatlist.first(); format != nullptr; format = format->next()) if (strcmp(format->name(), format_name) == 0) return format; - return NULL; + return nullptr; } /**************************************************************************** @@ -257,7 +257,7 @@ void device_image_interface::seterror(image_error_t err, const char *message) { clear_error(); m_err = err; - if (message != NULL) + if (message != nullptr) { m_err_message = message; } @@ -304,9 +304,9 @@ bool device_image_interface::try_change_working_directory(const char *subdir) bool done = FALSE; directory = osd_opendir(m_working_directory.c_str()); - if (directory != NULL) + if (directory != nullptr) { - while(!done && (entry = osd_readdir(directory)) != NULL) + while(!done && (entry = osd_readdir(directory)) != nullptr) { if (!core_stricmp(subdir, entry->name)) { @@ -331,7 +331,7 @@ bool device_image_interface::try_change_working_directory(const char *subdir) void device_image_interface::setup_working_directory() { - char *dst = NULL; + char *dst = nullptr; osd_get_full_path(&dst,"."); /* first set up the working directory to be the starting directory */ @@ -374,8 +374,8 @@ UINT8 *device_image_interface::get_software_region(const char *tag) { char full_tag[256]; - if ( m_software_info_ptr == NULL || m_software_part_ptr == NULL ) - return NULL; + if ( m_software_info_ptr == nullptr || m_software_part_ptr == nullptr ) + return nullptr; sprintf( full_tag, "%s:%s", device().tag(), tag ); return device().machine().root_device().memregion( full_tag )->base(); @@ -401,7 +401,7 @@ UINT32 device_image_interface::get_software_region_length(const char *tag) const char *device_image_interface::get_feature(const char *feature_name) { - return (m_software_part_ptr == NULL) ? NULL : m_software_part_ptr->feature(feature_name); + return (m_software_part_ptr == nullptr) ? nullptr : m_software_part_ptr->feature(feature_name); } @@ -546,14 +546,14 @@ bool device_image_interface::uses_file_extension(const char *file_extension) con /* find the extensions */ std::string extensions(file_extensions()); char *ext = strtok((char*)extensions.c_str(),","); - while (ext != NULL) + while (ext != nullptr) { if (!core_stricmp(ext, file_extension)) { result = TRUE; break; } - ext = strtok (NULL, ","); + ext = strtok (nullptr, ","); } return result; } @@ -569,7 +569,7 @@ bool device_image_interface::uses_file_extension(const char *file_extension) con bool device_image_interface::is_loaded() { - return (m_file != NULL); + return (m_file != nullptr); } /*------------------------------------------------- @@ -724,7 +724,7 @@ static void dump_wrong_and_correct_checksums(const hash_collection &hashes, cons static int verify_length_and_hash(emu_file *file, const char *name, UINT32 explength, const hash_collection &hashes) { int retVal = 0; - if (file==NULL) return 0; + if (file==nullptr) return 0; /* verify length */ UINT32 actlength = file->size(); @@ -767,7 +767,7 @@ bool device_image_interface::load_software(software_list_device &swlist, const c const rom_entry *region; bool retVal = FALSE; int warningcount = 0; - for (region = start; region != NULL; region = rom_next_region(region)) + for (region = start; region != nullptr; region = rom_next_region(region)) { /* loop until we hit the end of this region */ const rom_entry *romp = region + 1; @@ -782,7 +782,7 @@ bool device_image_interface::load_software(software_list_device &swlist, const c bool has_crc = hash_collection(ROM_GETHASHDATA(romp)).crc(crc); software_info *swinfo = swlist.find(swname); - if (swinfo == NULL) + if (swinfo == nullptr) return false; UINT32 supported = swinfo->supported(); @@ -795,11 +795,11 @@ bool device_image_interface::load_software(software_list_device &swlist, const c // " swlist % clonename % parentname " // below, we have the code to split the elements and to create paths to load from - while (swinfo != NULL) + while (swinfo != nullptr) { locationtag.append(swinfo->shortname()).append(breakstr); const char *parentname = swinfo->parentname(); - swinfo = (parentname != NULL) ? swlist.find(parentname) : NULL; + swinfo = (parentname != nullptr) ? swlist.find(parentname) : nullptr; } // strip the final '%' locationtag.erase(locationtag.length() - 1, 1); @@ -831,16 +831,16 @@ bool device_image_interface::load_software(software_list_device &swlist, const c // - if we are not using lists, we have regiontag only; // - if we are using lists, we have: list/clonename, list/parentname, clonename, parentname // try to load from list/setname - if ((m_mame_file == NULL) && (tag2.c_str() != NULL)) + if ((m_mame_file == nullptr) && (tag2.c_str() != nullptr)) filerr = common_process_file(device().machine().options(), tag2.c_str(), has_crc, crc, romp, &m_mame_file); // try to load from list/parentname - if ((m_mame_file == NULL) && (tag3.c_str() != NULL)) + if ((m_mame_file == nullptr) && (tag3.c_str() != nullptr)) filerr = common_process_file(device().machine().options(), tag3.c_str(), has_crc, crc, romp, &m_mame_file); // try to load from setname - if ((m_mame_file == NULL) && (tag4.c_str() != NULL)) + if ((m_mame_file == nullptr) && (tag4.c_str() != nullptr)) filerr = common_process_file(device().machine().options(), tag4.c_str(), has_crc, crc, romp, &m_mame_file); // try to load from parentname - if ((m_mame_file == NULL) && (tag5.c_str() != NULL)) + if ((m_mame_file == nullptr) && (tag5.c_str() != nullptr)) filerr = common_process_file(device().machine().options(), tag5.c_str(), has_crc, crc, romp, &m_mame_file); warningcount += verify_length_and_hash(m_mame_file,ROM_GETNAME(romp),ROM_GETLENGTH(romp),hash_collection(ROM_GETHASHDATA(romp))); @@ -939,7 +939,7 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int if ( m_software_info_ptr ) { // sanitize - if (m_software_info_ptr->longname() == NULL || m_software_info_ptr->publisher() == NULL || m_software_info_ptr->year() == NULL) + if (m_software_info_ptr->longname() == nullptr || m_software_info_ptr->publisher() == nullptr || m_software_info_ptr->year() == nullptr) fatalerror("Each entry in an XML list must have all of the following fields: description, publisher, year!\n"); // store @@ -1009,7 +1009,7 @@ done: bool device_image_interface::load(const char *path) { - return load_internal(path, FALSE, 0, NULL, FALSE); + return load_internal(path, FALSE, 0, nullptr, FALSE); } /*------------------------------------------------- @@ -1022,9 +1022,9 @@ bool device_image_interface::open_image_file(emu_options &options) if (*path != 0) { set_init_phase(); - if (load_internal(path, FALSE, 0, NULL, TRUE)==IMAGE_INIT_PASS) + if (load_internal(path, FALSE, 0, nullptr, TRUE)==IMAGE_INIT_PASS) { - if (software_entry()==NULL) return true; + if (software_entry()==nullptr) return true; } } return false; @@ -1065,7 +1065,7 @@ bool device_image_interface::finish_load() } m_is_loading = FALSE; m_create_format = 0; - m_create_args = NULL; + m_create_args = nullptr; m_init_phase = FALSE; return err; } @@ -1076,7 +1076,7 @@ bool device_image_interface::finish_load() bool device_image_interface::create(const char *path, const image_device_format *create_format, option_resolution *create_args) { - int format_index = (create_format != NULL) ? m_formatlist.indexof(*create_format) : 0; + int format_index = (create_format != nullptr) ? m_formatlist.indexof(*create_format) : 0; return load_internal(path, TRUE, format_index, create_args, FALSE); } @@ -1091,13 +1091,13 @@ void device_image_interface::clear() if (m_mame_file) { global_free(m_mame_file); - m_mame_file = NULL; - m_file = NULL; + m_mame_file = nullptr; + m_file = nullptr; } else { if (m_file) { core_fclose(m_file); - m_file = NULL; + m_file = nullptr; } } @@ -1113,8 +1113,8 @@ void device_image_interface::clear() m_filetype.clear(); m_full_software_name.clear(); - m_software_info_ptr = NULL; - m_software_part_ptr = NULL; + m_software_info_ptr = nullptr; + m_software_part_ptr = nullptr; m_software_list_name.clear(); } @@ -1141,15 +1141,15 @@ void device_image_interface::update_names(const device_type device_type, const c image_interface_iterator iter(device().mconfig().root_device()); int count = 0; int index = -1; - for (const device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { if (this == image) index = count; - if ((image->image_type() == image_type() && device_type==NULL) || (device_type==image->device().type())) + if ((image->image_type() == image_type() && device_type==nullptr) || (device_type==image->device().type())) count++; } - const char *inst_name = (device_type!=NULL) ? inst : device_typename(image_type()); - const char *brief_name = (device_type!=NULL) ? brief : device_brieftypename(image_type()); + const char *inst_name = (device_type!=nullptr) ? inst : device_typename(image_type()); + const char *brief_name = (device_type!=nullptr) ? brief : device_brieftypename(image_type()); if (count > 1) { strprintf(m_instance_name,"%s%d", inst_name, index + 1); @@ -1187,7 +1187,7 @@ void device_image_interface::software_name_split(const char *swlist_swname, std: // if no colon, this is the swname by itself const char *split1 = strchr(swlist_swname, ':'); - if (split1 == NULL) + if (split1 == nullptr) { swname.assign(swlist_swname); return; @@ -1195,7 +1195,7 @@ void device_image_interface::software_name_split(const char *swlist_swname, std: // if one colon, it is the swname and swpart alone const char *split2 = strchr(split1 + 1, ':'); - if (split2 == NULL) + if (split2 == nullptr) { swname.assign(swlist_swname, split1 - swlist_swname); swpart.assign(split1 + 1); @@ -1216,21 +1216,21 @@ software_part *device_image_interface::find_software_item(const char *path, bool software_name_split(path, swlist_name, swinfo_name, swpart_name); // determine interface - const char *interface = NULL; + const char *interface = nullptr; if (restrict_to_interface) interface = image_interface(); // find the software list if explicitly specified software_list_device_iterator deviter(device().mconfig().root_device()); - for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next()) + for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) { if (swlist_name.compare(swlistdev->list_name())==0 || !(swlist_name.length() > 0)) { software_info *info = swlistdev->find(swinfo_name.c_str()); - if (info != NULL) + if (info != nullptr) { software_part *part = info->find_part(swpart_name.c_str(), interface); - if (part != NULL) + if (part != nullptr) return part; } } @@ -1242,17 +1242,17 @@ software_part *device_image_interface::find_software_item(const char *path, bool // since the function cannot distinguish between this and the case // path = swinfo_name:swpart_name software_info *info = swlistdev->find(swpart_name.c_str()); - if (info != NULL) + if (info != nullptr) { - software_part *part = info->find_part(NULL, interface); - if (part != NULL) + software_part *part = info->find_part(nullptr, interface); + if (part != nullptr) return part; } } } // if explicitly specified and not found, just error here - return NULL; + return nullptr; } @@ -1273,7 +1273,7 @@ bool device_image_interface::load_software_part(const char *path, software_part { // if no match has been found, we suggest similar shortnames swpart = find_software_item(path, true); - if (swpart == NULL) + if (swpart == nullptr) { software_list_device::display_matches(device().machine().config(), image_interface(), path); return false; @@ -1292,16 +1292,16 @@ bool device_image_interface::load_software_part(const char *path, software_part // check requirements and load those images const char *requirement = swpart->feature("requirement"); - if (requirement != NULL) + if (requirement != nullptr) { software_part *req_swpart = find_software_item(requirement, false); - if (req_swpart != NULL) + if (req_swpart != nullptr) { image_interface_iterator imgiter(device().machine().root_device()); - for (device_image_interface *req_image = imgiter.first(); req_image != NULL; req_image = imgiter.next()) + for (device_image_interface *req_image = imgiter.first(); req_image != nullptr; req_image = imgiter.next()) { const char *interface = req_image->image_interface(); - if (interface != NULL) + if (interface != nullptr) { if (req_swpart->matches_interface(interface)) { @@ -1333,10 +1333,10 @@ void device_image_interface::software_get_default_slot(std::string &result, cons { result.assign(default_card_slot); software_part *swpart = find_software_item(path, true); - if (swpart != NULL) + if (swpart != nullptr) { const char *slot = swpart->feature("slot"); - if (slot != NULL) + if (slot != nullptr) result.assign(slot); } } diff --git a/src/emu/diimage.h b/src/emu/diimage.h index b2aa398396a..e699194fd6c 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -73,7 +73,7 @@ class image_device_format public: image_device_format(const char *name, const char *description, const char *extensions, const char *optspec) - : m_next(NULL), + : m_next(nullptr), m_name(name), m_description(description), m_extensions(extensions), @@ -149,7 +149,7 @@ public: virtual bool call_create(int format_type, option_resolution *format_options) { return FALSE; } virtual void call_unload() { } virtual void call_display() { } - virtual device_image_partialhash_func get_partial_hash() const { return NULL; } + virtual device_image_partialhash_func get_partial_hash() const { return nullptr; } virtual bool core_opens_image_file() const { return TRUE; } virtual iodevice_t image_type() const = 0; virtual bool is_readable() const = 0; @@ -157,7 +157,7 @@ public: virtual bool is_creatable() const = 0; virtual bool must_be_loaded() const = 0; virtual bool is_reset_on_load() const = 0; - virtual const char *image_interface() const { return NULL; } + virtual const char *image_interface() const { return nullptr; } virtual const char *file_extensions() const = 0; virtual const option_guide *create_option_guide() const = 0; @@ -172,10 +172,10 @@ public: void message(const char *format, ...) ATTR_PRINTF(2,3); bool exists() { return !m_image_name.empty(); } - const char *filename() { if (m_image_name.empty()) return NULL; else return m_image_name.c_str(); } - const char *basename() { if (m_basename.empty()) return NULL; else return m_basename.c_str(); } - const char *basename_noext() { if (m_basename_noext.empty()) return NULL; else return m_basename_noext.c_str(); } - const char *filetype() { if (m_filetype.empty()) return NULL; else return m_filetype.c_str(); } + const char *filename() { if (m_image_name.empty()) return nullptr; else return m_image_name.c_str(); } + const char *basename() { if (m_basename.empty()) return nullptr; else return m_basename.c_str(); } + const char *basename_noext() { if (m_basename_noext.empty()) return nullptr; else return m_basename_noext.c_str(); } + const char *filetype() { if (m_filetype.empty()) return nullptr; else return m_filetype.c_str(); } core_file *image_core_file() { return m_file; } UINT64 length() { check_for_file(); return core_fsize(m_file); } bool is_readonly() { return m_readonly; } @@ -248,14 +248,14 @@ protected: void clear_error(); - void check_for_file() { assert_always(m_file != NULL, "Illegal operation on unmounted image"); } + void check_for_file() { assert_always(m_file != nullptr, "Illegal operation on unmounted image"); } void setup_working_directory(); bool try_change_working_directory(const char *subdir); void run_hash(void (*partialhash)(hash_collection &, const unsigned char *, unsigned long, const char *), hash_collection &hashes, const char *types); void image_checkhash(); - void update_names(const device_type device_type = NULL, const char *inst = NULL, const char *brief = NULL); + void update_names(const device_type device_type = nullptr, const char *inst = nullptr, const char *brief = nullptr); software_part *find_software_item(const char *path, bool restrict_to_interface); bool load_software_part(const char *path, software_part *&swpart); diff --git a/src/emu/dimemory.cpp b/src/emu/dimemory.cpp index 0306774feae..0650ebfab70 100644 --- a/src/emu/dimemory.cpp +++ b/src/emu/dimemory.cpp @@ -44,8 +44,8 @@ address_space_config::address_space_config() m_addrbus_shift(0), m_logaddr_width(0), m_page_shift(0), - m_internal_map(NULL), - m_default_map(NULL) + m_internal_map(nullptr), + m_default_map(nullptr) { } @@ -92,10 +92,10 @@ address_space_config::address_space_config(const char *name, endianness_t endian m_addrbus_shift(addrshift), m_logaddr_width(addrwidth), m_page_shift(0), - m_internal_map(NULL), - m_default_map(NULL), - m_internal_map_delegate(internal), - m_default_map_delegate(defmap) + m_internal_map(nullptr), + m_default_map(nullptr), + m_internal_map_delegate(std::move(internal)), + m_default_map_delegate(std::move(defmap)) { } @@ -107,10 +107,10 @@ address_space_config::address_space_config(const char *name, endianness_t endian m_addrbus_shift(addrshift), m_logaddr_width(logwidth), m_page_shift(pageshift), - m_internal_map(NULL), - m_default_map(NULL), - m_internal_map_delegate(internal), - m_default_map_delegate(defmap) + m_internal_map(nullptr), + m_default_map(nullptr), + m_internal_map_delegate(std::move(internal)), + m_default_map_delegate(std::move(defmap)) { } @@ -244,16 +244,16 @@ void device_memory_interface::interface_validity_check(validity_checker &valid) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) { const address_space_config *spaceconfig = space_config(spacenum); - if (spaceconfig != NULL) + if (spaceconfig != nullptr) { int datawidth = spaceconfig->m_databus_width; int alignunit = datawidth / 8; // construct the maps - ::address_map *map = global_alloc(::address_map(const_cast(device()), spacenum)); + auto map = global_alloc(::address_map(const_cast(device()), spacenum)); // if this is an empty map, just skip it - if (map->m_entrylist.first() == NULL) + if (map->m_entrylist.first() == nullptr) { global_free(map); continue; @@ -266,7 +266,7 @@ void device_memory_interface::interface_validity_check(validity_checker &valid) osd_printf_error("Wrong memory handlers provided for %s space! (width = %d, memory = %08x)\n", spaceconfig->m_name, datawidth, map->m_databits); // loop over entries and look for errors - for (address_map_entry *entry = map->m_entrylist.first(); entry != NULL; entry = entry->next()) + for (address_map_entry *entry = map->m_entrylist.first(); entry != nullptr; entry = entry->next()) { UINT32 bytestart = spaceconfig->addr2byte(entry->m_addrstart); UINT32 byteend = spaceconfig->addr2byte_end(entry->m_addrend); @@ -295,14 +295,14 @@ void device_memory_interface::interface_validity_check(validity_checker &valid) osd_printf_error("Wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, alignunit); // if this is a program space, auto-assign implicit ROM entries - if (entry->m_read.m_type == AMH_ROM && entry->m_region == NULL) + if (entry->m_read.m_type == AMH_ROM && entry->m_region == nullptr) { entry->m_region = device().tag(); entry->m_rgnoffs = entry->m_addrstart; } // if this entry references a memory region, validate it - if (entry->m_region != NULL && entry->m_share == 0) + if (entry->m_region != nullptr && entry->m_share == nullptr) { // make sure we can resolve the full path to the region bool found = false; @@ -310,8 +310,8 @@ void device_memory_interface::interface_validity_check(validity_checker &valid) // look for the region device_iterator deviter(device().mconfig().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) - for (const rom_entry *romp = rom_first_region(*device); romp != NULL && !found; romp = rom_next_region(romp)) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) + for (const rom_entry *romp = rom_first_region(*device); romp != nullptr && !found; romp = rom_next_region(romp)) { if (rom_region_name(*device, romp) == entry_region) { @@ -330,16 +330,16 @@ void device_memory_interface::interface_validity_check(validity_checker &valid) // make sure all devices exist // FIXME: This doesn't work! AMH_DEVICE_DELEGATE entries don't even set m_tag, the device tag is inside the proto-delegate - if (entry->m_read.m_type == AMH_DEVICE_DELEGATE && entry->m_read.m_tag != NULL) + if (entry->m_read.m_type == AMH_DEVICE_DELEGATE && entry->m_read.m_tag != nullptr) { std::string temp(entry->m_read.m_tag); - if (device().siblingdevice(temp.c_str()) == NULL) + if (device().siblingdevice(temp.c_str()) == nullptr) osd_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_read.m_tag); } - if (entry->m_write.m_type == AMH_DEVICE_DELEGATE && entry->m_write.m_tag != NULL) + if (entry->m_write.m_type == AMH_DEVICE_DELEGATE && entry->m_write.m_tag != nullptr) { std::string temp(entry->m_write.m_tag); - if (device().siblingdevice(temp.c_str()) == NULL) + if (device().siblingdevice(temp.c_str()) == nullptr) osd_printf_error("%s space memory map entry references nonexistant device '%s'\n", spaceconfig->m_name, entry->m_write.m_tag); } @@ -353,7 +353,7 @@ void device_memory_interface::interface_validity_check(validity_checker &valid) valid.validate_tag(entry->m_read.m_tag); if (entry->m_write.m_type == AMH_BANK) valid.validate_tag(entry->m_write.m_tag); - if (entry->m_share != NULL) + if (entry->m_share != nullptr) valid.validate_tag(entry->m_share); } diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h index 5255aadb3da..66561b5a5cf 100644 --- a/src/emu/dimemory.h +++ b/src/emu/dimemory.h @@ -79,19 +79,19 @@ public: virtual ~device_memory_interface(); // configuration access - address_map_constructor address_map(address_spacenum spacenum = AS_0) const { return (spacenum < ARRAY_LENGTH(m_address_map)) ? m_address_map[spacenum] : NULL; } + address_map_constructor address_map(address_spacenum spacenum = AS_0) const { return (spacenum < ARRAY_LENGTH(m_address_map)) ? m_address_map[spacenum] : nullptr; } const address_space_config *space_config(address_spacenum spacenum = AS_0) const { return memory_space_config(spacenum); } // static inline configuration helpers static void static_set_addrmap(device_t &device, address_spacenum spacenum, address_map_constructor map); // basic information getters - bool has_space(int index = 0) const { return (m_addrspace[index] != NULL); } - bool has_space(address_spacenum index) const { return (m_addrspace[int(index)] != NULL); } - bool has_configured_map(int index = 0) const { return (m_address_map[index] != NULL); } - bool has_configured_map(address_spacenum index) const { return (m_address_map[int(index)] != NULL); } - address_space &space(int index = 0) const { assert(m_addrspace[index] != NULL); return *m_addrspace[index]; } - address_space &space(address_spacenum index) const { assert(m_addrspace[int(index)] != NULL); return *m_addrspace[int(index)]; } + bool has_space(int index = 0) const { return (m_addrspace[index] != nullptr); } + bool has_space(address_spacenum index) const { return (m_addrspace[int(index)] != nullptr); } + bool has_configured_map(int index = 0) const { return (m_address_map[index] != nullptr); } + bool has_configured_map(address_spacenum index) const { return (m_address_map[int(index)] != nullptr); } + address_space &space(int index = 0) const { assert(m_addrspace[index] != nullptr); return *m_addrspace[index]; } + address_space &space(address_spacenum index) const { assert(m_addrspace[int(index)] != nullptr); return *m_addrspace[int(index)]; } // address space accessors void set_address_space(address_spacenum spacenum, address_space &space); @@ -119,7 +119,7 @@ protected: virtual bool memory_readop(offs_t offset, int size, UINT64 &value); // interface-level overrides - virtual void interface_validity_check(validity_checker &valid) const; + virtual void interface_validity_check(validity_checker &valid) const override; // configuration address_map_constructor m_address_map[ADDRESS_SPACES]; // address maps for each address space diff --git a/src/emu/dioutput.cpp b/src/emu/dioutput.cpp index 54633f3acbd..32e1338d091 100644 --- a/src/emu/dioutput.cpp +++ b/src/emu/dioutput.cpp @@ -23,7 +23,7 @@ device_output_interface::device_output_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "output"), m_output_index(0), - m_output_name(NULL) + m_output_name(nullptr) { } diff --git a/src/emu/dipty.cpp b/src/emu/dipty.cpp index 97533eae976..bd1a166322f 100644 --- a/src/emu/dipty.cpp +++ b/src/emu/dipty.cpp @@ -13,7 +13,7 @@ device_pty_interface::device_pty_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "pty"), - m_pty_master(NULL), + m_pty_master(nullptr), m_slave_name(), m_opened(false) { @@ -33,7 +33,7 @@ bool device_pty_interface::open(void) m_slave_name.assign(buffer); } else { m_opened = false; - m_pty_master = NULL; + m_pty_master = nullptr; } } diff --git a/src/emu/diserial.cpp b/src/emu/diserial.cpp index 3b679b47232..3e4c0b4c785 100644 --- a/src/emu/diserial.cpp +++ b/src/emu/diserial.cpp @@ -27,8 +27,8 @@ device_serial_interface::device_serial_interface(const machine_config &mconfig, m_tra_flags(TRANSMIT_REGISTER_EMPTY), m_tra_bit_count_transmitted(0), m_tra_bit_count(0), - m_rcv_clock(NULL), - m_tra_clock(NULL), + m_rcv_clock(nullptr), + m_tra_clock(nullptr), m_rcv_rate(attotime::never), m_tra_rate(attotime::never), m_rcv_line(0), diff --git a/src/emu/diserial.h b/src/emu/diserial.h index 38b34bfdf2c..185c6849a4d 100644 --- a/src/emu/diserial.h +++ b/src/emu/diserial.h @@ -122,7 +122,7 @@ protected: virtual void rcv_complete() { } // interface-level overrides - virtual void interface_pre_start(); + virtual void interface_pre_start() override; // Must be called from device_timer in the underlying device virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); diff --git a/src/emu/dislot.cpp b/src/emu/dislot.cpp index 304a6517a42..697eb673a9f 100644 --- a/src/emu/dislot.cpp +++ b/src/emu/dislot.cpp @@ -11,7 +11,7 @@ device_slot_interface::device_slot_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "slot"), - m_default_option(NULL), + m_default_option(nullptr), m_fixed(false) { } @@ -21,13 +21,13 @@ device_slot_interface::~device_slot_interface() } device_slot_option::device_slot_option(const char *name, const device_type &devtype): - m_next(NULL), + m_next(nullptr), m_name(name), m_devtype(devtype), m_selectable(true), - m_default_bios(NULL), - m_machine_config(NULL), - m_input_device_defaults(NULL), + m_default_bios(nullptr), + m_machine_config(nullptr), + m_input_device_defaults(nullptr), m_clock(0) { } @@ -44,7 +44,7 @@ void device_slot_interface::static_option_add(device_t &device, const char *name device_slot_interface &intf = dynamic_cast(device); device_slot_option *option = intf.option(name); - if (option != NULL) + if (option != nullptr) throw emu_fatalerror("slot '%s' duplicate option '%s\n", device.tag(), name); intf.m_options.append(name, *global_alloc(device_slot_option(name, devtype))); @@ -55,7 +55,7 @@ device_slot_option *device_slot_interface::static_option(device_t &device, const device_slot_interface &intf = dynamic_cast(device); device_slot_option *option = intf.option(name); - if (option == NULL) + if (option == nullptr) throw emu_fatalerror("slot '%s' has no option '%s\n", device.tag(), name); return option; @@ -64,7 +64,7 @@ device_slot_option *device_slot_interface::static_option(device_t &device, const device_t* device_slot_interface::get_card_device() { const char *subtag; - device_t *dev = NULL; + device_t *dev = nullptr; std::string temp; if (!device().mconfig().options().exists(device().tag()+1)) { subtag = m_default_option; @@ -72,9 +72,9 @@ device_t* device_slot_interface::get_card_device() subtag = device().mconfig().options().main_value(temp,device().tag()+1); } if (subtag && *subtag != 0) { - device_slot_card_interface *intf = NULL; + device_slot_card_interface *intf = nullptr; dev = device().subdevice(subtag); - if (dev!=NULL && !dev->interface(intf)) + if (dev!=nullptr && !dev->interface(intf)) throw emu_fatalerror("get_card_device called for device '%s' with no slot card interface", dev->tag()); } return dev; diff --git a/src/emu/dislot.h b/src/emu/dislot.h index a13d0e37e2d..3c89b1350d3 100644 --- a/src/emu/dislot.h +++ b/src/emu/dislot.h @@ -115,7 +115,7 @@ public: bool fixed() const { return m_fixed; } const char *default_option() const { return m_default_option; } device_slot_option *first_option() const { return m_options.first(); } - device_slot_option *option(const char *name) const { if (name) return m_options.find(name); return NULL; } + device_slot_option *option(const char *name) const { if (name) return m_options.find(name); return nullptr; } virtual void get_default_card_software(std::string &result) { result.clear(); } device_t *get_card_device(); diff --git a/src/emu/disound.cpp b/src/emu/disound.cpp index e6c68737e0f..c1f4e49f4b6 100644 --- a/src/emu/disound.cpp +++ b/src/emu/disound.cpp @@ -91,7 +91,7 @@ int device_sound_interface::inputs() const { // scan the list counting streams we own and summing their inputs int inputs = 0; - for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != nullptr; stream = stream->next()) if (&stream->device() == &m_device) inputs += stream->input_count(); return inputs; @@ -107,7 +107,7 @@ int device_sound_interface::outputs() const { // scan the list counting streams we own and summing their outputs int outputs = 0; - for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != nullptr; stream = stream->next()) if (&stream->device() == &m_device) outputs += stream->output_count(); return outputs; @@ -125,7 +125,7 @@ sound_stream *device_sound_interface::input_to_stream_input(int inputnum, int &s assert(inputnum >= 0); // scan the list looking for streams owned by this device - for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != nullptr; stream = stream->next()) if (&stream->device() == &m_device) { if (inputnum < stream->input_count()) @@ -137,7 +137,7 @@ sound_stream *device_sound_interface::input_to_stream_input(int inputnum, int &s } // not found - return NULL; + return nullptr; } @@ -152,7 +152,7 @@ sound_stream *device_sound_interface::output_to_stream_output(int outputnum, int assert(outputnum >= 0); // scan the list looking for streams owned by this device - for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != nullptr; stream = stream->next()) if (&stream->device() == &device()) { if (outputnum < stream->output_count()) @@ -164,7 +164,7 @@ sound_stream *device_sound_interface::output_to_stream_output(int outputnum, int } // not found - return NULL; + return nullptr; } @@ -177,7 +177,7 @@ void device_sound_interface::set_input_gain(int inputnum, float gain) { int stream_inputnum; sound_stream *stream = input_to_stream_input(inputnum, stream_inputnum); - if (stream != NULL) + if (stream != nullptr) stream->set_input_gain(stream_inputnum, gain); } @@ -192,7 +192,7 @@ void device_sound_interface::set_output_gain(int outputnum, float gain) // handle ALL_OUTPUTS as a special case if (outputnum == ALL_OUTPUTS) { - for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != nullptr; stream = stream->next()) if (&stream->device() == &device()) for (int num = 0; num < stream->output_count(); num++) stream->set_output_gain(num, gain); @@ -203,7 +203,7 @@ void device_sound_interface::set_output_gain(int outputnum, float gain) { int stream_outputnum; sound_stream *stream = output_to_stream_output(outputnum, stream_outputnum); - if (stream != NULL) + if (stream != nullptr) stream->set_output_gain(stream_outputnum, gain); } } @@ -217,7 +217,7 @@ void device_sound_interface::set_output_gain(int outputnum, float gain) int device_sound_interface::inputnum_from_device(device_t &source_device, int outputnum) const { int overall = 0; - for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != nullptr; stream = stream->next()) if (&stream->device() == &device()) for (int inputnum = 0; inputnum < stream->input_count(); inputnum++, overall++) if (stream->input_source_device(inputnum) == &source_device && stream->input_source_outputnum(inputnum) == outputnum) @@ -235,16 +235,16 @@ int device_sound_interface::inputnum_from_device(device_t &source_device, int ou void device_sound_interface::interface_validity_check(validity_checker &valid) const { // loop over all the routes - for (const sound_route *route = first_route(); route != NULL; route = route->next()) + for (const sound_route *route = first_route(); route != nullptr; route = route->next()) { // find a device with the requested tag const device_t *target = device().siblingdevice(route->m_target.c_str()); - if (target == NULL) + if (target == nullptr) osd_printf_error("Attempting to route sound to non-existant device '%s'\n", route->m_target.c_str()); // if it's not a speaker or a sound device, error const device_sound_interface *sound; - if (target != NULL && target->type() != SPEAKER && !target->interface(sound)) + if (target != nullptr && target->type() != SPEAKER && !target->interface(sound)) osd_printf_error("Attempting to route sound to a non-sound device '%s' (%s)\n", route->m_target.c_str(), target->name()); } } @@ -259,10 +259,10 @@ void device_sound_interface::interface_pre_start() { // scan all the sound devices sound_interface_iterator iter(m_device.machine().root_device()); - for (device_sound_interface *sound = iter.first(); sound != NULL; sound = iter.next()) + for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) { // scan each route on the device - for (const sound_route *route = sound->first_route(); route != NULL; route = route->next()) + for (const sound_route *route = sound->first_route(); route != nullptr; route = route->next()) { // see if we are the target of this route; if we are, make sure the source device is started device_t *target_device = sound->device().siblingdevice(route->m_target.c_str()); @@ -273,10 +273,10 @@ void device_sound_interface::interface_pre_start() // now iterate through devices again and assign any auto-allocated inputs m_auto_allocated_inputs = 0; - for (device_sound_interface *sound = iter.first(); sound != NULL; sound = iter.next()) + for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) { // scan each route on the device - for (const sound_route *route = sound->first_route(); route != NULL; route = route->next()) + for (const sound_route *route = sound->first_route(); route != nullptr; route = route->next()) { // see if we are the target of this route device_t *target_device = sound->device().siblingdevice(route->m_target.c_str()); @@ -299,10 +299,10 @@ void device_sound_interface::interface_post_start() { // iterate over all the sound devices sound_interface_iterator iter(m_device.machine().root_device()); - for (device_sound_interface *sound = iter.first(); sound != NULL; sound = iter.next()) + for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) { // scan each route on the device - for (const sound_route *route = sound->first_route(); route != NULL; route = route->next()) + for (const sound_route *route = sound->first_route(); route != nullptr; route = route->next()) { // if we are the target of this route, hook it up device_t *target_device = sound->device().siblingdevice(route->m_target.c_str()); @@ -317,13 +317,13 @@ void device_sound_interface::interface_post_start() // find the output stream to connect from int streamoutputnum; sound_stream *outputstream = sound->output_to_stream_output(outputnum, streamoutputnum); - if (outputstream == NULL) + if (outputstream == nullptr) fatalerror("Sound device '%s' specifies route for non-existant output #%d\n", route->m_target.c_str(), outputnum); // find the input stream to connect to int streaminputnum; sound_stream *inputstream = input_to_stream_input(inputnum++, streaminputnum); - if (inputstream == NULL) + if (inputstream == nullptr) fatalerror("Sound device '%s' targeted output #%d to non-existant device '%s' input %d\n", route->m_target.c_str(), outputnum, m_device.tag(), inputnum - 1); // set the input @@ -343,7 +343,7 @@ void device_sound_interface::interface_post_start() void device_sound_interface::interface_pre_reset() { // update all streams on this device prior to reset - for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != nullptr; stream = stream->next()) if (&stream->device() == &device()) stream->update(); } @@ -359,7 +359,7 @@ void device_sound_interface::interface_pre_reset() //------------------------------------------------- device_sound_interface::sound_route::sound_route(int output, int input, float gain, const char *target, UINT32 mixoutput) - : m_next(NULL), + : m_next(nullptr), m_output(output), m_input(input), m_mixoutput(mixoutput), @@ -381,7 +381,7 @@ device_sound_interface::sound_route::sound_route(int output, int input, float ga device_mixer_interface::device_mixer_interface(const machine_config &mconfig, device_t &device, int outputs) : device_sound_interface(mconfig, device), m_outputs(outputs), - m_mixer_stream(NULL) + m_mixer_stream(nullptr) { } @@ -417,8 +417,8 @@ void device_mixer_interface::interface_pre_start() // iterate through all routes that point to us and note their mixer output sound_interface_iterator iter(m_device.machine().root_device()); - for (device_sound_interface *sound = iter.first(); sound != NULL; sound = iter.next()) - for (const sound_route *route = sound->first_route(); route != NULL; route = route->next()) + for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) + for (const sound_route *route = sound->first_route(); route != nullptr; route = route->next()) { // see if we are the target of this route device_t *target_device = sound->device().siblingdevice(route->m_target.c_str()); diff --git a/src/emu/disound.h b/src/emu/disound.h index 949d03ce29e..7f6f6868b98 100644 --- a/src/emu/disound.h +++ b/src/emu/disound.h @@ -111,10 +111,10 @@ public: protected: // optional operation overrides - virtual void interface_validity_check(validity_checker &valid) const; - virtual void interface_pre_start(); - virtual void interface_post_start(); - virtual void interface_pre_reset(); + virtual void interface_validity_check(validity_checker &valid) const override; + virtual void interface_pre_start() override; + virtual void interface_post_start() override; + virtual void interface_pre_reset() override; // internal state simple_list m_route_list; // list of sound routes @@ -138,11 +138,11 @@ public: protected: // optional operation overrides - virtual void interface_pre_start(); - virtual void interface_post_load(); + virtual void interface_pre_start() override; + virtual void interface_post_load() override; // sound interface overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); + virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; // internal state UINT8 m_outputs; // number of outputs diff --git a/src/emu/dispatch.h b/src/emu/dispatch.h index 02e3108b8c3..47e742c86b3 100644 --- a/src/emu/dispatch.h +++ b/src/emu/dispatch.h @@ -28,13 +28,13 @@ public: devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); void init_fwd() { - for(int i=0; i static devcb_base &set_fwd_cb(device_t &device, int entry, _Object object) { return downcast &>(device).fwd_cb[entry]->set_callback(object); } @@ -45,9 +45,9 @@ public: } protected: - virtual void device_start() { - for(int i=0; iresolve_safe(); + virtual void device_start() override { + for(auto & elem : fwd_cb) + elem->resolve_safe(); } private: diff --git a/src/emu/distate.cpp b/src/emu/distate.cpp index 450fe412259..77ed3307946 100644 --- a/src/emu/distate.cpp +++ b/src/emu/distate.cpp @@ -51,7 +51,7 @@ const UINT64 device_state_entry::k_decimal_divisor[] = device_state_entry::device_state_entry(int index, const char *symbol, void *dataptr, UINT8 size, device_state_interface *dev) : m_device_state(dev), - m_next(NULL), + m_next(nullptr), m_index(index), m_dataptr(dataptr), m_datamask(0), @@ -89,9 +89,9 @@ device_state_entry::device_state_entry(int index, const char *symbol, void *data device_state_entry::device_state_entry(int index, device_state_interface *dev) : m_device_state(dev), - m_next(NULL), + m_next(nullptr), m_index(index), - m_dataptr(NULL), + m_dataptr(nullptr), m_datamask(0), m_datasize(0), m_flags(DSF_DIVIDER), @@ -114,7 +114,7 @@ device_state_entry &device_state_entry::formatstr(const char *_format) // set the DSF_CUSTOM_STRING flag by formatting with a NULL string m_flags &= ~DSF_CUSTOM_STRING; std::string dummy; - format(dummy, NULL); + format(dummy, nullptr); return *this; } @@ -321,7 +321,7 @@ std::string &device_state_entry::format(std::string &dest, const char *string, b case 's': if (width == 0) throw emu_fatalerror("Width required for %%s formats\n"); - if (string == NULL) + if (string == nullptr) { const_cast(this)->m_flags |= DSF_CUSTOM_STRING; return dest; @@ -419,7 +419,7 @@ UINT64 device_state_interface::state_int(int index) { // NULL or out-of-range entry returns 0 const device_state_entry *entry = state_find_entry(index); - if (entry == NULL) + if (entry == nullptr) return 0; // call the exporter before we do anything @@ -440,7 +440,7 @@ std::string &device_state_interface::state_string(int index, std::string &dest) { // NULL or out-of-range entry returns bogus string const device_state_entry *entry = state_find_entry(index); - if (entry == NULL) + if (entry == nullptr) return dest.assign("???"); // get the custom string if needed @@ -462,7 +462,7 @@ int device_state_interface::state_string_max_length(int index) { // NULL or out-of-range entry returns bogus string const device_state_entry *entry = state_find_entry(index); - if (entry == NULL) + if (entry == nullptr) return 3; // ask the entry to format itself maximally @@ -480,7 +480,7 @@ void device_state_interface::set_state_int(int index, UINT64 value) { // NULL or out-of-range entry is a no-op const device_state_entry *entry = state_find_entry(index); - if (entry == NULL) + if (entry == nullptr) return; // set the value @@ -501,7 +501,7 @@ void device_state_interface::set_state_string(int index, const char *string) { // NULL or out-of-range entry is a no-op const device_state_entry *entry = state_find_entry(index); - if (entry == NULL) + if (entry == nullptr) return; // set the value @@ -522,10 +522,10 @@ device_state_entry &device_state_interface::state_add(int index, const char *sym { // assert validity of incoming parameters assert(size == 1 || size == 2 || size == 4 || size == 8); - assert(symbol != NULL); + assert(symbol != nullptr); // allocate new entry - device_state_entry *entry = global_alloc(device_state_entry(index, symbol, data, size, this)); + auto entry = global_alloc(device_state_entry(index, symbol, data, size, this)); // append to the end of the list m_state_list.append(*entry); @@ -545,7 +545,7 @@ device_state_entry &device_state_interface::state_add(int index, const char *sym device_state_entry &device_state_interface::state_add_divider(int index) { // allocate new entry - device_state_entry *entry = global_alloc(device_state_entry(index, this)); + auto entry = global_alloc(device_state_entry(index, this)); // append to the end of the list m_state_list.append(*entry); @@ -622,10 +622,10 @@ const device_state_entry *device_state_interface::state_find_entry(int index) return m_fast_state[index - FAST_STATE_MIN]; // otherwise, scan the first - for (const device_state_entry *entry = m_state_list.first(); entry != NULL; entry = entry->m_next) + for (const device_state_entry *entry = m_state_list.first(); entry != nullptr; entry = entry->m_next) if (entry->m_index == index) return entry; // handle failure by returning NULL - return NULL; + return nullptr; } diff --git a/src/emu/distate.h b/src/emu/distate.h index b8adb436f1c..f762bd9fb13 100644 --- a/src/emu/distate.h +++ b/src/emu/distate.h @@ -166,7 +166,7 @@ protected: virtual void state_string_export(const device_state_entry &entry, std::string &str); // internal operation overrides - virtual void interface_post_start(); + virtual void interface_post_start() override; // find the entry for a given index const device_state_entry *state_find_entry(int index); @@ -197,7 +197,7 @@ typedef device_interface_iterator state_interface_iterat inline offs_t device_t::safe_pc() const { - return (m_state != NULL) ? m_state->pc() : 0; + return (m_state != nullptr) ? m_state->pc() : 0; } @@ -208,7 +208,7 @@ inline offs_t device_t::safe_pc() const inline offs_t device_t::safe_pcbase() const { - return (m_state != NULL) ? m_state->pcbase() : 0; + return (m_state != nullptr) ? m_state->pcbase() : 0; } diff --git a/src/emu/divideo.cpp b/src/emu/divideo.cpp index 82433d93e88..2ba4d117a28 100644 --- a/src/emu/divideo.cpp +++ b/src/emu/divideo.cpp @@ -27,7 +27,7 @@ device_video_interface::device_video_interface(const machine_config &mconfig, de : device_interface(device, "video"), m_screen_required(screen_required), m_screen_tag(s_unconfigured_screen_tag), - m_screen(NULL) + m_screen(nullptr) { } @@ -65,14 +65,14 @@ void device_video_interface::static_set_screen(device_t &device, const char *tag void device_video_interface::interface_validity_check(validity_checker &valid) const { // only look up screens if we haven't explicitly requested no screen - screen_device *screen = NULL; - if (m_screen_tag != NULL) + screen_device *screen = nullptr; + if (m_screen_tag != nullptr) { // find the screen device if explicitly configured if (strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0) { screen = device().siblingdevice(m_screen_tag); - if (screen == NULL) + if (screen == nullptr) osd_printf_error("Screen '%s' not found, explicitly set for device '%s'\n", m_screen_tag, device().tag()); } @@ -81,13 +81,13 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c { screen_device_iterator iter(device().mconfig().root_device()); screen = iter.first(); - if (iter.next() != NULL) + if (iter.next() != nullptr) osd_printf_error("No screen specified for device '%s', but multiple screens found\n", device().tag()); } } // error if no screen is found - if (screen == NULL && m_screen_required) + if (screen == nullptr && m_screen_required) osd_printf_error("Device '%s' requires a screen\n", device().tag()); } @@ -100,13 +100,13 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c void device_video_interface::interface_pre_start() { // only look up screens if we haven't explicitly requested no screen - if (m_screen_tag != NULL) + if (m_screen_tag != nullptr) { // find the screen device if explicitly configured if (strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0) { m_screen = device().siblingdevice(m_screen_tag); - if (m_screen == NULL) + if (m_screen == nullptr) throw emu_fatalerror("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag()); } @@ -115,16 +115,16 @@ void device_video_interface::interface_pre_start() { screen_device_iterator iter(device().machine().root_device()); m_screen = iter.first(); - if (iter.next() != NULL) + if (iter.next() != nullptr) throw emu_fatalerror("No screen specified for device '%s', but multiple screens found", device().tag()); } } // fatal error if no screen is found - if (m_screen == NULL && m_screen_required) + if (m_screen == nullptr && m_screen_required) throw emu_fatalerror("Device '%s' requires a screen", device().tag()); // if we have a screen and it's not started, wait for it - if (m_screen != NULL && !m_screen->started()) + if (m_screen != nullptr && !m_screen->started()) throw device_missing_dependencies(); } diff --git a/src/emu/divideo.h b/src/emu/divideo.h index 4057ef083c3..e50a1b5df08 100644 --- a/src/emu/divideo.h +++ b/src/emu/divideo.h @@ -50,8 +50,8 @@ public: protected: // optional operation overrides - virtual void interface_validity_check(validity_checker &valid) const; - virtual void interface_pre_start(); + virtual void interface_validity_check(validity_checker &valid) const override; + virtual void interface_pre_start() override; // configuration state bool m_screen_required; // is a screen required? diff --git a/src/emu/drawgfx.cpp b/src/emu/drawgfx.cpp index 1c8a863bc84..2da798bfa97 100644 --- a/src/emu/drawgfx.cpp +++ b/src/emu/drawgfx.cpp @@ -87,7 +87,7 @@ gfxdecode_device::gfxdecode_device(const machine_config &mconfig, const char *ta //------------------------------------------------- gfx_element::gfx_element() - : m_palette(NULL), + : m_palette(nullptr), m_width(0), m_height(0), m_startx(0), @@ -101,9 +101,9 @@ gfx_element::gfx_element() m_total_colors(0), m_line_modulo(0), m_char_modulo(0), - m_srcdata(NULL), + m_srcdata(nullptr), m_dirtyseq(1), - m_gfxdata(NULL), + m_gfxdata(nullptr), m_layout_is_raw(false), m_layout_planes(0), m_layout_xormask(0), @@ -151,9 +151,9 @@ gfx_element::gfx_element(palette_device *palette, const gfx_layout &gl, const UI m_total_colors(total_colors), m_line_modulo(0), m_char_modulo(0), - m_srcdata(NULL), + m_srcdata(nullptr), m_dirtyseq(1), - m_gfxdata(NULL), + m_gfxdata(nullptr), m_layout_is_raw(false), m_layout_planes(0), m_layout_xormask(xormask), @@ -198,7 +198,7 @@ void gfx_element::set_layout(const gfx_layout &gl, const UINT8 *srcdata) m_char_modulo = gl.charincrement / 8; // RAW graphics must have a pointer up front - assert(srcdata != NULL); + assert(srcdata != nullptr); m_gfxdata = const_cast(srcdata); } @@ -573,7 +573,7 @@ void gfx_element::transtable(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // render color = colorbase() + granularity() * (color % colors()); @@ -587,7 +587,7 @@ void gfx_element::transtable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); @@ -859,7 +859,7 @@ void gfx_element::zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -877,7 +877,7 @@ void gfx_element::zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1144,7 +1144,7 @@ void gfx_element::prio_transtable(bitmap_ind16 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // high bit of the mask is implicitly on pmask |= 1 << 31; @@ -1160,7 +1160,7 @@ void gfx_element::prio_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // high bit of the mask is implicitly on pmask |= 1 << 31; @@ -1465,7 +1465,7 @@ void gfx_element::prio_zoom_transtable(bitmap_ind16 &dest, const rectangle &clip UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1486,7 +1486,7 @@ void gfx_element::prio_zoom_transtable(bitmap_rgb32 &dest, const rectangle &clip UINT32 scalex, UINT32 scaley, bitmap_ind8 &priority, UINT32 pmask, const UINT8 *pentable) { - assert(pentable != NULL); + assert(pentable != nullptr); // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1680,7 +1680,7 @@ void gfx_element::alphastore(bitmap_rgb32 &dest, const rectangle &cliprect, assert(dest.bpp() == 32); assert(dest.format() == BITMAP_FORMAT_ARGB32); - assert(alphatable != NULL); + assert(alphatable != nullptr); /* if we have a fixed alpha, call the standard drawgfx_transpen */ if (fixedalpha == 0xff) @@ -1730,7 +1730,7 @@ void gfx_element::alphatable(bitmap_rgb32 &dest, const rectangle &cliprect, } assert(dest.bpp() == 32); - assert(alphatable != NULL); + assert(alphatable != nullptr); /* get final code and color, and grab lookup tables */ code %= elements(); @@ -1759,7 +1759,7 @@ void draw_scanline8(bitmap_ind16 &bitmap, INT32 destx, INT32 desty, INT32 length DECLARE_NO_PRIORITY; // palette lookup case - if (paldata != NULL) + if (paldata != nullptr) DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case @@ -1772,7 +1772,7 @@ void draw_scanline8(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length DECLARE_NO_PRIORITY; // palette lookup case - if (paldata != NULL) + if (paldata != nullptr) DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case @@ -1791,7 +1791,7 @@ void draw_scanline16(bitmap_ind16 &bitmap, INT32 destx, INT32 desty, INT32 lengt DECLARE_NO_PRIORITY; // palette lookup case - if (paldata != NULL) + if (paldata != nullptr) DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case @@ -1804,7 +1804,7 @@ void draw_scanline16(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 lengt DECLARE_NO_PRIORITY; // palette lookup case - if (paldata != NULL) + if (paldata != nullptr) DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case @@ -1823,7 +1823,7 @@ void draw_scanline32(bitmap_ind16 &bitmap, INT32 destx, INT32 desty, INT32 lengt DECLARE_NO_PRIORITY; // palette lookup case - if (paldata != NULL) + if (paldata != nullptr) DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case @@ -1836,7 +1836,7 @@ void draw_scanline32(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 lengt DECLARE_NO_PRIORITY; // palette lookup case - if (paldata != NULL) + if (paldata != nullptr) DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case @@ -1986,10 +1986,10 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, _BitmapClas if (numrows == 0 && numcols == 0) return copybitmap_trans(dest, src, 0, 0, 0, 0, cliprect, trans_pen); - assert(numrows != 0 || rowscroll == NULL); - assert(numrows == 0 || rowscroll != NULL); - assert(numcols != 0 || colscroll == NULL); - assert(numcols == 0 || colscroll != NULL); + assert(numrows != 0 || rowscroll == nullptr); + assert(numrows == 0 || rowscroll != nullptr); + assert(numcols != 0 || colscroll == nullptr); + assert(numcols == 0 || colscroll != nullptr); // fully scrolling X,Y playfield if (numrows <= 1 && numcols <= 1) diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h index 1bc1cd0124c..a8be4a5f286 100644 --- a/src/emu/drawgfx.h +++ b/src/emu/drawgfx.h @@ -455,7 +455,7 @@ public: gfxdecode_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); protected: - virtual void device_start() {}; + virtual void device_start() override {}; }; GFXDECODE_EXTERN(empty); diff --git a/src/emu/drivenum.cpp b/src/emu/drivenum.cpp index b504366f12d..a410c3fbd85 100644 --- a/src/emu/drivenum.cpp +++ b/src/emu/drivenum.cpp @@ -35,7 +35,7 @@ driver_list::driver_list() int driver_list::find(const char *name) { // if no name, bail - if (name == NULL) + if (name == nullptr) return -1; // create a dummy item for comparison purposes @@ -45,7 +45,7 @@ int driver_list::find(const char *name) // binary search to find it const game_driver **result = reinterpret_cast(bsearch(&driverptr, s_drivers_sorted, s_driver_count, sizeof(*s_drivers_sorted), driver_sort_callback)); - return (result == NULL) ? -1 : result - s_drivers_sorted; + return (result == nullptr) ? -1 : result - s_drivers_sorted; } @@ -57,11 +57,11 @@ int driver_list::find(const char *name) bool driver_list::matches(const char *wildstring, const char *string) { // can only match internal drivers if the wildstring starts with an underscore - if (string[0] == '_' && (wildstring == NULL || wildstring[0] != '_')) + if (string[0] == '_' && (wildstring == nullptr || wildstring[0] != '_')) return false; // match everything else normally - return (wildstring == NULL || core_strwildcmp(wildstring, string) == 0); + return (wildstring == nullptr || core_strwildcmp(wildstring, string) == 0); } @@ -187,7 +187,7 @@ machine_config &driver_enumerator::config(int index, emu_options &options) const assert(index >= 0 && index < s_driver_count); // if we don't have it cached, add it - if (m_config[index] == NULL) + if (m_config[index] == nullptr) { m_config[index] = std::make_unique(*s_drivers_sorted[index], options); } @@ -307,7 +307,7 @@ void driver_enumerator::find_approximate_matches(const char *string, int count, #undef rand // if no name, pick random entries - if (string == NULL || string[0] == 0) + if (string == nullptr || string[0] == 0) { // seed the RNG first srand(osd_ticks()); @@ -392,11 +392,11 @@ void driver_enumerator::release_current() const return; // skip if we haven't cached a config - if (m_config[m_current] == NULL) + if (m_config[m_current] == nullptr) return; // iterate over software lists in this entry and reset software_list_device_iterator deviter(m_config[m_current]->root_device()); - for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next()) + for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) swlistdev->release(); } diff --git a/src/emu/drivenum.h b/src/emu/drivenum.h index 91dc1e711f7..4768623fa7c 100644 --- a/src/emu/drivenum.h +++ b/src/emu/drivenum.h @@ -103,7 +103,7 @@ public: using driver_list::compatible_with; // filtering/iterating - int filter(const char *string = NULL); + 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; } diff --git a/src/emu/driver.cpp b/src/emu/driver.cpp index 377d82c05c9..ee4ec8bebdb 100644 --- a/src/emu/driver.cpp +++ b/src/emu/driver.cpp @@ -33,10 +33,10 @@ ADDRESS_MAP_END //------------------------------------------------- driver_device::driver_device(const machine_config &mconfig, device_type type, const char *tag) - : device_t(mconfig, type, "Driver Device", tag, NULL, 0, "", __FILE__), + : device_t(mconfig, type, "Driver Device", tag, nullptr, 0, "", __FILE__), device_memory_interface(mconfig, *this), - m_space_config("generic", ENDIANNESS_LITTLE, 8, 32, 0, NULL, *ADDRESS_MAP_NAME(generic)), - m_system(NULL), + m_space_config("generic", ENDIANNESS_LITTLE, 8, 32, 0, nullptr, *ADDRESS_MAP_NAME(generic)), + m_system(nullptr), m_latch_clear_value(0), m_flip_screen_x(0), m_flip_screen_y(0) @@ -202,12 +202,12 @@ void driver_device::device_start() { // reschedule ourselves to be last device_iterator iter(*this); - for (device_t *test = iter.first(); test != NULL; test = iter.next()) + for (device_t *test = iter.first(); test != nullptr; test = iter.next()) if (test != this && !test->started()) throw device_missing_dependencies(); // call the game-specific init - if (m_system->driver_init != NULL) + if (m_system->driver_init != nullptr) (*m_system->driver_init)(machine()); // finish image devices init process @@ -274,7 +274,7 @@ void driver_device::device_reset_after_children() const address_space_config *driver_device::memory_space_config(address_spacenum spacenum) const { - return (spacenum == 0) ? &m_space_config : NULL; + return (spacenum == 0) ? &m_space_config : nullptr; } diff --git a/src/emu/driver.h b/src/emu/driver.h index fc3e389a7ce..9a122bbdf42 100644 --- a/src/emu/driver.h +++ b/src/emu/driver.h @@ -106,7 +106,7 @@ public: virtual ~driver_device(); // getters - const game_driver &system() const { assert(m_system != NULL); return *m_system; } + const game_driver &system() const { assert(m_system != nullptr); return *m_system; } // indexes into our generic callbacks enum callback_type @@ -247,13 +247,13 @@ protected: virtual void video_reset(); // device-level overrides - virtual const rom_entry *device_rom_region() const; - virtual ioport_constructor device_input_ports() const; - virtual void device_start(); - virtual void device_reset_after_children(); + virtual const rom_entry *device_rom_region() const override; + virtual ioport_constructor device_input_ports() const override; + virtual void device_start() override; + virtual void device_reset_after_children() override; // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override; private: // helpers void irq_pulse_clear(void *ptr, INT32 param); @@ -282,7 +282,7 @@ private: template device_t *driver_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) { - assert(owner == NULL); + assert(owner == nullptr); assert(clock == 0); return global_alloc_clear(_DriverClass(mconfig, &driver_device_creator<_DriverClass>, tag)); } diff --git a/src/emu/drivers/empty.cpp b/src/emu/drivers/empty.cpp index 215af57190b..9c48a6c8b26 100644 --- a/src/emu/drivers/empty.cpp +++ b/src/emu/drivers/empty.cpp @@ -26,7 +26,7 @@ public: { } - virtual void machine_start() + virtual void machine_start() override { // force the UI to show the game select screen ui_menu_select_game::force_game_select(machine(), &machine().render().ui_container()); diff --git a/src/emu/drivers/testcpu.cpp b/src/emu/drivers/testcpu.cpp index 4ee9e30271c..51bfa457694 100644 --- a/src/emu/drivers/testcpu.cpp +++ b/src/emu/drivers/testcpu.cpp @@ -33,12 +33,12 @@ public: : driver_device(mconfig, type, tag), m_cpu(*this, "maincpu"), m_ram(*this, "ram"), - m_space(NULL) + m_space(nullptr) { } // timer callback; used to wrest control of the system - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override { static const UINT32 sample_instructions[] = { @@ -52,11 +52,11 @@ public: }; // iterate over instructions - for (int instnum = 0; instnum < ARRAY_LENGTH(sample_instructions); instnum++) + for (auto & sample_instruction : sample_instructions) { // write the instruction to execute, followed by a BLR which will terminate the // basic block in the DRC - m_space->write_dword(RAM_BASE, sample_instructions[instnum]); + m_space->write_dword(RAM_BASE, sample_instruction); m_space->write_dword(RAM_BASE + 4, 0x4e800020); // initialize the register state @@ -92,7 +92,7 @@ public: } // startup code; do basic configuration and set a timer to go off immediately - virtual void machine_start() + virtual void machine_start() override { // find the CPU's address space m_space = &m_cpu->space(AS_PROGRAM); diff --git a/src/emu/emualloc.cpp b/src/emu/emualloc.cpp index 02642b44922..a43faae522c 100644 --- a/src/emu/emualloc.cpp +++ b/src/emu/emualloc.cpp @@ -40,8 +40,8 @@ resource_pool::resource_pool(int hash_size) : m_hash_size(hash_size), m_listlock(osd_lock_alloc()), m_hash(hash_size), - m_ordered_head(NULL), - m_ordered_tail(NULL) + m_ordered_head(nullptr), + m_ordered_tail(nullptr) { memset(&m_hash[0], 0, hash_size*sizeof(m_hash[0])); } @@ -56,7 +56,7 @@ resource_pool::resource_pool(int hash_size) resource_pool::~resource_pool() { clear(); - if (m_listlock != NULL) + if (m_listlock != nullptr) osd_lock_free(m_listlock); } @@ -82,15 +82,15 @@ void resource_pool::add(resource_pool_item &item, size_t size, const char *type) // find the entry to insert after resource_pool_item *insert_after; - for (insert_after = m_ordered_tail; insert_after != NULL; insert_after = insert_after->m_ordered_prev) + for (insert_after = m_ordered_tail; insert_after != nullptr; insert_after = insert_after->m_ordered_prev) if (insert_after->m_id < item.m_id) break; // insert into the appropriate spot - if (insert_after != NULL) + if (insert_after != nullptr) { item.m_ordered_next = insert_after->m_ordered_next; - if (item.m_ordered_next != NULL) + if (item.m_ordered_next != nullptr) item.m_ordered_next->m_ordered_prev = &item; else m_ordered_tail = &item; @@ -100,11 +100,11 @@ void resource_pool::add(resource_pool_item &item, size_t size, const char *type) else { item.m_ordered_next = m_ordered_head; - if (item.m_ordered_next != NULL) + if (item.m_ordered_next != nullptr) item.m_ordered_next->m_ordered_prev = &item; else m_ordered_tail = &item; - item.m_ordered_prev = NULL; + item.m_ordered_prev = nullptr; m_ordered_head = &item; } @@ -120,14 +120,14 @@ void resource_pool::add(resource_pool_item &item, size_t size, const char *type) void resource_pool::remove(void *ptr) { // ignore NULLs - if (ptr == NULL) + if (ptr == nullptr) return; // search for the item osd_lock_acquire(m_listlock); int hashval = reinterpret_cast(ptr) % m_hash_size; - for (resource_pool_item **scanptr = &m_hash[hashval]; *scanptr != NULL; scanptr = &(*scanptr)->m_next) + for (resource_pool_item **scanptr = &m_hash[hashval]; *scanptr != nullptr; scanptr = &(*scanptr)->m_next) // must match the pointer if ((*scanptr)->m_ptr == ptr) @@ -137,11 +137,11 @@ void resource_pool::remove(void *ptr) *scanptr = deleteme->m_next; // remove from ordered list - if (deleteme->m_ordered_prev != NULL) + if (deleteme->m_ordered_prev != nullptr) deleteme->m_ordered_prev->m_ordered_next = deleteme->m_ordered_next; else m_ordered_head = deleteme->m_ordered_next; - if (deleteme->m_ordered_next != NULL) + if (deleteme->m_ordered_next != nullptr) deleteme->m_ordered_next->m_ordered_prev = deleteme->m_ordered_prev; else m_ordered_tail = deleteme->m_ordered_prev; @@ -169,7 +169,7 @@ resource_pool_item *resource_pool::find(void *ptr) int hashval = reinterpret_cast(ptr) % m_hash_size; resource_pool_item *item; - for (item = m_hash[hashval]; item != NULL; item = item->m_next) + for (item = m_hash[hashval]; item != nullptr; item = item->m_next) if (item->m_ptr == ptr) break; @@ -192,8 +192,8 @@ bool resource_pool::contains(void *_ptrstart, void *_ptrend) // search for the item osd_lock_acquire(m_listlock); - resource_pool_item *item = NULL; - for (item = m_ordered_head; item != NULL; item = item->m_ordered_next) + resource_pool_item *item = nullptr; + for (item = m_ordered_head; item != nullptr; item = item->m_ordered_next) { UINT8 *objstart = reinterpret_cast(item->m_ptr); UINT8 *objend = objstart + item->m_size; @@ -204,7 +204,7 @@ bool resource_pool::contains(void *_ptrstart, void *_ptrend) found: osd_lock_release(m_listlock); - return (item != NULL); + return (item != nullptr); } @@ -218,7 +218,7 @@ void resource_pool::clear() // important: delete from earliest to latest; this allows objects to clean up after // themselves if they wish - while (m_ordered_head != NULL) + while (m_ordered_head != nullptr) remove(m_ordered_head->m_ptr); osd_lock_release(m_listlock); diff --git a/src/emu/emualloc.h b/src/emu/emualloc.h index 3a47180b517..192f1fca85e 100644 --- a/src/emu/emualloc.h +++ b/src/emu/emualloc.h @@ -60,9 +60,9 @@ private: public: resource_pool_item(void *ptr, size_t size) - : m_next(NULL), - m_ordered_next(NULL), - m_ordered_prev(NULL), + : m_next(nullptr), + m_ordered_next(nullptr), + m_ordered_prev(nullptr), m_ptr(ptr), m_size(size), m_id(~(UINT64)0) { } diff --git a/src/emu/emucore.cpp b/src/emu/emucore.cpp index 9d8917d22ea..26c23ac19fe 100644 --- a/src/emu/emucore.cpp +++ b/src/emu/emucore.cpp @@ -15,7 +15,7 @@ emu_fatalerror::emu_fatalerror(const char *format, ...) : code(0) { - if (format == NULL) + if (format == nullptr) { text[0] = '\0'; } @@ -32,7 +32,7 @@ emu_fatalerror::emu_fatalerror(const char *format, ...) emu_fatalerror::emu_fatalerror(const char *format, va_list ap) : code(0) { - if (format == NULL) + if (format == nullptr) { text[0] = '\0'; } @@ -46,7 +46,7 @@ emu_fatalerror::emu_fatalerror(const char *format, va_list ap) emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, ...) : code(_exitcode) { - if (format == NULL) + if (format == nullptr) { text[0] = '\0'; } @@ -62,7 +62,7 @@ emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, ...) emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, va_list ap) : code(_exitcode) { - if (format == NULL) + if (format == nullptr) { text[0] = '\0'; } diff --git a/src/emu/emucore.h b/src/emu/emucore.h index c26b0423493..ae631cecd79 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -321,7 +321,7 @@ inline _Dest downcast(_Source *src) try { if (dynamic_cast<_Dest>(src) != src) { - if (dynamic_cast(src) != NULL) + if (dynamic_cast(src) != nullptr) report_bad_device_cast(dynamic_cast(src), typeid(src), typeid(_Dest)); else report_bad_cast(typeid(src), typeid(_Dest)); @@ -342,7 +342,7 @@ inline _Dest downcast(_Source &src) try { if (&dynamic_cast<_Dest>(src) != &src) { - if (dynamic_cast(&src) != NULL) + if (dynamic_cast(&src) != nullptr) report_bad_device_cast(dynamic_cast(&src), typeid(src), typeid(_Dest)); else report_bad_cast(typeid(src), typeid(_Dest)); diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index 7fb6d51ef9e..11938000fe7 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -23,16 +23,16 @@ const options_entry emu_options::s_option_entries[] = { // unadorned options - only a single one supported at the moment - { OPTION_SYSTEMNAME, NULL, OPTION_STRING, NULL }, - { OPTION_SOFTWARENAME, NULL, OPTION_STRING, NULL }, + { OPTION_SYSTEMNAME, nullptr, OPTION_STRING, nullptr }, + { OPTION_SOFTWARENAME, nullptr, OPTION_STRING, nullptr }, // config options - { NULL, NULL, OPTION_HEADER, "CORE CONFIGURATION OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE CONFIGURATION OPTIONS" }, { OPTION_READCONFIG ";rc", "1", OPTION_BOOLEAN, "enable loading of configuration files" }, { OPTION_WRITECONFIG ";wc", "0", OPTION_BOOLEAN, "writes configuration to (driver).ini on exit" }, // seach path options - { NULL, NULL, OPTION_HEADER, "CORE SEARCH PATH OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE SEARCH PATH OPTIONS" }, { OPTION_MEDIAPATH ";rp;biospath;bp", "roms", OPTION_STRING, "path to ROMsets and hard disk images" }, { OPTION_HASHPATH ";hash_directory;hash", "hash", OPTION_STRING, "path to hash files" }, { OPTION_SAMPLEPATH ";sp", "samples", OPTION_STRING, "path to samplesets" }, @@ -44,7 +44,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_CROSSHAIRPATH, "crosshair", OPTION_STRING, "path to crosshair files" }, // output directory options - { NULL, NULL, OPTION_HEADER, "CORE OUTPUT DIRECTORY OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE OUTPUT DIRECTORY OPTIONS" }, { OPTION_CFG_DIRECTORY, "cfg", OPTION_STRING, "directory to save configurations" }, { OPTION_NVRAM_DIRECTORY, "nvram", OPTION_STRING, "directory to save nvram contents" }, { OPTION_INPUT_DIRECTORY, "inp", OPTION_STRING, "directory to save input device logs" }, @@ -54,17 +54,17 @@ const options_entry emu_options::s_option_entries[] = { OPTION_COMMENT_DIRECTORY, "comments", OPTION_STRING, "directory to save debugger comments" }, // state/playback options - { NULL, NULL, OPTION_HEADER, "CORE STATE/PLAYBACK OPTIONS" }, - { OPTION_STATE, NULL, OPTION_STRING, "saved state to load" }, + { nullptr, nullptr, OPTION_HEADER, "CORE STATE/PLAYBACK OPTIONS" }, + { OPTION_STATE, nullptr, OPTION_STRING, "saved state to load" }, { OPTION_AUTOSAVE, "0", OPTION_BOOLEAN, "enable automatic restore at startup, and automatic save at exit time" }, - { OPTION_PLAYBACK ";pb", NULL, OPTION_STRING, "playback an input file" }, - { OPTION_RECORD ";rec", NULL, OPTION_STRING, "record an input file" }, - { OPTION_MNGWRITE, NULL, OPTION_STRING, "optional filename to write a MNG movie of the current session" }, - { OPTION_AVIWRITE, NULL, OPTION_STRING, "optional filename to write an AVI movie of the current session" }, + { OPTION_PLAYBACK ";pb", nullptr, OPTION_STRING, "playback an input file" }, + { OPTION_RECORD ";rec", nullptr, OPTION_STRING, "record an input file" }, + { OPTION_MNGWRITE, nullptr, OPTION_STRING, "optional filename to write a MNG movie of the current session" }, + { OPTION_AVIWRITE, nullptr, OPTION_STRING, "optional filename to write an AVI movie of the current session" }, #ifdef MAME_DEBUG { OPTION_DUMMYWRITE, "0", OPTION_BOOLEAN, "indicates if a snapshot should be created if each frame" }, #endif - { OPTION_WAVWRITE, NULL, OPTION_STRING, "optional filename to write a WAV file of the current session" }, + { OPTION_WAVWRITE, nullptr, OPTION_STRING, "optional filename to write a WAV file of the current session" }, { OPTION_SNAPNAME, "%g/%i", OPTION_STRING, "override of the default snapshot/movie naming; %g == gamename, %i == index" }, { OPTION_SNAPSIZE, "auto", OPTION_STRING, "specify snapshot/movie resolution (x) or 'auto' to use minimal size " }, { OPTION_SNAPVIEW, "internal", OPTION_STRING, "specify snapshot/movie view or 'internal' to use internal pixel-aspect views" }, @@ -73,7 +73,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_BURNIN, "0", OPTION_BOOLEAN, "create burn-in snapshots for each screen" }, // performance options - { NULL, NULL, OPTION_HEADER, "CORE PERFORMANCE OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE PERFORMANCE OPTIONS" }, { OPTION_AUTOFRAMESKIP ";afs", "0", OPTION_BOOLEAN, "enable automatic frameskip selection" }, { OPTION_FRAMESKIP ";fs(0-10)", "0", OPTION_INTEGER, "set frameskip to fixed value, 0-10 (autoframeskip must be disabled)" }, { OPTION_SECONDS_TO_RUN ";str", "0", OPTION_INTEGER, "number of emulated seconds to run before automatically exiting" }, @@ -83,7 +83,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_REFRESHSPEED ";rs", "0", OPTION_BOOLEAN, "automatically adjusts the speed of gameplay to keep the refresh rate lower than the screen" }, // rotation options - { NULL, NULL, OPTION_HEADER, "CORE ROTATION OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE ROTATION OPTIONS" }, { OPTION_ROTATE, "1", OPTION_BOOLEAN, "rotate the game screen according to the game's orientation needs it" }, { OPTION_ROR, "0", OPTION_BOOLEAN, "rotate screen clockwise 90 degrees" }, { OPTION_ROL, "0", OPTION_BOOLEAN, "rotate screen counterclockwise 90 degrees" }, @@ -93,7 +93,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_FLIPY, "0", OPTION_BOOLEAN, "flip screen upside-down" }, // artwork options - { NULL, NULL, OPTION_HEADER, "CORE ARTWORK OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE ARTWORK OPTIONS" }, { OPTION_ARTWORK_CROP ";artcrop", "0", OPTION_BOOLEAN, "crop artwork to game screen size" }, { OPTION_USE_BACKDROPS ";backdrop", "1", OPTION_BOOLEAN, "enable backdrops if artwork is enabled and available" }, { OPTION_USE_OVERLAYS ";overlay", "1", OPTION_BOOLEAN, "enable overlays if artwork is enabled and available" }, @@ -102,7 +102,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_USE_MARQUEES ";marquee", "1", OPTION_BOOLEAN, "enable marquees if artwork is enabled and available" }, // screen options - { NULL, NULL, OPTION_HEADER, "CORE SCREEN OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE SCREEN OPTIONS" }, { OPTION_BRIGHTNESS "(0.1-2.0)", "1.0", OPTION_FLOAT, "default game screen brightness correction" }, { OPTION_CONTRAST "(0.1-2.0)", "1.0", OPTION_FLOAT, "default game screen contrast correction" }, { OPTION_GAMMA "(0.1-3.0)", "1.0", OPTION_FLOAT, "default game screen gamma correction" }, @@ -110,7 +110,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_EFFECT, "none", OPTION_STRING, "name of a PNG file to use for visual effects, or 'none'" }, // vector options - { NULL, NULL, OPTION_HEADER, "CORE VECTOR OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE VECTOR OPTIONS" }, { OPTION_ANTIALIAS ";aa", "1", OPTION_BOOLEAN, "use antialiasing when drawing vectors" }, { OPTION_BEAM_WIDTH_MIN, "1.0", OPTION_FLOAT, "set vector beam width minimum" }, { OPTION_BEAM_WIDTH_MAX, "1.0", OPTION_FLOAT, "set vector beam width maximum" }, @@ -118,15 +118,15 @@ const options_entry emu_options::s_option_entries[] = { OPTION_FLICKER, "0", OPTION_FLOAT, "set vector flicker effect" }, // sound options - { NULL, NULL, OPTION_HEADER, "CORE SOUND OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE SOUND OPTIONS" }, { OPTION_SAMPLERATE ";sr(1000-1000000)", "48000", OPTION_INTEGER, "set sound output sample rate" }, { OPTION_SAMPLES, "1", OPTION_BOOLEAN, "enable the use of external samples if available" }, { OPTION_VOLUME ";vol", "0", OPTION_INTEGER, "sound volume in decibels (-32 min, 0 max)" }, // input options - { NULL, NULL, OPTION_HEADER, "CORE INPUT OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "CORE INPUT OPTIONS" }, { OPTION_COIN_LOCKOUT ";coinlock", "1", OPTION_BOOLEAN, "enable coin lockouts to actually lock out coins" }, - { OPTION_CTRLR, NULL, OPTION_STRING, "preconfigure for specified controller" }, + { OPTION_CTRLR, nullptr, OPTION_STRING, "preconfigure for specified controller" }, { OPTION_MOUSE, "0", OPTION_BOOLEAN, "enable mouse input" }, { OPTION_JOYSTICK ";joy", "1", OPTION_BOOLEAN, "enable joystick input" }, { OPTION_LIGHTGUN ";gun", "0", OPTION_BOOLEAN, "enable lightgun input" }, @@ -143,7 +143,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_COIN_IMPULSE, "0", OPTION_INTEGER, "set coin impulse time (n<0 disable impulse, n==0 obey driver, 0fixed()) @@ -236,7 +236,7 @@ bool emu_options::add_slot_options(bool isfirstpass) // first device? add the header as to be pretty if (isfirstpass && first) - add_entry(NULL, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); + add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); first = false; // retrieve info about the device instance @@ -246,13 +246,13 @@ bool emu_options::add_slot_options(bool isfirstpass) // add the option UINT32 flags = OPTION_STRING | OPTION_FLAG_DEVICE; const char *defvalue = slot->default_option(); - if (defvalue != NULL) + if (defvalue != nullptr) { const device_slot_option *option = slot->option(defvalue); - if (option != NULL && !option->selectable()) + if (option != nullptr && !option->selectable()) flags |= OPTION_FLAG_INTERNAL; } - add_entry(name, NULL, flags, defvalue, true); + add_entry(name, nullptr, flags, defvalue, true); } } return (options_count() != starting_count); @@ -268,17 +268,17 @@ void emu_options::update_slot_options() { // look up the system configured by name; if no match, do nothing const game_driver *cursystem = system(); - if (cursystem == NULL) + if (cursystem == nullptr) return; machine_config config(*cursystem, *this); // iterate through all slot devices slot_interface_iterator iter(config.root_device()); - for (device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next()) + for (device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next()) { // retrieve info about the device instance const char *name = slot->device().tag() + 1; - if (exists(name) && slot->first_option() != NULL) + if (exists(name) && slot->first_option() != nullptr) { std::string defvalue; slot->get_default_card_software(defvalue); @@ -286,7 +286,7 @@ void emu_options::update_slot_options() { set_default_value(name, defvalue.c_str()); const device_slot_option *option = slot->option(defvalue.c_str()); - set_flag(name, ~OPTION_FLAG_INTERNAL, (option != NULL && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0); + set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0); } } } @@ -304,18 +304,18 @@ void emu_options::add_device_options(bool isfirstpass) { // look up the system configured by name; if no match, do nothing const game_driver *cursystem = system(); - if (cursystem == NULL) + if (cursystem == nullptr) return; machine_config config(*cursystem, *this); // iterate through all image devices bool first = true; image_interface_iterator iter(config.root_device()); - for (const device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { // first device? add the header as to be pretty if (first && isfirstpass) - add_entry(NULL, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); + add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); first = false; // retrieve info about the device instance @@ -326,7 +326,7 @@ void emu_options::add_device_options(bool isfirstpass) // add the option if (!exists(image->instance_name())) - add_entry(option_name.c_str(), NULL, OPTION_STRING | OPTION_FLAG_DEVICE, NULL, true); + add_entry(option_name.c_str(), nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, nullptr, true); } } @@ -339,7 +339,7 @@ void emu_options::remove_device_options() { // iterate through options and remove interesting ones entry *nextentry; - for (entry *curentry = first(); curentry != NULL; curentry = nextentry) + for (entry *curentry = first(); curentry != nullptr; curentry = nextentry) { // pre-fetch the next entry in case we delete this one nextentry = curentry->next(); @@ -373,7 +373,7 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], std::string &error_ // add device options and reparse add_device_options(true); - if (name != NULL && exists(name)) + if (name != nullptr && exists(name)) set_value(name, value, OPTION_PRIORITY_CMDLINE, error_string); core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string); @@ -399,7 +399,7 @@ bool emu_options::parse_command_line(int argc, char *argv[], std::string &error_ { // parse as normal core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string); - bool result = parse_slot_devices(argc, argv, error_string, NULL, NULL); + bool result = parse_slot_devices(argc, argv, error_string, nullptr, nullptr); update_cached_options(); return result; } @@ -426,7 +426,7 @@ void emu_options::parse_standard_inis(std::string &error_string) // if we have a valid system driver, parse system-specific INI files const game_driver *cursystem = system(); - if (cursystem == NULL) + if (cursystem == nullptr) return; // parse "vertical.ini" or "horizont.ini" @@ -446,7 +446,7 @@ void emu_options::parse_standard_inis(std::string &error_string) machine_config config(*cursystem, *this); screen_device_iterator iter(config.root_device()); - for (const screen_device *device = iter.first(); device != NULL; device = iter.next()) + for (const screen_device *device = iter.first(); device != nullptr; device = iter.next()) { // parse "raster.ini" for raster games if (device->screen_type() == SCREEN_TYPE_RASTER) @@ -502,7 +502,7 @@ const game_driver *emu_options::system() const { std::string tempstr; int index = driver_list::find(core_filename_extract_base(tempstr, system_name(), true).c_str()); - return (index != -1) ? &driver_list::driver(index) : NULL; + return (index != -1) ? &driver_list::driver(index) : nullptr; } @@ -560,7 +560,7 @@ bool emu_options::parse_one_ini(const char *basename, int priority, std::string bool result = parse_ini_file((core_file&)file, priority, OPTION_PRIORITY_DRIVER_INI, error); // append errors if requested - if (!error.empty() && error_string != NULL) + if (!error.empty() && error_string != nullptr) strcatprintf(*error_string, "While parsing %s:\n%s\n", file.fullpath(), error.c_str()); return result; diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h index 9e8485bde29..3bd7cd8afd6 100644 --- a/src/emu/emuopts.h +++ b/src/emu/emuopts.h @@ -374,7 +374,7 @@ private: void update_slot_options(); // INI parsing helper - bool parse_one_ini(const char *basename, int priority, std::string *error_string = NULL); + bool parse_one_ini(const char *basename, int priority, std::string *error_string = nullptr); // cache frequently used options in members void update_cached_options(); diff --git a/src/emu/emupal.cpp b/src/emu/emupal.cpp index 53841d93581..e3d2dcd97a1 100644 --- a/src/emu/emupal.cpp +++ b/src/emu/emupal.cpp @@ -30,10 +30,10 @@ palette_device::palette_device(const machine_config &mconfig, const char *tag, d m_endianness(), m_endianness_supplied(false), m_raw_to_rgb(raw_to_rgb_converter()), - m_palette(NULL), - m_pens(NULL), + m_palette(nullptr), + m_pens(nullptr), m_format(), - m_shadow_table(NULL), + m_shadow_table(nullptr), m_shadow_group(0), m_hilight_group(0), m_white_pen(0), @@ -234,7 +234,7 @@ void palette_device::set_shadow_dRGB32(int mode, int dr, int dg, int db, bool no // only applies to RGB direct modes assert(m_format != BITMAP_FORMAT_IND16); - assert(stable.base != NULL); + assert(stable.base != nullptr); // clamp the deltas (why?) if (dr < -0xff) dr = -0xff; else if (dr > 0xff) dr = 0xff; @@ -302,7 +302,7 @@ inline void palette_device::update_for_write(offs_t byte_offset, int bytes_modif for (int index = 0; index < count; index++) { UINT32 data = m_paletteram.read(base + index); - if (m_paletteram_ext.base() != NULL) + if (m_paletteram_ext.base() != nullptr) data |= m_paletteram_ext.read(base + index) << (8 * bpe); if (indirect) @@ -410,7 +410,7 @@ void palette_device::device_start() // find the memory, if present const memory_share *share = memshare(tag()); - if (share != NULL) + if (share != nullptr) { // find the extended (split) memory, if present std::string tag_ext = std::string(tag()).append("_ext"); @@ -421,7 +421,7 @@ void palette_device::device_start() // determine bytes per entry and configure int bytes_per_entry = m_raw_to_rgb.bytes_per_entry(); - if (share_ext == NULL) + if (share_ext == nullptr) m_paletteram.set(*share, bytes_per_entry); else { @@ -435,7 +435,7 @@ void palette_device::device_start() // forcing width only makes sense when narrower than the native bus width assert_always(m_membits < share->bitwidth(), "Improper use of MCFG_PALETTE_MEMBITS"); m_paletteram.set_membits(m_membits); - if (share_ext != NULL) + if (share_ext != nullptr) m_paletteram_ext.set_membits(m_membits); } @@ -443,14 +443,14 @@ void palette_device::device_start() if (m_endianness_supplied) { // forcing endianness only makes sense when the RAM is narrower than the palette format and not split - assert_always((share_ext == NULL && m_paletteram.membits() / 8 < bytes_per_entry), "Improper use of MCFG_PALETTE_ENDIANNESS"); + assert_always((share_ext == nullptr && m_paletteram.membits() / 8 < bytes_per_entry), "Improper use of MCFG_PALETTE_ENDIANNESS"); m_paletteram.set_endianness(m_endianness); } } // reset all our data screen_device *device = machine().first_screen(); - m_format = (device != NULL) ? device->format() : BITMAP_FORMAT_INVALID; + m_format = (device != nullptr) ? device->format() : BITMAP_FORMAT_INVALID; // allocate the palette if (m_entries > 0) @@ -540,7 +540,7 @@ void palette_device::device_post_load() void palette_device::device_stop() { // dereference the palette - if (m_palette != NULL) + if (m_palette != nullptr) m_palette->deref(); } @@ -638,7 +638,7 @@ void palette_device::allocate_color_tables() break; default: - m_pens = NULL; + m_pens = nullptr; break; } } @@ -713,7 +713,7 @@ void palette_device::configure_rgb_shadows(int mode, float factor) // verify the shadow table assert(mode >= 0 && mode < ARRAY_LENGTH(m_shadow_tables)); shadow_table_data &stable = m_shadow_tables[mode]; - assert(stable.base != NULL); + assert(stable.base != nullptr); // regenerate the table int ifactor = int(factor * 256.0f); diff --git a/src/emu/emupal.h b/src/emu/emupal.h index 1b6bfb296a5..b06a5b43d7f 100644 --- a/src/emu/emupal.h +++ b/src/emu/emupal.h @@ -309,7 +309,7 @@ class raw_to_rgb_converter public: // constructor - raw_to_rgb_converter(int bytes_per_entry = 0, raw_to_rgb_func func = NULL) + raw_to_rgb_converter(int bytes_per_entry = 0, raw_to_rgb_func func = nullptr) : m_bytes_per_entry(bytes_per_entry), m_func(func) { } @@ -458,11 +458,11 @@ public: void update() { if (!m_init.isnull()) m_init(*this); } protected: // device-level overrides - virtual void device_validity_check(validity_checker &valid) const; - virtual void device_start(); - virtual void device_pre_save(); - virtual void device_post_load(); - virtual void device_stop(); + virtual void device_validity_check(validity_checker &valid) const override; + virtual void device_start() override; + virtual void device_pre_save() override; + virtual void device_post_load() override; + virtual void device_stop() override; void allocate_palette(); void allocate_color_tables(); diff --git a/src/emu/fileio.cpp b/src/emu/fileio.cpp index 68efdb021a3..8c982d03f19 100644 --- a/src/emu/fileio.cpp +++ b/src/emu/fileio.cpp @@ -47,13 +47,13 @@ bool path_iterator::next(std::string &buffer, const char *name) // copy up to the next semicolon const char *semi = strchr(m_current, ';'); - if (semi == NULL) + if (semi == nullptr) semi = m_current + strlen(m_current); buffer.assign(m_current, semi - m_current); m_current = (*semi == 0) ? semi : semi + 1; // append the name if we have one - if (name != NULL) + if (name != nullptr) { // compute the full pathname if (buffer.length() > 0) @@ -78,7 +78,7 @@ bool path_iterator::next(std::string &buffer, const char *name) file_enumerator::file_enumerator(const char *searchpath) : m_iterator(searchpath), - m_curdir(NULL)/*, + m_curdir(nullptr)/*, m_buflen(0)*/ { } @@ -91,7 +91,7 @@ file_enumerator::file_enumerator(const char *searchpath) file_enumerator::~file_enumerator() { // close anything open - if (m_curdir != NULL) + if (m_curdir != nullptr) osd_closedir(m_curdir); } @@ -107,11 +107,11 @@ const osd_directory_entry *file_enumerator::next() while (1) { // if no open directory, get the next path - while (m_curdir == NULL) + while (m_curdir == nullptr) { // if we fail to get anything more, we're done if (!m_iterator.next(m_pathbuffer)) - return NULL; + return nullptr; // open the path m_curdir = osd_opendir(m_pathbuffer.c_str()); @@ -119,12 +119,12 @@ const osd_directory_entry *file_enumerator::next() // get the next entry from the current directory const osd_directory_entry *result = osd_readdir(m_curdir); - if (result != NULL) + if (result != nullptr) return result; // we're done; close this directory osd_closedir(m_curdir); - m_curdir = NULL; + m_curdir = nullptr; } } @@ -139,14 +139,14 @@ const osd_directory_entry *file_enumerator::next() //------------------------------------------------- emu_file::emu_file(UINT32 openflags) - : m_file(NULL), + : m_file(nullptr), m_iterator(""), m_mediapaths(""), m_crc(0), m_openflags(openflags), - m_zipfile(NULL), + m_zipfile(nullptr), m_ziplength(0), - m__7zfile(NULL), + m__7zfile(nullptr), m__7zlength(0), m_remove_on_close(false), m_restrict_to_mediapath(false) @@ -157,14 +157,14 @@ emu_file::emu_file(UINT32 openflags) } emu_file::emu_file(const char *searchpath, UINT32 openflags) - : m_file(NULL), + : m_file(nullptr), m_iterator(searchpath), m_mediapaths(searchpath), m_crc(0), m_openflags(openflags), - m_zipfile(NULL), + m_zipfile(nullptr), m_ziplength(0), - m__7zfile(NULL), + m__7zfile(nullptr), m__7zlength(0), m_remove_on_close(false), m_restrict_to_mediapath(false) @@ -195,7 +195,7 @@ emu_file::operator core_file *() { // load the ZIP file now if we haven't yet if (compressed_file_ready()) - return NULL; + return nullptr; // return the core file return m_file; @@ -235,7 +235,7 @@ hash_collection &emu_file::hashes(const char *types) // load the ZIP file if needed if (compressed_file_ready()) return m_hashes; - if (m_file == NULL) + if (m_file == nullptr) return m_hashes; // if we have ZIP data, just hash that directly @@ -253,7 +253,7 @@ hash_collection &emu_file::hashes(const char *types) // read the data if we can const UINT8 *filedata = (const UINT8 *)core_fbuffer(m_file); - if (filedata == NULL) + if (filedata == nullptr) return m_hashes; // compute the hash @@ -341,7 +341,7 @@ file_error emu_file::open(const char *name1, const char *name2, const char *name file_error emu_file::open_next() { // if we're open from a previous attempt, close up now - if (m_file != NULL) + if (m_file != nullptr) close(); // loop over paths @@ -397,17 +397,17 @@ file_error emu_file::open_ram(const void *data, UINT32 length) void emu_file::close() { // close files and free memory - if (m__7zfile != NULL) + if (m__7zfile != nullptr) _7z_file_close(m__7zfile); - m__7zfile = NULL; + m__7zfile = nullptr; - if (m_zipfile != NULL) + if (m_zipfile != nullptr) zip_file_close(m_zipfile); - m_zipfile = NULL; + m_zipfile = nullptr; - if (m_file != NULL) + if (m_file != nullptr) core_fclose(m_file); - m_file = NULL; + m_file = nullptr; m__7zdata.clear(); m_zipdata.clear(); @@ -442,10 +442,10 @@ file_error emu_file::compress(int level) bool emu_file::compressed_file_ready(void) { // load the ZIP file now if we haven't yet - if (m__7zfile != NULL && load__7zped_file() != FILERR_NONE) + if (m__7zfile != nullptr && load__7zped_file() != FILERR_NONE) return true; - if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE) + if (m_zipfile != nullptr && load_zipped_file() != FILERR_NONE) return true; return false; @@ -462,7 +462,7 @@ int emu_file::seek(INT64 offset, int whence) return 1; // seek if we can - if (m_file != NULL) + if (m_file != nullptr) return core_fseek(m_file, offset, whence); return 1; @@ -480,7 +480,7 @@ UINT64 emu_file::tell() return 0; // tell if we can - if (m_file != NULL) + if (m_file != nullptr) return core_ftell(m_file); return 0; @@ -498,7 +498,7 @@ bool emu_file::eof() return 0; // return EOF if we can - if (m_file != NULL) + if (m_file != nullptr) return core_feof(m_file); return 0; @@ -512,14 +512,14 @@ bool emu_file::eof() UINT64 emu_file::size() { // use the ZIP length if present - if (m__7zfile != NULL) + if (m__7zfile != nullptr) return m__7zlength; - if (m_zipfile != NULL) + if (m_zipfile != nullptr) return m_ziplength; // return length if we can - if (m_file != NULL) + if (m_file != nullptr) return core_fsize(m_file); return 0; @@ -537,7 +537,7 @@ UINT32 emu_file::read(void *buffer, UINT32 length) return 0; // read the data if we can - if (m_file != NULL) + if (m_file != nullptr) return core_fread(m_file, buffer, length); return 0; @@ -555,7 +555,7 @@ int emu_file::getc() return EOF; // read the data if we can - if (m_file != NULL) + if (m_file != nullptr) return core_fgetc(m_file); return EOF; @@ -573,7 +573,7 @@ int emu_file::ungetc(int c) return 1; // read the data if we can - if (m_file != NULL) + if (m_file != nullptr) return core_ungetc(c, m_file); return 1; @@ -588,13 +588,13 @@ char *emu_file::gets(char *s, int n) { // load the ZIP file now if we haven't yet if (compressed_file_ready()) - return NULL; + return nullptr; // read the data if we can - if (m_file != NULL) + if (m_file != nullptr) return core_fgets(s, n, m_file); - return NULL; + return nullptr; } @@ -605,7 +605,7 @@ char *emu_file::gets(char *s, int n) UINT32 emu_file::write(const void *buffer, UINT32 length) { // write the data if we can - if (m_file != NULL) + if (m_file != nullptr) return core_fwrite(m_file, buffer, length); return 0; @@ -619,7 +619,7 @@ UINT32 emu_file::write(const void *buffer, UINT32 length) int emu_file::puts(const char *s) { // write the data if we can - if (m_file != NULL) + if (m_file != nullptr) return core_fputs(m_file, s); return 0; @@ -648,7 +648,7 @@ int CLIB_DECL emu_file::printf(const char *fmt, ...) int emu_file::vprintf(const char *fmt, va_list va) { // write the data if we can - return (m_file != NULL) ? core_vfprintf(m_file, fmt, va) : 0; + return (m_file != nullptr) ? core_vfprintf(m_file, fmt, va) : 0; } @@ -662,7 +662,7 @@ bool emu_file::part_of_mediapath(std::string path) bool result = false; std::string mediapath; m_mediapaths.reset(); - while (m_mediapaths.next(mediapath, NULL) && !result) { + while (m_mediapaths.next(mediapath, nullptr) && !result) { if (path.compare(mediapath.substr(0, mediapath.length()))) result = true; } @@ -710,25 +710,25 @@ file_error emu_file::attempt_zipped() // see if we can find a file with the right name and (if available) crc const zip_file_header *header; - for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip)) + for (header = zip_file_first_file(zip); header != nullptr; header = zip_file_next_file(zip)) if (zip_filename_match(*header, filename) && (!(m_openflags & OPEN_FLAG_HAS_CRC) || header->crc == m_crc)) break; // if that failed, look for a file with the right crc, but the wrong filename - if (header == NULL && (m_openflags & OPEN_FLAG_HAS_CRC)) - for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip)) + if (header == nullptr && (m_openflags & OPEN_FLAG_HAS_CRC)) + for (header = zip_file_first_file(zip); header != nullptr; header = zip_file_next_file(zip)) if (header->crc == m_crc && !zip_header_is_path(*header)) break; // if that failed, look for a file with the right name; reporting a bad checksum // is more helpful and less confusing than reporting "rom not found" - if (header == NULL) - for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip)) + if (header == nullptr) + for (header = zip_file_first_file(zip); header != nullptr; header = zip_file_next_file(zip)) if (zip_filename_match(*header, filename)) break; // if we got it, read the data - if (header != NULL) + if (header != nullptr) { m_zipfile = zip; m_ziplength = header->uncompressed_length; @@ -751,9 +751,9 @@ file_error emu_file::attempt_zipped() file_error emu_file::load_zipped_file() { - assert(m_file == NULL); + assert(m_file == nullptr); assert(m_zipdata.empty()); - assert(m_zipfile != NULL); + assert(m_zipfile != nullptr); // allocate some memory m_zipdata.resize(m_ziplength); @@ -776,7 +776,7 @@ file_error emu_file::load_zipped_file() // close out the ZIP file zip_file_close(m_zipfile); - m_zipfile = NULL; + m_zipfile = nullptr; return FILERR_NONE; } @@ -880,9 +880,9 @@ file_error emu_file::attempt__7zped() file_error emu_file::load__7zped_file() { - assert(m_file == NULL); + assert(m_file == nullptr); assert(m__7zdata.empty()); - assert(m__7zfile != NULL); + assert(m__7zfile != nullptr); // allocate some memory m__7zdata.resize(m__7zlength); @@ -905,6 +905,6 @@ file_error emu_file::load__7zped_file() // close out the _7Z file _7z_file_close(m__7zfile); - m__7zfile = NULL; + m__7zfile = nullptr; return FILERR_NONE; } diff --git a/src/emu/fileio.h b/src/emu/fileio.h index 1377eca6bb9..39f3b0b8dc5 100644 --- a/src/emu/fileio.h +++ b/src/emu/fileio.h @@ -42,7 +42,7 @@ public: path_iterator(const char *searchpath); // getters - bool next(std::string &buffer, const char *name = NULL); + bool next(std::string &buffer, const char *name = nullptr); // reset void reset() { m_current = m_base; m_index = 0; } @@ -92,7 +92,7 @@ public: // getters operator core_file *(); operator core_file &(); - bool is_open() const { return (m_file != NULL); } + bool is_open() const { return (m_file != nullptr); } const char *filename() const { return m_filename.c_str(); } const char *fullpath() const { return m_fullpath.c_str(); } UINT32 openflags() const { return m_openflags; } @@ -102,7 +102,7 @@ public: // setters void remove_on_close() { m_remove_on_close = true; } - void set_openflags(UINT32 openflags) { assert(m_file == NULL); m_openflags = openflags; } + void set_openflags(UINT32 openflags) { assert(m_file == nullptr); m_openflags = openflags; } void set_restrict_to_mediapath(bool rtmp = true) { m_restrict_to_mediapath = rtmp; } // open/close diff --git a/src/emu/hash.cpp b/src/emu/hash.cpp index 3ada8eb2690..20894f4fa3e 100644 --- a/src/emu/hash.cpp +++ b/src/emu/hash.cpp @@ -36,7 +36,7 @@ const char *hash_collection::HASH_TYPES_ALL = "RS"; hash_collection::hash_collection() : m_has_crc32(false), m_has_sha1(false), - m_creator(NULL) + m_creator(nullptr) { } @@ -44,7 +44,7 @@ hash_collection::hash_collection() hash_collection::hash_collection(const char *string) : m_has_crc32(false), m_has_sha1(false), - m_creator(NULL) + m_creator(nullptr) { from_internal_string(string); } @@ -53,7 +53,7 @@ hash_collection::hash_collection(const char *string) hash_collection::hash_collection(const hash_collection &src) : m_has_crc32(false), m_has_sha1(false), - m_creator(NULL) + m_creator(nullptr) { copyfrom(src); } @@ -136,7 +136,7 @@ void hash_collection::reset() m_flags.clear(); m_has_crc32 = m_has_sha1 = false; delete m_creator; - m_creator = NULL; + m_creator = nullptr; } @@ -339,14 +339,14 @@ void hash_collection::begin(const char *types) m_creator = new hash_creator; // by default use all types - if (types == NULL) + if (types == nullptr) m_creator->m_doing_crc32 = m_creator->m_doing_sha1 = true; // otherwise, just allocate the ones that are specified else { - m_creator->m_doing_crc32 = (strchr(types, HASH_CRC) != NULL); - m_creator->m_doing_sha1 = (strchr(types, HASH_SHA1) != NULL); + m_creator->m_doing_crc32 = (strchr(types, HASH_CRC) != nullptr); + m_creator->m_doing_sha1 = (strchr(types, HASH_SHA1) != nullptr); } } @@ -357,7 +357,7 @@ void hash_collection::begin(const char *types) void hash_collection::buffer(const UINT8 *data, UINT32 length) { - assert(m_creator != NULL); + assert(m_creator != nullptr); // append to each active hash if (m_creator->m_doing_crc32) @@ -373,7 +373,7 @@ void hash_collection::buffer(const UINT8 *data, UINT32 length) void hash_collection::end() { - assert(m_creator != NULL); + assert(m_creator != nullptr); // finish up the CRC32 if (m_creator->m_doing_crc32) @@ -391,7 +391,7 @@ void hash_collection::end() // nuke the creator delete m_creator; - m_creator = NULL; + m_creator = nullptr; } @@ -412,5 +412,5 @@ void hash_collection::copyfrom(const hash_collection &src) m_sha1 = src.m_sha1; // don't copy creators - m_creator = NULL; + m_creator = nullptr; } diff --git a/src/emu/hash.h b/src/emu/hash.h index 6f066b237a0..52d5c6bf3b6 100644 --- a/src/emu/hash.h +++ b/src/emu/hash.h @@ -89,10 +89,10 @@ public: bool from_internal_string(const char *string); // creation - void begin(const char *types = NULL); + void begin(const char *types = nullptr); void buffer(const UINT8 *data, UINT32 length); void end(); - void compute(const UINT8 *data, UINT32 length, const char *types = NULL) { begin(types); buffer(data, length); end(); } + void compute(const UINT8 *data, UINT32 length, const char *types = nullptr) { begin(types); buffer(data, length); end(); } private: // internal helpers diff --git a/src/emu/hashfile.cpp b/src/emu/hashfile.cpp index c4735191780..374a09f5176 100644 --- a/src/emu/hashfile.cpp +++ b/src/emu/hashfile.cpp @@ -198,7 +198,7 @@ static void start_handler(void *data, const char *tagname, const char **attribut if (!strcmp(tagname, "hash")) { // we are now examining a hash tag - name = NULL; + name = nullptr; // device = IO_COUNT; while(attributes[0]) @@ -264,7 +264,7 @@ static void start_handler(void *data, const char *tagname, const char **attribut break; case HASH_POS_HASH: - text_dest = NULL; + text_dest = nullptr; if (!strcmp(tagname, "year")) { } @@ -296,7 +296,7 @@ static void start_handler(void *data, const char *tagname, const char **attribut static void end_handler(void *data, const char *name) { struct hash_parse_state *state = (struct hash_parse_state *) data; - state->text_dest = NULL; + state->text_dest = nullptr; state->pos = (hash_parse_position) (state->pos - 1); switch(state->pos) @@ -310,7 +310,7 @@ static void end_handler(void *data, const char *name) { if (state->use_proc) (*state->use_proc)(state->hashfile, state->param, state->hi); - state->hi = NULL; + state->hi = nullptr; } break; } @@ -373,7 +373,7 @@ static void hashfile_parse(hash_file *hashfile, memcallbacks.malloc_fcn = expat_malloc; memcallbacks.realloc_fcn = expat_realloc; memcallbacks.free_fcn = expat_free; - state.parser = XML_ParserCreate_MM(NULL, &memcallbacks, NULL); + state.parser = XML_ParserCreate_MM(nullptr, &memcallbacks, nullptr); if (!state.parser) goto done; @@ -428,8 +428,8 @@ static void preload_use_proc(hash_file *hashfile, void *param, hash_info *hi) hash_file *hashfile_open(emu_options &options, const char *sysname, int is_preload, void (*error_proc)(const char *message)) { - hash_file *hashfile = NULL; - object_pool *pool = NULL; + hash_file *hashfile = nullptr; + object_pool *pool = nullptr; file_error filerr; /* create a pool for this hash file */ @@ -453,19 +453,19 @@ hash_file *hashfile_open(emu_options &options, const char *sysname, int is_prelo if (filerr != FILERR_NONE) { global_free(hashfile->file); - hashfile->file = NULL; + hashfile->file = nullptr; goto error; } if (is_preload) - hashfile_parse(hashfile, NULL, preload_use_proc, hashfile->error_proc, NULL); + hashfile_parse(hashfile, nullptr, preload_use_proc, hashfile->error_proc, nullptr); return hashfile; error: - if (hashfile != NULL) + if (hashfile != nullptr) hashfile_close(hashfile); - return NULL; + return nullptr; } @@ -522,11 +522,11 @@ const hash_info *hashfile_lookup(hash_file *hashfile, const hash_collection *has int i; param.hashes = hashes; - param.hi = NULL; + param.hi = nullptr; for (i = 0; i < hashfile->preloaded_hash_count; i++) { - if (singular_selector_proc(hashfile, ¶m, NULL, hashfile->preloaded_hashes[i]->hashes)) + if (singular_selector_proc(hashfile, ¶m, nullptr, hashfile->preloaded_hashes[i]->hashes)) return hashfile->preloaded_hashes[i]; } @@ -535,7 +535,7 @@ const hash_info *hashfile_lookup(hash_file *hashfile, const hash_collection *has return param.hi; } -const char *extra_info = NULL; +const char *extra_info = nullptr; bool read_hash_config(device_image_interface &image, const char *sysname, std::string &result) { @@ -543,7 +543,7 @@ bool read_hash_config(device_image_interface &image, const char *sysname, std::s const hash_info *info; /* open the hash file */ - hashfile = hashfile_open(image.device().mconfig().options(), sysname, FALSE, NULL); + hashfile = hashfile_open(image.device().mconfig().options(), sysname, FALSE, nullptr); if (!hashfile) return false; @@ -567,7 +567,7 @@ bool hashfile_extrainfo(device_image_interface &image, std::string &result) { /* now read the hash file */ image.crc(); - extra_info = NULL; + extra_info = nullptr; int drv = driver_list::find(*image.device().mconfig().options().system()); int compat, open = drv; bool hashfound; diff --git a/src/emu/image.cpp b/src/emu/image.cpp index b9b8b89dc41..ab7f7406854 100644 --- a/src/emu/image.cpp +++ b/src/emu/image.cpp @@ -47,7 +47,7 @@ static UINT64 image_fsize_thunk(void *file) struct io_procs image_ioprocs = { - NULL, + nullptr, image_fseek_thunk, image_fread_thunk, image_fwrite_thunk, @@ -69,20 +69,20 @@ static void image_dirs_load(running_machine &machine, int config_type, xml_data_ const char *dev_instance; const char *working_directory; - if ((config_type == CONFIG_TYPE_GAME) && (parentnode != NULL)) + if ((config_type == CONFIG_TYPE_GAME) && (parentnode != nullptr)) { for (node = xml_get_sibling(parentnode->child, "device"); node; node = xml_get_sibling(node->next, "device")) { - dev_instance = xml_get_attribute_string(node, "instance", NULL); + dev_instance = xml_get_attribute_string(node, "instance", nullptr); - if ((dev_instance != NULL) && (dev_instance[0] != '\0')) + if ((dev_instance != nullptr) && (dev_instance[0] != '\0')) { image_interface_iterator iter(machine.root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { if (!strcmp(dev_instance, image->instance_name())) { - working_directory = xml_get_attribute_string(node, "directory", NULL); - if (working_directory != NULL) + working_directory = xml_get_attribute_string(node, "directory", nullptr); + if (working_directory != nullptr) image->set_working_directory(working_directory); } } @@ -107,12 +107,12 @@ static void image_dirs_save(running_machine &machine, int config_type, xml_data_ if (config_type == CONFIG_TYPE_GAME) { image_interface_iterator iter(machine.root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { dev_instance = image->instance_name(); - node = xml_add_child(parentnode, "device", NULL); - if (node != NULL) + node = xml_add_child(parentnode, "device", nullptr); + if (node != nullptr) { xml_set_attribute(node, "instance", dev_instance); xml_set_attribute(node, "directory", image->working_directory()); @@ -131,7 +131,7 @@ static int write_config(emu_options &options, const char *filename, const game_d char buffer[128]; int retval = 1; - if (gamedrv != NULL) + if (gamedrv != nullptr) { sprintf(buffer, "%s.ini", gamedrv->name); filename = buffer; @@ -162,7 +162,7 @@ static void image_options_extract(running_machine &machine) int index = 0; image_interface_iterator iter(machine.root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { const char *filename = image->filename(); @@ -176,7 +176,7 @@ static void image_options_extract(running_machine &machine) /* write the config, if appropriate */ if (machine.options().write_config()) - write_config(machine.options(), NULL, &machine.system()); + write_config(machine.options(), nullptr, &machine.system()); } /*------------------------------------------------- @@ -190,7 +190,7 @@ void image_unload_all(running_machine &machine) image_options_extract(machine); image_interface_iterator iter(machine.root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { // unload this image image->unload(); @@ -207,12 +207,12 @@ void image_device_init(running_machine &machine) /* make sure that any required devices have been allocated */ image_interface_iterator iter(machine.root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { /* is an image specified for this image */ image_name = machine.options().value(image->instance_name()); - if ((image_name != NULL) && (image_name[0] != '\0')) + if ((image_name != nullptr) && (image_name[0] != '\0')) { /* mark init state */ image->set_init_phase(); @@ -249,9 +249,9 @@ std::string &image_mandatory_scan(running_machine &machine, std::string &mandato mandatory.clear(); // make sure that any required image has a mounted file image_interface_iterator iter(machine.root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { - if (image->filename() == NULL && image->must_be_loaded()) + if (image->filename() == nullptr && image->must_be_loaded()) mandatory.append("\"").append(image->instance_name()).append("\", "); } return mandatory; @@ -266,7 +266,7 @@ void image_postdevice_init(running_machine &machine) { /* make sure that any required devices have been allocated */ image_interface_iterator iter(machine.root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { int result = image->finish_load(); /* did the image load fail? */ diff --git a/src/emu/info.cpp b/src/emu/info.cpp index 2127de32b6f..fdf5e1c9a5c 100644 --- a/src/emu/info.cpp +++ b/src/emu/info.cpp @@ -175,7 +175,7 @@ const char info_xml_creator::s_dtd_string[] = //------------------------------------------------- info_xml_creator::info_xml_creator(driver_enumerator &drivlist) - : m_output(NULL), + : m_output(nullptr), m_drivlist(drivlist), m_lookup_options(m_drivlist.options()) { @@ -242,7 +242,7 @@ void info_xml_creator::output_one() ioport_list portlist; std::string errors; device_iterator iter(config.root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) portlist.append(*device, errors); // print the header and the game name @@ -251,9 +251,9 @@ void info_xml_creator::output_one() // strip away any path information from the source_file and output it const char *start = strrchr(driver.source_file, '/'); - if (start == NULL) + if (start == nullptr) start = strrchr(driver.source_file, '\\'); - if (start == NULL) + if (start == nullptr) start = driver.source_file - 1; fprintf(m_output, " sourcefile=\"%s\"", xml_normalize_string(start + 1)); @@ -277,15 +277,15 @@ void info_xml_creator::output_one() fprintf(m_output, ">\n"); // output game description - if (driver.description != NULL) + if (driver.description != nullptr) fprintf(m_output, "\t\t%s\n", xml_normalize_string(driver.description)); // print the year only if is a number or another allowed character (? or +) - if (driver.year != NULL && strspn(driver.year, "0123456789?+") == strlen(driver.year)) + if (driver.year != nullptr && strspn(driver.year, "0123456789?+") == strlen(driver.year)) fprintf(m_output, "\t\t%s\n", xml_normalize_string(driver.year)); // print the manufacturer information - if (driver.manufacturer != NULL) + if (driver.manufacturer != nullptr) fprintf(m_output, "\t\t%s\n", xml_normalize_string(driver.manufacturer)); // now print various additional information @@ -322,17 +322,17 @@ void info_xml_creator::output_one_device(device_t &device, const char *devtag) bool has_speaker = FALSE, has_input = FALSE; // check if the device adds speakers to the system sound_interface_iterator snditer(device); - if (snditer.first() != NULL) + if (snditer.first() != nullptr) has_speaker = TRUE; // generate input list ioport_list portlist; std::string errors; device_iterator iptiter(device); - for (device_t *dev = iptiter.first(); dev != NULL; dev = iptiter.next()) + for (device_t *dev = iptiter.first(); dev != nullptr; dev = iptiter.next()) portlist.append(*dev, errors); // check if the device adds player inputs (other than dsw and configs) to the system - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->type() >= IPT_START1 && field->type() < IPT_UI_FIRST) { has_input = TRUE; @@ -354,7 +354,7 @@ void info_xml_creator::output_one_device(device_t &device, const char *devtag) output_rom(device); samples_device *samples = dynamic_cast(&device); - if (samples==NULL) output_sample(device); // ignore samples_device itself + if (samples==nullptr) output_sample(device); // ignore samples_device itself output_chips(device, devtag); output_display(device, devtag); @@ -394,9 +394,9 @@ void info_xml_creator::output_devices() { // first, run through devices with roms which belongs to the default configuration device_iterator deviter(m_drivlist.config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { - if (device->owner() != NULL && device->shortname()!= NULL && strlen(device->shortname())!=0) + if (device->owner() != nullptr && device->shortname()!= nullptr && strlen(device->shortname())!=0) { if (shortnames.add(device->shortname(), 0, FALSE) != TMERR_DUPLICATE) output_one_device(*device, device->tag()); @@ -405,9 +405,9 @@ void info_xml_creator::output_devices() // then, run through slot devices slot_interface_iterator iter(m_drivlist.config().root_device()); - for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next()) + for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next()) { - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) { std::string temptag("_"); temptag.append(option->name()); @@ -415,7 +415,7 @@ void info_xml_creator::output_devices() // notify this device and all its subdevices that they are now configured device_iterator subiter(*dev); - for (device_t *device = subiter.first(); device != NULL; device = subiter.next()) + for (device_t *device = subiter.first(); device != nullptr; device = subiter.next()) if (!device->configured()) device->config_complete(); @@ -424,9 +424,9 @@ void info_xml_creator::output_devices() // also, check for subdevices with ROMs (a few devices are missed otherwise, e.g. MPU401) device_iterator deviter2(*dev); - for (device_t *device = deviter2.first(); device != NULL; device = deviter2.next()) + for (device_t *device = deviter2.first(); device != nullptr; device = deviter2.next()) { - if (device->owner() == dev && device->shortname()!= NULL && strlen(device->shortname())!=0) + if (device->owner() == dev && device->shortname()!= nullptr && strlen(device->shortname())!=0) { if (shortnames.add(device->shortname(), 0, FALSE) != TMERR_DUPLICATE) output_one_device(*device, device->tag()); @@ -448,8 +448,8 @@ void info_xml_creator::output_devices() void info_xml_creator::output_device_roms() { device_iterator deviter(m_drivlist.config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) - if (device->owner() != NULL && device->shortname()!= NULL && strlen(device->shortname())!=0) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) + if (device->owner() != nullptr && device->shortname()!= nullptr && strlen(device->shortname())!=0) fprintf(m_output, "\t\t\n", xml_normalize_string(device->shortname())); } @@ -463,10 +463,10 @@ void info_xml_creator::output_sampleof() { // iterate over sample devices samples_device_iterator iter(m_drivlist.config().root_device()); - for (samples_device *device = iter.first(); device != NULL; device = iter.next()) + for (samples_device *device = iter.first(); device != nullptr; device = iter.next()) { samples_iterator sampiter(*device); - if (sampiter.altbasename() != NULL) + if (sampiter.altbasename() != nullptr) { fprintf(m_output, " sampleof=\"%s\"", xml_normalize_string(sampiter.altbasename())); @@ -485,7 +485,7 @@ void info_xml_creator::output_sampleof() void info_xml_creator::output_bios() { // skip if no ROMs - if (m_drivlist.driver().rom == NULL) + if (m_drivlist.driver().rom == nullptr) return; // iterate over ROM entries and look for BIOSes @@ -512,7 +512,7 @@ void info_xml_creator::output_rom(device_t &device) { // iterate over 3 different ROM "types": BIOS, ROMs, DISKs for (int rom_type = 0; rom_type < 3; rom_type++) - for (const rom_entry *region = rom_first_region(device); region != NULL; region = rom_next_region(region)) + for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region)) { bool is_disk = ROMREGION_ISDISKDATA(region); @@ -521,12 +521,12 @@ void info_xml_creator::output_rom(device_t &device) continue; // iterate through ROM entries - for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) + for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) { bool is_bios = ROM_GETBIOSFLAGS(rom); const char *name = ROM_GETNAME(rom); int offset = ROM_GETOFFSET(rom); - const char *merge_name = NULL; + const char *merge_name = nullptr; char bios_name[100]; // BIOS ROMs only apply to bioses @@ -538,7 +538,7 @@ void info_xml_creator::output_rom(device_t &device) if (!hashes.flag(hash_collection::FLAG_NO_DUMP)) merge_name = get_merge_name(hashes); if (&device != &m_drivlist.config().root_device()) - merge_name = NULL; + merge_name = nullptr; // scan for a BIOS name bios_name[0] = 0; if (!is_disk && is_bios) @@ -561,9 +561,9 @@ void info_xml_creator::output_rom(device_t &device) output.append("\t\t already_printed; - for (const char *samplename = iter.first(); samplename != NULL; samplename = iter.next()) + for (const char *samplename = iter.first(); samplename != nullptr; samplename = iter.next()) { // filter out duplicates if (already_printed.add(samplename, 1) == TMERR_DUPLICATE) @@ -641,7 +641,7 @@ void info_xml_creator::output_chips(device_t &device, const char *root_tag) { // iterate over executable devices execute_interface_iterator execiter(device); - for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next()) + for (device_execute_interface *exec = execiter.first(); exec != nullptr; exec = execiter.next()) { if (strcmp(exec->device().tag(), device.tag())) { @@ -659,7 +659,7 @@ void info_xml_creator::output_chips(device_t &device, const char *root_tag) // iterate over sound devices sound_interface_iterator sounditer(device); - for (device_sound_interface *sound = sounditer.first(); sound != NULL; sound = sounditer.next()) + for (device_sound_interface *sound = sounditer.first(); sound != nullptr; sound = sounditer.next()) { if (strcmp(sound->device().tag(), device.tag())) { @@ -687,7 +687,7 @@ void info_xml_creator::output_display(device_t &device, const char *root_tag) { // iterate over screens screen_device_iterator iter(device); - for (const screen_device *screendev = iter.first(); screendev != NULL; screendev = iter.next()) + for (const screen_device *screendev = iter.first(); screendev != nullptr; screendev = iter.next()) { if (strcmp(screendev->tag(), device.tag())) { @@ -777,7 +777,7 @@ void info_xml_creator::output_sound(device_t &device) // if we have no sound, zero m_output the speaker count sound_interface_iterator snditer(device); - if (snditer.first() == NULL) + if (snditer.first() == nullptr) speakers = 0; fprintf(m_output, "\t\t\n", speakers); @@ -841,8 +841,8 @@ void info_xml_creator::output_input(const ioport_list &portlist) bool gambling = false; // iterate over the ports - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) { int analogtype = -1; @@ -1046,20 +1046,20 @@ void info_xml_creator::output_input(const ioport_list &portlist) } // output analog types - for (int type = 0; type < ANALOG_TYPE_COUNT; type++) - if (control_info[type].type != NULL) + for (auto & elem : control_info) + if (elem.type != nullptr) { - fprintf(m_output, "\t\t\t\n"); @@ -1091,8 +1091,8 @@ void info_xml_creator::output_input(const ioport_list &portlist) void info_xml_creator::output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag) { // iterate looking for DIP switches - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->type() == type) { std::string output; @@ -1106,7 +1106,7 @@ void info_xml_creator::output_switches(const ioport_list &portlist, const char * strcatprintf(output,"\t\t<%s name=\"%s\" tag=\"%s\" mask=\"%u\">\n", outertag, normalized_field_name.c_str(), normalized_newtag.c_str(), field->mask()); // loop over settings - for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = field->first_setting(); setting != nullptr; setting = setting->next()) { strcatprintf(output,"\t\t\t<%s name=\"%s\" value=\"%u\"%s/>\n", innertag, xml_normalize_string(setting->name()), setting->value(), setting->value() == field->defvalue() ? " default=\"yes\"" : ""); } @@ -1125,10 +1125,10 @@ void info_xml_creator::output_switches(const ioport_list &portlist, const char * void info_xml_creator::output_ports(const ioport_list &portlist) { // cycle through ports - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) { fprintf(m_output,"\t\t\n",port->tag()); - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) { if(field->is_analog()) fprintf(m_output,"\t\t\t\n",field->mask()); @@ -1147,8 +1147,8 @@ void info_xml_creator::output_ports(const ioport_list &portlist) void info_xml_creator::output_adjusters(const ioport_list &portlist) { // iterate looking for Adjusters - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->type() == IPT_ADJUSTER) fprintf(m_output, "\t\t\n", xml_normalize_string(field->name()), field->defvalue()); } @@ -1224,7 +1224,7 @@ void info_xml_creator::output_driver() void info_xml_creator::output_images(device_t &device, const char *root_tag) { image_interface_iterator iter(device); - for (const device_image_interface *imagedev = iter.first(); imagedev != NULL; imagedev = iter.next()) + for (const device_image_interface *imagedev = iter.first(); imagedev != nullptr; imagedev = iter.next()) { if (strcmp(imagedev->device().tag(), device.tag())) { @@ -1259,12 +1259,12 @@ void info_xml_creator::output_images(device_t &device, const char *root_tag) std::string extensions(imagedev->file_extensions()); char *ext = strtok((char *)extensions.c_str(), ","); - while (ext != NULL) + while (ext != nullptr) { fprintf(m_output, "\t\t\t\n"); - ext = strtok(NULL, ","); + ext = strtok(nullptr, ","); } fprintf(m_output, "\t\t\n"); @@ -1280,7 +1280,7 @@ void info_xml_creator::output_images(device_t &device, const char *root_tag) void info_xml_creator::output_slots(device_t &device, const char *root_tag) { slot_interface_iterator iter(device); - for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next()) + for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next()) { if (slot->fixed()) continue; // or shall we list these as non-configurable? @@ -1297,7 +1297,7 @@ void info_xml_creator::output_slots(device_t &device, const char *root_tag) fprintf(m_output, " interface=\"%s\"", xml_normalize_string(slot->slot_interface())); */ - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) { if (option->selectable()) { @@ -1332,7 +1332,7 @@ void info_xml_creator::output_slots(device_t &device, const char *root_tag) void info_xml_creator::output_software_list() { software_list_device_iterator iter(m_drivlist.config().root_device()); - for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next()) + for (const software_list_device *swlist = iter.first(); swlist != nullptr; swlist = iter.next()) { fprintf(m_output, "\t\tlist_name()); fprintf(m_output, "status=\"%s\" ", (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) ? "original" : "compatible"); @@ -1353,11 +1353,11 @@ void info_xml_creator::output_software_list() void info_xml_creator::output_ramoptions() { ram_device_iterator iter(m_drivlist.config().root_device()); - for (const ram_device *ram = iter.first(); ram != NULL; ram = iter.next()) + for (const ram_device *ram = iter.first(); ram != nullptr; ram = iter.next()) { fprintf(m_output, "\t\t%u\n", ram->default_size()); - if (ram->extra_options() != NULL) + if (ram->extra_options() != nullptr) { std::string options(ram->extra_options()); for (int start = 0, end = options.find_first_of(',');; start = end + 1, end = options.find_first_of(',', start)) @@ -1381,13 +1381,13 @@ void info_xml_creator::output_ramoptions() const char *info_xml_creator::get_merge_name(const hash_collection &romhashes) { // walk the parent chain - const char *merge_name = NULL; + const char *merge_name = nullptr; for (int clone_of = m_drivlist.find(m_drivlist.driver().parent); clone_of != -1; clone_of = m_drivlist.find(m_drivlist.driver(clone_of).parent)) { // look in the parent's ROMs device_t *device = &m_drivlist.config(clone_of, m_lookup_options).root_device(); - for (const rom_entry *pregion = rom_first_region(*device); pregion != NULL; pregion = rom_next_region(pregion)) - for (const rom_entry *prom = rom_first_file(pregion); prom != NULL; prom = rom_next_file(prom)) + for (const rom_entry *pregion = rom_first_region(*device); pregion != nullptr; pregion = rom_next_region(pregion)) + for (const rom_entry *prom = rom_first_file(pregion); prom != nullptr; prom = rom_next_file(prom)) { hash_collection phashes(ROM_GETHASHDATA(prom)); if (!phashes.flag(hash_collection::FLAG_NO_DUMP) && romhashes == phashes) diff --git a/src/emu/inpttype.h b/src/emu/inpttype.h index 849fea74d61..79843fdff34 100644 --- a/src/emu/inpttype.h +++ b/src/emu/inpttype.h @@ -755,33 +755,33 @@ void construct_core_types_UI(simple_list &typelist) void construct_core_types_OSD(simple_list &typelist) { - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_1, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_2, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_3, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_4, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_5, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_6, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_7, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_8, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_9, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_10, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_11, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_12, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_13, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_14, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_15, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_16, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_1, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_2, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_3, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_4, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_5, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_6, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_7, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_8, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_9, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_10, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_11, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_12, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_13, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_14, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_15, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_16, nullptr, input_seq() ) } void construct_core_types_invalid(simple_list &typelist) { - INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNKNOWN, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNUSED, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, INVALID, SPECIAL, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, INVALID, OTHER, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, INVALID, ADJUSTER, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, INVALID, DIPSWITCH, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, INVALID, CONFIG, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNKNOWN, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNUSED, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, SPECIAL, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, OTHER, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, ADJUSTER, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, DIPSWITCH, nullptr, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, CONFIG, nullptr, input_seq() ) } void construct_core_types(simple_list &typelist) diff --git a/src/emu/input.cpp b/src/emu/input.cpp index 5e50d3e66fc..41f7b132bac 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -54,9 +54,9 @@ public: input_device_switch_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate); // readers - virtual INT32 read_as_switch(input_item_modifier modifier); - virtual INT32 read_as_relative(input_item_modifier modifier); - virtual INT32 read_as_absolute(input_item_modifier modifier); + virtual INT32 read_as_switch(input_item_modifier modifier) override; + virtual INT32 read_as_relative(input_item_modifier modifier) override; + virtual INT32 read_as_absolute(input_item_modifier modifier) override; // steadykey helper bool steadykey_changed(); @@ -79,9 +79,9 @@ public: input_device_relative_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate); // readers - virtual INT32 read_as_switch(input_item_modifier modifier); - virtual INT32 read_as_relative(input_item_modifier modifier); - virtual INT32 read_as_absolute(input_item_modifier modifier); + virtual INT32 read_as_switch(input_item_modifier modifier) override; + virtual INT32 read_as_relative(input_item_modifier modifier) override; + virtual INT32 read_as_absolute(input_item_modifier modifier) override; }; @@ -95,9 +95,9 @@ public: input_device_absolute_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate); // readers - virtual INT32 read_as_switch(input_item_modifier modifier); - virtual INT32 read_as_relative(input_item_modifier modifier); - virtual INT32 read_as_absolute(input_item_modifier modifier); + virtual INT32 read_as_switch(input_item_modifier modifier) override; + virtual INT32 read_as_relative(input_item_modifier modifier) override; + virtual INT32 read_as_absolute(input_item_modifier modifier) override; }; @@ -119,7 +119,7 @@ struct code_string_table for (const code_string_table *current = this; current->m_code != ~0; current++) if (current->m_code == code) return current->m_string; - return NULL; + return nullptr; } UINT32 m_code; @@ -411,7 +411,7 @@ static const code_string_table itemid_token_table[] = { ITEM_ID_ADD_RELATIVE15,"ADDREL15" }, { ITEM_ID_ADD_RELATIVE16,"ADDREL16" }, - { ~0U, NULL } + { ~0U, nullptr } }; @@ -509,7 +509,7 @@ bool joystick_map::parse(const char *mapstring) const char *ptr = strchr(validchars, *mapstring++); // invalid characters exit immediately - if (ptr == NULL) + if (ptr == nullptr) return false; m_map[rownum][colnum] = charmap[ptr - validchars]; } @@ -532,11 +532,11 @@ bool joystick_map::parse(const char *mapstring) const char *joystick_map::to_string(std::string &str) const { strprintf(str, "%s\n", m_origstring.c_str()); - for (int rownum = 0; rownum < 9; rownum++) + for (auto & elem : m_map) { str.append(" "); for (int colnum = 0; colnum < 9; colnum++) - switch (m_map[rownum][colnum]) + switch (elem[colnum]) { case JOYSTICK_MAP_UP | JOYSTICK_MAP_LEFT: str.append("7"); break; case JOYSTICK_MAP_UP: str.append("8"); break; @@ -594,7 +594,7 @@ input_code::input_code(input_device &device, input_item_id itemid) { assert(itemid < ITEM_ID_ABSOLUTE_MAXIMUM); input_device_item *item = device.item(itemid); - assert(item != NULL); + assert(item != nullptr); m_internal = ((device.devclass() & 0xf) << 28) | ((device.devindex() & 0xff) << 20) | ((item->itemclass() & 0xf) << 16) | (ITEM_MODIFIER_NONE << 12) | (item->itemid() & 0xfff); } @@ -673,10 +673,10 @@ bool input_seq::is_valid() const input_item_class lastclass = ITEM_CLASS_INVALID; input_code lastcode = INPUT_CODE_INVALID; int positive_code_count = 0; - for (int seqnum = 0; seqnum < ARRAY_LENGTH(m_code); seqnum++) + for (auto code : m_code) { // invalid codes are never permitted - input_code code = m_code[seqnum]; + if (code == INPUT_CODE_INVALID) return false; @@ -773,9 +773,9 @@ void input_seq::backspace() void input_seq::replace(input_code oldcode, input_code newcode) { - for (int codenum = 0; codenum < ARRAY_LENGTH(m_code); codenum++) - if (m_code[codenum] == oldcode) - m_code[codenum] = newcode; + for (auto & elem : m_code) + if (elem == oldcode) + elem = newcode; } @@ -827,20 +827,20 @@ input_device::input_device(input_class &_class, int devindex, const char *name, input_item_id input_device::add_item(const char *name, input_item_id itemid, item_get_state_func getstate, void *internal) { assert_always(machine().phase() == MACHINE_PHASE_INIT, "Can only call input_device::add_item at init time!"); - assert(name != NULL); + assert(name != nullptr); assert(itemid > ITEM_ID_INVALID && itemid < ITEM_ID_MAXIMUM); - assert(getstate != NULL); + assert(getstate != nullptr); // if we have a generic ID, pick a new internal one input_item_id originalid = itemid; if (itemid >= ITEM_ID_OTHER_SWITCH && itemid <= ITEM_ID_OTHER_AXIS_RELATIVE) for (itemid = (input_item_id)(ITEM_ID_MAXIMUM + 1); itemid <= ITEM_ID_ABSOLUTE_MAXIMUM; ++itemid) - if (m_item[itemid] == NULL) + if (m_item[itemid] == nullptr) break; assert(itemid <= ITEM_ID_ABSOLUTE_MAXIMUM); // make sure we don't have any overlap - assert(m_item[itemid] == NULL); + assert(m_item[itemid] == nullptr); // determine the class and create the appropriate item class switch (m_class.standard_item_class(originalid)) @@ -921,7 +921,7 @@ void input_device::apply_steadykey() const for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= m_maxitem; ++itemid) { input_device_item *item = m_item[itemid].get(); - if (item != NULL && item->itemclass() == ITEM_CLASS_SWITCH) + if (item != nullptr && item->itemclass() == ITEM_CLASS_SWITCH) if (downcast(item)->steadykey_changed()) anything_changed = true; } @@ -931,7 +931,7 @@ void input_device::apply_steadykey() const for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= m_maxitem; ++itemid) { input_device_item *item = m_item[itemid].get(); - if (item != NULL && item->itemclass() == ITEM_CLASS_SWITCH) + if (item != nullptr && item->itemclass() == ITEM_CLASS_SWITCH) downcast(item)->steadykey_update_to_current(); } } @@ -968,7 +968,7 @@ input_device *input_class::add_device(const char *name, void *internal) // find the next empty index int devindex; for (devindex = 0; devindex < DEVICE_INDEX_MAXIMUM; devindex++) - if (m_device[devindex] == NULL) + if (m_device[devindex] == nullptr) break; // call through @@ -978,9 +978,9 @@ input_device *input_class::add_device(const char *name, void *internal) input_device *input_class::add_device(int devindex, const char *name, void *internal) { assert_always(machine().phase() == MACHINE_PHASE_INIT, "Can only call input_class::add_device at init time!"); - assert(name != NULL); + assert(name != nullptr); assert(devindex >= 0 && devindex < DEVICE_INDEX_MAXIMUM); - assert(m_device[devindex] == NULL); + assert(m_device[devindex] == nullptr); // allocate a new device m_device[devindex] = std::make_unique(*this, devindex, name, internal); @@ -1023,7 +1023,7 @@ void input_class::frame_callback() { // iterate over all devices in our class for (int devnum = 0; devnum <= m_maxindex; devnum++) - if (m_device[devnum] != NULL) + if (m_device[devnum] != nullptr) m_device[devnum]->apply_steadykey(); } @@ -1073,7 +1073,7 @@ INT32 input_manager::code_value(input_code code) { // return 0 for any invalid devices input_device *device = device_from_code(code); - if (device == NULL) + if (device == nullptr) break; // also return 0 if the device class is disabled @@ -1098,7 +1098,7 @@ INT32 input_manager::code_value(input_code code) // lookup the item for the appropriate index code.set_device_index(curindex); input_device_item *item = item_from_code(code); - if (item == NULL) + if (item == nullptr) continue; // process items according to their native type @@ -1186,7 +1186,7 @@ void input_manager::reset_polling() { // fetch the device; ignore if NULL input_device *device = m_class[devclass]->device(devnum); - if (device == NULL) + if (device == nullptr) continue; // iterate over items within each device @@ -1194,7 +1194,7 @@ void input_manager::reset_polling() { // for any non-switch items, set memory equal to the current value input_device_item *item = device->item(itemid); - if (item != NULL && item->itemclass() != ITEM_CLASS_SWITCH) + if (item != nullptr && item->itemclass() != ITEM_CLASS_SWITCH) item->set_memory(code_value(input_code(*device, itemid))); } } @@ -1213,14 +1213,14 @@ input_code input_manager::poll_switches() { // fetch the device; ignore if NULL input_device *device = m_class[devclass]->device(devnum); - if (device == NULL) + if (device == nullptr) continue; // iterate over items within each device for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid) { input_device_item *item = device->item(itemid); - if (item != NULL) + if (item != nullptr) { input_code code(*device, itemid); @@ -1293,14 +1293,14 @@ input_code input_manager::poll_keyboard_switches() { // fetch the device; ignore if NULL input_device *device = m_keyboard_class.device(devnum); - if (device == NULL) + if (device == nullptr) continue; // iterate over items within each device for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid) { input_device_item *item = device->item(itemid); - if (item != NULL && item->itemclass() == ITEM_CLASS_SWITCH) + if (item != nullptr && item->itemclass() == ITEM_CLASS_SWITCH) { input_code code(*device, itemid); if (code_pressed_once(code)) @@ -1367,14 +1367,14 @@ input_code input_manager::poll_axes() { // fetch the device; ignore if NULL input_device *device = m_class[devclass]->device(devnum); - if (device == NULL) + if (device == nullptr) continue; // iterate over items within each device for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid) { input_device_item *item = device->item(itemid); - if (item != NULL && item->itemclass() != ITEM_CLASS_SWITCH) + if (item != nullptr && item->itemclass() != ITEM_CLASS_SWITCH) { input_code code(*device, itemid); if (code_check_axis(*item, code)) @@ -1401,7 +1401,7 @@ input_device *input_manager::device_from_code(input_code code) const return m_class[devclass]->device(code.device_index()); // otherwise, return NULL - return NULL; + return nullptr; } @@ -1414,8 +1414,8 @@ input_device_item *input_manager::item_from_code(input_code code) const { // first get the device; if none, then we don't have an item input_device *device = device_from_code(code); - if (device == NULL) - return NULL; + if (device == nullptr) + return nullptr; // then return the device's item return device->item(code.item_id()); @@ -1430,8 +1430,8 @@ input_device_item *input_manager::item_from_code(input_code code) const void input_manager::reset_memory() { // reset all entries in switch memory to invalid - for (int memnum = 0; memnum < ARRAY_LENGTH(m_switch_memory); memnum++) - m_switch_memory[memnum] = INPUT_CODE_INVALID; + for (auto & elem : m_switch_memory) + elem = INPUT_CODE_INVALID; } @@ -1447,7 +1447,7 @@ input_code input_manager::code_from_itemid(input_item_id itemid) const for (int devnum = 0; devnum <= m_class[devclass]->maxindex(); devnum++) { input_device *device = m_class[devclass]->device(devnum); - if (device != NULL && device->item(itemid) != NULL) + if (device != nullptr && device->item(itemid) != nullptr) return input_code(*device, itemid); } @@ -1466,7 +1466,7 @@ const char *input_manager::code_name(std::string &str, input_code code) const // if nothing there, return an empty string input_device_item *item = item_from_code(code); - if (item == NULL) + if (item == nullptr) return str.c_str(); // determine the devclass part @@ -1505,7 +1505,7 @@ const char *input_manager::code_name(std::string &str, input_code code) const str.append(" ").append(devindex); if (devcode[0] != 0) str.append(" ").append(devcode); - if (modifier != NULL) + if (modifier != nullptr) str.append(" ").append(modifier); // delete any leading spaces @@ -1531,14 +1531,14 @@ const char *input_manager::code_to_token(std::string &str, input_code code) cons // determine the itemid part; look up in the table if we don't have a token input_device_item *item = item_from_code(code); - const char *devcode = (item != NULL) ? item->token() : "UNKNOWN"; + const char *devcode = (item != nullptr) ? item->token() : "UNKNOWN"; // determine the modifier part const char *modifier = (*modifier_token_table)[code.item_modifier()]; // determine the itemclass part; if we match the native class, we don't include this const char *itemclass = ""; - if (item == NULL || item->itemclass() != code.item_class()) + if (item == nullptr || item->itemclass() != code.item_class()) itemclass = (*itemclass_token_table)[code.item_class()]; // concatenate the strings @@ -1547,7 +1547,7 @@ const char *input_manager::code_to_token(std::string &str, input_code code) cons str.append("_").append(devindex); if (devcode[0] != 0) str.append("_").append(devcode); - if (modifier != NULL) + if (modifier != nullptr) str.append("_").append(modifier); if (itemclass[0] != 0) str.append("_").append(itemclass); @@ -1569,10 +1569,10 @@ input_code input_manager::code_from_token(const char *_token) { // make a token up to the next underscore char *score = (char *)strchr(_token, '_'); - token[numtokens++].assign(_token, (score == NULL) ? strlen(_token) : (score - _token)); + token[numtokens++].assign(_token, (score == nullptr) ? strlen(_token) : (score - _token)); // if we hit the end, we're done, else advance our pointer - if (score == NULL) + if (score == nullptr) break; _token = score + 1; } @@ -1607,14 +1607,14 @@ input_code input_manager::code_from_token(const char *_token) { // if this is an invalid device, we have nothing to look up input_device *device = m_class[devclass]->device(devindex); - if (device == NULL) + if (device == nullptr) return INPUT_CODE_INVALID; // if not a standard code, look it up in the device specific codes for (itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid) { input_device_item *item = device->item(itemid); - if (item != NULL && token[curtok].compare(item->token()) == 0) + if (item != nullptr && token[curtok].compare(item->token()) == 0) { // take the itemclass from the item itemclass = item->itemclass(); @@ -1811,7 +1811,7 @@ void input_manager::seq_poll_start(input_item_class itemclass, const input_seq * m_poll_seq.reset(); // grab the starting sequence to append to, and append an OR - if (startseq != NULL) + if (startseq != nullptr) { m_poll_seq = *startseq; if (m_poll_seq.length() > 0) @@ -2079,7 +2079,7 @@ bool input_manager::set_global_joystick_map(const char *mapstring) for (int joynum = 0; joynum <= m_joystick_class.maxindex(); joynum++) { input_device *device = m_joystick_class.device(joynum); - if (device != NULL) + if (device != nullptr) device->set_joystick_map(map); } return true; @@ -2106,7 +2106,7 @@ input_device_item::input_device_item(input_device &device, const char *name, voi m_memory(0) { // use a standard token name for know item IDs - if (itemid <= ITEM_ID_MAXIMUM && (*itemid_token_table)[itemid] != NULL) + if (itemid <= ITEM_ID_MAXIMUM && (*itemid_token_table)[itemid] != nullptr) m_token.assign((*itemid_token_table)[itemid]); // otherwise, create a tokenized name @@ -2160,7 +2160,7 @@ INT32 input_device_switch_item::read_as_switch(input_item_modifier modifier) if (m_itemid == ITEM_ID_BUTTON1) { input_device_item *button2_item = m_device.item(ITEM_ID_BUTTON2); - if (button2_item != NULL) + if (button2_item != nullptr) return button2_item->update_value() | update_value(); } @@ -2310,7 +2310,7 @@ INT32 input_device_absolute_item::read_as_switch(input_item_modifier modifier) { input_device_item *xaxis_item = m_device.item(ITEM_ID_XAXIS); input_device_item *yaxis_item = m_device.item(ITEM_ID_YAXIS); - if (xaxis_item != NULL && yaxis_item != NULL) + if (xaxis_item != nullptr && yaxis_item != nullptr) { // determine which item we didn't update, and update it assert(this == xaxis_item || this == yaxis_item); @@ -2364,7 +2364,7 @@ INT32 input_device_absolute_item::read_as_absolute(input_item_modifier modifier) { // if it is pressed, return (min,max) input_device_item *button2_item = m_device.item(ITEM_ID_BUTTON2); - if (button2_item != NULL && button2_item->update_value()) + if (button2_item != nullptr && button2_item->update_value()) result = (m_itemid == ITEM_ID_XAXIS) ? INPUT_ABSOLUTE_MIN : INPUT_ABSOLUTE_MAX; } diff --git a/src/emu/input.h b/src/emu/input.h index da2b6a2b3ec..b0f006d3fd9 100644 --- a/src/emu/input.h +++ b/src/emu/input.h @@ -558,7 +558,7 @@ public: bool lightgun_reload_button() const { return m_lightgun_reload_button; } // item management - input_item_id add_item(const char *name, input_item_id itemid, item_get_state_func getstate, void *internal = NULL); + input_item_id add_item(const char *name, input_item_id itemid, item_get_state_func getstate, void *internal = nullptr); void set_joystick_map(const joystick_map &map) { m_joymap = map; } // helpers @@ -595,7 +595,7 @@ public: // getters input_manager &manager() const { return m_manager; } running_machine &machine() const; - input_device *device(int index) const { return (index <= m_maxindex) ? m_device[index].get() : NULL; } + input_device *device(int index) const { return (index <= m_maxindex) ? m_device[index].get() : nullptr; } input_device_class devclass() const { return m_devclass; } int maxindex() const { return m_maxindex; } bool enabled() const { return m_enabled; } @@ -606,8 +606,8 @@ public: void set_multi(bool multi = true) { m_multi = multi; } // device management - input_device *add_device(const char *name, void *internal = NULL); - input_device *add_device(int devindex, const char *name, void *internal = NULL); + input_device *add_device(const char *name, void *internal = nullptr); + input_device *add_device(int devindex, const char *name, void *internal = nullptr); // misc helpers input_item_class standard_item_class(input_item_id itemid); @@ -637,7 +637,7 @@ public: // getters running_machine &machine() const { return m_machine; } - input_class &device_class(input_device_class devclass) { assert(devclass < ARRAY_LENGTH(m_class)); assert(m_class[devclass] != NULL); return *m_class[devclass]; } + input_class &device_class(input_device_class devclass) { assert(devclass < ARRAY_LENGTH(m_class)); assert(m_class[devclass] != nullptr); return *m_class[devclass]; } // input code readers INT32 code_value(input_code code); @@ -663,7 +663,7 @@ public: INT32 seq_axis_value(const input_seq &seq, input_item_class &itemclass); // input sequence polling - void seq_poll_start(input_item_class itemclass, const input_seq *startseq = NULL); + void seq_poll_start(input_item_class itemclass, const input_seq *startseq = nullptr); bool seq_poll(); const input_seq &seq_poll_final() const { return m_poll_seq; } diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 19694f1fd9d..9bb43f0c4ec 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -191,296 +191,296 @@ static const char *const seqtypestrings[] = { "standard", "increment", "decremen // master character info table static const char_info charinfo[] = { - { 0x0008, "Backspace", NULL }, // Backspace + { 0x0008, "Backspace", nullptr }, // Backspace { 0x0009, "Tab", " " }, // Tab - { 0x000c, "Clear", NULL }, // Clear - { 0x000d, "Enter", NULL }, // Enter - { 0x001a, "Esc", NULL }, // Esc + { 0x000c, "Clear", nullptr }, // Clear + { 0x000d, "Enter", nullptr }, // Enter + { 0x001a, "Esc", nullptr }, // Esc { 0x0020, "Space", " " }, // Space - { 0x0061, NULL, "A" }, // a - { 0x0062, NULL, "B" }, // b - { 0x0063, NULL, "C" }, // c - { 0x0064, NULL, "D" }, // d - { 0x0065, NULL, "E" }, // e - { 0x0066, NULL, "F" }, // f - { 0x0067, NULL, "G" }, // g - { 0x0068, NULL, "H" }, // h - { 0x0069, NULL, "I" }, // i - { 0x006a, NULL, "J" }, // j - { 0x006b, NULL, "K" }, // k - { 0x006c, NULL, "L" }, // l - { 0x006d, NULL, "M" }, // m - { 0x006e, NULL, "N" }, // n - { 0x006f, NULL, "O" }, // o - { 0x0070, NULL, "P" }, // p - { 0x0071, NULL, "Q" }, // q - { 0x0072, NULL, "R" }, // r - { 0x0073, NULL, "S" }, // s - { 0x0074, NULL, "T" }, // t - { 0x0075, NULL, "U" }, // u - { 0x0076, NULL, "V" }, // v - { 0x0077, NULL, "W" }, // w - { 0x0078, NULL, "X" }, // x - { 0x0079, NULL, "Y" }, // y - { 0x007a, NULL, "Z" }, // z - { 0x00a0, NULL, " " }, // non breaking space - { 0x00a1, NULL, "!" }, // inverted exclaimation mark - { 0x00a6, NULL, "|" }, // broken bar - { 0x00a9, NULL, "(c)" }, // copyright sign - { 0x00ab, NULL, "<<" }, // left pointing double angle - { 0x00ae, NULL, "(r)" }, // registered sign - { 0x00bb, NULL, ">>" }, // right pointing double angle - { 0x00bc, NULL, "1/4" }, // vulgar fraction one quarter - { 0x00bd, NULL, "1/2" }, // vulgar fraction one half - { 0x00be, NULL, "3/4" }, // vulgar fraction three quarters - { 0x00bf, NULL, "?" }, // inverted question mark - { 0x00c0, NULL, "A" }, // 'A' grave - { 0x00c1, NULL, "A" }, // 'A' acute - { 0x00c2, NULL, "A" }, // 'A' circumflex - { 0x00c3, NULL, "A" }, // 'A' tilde - { 0x00c4, NULL, "A" }, // 'A' diaeresis - { 0x00c5, NULL, "A" }, // 'A' ring above - { 0x00c6, NULL, "AE" }, // 'AE' ligature - { 0x00c7, NULL, "C" }, // 'C' cedilla - { 0x00c8, NULL, "E" }, // 'E' grave - { 0x00c9, NULL, "E" }, // 'E' acute - { 0x00ca, NULL, "E" }, // 'E' circumflex - { 0x00cb, NULL, "E" }, // 'E' diaeresis - { 0x00cc, NULL, "I" }, // 'I' grave - { 0x00cd, NULL, "I" }, // 'I' acute - { 0x00ce, NULL, "I" }, // 'I' circumflex - { 0x00cf, NULL, "I" }, // 'I' diaeresis - { 0x00d0, NULL, "D" }, // 'ETH' - { 0x00d1, NULL, "N" }, // 'N' tilde - { 0x00d2, NULL, "O" }, // 'O' grave - { 0x00d3, NULL, "O" }, // 'O' acute - { 0x00d4, NULL, "O" }, // 'O' circumflex - { 0x00d5, NULL, "O" }, // 'O' tilde - { 0x00d6, NULL, "O" }, // 'O' diaeresis - { 0x00d7, NULL, "X" }, // multiplication sign - { 0x00d8, NULL, "O" }, // 'O' stroke - { 0x00d9, NULL, "U" }, // 'U' grave - { 0x00da, NULL, "U" }, // 'U' acute - { 0x00db, NULL, "U" }, // 'U' circumflex - { 0x00dc, NULL, "U" }, // 'U' diaeresis - { 0x00dd, NULL, "Y" }, // 'Y' acute - { 0x00df, NULL, "SS" }, // sharp S - { 0x00e0, NULL, "a" }, // 'a' grave - { 0x00e1, NULL, "a" }, // 'a' acute - { 0x00e2, NULL, "a" }, // 'a' circumflex - { 0x00e3, NULL, "a" }, // 'a' tilde - { 0x00e4, NULL, "a" }, // 'a' diaeresis - { 0x00e5, NULL, "a" }, // 'a' ring above - { 0x00e6, NULL, "ae" }, // 'ae' ligature - { 0x00e7, NULL, "c" }, // 'c' cedilla - { 0x00e8, NULL, "e" }, // 'e' grave - { 0x00e9, NULL, "e" }, // 'e' acute - { 0x00ea, NULL, "e" }, // 'e' circumflex - { 0x00eb, NULL, "e" }, // 'e' diaeresis - { 0x00ec, NULL, "i" }, // 'i' grave - { 0x00ed, NULL, "i" }, // 'i' acute - { 0x00ee, NULL, "i" }, // 'i' circumflex - { 0x00ef, NULL, "i" }, // 'i' diaeresis - { 0x00f0, NULL, "d" }, // 'eth' - { 0x00f1, NULL, "n" }, // 'n' tilde - { 0x00f2, NULL, "o" }, // 'o' grave - { 0x00f3, NULL, "o" }, // 'o' acute - { 0x00f4, NULL, "o" }, // 'o' circumflex - { 0x00f5, NULL, "o" }, // 'o' tilde - { 0x00f6, NULL, "o" }, // 'o' diaeresis - { 0x00f8, NULL, "o" }, // 'o' stroke - { 0x00f9, NULL, "u" }, // 'u' grave - { 0x00fa, NULL, "u" }, // 'u' acute - { 0x00fb, NULL, "u" }, // 'u' circumflex - { 0x00fc, NULL, "u" }, // 'u' diaeresis - { 0x00fd, NULL, "y" }, // 'y' acute - { 0x00ff, NULL, "y" }, // 'y' diaeresis - { 0x2010, NULL, "-" }, // hyphen - { 0x2011, NULL, "-" }, // non-breaking hyphen - { 0x2012, NULL, "-" }, // figure dash - { 0x2013, NULL, "-" }, // en dash - { 0x2014, NULL, "-" }, // em dash - { 0x2015, NULL, "-" }, // horizontal dash - { 0x2018, NULL, "\'" }, // left single quotation mark - { 0x2019, NULL, "\'" }, // right single quotation mark - { 0x201a, NULL, "\'" }, // single low quotation mark - { 0x201b, NULL, "\'" }, // single high reversed quotation mark - { 0x201c, NULL, "\"" }, // left double quotation mark - { 0x201d, NULL, "\"" }, // right double quotation mark - { 0x201e, NULL, "\"" }, // double low quotation mark - { 0x201f, NULL, "\"" }, // double high reversed quotation mark - { 0x2024, NULL, "." }, // one dot leader - { 0x2025, NULL, ".." }, // two dot leader - { 0x2026, NULL, "..." }, // horizontal ellipsis - { 0x2047, NULL, "??" }, // double question mark - { 0x2048, NULL, "?!" }, // question exclamation mark - { 0x2049, NULL, "!?" }, // exclamation question mark - { 0xff01, NULL, "!" }, // fullwidth exclamation point - { 0xff02, NULL, "\"" }, // fullwidth quotation mark - { 0xff03, NULL, "#" }, // fullwidth number sign - { 0xff04, NULL, "$" }, // fullwidth dollar sign - { 0xff05, NULL, "%" }, // fullwidth percent sign - { 0xff06, NULL, "&" }, // fullwidth ampersand - { 0xff07, NULL, "\'" }, // fullwidth apostrophe - { 0xff08, NULL, "(" }, // fullwidth left parenthesis - { 0xff09, NULL, ")" }, // fullwidth right parenthesis - { 0xff0a, NULL, "*" }, // fullwidth asterisk - { 0xff0b, NULL, "+" }, // fullwidth plus - { 0xff0c, NULL, "," }, // fullwidth comma - { 0xff0d, NULL, "-" }, // fullwidth minus - { 0xff0e, NULL, "." }, // fullwidth period - { 0xff0f, NULL, "/" }, // fullwidth slash - { 0xff10, NULL, "0" }, // fullwidth zero - { 0xff11, NULL, "1" }, // fullwidth one - { 0xff12, NULL, "2" }, // fullwidth two - { 0xff13, NULL, "3" }, // fullwidth three - { 0xff14, NULL, "4" }, // fullwidth four - { 0xff15, NULL, "5" }, // fullwidth five - { 0xff16, NULL, "6" }, // fullwidth six - { 0xff17, NULL, "7" }, // fullwidth seven - { 0xff18, NULL, "8" }, // fullwidth eight - { 0xff19, NULL, "9" }, // fullwidth nine - { 0xff1a, NULL, ":" }, // fullwidth colon - { 0xff1b, NULL, ";" }, // fullwidth semicolon - { 0xff1c, NULL, "<" }, // fullwidth less than sign - { 0xff1d, NULL, "=" }, // fullwidth equals sign - { 0xff1e, NULL, ">" }, // fullwidth greater than sign - { 0xff1f, NULL, "?" }, // fullwidth question mark - { 0xff20, NULL, "@" }, // fullwidth at sign - { 0xff21, NULL, "A" }, // fullwidth 'A' - { 0xff22, NULL, "B" }, // fullwidth 'B' - { 0xff23, NULL, "C" }, // fullwidth 'C' - { 0xff24, NULL, "D" }, // fullwidth 'D' - { 0xff25, NULL, "E" }, // fullwidth 'E' - { 0xff26, NULL, "F" }, // fullwidth 'F' - { 0xff27, NULL, "G" }, // fullwidth 'G' - { 0xff28, NULL, "H" }, // fullwidth 'H' - { 0xff29, NULL, "I" }, // fullwidth 'I' - { 0xff2a, NULL, "J" }, // fullwidth 'J' - { 0xff2b, NULL, "K" }, // fullwidth 'K' - { 0xff2c, NULL, "L" }, // fullwidth 'L' - { 0xff2d, NULL, "M" }, // fullwidth 'M' - { 0xff2e, NULL, "N" }, // fullwidth 'N' - { 0xff2f, NULL, "O" }, // fullwidth 'O' - { 0xff30, NULL, "P" }, // fullwidth 'P' - { 0xff31, NULL, "Q" }, // fullwidth 'Q' - { 0xff32, NULL, "R" }, // fullwidth 'R' - { 0xff33, NULL, "S" }, // fullwidth 'S' - { 0xff34, NULL, "T" }, // fullwidth 'T' - { 0xff35, NULL, "U" }, // fullwidth 'U' - { 0xff36, NULL, "V" }, // fullwidth 'V' - { 0xff37, NULL, "W" }, // fullwidth 'W' - { 0xff38, NULL, "X" }, // fullwidth 'X' - { 0xff39, NULL, "Y" }, // fullwidth 'Y' - { 0xff3a, NULL, "Z" }, // fullwidth 'Z' - { 0xff3b, NULL, "[" }, // fullwidth left bracket - { 0xff3c, NULL, "\\" }, // fullwidth backslash - { 0xff3d, NULL, "]" }, // fullwidth right bracket - { 0xff3e, NULL, "^" }, // fullwidth caret - { 0xff3f, NULL, "_" }, // fullwidth underscore - { 0xff40, NULL, "`" }, // fullwidth backquote - { 0xff41, NULL, "a" }, // fullwidth 'a' - { 0xff42, NULL, "b" }, // fullwidth 'b' - { 0xff43, NULL, "c" }, // fullwidth 'c' - { 0xff44, NULL, "d" }, // fullwidth 'd' - { 0xff45, NULL, "e" }, // fullwidth 'e' - { 0xff46, NULL, "f" }, // fullwidth 'f' - { 0xff47, NULL, "g" }, // fullwidth 'g' - { 0xff48, NULL, "h" }, // fullwidth 'h' - { 0xff49, NULL, "i" }, // fullwidth 'i' - { 0xff4a, NULL, "j" }, // fullwidth 'j' - { 0xff4b, NULL, "k" }, // fullwidth 'k' - { 0xff4c, NULL, "l" }, // fullwidth 'l' - { 0xff4d, NULL, "m" }, // fullwidth 'm' - { 0xff4e, NULL, "n" }, // fullwidth 'n' - { 0xff4f, NULL, "o" }, // fullwidth 'o' - { 0xff50, NULL, "p" }, // fullwidth 'p' - { 0xff51, NULL, "q" }, // fullwidth 'q' - { 0xff52, NULL, "r" }, // fullwidth 'r' - { 0xff53, NULL, "s" }, // fullwidth 's' - { 0xff54, NULL, "t" }, // fullwidth 't' - { 0xff55, NULL, "u" }, // fullwidth 'u' - { 0xff56, NULL, "v" }, // fullwidth 'v' - { 0xff57, NULL, "w" }, // fullwidth 'w' - { 0xff58, NULL, "x" }, // fullwidth 'x' - { 0xff59, NULL, "y" }, // fullwidth 'y' - { 0xff5a, NULL, "z" }, // fullwidth 'z' - { 0xff5b, NULL, "{" }, // fullwidth left brace - { 0xff5c, NULL, "|" }, // fullwidth vertical bar - { 0xff5d, NULL, "}" }, // fullwidth right brace - { 0xff5e, NULL, "~" }, // fullwidth tilde - { 0xff5f, NULL, "((" }, // fullwidth double left parenthesis - { 0xff60, NULL, "))" }, // fullwidth double right parenthesis - { 0xffe0, NULL, "\xC2\xA2" }, // fullwidth cent sign - { 0xffe1, NULL, "\xC2\xA3" }, // fullwidth pound sign - { 0xffe4, NULL, "\xC2\xA4" }, // fullwidth broken bar - { 0xffe5, NULL, "\xC2\xA5" }, // fullwidth yen sign - { 0xffe6, NULL, "\xE2\x82\xA9" }, // fullwidth won sign - { 0xffe9, NULL, "\xE2\x86\x90" }, // fullwidth left arrow - { 0xffea, NULL, "\xE2\x86\x91" }, // fullwidth up arrow - { 0xffeb, NULL, "\xE2\x86\x92" }, // fullwidth right arrow - { 0xffec, NULL, "\xE2\x86\x93" }, // fullwidth down arrow - { 0xffed, NULL, "\xE2\x96\xAA" }, // fullwidth solid box - { 0xffee, NULL, "\xE2\x97\xA6" }, // fullwidth open circle - { UCHAR_SHIFT_1, "Shift", NULL }, // Shift key - { UCHAR_SHIFT_2, "Ctrl", NULL }, // Ctrl key - { UCHAR_MAMEKEY(F1), "F1", NULL }, // F1 function key - { UCHAR_MAMEKEY(F2), "F2", NULL }, // F2 function key - { UCHAR_MAMEKEY(F3), "F3", NULL }, // F3 function key - { UCHAR_MAMEKEY(F4), "F4", NULL }, // F4 function key - { UCHAR_MAMEKEY(F5), "F5", NULL }, // F5 function key - { UCHAR_MAMEKEY(F6), "F6", NULL }, // F6 function key - { UCHAR_MAMEKEY(F7), "F7", NULL }, // F7 function key - { UCHAR_MAMEKEY(F8), "F8", NULL }, // F8 function key - { UCHAR_MAMEKEY(F9), "F9", NULL }, // F9 function key - { UCHAR_MAMEKEY(F10), "F10", NULL }, // F10 function key - { UCHAR_MAMEKEY(F11), "F11", NULL }, // F11 function key - { UCHAR_MAMEKEY(F12), "F12", NULL }, // F12 function key - { UCHAR_MAMEKEY(F13), "F13", NULL }, // F13 function key - { UCHAR_MAMEKEY(F14), "F14", NULL }, // F14 function key - { UCHAR_MAMEKEY(F15), "F15", NULL }, // F15 function key + { 0x0061, nullptr, "A" }, // a + { 0x0062, nullptr, "B" }, // b + { 0x0063, nullptr, "C" }, // c + { 0x0064, nullptr, "D" }, // d + { 0x0065, nullptr, "E" }, // e + { 0x0066, nullptr, "F" }, // f + { 0x0067, nullptr, "G" }, // g + { 0x0068, nullptr, "H" }, // h + { 0x0069, nullptr, "I" }, // i + { 0x006a, nullptr, "J" }, // j + { 0x006b, nullptr, "K" }, // k + { 0x006c, nullptr, "L" }, // l + { 0x006d, nullptr, "M" }, // m + { 0x006e, nullptr, "N" }, // n + { 0x006f, nullptr, "O" }, // o + { 0x0070, nullptr, "P" }, // p + { 0x0071, nullptr, "Q" }, // q + { 0x0072, nullptr, "R" }, // r + { 0x0073, nullptr, "S" }, // s + { 0x0074, nullptr, "T" }, // t + { 0x0075, nullptr, "U" }, // u + { 0x0076, nullptr, "V" }, // v + { 0x0077, nullptr, "W" }, // w + { 0x0078, nullptr, "X" }, // x + { 0x0079, nullptr, "Y" }, // y + { 0x007a, nullptr, "Z" }, // z + { 0x00a0, nullptr, " " }, // non breaking space + { 0x00a1, nullptr, "!" }, // inverted exclaimation mark + { 0x00a6, nullptr, "|" }, // broken bar + { 0x00a9, nullptr, "(c)" }, // copyright sign + { 0x00ab, nullptr, "<<" }, // left pointing double angle + { 0x00ae, nullptr, "(r)" }, // registered sign + { 0x00bb, nullptr, ">>" }, // right pointing double angle + { 0x00bc, nullptr, "1/4" }, // vulgar fraction one quarter + { 0x00bd, nullptr, "1/2" }, // vulgar fraction one half + { 0x00be, nullptr, "3/4" }, // vulgar fraction three quarters + { 0x00bf, nullptr, "?" }, // inverted question mark + { 0x00c0, nullptr, "A" }, // 'A' grave + { 0x00c1, nullptr, "A" }, // 'A' acute + { 0x00c2, nullptr, "A" }, // 'A' circumflex + { 0x00c3, nullptr, "A" }, // 'A' tilde + { 0x00c4, nullptr, "A" }, // 'A' diaeresis + { 0x00c5, nullptr, "A" }, // 'A' ring above + { 0x00c6, nullptr, "AE" }, // 'AE' ligature + { 0x00c7, nullptr, "C" }, // 'C' cedilla + { 0x00c8, nullptr, "E" }, // 'E' grave + { 0x00c9, nullptr, "E" }, // 'E' acute + { 0x00ca, nullptr, "E" }, // 'E' circumflex + { 0x00cb, nullptr, "E" }, // 'E' diaeresis + { 0x00cc, nullptr, "I" }, // 'I' grave + { 0x00cd, nullptr, "I" }, // 'I' acute + { 0x00ce, nullptr, "I" }, // 'I' circumflex + { 0x00cf, nullptr, "I" }, // 'I' diaeresis + { 0x00d0, nullptr, "D" }, // 'ETH' + { 0x00d1, nullptr, "N" }, // 'N' tilde + { 0x00d2, nullptr, "O" }, // 'O' grave + { 0x00d3, nullptr, "O" }, // 'O' acute + { 0x00d4, nullptr, "O" }, // 'O' circumflex + { 0x00d5, nullptr, "O" }, // 'O' tilde + { 0x00d6, nullptr, "O" }, // 'O' diaeresis + { 0x00d7, nullptr, "X" }, // multiplication sign + { 0x00d8, nullptr, "O" }, // 'O' stroke + { 0x00d9, nullptr, "U" }, // 'U' grave + { 0x00da, nullptr, "U" }, // 'U' acute + { 0x00db, nullptr, "U" }, // 'U' circumflex + { 0x00dc, nullptr, "U" }, // 'U' diaeresis + { 0x00dd, nullptr, "Y" }, // 'Y' acute + { 0x00df, nullptr, "SS" }, // sharp S + { 0x00e0, nullptr, "a" }, // 'a' grave + { 0x00e1, nullptr, "a" }, // 'a' acute + { 0x00e2, nullptr, "a" }, // 'a' circumflex + { 0x00e3, nullptr, "a" }, // 'a' tilde + { 0x00e4, nullptr, "a" }, // 'a' diaeresis + { 0x00e5, nullptr, "a" }, // 'a' ring above + { 0x00e6, nullptr, "ae" }, // 'ae' ligature + { 0x00e7, nullptr, "c" }, // 'c' cedilla + { 0x00e8, nullptr, "e" }, // 'e' grave + { 0x00e9, nullptr, "e" }, // 'e' acute + { 0x00ea, nullptr, "e" }, // 'e' circumflex + { 0x00eb, nullptr, "e" }, // 'e' diaeresis + { 0x00ec, nullptr, "i" }, // 'i' grave + { 0x00ed, nullptr, "i" }, // 'i' acute + { 0x00ee, nullptr, "i" }, // 'i' circumflex + { 0x00ef, nullptr, "i" }, // 'i' diaeresis + { 0x00f0, nullptr, "d" }, // 'eth' + { 0x00f1, nullptr, "n" }, // 'n' tilde + { 0x00f2, nullptr, "o" }, // 'o' grave + { 0x00f3, nullptr, "o" }, // 'o' acute + { 0x00f4, nullptr, "o" }, // 'o' circumflex + { 0x00f5, nullptr, "o" }, // 'o' tilde + { 0x00f6, nullptr, "o" }, // 'o' diaeresis + { 0x00f8, nullptr, "o" }, // 'o' stroke + { 0x00f9, nullptr, "u" }, // 'u' grave + { 0x00fa, nullptr, "u" }, // 'u' acute + { 0x00fb, nullptr, "u" }, // 'u' circumflex + { 0x00fc, nullptr, "u" }, // 'u' diaeresis + { 0x00fd, nullptr, "y" }, // 'y' acute + { 0x00ff, nullptr, "y" }, // 'y' diaeresis + { 0x2010, nullptr, "-" }, // hyphen + { 0x2011, nullptr, "-" }, // non-breaking hyphen + { 0x2012, nullptr, "-" }, // figure dash + { 0x2013, nullptr, "-" }, // en dash + { 0x2014, nullptr, "-" }, // em dash + { 0x2015, nullptr, "-" }, // horizontal dash + { 0x2018, nullptr, "\'" }, // left single quotation mark + { 0x2019, nullptr, "\'" }, // right single quotation mark + { 0x201a, nullptr, "\'" }, // single low quotation mark + { 0x201b, nullptr, "\'" }, // single high reversed quotation mark + { 0x201c, nullptr, "\"" }, // left double quotation mark + { 0x201d, nullptr, "\"" }, // right double quotation mark + { 0x201e, nullptr, "\"" }, // double low quotation mark + { 0x201f, nullptr, "\"" }, // double high reversed quotation mark + { 0x2024, nullptr, "." }, // one dot leader + { 0x2025, nullptr, ".." }, // two dot leader + { 0x2026, nullptr, "..." }, // horizontal ellipsis + { 0x2047, nullptr, "??" }, // double question mark + { 0x2048, nullptr, "?!" }, // question exclamation mark + { 0x2049, nullptr, "!?" }, // exclamation question mark + { 0xff01, nullptr, "!" }, // fullwidth exclamation point + { 0xff02, nullptr, "\"" }, // fullwidth quotation mark + { 0xff03, nullptr, "#" }, // fullwidth number sign + { 0xff04, nullptr, "$" }, // fullwidth dollar sign + { 0xff05, nullptr, "%" }, // fullwidth percent sign + { 0xff06, nullptr, "&" }, // fullwidth ampersand + { 0xff07, nullptr, "\'" }, // fullwidth apostrophe + { 0xff08, nullptr, "(" }, // fullwidth left parenthesis + { 0xff09, nullptr, ")" }, // fullwidth right parenthesis + { 0xff0a, nullptr, "*" }, // fullwidth asterisk + { 0xff0b, nullptr, "+" }, // fullwidth plus + { 0xff0c, nullptr, "," }, // fullwidth comma + { 0xff0d, nullptr, "-" }, // fullwidth minus + { 0xff0e, nullptr, "." }, // fullwidth period + { 0xff0f, nullptr, "/" }, // fullwidth slash + { 0xff10, nullptr, "0" }, // fullwidth zero + { 0xff11, nullptr, "1" }, // fullwidth one + { 0xff12, nullptr, "2" }, // fullwidth two + { 0xff13, nullptr, "3" }, // fullwidth three + { 0xff14, nullptr, "4" }, // fullwidth four + { 0xff15, nullptr, "5" }, // fullwidth five + { 0xff16, nullptr, "6" }, // fullwidth six + { 0xff17, nullptr, "7" }, // fullwidth seven + { 0xff18, nullptr, "8" }, // fullwidth eight + { 0xff19, nullptr, "9" }, // fullwidth nine + { 0xff1a, nullptr, ":" }, // fullwidth colon + { 0xff1b, nullptr, ";" }, // fullwidth semicolon + { 0xff1c, nullptr, "<" }, // fullwidth less than sign + { 0xff1d, nullptr, "=" }, // fullwidth equals sign + { 0xff1e, nullptr, ">" }, // fullwidth greater than sign + { 0xff1f, nullptr, "?" }, // fullwidth question mark + { 0xff20, nullptr, "@" }, // fullwidth at sign + { 0xff21, nullptr, "A" }, // fullwidth 'A' + { 0xff22, nullptr, "B" }, // fullwidth 'B' + { 0xff23, nullptr, "C" }, // fullwidth 'C' + { 0xff24, nullptr, "D" }, // fullwidth 'D' + { 0xff25, nullptr, "E" }, // fullwidth 'E' + { 0xff26, nullptr, "F" }, // fullwidth 'F' + { 0xff27, nullptr, "G" }, // fullwidth 'G' + { 0xff28, nullptr, "H" }, // fullwidth 'H' + { 0xff29, nullptr, "I" }, // fullwidth 'I' + { 0xff2a, nullptr, "J" }, // fullwidth 'J' + { 0xff2b, nullptr, "K" }, // fullwidth 'K' + { 0xff2c, nullptr, "L" }, // fullwidth 'L' + { 0xff2d, nullptr, "M" }, // fullwidth 'M' + { 0xff2e, nullptr, "N" }, // fullwidth 'N' + { 0xff2f, nullptr, "O" }, // fullwidth 'O' + { 0xff30, nullptr, "P" }, // fullwidth 'P' + { 0xff31, nullptr, "Q" }, // fullwidth 'Q' + { 0xff32, nullptr, "R" }, // fullwidth 'R' + { 0xff33, nullptr, "S" }, // fullwidth 'S' + { 0xff34, nullptr, "T" }, // fullwidth 'T' + { 0xff35, nullptr, "U" }, // fullwidth 'U' + { 0xff36, nullptr, "V" }, // fullwidth 'V' + { 0xff37, nullptr, "W" }, // fullwidth 'W' + { 0xff38, nullptr, "X" }, // fullwidth 'X' + { 0xff39, nullptr, "Y" }, // fullwidth 'Y' + { 0xff3a, nullptr, "Z" }, // fullwidth 'Z' + { 0xff3b, nullptr, "[" }, // fullwidth left bracket + { 0xff3c, nullptr, "\\" }, // fullwidth backslash + { 0xff3d, nullptr, "]" }, // fullwidth right bracket + { 0xff3e, nullptr, "^" }, // fullwidth caret + { 0xff3f, nullptr, "_" }, // fullwidth underscore + { 0xff40, nullptr, "`" }, // fullwidth backquote + { 0xff41, nullptr, "a" }, // fullwidth 'a' + { 0xff42, nullptr, "b" }, // fullwidth 'b' + { 0xff43, nullptr, "c" }, // fullwidth 'c' + { 0xff44, nullptr, "d" }, // fullwidth 'd' + { 0xff45, nullptr, "e" }, // fullwidth 'e' + { 0xff46, nullptr, "f" }, // fullwidth 'f' + { 0xff47, nullptr, "g" }, // fullwidth 'g' + { 0xff48, nullptr, "h" }, // fullwidth 'h' + { 0xff49, nullptr, "i" }, // fullwidth 'i' + { 0xff4a, nullptr, "j" }, // fullwidth 'j' + { 0xff4b, nullptr, "k" }, // fullwidth 'k' + { 0xff4c, nullptr, "l" }, // fullwidth 'l' + { 0xff4d, nullptr, "m" }, // fullwidth 'm' + { 0xff4e, nullptr, "n" }, // fullwidth 'n' + { 0xff4f, nullptr, "o" }, // fullwidth 'o' + { 0xff50, nullptr, "p" }, // fullwidth 'p' + { 0xff51, nullptr, "q" }, // fullwidth 'q' + { 0xff52, nullptr, "r" }, // fullwidth 'r' + { 0xff53, nullptr, "s" }, // fullwidth 's' + { 0xff54, nullptr, "t" }, // fullwidth 't' + { 0xff55, nullptr, "u" }, // fullwidth 'u' + { 0xff56, nullptr, "v" }, // fullwidth 'v' + { 0xff57, nullptr, "w" }, // fullwidth 'w' + { 0xff58, nullptr, "x" }, // fullwidth 'x' + { 0xff59, nullptr, "y" }, // fullwidth 'y' + { 0xff5a, nullptr, "z" }, // fullwidth 'z' + { 0xff5b, nullptr, "{" }, // fullwidth left brace + { 0xff5c, nullptr, "|" }, // fullwidth vertical bar + { 0xff5d, nullptr, "}" }, // fullwidth right brace + { 0xff5e, nullptr, "~" }, // fullwidth tilde + { 0xff5f, nullptr, "((" }, // fullwidth double left parenthesis + { 0xff60, nullptr, "))" }, // fullwidth double right parenthesis + { 0xffe0, nullptr, "\xC2\xA2" }, // fullwidth cent sign + { 0xffe1, nullptr, "\xC2\xA3" }, // fullwidth pound sign + { 0xffe4, nullptr, "\xC2\xA4" }, // fullwidth broken bar + { 0xffe5, nullptr, "\xC2\xA5" }, // fullwidth yen sign + { 0xffe6, nullptr, "\xE2\x82\xA9" }, // fullwidth won sign + { 0xffe9, nullptr, "\xE2\x86\x90" }, // fullwidth left arrow + { 0xffea, nullptr, "\xE2\x86\x91" }, // fullwidth up arrow + { 0xffeb, nullptr, "\xE2\x86\x92" }, // fullwidth right arrow + { 0xffec, nullptr, "\xE2\x86\x93" }, // fullwidth down arrow + { 0xffed, nullptr, "\xE2\x96\xAA" }, // fullwidth solid box + { 0xffee, nullptr, "\xE2\x97\xA6" }, // fullwidth open circle + { UCHAR_SHIFT_1, "Shift", nullptr }, // Shift key + { UCHAR_SHIFT_2, "Ctrl", nullptr }, // Ctrl key + { UCHAR_MAMEKEY(F1), "F1", nullptr }, // F1 function key + { UCHAR_MAMEKEY(F2), "F2", nullptr }, // F2 function key + { UCHAR_MAMEKEY(F3), "F3", nullptr }, // F3 function key + { UCHAR_MAMEKEY(F4), "F4", nullptr }, // F4 function key + { UCHAR_MAMEKEY(F5), "F5", nullptr }, // F5 function key + { UCHAR_MAMEKEY(F6), "F6", nullptr }, // F6 function key + { UCHAR_MAMEKEY(F7), "F7", nullptr }, // F7 function key + { UCHAR_MAMEKEY(F8), "F8", nullptr }, // F8 function key + { UCHAR_MAMEKEY(F9), "F9", nullptr }, // F9 function key + { UCHAR_MAMEKEY(F10), "F10", nullptr }, // F10 function key + { UCHAR_MAMEKEY(F11), "F11", nullptr }, // F11 function key + { UCHAR_MAMEKEY(F12), "F12", nullptr }, // F12 function key + { UCHAR_MAMEKEY(F13), "F13", nullptr }, // F13 function key + { UCHAR_MAMEKEY(F14), "F14", nullptr }, // F14 function key + { UCHAR_MAMEKEY(F15), "F15", nullptr }, // F15 function key { UCHAR_MAMEKEY(ESC), "Esc", "\033" }, // Esc key - { UCHAR_MAMEKEY(INSERT), "Insert", NULL }, // Insert key + { UCHAR_MAMEKEY(INSERT), "Insert", nullptr }, // Insert key { UCHAR_MAMEKEY(DEL), "Delete", "\010" }, // Delete key { UCHAR_MAMEKEY(HOME), "Home", "\014" }, // Home key - { UCHAR_MAMEKEY(END), "End", NULL }, // End key - { UCHAR_MAMEKEY(PGUP), "Page Up", NULL }, // Page Up key - { UCHAR_MAMEKEY(PGDN), "Page Down", NULL }, // Page Down key - { UCHAR_MAMEKEY(LEFT), "Cursor Left", NULL }, // Cursor Left - { UCHAR_MAMEKEY(RIGHT), "Cursor Right", NULL }, // Cursor Right - { UCHAR_MAMEKEY(UP), "Cursor Up", NULL }, // Cursor Up - { UCHAR_MAMEKEY(DOWN), "Cursor Down", NULL }, // Cursor Down - { UCHAR_MAMEKEY(0_PAD), "Keypad 0", NULL }, // 0 on the numeric keypad - { UCHAR_MAMEKEY(1_PAD), "Keypad 1", NULL }, // 1 on the numeric keypad - { UCHAR_MAMEKEY(2_PAD), "Keypad 2", NULL }, // 2 on the numeric keypad - { UCHAR_MAMEKEY(3_PAD), "Keypad 3", NULL }, // 3 on the numeric keypad - { UCHAR_MAMEKEY(4_PAD), "Keypad 4", NULL }, // 4 on the numeric keypad - { UCHAR_MAMEKEY(5_PAD), "Keypad 5", NULL }, // 5 on the numeric keypad - { UCHAR_MAMEKEY(6_PAD), "Keypad 6", NULL }, // 6 on the numeric keypad - { UCHAR_MAMEKEY(7_PAD), "Keypad 7", NULL }, // 7 on the numeric keypad - { UCHAR_MAMEKEY(8_PAD), "Keypad 8", NULL }, // 8 on the numeric keypad - { UCHAR_MAMEKEY(9_PAD), "Keypad 9", NULL }, // 9 on the numeric keypad - { UCHAR_MAMEKEY(SLASH_PAD), "Keypad /", NULL }, // / on the numeric keypad - { UCHAR_MAMEKEY(ASTERISK), "Keypad *", NULL }, // * on the numeric keypad - { UCHAR_MAMEKEY(MINUS_PAD), "Keypad -", NULL }, // - on the numeric Keypad - { UCHAR_MAMEKEY(PLUS_PAD), "Keypad +", NULL }, // + on the numeric Keypad - { UCHAR_MAMEKEY(DEL_PAD), "Keypad .", NULL }, // . on the numeric keypad - { UCHAR_MAMEKEY(ENTER_PAD), "Keypad Enter", NULL }, // Enter on the numeric keypad - { UCHAR_MAMEKEY(PRTSCR), "Print Screen", NULL }, // Print Screen key - { UCHAR_MAMEKEY(PAUSE), "Pause", NULL }, // Pause key - { UCHAR_MAMEKEY(LSHIFT), "Left Shift", NULL }, // Left Shift key - { UCHAR_MAMEKEY(RSHIFT), "Right Shift", NULL }, // Right Shift key - { UCHAR_MAMEKEY(LCONTROL), "Left Ctrl", NULL }, // Left Control key - { UCHAR_MAMEKEY(RCONTROL), "Right Ctrl", NULL }, // Right Control key - { UCHAR_MAMEKEY(LALT), "Left Alt", NULL }, // Left Alt key - { UCHAR_MAMEKEY(RALT), "Right Alt", NULL }, // Right Alt key - { UCHAR_MAMEKEY(SCRLOCK), "Scroll Lock", NULL }, // Scroll Lock key - { UCHAR_MAMEKEY(NUMLOCK), "Num Lock", NULL }, // Num Lock key - { UCHAR_MAMEKEY(CAPSLOCK), "Caps Lock", NULL }, // Caps Lock key - { UCHAR_MAMEKEY(LWIN), "Left Win", NULL }, // Left Win key - { UCHAR_MAMEKEY(RWIN), "Right Win", NULL }, // Right Win key - { UCHAR_MAMEKEY(MENU), "Menu", NULL }, // Menu key - { UCHAR_MAMEKEY(CANCEL), "Break", NULL } // Break/Pause key + { UCHAR_MAMEKEY(END), "End", nullptr }, // End key + { UCHAR_MAMEKEY(PGUP), "Page Up", nullptr }, // Page Up key + { UCHAR_MAMEKEY(PGDN), "Page Down", nullptr }, // Page Down key + { UCHAR_MAMEKEY(LEFT), "Cursor Left", nullptr }, // Cursor Left + { UCHAR_MAMEKEY(RIGHT), "Cursor Right", nullptr }, // Cursor Right + { UCHAR_MAMEKEY(UP), "Cursor Up", nullptr }, // Cursor Up + { UCHAR_MAMEKEY(DOWN), "Cursor Down", nullptr }, // Cursor Down + { UCHAR_MAMEKEY(0_PAD), "Keypad 0", nullptr }, // 0 on the numeric keypad + { UCHAR_MAMEKEY(1_PAD), "Keypad 1", nullptr }, // 1 on the numeric keypad + { UCHAR_MAMEKEY(2_PAD), "Keypad 2", nullptr }, // 2 on the numeric keypad + { UCHAR_MAMEKEY(3_PAD), "Keypad 3", nullptr }, // 3 on the numeric keypad + { UCHAR_MAMEKEY(4_PAD), "Keypad 4", nullptr }, // 4 on the numeric keypad + { UCHAR_MAMEKEY(5_PAD), "Keypad 5", nullptr }, // 5 on the numeric keypad + { UCHAR_MAMEKEY(6_PAD), "Keypad 6", nullptr }, // 6 on the numeric keypad + { UCHAR_MAMEKEY(7_PAD), "Keypad 7", nullptr }, // 7 on the numeric keypad + { UCHAR_MAMEKEY(8_PAD), "Keypad 8", nullptr }, // 8 on the numeric keypad + { UCHAR_MAMEKEY(9_PAD), "Keypad 9", nullptr }, // 9 on the numeric keypad + { UCHAR_MAMEKEY(SLASH_PAD), "Keypad /", nullptr }, // / on the numeric keypad + { UCHAR_MAMEKEY(ASTERISK), "Keypad *", nullptr }, // * on the numeric keypad + { UCHAR_MAMEKEY(MINUS_PAD), "Keypad -", nullptr }, // - on the numeric Keypad + { UCHAR_MAMEKEY(PLUS_PAD), "Keypad +", nullptr }, // + on the numeric Keypad + { UCHAR_MAMEKEY(DEL_PAD), "Keypad .", nullptr }, // . on the numeric keypad + { UCHAR_MAMEKEY(ENTER_PAD), "Keypad Enter", nullptr }, // Enter on the numeric keypad + { UCHAR_MAMEKEY(PRTSCR), "Print Screen", nullptr }, // Print Screen key + { UCHAR_MAMEKEY(PAUSE), "Pause", nullptr }, // Pause key + { UCHAR_MAMEKEY(LSHIFT), "Left Shift", nullptr }, // Left Shift key + { UCHAR_MAMEKEY(RSHIFT), "Right Shift", nullptr }, // Right Shift key + { UCHAR_MAMEKEY(LCONTROL), "Left Ctrl", nullptr }, // Left Control key + { UCHAR_MAMEKEY(RCONTROL), "Right Ctrl", nullptr }, // Right Control key + { UCHAR_MAMEKEY(LALT), "Left Alt", nullptr }, // Left Alt key + { UCHAR_MAMEKEY(RALT), "Right Alt", nullptr }, // Right Alt key + { UCHAR_MAMEKEY(SCRLOCK), "Scroll Lock", nullptr }, // Scroll Lock key + { UCHAR_MAMEKEY(NUMLOCK), "Num Lock", nullptr }, // Num Lock key + { UCHAR_MAMEKEY(CAPSLOCK), "Caps Lock", nullptr }, // Caps Lock key + { UCHAR_MAMEKEY(LWIN), "Left Win", nullptr }, // Left Win key + { UCHAR_MAMEKEY(RWIN), "Right Win", nullptr }, // Right Win key + { UCHAR_MAMEKEY(MENU), "Menu", nullptr }, // Menu key + { UCHAR_MAMEKEY(CANCEL), "Break", nullptr } // Break/Pause key }; @@ -643,7 +643,7 @@ void ioport_list::append(device_t &device, std::string &errorbuf) { // no constructor, no list ioport_constructor constructor = device.input_ports(); - if (constructor == NULL) + if (constructor == nullptr) return; // reset error buffer @@ -653,7 +653,7 @@ void ioport_list::append(device_t &device, std::string &errorbuf) (*constructor)(device, *this, errorbuf); // collapse fields and sort the list - for (ioport_port *port = first(); port != NULL; port = port->next()) + for (ioport_port *port = first(); port != nullptr; port = port->next()) port->collapse_fields(errorbuf); } @@ -668,7 +668,7 @@ void ioport_list::append(device_t &device, std::string &errorbuf) //------------------------------------------------- input_type_entry::input_type_entry(ioport_type type, ioport_group group, int player, const char *token, const char *name, input_seq standard) - : m_next(NULL), + : m_next(nullptr), m_type(type), m_group(group), m_player(player), @@ -679,7 +679,7 @@ input_type_entry::input_type_entry(ioport_type type, ioport_group group, int pla } input_type_entry::input_type_entry(ioport_type type, ioport_group group, int player, const char *token, const char *name, input_seq standard, input_seq decrement, input_seq increment) - : m_next(NULL), + : m_next(nullptr), m_type(type), m_group(group), m_player(player), @@ -726,7 +726,7 @@ void input_type_entry::restore_default_seq() //------------------------------------------------- digital_joystick::digital_joystick(int player, int number) - : m_next(NULL), + : m_next(nullptr), m_player(player), m_number(number), m_current(0), @@ -762,9 +762,9 @@ void digital_joystick::frame_update() m_current = 0; // read all the associated ports - running_machine *machine = NULL; + running_machine *machine = nullptr; for (direction_t direction = JOYDIR_UP; direction < JOYDIR_COUNT; ++direction) - for (const simple_list_wrapper *i = m_field[direction].first(); i != NULL; i = i->next()) + for (const simple_list_wrapper *i = m_field[direction].first(); i != nullptr; i = i->next()) { machine = &i->object()->machine(); if (machine->input().seq_pressed(i->object()->seq(SEQ_TYPE_STANDARD))) @@ -837,7 +837,7 @@ natural_keyboard::natural_keyboard(running_machine &machine) m_bufend(0), m_status_keydown(false), m_last_cr(false), - m_timer(NULL), + m_timer(nullptr), m_current_rate(attotime::zero) { m_queue_chars = ioport_queue_chars_delegate(); @@ -898,7 +898,7 @@ void natural_keyboard::post(unicode_char ch) { const keycode_map_entry *code = find_code(ch); std::string tempstr; - machine().logerror("natural_keyboard::post(): code=%i (%s) field->name='%s'\n", int(ch), unicode_to_string(tempstr, ch), (code != NULL && code->field[0] != NULL) ? code->field[0]->name() : ""); + machine().logerror("natural_keyboard::post(): code=%i (%s) field->name='%s'\n", int(ch), unicode_to_string(tempstr, ch), (code != nullptr && code->field[0] != nullptr) ? code->field[0]->name() : ""); } // can we post this key in the queue directly? @@ -909,7 +909,7 @@ void natural_keyboard::post(unicode_char ch) else if (can_post_alternate(ch)) { const char_info *info = char_info::find(ch); - assert(info != NULL && info->alternate != NULL); + assert(info != nullptr && info->alternate != nullptr); const char *altstring = info->alternate; while (*altstring != 0) { @@ -1036,13 +1036,13 @@ void natural_keyboard::post_coded(const char *text, size_t length, const attotim // look for escape characters if (ch == '{') - for (int codenum = 0; codenum < ARRAY_LENGTH(codes); codenum++) + for (auto & code : codes) { - size_t keylen = strlen(codes[codenum].key); + size_t keylen = strlen(code.key); if (curpos + keylen + 2 <= length) - if (core_strnicmp(codes[codenum].key, &text[curpos + 1], keylen) == 0 && text[curpos + keylen + 1] == '}') + if (core_strnicmp(code.key, &text[curpos + 1], keylen) == 0 && text[curpos + keylen + 1] == '}') { - ch = codes[codenum].code; + ch = code.code; increment = keylen + 2; } } @@ -1064,13 +1064,13 @@ void natural_keyboard::post_coded(const char *text, size_t length, const attotim void natural_keyboard::build_codes(ioport_manager &manager) { // iterate over shift keys - ioport_field *shift[UCHAR_SHIFT_END + 1 - UCHAR_SHIFT_BEGIN] = { 0 }; + ioport_field *shift[UCHAR_SHIFT_END + 1 - UCHAR_SHIFT_BEGIN] = { nullptr }; for (int curshift = 0; curshift <= ARRAY_LENGTH(shift); curshift++) - if (curshift == 0 || shift[curshift - 1] != NULL) + if (curshift == 0 || shift[curshift - 1] != nullptr) // iterate over ports and fields - for (ioport_port *port = manager.first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = manager.first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->type() == IPT_KEYBOARD) { // fetch the code, ignoring 0 @@ -1089,7 +1089,7 @@ void natural_keyboard::build_codes(ioport_manager &manager) if (curshift == 0) { newcode.field[0] = field; - newcode.field[1] = 0; + newcode.field[1] = nullptr; } else { @@ -1122,7 +1122,7 @@ bool natural_keyboard::can_post_directly(unicode_char ch) // otherwise, it depends on the input codes const keycode_map_entry *code = find_code(ch); - return (code != NULL && code->field[0] != NULL); + return (code != nullptr && code->field[0] != nullptr); } @@ -1134,11 +1134,11 @@ bool natural_keyboard::can_post_directly(unicode_char ch) bool natural_keyboard::can_post_alternate(unicode_char ch) { const char_info *info = char_info::find(ch); - if (info == NULL) + if (info == nullptr) return false; const char *altstring = info->alternate; - if (altstring == NULL) + if (altstring == nullptr) return false; while (*altstring != 0) @@ -1274,12 +1274,12 @@ const char *natural_keyboard::unicode_to_string(std::string &buffer, unicode_cha const natural_keyboard::keycode_map_entry *natural_keyboard::find_code(unicode_char ch) const { - for (unsigned int index = 0; index < m_keycode_map.size(); index++) + for (auto & elem : m_keycode_map) { - if (m_keycode_map[index].ch == ch) - return &m_keycode_map[index]; + if (elem.ch == ch) + return &elem; } - return NULL; + return nullptr; } @@ -1295,8 +1295,8 @@ void natural_keyboard::frame_update(ioport_port &port, ioport_value &digital) { // loop through this character's component codes const keycode_map_entry *code = find_code(m_buffer[m_bufbegin]); - if (code != NULL) - for (int fieldnum = 0; fieldnum < ARRAY_LENGTH(code->field) && code->field[fieldnum] != NULL; fieldnum++) + if (code != nullptr) + for (int fieldnum = 0; fieldnum < ARRAY_LENGTH(code->field) && code->field[fieldnum] != nullptr; fieldnum++) if (&code->field[fieldnum]->port() == &port) digital |= code->field[fieldnum]->mask(); } @@ -1311,8 +1311,8 @@ const char *natural_keyboard::key_name(std::string &str, unicode_char ch) { // attempt to get the string from the character info table const char_info *ci = char_info::find(ch); - const char *result = (ci != NULL) ? ci->name : NULL; - if (result != NULL) + const char *result = (ci != nullptr) ? ci->name : nullptr; + if (result != nullptr) str.assign(result); // if that doesn't work, convert to UTF-8 @@ -1341,10 +1341,10 @@ std::string natural_keyboard::dump() const size_t left_column_width = 24; // loop through all codes - for (unsigned int index = 0; index < m_keycode_map.size(); index++) + for (auto & code : m_keycode_map) { // describe the character code - const natural_keyboard::keycode_map_entry &code = m_keycode_map[index]; + strcatprintf(buffer,"%08X (%s) ", code.ch, unicode_to_string(tempstr, code.ch)); // pad with spaces @@ -1352,7 +1352,7 @@ std::string natural_keyboard::dump() buffer.push_back(' '); // identify the keys used - for (int field = 0; field < ARRAY_LENGTH(code.field) && code.field[field] != 0; field++) + for (int field = 0; field < ARRAY_LENGTH(code.field) && code.field[field] != nullptr; field++) strcatprintf(buffer, "%s'%s'", (field > 0) ? ", " : "", code.field[field]->name()); // carriage return @@ -1399,7 +1399,7 @@ bool ioport_condition::eval() const void ioport_condition::initialize(device_t &device) { - if (m_tag != NULL) + if (m_tag != nullptr) m_port = device.ioport(m_tag); } @@ -1414,7 +1414,7 @@ void ioport_condition::initialize(device_t &device) //------------------------------------------------- ioport_setting::ioport_setting(ioport_field &field, ioport_value _value, const char *_name) - : m_next(NULL), + : m_next(nullptr), m_field(field), m_value(_value), m_name(_name) @@ -1432,7 +1432,7 @@ ioport_setting::ioport_setting(ioport_field &field, ioport_value _value, const c //------------------------------------------------- ioport_diplocation::ioport_diplocation(const char *name, UINT8 swnum, bool invert) - : m_next(NULL), + : m_next(nullptr), m_name(name), m_number(swnum), m_invert(invert) @@ -1450,7 +1450,7 @@ ioport_diplocation::ioport_diplocation(const char *name, UINT8 swnum, bool inver //------------------------------------------------- ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value defvalue, ioport_value maskbits, const char *name) - : m_next(NULL), + : m_next(nullptr), m_port(port), m_modcount(port.modcount()), m_mask(maskbits), @@ -1460,8 +1460,8 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def m_flags(0), m_impulse(0), m_name(name), - m_read_param(NULL), - m_write_param(NULL), + m_read_param(nullptr), + m_write_param(nullptr), m_digital_value(false), m_min(0), m_max(maskbits), @@ -1473,7 +1473,7 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def m_crosshair_offset(0), m_crosshair_altaxis(0), m_full_turn_count(0), - m_remap_table(NULL), + m_remap_table(nullptr), m_way(0) { // reset sequences and chars @@ -1485,10 +1485,10 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def if (type == IPT_DIPSWITCH || type == IPT_CONFIG) { const input_device_default *def = device().input_ports_defaults(); - if (def != NULL) + if (def != nullptr) { const char *fulltag = port.tag(); - for ( ; def->tag != NULL; def++) + for ( ; def->tag != nullptr; def++) if (device().subtag(def->tag) == fulltag && def->mask == m_mask) m_defvalue = def->defvalue & m_mask; } @@ -1518,9 +1518,9 @@ ioport_field::~ioport_field() const char *ioport_field::name() const { // if we have a non-default name, use that - if (m_live != NULL && !m_live->name.empty()) + if (m_live != nullptr && !m_live->name.empty()) return m_live->name.c_str(); - if (m_name != NULL) + if (m_name != nullptr) return m_name; // otherwise, return the name associated with the type @@ -1536,7 +1536,7 @@ const char *ioport_field::name() const const input_seq &ioport_field::seq(input_seq_type seqtype) const { // if no live state, return default - if (m_live == NULL) + if (m_live == nullptr) return defseq(seqtype); // if the field is disabled, return no key @@ -1633,7 +1633,7 @@ ioport_type_class ioport_field::type_class() const break; case 0: - if (m_name != NULL && m_name != (const char *)-1) + if (m_name != nullptr && m_name != (const char *)-1) result = INPUT_CLASS_MISC; else result = INPUT_CLASS_INTERNAL; @@ -1683,11 +1683,11 @@ void ioport_field::get_user_settings(user_settings &settings) settings.seq[seqtype] = seq(seqtype); // if there's a list of settings or we're an adjuster, copy the current value - if (first_setting() != NULL || m_type == IPT_ADJUSTER) + if (first_setting() != nullptr || m_type == IPT_ADJUSTER) settings.value = m_live->value; // if there's analog data, extract the analog settings - if (m_live->analog != NULL) + if (m_live->analog != nullptr) { settings.sensitivity = m_live->analog->sensitivity(); settings.delta = m_live->analog->delta(); @@ -1721,11 +1721,11 @@ void ioport_field::set_user_settings(const user_settings &settings) } // if there's a list of settings or we're an adjuster, copy the current value - if (first_setting() != NULL || m_type == IPT_ADJUSTER) + if (first_setting() != nullptr || m_type == IPT_ADJUSTER) m_live->value = settings.value; // if there's analog data, extract the analog settings - if (m_live->analog != NULL) + if (m_live->analog != nullptr) { m_live->analog->m_sensitivity = settings.sensitivity; m_live->analog->m_delta = settings.delta; @@ -1749,10 +1749,10 @@ void ioport_field::set_user_settings(const user_settings &settings) const char *ioport_field::setting_name() const { // only makes sense if we have settings - assert(first_setting() != NULL); + assert(first_setting() != nullptr); // scan the list of settings looking for a match on the current value - for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = first_setting(); setting != nullptr; setting = setting->next()) if (setting->enabled()) if (setting->value() == m_live->value) return setting->name(); @@ -1769,10 +1769,10 @@ const char *ioport_field::setting_name() const bool ioport_field::has_previous_setting() const { // only makes sense if we have settings - assert(first_setting() != NULL); + assert(first_setting() != nullptr); // scan the list of settings looking for a match on the current value - for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = first_setting(); setting != nullptr; setting = setting->next()) if (setting->enabled()) return (setting->value() != m_live->value); @@ -1788,18 +1788,18 @@ bool ioport_field::has_previous_setting() const void ioport_field::select_previous_setting() { // only makes sense if we have settings - assert(first_setting() != NULL); + assert(first_setting() != nullptr); // scan the list of settings looking for a match on the current value - ioport_setting *prevsetting = NULL; + ioport_setting *prevsetting = nullptr; bool found_match = false; - for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = first_setting(); setting != nullptr; setting = setting->next()) if (setting->enabled()) { if (setting->value() == m_live->value) { found_match = true; - if (prevsetting != NULL) + if (prevsetting != nullptr) break; } prevsetting = setting; @@ -1808,13 +1808,13 @@ void ioport_field::select_previous_setting() // if we didn't find a matching value, select the first if (!found_match) { - for (prevsetting = first_setting(); prevsetting != NULL; prevsetting = prevsetting->next()) + for (prevsetting = first_setting(); prevsetting != nullptr; prevsetting = prevsetting->next()) if (prevsetting->enabled()) break; } // update the value to the previous one - if (prevsetting != NULL) + if (prevsetting != nullptr) m_live->value = prevsetting->value(); } @@ -1827,11 +1827,11 @@ void ioport_field::select_previous_setting() bool ioport_field::has_next_setting() const { // only makes sense if we have settings - assert(first_setting() != NULL); + assert(first_setting() != nullptr); // scan the list of settings looking for a match on the current value bool found = false; - for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = first_setting(); setting != nullptr; setting = setting->next()) if (setting->enabled()) { if (found) @@ -1852,30 +1852,30 @@ bool ioport_field::has_next_setting() const void ioport_field::select_next_setting() { // only makes sense if we have settings - assert(first_setting() != NULL); + assert(first_setting() != nullptr); // scan the list of settings looking for a match on the current value - ioport_setting *nextsetting = NULL; + ioport_setting *nextsetting = nullptr; ioport_setting *setting; - for (setting = first_setting(); setting != NULL; setting = setting->next()) + for (setting = first_setting(); setting != nullptr; setting = setting->next()) if (setting->enabled()) if (setting->value() == m_live->value) break; // if we found one, scan forward for the next valid one - if (setting != NULL) - for (nextsetting = setting->next(); nextsetting != NULL; nextsetting = nextsetting->next()) + if (setting != nullptr) + for (nextsetting = setting->next(); nextsetting != nullptr; nextsetting = nextsetting->next()) if (nextsetting->enabled()) break; // if we hit the end, search from the beginning - if (nextsetting == NULL) - for (nextsetting = first_setting(); nextsetting != NULL; nextsetting = nextsetting->next()) + if (nextsetting == nullptr) + for (nextsetting = first_setting(); nextsetting != nullptr; nextsetting = nextsetting->next()) if (nextsetting->enabled()) break; // update the value to the previous one - if (nextsetting != NULL) + if (nextsetting != nullptr) m_live->value = nextsetting->value(); } @@ -1892,7 +1892,7 @@ void ioport_field::frame_update(ioport_value &result, bool mouse_down) return; // handle analog inputs first - if (m_live->analog != NULL) + if (m_live->analog != nullptr) { m_live->analog->frame_update(machine()); return; @@ -1957,7 +1957,7 @@ void ioport_field::frame_update(ioport_value &result, bool mouse_down) curstate = false; // additional logic to restrict digital joysticks - if (curstate && !m_digital_value && !mouse_down && m_live->joystick != NULL && m_way != 16 && !machine().options().joystick_contradictory()) + if (curstate && !m_digital_value && !mouse_down && m_live->joystick != nullptr && m_way != 16 && !machine().options().joystick_contradictory()) { UINT8 mask = (m_way == 4) ? m_live->joystick->current4way() : m_live->joystick->current(); if (!(mask & (1 << m_live->joydir))) @@ -2043,21 +2043,21 @@ void ioport_field::crosshair_position(float &x, float &y, bool &gotx, bool &goty void ioport_field::expand_diplocation(const char *location, std::string &errorbuf) { // if nothing present, bail - if (location == NULL) + if (location == nullptr) return; m_diploclist.reset(); // parse the string std::string name; // Don't move this variable inside the loop, lastname's lifetime depends on it being outside - const char *lastname = NULL; + const char *lastname = nullptr; const char *curentry = location; int entries = 0; while (*curentry != 0) { // find the end of this entry const char *comma = strchr(curentry, ','); - if (comma == NULL) + if (comma == nullptr) comma = curentry + strlen(curentry); // extract it to tempbuf @@ -2069,7 +2069,7 @@ void ioport_field::expand_diplocation(const char *location, std::string &errorbu const char *colon = strchr(tempstr.c_str(), ':'); // allocate and copy the name if it is present - if (colon != NULL) + if (colon != nullptr) { lastname = name.assign(number, colon - number).c_str(); number = colon + 1; @@ -2078,7 +2078,7 @@ void ioport_field::expand_diplocation(const char *location, std::string &errorbu // otherwise, just copy the last name else { - if (lastname == NULL) + if (lastname == nullptr) { strcatprintf(errorbuf, "Switch location '%s' missing switch name!\n", location); lastname = (char *)"UNK"; @@ -2135,7 +2135,7 @@ void ioport_field::init_live_state(analog_field *analog) m_condition.initialize(device()); - for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = first_setting(); setting != nullptr; setting = setting->next()) setting->condition().initialize(setting->device()); } @@ -2151,7 +2151,7 @@ void ioport_field::init_live_state(analog_field *analog) ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog) : analog(analog), - joystick(NULL), + joystick(nullptr), value(field.defvalue()), impulse(0), last(0), @@ -2170,7 +2170,7 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog) } // Name keyboard key names - if (field.type_class() == INPUT_CLASS_KEYBOARD && field.specific_name() == NULL) + if (field.type_class() == INPUT_CLASS_KEYBOARD && field.specific_name() == nullptr) { // loop through each character on the field std::string tempstr; @@ -2202,7 +2202,7 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog) //------------------------------------------------- ioport_port::ioport_port(device_t &owner, const char *tag) - : m_next(NULL), + : m_next(nullptr), m_device(owner), m_tag(tag), m_modcount(0), @@ -2250,10 +2250,10 @@ ioport_manager &ioport_port::manager() const ioport_field *ioport_port::field(ioport_value mask) { // if we got the port, look for the field - for (ioport_field *field = first_field(); field != NULL; field = field->next()) + for (ioport_field *field = first_field(); field != nullptr; field = field->next()) if ((field->mask() & mask) != 0) return field; - return NULL; + return nullptr; } @@ -2269,14 +2269,14 @@ ioport_value ioport_port::read() ioport_value result = m_live->digital; // insert dynamic read values - for (dynamic_field *dynfield = m_live->readlist.first(); dynfield != NULL; dynfield = dynfield->next()) + for (dynamic_field *dynfield = m_live->readlist.first(); dynfield != nullptr; dynfield = dynfield->next()) dynfield->read(result); // apply active high/low state to digital and dynamic read inputs result ^= m_live->defvalue; // insert analog portions - for (analog_field *analog = m_live->analoglist.first(); analog != NULL; analog = analog->next()) + for (analog_field *analog = m_live->analoglist.first(); analog != nullptr; analog = analog->next()) analog->read(result); return result; @@ -2291,7 +2291,7 @@ void ioport_port::write(ioport_value data, ioport_value mem_mask) { // call device line write handlers COMBINE_DATA(&m_live->outputvalue); - for (dynamic_field *dynfield = m_live->writelist.first(); dynfield != NULL; dynfield = dynfield->next()) + for (dynamic_field *dynfield = m_live->writelist.first(); dynfield != nullptr; dynfield = dynfield->next()) if (dynfield->field().type() == IPT_OUTPUT) dynfield->write(m_live->outputvalue ^ dynfield->field().defvalue()); } @@ -2307,7 +2307,7 @@ void ioport_port::frame_update(ioport_field *mouse_field) m_live->digital = 0; // now loop back and modify based on the inputs - for (ioport_field *field = first_field(); field != NULL; field = field->next()) + for (ioport_field *field = first_field(); field != nullptr; field = field->next()) field->frame_update(m_live->digital, field == mouse_field); // hook for MESS's natural keyboard support @@ -2327,7 +2327,7 @@ void ioport_port::collapse_fields(std::string &errorbuf) // remove the whole list and start from scratch ioport_field *field = m_fieldlist.detach_all(); - while (field != NULL) + while (field != nullptr) { // if this modcount doesn't match, reset if (field->modcount() != lastmodcount) @@ -2361,7 +2361,7 @@ void ioport_port::insert_field(ioport_field &newfield, ioport_value &disallowedb // first modify/nuke any entries that intersect our maskbits ioport_field *nextfield; - for (ioport_field *field = first_field(); field != NULL; field = nextfield) + for (ioport_field *field = first_field(); field != nullptr; field = nextfield) { nextfield = field->next(); if ((field->mask() & newfield.mask()) != 0 && @@ -2381,7 +2381,7 @@ void ioport_port::insert_field(ioport_field &newfield, ioport_value &disallowedb // scan forward to find where to insert ourselves ioport_field *field; - for (field = first_field(); field != NULL; field = field->next()) + for (field = first_field(); field != nullptr; field = field->next()) if (field->mask() > lowbit) break; @@ -2415,10 +2415,10 @@ ioport_port_live::ioport_port_live(ioport_port &port) outputvalue(0) { // iterate over fields - for (ioport_field *field = port.first_field(); field != NULL; field = field->next()) + for (ioport_field *field = port.first_field(); field != nullptr; field = field->next()) { // allocate analog state if it's analog - analog_field *analog = NULL; + analog_field *analog = nullptr; if (field->is_analog()) analog = &analoglist.append(*global_alloc(analog_field(*field))); @@ -2480,7 +2480,7 @@ time_t ioport_manager::initialize() // if we have a token list, proceed device_iterator iter(machine().root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) { std::string errors; m_portlist.append(*device, errors); @@ -2490,14 +2490,14 @@ time_t ioport_manager::initialize() // renumber player numbers for controller ports int player_offset = 0; - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) { int players = 0; - for (ioport_port *port = first_port(); port != NULL; port = port->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) { if (&port->device()==device) { - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->type_class()==INPUT_CLASS_CONTROLLER) { if (players < field->player() + 1) players = field->player() + 1; @@ -2509,7 +2509,7 @@ time_t ioport_manager::initialize() } // allocate live structures to mirror the configuration - for (ioport_port *port = first_port(); port != NULL; port = port->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) port->init_live_state(); // handle autoselection of devices @@ -2525,9 +2525,9 @@ time_t ioport_manager::initialize() // look for 4-way diagonal joysticks and change the default map if we find any const char *joystick_map_default = machine().options().joystick_map(); if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0) - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) - if (field->live().joystick != NULL && field->rotated()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) + if (field->live().joystick != nullptr && field->rotated()) { machine().input().set_global_joystick_map(joystick_map_4way_diagonal); break; @@ -2545,8 +2545,8 @@ time_t ioport_manager::initialize() m_has_bioses = false; // scan the input port array to see what options we need to enable - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) { if (field->type() == IPT_DIPSWITCH) m_has_dips = true; @@ -2556,7 +2556,7 @@ time_t ioport_manager::initialize() m_has_analog = true; } device_iterator deviter(machine().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) if (device->rom_region()) for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { m_has_bioses= true; break; } @@ -2583,7 +2583,7 @@ void ioport_manager::init_port_types() machine().osd().customize_input_type_list(m_typelist); // now iterate over the OSD-modified types - for (input_type_entry *curtype = first_type(); curtype != NULL; curtype = curtype->next()) + for (input_type_entry *curtype = first_type(); curtype != nullptr; curtype = curtype->next()) { // first copy all the OSD-updated sequences into our current state curtype->restore_default_seq(); @@ -2634,9 +2634,9 @@ void ioport_manager::init_autoselect_devices(int type1, int type2, int type3, co osd_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp); // only scan the list if we haven't already enabled this class of control - if (first_port() != NULL && !machine().input().device_class(autoenable).enabled()) - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + if (first_port() != nullptr && !machine().input().device_class(autoenable).enabled()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) // if this port type is in use, apply the autoselect criteria if ((type1 != 0 && field->type() == type1) || (type2 != 0 && field->type() == type2) || (type3 != 0 && field->type() == type3)) @@ -2670,7 +2670,7 @@ const char *ioport_manager::type_name(ioport_type type, UINT8 player) { // if we have a machine, use the live state and quick lookup input_type_entry *entry = m_type_to_entry[type][player]; - if (entry != NULL) + if (entry != nullptr) return entry->name(); // if we find nothing, return an invalid group @@ -2686,7 +2686,7 @@ const char *ioport_manager::type_name(ioport_type type, UINT8 player) ioport_group ioport_manager::type_group(ioport_type type, int player) { input_type_entry *entry = m_type_to_entry[type][player]; - if (entry != NULL) + if (entry != nullptr) return entry->group(); // if we find nothing, return an invalid group @@ -2706,7 +2706,7 @@ const input_seq &ioport_manager::type_seq(ioport_type type, int player, input_se // if we have a machine, use the live state and quick lookup input_type_entry *entry = m_type_to_entry[type][player]; - if (entry != NULL) + if (entry != nullptr) return entry->seq(seqtype); // if we find nothing, return an empty sequence @@ -2722,7 +2722,7 @@ const input_seq &ioport_manager::type_seq(ioport_type type, int player, input_se void ioport_manager::set_type_seq(ioport_type type, int player, input_seq_type seqtype, const input_seq &newseq) { input_type_entry *entry = m_type_to_entry[type][player]; - if (entry != NULL) + if (entry != nullptr) entry->m_seq[seqtype] = newseq; } @@ -2745,8 +2745,8 @@ bool ioport_manager::type_pressed(ioport_type type, int player) bool ioport_manager::type_class_present(ioport_type_class inputclass) { - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->type_class() == inputclass) return true; return false; @@ -2761,8 +2761,8 @@ bool ioport_manager::type_class_present(ioport_type_class inputclass) bool ioport_manager::has_keyboard() const { // iterate over ports and fields - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) { // if we are at init, check IPT_KEYBOARD if (!m_safe_to_read && field->type() == IPT_KEYBOARD) @@ -2784,8 +2784,8 @@ bool ioport_manager::has_keyboard() const int ioport_manager::count_players() const { int max_player = 0; - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->type_class() == INPUT_CLASS_CONTROLLER && max_player <= field->player() + 1) max_player = field->player() + 1; @@ -2802,8 +2802,8 @@ bool ioport_manager::crosshair_position(int player, float &x, float &y) { // read all the lightgun values bool gotx = false, goty = false; - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->player() == player && field->crosshair_axis() != CROSSHAIR_AXIS_NONE && field->enabled()) { field->crosshair_position(x, y, gotx, goty); @@ -2828,14 +2828,14 @@ void ioport_manager::update_defaults() for (int loopnum = 0; loopnum < 2; loopnum++) { // loop over all input ports - for (ioport_port *port = first_port(); port != NULL; port = port->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) { // only clear on the first pass if (loopnum == 0) port->live().defvalue = 0; // first compute the default value for the entire port - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (field->enabled()) port->live().defvalue = (port->live().defvalue & ~field->mask()) | (field->live().value & field->mask()); } @@ -2851,7 +2851,7 @@ void ioport_manager::update_defaults() digital_joystick &ioport_manager::digjoystick(int player, int number) { // find it in the list - for (digital_joystick *joystick = m_joystick_list.first(); joystick != NULL; joystick = joystick->next()) + for (digital_joystick *joystick = m_joystick_list.first(); joystick != nullptr; joystick = joystick->next()) if (joystick->player() == player && joystick->number() == number) return *joystick; @@ -2891,7 +2891,7 @@ g_profiler.start(PROFILER_INPUT); m_last_frame_time = curtime; // update the digital joysticks - for (digital_joystick *joystick = m_joystick_list.first(); joystick != NULL; joystick = joystick->next()) + for (digital_joystick *joystick = m_joystick_list.first(); joystick != nullptr; joystick = joystick->next()) joystick->frame_update(); // compute default values for all the ports @@ -2903,21 +2903,21 @@ g_profiler.start(PROFILER_INPUT); render_target *mouse_target = ui_input_find_mouse(machine(), &mouse_target_x, &mouse_target_y, &mouse_button); // if the button is pressed, map the point and determine what was hit - ioport_field *mouse_field = NULL; - if (mouse_button && mouse_target != NULL) + ioport_field *mouse_field = nullptr; + if (mouse_button && mouse_target != nullptr) { - ioport_port *port = NULL; + ioport_port *port = nullptr; ioport_value mask; float x, y; if (mouse_target->map_point_input(mouse_target_x, mouse_target_y, port, mask, x, y)) { - if (port != NULL) + if (port != nullptr) mouse_field = port->field(mask); } } // loop over all input ports - for (ioport_port *port = first_port(); port != NULL; port = port->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) { port->frame_update(mouse_field); @@ -2927,7 +2927,7 @@ g_profiler.start(PROFILER_INPUT); // call device line write handlers ioport_value newvalue = port->read(); - for (dynamic_field *dynfield = port->live().writelist.first(); dynfield != NULL; dynfield = dynfield->next()) + for (dynamic_field *dynfield = port->live().writelist.first(); dynfield != nullptr; dynfield = dynfield->next()) if (dynfield->field().type() != IPT_OUTPUT) dynfield->write(newvalue); } @@ -2968,7 +2968,7 @@ void ioport_manager::load_config(int config_type, xml_data_node *parentnode) } // early exit if no data to parse - if (parentnode == NULL) + if (parentnode == nullptr) return; // iterate over all the remap nodes for controller configs only @@ -2992,7 +2992,7 @@ void ioport_manager::load_config(int config_type, xml_data_node *parentnode) { // with a valid type, parse out the new sequence input_seq_type seqtype = token_to_seq_type(xml_get_attribute_string(seqnode, "type", "")); - if (seqtype != -1 && seqnode->value != NULL) + if (seqtype != -1 && seqnode->value != nullptr) { if (strcmp(seqnode->value, "NONE") == 0) newseq[seqtype].set(); @@ -3011,7 +3011,7 @@ void ioport_manager::load_config(int config_type, xml_data_node *parentnode) // after applying the controller config, push that back into the backup, since that is // what we will diff against if (config_type == CONFIG_TYPE_CONTROLLER) - for (input_type_entry *entry = m_typelist.first(); entry != NULL; entry = entry->next()) + for (input_type_entry *entry = m_typelist.first(); entry != nullptr; entry = entry->next()) for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) entry->defseq(seqtype) = entry->seq(seqtype); } @@ -3026,7 +3026,7 @@ void ioport_manager::load_remap_table(xml_data_node *parentnode) { // count items first so we can allocate int count = 0; - for (xml_data_node *remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != NULL; remapnode = xml_get_sibling(remapnode->next, "remap")) + for (xml_data_node *remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != nullptr; remapnode = xml_get_sibling(remapnode->next, "remap")) count++; // if we have some, deal with them @@ -3038,7 +3038,7 @@ void ioport_manager::load_remap_table(xml_data_node *parentnode) // build up the remap table count = 0; - for (xml_data_node *remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != NULL; remapnode = xml_get_sibling(remapnode->next, "remap")) + for (xml_data_node *remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != nullptr; remapnode = xml_get_sibling(remapnode->next, "remap")) { input_code origcode = machine().input().code_from_token(xml_get_attribute_string(remapnode, "origcode", "")); input_code newcode = machine().input().code_from_token(xml_get_attribute_string(remapnode, "newcode", "")); @@ -3052,7 +3052,7 @@ void ioport_manager::load_remap_table(xml_data_node *parentnode) // loop over the remapping table, then over default ports, replacing old with new for (int remapnum = 0; remapnum < count; remapnum++) - for (input_type_entry *entry = m_typelist.first(); entry != NULL; entry = entry->next()) + for (input_type_entry *entry = m_typelist.first(); entry != nullptr; entry = entry->next()) for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) entry->m_seq[seqtype].replace(oldtable[remapnum], newtable[remapnum]); } @@ -3067,7 +3067,7 @@ void ioport_manager::load_remap_table(xml_data_node *parentnode) bool ioport_manager::load_default_config(xml_data_node *portnode, int type, int player, const input_seq *newseq) { // find a matching port in the list - for (input_type_entry *entry = m_typelist.first(); entry != NULL; entry = entry->next()) + for (input_type_entry *entry = m_typelist.first(); entry != nullptr; entry = entry->next()) if (entry->type() == type && entry->player() == player) { for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) @@ -3088,14 +3088,14 @@ bool ioport_manager::load_default_config(xml_data_node *portnode, int type, int bool ioport_manager::load_game_config(xml_data_node *portnode, int type, int player, const input_seq *newseq) { // read the mask, index, and defvalue attributes - const char *tag = xml_get_attribute_string(portnode, "tag", NULL); + const char *tag = xml_get_attribute_string(portnode, "tag", nullptr); ioport_value mask = xml_get_attribute_int(portnode, "mask", 0); ioport_value defvalue = xml_get_attribute_int(portnode, "defvalue", 0); // find the port we want; if no tag, search them all - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - if (tag == NULL || strcmp(port->tag(), tag) == 0) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + if (tag == nullptr || strcmp(port->tag(), tag) == 0) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) // find the matching mask and defvalue if (field->type() == type && field->player() == player && @@ -3108,14 +3108,14 @@ bool ioport_manager::load_game_config(xml_data_node *portnode, int type, int pla // fetch configurable attributes // for non-analog fields - if (field->live().analog == NULL) + if (field->live().analog == nullptr) { // fetch the value field->live().value = xml_get_attribute_int(portnode, "value", field->defvalue()); // fetch yes/no for toggle setting - const char *togstring = xml_get_attribute_string(portnode, "toggle", NULL); - if (togstring != NULL) + const char *togstring = xml_get_attribute_string(portnode, "toggle", nullptr); + if (togstring != nullptr) field->live().toggle = (strcmp(togstring, "yes") == 0); } @@ -3128,8 +3128,8 @@ bool ioport_manager::load_game_config(xml_data_node *portnode, int type, int pla field->live().analog->m_sensitivity = xml_get_attribute_int(portnode, "sensitivity", field->sensitivity()); // fetch yes/no for reverse setting - const char *revstring = xml_get_attribute_string(portnode, "reverse", NULL); - if (revstring != NULL) + const char *revstring = xml_get_attribute_string(portnode, "reverse", nullptr); + if (revstring != nullptr) field->live().analog->m_reverse = (strcmp(revstring, "yes") == 0); } return true; @@ -3152,7 +3152,7 @@ bool ioport_manager::load_game_config(xml_data_node *portnode, int type, int pla void ioport_manager::save_config(int config_type, xml_data_node *parentnode) { // if no parentnode, ignore - if (parentnode == NULL) + if (parentnode == nullptr) return; // default ports save differently @@ -3179,7 +3179,7 @@ void ioport_manager::save_sequence(xml_data_node *parentnode, input_seq_type typ // add the new node xml_data_node *seqnode = xml_add_child(parentnode, "newseq", seqstring.c_str()); - if (seqnode != NULL) + if (seqnode != nullptr) xml_set_attribute(seqnode, "type", seqtypestrings[type]); } @@ -3214,7 +3214,7 @@ bool ioport_manager::save_this_input_field_type(ioport_type type) void ioport_manager::save_default_inputs(xml_data_node *parentnode) { // iterate over ports - for (input_type_entry *entry = m_typelist.first(); entry != NULL; entry = entry->next()) + for (input_type_entry *entry = m_typelist.first(); entry != nullptr; entry = entry->next()) { // only save if this port is a type we save if (save_this_input_field_type(entry->type())) @@ -3229,8 +3229,8 @@ void ioport_manager::save_default_inputs(xml_data_node *parentnode) if (seqtype < SEQ_TYPE_TOTAL) { // add a new port node - xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); - if (portnode != NULL) + xml_data_node *portnode = xml_add_child(parentnode, "port", nullptr); + if (portnode != nullptr) { // add the port information and attributes std::string tempstr; @@ -3255,8 +3255,8 @@ void ioport_manager::save_default_inputs(xml_data_node *parentnode) void ioport_manager::save_game_inputs(xml_data_node *parentnode) { // iterate over ports - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = first_port(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) if (save_this_input_field_type(field->type())) { // determine if we changed @@ -3284,8 +3284,8 @@ void ioport_manager::save_game_inputs(xml_data_node *parentnode) if (changed) { // add a new port node - xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); - if (portnode != NULL) + xml_data_node *portnode = xml_add_child(parentnode, "port", nullptr); + if (portnode != nullptr) { // add the identifying information and attributes std::string tempstr; @@ -3424,7 +3424,7 @@ void ioport_manager::playback_end(const char *message) m_playback_file.close(); // pop a message - if (message != NULL) + if (message != nullptr) machine().popmessage("Playback Ended\nReason: %s", message); // display speed stats @@ -3476,7 +3476,7 @@ void ioport_manager::playback_port(ioport_port &port) playback_read(port.live().digital); // loop over analog ports and save their data - for (analog_field *analog = port.live().analoglist.first(); analog != NULL; analog = analog->next()) + for (analog_field *analog = port.live().analoglist.first(); analog != nullptr; analog = analog->next()) { // read current and previous values playback_read(analog->m_accum); @@ -3570,7 +3570,7 @@ void ioport_manager::record_end(const char *message) m_record_file.close(); // pop a message - if (message != NULL) + if (message != nullptr) machine().popmessage("Recording Ended\nReason: %s", message); } } @@ -3610,7 +3610,7 @@ void ioport_manager::record_port(ioport_port &port) record_write(port.live().digital); // loop over analog ports and save their data - for (analog_field *analog = port.live().analoglist.first(); analog != NULL; analog = analog->next()) + for (analog_field *analog = port.live().analoglist.first(); analog != nullptr; analog = analog->next()) { // store current and previous values record_write(analog->m_accum); @@ -3637,9 +3637,9 @@ ioport_configurer::ioport_configurer(device_t &owner, ioport_list &portlist, std : m_owner(owner), m_portlist(portlist), m_errorbuf(errorbuf), - m_curport(NULL), - m_curfield(NULL), - m_cursetting(NULL) + m_curport(nullptr), + m_curfield(nullptr), + m_cursetting(nullptr) { } @@ -3652,8 +3652,8 @@ ioport_configurer::ioport_configurer(device_t &owner, ioport_list &portlist, std const char *ioport_configurer::string_from_token(const char *string) { // 0 is an invalid index - if (string == NULL) - return NULL; + if (string == nullptr) + return nullptr; // if the index is greater than the count, assume it to be a pointer if (FPTR(string) >= INPUT_STRING_COUNT) @@ -3689,8 +3689,8 @@ void ioport_configurer::port_alloc(const char *tag) // add it to the list, and reset current field/setting m_curport = &m_portlist.append(fulltag.c_str(), *global_alloc(ioport_port(m_owner, fulltag.c_str()))); - m_curfield = NULL; - m_cursetting = NULL; + m_curfield = nullptr; + m_cursetting = nullptr; } @@ -3706,13 +3706,13 @@ void ioport_configurer::port_modify(const char *tag) // find the existing port m_curport = m_portlist.find(fulltag.c_str()); - if (m_curport == NULL) + if (m_curport == nullptr) throw emu_fatalerror("Requested to modify nonexistent port '%s'", fulltag.c_str()); // bump the modification count, and reset current field/setting m_curport->m_modcount++; - m_curfield = NULL; - m_cursetting = NULL; + m_curfield = nullptr; + m_cursetting = nullptr; } @@ -3723,7 +3723,7 @@ void ioport_configurer::port_modify(const char *tag) void ioport_configurer::field_alloc(ioport_type type, ioport_value defval, ioport_value mask, const char *name) { // make sure we have a port - if (m_curport == NULL) + if (m_curport == nullptr) throw emu_fatalerror("alloc_field called with no active port (mask=%X defval=%X)\n", mask, defval); // append the field if (type != IPT_UNKNOWN && type != IPT_UNUSED) @@ -3731,7 +3731,7 @@ void ioport_configurer::field_alloc(ioport_type type, ioport_value defval, iopor m_curfield = &m_curport->m_fieldlist.append(*global_alloc(ioport_field(*m_curport, type, defval, mask, string_from_token(name)))); // reset the current setting - m_cursetting = NULL; + m_cursetting = nullptr; } @@ -3769,7 +3769,7 @@ void ioport_configurer::field_add_code(input_seq_type which, input_code code) void ioport_configurer::setting_alloc(ioport_value value, const char *name) { // make sure we have a field - if (m_curfield == NULL) + if (m_curfield == nullptr) throw emu_fatalerror("alloc_setting called with no active field (value=%X name=%s)\n", value, name); m_cursetting = global_alloc(ioport_setting(*m_curfield, value & m_curfield->mask(), string_from_token(name))); @@ -3785,7 +3785,7 @@ void ioport_configurer::setting_alloc(ioport_value value, const char *name) void ioport_configurer::set_condition(ioport_condition::condition_t condition, const char *tag, ioport_value mask, ioport_value value) { - ioport_condition &target = (m_cursetting != NULL) ? m_cursetting->condition() : m_curfield->condition(); + ioport_condition &target = (m_cursetting != nullptr) ? m_cursetting->condition() : m_curfield->condition(); target.set(condition, tag, mask, value); } @@ -3807,14 +3807,14 @@ void ioport_configurer::onoff_alloc(const char *name, ioport_value defval, iopor } // expand the diplocation - if (diplocation != NULL) + if (diplocation != nullptr) field_set_diplocation(diplocation); // allocate settings setting_alloc(defval & mask, DEF_STR(Off)); setting_alloc(~defval & mask, DEF_STR(On)); // clear cursettings set by setting_alloc - m_cursetting = NULL; + m_cursetting = nullptr; } @@ -3844,7 +3844,7 @@ const char_info *char_info::find(unicode_char target) else return &charinfo[middle]; } - return NULL; + return nullptr; } @@ -3853,7 +3853,7 @@ const char_info *char_info::find(unicode_char target) //------------------------------------------------- dynamic_field::dynamic_field(ioport_field &field) - : m_next(NULL), + : m_next(nullptr), m_field(field), m_shift(0), m_oldval(field.defvalue()) @@ -3911,7 +3911,7 @@ void dynamic_field::write(ioport_value newval) //------------------------------------------------- analog_field::analog_field(ioport_field &field) - : m_next(NULL), + : m_next(nullptr), m_field(field), m_shift(0), m_adjdefvalue(field.defvalue() & field.mask()), @@ -4339,7 +4339,7 @@ void analog_field::read(ioport_value &result) value = apply_settings(value); // remap the value if needed - if (m_field.remap_table() != NULL) + if (m_field.remap_table() != nullptr) value = m_field.remap_table()[value]; // invert bits if needed @@ -4381,8 +4381,8 @@ ioport_type ioport_manager::token_to_input_type(const char *string, int &player) return ioport_type(ipnum); // find the token in the list - for (input_type_entry *entry = m_typelist.first(); entry != NULL; entry = entry->next()) - if (entry->token() != NULL && !strcmp(entry->token(), string)) + for (input_type_entry *entry = m_typelist.first(); entry != nullptr; entry = entry->next()) + if (entry->token() != nullptr && !strcmp(entry->token(), string)) { player = entry->player(); return entry->type(); @@ -4403,7 +4403,7 @@ const char *ioport_manager::input_type_to_token(std::string &str, ioport_type ty { // look up the port and return the token input_type_entry *entry = m_type_to_entry[type][player]; - if (entry != NULL) + if (entry != nullptr) return str.assign(entry->token()).c_str(); // if that fails, carry on diff --git a/src/emu/ioport.h b/src/emu/ioport.h index fc42ae805d8..ddb653b5926 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -900,7 +900,7 @@ public: bool none() const { return (m_condition == ALWAYS); } // configuration - void reset() { set(ALWAYS, NULL, 0, 0); } + void reset() { set(ALWAYS, nullptr, 0, 0); } void set(condition_t condition, const char *tag, ioport_value mask, ioport_value value) { m_condition = condition; @@ -1003,7 +1003,7 @@ class ioport_field public: // construction/destruction - ioport_field(ioport_port &port, ioport_type type, ioport_value defvalue, ioport_value maskbits, const char *name = NULL); + ioport_field(ioport_port &port, ioport_type type, ioport_value defvalue, ioport_value maskbits, const char *name = nullptr); ~ioport_field(); // getters @@ -1225,7 +1225,7 @@ private: std::unique_ptr m_live; // live state of port (NULL if not live) }; -inline ioport_value read_safe(ioport_port *port, ioport_value defval) { return (port == NULL) ? defval : port->read(); } +inline ioport_value read_safe(ioport_port *port, ioport_value defval) { return (port == nullptr) ? defval : port->read(); } @@ -1424,13 +1424,13 @@ private: template _Type playback_read(_Type &result); time_t playback_init(); - void playback_end(const char *message = NULL); + void playback_end(const char *message = nullptr); void playback_frame(const attotime &curtime); void playback_port(ioport_port &port); template void record_write(_Type value); void record_init(); - void record_end(const char *message = NULL); + void record_end(const char *message = nullptr); void record_frame(const attotime &curtime); void record_port(ioport_port &port); @@ -1482,7 +1482,7 @@ public: void port_modify(const char *tag); // field helpers - void field_alloc(ioport_type type, ioport_value defval, ioport_value mask, const char *name = NULL); + void field_alloc(ioport_type type, ioport_value defval, ioport_value mask, const char *name = nullptr); void field_add_char(unicode_char ch); void field_add_code(input_seq_type which, input_code code); void field_set_way(int way) const { m_curfield->m_way = way; } @@ -1505,8 +1505,8 @@ public: void field_set_analog_wraps() const { m_curfield->m_flags |= ioport_field::ANALOG_FLAG_WRAPS; } void field_set_remap_table(const ioport_value *table) { m_curfield->m_remap_table = table; } void field_set_analog_invert() const { m_curfield->m_flags |= ioport_field::ANALOG_FLAG_INVERT; } - void field_set_dynamic_read(ioport_field_read_delegate delegate, void *param = NULL) const { m_curfield->m_read = delegate; m_curfield->m_read_param = param; } - void field_set_dynamic_write(ioport_field_write_delegate delegate, void *param = NULL) const { m_curfield->m_write = delegate; m_curfield->m_write_param = param; } + void field_set_dynamic_read(ioport_field_read_delegate delegate, void *param = nullptr) const { m_curfield->m_read = delegate; m_curfield->m_read_param = param; } + void field_set_dynamic_write(ioport_field_write_delegate delegate, void *param = nullptr) const { m_curfield->m_write = delegate; m_curfield->m_write_param = param; } void field_set_diplocation(const char *location) const { m_curfield->expand_diplocation(location, m_errorbuf); } // setting helpers diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp index 867e5fa992c..0aa4b45deb1 100644 --- a/src/emu/luaengine.cpp +++ b/src/emu/luaengine.cpp @@ -34,13 +34,13 @@ (fputs(p, stdout), fflush(stdout), /* show prompt */ \ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ -static lua_State *globalL = NULL; +static lua_State *globalL = nullptr; #define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) #define luai_writeline() (luai_writestring("\n", 1), fflush(stdout)) const char *const lua_engine::tname_ioport = "lua.ioport"; -lua_engine* lua_engine::luaThis = NULL; +lua_engine* lua_engine::luaThis = nullptr; extern "C" { int luaopen_lsqlite3(lua_State *L); @@ -49,7 +49,7 @@ extern "C" { static void lstop(lua_State *L, lua_Debug *ar) { (void)ar; /* unused arg. */ - lua_sethook(L, NULL, 0, 0); + lua_sethook(L, nullptr, 0, 0); luaL_error(L, "interrupted!"); } @@ -65,7 +65,7 @@ int lua_engine::report(int status) { if (status != LUA_OK && !lua_isnil(m_lua_state, -1)) { const char *msg = lua_tostring(m_lua_state, -1); - if (msg == NULL) msg = "(error object is not a string)"; + if (msg == nullptr) msg = "(error object is not a string)"; lua_writestringerror("%s\n", msg); lua_pop(m_lua_state, 1); /* force a complete garbage collection in case of errors */ @@ -124,7 +124,7 @@ int lua_engine::incomplete(int status) lua_engine::hook::hook() { - L = NULL; + L = nullptr; cb = -1; } @@ -138,7 +138,7 @@ void lua_engine::hook::set(lua_State *_L, int idx) luaL_unref(L, LUA_REGISTRYINDEX, cb); if (lua_isnil(_L, idx)) { - L = NULL; + L = nullptr; cb = -1; } else { @@ -162,7 +162,7 @@ void lua_engine::hook::call(lua_engine *engine, lua_State *T, int nparam) void lua_engine::resume(lua_State *L, int nparam, lua_State *root) { - int s = lua_resume(L, NULL, nparam); + int s = lua_resume(L, nullptr, nparam); switch(s) { case LUA_OK: if(!root) { @@ -301,7 +301,7 @@ int lua_engine::emu_wait(lua_State *L) { luaL_argcheck(L, lua_isnumber(L, 1), 1, "waiting duration expected"); machine().scheduler().timer_set(attotime::from_double(lua_tonumber(L, 1)), timer_expired_delegate(FUNC(lua_engine::resume), this), 0, L); - return lua_yieldk(L, 0, 0, 0); + return lua_yieldk(L, 0, 0, nullptr); } int lua_engine::l_emu_wait(lua_State *L) @@ -330,7 +330,7 @@ void lua_engine::emu_hook_output(lua_State *L) hook_output_cb.set(L, 1); if (!output_notifier_set) { - output_set_notifier(NULL, s_output_notifier, this); + output_set_notifier(nullptr, s_output_notifier, this); output_notifier_set = true; } } @@ -356,7 +356,7 @@ void lua_engine::emu_set_hook(lua_State *L) if (strcmp(hookname, "output") == 0) { hook_output_cb.set(L, 1); if (!output_notifier_set) { - output_set_notifier(NULL, s_output_notifier, this); + output_set_notifier(nullptr, s_output_notifier, this); output_notifier_set = true; } } else if (strcmp(hookname, "frame") == 0) { @@ -376,7 +376,7 @@ luabridge::LuaRef lua_engine::l_machine_get_screens(const running_machine *r) lua_State *L = luaThis->m_lua_state; luabridge::LuaRef screens_table = luabridge::LuaRef::newTable(L); - for (device_t *dev = r->first_screen(); dev != NULL; dev = dev->next()) { + for (device_t *dev = r->first_screen(); dev != nullptr; dev = dev->next()) { screen_device *sc = dynamic_cast(dev); if (sc && sc->configured() && sc->started() && sc->type()) { screens_table[sc->tag()] = sc; @@ -407,7 +407,7 @@ luabridge::LuaRef lua_engine::l_machine_get_devices(const running_machine *r) luabridge::LuaRef lua_engine::devtree_dfs(device_t *root, luabridge::LuaRef devs_table) { if (root) { - for (device_t *dev = root->first_subdevice(); dev != NULL; dev = dev->next()) { + for (device_t *dev = root->first_subdevice(); dev != nullptr; dev = dev->next()) { if (dev && dev->configured() && dev->started()) { devs_table[dev->tag()] = dev; devtree_dfs(dev, devs_table); @@ -447,7 +447,7 @@ luabridge::LuaRef lua_engine::l_dev_get_states(const device_t *d) device_t *dev = const_cast(d); lua_State *L = luaThis->m_lua_state; luabridge::LuaRef st_table = luabridge::LuaRef::newTable(L); - for (const device_state_entry *s = dev->state().state_first(); s != NULL; s = s->next()) { + for (const device_state_entry *s = dev->state().state_first(); s != nullptr; s = s->next()) { // XXX: refrain from exporting non-visible entries? if (s) { st_table[s->symbol()] = const_cast(s); @@ -723,7 +723,7 @@ int lua_engine::lua_screen::l_draw_text(lua_State *L) ui_manager &ui = sc->machine().ui(); ui.draw_text_full(&rc, msg, x, y , (1.0f - x), JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, textcolor, - UI_TEXT_BG_COLOR, NULL, NULL); + UI_TEXT_BG_COLOR, nullptr, nullptr); return 0; } @@ -733,13 +733,13 @@ void *lua_engine::checkparam(lua_State *L, int idx, const char *tname) const char *name; if(!lua_getmetatable(L, idx)) - return 0; + return nullptr; lua_rawget(L, LUA_REGISTRYINDEX); name = lua_tostring(L, -1); if(!name || strcmp(name, tname)) { lua_pop(L, 1); - return 0; + return nullptr; } lua_pop(L, 1); @@ -785,7 +785,7 @@ int lua_engine::luaopen_ioport(lua_State *L) { static const struct luaL_Reg ioport_funcs [] = { { "write", l_ioport_write }, - { NULL, NULL } /* sentinel */ + { nullptr, nullptr } /* sentinel */ }; luaL_newmetatable(L, tname_ioport); @@ -875,7 +875,7 @@ static void *serve_lua(void *param) lua_engine::lua_engine() { - m_machine = NULL; + m_machine = nullptr; luaThis = this; m_lua_state = luaL_newstate(); /* create state */ output_notifier_set = false; @@ -908,7 +908,7 @@ lua_engine::~lua_engine() void lua_engine::update_machine() { lua_newtable(m_lua_state); - if (m_machine!=NULL) + if (m_machine!=nullptr) { // Create the ioport array ioport_port *port = machine().ioport().first_port(); @@ -1032,7 +1032,7 @@ void lua_engine::start_console() bool lua_engine::frame_hook() { bool is_cb_hooked = false; - if (m_machine != NULL) { + if (m_machine != nullptr) { // invoke registered callback (if any) is_cb_hooked = hook_frame_cb.active(); if (is_cb_hooked) { diff --git a/src/emu/luaengine.h b/src/emu/luaengine.h index 7f9018d3759..9bc6275100e 100644 --- a/src/emu/luaengine.h +++ b/src/emu/luaengine.h @@ -46,7 +46,7 @@ public: void periodic_check(); bool frame_hook(); - void resume(lua_State *L, int nparam = 0, lua_State *root = NULL); + void resume(lua_State *L, int nparam = 0, lua_State *root = nullptr); void set_machine(running_machine *machine) { m_machine = machine; update_machine(); } private: struct hook { @@ -57,7 +57,7 @@ private: void set(lua_State *L, int idx); lua_State *precall(); void call(lua_engine *engine, lua_State *T, int nparam); - bool active() const { return L != NULL; } + bool active() const { return L != nullptr; } }; static const char *const tname_ioport; diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 375ff153a48..16b11f5a970 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -115,13 +115,13 @@ osd_interface &running_machine::osd() const //------------------------------------------------- running_machine::running_machine(const machine_config &_config, machine_manager &manager) - : firstcpu(NULL), - primary_screen(NULL), + : firstcpu(nullptr), + primary_screen(nullptr), debug_flags(0), - romload_data(NULL), - ui_input_data(NULL), - debugcpu_data(NULL), - generic_machine_data(NULL), + romload_data(nullptr), + ui_input_data(nullptr), + debugcpu_data(nullptr), + generic_machine_data(nullptr), m_config(_config), m_system(_config.gamedrv()), m_manager(manager), @@ -129,14 +129,14 @@ running_machine::running_machine(const machine_config &_config, machine_manager m_paused(false), m_hard_reset_pending(false), m_exit_pending(false), - m_soft_reset_timer(NULL), + m_soft_reset_timer(nullptr), m_rand_seed(0x9d14abd7), m_ui_active(_config.options().ui_active()), m_basename(_config.gamedrv().name), m_sample_rate(_config.options().sample_rate()), m_saveload_schedule(SLS_NONE), m_saveload_schedule_time(attotime::zero), - m_saveload_searchpath(NULL), + m_saveload_searchpath(nullptr), m_save(*this), m_memory(*this), @@ -148,12 +148,12 @@ running_machine::running_machine(const machine_config &_config, machine_manager // set the machine on all devices device_iterator iter(root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->set_machine(*this); // find devices - for (device_t *device = iter.first(); device != NULL; device = iter.next()) - if (dynamic_cast(device) != NULL) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) + if (dynamic_cast(device) != nullptr) { firstcpu = downcast(device); break; @@ -185,10 +185,10 @@ running_machine::~running_machine() const char *running_machine::describe_context() { device_execute_interface *executing = m_scheduler.currently_executing(); - if (executing != NULL) + if (executing != nullptr) { cpu_device *cpu = dynamic_cast(&executing->device()); - if (cpu != NULL) + if (cpu != nullptr) strprintf(m_context, "'%s' (%s)", cpu->tag(), core_i64_format(cpu->pc(), cpu->space(AS_PROGRAM).logaddrchars(), cpu->is_octal())); } else @@ -257,7 +257,7 @@ void running_machine::start() // initialize the watchdog m_watchdog_counter = 0; m_watchdog_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::watchdog_fired), this)); - if (config().m_watchdog_vblank_count != 0 && primary_screen != NULL) + if (config().m_watchdog_vblank_count != 0 && primary_screen != nullptr) primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(running_machine::watchdog_vblank), this)); save().save_item(NAME(m_watchdog_enabled)); save().save_item(NAME(m_watchdog_counter)); @@ -530,7 +530,7 @@ void running_machine::schedule_soft_reset() std::string running_machine::get_statename(const char *option) { std::string statename_str(""); - if (option == NULL || option[0] == 0) + if (option == nullptr || option[0] == 0) statename_str.assign("%g"); else statename_str.assign(option); @@ -578,7 +578,7 @@ std::string running_machine::get_statename(const char *option) // verify that there is such a device for this system image_interface_iterator iter(root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { // get the device name std::string tempdevname(image->brief_instance_name()); @@ -587,7 +587,7 @@ std::string running_machine::get_statename(const char *option) if (devname_str.compare(tempdevname) == 0) { // verify that such a device has an image mounted - if (image->basename_noext() != NULL) + if (image->basename_noext() != nullptr) { std::string filename(image->basename_noext()); @@ -624,7 +624,7 @@ void running_machine::set_saveload_filename(const char *filename) // free any existing request and allocate a copy of the requested name if (osd_is_absolute_path(filename)) { - m_saveload_searchpath = NULL; + m_saveload_searchpath = nullptr; m_saveload_pending_file.assign(filename); } else @@ -794,7 +794,7 @@ void running_machine::add_logerror_callback(logerror_callback callback) void running_machine::popmessage(const char *format, ...) const { // if the format is NULL, it is a signal to clear the popmessage - if (format == NULL) + if (format == nullptr) ui().popup_time(0, " "); // otherwise, generate the buffer and call the UI to display the message @@ -978,7 +978,7 @@ void running_machine::handle_saveload() // unschedule the operation cancel: m_saveload_pending_file.clear(); - m_saveload_searchpath = NULL; + m_saveload_searchpath = nullptr; m_saveload_schedule = SLS_NONE; } @@ -1094,7 +1094,7 @@ void running_machine::watchdog_vblank(screen_device &screen, bool vblank_state) void running_machine::logfile_callback(const running_machine &machine, const char *buffer) { - if (machine.m_logfile != NULL) + if (machine.m_logfile != nullptr) machine.m_logfile->puts(buffer); } @@ -1112,14 +1112,14 @@ void running_machine::start_all_devices() // iterate over all devices int failed_starts = 0; device_iterator iter(root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (!device->started()) { // attempt to start the device, catching any expected exceptions try { // if the device doesn't have a machine yet, set it first - if (device->m_machine == NULL) + if (device->m_machine == nullptr) device->set_machine(*this); // now start the device @@ -1170,7 +1170,7 @@ void running_machine::stop_all_devices() // iterate over devices and stop them device_iterator iter(root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->stop(); } @@ -1183,7 +1183,7 @@ void running_machine::stop_all_devices() void running_machine::presave_all_devices() { device_iterator iter(root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->pre_save(); } @@ -1196,7 +1196,7 @@ void running_machine::presave_all_devices() void running_machine::postload_all_devices() { device_iterator iter(root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) device->post_load(); } @@ -1210,14 +1210,14 @@ const char *running_machine::image_parent_basename(device_t *device) device_t *dev = device; while(dev != &root_device()) { - device_image_interface *intf = NULL; - if (dev!=NULL && dev->interface(intf)) + device_image_interface *intf = nullptr; + if (dev!=nullptr && dev->interface(intf)) { return intf->basename_noext(); } dev = dev->owner(); } - return NULL; + return nullptr; } /*------------------------------------------------- @@ -1237,7 +1237,7 @@ std::string &running_machine::nvram_filename(std::string &result, device_t &devi { // add per software nvrams into one folder const char *software = image_parent_basename(&device); - if (software!=NULL && strlen(software)>0) + if (software!=nullptr && strlen(software)>0) { result.append(PATH_SEPARATOR).append(software); } @@ -1256,7 +1256,7 @@ std::string &running_machine::nvram_filename(std::string &result, device_t &devi void running_machine::nvram_load() { nvram_interface_iterator iter(root_device()); - for (device_nvram_interface *nvram = iter.first(); nvram != NULL; nvram = iter.next()) + for (device_nvram_interface *nvram = iter.first(); nvram != nullptr; nvram = iter.next()) { std::string filename; emu_file file(options().nvram_directory(), OPEN_FLAG_READ); @@ -1278,7 +1278,7 @@ void running_machine::nvram_load() void running_machine::nvram_save() { nvram_interface_iterator iter(root_device()); - for (device_nvram_interface *nvram = iter.first(); nvram != NULL; nvram = iter.next()) + for (device_nvram_interface *nvram = iter.first(); nvram != nullptr; nvram = iter.next()) { std::string filename; emu_file file(options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -1298,7 +1298,7 @@ void running_machine::nvram_save() //------------------------------------------------- running_machine::notifier_callback_item::notifier_callback_item(machine_notify_delegate func) - : m_func(func) + : m_func(std::move(func)) { } diff --git a/src/emu/machine.h b/src/emu/machine.h index 9f3ed6de3e8..755e8466384 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -253,8 +253,8 @@ private: void set_saveload_filename(const char *filename); std::string get_statename(const char *statename_opt); void handle_saveload(); - void soft_reset(void *ptr = NULL, INT32 param = 0); - void watchdog_fired(void *ptr = NULL, INT32 param = 0); + void soft_reset(void *ptr = nullptr, INT32 param = 0); + void watchdog_fired(void *ptr = nullptr, INT32 param = 0); void watchdog_vblank(screen_device &screen, bool vblank_state); const char *image_parent_basename(device_t *device); std::string &nvram_filename(std::string &result, device_t &device); diff --git a/src/emu/machine/generic.cpp b/src/emu/machine/generic.cpp index 636b65f3581..2f4b94fb718 100644 --- a/src/emu/machine/generic.cpp +++ b/src/emu/machine/generic.cpp @@ -128,7 +128,7 @@ static void counters_load(running_machine &machine, int config_type, xml_data_no return; /* might not have any data */ - if (parentnode == NULL) + if (parentnode == nullptr) return; /* iterate over coins nodes */ @@ -141,7 +141,7 @@ static void counters_load(running_machine &machine, int config_type, xml_data_no /* get the single tickets node */ ticketnode = xml_get_sibling(parentnode->child, "tickets"); - if (ticketnode != NULL) + if (ticketnode != nullptr) state->dispensed_tickets = xml_get_attribute_int(ticketnode, "number", 0); } @@ -164,8 +164,8 @@ static void counters_save(running_machine &machine, int config_type, xml_data_no for (i = 0; i < COIN_COUNTERS; i++) if (state->coin_count[i] != 0) { - xml_data_node *coinnode = xml_add_child(parentnode, "coins", NULL); - if (coinnode != NULL) + xml_data_node *coinnode = xml_add_child(parentnode, "coins", nullptr); + if (coinnode != nullptr) { xml_set_attribute_int(coinnode, "index", i); xml_set_attribute_int(coinnode, "number", state->coin_count[i]); @@ -175,8 +175,8 @@ static void counters_save(running_machine &machine, int config_type, xml_data_no /* output tickets */ if (state->dispensed_tickets != 0) { - xml_data_node *tickets = xml_add_child(parentnode, "tickets", NULL); - if (tickets != NULL) + xml_data_node *tickets = xml_add_child(parentnode, "tickets", nullptr); + if (tickets != nullptr) xml_set_attribute_int(tickets, "number", state->dispensed_tickets); } } diff --git a/src/emu/mame.cpp b/src/emu/mame.cpp index 8ec83710330..f3ca9059a8d 100644 --- a/src/emu/mame.cpp +++ b/src/emu/mame.cpp @@ -81,7 +81,7 @@ // MACHINE MANAGER //************************************************************************** -machine_manager* machine_manager::m_manager = NULL; +machine_manager* machine_manager::m_manager = nullptr; osd_interface &machine_manager::osd() const { @@ -111,8 +111,8 @@ machine_manager::machine_manager(emu_options &options,osd_interface &osd) : m_osd(osd), m_options(options), m_lua(global_alloc(lua_engine)), - m_new_driver_pending(NULL), - m_machine(NULL) + m_new_driver_pending(nullptr), + m_machine(nullptr) { } @@ -124,7 +124,7 @@ machine_manager::machine_manager(emu_options &options,osd_interface &osd) machine_manager::~machine_manager() { global_free(m_lua); - m_manager = NULL; + m_manager = nullptr; } @@ -169,11 +169,11 @@ int machine_manager::execute() m_lua->initialize(); while (error == MAMERR_NONE && !exit_pending) { - m_new_driver_pending = NULL; + m_new_driver_pending = nullptr; // if no driver, use the internal empty driver const game_driver *system = m_options.system(); - if (system == NULL) + if (system == nullptr) { system = &GAME_NAME(___empty); if (firstgame) @@ -191,7 +191,7 @@ int machine_manager::execute() } // otherwise, perform validity checks before anything else - if (system != NULL) + if (system != nullptr) { validity_checker valid(m_options); valid.check_shared_source(*system); @@ -237,7 +237,7 @@ int machine_manager::execute() exit_pending = true; // machine will go away when we exit scope - set_machine(NULL); + set_machine(nullptr); } // return an error return error; diff --git a/src/emu/mconfig.cpp b/src/emu/mconfig.cpp index 8bee637c50e..1d3b5a2effd 100644 --- a/src/emu/mconfig.cpp +++ b/src/emu/mconfig.cpp @@ -26,17 +26,17 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) m_watchdog_vblank_count(0), m_watchdog_time(attotime::zero), m_force_no_drc(false), - m_default_layout(NULL), + m_default_layout(nullptr), m_gamedrv(gamedrv), m_options(options) { // construct the config - (*gamedrv.machine_config)(*this, NULL, NULL); + (*gamedrv.machine_config)(*this, nullptr, nullptr); bool is_selected_driver = core_stricmp(gamedrv.name,options.system_name())==0; // intialize slot devices - make sure that any required devices have been allocated slot_interface_iterator slotiter(root_device()); - for (device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next()) + for (device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next()) { device_t &owner = slot->device(); std::string temp; @@ -45,7 +45,7 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) if (!is_selected_driver || !options.exists(owner.tag()+1)) selval = slot->default_option(); - if (selval != NULL && *selval != 0) + if (selval != nullptr && *selval != 0) { const device_slot_option *option = slot->option(selval); @@ -54,11 +54,11 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) device_t *new_dev = device_add(&owner, option->name(), option->devtype(), option->clock()); const char *default_bios = option->default_bios(); - if (default_bios != NULL) + if (default_bios != nullptr) device_t::static_set_default_bios_tag(*new_dev, default_bios); machine_config_constructor additions = option->machine_config(); - if (additions != NULL) + if (additions != nullptr) (*additions)(const_cast(*this), new_dev, new_dev); const input_device_default *input_device_defaults = option->input_device_defaults(); @@ -75,7 +75,7 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) // then notify all devices that their configuration is complete device_iterator iter(root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) if (!device->configured()) device->config_complete(); } @@ -125,7 +125,7 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty assert(next != tag); std::string part(tag, next-tag); device_t *curdevice; - for (curdevice = owner->m_subdevice_list.first(); curdevice != NULL; curdevice = curdevice->next()) + for (curdevice = owner->m_subdevice_list.first(); curdevice != nullptr; curdevice = curdevice->next()) if (part.compare(curdevice->m_basetag)==0) break; if (!curdevice) @@ -137,17 +137,17 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty assert(tag[0]); // if there's an owner, let the owner do the work - if (owner != NULL) + if (owner != nullptr) return owner->add_subdevice(type, tag, clock); // otherwise, allocate the device directly - assert(m_root_device == NULL); + assert(m_root_device == nullptr); m_root_device.reset((*type)(*this, tag, owner, clock)); // apply any machine configuration owned by the device now machine_config_constructor additions = m_root_device->machine_config_additions(); - if (additions != NULL) - (*additions)(*this, m_root_device.get(), NULL); + if (additions != nullptr) + (*additions)(*this, m_root_device.get(), nullptr); return m_root_device.get(); } @@ -160,9 +160,9 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty device_t *machine_config::device_replace(device_t *owner, const char *tag, device_type type, UINT32 clock) { // find the original device by this name (must exist) - assert(owner != NULL); + assert(owner != nullptr); device_t *device = owner->subdevice(tag); - if (device == NULL) + if (device == nullptr) { osd_printf_warning("Warning: attempting to replace non-existent device '%s'\n", tag); return device_add(owner, tag, type, clock); @@ -181,17 +181,17 @@ device_t *machine_config::device_replace(device_t *owner, const char *tag, devic device_t *machine_config::device_remove(device_t *owner, const char *tag) { // find the original device by this name (must exist) - assert(owner != NULL); + assert(owner != nullptr); device_t *device = owner->subdevice(tag); - if (device == NULL) + if (device == nullptr) { osd_printf_warning("Warning: attempting to remove non-existent device '%s'\n", tag); - return NULL; + return nullptr; } // let the device's owner do the work device->owner()->remove_subdevice(*device); - return NULL; + return nullptr; } @@ -203,10 +203,10 @@ device_t *machine_config::device_remove(device_t *owner, const char *tag) device_t *machine_config::device_find(device_t *owner, const char *tag) { // find the original device by this name (must exist) - assert(owner != NULL); + assert(owner != nullptr); device_t *device = owner->subdevice(tag); - assert(device != NULL); - if (device == NULL) + assert(device != nullptr); + if (device == nullptr) throw emu_fatalerror("Unable to find device '%s'\n", tag); // return the device diff --git a/src/emu/memarray.cpp b/src/emu/memarray.cpp index 94662f0c7b0..03161f000bf 100644 --- a/src/emu/memarray.cpp +++ b/src/emu/memarray.cpp @@ -20,13 +20,13 @@ //------------------------------------------------- memory_array::memory_array() - : m_base(NULL), + : m_base(nullptr), m_bytes(0), m_membits(0), m_endianness(ENDIANNESS_LITTLE), m_bytes_per_entry(0), - m_read_entry(NULL), - m_write_entry(NULL) + m_read_entry(nullptr), + m_write_entry(nullptr) { } @@ -38,7 +38,7 @@ memory_array::memory_array() void memory_array::set(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe) { // validate inputs - assert(base != NULL); + assert(base != nullptr); assert(bytes > 0); assert(membits == 8 || membits == 16 || membits == 32 || membits == 64); assert(bpe == 1 || bpe == 2 || bpe == 4); diff --git a/src/emu/memory.cpp b/src/emu/memory.cpp index 6f89681d5d3..598ffab9ac6 100644 --- a/src/emu/memory.cpp +++ b/src/emu/memory.cpp @@ -336,15 +336,15 @@ public: // construction/destruction handler_entry_read(UINT8 width, endianness_t endianness, UINT8 **rambaseptr) : handler_entry(width, endianness, rambaseptr), - m_ioport(NULL) + m_ioport(nullptr) { } - virtual void copy(handler_entry *entry); + virtual void copy(handler_entry *entry) override; // getters - virtual const char *name() const; - virtual const char *subunit_name(int entry) const; + virtual const char *name() const override; + virtual const char *subunit_name(int entry) const override; // configure delegate callbacks void set_delegate(read8_delegate delegate, UINT64 mask = 0); @@ -372,7 +372,7 @@ private: _UintType read_stub_ioport(address_space &space, offs_t offset, _UintType mask) { return m_ioport->read(); } // internal helper - virtual void remove_subunit(int entry); + virtual void remove_subunit(int entry) override; // internal state access_handler m_read; @@ -399,15 +399,15 @@ public: // construction/destruction handler_entry_write(UINT8 width, endianness_t endianness, UINT8 **rambaseptr) : handler_entry(width, endianness, rambaseptr), - m_ioport(NULL) + m_ioport(nullptr) { } - virtual void copy(handler_entry *entry); + virtual void copy(handler_entry *entry) override; // getters - virtual const char *name() const; - virtual const char *subunit_name(int entry) const; + virtual const char *name() const override; + virtual const char *subunit_name(int entry) const override; // configure delegate callbacks void set_delegate(write8_delegate delegate, UINT64 mask = 0); @@ -435,7 +435,7 @@ private: void write_stub_ioport(address_space &space, offs_t offset, _UintType data, _UintType mask) { m_ioport->write(data, mask); } // internal helper - virtual void remove_subunit(int entry); + virtual void remove_subunit(int entry) override; // internal state access_handler m_write; @@ -450,12 +450,12 @@ class handler_entry_setoffset : public handler_entry public: // construction/destruction handler_entry_setoffset() - : handler_entry(0, ENDIANNESS_LITTLE, NULL) + : handler_entry(0, ENDIANNESS_LITTLE, nullptr) { } - const char *name() const { return m_setoffset.name(); } - const char *subunit_name(int entry) const { return "no subunit"; } + const char *name() const override { return m_setoffset.name(); } + const char *subunit_name(int entry) const override { return "no subunit"; } // Call through only if the setoffset handler has been late-bound before // (i.e. if it was declared in the address map) @@ -468,7 +468,7 @@ private: setoffset_delegate m_setoffset; // We do not have subunits for setoffset // Accordingly, we need not implement unused functions. - void remove_subunit(int entry) { } + void remove_subunit(int entry) override { } }; // ======================> handler_entry_proxy @@ -479,19 +479,19 @@ template class handler_entry_proxy { public: - handler_entry_proxy(const std::list<_HandlerEntry *> &_handlers, UINT64 _mask) : handlers(_handlers), mask(_mask) {} + handler_entry_proxy(std::list<_HandlerEntry *> _handlers, UINT64 _mask) : handlers(std::move(_handlers)), mask(_mask) {} handler_entry_proxy(const handler_entry_proxy<_HandlerEntry> &hep) : handlers(hep.handlers), mask(hep.mask) {} // forward delegate callbacks configuration template void set_delegate(_delegate delegate) const { - for (typename std::list<_HandlerEntry *>::const_iterator i = handlers.begin(); i != handlers.end(); ++i) - (*i)->set_delegate(delegate, mask); + for (const auto & elem : handlers) + (elem)->set_delegate(delegate, mask); } // forward I/O port access configuration void set_ioport(ioport_port &ioport) const { - for (typename std::list<_HandlerEntry *>::const_iterator i = handlers.begin(); i != handlers.end(); ++i) - (*i)->set_ioport(ioport); + for (const auto & elem : handlers) + (elem)->set_ioport(ioport); } private: @@ -653,7 +653,7 @@ public: virtual ~address_table_read(); // getters - virtual handler_entry &handler(UINT32 index) const; + virtual handler_entry &handler(UINT32 index) const override; handler_entry_read &handler_read(UINT32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } // range getter @@ -726,7 +726,7 @@ public: virtual ~address_table_write(); // getters - virtual handler_entry &handler(UINT32 index) const; + virtual handler_entry &handler(UINT32 index) const override; handler_entry_write &handler_write(UINT32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } // range getter @@ -792,8 +792,8 @@ public: : address_table(space, large) { // allocate handlers for each entry, prepopulating the bankptrs for banks - for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++) - m_handlers[entrynum] = std::make_unique(); + for (auto & elem : m_handlers) + elem = std::make_unique(); // Watchpoints and unmap states do not make sense for setoffset m_handlers[STATIC_NOP]->set_delegate(setoffset_delegate(FUNC(address_table_setoffset::nop_so), this)); @@ -804,7 +804,7 @@ public: { } - handler_entry &handler(UINT32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } + handler_entry &handler(UINT32 index) const override { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } handler_entry_setoffset &handler_setoffset(UINT32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } // range getter @@ -997,16 +997,16 @@ public: } // accessors - virtual address_table_read &read() { return m_read; } - virtual address_table_write &write() { return m_write; } - virtual address_table_setoffset &setoffset() { return m_setoffset; } + virtual address_table_read &read() override { return m_read; } + virtual address_table_write &write() override { return m_write; } + virtual address_table_setoffset &setoffset() override { return m_setoffset; } // watchpoint control - virtual void enable_read_watchpoints(bool enable = true) { m_read.enable_watchpoints(enable); } - virtual void enable_write_watchpoints(bool enable = true) { m_write.enable_watchpoints(enable); } + virtual void enable_read_watchpoints(bool enable = true) override { m_read.enable_watchpoints(enable); } + virtual void enable_write_watchpoints(bool enable = true) override { m_write.enable_watchpoints(enable); } // generate accessor table - virtual void accessors(data_accessors &accessors) const + virtual void accessors(data_accessors &accessors) const override { accessors.read_byte = reinterpret_cast(&read_byte_static); accessors.read_word = reinterpret_cast(&read_word_static); @@ -1025,7 +1025,7 @@ public: } // return a pointer to the read bank, or NULL if none - virtual void *get_read_ptr(offs_t byteaddress) + virtual void *get_read_ptr(offs_t byteaddress) override { // perform the lookup byteaddress &= m_bytemask; @@ -1034,12 +1034,12 @@ public: // 8-bit case: RAM/ROM if (entry > STATIC_BANKMAX) - return NULL; + return nullptr; return handler.ramptr(handler.byteoffset(byteaddress)); } // return a pointer to the write bank, or NULL if none - virtual void *get_write_ptr(offs_t byteaddress) + virtual void *get_write_ptr(offs_t byteaddress) override { // perform the lookup byteaddress &= m_bytemask; @@ -1048,7 +1048,7 @@ public: // 8-bit case: RAM/ROM if (entry > STATIC_BANKMAX) - return NULL; + return nullptr; return handler.ramptr(handler.byteoffset(byteaddress)); } @@ -1400,7 +1400,7 @@ public: // Allows to announce a pending read or write operation on this address. // The user of the address_space calls a set_address operation which leads // to some particular set_offset operation for an entry in the address map. - void set_address(offs_t address) + void set_address(offs_t address) override { offs_t byteaddress = address & m_bytemask; UINT32 entry = setoffset_lookup(byteaddress); @@ -1411,33 +1411,33 @@ public: } // virtual access to these functions - UINT8 read_byte(offs_t address) { return (NATIVE_BITS == 8) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xff); } - UINT16 read_word(offs_t address) { return (NATIVE_BITS == 16) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffff); } - UINT16 read_word(offs_t address, UINT16 mask) { return read_direct(address, mask); } - UINT16 read_word_unaligned(offs_t address) { return read_direct(address, 0xffff); } - UINT16 read_word_unaligned(offs_t address, UINT16 mask) { return read_direct(address, mask); } - UINT32 read_dword(offs_t address) { return (NATIVE_BITS == 32) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffffffff); } - UINT32 read_dword(offs_t address, UINT32 mask) { return read_direct(address, mask); } - UINT32 read_dword_unaligned(offs_t address) { return read_direct(address, 0xffffffff); } - UINT32 read_dword_unaligned(offs_t address, UINT32 mask) { return read_direct(address, mask); } - UINT64 read_qword(offs_t address) { return (NATIVE_BITS == 64) ? read_native(address & ~NATIVE_MASK) : read_direct(address, U64(0xffffffffffffffff)); } - UINT64 read_qword(offs_t address, UINT64 mask) { return read_direct(address, mask); } - UINT64 read_qword_unaligned(offs_t address) { return read_direct(address, U64(0xffffffffffffffff)); } - UINT64 read_qword_unaligned(offs_t address, UINT64 mask) { return read_direct(address, mask); } - - void write_byte(offs_t address, UINT8 data) { if (NATIVE_BITS == 8) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xff); } - void write_word(offs_t address, UINT16 data) { if (NATIVE_BITS == 16) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffff); } - void write_word(offs_t address, UINT16 data, UINT16 mask) { write_direct(address, data, mask); } - void write_word_unaligned(offs_t address, UINT16 data) { write_direct(address, data, 0xffff); } - void write_word_unaligned(offs_t address, UINT16 data, UINT16 mask) { write_direct(address, data, mask); } - void write_dword(offs_t address, UINT32 data) { if (NATIVE_BITS == 32) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffffffff); } - void write_dword(offs_t address, UINT32 data, UINT32 mask) { write_direct(address, data, mask); } - void write_dword_unaligned(offs_t address, UINT32 data) { write_direct(address, data, 0xffffffff); } - void write_dword_unaligned(offs_t address, UINT32 data, UINT32 mask) { write_direct(address, data, mask); } - void write_qword(offs_t address, UINT64 data) { if (NATIVE_BITS == 64) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, U64(0xffffffffffffffff)); } - void write_qword(offs_t address, UINT64 data, UINT64 mask) { write_direct(address, data, mask); } - void write_qword_unaligned(offs_t address, UINT64 data) { write_direct(address, data, U64(0xffffffffffffffff)); } - void write_qword_unaligned(offs_t address, UINT64 data, UINT64 mask) { write_direct(address, data, mask); } + UINT8 read_byte(offs_t address) override { return (NATIVE_BITS == 8) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xff); } + UINT16 read_word(offs_t address) override { return (NATIVE_BITS == 16) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffff); } + UINT16 read_word(offs_t address, UINT16 mask) override { return read_direct(address, mask); } + UINT16 read_word_unaligned(offs_t address) override { return read_direct(address, 0xffff); } + UINT16 read_word_unaligned(offs_t address, UINT16 mask) override { return read_direct(address, mask); } + UINT32 read_dword(offs_t address) override { return (NATIVE_BITS == 32) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffffffff); } + UINT32 read_dword(offs_t address, UINT32 mask) override { return read_direct(address, mask); } + UINT32 read_dword_unaligned(offs_t address) override { return read_direct(address, 0xffffffff); } + UINT32 read_dword_unaligned(offs_t address, UINT32 mask) override { return read_direct(address, mask); } + UINT64 read_qword(offs_t address) override { return (NATIVE_BITS == 64) ? read_native(address & ~NATIVE_MASK) : read_direct(address, U64(0xffffffffffffffff)); } + UINT64 read_qword(offs_t address, UINT64 mask) override { return read_direct(address, mask); } + UINT64 read_qword_unaligned(offs_t address) override { return read_direct(address, U64(0xffffffffffffffff)); } + UINT64 read_qword_unaligned(offs_t address, UINT64 mask) override { return read_direct(address, mask); } + + void write_byte(offs_t address, UINT8 data) override { if (NATIVE_BITS == 8) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xff); } + void write_word(offs_t address, UINT16 data) override { if (NATIVE_BITS == 16) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffff); } + void write_word(offs_t address, UINT16 data, UINT16 mask) override { write_direct(address, data, mask); } + void write_word_unaligned(offs_t address, UINT16 data) override { write_direct(address, data, 0xffff); } + void write_word_unaligned(offs_t address, UINT16 data, UINT16 mask) override { write_direct(address, data, mask); } + void write_dword(offs_t address, UINT32 data) override { if (NATIVE_BITS == 32) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffffffff); } + void write_dword(offs_t address, UINT32 data, UINT32 mask) override { write_direct(address, data, mask); } + void write_dword_unaligned(offs_t address, UINT32 data) override { write_direct(address, data, 0xffffffff); } + void write_dword_unaligned(offs_t address, UINT32 data, UINT32 mask) override { write_direct(address, data, mask); } + void write_qword(offs_t address, UINT64 data) override { if (NATIVE_BITS == 64) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, U64(0xffffffffffffffff)); } + void write_qword(offs_t address, UINT64 data, UINT64 mask) override { write_direct(address, data, mask); } + void write_qword_unaligned(offs_t address, UINT64 data) override { write_direct(address, data, U64(0xffffffffffffffff)); } + void write_qword_unaligned(offs_t address, UINT64 data, UINT64 mask) override { write_direct(address, data, mask); } // static access to these functions static UINT8 read_byte_static(this_type &space, offs_t address) { return (NATIVE_BITS == 8) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xff); } @@ -1523,33 +1523,33 @@ void memory_manager::initialize() { // loop over devices and spaces within each device memory_interface_iterator iter(machine().root_device()); - for (device_memory_interface *memory = iter.first(); memory != NULL; memory = iter.next()) + for (device_memory_interface *memory = iter.first(); memory != nullptr; memory = iter.next()) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) { // if there is a configuration for this space, we need an address space const address_space_config *spaceconfig = memory->space_config(spacenum); - if (spaceconfig != NULL) + if (spaceconfig != nullptr) m_spacelist.append(address_space::allocate(*this, *spaceconfig, *memory, spacenum)); } // construct and preprocess the address_map for each space - for (address_space *space = m_spacelist.first(); space != NULL; space = space->next()) + for (address_space *space = m_spacelist.first(); space != nullptr; space = space->next()) space->prepare_map(); // create the handlers from the resulting address maps - for (address_space *space = m_spacelist.first(); space != NULL; space = space->next()) + for (address_space *space = m_spacelist.first(); space != nullptr; space = space->next()) space->populate_from_map(); // allocate memory needed to back each address space - for (address_space *space = m_spacelist.first(); space != NULL; space = space->next()) + for (address_space *space = m_spacelist.first(); space != nullptr; space = space->next()) space->allocate_memory(); // find all the allocated pointers - for (address_space *space = m_spacelist.first(); space != NULL; space = space->next()) + for (address_space *space = m_spacelist.first(); space != nullptr; space = space->next()) space->locate_memory(); // disable logging of unmapped access when no one receives it - for (address_space *space = m_spacelist.first(); space != NULL; space = space->next()) + for (address_space *space = m_spacelist.first(); space != nullptr; space = space->next()) { if (!machine().options().log() && !machine().options().oslog() && !(machine().debug_flags & DEBUG_FLAG_ENABLED)) space->set_log_unmap(false); @@ -1574,11 +1574,11 @@ void memory_manager::initialize() void memory_manager::dump(FILE *file) { // skip if we can't open the file - if (file == NULL) + if (file == nullptr) return; // loop over address spaces - for (address_space *space = m_spacelist.first(); space != NULL; space = space->next()) + for (address_space *space = m_spacelist.first(); space != nullptr; space = space->next()) { fprintf(file, "\n\n" "====================================================\n" @@ -1604,7 +1604,7 @@ memory_region *memory_manager::region_alloc(const char *name, UINT32 length, UIN osd_printf_verbose("Region '%s' created\n", name); // make sure we don't have a region of the same name; also find the end of the list memory_region *info = m_regionlist.find(name); - if (info != NULL) + if (info != nullptr) fatalerror("region_alloc called with duplicate region name \"%s\"\n", name); // allocate the region @@ -1647,7 +1647,7 @@ static void generate_memdump(running_machine &machine) void memory_manager::bank_reattach() { // for each non-anonymous bank, explicitly reset its entry - for (memory_bank *bank = m_banklist.first(); bank != NULL; bank = bank->next()) + for (memory_bank *bank = m_banklist.first(); bank != nullptr; bank = bank->next()) if (!bank->anonymous() && bank->entry() != BANK_ENTRY_UNSPECIFIED) bank->set_entry(bank->entry()); } @@ -1663,7 +1663,7 @@ void memory_manager::bank_reattach() //------------------------------------------------- address_space::address_space(memory_manager &manager, device_memory_interface &memory, address_spacenum spacenum, bool large) - : m_next(NULL), + : m_next(nullptr), m_config(*memory.space_config(spacenum)), m_device(memory.device()), m_addrmask(0xffffffffUL >> (32 - m_config.m_addrbus_width)), @@ -1805,8 +1805,8 @@ inline void address_space::adjust_addresses(offs_t &start, offs_t &end, offs_t & void address_space::prepare_map() { - memory_region *devregion = (m_spacenum == AS_0) ? machine().root_device().memregion(m_device.tag()) : NULL; - UINT32 devregionsize = (devregion != NULL) ? devregion->bytes() : 0; + memory_region *devregion = (m_spacenum == AS_0) ? machine().root_device().memregion(m_device.tag()) : nullptr; + UINT32 devregionsize = (devregion != nullptr) ? devregion->bytes() : 0; // allocate the address map m_map = std::make_unique(m_device, m_spacenum); @@ -1823,7 +1823,7 @@ void address_space::prepare_map() } // make a pass over the address map, adjusting for the device and getting memory pointers - for (address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next()) + for (address_map_entry *entry = m_map->m_entrylist.first(); entry != nullptr; entry = entry->next()) { // computed adjusted addresses first entry->m_bytestart = entry->m_addrstart; @@ -1833,20 +1833,20 @@ void address_space::prepare_map() adjust_addresses(entry->m_bytestart, entry->m_byteend, entry->m_bytemask, entry->m_bytemirror); // if we have a share entry, add it to our map - if (entry->m_share != NULL) + if (entry->m_share != nullptr) { // if we can't find it, add it to our map std::string fulltag = entry->m_devbase.subtag(entry->m_share); - if (manager().m_sharelist.find(fulltag.c_str()) == NULL) + if (manager().m_sharelist.find(fulltag.c_str()) == nullptr) { VPRINTF(("Creating share '%s' of length 0x%X\n", fulltag.c_str(), entry->m_byteend + 1 - entry->m_bytestart)); - memory_share *share = global_alloc(memory_share(m_map->m_databits, entry->m_byteend + 1 - entry->m_bytestart, endianness())); + auto share = global_alloc(memory_share(m_map->m_databits, entry->m_byteend + 1 - entry->m_bytestart, endianness())); manager().m_sharelist.append(fulltag.c_str(), *share); } } // if this is a ROM handler without a specified region, attach it to the implicit region - if (m_spacenum == AS_0 && entry->m_read.m_type == AMH_ROM && entry->m_region == NULL) + if (m_spacenum == AS_0 && entry->m_read.m_type == AMH_ROM && entry->m_region == nullptr) { // make sure it fits within the memory region before doing so, however if (entry->m_byteend < devregionsize) @@ -1857,14 +1857,14 @@ void address_space::prepare_map() } // validate adjusted addresses against implicit regions - if (entry->m_region != NULL && entry->m_share == NULL) + if (entry->m_region != nullptr && entry->m_share == nullptr) { // determine full tag std::string fulltag = entry->m_devbase.subtag(entry->m_region); // find the region memory_region *region = machine().root_device().memregion(fulltag.c_str()); - if (region == NULL) + if (region == nullptr) fatalerror("Error: device '%s' %s space memory map entry %X-%X references non-existant region \"%s\"\n", m_device.tag(), m_name, entry->m_addrstart, entry->m_addrend, entry->m_region); // validate the region @@ -1873,7 +1873,7 @@ void address_space::prepare_map() } // convert any region-relative entries to their memory pointers - if (entry->m_region != NULL) + if (entry->m_region != nullptr) { // determine full tag std::string fulltag = entry->m_devbase.subtag(entry->m_region); @@ -1898,15 +1898,15 @@ void address_space::prepare_map() void address_space::populate_from_map(address_map *map) { // no map specified, use the space-specific one - if (map == NULL) + if (map == nullptr) map = m_map.get(); // no map, nothing to do - if (map == NULL) + if (map == nullptr) return; // install the handlers, using the original, unadjusted memory map - const address_map_entry *last_entry = NULL; + const address_map_entry *last_entry = nullptr; while (last_entry != map->m_entrylist.first()) { // find the entry before the last one we processed @@ -1944,7 +1944,7 @@ void address_space::populate_map_entry(const address_map_entry &entry, read_or_w // fall through to the RAM case otherwise case AMH_RAM: - install_ram_generic(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, readorwrite, NULL); + install_ram_generic(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, readorwrite, nullptr); break; case AMH_NOP: @@ -1976,14 +1976,14 @@ void address_space::populate_map_entry(const address_map_entry &entry, read_or_w case AMH_PORT: install_readwrite_port(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, - (readorwrite == ROW_READ) ? data.m_tag : NULL, - (readorwrite == ROW_WRITE) ? data.m_tag : NULL); + (readorwrite == ROW_READ) ? data.m_tag : nullptr, + (readorwrite == ROW_WRITE) ? data.m_tag : nullptr); break; case AMH_BANK: install_bank_generic(entry.m_addrstart, entry.m_addrend, entry.m_addrmask, entry.m_addrmirror, - (readorwrite == ROW_READ) ? data.m_tag : NULL, - (readorwrite == ROW_WRITE) ? data.m_tag : NULL); + (readorwrite == ROW_READ) ? data.m_tag : nullptr, + (readorwrite == ROW_WRITE) ? data.m_tag : nullptr); break; case AMH_DEVICE_SUBMAP: @@ -2014,22 +2014,22 @@ void address_space::allocate_memory() // make a first pass over the memory map and track blocks with hardcoded pointers // we do this to make sure they are found by space_find_backing_memory first memory_block *prev_memblock_tail = blocklist.last(); - for (address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next()) - if (entry->m_memory != NULL) + for (address_map_entry *entry = m_map->m_entrylist.first(); entry != nullptr; entry = entry->next()) + if (entry->m_memory != nullptr) blocklist.append(*global_alloc(memory_block(*this, entry->m_bytestart, entry->m_byteend, entry->m_memory))); // loop over all blocks just allocated and assign pointers from them - address_map_entry *unassigned = NULL; - memory_block *first_new_block = (prev_memblock_tail != NULL) ? prev_memblock_tail->next() : blocklist.first(); - for (memory_block *memblock = first_new_block; memblock != NULL; memblock = memblock->next()) + address_map_entry *unassigned = nullptr; + memory_block *first_new_block = (prev_memblock_tail != nullptr) ? prev_memblock_tail->next() : blocklist.first(); + for (memory_block *memblock = first_new_block; memblock != nullptr; memblock = memblock->next()) unassigned = block_assign_intersecting(memblock->bytestart(), memblock->byteend(), memblock->data()); // if we don't have an unassigned pointer yet, try to find one - if (unassigned == NULL) - unassigned = block_assign_intersecting(~0, 0, NULL); + if (unassigned == nullptr) + unassigned = block_assign_intersecting(~0, 0, nullptr); // loop until we've assigned all memory in this space - while (unassigned != NULL) + while (unassigned != nullptr) { // work in MEMORY_BLOCK_CHUNK-sized chunks offs_t curblockstart = unassigned->m_bytestart / MEMORY_BLOCK_CHUNK; @@ -2042,8 +2042,8 @@ void address_space::allocate_memory() changed = false; // scan for unmapped blocks in the adjusted map - for (address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next()) - if (entry->m_memory == NULL && entry != unassigned && needs_backing_store(entry)) + for (address_map_entry *entry = m_map->m_entrylist.first(); entry != nullptr; entry = entry->next()) + if (entry->m_memory == nullptr && entry != unassigned && needs_backing_store(entry)) { // get block start/end blocks for this block offs_t blockstart = entry->m_bytestart / MEMORY_BLOCK_CHUNK; @@ -2079,12 +2079,12 @@ void address_space::allocate_memory() void address_space::locate_memory() { // once this is done, find the starting bases for the banks - for (memory_bank *bank = manager().m_banklist.first(); bank != NULL; bank = bank->next()) - if (bank->base() == NULL && bank->references_space(*this, ROW_READWRITE)) + for (memory_bank *bank = manager().m_banklist.first(); bank != nullptr; bank = bank->next()) + if (bank->base() == nullptr && bank->references_space(*this, ROW_READWRITE)) { // set the initial bank pointer - for (address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next()) - if (entry->m_bytestart == bank->bytestart() && entry->m_memory != NULL) + for (address_map_entry *entry = m_map->m_entrylist.first(); entry != nullptr; entry = entry->next()) + if (entry->m_bytestart == bank->bytestart() && entry->m_memory != nullptr) { bank->set_base(entry->m_memory); VPRINTF(("assigned bank '%s' pointer to memory from range %08X-%08X [%p]\n", bank->tag(), entry->m_addrstart, entry->m_addrend, entry->m_memory)); @@ -2107,17 +2107,17 @@ void address_space::locate_memory() address_map_entry *address_space::block_assign_intersecting(offs_t bytestart, offs_t byteend, UINT8 *base) { - address_map_entry *unassigned = NULL; + address_map_entry *unassigned = nullptr; // loop over the adjusted map and assign memory to any blocks we can - for (address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next()) + for (address_map_entry *entry = m_map->m_entrylist.first(); entry != nullptr; entry = entry->next()) { // if we haven't assigned this block yet, see if we have a mapped shared pointer for it - if (entry->m_memory == NULL && entry->m_share != NULL) + if (entry->m_memory == nullptr && entry->m_share != nullptr) { std::string fulltag = entry->m_devbase.subtag(entry->m_share); memory_share *share = manager().m_sharelist.find(fulltag.c_str()); - if (share != NULL && share->ptr() != NULL) + if (share != nullptr && share->ptr() != nullptr) { entry->m_memory = share->ptr(); VPRINTF(("memory range %08X-%08X -> shared_ptr '%s' [%p]\n", entry->m_addrstart, entry->m_addrend, entry->m_share, entry->m_memory)); @@ -2129,18 +2129,18 @@ address_map_entry *address_space::block_assign_intersecting(offs_t bytestart, of } // otherwise, look for a match in this block - if (entry->m_memory == NULL && entry->m_bytestart >= bytestart && entry->m_byteend <= byteend) + if (entry->m_memory == nullptr && entry->m_bytestart >= bytestart && entry->m_byteend <= byteend) { entry->m_memory = base + (entry->m_bytestart - bytestart); VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, bytestart, byteend, entry->m_memory)); } // if we're the first match on a shared pointer, assign it now - if (entry->m_memory != NULL && entry->m_share != NULL) + if (entry->m_memory != nullptr && entry->m_share != nullptr) { std::string fulltag = entry->m_devbase.subtag(entry->m_share); memory_share *share = manager().m_sharelist.find(fulltag.c_str()); - if (share != NULL && share->ptr() == NULL) + if (share != nullptr && share->ptr() == nullptr) { share->set_ptr(entry->m_memory); VPRINTF(("setting shared_ptr '%s' = %p\n", entry->m_share, entry->m_memory)); @@ -2148,7 +2148,7 @@ address_map_entry *address_space::block_assign_intersecting(offs_t bytestart, of } // keep track of the first unassigned entry - if (entry->m_memory == NULL && unassigned == NULL && needs_backing_store(entry)) + if (entry->m_memory == nullptr && unassigned == nullptr && needs_backing_store(entry)) unassigned = entry; } @@ -2248,25 +2248,25 @@ void address_space::install_readwrite_port(offs_t addrstart, offs_t addrend, off VPRINTF(("address_space::install_readwrite_port(%s-%s mask=%s mirror=%s, read=\"%s\" / write=\"%s\")\n", core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), - (rtag != NULL) ? rtag : "(none)", (wtag != NULL) ? wtag : "(none)")); + (rtag != nullptr) ? rtag : "(none)", (wtag != nullptr) ? wtag : "(none)")); // read handler - if (rtag != NULL) + if (rtag != nullptr) { // find the port ioport_port *port = machine().root_device().ioport(device().siblingtag(rtag).c_str()); - if (port == NULL) + if (port == nullptr) throw emu_fatalerror("Attempted to map non-existent port '%s' for read in space %s of device '%s'\n", rtag, m_name, m_device.tag()); // map the range and set the ioport read().handler_map_range(addrstart, addrend, addrmask, addrmirror).set_ioport(*port); } - if (wtag != NULL) + if (wtag != nullptr) { // find the port ioport_port *port = machine().root_device().ioport(device().siblingtag(wtag).c_str()); - if (port == NULL) + if (port == nullptr) fatalerror("Attempted to map non-existent port '%s' for write in space %s of device '%s'\n", wtag, m_name, m_device.tag()); // map the range and set the ioport @@ -2288,10 +2288,10 @@ void address_space::install_bank_generic(offs_t addrstart, offs_t addrend, offs_ VPRINTF(("address_space::install_readwrite_bank(%s-%s mask=%s mirror=%s, read=\"%s\" / write=\"%s\")\n", core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), - (rtag != NULL) ? rtag : "(none)", (wtag != NULL) ? wtag : "(none)")); + (rtag != nullptr) ? rtag : "(none)", (wtag != nullptr) ? wtag : "(none)")); // map the read bank - if (rtag != NULL) + if (rtag != nullptr) { std::string fulltag = device().siblingtag(rtag); memory_bank &bank = bank_find_or_allocate(fulltag.c_str(), addrstart, addrend, addrmask, addrmirror, ROW_READ); @@ -2299,7 +2299,7 @@ void address_space::install_bank_generic(offs_t addrstart, offs_t addrend, offs_ } // map the write bank - if (wtag != NULL) + if (wtag != nullptr) { std::string fulltag = device().siblingtag(wtag); memory_bank &bank = bank_find_or_allocate(fulltag.c_str(), addrstart, addrend, addrmask, addrmirror, ROW_WRITE); @@ -2316,16 +2316,16 @@ void address_space::install_bank_generic(offs_t addrstart, offs_t addrend, offs_ VPRINTF(("address_space::install_readwrite_bank(%s-%s mask=%s mirror=%s, read=\"%s\" / write=\"%s\")\n", core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), - (rbank != NULL) ? rbank->tag() : "(none)", (wbank != NULL) ? wbank->tag() : "(none)")); + (rbank != nullptr) ? rbank->tag() : "(none)", (wbank != nullptr) ? wbank->tag() : "(none)")); // map the read bank - if (rbank != NULL) + if (rbank != nullptr) { read().map_range(addrstart, addrend, addrmask, addrmirror, rbank->index()); } // map the write bank - if (wbank != NULL) + if (wbank != nullptr) { write().map_range(addrstart, addrend, addrmask, addrmirror, wbank->index()); } @@ -2352,23 +2352,23 @@ void *address_space::install_ram_generic(offs_t addrstart, offs_t addrend, offs_ if (readorwrite == ROW_READ || readorwrite == ROW_READWRITE) { // find a bank and map it - memory_bank &bank = bank_find_or_allocate(NULL, addrstart, addrend, addrmask, addrmirror, ROW_READ); + memory_bank &bank = bank_find_or_allocate(nullptr, addrstart, addrend, addrmask, addrmirror, ROW_READ); read().map_range(addrstart, addrend, addrmask, addrmirror, bank.index()); // if we are provided a pointer, set it - if (baseptr != NULL) + if (baseptr != nullptr) bank.set_base(baseptr); // if we don't have a bank pointer yet, try to find one - if (bank.base() == NULL) + if (bank.base() == nullptr) { void *backing = find_backing_memory(addrstart, addrend); - if (backing != NULL) + if (backing != nullptr) bank.set_base(backing); } // if we still don't have a pointer, and we're past the initialization phase, allocate a new block - if (bank.base() == NULL && manager().m_initialized) + if (bank.base() == nullptr && manager().m_initialized) { if (machine().phase() >= MACHINE_PHASE_RESET) fatalerror("Attempted to call install_ram_generic() after initialization time without a baseptr!\n"); @@ -2381,23 +2381,23 @@ void *address_space::install_ram_generic(offs_t addrstart, offs_t addrend, offs_ if (readorwrite == ROW_WRITE || readorwrite == ROW_READWRITE) { // find a bank and map it - memory_bank &bank = bank_find_or_allocate(NULL, addrstart, addrend, addrmask, addrmirror, ROW_WRITE); + memory_bank &bank = bank_find_or_allocate(nullptr, addrstart, addrend, addrmask, addrmirror, ROW_WRITE); write().map_range(addrstart, addrend, addrmask, addrmirror, bank.index()); // if we are provided a pointer, set it - if (baseptr != NULL) + if (baseptr != nullptr) bank.set_base(baseptr); // if we don't have a bank pointer yet, try to find one - if (bank.base() == NULL) + if (bank.base() == nullptr) { void *backing = find_backing_memory(addrstart, addrend); - if (backing != NULL) + if (backing != nullptr) bank.set_base(backing); } // if we still don't have a pointer, and we're past the initialization phase, allocate a new block - if (bank.base() == NULL && manager().m_initialized) + if (bank.base() == nullptr && manager().m_initialized) { if (machine().phase() >= MACHINE_PHASE_RESET) fatalerror("Attempted to call install_ram_generic() after initialization time without a baseptr!\n"); @@ -2555,15 +2555,15 @@ void *address_space::find_backing_memory(offs_t addrstart, offs_t addrend) VPRINTF(("address_space::find_backing_memory('%s',%s,%08X-%08X) -> ", m_device.tag(), m_name, bytestart, byteend)); - if (m_map == NULL) - return NULL; + if (m_map == nullptr) + return nullptr; // look in the address map first - for (address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next()) + for (address_map_entry *entry = m_map->m_entrylist.first(); entry != nullptr; entry = entry->next()) { offs_t maskstart = bytestart & entry->m_bytemask; offs_t maskend = byteend & entry->m_bytemask; - if (entry->m_memory != NULL && maskstart >= entry->m_bytestart && maskend <= entry->m_byteend) + if (entry->m_memory != nullptr && maskstart >= entry->m_bytestart && maskend <= entry->m_byteend) { VPRINTF(("found in entry %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart))); return (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart); @@ -2571,7 +2571,7 @@ void *address_space::find_backing_memory(offs_t addrstart, offs_t addrend) } // if not found there, look in the allocated blocks - for (memory_block *block = manager().m_blocklist.first(); block != NULL; block = block->next()) + for (memory_block *block = manager().m_blocklist.first(); block != nullptr; block = block->next()) if (block->contains(*this, bytestart, byteend)) { VPRINTF(("found in allocated memory block %08X-%08X [%p]\n", block->bytestart(), block->byteend(), block->data() + (bytestart - block->bytestart()))); @@ -2579,7 +2579,7 @@ void *address_space::find_backing_memory(offs_t addrstart, offs_t addrend) } VPRINTF(("did not find\n")); - return NULL; + return nullptr; } @@ -2592,11 +2592,11 @@ void *address_space::find_backing_memory(offs_t addrstart, offs_t addrend) bool address_space::needs_backing_store(const address_map_entry *entry) { // if we are sharing, and we don't have a pointer yet, create one - if (entry->m_share != NULL) + if (entry->m_share != nullptr) { std::string fulltag = entry->m_devbase.subtag(entry->m_share); memory_share *share = manager().m_sharelist.find(fulltag.c_str()); - if (share != NULL && share->ptr() == NULL) + if (share != nullptr && share->ptr() == nullptr) return true; } @@ -2607,7 +2607,7 @@ bool address_space::needs_backing_store(const address_map_entry *entry) // if we're reading from RAM or from ROM outside of address space 0 or its region, then yes, we do need backing memory_region *region = machine().root_device().memregion(m_device.tag()); if (entry->m_read.m_type == AMH_RAM || - (entry->m_read.m_type == AMH_ROM && (m_spacenum != AS_0 || region == NULL || entry->m_addrstart >= region->bytes()))) + (entry->m_read.m_type == AMH_ROM && (m_spacenum != AS_0 || region == nullptr || entry->m_addrstart >= region->bytes()))) return true; // all other cases don't need backing @@ -2636,24 +2636,24 @@ memory_bank &address_space::bank_find_or_allocate(const char *tag, offs_t addrst adjust_addresses(bytestart, byteend, bytemask, bytemirror); // if this bank is named, look it up - memory_bank *membank = NULL; - if (tag != NULL) + memory_bank *membank = nullptr; + if (tag != nullptr) membank = manager().bank(tag); // else try to find an exact match else - for (membank = manager().m_banklist.first(); membank != NULL; membank = membank->next()) + for (membank = manager().m_banklist.first(); membank != nullptr; membank = membank->next()) if (membank->anonymous() && membank->references_space(*this, ROW_READWRITE) && membank->matches_exactly(bytestart, byteend)) break; // if we don't have a bank yet, find a free one - if (membank == NULL) + if (membank == nullptr) { // handle failure int banknum = manager().m_banknext++; if (banknum > STATIC_BANKMAX) { - if (tag != NULL) + if (tag != nullptr) throw emu_fatalerror("Unable to allocate new bank '%s'", tag); else throw emu_fatalerror("Unable to allocate bank for RAM/ROM area %X-%X\n", bytestart, byteend); @@ -2662,7 +2662,7 @@ memory_bank &address_space::bank_find_or_allocate(const char *tag, offs_t addrst // if no tag, create a unique one membank = global_alloc(memory_bank(*this, banknum, bytestart, byteend, tag)); std::string temptag; - if (tag == NULL) { + if (tag == nullptr) { strprintf(temptag, "anon_%p", (void *) membank); tag = temptag.c_str(); } @@ -2912,8 +2912,8 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t curentry.configure(bytestart, byteend, bytemask); // Populate it wherever needed - for (std::list::const_iterator j = i->second.begin(); j != i->second.end(); ++j) - populate_range(j->start, j->end, entry); + for (const auto & elem : i->second) + populate_range(elem.start, elem.end, entry); // Add it in the "to be setup" list entries.push_back(entry); @@ -3477,7 +3477,7 @@ const char *address_table::handler_name(UINT16 entry) const { // banks have names if (entry >= STATIC_BANK1 && entry <= STATIC_BANKMAX) - for (memory_bank *info = m_space.manager().first_bank(); info != NULL; info = info->next()) + for (memory_bank *info = m_space.manager().first_bank(); info != nullptr; info = info->next()) if (info->index() == entry) return info->name(); @@ -3505,7 +3505,7 @@ address_table_read::address_table_read(address_space &space, bool large) // allocate handlers for each entry, prepopulating the bankptrs for banks for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++) { - UINT8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : NULL; + UINT8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : nullptr; m_handlers[entrynum] = std::make_unique(space.data_width(), space.endianness(), bankptr); } @@ -3579,7 +3579,7 @@ address_table_write::address_table_write(address_space &space, bool large) // allocate handlers for each entry, prepopulating the bankptrs for banks for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++) { - UINT8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : NULL; + UINT8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : nullptr; m_handlers[entrynum] = std::make_unique(space.data_width(), space.endianness(), bankptr); } @@ -3654,7 +3654,7 @@ handler_entry &address_table_write::handler(UINT32 index) const direct_read_data::direct_read_data(address_space &space) : m_space(space), - m_ptr(NULL), + m_ptr(nullptr), m_bytemask(space.bytemask()), m_bytestart(1), m_byteend(0), @@ -3728,13 +3728,13 @@ direct_read_data::direct_range *direct_read_data::find_range(offs_t byteaddress, entry = m_space.read().lookup_live_nowp(byteaddress); // scan our table - for (direct_range *range = m_rangelist[entry].first(); range != NULL; range = range->next()) + for (direct_range *range = m_rangelist[entry].first(); range != nullptr; range = range->next()) if (byteaddress >= range->m_bytestart && byteaddress <= range->m_byteend) return range; // didn't find out; allocate a new one direct_range *range = m_freerangelist.first(); - if (range != NULL) + if (range != nullptr) m_freerangelist.detach(*range); else range = global_alloc(direct_range); @@ -3755,18 +3755,18 @@ direct_read_data::direct_range *direct_read_data::find_range(offs_t byteaddress, void direct_read_data::remove_intersecting_ranges(offs_t bytestart, offs_t byteend) { // loop over all entries - for (int entry = 0; entry < ARRAY_LENGTH(m_rangelist); entry++) + for (auto & elem : m_rangelist) { // loop over all ranges in this entry's list direct_range *nextrange; - for (direct_range *range = m_rangelist[entry].first(); range != NULL; range = nextrange) + for (direct_range *range = elem.first(); range != nullptr; range = nextrange) { nextrange = range->next(); // if we intersect, remove and add to the free range list if (bytestart <= range->m_byteend && byteend >= range->m_bytestart) { - m_rangelist[entry].detach(*range); + elem.detach(*range); m_freerangelist.prepend(*range); } } @@ -3812,7 +3812,7 @@ void direct_read_data::explicit_configure(offs_t bytestart, offs_t byteend, offs //------------------------------------------------- memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteend, void *memory) - : m_next(NULL), + : m_next(nullptr), m_machine(space.machine()), m_space(space), m_bytestart(bytestart), @@ -3822,7 +3822,7 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen VPRINTF(("block_allocate('%s',%s,%08X,%08X,%p)\n", space.device().tag(), space.name(), bytestart, byteend, memory)); // allocate a block if needed - if (m_data == NULL) + if (m_data == nullptr) { offs_t length = byteend + 1 - bytestart; if (length < 4096) @@ -3841,7 +3841,7 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen // register for saving, but only if we're not part of a memory region memory_region *region; - for (region = space.machine().memory().first_region(); region != NULL; region = region->next()) + for (region = space.machine().memory().first_region(); region != nullptr; region = region->next()) if (m_data >= region->base() && (m_data + (byteend - bytestart + 1)) < region->end()) { VPRINTF(("skipping save of this memory block as it is covered by a memory region\n")); @@ -3849,12 +3849,12 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen } // if we didn't find a match, register - if (region == NULL) + if (region == nullptr) { int bytes_per_element = space.data_width() / 8; std::string name; strprintf(name,"%08x-%08x", bytestart, byteend); - space.machine().save().save_memory(NULL, "memory", space.device().tag(), space.spacenum(), name.c_str(), m_data, bytes_per_element, (UINT32)(byteend + 1 - bytestart) / bytes_per_element); + space.machine().save().save_memory(nullptr, "memory", space.device().tag(), space.spacenum(), name.c_str(), m_data, bytes_per_element, (UINT32)(byteend + 1 - bytestart) / bytes_per_element); } } @@ -3878,17 +3878,17 @@ memory_block::~memory_block() //------------------------------------------------- memory_bank::memory_bank(address_space &space, int index, offs_t bytestart, offs_t byteend, const char *tag) - : m_next(NULL), + : m_next(nullptr), m_machine(space.machine()), m_baseptr(space.manager().bank_pointer_addr(index)), m_index(index), - m_anonymous(tag == NULL), + m_anonymous(tag == nullptr), m_bytestart(bytestart), m_byteend(byteend), m_curentry(BANK_ENTRY_UNSPECIFIED) { // generate an internal tag if we don't have one - if (tag == NULL) + if (tag == nullptr) { strprintf(m_tag,"~%d~", index); strprintf(m_name,"Internal bank #%d", index); @@ -3900,7 +3900,7 @@ memory_bank::memory_bank(address_space &space, int index, offs_t bytestart, offs } if (!m_anonymous && space.machine().save().registration_allowed()) - space.machine().save().save_item(NULL, "memory", m_tag.c_str(), 0, NAME(m_curentry)); + space.machine().save().save_item(nullptr, "memory", m_tag.c_str(), 0, NAME(m_curentry)); } @@ -3921,7 +3921,7 @@ memory_bank::~memory_bank() bool memory_bank::references_space(address_space &space, read_or_write readorwrite) const { - for (bank_reference *ref = m_reflist.first(); ref != NULL; ref = ref->next()) + for (bank_reference *ref = m_reflist.first(); ref != nullptr; ref = ref->next()) if (ref->matches(space, readorwrite)) return true; return false; @@ -3950,7 +3950,7 @@ void memory_bank::add_reference(address_space &space, read_or_write readorwrite) void memory_bank::invalidate_references() { // invalidate all the direct references to any referenced address spaces - for (bank_reference *ref = m_reflist.first(); ref != NULL; ref = ref->next()) + for (bank_reference *ref = m_reflist.first(); ref != nullptr; ref = ref->next()) ref->space().direct().force_update(); } @@ -3962,7 +3962,7 @@ void memory_bank::invalidate_references() void memory_bank::set_base(void *base) { // NULL is not an option - if (base == NULL) + if (base == nullptr) throw emu_fatalerror("memory_bank::set_base called NULL base"); // set the base and invalidate any referencing spaces @@ -3983,7 +3983,7 @@ void memory_bank::set_entry(int entrynum) throw emu_fatalerror("memory_bank::set_entry called for anonymous bank"); if (entrynum < 0 || entrynum >= int(m_entry.size())) throw emu_fatalerror("memory_bank::set_entry called with out-of-range entry %d", entrynum); - if (m_entry[entrynum].m_ptr == NULL) + if (m_entry[entrynum].m_ptr == nullptr) throw emu_fatalerror("memory_bank::set_entry called for bank '%s' with invalid bank entry %d", m_tag.c_str(), entrynum); m_curentry = entrynum; @@ -4026,7 +4026,7 @@ void memory_bank::configure_entry(int entrynum, void *base) m_entry[entrynum].m_ptr = reinterpret_cast(base); // if the bank base is not configured, and we're the first entry, set us up - if (*m_baseptr == NULL && entrynum == 0) + if (*m_baseptr == nullptr && entrynum == 0) *m_baseptr = m_entry[entrynum].m_ptr; } @@ -4053,7 +4053,7 @@ void memory_bank::configure_entries(int startentry, int numentries, void *base, memory_region::memory_region(running_machine &machine, const char *name, UINT32 length, UINT8 width, endianness_t endian) : m_machine(machine), - m_next(NULL), + m_next(nullptr), m_name(name), m_buffer(length), m_endianness(endian), @@ -4115,7 +4115,7 @@ void handler_entry::copy(handler_entry *entry) m_bytestart = entry->m_bytestart; m_byteend = entry->m_byteend; m_bytemask = entry->m_bytemask; - m_rambaseptr = 0; + m_rambaseptr = nullptr; m_subunits = entry->m_subunits; memcpy(m_subunit_infos, entry->m_subunit_infos, m_subunits*sizeof(subunit_info)); m_invsubmask = entry->m_invsubmask; @@ -4318,7 +4318,7 @@ const char *handler_entry_read::name() const case 32: return m_read.r32.name(); case 64: return m_read.r64.name(); } - return NULL; + return nullptr; } //------------------------------------------------- @@ -4335,7 +4335,7 @@ const char *handler_entry_read::subunit_name(int entry) const case 32: return m_subread[entry].r32.name(); case 64: return m_subread[entry].r64.name(); } - return NULL; + return nullptr; } @@ -4631,7 +4631,7 @@ const char *handler_entry_write::name() const case 32: return m_write.w32.name(); case 64: return m_write.w64.name(); } - return NULL; + return nullptr; } @@ -4649,7 +4649,7 @@ const char *handler_entry_write::subunit_name(int entry) const case 32: return m_subwrite[entry].w32.name(); case 64: return m_subwrite[entry].w64.name(); } - return NULL; + return nullptr; } diff --git a/src/emu/memory.h b/src/emu/memory.h index 2d7e5ff2ca0..e04ac52f1b4 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -148,7 +148,7 @@ public: public: // construction direct_range() - : m_next(NULL), + : m_next(nullptr), m_bytestart(0), m_byteend(~0) { } @@ -214,8 +214,8 @@ class address_space_config public: // construction/destruction address_space_config(); - address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift = 0, address_map_constructor internal = NULL, address_map_constructor defmap = NULL); - address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, address_map_constructor internal = NULL, address_map_constructor defmap = NULL); + address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift = 0, address_map_constructor internal = nullptr, address_map_constructor defmap = nullptr); + address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, address_map_constructor internal = nullptr, address_map_constructor defmap = nullptr); address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, address_map_delegate internal, address_map_delegate defmap = address_map_delegate()); address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, address_map_delegate internal, address_map_delegate defmap = address_map_delegate()); @@ -376,23 +376,23 @@ public: void install_read_bank(offs_t addrstart, offs_t addrend, memory_bank *bank) { install_read_bank(addrstart, addrend, 0, 0, bank); } void install_write_bank(offs_t addrstart, offs_t addrend, memory_bank *bank) { install_write_bank(addrstart, addrend, 0, 0, bank); } void install_readwrite_bank(offs_t addrstart, offs_t addrend, memory_bank *bank) { install_readwrite_bank(addrstart, addrend, 0, 0, bank); } - void *install_rom(offs_t addrstart, offs_t addrend, void *baseptr = NULL) { return install_rom(addrstart, addrend, 0, 0, baseptr); } - void *install_writeonly(offs_t addrstart, offs_t addrend, void *baseptr = NULL) { return install_writeonly(addrstart, addrend, 0, 0, baseptr); } - void *install_ram(offs_t addrstart, offs_t addrend, void *baseptr = NULL) { return install_ram(addrstart, addrend, 0, 0, baseptr); } + void *install_rom(offs_t addrstart, offs_t addrend, void *baseptr = nullptr) { return install_rom(addrstart, addrend, 0, 0, baseptr); } + void *install_writeonly(offs_t addrstart, offs_t addrend, void *baseptr = nullptr) { return install_writeonly(addrstart, addrend, 0, 0, baseptr); } + void *install_ram(offs_t addrstart, offs_t addrend, void *baseptr = nullptr) { return install_ram(addrstart, addrend, 0, 0, baseptr); } // install ports, banks, RAM (with mirror/mask) - void install_read_port(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag) { install_readwrite_port(addrstart, addrend, addrmask, addrmirror, rtag, NULL); } - void install_write_port(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *wtag) { install_readwrite_port(addrstart, addrend, addrmask, addrmirror, NULL, wtag); } + void install_read_port(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag) { install_readwrite_port(addrstart, addrend, addrmask, addrmirror, rtag, nullptr); } + void install_write_port(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *wtag) { install_readwrite_port(addrstart, addrend, addrmask, addrmirror, nullptr, wtag); } void install_readwrite_port(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag); - void install_read_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, tag, NULL); } - void install_write_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, NULL, tag); } + void install_read_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, tag, nullptr); } + void install_write_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, nullptr, tag); } void install_readwrite_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, tag, tag); } - void install_read_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, memory_bank *bank) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, bank, NULL); } - void install_write_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, memory_bank *bank) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, NULL, bank); } + void install_read_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, memory_bank *bank) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, bank, nullptr); } + void install_write_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, memory_bank *bank) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, nullptr, bank); } void install_readwrite_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, memory_bank *bank) { install_bank_generic(addrstart, addrend, addrmask, addrmirror, bank, bank); } - void *install_rom(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, void *baseptr = NULL) { return install_ram_generic(addrstart, addrend, addrmask, addrmirror, ROW_READ, baseptr); } - void *install_writeonly(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, void *baseptr = NULL) { return install_ram_generic(addrstart, addrend, addrmask, addrmirror, ROW_WRITE, baseptr); } - void *install_ram(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, void *baseptr = NULL) { return install_ram_generic(addrstart, addrend, addrmask, addrmirror, ROW_READWRITE, baseptr); } + void *install_rom(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, void *baseptr = nullptr) { return install_ram_generic(addrstart, addrend, addrmask, addrmirror, ROW_READ, baseptr); } + void *install_writeonly(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, void *baseptr = nullptr) { return install_ram_generic(addrstart, addrend, addrmask, addrmirror, ROW_WRITE, baseptr); } + void *install_ram(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, void *baseptr = nullptr) { return install_ram_generic(addrstart, addrend, addrmask, addrmirror, ROW_READWRITE, baseptr); } // install device memory maps template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(address_map &map, device_t &device), int bits = 0, UINT64 unitmask = 0) { @@ -436,7 +436,7 @@ public: // setup void prepare_map(); - void populate_from_map(address_map *map = NULL); + void populate_from_map(address_map *map = nullptr); void allocate_memory(); void locate_memory(); @@ -495,7 +495,7 @@ class memory_block public: // construction/destruction - memory_block(address_space &space, offs_t bytestart, offs_t byteend, void *memory = NULL); + memory_block(address_space &space, offs_t bytestart, offs_t byteend, void *memory = nullptr); ~memory_block(); // getters @@ -539,7 +539,7 @@ class memory_bank public: // construction/destruction bank_reference(address_space &space, read_or_write readorwrite) - : m_next(NULL), + : m_next(nullptr), m_space(space), m_readorwrite(readorwrite) { } @@ -568,7 +568,7 @@ class memory_bank public: // construction/destruction - memory_bank(address_space &space, int index, offs_t bytestart, offs_t byteend, const char *tag = NULL); + memory_bank(address_space &space, int index, offs_t bytestart, offs_t byteend, const char *tag = nullptr); ~memory_bank(); // getters @@ -630,8 +630,8 @@ class memory_share public: // construction/destruction - memory_share(UINT8 width, size_t bytes, endianness_t endianness, void *ptr = NULL) - : m_next(NULL), + memory_share(UINT8 width, size_t bytes, endianness_t endianness, void *ptr = nullptr) + : m_next(nullptr), m_ptr(ptr), m_bytes(bytes), m_endianness(endianness), @@ -643,7 +643,7 @@ public: 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 == NULL) return NULL; return m_ptr; } + void *ptr() const { if (this == nullptr) return nullptr; 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 +682,9 @@ public: // getters running_machine &machine() const { return m_machine; } memory_region *next() const { return m_next; } - UINT8 *base() { return (this != NULL) ? &m_buffer[0] : NULL; } - UINT8 *end() { return (this != NULL) ? base() + m_buffer.size() : NULL; } - UINT32 bytes() const { return (this != NULL) ? m_buffer.size() : 0; } + 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; } const char *name() const { return m_name.c_str(); } // flag expansion @@ -883,7 +883,7 @@ inline void *direct_read_data::read_ptr(offs_t byteaddress, offs_t directxor) { if (address_is_valid(byteaddress)) return &m_ptr[(byteaddress ^ directxor) & m_bytemask]; - return NULL; + return nullptr; } diff --git a/src/emu/network.cpp b/src/emu/network.cpp index ceb557cdefd..5bcd8173618 100644 --- a/src/emu/network.cpp +++ b/src/emu/network.cpp @@ -20,22 +20,22 @@ static void network_load(running_machine &machine, int config_type, xml_data_node *parentnode) { xml_data_node *node; - if ((config_type == CONFIG_TYPE_GAME) && (parentnode != NULL)) + if ((config_type == CONFIG_TYPE_GAME) && (parentnode != nullptr)) { for (node = xml_get_sibling(parentnode->child, "device"); node; node = xml_get_sibling(node->next, "device")) { - const char *tag = xml_get_attribute_string(node, "tag", NULL); + const char *tag = xml_get_attribute_string(node, "tag", nullptr); - if ((tag != NULL) && (tag[0] != '\0')) + if ((tag != nullptr) && (tag[0] != '\0')) { network_interface_iterator iter(machine.root_device()); - for (device_network_interface *network = iter.first(); network != NULL; network = iter.next()) + for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next()) { if (!strcmp(tag, network->device().tag())) { int interface = xml_get_attribute_int(node, "interface", 0); network->set_interface(interface); - const char *mac_addr = xml_get_attribute_string(node, "mac", NULL); - if (mac_addr != NULL && strlen(mac_addr)==17) { + const char *mac_addr = xml_get_attribute_string(node, "mac", nullptr); + if (mac_addr != nullptr && strlen(mac_addr)==17) { char mac[7]; unsigned int mac_num[6]; sscanf (mac_addr,"%02x:%02x:%02x:%02x:%02x:%02x",&mac_num[0],&mac_num[1],&mac_num[2],&mac_num[3],&mac_num[4],&mac_num[5]); @@ -58,10 +58,10 @@ static void network_save(running_machine &machine, int config_type, xml_data_nod if (config_type == CONFIG_TYPE_GAME) { network_interface_iterator iter(machine.root_device()); - for (device_network_interface *network = iter.first(); network != NULL; network = iter.next()) + for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next()) { - node = xml_add_child(parentnode, "device", NULL); - if (node != NULL) + node = xml_add_child(parentnode, "device", nullptr); + if (node != nullptr) { xml_set_attribute(node, "tag", network->device().tag()); xml_set_attribute_int(node, "interface", network->get_interface()); diff --git a/src/emu/output.cpp b/src/emu/output.cpp index 54d2d91e85a..e2e919dfaa3 100644 --- a/src/emu/output.cpp +++ b/src/emu/output.cpp @@ -26,7 +26,7 @@ class output_notify { public: output_notify(output_notifier_func callback, void *param) - : m_next(NULL), + : m_next(nullptr), m_notifier(callback), m_param(param) { } @@ -94,11 +94,11 @@ INLINE output_item *find_item(const char *string) output_item *item; /* use the hash as a starting point and find an entry */ - for (item = itemtable[hash % HASH_SIZE]; item != NULL; item = item->next) + for (item = itemtable[hash % HASH_SIZE]; item != nullptr; item = item->next) if (item->hash == hash && strcmp(string, item->name.c_str()) == 0) return item; - return NULL; + return nullptr; } @@ -108,7 +108,7 @@ INLINE output_item *find_item(const char *string) INLINE output_item *create_new_item(const char *outname, INT32 value) { - output_item *item = global_alloc(output_item); + auto item = global_alloc(output_item); UINT32 hash = get_hash(outname); /* fill in the data */ @@ -174,7 +174,7 @@ static void output_exit(running_machine &machine) /* remove all items */ for (hash = 0; hash < HASH_SIZE; hash++) - for (item = itemtable[hash]; item != NULL; ) + for (item = itemtable[hash]; item != nullptr; ) { output_item *next = item->next; @@ -198,7 +198,7 @@ void output_set_value(const char *outname, INT32 value) INT32 oldval; /* if no item of that name, create a new one and send the item's state */ - if (item == NULL) + if (item == nullptr) { item = create_new_item(outname, value); oldval = value + 1; @@ -215,11 +215,11 @@ void output_set_value(const char *outname, INT32 value) if (oldval != value) { /* call the local notifiers first */ - for (output_notify *notify = item->notifylist.first(); notify != NULL; notify = notify->next()) + for (output_notify *notify = item->notifylist.first(); notify != nullptr; notify = notify->next()) (*notify->m_notifier)(outname, value, notify->m_param); /* call the global notifiers next */ - for (output_notify *notify = global_notifylist.first(); notify != NULL; notify = notify->next()) + for (output_notify *notify = global_notifylist.first(); notify != nullptr; notify = notify->next()) (*notify->m_notifier)(outname, value, notify->m_param); } } @@ -261,7 +261,7 @@ INT32 output_get_value(const char *outname) output_item *item = find_item(outname); /* if no item, value is 0 */ - if (item == NULL) + if (item == nullptr) return 0; return item->value; } @@ -302,12 +302,12 @@ INT32 output_get_indexed_value(const char *basename, int index) void output_set_notifier(const char *outname, output_notifier_func callback, void *param) { /* if an item is specified, find it */ - if (outname != NULL) + if (outname != nullptr) { output_item *item = find_item(outname); /* if no item of that name, create a new one */ - if (item == NULL) + if (item == nullptr) item = create_new_item(outname, 0); item->notifylist.append(*global_alloc(output_notify(callback, param))); } @@ -328,7 +328,7 @@ void output_notify_all(output_notifier_func callback, void *param) /* remove all items */ for (hash = 0; hash < HASH_SIZE; hash++) - for (item = itemtable[hash]; item != NULL; item = item->next) + for (item = itemtable[hash]; item != nullptr; item = item->next) (*callback)(item->name.c_str(), item->value, param); } @@ -343,7 +343,7 @@ UINT32 output_name_to_id(const char *outname) output_item *item = find_item(outname); /* if no item, ID is 0 */ - if (item == NULL) + if (item == nullptr) return 0; return item->id; } @@ -361,10 +361,10 @@ const char *output_id_to_name(UINT32 id) /* remove all items */ for (hash = 0; hash < HASH_SIZE; hash++) - for (item = itemtable[hash]; item != NULL; item = item->next) + for (item = itemtable[hash]; item != nullptr; item = item->next) if (item->id == id) return item->name.c_str(); /* nothing found, return NULL */ - return NULL; + return nullptr; } diff --git a/src/emu/profiler.cpp b/src/emu/profiler.cpp index 668d57964c2..102f0358e09 100644 --- a/src/emu/profiler.cpp +++ b/src/emu/profiler.cpp @@ -105,7 +105,7 @@ void real_profiler_state::reset(bool enabled) else { // magic value to indicate disabled - m_filoptr = NULL; + m_filoptr = nullptr; } } @@ -212,10 +212,10 @@ void real_profiler_state::update_text(running_machine &machine) if (curtype >= PROFILER_DEVICE_FIRST && curtype <= PROFILER_DEVICE_MAX) strcatprintf(m_text, "'%s'", iter.byindex(curtype - PROFILER_DEVICE_FIRST)->tag()); else - for (int nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++) - if (names[nameindex].type == curtype) + for (auto & name : names) + if (name.type == curtype) { - m_text.append(names[nameindex].string); + m_text.append(name.string); break; } diff --git a/src/emu/profiler.h b/src/emu/profiler.h index ceb1afee877..9309b130df2 100644 --- a/src/emu/profiler.h +++ b/src/emu/profiler.h @@ -91,7 +91,7 @@ public: // getters bool enabled() const { - return m_filoptr != NULL; + return m_filoptr != nullptr; } const char *text(running_machine &machine); diff --git a/src/emu/render.cpp b/src/emu/render.cpp index 712c8287a32..0f9bc97d77d 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -182,7 +182,7 @@ inline item_layer get_layer_and_blendmode(const layout_view &view, int index, in // screens (add) + overlays (RGB multiply) + backdrop (add) + bezels (alpha) + cpanels (alpha) + marquees (alpha) const int *layer_order = layer_order_standard; - if (view.first_item(ITEM_LAYER_BACKDROP) != NULL && view.first_item(ITEM_LAYER_BACKDROP)->next() != NULL && view.first_item(ITEM_LAYER_OVERLAY) == NULL) + if (view.first_item(ITEM_LAYER_BACKDROP) != nullptr && view.first_item(ITEM_LAYER_BACKDROP)->next() != nullptr && view.first_item(ITEM_LAYER_OVERLAY) == nullptr) layer_order = layer_order_alternate; // select the layer @@ -268,7 +268,7 @@ inline void render_primitive_list::add_reference(void *refptr) inline bool render_primitive_list::has_reference(void *refptr) const { // skip if we already have one - for (reference *ref = m_reflist.first(); ref != NULL; ref = ref->next()) + for (reference *ref = m_reflist.first(); ref != nullptr; ref = ref->next()) if (ref->m_refptr == refptr) return true; return false; @@ -328,13 +328,13 @@ void render_primitive_list::append_or_return(render_primitive &prim, bool clippe //------------------------------------------------- render_texture::render_texture() - : m_manager(NULL), - m_next(NULL), - m_bitmap(NULL), + : m_manager(nullptr), + m_next(nullptr), + m_bitmap(nullptr), m_format(TEXFORMAT_ARGB32), m_osddata(~0L), - m_scaler(NULL), - m_param(NULL), + m_scaler(nullptr), + m_param(nullptr), m_curseq(0) { m_sbounds.set(0, -1, 0, -1); @@ -360,7 +360,7 @@ render_texture::~render_texture() void render_texture::reset(render_manager &manager, texture_scaler_func scaler, void *param) { m_manager = &manager; - if (scaler != NULL) + if (scaler != nullptr) { assert(m_format == TEXFORMAT_ARGB32); m_scaler = scaler; @@ -377,17 +377,17 @@ void render_texture::reset(render_manager &manager, texture_scaler_func scaler, void render_texture::release() { // free all scaled versions - for (int scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++) + for (auto & elem : m_scaled) { - m_manager->invalidate_all(m_scaled[scalenum].bitmap); - global_free(m_scaled[scalenum].bitmap); - m_scaled[scalenum].bitmap = NULL; - m_scaled[scalenum].seqid = 0; + m_manager->invalidate_all(elem.bitmap); + global_free(elem.bitmap); + elem.bitmap = nullptr; + elem.seqid = 0; } // invalidate references to the original bitmap as well m_manager->invalidate_all(m_bitmap); - m_bitmap = NULL; + m_bitmap = nullptr; m_sbounds.set(0, -1, 0, -1); m_format = TEXFORMAT_ARGB32; m_curseq = 0; @@ -404,10 +404,10 @@ void render_texture::set_bitmap(bitmap_t &bitmap, const rectangle &sbounds, text // ensure we have a valid palette for palettized modes if (format == TEXFORMAT_PALETTE16 || format == TEXFORMAT_PALETTEA16) - assert(bitmap.palette() != NULL); + assert(bitmap.palette() != nullptr); // invalidate references to the old bitmap - if (&bitmap != m_bitmap && m_bitmap != NULL) + if (&bitmap != m_bitmap && m_bitmap != nullptr) m_manager->invalidate_all(m_bitmap); // set the new bitmap/palette @@ -416,15 +416,15 @@ void render_texture::set_bitmap(bitmap_t &bitmap, const rectangle &sbounds, text m_format = format; // invalidate all scaled versions - for (int scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++) + for (auto & elem : m_scaled) { - if (m_scaled[scalenum].bitmap != NULL) + if (elem.bitmap != nullptr) { - m_manager->invalidate_all(m_scaled[scalenum].bitmap); - global_free(m_scaled[scalenum].bitmap); + m_manager->invalidate_all(elem.bitmap); + global_free(elem.bitmap); } - m_scaled[scalenum].bitmap = NULL; - m_scaled[scalenum].seqid = 0; + elem.bitmap = nullptr; + elem.seqid = 0; } } @@ -459,7 +459,7 @@ void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t texinfo.osddata = m_osddata; // are we scaler-free? if so, just return the source bitmap - if (m_scaler == NULL || (m_bitmap != NULL && swidth == dwidth && sheight == dheight)) + if (m_scaler == nullptr || (m_bitmap != nullptr && swidth == dwidth && sheight == dheight)) { // add a reference and set up the source bitmap primlist.add_reference(m_bitmap); @@ -474,17 +474,17 @@ void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t { // make sure we can recover the original argb32 bitmap bitmap_argb32 dummy; - bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast(*m_bitmap) : dummy; + bitmap_argb32 &srcbitmap = (m_bitmap != nullptr) ? downcast(*m_bitmap) : dummy; // is it a size we already have? - scaled_texture *scaled = NULL; + scaled_texture *scaled = nullptr; int scalenum; for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++) { scaled = &m_scaled[scalenum]; // we need a non-NULL bitmap with matching dest size - if (scaled->bitmap != NULL && dwidth == scaled->bitmap->width() && dheight == scaled->bitmap->height()) + if (scaled->bitmap != nullptr && dwidth == scaled->bitmap->width() && dheight == scaled->bitmap->height()) break; } @@ -501,7 +501,7 @@ void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t // throw out any existing entries scaled = &m_scaled[lowest]; - if (scaled->bitmap != NULL) + if (scaled->bitmap != nullptr) { m_manager->invalidate_all(scaled->bitmap); global_free(scaled->bitmap); @@ -540,7 +540,7 @@ const rgb_t *render_texture::get_adjusted_palette(render_container &container) case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTEA16: - assert(m_bitmap->palette() != NULL); + assert(m_bitmap->palette() != nullptr); // return our adjusted palette return container.bcg_lookup_table(m_format, m_bitmap->palette()); @@ -551,14 +551,14 @@ const rgb_t *render_texture::get_adjusted_palette(render_container &container) // if no adjustment necessary, return NULL if (!container.has_brightness_contrast_gamma_changes()) - return NULL; + return nullptr; return container.bcg_lookup_table(m_format); default: assert(FALSE); } - return NULL; + return nullptr; } @@ -572,17 +572,17 @@ const rgb_t *render_texture::get_adjusted_palette(render_container &container) //------------------------------------------------- render_container::render_container(render_manager &manager, screen_device *screen) - : m_next(NULL), + : m_next(nullptr), m_manager(manager), m_screen(screen), - m_overlaybitmap(NULL), - m_overlaytexture(NULL) + m_overlaybitmap(nullptr), + m_overlaytexture(nullptr) { // make sure it is empty empty(); // if we have a screen, read and apply the options - if (m_screen != NULL) + if (m_screen != nullptr) { // set the initial orientation and brightness/contrast/gamma m_user.m_orientation = manager.machine().system().flags & ORIENTATION_MASK; @@ -622,7 +622,7 @@ void render_container::set_overlay(bitmap_argb32 *bitmap) // set the new data and allocate the texture m_overlaybitmap = bitmap; - if (m_overlaybitmap != NULL) + if (m_overlaybitmap != nullptr) { m_overlaytexture = m_manager.texture_alloc(render_container::overlay_scale); m_overlaytexture->set_bitmap(*bitmap, bitmap->cliprect(), TEXFORMAT_ARGB32); @@ -737,7 +737,7 @@ const rgb_t *render_container::bcg_lookup_table(int texformat, palette_t *palett return m_bcglookup256; default: - return NULL; + return nullptr; } } @@ -788,7 +788,7 @@ render_container::item &render_container::add_generic(UINT8 type, float x0, floa newitem->m_flags = 0; newitem->m_internal = 0; newitem->m_width = 0; - newitem->m_texture = NULL; + newitem->m_texture = nullptr; // add the item to the container return m_itemlist.append(*newitem); @@ -844,7 +844,7 @@ void render_container::recompute_lookups() void render_container::update_palette() { // skip if no client - if (m_palclient == NULL) + if (m_palclient == nullptr) return; // get the dirty list @@ -852,7 +852,7 @@ void render_container::update_palette() const UINT32 *dirty = m_palclient->dirty_list(mindirty, maxdirty); // iterate over dirty items and update them - if (dirty != NULL) + if (dirty != nullptr) { palette_t &palette = m_palclient->palette(); const rgb_t *adjusted_palette = palette.entry_list_adjusted(); @@ -911,9 +911,9 @@ render_container::user_settings::user_settings() //------------------------------------------------- render_target::render_target(render_manager &manager, const char *layoutfile, UINT32 flags) - : m_next(NULL), + : m_next(nullptr), m_manager(manager), - m_curview(NULL), + m_curview(nullptr), m_flags(flags), m_listindex(0), m_width(640), @@ -921,7 +921,7 @@ render_target::render_target(render_manager &manager, const char *layoutfile, UI m_pixel_aspect(0.0f), m_max_refresh(0), m_orientation(0), - m_base_view(NULL), + m_base_view(nullptr), m_base_orientation(ROT0), m_maxtexwidth(65536), m_maxtexheight(65536), @@ -962,7 +962,7 @@ render_target::render_target(render_manager &manager, const char *layoutfile, UI set_view(0); // make us the UI target if there is none - if (!hidden() && manager.m_ui_target == NULL) + if (!hidden() && manager.m_ui_target == nullptr) manager.set_ui_target(*this); } @@ -1021,7 +1021,7 @@ void render_target::set_bounds(INT32 width, INT32 height, float pixel_aspect) void render_target::set_view(int viewindex) { layout_view *view = view_by_index(viewindex); - if (view != NULL) + if (view != nullptr) { m_curview = view; view->recompute(m_layerconfig); @@ -1048,14 +1048,14 @@ void render_target::set_max_texture_size(int maxwidth, int maxheight) int render_target::configured_view(const char *viewname, int targetindex, int numtargets) { - layout_view *view = NULL; + layout_view *view = nullptr; int viewindex; // auto view just selects the nth view if (strcmp(viewname, "auto") != 0) { // scan for a matching view name - for (view = view_by_index(viewindex = 0); view != NULL; view = view_by_index(++viewindex)) + for (view = view_by_index(viewindex = 0); view != nullptr; view = view_by_index(++viewindex)) if (core_strnicmp(view->name(), viewname, strlen(viewname)) == 0) break; } @@ -1063,7 +1063,7 @@ int render_target::configured_view(const char *viewname, int targetindex, int nu // if we don't have a match, default to the nth view screen_device_iterator iter(m_manager.machine().root_device()); int scrcount = iter.count(); - if (view == NULL && scrcount > 0) + if (view == nullptr && scrcount > 0) { // if we have enough targets to be one per screen, assign in order if (numtargets >= scrcount) @@ -1072,12 +1072,12 @@ int render_target::configured_view(const char *viewname, int targetindex, int nu screen_device *screen = iter.byindex(ourindex); // find the first view with this screen and this screen only - for (view = view_by_index(viewindex = 0); view != NULL; view = view_by_index(++viewindex)) + for (view = view_by_index(viewindex = 0); view != nullptr; view = view_by_index(++viewindex)) { const render_screen_list &viewscreens = view->screens(); if (viewscreens.count() == 0) { - view = NULL; + view = nullptr; break; } else if (viewscreens.count() == viewscreens.contains(*screen)) @@ -1086,9 +1086,9 @@ int render_target::configured_view(const char *viewname, int targetindex, int nu } // otherwise, find the first view that has all the screens - if (view == NULL) + if (view == nullptr) { - for (view = view_by_index(viewindex = 0); view != NULL; view = view_by_index(++viewindex)) + for (view = view_by_index(viewindex = 0); view != nullptr; view = view_by_index(++viewindex)) { const render_screen_list &viewscreens = view->screens(); if (viewscreens.count() == 0) @@ -1096,10 +1096,10 @@ int render_target::configured_view(const char *viewname, int targetindex, int nu if (viewscreens.count() >= scrcount) { screen_device *screen; - for (screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen = iter.first(); screen != nullptr; screen = iter.next()) if (!viewscreens.contains(*screen)) break; - if (screen == NULL) + if (screen == nullptr) break; } } @@ -1107,7 +1107,7 @@ int render_target::configured_view(const char *viewname, int targetindex, int nu } // make sure it's a valid view - return (view != NULL) ? view_index(*view) : 0; + return (view != nullptr) ? view_index(*view) : 0; } @@ -1118,7 +1118,7 @@ int render_target::configured_view(const char *viewname, int targetindex, int nu const char *render_target::view_name(int viewindex) { layout_view *view = view_by_index(viewindex); - return (view != NULL) ? view->name() : NULL; + return (view != nullptr) ? view->name() : nullptr; } @@ -1131,7 +1131,7 @@ const char *render_target::view_name(int viewindex) const render_screen_list &render_target::view_screens(int viewindex) { layout_view *view = view_by_index(viewindex); - return (view != NULL) ? view->screens() : s_empty_screen_list; + return (view != nullptr) ? view->screens() : s_empty_screen_list; } @@ -1201,15 +1201,15 @@ void render_target::compute_minimum_size(INT32 &minwidth, INT32 &minheight) return; } - if (m_curview == NULL) + if (m_curview == nullptr) throw emu_fatalerror("Mandatory artwork is missing"); // scan the current view for all screens for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; ++layer) // iterate over items in the layer - for (layout_view::item *curitem = m_curview->first_item(layer); curitem != NULL; curitem = curitem->next()) - if (curitem->screen() != NULL) + for (layout_view::item *curitem = m_curview->first_item(layer); curitem != nullptr; curitem = curitem->next()) + if (curitem->screen() != nullptr) { // use a hard-coded default visible area for vector screens screen_device *screen = curitem->screen(); @@ -1261,7 +1261,7 @@ void render_target::compute_minimum_size(INT32 &minwidth, INT32 &minheight) render_primitive_list &render_target::get_primitives() { // remember the base values if this is the first frame - if (m_base_view == NULL) + if (m_base_view == nullptr) m_base_view = m_curview; // switch to the next primitive list @@ -1295,7 +1295,7 @@ render_primitive_list &render_target::get_primitives() if (m_curview->layer_enabled(layer)) { // iterate over items in the layer - for (layout_view::item *curitem = m_curview->first_item(layer); curitem != NULL; curitem = curitem->next()) + for (layout_view::item *curitem = m_curview->first_item(layer); curitem != nullptr; curitem = curitem->next()) { // first apply orientation to the bounds render_bounds bounds = curitem->bounds(); @@ -1316,7 +1316,7 @@ render_primitive_list &render_target::get_primitives() item_xform.no_center = false; // if there is no associated element, it must be a screen element - if (curitem->screen() != NULL) + if (curitem->screen() != nullptr) add_container_primitives(list, item_xform, curitem->screen()->container(), blendmode); else add_element_primitives(list, item_xform, *curitem->element(), curitem->state(), blendmode); @@ -1330,7 +1330,7 @@ render_primitive_list &render_target::get_primitives() render_primitive *prim = list.alloc(render_primitive::QUAD); set_render_bounds_xy(&prim->bounds, 0.0f, 0.0f, (float)m_width, (float)m_height); set_render_color(&prim->color, 1.0f, 1.0f, 1.0f, 1.0f); - prim->texture.base = NULL; + prim->texture.base = nullptr; prim->flags = PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA); list.append(*prim); @@ -1339,14 +1339,14 @@ render_primitive_list &render_target::get_primitives() prim = list.alloc(render_primitive::QUAD); set_render_bounds_xy(&prim->bounds, 1.0f, 1.0f, (float)(m_width - 1), (float)(m_height - 1)); set_render_color(&prim->color, 1.0f, 0.0f, 0.0f, 0.0f); - prim->texture.base = NULL; + prim->texture.base = nullptr; prim->flags = PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA); list.append(*prim); } } // process the debug containers - for (render_container *debug = m_debug_containers.first(); debug != NULL; debug = debug->next()) + for (render_container *debug = m_debug_containers.first(); debug != nullptr; debug = debug->next()) { object_transform ui_xform; ui_xform.xoffs = 0; @@ -1408,7 +1408,7 @@ bool render_target::map_point_container(INT32 target_x, INT32 target_y, render_c bool render_target::map_point_input(INT32 target_x, INT32 target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y) { - return map_point_internal(target_x, target_y, NULL, input_x, input_y, input_port, input_mask);; + return map_point_internal(target_x, target_y, nullptr, input_x, input_y, input_port, input_mask);; } @@ -1421,9 +1421,9 @@ bool render_target::map_point_input(INT32 target_x, INT32 target_y, ioport_port void render_target::invalidate_all(void *refptr) { // iterate through all our primitive lists - for (int listnum = 0; listnum < ARRAY_LENGTH(m_primlist); listnum++) + for (auto & list : m_primlist) { - render_primitive_list &list = m_primlist[listnum]; + // if we have a reference to this object, release our list list.acquire_lock(); @@ -1472,9 +1472,9 @@ void render_target::debug_top(render_container &container) void render_target::resolve_tags() { - for (layout_file *file = m_filelist.first(); file != NULL; file = file->next()) + for (layout_file *file = m_filelist.first(); file != nullptr; file = file->next()) { - for (layout_view *view = file->first_view(); view != NULL; view = view->next()) + for (layout_view *view = file->first_view(); view != nullptr; view = view->next()) { view->resolve_tags(); } @@ -1503,7 +1503,7 @@ void render_target::load_layout_files(const char *layoutfile, bool singlefile) bool have_default = false; // if there's an explicit file, load that first const char *basename = m_manager.machine().basename(); - if (layoutfile != NULL) + if (layoutfile != nullptr) have_default |= load_layout_file(basename, layoutfile); // if we're only loading this file, we know our final result @@ -1518,10 +1518,10 @@ void render_target::load_layout_files(const char *layoutfile, bool singlefile) have_default |= true; // if a default view has been specified, use that as a fallback - if (system.default_layout != NULL) - have_default |= load_layout_file(NULL, system.default_layout); - if (m_manager.machine().config().m_default_layout != NULL) - have_default |= load_layout_file(NULL, m_manager.machine().config().m_default_layout); + if (system.default_layout != nullptr) + have_default |= load_layout_file(nullptr, system.default_layout); + if (m_manager.machine().config().m_default_layout != nullptr) + have_default |= load_layout_file(nullptr, m_manager.machine().config().m_default_layout); // try to load another file based on the parent driver name int cloneof = driver_list::clone(system); @@ -1537,34 +1537,34 @@ void render_target::load_layout_files(const char *layoutfile, bool singlefile) if (screens == 1) { if (system.flags & ORIENTATION_SWAP_XY) - load_layout_file(NULL, layout_vertical); + load_layout_file(nullptr, layout_vertical); else - load_layout_file(NULL, layout_horizont); + load_layout_file(nullptr, layout_horizont); assert_always(m_filelist.count() > 0, "Couldn't parse default layout??"); } if (!have_default) { if (screens == 0) { - load_layout_file(NULL, layout_noscreens); + load_layout_file(nullptr, layout_noscreens); assert_always(m_filelist.count() > 0, "Couldn't parse default layout??"); } else if (screens == 2) { - load_layout_file(NULL, layout_dualhsxs); + load_layout_file(nullptr, layout_dualhsxs); assert_always(m_filelist.count() > 0, "Couldn't parse default layout??"); } else if (screens == 3) { - load_layout_file(NULL, layout_triphsxs); + load_layout_file(nullptr, layout_triphsxs); assert_always(m_filelist.count() > 0, "Couldn't parse default layout??"); } else if (screens == 4) { - load_layout_file(NULL, layout_quadhsxs); + load_layout_file(nullptr, layout_quadhsxs); assert_always(m_filelist.count() > 0, "Couldn't parse default layout??"); } } @@ -1581,14 +1581,14 @@ bool render_target::load_layout_file(const char *dirname, const char *filename) // if the first character of the "file" is an open brace, assume it is an XML string xml_data_node *rootnode; if (filename[0] == '<') - rootnode = xml_string_read(filename, NULL); + rootnode = xml_string_read(filename, nullptr); // otherwise, assume it is a file else { // build the path and optionally prepend the directory std::string fname = std::string(filename).append(".lay"); - if (dirname != NULL) + if (dirname != nullptr) fname.insert(0, PATH_SEPARATOR).insert(0, dirname); // attempt to open the file; bail if we can't @@ -1598,11 +1598,11 @@ bool render_target::load_layout_file(const char *dirname, const char *filename) return false; // read the file - rootnode = xml_file_read(layoutfile, NULL); + rootnode = xml_file_read(layoutfile, nullptr); } // if we didn't get a properly-formatted XML file, record a warning and exit - if (rootnode == NULL) + if (rootnode == nullptr) { if (filename[0] != '<') osd_printf_warning("Improperly formatted XML file '%s', ignoring\n", filename); @@ -1683,7 +1683,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const } // iterate over elements - for (render_container::item *curitem = container.first_item(); curitem != NULL; curitem = curitem->next()) + for (render_container::item *curitem = container.first_item(); curitem != nullptr; curitem = curitem->next()) { // compute the oriented bounds render_bounds bounds = curitem->bounds(); @@ -1745,7 +1745,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const normalize_bounds(prim->bounds); // get the scaled bitmap and set the resulting palette - if (curitem->texture() != NULL) + if (curitem->texture() != nullptr) { // determine the final orientation int finalorient = orientation_add(PRIMFLAG_GET_TEXORIENT(curitem->flags()), container_xform.orientation); @@ -1782,11 +1782,11 @@ void render_target::add_container_primitives(render_primitive_list &list, const prim->color.b = container.apply_brightness_contrast_gamma_fp(prim->color.b); // no texture -- set the basic flags - prim->texture.base = NULL; + prim->texture.base = nullptr; prim->flags = (curitem->flags() &~ PRIMFLAG_BLENDMODE_MASK) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA); // apply clipping - clipped = render_clip_quad(&prim->bounds, &cliprect, NULL); + clipped = render_clip_quad(&prim->bounds, &cliprect, nullptr); } break; } @@ -1796,7 +1796,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const } // add the overlay if it exists - if (container.overlay() != NULL && m_layerconfig.screen_overlay_enabled()) + if (container.overlay() != nullptr && m_layerconfig.screen_overlay_enabled()) { INT32 width, height; @@ -1840,7 +1840,7 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob // get a pointer to the relevant texture render_texture *texture = element.state_texture(state); - if (texture != NULL) + if (texture != nullptr) { render_primitive *prim = list.alloc(render_primitive::QUAD); @@ -1898,7 +1898,7 @@ bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_co // default to point not mapped mapped_x = -1.0; mapped_y = -1.0; - mapped_input_port = NULL; + mapped_input_port = nullptr; mapped_input_mask = 0; // convert target coordinates to float @@ -1910,7 +1910,7 @@ bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_co target_fy = (float)target_y / m_height; } // explicitly check for the UI container - if (container != NULL && container == &m_manager.ui_container()) + if (container != nullptr && container == &m_manager.ui_container()) { // this hit test went against the UI container if (target_fx >= 0.0f && target_fx < 1.0f && target_fy >= 0.0f && target_fy < 1.0f) @@ -1931,13 +1931,13 @@ bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_co if (m_curview->layer_enabled(layer)) { // iterate over items in the layer - for (layout_view::item *item = m_curview->first_item(layer); item != NULL; item = item->next()) + for (layout_view::item *item = m_curview->first_item(layer); item != nullptr; item = item->next()) { bool checkit; // if we're looking for a particular container, verify that we have the right one - if (container != NULL) - checkit = (item->screen() != NULL && &item->screen()->container() == container); + if (container != nullptr) + checkit = (item->screen() != nullptr && &item->screen()->container() == container); // otherwise, assume we're looking for an input else @@ -1967,12 +1967,12 @@ bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_co layout_view *render_target::view_by_index(int index) const { // scan the list of views within each layout, skipping those that don't apply - for (layout_file *file = m_filelist.first(); file != NULL; file = file->next()) - for (layout_view *view = file->first_view(); view != NULL; view = view->next()) + for (layout_file *file = m_filelist.first(); file != nullptr; file = file->next()) + for (layout_view *view = file->first_view(); view != nullptr; view = view->next()) if (!(m_flags & RENDER_CREATE_NO_ART) || !view->has_art()) if (index-- == 0) return view; - return NULL; + return nullptr; } @@ -1987,8 +1987,8 @@ int render_target::view_index(layout_view &targetview) const int index = 0; // scan the list of views within each layout, skipping those that don't apply - for (layout_file *file = m_filelist.first(); file != NULL; file = file->next()) - for (layout_view *view = file->first_view(); view != NULL; view = view->next()) + for (layout_file *file = m_filelist.first(); file != nullptr; file = file->next()) + for (layout_view *view = file->first_view(); view != nullptr; view = view->next()) if (!(m_flags & RENDER_CREATE_NO_ART) || !view->has_art()) { if (&targetview == view) @@ -2006,12 +2006,12 @@ int render_target::view_index(layout_view &targetview) const void render_target::config_load(xml_data_node &targetnode) { // find the view - const char *viewname = xml_get_attribute_string(&targetnode, "view", NULL); - if (viewname != NULL) + const char *viewname = xml_get_attribute_string(&targetnode, "view", nullptr); + if (viewname != nullptr) for (int viewnum = 0; viewnum < 1000; viewnum++) { const char *testname = view_name(viewnum); - if (testname == NULL) + if (testname == nullptr) break; if (!strcmp(viewname, testname)) { @@ -2307,7 +2307,7 @@ void render_target::add_clear_extents(render_primitive_list &list) render_primitive *prim = list.alloc(render_primitive::QUAD); set_render_bounds_xy(&prim->bounds, (float)x0, (float)y0, (float)x1, (float)y1); set_render_color(&prim->color, 1.0f, 0.0f, 0.0f, 0.0f); - prim->texture.base = NULL; + prim->texture.base = nullptr; prim->flags = PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA); clearlist.append(*prim); } @@ -2338,7 +2338,7 @@ void render_target::add_clear_and_optimize_primitive_list(render_primitive_list init_clear_extents(); // scan the list until we hit an intersection quad or a line - for (render_primitive *prim = list.first(); prim != NULL; prim = prim->next()) + for (render_primitive *prim = list.first(); prim != nullptr; prim = prim->next()) { // switch off the type switch (prim->type) @@ -2361,7 +2361,7 @@ void render_target::add_clear_and_optimize_primitive_list(render_primitive_list { // RGB multiply will multiply against 0, leaving nothing set_render_color(&prim->color, 1.0f, 0.0f, 0.0f, 0.0f); - prim->texture.base = NULL; + prim->texture.base = nullptr; prim->flags = (prim->flags & ~PRIMFLAG_BLENDMODE_MASK) | PRIMFLAG_BLENDMODE(BLENDMODE_NONE); } else @@ -2400,7 +2400,7 @@ done: render_manager::render_manager(running_machine &machine) : m_machine(machine), - m_ui_target(NULL), + m_ui_target(nullptr), m_live_textures(0), m_ui_container(global_alloc(render_container(*this))) { @@ -2409,7 +2409,7 @@ render_manager::render_manager(running_machine &machine) // create one container per screen screen_device_iterator iter(machine.root_device()); - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) screen->set_container(*container_alloc(screen)); } @@ -2436,7 +2436,7 @@ render_manager::~render_manager() bool render_manager::is_live(screen_device &screen) const { // iterate over all live targets and or together their screen masks - for (render_target *target = m_targetlist.first(); target != NULL; target = target->next()) + for (render_target *target = m_targetlist.first(); target != nullptr; target = target->next()) if (!target->hidden() && target->view_screens(target->view()).contains(screen)) return true; return false; @@ -2452,7 +2452,7 @@ float render_manager::max_update_rate() const { // iterate over all live targets and or together their screen masks float minimum = 0; - for (render_target *target = m_targetlist.first(); target != NULL; target = target->next()) + for (render_target *target = m_targetlist.first(); target != nullptr; target = target->next()) if (target->max_update_rate() != 0) { if (minimum == 0) @@ -2481,7 +2481,7 @@ render_target *render_manager::target_alloc(const char *layoutfile, UINT32 flags void render_manager::target_free(render_target *target) { - if (target != NULL) + if (target != nullptr) m_targetlist.remove(*target); } @@ -2493,11 +2493,11 @@ void render_manager::target_free(render_target *target) render_target *render_manager::target_by_index(int index) const { // count up the targets until we hit the requested index - for (render_target *target = m_targetlist.first(); target != NULL; target = target->next()) + for (render_target *target = m_targetlist.first(); target != nullptr; target = target->next()) if (!target->hidden()) if (index-- == 0) return target; - return NULL; + return nullptr; } @@ -2511,7 +2511,7 @@ float render_manager::ui_aspect(render_container *rc) int orient; float aspect; - if (rc == m_ui_container || rc == NULL) { + if (rc == m_ui_container || rc == nullptr) { // ui container, aggregated multi-screen target orient = orientation_add(m_ui_target->orientation(), m_ui_container->orientation()); @@ -2565,7 +2565,7 @@ render_texture *render_manager::texture_alloc(texture_scaler_func scaler, void * void render_manager::texture_free(render_texture *texture) { - if (texture != NULL) + if (texture != nullptr) { m_live_textures--; texture->release(); @@ -2602,11 +2602,11 @@ void render_manager::font_free(render_font *font) void render_manager::invalidate_all(void *refptr) { // permit NULL - if (refptr == NULL) + if (refptr == nullptr) return; // loop over targets - for (render_target *target = m_targetlist.first(); target != NULL; target = target->next()) + for (render_target *target = m_targetlist.first(); target != nullptr; target = target->next()) target->invalidate_all(refptr); } @@ -2617,7 +2617,7 @@ void render_manager::invalidate_all(void *refptr) void render_manager::resolve_tags() { - for (render_target *target = m_targetlist.first(); target != NULL; target = target->next()) + for (render_target *target = m_targetlist.first(); target != nullptr; target = target->next()) { target->resolve_tags(); } @@ -2630,8 +2630,8 @@ void render_manager::resolve_tags() render_container *render_manager::container_alloc(screen_device *screen) { - render_container *container = global_alloc(render_container(*this, screen)); - if (screen != NULL) + auto container = global_alloc(render_container(*this, screen)); + if (screen != nullptr) m_screen_container_list.append(*container); return container; } @@ -2659,15 +2659,15 @@ void render_manager::config_load(int config_type, xml_data_node *parentnode) return; // might not have any data - if (parentnode == NULL) + if (parentnode == nullptr) return; // check the UI target xml_data_node *uinode = xml_get_sibling(parentnode->child, "interface"); - if (uinode != NULL) + if (uinode != nullptr) { render_target *target = target_by_index(xml_get_attribute_int(uinode, "target", 0)); - if (target != NULL) + if (target != nullptr) set_ui_target(*target); } @@ -2675,7 +2675,7 @@ void render_manager::config_load(int config_type, xml_data_node *parentnode) for (xml_data_node *targetnode = xml_get_sibling(parentnode->child, "target"); targetnode; targetnode = xml_get_sibling(targetnode->next, "target")) { render_target *target = target_by_index(xml_get_attribute_int(targetnode, "index", -1)); - if (target != NULL) + if (target != nullptr) target->config_load(*targetnode); } @@ -2721,8 +2721,8 @@ void render_manager::config_save(int config_type, xml_data_node *parentnode) if (m_ui_target->index() != 0) { // create a node for it - xml_data_node *uinode = xml_add_child(parentnode, "interface", NULL); - if (uinode != NULL) + xml_data_node *uinode = xml_add_child(parentnode, "interface", nullptr); + if (uinode != nullptr) xml_set_attribute_int(uinode, "target", m_ui_target->index()); } @@ -2731,22 +2731,22 @@ void render_manager::config_save(int config_type, xml_data_node *parentnode) { // get this target and break when we fail render_target *target = target_by_index(targetnum); - if (target == NULL) + if (target == nullptr) break; // create a node - xml_data_node *targetnode = xml_add_child(parentnode, "target", NULL); - if (targetnode != NULL && !target->config_save(*targetnode)) + xml_data_node *targetnode = xml_add_child(parentnode, "target", nullptr); + if (targetnode != nullptr && !target->config_save(*targetnode)) xml_delete_node(targetnode); } // iterate over screen containers int scrnum = 0; - for (render_container *container = m_screen_container_list.first(); container != NULL; container = container->next(), scrnum++) + for (render_container *container = m_screen_container_list.first(); container != nullptr; container = container->next(), scrnum++) { // create a node - xml_data_node *screennode = xml_add_child(parentnode, "screen", NULL); - if (screennode != NULL) + xml_data_node *screennode = xml_add_child(parentnode, "screen", nullptr); + if (screennode != nullptr) { bool changed = false; diff --git a/src/emu/render.h b/src/emu/render.h index 7b675d04177..e4136ded0d1 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -223,7 +223,7 @@ class render_screen_list public: // construction/destruction item(screen_device &screen) - : m_next(NULL), + : m_next(nullptr), m_screen(screen) { } // state @@ -243,7 +243,7 @@ public: int contains(screen_device &screen) const { int count = 0; - for (item *curitem = m_list.first(); curitem != NULL; curitem = curitem->m_next) + for (item *curitem = m_list.first(); curitem != nullptr; curitem = curitem->m_next) if (&curitem->m_screen == &screen) count++; return count; } @@ -308,8 +308,8 @@ public: type(), flags(0), width(0), - container(NULL), - m_next(NULL) + container(nullptr), + m_next(nullptr) {} // render primitive types @@ -408,7 +408,7 @@ class render_texture ~render_texture(); // reset before re-use - void reset(render_manager &manager, texture_scaler_func scaler = NULL, void *param = NULL); + void reset(render_manager &manager, texture_scaler_func scaler = nullptr, void *param = nullptr); // release resources when freed void release(); @@ -468,7 +468,7 @@ class render_container friend class render_target; // construction/destruction - render_container(render_manager &manager, screen_device *screen = NULL); + render_container(render_manager &manager, screen_device *screen = nullptr); ~render_container(); public: @@ -514,13 +514,13 @@ public: void add_quad(float x0, float y0, float x1, float y1, rgb_t argb, render_texture *texture, UINT32 flags); void add_char(float x0, float y0, float height, float aspect, rgb_t argb, render_font &font, UINT16 ch); void add_point(float x0, float y0, float diameter, rgb_t argb, UINT32 flags) { add_line(x0, y0, x0, y0, diameter, argb, flags); } - void add_rect(float x0, float y0, float x1, float y1, rgb_t argb, UINT32 flags) { add_quad(x0, y0, x1, y1, argb, NULL, flags); } + void add_rect(float x0, float y0, float x1, float y1, rgb_t argb, UINT32 flags) { add_quad(x0, y0, x1, y1, argb, nullptr, flags); } // brightness/contrast/gamma helpers bool has_brightness_contrast_gamma_changes() const { return (m_user.m_brightness != 1.0f || m_user.m_contrast != 1.0f || m_user.m_gamma != 1.0f); } UINT8 apply_brightness_contrast_gamma(UINT8 value); float apply_brightness_contrast_gamma_fp(float value); - const rgb_t *bcg_lookup_table(int texformat, palette_t *palette = NULL); + const rgb_t *bcg_lookup_table(int texformat, palette_t *palette = nullptr); private: // an item describes a high level primitive that is added to a container @@ -530,7 +530,7 @@ private: friend class simple_list; public: - item() : m_next(NULL), m_type(0), m_flags(0), m_internal(0), m_width(0), m_texture(NULL) { } + item() : m_next(nullptr), m_type(0), m_flags(0), m_internal(0), m_width(0), m_texture(nullptr) { } // getters item *next() const { return m_next; } @@ -873,7 +873,7 @@ class render_target friend class render_manager; // construction/destruction - render_target(render_manager &manager, const char *layoutfile = NULL, UINT32 flags = 0); + render_target(render_manager &manager, const char *layoutfile = nullptr, UINT32 flags = 0); ~render_target(); public: @@ -1024,25 +1024,25 @@ public: float max_update_rate() const; // targets - render_target *target_alloc(const char *layoutfile = NULL, UINT32 flags = 0); + render_target *target_alloc(const char *layoutfile = nullptr, UINT32 flags = 0); void target_free(render_target *target); render_target *first_target() const { return m_targetlist.first(); } render_target *target_by_index(int index) const; // UI targets - render_target &ui_target() const { assert(m_ui_target != NULL); return *m_ui_target; } + render_target &ui_target() const { assert(m_ui_target != nullptr); return *m_ui_target; } void set_ui_target(render_target &target) { m_ui_target = ⌖ } - float ui_aspect(render_container *rc = NULL); + float ui_aspect(render_container *rc = nullptr); // UI containers - render_container &ui_container() const { assert(m_ui_container != NULL); return *m_ui_container; } + render_container &ui_container() const { assert(m_ui_container != nullptr); return *m_ui_container; } // textures - render_texture *texture_alloc(texture_scaler_func scaler = NULL, void *param = NULL); + render_texture *texture_alloc(texture_scaler_func scaler = nullptr, void *param = nullptr); void texture_free(render_texture *texture); // fonts - render_font *font_alloc(const char *filename = NULL); + render_font *font_alloc(const char *filename = nullptr); void font_free(render_font *font); // reference tracking @@ -1053,7 +1053,7 @@ public: private: // containers - render_container *container_alloc(screen_device *screen = NULL); + render_container *container_alloc(screen_device *screen = nullptr); void container_free(render_container *container); // config callbacks diff --git a/src/emu/rendersw.inc b/src/emu/rendersw.inc index 3ab326a5459..a7dcbac0191 100644 --- a/src/emu/rendersw.inc +++ b/src/emu/rendersw.inc @@ -610,7 +610,7 @@ private: INT32 endx = setup.endx; // ensure all parameters are valid - assert(prim.texture.palette != NULL); + assert(prim.texture.palette != nullptr); // fast case: no coloring, no alpha if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) @@ -718,7 +718,7 @@ private: INT32 endx = setup.endx; // ensure all parameters are valid - assert(prim.texture.palette != NULL); + assert(prim.texture.palette != nullptr); // fast case: no coloring, no alpha if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) @@ -811,7 +811,7 @@ private: INT32 endx = setup.endx; // ensure all parameters are valid - assert(prim.texture.palette != NULL); + assert(prim.texture.palette != nullptr); // fast case: no coloring, no alpha if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) @@ -918,7 +918,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -965,7 +965,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1022,7 +1022,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1088,7 +1088,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1139,7 +1139,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1196,7 +1196,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1262,7 +1262,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1325,7 +1325,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1396,7 +1396,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1467,7 +1467,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1546,7 +1546,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1601,7 +1601,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1665,7 +1665,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1738,7 +1738,7 @@ private: INT32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case - if (palbase == NULL) + if (palbase == nullptr) { // loop over cols for (INT32 x = setup.startx; x < endx; x++) @@ -1910,7 +1910,7 @@ public: static void draw_primitives(const render_primitive_list &primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch) { // loop over the list and render each element - for (const render_primitive *prim = primlist.first(); prim != NULL; prim = prim->next()) + for (const render_primitive *prim = primlist.first(); prim != nullptr; prim = prim->next()) switch (prim->type) { case render_primitive::LINE: diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp index dea9f32db4a..63ff7dc47de 100644 --- a/src/emu/rendfont.cpp +++ b/src/emu/rendfont.cpp @@ -33,7 +33,7 @@ inline const char *next_line(const char *ptr) // if we hit the end, return NULL if (*ptr == 0) - return NULL; + return nullptr; // eat the trailing linefeed if present if (*++ptr == 10) @@ -83,15 +83,15 @@ render_font::render_font(render_manager &manager, const char *filename) m_yoffs(0), m_scale(1.0f), m_rawsize(0), - m_osdfont(NULL) + m_osdfont(nullptr) { memset(m_glyphs, 0, sizeof(m_glyphs)); // if this is an OSD font, we're done - if (filename != NULL) + if (filename != nullptr) { m_osdfont = manager.machine().osd().font_alloc(); - if (m_osdfont != NULL) + if (m_osdfont != nullptr) { if (m_osdfont->open(manager.machine().options().font_path(), filename, m_height)) { @@ -100,16 +100,16 @@ render_font::render_font(render_manager &manager, const char *filename) return; } global_free(m_osdfont); - m_osdfont = NULL; + m_osdfont = nullptr; } } // if the filename is 'default' default to 'ui.bdf' for backwards compatibility - if (filename != NULL && core_stricmp(filename, "default") == 0) + if (filename != nullptr && core_stricmp(filename, "default") == 0) filename = "ui.bdf"; // attempt to load the cached version of the font first - if (filename != NULL && load_cached_bdf(filename)) + if (filename != nullptr && load_cached_bdf(filename)) return; // load the raw data instead @@ -127,19 +127,19 @@ render_font::render_font(render_manager &manager, const char *filename) render_font::~render_font() { // free all the subtables - for (int tablenum = 0; tablenum < 256; tablenum++) - if (m_glyphs[tablenum]) + for (auto & elem : m_glyphs) + if (elem) { for (unsigned int charnum = 0; charnum < 256; charnum++) { - glyph &gl = m_glyphs[tablenum][charnum]; + glyph &gl = elem[charnum]; m_manager.texture_free(gl.texture); } - delete[] m_glyphs[tablenum]; + delete[] elem; } // release the OSD font - if (m_osdfont != NULL) + if (m_osdfont != nullptr) { m_osdfont->close(); global_free(m_osdfont); @@ -178,7 +178,7 @@ void render_font::char_expand(unicode_char chnum, glyph &gl) else { // punt if nothing there - if (gl.bmwidth == 0 || gl.bmheight == 0 || gl.rawdata == NULL) + if (gl.bmwidth == 0 || gl.bmheight == 0 || gl.rawdata == nullptr) return; // allocate a new bitmap of the size we need @@ -191,7 +191,7 @@ void render_font::char_expand(unicode_char chnum, glyph &gl) for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height + m_yoffs - gl.yoffs - gl.bmheight; - UINT32 *dest = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : NULL; + UINT32 *dest = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; // text format if (m_format == FF_TEXT) @@ -214,7 +214,7 @@ void render_font::char_expand(unicode_char chnum, glyph &gl) } // expand the four bits - if (dest != NULL) + if (dest != nullptr) { *dest++ = (bits & 8) ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff); *dest++ = (bits & 4) ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff); @@ -234,7 +234,7 @@ void render_font::char_expand(unicode_char chnum, glyph &gl) { if (accumbit == 7) accum = *ptr++; - if (dest != NULL) + if (dest != nullptr) *dest++ = (accum & (1 << accumbit)) ? rgb_t(0xff,0xff,0xff,0xff) : rgb_t(0x00,0xff,0xff,0xff); accumbit = (accumbit - 1) & 7; } @@ -296,7 +296,7 @@ void render_font::get_scaled_bitmap_and_bounds(bitmap_argb32 &dest, float height return; // if no texture, fill the target - if (gl.texture == NULL) + if (gl.texture == nullptr) { dest.fill(0); return; @@ -304,7 +304,7 @@ void render_font::get_scaled_bitmap_and_bounds(bitmap_argb32 &dest, float height // scale the font bitmap_argb32 tempbitmap(&dest.pix(0), bounds.width(), bounds.height(), dest.rowpixels()); - render_texture::hq_scale(tempbitmap, gl.bitmap, gl.bitmap.cliprect(), NULL); + render_texture::hq_scale(tempbitmap, gl.bitmap, gl.bitmap.cliprect(), nullptr); } @@ -450,7 +450,7 @@ bool render_font::load_bdf() // first find the FONTBOUNDINGBOX tag const char *ptr; - for (ptr = &m_rawdata[0]; ptr != NULL; ptr = next_line(ptr)) + for (ptr = &m_rawdata[0]; ptr != nullptr; ptr = next_line(ptr)) { // we only care about a tiny few fields if (strncmp(ptr, "FONTBOUNDINGBOX ", 16) == 0) @@ -467,7 +467,7 @@ bool render_font::load_bdf() // now scan for characters int charcount = 0; - for ( ; ptr != NULL; ptr = next_line(ptr)) + for ( ; ptr != nullptr; ptr = next_line(ptr)) { // stop at ENDFONT if (strncmp(ptr, "ENDFONT", 7) == 0) @@ -477,12 +477,12 @@ bool render_font::load_bdf() if (strncmp(ptr, "STARTCHAR ", 10) == 0) { int bmwidth = -1, bmheight = -1, xoffs = -1, yoffs = -1; - const char *rawdata = NULL; + const char *rawdata = nullptr; int charnum = -1; int width = -1; // scan for interesting per-character tags - for ( ; ptr != NULL; ptr = next_line(ptr)) + for ( ; ptr != nullptr; ptr = next_line(ptr)) { // ENCODING tells us which character if (strncmp(ptr, "ENCODING ", 9) == 0) @@ -510,13 +510,13 @@ bool render_font::load_bdf() else if (strncmp(ptr, "BITMAP", 6) == 0) { // stash the raw pointer and scan for the end of the character - for (rawdata = ptr = next_line(ptr); ptr != NULL && strncmp(ptr, "ENDCHAR", 7) != 0; ptr = next_line(ptr)) { } + for (rawdata = ptr = next_line(ptr); ptr != nullptr && strncmp(ptr, "ENDCHAR", 7) != 0; ptr = next_line(ptr)) { } break; } } // if we have everything, allocate a new character - if (charnum >= 0 && charnum < 65536 && rawdata != NULL && bmwidth >= 0 && bmheight >= 0) + if (charnum >= 0 && charnum < 65536 && rawdata != nullptr && bmwidth >= 0 && bmheight >= 0) { // if we don't have a subtable yet, make one if (!m_glyphs[charnum / 256]) @@ -705,10 +705,10 @@ bool render_font::save_cached(const char *filename, UINT32 hash) for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height + m_yoffs - gl.yoffs - gl.bmheight; - const UINT32 *src = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : NULL; + const UINT32 *src = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; for (int x = 0; x < gl.bmwidth; x++) { - if (src != NULL && rgb_t(src[x]).a() != 0) + if (src != nullptr && rgb_t(src[x]).a() != 0) accum |= 1 << accbit; if (accbit-- == 0) { @@ -731,7 +731,7 @@ bool render_font::save_cached(const char *filename, UINT32 hash) // free the bitmap and texture m_manager.texture_free(gl.texture); gl.bitmap.reset(); - gl.texture = NULL; + gl.texture = nullptr; } // compute the table entry diff --git a/src/emu/rendfont.h b/src/emu/rendfont.h index 13d06be7dd9..aced202260d 100644 --- a/src/emu/rendfont.h +++ b/src/emu/rendfont.h @@ -56,8 +56,8 @@ private: : width(0), xoffs(0), yoffs(0), bmwidth(0), bmheight(0), - rawdata(NULL), - texture(NULL) { } + rawdata(nullptr), + texture(nullptr) { } INT32 width; // width from this character to the next INT32 xoffs, yoffs; // X and Y offset from baseline to top,left of bitmap diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp index 7e90ed81d44..582ed75fef2 100644 --- a/src/emu/rendlay.cpp +++ b/src/emu/rendlay.cpp @@ -164,7 +164,7 @@ static int get_variable_value(running_machine &machine, const char *string, char // screen 0 parameters screen_device_iterator iter(machine.root_device()); int scrnum = 0; - for (const screen_device *device = iter.first(); device != NULL; device = iter.next(), scrnum++) + for (const screen_device *device = iter.first(); device != nullptr; device = iter.next(), scrnum++) { // native X aspect factor sprintf(temp, "~scr%dnativexaspect~", scrnum); @@ -220,15 +220,15 @@ static int get_variable_value(running_machine &machine, const char *string, char static const char *xml_get_attribute_string_with_subst(running_machine &machine, xml_data_node &node, const char *attribute, const char *defvalue) { - const char *str = xml_get_attribute_string(&node, attribute, NULL); + const char *str = xml_get_attribute_string(&node, attribute, nullptr); static char buffer[1000]; // if nothing, just return the default - if (str == NULL) + if (str == nullptr) return defvalue; // if no tildes, don't worry - if (strchr(str, '~') == NULL) + if (strchr(str, '~') == nullptr) return str; // make a copy of the string, doing substitutions along the way @@ -257,11 +257,11 @@ static const char *xml_get_attribute_string_with_subst(running_machine &machine, static int xml_get_attribute_int_with_subst(running_machine &machine, xml_data_node &node, const char *attribute, int defvalue) { - const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, NULL); + const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, nullptr); int value; unsigned int uvalue; - if (string == NULL) + if (string == nullptr) return defvalue; if (string[0] == '$') return (sscanf(&string[1], "%X", &uvalue) == 1) ? uvalue : defvalue; @@ -281,10 +281,10 @@ static int xml_get_attribute_int_with_subst(running_machine &machine, xml_data_n static float xml_get_attribute_float_with_subst(running_machine &machine, xml_data_node &node, const char *attribute, float defvalue) { - const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, NULL); + const char *string = xml_get_attribute_string_with_subst(machine, node, attribute, nullptr); float value; - if (string == NULL || sscanf(string, "%f", &value) != 1) + if (string == nullptr || sscanf(string, "%f", &value) != 1) return defvalue; return value; } @@ -297,7 +297,7 @@ static float xml_get_attribute_float_with_subst(running_machine &machine, xml_da void parse_bounds(running_machine &machine, xml_data_node *boundsnode, render_bounds &bounds) { // skip if nothing - if (boundsnode == NULL) + if (boundsnode == nullptr) { bounds.x0 = bounds.y0 = 0.0f; bounds.x1 = bounds.y1 = 1.0f; @@ -305,7 +305,7 @@ void parse_bounds(running_machine &machine, xml_data_node *boundsnode, render_bo } // parse out the data - if (xml_get_attribute(boundsnode, "left") != NULL) + if (xml_get_attribute(boundsnode, "left") != nullptr) { // left/right/top/bottom format bounds.x0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "left", 0.0f); @@ -313,7 +313,7 @@ void parse_bounds(running_machine &machine, xml_data_node *boundsnode, render_bo bounds.y0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "top", 0.0f); bounds.y1 = xml_get_attribute_float_with_subst(machine, *boundsnode, "bottom", 1.0f); } - else if (xml_get_attribute(boundsnode, "x") != NULL) + else if (xml_get_attribute(boundsnode, "x") != nullptr) { // x/y/width/height format bounds.x0 = xml_get_attribute_float_with_subst(machine, *boundsnode, "x", 0.0f); @@ -338,7 +338,7 @@ void parse_bounds(running_machine &machine, xml_data_node *boundsnode, render_bo void parse_color(running_machine &machine, xml_data_node *colornode, render_color &color) { // skip if nothing - if (colornode == NULL) + if (colornode == nullptr) { color.r = color.g = color.b = color.a = 1.0f; return; @@ -366,7 +366,7 @@ void parse_color(running_machine &machine, xml_data_node *colornode, render_colo static void parse_orientation(running_machine &machine, xml_data_node *orientnode, int &orientation) { // skip if nothing - if (orientnode == NULL) + if (orientnode == nullptr) { orientation = ROT0; return; @@ -401,14 +401,14 @@ static void parse_orientation(running_machine &machine, xml_data_node *orientnod //------------------------------------------------- layout_element::layout_element(running_machine &machine, xml_data_node &elemnode, const char *dirname) - : m_next(NULL), + : m_next(nullptr), m_machine(machine), m_defstate(0), m_maxstate(0) { // extract the name - const char *name = xml_get_attribute_string_with_subst(machine, elemnode, "name", NULL); - if (name == NULL) + const char *name = xml_get_attribute_string_with_subst(machine, elemnode, "name", nullptr); + if (name == nullptr) throw emu_fatalerror("All layout elements must have a name!\n"); m_name = name; @@ -418,7 +418,7 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode // parse components in order bool first = true; render_bounds bounds = { 0 }; - for (xml_data_node *compnode = elemnode.child; compnode != NULL; compnode = compnode->next) + for (xml_data_node *compnode = elemnode.child; compnode != nullptr; compnode = compnode->next) { // allocate a new component component &newcomp = m_complist.append(*global_alloc(component(machine, *compnode, dirname))); @@ -453,7 +453,7 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode m_maxstate = 65536; } - if (m_complist.first() != NULL) + if (m_complist.first() != nullptr) { // determine the scale/offset for normalization float xoffs = bounds.x0; @@ -462,7 +462,7 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode float yscale = 1.0f / (bounds.y1 - bounds.y0); // normalize all the component bounds - for (component *curcomp = m_complist.first(); curcomp != NULL; curcomp = curcomp->next()) + for (component *curcomp = m_complist.first(); curcomp != nullptr; curcomp = curcomp->next()) { curcomp->m_bounds.x0 = (curcomp->m_bounds.x0 - xoffs) * xscale; curcomp->m_bounds.x1 = (curcomp->m_bounds.x1 - xoffs) * xscale; @@ -494,7 +494,7 @@ layout_element::~layout_element() render_texture *layout_element::state_texture(int state) { assert(state <= m_maxstate); - if (m_elemtex[state].m_texture == NULL) + if (m_elemtex[state].m_texture == nullptr) { m_elemtex[state].m_element = this; m_elemtex[state].m_state = state; @@ -515,7 +515,7 @@ void layout_element::element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, c texture *elemtex = (texture *)param; // iterate over components that are part of the current state - for (component *curcomp = elemtex->m_element->m_complist.first(); curcomp != NULL; curcomp = curcomp->next()) + for (component *curcomp = elemtex->m_element->m_complist.first(); curcomp != nullptr; curcomp = curcomp->next()) if (curcomp->m_state == -1 || curcomp->m_state == elemtex->m_state) { // get the local scaled bounds @@ -541,8 +541,8 @@ void layout_element::element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, c //------------------------------------------------- layout_element::texture::texture() - : m_element(NULL), - m_texture(NULL), + : m_element(nullptr), + m_texture(nullptr), m_state(0) { } @@ -554,7 +554,7 @@ layout_element::texture::texture() layout_element::texture::~texture() { - if (m_element != NULL) + if (m_element != nullptr) m_element->machine().render().texture_free(m_texture); } @@ -569,12 +569,12 @@ layout_element::texture::~texture() //------------------------------------------------- layout_element::component::component(running_machine &machine, xml_data_node &compnode, const char *dirname) - : m_next(NULL), + : m_next(nullptr), m_type(CTYPE_INVALID), m_state(0) { - for (int i=0;i &elemlist) - : m_next(NULL), + : m_next(nullptr), m_aspect(1.0f), m_scraspect(1.0f) { @@ -2140,31 +2140,31 @@ layout_view::layout_view(running_machine &machine, xml_data_node &viewnode, simp // if we have a bounds item, load it xml_data_node *boundsnode = xml_get_sibling(viewnode.child, "bounds"); m_expbounds.x0 = m_expbounds.y0 = m_expbounds.x1 = m_expbounds.y1 = 0; - if (boundsnode != NULL) + if (boundsnode != nullptr) parse_bounds(machine, xml_get_sibling(boundsnode, "bounds"), m_expbounds); // load backdrop items - for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "backdrop"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "backdrop")) + for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "backdrop"); itemnode != nullptr; itemnode = xml_get_sibling(itemnode->next, "backdrop")) m_backdrop_list.append(*global_alloc(item(machine, *itemnode, elemlist))); // load screen items - for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "screen"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "screen")) + for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "screen"); itemnode != nullptr; itemnode = xml_get_sibling(itemnode->next, "screen")) m_screen_list.append(*global_alloc(item(machine, *itemnode, elemlist))); // load overlay items - for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "overlay"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "overlay")) + for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "overlay"); itemnode != nullptr; itemnode = xml_get_sibling(itemnode->next, "overlay")) m_overlay_list.append(*global_alloc(item(machine, *itemnode, elemlist))); // load bezel items - for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "bezel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "bezel")) + for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "bezel"); itemnode != nullptr; itemnode = xml_get_sibling(itemnode->next, "bezel")) m_bezel_list.append(*global_alloc(item(machine, *itemnode, elemlist))); // load cpanel items - for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "cpanel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "cpanel")) + for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "cpanel"); itemnode != nullptr; itemnode = xml_get_sibling(itemnode->next, "cpanel")) m_cpanel_list.append(*global_alloc(item(machine, *itemnode, elemlist))); // load marquee items - for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "marquee"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "marquee")) + for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "marquee"); itemnode != nullptr; itemnode = xml_get_sibling(itemnode->next, "marquee")) m_marquee_list.append(*global_alloc(item(machine, *itemnode, elemlist))); // recompute the data for the view based on a default layer config @@ -2196,7 +2196,7 @@ layout_view::item *layout_view::first_item(item_layer layer) const case ITEM_LAYER_BEZEL: return m_bezel_list.first(); case ITEM_LAYER_CPANEL: return m_cpanel_list.first(); case ITEM_LAYER_MARQUEE: return m_marquee_list.first(); - default: return NULL; + default: return nullptr; } } @@ -2231,7 +2231,7 @@ void layout_view::recompute(render_layer_config layerconfig) // only do it if requested if (m_layenabled[layer]) - for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next()) + for (item *curitem = first_item(layer); curitem != nullptr; curitem = curitem->next()) { // accumulate bounds if (first) @@ -2241,7 +2241,7 @@ void layout_view::recompute(render_layer_config layerconfig) first = false; // accumulate screen bounds - if (curitem->m_screen != NULL) + if (curitem->m_screen != nullptr) { if (scrfirst) m_scrbounds = curitem->m_rawbounds; @@ -2292,7 +2292,7 @@ void layout_view::recompute(render_layer_config layerconfig) // normalize all the item bounds for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; ++layer) - for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next()) + for (item *curitem = first_item(layer); curitem != nullptr; curitem = curitem->next()) { curitem->m_bounds.x0 = target_bounds.x0 + (curitem->m_rawbounds.x0 - xoffs) * xscale; curitem->m_bounds.x1 = target_bounds.x0 + (curitem->m_rawbounds.x1 - xoffs) * xscale; @@ -2310,7 +2310,7 @@ void layout_view::resolve_tags() { for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; ++layer) { - for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next()) + for (item *curitem = first_item(layer); curitem != nullptr; curitem = curitem->next()) { curitem->resolve_tags(); } @@ -2328,11 +2328,11 @@ void layout_view::resolve_tags() //------------------------------------------------- layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simple_list &elemlist) - : m_next(NULL), - m_element(NULL), - m_input_port(NULL), + : m_next(nullptr), + m_element(nullptr), + m_input_port(nullptr), m_input_mask(0), - m_screen(NULL), + m_screen(nullptr), m_orientation(ROT0) { // allocate a copy of the output name @@ -2342,16 +2342,16 @@ layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simpl m_input_tag = xml_get_attribute_string_with_subst(machine, itemnode, "inputtag", ""); // find the associated element - const char *name = xml_get_attribute_string_with_subst(machine, itemnode, "element", NULL); - if (name != NULL) + const char *name = xml_get_attribute_string_with_subst(machine, itemnode, "element", nullptr); + if (name != nullptr) { // search the list of elements for a match - for (m_element = elemlist.first(); m_element != NULL; m_element = m_element->next()) + for (m_element = elemlist.first(); m_element != nullptr; m_element = m_element->next()) if (strcmp(name, m_element->name()) == 0) break; // error if not found - if (m_element == NULL) + if (m_element == nullptr) throw emu_fatalerror("Unable to find layout element %s", name); } @@ -2363,7 +2363,7 @@ layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simpl m_screen = iter.byindex(index); } m_input_mask = xml_get_attribute_int_with_subst(machine, itemnode, "inputmask", 0); - if (m_output_name[0] != 0 && m_element != NULL) + if (m_output_name[0] != 0 && m_element != nullptr) output_set_value(m_output_name.c_str(), m_element->default_state()); parse_bounds(machine, xml_get_sibling(itemnode.child, "bounds"), m_rawbounds); parse_color(machine, xml_get_sibling(itemnode.child, "color"), m_color); @@ -2372,12 +2372,12 @@ layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simpl // sanity checks if (strcmp(itemnode.name, "screen") == 0) { - if (m_screen == NULL) + if (m_screen == nullptr) throw emu_fatalerror("Layout references invalid screen index %d", index); } else { - if (m_element == NULL) + if (m_element == nullptr) throw emu_fatalerror("Layout item of type %s require an element tag", itemnode.name); } @@ -2404,7 +2404,7 @@ layout_view::item::~item() render_container *layout_view::item::screen_container(running_machine &machine) const { - return (m_screen != NULL) ? &m_screen->container() : NULL; + return (m_screen != nullptr) ? &m_screen->container() : nullptr; } @@ -2416,7 +2416,7 @@ int layout_view::item::state() const { int state = 0; - assert(m_element != NULL); + assert(m_element != nullptr); // if configured to an output, fetch the output value if (m_output_name[0] != 0) @@ -2425,10 +2425,10 @@ int layout_view::item::state() const // if configured to an input, fetch the input value else if (m_input_tag[0] != 0) { - if (m_input_port != NULL) + if (m_input_port != nullptr) { ioport_field *field = m_input_port->field(m_input_mask); - if (field != NULL) + if (field != nullptr) state = ((m_input_port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0; } } @@ -2460,11 +2460,11 @@ void layout_view::item::resolve_tags() //------------------------------------------------- layout_file::layout_file(running_machine &machine, xml_data_node &rootnode, const char *dirname) - : m_next(NULL) + : m_next(nullptr) { // find the layout node xml_data_node *mamelayoutnode = xml_get_sibling(rootnode.child, "mamelayout"); - if (mamelayoutnode == NULL) + if (mamelayoutnode == nullptr) throw emu_fatalerror("Invalid XML file: missing mamelayout node"); // validate the config data version @@ -2473,11 +2473,11 @@ layout_file::layout_file(running_machine &machine, xml_data_node &rootnode, cons throw emu_fatalerror("Invalid XML file: unsupported version"); // parse all the elements - for (xml_data_node *elemnode = xml_get_sibling(mamelayoutnode->child, "element"); elemnode != NULL; elemnode = xml_get_sibling(elemnode->next, "element")) + for (xml_data_node *elemnode = xml_get_sibling(mamelayoutnode->child, "element"); elemnode != nullptr; elemnode = xml_get_sibling(elemnode->next, "element")) m_elemlist.append(*global_alloc(layout_element(machine, *elemnode, dirname))); // parse all the views - for (xml_data_node *viewnode = xml_get_sibling(mamelayoutnode->child, "view"); viewnode != NULL; viewnode = xml_get_sibling(viewnode->next, "view")) + for (xml_data_node *viewnode = xml_get_sibling(mamelayoutnode->child, "view"); viewnode != nullptr; viewnode = xml_get_sibling(viewnode->next, "view")) m_viewlist.append(*global_alloc(layout_view(machine, *viewnode, m_elemlist))); } diff --git a/src/emu/rendutil.cpp b/src/emu/rendutil.cpp index 872533583b5..1a487536455 100644 --- a/src/emu/rendutil.cpp +++ b/src/emu/rendutil.cpp @@ -370,7 +370,7 @@ int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_qu { float frac = (clip->y0 - bounds->y0) / (bounds->y1 - bounds->y0); bounds->y0 = clip->y0; - if (texcoords != NULL) + if (texcoords != nullptr) { texcoords->tl.u += (texcoords->bl.u - texcoords->tl.u) * frac; texcoords->tl.v += (texcoords->bl.v - texcoords->tl.v) * frac; @@ -384,7 +384,7 @@ int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_qu { float frac = (bounds->y1 - clip->y1) / (bounds->y1 - bounds->y0); bounds->y1 = clip->y1; - if (texcoords != NULL) + if (texcoords != nullptr) { texcoords->bl.u -= (texcoords->bl.u - texcoords->tl.u) * frac; texcoords->bl.v -= (texcoords->bl.v - texcoords->tl.v) * frac; @@ -398,7 +398,7 @@ int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_qu { float frac = (clip->x0 - bounds->x0) / (bounds->x1 - bounds->x0); bounds->x0 = clip->x0; - if (texcoords != NULL) + if (texcoords != nullptr) { texcoords->tl.u += (texcoords->tr.u - texcoords->tl.u) * frac; texcoords->tl.v += (texcoords->tr.v - texcoords->tl.v) * frac; @@ -412,7 +412,7 @@ int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_qu { float frac = (bounds->x1 - clip->x1) / (bounds->x1 - bounds->x0); bounds->x1 = clip->x1; - if (texcoords != NULL) + if (texcoords != nullptr) { texcoords->tr.u -= (texcoords->tr.u - texcoords->tl.u) * frac; texcoords->tr.v -= (texcoords->tr.v - texcoords->tl.v) * frac; @@ -536,7 +536,7 @@ bool render_load_png(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, // open the file std::string fname; - if (dirname == NULL) + if (dirname == nullptr) fname.assign(filename); else fname.assign(dirname).append(PATH_SEPARATOR).append(filename); diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp index a43adc4f58b..c5de902a482 100644 --- a/src/emu/romload.cpp +++ b/src/emu/romload.cpp @@ -37,7 +37,7 @@ class open_chd public: open_chd(const char *region) - : m_next(NULL), + : m_next(nullptr), m_region(region) { } open_chd *next() const { return m_next; } @@ -56,7 +56,7 @@ private: struct romload_private { - running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + running_machine &machine() const { assert(m_machine != nullptr); return *m_machine; } running_machine *m_machine; /* machine object where needed */ @@ -93,7 +93,7 @@ file_error common_process_file(emu_options &options, const char *location, const { file_error filerr; - if (location != NULL && strcmp(location, "") != 0) + if (location != nullptr && strcmp(location, "") != 0) filerr = image_file.open(location, PATH_SEPARATOR, ROM_GETNAME(romp), ext); else filerr = image_file.open(ROM_GETNAME(romp), ext); @@ -114,7 +114,7 @@ file_error common_process_file(emu_options &options, const char *location, bool if (filerr != FILERR_NONE) { global_free(*image_file); - *image_file = NULL; + *image_file = nullptr; } return filerr; } @@ -131,10 +131,10 @@ file_error common_process_file(emu_options &options, const char *location, bool chd_file *get_disk_handle(running_machine &machine, const char *region) { - for (open_chd *curdisk = machine.romload_data->chd_list.first(); curdisk != NULL; curdisk = curdisk->next()) + for (open_chd *curdisk = machine.romload_data->chd_list.first(); curdisk != nullptr; curdisk = curdisk->next()) if (strcmp(curdisk->region(), region) == 0) return &curdisk->chd(); - return NULL; + return nullptr; } @@ -145,7 +145,7 @@ chd_file *get_disk_handle(running_machine &machine, const char *region) int set_disk_handle(running_machine &machine, const char *region, const char *fullpath) { - open_chd *chd = global_alloc(open_chd(region)); + auto chd = global_alloc(open_chd(region)); chd_error err = chd->orig_chd().open(fullpath); if (err == CHDERR_NONE) machine.romload_data->chd_list.append(*chd); @@ -170,7 +170,7 @@ const rom_entry *rom_first_region(const device_t &device) const rom_entry *romp = device.rom_region(); while (romp && ROMENTRY_ISPARAMETER(romp)) romp++; - return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL; + return (romp != nullptr && !ROMENTRY_ISEND(romp)) ? romp : nullptr; } @@ -186,7 +186,7 @@ const rom_entry *rom_next_region(const rom_entry *romp) romp++; while (ROMENTRY_ISPARAMETER(romp)) romp++; - return ROMENTRY_ISEND(romp) ? NULL : romp; + return ROMENTRY_ISEND(romp) ? nullptr : romp; } @@ -200,7 +200,7 @@ const rom_entry *rom_first_file(const rom_entry *romp) romp++; while (!ROMENTRY_ISFILE(romp) && !ROMENTRY_ISREGIONEND(romp)) romp++; - return ROMENTRY_ISREGIONEND(romp) ? NULL : romp; + return ROMENTRY_ISREGIONEND(romp) ? nullptr : romp; } @@ -214,7 +214,7 @@ const rom_entry *rom_next_file(const rom_entry *romp) romp++; while (!ROMENTRY_ISFILE(romp) && !ROMENTRY_ISREGIONEND(romp)) romp++; - return ROMENTRY_ISREGIONEND(romp) ? NULL : romp; + return ROMENTRY_ISREGIONEND(romp) ? nullptr : romp; } @@ -228,7 +228,7 @@ const rom_entry *rom_first_parameter(const device_t &device) const rom_entry *romp = device.rom_region(); while (romp && !ROMENTRY_ISEND(romp) && !ROMENTRY_ISPARAMETER(romp)) romp++; - return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL; + return (romp != nullptr && !ROMENTRY_ISEND(romp)) ? romp : nullptr; } @@ -242,7 +242,7 @@ const rom_entry *rom_next_parameter(const rom_entry *romp) romp++; while (!ROMENTRY_ISREGIONEND(romp) && !ROMENTRY_ISPARAMETER(romp)) romp++; - return ROMENTRY_ISEND(romp) ? NULL : romp; + return ROMENTRY_ISEND(romp) ? nullptr : romp; } @@ -335,7 +335,7 @@ static void CLIB_DECL ATTR_PRINTF(1,2) debugload(const char *string, ...) static void determine_bios_rom(romload_private *romdata, device_t *device, const char *specbios) { - const char *defaultname = NULL; + const char *defaultname = nullptr; const rom_entry *rom; int default_no = 1; int bios_count = 0; @@ -359,7 +359,7 @@ static void determine_bios_rom(romload_private *romdata, device_t *device, const sprintf(bios_number, "%d", bios_flags - 1); if (core_stricmp(bios_number, specbios) == 0 || core_stricmp(biosname, specbios) == 0) device->set_system_bios(bios_flags); - if (defaultname != NULL && core_stricmp(biosname, defaultname) == 0) + if (defaultname != nullptr && core_stricmp(biosname, defaultname) == 0) default_no = bios_flags; bios_count++; } @@ -368,7 +368,7 @@ static void determine_bios_rom(romload_private *romdata, device_t *device, const if (device->system_bios() == 0 && bios_count > 0) { /* if we got neither an empty string nor 'default' then warn the user */ - if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL) + if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != nullptr) { strcatprintf(romdata->errorstring, "%s: invalid bios\n", specbios); romdata->errors++; @@ -397,9 +397,9 @@ static void count_roms(romload_private *romdata) /* loop over regions, then over files */ device_iterator deviter(romdata->machine().config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) - for (region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) - for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) + for (region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) + for (rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == device->system_bios()) { romdata->romstotal++; @@ -488,7 +488,7 @@ static void dump_wrong_and_correct_checksums(romload_private *romdata, const has static void verify_length_and_hash(romload_private *romdata, const char *name, UINT32 explength, const hash_collection &hashes) { /* we've already complained if there is no file */ - if (romdata->file == NULL) + if (romdata->file == nullptr) return; /* verify length */ @@ -533,7 +533,7 @@ static void display_loading_rom_message(romload_private *romdata, const char *na { char buffer[200]; - if (name != NULL) + if (name != nullptr) sprintf(buffer, "Loading %s (%d%%)", from_list ? "Software" : emulator_info::get_capstartgamenoun(), (UINT32)(100 * (UINT64)romdata->romsloadedsize / (UINT64)romdata->romstotalsize)); else sprintf(buffer, "Loading Complete"); @@ -551,7 +551,7 @@ static void display_loading_rom_message(romload_private *romdata, const char *na static void display_rom_load_results(romload_private *romdata, bool from_list) { /* final status display */ - display_loading_rom_message(romdata, NULL, from_list); + display_loading_rom_message(romdata, nullptr, from_list); /* if we had errors, they are fatal */ if (romdata->errors != 0) @@ -584,7 +584,7 @@ static void region_post_process(romload_private *romdata, const char *rgntag, bo int i, j; // do nothing if no region - if (region == NULL) + if (region == nullptr) return; LOG(("+ datawidth=%dbit endian=%s\n", region->bitwidth(), @@ -634,8 +634,8 @@ static int open_rom_file(romload_private *romdata, const char *regiontag, const /* attempt reading up the chain through the parents. It automatically also attempts any kind of load by checksum supported by the archives. */ - romdata->file = NULL; - for (int drv = driver_list::find(romdata->machine().system()); romdata->file == NULL && drv != -1; drv = driver_list::clone(drv)) { + romdata->file = nullptr; + for (int drv = driver_list::find(romdata->machine().system()); romdata->file == nullptr && drv != -1; drv = driver_list::clone(drv)) { if (tried_file_names.length() != 0) tried_file_names += " "; tried_file_names += driver_list::driver(drv).name; @@ -643,7 +643,7 @@ static int open_rom_file(romload_private *romdata, const char *regiontag, const } /* if the region is load by name, load the ROM from there */ - if (romdata->file == NULL && regiontag != NULL) + if (romdata->file == nullptr && regiontag != nullptr) { // check if we are dealing with softwarelists. if so, locationtag // is actually a concatenation of: listname + setname + parentname @@ -697,25 +697,25 @@ static int open_rom_file(romload_private *romdata, const char *regiontag, const else { // try to load from list/setname - if ((romdata->file == NULL) && (tag2.c_str() != NULL)) + if ((romdata->file == nullptr) && (tag2.c_str() != nullptr)) { tried_file_names += " " + tag2; filerr = common_process_file(romdata->machine().options(), tag2.c_str(), has_crc, crc, romp, &romdata->file); } // try to load from list/parentname - if ((romdata->file == NULL) && has_parent && (tag3.c_str() != NULL)) + if ((romdata->file == nullptr) && has_parent && (tag3.c_str() != nullptr)) { tried_file_names += " " + tag3; filerr = common_process_file(romdata->machine().options(), tag3.c_str(), has_crc, crc, romp, &romdata->file); } // try to load from setname - if ((romdata->file == NULL) && (tag4.c_str() != NULL)) + if ((romdata->file == nullptr) && (tag4.c_str() != nullptr)) { tried_file_names += " " + tag4; filerr = common_process_file(romdata->machine().options(), tag4.c_str(), has_crc, crc, romp, &romdata->file); } // try to load from parentname - if ((romdata->file == NULL) && has_parent && (tag5.c_str() != NULL)) + if ((romdata->file == nullptr) && has_parent && (tag5.c_str() != nullptr)) { tried_file_names += " " + tag5; filerr = common_process_file(romdata->machine().options(), tag5.c_str(), has_crc, crc, romp, &romdata->file); @@ -740,7 +740,7 @@ static int open_rom_file(romload_private *romdata, const char *regiontag, const static int rom_fread(romload_private *romdata, UINT8 *buffer, int length, const rom_entry *parent_region) { /* files just pass through */ - if (romdata->file != NULL) + if (romdata->file != nullptr) return romdata->file->read(buffer, length); /* otherwise, fill with randomness unless it was already specifically erased */ @@ -910,7 +910,7 @@ static void copy_rom_data(romload_private *romdata, const rom_entry *romp) /* make sure the source was valid */ memory_region *region = romdata->machine().root_device().memregion(srcrgntag); - if (region == NULL) + if (region == nullptr) fatalerror("Error in RomModule definition: COPY from an invalid region\n"); /* make sure we find within the region space */ @@ -999,19 +999,19 @@ static void process_rom_entries(romload_private *romdata, const char *regiontag, } /* reseek to the start and clear the baserom so we don't reverify */ - if (romdata->file != NULL) + if (romdata->file != nullptr) romdata->file->seek(0, SEEK_SET); - baserom = NULL; + baserom = nullptr; explength = 0; } while (ROMENTRY_ISRELOAD(romp)); /* close the file */ - if (romdata->file != NULL) + if (romdata->file != nullptr) { LOG(("Closing ROM file\n")); global_free(romdata->file); - romdata->file = NULL; + romdata->file = nullptr; } } else @@ -1041,10 +1041,10 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_ filerr = common_process_file(options, driver_list::driver(searchdrv).name, ".chd", romp, image_file); if (filerr != FILERR_NONE) - filerr = common_process_file(options, NULL, ".chd", romp, image_file); + filerr = common_process_file(options, nullptr, ".chd", romp, image_file); /* look for the disk in the locationtag too */ - if (filerr != FILERR_NONE && locationtag != NULL) + if (filerr != FILERR_NONE && locationtag != nullptr) { // check if we are dealing with softwarelists. if so, locationtag // is actually a concatenation of: listname + setname + parentname @@ -1095,19 +1095,19 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_ else { // try to load from list/setname - if ((filerr != FILERR_NONE) && (tag2.c_str() != NULL)) + if ((filerr != FILERR_NONE) && (tag2.c_str() != nullptr)) filerr = common_process_file(options, tag2.c_str(), ".chd", romp, image_file); // try to load from list/parentname (if any) - if ((filerr != FILERR_NONE) && has_parent && (tag3.c_str() != NULL)) + if ((filerr != FILERR_NONE) && has_parent && (tag3.c_str() != nullptr)) filerr = common_process_file(options, tag3.c_str(), ".chd", romp, image_file); // try to load from setname - if ((filerr != FILERR_NONE) && (tag4.c_str() != NULL)) + if ((filerr != FILERR_NONE) && (tag4.c_str() != nullptr)) filerr = common_process_file(options, tag4.c_str(), ".chd", romp, image_file); // try to load from parentname (if any) - if ((filerr != FILERR_NONE) && has_parent && (tag5.c_str() != NULL)) + if ((filerr != FILERR_NONE) && has_parent && (tag5.c_str() != nullptr)) filerr = common_process_file(options, tag5.c_str(), ".chd", romp, image_file); // only for CHD we also try to load from list/ - if ((filerr != FILERR_NONE) && (tag1.c_str() != NULL)) + if ((filerr != FILERR_NONE) && (tag1.c_str() != nullptr)) { tag1.erase(tag1.length() - 1, 1); // remove the PATH_SEPARATOR filerr = common_process_file(options, tag1.c_str(), ".chd", romp, image_file); @@ -1136,10 +1136,10 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_ { machine_config config(driver_list::driver(drv), options); device_iterator deviter(config.root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) - for (region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) + for (region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) if (ROMREGION_ISDISKDATA(region)) - for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) + for (rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) /* look for a differing name but with the same hash data */ if (strcmp(ROM_GETNAME(romp), ROM_GETNAME(rom)) != 0 && @@ -1151,7 +1151,7 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_ filerr = common_process_file(options, driver_list::driver(searchdrv).name, ".chd", rom, image_file); if (filerr != FILERR_NONE) - filerr = common_process_file(options, NULL, ".chd", rom, image_file); + filerr = common_process_file(options, nullptr, ".chd", rom, image_file); /* did the file open succeed? */ if (filerr == FILERR_NONE) @@ -1227,7 +1227,7 @@ static void process_disk_entries(romload_private *romdata, const char *regiontag /* handle files */ if (ROMENTRY_ISFILE(romp)) { - open_chd *chd = global_alloc(open_chd(regiontag)); + auto chd = global_alloc(open_chd(regiontag)); hash_collection hashes(ROM_GETHASHDATA(romp)); chd_error err; @@ -1296,7 +1296,7 @@ static void normalize_flags_for_device(running_machine &machine, const char *rgn if (device->interface(memory)) { const address_space_config *spaceconfig = memory->space_config(); - if (spaceconfig != NULL) + if (spaceconfig != nullptr) { int buswidth; @@ -1345,7 +1345,7 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c romdata->romsloadedsize = 0; software_info *swinfo = swlist.find(swname); - if (swinfo != NULL) + if (swinfo != nullptr) { UINT32 supported = swinfo->supported(); if (supported == SOFTWARE_SUPPORTED_PARTIAL) @@ -1365,11 +1365,11 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c locationtag.append(breakstr); - while (swinfo != NULL) + while (swinfo != nullptr) { locationtag.append(swinfo->shortname()).append(breakstr); const char *parentname = swinfo->parentname(); - swinfo = (parentname != NULL) ? swlist.find(parentname) : NULL; + swinfo = (parentname != nullptr) ? swlist.find(parentname) : nullptr; } // strip the final '%' locationtag.erase(locationtag.length() - 1, 1); @@ -1377,7 +1377,7 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c /* loop until we hit the end */ - for (region = start_region; region != NULL; region = rom_next_region(region)) + for (region = start_region; region != nullptr; region = rom_next_region(region)) { UINT32 regionlength = ROMREGION_GETLENGTH(region); @@ -1391,9 +1391,9 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c endianness_t endianness = ROMREGION_ISBIGENDIAN(region) ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; UINT8 width = ROMREGION_GETWIDTH(region) / 8; memory_region *memregion = romdata->machine().root_device().memregion(regiontag.c_str()); - if (memregion != NULL) + if (memregion != nullptr) { - if (romdata->machine().device(regiontag.c_str()) != NULL) + if (romdata->machine().device(regiontag.c_str()) != nullptr) normalize_flags_for_device(romdata->machine(), regiontag.c_str(), width, endianness); /* clear old region (todo: should be moved to an image unload function) */ @@ -1419,7 +1419,7 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c #endif /* update total number of roms */ - for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) + for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) { romdata->romstotal++; romdata->romstotalsize += rom_file_size(rom); @@ -1433,7 +1433,7 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c } /* now go back and post-process all the regions */ - for (region = start_region; region != NULL; region = rom_next_region(region)) + for (region = start_region; region != nullptr; region = rom_next_region(region)) { regiontag = device.subtag(ROMREGION_GETTAG(region)); region_post_process(romdata, regiontag.c_str(), ROMREGION_ISINVERTED(region)); @@ -1454,8 +1454,8 @@ static void process_region_list(romload_private *romdata) /* loop until we hit the end */ device_iterator deviter(romdata->machine().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) - for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) + for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) { UINT32 regionlength = ROMREGION_GETLENGTH(region); @@ -1470,7 +1470,7 @@ static void process_region_list(romload_private *romdata) /* if this is a device region, override with the device width and endianness */ UINT8 width = ROMREGION_GETWIDTH(region) / 8; endianness_t endianness = ROMREGION_ISBIGENDIAN(region) ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; - if (romdata->machine().device(regiontag.c_str()) != NULL) + if (romdata->machine().device(regiontag.c_str()) != nullptr) normalize_flags_for_device(romdata->machine(), regiontag.c_str(), width, endianness); /* remember the base and length */ @@ -1495,20 +1495,20 @@ static void process_region_list(romload_private *romdata) process_rom_entries(romdata, device->shortname(), region, region + 1, device, FALSE); } else if (ROMREGION_ISDISKDATA(region)) - process_disk_entries(romdata, regiontag.c_str(), region, region + 1, NULL); + process_disk_entries(romdata, regiontag.c_str(), region, region + 1, nullptr); } /* now go back and post-process all the regions */ - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) - for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) + for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) { regiontag = rom_region_name(*device, region); region_post_process(romdata, regiontag.c_str(), ROMREGION_ISINVERTED(region)); } /* and finally register all per-game parameters */ - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) - for (const rom_entry *param = rom_first_parameter(*device); param != NULL; param = rom_next_parameter(param)) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) + for (const rom_entry *param = rom_first_parameter(*device); param != nullptr; param = rom_next_parameter(param)) { regiontag = rom_parameter_name(*device, param); romdata->machine().parameters().add(regiontag, rom_parameter_value(param)); @@ -1536,7 +1536,7 @@ void rom_init(running_machine &machine) /* figure out which BIOS we are using */ device_iterator deviter(romdata->machine().config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) { + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { if (device->rom_region()) { const char *specbios; std::string temp; diff --git a/src/emu/save.cpp b/src/emu/save.cpp index 4af850163c2..4a5b3ef7ebf 100644 --- a/src/emu/save.cpp +++ b/src/emu/save.cpp @@ -88,8 +88,8 @@ void save_manager::allow_registration(bool allowed) const char *save_manager::indexed_item(int index, void *&base, UINT32 &valsize, UINT32 &valcount) const { state_entry *entry = m_entry_list.find(index); - if (entry == NULL) - return NULL; + if (entry == nullptr) + return nullptr; base = entry->m_data; valsize = entry->m_typesize; @@ -111,7 +111,7 @@ void save_manager::register_presave(save_prepost_delegate func) fatalerror("Attempt to register callback function after state registration is closed!\n"); // scan for duplicates and push through to the end - for (state_callback *cb = m_presave_list.first(); cb != NULL; cb = cb->next()) + for (state_callback *cb = m_presave_list.first(); cb != nullptr; cb = cb->next()) if (cb->m_func == func) fatalerror("Duplicate save state function (%s/%s)\n", cb->m_func.name(), func.name()); @@ -132,7 +132,7 @@ void save_manager::register_postload(save_prepost_delegate func) fatalerror("Attempt to register callback function after state registration is closed!\n"); // scan for duplicates and push through to the end - for (state_callback *cb = m_postload_list.first(); cb != NULL; cb = cb->next()) + for (state_callback *cb = m_postload_list.first(); cb != nullptr; cb = cb->next()) if (cb->m_func == func) fatalerror("Duplicate save state function (%s/%s)\n", cb->m_func.name(), func.name()); @@ -162,14 +162,14 @@ void save_manager::save_memory(device_t *device, const char *module, const char // create the full name std::string totalname; - if (tag != NULL) + if (tag != nullptr) strprintf(totalname, "%s/%s/%X/%s", module, tag, index, name); else strprintf(totalname, "%s/%X/%s", module, index, name); // look for duplicates and an entry to insert in front of - state_entry *insert_after = NULL; - for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next()) + state_entry *insert_after = nullptr; + for (state_entry *entry = m_entry_list.first(); entry != nullptr; entry = entry->next()) { // stop when we find an entry whose name is after ours if (entry->m_name.compare(totalname)>0) @@ -203,7 +203,7 @@ save_error save_manager::check_file(running_machine &machine, emu_file &file, co UINT8 header[HEADER_SIZE]; if (file.read(header, sizeof(header)) != sizeof(header)) { - if (errormsg != NULL) + if (errormsg != nullptr) (*errormsg)("Could not read %s save file header",emulator_info::get_appname()); return STATERR_READ_ERROR; } @@ -220,7 +220,7 @@ save_error save_manager::check_file(running_machine &machine, emu_file &file, co void save_manager::dispatch_postload() { - for (state_callback *func = m_postload_list.first(); func != NULL; func = func->next()) + for (state_callback *func = m_postload_list.first(); func != nullptr; func = func->next()) func->m_func(); } @@ -244,14 +244,14 @@ save_error save_manager::read_file(emu_file &file) // verify the header and report an error if it doesn't match UINT32 sig = signature(); - if (validate_header(header, machine().system().name, sig, NULL, "Error: ") != STATERR_NONE) + if (validate_header(header, machine().system().name, sig, nullptr, "Error: ") != STATERR_NONE) return STATERR_INVALID_HEADER; // determine whether or not to flip the data when done bool flip = NATIVE_ENDIAN_VALUE_LE_BE((header[9] & SS_MSB_FIRST) != 0, (header[9] & SS_MSB_FIRST) == 0); // read all the data, flipping if necessary - for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next()) + for (state_entry *entry = m_entry_list.first(); entry != nullptr; entry = entry->next()) { UINT32 totalsize = entry->m_typesize * entry->m_typecount; if (file.read(entry->m_data, totalsize) != totalsize) @@ -276,7 +276,7 @@ save_error save_manager::read_file(emu_file &file) void save_manager::dispatch_presave() { - for (state_callback *func = m_presave_list.first(); func != NULL; func = func->next()) + for (state_callback *func = m_presave_list.first(); func != nullptr; func = func->next()) func->m_func(); } @@ -310,7 +310,7 @@ save_error save_manager::write_file(emu_file &file) dispatch_presave(); // then write all the data - for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next()) + for (state_entry *entry = m_entry_list.first(); entry != nullptr; entry = entry->next()) { UINT32 totalsize = entry->m_typesize * entry->m_typecount; if (file.write(entry->m_data, totalsize) != totalsize) @@ -329,7 +329,7 @@ UINT32 save_manager::signature() const { // iterate over entries UINT32 crc = 0; - for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next()) + for (state_entry *entry = m_entry_list.first(); entry != nullptr; entry = entry->next()) { // add the entry name to the CRC crc = core_crc32(crc, (UINT8 *)entry->m_name.c_str(), entry->m_name.length()); @@ -351,7 +351,7 @@ UINT32 save_manager::signature() const void save_manager::dump_registry() const { - for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next()) + for (state_entry *entry = m_entry_list.first(); entry != nullptr; entry = entry->next()) LOG(("%s: %d x %d\n", entry->m_name.c_str(), entry->m_typesize, entry->m_typecount)); } @@ -367,7 +367,7 @@ save_error save_manager::validate_header(const UINT8 *header, const char *gamena // check magic number if (memcmp(header, emulator_info::get_state_magic_num(), 8)) { - if (errormsg != NULL) + if (errormsg != nullptr) (*errormsg)("%sThis is not a %s save file", error_prefix,emulator_info::get_appname()); return STATERR_INVALID_HEADER; } @@ -375,15 +375,15 @@ save_error save_manager::validate_header(const UINT8 *header, const char *gamena // check save state version if (header[8] != SAVE_VERSION) { - if (errormsg != NULL) + if (errormsg != nullptr) (*errormsg)("%sWrong version in save file (version %d, expected %d)", error_prefix, header[8], SAVE_VERSION); return STATERR_INVALID_HEADER; } // check gamename, if we were asked to - if (gamename != NULL && strncmp(gamename, (const char *)&header[0x0a], 0x1c - 0x0a)) + if (gamename != nullptr && strncmp(gamename, (const char *)&header[0x0a], 0x1c - 0x0a)) { - if (errormsg != NULL) + if (errormsg != nullptr) (*errormsg)("%s'File is not a valid savestate file for game '%s'.", error_prefix, gamename); return STATERR_INVALID_HEADER; } @@ -394,7 +394,7 @@ save_error save_manager::validate_header(const UINT8 *header, const char *gamena UINT32 rawsig = *(UINT32 *)&header[0x1c]; if (signature != LITTLE_ENDIANIZE_INT32(rawsig)) { - if (errormsg != NULL) + if (errormsg != nullptr) (*errormsg)("%sIncompatible save file (signature %08x, expected %08x)", error_prefix, LITTLE_ENDIANIZE_INT32(rawsig), signature); return STATERR_INVALID_HEADER; } @@ -408,8 +408,8 @@ save_error save_manager::validate_header(const UINT8 *header, const char *gamena //------------------------------------------------- save_manager::state_callback::state_callback(save_prepost_delegate callback) - : m_next(NULL), - m_func(callback) + : m_next(nullptr), + m_func(std::move(callback)) { } @@ -419,7 +419,7 @@ save_manager::state_callback::state_callback(save_prepost_delegate callback) //------------------------------------------------- state_entry::state_entry(void *data, const char *name, device_t *device, const char *module, const char *tag, int index, UINT8 size, UINT32 count) - : m_next(NULL), + : m_next(nullptr), m_data(data), m_name(name), m_device(device), diff --git a/src/emu/save.h b/src/emu/save.h index 41cc4a07fb4..b82b46ca32f 100644 --- a/src/emu/save.h +++ b/src/emu/save.h @@ -148,7 +148,7 @@ public: // global memory registration template - void save_item(_ItemType &value, const char *valname, int index = 0) { save_item(NULL, "global", NULL, index, value, valname); } + void save_item(_ItemType &value, const char *valname, int index = 0) { save_item(nullptr, "global", nullptr, index, value, valname); } template void save_pointer(_ItemType *value, const char *valname, UINT32 count, int index = 0) { save_pointer(NULL, "global", NULL, index, value, valname, count); } diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp index 43a26ebb1fd..925364aab07 100644 --- a/src/emu/schedule.cpp +++ b/src/emu/schedule.cpp @@ -45,17 +45,17 @@ enum //------------------------------------------------- emu_timer::emu_timer() - : m_machine(NULL), - m_next(NULL), - m_prev(NULL), + : m_machine(nullptr), + m_next(nullptr), + m_prev(nullptr), m_param(0), - m_ptr(NULL), + m_ptr(nullptr), m_enabled(false), m_temporary(false), m_period(attotime::zero), m_start(attotime::zero), m_expire(attotime::never), - m_device(NULL), + m_device(nullptr), m_id(0) { } @@ -79,8 +79,8 @@ emu_timer &emu_timer::init(running_machine &machine, timer_expired_delegate call { // ensure the entire timer state is clean m_machine = &machine; - m_next = NULL; - m_prev = NULL; + m_next = nullptr; + m_prev = nullptr; m_callback = callback; m_param = 0; m_ptr = ptr; @@ -89,7 +89,7 @@ emu_timer &emu_timer::init(running_machine &machine, timer_expired_delegate call m_period = attotime::never; m_start = machine.time(); m_expire = attotime::never; - m_device = NULL; + m_device = nullptr; m_id = 0; // if we're not temporary, register ourselves with the save state system @@ -111,8 +111,8 @@ emu_timer &emu_timer::init(device_t &device, device_timer_id id, void *ptr, bool { // ensure the entire timer state is clean m_machine = &device.machine(); - m_next = NULL; - m_prev = NULL; + m_next = nullptr; + m_prev = nullptr; m_callback = timer_expired_delegate(); m_param = 0; m_ptr = ptr; @@ -241,11 +241,11 @@ void emu_timer::register_save() std::string name; // for non-device timers, it is an index based on the callback function name - if (m_device == NULL) + if (m_device == nullptr) { name = m_callback.name(); - for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != NULL; curtimer = curtimer->next()) - if (!curtimer->m_temporary && curtimer->m_device == NULL && strcmp(curtimer->m_callback.name(), m_callback.name()) == 0) + for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != nullptr; curtimer = curtimer->next()) + if (!curtimer->m_temporary && curtimer->m_device == nullptr && strcmp(curtimer->m_callback.name(), m_callback.name()) == 0) index++; } @@ -253,8 +253,8 @@ void emu_timer::register_save() else { strprintf(name,"%s/%d", m_device->tag(), m_id); - for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != NULL; curtimer = curtimer->next()) - if (!curtimer->m_temporary && curtimer->m_device != NULL && curtimer->m_device == m_device && curtimer->m_id == m_id) + for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != nullptr; curtimer = curtimer->next()) + if (!curtimer->m_temporary && curtimer->m_device != nullptr && curtimer->m_device == m_device && curtimer->m_id == m_id) index++; } @@ -293,7 +293,7 @@ inline void emu_timer::schedule_next_period() void emu_timer::dump() const { machine().logerror("%p: en=%d temp=%d exp=%15s start=%15s per=%15s param=%d ptr=%p", this, m_enabled, m_temporary, m_expire.as_string(PRECISION), m_start.as_string(PRECISION), m_period.as_string(PRECISION), m_param, m_ptr); - if (m_device == NULL) + if (m_device == nullptr) machine().logerror(" cb=%s\n", m_callback.name()); else machine().logerror(" dev=%s id=%d\n", m_device->tag(), m_id); @@ -311,18 +311,18 @@ void emu_timer::dump() const device_scheduler::device_scheduler(running_machine &machine) : m_machine(machine), - m_executing_device(NULL), - m_execute_list(NULL), + m_executing_device(nullptr), + m_execute_list(nullptr), m_basetime(attotime::zero), - m_timer_list(NULL), - m_callback_timer(NULL), + m_timer_list(nullptr), + m_callback_timer(nullptr), m_callback_timer_modified(false), m_callback_timer_expire_time(attotime::zero), m_suspend_changes_pending(true), m_quantum_minimum(ATTOSECONDS_IN_NSEC(1) / 1000) { // append a single never-expiring timer so there is always one in the list - m_timer_list = &m_timer_allocator.alloc()->init(machine, timer_expired_delegate(), NULL, true); + m_timer_list = &m_timer_allocator.alloc()->init(machine, timer_expired_delegate(), nullptr, true); m_timer_list->adjust(attotime::never); // register global states @@ -339,7 +339,7 @@ device_scheduler::device_scheduler(running_machine &machine) : device_scheduler::~device_scheduler() { // remove all timers - while (m_timer_list != NULL) + while (m_timer_list != nullptr) m_timer_allocator.reclaim(m_timer_list->release()); } @@ -351,12 +351,12 @@ device_scheduler::~device_scheduler() attotime device_scheduler::time() const { // if we're currently in a callback, use the timer's expiration time as a base - if (m_callback_timer != NULL) + if (m_callback_timer != nullptr) return m_callback_timer_expire_time; // if we're executing as a particular CPU, use its local time as a base // otherwise, return the global base time - return (m_executing_device != NULL) ? m_executing_device->local_time() : m_basetime; + return (m_executing_device != nullptr) ? m_executing_device->local_time() : m_basetime; } @@ -368,7 +368,7 @@ attotime device_scheduler::time() const bool device_scheduler::can_save() const { // if any live temporary timers exit, fail - for (emu_timer *timer = m_timer_list; timer != NULL; timer = timer->next()) + for (emu_timer *timer = m_timer_list; timer != nullptr; timer = timer->next()) if (timer->m_temporary && !timer->expire().is_never()) { machine().logerror("Failed save state attempt due to anonymous timers:\n"); @@ -389,7 +389,7 @@ bool device_scheduler::can_save() const inline void device_scheduler::apply_suspend_changes() { UINT32 suspendchanged = 0; - for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + for (device_execute_interface *exec = m_execute_list; exec != nullptr; exec = exec->m_nextexec) { suspendchanged |= exec->m_suspend ^ exec->m_nextsuspend; exec->m_suspend = exec->m_nextsuspend; @@ -415,7 +415,7 @@ void device_scheduler::timeslice() bool call_debugger = ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0); // build the execution list if we don't have one yet - if (UNEXPECTED(m_execute_list == NULL)) + if (UNEXPECTED(m_execute_list == nullptr)) rebuild_execute_list(); // if the current quantum has expired, find a new one @@ -440,7 +440,7 @@ void device_scheduler::timeslice() apply_suspend_changes(); // loop over all CPUs - for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + for (device_execute_interface *exec = m_execute_list; exec != nullptr; exec = exec->m_nextexec) { // only process if this CPU is executing or truly halted (not yielding) // and if our target is later than the CPU's current time (coarse check) @@ -504,7 +504,7 @@ void device_scheduler::timeslice() } } } - m_executing_device = NULL; + m_executing_device = nullptr; // update the base time m_basetime = target; @@ -522,7 +522,7 @@ void device_scheduler::timeslice() void device_scheduler::abort_timeslice() { - if (m_executing_device != NULL) + if (m_executing_device != nullptr) m_executing_device->abort_timeslice(); } @@ -534,7 +534,7 @@ void device_scheduler::abort_timeslice() void device_scheduler::trigger(int trigid, const attotime &after) { // ensure we have a list of executing devices - if (m_execute_list == NULL) + if (m_execute_list == nullptr) rebuild_execute_list(); // if we have a non-zero time, schedule a timer @@ -543,7 +543,7 @@ void device_scheduler::trigger(int trigid, const attotime &after) // send the trigger to everyone who cares else - for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + for (device_execute_interface *exec = m_execute_list; exec != nullptr; exec = exec->m_nextexec) exec->trigger(trigid); } @@ -627,7 +627,7 @@ void device_scheduler::timer_set(const attotime &duration, device_t &device, dev void device_scheduler::eat_all_cycles() { - for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + for (device_execute_interface *exec = m_execute_list; exec != nullptr; exec = exec->m_nextexec) exec->eat_cycles(1000000000); } @@ -663,7 +663,7 @@ void device_scheduler::postload() { // remove all timers and make a private list of permanent ones simple_list private_list; - while (m_timer_list != NULL) + while (m_timer_list != nullptr) { emu_timer &timer = *m_timer_list; @@ -678,7 +678,7 @@ void device_scheduler::postload() // now re-insert them; this effectively re-sorts them by time emu_timer *timer; - while ((timer = private_list.detach_head()) != NULL) + while ((timer = private_list.detach_head()) != nullptr) timer_list_insert(*timer); m_suspend_changes_pending = true; @@ -698,17 +698,17 @@ void device_scheduler::postload() void device_scheduler::compute_perfect_interleave() { // ensure we have a list of executing devices - if (m_execute_list == NULL) + if (m_execute_list == nullptr) rebuild_execute_list(); // start with the first one device_execute_interface *first = m_execute_list; - if (first != NULL) + if (first != nullptr) { // start with a huge time factor and find the 2nd smallest cycle time attoseconds_t smallest = first->minimum_quantum(); attoseconds_t perfect = ATTOSECONDS_PER_SECOND - 1; - for (device_execute_interface *exec = first->m_nextexec; exec != NULL; exec = exec->m_nextexec) + for (device_execute_interface *exec = first->m_nextexec; exec != nullptr; exec = exec->m_nextexec) { // find the 2nd smallest cycle interval attoseconds_t curquantum = exec->minimum_quantum(); @@ -726,7 +726,7 @@ void device_scheduler::compute_perfect_interleave() { // adjust all the actuals; this doesn't affect the current m_quantum_minimum = perfect; - for (quantum_slot *quant = m_quantum_list.first(); quant != NULL; quant = quant->next()) + for (quantum_slot *quant = m_quantum_list.first(); quant != nullptr; quant = quant->next()) quant->m_actual = MAX(quant->m_requested, m_quantum_minimum); } } @@ -742,7 +742,7 @@ void device_scheduler::compute_perfect_interleave() void device_scheduler::rebuild_execute_list() { // if we haven't yet set a scheduling quantum, do it now - if (m_quantum_list.first() == NULL) + if (m_quantum_list.first() == nullptr) { // set the core scheduling quantum attotime min_quantum = machine().config().m_minimum_quantum; @@ -755,7 +755,7 @@ void device_scheduler::rebuild_execute_list() if (!machine().config().m_perfect_cpu_quantum.empty()) { device_t *device = machine().device(machine().config().m_perfect_cpu_quantum.c_str()); - if (device == NULL) + if (device == nullptr) fatalerror("Device '%s' specified for perfect interleave is not present!\n", machine().config().m_perfect_cpu_quantum.c_str()); device_execute_interface *exec; @@ -774,18 +774,18 @@ void device_scheduler::rebuild_execute_list() // start with an empty list device_execute_interface **active_tailptr = &m_execute_list; - *active_tailptr = NULL; + *active_tailptr = nullptr; // also make an empty list of suspended devices - device_execute_interface *suspend_list = NULL; + device_execute_interface *suspend_list = nullptr; device_execute_interface **suspend_tailptr = &suspend_list; // iterate over all devices execute_interface_iterator iter(machine().root_device()); - for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next()) + for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) { // append to the appropriate list - exec->m_nextexec = NULL; + exec->m_nextexec = nullptr; if (exec->m_suspend == 0) { *active_tailptr = exec; @@ -814,8 +814,8 @@ emu_timer &device_scheduler::timer_list_insert(emu_timer &timer) const attotime &expire = timer.m_enabled ? timer.m_expire : attotime::never; // loop over the timer list - emu_timer *prevtimer = NULL; - for (emu_timer *curtimer = m_timer_list; curtimer != NULL; prevtimer = curtimer, curtimer = curtimer->next()) + emu_timer *prevtimer = nullptr; + for (emu_timer *curtimer = m_timer_list; curtimer != nullptr; prevtimer = curtimer, curtimer = curtimer->next()) { // if the current list entry expires after us, we should be inserted before it if (curtimer->m_expire > expire) @@ -824,7 +824,7 @@ emu_timer &device_scheduler::timer_list_insert(emu_timer &timer) timer.m_prev = curtimer->m_prev; timer.m_next = curtimer; - if (curtimer->m_prev != NULL) + if (curtimer->m_prev != nullptr) curtimer->m_prev->m_next = &timer; else m_timer_list = &timer; @@ -835,13 +835,13 @@ emu_timer &device_scheduler::timer_list_insert(emu_timer &timer) } // need to insert after the last one - if (prevtimer != NULL) + if (prevtimer != nullptr) prevtimer->m_next = &timer; else m_timer_list = &timer; timer.m_prev = prevtimer; - timer.m_next = NULL; + timer.m_next = nullptr; return timer; } @@ -854,12 +854,12 @@ emu_timer &device_scheduler::timer_list_insert(emu_timer &timer) emu_timer &device_scheduler::timer_list_remove(emu_timer &timer) { // remove it from the list - if (timer.m_prev != NULL) + if (timer.m_prev != nullptr) timer.m_prev->m_next = timer.m_next; else m_timer_list = timer.m_next; - if (timer.m_next != NULL) + if (timer.m_next != nullptr) timer.m_next->m_prev = timer.m_prev; return timer; @@ -893,7 +893,7 @@ inline void device_scheduler::execute_timers() { g_profiler.start(PROFILER_TIMER_CALLBACK); - if (timer.m_device != NULL) + if (timer.m_device != nullptr) { LOG(("execute_timers: timer device %s timer %d\n", timer.m_device->tag(), timer.m_id)); timer.m_device->timer_expired(timer, timer.m_id, timer.m_param, timer.m_ptr); @@ -908,7 +908,7 @@ inline void device_scheduler::execute_timers() } // clear the callback timer global - m_callback_timer = NULL; + m_callback_timer = nullptr; // reset or remove the timer, but only if it wasn't modified during the callback if (!m_callback_timer_modified) @@ -940,9 +940,9 @@ void device_scheduler::add_scheduling_quantum(const attotime &quantum, const att const attoseconds_t quantum_attos = quantum.attoseconds(); // figure out where to insert ourselves, expiring any quanta that are out-of-date - quantum_slot *insert_after = NULL; + quantum_slot *insert_after = nullptr; quantum_slot *next; - for (quantum_slot *quant = m_quantum_list.first(); quant != NULL; quant = next) + for (quantum_slot *quant = m_quantum_list.first(); quant != nullptr; quant = next) { // if this quantum is expired, nuke it next = quant->next(); @@ -955,7 +955,7 @@ void device_scheduler::add_scheduling_quantum(const attotime &quantum, const att } // if we found an exact match, just take the maximum expiry time - if (insert_after != NULL && insert_after->m_requested == quantum_attos) + if (insert_after != nullptr && insert_after->m_requested == quantum_attos) insert_after->m_expire = max(insert_after->m_expire, expire); // otherwise, allocate a new quantum and insert it after the one we picked @@ -978,7 +978,7 @@ void device_scheduler::dump_timers() const { machine().logerror("=============================================\n"); machine().logerror("Timer Dump: Time = %15s\n", time().as_string(PRECISION)); - for (emu_timer *timer = first_timer(); timer != NULL; timer = timer->next()) + for (emu_timer *timer = first_timer(); timer != nullptr; timer = timer->next()) timer->dump(); machine().logerror("=============================================\n"); } diff --git a/src/emu/schedule.h b/src/emu/schedule.h index a2d8660ef4f..2f3a7f8a23a 100644 --- a/src/emu/schedule.h +++ b/src/emu/schedule.h @@ -68,7 +68,7 @@ class emu_timer public: // getters emu_timer *next() const { return m_next; } - running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + running_machine &machine() const { assert(m_machine != nullptr); return *m_machine; } bool enabled() const { return m_enabled; } int param() const { return m_param; } void *ptr() const { return m_ptr; } @@ -138,22 +138,22 @@ public: void suspend_resume_changed() { m_suspend_changes_pending = true; } // timers, specified by callback/name - emu_timer *timer_alloc(timer_expired_delegate callback, void *ptr = NULL); - void timer_set(const attotime &duration, timer_expired_delegate callback, int param = 0, void *ptr = NULL); - void timer_pulse(const attotime &period, timer_expired_delegate callback, int param = 0, void *ptr = NULL); - void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, param, ptr); } + emu_timer *timer_alloc(timer_expired_delegate callback, void *ptr = nullptr); + void timer_set(const attotime &duration, timer_expired_delegate callback, int param = 0, void *ptr = nullptr); + void timer_pulse(const attotime &period, timer_expired_delegate callback, int param = 0, void *ptr = nullptr); + void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0, void *ptr = nullptr) { timer_set(attotime::zero, callback, param, ptr); } // timers with old-skool callbacks #ifdef USE_STATIC_DELEGATE - emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = NULL) { return timer_alloc(timer_expired_delegate(callback, name, &machine()), ptr); } - void timer_set(const attotime &duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_set(duration, timer_expired_delegate(callback, name, &machine()), param, ptr); } - void timer_pulse(const attotime &period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_pulse(period, timer_expired_delegate(callback, name, &machine()), param, ptr); } - void synchronize(timer_expired_func callback, const char *name = NULL, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, name, param, ptr); } + emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = nullptr) { return timer_alloc(timer_expired_delegate(callback, name, &machine()), ptr); } + void timer_set(const attotime &duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = nullptr) { timer_set(duration, timer_expired_delegate(callback, name, &machine()), param, ptr); } + void timer_pulse(const attotime &period, timer_expired_func callback, const char *name, int param = 0, void *ptr = nullptr) { timer_pulse(period, timer_expired_delegate(callback, name, &machine()), param, ptr); } + void synchronize(timer_expired_func callback, const char *name = nullptr, int param = 0, void *ptr = nullptr) { timer_set(attotime::zero, callback, name, param, ptr); } #endif // timers, specified by device/id; generally devices should use the device_t methods instead - emu_timer *timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = NULL); - void timer_set(const attotime &duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = NULL); + emu_timer *timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = nullptr); + void timer_set(const attotime &duration, device_t &device, device_timer_id id = 0, int param = 0, void *ptr = nullptr); // debugging void dump_timers() const; diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index 84b343bdc81..2ae1269cdd8 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -55,7 +55,7 @@ screen_device::screen_device(const machine_config &mconfig, const char *tag, dev m_yscale(1.0f), m_palette(*this), m_video_attributes(0), - m_container(NULL), + m_container(nullptr), m_width(100), m_height(100), m_visarea(0, 99, 0, 99), @@ -73,10 +73,10 @@ screen_device::screen_device(const machine_config &mconfig, const char *tag, dev m_vblank_period(0), m_vblank_start_time(attotime::zero), m_vblank_end_time(attotime::zero), - m_vblank_begin_timer(NULL), - m_vblank_end_timer(NULL), - m_scanline0_timer(NULL), - m_scanline_timer(NULL), + m_vblank_begin_timer(nullptr), + m_vblank_end_timer(nullptr), + m_scanline0_timer(nullptr), + m_scanline_timer(nullptr), m_frame_number(0), m_partial_updates_this_frame(0) { @@ -267,9 +267,9 @@ void screen_device::device_validity_check(validity_checker &valid) const osd_printf_error("Invalid (zero) refresh rate\n"); texture_format texformat = !m_screen_update_ind16.isnull() ? TEXFORMAT_PALETTE16 : TEXFORMAT_RGB32; - if (m_palette == NULL && texformat == TEXFORMAT_PALETTE16) + if (m_palette == nullptr && texformat == TEXFORMAT_PALETTE16) osd_printf_error("Screen does not have palette defined\n"); - if (m_palette != NULL && texformat == TEXFORMAT_RGB32) + if (m_palette != nullptr && texformat == TEXFORMAT_RGB32) osd_printf_warning("Screen does not need palette defined\n"); } @@ -286,16 +286,16 @@ void screen_device::device_start() m_screen_vblank.bind_relative_to(*owner()); // if we have a palette and it's not started, wait for it - if (m_palette != NULL && !m_palette->started()) + if (m_palette != nullptr && !m_palette->started()) throw device_missing_dependencies(); // configure bitmap formats and allocate screen bitmaps texture_format texformat = !m_screen_update_ind16.isnull() ? TEXFORMAT_PALETTE16 : TEXFORMAT_RGB32; - for (int index = 0; index < ARRAY_LENGTH(m_bitmap); index++) + for (auto & elem : m_bitmap) { - m_bitmap[index].set_format(format(), texformat); - register_screen_bitmap(m_bitmap[index]); + elem.set_format(format(), texformat); + register_screen_bitmap(elem); } register_screen_bitmap(m_priority); @@ -348,7 +348,7 @@ void screen_device::device_start() // load the effect overlay const char *overname = machine().options().effect(); - if (overname != NULL && strcmp(overname, "none") != 0) + if (overname != nullptr && strcmp(overname, "none") != 0) load_effect_overlay(overname); // register items for saving @@ -553,11 +553,11 @@ void screen_device::realloc_screen_bitmaps() INT32 effheight = MAX(m_height, m_visarea.max_y + 1); // reize all registered screen bitmaps - for (auto_bitmap_item *item = m_auto_bitmap_list.first(); item != NULL; item = item->next()) + for (auto_bitmap_item *item = m_auto_bitmap_list.first(); item != nullptr; item = item->next()) item->m_bitmap.resize(effwidth, effheight); // re-set up textures - if (m_palette != NULL) + if (m_palette != nullptr) { m_bitmap[0].set_palette(m_palette->palette()); m_bitmap[1].set_palette(m_palette->palette()); @@ -899,12 +899,12 @@ void screen_device::register_vblank_callback(vblank_state_delegate vblank_callba // check if we already have this callback registered callback_item *item; - for (item = m_callback_list.first(); item != NULL; item = item->next()) + for (item = m_callback_list.first(); item != nullptr; item = item->next()) if (item->m_callback == vblank_callback) break; // if not found, register - if (item == NULL) + if (item == nullptr) m_callback_list.append(*global_alloc(callback_item(vblank_callback))); } @@ -921,7 +921,7 @@ void screen_device::register_screen_bitmap(bitmap_t &bitmap) // if allocating now, just do it bitmap.allocate(width(), height()); - if (m_palette != NULL) + if (m_palette != nullptr) bitmap.set_palette(m_palette->palette()); } @@ -942,7 +942,7 @@ void screen_device::vblank_begin() machine().video().frame_update(); // call the screen specific callbacks - for (callback_item *item = m_callback_list.first(); item != NULL; item = item->next()) + for (callback_item *item = m_callback_list.first(); item != nullptr; item = item->next()) item->m_callback(*this, true); if (!m_screen_vblank.isnull()) m_screen_vblank(*this, true); @@ -966,7 +966,7 @@ void screen_device::vblank_begin() void screen_device::vblank_end() { // call the screen specific callbacks - for (callback_item *item = m_callback_list.first(); item != NULL; item = item->next()) + for (callback_item *item = m_callback_list.first(); item != nullptr; item = item->next()) item->m_callback(*this, false); if (!m_screen_vblank.isnull()) m_screen_vblank(*this, false); @@ -1143,7 +1143,7 @@ void screen_device::finalize_burnin() file_error filerr = file.open(machine().basename(), PATH_SEPARATOR "burnin-", this->tag()+1, ".png") ; if (filerr == FILERR_NONE) { - png_info pnginfo = { 0 }; + png_info pnginfo = { nullptr }; // png_error pngerr; char text[256]; @@ -1154,7 +1154,7 @@ void screen_device::finalize_burnin() png_add_text(&pnginfo, "System", text); // now do the actual work - png_write_bitmap(file, &pnginfo, finalmap, 0, NULL); + png_write_bitmap(file, &pnginfo, finalmap, 0, nullptr); // free any data allocated png_free(&pnginfo); @@ -1177,7 +1177,7 @@ void screen_device::load_effect_overlay(const char *filename) // load the file emu_file file(machine().options().art_path(), OPEN_FLAG_READ); - render_load_png(m_screen_overlay_bitmap, file, NULL, fullname.c_str()); + render_load_png(m_screen_overlay_bitmap, file, nullptr, fullname.c_str()); if (m_screen_overlay_bitmap.valid()) m_container->set_overlay(&m_screen_overlay_bitmap); else diff --git a/src/emu/screen.h b/src/emu/screen.h index 0a12c92f6b3..45caece012e 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -8,6 +8,8 @@ ***************************************************************************/ +#include + #pragma once #ifndef __EMU_H__ @@ -76,8 +78,8 @@ class screen_bitmap { private: // internal helpers - bitmap_t &live() { assert(m_live != NULL); return *m_live; } - const bitmap_t &live() const { assert(m_live != NULL); return *m_live; } + bitmap_t &live() { assert(m_live != nullptr); return *m_live; } + const bitmap_t &live() const { assert(m_live != nullptr); return *m_live; } public: // construction/destruction @@ -126,7 +128,7 @@ public: { case BITMAP_FORMAT_IND16: m_live = &m_ind16; break; case BITMAP_FORMAT_RGB32: m_live = &m_rgb32; break; - default: m_live = NULL; break; + default: m_live = nullptr; break; } m_ind16.reset(); m_rgb32.reset(); @@ -193,7 +195,7 @@ public: static void static_set_video_attributes(device_t &device, UINT32 flags); // information getters - render_container &container() const { assert(m_container != NULL); return *m_container; } + render_container &container() const { assert(m_container != nullptr); return *m_container; } bitmap_ind8 &priority() { return m_priority; } palette_device *palette() { return m_palette; } @@ -216,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 == NULL) ? DEFAULT_FRAME_PERIOD : attotime(0, m_frame_period); }; + attotime frame_period() const { return (this == nullptr) ? DEFAULT_FRAME_PERIOD : attotime(0, m_frame_period); }; UINT64 frame_number() const { return m_frame_number; } // updating @@ -248,12 +250,12 @@ private: }; // device-level overrides - virtual void device_validity_check(validity_checker &valid) const; - virtual void device_start(); - virtual void device_reset(); - virtual void device_stop(); - virtual void device_post_load(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + virtual void device_validity_check(validity_checker &valid) const override; + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_stop() override; + virtual void device_post_load() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // internal helpers void set_container(render_container &container) { m_container = &container; } @@ -319,8 +321,8 @@ private: { public: callback_item(vblank_state_delegate callback) - : m_next(NULL), - m_callback(callback) { } + : m_next(nullptr), + m_callback(std::move(callback)) { } callback_item *next() const { return m_next; } callback_item * m_next; @@ -333,7 +335,7 @@ private: { public: auto_bitmap_item(bitmap_t &bitmap) - : m_next(NULL), + : m_next(nullptr), m_bitmap(bitmap) { } auto_bitmap_item *next() const { return m_next; } @@ -461,7 +463,7 @@ inline screen_update_ind16_delegate screen_update_delegate_smart(UINT32 (_Functi template inline screen_update_rgb32_delegate screen_update_delegate_smart(UINT32 (_FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, const rectangle &), const char *name, const char *devname) { - return screen_update_rgb32_delegate(callback, name, devname, (_FunctionClass *)0); + return screen_update_rgb32_delegate(callback, name, devname, (_FunctionClass *)nullptr); } diff --git a/src/emu/softlist.cpp b/src/emu/softlist.cpp index ce0aee13a92..1e1fd1718f8 100644 --- a/src/emu/softlist.cpp +++ b/src/emu/softlist.cpp @@ -45,7 +45,7 @@ private: // internal parsing helpers const char *filename() const { return m_list.filename(); } - const char *infoname() const { return (m_current_info != NULL) ? m_current_info->shortname() : "???"; } + const char *infoname() const { return (m_current_info != nullptr) ? m_current_info->shortname() : "???"; } int line() const { return XML_GetCurrentLineNumber(m_parser); } int column() const { return XML_GetCurrentColumnNumber(m_parser); } const char *parser_error() const { return XML_ErrorString(XML_GetErrorCode(m_parser)); } @@ -107,7 +107,7 @@ const device_type SOFTWARE_LIST = &device_creator; //------------------------------------------------- software_part::software_part(software_info &info, const char *name, const char *interface) - : m_next(NULL), + : m_next(nullptr), m_info(info), m_name(name), m_interface(interface) @@ -125,13 +125,13 @@ software_part::software_part(software_info &info, const char *name, const char * const char *software_part::feature(const char *feature_name) const { - assert(feature_name != NULL); + assert(feature_name != nullptr); // scan the feature list for an entry matching feature_name and return the value - for (const feature_list_item *feature = m_featurelist.first(); feature != NULL; feature = feature->next()) + for (const feature_list_item *feature = m_featurelist.first(); feature != nullptr; feature = feature->next()) if (strcmp(feature->name(), feature_name) == 0) return feature->value(); - return NULL; + return nullptr; } @@ -146,7 +146,7 @@ bool software_part::is_compatible(const software_list_device &swlistdev) const // get the compatibility feature and the softlist filter; if either is NULL, assume compatible const char *compatibility = feature("compatibility"); const char *filter = swlistdev.filter(); - if (compatibility == NULL || filter == NULL) + if (compatibility == nullptr || filter == nullptr) return true; // copy the comma-delimited strings and ensure they end with a final comma @@ -172,7 +172,7 @@ bool software_part::is_compatible(const software_list_device &swlistdev) const bool software_part::matches_interface(const char *interface_list) const { // if we have no interface, then we match by default - if (m_interface == NULL) + if (m_interface == nullptr) return true; // copy the comma-delimited interface list and ensure it ends with a final comma @@ -194,21 +194,21 @@ bool software_part::matches_interface(const char *interface_list) const //------------------------------------------------- software_info::software_info(software_list_device &list, const char *name, const char *parent, const char *supported) - : m_next(NULL), + : m_next(nullptr), m_list(list), m_supported(SOFTWARE_SUPPORTED_YES), m_shortname(name), - m_longname(NULL), + m_longname(nullptr), m_parentname(parent), - m_year(NULL), - m_publisher(NULL) + m_year(nullptr), + m_publisher(nullptr) { // ensure strings we are passed are in the string pool assert(list.string_pool_contains(name)); assert(list.string_pool_contains(parent)); // handle the supported flag if provided - if (supported != NULL) + if (supported != nullptr) { if (strcmp(supported, "partial") == 0) m_supported = SOFTWARE_SUPPORTED_PARTIAL; @@ -226,21 +226,21 @@ software_info::software_info(software_list_device &list, const char *name, const software_part *software_info::find_part(const char *partname, const char *interface) { // if neither partname nor interface supplied, then we just return the first entry - if (partname != NULL && strlen(partname)==0) partname = NULL; + if (partname != nullptr && strlen(partname)==0) partname = nullptr; - if (partname == NULL && interface == NULL) + if (partname == nullptr && interface == nullptr) return m_partdata.first(); // look for the part by name and match against the interface if provided - for (software_part *part = m_partdata.first(); part != NULL; part = part->next()) - if (partname != NULL && strcmp(partname, part->name()) == 0) + for (software_part *part = m_partdata.first(); part != nullptr; part = part->next()) + if (partname != nullptr && strcmp(partname, part->name()) == 0) { - if (interface == NULL || part->matches_interface(interface)) + if (interface == nullptr || part->matches_interface(interface)) return part; } - else if (partname == NULL && part->matches_interface(interface)) + else if (partname == nullptr && part->matches_interface(interface)) return part; - return NULL; + return nullptr; } @@ -255,7 +255,7 @@ bool software_info::has_multiple_parts(const char *interface) const int count = 0; // increment the count for each match and stop if we hit more than 1 - for (software_part *part = first_part(); part != NULL; part = part->next()) + for (software_part *part = first_part(); part != nullptr; part = part->next()) if (part->matches_interface(interface)) if (++count > 1) return true; @@ -276,10 +276,10 @@ bool software_info::has_multiple_parts(const char *interface) const software_list_device::software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, SOFTWARE_LIST, "Software list", tag, owner, clock, "software_list", __FILE__), m_list_type(SOFTWARE_LIST_ORIGINAL_SYSTEM), - m_filter(NULL), + m_filter(nullptr), m_parsed(false), m_file(mconfig.options().hash_path(), OPEN_FLAG_READ), - m_description(NULL) + m_description(nullptr) { } @@ -326,7 +326,7 @@ void software_list_device::device_start() void software_list_device::find_approx_matches(const char *name, int matches, software_info **list, const char *interface) { // if no name, return - if (name == NULL || name[0] == 0) + if (name == nullptr || name[0] == 0) return; // initialize everyone's states @@ -334,14 +334,14 @@ void software_list_device::find_approx_matches(const char *name, int matches, so for (int matchnum = 0; matchnum < matches; matchnum++) { penalty[matchnum] = 9999; - list[matchnum] = NULL; + list[matchnum] = nullptr; } // iterate over our info (will cause a parse if needed) - for (software_info *swinfo = first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (software_info *swinfo = first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) { software_part *part = swinfo->first_part(); - if ((interface == NULL || part->matches_interface(interface)) && part->is_compatible(*this)) + if ((interface == nullptr || part->matches_interface(interface)) && part->is_compatible(*this)) { // pick the best match between driver name and description int longpenalty = driver_list::penalty_compare(name, swinfo->longname()); @@ -377,7 +377,7 @@ void software_list_device::release() { osd_printf_verbose("Resetting %s\n", m_file.filename()); m_parsed = false; - m_description = NULL; + m_description = nullptr; m_errors.clear(); m_infolist.reset(); m_stringpool.reset(); @@ -393,10 +393,10 @@ software_list_device *software_list_device::find_by_name(const machine_config &c { // iterate over each device in the system and find a match software_list_device_iterator deviter(config.root_device()); - for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next()) + for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) if (strcmp(swlistdev->list_name(), name) == 0) return swlistdev; - return NULL; + return nullptr; } @@ -415,14 +415,14 @@ void software_list_device::display_matches(const machine_config &config, const c "supported software items (best match first):\n\n", name); // iterate through lists - for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next()) + for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) { // get the top 16 approximate matches for the selected device interface (i.e. only carts for cartslot, etc.) - software_info *matches[16] = { 0 }; + software_info *matches[16] = { nullptr }; swlistdev->find_approx_matches(name, ARRAY_LENGTH(matches), matches, interface); // if we found some, print them - if (matches[0] != 0) + if (matches[0] != nullptr) { // different output depending on original system or compatible if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) @@ -431,9 +431,9 @@ void software_list_device::display_matches(const machine_config &config, const c osd_printf_error("* Compatible software list \"%s\" (%s) matches: \n", swlistdev->list_name(), swlistdev->description()); // print them out - for (int softnum = 0; softnum < ARRAY_LENGTH(matches); softnum++) - if (matches[softnum] != NULL) - osd_printf_error("%-18s%s\n", matches[softnum]->shortname(), matches[softnum]->longname()); + for (auto & matche : matches) + if (matche != nullptr) + osd_printf_error("%-18s%s\n", matche->shortname(), matche->longname()); osd_printf_error("\n"); } @@ -450,13 +450,13 @@ void software_list_device::display_matches(const machine_config &config, const c software_info *software_list_device::find(const char *look_for, software_info *prev) { // NULL search returns nothing - if (look_for == NULL) - return NULL; + if (look_for == nullptr) + return nullptr; - bool iswild = strchr(look_for, '*') != NULL || strchr(look_for, '?'); + bool iswild = strchr(look_for, '*') != nullptr || strchr(look_for, '?'); // find a match (will cause a parse if needed when calling first_software_info) - for (prev = (prev != NULL) ? prev->next() : first_software_info(); prev != NULL; prev = prev->next()) + for (prev = (prev != nullptr) ? prev->next() : first_software_info(); prev != nullptr; prev = prev->next()) if ((iswild && core_strwildcmp(look_for, prev->shortname()) == 0) || core_stricmp(look_for, prev->shortname()) == 0) break; @@ -525,7 +525,7 @@ void software_list_device::internal_validity_check(validity_checker &valid) softlist_map names; softlist_map descriptions; - for (software_info *swinfo = first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (software_info *swinfo = first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) { // first parse and output core errors if any if (m_errors.length() > 0) @@ -537,21 +537,21 @@ void software_list_device::internal_validity_check(validity_checker &valid) // Now check if the xml data is valid: // Did we lost any description? - if (swinfo->longname() == NULL) + if (swinfo->longname() == nullptr) { osd_printf_error("%s: %s has no description\n", filename(), swinfo->shortname()); break; } // Did we lost any year? - if (swinfo->year() == NULL) + if (swinfo->year() == nullptr) { osd_printf_error("%s: %s has no year\n", filename(), swinfo->shortname()); break; } // Did we lost any publisher? - if (swinfo->publisher() == NULL) + if (swinfo->publisher() == nullptr) { osd_printf_error("%s: %s has no publisher\n", filename(), swinfo->shortname()); break; @@ -579,7 +579,7 @@ void software_list_device::internal_validity_check(validity_checker &valid) osd_printf_error("%s: %s is a duplicate description (%s)\n", filename(), swinfo->longname(), swinfo->shortname()); bool is_clone = false; - if (swinfo->parentname() != NULL) + if (swinfo->parentname() != nullptr) { is_clone = true; if (strcmp(swinfo->parentname(), swinfo->shortname()) == 0) @@ -591,9 +591,9 @@ void software_list_device::internal_validity_check(validity_checker &valid) // make sure the parent exists software_info *swinfo2 = find(swinfo->parentname()); - if (swinfo2 == NULL) + if (swinfo2 == nullptr) osd_printf_error("%s: parent '%s' software for '%s' not found\n", filename(), swinfo->parentname(), swinfo->shortname()); - else if (swinfo2->parentname() != NULL) + else if (swinfo2->parentname() != nullptr) osd_printf_error("%s: %s is a clone of a clone\n", filename(), swinfo->shortname()); } @@ -611,19 +611,19 @@ void software_list_device::internal_validity_check(validity_checker &valid) } softlist_map part_names; - for (software_part *part = swinfo->first_part(); part != NULL; part = part->next()) + for (software_part *part = swinfo->first_part(); part != nullptr; part = part->next()) { - if (part->interface() == NULL) + if (part->interface() == nullptr) osd_printf_error("%s: %s has a part (%s) without interface\n", filename(), swinfo->shortname(), part->name()); - if (part->romdata() == NULL) + if (part->romdata() == nullptr) osd_printf_error("%s: %s has a part (%s) with no data\n", filename(), swinfo->shortname(), part->name()); if (part_names.add(part->name(), swinfo, false) == TMERR_DUPLICATE) osd_printf_error("%s: %s has a part (%s) whose name is duplicate\n", filename(), swinfo->shortname(), part->name()); - for (const rom_entry *data = part->romdata(); data->_name != NULL; data++) - if (data->_hashdata != NULL) + for (const rom_entry *data = part->romdata(); data->_name != nullptr; data++) + if (data->_hashdata != nullptr) { // make sure the hash is valid hash_collection hashes; @@ -652,8 +652,8 @@ softlist_parser::softlist_parser(software_list_device &list, std::string &errors m_errors(errors), m_done(false), m_data_accum_expected(false), - m_current_info(NULL), - m_current_part(NULL), + m_current_info(nullptr), + m_current_part(nullptr), m_pos(POS_ROOT) { osd_printf_verbose("Parsing %s\n", m_list.m_file.filename()); @@ -665,8 +665,8 @@ softlist_parser::softlist_parser(software_list_device &list, std::string &errors memcallbacks.free_fcn = expat_free; // create the parser - m_parser = XML_ParserCreate_MM(NULL, &memcallbacks, NULL); - if (m_parser == NULL) + m_parser = XML_ParserCreate_MM(nullptr, &memcallbacks, nullptr); + if (m_parser == nullptr) throw std::bad_alloc(); // set the handlers @@ -708,7 +708,7 @@ void *softlist_parser::expat_malloc(size_t size) void *softlist_parser::expat_realloc(void *ptr, size_t size) { - if (ptr != NULL) global_free_array((UINT8 *)ptr); + if (ptr != nullptr) global_free_array((UINT8 *)ptr); return global_alloc_array_clear(UINT8, size); } @@ -775,16 +775,16 @@ void softlist_parser::parse_attributes(const char **attributes, int numattrs, co void softlist_parser::add_rom_entry(const char *name, const char *hashdata, UINT32 offset, UINT32 length, UINT32 flags) { // get the current part - if (m_current_part == NULL) + if (m_current_part == nullptr) { parse_error("ROM entry added in invalid context"); return; } // make sure we don't add duplicate regions - if (name != NULL && (flags & ROMENTRY_TYPEMASK) == ROMENTRYTYPE_REGION) - for (unsigned int romentry = 0; romentry < m_current_part->m_romdata.size(); romentry++) - if (m_current_part->m_romdata[romentry]._name != NULL && strcmp(m_current_part->m_romdata[romentry]._name, name) == 0) + if (name != nullptr && (flags & ROMENTRY_TYPEMASK) == ROMENTRYTYPE_REGION) + for (auto & elem : m_current_part->m_romdata) + if (elem._name != nullptr && strcmp(elem._name, name) == 0) parse_error("Duplicated dataarea %s in software %s", name, infoname()); // create the new entry and append it @@ -852,12 +852,12 @@ void softlist_parser::end_handler(void *data, const char *name) break; case POS_MAIN: - state->m_current_info = NULL; + state->m_current_info = nullptr; break; case POS_SOFT: state->parse_soft_end(name); - state->m_current_part = NULL; + state->m_current_part = nullptr; break; case POS_PART: @@ -906,10 +906,10 @@ void softlist_parser::parse_root_start(const char *tagname, const char **attribu if (strcmp(tagname, "softwarelist") == 0) { static const char *attrnames[] = { "name", "description" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[1] != NULL) + if (attrvalues[1] != nullptr) m_list.m_description = m_list.add_string(attrvalues[1]); } else @@ -928,10 +928,10 @@ void softlist_parser::parse_main_start(const char *tagname, const char **attribu if (strcmp(tagname, "software") == 0) { static const char *attrnames[] = { "name", "cloneof", "supported" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[0] != NULL) + if (attrvalues[0] != nullptr) m_current_info = &m_list.m_infolist.append(*global_alloc(software_info(m_list, m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1]), attrvalues[2]))); else parse_error("No name defined for item"); @@ -949,7 +949,7 @@ void softlist_parser::parse_main_start(const char *tagname, const char **attribu void softlist_parser::parse_soft_start(const char *tagname, const char **attributes) { // get the current info; error if none - if (m_current_info == NULL) + if (m_current_info == nullptr) { parse_error("Tag %s found outside of software context", tagname); return; @@ -971,10 +971,10 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu else if (strcmp(tagname, "info") == 0) { static const char *attrnames[] = { "name", "value" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[0] != NULL && attrvalues[1] != NULL) + if (attrvalues[0] != nullptr && attrvalues[1] != nullptr) m_current_info->m_other_info.append(*global_alloc(feature_list_item(m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1])))); else parse_error("Incomplete other_info definition"); @@ -984,10 +984,10 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu else if (strcmp(tagname, "sharedfeat") == 0) { static const char *attrnames[] = { "name", "value" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[0] != NULL && attrvalues[1] != NULL) + if (attrvalues[0] != nullptr && attrvalues[1] != nullptr) m_current_info->m_shared_info.append(*global_alloc(feature_list_item(m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1])))); else parse_error("Incomplete sharedfeat definition"); @@ -997,10 +997,10 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu else if (strcmp(tagname, "part" ) == 0) { static const char *attrnames[] = { "name", "interface" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[0] != NULL && attrvalues[1] != NULL && strcmp(attrvalues[0], "") != 0 && strcmp(attrvalues[1], "") != 0) + if (attrvalues[0] != nullptr && attrvalues[1] != nullptr && strcmp(attrvalues[0], "") != 0 && strcmp(attrvalues[1], "") != 0) m_current_part = &m_current_info->m_partdata.append(*global_alloc(software_part(*m_current_info, m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1])))); else parse_error("Incomplete part definition"); @@ -1018,7 +1018,7 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu void softlist_parser::parse_part_start(const char *tagname, const char **attributes) { // get the current part; error if none - if (m_current_part == NULL) + if (m_current_part == nullptr) { parse_error("Tag %s found outside of part context", tagname); return; @@ -1028,17 +1028,17 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu if (strcmp(tagname, "dataarea") == 0) { static const char *attrnames[] = { "name", "size", "width", "endianness" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[0] != NULL && attrvalues[1] != NULL && strcmp(attrvalues[0], "") != 0 && strcmp(attrvalues[1], "") != 0) + if (attrvalues[0] != nullptr && attrvalues[1] != nullptr && strcmp(attrvalues[0], "") != 0 && strcmp(attrvalues[1], "") != 0) { // handle region attributes const char *width = attrvalues[2]; const char *endianness = attrvalues[3]; UINT32 regionflags = ROMENTRYTYPE_REGION; - if (width != NULL) + if (width != nullptr) { if (strcmp(width, "8") == 0) regionflags |= ROMREGION_8BIT; @@ -1051,7 +1051,7 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu else parse_error("Invalid dataarea width"); } - if (endianness != NULL) + if (endianness != nullptr) { if (strcmp(endianness, "little") == 0) regionflags |= ROMREGION_LE; @@ -1061,7 +1061,7 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu parse_error("Invalid dataarea endianness"); } - add_rom_entry(attrvalues[0], NULL, 0, strtol(attrvalues[1], NULL, 0), regionflags); + add_rom_entry(attrvalues[0], nullptr, 0, strtol(attrvalues[1], nullptr, 0), regionflags); } else parse_error("Incomplete dataarea definition"); @@ -1071,11 +1071,11 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu else if (strcmp(tagname, "diskarea") == 0) { static const char *attrnames[] = { "name" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[0] != NULL) - add_rom_entry(attrvalues[0], NULL, 0, 1, ROMENTRYTYPE_REGION | ROMREGION_DATATYPEDISK); + if (attrvalues[0] != nullptr) + add_rom_entry(attrvalues[0], nullptr, 0, 1, ROMENTRYTYPE_REGION | ROMREGION_DATATYPEDISK); else parse_error("Incomplete diskarea definition"); } @@ -1084,10 +1084,10 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu else if (strcmp(tagname, "feature") == 0) { static const char *attrnames[] = { "name", "value" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); - if (attrvalues[0] != NULL) + if (attrvalues[0] != nullptr) m_current_part->m_featurelist.append(*global_alloc(feature_list_item(m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1])))); else parse_error("Incomplete feature definition"); @@ -1109,7 +1109,7 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu void softlist_parser::parse_data_start(const char *tagname, const char **attributes) { // get the current part; error if none - if (m_current_part == NULL) + if (m_current_part == nullptr) { parse_error("Tag %s found outside of part context", tagname); return; @@ -1119,7 +1119,7 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu if (strcmp(tagname, "rom") == 0) { static const char *attrnames[] = { "name", "size", "crc", "sha1", "offset", "value", "status", "loadflag" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); const char *name = attrvalues[0]; @@ -1130,34 +1130,34 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu const char *value = attrvalues[5]; const char *status = attrvalues[6]; const char *loadflag = attrvalues[7]; - if (sizestr != NULL && offsetstr != NULL) + if (sizestr != nullptr && offsetstr != nullptr) { - UINT32 length = strtol(sizestr, NULL, 0); - UINT32 offset = strtol(offsetstr, NULL, 0); - - if (loadflag != NULL && strcmp(loadflag, "reload") == 0) - add_rom_entry(NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS); - else if (loadflag != NULL && strcmp(loadflag, "reload_plain") == 0) - add_rom_entry(NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD); - else if (loadflag != NULL && strcmp(loadflag, "continue") == 0) - add_rom_entry(NULL, NULL, offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS); - else if (loadflag != NULL && strcmp(loadflag, "fill") == 0) - add_rom_entry(NULL, (const char *)(FPTR)(strtol(value, NULL, 0) & 0xff), offset, length, ROMENTRYTYPE_FILL); - else if (name != NULL) + UINT32 length = strtol(sizestr, nullptr, 0); + UINT32 offset = strtol(offsetstr, nullptr, 0); + + if (loadflag != nullptr && strcmp(loadflag, "reload") == 0) + add_rom_entry(nullptr, nullptr, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS); + else if (loadflag != nullptr && strcmp(loadflag, "reload_plain") == 0) + add_rom_entry(nullptr, nullptr, offset, length, ROMENTRYTYPE_RELOAD); + else if (loadflag != nullptr && strcmp(loadflag, "continue") == 0) + add_rom_entry(nullptr, nullptr, offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS); + else if (loadflag != nullptr && strcmp(loadflag, "fill") == 0) + add_rom_entry(nullptr, (const char *)(FPTR)(strtol(value, nullptr, 0) & 0xff), offset, length, ROMENTRYTYPE_FILL); + else if (name != nullptr) { - bool baddump = (status != NULL && strcmp(status, "baddump") == 0); - bool nodump = (status != NULL && strcmp(status, "nodump") == 0); + bool baddump = (status != nullptr && strcmp(status, "baddump") == 0); + bool nodump = (status != nullptr && strcmp(status, "nodump") == 0); std::string hashdata; if (nodump) { strprintf(hashdata, "%s", NO_DUMP); - if (crc != NULL && sha1 != NULL) + if (crc != nullptr && sha1 != nullptr) parse_error("No need for hash definition"); } else { - if (crc != NULL && sha1 != NULL) + if (crc != nullptr && sha1 != nullptr) strprintf(hashdata, "%c%s%c%s%s", hash_collection::HASH_CRC, crc, hash_collection::HASH_SHA1, sha1, (baddump ? BAD_DUMP : "")); else parse_error("Incomplete rom hash definition"); @@ -1165,15 +1165,15 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu // Handle loadflag attribute int romflags = 0; - if (loadflag != NULL && strcmp(loadflag, "load16_word_swap") == 0) + if (loadflag != nullptr && strcmp(loadflag, "load16_word_swap") == 0) romflags = ROM_GROUPWORD | ROM_REVERSE; - else if (loadflag != NULL && strcmp(loadflag, "load16_byte") == 0) + else if (loadflag != nullptr && strcmp(loadflag, "load16_byte") == 0) romflags = ROM_SKIP(1); - else if (loadflag != NULL && strcmp(loadflag, "load32_word_swap") == 0) + else if (loadflag != nullptr && strcmp(loadflag, "load32_word_swap") == 0) romflags = ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(2); - else if (loadflag != NULL && strcmp(loadflag, "load32_word") == 0) + else if (loadflag != nullptr && strcmp(loadflag, "load32_word") == 0) romflags = ROM_GROUPWORD | ROM_SKIP(2); - else if (loadflag != NULL && strcmp(loadflag, "load32_byte") == 0) + else if (loadflag != nullptr && strcmp(loadflag, "load32_byte") == 0) romflags = ROM_SKIP(3); add_rom_entry(name, hashdata.c_str(), offset, length, ROMENTRYTYPE_ROM | romflags); @@ -1189,24 +1189,24 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu else if (strcmp(tagname, "disk") == 0) { static const char *attrnames[] = { "name", "sha1", "status", "writeable" }; - const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 }; + const char *attrvalues[ARRAY_LENGTH(attrnames)] = { nullptr }; parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues); const char *name = attrvalues[0]; const char *sha1 = attrvalues[1]; const char *status = attrvalues[2]; const char *writeablestr = attrvalues[3]; - if (name != NULL && sha1 != NULL) + if (name != nullptr && sha1 != nullptr) { - bool baddump = (status != NULL && strcmp(status, "baddump") == 0); - bool nodump = (status != NULL && strcmp(status, "nodump" ) == 0); - bool writeable = (writeablestr != NULL && strcmp(writeablestr, "yes") == 0); + bool baddump = (status != nullptr && strcmp(status, "baddump") == 0); + bool nodump = (status != nullptr && strcmp(status, "nodump" ) == 0); + bool writeable = (writeablestr != nullptr && strcmp(writeablestr, "yes") == 0); std::string hashdata; strprintf(hashdata, "%c%s%s", hash_collection::HASH_SHA1, sha1, (nodump ? NO_DUMP : (baddump ? BAD_DUMP : ""))); add_rom_entry(name, hashdata.c_str(), 0, 0, ROMENTRYTYPE_ROM | (writeable ? DISK_READWRITE : DISK_READONLY)); } - else if (status == NULL || !strcmp(status, "nodump")) // a no_dump chd is not an incomplete entry + else if (status == nullptr || !strcmp(status, "nodump")) // a no_dump chd is not an incomplete entry parse_error("Incomplete disk definition"); } @@ -1225,7 +1225,7 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu void softlist_parser::parse_soft_end(const char *tagname) { - assert(m_current_info != NULL); + assert(m_current_info != nullptr); // if (strcmp(tagname, "description") == 0) @@ -1243,18 +1243,18 @@ void softlist_parser::parse_soft_end(const char *tagname) else if (strcmp(tagname, "part") == 0) { // get the last part - assert(m_current_part != NULL); - if (m_current_part == NULL) + assert(m_current_part != nullptr); + if (m_current_part == nullptr) return; // was any dataarea/rom information encountered? if so, add a terminator - if (m_current_part->romdata() != NULL) - add_rom_entry(NULL, NULL, 0, 0, ROMENTRYTYPE_END); + if (m_current_part->romdata() != nullptr) + add_rom_entry(nullptr, nullptr, 0, 0, ROMENTRYTYPE_END); // get the info; if present, copy shared data (we assume name/value strings live // in the string pool and don't need to be reallocated) - if (m_current_info != NULL) - for (feature_list_item *item = m_current_info->shared_info(); item != NULL; item = item->next()) + if (m_current_info != nullptr) + for (feature_list_item *item = m_current_info->shared_info(); item != nullptr; item = item->next()) m_current_part->m_featurelist.append(*global_alloc(feature_list_item(item->name(), item->value()))); } } diff --git a/src/emu/softlist.h b/src/emu/softlist.h index b500ab4f018..63ce6f0da20 100644 --- a/src/emu/softlist.h +++ b/src/emu/softlist.h @@ -76,8 +76,8 @@ class feature_list_item public: // construction/destruction - feature_list_item(const char *name = NULL, const char *value = NULL) - : m_next(NULL), + feature_list_item(const char *name = nullptr, const char *value = nullptr) + : m_next(nullptr), m_name(name), m_value(value) { } @@ -104,7 +104,7 @@ class software_part public: // construction/destruction - software_part(software_info &info, const char *name = NULL, const char *interface = NULL); + software_part(software_info &info, const char *name = nullptr, const char *interface = nullptr); // getters software_part *next() const { return m_next; } @@ -112,7 +112,7 @@ public: const char *name() const { return m_name; } const char *interface() const { return m_interface; } feature_list_item *featurelist() const { return m_featurelist.first(); } - rom_entry *romdata(unsigned int index = 0) { return (index < m_romdata.size()) ? &m_romdata[index] : NULL; } + rom_entry *romdata(unsigned int index = 0) { return (index < m_romdata.size()) ? &m_romdata[index] : nullptr; } // helpers bool is_compatible(const software_list_device &swlist) const; @@ -158,7 +158,7 @@ public: software_part *last_part() const { return m_partdata.last(); } // additional operations - software_part *find_part(const char *partname, const char *interface = NULL); + software_part *find_part(const char *partname, const char *interface = nullptr); bool has_multiple_parts(const char *interface) const; private: @@ -205,7 +205,7 @@ public: const char *errors_string() { if (!m_parsed) parse(); return m_errors.c_str(); } // operations - software_info *find(const char *look_for, software_info *prev = NULL); + software_info *find(const char *look_for, software_info *prev = nullptr); software_info *first_software_info() { if (!m_parsed) parse(); return m_infolist.first(); } void find_approx_matches(const char *name, int matches, software_info **list, const char *interface); void release(); @@ -224,8 +224,8 @@ protected: void internal_validity_check(validity_checker &valid) ATTR_COLD; // device-level overrides - virtual void device_start(); - virtual void device_validity_check(validity_checker &valid) const ATTR_COLD; + virtual void device_start() override; + virtual void device_validity_check(validity_checker &valid) const override ATTR_COLD; // configuration state std::string m_list_name; diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index f24fb56980b..dbfc8813ec7 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -50,7 +50,7 @@ const attotime sound_manager::STREAMS_UPDATE_ATTOTIME = attotime::from_hz(STREAM sound_stream::sound_stream(device_t &device, int inputs, int outputs, int sample_rate, stream_update_delegate callback) : m_device(device), - m_next(NULL), + m_next(nullptr), m_sample_rate(sample_rate), m_new_sample_rate(0), m_attoseconds_per_sample(0), @@ -64,7 +64,7 @@ sound_stream::sound_stream(device_t &device, int inputs, int outputs, int sample m_output_sampindex(0), m_output_update_sampindex(0), m_output_base_sampindex(0), - m_callback(callback) + m_callback(std::move(callback)) { // get the device's sound interface device_sound_interface *sound; @@ -100,7 +100,7 @@ sound_stream::sound_stream(device_t &device, int inputs, int outputs, int sample m_sync_timer = m_device.machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sound_stream::sync_update), this)); } else - m_sync_timer = NULL; + m_sync_timer = nullptr; // force an update to the sample rates; this will cause everything to be recomputed // and will generate the initial resample buffers for our inputs @@ -170,7 +170,7 @@ const char *sound_stream::input_name(int inputnum, std::string &str) const strprintf(str, "%s '%s': ", m_device.name(), m_device.tag()); // if we have a source, indicate where the sound comes from by device name and tag - if (m_input[inputnum].m_source != NULL && m_input[inputnum].m_source->m_stream != NULL) + if (m_input[inputnum].m_source != nullptr && m_input[inputnum].m_source->m_stream != nullptr) { device_t &source = m_input[inputnum].m_source->m_stream->device(); strcatprintf(str, "%s '%s'", source.name(), source.tag()); @@ -183,7 +183,7 @@ const char *sound_stream::input_name(int inputnum, std::string &str) const // then look for a match on the output number sound_stream *outstream; int streamoutputnum; - for (int outputnum = 0; (outstream = sound->output_to_stream_output(outputnum, streamoutputnum)) != NULL; outputnum++) + for (int outputnum = 0; (outstream = sound->output_to_stream_output(outputnum, streamoutputnum)) != nullptr; outputnum++) if (outstream == m_input[inputnum].m_source->m_stream && m_input[inputnum].m_source == &outstream->m_output[streamoutputnum]) { strcatprintf(str, " Ch.%d", outputnum); @@ -203,7 +203,7 @@ const char *sound_stream::input_name(int inputnum, std::string &str) const device_t *sound_stream::input_source_device(int inputnum) const { assert(inputnum >= 0 && inputnum < m_input.size()); - return (m_input[inputnum].m_source != NULL) ? &m_input[inputnum].m_source->m_stream->device() : NULL; + return (m_input[inputnum].m_source != nullptr) ? &m_input[inputnum].m_source->m_stream->device() : nullptr; } @@ -215,7 +215,7 @@ device_t *sound_stream::input_source_device(int inputnum) const int sound_stream::input_source_outputnum(int inputnum) const { assert(inputnum >= 0 && inputnum < m_input.size()); - return (m_input[inputnum].m_source != NULL) ? (m_input[inputnum].m_source - &m_input[inputnum].m_source->m_stream->m_output[0]) : -1; + return (m_input[inputnum].m_source != nullptr) ? (m_input[inputnum].m_source - &m_input[inputnum].m_source->m_stream->m_output[0]) : -1; } @@ -233,21 +233,21 @@ void sound_stream::set_input(int index, sound_stream *input_stream, int output_i fatalerror("Fatal error: stream_set_input attempted to configure non-existant input %d (%d max)\n", index, int(m_input.size())); // make sure it's a valid output - if (input_stream != NULL && output_index >= input_stream->m_output.size()) + if (input_stream != nullptr && output_index >= input_stream->m_output.size()) fatalerror("Fatal error: stream_set_input attempted to use a non-existant output %d (%d max)\n", output_index, int(m_output.size())); // if this input is already wired, update the dependent info stream_input &input = m_input[index]; - if (input.m_source != NULL) + if (input.m_source != nullptr) input.m_source->m_dependents--; // wire it up - input.m_source = (input_stream != NULL) ? &input_stream->m_output[output_index] : NULL; + input.m_source = (input_stream != nullptr) ? &input_stream->m_output[output_index] : nullptr; input.m_gain = int(0x100 * gain); input.m_user_gain = 0x100; // update the dependent info - if (input.m_source != NULL) + if (input.m_source != nullptr) input.m_source->m_dependents++; // update sample rates now that we know the input @@ -402,9 +402,9 @@ void sound_stream::update_with_accounting(bool second_tick) { // if we have samples to move, do so for each output if (output_bufindex > 0) - for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) + for (auto & output : m_output) { - stream_output &output = m_output[outputnum]; + memmove(&output.m_buffer[0], &output.m_buffer[samples_to_lose], sizeof(output.m_buffer[0]) * (output_bufindex - samples_to_lose)); } @@ -440,8 +440,8 @@ void sound_stream::apply_sample_rate_changes() m_output_base_sampindex = m_output_sampindex - m_max_samples_per_update; // clear out the buffer - for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) - memset(&m_output[outputnum].m_buffer[0], 0, m_max_samples_per_update * sizeof(m_output[outputnum].m_buffer[0])); + for (auto & elem : m_output) + memset(&elem.m_buffer[0], 0, m_max_samples_per_update * sizeof(elem.m_buffer[0])); } @@ -457,10 +457,10 @@ void sound_stream::recompute_sample_rate_data() { m_sample_rate = 0; // When synchronous, pick the sample rate for the inputs, if any - for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) + for (auto & input : m_input) { - stream_input &input = m_input[inputnum]; - if (input.m_source != NULL) + + if (input.m_source != nullptr) { if (!m_sample_rate) m_sample_rate = input.m_source->m_stream->m_sample_rate; @@ -483,11 +483,11 @@ void sound_stream::recompute_sample_rate_data() allocate_output_buffers(); // iterate over each input - for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) + for (auto & input : m_input) { // if we have a source, see if its sample rate changed - stream_input &input = m_input[inputnum]; - if (input.m_source != NULL) + + if (input.m_source != nullptr) { // okay, we have a new sample rate; recompute the latency to be the maximum // sample period between us and our input @@ -537,10 +537,10 @@ void sound_stream::allocate_resample_buffers() m_resample_bufalloc = bufsize; // iterate over outputs and realloc their buffers - for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) { - unsigned int old_size = m_input[inputnum].m_resample.size(); - m_input[inputnum].m_resample.resize(m_resample_bufalloc); - memset(&m_input[inputnum].m_resample[old_size], 0, (m_resample_bufalloc - old_size)*sizeof(m_input[inputnum].m_resample[0])); + for (auto & elem : m_input) { + unsigned int old_size = elem.m_resample.size(); + elem.m_resample.resize(m_resample_bufalloc); + memset(&elem.m_resample[old_size], 0, (m_resample_bufalloc - old_size)*sizeof(elem.m_resample[0])); } } } @@ -561,10 +561,10 @@ void sound_stream::allocate_output_buffers() m_output_bufalloc = bufsize; // iterate over outputs and realloc their buffers - for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) { - unsigned int old_size = m_output[outputnum].m_buffer.size(); - m_output[outputnum].m_buffer.resize(m_output_bufalloc); - memset(&m_output[outputnum].m_buffer[old_size], 0, (m_output_bufalloc - old_size)*sizeof(m_output[outputnum].m_buffer[0])); + for (auto & elem : m_output) { + unsigned int old_size = elem.m_buffer.size(); + elem.m_buffer.resize(m_output_bufalloc); + memset(&elem.m_buffer[old_size], 0, (m_output_bufalloc - old_size)*sizeof(elem.m_buffer[0])); } } } @@ -580,8 +580,8 @@ void sound_stream::postload() recompute_sample_rate_data(); // make sure our output buffers are fully cleared - for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) - memset(&m_output[outputnum].m_buffer[0], 0, m_output_bufalloc * sizeof(m_output[outputnum].m_buffer[0])); + for (auto & elem : m_output) + memset(&elem.m_buffer[0], 0, m_output_bufalloc * sizeof(elem.m_buffer[0])); // recompute the sample indexes to make sense m_output_sampindex = m_device.machine().sound().last_update().attoseconds() / m_attoseconds_per_sample; @@ -599,8 +599,8 @@ void sound_stream::postload() void sound_stream::generate_samples(int samples) { - stream_sample_t **inputs = NULL; - stream_sample_t **outputs = NULL; + stream_sample_t **inputs = nullptr; + stream_sample_t **outputs = nullptr; // if we're already there, skip it if (samples <= 0) return; @@ -612,7 +612,7 @@ void sound_stream::generate_samples(int samples) { // update the stream to the current time stream_input &input = m_input[inputnum]; - if (input.m_source != NULL) + if (input.m_source != nullptr) input.m_source->m_stream->update(); // generate the resampled data @@ -652,7 +652,7 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, UINT { // if we don't have an output to pull data from, generate silence stream_sample_t *dest = &input.m_resample[0]; - if (input.m_source == NULL) + if (input.m_source == nullptr) { memset(dest, 0, numsamples * sizeof(*dest)); return &input.m_resample[0]; @@ -773,7 +773,7 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, UINT //------------------------------------------------- sound_stream::stream_input::stream_input() - : m_source(NULL), + : m_source(nullptr), m_latency_attoseconds(0), m_gain(0x100), m_user_gain(0x100) @@ -791,7 +791,7 @@ sound_stream::stream_input::stream_input() //------------------------------------------------- sound_stream::stream_output::stream_output() - : m_stream(NULL), + : m_stream(nullptr), m_dependents(0), m_gain(0x100) { @@ -809,7 +809,7 @@ sound_stream::stream_output::stream_output() sound_manager::sound_manager(running_machine &machine) : m_machine(machine), - m_update_timer(NULL), + m_update_timer(nullptr), m_finalmix_leftover(0), m_finalmix(machine.sample_rate()), m_leftmix(machine.sample_rate()), @@ -817,7 +817,7 @@ sound_manager::sound_manager(running_machine &machine) m_muted(0), m_attenuation(0), m_nosound_mode(machine.osd().no_sound()), - m_wavfile(NULL), + m_wavfile(nullptr), m_update_attoseconds(STREAMS_UPDATE_ATTOTIME.attoseconds()), m_last_update(attotime::zero) { @@ -864,9 +864,9 @@ sound_manager::sound_manager(running_machine &machine) sound_manager::~sound_manager() { // close any open WAV file - if (m_wavfile != NULL) + if (m_wavfile != nullptr) wav_close(m_wavfile); - m_wavfile = NULL; + m_wavfile = nullptr; } @@ -901,12 +901,12 @@ bool sound_manager::indexed_mixer_input(int index, mixer_input &info) const { // scan through the mixers until we find the indexed input mixer_interface_iterator iter(machine().root_device()); - for (info.mixer = iter.first(); info.mixer != NULL; info.mixer = iter.next()) + for (info.mixer = iter.first(); info.mixer != nullptr; info.mixer = iter.next()) { if (index < info.mixer->inputs()) { info.stream = info.mixer->input_to_stream_input(index, info.inputnum); - assert(info.stream != NULL); + assert(info.stream != nullptr); return true; } index -= info.mixer->inputs(); @@ -939,7 +939,7 @@ void sound_manager::reset() { // reset all the sound chips sound_interface_iterator iter(machine().root_device()); - for (device_sound_interface *sound = iter.first(); sound != NULL; sound = iter.next()) + for (device_sound_interface *sound = iter.first(); sound != nullptr; sound = iter.next()) sound->device().reset(); } @@ -976,11 +976,11 @@ void sound_manager::config_load(int config_type, xml_data_node *parentnode) return; // might not have any data - if (parentnode == NULL) + if (parentnode == nullptr) return; // iterate over channel nodes - for (xml_data_node *channelnode = xml_get_sibling(parentnode->child, "channel"); channelnode != NULL; channelnode = xml_get_sibling(channelnode->next, "channel")) + for (xml_data_node *channelnode = xml_get_sibling(parentnode->child, "channel"); channelnode != nullptr; channelnode = xml_get_sibling(channelnode->next, "channel")) { mixer_input info; if (indexed_mixer_input(xml_get_attribute_int(channelnode, "index", -1), info)) @@ -1006,7 +1006,7 @@ void sound_manager::config_save(int config_type, xml_data_node *parentnode) return; // iterate over mixer channels - if (parentnode != NULL) + if (parentnode != nullptr) for (int mixernum = 0; ; mixernum++) { mixer_input info; @@ -1016,8 +1016,8 @@ void sound_manager::config_save(int config_type, xml_data_node *parentnode) if (newvol != 1.0f) { - xml_data_node *channelnode = xml_add_child(parentnode, "channel", NULL); - if (channelnode != NULL) + xml_data_node *channelnode = xml_add_child(parentnode, "channel", nullptr); + if (channelnode != nullptr) { xml_set_attribute_int(channelnode, "index", mixernum); xml_set_attribute_float(channelnode, "newvol", newvol); @@ -1041,7 +1041,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; speaker_device_iterator iter(machine().root_device()); - for (speaker_device *speaker = iter.first(); speaker != NULL; speaker = iter.next()) + for (speaker_device *speaker = iter.first(); speaker != nullptr; speaker = iter.next()) speaker->mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM)); // now downmix the final result @@ -1077,7 +1077,7 @@ void sound_manager::update(void *ptr, int param) if (!m_nosound_mode) machine().osd().update_audio_stream(finalmix, finalmix_offset / 2); machine().video().add_sound_to_recording(finalmix, finalmix_offset / 2); - if (m_wavfile != NULL) + if (m_wavfile != nullptr) wav_add_data_16(m_wavfile, finalmix, finalmix_offset); } @@ -1091,14 +1091,14 @@ void sound_manager::update(void *ptr, int param) } // iterate over all the streams and update them - for (sound_stream *stream = m_stream_list.first(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_stream_list.first(); stream != nullptr; stream = stream->next()) stream->update_with_accounting(second_tick); // remember the update time m_last_update = curtime; // update sample rates if they have changed - for (sound_stream *stream = m_stream_list.first(); stream != NULL; stream = stream->next()) + for (sound_stream *stream = m_stream_list.first(); stream != nullptr; stream = stream->next()) stream->apply_sample_rate_changes(); g_profiler.stop(); diff --git a/src/emu/sound.h b/src/emu/sound.h index 557d4242fa6..50c94486eb3 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -225,7 +225,7 @@ private: void config_load(int config_type, xml_data_node *parentnode); void config_save(int config_type, xml_data_node *parentnode); - void update(void *ptr = NULL, INT32 param = 0); + void update(void *ptr = nullptr, INT32 param = 0); // internal state running_machine & m_machine; // reference to our machine diff --git a/src/emu/sound/filter.cpp b/src/emu/sound/filter.cpp index 4893c29c005..452dd8b3f1b 100644 --- a/src/emu/sound/filter.cpp +++ b/src/emu/sound/filter.cpp @@ -4,7 +4,7 @@ #include "filter.h" static filter* filter_alloc(void) { - filter* f = global_alloc(filter); + auto f = global_alloc(filter); return f; } @@ -22,7 +22,7 @@ void filter_state_reset(filter* f, filter_state* s) { filter_state* filter_state_alloc(void) { int i; - filter_state* s = global_alloc(filter_state); + auto s = global_alloc(filter_state); s->prev_mac = 0; for(i=0;ixprev[i] = 0; diff --git a/src/emu/sound/wavwrite.cpp b/src/emu/sound/wavwrite.cpp index baf5498f02c..210b1bcc9d5 100644 --- a/src/emu/sound/wavwrite.cpp +++ b/src/emu/sound/wavwrite.cpp @@ -20,14 +20,14 @@ wav_file *wav_open(const char *filename, int sample_rate, int channels) /* allocate memory for the wav struct */ wav = (wav_file *) global_alloc(wav_file); if (!wav) - return NULL; + return nullptr; /* create the file */ wav->file = fopen(filename, "wb"); if (!wav->file) { global_free(wav); - return NULL; + return nullptr; } /* write the 'RIFF' header */ diff --git a/src/emu/speaker.cpp b/src/emu/speaker.cpp index c525ff2cbc6..485a6be73ca 100644 --- a/src/emu/speaker.cpp +++ b/src/emu/speaker.cpp @@ -90,7 +90,7 @@ void speaker_device::static_set_position(device_t &device, double x, double y, d void speaker_device::mix(INT32 *leftmix, INT32 *rightmix, int &samples_this_update, bool suppress) { // skip if no stream - if (m_mixer_stream == NULL) + if (m_mixer_stream == nullptr) return; // update the stream, getting the start/end pointers around the operation diff --git a/src/emu/speaker.h b/src/emu/speaker.h index 1b9103beb01..dc814a26911 100644 --- a/src/emu/speaker.h +++ b/src/emu/speaker.h @@ -68,7 +68,7 @@ public: protected: // device-level overrides - virtual void device_start() ATTR_COLD; + virtual void device_start() override ATTR_COLD; // inline configuration state double m_x; diff --git a/src/emu/sprite.cpp b/src/emu/sprite.cpp index f96d483beeb..7567f0dd0ac 100644 --- a/src/emu/sprite.cpp +++ b/src/emu/sprite.cpp @@ -114,7 +114,7 @@ sparse_dirty_rect *sparse_dirty_bitmap::first_dirty_rect(const rectangle &clipre for (int y = sy; y <= ey; y++) { UINT8 *dirtybase = &m_bitmap.pix(y); - sparse_dirty_rect *currect = NULL; + sparse_dirty_rect *currect = nullptr; // loop over all grid columns that intersect our cliprect for (int x = sx; x <= ex; x++) @@ -122,14 +122,14 @@ sparse_dirty_rect *sparse_dirty_bitmap::first_dirty_rect(const rectangle &clipre // if this tile is not dirty, end our current run and continue if (!dirtybase[x]) { - if (currect != NULL) + if (currect != nullptr) *currect &= cliprect; - currect = NULL; + currect = nullptr; continue; } // if we can't add to an existing rect, create a new one - if (currect == NULL) + if (currect == nullptr) { // allocate a new rect and add it to the list currect = &m_rect_list.append(*m_rect_allocator.alloc()); @@ -147,7 +147,7 @@ sparse_dirty_rect *sparse_dirty_bitmap::first_dirty_rect(const rectangle &clipre } // clip the last rect to the cliprect - if (currect != NULL) + if (currect != nullptr) *currect &= cliprect; } diff --git a/src/emu/sprite.h b/src/emu/sprite.h index b61f5e07f3b..eb8aaec71db 100644 --- a/src/emu/sprite.h +++ b/src/emu/sprite.h @@ -24,7 +24,7 @@ class sparse_dirty_rect : public rectangle friend class simple_list; public: - sparse_dirty_rect(): m_next(NULL) { } + sparse_dirty_rect(): m_next(nullptr) { } // getters const sparse_dirty_rect *next() const { return m_next; } @@ -126,7 +126,7 @@ public: void clear() { clear(m_bitmap.cliprect()); } void clear(const rectangle &cliprect) { - for (const sparse_dirty_rect *rect = m_dirty.first_dirty_rect(cliprect); rect != NULL; rect = rect->next()) + for (const sparse_dirty_rect *rect = m_dirty.first_dirty_rect(cliprect); rect != nullptr; rect = rect->next()) m_bitmap.fill(~0, *rect); m_dirty.clean(cliprect); } @@ -167,11 +167,11 @@ public: protected: // device-level overrides - virtual void device_start() + virtual void device_start() override { // find spriteram memory_share *spriteram = owner()->memshare(tag()); - if (spriteram != NULL) + if (spriteram != nullptr) { set_spriteram(reinterpret_cast<_SpriteRAMType *>(spriteram->ptr()), spriteram->bytes()); diff --git a/src/emu/tilemap.cpp b/src/emu/tilemap.cpp index 43be2252666..2c7334bb068 100644 --- a/src/emu/tilemap.cpp +++ b/src/emu/tilemap.cpp @@ -349,8 +349,8 @@ tilemap_t &tilemap_t::init(tilemap_manager &manager, device_gfx_interface &decod m_manager = &manager; m_device = dynamic_cast(this); m_palette = decoder.palette(); - m_next = NULL; - m_user_data = NULL; + m_next = nullptr; + m_user_data = nullptr; // populate tilemap metrics m_rows = rows; @@ -409,17 +409,17 @@ tilemap_t &tilemap_t::init(tilemap_manager &manager, device_gfx_interface &decod // save relevant state int instance = manager.alloc_instance(); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_enable)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_attributes)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_palette_offset)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_scrollrows)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_scrollcols)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_rowscroll)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_colscroll)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dx)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dx_flipped)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dy)); - machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dy_flipped)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_enable)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_attributes)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_palette_offset)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_scrollrows)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_scrollcols)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_rowscroll)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_colscroll)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_dx)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_dx_flipped)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_dy)); + machine().save().save_item(m_device, "tilemap", nullptr, instance, NAME(m_dy_flipped)); // reset everything after a load machine().save().register_postload(save_prepost_delegate(FUNC(tilemap_t::postload), this)); @@ -760,7 +760,7 @@ g_profiler.start(PROFILER_TILEMAP_UPDATE); m_tileinfo.palette_base, m_tileinfo.category, m_tileinfo.group, flags, m_tileinfo.pen_mask); // if mask data is specified, apply it - if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && m_tileinfo.mask_data != NULL) + if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && m_tileinfo.mask_data != nullptr) m_tileflags[logindex] = tile_apply_bitmask(m_tileinfo.mask_data, x0, y0, m_tileinfo.category, flags); // track which gfx have been used for this tilemap @@ -1124,7 +1124,7 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b // look up priority and destination base addresses for y1 bitmap_ind8 &priority_bitmap = *blit.priority; UINT8 *priority_baseaddr = &priority_bitmap.pix8(y1, xpos); - typename _BitmapClass::pixel_t *dest_baseaddr = NULL; + typename _BitmapClass::pixel_t *dest_baseaddr = nullptr; int dest_rowpixels = 0; if (dest.valid()) { @@ -1208,7 +1208,7 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b { for (int cury = y; cury < nexty; cury++) { - if (dest_baseaddr == NULL) + if (dest_baseaddr == nullptr) scanline_draw_opaque_null(x_end - x_start, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 2) scanline_draw_opaque_ind16(reinterpret_cast(dest0), source0, x_end - x_start, pmap0, blit.tilemap_priority_code); @@ -1229,7 +1229,7 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b const UINT8 *mask0 = mask_baseaddr + x_start; for (int cury = y; cury < nexty; cury++) { - if (dest_baseaddr == NULL) + if (dest_baseaddr == nullptr) scanline_draw_masked_null(mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 2) scanline_draw_masked_ind16(reinterpret_cast(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code); @@ -1503,8 +1503,8 @@ tilemap_manager::~tilemap_manager() while (found) { found = false; - for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next()) - if (tmap->device() != NULL) + for (tilemap_t *tmap = m_tilemap_list.first(); tmap != nullptr; tmap = tmap->next()) + if (tmap->device() != nullptr) { found = true; m_tilemap_list.detach(*tmap); @@ -1537,14 +1537,14 @@ static const struct tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated) { - if (allocated == NULL) + if (allocated == nullptr) allocated = global_alloc(tilemap_t); return m_tilemap_list.append(allocated->init(*this, decoder, tile_get_info, mapper, tilewidth, tileheight, cols, rows)); } tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated) { - if (allocated == NULL) + if (allocated == nullptr) allocated = global_alloc(tilemap_t); return m_tilemap_list.append(allocated->init(*this, decoder, tile_get_info, tilemap_mapper_delegate(s_standard_mappers[mapper].func, s_standard_mappers[mapper].name, machine().driver_data()), tilewidth, tileheight, cols, rows)); } @@ -1557,7 +1557,7 @@ tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_in void tilemap_manager::set_flip_all(UINT32 attributes) { - for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next()) + for (tilemap_t *tmap = m_tilemap_list.first(); tmap != nullptr; tmap = tmap->next()) tmap->set_flip(attributes); } @@ -1569,7 +1569,7 @@ void tilemap_manager::set_flip_all(UINT32 attributes) void tilemap_manager::mark_all_dirty() { - for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next()) + for (tilemap_t *tmap = m_tilemap_list.first(); tmap != nullptr; tmap = tmap->next()) tmap->mark_all_dirty(); } @@ -1783,14 +1783,14 @@ void tilemap_device::device_start() // find the memory, if present const memory_share *share = memshare(tag()); - if (share != NULL) + if (share != nullptr) { m_basemem.set(*share, m_bytes_per_entry); // look for an extension entry std::string tag_ext = std::string(tag()).append("_ext"); share = memshare(tag_ext.c_str()); - if (share != NULL) + if (share != nullptr) m_extmem.set(*share, m_bytes_per_entry); } diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h index 55fa4d5769a..aaba8818d53 100644 --- a/src/emu/tilemap.h +++ b/src/emu/tilemap.h @@ -692,8 +692,8 @@ public: running_machine &machine() const { return m_machine; } // tilemap creation - tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated = NULL); - tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated = NULL); + tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated = nullptr); + tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated = nullptr); // tilemap list information tilemap_t *find(int index) { return m_tilemap_list.find(index); } @@ -748,7 +748,7 @@ public: protected: // device-level overrides - virtual void device_start(); + virtual void device_start() override; private: // devices diff --git a/src/emu/timer.cpp b/src/emu/timer.cpp index 7d089ca4655..605a16a7d4f 100644 --- a/src/emu/timer.cpp +++ b/src/emu/timer.cpp @@ -36,15 +36,15 @@ timer_device::timer_device(const machine_config &mconfig, const char *tag, devic : device_t(mconfig, TIMER, "Timer", tag, owner, clock, "timer", __FILE__), m_type(TIMER_TYPE_GENERIC), m_callback(timer_device_expired_delegate()), - m_ptr(NULL), + m_ptr(nullptr), m_start_delay(attotime::zero), m_period(attotime::zero), m_param(0), - m_screen_tag(NULL), - m_screen(NULL), + m_screen_tag(nullptr), + m_screen(nullptr), m_first_vpos(0), m_increment(0), - m_timer(NULL), + m_timer(nullptr), m_first_time(true) { } @@ -152,14 +152,14 @@ void timer_device::device_validity_check(validity_checker &valid) const switch (m_type) { case TIMER_TYPE_GENERIC: - if (m_screen_tag != NULL || m_first_vpos != 0 || m_start_delay != attotime::zero) + if (m_screen_tag != nullptr || m_first_vpos != 0 || m_start_delay != attotime::zero) osd_printf_warning("Generic timer specified parameters for a scanline timer\n"); if (m_period != attotime::zero || m_start_delay != attotime::zero) osd_printf_warning("Generic timer specified parameters for a periodic timer\n"); break; case TIMER_TYPE_PERIODIC: - if (m_screen_tag != NULL || m_first_vpos != 0) + if (m_screen_tag != nullptr || m_first_vpos != 0) osd_printf_warning("Periodic timer specified parameters for a scanline timer\n"); if (m_period <= attotime::zero) osd_printf_error("Periodic timer specified invalid period\n"); @@ -191,7 +191,7 @@ void timer_device::device_validity_check(validity_checker &valid) const void timer_device::device_start() { // fetch the screen - if (m_screen_tag != NULL) + if (m_screen_tag != nullptr) m_screen = machine().device(m_screen_tag); // allocate the timer @@ -234,7 +234,7 @@ void timer_device::device_reset() } case TIMER_TYPE_SCANLINE: - if (m_screen == NULL) + if (m_screen == nullptr) fatalerror("timer '%s': unable to find screen '%s'\n", tag(), m_screen_tag); // set the timer to fire immediately diff --git a/src/emu/timer.h b/src/emu/timer.h index 0dab2d50e6a..55db37c267b 100644 --- a/src/emu/timer.h +++ b/src/emu/timer.h @@ -114,10 +114,10 @@ public: private: // device-level overrides - virtual void device_validity_check(validity_checker &valid) const; - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + virtual void device_validity_check(validity_checker &valid) const override; + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // timer types enum timer_type diff --git a/src/emu/ui/barcode.cpp b/src/emu/ui/barcode.cpp index 84f4b89250b..fece584c641 100644 --- a/src/emu/ui/barcode.cpp +++ b/src/emu/ui/barcode.cpp @@ -72,8 +72,8 @@ void ui_menu_barcode_reader::populate() item_append("New Barcode:", new_barcode, 0, ITEMREF_NEW_BARCODE); // finish up the menu - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Enter Code", NULL, 0, ITEMREF_ENTER_BARCODE); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append("Enter Code", nullptr, 0, ITEMREF_ENTER_BARCODE); customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -94,7 +94,7 @@ void ui_menu_barcode_reader::handle() const ui_menu_event *event = process(UI_MENU_PROCESS_LR_REPEAT); // process the event - if (event != NULL) + if (event != nullptr) { // handle selections switch (event->iptkey) diff --git a/src/emu/ui/barcode.h b/src/emu/ui/barcode.h index 9d1ef25bc84..5a3dbff634e 100644 --- a/src/emu/ui/barcode.h +++ b/src/emu/ui/barcode.h @@ -20,8 +20,8 @@ class ui_menu_barcode_reader : public ui_menu_device_controlitemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { bool changed = false; /* clear cheat comment on any movement or keypress */ - machine().popmessage(NULL); + machine().popmessage(nullptr); /* handle reset all + reset all cheats for reload all option */ if ((FPTR)menu_event->itemref < 3 && menu_event->iptkey == IPT_UI_SELECT) { - for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next()) + for (cheat_entry *curcheat = machine().cheat().first(); curcheat != nullptr; curcheat = curcheat->next()) if (curcheat->select_default_state()) changed = true; } @@ -73,7 +73,7 @@ void ui_menu_cheat::handle() case IPT_UI_UP: case IPT_UI_DOWN: string = curcheat->comment(); - if (string != NULL && string[0] != 0) + if (string != nullptr && string[0] != 0) machine().popmessage("Cheat Comment:\n%s", string); break; } @@ -110,7 +110,7 @@ void ui_menu_cheat::populate() /* iterate over cheats */ std::string text; std::string subtext; - for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next()) + for (cheat_entry *curcheat = machine().cheat().first(); curcheat != nullptr; curcheat = curcheat->next()) { UINT32 flags; curcheat->menu_text(text, subtext, flags); @@ -118,13 +118,13 @@ void ui_menu_cheat::populate() } /* add a separator */ - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); /* add a reset all option */ - item_append("Reset All", NULL, 0, (void *)1); + item_append("Reset All", nullptr, 0, (void *)1); /* add a reload all cheats option */ - item_append("Reload All", NULL, 0, (void *)2); + item_append("Reload All", nullptr, 0, (void *)2); } ui_menu_cheat::~ui_menu_cheat() diff --git a/src/emu/ui/cheatopt.h b/src/emu/ui/cheatopt.h index 2117cbf57a1..0358af493ab 100644 --- a/src/emu/ui/cheatopt.h +++ b/src/emu/ui/cheatopt.h @@ -17,8 +17,8 @@ class ui_menu_cheat : public ui_menu { public: ui_menu_cheat(running_machine &machine, render_container *container); virtual ~ui_menu_cheat(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; #endif /* __UI_CHEATOPT_H__ */ diff --git a/src/emu/ui/devctrl.h b/src/emu/ui/devctrl.h index ae9fb977f7e..f7054e6279f 100644 --- a/src/emu/ui/devctrl.h +++ b/src/emu/ui/devctrl.h @@ -82,7 +82,7 @@ template void ui_menu_device_control<_DeviceType>::previous() { // left arrow - rotate left through cassette devices - if (m_device != NULL) + if (m_device != nullptr) { iterator iter(machine().root_device()); int index = iter.indexof(*m_device); @@ -103,7 +103,7 @@ template void ui_menu_device_control<_DeviceType>::next() { // right arrow - rotate right through cassette devices - if (m_device != NULL) + if (m_device != nullptr) { iterator iter(machine().root_device()); int index = iter.indexof(*m_device); diff --git a/src/emu/ui/devopt.cpp b/src/emu/ui/devopt.cpp index 432d71fa839..40ee5429e6a 100644 --- a/src/emu/ui/devopt.cpp +++ b/src/emu/ui/devopt.cpp @@ -27,7 +27,7 @@ ui_menu_device_config::ui_menu_device_config(running_machine &machine, render_co m_mounted = false; device_iterator deviter(machine.config().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { if (strcmp(device->tag(), tmp_tag.c_str()) == 0) { @@ -59,7 +59,7 @@ void ui_menu_device_config::populate() { str.append("* CPU:\n"); tagmap_t exectags; - for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next()) + for (device_execute_interface *exec = execiter.first(); exec != nullptr; exec = execiter.next()) { if (exectags.add(exec->device().tag(), 1, FALSE) == TMERR_DUPLICATE) continue; @@ -71,7 +71,7 @@ void ui_menu_device_config::populate() int count = 1; const char *name = exec->device().name(); execute_interface_iterator execinneriter(*dev); - for (device_execute_interface *scan = execinneriter.first(); scan != NULL; scan = execinneriter.next()) + for (device_execute_interface *scan = execinneriter.first(); scan != nullptr; scan = execinneriter.next()) { if (exec->device().type() == scan->device().type() && strcmp(name, scan->device().name()) == 0 && exec->device().clock() == scan->device().clock()) if (exectags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) @@ -98,7 +98,7 @@ void ui_menu_device_config::populate() if (scriter.count() > 0) { str.append("* Video:\n"); - for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next()) + for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) { strcatprintf(str," Screen '%s': ", screen->tag()); @@ -122,7 +122,7 @@ void ui_menu_device_config::populate() { str.append("* Sound:\n"); tagmap_t soundtags; - for (device_sound_interface *sound = snditer.first(); sound != NULL; sound = snditer.next()) + for (device_sound_interface *sound = snditer.first(); sound != nullptr; sound = snditer.next()) { if (soundtags.add(sound->device().tag(), 1, FALSE) == TMERR_DUPLICATE) continue; @@ -130,7 +130,7 @@ void ui_menu_device_config::populate() // count how many identical sound chips we have int count = 1; sound_interface_iterator sndinneriter(*dev); - for (device_sound_interface *scan = sndinneriter.first(); scan != NULL; scan = sndinneriter.next()) + for (device_sound_interface *scan = sndinneriter.first(); scan != nullptr; scan = sndinneriter.next()) { if (sound->device().type() == scan->device().type() && sound->device().clock() == scan->device().clock()) if (soundtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) @@ -184,12 +184,12 @@ void ui_menu_device_config::populate() std::string errors, dips_opt, confs_opt; ioport_list portlist; device_iterator iptiter(*dev); - for (device_t *iptdev = iptiter.first(); iptdev != NULL; iptdev = iptiter.next()) + for (device_t *iptdev = iptiter.first(); iptdev != nullptr; iptdev = iptiter.next()) portlist.append(*iptdev, errors); // check if the device adds inputs to the system - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) { if (field->type() >= IPT_MAHJONG_FIRST && field->type() < IPT_MAHJONG_LAST) input_mj++; @@ -211,7 +211,7 @@ void ui_menu_device_config::populate() { dips++; dips_opt.append(" ").append(field->name()); - for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = field->first_setting(); setting != nullptr; setting = setting->next()) { if (setting->value() == field->defvalue()) { @@ -224,7 +224,7 @@ void ui_menu_device_config::populate() { confs++; confs_opt.append(" ").append(field->name()); - for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = field->first_setting(); setting != nullptr; setting = setting->next()) { if (setting->value() == field->defvalue()) { @@ -262,7 +262,7 @@ void ui_menu_device_config::populate() if (imgiter.count() > 0) { str.append("* Media Options:\n"); - for (const device_image_interface *imagedev = imgiter.first(); imagedev != NULL; imagedev = imgiter.next()) + for (const device_image_interface *imagedev = imgiter.first(); imagedev != nullptr; imagedev = imgiter.next()) strcatprintf(str," %s [tag: %s]\n", imagedev->image_type_name(), imagedev->device().tag()); } @@ -270,7 +270,7 @@ void ui_menu_device_config::populate() if (slotiter.count() > 0) { str.append("* Slot Options:\n"); - for (const device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next()) + for (const device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next()) strcatprintf(str," %s [default: %s]\n", slot->device().tag(), slot->default_option() ? slot->default_option() : "----"); } @@ -279,7 +279,7 @@ void ui_menu_device_config::populate() str.append("[None]\n"); const_cast(machine().config()).device_remove(&machine().config().root_device(), m_option->name()); - item_append(str.c_str(), NULL, MENU_FLAG_MULTILINE, NULL); + item_append(str.c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); } void ui_menu_device_config::handle() diff --git a/src/emu/ui/devopt.h b/src/emu/ui/devopt.h index 6643a7f7962..56916aebb54 100644 --- a/src/emu/ui/devopt.h +++ b/src/emu/ui/devopt.h @@ -17,8 +17,8 @@ class ui_menu_device_config : public ui_menu { public: ui_menu_device_config(running_machine &machine, render_container *container, device_slot_interface *slot, device_slot_option *option); virtual ~ui_menu_device_config(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: device_slot_interface *m_owner; diff --git a/src/emu/ui/filemngr.cpp b/src/emu/ui/filemngr.cpp index 6bc789299d9..6af12895186 100644 --- a/src/emu/ui/filemngr.cpp +++ b/src/emu/ui/filemngr.cpp @@ -28,7 +28,7 @@ // ctor //------------------------------------------------- -ui_menu_file_manager::ui_menu_file_manager(running_machine &machine, render_container *container, const char *warnings) : ui_menu(machine, container), selected_device(NULL) +ui_menu_file_manager::ui_menu_file_manager(running_machine &machine, render_container *container, const char *warnings) : ui_menu(machine, container), selected_device(nullptr) { // This warning string is used when accessing from the force_file_manager call, i.e. // when the file manager is loaded top front in the case of mandatory image devices @@ -59,9 +59,9 @@ void ui_menu_file_manager::custom_render(void *selectedref, float top, float bot const char *path; // access the path - path = selected_device ? selected_device->filename() : NULL; + path = selected_device ? selected_device->filename() : nullptr; extra_text_render(container, top, bottom, - origx1, origy1, origx2, origy2, NULL, path); + origx1, origy1, origx2, origy2, nullptr, path); } @@ -71,20 +71,20 @@ void ui_menu_file_manager::fill_image_line(device_image_interface *img, std::str strprintf(instance,"%s (%s)", img->instance_name(), img->brief_instance_name()); // get the base name - if (img->basename() != NULL) + if (img->basename() != nullptr) { filename.assign(img->basename()); // if the image has been loaded through softlist, also show the loaded part - if (img->part_entry() != NULL) + if (img->part_entry() != nullptr) { const software_part *tmp = img->part_entry(); - if (tmp->name() != NULL) + if (tmp->name() != nullptr) { filename.append(" ("); filename.append(tmp->name()); // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it - if (img->get_feature("part_id") != NULL) + if (img->get_feature("part_id") != nullptr) { filename.append(": "); filename.append(img->get_feature("part_id")); @@ -108,14 +108,14 @@ void ui_menu_file_manager::populate() if (!m_warnings.empty()) { - item_append(m_warnings.c_str(), NULL, MENU_FLAG_DISABLE, NULL); - item_append("", NULL, MENU_FLAG_DISABLE, NULL); + item_append(m_warnings.c_str(), nullptr, MENU_FLAG_DISABLE, nullptr); + item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); } // cycle through all devices for this system device_iterator iter(machine().root_device()); tagmap_t devtags; - for (device_t *dev = iter.first(); dev != NULL; dev = iter.next()) + for (device_t *dev = iter.first(); dev != nullptr; dev = iter.next()) { bool tag_appended = false; if (devtags.add(dev->tag(), 1, FALSE) == TMERR_DUPLICATE) @@ -127,7 +127,7 @@ void ui_menu_file_manager::populate() { // if so, cycle through all its image interfaces image_interface_iterator subiterator(*dev); - for (device_image_interface *scan = subiterator.first(); scan != NULL; scan = subiterator.next()) + for (device_image_interface *scan = subiterator.first(); scan != nullptr; scan = subiterator.next()) { // if it is a children device, and not something further down the device tree, we want it in the menu! if (strcmp(scan->device().owner()->tag(), dev->tag()) == 0) @@ -139,9 +139,9 @@ void ui_menu_file_manager::populate() if (first_entry) first_entry = false; else - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); strprintf(buffer, "[root%s]", dev->tag()); - item_append(buffer.c_str(), NULL, 0, NULL); + item_append(buffer.c_str(), nullptr, 0, nullptr); tag_appended = true; } // finally, append the image interface to the menu @@ -151,8 +151,8 @@ void ui_menu_file_manager::populate() } } } - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Reset", NULL, 0, (void *)1); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append("Reset", nullptr, 0, (void *)1); custombottom = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -166,7 +166,7 @@ void ui_menu_file_manager::handle() { // process the menu const ui_menu_event *event = process(0); - if (event != NULL && event->itemref != NULL && event->iptkey == IPT_UI_SELECT) + if (event != nullptr && event->itemref != nullptr && event->iptkey == IPT_UI_SELECT) { if ((FPTR)event->itemref == 1) { @@ -176,7 +176,7 @@ void ui_menu_file_manager::handle() else { selected_device = (device_image_interface *) event->itemref; - if (selected_device != NULL) + if (selected_device != nullptr) { m_curr_selected = TRUE; ui_menu::stack_push(selected_device->get_selection_menu(machine(), container)); diff --git a/src/emu/ui/filemngr.h b/src/emu/ui/filemngr.h index 8cf34451078..38c4e068281 100644 --- a/src/emu/ui/filemngr.h +++ b/src/emu/ui/filemngr.h @@ -23,9 +23,9 @@ public: ui_menu_file_manager(running_machine &machine, render_container *container, const char *warnings); virtual ~ui_menu_file_manager(); - virtual void populate(); - virtual void handle(); - virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); + virtual void populate() override; + virtual void handle() override; + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; void fill_image_line(device_image_interface *img, std::string &instance, std::string &filename); diff --git a/src/emu/ui/filesel.cpp b/src/emu/ui/filesel.cpp index 02b0f89e295..140bfdd492d 100644 --- a/src/emu/ui/filesel.cpp +++ b/src/emu/ui/filesel.cpp @@ -56,7 +56,7 @@ static void input_character(char *buffer, size_t buffer_length, unicode_char uni { *(char *)utf8_previous_char(&buffer[buflen]) = 0; } - else if ((unichar > ' ') && ((filter == NULL) || (*filter)(unichar))) + else if ((unichar > ' ') && ((filter == nullptr) || (*filter)(unichar))) { buflen += utf8_from_uchar(&buffer[buflen], buffer_length - buflen, unichar); buffer[buflen] = 0; @@ -102,7 +102,7 @@ static void extra_text_draw_box(render_container *container, float origx1, float // draw the text within it container->manager().machine().ui().draw_text_full(container,text, x1, y1, text_width, JUSTIFY_LEFT, WRAP_WORD, - DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, NULL, NULL); + DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr); } @@ -115,12 +115,12 @@ void extra_text_render(render_container *container, float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer) { - header = ((header != NULL) && (header[0] != '\0')) ? header : NULL; - footer = ((footer != NULL) && (footer[0] != '\0')) ? footer : NULL; + header = ((header != nullptr) && (header[0] != '\0')) ? header : nullptr; + footer = ((footer != nullptr) && (footer[0] != '\0')) ? footer : nullptr; - if (header != NULL) + if (header != nullptr) extra_text_draw_box(container, origx1, origx2, origy1, top, header, -1); - if (footer != NULL) + if (footer != nullptr) extra_text_draw_box(container, origx1, origx2, origy2, bottom, footer, +1); } @@ -156,10 +156,10 @@ ui_menu_confirm_save_as::~ui_menu_confirm_save_as() void ui_menu_confirm_save_as::populate() { - item_append("File Already Exists - Override?", NULL, MENU_FLAG_DISABLE, NULL); - item_append(MENU_SEPARATOR_ITEM, NULL, MENU_FLAG_DISABLE, NULL); - item_append("No", NULL, 0, ITEMREF_NO); - item_append("Yes", NULL, 0, ITEMREF_YES); + item_append("File Already Exists - Override?", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(MENU_SEPARATOR_ITEM, nullptr, MENU_FLAG_DISABLE, nullptr); + item_append("No", nullptr, 0, ITEMREF_NO); + item_append("Yes", nullptr, 0, ITEMREF_YES); } //------------------------------------------------- @@ -172,7 +172,7 @@ void ui_menu_confirm_save_as::handle() const ui_menu_event *event = process(0); // process the event - if ((event != NULL) && (event->iptkey == IPT_UI_SELECT)) + if ((event != nullptr) && (event->iptkey == IPT_UI_SELECT)) { if (event->itemref == ITEMREF_YES) *m_yes = true; @@ -219,7 +219,7 @@ ui_menu_file_create::ui_menu_file_create(running_machine &machine, render_contai : ui_menu(machine, container), m_current_directory(current_directory), m_current_file(current_file), - m_current_format(NULL) + m_current_format(nullptr) { m_image = image; m_ok = ok; @@ -244,7 +244,7 @@ void ui_menu_file_create::custom_render(void *selectedref, float top, float bott { extra_text_render(container, top, bottom, origx1, origy1, origx2, origy2, m_current_directory.c_str(), - NULL); + nullptr); } @@ -272,15 +272,15 @@ void ui_menu_file_create::populate() // do we support multiple formats? if (ENABLE_FORMATS) format = m_image->formatlist(); - if (ENABLE_FORMATS && (format != NULL)) + if (ENABLE_FORMATS && (format != nullptr)) { item_append("Image Format:", m_current_format->description(), 0, ITEMREF_FORMAT); m_current_format = format; } // finish up the menu - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Create", NULL, 0, ITEMREF_CREATE); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append("Create", nullptr, 0, ITEMREF_CREATE); customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -296,7 +296,7 @@ void ui_menu_file_create::handle() const ui_menu_event *event = process(0); // process the event - if (event != NULL) + if (event != nullptr) { // handle selections switch(event->iptkey) @@ -345,7 +345,7 @@ ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_co : ui_menu(machine, container), m_current_directory(current_directory), m_current_file(current_file), - m_entrylist(NULL) + m_entrylist(nullptr) { m_image = image; m_has_empty = has_empty; @@ -373,7 +373,7 @@ void ui_menu_file_selector::custom_render(void *selectedref, float top, float bo extra_text_render(container, top, bottom, origx1, origy1, origx2, origy2, m_current_directory.c_str(), - NULL); + nullptr); } @@ -386,8 +386,8 @@ void ui_menu_file_selector::custom_render(void *selectedref, float top, float bo int ui_menu_file_selector::compare_entries(const file_selector_entry *e1, const file_selector_entry *e2) { int result; - const char *e1_basename = (e1->basename != NULL) ? e1->basename : ""; - const char *e2_basename = (e2->basename != NULL) ? e2->basename : ""; + const char *e1_basename = (e1->basename != nullptr) ? e1->basename : ""; + const char *e2_basename = (e2->basename != nullptr) ? e2->basename : ""; if (e1->type < e2->type) { @@ -432,12 +432,12 @@ ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_entry( entry = (file_selector_entry *) m_pool_alloc(sizeof(*entry)); memset(entry, 0, sizeof(*entry)); entry->type = entry_type; - entry->basename = (entry_basename != NULL) ? pool_strdup(entry_basename) : entry_basename; - entry->fullpath = (entry_fullpath != NULL) ? pool_strdup(entry_fullpath) : entry_fullpath; + entry->basename = (entry_basename != nullptr) ? pool_strdup(entry_basename) : entry_basename; + entry->fullpath = (entry_fullpath != nullptr) ? pool_strdup(entry_fullpath) : entry_fullpath; // find the end of the list entryptr = &m_entrylist; - while ((*entryptr != NULL) && (compare_entries(entry, *entryptr) >= 0)) + while ((*entryptr != nullptr) && (compare_entries(entry, *entryptr) >= 0)) entryptr = &(*entryptr)->next; // insert the entry @@ -470,7 +470,7 @@ ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent default: // exceptional case; do not add a menu item - return NULL; + return nullptr; } // determine the full path @@ -493,8 +493,8 @@ ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent void ui_menu_file_selector::append_entry_menu_item(const file_selector_entry *entry) { - const char *text = NULL; - const char *subtext = NULL; + const char *text = nullptr; + const char *subtext = nullptr; switch(entry->type) { @@ -535,11 +535,11 @@ void ui_menu_file_selector::append_entry_menu_item(const file_selector_entry *en void ui_menu_file_selector::populate() { - zippath_directory *directory = NULL; + zippath_directory *directory = nullptr; file_error err; const osd_directory_entry *dirent; const file_selector_entry *entry; - const file_selector_entry *selected_entry = NULL; + const file_selector_entry *selected_entry = nullptr; int i; const char *volume_name; const char *path = m_current_directory.c_str(); @@ -548,30 +548,30 @@ void ui_menu_file_selector::populate() err = zippath_opendir(path, &directory); // clear out the menu entries - m_entrylist = NULL; + m_entrylist = nullptr; if (m_has_empty) { // add the "[empty slot]" entry - append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL); + append_entry(SELECTOR_ENTRY_TYPE_EMPTY, nullptr, nullptr); } if (m_has_create) { // add the "[create]" entry - append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL); + append_entry(SELECTOR_ENTRY_TYPE_CREATE, nullptr, nullptr); } if (m_has_softlist) { // add the "[software list]" entry - entry = append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL); + entry = append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, nullptr, nullptr); selected_entry = entry; } // add the drives i = 0; - while((volume_name = osd_get_volume_name(i))!=NULL) + while((volume_name = osd_get_volume_name(i))!=nullptr) { append_entry(SELECTOR_ENTRY_TYPE_DRIVE, volume_name, volume_name); @@ -581,15 +581,15 @@ void ui_menu_file_selector::populate() // build the menu for each item if (err == FILERR_NONE) { - while((dirent = zippath_readdir(directory)) != NULL) + while((dirent = zippath_readdir(directory)) != nullptr) { // append a dirent entry entry = append_dirent_entry(dirent); - if (entry != NULL) + if (entry != nullptr) { // set the selected item to be the first non-parent directory or file - if ((selected_entry == NULL) && strcmp(dirent->name, "..")) + if ((selected_entry == nullptr) && strcmp(dirent->name, "..")) selected_entry = entry; // do we have to select this file? @@ -600,17 +600,17 @@ void ui_menu_file_selector::populate() } // append all of the menu entries - for (entry = m_entrylist; entry != NULL; entry = entry->next) + for (entry = m_entrylist; entry != nullptr; entry = entry->next) append_entry_menu_item(entry); // set the selection (if we have one) - if (selected_entry != NULL) + if (selected_entry != nullptr) set_selection((void *) selected_entry); // set up custom render proc customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; - if (directory != NULL) + if (directory != nullptr) zippath_closedir(directory); } @@ -623,12 +623,12 @@ void ui_menu_file_selector::handle() { file_error err; const file_selector_entry *entry; - const file_selector_entry *selected_entry = NULL; + const file_selector_entry *selected_entry = nullptr; int bestmatch = 0; // process the menu const ui_menu_event *event = process(0); - if (event != NULL && event->itemref != NULL) + if (event != nullptr && event->itemref != nullptr) { // handle selections if (event->iptkey == IPT_UI_SELECT) @@ -656,7 +656,7 @@ void ui_menu_file_selector::handle() case SELECTOR_ENTRY_TYPE_DRIVE: case SELECTOR_ENTRY_TYPE_DIRECTORY: // drive/directory - first check the path - err = zippath_opendir(entry->fullpath, NULL); + err = zippath_opendir(entry->fullpath, nullptr); if (err != FILERR_NONE) { // this path is problematic; present the user with an error and bail @@ -710,9 +710,9 @@ void ui_menu_file_selector::handle() // check for entries which matches our m_filename_buffer: // from current entry to the end - for (entry = cur_selected; entry != NULL; entry = entry->next) + for (entry = cur_selected; entry != nullptr; entry = entry->next) { - if (entry->basename != NULL && m_filename_buffer != NULL) + if (entry->basename != nullptr && m_filename_buffer != nullptr) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(m_filename_buffer); i++) @@ -731,7 +731,7 @@ void ui_menu_file_selector::handle() // and from the first entry to current one for (entry = m_entrylist; entry != cur_selected; entry = entry->next) { - if (entry->basename != NULL && m_filename_buffer != NULL) + if (entry->basename != nullptr && m_filename_buffer != nullptr) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(m_filename_buffer); i++) @@ -748,7 +748,7 @@ void ui_menu_file_selector::handle() } } - if (selected_entry != NULL && selected_entry != cur_selected) + if (selected_entry != nullptr && selected_entry != cur_selected) set_selection((void *) selected_entry); } } @@ -796,13 +796,13 @@ ui_menu_select_format::~ui_menu_select_format() void ui_menu_select_format::populate() { - item_append("Select image format", NULL, MENU_FLAG_DISABLE, NULL); + item_append("Select image format", nullptr, MENU_FLAG_DISABLE, nullptr); for (int i = 0; i < m_total_usable; i++) { const floppy_image_format_t *fmt = m_formats[i]; if (i && i == m_ext_match) - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); item_append(fmt->description(), fmt->name(), 0, (void *)(FPTR)i); } } @@ -816,7 +816,7 @@ void ui_menu_select_format::handle() { // process the menu const ui_menu_event *event = process(0); - if (event != NULL && event->iptkey == IPT_UI_SELECT) + if (event != nullptr && event->iptkey == IPT_UI_SELECT) { *m_result = int(FPTR(event->itemref)); ui_menu::stack_pop(machine()); @@ -856,12 +856,12 @@ ui_menu_select_rw::~ui_menu_select_rw() void ui_menu_select_rw::populate() { - item_append("Select access mode", NULL, MENU_FLAG_DISABLE, NULL); - item_append("Read-only", 0, 0, (void *)READONLY); + item_append("Select access mode", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append("Read-only", nullptr, 0, (void *)READONLY); if (m_can_in_place) - item_append("Read-write", 0, 0, (void *)READWRITE); - item_append("Read this image, write to another image", 0, 0, (void *)WRITE_OTHER); - item_append("Read this image, write to diff", 0, 0, (void *)WRITE_DIFF); + item_append("Read-write", nullptr, 0, (void *)READWRITE); + item_append("Read this image, write to another image", nullptr, 0, (void *)WRITE_OTHER); + item_append("Read this image, write to diff", nullptr, 0, (void *)WRITE_DIFF); } @@ -873,7 +873,7 @@ void ui_menu_select_rw::handle() { // process the menu const ui_menu_event *event = process(0); - if (event != NULL && event->iptkey == IPT_UI_SELECT) + if (event != nullptr && event->iptkey == IPT_UI_SELECT) { *m_result = int(FPTR(event->itemref)); ui_menu::stack_pop(machine()); diff --git a/src/emu/ui/filesel.h b/src/emu/ui/filesel.h index 0ba52134fc8..c7e113e463b 100644 --- a/src/emu/ui/filesel.h +++ b/src/emu/ui/filesel.h @@ -20,8 +20,8 @@ class ui_menu_confirm_save_as : public ui_menu public: ui_menu_confirm_save_as(running_machine &machine, render_container *container, bool *yes); virtual ~ui_menu_confirm_save_as(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: bool *m_yes; @@ -35,9 +35,9 @@ class ui_menu_file_create : public ui_menu public: ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool *ok); virtual ~ui_menu_file_create(); - virtual void populate(); - virtual void handle(); - virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); + virtual void populate() override; + virtual void handle() override; + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: device_image_interface * m_image; @@ -59,9 +59,9 @@ public: enum { R_EMPTY, R_SOFTLIST, R_CREATE, R_FILE }; ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result); virtual ~ui_menu_file_selector(); - virtual void populate(); - virtual void handle(); - virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); + virtual void populate() override; + virtual void handle() override; + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: enum file_selector_entry_type @@ -110,8 +110,8 @@ public: ui_menu_select_format(running_machine &machine, render_container *container, class floppy_image_format_t **formats, int ext_match, int total_usable, int *result); virtual ~ui_menu_select_format(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: // internal state @@ -131,8 +131,8 @@ public: ui_menu_select_rw(running_machine &machine, render_container *container, bool can_in_place, int *result); virtual ~ui_menu_select_rw(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: // internal state diff --git a/src/emu/ui/imgcntrl.cpp b/src/emu/ui/imgcntrl.cpp index d1d4c43e60f..11ed8c26c5c 100644 --- a/src/emu/ui/imgcntrl.cpp +++ b/src/emu/ui/imgcntrl.cpp @@ -35,10 +35,10 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach { image = _image; - sld = 0; + sld = nullptr; if (image->software_list_name()) { software_list_device_iterator iter(machine.config().root_device()); - for (software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next()) + for (software_list_device *swlist = iter.first(); swlist != nullptr; swlist = iter.next()) { if (strcmp(swlist->list_name(),image->software_list_name())==0) sld = swlist; } @@ -64,7 +64,7 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach current_directory.assign(image->working_directory()); /* check to see if the path exists; if not clear it */ - if (zippath_opendir(current_directory.c_str(), NULL) != FILERR_NONE) + if (zippath_opendir(current_directory.c_str(), nullptr) != FILERR_NONE) current_directory.clear(); } } @@ -94,7 +94,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf /* does a file or a directory exist at the path */ entry = osd_stat(path.c_str()); - file_type = (entry != NULL) ? entry->type : ENTTYPE_NONE; + file_type = (entry != nullptr) ? entry->type : ENTTYPE_NONE; switch(file_type) { @@ -124,7 +124,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf break; } - if (entry != NULL) + if (entry != nullptr) osd_free(entry); } @@ -183,20 +183,20 @@ void ui_menu_control_device_image::handle() case START_FILE: { bool can_create = false; if(image->is_creatable()) { - zippath_directory *directory = NULL; + zippath_directory *directory = nullptr; file_error err = zippath_opendir(current_directory.c_str(), &directory); can_create = err == FILERR_NONE && !zippath_is_zip(directory); if(directory) zippath_closedir(directory); } submenu_result = -1; - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=NULL, can_create, &submenu_result))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=nullptr, can_create, &submenu_result))); state = SELECT_FILE; break; } case START_SOFTLIST: - sld = 0; + sld = nullptr; ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, image->image_interface(), &sld))); state = SELECT_SOFTLIST; break; @@ -225,7 +225,7 @@ void ui_menu_control_device_image::handle() else if(swi->has_multiple_parts(image->image_interface())) { submenu_result = -1; - swp = 0; + swp = nullptr; ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result))); state = SELECT_ONE_PART; } @@ -336,7 +336,7 @@ void ui_menu_control_device_image::handle() case DO_CREATE: { std::string path; zippath_combine(path, current_directory.c_str(), current_file.c_str()); - int err = image->create(path.c_str(), 0, NULL); + int err = image->create(path.c_str(), nullptr, nullptr); if (err != 0) machine().popmessage("Error: %s", image->error()); ui_menu::stack_pop(machine()); diff --git a/src/emu/ui/imgcntrl.h b/src/emu/ui/imgcntrl.h index 4682d7f703f..3d978ed617c 100644 --- a/src/emu/ui/imgcntrl.h +++ b/src/emu/ui/imgcntrl.h @@ -21,8 +21,8 @@ class ui_menu_control_device_image : public ui_menu { public: ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *image); virtual ~ui_menu_control_device_image(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; protected: enum { diff --git a/src/emu/ui/info.cpp b/src/emu/ui/info.cpp index cb84a99418a..0b198769b15 100644 --- a/src/emu/ui/info.cpp +++ b/src/emu/ui/info.cpp @@ -30,7 +30,7 @@ ui_menu_game_info::~ui_menu_game_info() void ui_menu_game_info::populate() { std::string tempstring; - item_append(machine().ui().game_info_astring(tempstring).c_str(), NULL, MENU_FLAG_MULTILINE, NULL); + item_append(machine().ui().game_info_astring(tempstring).c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); } void ui_menu_game_info::handle() @@ -55,11 +55,11 @@ ui_menu_image_info::~ui_menu_image_info() void ui_menu_image_info::populate() { - item_append(machine().system().description, NULL, MENU_FLAG_DISABLE, NULL); - item_append("", NULL, MENU_FLAG_DISABLE, NULL); + item_append(machine().system().description, nullptr, MENU_FLAG_DISABLE, nullptr); + item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); image_interface_iterator iter(machine().root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) image_info(image); } @@ -80,7 +80,7 @@ void ui_menu_image_info::image_info(device_image_interface *image) if (image->exists()) { // display device type and filename - item_append(image->brief_instance_name(), image->basename(), 0, NULL); + item_append(image->brief_instance_name(), image->basename(), 0, nullptr); // if image has been loaded through softlist, let's add some more info if (image->software_entry()) @@ -88,20 +88,20 @@ void ui_menu_image_info::image_info(device_image_interface *image) std::string str; // display long filename - item_append(image->longname(), "", MENU_FLAG_DISABLE, NULL); + item_append(image->longname(), "", MENU_FLAG_DISABLE, nullptr); // display manufacturer and year strcatprintf(str, "%s, %s", image->manufacturer(), image->year()); - item_append(str.c_str(), "", MENU_FLAG_DISABLE, NULL); + item_append(str.c_str(), "", MENU_FLAG_DISABLE, nullptr); // display supported information, if available switch (image->supported()) { case SOFTWARE_SUPPORTED_NO: - item_append("Not supported", "", MENU_FLAG_DISABLE, NULL); + item_append("Not supported", "", MENU_FLAG_DISABLE, nullptr); break; case SOFTWARE_SUPPORTED_PARTIAL: - item_append("Partially supported", "", MENU_FLAG_DISABLE, NULL); + item_append("Partially supported", "", MENU_FLAG_DISABLE, nullptr); break; default: break; @@ -109,6 +109,6 @@ void ui_menu_image_info::image_info(device_image_interface *image) } } else - item_append(image->brief_instance_name(), "[empty]", 0, NULL); - item_append("", NULL, MENU_FLAG_DISABLE, NULL); + item_append(image->brief_instance_name(), "[empty]", 0, nullptr); + item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); } diff --git a/src/emu/ui/info.h b/src/emu/ui/info.h index 476657b8791..a9459b25340 100644 --- a/src/emu/ui/info.h +++ b/src/emu/ui/info.h @@ -17,8 +17,8 @@ class ui_menu_game_info : public ui_menu { public: ui_menu_game_info(running_machine &machine, render_container *container); virtual ~ui_menu_game_info(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; @@ -27,8 +27,8 @@ class ui_menu_image_info : public ui_menu public: ui_menu_image_info(running_machine &machine, render_container *container); virtual ~ui_menu_image_info(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: void image_info(device_image_interface *image); diff --git a/src/emu/ui/info_pty.cpp b/src/emu/ui/info_pty.cpp index 5a6dca59efb..e0e44fa7833 100644 --- a/src/emu/ui/info_pty.cpp +++ b/src/emu/ui/info_pty.cpp @@ -23,18 +23,18 @@ ui_menu_pty_info::~ui_menu_pty_info() void ui_menu_pty_info::populate() { - item_append("Pseudo terminals", NULL, MENU_FLAG_DISABLE, NULL); - item_append("", NULL, MENU_FLAG_DISABLE, NULL); + item_append("Pseudo terminals", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); pty_interface_iterator iter(machine().root_device()); - for (device_pty_interface *pty = iter.first(); pty != NULL; pty = iter.next()) { + for (device_pty_interface *pty = iter.first(); pty != nullptr; pty = iter.next()) { const char *port_name = pty->device().owner()->tag() + 1; if (pty->is_open()) { - item_append(port_name , pty->slave_name() , MENU_FLAG_DISABLE , NULL); + item_append(port_name , pty->slave_name() , MENU_FLAG_DISABLE , nullptr); } else { - item_append(port_name , "[failed]" , MENU_FLAG_DISABLE , NULL); + item_append(port_name , "[failed]" , MENU_FLAG_DISABLE , nullptr); } - item_append("", NULL, MENU_FLAG_DISABLE, NULL); + item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); } } diff --git a/src/emu/ui/info_pty.h b/src/emu/ui/info_pty.h index 4352c1d48c8..584652211a6 100644 --- a/src/emu/ui/info_pty.h +++ b/src/emu/ui/info_pty.h @@ -17,8 +17,8 @@ class ui_menu_pty_info : public ui_menu { public: ui_menu_pty_info(running_machine &machine, render_container *container); virtual ~ui_menu_pty_info(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; #endif // __UI_INFO_PTY_H__ diff --git a/src/emu/ui/inputmap.cpp b/src/emu/ui/inputmap.cpp index ab1318e30c3..3474cacee75 100644 --- a/src/emu/ui/inputmap.cpp +++ b/src/emu/ui/inputmap.cpp @@ -49,14 +49,14 @@ void ui_menu_input_groups::populate() int player; /* build up the menu */ - item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1)); + item_append("User Interface", nullptr, 0, (void *)(IPG_UI + 1)); for (player = 0; player < MAX_PLAYERS; player++) { char buffer[40]; sprintf(buffer, "Player %d Controls", player + 1); - item_append(buffer, NULL, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1)); + item_append(buffer, nullptr, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1)); } - item_append("Other Controls", NULL, 0, (void *)(FPTR)(IPG_OTHER + 1)); + item_append("Other Controls", nullptr, 0, (void *)(FPTR)(IPG_OTHER + 1)); } ui_menu_input_groups::~ui_menu_input_groups() @@ -72,7 +72,7 @@ void ui_menu_input_groups::handle() { /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) + if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)(menu_event->itemref)-1)))); } @@ -90,7 +90,7 @@ ui_menu_input_general::ui_menu_input_general(running_machine &machine, render_co void ui_menu_input_general::populate() { - input_item_data *itemlist = NULL; + input_item_data *itemlist = nullptr; int suborder[SEQ_TYPE_TOTAL]; int sortorder = 1; @@ -100,10 +100,10 @@ void ui_menu_input_general::populate() suborder[SEQ_TYPE_INCREMENT] = 2; /* iterate over the input ports and add menu items */ - for (input_type_entry *entry = machine().ioport().first_type(); entry != NULL; entry = entry->next()) + for (input_type_entry *entry = machine().ioport().first_type(); entry != nullptr; entry = entry->next()) /* add if we match the group and we have a valid name */ - if (entry->group() == group && entry->name() != NULL && entry->name()[0] != 0) + if (entry->group() == group && entry->name() != nullptr && entry->name()[0] != 0) { input_seq_type seqtype; @@ -123,7 +123,7 @@ void ui_menu_input_general::populate() item->sortorder = sortorder * 4 + suborder[seqtype]; item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; item->name = entry->name(); - item->owner_name = NULL; + item->owner_name = nullptr; item->next = itemlist; itemlist = item; @@ -152,7 +152,7 @@ ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_ void ui_menu_input_specific::populate() { - input_item_data *itemlist = NULL; + input_item_data *itemlist = nullptr; int suborder[SEQ_TYPE_TOTAL]; int port_count = 0; @@ -162,16 +162,16 @@ void ui_menu_input_specific::populate() suborder[SEQ_TYPE_INCREMENT] = 2; /* iterate over the input ports and add menu items */ - for (ioport_port *port = machine().ioport().first_port(); port != NULL; port = port->next()) + for (ioport_port *port = machine().ioport().first_port(); port != nullptr; port = port->next()) { port_count++; - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) { const char *name = field->name(); /* add if we match the group and we have a valid name */ - if (name != NULL && field->enabled() && - ((field->type() == IPT_OTHER && field->name() != NULL) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID)) + if (name != nullptr && field->enabled() && + ((field->type() == IPT_OTHER && field->name() != nullptr) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID)) { input_seq_type seqtype; UINT32 sortorder; @@ -226,8 +226,8 @@ ui_menu_input_specific::~ui_menu_input_specific() -------------------------------------------------*/ ui_menu_input::ui_menu_input(running_machine &machine, render_container *container) : ui_menu(machine, container), last_sortorder(0), record_next(false) { - pollingitem = 0; - pollingref = 0; + pollingitem = nullptr; + pollingref = nullptr; pollingseq = SEQ_TYPE_STANDARD; } @@ -253,22 +253,22 @@ void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &orig void ui_menu_input::handle() { - input_item_data *seqchangeditem = NULL; + input_item_data *seqchangeditem = nullptr; const ui_menu_event *menu_event; int invalidate = false; /* process the menu */ - menu_event = process((pollingitem != NULL) ? UI_MENU_PROCESS_NOKEYS : 0); + menu_event = process((pollingitem != nullptr) ? UI_MENU_PROCESS_NOKEYS : 0); /* if we are polling, handle as a special case */ - if (pollingitem != NULL) + if (pollingitem != nullptr) { input_item_data *item = pollingitem; /* if UI_CANCEL is pressed, abort */ if (ui_input_pressed(machine(), IPT_UI_CANCEL)) { - pollingitem = NULL; + pollingitem = nullptr; record_next = false; toggle_none_default(item->seq, starting_seq, *item->defseq); seqchangeditem = item; @@ -277,7 +277,7 @@ void ui_menu_input::handle() /* poll again; if finished, update the sequence */ if (machine().input().seq_poll()) { - pollingitem = NULL; + pollingitem = nullptr; record_next = true; item->seq = machine().input().seq_poll_final(); seqchangeditem = item; @@ -285,7 +285,7 @@ void ui_menu_input::handle() } /* otherwise, handle the events */ - else if (menu_event != NULL && menu_event->itemref != NULL) + else if (menu_event != nullptr && menu_event->itemref != nullptr) { input_item_data *item = (input_item_data *)menu_event->itemref; switch (menu_event->iptkey) @@ -295,7 +295,7 @@ void ui_menu_input::handle() pollingitem = item; last_sortorder = item->sortorder; starting_seq = item->seq; - machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : NULL); + machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : nullptr); invalidate = true; break; @@ -314,7 +314,7 @@ void ui_menu_input::handle() } /* if the sequence changed, update it */ - if (seqchangeditem != NULL) + if (seqchangeditem != nullptr) { update_input(seqchangeditem); @@ -325,8 +325,8 @@ void ui_menu_input::handle() /* if the menu is invalidated, clear it now */ if (invalidate) { - pollingref = NULL; - if (pollingitem != NULL) + pollingref = nullptr; + if (pollingitem != nullptr) { pollingref = pollingitem->ref; pollingseq = pollingitem->seqtype; @@ -376,7 +376,7 @@ int ui_menu_input::compare_items(const void *i1, const void *i2) void ui_menu_input::populate_and_sort(input_item_data *itemlist) { - const char *nameformat[INPUT_TYPE_TOTAL] = { 0 }; + const char *nameformat[INPUT_TYPE_TOTAL] = { nullptr }; input_item_data **itemarray, *item; int numitems = 0, curitem; std::string text; @@ -391,12 +391,12 @@ void ui_menu_input::populate_and_sort(input_item_data *itemlist) nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec"; /* first count the number of items */ - for (item = itemlist; item != NULL; item = item->next) + for (item = itemlist; item != nullptr; item = item->next) numitems++; /* now allocate an array of items and fill it up */ itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems); - for (item = itemlist, curitem = 0; item != NULL; item = item->next) + for (item = itemlist, curitem = 0; item != nullptr; item = item->next) itemarray[curitem++] = item; /* sort it */ @@ -409,16 +409,16 @@ void ui_menu_input::populate_and_sort(input_item_data *itemlist) /* generate the name of the item itself, based off the base name and the type */ item = itemarray[curitem]; - assert(nameformat[item->type] != NULL); + assert(nameformat[item->type] != nullptr); if (item->owner_name && strcmp(item->owner_name, prev_owner.c_str()) != 0) { if (first_entry) first_entry = false; else - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); strprintf(text, "[root%s]", item->owner_name); - item_append(text.c_str(), NULL, 0, NULL); + item_append(text.c_str(), nullptr, 0, nullptr); prev_owner.assign(item->owner_name); } @@ -481,7 +481,7 @@ void ui_menu_settings::handle() const ui_menu_event *menu_event = process(0); // handle events - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { // reset if ((FPTR)menu_event->itemref == 1) @@ -532,7 +532,7 @@ void ui_menu_settings::handle() switches menus -------------------------------------------------*/ -ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container), diplist(NULL), dipcount(0) +ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container), diplist(nullptr), dipcount(0) { type = _type; } @@ -547,12 +547,12 @@ void ui_menu_settings::populate() /* reset the dip switch tracking */ dipcount = 0; - diplist = NULL; + diplist = nullptr; diplist_tailptr = &diplist; /* loop over input ports and set up the current values */ - for (port = machine().ioport().first_port(); port != NULL; port = port->next()) - for (field = port->first_field(); field != NULL; field = field->next()) + for (port = machine().ioport().first_port(); port != nullptr; port = port->next()) + for (field = port->first_field(); field != nullptr; field = field->next()) if (field->type() == type && field->enabled()) { UINT32 flags = 0; @@ -570,9 +570,9 @@ void ui_menu_settings::populate() if (first_entry) first_entry = false; else - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); strprintf(name, "[root%s]", field->device().tag()); - item_append(name.c_str(), NULL, 0, NULL); + item_append(name.c_str(), nullptr, 0, nullptr); prev_owner.assign(field->device().tag()); } @@ -581,7 +581,7 @@ void ui_menu_settings::populate() item_append(name.c_str(), field->setting_name(), flags, (void *)field); /* for DIP switches, build up the model */ - if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL) + if (type == IPT_DIPSWITCH && field->first_diplocation() != nullptr) { const ioport_diplocation *diploc; ioport_field::user_settings settings; @@ -591,21 +591,21 @@ void ui_menu_settings::populate() field->get_user_settings(settings); /* iterate over each bit in the field */ - for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next()) + for (diploc = field->first_diplocation(); diploc != nullptr; diploc = diploc->next()) { UINT32 mask = accummask & ~(accummask - 1); dip_descriptor *dip; /* find the matching switch name */ - for (dip = diplist; dip != NULL; dip = dip->next) + for (dip = diplist; dip != nullptr; dip = dip->next) if (strcmp(dip->name, diploc->name()) == 0) break; /* allocate new if none */ - if (dip == NULL) + if (dip == nullptr) { dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip)); - dip->next = NULL; + dip->next = nullptr; dip->name = diploc->name(); dip->mask = dip->state = 0; *diplist_tailptr = dip; @@ -626,8 +626,8 @@ void ui_menu_settings::populate() if (type == IPT_DIPSWITCH) custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0; - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Reset", NULL, 0, (void *)1); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append("Reset", nullptr, 0, (void *)1); } ui_menu_settings::~ui_menu_settings() @@ -654,7 +654,7 @@ void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, y1 += (float)DIP_SWITCH_SPACING; // iterate over DIP switches - for (dip_descriptor *dip = diplist; dip != NULL; dip = dip->next) + for (dip_descriptor *dip = diplist; dip != nullptr; dip = dip->next) { const ioport_diplocation *diploc; UINT32 selectedmask = 0; @@ -664,8 +664,8 @@ void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, { ioport_field *field = (ioport_field *)selectedref; - if (field != NULL && field->first_diplocation() != NULL) - for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next()) + if (field != nullptr && field->first_diplocation() != nullptr) + for (diploc = field->first_diplocation(); diploc != nullptr; diploc = diploc->next()) if (strcmp(dip->name, diploc->name()) == 0) selectedmask |= 1 << (diploc->number() - 1); } @@ -707,8 +707,8 @@ void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float DRAW_NORMAL, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA), - NULL , - NULL); + nullptr , + nullptr); /* compute top and bottom for on and off positions */ switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2; @@ -757,7 +757,7 @@ void ui_menu_analog::handle() const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); /* handle events */ - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { analog_item_data *data = (analog_item_data *)menu_event->itemref; int newval = data->cur; @@ -828,8 +828,8 @@ void ui_menu_analog::populate() bool first_entry = true; /* loop over input ports and add the items */ - for (port = machine().ioport().first_port(); port != NULL; port = port->next()) - for (field = port->first_field(); field != NULL; field = field->next()) + for (port = machine().ioport().first_port(); port != nullptr; port = port->next()) + for (field = port->first_field(); field != nullptr; field = field->next()) if (field->is_analog() && field->enabled()) { ioport_field::user_settings settings; @@ -874,9 +874,9 @@ void ui_menu_analog::populate() if (first_entry) first_entry = false; else - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); strprintf(name,"[root%s]", field->device().tag()); - item_append(name.c_str(), NULL, 0, NULL); + item_append(name.c_str(), nullptr, 0, nullptr); prev_owner.assign(field->device().tag()); } diff --git a/src/emu/ui/inputmap.h b/src/emu/ui/inputmap.h index 04bd52be538..32ad48092ea 100644 --- a/src/emu/ui/inputmap.h +++ b/src/emu/ui/inputmap.h @@ -19,15 +19,15 @@ class ui_menu_input_groups : public ui_menu { public: ui_menu_input_groups(running_machine &machine, render_container *container); virtual ~ui_menu_input_groups(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; class ui_menu_input : public ui_menu { public: ui_menu_input(running_machine &machine, render_container *container); virtual ~ui_menu_input(); - virtual void handle(); + virtual void handle() override; protected: enum { @@ -72,29 +72,29 @@ class ui_menu_input_general : public ui_menu_input { public: ui_menu_input_general(running_machine &machine, render_container *container, int group); virtual ~ui_menu_input_general(); - virtual void populate(); + virtual void populate() override; protected: int group; - virtual void update_input(struct input_item_data *seqchangeditem); + virtual void update_input(struct input_item_data *seqchangeditem) override; }; class ui_menu_input_specific : public ui_menu_input { public: ui_menu_input_specific(running_machine &machine, render_container *container); virtual ~ui_menu_input_specific(); - virtual void populate(); + virtual void populate() override; protected: - virtual void update_input(struct input_item_data *seqchangeditem); + virtual void update_input(struct input_item_data *seqchangeditem) override; }; class ui_menu_settings : public ui_menu { public: ui_menu_settings(running_machine &machine, render_container *container, UINT32 type); virtual ~ui_menu_settings(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; protected: /* DIP switch descriptor */ @@ -115,7 +115,7 @@ public: ui_menu_settings_dip_switches(running_machine &machine, render_container *container); virtual ~ui_menu_settings_dip_switches(); - virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: void custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask); }; @@ -130,8 +130,8 @@ class ui_menu_analog : public ui_menu { public: ui_menu_analog(running_machine &machine, render_container *container); virtual ~ui_menu_analog(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: enum { diff --git a/src/emu/ui/mainmenu.cpp b/src/emu/ui/mainmenu.cpp index b49aa51d4e3..9b0e72aacad 100644 --- a/src/emu/ui/mainmenu.cpp +++ b/src/emu/ui/mainmenu.cpp @@ -48,93 +48,93 @@ void ui_menu_main::populate() std::string menu_text; /* add input menu items */ - item_append("Input (general)", NULL, 0, (void *)INPUT_GROUPS); + item_append("Input (general)", nullptr, 0, (void *)INPUT_GROUPS); strprintf(menu_text, "Input (this %s)", emulator_info::get_capstartgamenoun()); - item_append(menu_text.c_str(), NULL, 0, (void *)INPUT_SPECIFIC); + item_append(menu_text.c_str(), nullptr, 0, (void *)INPUT_SPECIFIC); /* add optional input-related menus */ if (machine().ioport().has_analog()) - item_append("Analog Controls", NULL, 0, (void *)ANALOG); + item_append("Analog Controls", nullptr, 0, (void *)ANALOG); if (machine().ioport().has_dips()) - item_append("Dip Switches", NULL, 0, (void *)SETTINGS_DIP_SWITCHES); + item_append("Dip Switches", nullptr, 0, (void *)SETTINGS_DIP_SWITCHES); if (machine().ioport().has_configs()) { strprintf(menu_text, "%s Configuration", emulator_info::get_capstartgamenoun()); - item_append(menu_text.c_str(), NULL, 0, (void *)SETTINGS_DRIVER_CONFIG); + item_append(menu_text.c_str(), nullptr, 0, (void *)SETTINGS_DRIVER_CONFIG); } /* add bookkeeping menu */ - item_append("Bookkeeping Info", NULL, 0, (void *)BOOKKEEPING); + item_append("Bookkeeping Info", nullptr, 0, (void *)BOOKKEEPING); /* add game info menu */ strprintf(menu_text, "%s Information", emulator_info::get_capstartgamenoun()); - item_append(menu_text.c_str(), NULL, 0, (void *)GAME_INFO); + item_append(menu_text.c_str(), nullptr, 0, (void *)GAME_INFO); image_interface_iterator imgiter(machine().root_device()); - if (imgiter.first() != NULL) + if (imgiter.first() != nullptr) { /* add image info menu */ - item_append("Image Information", NULL, 0, (void *)IMAGE_MENU_IMAGE_INFO); + item_append("Image Information", nullptr, 0, (void *)IMAGE_MENU_IMAGE_INFO); /* add file manager menu */ - item_append("File Manager", NULL, 0, (void *)IMAGE_MENU_FILE_MANAGER); + item_append("File Manager", nullptr, 0, (void *)IMAGE_MENU_FILE_MANAGER); /* add tape control menu */ cassette_device_iterator cassiter(machine().root_device()); - if (cassiter.first() != NULL) - item_append("Tape Control", NULL, 0, (void *)TAPE_CONTROL); + if (cassiter.first() != nullptr) + item_append("Tape Control", nullptr, 0, (void *)TAPE_CONTROL); } pty_interface_iterator ptyiter(machine().root_device()); - if (ptyiter.first() != NULL) { - item_append("Pseudo terminals", NULL, 0, (void *)PTY_INFO); + if (ptyiter.first() != nullptr) { + item_append("Pseudo terminals", nullptr, 0, (void *)PTY_INFO); } if (machine().ioport().has_bioses()) - item_append("Bios Selection", NULL, 0, (void *)BIOS_SELECTION); + item_append("Bios Selection", nullptr, 0, (void *)BIOS_SELECTION); slot_interface_iterator slotiter(machine().root_device()); - if (slotiter.first() != NULL) + if (slotiter.first() != nullptr) { /* add slot info menu */ - item_append("Slot Devices", NULL, 0, (void *)SLOT_DEVICES); + item_append("Slot Devices", nullptr, 0, (void *)SLOT_DEVICES); } barcode_reader_device_iterator bcriter(machine().root_device()); - if (bcriter.first() != NULL) + if (bcriter.first() != nullptr) { /* add slot info menu */ - item_append("Barcode Reader", NULL, 0, (void *)BARCODE_READ); + item_append("Barcode Reader", nullptr, 0, (void *)BARCODE_READ); } network_interface_iterator netiter(machine().root_device()); - if (netiter.first() != NULL) + if (netiter.first() != nullptr) { /* add image info menu */ - item_append("Network Devices", NULL, 0, (void*)NETWORK_DEVICES); + item_append("Network Devices", nullptr, 0, (void*)NETWORK_DEVICES); } /* add keyboard mode menu */ if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post()) - item_append("Keyboard Mode", NULL, 0, (void *)KEYBOARD_MODE); + item_append("Keyboard Mode", nullptr, 0, (void *)KEYBOARD_MODE); /* add sliders menu */ - item_append("Slider Controls", NULL, 0, (void *)SLIDERS); + item_append("Slider Controls", nullptr, 0, (void *)SLIDERS); /* add video options menu */ - item_append("Video Options", NULL, 0, (machine().render().target_by_index(1) != NULL) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS); + item_append("Video Options", nullptr, 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS); /* add crosshair options menu */ if (crosshair_get_usage(machine())) - item_append("Crosshair Options", NULL, 0, (void *)CROSSHAIR); + item_append("Crosshair Options", nullptr, 0, (void *)CROSSHAIR); /* add cheat menu */ - if (machine().options().cheat() && machine().cheat().first() != NULL) - item_append("Cheat", NULL, 0, (void *)CHEAT); + if (machine().options().cheat() && machine().cheat().first() != nullptr) + item_append("Cheat", nullptr, 0, (void *)CHEAT); /* add reset and exit menus */ strprintf(menu_text, "Select New %s", emulator_info::get_capstartgamenoun()); - item_append(menu_text.c_str(), NULL, 0, (void *)SELECT_GAME); + item_append(menu_text.c_str(), nullptr, 0, (void *)SELECT_GAME); } ui_menu_main::~ui_menu_main() @@ -149,7 +149,7 @@ void ui_menu_main::handle() { /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) { + if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) { switch((long long)(menu_event->itemref)) { case INPUT_GROUPS: ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_groups(machine(), container))); @@ -184,11 +184,11 @@ void ui_menu_main::handle() break; case IMAGE_MENU_FILE_MANAGER: - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_manager(machine(), container, NULL))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_manager(machine(), container, nullptr))); break; case TAPE_CONTROL: - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_tape_control(machine(), container, NULL))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_tape_control(machine(), container, nullptr))); break; case PTY_INFO: @@ -228,7 +228,7 @@ void ui_menu_main::handle() break; case SELECT_GAME: - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, 0))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, nullptr))); break; case BIOS_SELECTION: @@ -236,7 +236,7 @@ void ui_menu_main::handle() break; case BARCODE_READ: - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_barcode_reader(machine(), container, NULL))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_barcode_reader(machine(), container, nullptr))); break; default: diff --git a/src/emu/ui/mainmenu.h b/src/emu/ui/mainmenu.h index aa1f3a99885..27a810341c3 100644 --- a/src/emu/ui/mainmenu.h +++ b/src/emu/ui/mainmenu.h @@ -19,8 +19,8 @@ class ui_menu_main : public ui_menu { public: ui_menu_main(running_machine &machine, render_container *container); virtual ~ui_menu_main(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: enum { diff --git a/src/emu/ui/menu.cpp b/src/emu/ui/menu.cpp index 63b47a37b5f..6456d425ddd 100644 --- a/src/emu/ui/menu.cpp +++ b/src/emu/ui/menu.cpp @@ -166,14 +166,14 @@ void ui_menu::reset(ui_menu_reset_options options) { // based on the reset option, set the reset info resetpos = 0; - resetref = NULL; + resetref = nullptr; if (options == UI_MENU_RESET_REMEMBER_POSITION) resetpos = selected; else if (options == UI_MENU_RESET_REMEMBER_REF) resetref = item[selected].ref; // reset all the pools and the numitems back to 0 - for (ui_menu_pool *ppool = pool; ppool != NULL; ppool = ppool->next) + for (ui_menu_pool *ppool = pool; ppool != nullptr; ppool = ppool->next) ppool->top = (UINT8 *)(ppool + 1); numitems = 0; visitems = 0; @@ -182,12 +182,12 @@ void ui_menu::reset(ui_menu_reset_options options) strprintf(backtext, "Return to %s", emulator_info::get_capstartgamenoun()); // add an item to return - if (parent == NULL) - item_append(backtext.c_str(), NULL, 0, NULL); + if (parent == nullptr) + item_append(backtext.c_str(), nullptr, 0, nullptr); else if (parent->is_special_main_menu()) - item_append("Exit", NULL, 0, NULL); + item_append("Exit", nullptr, 0, nullptr); else - item_append("Return to Previous Menu", NULL, 0, NULL); + item_append("Return to Previous Menu", nullptr, 0, nullptr); } @@ -264,13 +264,13 @@ void ui_menu::item_append(const char *text, const char *subtext, UINT32 flags, v // allocate a new item and populate it pitem = &item[index]; - pitem->text = (text != NULL) ? pool_strdup(text) : NULL; - pitem->subtext = (subtext != NULL) ? pool_strdup(subtext) : NULL; + pitem->text = (text != nullptr) ? pool_strdup(text) : nullptr; + pitem->subtext = (subtext != nullptr) ? pool_strdup(subtext) : nullptr; pitem->flags = flags; pitem->ref = ref; // update the selection if we need to - if (resetpos == index || (resetref != NULL && resetref == ref)) + if (resetpos == index || (resetref != nullptr && resetref == ref)) selected = index; if (resetpos == numitems - 1) selected = numitems - 1; @@ -313,7 +313,7 @@ const ui_menu_event *ui_menu::process(UINT32 flags) menu_event.itemref = item[selected].ref; return &menu_event; } - return NULL; + return nullptr; } @@ -329,7 +329,7 @@ void *ui_menu::m_pool_alloc(size_t size) assert(size < UI_MENU_POOL_SIZE); // find a pool with enough room - for (ppool = pool; ppool != NULL; ppool = ppool->next) + for (ppool = pool; ppool != nullptr; ppool = ppool->next) if (ppool->end - ppool->top >= size) { void *result = ppool->top; @@ -367,7 +367,7 @@ const char *ui_menu::pool_strdup(const char *string) void *ui_menu::get_selection() { - return (selected >= 0 && selected < numitems) ? item[selected].ref : NULL; + return (selected >= 0 && selected < numitems) ? item[selected].ref : nullptr; } @@ -493,7 +493,7 @@ void ui_menu::draw(bool customonly) if (!customonly) { mouse_target = ui_input_find_mouse(machine(), &mouse_target_x, &mouse_target_y, &mouse_button); - if (mouse_target != NULL) + if (mouse_target != nullptr) if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, *container, mouse_x, mouse_y)) mouse_hit = true; } @@ -577,9 +577,9 @@ void ui_menu::draw(bool customonly) container->add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // if we don't have a subitem, just draw the string centered - else if (pitem.subtext == NULL) + else if (pitem.subtext == nullptr) machine().ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width, - JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, NULL, NULL); + JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr); // otherwise, draw the item on the left and the subitem text on the right else @@ -590,7 +590,7 @@ void ui_menu::draw(bool customonly) // draw the left-side text machine().ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width, - JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, &item_width, NULL); + JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, &item_width, nullptr); // give 2 spaces worth of padding item_width += 2.0f * gutter_width; @@ -605,7 +605,7 @@ void ui_menu::draw(bool customonly) // draw the subitem right-justified machine().ui().draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width, - JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, NULL); + JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, nullptr); // apply arrows if (itemnum == selected && (pitem.flags & MENU_FLAG_LEFT_ARROW)) @@ -659,11 +659,11 @@ void ui_menu::draw(bool customonly) target_x + target_width + UI_BOX_LR_BORDER, target_y + target_height + UI_BOX_TB_BORDER, subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR); machine().ui().draw_text_full(container, pitem.subtext, target_x, target_y, target_width, - JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL); + JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr); } // if there is something special to add, do it by calling the virtual method - custom_render((selected >= 0 && selected < numitems) ? item[selected].ref : NULL, customtop, custombottom, x1, y1, x2, y2); + custom_render((selected >= 0 && selected < numitems) ? item[selected].ref : nullptr, customtop, custombottom, x1, y1, x2, y2); // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow visitems = visible_lines - (top_line != 0) - (top_line + visible_lines != numitems); @@ -720,7 +720,7 @@ void ui_menu::draw_text_box() target_x + target_width + gutter_width + UI_BOX_LR_BORDER, target_y + target_height + UI_BOX_TB_BORDER, (item[0].flags & MENU_FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR); machine().ui().draw_text_full(container, text, target_x, target_y, target_width, - JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); + JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // draw the "return to prior menu" text with a hilight behind it highlight( @@ -731,7 +731,7 @@ void ui_menu::draw_text_box() target_y + target_height, UI_SELECTED_BG_COLOR); machine().ui().draw_text_full(container, backtext, target_x, target_y + target_height - line_height, target_width, - JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL); + JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr); // artificially set the hover to the last item so a double-click exits hover = numitems - 1; @@ -944,7 +944,7 @@ void ui_menu::validate_selection(int scandir) void ui_menu::clear_free_list(running_machine &machine) { - while (menu_free != NULL) + while (menu_free != nullptr) { ui_menu *menu = menu_free; menu_free = menu->parent; @@ -964,7 +964,7 @@ void ui_menu::clear_free_list(running_machine &machine) void ui_menu::stack_reset(running_machine &machine) { - while (menu_stack != NULL) + while (menu_stack != nullptr) ui_menu::stack_pop(machine); } @@ -989,7 +989,7 @@ void ui_menu::stack_push(ui_menu *menu) void ui_menu::stack_pop(running_machine &machine) { - if (menu_stack != NULL) + if (menu_stack != nullptr) { ui_menu *menu = menu_stack; menu_stack = menu->parent; @@ -1009,7 +1009,7 @@ bool ui_menu::stack_has_special_main_menu() { ui_menu *menu; - for (menu = menu_stack; menu != NULL; menu = menu->parent) + for (menu = menu_stack; menu != nullptr; menu = menu->parent) if (menu->is_special_main_menu()) return true; @@ -1036,18 +1036,18 @@ void ui_menu::do_handle() UINT32 ui_menu::ui_handler(running_machine &machine, render_container *container, UINT32 state) { // if we have no menus stacked up, start with the main menu - if (menu_stack == NULL) + if (menu_stack == nullptr) stack_push(auto_alloc_clear(machine, ui_menu_main(machine, container))); // update the menu state - if (menu_stack != NULL) + if (menu_stack != nullptr) menu_stack->do_handle(); // clear up anything pending to be released clear_free_list(machine); // if the menus are to be hidden, return a cancel here - if (machine.ui().is_menu_active() && ((ui_input_pressed(machine, IPT_UI_CONFIGURE) && !stack_has_special_main_menu()) || menu_stack == NULL)) + if (machine.ui().is_menu_active() && ((ui_input_pressed(machine, IPT_UI_CONFIGURE) && !stack_has_special_main_menu()) || menu_stack == nullptr)) return UI_HANDLER_CANCEL; return 0; diff --git a/src/emu/ui/miscmenu.cpp b/src/emu/ui/miscmenu.cpp index 1f5d3e49c3d..9053b6cd7c1 100644 --- a/src/emu/ui/miscmenu.cpp +++ b/src/emu/ui/miscmenu.cpp @@ -32,7 +32,7 @@ ui_menu_keyboard_mode::ui_menu_keyboard_mode(running_machine &machine, render_co void ui_menu_keyboard_mode::populate() { bool natural = machine().ui().use_natural_keyboard(); - item_append("Keyboard Mode:", natural ? "Natural" : "Emulated", natural ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, NULL); + item_append("Keyboard Mode:", natural ? "Natural" : "Emulated", natural ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, nullptr); } ui_menu_keyboard_mode::~ui_menu_keyboard_mode() @@ -46,7 +46,7 @@ void ui_menu_keyboard_mode::handle() /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL) + if (menu_event != nullptr) { if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { @@ -70,7 +70,7 @@ void ui_menu_bios_selection::populate() { /* cycle through all devices for this system */ device_iterator deviter(machine().root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { if (device->rom_region()) { const char *val = "default"; @@ -85,8 +85,8 @@ void ui_menu_bios_selection::populate() } } - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Reset", NULL, 0, (void *)1); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append("Reset", nullptr, 0, (void *)1); } ui_menu_bios_selection::~ui_menu_bios_selection() @@ -102,7 +102,7 @@ void ui_menu_bios_selection::handle() /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT) machine().schedule_hard_reset(); @@ -154,10 +154,10 @@ void ui_menu_network_devices::populate() { /* cycle through all devices for this system */ network_interface_iterator iter(machine().root_device()); - for (device_network_interface *network = iter.first(); network != NULL; network = iter.next()) + for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next()) { int curr = network->get_interface(); - const char *title = NULL; + const char *title = nullptr; const osd_netdev::entry_t *entry = netdev_first(); while(entry) { if(entry->id==curr) { @@ -180,7 +180,7 @@ void ui_menu_network_devices::handle() /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { device_network_interface *network = (device_network_interface *)menu_event->itemref; @@ -266,7 +266,7 @@ void ui_menu_bookkeeping::populate() } /* append the single item */ - item_append(tempstring.c_str(), NULL, MENU_FLAG_MULTILINE, NULL); + item_append(tempstring.c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); } /*------------------------------------------------- @@ -280,7 +280,7 @@ void ui_menu_crosshair::handle() const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); /* handle events */ - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { crosshair_user_settings settings; crosshair_item_data *data = (crosshair_item_data *)menu_event->itemref; @@ -445,7 +445,7 @@ void ui_menu_crosshair::populate() /* look for the current name, then remember the name before */ /* and find the next name */ - while (((dir = path.next()) != NULL) && !finished) + while (((dir = path.next()) != nullptr) && !finished) { int length = strlen(dir->name); diff --git a/src/emu/ui/miscmenu.h b/src/emu/ui/miscmenu.h index 4b54a67f63e..649977869f3 100644 --- a/src/emu/ui/miscmenu.h +++ b/src/emu/ui/miscmenu.h @@ -20,24 +20,24 @@ class ui_menu_keyboard_mode : public ui_menu { public: ui_menu_keyboard_mode(running_machine &machine, render_container *container); virtual ~ui_menu_keyboard_mode(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; class ui_menu_network_devices : public ui_menu { public: ui_menu_network_devices(running_machine &machine, render_container *container); virtual ~ui_menu_network_devices(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; class ui_menu_bookkeeping : public ui_menu { public: ui_menu_bookkeeping(running_machine &machine, render_container *container); virtual ~ui_menu_bookkeeping(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: attotime prevtime; @@ -47,8 +47,8 @@ class ui_menu_crosshair : public ui_menu { public: ui_menu_crosshair(running_machine &machine, render_container *container); virtual ~ui_menu_crosshair(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: enum { @@ -73,16 +73,16 @@ class ui_menu_quit_game : public ui_menu { public: ui_menu_quit_game(running_machine &machine, render_container *container); virtual ~ui_menu_quit_game(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; class ui_menu_bios_selection : public ui_menu { public: ui_menu_bios_selection(running_machine &machine, render_container *container); virtual ~ui_menu_bios_selection(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: }; diff --git a/src/emu/ui/selgame.cpp b/src/emu/ui/selgame.cpp index 0504842a8f4..a9286bcf3ee 100644 --- a/src/emu/ui/selgame.cpp +++ b/src/emu/ui/selgame.cpp @@ -59,7 +59,7 @@ void ui_menu_select_game::build_driver_list() const osd_directory_entry *dir; // iterate while we get new objects - while ((dir = path.next()) != NULL) + while ((dir = path.next()) != nullptr) { char drivername[50]; char *dst = drivername; @@ -82,7 +82,7 @@ void ui_menu_select_game::build_driver_list() m_driverlist[listnum++] = &m_drivlist->driver(); // NULL-terminate - m_driverlist[listnum] = NULL; + m_driverlist[listnum] = nullptr; } @@ -98,7 +98,7 @@ void ui_menu_select_game::handle() // process the menu const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { // reset the error on any future menu_event if (m_error) @@ -180,7 +180,7 @@ void ui_menu_select_game::inkey_cancel(const ui_menu_event *menu_event) if (m_search[0] != 0) { // since we have already been popped, we must recreate ourself from scratch - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, NULL))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, nullptr))); } } @@ -221,7 +221,7 @@ void ui_menu_select_game::populate() int matchcount; int curitem; - for (curitem = matchcount = 0; m_driverlist[curitem] != NULL && matchcount < VISIBLE_GAMES_IN_LIST; curitem++) + for (curitem = matchcount = 0; m_driverlist[curitem] != nullptr && matchcount < VISIBLE_GAMES_IN_LIST; curitem++) if (!(m_driverlist[curitem]->flags & MACHINE_NO_STANDALONE)) matchcount++; @@ -235,12 +235,12 @@ void ui_menu_select_game::populate() emulator_info::get_gamesnoun(), emulator_info::get_configname(), emulator_info::get_appname(),emulator_info::get_appname() ); - item_append(txt.c_str(), NULL, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, NULL); + item_append(txt.c_str(), nullptr, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, nullptr); return; } // otherwise, rebuild the match list - assert(m_drivlist != NULL); + assert(m_drivlist != nullptr); if (m_search[0] != 0 || m_matchlist[0] == -1 || m_rerandomize) m_drivlist->find_approximate_matches(m_search, matchcount, m_matchlist); m_rerandomize = false; @@ -259,8 +259,8 @@ void ui_menu_select_game::populate() // if we're forced into this, allow general input configuration as well if (ui_menu::stack_has_special_main_menu()) { - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Configure General Inputs", NULL, 0, (void *)1); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append("Configure General Inputs", nullptr, 0, (void *)1); } // configure the custom rendering @@ -290,7 +290,7 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott // get the size of the text machine().ui().draw_text_full(container, tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL); + DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(width, origx2 - origx1); @@ -310,10 +310,10 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott // draw the text within it machine().ui().draw_text_full(container, tempbuf[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); + DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // determine the text to render below - driver = ((FPTR)selectedref > 1) ? (const game_driver *)selectedref : NULL; + driver = ((FPTR)selectedref > 1) ? (const game_driver *)selectedref : nullptr; if ((FPTR)driver > 1) { const char *gfxstat, *soundstat; @@ -380,7 +380,7 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott for (line = 0; line < 4; line++) { machine().ui().draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL); + DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(maxwidth, width); } @@ -393,11 +393,11 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott // draw a box color = UI_BACKGROUND_COLOR; - if (driver != NULL) + if (driver != nullptr) color = UI_GREEN_COLOR; - if (driver != NULL && (driver->flags & (MACHINE_IMPERFECT_GRAPHICS | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_COLORS | MACHINE_NO_SOUND | MACHINE_IMPERFECT_SOUND)) != 0) + if (driver != nullptr && (driver->flags & (MACHINE_IMPERFECT_GRAPHICS | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_COLORS | MACHINE_NO_SOUND | MACHINE_IMPERFECT_SOUND)) != 0) color = UI_YELLOW_COLOR; - if (driver != NULL && (driver->flags & (MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION)) != 0) + if (driver != nullptr && (driver->flags & (MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION)) != 0) color = UI_RED_COLOR; machine().ui().draw_outlined_box(container, x1, y1, x2, y2, color); @@ -410,7 +410,7 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott for (line = 0; line < 4; line++) { machine().ui().draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); + DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); y1 += machine().ui().get_line_height(); } } diff --git a/src/emu/ui/selgame.h b/src/emu/ui/selgame.h index d442e6279bc..b5e6687c4f3 100644 --- a/src/emu/ui/selgame.h +++ b/src/emu/ui/selgame.h @@ -20,9 +20,9 @@ class ui_menu_select_game : public ui_menu { public: ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename); virtual ~ui_menu_select_game(); - virtual void populate(); - virtual void handle(); - virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); + virtual void populate() override; + virtual void handle() override; + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; // force game select menu static void force_game_select(running_machine &machine, render_container *container); diff --git a/src/emu/ui/sliders.cpp b/src/emu/ui/sliders.cpp index f69e6b5ab14..a7b58aeb275 100644 --- a/src/emu/ui/sliders.cpp +++ b/src/emu/ui/sliders.cpp @@ -36,13 +36,13 @@ void ui_menu_sliders::handle() /* process the menu */ menu_event = process(UI_MENU_PROCESS_LR_REPEAT | (hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0)); - if (menu_event != NULL) + if (menu_event != nullptr) { /* handle keys if there is a valid item selected */ - if (menu_event->itemref != NULL) + if (menu_event->itemref != nullptr) { const slider_state *slider = (const slider_state *)menu_event->itemref; - INT32 curvalue = (*slider->update)(machine(), slider->arg, NULL, SLIDER_NOCHANGE); + INT32 curvalue = (*slider->update)(machine(), slider->arg, nullptr, SLIDER_NOCHANGE); INT32 increment = 0; switch (menu_event->iptkey) @@ -97,7 +97,7 @@ void ui_menu_sliders::handle() newvalue = slider->maxval; /* update the slider and recompute the menu */ - (*slider->update)(machine(), slider->arg, NULL, newvalue); + (*slider->update)(machine(), slider->arg, nullptr, newvalue); reset(UI_MENU_RESET_REMEMBER_REF); } } @@ -133,7 +133,7 @@ void ui_menu_sliders::populate() std::string tempstring; /* add UI sliders */ - for (const slider_state *curslider = machine().ui().get_slider_list(); curslider != NULL; curslider = curslider->next) + for (const slider_state *curslider = machine().ui().get_slider_list(); curslider != nullptr; curslider = curslider->next) { INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); UINT32 flags = 0; @@ -145,7 +145,7 @@ void ui_menu_sliders::populate() } /* add OSD sliders */ - for (const slider_state *curslider = (slider_state*)machine().osd().get_slider_list(); curslider != NULL; curslider = curslider->next) + for (const slider_state *curslider = (slider_state*)machine().osd().get_slider_list(); curslider != nullptr; curslider = curslider->next) { INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); UINT32 flags = 0; @@ -167,7 +167,7 @@ void ui_menu_sliders::populate() void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) { const slider_state *curslider = (const slider_state *)selectedref; - if (curslider != NULL) + if (curslider != nullptr) { float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x; float line_height = machine().ui().get_line_height(); @@ -198,7 +198,7 @@ void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, /* determine the text height */ machine().ui().draw_text_full(container, tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, - JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height); + JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, nullptr, &text_height); /* draw the thermometer */ bar_left = x1 + UI_BOX_LR_BORDER; @@ -225,7 +225,7 @@ void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, /* draw the actual text */ machine().ui().draw_text_full(container, tempstring.c_str(), x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, - JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height); + JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, &text_height); } } diff --git a/src/emu/ui/sliders.h b/src/emu/ui/sliders.h index 069a10c5c84..d76a24c1671 100644 --- a/src/emu/ui/sliders.h +++ b/src/emu/ui/sliders.h @@ -17,10 +17,10 @@ class ui_menu_sliders : public ui_menu { public: ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode = false); virtual ~ui_menu_sliders(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; - virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; static UINT32 ui_handler(running_machine &machine, render_container *container, UINT32 state); diff --git a/src/emu/ui/slotopt.cpp b/src/emu/ui/slotopt.cpp index 510e3392ec8..370fe8388a7 100644 --- a/src/emu/ui/slotopt.cpp +++ b/src/emu/ui/slotopt.cpp @@ -42,10 +42,10 @@ int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot) { const device_slot_option *current = slot_get_current_option(slot); - if (current != NULL) + if (current != nullptr) { int val = 0; - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) { if (option == current) return val; @@ -64,7 +64,7 @@ int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot) int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot) { int val = 0; - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) if (option->selectable()) val++; @@ -113,7 +113,7 @@ const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, i if (index >= 0) { int val = 0; - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) { if (val == index) return option->name(); @@ -152,12 +152,12 @@ void ui_menu_slot_devices::populate() { /* cycle through all devices for this system */ slot_interface_iterator iter(machine().root_device()); - for (device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next()) + for (device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next()) { /* record the menu item */ const device_slot_option *option = slot_get_current_option(slot); std::string opt_name; - if (option == NULL) + if (option == nullptr) opt_name.assign("------"); else { @@ -168,8 +168,8 @@ void ui_menu_slot_devices::populate() item_append(slot->device().tag() + 1, opt_name.c_str(), (slot->fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)slot); } - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Reset", NULL, 0, (void *)1); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append("Reset", nullptr, 0, (void *)1); } ui_menu_slot_devices::~ui_menu_slot_devices() @@ -185,7 +185,7 @@ void ui_menu_slot_devices::handle() /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT) { diff --git a/src/emu/ui/slotopt.h b/src/emu/ui/slotopt.h index 72e36af779c..86cf75102de 100644 --- a/src/emu/ui/slotopt.h +++ b/src/emu/ui/slotopt.h @@ -19,8 +19,8 @@ class ui_menu_slot_devices : public ui_menu { public: ui_menu_slot_devices(running_machine &machine, render_container *container); virtual ~ui_menu_slot_devices(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: device_slot_option *slot_get_current_option(device_slot_interface *slot); diff --git a/src/emu/ui/swlist.cpp b/src/emu/ui/swlist.cpp index b8dbeb45ccf..6155a4c5883 100644 --- a/src/emu/ui/swlist.cpp +++ b/src/emu/ui/swlist.cpp @@ -61,22 +61,22 @@ void ui_menu_software_parts::populate() { software_part_menu_entry *entry1 = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry1)); entry1->type = T_EMPTY; - entry1->part = 0; - item_append("[empty slot]", 0, 0, entry1); + entry1->part = nullptr; + item_append("[empty slot]", nullptr, 0, entry1); software_part_menu_entry *entry2 = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry2)); entry2->type = T_FMGR; - entry2->part = 0; - item_append("[file manager]", 0, 0, entry2); + entry2->part = nullptr; + item_append("[file manager]", nullptr, 0, entry2); software_part_menu_entry *entry3 = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry3)); entry3->type = T_SWLIST; - entry3->part = 0; - item_append("[software list]", 0, 0, entry3); + entry3->part = nullptr; + item_append("[software list]", nullptr, 0, entry3); } - for (const software_part *swpart = m_info->first_part(); swpart != NULL; swpart = swpart->next()) + for (const software_part *swpart = m_info->first_part(); swpart != nullptr; swpart = swpart->next()) { if (swpart->matches_interface(m_interface)) { @@ -84,7 +84,7 @@ void ui_menu_software_parts::populate() // check if the available parts have specific part_id to be displayed (e.g. "Map Disc", "Bonus Disc", etc.) // if not, we simply display "part_name"; if yes we display "part_name (part_id)" std::string menu_part_name(swpart->name()); - if (swpart->feature("part_id") != NULL) + if (swpart->feature("part_id") != nullptr) menu_part_name.append(" (").append(swpart->feature("part_id")).append(")"); entry->type = T_ENTRY; entry->part = swpart; @@ -103,7 +103,7 @@ void ui_menu_software_parts::handle() // process the menu const ui_menu_event *event = process(0); - if (event != NULL && event->iptkey == IPT_UI_SELECT && event->itemref != NULL) + if (event != nullptr && event->iptkey == IPT_UI_SELECT && event->itemref != nullptr) { software_part_menu_entry *entry = (software_part_menu_entry *) event->itemref; *m_result = entry->type; @@ -126,7 +126,7 @@ ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_co { m_swlist = swlist; m_interface = interface; - m_entrylist = NULL; + m_entrylist = nullptr; m_ordered_by_shortname = true; } @@ -152,13 +152,13 @@ int ui_menu_software_list::compare_entries(const entry_info *e1, const entry_inf if (shortname) { - e1_basename = (e1->short_name != NULL) ? e1->short_name : ""; - e2_basename = (e2->short_name != NULL) ? e2->short_name : ""; + e1_basename = (e1->short_name != nullptr) ? e1->short_name : ""; + e2_basename = (e2->short_name != nullptr) ? e2->short_name : ""; } else { - e1_basename = (e1->long_name != NULL) ? e1->long_name : ""; - e2_basename = (e2->long_name != NULL) ? e2->long_name : ""; + e1_basename = (e1->long_name != nullptr) ? e1->long_name : ""; + e2_basename = (e2->long_name != nullptr) ? e2->long_name : ""; } result = core_stricmp(e1_basename, e2_basename); @@ -184,12 +184,12 @@ int ui_menu_software_list::compare_entries(const entry_info *e1, const entry_inf ui_menu_software_list::entry_info *ui_menu_software_list::append_software_entry(const software_info *swinfo) { - entry_info *entry = NULL; + entry_info *entry = nullptr; entry_info **entryptr; bool entry_updated = FALSE; // check if at least one of the parts has the correct interface and add a menu entry only in this case - for (const software_part *swpart = swinfo->first_part(); swpart != NULL; swpart = swpart->next()) + for (const software_part *swpart = swinfo->first_part(); swpart != nullptr; swpart = swpart->next()) { if (swpart->matches_interface(m_interface) && swpart->is_compatible(*m_swlist)) { @@ -209,7 +209,7 @@ ui_menu_software_list::entry_info *ui_menu_software_list::append_software_entry( { // find the end of the list entryptr = &m_entrylist; - while ((*entryptr != NULL) && (compare_entries(entry, *entryptr, m_ordered_by_shortname) >= 0)) + while ((*entryptr != nullptr) && (compare_entries(entry, *entryptr, m_ordered_by_shortname) >= 0)) entryptr = &(*entryptr)->next; // insert the entry @@ -228,14 +228,14 @@ ui_menu_software_list::entry_info *ui_menu_software_list::append_software_entry( void ui_menu_software_list::populate() { // build up the list of entries for the menu - for (const software_info *swinfo = m_swlist->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (const software_info *swinfo = m_swlist->first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) append_software_entry(swinfo); // add an entry to change ordering - item_append("Switch Item Ordering", NULL, 0, (void *)1); + item_append("Switch Item Ordering", nullptr, 0, (void *)1); // append all of the menu entries - for (entry_info *entry = m_entrylist; entry != NULL; entry = entry->next) + for (entry_info *entry = m_entrylist; entry != nullptr; entry = entry->next) item_append(entry->short_name, entry->long_name, 0, entry); } @@ -247,18 +247,18 @@ void ui_menu_software_list::populate() void ui_menu_software_list::handle() { const entry_info *entry; - const entry_info *selected_entry = NULL; + const entry_info *selected_entry = nullptr; int bestmatch = 0; // process the menu const ui_menu_event *event = process(0); - if (event != NULL && event->itemref != NULL) + if (event != nullptr && event->itemref != nullptr) { if ((FPTR)event->itemref == 1 && event->iptkey == IPT_UI_SELECT) { m_ordered_by_shortname = !m_ordered_by_shortname; - m_entrylist = NULL; + m_entrylist = nullptr; // reset the char buffer if we change ordering criterion memset(m_filename_buffer, '\0', ARRAY_LENGTH(m_filename_buffer)); @@ -312,11 +312,11 @@ void ui_menu_software_list::handle() // check for entries which matches our filename_buffer: // from current entry to the end - for (entry = cur_selected; entry != NULL; entry = entry->next) + for (entry = cur_selected; entry != nullptr; entry = entry->next) { const char *compare_name = m_ordered_by_shortname ? entry->short_name : entry->long_name; - if (compare_name != NULL && m_filename_buffer != NULL) + if (compare_name != nullptr && m_filename_buffer != nullptr) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(m_filename_buffer); i++) @@ -337,7 +337,7 @@ void ui_menu_software_list::handle() { const char *compare_name = m_ordered_by_shortname ? entry->short_name : entry->long_name; - if (compare_name != NULL && m_filename_buffer != NULL) + if (compare_name != nullptr && m_filename_buffer != nullptr) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(m_filename_buffer); i++) @@ -354,7 +354,7 @@ void ui_menu_software_list::handle() } } - if (selected_entry != NULL && selected_entry != cur_selected) + if (selected_entry != nullptr && selected_entry != cur_selected) set_selection((void *) selected_entry); } } @@ -406,32 +406,32 @@ void ui_menu_software::populate() // Add original software lists for this system software_list_device_iterator iter(machine().config().root_device()); - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) - if (swlistdev->first_software_info() != NULL && m_interface != NULL) + if (swlistdev->first_software_info() != nullptr && m_interface != nullptr) { bool found = false; - for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) if (swinfo->first_part()->matches_interface(m_interface)) found = true; if (found) - item_append(swlistdev->description(), NULL, 0, (void *)swlistdev); + item_append(swlistdev->description(), nullptr, 0, (void *)swlistdev); } // add compatible software lists for this system - for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + for (software_list_device *swlistdev = iter.first(); swlistdev != nullptr; swlistdev = iter.next()) if (swlistdev->list_type() == SOFTWARE_LIST_COMPATIBLE_SYSTEM) - if (swlistdev->first_software_info() != NULL && m_interface != NULL) + if (swlistdev->first_software_info() != nullptr && m_interface != nullptr) { bool found = false; - for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != nullptr; swinfo = swinfo->next()) if (swinfo->first_part()->matches_interface(m_interface)) found = true; if (found) { if (!have_compatible) - item_append("[compatible lists]", NULL, MENU_FLAG_DISABLE, NULL); - item_append(swlistdev->description(), NULL, 0, (void *)swlistdev); + item_append("[compatible lists]", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(swlistdev->description(), nullptr, 0, (void *)swlistdev); } have_compatible = true; } @@ -447,7 +447,7 @@ void ui_menu_software::handle() // process the menu const ui_menu_event *event = process(0); - if (event != NULL && event->iptkey == IPT_UI_SELECT) { + if (event != nullptr && event->iptkey == IPT_UI_SELECT) { // ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, (software_list_config *)event->itemref, image))); *m_result = (software_list_device *)event->itemref; ui_menu::stack_pop(machine()); diff --git a/src/emu/ui/swlist.h b/src/emu/ui/swlist.h index 7ced74cc97c..944aeadf6c5 100644 --- a/src/emu/ui/swlist.h +++ b/src/emu/ui/swlist.h @@ -18,8 +18,8 @@ public: enum { T_EMPTY, T_FMGR, T_SWLIST, T_ENTRY }; ui_menu_software_parts(running_machine &machine, render_container *container, const software_info *info, const char *interface, const software_part **part, bool other_opt, int *result); virtual ~ui_menu_software_parts(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: struct software_part_menu_entry { @@ -42,8 +42,8 @@ class ui_menu_software_list : public ui_menu { public: ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, std::string &result); virtual ~ui_menu_software_list(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: struct entry_info { @@ -73,8 +73,8 @@ class ui_menu_software : public ui_menu { public: ui_menu_software(running_machine &machine, render_container *container, const char *interface, software_list_device **result); virtual ~ui_menu_software(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: const char * m_interface; diff --git a/src/emu/ui/tapectrl.cpp b/src/emu/ui/tapectrl.cpp index a44fb9f009a..253ffbf915d 100644 --- a/src/emu/ui/tapectrl.cpp +++ b/src/emu/ui/tapectrl.cpp @@ -77,7 +77,7 @@ void ui_menu_tape_control::populate() tapeflags |= MENU_FLAG_RIGHT_ARROW; } - get_time_string(timepos, current_device(), NULL, NULL); + get_time_string(timepos, current_device(), nullptr, nullptr); state = current_device()->get_state(); item_append( (state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED @@ -91,19 +91,19 @@ void ui_menu_tape_control::populate() TAPECMD_SLIDER); // pause or stop - item_append("Pause/Stop", NULL, 0, TAPECMD_STOP); + item_append("Pause/Stop", nullptr, 0, TAPECMD_STOP); // play - item_append("Play", NULL, 0, TAPECMD_PLAY); + item_append("Play", nullptr, 0, TAPECMD_PLAY); // record - item_append("Record", NULL, 0, TAPECMD_RECORD); + item_append("Record", nullptr, 0, TAPECMD_RECORD); // rewind - item_append("Rewind", NULL, 0, TAPECMD_REWIND); + item_append("Rewind", nullptr, 0, TAPECMD_REWIND); // fast forward - item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD); + item_append("Fast Forward", nullptr, 0, TAPECMD_FAST_FORWARD); } } } @@ -121,7 +121,7 @@ void ui_menu_tape_control::handle() // process the menu const ui_menu_event *event = process(UI_MENU_PROCESS_LR_REPEAT); - if (event != NULL) + if (event != nullptr) { switch(event->iptkey) { @@ -175,8 +175,8 @@ void ui_menu_tape_control::get_time_string(std::string &dest, cassette_image_dev else strprintf(dest, "%04d/%04d", 0, (int)t1); - if (curpos != NULL) + if (curpos != nullptr) *curpos = t0; - if (endpos != NULL) + if (endpos != nullptr) *endpos = t1; } diff --git a/src/emu/ui/tapectrl.h b/src/emu/ui/tapectrl.h index 8e4e539df9b..9cfa1316a99 100644 --- a/src/emu/ui/tapectrl.h +++ b/src/emu/ui/tapectrl.h @@ -20,8 +20,8 @@ class ui_menu_tape_control : public ui_menu_device_controlmap_point_container(mouse_target_x, mouse_target_y, *container, mouse_x, mouse_y)) { @@ -475,7 +475,7 @@ void ui_manager::update_and_render(render_container *container) render_font *ui_manager::get_font() { // allocate the font and messagebox string - if (m_font == NULL) + if (m_font == nullptr) m_font = machine().render().font_alloc(machine().options().ui_font()); return m_font; } @@ -582,7 +582,7 @@ void ui_manager::draw_outlined_box(render_container *container, float x0, float void ui_manager::draw_text(render_container *container, const char *buf, float x, float y) { - draw_text_full(container, buf, x, y, 1.0f - x, JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); + draw_text_full(container, buf, x, y, 1.0f - x, JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } @@ -612,7 +612,7 @@ void ui_manager::draw_text_full(render_container *container, const char *origs, // loop over lines while (*s != 0) { - const char *lastbreak = NULL; + const char *lastbreak = nullptr; int line_justify = justify; unicode_char schar; int scharcount; @@ -679,7 +679,7 @@ void ui_manager::draw_text_full(render_container *container, const char *origs, if (wrap == WRAP_WORD) { // if we hit a break, back up to there with the appropriate width - if (lastbreak != NULL) + if (lastbreak != nullptr) { s = lastbreak; curwidth = lastbreak_width; @@ -844,7 +844,7 @@ void ui_manager::draw_text_box(render_container *container, const char *text, in target_x + target_width + UI_BOX_LR_BORDER, target_y + target_height + UI_BOX_TB_BORDER, backcolor); draw_text_full(container, text, target_x, target_y, target_width + 0.00001f, - justify, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); + justify, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } @@ -1159,7 +1159,7 @@ std::string &ui_manager::game_info_astring(std::string &str) // loop over all CPUs execute_interface_iterator execiter(machine().root_device()); tagmap_t exectags; - for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next()) + for (device_execute_interface *exec = execiter.first(); exec != nullptr; exec = execiter.next()) { if (exectags.add(exec->device().tag(), 1, FALSE) == TMERR_DUPLICATE) continue; @@ -1170,7 +1170,7 @@ std::string &ui_manager::game_info_astring(std::string &str) int count = 1; const char *name = exec->device().name(); execute_interface_iterator execinneriter(machine().root_device()); - for (device_execute_interface *scan = execinneriter.first(); scan != NULL; scan = execinneriter.next()) + for (device_execute_interface *scan = execinneriter.first(); scan != nullptr; scan = execinneriter.next()) { if (exec->device().type() == scan->device().type() && strcmp(name, scan->device().name()) == 0 && exec->device().clock() == scan->device().clock()) if (exectags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) @@ -1193,7 +1193,7 @@ std::string &ui_manager::game_info_astring(std::string &str) sound_interface_iterator snditer(machine().root_device()); tagmap_t soundtags; bool found_sound = false; - for (device_sound_interface *sound = snditer.first(); sound != NULL; sound = snditer.next()) + for (device_sound_interface *sound = snditer.first(); sound != nullptr; sound = snditer.next()) { if (soundtags.add(sound->device().tag(), 1, FALSE) == TMERR_DUPLICATE) continue; @@ -1206,7 +1206,7 @@ std::string &ui_manager::game_info_astring(std::string &str) // count how many identical sound chips we have int count = 1; sound_interface_iterator sndinneriter(machine().root_device()); - for (device_sound_interface *scan = sndinneriter.first(); scan != NULL; scan = sndinneriter.next()) + for (device_sound_interface *scan = sndinneriter.first(); scan != nullptr; scan = sndinneriter.next()) { if (sound->device().type() == scan->device().type() && sound->device().clock() == scan->device().clock()) if (soundtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) @@ -1235,7 +1235,7 @@ std::string &ui_manager::game_info_astring(std::string &str) str.append("None\n"); else { - for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next()) + for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) { if (scrcount > 1) { @@ -1430,11 +1430,11 @@ bool ui_manager::can_paste() char *text = osd_get_clipboard_text(); // free the string if allocated - if (text != NULL) + if (text != nullptr) osd_free(text); // did we have text? - return text != NULL; + return text != nullptr; } @@ -1448,7 +1448,7 @@ void ui_manager::paste() char *text = osd_get_clipboard_text(); // was a result returned? - if (text != NULL) + if (text != nullptr) { // post the text machine().ioport().natkeyboard().post_utf8(text); @@ -1470,7 +1470,7 @@ void ui_manager::image_handler_ingame() if (machine().phase() == MACHINE_PHASE_RUNNING) { image_interface_iterator iter(machine().root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) image->call_display(); } } @@ -1490,14 +1490,14 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co { std::string tempstring; machine.ui().draw_text_full(container, machine.video().speed_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f, - JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); + JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr); } // draw the profiler if visible if (machine.ui().show_profiler()) { const char *text = g_profiler.text(machine); - machine.ui().draw_text_full(container, text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); + machine.ui().draw_text_full(container, text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr); } // if we're single-stepping, pause now @@ -1590,7 +1590,7 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co if (ui_input_pressed(machine, IPT_UI_TAPE_START)) { cassette_device_iterator cassiter(machine.root_device()); - for (cassette_image_device *cass = cassiter.first(); cass != NULL; cass = cassiter.next()) + for (cassette_image_device *cass = cassiter.first(); cass != nullptr; cass = cassiter.next()) { cass->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE); return 0; @@ -1599,7 +1599,7 @@ UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *co if (ui_input_pressed(machine, IPT_UI_TAPE_STOP)) { cassette_device_iterator cassiter(machine.root_device()); - for (cassette_image_device *cass = cassiter.first(); cass != NULL; cass = cassiter.next()) + for (cassette_image_device *cass = cassiter.first(); cass != nullptr; cass = cassiter.next()) { cass->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE); return 0; @@ -1845,13 +1845,13 @@ static slider_state *slider_init(running_machine &machine) { ioport_field *field; ioport_port *port; - slider_state *listhead = NULL; + slider_state *listhead = nullptr; slider_state **tailptr = &listhead; std::string str; int item; // add overall volume - *tailptr = slider_alloc(machine, "Master Volume", -32, 0, 0, 1, slider_volume, NULL); + *tailptr = slider_alloc(machine, "Master Volume", -32, 0, 0, 1, slider_volume, nullptr); tailptr = &(*tailptr)->next; // add per-channel volume @@ -1868,8 +1868,8 @@ static slider_state *slider_init(running_machine &machine) } // add analog adjusters - for (port = machine.ioport().first_port(); port != NULL; port = port->next()) - for (field = port->first_field(); field != NULL; field = field->next()) + for (port = machine.ioport().first_port(); port != nullptr; port = port->next()) + for (field = port->first_field(); field != nullptr; field = field->next()) if (field->type() == IPT_ADJUSTER) { void *param = (void *)field; @@ -1881,7 +1881,7 @@ static slider_state *slider_init(running_machine &machine) if (machine.options().cheat()) { execute_interface_iterator iter(machine.root_device()); - for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next()) + for (device_execute_interface *exec = iter.first(); exec != nullptr; exec = iter.next()) { void *param = (void *)&exec->device(); strprintf(str, "Overclock CPU %s", exec->device().tag()); @@ -1892,7 +1892,7 @@ static slider_state *slider_init(running_machine &machine) // add screen parameters screen_device_iterator scriter(machine.root_device()); - for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next()) + for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) { int defxscale = floor(screen->xscale() * 1000.0f + 0.5f); int defyscale = floor(screen->yscale() * 1000.0f + 0.5f); @@ -1935,7 +1935,7 @@ static slider_state *slider_init(running_machine &machine) } laserdisc_device_iterator lditer(machine.root_device()); - for (laserdisc_device *laserdisc = lditer.first(); laserdisc != NULL; laserdisc = lditer.next()) + for (laserdisc_device *laserdisc = lditer.first(); laserdisc != nullptr; laserdisc = lditer.next()) if (laserdisc->overlay_configured()) { laserdisc_overlay_config config; @@ -1961,25 +1961,25 @@ static slider_state *slider_init(running_machine &machine) tailptr = &(*tailptr)->next; } - for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next()) + for (screen_device *screen = scriter.first(); screen != nullptr; screen = scriter.next()) if (screen->screen_type() == SCREEN_TYPE_VECTOR) { // add vector control - *tailptr = slider_alloc(machine, "Vector Flicker", 0, 0, 1000, 10, slider_flicker, NULL); + *tailptr = slider_alloc(machine, "Vector Flicker", 0, 0, 1000, 10, slider_flicker, nullptr); tailptr = &(*tailptr)->next; - *tailptr = slider_alloc(machine, "Beam Width Minimum", 1, 100, 1000, 1, slider_beam_width_min, NULL); + *tailptr = slider_alloc(machine, "Beam Width Minimum", 1, 100, 1000, 1, slider_beam_width_min, nullptr); tailptr = &(*tailptr)->next; - *tailptr = slider_alloc(machine, "Beam Width Maximum", 1, 100, 1000, 1, slider_beam_width_max, NULL); + *tailptr = slider_alloc(machine, "Beam Width Maximum", 1, 100, 1000, 1, slider_beam_width_max, nullptr); tailptr = &(*tailptr)->next; - *tailptr = slider_alloc(machine, "Beam Intensity Weight", -1000, 0, 1000, 10, slider_beam_intensity_weight, NULL); + *tailptr = slider_alloc(machine, "Beam Intensity Weight", -1000, 0, 1000, 10, slider_beam_intensity_weight, nullptr); tailptr = &(*tailptr)->next; break; } #ifdef MAME_DEBUG // add crosshair adjusters - for (port = machine.ioport().first_port(); port != NULL; port = port->next()) - for (field = port->first_field(); field != NULL; field = field->next()) + for (port = machine.ioport().first_port(); port != nullptr; port = port->next()) + for (field = port->first_field(); field != nullptr; field = field->next()) if (field->crosshair_axis() != CROSSHAIR_AXIS_NONE && field->player() == 0) { void *param = (void *)field; @@ -2004,7 +2004,7 @@ static INT32 slider_volume(running_machine &machine, void *arg, std::string *str { if (newval != SLIDER_NOCHANGE) machine.sound().set_attenuation(newval); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%3ddB", machine.sound().attenuation()); return machine.sound().attenuation(); } @@ -2026,7 +2026,7 @@ static INT32 slider_mixervol(running_machine &machine, void *arg, std::string *s if (newval > curval && (newval - curval) <= 4) newval += 4; // round up on increment info.stream->set_user_gain(info.inputnum, (float)newval * 0.001f); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%4.2f", (double) info.stream->user_gain(info.inputnum)); return floorf(info.stream->user_gain(info.inputnum) * 1000.0f + 0.5f); } @@ -2048,7 +2048,7 @@ static INT32 slider_adjuster(running_machine &machine, void *arg, std::string *s settings.value = newval; field->set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%d%%", settings.value); return settings.value; } @@ -2064,7 +2064,7 @@ static INT32 slider_overclock(running_machine &machine, void *arg, std::string * device_t *cpu = (device_t *)arg; if (newval != SLIDER_NOCHANGE) cpu->set_clock_scale((float)newval * 0.001f); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%3.0f%%", floor(cpu->clock_scale() * 100.0 + 0.5)); return floor(cpu->clock_scale() * 1000.0 + 0.5); } @@ -2087,7 +2087,7 @@ static INT32 slider_refresh(running_machine &machine, void *arg, std::string *st const rectangle &visarea = screen->visible_area(); screen->configure(width, height, visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001)); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3ffps", ATTOSECONDS_TO_HZ(machine.first_screen()->frame_period().attoseconds())); refresh = ATTOSECONDS_TO_HZ(machine.first_screen()->frame_period().attoseconds()); return floor((refresh - defrefresh) * 1000.0 + 0.5); @@ -2110,7 +2110,7 @@ static INT32 slider_brightness(running_machine &machine, void *arg, std::string settings.m_brightness = (float)newval * 0.001f; screen->container().set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_brightness); return floor(settings.m_brightness * 1000.0f + 0.5f); } @@ -2132,7 +2132,7 @@ static INT32 slider_contrast(running_machine &machine, void *arg, std::string *s settings.m_contrast = (float)newval * 0.001f; screen->container().set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_contrast); return floor(settings.m_contrast * 1000.0f + 0.5f); } @@ -2153,7 +2153,7 @@ static INT32 slider_gamma(running_machine &machine, void *arg, std::string *str, settings.m_gamma = (float)newval * 0.001f; screen->container().set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_gamma); return floor(settings.m_gamma * 1000.0f + 0.5f); } @@ -2175,7 +2175,7 @@ static INT32 slider_xscale(running_machine &machine, void *arg, std::string *str settings.m_xscale = (float)newval * 0.001f; screen->container().set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_xscale); return floor(settings.m_xscale * 1000.0f + 0.5f); } @@ -2197,7 +2197,7 @@ static INT32 slider_yscale(running_machine &machine, void *arg, std::string *str settings.m_yscale = (float)newval * 0.001f; screen->container().set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_yscale); return floor(settings.m_yscale * 1000.0f + 0.5f); } @@ -2219,7 +2219,7 @@ static INT32 slider_xoffset(running_machine &machine, void *arg, std::string *st settings.m_xoffset = (float)newval * 0.001f; screen->container().set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_xoffset); return floor(settings.m_xoffset * 1000.0f + 0.5f); } @@ -2241,7 +2241,7 @@ static INT32 slider_yoffset(running_machine &machine, void *arg, std::string *st settings.m_yoffset = (float)newval * 0.001f; screen->container().set_user_settings(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_yoffset); return floor(settings.m_yoffset * 1000.0f + 0.5f); } @@ -2263,7 +2263,7 @@ static INT32 slider_overxscale(running_machine &machine, void *arg, std::string settings.m_overscalex = (float)newval * 0.001f; laserdisc->set_overlay_config(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_overscalex); return floor(settings.m_overscalex * 1000.0f + 0.5f); } @@ -2285,7 +2285,7 @@ static INT32 slider_overyscale(running_machine &machine, void *arg, std::string settings.m_overscaley = (float)newval * 0.001f; laserdisc->set_overlay_config(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_overscaley); return floor(settings.m_overscaley * 1000.0f + 0.5f); } @@ -2307,7 +2307,7 @@ static INT32 slider_overxoffset(running_machine &machine, void *arg, std::string settings.m_overposx = (float)newval * 0.001f; laserdisc->set_overlay_config(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_overposx); return floor(settings.m_overposx * 1000.0f + 0.5f); } @@ -2329,7 +2329,7 @@ static INT32 slider_overyoffset(running_machine &machine, void *arg, std::string settings.m_overposy = (float)newval * 0.001f; laserdisc->set_overlay_config(settings); } - if (str != NULL) + if (str != nullptr) strprintf(*str,"%.3f", (double) settings.m_overposy); return floor(settings.m_overposy * 1000.0f + 0.5f); } @@ -2342,10 +2342,10 @@ static INT32 slider_overyoffset(running_machine &machine, void *arg, std::string static INT32 slider_flicker(running_machine &machine, void *arg, std::string *str, INT32 newval) { - vector_device *vector = NULL; + vector_device *vector = nullptr; if (newval != SLIDER_NOCHANGE) vector->set_flicker((float)newval * 0.001f); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%1.2f", (double) vector->get_flicker()); return floor(vector->get_flicker() * 1000.0f + 0.5f); } @@ -2358,10 +2358,10 @@ static INT32 slider_flicker(running_machine &machine, void *arg, std::string *st static INT32 slider_beam_width_min(running_machine &machine, void *arg, std::string *str, INT32 newval) { - vector_device *vector = NULL; + vector_device *vector = nullptr; if (newval != SLIDER_NOCHANGE) vector->set_beam_width_min(MIN((float)newval * 0.01f, vector->get_beam_width_max())); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%1.2f", (double) vector->get_beam_width_min()); return floor(vector->get_beam_width_min() * 100.0f + 0.5f); } @@ -2374,10 +2374,10 @@ static INT32 slider_beam_width_min(running_machine &machine, void *arg, std::str static INT32 slider_beam_width_max(running_machine &machine, void *arg, std::string *str, INT32 newval) { - vector_device *vector = NULL; + vector_device *vector = nullptr; if (newval != SLIDER_NOCHANGE) vector->set_beam_width_max(MAX((float)newval * 0.01f, vector->get_beam_width_min())); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%1.2f", (double) vector->get_beam_width_max()); return floor(vector->get_beam_width_max() * 100.0f + 0.5f); } @@ -2390,10 +2390,10 @@ static INT32 slider_beam_width_max(running_machine &machine, void *arg, std::str static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, std::string *str, INT32 newval) { - vector_device *vector = NULL; + vector_device *vector = nullptr; if (newval != SLIDER_NOCHANGE) vector->set_beam_intensity_weight((float)newval * 0.001f); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%1.2f", (double) vector->get_beam_intensity_weight()); return floor(vector->get_beam_intensity_weight() * 1000.0f + 0.5f); } @@ -2430,7 +2430,7 @@ static INT32 slider_crossscale(running_machine &machine, void *arg, std::string if (newval != SLIDER_NOCHANGE) field->set_crosshair_scale(float(newval) * 0.001); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%s %s %1.3f", "Crosshair Scale", (field->crosshair_axis() == CROSSHAIR_AXIS_X) ? "X" : "Y", float(newval) * 0.001f); return floor(field->crosshair_scale() * 1000.0f + 0.5f); } @@ -2449,7 +2449,7 @@ static INT32 slider_crossoffset(running_machine &machine, void *arg, std::string if (newval != SLIDER_NOCHANGE) field->set_crosshair_offset(float(newval) * 0.001f); - if (str != NULL) + if (str != nullptr) strprintf(*str,"%s %s %1.3f", "Crosshair Offset", (field->crosshair_axis() == CROSSHAIR_AXIS_X) ? "X" : "Y", float(newval) * 0.001f); return field->crosshair_offset(); } diff --git a/src/emu/ui/ui.h b/src/emu/ui/ui.h index 6c4af3bf005..987cf2b8976 100644 --- a/src/emu/ui/ui.h +++ b/src/emu/ui/ui.h @@ -135,7 +135,7 @@ public: void draw_outlined_box(render_container *container, float x0, float y0, float x1, float y1, rgb_t backcolor); void draw_outlined_box(render_container *container, float x0, float y0, float x1, float y1, rgb_t fgcolor, rgb_t bgcolor); void draw_text(render_container *container, const char *buf, float x, float y); - void draw_text_full(render_container *container, const char *origs, float x, float y, float origwrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth = NULL, float *totalheight = NULL); + void draw_text_full(render_container *container, const char *origs, float x, float y, float origwrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth = nullptr, float *totalheight = nullptr); void draw_text_box(render_container *container, const char *text, int justify, float xpos, float ypos, rgb_t backcolor); void draw_message_window(render_container *container, const char *text); diff --git a/src/emu/ui/videoopt.cpp b/src/emu/ui/videoopt.cpp index 584ec6e679f..c3427004008 100644 --- a/src/emu/ui/videoopt.cpp +++ b/src/emu/ui/videoopt.cpp @@ -23,7 +23,7 @@ void ui_menu_video_targets::handle() { /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) + if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, static_cast(menu_event->itemref)))); } @@ -48,12 +48,12 @@ void ui_menu_video_targets::populate() char buffer[40]; /* stop when we run out */ - if (target == NULL) + if (target == nullptr) break; /* add a menu item */ sprintf(buffer, "Screen #%d", targetnum); - item_append(buffer, NULL, 0, target); + item_append(buffer, nullptr, 0, target); } } @@ -72,7 +72,7 @@ void ui_menu_video_options::handle() /* process the menu */ const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->itemref != NULL) + if (menu_event != nullptr && menu_event->itemref != nullptr) { switch ((FPTR)menu_event->itemref) { @@ -180,17 +180,17 @@ void ui_menu_video_options::populate() for (viewnum = 0; ; viewnum++) { const char *name = target->view_name(viewnum); - if (name == NULL) + if (name == nullptr) break; /* create a string for the item, replacing underscores with spaces */ tempstring.assign(name); strreplace(tempstring, "_", " "); - item_append(tempstring.c_str(), NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum)); + item_append(tempstring.c_str(), nullptr, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum)); } /* add a separator */ - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); /* add a rotate item */ switch (target->orientation()) diff --git a/src/emu/ui/videoopt.h b/src/emu/ui/videoopt.h index b5ea569b936..802f1295c08 100644 --- a/src/emu/ui/videoopt.h +++ b/src/emu/ui/videoopt.h @@ -18,16 +18,16 @@ class ui_menu_video_targets : public ui_menu { public: ui_menu_video_targets(running_machine &machine, render_container *container); virtual ~ui_menu_video_targets(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; }; class ui_menu_video_options : public ui_menu { public: ui_menu_video_options(running_machine &machine, render_container *container, render_target *target); virtual ~ui_menu_video_options(); - virtual void populate(); - virtual void handle(); + virtual void populate() override; + virtual void handle() override; private: enum { diff --git a/src/emu/ui/viewgfx.cpp b/src/emu/ui/viewgfx.cpp index 0d133af3f6c..c59be16b199 100644 --- a/src/emu/ui/viewgfx.cpp +++ b/src/emu/ui/viewgfx.cpp @@ -192,7 +192,7 @@ static void ui_gfx_count_devices(running_machine &machine, ui_gfx_state &state) i < tempcount && state.gfxset.devcount < MAX_GFX_DECODERS; i++, interface = gfx_iter.next()) { - for (count = 0; count < MAX_GFX_ELEMENTS && interface->gfx(count) != NULL; count++) { } + for (count = 0; count < MAX_GFX_ELEMENTS && interface->gfx(count) != nullptr; count++) { } // count = index of first NULL if (count > 0) @@ -216,11 +216,11 @@ static void ui_gfx_exit(running_machine &machine) { // free the texture machine.render().texture_free(ui_gfx.texture); - ui_gfx.texture = NULL; + ui_gfx.texture = nullptr; // free the bitmap global_free(ui_gfx.bitmap); - ui_gfx.bitmap = NULL; + ui_gfx.bitmap = nullptr; } @@ -835,7 +835,7 @@ static void gfxset_update_bitmap(running_machine &machine, ui_gfx_state &state, cellypix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.width() : gfx.height()); // realloc the bitmap if it is too small - if (state.bitmap == NULL || state.texture == NULL || state.bitmap->bpp() != 32 || state.bitmap->width() != cellxpix * xcells || state.bitmap->height() != cellypix * ycells) + if (state.bitmap == nullptr || state.texture == nullptr || state.bitmap->bpp() != 32 || state.bitmap->width() != cellxpix * xcells || state.bitmap->height() != cellypix * ycells) { // free the old stuff machine.render().texture_free(state.texture); @@ -1144,7 +1144,7 @@ static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, { UINT32 temp = width; width = height; height = temp; } // realloc the bitmap if it is too small - if (state.bitmap == NULL || state.texture == NULL || state.bitmap->width() != width || state.bitmap->height() != height) + if (state.bitmap == nullptr || state.texture == nullptr || state.bitmap->width() != width || state.bitmap->height() != height) { // free the old stuff machine.render().texture_free(state.texture); diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp index b0cbaa0add0..8ec5c8b91cc 100644 --- a/src/emu/uiinput.cpp +++ b/src/emu/uiinput.cpp @@ -116,7 +116,7 @@ bool ui_input_push_event(running_machine &machine, ui_event evt) ui_input_private *uidata = machine.ui_input_data; /* we may be called before the UI is initialized */ - if (uidata == NULL) + if (uidata == nullptr) return false; /* some pre-processing (this is an icky place to do this stuff!) */ @@ -131,7 +131,7 @@ bool ui_input_push_event(running_machine &machine, ui_event evt) case UI_EVENT_MOUSE_LEAVE: if (uidata->current_mouse_target == evt.target) { - uidata->current_mouse_target = NULL; + uidata->current_mouse_target = nullptr; uidata->current_mouse_x = -1; uidata->current_mouse_y = -1; } @@ -212,11 +212,11 @@ void ui_input_reset(running_machine &machine) render_target *ui_input_find_mouse(running_machine &machine, INT32 *x, INT32 *y, bool *button) { ui_input_private *uidata = machine.ui_input_data; - if (x != NULL) + if (x != nullptr) *x = uidata->current_mouse_x; - if (y != NULL) + if (y != nullptr) *y = uidata->current_mouse_y; - if (button != NULL) + if (button != nullptr) *button = uidata->current_mouse_down; return uidata->current_mouse_target; } diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp index 014a2a5bf92..78404d121ce 100644 --- a/src/emu/validity.cpp +++ b/src/emu/validity.cpp @@ -88,7 +88,7 @@ void validity_checker::validate_tag(const char *tag) osd_printf_error("Tag '%s' contains spaces\n", tag); break; } - if (strchr(validchars, *p) == NULL) + if (strchr(validchars, *p) == nullptr) { osd_printf_error("Tag '%s' contains invalid character '%c'\n", tag, *p); break; @@ -97,7 +97,7 @@ void validity_checker::validate_tag(const char *tag) // find the start of the final tag const char *begin = strrchr(tag, ':'); - if (begin == NULL) + if (begin == nullptr) begin = tag; else begin += 1; @@ -125,16 +125,16 @@ validity_checker::validity_checker(emu_options &options) : m_drivlist(options), m_errors(0), m_warnings(0), - m_current_driver(NULL), - m_current_config(NULL), - m_current_device(NULL), - m_current_ioport(NULL) + m_current_driver(nullptr), + m_current_config(nullptr), + m_current_device(nullptr), + m_current_ioport(nullptr) { // pre-populate the defstr map with all the default strings for (int strnum = 1; strnum < INPUT_STRING_COUNT; strnum++) { const char *string = ioport_string_from_index(strnum); - if (string != NULL) + if (string != nullptr) m_defstr_map.add(string, strnum, false); } } @@ -267,9 +267,9 @@ void validity_checker::validate_one(const game_driver &driver) { // set the current driver m_current_driver = &driver; - m_current_config = NULL; - m_current_device = NULL; - m_current_ioport = NULL; + m_current_config = nullptr; + m_current_device = nullptr; + m_current_ioport = nullptr; m_region_map.reset(); // reset error/warning state @@ -287,7 +287,7 @@ void validity_checker::validate_one(const game_driver &driver) validate_roms(); validate_inputs(); validate_devices(); - m_current_config = NULL; + m_current_config = nullptr; } catch (emu_fatalerror &err) { @@ -313,10 +313,10 @@ void validity_checker::validate_one(const game_driver &driver) } // reset the driver/device - m_current_driver = NULL; - m_current_config = NULL; - m_current_device = NULL; - m_current_ioport = NULL; + m_current_driver = nullptr; + m_current_config = nullptr; + m_current_device = nullptr; + m_current_ioport = nullptr; } @@ -579,15 +579,15 @@ void validity_checker::validate_driver() // normalize driver->compatible_with const char *compatible_with = m_current_driver->compatible_with; - if (compatible_with != NULL && strcmp(compatible_with, "0") == 0) - compatible_with = NULL; + if (compatible_with != nullptr && strcmp(compatible_with, "0") == 0) + compatible_with = nullptr; // check for this driver being compatible with a non-existant driver - if (compatible_with != NULL && m_drivlist.find(m_current_driver->compatible_with) == -1) + if (compatible_with != nullptr && m_drivlist.find(m_current_driver->compatible_with) == -1) osd_printf_error("Driver is listed as compatible with nonexistant driver %s\n", m_current_driver->compatible_with); // check for clone_of and compatible_with being specified at the same time - if (m_drivlist.clone(*m_current_driver) != -1 && compatible_with != NULL) + if (m_drivlist.clone(*m_current_driver) != -1 && compatible_with != nullptr) osd_printf_error("Driver cannot be both a clone and listed as compatible with another system\n"); // find any recursive dependencies on the current driver @@ -600,7 +600,7 @@ void validity_checker::validate_driver() // make sure sound-less drivers are flagged sound_interface_iterator iter(m_current_config->root_device()); - if ((m_current_driver->flags & MACHINE_IS_BIOS_ROOT) == 0 && iter.first() == NULL && (m_current_driver->flags & MACHINE_NO_SOUND) == 0 && (m_current_driver->flags & MACHINE_NO_SOUND_HW) == 0) + if ((m_current_driver->flags & MACHINE_IS_BIOS_ROOT) == 0 && iter.first() == nullptr && (m_current_driver->flags & MACHINE_NO_SOUND) == 0 && (m_current_driver->flags & MACHINE_NO_SOUND_HW) == 0) osd_printf_error("Driver is missing MACHINE_NO_SOUND flag\n"); } @@ -613,10 +613,10 @@ void validity_checker::validate_roms() { // iterate, starting with the driver's ROMs and continuing with device ROMs device_iterator deviter(m_current_config->root_device()); - for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) + for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { // for non-root devices, track the current device - m_current_device = (device->owner() == NULL) ? NULL : device; + m_current_device = (device->owner() == nullptr) ? nullptr : device; // scan the ROM entries for this device const char *last_region_name = "???"; @@ -625,7 +625,7 @@ void validity_checker::validate_roms() int items_since_region = 1; int last_bios = 0; int total_files = 0; - for (const rom_entry *romp = rom_first_region(*device); romp != NULL && !ROMENTRY_ISEND(romp); romp++) + for (const rom_entry *romp = rom_first_region(*device); romp != nullptr && !ROMENTRY_ISEND(romp); romp++) { // if this is a region, make sure it's valid, and record the length if (ROMENTRY_ISREGION(romp)) @@ -640,7 +640,7 @@ void validity_checker::validate_roms() last_region_name = basetag; // check for a valid tag - if (basetag == NULL) + if (basetag == nullptr) { osd_printf_error("ROM_REGION tag with NULL name\n"); continue; @@ -695,7 +695,7 @@ void validity_checker::validate_roms() // reset the current device - m_current_device = NULL; + m_current_device = nullptr; } } @@ -794,7 +794,7 @@ void validity_checker::validate_dip_settings(ioport_field &field) bool coin_error = false; // iterate through the settings - for (ioport_setting *setting = field.first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = field.first_setting(); setting != nullptr; setting = setting->next()) { // note any coinage strings int strindex = get_defstr_index(setting->name()); @@ -814,7 +814,7 @@ void validity_checker::validate_dip_settings(ioport_field &field) osd_printf_error("Flip Screen option must be Off/On, not %s\n", setting->name()); // if we have a neighbor, compare ourselves to him - if (setting->next() != NULL) + if (setting->next() != nullptr) { // check for inverted off/on dispswitch order int next_strindex = get_defstr_index(setting->next()->name(), true); @@ -874,14 +874,14 @@ void validity_checker::validate_inputs() // iterate over devices device_iterator iter(m_current_config->root_device()); - for (device_t *device = iter.first(); device != NULL; device = iter.next()) + for (device_t *device = iter.first(); device != nullptr; device = iter.next()) { // see if this device has ports; if not continue - if (device->input_ports() == NULL) + if (device->input_ports() == nullptr) continue; // for non-root devices, track the current device - m_current_device = (device == &m_current_config->root_device()) ? NULL : device; + m_current_device = (device == &m_current_config->root_device()) ? nullptr : device; // allocate the input ports ioport_list portlist; @@ -893,17 +893,17 @@ void validity_checker::validate_inputs() osd_printf_error("I/O port error during construction:\n%s\n", errorbuf.c_str()); // do a first pass over ports to add their names and find duplicates - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) if (port_map.add(port->tag(), 1, false) == TMERR_DUPLICATE) osd_printf_error("Multiple I/O ports with the same tag '%s' defined\n", port->tag()); // iterate over ports - for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) + for (ioport_port *port = portlist.first(); port != nullptr; port = port->next()) { m_current_ioport = port->tag(); // iterate through the fields on this port - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) + for (ioport_field *field = port->first_field(); field != nullptr; field = field->next()) { // verify analog inputs if (field->is_analog()) @@ -917,7 +917,7 @@ void validity_checker::validate_inputs() if (field->type() == IPT_DIPSWITCH) { // dip switch fields must have a name - if (field->name() == NULL) + if (field->name() == nullptr) osd_printf_error("DIP switch has a NULL name\n"); // verify the settings list @@ -926,7 +926,7 @@ void validity_checker::validate_inputs() // verify names const char *name = field->specific_name(); - if (name != NULL) + if (name != nullptr) { // check for empty string if (name[0] == 0) @@ -949,17 +949,17 @@ void validity_checker::validate_inputs() validate_condition(field->condition(), *device, port_map); // verify conditions on the settings - for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) + for (ioport_setting *setting = field->first_setting(); setting != nullptr; setting = setting->next()) if (!setting->condition().none()) validate_condition(setting->condition(), *device, port_map); } // done with this port - m_current_ioport = NULL; + m_current_ioport = nullptr; } // done with this device - m_current_device = NULL; + m_current_device = nullptr; } } @@ -974,17 +974,17 @@ void validity_checker::validate_devices() int_map device_map; device_iterator iter_find(m_current_config->root_device()); - for (const device_t *device = iter_find.first(); device != NULL; device = iter_find.next()) + for (const device_t *device = iter_find.first(); device != nullptr; device = iter_find.next()) { device->findit(true); } // iterate over devices device_iterator iter(m_current_config->root_device()); - for (const device_t *device = iter.first(); device != NULL; device = iter.next()) + for (const device_t *device = iter.first(); device != nullptr; device = iter.next()) { // for non-root devices, track the current device - m_current_device = (device == &m_current_config->root_device()) ? NULL : device; + m_current_device = (device == &m_current_config->root_device()) ? nullptr : device; // validate the device tag validate_tag(device->basetag()); @@ -1005,15 +1005,15 @@ void validity_checker::validate_devices() device->validity_check(*this); // done with this device - m_current_device = NULL; + m_current_device = nullptr; } // if device is slot cart device, we must have a shortname int_map slot_device_map; slot_interface_iterator slotiter(m_current_config->root_device()); - for (const device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next()) + for (const device_slot_interface *slot = slotiter.first(); slot != nullptr; slot = slotiter.next()) { - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + for (const device_slot_option *option = slot->first_option(); option != nullptr; option = option->next()) { std::string temptag("_"); temptag.append(option->name()); @@ -1021,7 +1021,7 @@ void validity_checker::validate_devices() // notify this device and all its subdevices that they are now configured device_iterator subiter(*dev); - for (device_t *device = subiter.first(); device != NULL; device = subiter.next()) + for (device_t *device = subiter.first(); device != nullptr; device = subiter.next()) if (!device->configured()) device->config_complete(); @@ -1049,11 +1049,11 @@ void validity_checker::build_output_prefix(std::string &str) str.clear(); // if we have a current device, indicate that - if (m_current_device != NULL) + if (m_current_device != nullptr) str.append(m_current_device->name()).append(" device '").append(m_current_device->tag()).append("': "); // if we have a current port, indicate that as well - if (m_current_ioport != NULL) + if (m_current_ioport != nullptr) str.append("ioport '").append(m_current_ioport).append("': "); } diff --git a/src/emu/validity.h b/src/emu/validity.h index acc271a7cae..7581d454241 100644 --- a/src/emu/validity.h +++ b/src/emu/validity.h @@ -55,7 +55,7 @@ public: // osd_output interface protected: - virtual void output_callback(osd_output_channel channel, const char *msg, va_list args); + virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override; private: // internal helpers diff --git a/src/emu/video.cpp b/src/emu/video.cpp index d2358949407..ea50e8a662b 100644 --- a/src/emu/video.cpp +++ b/src/emu/video.cpp @@ -72,7 +72,7 @@ static void video_notifier_callback(const char *outname, INT32 value, void *para video_manager::video_manager(running_machine &machine) : m_machine(machine), - m_screenless_frame_timer(NULL), + m_screenless_frame_timer(nullptr), m_output_changed(false), m_throttle_last_ticks(0), m_throttle_realtime(attotime::zero), @@ -97,14 +97,14 @@ video_manager::video_manager(running_machine &machine) m_frameskip_adjust(0), m_skipping_this_frame(false), m_average_oversleep(0), - m_snap_target(NULL), + m_snap_target(nullptr), m_snap_native(true), m_snap_width(0), m_snap_height(0), m_mng_frame_period(attotime::zero), m_mng_next_frame_time(attotime::zero), m_mng_frame(0), - m_avi_file(NULL), + m_avi_file(nullptr), m_avi_frame_period(attotime::zero), m_avi_next_frame_time(attotime::zero), m_avi_frame(0), @@ -119,7 +119,7 @@ video_manager::video_manager(running_machine &machine) // create a render target for snapshots const char *viewname = machine.options().snap_view(); - m_snap_native = (machine.first_screen() != NULL && (viewname[0] == 0 || strcmp(viewname, "native") == 0)); + m_snap_native = (machine.first_screen() != nullptr && (viewname[0] == 0 || strcmp(viewname, "native") == 0)); // the native target is hard-coded to our internal layout and has all options disabled if (m_snap_native) @@ -137,7 +137,7 @@ video_manager::video_manager(running_machine &machine) // other targets select the specified view and turn off effects else { - m_snap_target = machine.render().target_alloc(NULL, RENDER_CREATE_HIDDEN); + m_snap_target = machine.render().target_alloc(nullptr, RENDER_CREATE_HIDDEN); m_snap_target->set_view(m_snap_target->configured_view(viewname, 0, 1)); m_snap_target->set_screen_overlay_enabled(false); } @@ -160,11 +160,11 @@ video_manager::video_manager(running_machine &machine) #endif // if no screens, create a periodic timer to drive updates - if (machine.first_screen() == NULL) + if (machine.first_screen() == nullptr) { m_screenless_frame_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(video_manager::screenless_update_callback), this)); m_screenless_frame_timer->adjust(screen_device::DEFAULT_FRAME_PERIOD, 0, screen_device::DEFAULT_FRAME_PERIOD); - output_set_notifier(NULL, video_notifier_callback, this); + output_set_notifier(nullptr, video_notifier_callback, this); } } @@ -247,7 +247,7 @@ void video_manager::frame_update(bool debug) if (phase == MACHINE_PHASE_RUNNING) { // reset partial updates if we're paused or if the debugger is active - if (machine().first_screen() != NULL && (machine().paused() || debug || debugger_within_instruction_hook(machine()))) + if (machine().first_screen() != nullptr && (machine().paused() || debug || debugger_within_instruction_hook(machine()))) machine().first_screen()->reset_partial_updates(); } } @@ -286,7 +286,7 @@ std::string &video_manager::speed_text(std::string &str) // display the number of partial updates as well int partials = 0; screen_device_iterator iter(machine().root_device()); - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) partials += screen->partial_updates(); if (partials > 1) strcatprintf(str, "\n%d partial updates", partials); @@ -303,7 +303,7 @@ std::string &video_manager::speed_text(std::string &str) void video_manager::save_snapshot(screen_device *screen, emu_file &file) { // validate - assert(!m_snap_native || screen != NULL); + assert(!m_snap_native || screen != nullptr); // create the bitmap to pass in create_snapshot_bitmap(screen); @@ -311,13 +311,13 @@ void video_manager::save_snapshot(screen_device *screen, emu_file &file) // add two text entries describing the image std::string text1 = std::string(emulator_info::get_appname()).append(" ").append(build_version); std::string text2 = std::string(machine().system().manufacturer).append(" ").append(machine().system().description); - png_info pnginfo = { 0 }; + png_info pnginfo = { nullptr }; png_add_text(&pnginfo, "Software", text1.c_str()); png_add_text(&pnginfo, "System", text2.c_str()); // now do the actual work - const rgb_t *palette = (screen !=NULL && screen->palette() != NULL) ? screen->palette()->palette()->entry_list_adjusted() : NULL; - int entries = (screen !=NULL && screen->palette() != NULL) ? screen->palette()->entries() : 0; + const rgb_t *palette = (screen !=nullptr && screen->palette() != nullptr) ? screen->palette()->palette()->entry_list_adjusted() : nullptr; + int entries = (screen !=nullptr && screen->palette() != nullptr) ? screen->palette()->entries() : 0; png_error error = png_write_bitmap(file, &pnginfo, m_snap_bitmap, entries, palette); if (error != PNGERR_NONE) osd_printf_error("Error generating PNG for snapshot: png_error = %d\n", error); @@ -339,7 +339,7 @@ void video_manager::save_active_screen_snapshots() { // write one snapshot per visible screen screen_device_iterator iter(machine().root_device()); - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) if (machine().render().is_live(*screen)) { emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -355,7 +355,7 @@ void video_manager::save_active_screen_snapshots() emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); file_error filerr = open_next(file, "png"); if (filerr == FILERR_NONE) - save_snapshot(NULL, file); + save_snapshot(nullptr, file); } } @@ -367,7 +367,7 @@ void video_manager::save_active_screen_snapshots() void video_manager::begin_recording(const char *name, movie_format format) { // create a snapshot bitmap so we know what the target size is - create_snapshot_bitmap(NULL); + create_snapshot_bitmap(nullptr); // start up an AVI recording if (format == MF_AVI) @@ -382,7 +382,7 @@ void video_manager::begin_recording(const char *name, movie_format format) // build up information about this new movie avi_movie_info info; info.video_format = 0; - info.video_timescale = 1000 * ((machine().first_screen() != NULL) ? ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE); + info.video_timescale = 1000 * ((machine().first_screen() != nullptr) ? ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE); info.video_sampletime = 1000; info.video_numsamples = 0; info.video_width = m_snap_bitmap.width(); @@ -402,7 +402,7 @@ void video_manager::begin_recording(const char *name, movie_format format) std::string fullpath; { emu_file tempfile(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - if (name != NULL) + if (name != nullptr) filerr = tempfile.open(name); else filerr = open_next(tempfile, "avi"); @@ -440,7 +440,7 @@ void video_manager::begin_recording(const char *name, movie_format format) // create a new movie file and start recording m_mng_file = std::make_unique(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); file_error filerr; - if (name != NULL) + if (name != nullptr) filerr = m_mng_file->open(name); else filerr = open_next(*m_mng_file, "mng"); @@ -448,7 +448,7 @@ void video_manager::begin_recording(const char *name, movie_format format) if (filerr == FILERR_NONE) { // start the capture - int rate = (machine().first_screen() != NULL) ? ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE; + int rate = (machine().first_screen() != nullptr) ? ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE; png_error pngerr = mng_capture_start(*m_mng_file, m_snap_bitmap, rate); if (pngerr != PNGERR_NONE) { @@ -477,10 +477,10 @@ void video_manager::end_recording(movie_format format) if (format == MF_AVI) { // close the file if it exists - if (m_avi_file != NULL) + if (m_avi_file != nullptr) { avi_close(m_avi_file); - m_avi_file = NULL; + m_avi_file = nullptr; // reset the state m_avi_frame = 0; @@ -489,7 +489,7 @@ void video_manager::end_recording(movie_format format) else if (format == MF_MNG) { // close the file if it exists - if (m_mng_file != NULL) + if (m_mng_file != nullptr) { mng_capture_stop(*m_mng_file); m_mng_file.reset(); @@ -509,7 +509,7 @@ void video_manager::end_recording(movie_format format) void video_manager::add_sound_to_recording(const INT16 *sound, int numsamples) { // only record if we have a file - if (m_avi_file != NULL) + if (m_avi_file != nullptr) { g_profiler.start(PROFILER_MOVIE_REC); @@ -651,13 +651,13 @@ bool video_manager::finish_screen_updates() // finish updating the screens screen_device_iterator iter(machine().root_device()); - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) screen->update_partial(screen->visible_area().max_y); // now add the quads for all the screens bool anything_changed = m_output_changed; m_output_changed = false; - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) if (screen->update_quads()) anything_changed = true; @@ -670,12 +670,12 @@ bool video_manager::finish_screen_updates() record_frame(); // iterate over screens and update the burnin for the ones that care - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) screen->update_burnin(); } // draw any crosshairs - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) crosshair_render(*screen); return anything_changed; @@ -961,7 +961,7 @@ void video_manager::update_refresh_speed() // note that we first check the token since this can get called before all screens are created attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND; screen_device_iterator iter(machine().root_device()); - for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) { attoseconds_t period = screen->frame_period().attoseconds(); if (period != 0) @@ -1046,7 +1046,7 @@ void video_manager::recompute_speed(const attotime &emutime) } #endif - if (machine().first_screen() != NULL) + if (machine().first_screen() != nullptr) { // create a final screenshot emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -1073,7 +1073,7 @@ typedef software_renderer snap_renderer; void video_manager::create_snapshot_bitmap(screen_device *screen) { // select the appropriate view in our dummy target - if (m_snap_native && screen != NULL) + if (m_snap_native && screen != nullptr) { screen_device_iterator iter(machine().root_device()); int view_index = iter.indexof(*screen); @@ -1116,7 +1116,7 @@ file_error video_manager::open_next(emu_file &file, const char *extension) // handle defaults const char *snapname = machine().options().snap_name(); - if (snapname == NULL || snapname[0] == 0) + if (snapname == nullptr || snapname[0] == 0) snapname = "%g/%i"; std::string snapstr(snapname); @@ -1163,7 +1163,7 @@ file_error video_manager::open_next(emu_file &file, const char *extension) // verify that there is such a device for this system image_interface_iterator iter(machine().root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { // get the device name std::string tempdevname(image->brief_instance_name()); @@ -1172,7 +1172,7 @@ file_error video_manager::open_next(emu_file &file, const char *extension) if (snapdevname.compare(tempdevname) == 0) { // verify that such a device has an image mounted - if (image->basename() != NULL) + if (image->basename() != nullptr) { std::string filename(image->basename()); @@ -1240,7 +1240,7 @@ file_error video_manager::open_next(emu_file &file, const char *extension) void video_manager::record_frame() { // ignore if nothing to do - if (m_mng_file == NULL && m_avi_file == NULL && !m_dummy_recording) + if (m_mng_file == nullptr && m_avi_file == nullptr && !m_dummy_recording) return; // start the profiler and get the current time @@ -1248,10 +1248,10 @@ void video_manager::record_frame() attotime curtime = machine().time(); // create the bitmap - create_snapshot_bitmap(NULL); + create_snapshot_bitmap(nullptr); // handle an AVI recording - if (m_avi_file != NULL) + if (m_avi_file != nullptr) { // loop until we hit the right time while (m_avi_next_frame_time <= curtime) @@ -1272,13 +1272,13 @@ void video_manager::record_frame() } // handle a MNG recording - if (m_mng_file != NULL) + if (m_mng_file != nullptr) { // loop until we hit the right time while (m_mng_next_frame_time <= curtime) { // set up the text fields in the movie info - png_info pnginfo = { 0 }; + png_info pnginfo = { nullptr }; if (m_mng_frame == 0) { std::string text1 = std::string(emulator_info::get_appname()).append(" ").append(build_version); @@ -1288,8 +1288,8 @@ void video_manager::record_frame() } // write the next frame - const rgb_t *palette = (machine().first_screen() !=NULL && machine().first_screen()->palette() != NULL) ? machine().first_screen()->palette()->palette()->entry_list_adjusted() : NULL; - int entries = (machine().first_screen() !=NULL && machine().first_screen()->palette() != NULL) ? machine().first_screen()->palette()->entries() : 0; + const rgb_t *palette = (machine().first_screen() !=nullptr && machine().first_screen()->palette() != nullptr) ? machine().first_screen()->palette()->palette()->entry_list_adjusted() : nullptr; + int entries = (machine().first_screen() !=nullptr && machine().first_screen()->palette() != nullptr) ? machine().first_screen()->palette()->entries() : 0; png_error error = mng_capture_frame(*m_mng_file, &pnginfo, m_snap_bitmap, entries, palette); png_free(&pnginfo); if (error != PNGERR_NONE) @@ -1326,7 +1326,7 @@ void video_manager::toggle_record_movie() { if (!is_recording()) { - begin_recording(NULL, MF_MNG); + begin_recording(nullptr, MF_MNG); machine().popmessage("REC START"); } else diff --git a/src/emu/video.h b/src/emu/video.h index c2dc94f4c73..9eb67b70353 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -64,7 +64,7 @@ public: bool throttled() const { return m_throttled; } float throttle_rate() const { return m_throttle_rate; } bool fastforward() const { return m_fastforward; } - bool is_recording() const { return (m_mng_file != nullptr || m_avi_file != NULL); } + bool is_recording() const { return (m_mng_file != nullptr || m_avi_file != nullptr); } // setters void set_frameskip(int frameskip); diff --git a/src/emu/video/vector.cpp b/src/emu/video/vector.cpp index 8cc5aaf9bdb..bcc3b3604b9 100644 --- a/src/emu/video/vector.cpp +++ b/src/emu/video/vector.cpp @@ -131,7 +131,7 @@ const device_type VECTOR = &device_creator; vector_device::vector_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : device_t(mconfig, type, name, tag, owner, clock, shortname, source), device_video_interface(mconfig, *this), - m_vector_list(NULL), + m_vector_list(nullptr), m_min_intensity(255), m_max_intensity(0) { @@ -140,7 +140,7 @@ vector_device::vector_device(const machine_config &mconfig, device_type type, co vector_device::vector_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, VECTOR, "VECTOR", tag, owner, clock, "vector_device", __FILE__), device_video_interface(mconfig, *this), - m_vector_list(NULL), + m_vector_list(nullptr), m_min_intensity(255), m_max_intensity(0) { diff --git a/src/emu/video/vector.h b/src/emu/video/vector.h index d021824e484..37a1587d01e 100644 --- a/src/emu/video/vector.h +++ b/src/emu/video/vector.h @@ -58,7 +58,7 @@ public: float get_beam_intensity_weight(); // device-level overrides - virtual void device_start(); + virtual void device_start() override; private: static float m_flicker; diff --git a/src/lib/formats/cqm_dsk.h b/src/lib/formats/cqm_dsk.h index e07577c1e4c..48bc8d5521c 100644 --- a/src/lib/formats/cqm_dsk.h +++ b/src/lib/formats/cqm_dsk.h @@ -18,14 +18,14 @@ class cqm_format : public floppy_image_format_t public: cqm_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); - virtual bool save(io_generic *io, floppy_image *image); - - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; + virtual bool save(io_generic *io, floppy_image *image) override; + + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; }; extern const floppy_format_type FLOPPY_CQM_FORMAT; diff --git a/src/lib/formats/d88_dsk.h b/src/lib/formats/d88_dsk.h index 5b12f8eb600..2ab8db763f6 100644 --- a/src/lib/formats/d88_dsk.h +++ b/src/lib/formats/d88_dsk.h @@ -19,14 +19,14 @@ class d88_format : public floppy_image_format_t public: d88_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); - virtual bool save(io_generic *io, floppy_image *image); - - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; + virtual bool save(io_generic *io, floppy_image *image) override; + + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; }; extern const floppy_format_type FLOPPY_D88_FORMAT; diff --git a/src/lib/formats/dfi_dsk.h b/src/lib/formats/dfi_dsk.h index 72de8695ae2..b25278275f3 100644 --- a/src/lib/formats/dfi_dsk.h +++ b/src/lib/formats/dfi_dsk.h @@ -10,14 +10,14 @@ class dfi_format : public floppy_image_format_t public: dfi_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; // virtual bool save(io_generic *io, floppy_image *image); - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; }; extern const floppy_format_type FLOPPY_DFI_FORMAT; diff --git a/src/lib/formats/dsk_dsk.h b/src/lib/formats/dsk_dsk.h index d92784f78e8..fc27c0c5030 100644 --- a/src/lib/formats/dsk_dsk.h +++ b/src/lib/formats/dsk_dsk.h @@ -18,13 +18,13 @@ class dsk_format : public floppy_image_format_t public: dsk_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; }; extern const floppy_format_type FLOPPY_DSK_FORMAT; diff --git a/src/lib/formats/hxcmfm_dsk.h b/src/lib/formats/hxcmfm_dsk.h index edaac320d69..63238ab2006 100644 --- a/src/lib/formats/hxcmfm_dsk.h +++ b/src/lib/formats/hxcmfm_dsk.h @@ -18,14 +18,14 @@ class mfm_format : public floppy_image_format_t public: mfm_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); - virtual bool save(io_generic *io, floppy_image *image); - - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; + virtual bool save(io_generic *io, floppy_image *image) override; + + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; }; extern const floppy_format_type FLOPPY_MFM_FORMAT; diff --git a/src/lib/formats/imd_dsk.h b/src/lib/formats/imd_dsk.h index a993a061050..5f26de88d75 100644 --- a/src/lib/formats/imd_dsk.h +++ b/src/lib/formats/imd_dsk.h @@ -19,13 +19,13 @@ class imd_format : public floppy_image_format_t public: imd_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; private: void fixnum(char *start, char *end) const; diff --git a/src/lib/formats/ipf_dsk.h b/src/lib/formats/ipf_dsk.h index f3152e8c5c4..a0a16d36daf 100644 --- a/src/lib/formats/ipf_dsk.h +++ b/src/lib/formats/ipf_dsk.h @@ -10,13 +10,13 @@ class ipf_format : public floppy_image_format_t public: ipf_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; private: struct track_info { diff --git a/src/lib/formats/mfi_dsk.h b/src/lib/formats/mfi_dsk.h index c9e26337ca6..dfac913d4c1 100644 --- a/src/lib/formats/mfi_dsk.h +++ b/src/lib/formats/mfi_dsk.h @@ -10,14 +10,14 @@ class mfi_format : public floppy_image_format_t public: mfi_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); - virtual bool save(io_generic *io, floppy_image *image); - - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; + virtual bool save(io_generic *io, floppy_image *image) override; + + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; private: enum { diff --git a/src/lib/formats/td0_dsk.h b/src/lib/formats/td0_dsk.h index a714d1d9e1c..eae873e30e0 100644 --- a/src/lib/formats/td0_dsk.h +++ b/src/lib/formats/td0_dsk.h @@ -11,14 +11,14 @@ class td0_format : public floppy_image_format_t public: td0_format(); - virtual int identify(io_generic *io, UINT32 form_factor); - virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); - virtual bool save(io_generic *io, floppy_image *image); + virtual int identify(io_generic *io, UINT32 form_factor) override; + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) override; + virtual bool save(io_generic *io, floppy_image *image) override; - virtual const char *name() const; - virtual const char *description() const; - virtual const char *extensions() const; - virtual bool supports_save() const; + virtual const char *name() const override; + virtual const char *description() const override; + virtual const char *extensions() const override; + virtual bool supports_save() const override; }; extern const floppy_format_type FLOPPY_TD0_FORMAT; diff --git a/src/lib/util/avhuff.cpp b/src/lib/util/avhuff.cpp index b9b9057193c..277f056c7ad 100644 --- a/src/lib/util/avhuff.cpp +++ b/src/lib/util/avhuff.cpp @@ -754,7 +754,7 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength, // if we are decoding raw, set up the output parameters UINT8 *metastart, *videostart, *audiostart[16]; UINT32 audioxor, videoxor, videostride; - if (dest != NULL) + if (dest != nullptr) { // create a header dest[0] = 'c'; @@ -793,7 +793,7 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength, metastart = m_config.metadata; for (int chnum = 0; chnum < channels; chnum++) audiostart[chnum] = (UINT8 *)m_config.audio[chnum]; - videostart = (m_config.video.valid()) ? reinterpret_cast(&m_config.video.pix(0)) : NULL; + videostart = (m_config.video.valid()) ? reinterpret_cast(&m_config.video.pix(0)) : nullptr; videostride = (m_config.video.valid()) ? m_config.video.rowpixels() * 2 : 0; // data is assumed to be native-endian @@ -805,22 +805,22 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength, if (m_config.video.valid() && (m_config.video.width() < width || m_config.video.height() < height)) return AVHERR_VIDEO_TOO_LARGE; for (int chnum = 0; chnum < channels; chnum++) - if (m_config.audio[chnum] != NULL && m_config.maxsamples < samples) + if (m_config.audio[chnum] != nullptr && m_config.maxsamples < samples) return AVHERR_AUDIO_TOO_LARGE; - if (m_config.metadata != NULL && m_config.maxmetalength < metasize) + if (m_config.metadata != nullptr && m_config.maxmetalength < metasize) return AVHERR_METADATA_TOO_LARGE; // set the output values - if (m_config.actsamples != NULL) + if (m_config.actsamples != nullptr) *m_config.actsamples = samples; - if (m_config.actmetalength != NULL) + if (m_config.actmetalength != nullptr) *m_config.actmetalength = metasize; } // copy the metadata first if (metasize > 0) { - if (metastart != NULL) + if (metastart != nullptr) memcpy(metastart, source + srcoffs, metasize); srcoffs += metasize; } @@ -842,7 +842,7 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength, } // decode the video data - if (width > 0 && height > 0 && videostart != NULL) + if (width > 0 && height > 0 && videostart != nullptr) { // decode the video avhuff_error err = decode_video(width, height, source + srcoffs, complength - srcoffs, videostart, videostride, videoxor); @@ -897,7 +897,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8 // only process if the data is requested UINT8 *curdest = dest[chnum]; - if (curdest != NULL) + if (curdest != nullptr) { // reset and decode if (!m_flac_decoder.reset(48000, 1, samples, source, size)) @@ -941,7 +941,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8 // only process if the data is requested UINT8 *curdest = dest[chnum]; - if (curdest != NULL) + if (curdest != nullptr) { INT16 prevsample = 0; diff --git a/src/lib/util/avhuff.h b/src/lib/util/avhuff.h index 26873292fdc..cdaa3ec5f3a 100644 --- a/src/lib/util/avhuff.h +++ b/src/lib/util/avhuff.h @@ -57,10 +57,10 @@ class avhuff_decompress_config public: avhuff_decompress_config() : maxsamples(0), - actsamples(NULL), + actsamples(nullptr), maxmetalength(0), - actmetalength(NULL), - metadata(NULL) + actmetalength(nullptr), + metadata(nullptr) { memset(audio, 0, sizeof(audio)); } @@ -90,7 +90,7 @@ public: // static helpers static UINT32 raw_data_size(const UINT8 *data); static UINT32 raw_data_size(UINT32 width, UINT32 height, UINT8 channels, UINT32 numsamples, UINT32 metadatasize = 0) { return 12 + channels * numsamples * 2 + width * height * 2; } - static avhuff_error assemble_data(dynamic_buffer &buffer, bitmap_yuy16 &bitmap, UINT8 channels, UINT32 numsamples, INT16 **samples, UINT8 *metadata = NULL, UINT32 metadatasize = 0); + static avhuff_error assemble_data(dynamic_buffer &buffer, bitmap_yuy16 &bitmap, UINT8 channels, UINT32 numsamples, INT16 **samples, UINT8 *metadata = nullptr, UINT32 metadatasize = 0); private: // delta-RLE Huffman encoder diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp index 06b603e0e31..95d96ca6422 100644 --- a/src/lib/util/aviio.cpp +++ b/src/lib/util/aviio.cpp @@ -626,7 +626,7 @@ INLINE avi_stream *get_video_stream(avi_file *file) if (file->stream[streamnum].type == STREAMTYPE_VIDS) return &file->stream[streamnum]; - return NULL; + return nullptr; } @@ -657,14 +657,14 @@ INLINE avi_stream *get_audio_stream(avi_file *file, int channel, int *offset) { if (channel < file->stream[streamnum].channels) { - if (offset != NULL) + if (offset != nullptr) *offset = channel; return &file->stream[streamnum]; } channel -= file->stream[streamnum].channels; } - return NULL; + return nullptr; } @@ -693,9 +693,9 @@ INLINE avi_error set_stream_chunk_info(avi_stream *stream, UINT32 index, UINT64 { UINT32 newcount = MAX(index, stream->chunksalloc + 1000); avi_chunk_list *newchunks = (avi_chunk_list *)malloc(newcount * sizeof(stream->chunk[0])); - if (newchunks == NULL) + if (newchunks == nullptr) return AVIERR_NO_MEMORY; - if (stream->chunk != NULL) + if (stream->chunk != nullptr) { memcpy(newchunks, stream->chunk, stream->chunksalloc * sizeof(stream->chunk[0])); free(stream->chunk); @@ -818,9 +818,9 @@ INLINE avi_error expand_tempbuffer(avi_file *file, UINT32 length) { file->tempbuffersize = 2 * length; UINT8 *newbuffer = (UINT8 *)malloc(file->tempbuffersize); - if (newbuffer == NULL) + if (newbuffer == nullptr) return AVIERR_NO_MEMORY; - if (file->tempbuffer != NULL) + if (file->tempbuffer != nullptr) free(file->tempbuffer); file->tempbuffer = newbuffer; } @@ -850,14 +850,14 @@ INLINE avi_error expand_tempbuffer(avi_file *file, UINT32 length) avi_error avi_open(const char *filename, avi_file **file) { - avi_file *newfile = NULL; + avi_file *newfile = nullptr; file_error filerr; avi_error avierr; UINT64 length; /* allocate the file */ newfile = (avi_file *)malloc(sizeof(*newfile)); - if (newfile == NULL) + if (newfile == nullptr) return AVIERR_NO_MEMORY; memset(newfile, 0, sizeof(*newfile)); newfile->type = FILETYPE_READ; @@ -886,9 +886,9 @@ avi_error avi_open(const char *filename, avi_file **file) error: /* clean up after an error */ - if (newfile != NULL) + if (newfile != nullptr) { - if (newfile->file != NULL) + if (newfile->file != nullptr) osd_close(newfile->file); free(newfile); } @@ -914,7 +914,7 @@ error: avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file **file) { - avi_file *newfile = NULL; + avi_file *newfile = nullptr; file_error filerr; avi_stream *stream; avi_error avierr; @@ -935,7 +935,7 @@ avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file /* allocate the file */ newfile = (avi_file *)malloc(sizeof(*newfile)); - if (newfile == NULL) + if (newfile == nullptr) return AVIERR_NO_MEMORY; memset(newfile, 0, sizeof(*newfile)); newfile->type = FILETYPE_CREATE; @@ -955,7 +955,7 @@ avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file /* allocate two streams */ newfile->stream = (avi_stream *)malloc(2 * sizeof(newfile->stream[0])); - if (newfile->stream == NULL) + if (newfile->stream == nullptr) { avierr = AVIERR_NO_MEMORY; goto error; @@ -1000,11 +1000,11 @@ avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file error: /* clean up after an error */ - if (newfile != NULL) + if (newfile != nullptr) { - if (newfile->stream != NULL) + if (newfile->stream != nullptr) free(newfile->stream); - if (newfile->file != NULL) + if (newfile->file != nullptr) { osd_close(newfile->file); osd_rmfile(filename); @@ -1073,26 +1073,26 @@ avi_error avi_close(avi_file *file) for (strnum = 0; strnum < file->streams; strnum++) { avi_stream *stream = &file->stream[strnum]; - if (stream->huffyuv != NULL) + if (stream->huffyuv != nullptr) { huffyuv_data *huffyuv = stream->huffyuv; int table; for (table = 0; table < ARRAY_LENGTH(huffyuv->table); table++) - if (huffyuv->table[table].extralookup != NULL) + if (huffyuv->table[table].extralookup != nullptr) free(huffyuv->table[table].extralookup); free(huffyuv); } - if (stream->chunk != NULL) + if (stream->chunk != nullptr) free(stream->chunk); } /* free the file itself */ - if (file->soundbuf != NULL) + if (file->soundbuf != nullptr) free(file->soundbuf); - if (file->stream != NULL) + if (file->stream != nullptr) free(file->stream); - if (file->tempbuffer != NULL) + if (file->tempbuffer != nullptr) free(file->tempbuffer); free(file); return avierr; @@ -1228,7 +1228,7 @@ avi_error avi_read_video_frame(avi_file *file, UINT32 framenum, bitmap_yuy16 &bi /* get the video stream */ stream = get_video_stream(file); - if (stream == NULL) + if (stream == nullptr) return AVIERR_INVALID_STREAM; /* validate our ability to handle the data */ @@ -1301,7 +1301,7 @@ avi_error avi_read_sound_samples(avi_file *file, int channel, UINT32 firstsample /* get the audio stream */ stream = get_audio_stream(file, channel, &offset); - if (stream == NULL) + if (stream == nullptr) return AVIERR_INVALID_STREAM; /* validate our ability to handle the data */ @@ -1579,7 +1579,7 @@ static avi_error read_chunk_data(avi_file *file, const avi_chunk *chunk, UINT8 * /* allocate memory for the data */ *buffer = (UINT8 *)malloc(chunk->size); - if (*buffer == NULL) + if (*buffer == nullptr) return AVIERR_NO_MEMORY; /* read from the file */ @@ -1587,7 +1587,7 @@ static avi_error read_chunk_data(avi_file *file, const avi_chunk *chunk, UINT8 * if (filerr != FILERR_NONE || bytes_read != chunk->size) { free(*buffer); - *buffer = NULL; + *buffer = nullptr; return AVIERR_READ_ERROR; } @@ -1614,8 +1614,8 @@ static avi_error read_chunk_data(avi_file *file, const avi_chunk *chunk, UINT8 * static avi_error get_first_chunk(avi_file *file, const avi_chunk *parent, avi_chunk *newchunk) { - UINT64 startoffset = (parent != NULL && parent->type != 0) ? parent->offset + 12 : 0; - if (parent != NULL && parent->type != CHUNKTYPE_LIST && parent->type != CHUNKTYPE_RIFF && parent->type != 0) + UINT64 startoffset = (parent != nullptr && parent->type != 0) ? parent->offset + 12 : 0; + if (parent != nullptr && parent->type != CHUNKTYPE_LIST && parent->type != CHUNKTYPE_RIFF && parent->type != 0) return AVIERR_INVALID_DATA; return get_next_chunk_internal(file, parent, newchunk, startoffset); } @@ -1790,7 +1790,7 @@ static avi_error get_next_chunk_internal(avi_file *file, const avi_chunk *parent UINT32 bytesread; /* NULL parent implies the root */ - if (parent == NULL) + if (parent == nullptr) parent = &file->rootchunk; /* start at the current offset */ @@ -1843,7 +1843,7 @@ static avi_error read_movie_data(avi_file *file) int strindex; /* find the RIFF chunk */ - avierr = find_first_chunk(file, CHUNKTYPE_RIFF, NULL, &riff); + avierr = find_first_chunk(file, CHUNKTYPE_RIFF, nullptr, &riff); if (avierr != AVIERR_NONE) goto error; @@ -1954,7 +1954,7 @@ static avi_error extract_movie_info(avi_file *file) /* get the video stream */ stream = get_video_stream(file); - if (stream != NULL) + if (stream != nullptr) { /* fill in the info */ file->info.video_format = stream->format; @@ -1966,8 +1966,8 @@ static avi_error extract_movie_info(avi_file *file) } /* get the first audio stream */ - stream = get_audio_stream(file, 0, NULL); - if (stream != NULL) + stream = get_audio_stream(file, 0, nullptr); + if (stream != nullptr) { /* fill in the info */ file->info.audio_format = stream->format; @@ -1984,8 +1984,8 @@ static avi_error extract_movie_info(avi_file *file) while (1) { /* get the stream info */ - stream = get_audio_stream(file, file->info.audio_channels, NULL); - if (stream == NULL) + stream = get_audio_stream(file, file->info.audio_channels, nullptr); + if (stream == nullptr) break; file->info.audio_channels++; @@ -2021,7 +2021,7 @@ static avi_error extract_movie_info(avi_file *file) static avi_error parse_avih_chunk(avi_file *file, avi_chunk *avih) { - UINT8 *chunkdata = NULL; + UINT8 *chunkdata = nullptr; avi_error avierr; /* read the data */ @@ -2034,12 +2034,12 @@ static avi_error parse_avih_chunk(avi_file *file, avi_chunk *avih) /* allocate memory for the streams */ file->stream = (avi_stream *)malloc(sizeof(*file->stream) * file->streams); - if (file->stream == NULL) + if (file->stream == nullptr) goto error; memset(file->stream, 0, sizeof(*file->stream) * file->streams); error: - if (chunkdata != NULL) + if (chunkdata != nullptr) free(chunkdata); return avierr; } @@ -2064,7 +2064,7 @@ error: static avi_error parse_strh_chunk(avi_file *file, avi_stream *stream, avi_chunk *strh) { - UINT8 *chunkdata = NULL; + UINT8 *chunkdata = nullptr; avi_error avierr; /* read the data */ @@ -2079,7 +2079,7 @@ static avi_error parse_strh_chunk(avi_file *file, avi_stream *stream, avi_chunk stream->samples = fetch_32bits(&chunkdata[32]); error: - if (chunkdata != NULL) + if (chunkdata != nullptr) free(chunkdata); return avierr; } @@ -2104,7 +2104,7 @@ error: static avi_error parse_strf_chunk(avi_file *file, avi_stream *stream, avi_chunk *strf) { - UINT8 *chunkdata = NULL; + UINT8 *chunkdata = nullptr; avi_error avierr; /* read the data */ @@ -2136,7 +2136,7 @@ static avi_error parse_strf_chunk(avi_file *file, avi_stream *stream, avi_chunk } error: - if (chunkdata != NULL) + if (chunkdata != nullptr) free(chunkdata); return avierr; } @@ -2161,7 +2161,7 @@ error: static avi_error parse_indx_chunk(avi_file *file, avi_stream *stream, avi_chunk *strf) { UINT32 entries, entry; - UINT8 *chunkdata = NULL; + UINT8 *chunkdata = nullptr; UINT16 longs_per_entry; UINT8 type; UINT64 baseoffset; @@ -2238,7 +2238,7 @@ static avi_error parse_indx_chunk(avi_file *file, avi_stream *stream, avi_chunk } error: - if (chunkdata != NULL) + if (chunkdata != nullptr) free(chunkdata); return avierr; } @@ -2262,7 +2262,7 @@ error: static avi_error parse_idx1_chunk(avi_file *file, UINT64 baseoffset, avi_chunk *idx1) { - UINT8 *chunkdata = NULL; + UINT8 *chunkdata = nullptr; avi_error avierr; UINT32 entries; UINT32 entry; @@ -2300,7 +2300,7 @@ static avi_error parse_idx1_chunk(avi_file *file, UINT64 baseoffset, avi_chunk * } error: - if (chunkdata != NULL) + if (chunkdata != nullptr) free(chunkdata); return avierr; } @@ -2841,7 +2841,7 @@ static avi_error write_indx_chunk(avi_file *file, avi_stream *stream, int initia /* allocate memory */ tempbuf = (UINT8 *)malloc(24 + 8 * chunks_this_index); - if (tempbuf == NULL) + if (tempbuf == nullptr) return AVIERR_NO_MEMORY; memset(tempbuf, 0, 24 + 8 * chunks_this_index); @@ -2920,7 +2920,7 @@ static avi_error write_idx1_chunk(avi_file *file) /* allocate a temporary buffer */ tempbuf = (UINT8 *)malloc(tempbuflength); - if (tempbuf == NULL) + if (tempbuf == nullptr) return AVIERR_NO_MEMORY; /* fill it in */ @@ -2971,15 +2971,15 @@ static avi_error write_idx1_chunk(avi_file *file) static avi_error soundbuf_initialize(avi_file *file) { - avi_stream *audio = get_audio_stream(file, 0, NULL); + avi_stream *audio = get_audio_stream(file, 0, nullptr); avi_stream *video = get_video_stream(file); /* we require a video stream */ - if (video == NULL) + if (video == nullptr) return AVIERR_UNSUPPORTED_VIDEO_FORMAT; /* skip if no audio stream */ - if (audio == NULL) + if (audio == nullptr) return AVIERR_NONE; /* determine the number of samples we want in our buffer; 2 seconds should be enough */ @@ -2987,7 +2987,7 @@ static avi_error soundbuf_initialize(avi_file *file) /* allocate a buffer */ file->soundbuf = (INT16 *)malloc(file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); - if (file->soundbuf == NULL) + if (file->soundbuf == nullptr) return AVIERR_NO_MEMORY; memset(file->soundbuf, 0, file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); @@ -3015,12 +3015,12 @@ static avi_error soundbuf_initialize(avi_file *file) static avi_error soundbuf_write_chunk(avi_file *file, UINT32 framenum) { - avi_stream *stream = get_audio_stream(file, 0, NULL); + avi_stream *stream = get_audio_stream(file, 0, nullptr); avi_error avierr; UINT32 length; /* skip if no audio stream */ - if (stream == NULL) + if (stream == nullptr) return AVIERR_NONE; /* determine the length of this chunk */ @@ -3058,7 +3058,7 @@ static avi_error soundbuf_write_chunk(avi_file *file, UINT32 framenum) static avi_error soundbuf_flush(avi_file *file, int only_flush_full) { - avi_stream *stream = get_audio_stream(file, 0, NULL); + avi_stream *stream = get_audio_stream(file, 0, nullptr); INT32 channelsamples = file->soundbuf_samples; INT32 processedsamples = 0; UINT32 bytes_per_sample; @@ -3069,7 +3069,7 @@ static avi_error soundbuf_flush(avi_file *file, int only_flush_full) int channel; /* skip if no stream */ - if (stream == NULL) + if (stream == nullptr) return AVIERR_NONE; /* get the chunk ID for this stream */ @@ -3337,7 +3337,7 @@ static avi_error huffyuv_extract_tables(avi_stream *stream, const UINT8 *chunkda /* allocate memory for the data */ stream->huffyuv = (huffyuv_data *)malloc(sizeof(*stream->huffyuv)); - if (stream->huffyuv == NULL) + if (stream->huffyuv == nullptr) { avierr = AVIERR_NO_MEMORY; goto error; @@ -3425,7 +3425,7 @@ static avi_error huffyuv_extract_tables(avi_stream *stream, const UINT8 *chunkda if (bitsat16 > 0) { table->extralookup = (UINT16 *)malloc(bitsat16 * 65536 * sizeof(table->extralookup[0])); - if (table->extralookup == NULL) + if (table->extralookup == nullptr) { avierr = AVIERR_NO_MEMORY; goto error; @@ -3454,10 +3454,10 @@ static avi_error huffyuv_extract_tables(avi_stream *stream, const UINT8 *chunkda } error: - if (avierr != AVIERR_NONE && stream->huffyuv != NULL) + if (avierr != AVIERR_NONE && stream->huffyuv != nullptr) { free(stream->huffyuv); - stream->huffyuv = NULL; + stream->huffyuv = nullptr; } return avierr; } @@ -3759,7 +3759,7 @@ static void printf_chunk_recursive(avi_file *file, avi_chunk *container, int ind /* print data within the chunk */ if (chunksize > 0 && curchunk.size < 1024 * 1024) { - UINT8 *data = NULL; + UINT8 *data = nullptr; int i; /* read the data for a chunk */ diff --git a/src/lib/util/bitmap.cpp b/src/lib/util/bitmap.cpp index aeb9852ca1c..2436e474136 100644 --- a/src/lib/util/bitmap.cpp +++ b/src/lib/util/bitmap.cpp @@ -77,11 +77,11 @@ inline void bitmap_t::compute_base(int xslop, int yslop) */ bitmap_t::bitmap_t(bitmap_format format, int bpp, int width, int height, int xslop, int yslop) - : m_alloc(NULL), + : m_alloc(nullptr), m_allocbytes(0), m_format(format), m_bpp(bpp), - m_palette(NULL) + m_palette(nullptr) { // allocate intializes all other fields allocate(width, height, xslop, yslop); @@ -101,7 +101,7 @@ bitmap_t::bitmap_t(bitmap_format format, int bpp, int width, int height, int xsl */ bitmap_t::bitmap_t(bitmap_format format, int bpp, void *base, int width, int height, int rowpixels) - : m_alloc(NULL), + : m_alloc(nullptr), m_allocbytes(0), m_base(base), m_rowpixels(rowpixels), @@ -109,7 +109,7 @@ bitmap_t::bitmap_t(bitmap_format format, int bpp, void *base, int width, int hei m_height(height), m_format(format), m_bpp(bpp), - m_palette(NULL), + m_palette(nullptr), m_cliprect(0, width - 1, 0, height - 1) { } @@ -126,7 +126,7 @@ bitmap_t::bitmap_t(bitmap_format format, int bpp, void *base, int width, int hei */ bitmap_t::bitmap_t(bitmap_format format, int bpp, bitmap_t &source, const rectangle &subrect) - : m_alloc(NULL), + : m_alloc(nullptr), m_allocbytes(0), m_base(source.raw_pixptr(subrect.min_y, subrect.min_x)), m_rowpixels(source.m_rowpixels), @@ -134,7 +134,7 @@ bitmap_t::bitmap_t(bitmap_format format, int bpp, bitmap_t &source, const rectan m_height(subrect.height()), m_format(format), m_bpp(bpp), - m_palette(NULL), + m_palette(nullptr), m_cliprect(0, subrect.width() - 1, 0, subrect.height() - 1) { assert(format == source.m_format); @@ -258,10 +258,10 @@ void bitmap_t::resize(int width, int height, int xslop, int yslop) void bitmap_t::reset() { // delete any existing stuff - set_palette(NULL); + set_palette(nullptr); delete[] m_alloc; - m_alloc = NULL; - m_base = NULL; + m_alloc = nullptr; + m_base = nullptr; // reset all fields m_rowpixels = 0; @@ -339,14 +339,14 @@ void bitmap_t::wrap(const bitmap_t &source, const rectangle &subrect) void bitmap_t::set_palette(palette_t *palette) { // first dereference any existing palette - if (m_palette != NULL) + if (m_palette != nullptr) { m_palette->deref(); - m_palette = NULL; + m_palette = nullptr; } // then reference any new palette - if (palette != NULL) + if (palette != nullptr) { palette->ref(); m_palette = palette; diff --git a/src/lib/util/bitmap.h b/src/lib/util/bitmap.h index 91d693124e1..23d05af90df 100644 --- a/src/lib/util/bitmap.h +++ b/src/lib/util/bitmap.h @@ -141,7 +141,7 @@ public: INT32 rowbytes() const { return m_rowpixels * m_bpp / 8; } UINT8 bpp() const { return m_bpp; } bitmap_format format() const { return m_format; } - bool valid() const { return (m_base != NULL); } + bool valid() const { return (m_base != nullptr); } palette_t *palette() const { return m_palette; } const rectangle &cliprect() const { return m_cliprect; } diff --git a/src/lib/util/cdrom.cpp b/src/lib/util/cdrom.cpp index e3cb14e8f0c..917cb355839 100644 --- a/src/lib/util/cdrom.cpp +++ b/src/lib/util/cdrom.cpp @@ -225,8 +225,8 @@ cdrom_file *cdrom_open(const char *inputfile) /* allocate memory for the CD-ROM file */ file = new cdrom_file(); - if (file == NULL) - return NULL; + if (file == nullptr) + return nullptr; /* setup the CDROM module and get the disc info */ chd_error err = chdcd_parse_toc(inputfile, file->cdtoc, file->track_info); @@ -234,11 +234,11 @@ cdrom_file *cdrom_open(const char *inputfile) { fprintf(stderr, "Error reading input file: %s\n", chd_file::error_string(err)); delete file; - return NULL; + return nullptr; } /* fill in the data */ - file->chd = NULL; + file->chd = nullptr; LOG(("CD has %d tracks\n", file->cdtoc.numtrks)); @@ -249,7 +249,7 @@ cdrom_file *cdrom_open(const char *inputfile) { fprintf(stderr, "Unable to open file: %s\n", file->track_info.track[i].fname.c_str()); cdrom_close(file); - return NULL; + return nullptr; } } /* calculate the starting frame for each track, keeping in mind that CHDMAN @@ -322,18 +322,18 @@ cdrom_file *cdrom_open(chd_file *chd) /* punt if no CHD */ if (!chd) - return NULL; + return nullptr; /* validate the CHD information */ if (chd->hunk_bytes() % CD_FRAME_SIZE != 0) - return NULL; + return nullptr; if (chd->unit_bytes() != CD_FRAME_SIZE) - return NULL; + return nullptr; /* allocate memory for the CD-ROM file */ file = new cdrom_file(); - if (file == NULL) - return NULL; + if (file == nullptr) + return nullptr; /* fill in the data */ file->chd = chd; @@ -343,7 +343,7 @@ cdrom_file *cdrom_open(chd_file *chd) if (err != CHDERR_NONE) { delete file; - return NULL; + return nullptr; } LOG(("CD has %d tracks\n", file->cdtoc.numtrks)); @@ -411,10 +411,10 @@ cdrom_file *cdrom_open(chd_file *chd) void cdrom_close(cdrom_file *file) { - if (file == NULL) + if (file == nullptr) return; - if (file->chd == NULL) + if (file->chd == nullptr) { for (int i = 0; i < file->cdtoc.numtrks; i++) { @@ -461,7 +461,7 @@ chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UI } // if a CHD, just read - if (file->chd != NULL) + if (file->chd != nullptr) { result = file->chd->read_bytes(UINT64(chdsector) * UINT64(CD_FRAME_SIZE) + startoffs, dest, length); /* swap CDDA in the case of LE GDROMs */ @@ -521,7 +521,7 @@ chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UI UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32 datatype, bool phys) { - if (file == NULL) + if (file == nullptr) return 0; // compute CHD sector and tracknumber @@ -606,7 +606,7 @@ UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32 UINT32 cdrom_read_subcode(cdrom_file *file, UINT32 lbasector, void *buffer, bool phys) { - if (file == NULL) + if (file == nullptr) return ~0; // compute CHD sector and tracknumber @@ -656,7 +656,7 @@ UINT32 cdrom_get_track(cdrom_file *file, UINT32 frame) { UINT32 track = 0; - if (file == NULL) + if (file == nullptr) return ~0; /* convert to a CHD sector offset and get track information */ @@ -684,7 +684,7 @@ UINT32 cdrom_get_track(cdrom_file *file, UINT32 frame) UINT32 cdrom_get_track_start(cdrom_file *file, UINT32 track) { - if (file == NULL) + if (file == nullptr) return ~0; /* handle lead-out specially */ @@ -712,7 +712,7 @@ UINT32 cdrom_get_track_start(cdrom_file *file, UINT32 track) UINT32 cdrom_get_track_start_phys(cdrom_file *file, UINT32 track) { - if (file == NULL) + if (file == nullptr) return ~0; /* handle lead-out specially */ @@ -743,7 +743,7 @@ UINT32 cdrom_get_track_start_phys(cdrom_file *file, UINT32 track) int cdrom_get_last_track(cdrom_file *file) { - if (file == NULL) + if (file == nullptr) return -1; return file->cdtoc.numtrks; @@ -768,7 +768,7 @@ int cdrom_get_last_track(cdrom_file *file) int cdrom_get_adr_control(cdrom_file *file, int track) { - if (file == NULL) + if (file == nullptr) return -1; if (track == 0xaa || file->cdtoc.tracks[track].trktype == CD_TRACK_AUDIO) @@ -797,7 +797,7 @@ int cdrom_get_adr_control(cdrom_file *file, int track) int cdrom_get_track_type(cdrom_file *file, int track) { - if (file == NULL) + if (file == nullptr) return -1; return file->cdtoc.tracks[track].trktype; @@ -821,8 +821,8 @@ int cdrom_get_track_type(cdrom_file *file, int track) const cdrom_toc *cdrom_get_toc(cdrom_file *file) { - if (file == NULL) - return NULL; + if (file == nullptr) + return nullptr; return &file->cdtoc; } diff --git a/src/lib/util/chd.cpp b/src/lib/util/chd.cpp index 07e98d03b85..9f1b79081c5 100644 --- a/src/lib/util/chd.cpp +++ b/src/lib/util/chd.cpp @@ -186,7 +186,7 @@ inline void chd_file::be_write_sha1(UINT8 *base, sha1_t value) inline void chd_file::file_read(UINT64 offset, void *dest, UINT32 length) { // no file = failure - if (m_file == NULL) + if (m_file == nullptr) throw CHDERR_NOT_OPEN; // seek and read @@ -205,7 +205,7 @@ inline void chd_file::file_read(UINT64 offset, void *dest, UINT32 length) inline void chd_file::file_write(UINT64 offset, const void *source, UINT32 length) { // no file = failure - if (m_file == NULL) + if (m_file == nullptr) throw CHDERR_NOT_OPEN; // seek and write @@ -225,7 +225,7 @@ inline void chd_file::file_write(UINT64 offset, const void *source, UINT32 lengt inline UINT64 chd_file::file_append(const void *source, UINT32 length, UINT32 alignment) { // no file = failure - if (m_file == NULL) + if (m_file == nullptr) throw CHDERR_NOT_OPEN; // seek to the end and align if necessary @@ -288,7 +288,7 @@ inline UINT8 chd_file::bits_for_value(UINT64 value) */ chd_file::chd_file() - : m_file(NULL), + : m_file(nullptr), m_owns_file(false) { // reset state @@ -554,7 +554,7 @@ void chd_file::set_raw_sha1(sha1_t rawdata) void chd_file::set_parent_sha1(sha1_t parent) { // if no file, fail - if (m_file == NULL) + if (m_file == nullptr) throw CHDERR_INVALID_FILE; // create a big-endian version @@ -585,7 +585,7 @@ void chd_file::set_parent_sha1(sha1_t parent) chd_error chd_file::create(core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4]) { // make sure we don't already have a file open - if (m_file != NULL) + if (m_file != nullptr) return CHDERR_ALREADY_OPEN; // set the header parameters @@ -593,7 +593,7 @@ chd_error chd_file::create(core_file &file, UINT64 logicalbytes, UINT32 hunkbyte m_hunkbytes = hunkbytes; m_unitbytes = unitbytes; memcpy(m_compression, compression, sizeof(m_compression)); - m_parent = NULL; + m_parent = nullptr; // take ownership of the file m_file = &file; @@ -620,7 +620,7 @@ chd_error chd_file::create(core_file &file, UINT64 logicalbytes, UINT32 hunkbyte chd_error chd_file::create(core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent) { // make sure we don't already have a file open - if (m_file != NULL) + if (m_file != nullptr) return CHDERR_ALREADY_OPEN; // set the header parameters @@ -655,11 +655,11 @@ chd_error chd_file::create(core_file &file, UINT64 logicalbytes, UINT32 hunkbyte chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4]) { // make sure we don't already have a file open - if (m_file != NULL) + if (m_file != nullptr) return CHDERR_ALREADY_OPEN; // create the new file - core_file *file = NULL; + core_file *file = nullptr; file_error filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file); if (filerr != FILERR_NONE) return CHDERR_FILE_NOT_FOUND; @@ -696,11 +696,11 @@ chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hun chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent) { // make sure we don't already have a file open - if (m_file != NULL) + if (m_file != nullptr) return CHDERR_ALREADY_OPEN; // create the new file - core_file *file = NULL; + core_file *file = nullptr; file_error filerr = core_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file); if (filerr != FILERR_NONE) return CHDERR_FILE_NOT_FOUND; @@ -735,12 +735,12 @@ chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hun chd_error chd_file::open(const char *filename, bool writeable, chd_file *parent) { // make sure we don't already have a file open - if (m_file != NULL) + if (m_file != nullptr) return CHDERR_ALREADY_OPEN; // open the file UINT32 openflags = writeable ? (OPEN_FLAG_READ | OPEN_FLAG_WRITE) : OPEN_FLAG_READ; - core_file *file = NULL; + core_file *file = nullptr; file_error filerr = core_fopen(filename, openflags, &file); if (filerr != FILERR_NONE) return CHDERR_FILE_NOT_FOUND; @@ -775,7 +775,7 @@ chd_error chd_file::open(const char *filename, bool writeable, chd_file *parent) chd_error chd_file::open(core_file &file, bool writeable, chd_file *parent) { // make sure we don't already have a file open - if (m_file != NULL) + if (m_file != nullptr) return CHDERR_ALREADY_OPEN; // open the file @@ -796,9 +796,9 @@ chd_error chd_file::open(core_file &file, bool writeable, chd_file *parent) void chd_file::close() { // reset file characteristics - if (m_owns_file && m_file != NULL) + if (m_owns_file && m_file != nullptr) core_fclose(m_file); - m_file = NULL; + m_file = nullptr; m_owns_file = false; m_allow_reads = false; m_allow_writes = false; @@ -813,7 +813,7 @@ void chd_file::close() m_unitbytes = 0; m_unitcount = 0; memset(m_compression, 0, sizeof(m_compression)); - m_parent = NULL; + m_parent = nullptr; m_parent_missing = false; // reset key offsets within the header @@ -828,10 +828,10 @@ void chd_file::close() m_rawmap.clear(); // reset compression management - for (int decompnum = 0; decompnum < ARRAY_LENGTH(m_decompressor); decompnum++) + for (auto & elem : m_decompressor) { - delete m_decompressor[decompnum]; - m_decompressor[decompnum] = NULL; + delete elem; + elem = nullptr; } m_compressed.clear(); @@ -869,7 +869,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer) try { // punt if no file - if (m_file == NULL) + if (m_file == nullptr) throw CHDERR_NOT_OPEN; // return an error if out of range @@ -896,7 +896,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer) blocklen = be_read(&rawmap[12], 2) + (rawmap[14] << 16); file_read(blockoffs, &m_compressed[0], blocklen); m_decompressor[0]->decompress(&m_compressed[0], blocklen, dest, m_hunkbytes); - if (!(rawmap[15] & V34_MAP_ENTRY_FLAG_NO_CRC) && dest != NULL && crc32_creator::simple(dest, m_hunkbytes) != blockcrc) + if (!(rawmap[15] & V34_MAP_ENTRY_FLAG_NO_CRC) && dest != nullptr && crc32_creator::simple(dest, m_hunkbytes) != blockcrc) throw CHDERR_DECOMPRESSION_ERROR; return CHDERR_NONE; @@ -936,7 +936,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer) file_read(blockoffs, dest, m_hunkbytes); else if (m_parent_missing) throw CHDERR_REQUIRES_PARENT; - else if (m_parent != NULL) + else if (m_parent != nullptr) m_parent->read_hunk(hunknum, dest); else memset(dest, 0, m_hunkbytes); @@ -955,7 +955,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer) case COMPRESSION_TYPE_3: file_read(blockoffs, &m_compressed[0], blocklen); m_decompressor[rawmap[0]]->decompress(&m_compressed[0], blocklen, dest, m_hunkbytes); - if (!m_decompressor[rawmap[0]]->lossy() && dest != NULL && crc16_creator::simple(dest, m_hunkbytes) != blockcrc) + if (!m_decompressor[rawmap[0]]->lossy() && dest != nullptr && crc16_creator::simple(dest, m_hunkbytes) != blockcrc) throw CHDERR_DECOMPRESSION_ERROR; if (m_decompressor[rawmap[0]]->lossy() && crc16_creator::simple(&m_compressed[0], blocklen) != blockcrc) throw CHDERR_DECOMPRESSION_ERROR; @@ -1014,7 +1014,7 @@ chd_error chd_file::write_hunk(UINT32 hunknum, const void *buffer) try { // punt if no file - if (m_file == NULL) + if (m_file == nullptr) throw CHDERR_NOT_OPEN; // return an error if out of range @@ -1249,7 +1249,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex // read the metadata // TODO: how to properly allocate a dynamic char buffer? - char* metabuf = new char[metaentry.length+1]; + auto metabuf = new char[metaentry.length+1]; memset(metabuf, 0x00, metaentry.length+1); file_read(metaentry.offset + METADATA_HEADER_SIZE, metabuf, metaentry.length); output.assign(metabuf); @@ -2268,25 +2268,25 @@ chd_error chd_file::create_common() m_metaoffset = 0; // if we have a parent, it must be V3 or later - if (m_parent != NULL && m_parent->version() < 3) + if (m_parent != nullptr && m_parent->version() < 3) throw CHDERR_UNSUPPORTED_VERSION; // must be an even number of units per hunk if (m_hunkbytes % m_unitbytes != 0) throw CHDERR_INVALID_PARAMETER; - if (m_parent != NULL && m_unitbytes != m_parent->unit_bytes()) + if (m_parent != nullptr && m_unitbytes != m_parent->unit_bytes()) throw CHDERR_INVALID_PARAMETER; // verify the compression types bool found_zero = false; - for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compression); codecnum++) + for (auto & elem : m_compression) { // once we hit an empty slot, all later slots must be empty as well - if (m_compression[codecnum] == CHD_CODEC_NONE) + if (elem == CHD_CODEC_NONE) found_zero = true; else if (found_zero) throw CHDERR_INVALID_PARAMETER; - else if (!chd_codec_list::codec_exists(m_compression[codecnum])) + else if (!chd_codec_list::codec_exists(elem)) throw CHDERR_UNKNOWN_COMPRESSION; } @@ -2306,7 +2306,7 @@ chd_error chd_file::create_common() be_write(&rawheader[60], m_unitbytes, 4); be_write_sha1(&rawheader[64], sha1_t::null); be_write_sha1(&rawheader[84], sha1_t::null); - be_write_sha1(&rawheader[104], (m_parent != NULL) ? m_parent->sha1() : sha1_t::null); + be_write_sha1(&rawheader[104], (m_parent != nullptr) ? m_parent->sha1() : sha1_t::null); // write the resulting header file_write(0, rawheader, sizeof(rawheader)); @@ -2412,12 +2412,12 @@ chd_error chd_file::open_common(bool writeable) // make sure we have a parent if we need one (and don't if we don't) if (parentsha1 != sha1_t::null) { - if (m_parent == NULL) + if (m_parent == nullptr) m_parent_missing = true; else if (m_parent->sha1() != parentsha1) throw CHDERR_INVALID_PARENT; } - else if (m_parent != NULL) + else if (m_parent != nullptr) throw CHDERR_INVALID_PARAMETER; // finish opening the file @@ -2450,7 +2450,7 @@ void chd_file::create_open_common() for (int decompnum = 0; decompnum < ARRAY_LENGTH(m_compression); decompnum++) { m_decompressor[decompnum] = chd_codec_list::new_decompressor(m_compression[decompnum], *this); - if (m_decompressor[decompnum] == NULL && m_compression[decompnum] != 0) + if (m_decompressor[decompnum] == nullptr && m_compression[decompnum] != 0) throw CHDERR_UNKNOWN_COMPRESSION; } @@ -2488,7 +2488,7 @@ void chd_file::create_open_common() void chd_file::verify_proper_compression_append(UINT32 hunknum) { // punt if no file - if (m_file == NULL) + if (m_file == nullptr) throw CHDERR_NOT_OPEN; // return an error if out of range @@ -2751,11 +2751,11 @@ chd_file_compressor::chd_file_compressor() : m_walking_parent(false), m_total_in(0), m_total_out(0), - m_read_queue(NULL), + m_read_queue(nullptr), m_read_queue_offset(0), m_read_done_offset(0), m_read_error(false), - m_work_queue(NULL), + m_work_queue(nullptr), m_write_hunk(0) { // zap arrays @@ -2781,8 +2781,8 @@ chd_file_compressor::~chd_file_compressor() osd_work_queue_free(m_work_queue); // delete allocated arrays - for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_codecs); codecnum++) - delete m_codecs[codecnum]; + for (auto & elem : m_codecs) + delete elem; } /** @@ -2796,7 +2796,7 @@ chd_file_compressor::~chd_file_compressor() void chd_file_compressor::compress_begin() { // reset state - m_walking_parent = (m_parent != NULL); + m_walking_parent = (m_parent != nullptr); m_total_in = 0; m_total_out = 0; m_compsha1.reset(); @@ -2824,10 +2824,10 @@ void chd_file_compressor::compress_begin() } // initialize codec instances - for (int instance = 0; instance < ARRAY_LENGTH(m_codecs); instance++) + for (auto & elem : m_codecs) { - delete m_codecs[instance]; - m_codecs[instance] = new chd_compressor_group(*this, m_compression); + delete elem; + elem = new chd_compressor_group(*this, m_compression); } // reset write state @@ -2886,9 +2886,9 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio work_item &item = m_work_item[m_write_hunk % WORK_BUFFER_HUNKS]; // free any OSD work item - if (item.m_osd != NULL) + if (item.m_osd != nullptr) osd_work_item_release(item.m_osd); - item.m_osd = NULL; + item.m_osd = nullptr; // for parent walking, just add to the hashmap if (m_walking_parent) @@ -2929,7 +2929,7 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio } // if not, see if it's in the parent map - if (m_parent != NULL) + if (m_parent != nullptr) { UINT64 parentunit = m_parent_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1); if (parentunit != hashmap::NOT_FOUND) @@ -2958,8 +2958,8 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio m_walking_parent = false; m_read_queue_offset = m_read_done_offset = 0; m_write_hunk = 0; - for (int itemnum = 0; itemnum < WORK_BUFFER_HUNKS; itemnum++) - atomic_exchange32(&m_work_item[itemnum].m_status, WS_READY); + for (auto & elem : m_work_item) + atomic_exchange32(&elem.m_status, WS_READY); } // wait for all reads to finish and if we're compressed, write the final SHA1 and map @@ -2982,7 +2982,7 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio ratio = (m_total_in == 0) ? 1.0 : double(m_total_out) / double(m_total_in); // if we're waiting for work, wait - while (m_work_item[m_write_hunk % WORK_BUFFER_HUNKS].m_status != WS_COMPLETE && m_work_item[m_write_hunk % WORK_BUFFER_HUNKS].m_osd != NULL) + while (m_work_item[m_write_hunk % WORK_BUFFER_HUNKS].m_status != WS_COMPLETE && m_work_item[m_write_hunk % WORK_BUFFER_HUNKS].m_osd != nullptr) osd_work_item_wait(m_work_item[m_write_hunk % WORK_BUFFER_HUNKS].m_osd, osd_ticks_per_second()); return m_walking_parent ? CHDERR_WALKING_PARENT : CHDERR_COMPRESSING; @@ -3005,7 +3005,7 @@ void *chd_file_compressor::async_walk_parent_static(void *param, int threadid) { work_item *item = reinterpret_cast(param); item->m_compressor->async_walk_parent(*item); - return NULL; + return nullptr; } /** @@ -3047,7 +3047,7 @@ void *chd_file_compressor::async_compress_hunk_static(void *param, int threadid) { work_item *item = reinterpret_cast(param); item->m_compressor->async_compress_hunk(*item, threadid); - return NULL; + return nullptr; } /** @@ -3096,7 +3096,7 @@ void chd_file_compressor::async_compress_hunk(work_item &item, int threadid) void *chd_file_compressor::async_read_static(void *param, int threadid) { reinterpret_cast(param)->async_read(); - return NULL; + return nullptr; } /** @@ -3189,7 +3189,7 @@ void chd_file_compressor::async_read() */ chd_file_compressor::hashmap::hashmap() - : m_block_list(new entry_block(NULL)) + : m_block_list(new entry_block(nullptr)) { // initialize the map to empty memset(m_map, 0, sizeof(m_map)); @@ -3220,7 +3220,7 @@ chd_file_compressor::hashmap::~hashmap() void chd_file_compressor::hashmap::reset() { // delete all the blocks - while (m_block_list->m_next != NULL) + while (m_block_list->m_next != nullptr) { entry_block *block = m_block_list; m_block_list = block->m_next; @@ -3248,7 +3248,7 @@ void chd_file_compressor::hashmap::reset() UINT64 chd_file_compressor::hashmap::find(crc16_t crc16, sha1_t sha1) { // look up the entry in the map - for (entry_t *entry = m_map[crc16]; entry != NULL; entry = entry->m_next) + for (entry_t *entry = m_map[crc16]; entry != nullptr; entry = entry->m_next) if (entry->m_sha1 == sha1) return entry->m_itemnum; return NOT_FOUND; diff --git a/src/lib/util/chd.h b/src/lib/util/chd.h index d767c0889e0..114a29a5b5e 100644 --- a/src/lib/util/chd.h +++ b/src/lib/util/chd.h @@ -307,7 +307,7 @@ public: operator core_file *() { return m_file; } // getters - bool opened() const { return (m_file != NULL); } + bool opened() const { return (m_file != nullptr); } UINT32 version() const { return m_version; } UINT64 logical_bytes() const { return m_logicalbytes; } UINT32 hunk_bytes() const { return m_hunkbytes; } @@ -333,8 +333,8 @@ public: chd_error create(core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent); // file open - chd_error open(const char *filename, bool writeable = false, chd_file *parent = NULL); - chd_error open(core_file &file, bool writeable = false, chd_file *parent = NULL); + chd_error open(const char *filename, bool writeable = false, chd_file *parent = nullptr); + chd_error open(core_file &file, bool writeable = false, chd_file *parent = nullptr); // file close void close(); @@ -519,14 +519,14 @@ private: struct work_item { work_item() - : m_osd(NULL) - , m_compressor(NULL) + : m_osd(nullptr) + , m_compressor(nullptr) , m_status(WS_READY) - , m_data(NULL) - , m_compressed(NULL) + , m_data(nullptr) + , m_compressed(nullptr) , m_complen(0) , m_compression(0) - , m_codecs(NULL) + , m_codecs(nullptr) { } osd_work_item * m_osd; // OSD work item running on this block diff --git a/src/lib/util/chdcd.cpp b/src/lib/util/chdcd.cpp index e267c613d1d..eeb196d242f 100644 --- a/src/lib/util/chdcd.cpp +++ b/src/lib/util/chdcd.cpp @@ -475,7 +475,7 @@ chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc &outtoc, chdcd_track_ infile = fopen(tocfname, "rb"); path = get_file_path(path); - if (infile == (FILE *)NULL) + if (infile == (FILE *)nullptr) { return CHDERR_FILE_NOT_FOUND; } @@ -657,7 +657,7 @@ chd_error chdcd_parse_iso(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i infile = fopen(tocfname, "rb"); path = get_file_path(path); - if (infile == (FILE *)NULL) + if (infile == (FILE *)nullptr) { return CHDERR_FILE_NOT_FOUND; } @@ -736,7 +736,7 @@ static chd_error chdcd_parse_gdi(const char *tocfname, cdrom_toc &outtoc, chdcd_ infile = fopen(tocfname, "rt"); path = get_file_path(path); - if (infile == (FILE *)NULL) + if (infile == (FILE *)nullptr) { return CHDERR_FILE_NOT_FOUND; } @@ -771,13 +771,13 @@ static chd_error chdcd_parse_gdi(const char *tocfname, cdrom_toc &outtoc, chdcd_ outtoc.tracks[trknum].subsize = 0; outtoc.tracks[trknum].pgsub = CD_SUB_NONE; - tok=strtok(NULL," "); + tok=strtok(nullptr," "); outtoc.tracks[trknum].physframeofs=atoi(tok); - tok=strtok(NULL," "); + tok=strtok(nullptr," "); trktype=atoi(tok); - tok=strtok(NULL," "); + tok=strtok(nullptr," "); trksize=atoi(tok); if(trktype==4 && trksize==2352) @@ -799,16 +799,16 @@ static chd_error chdcd_parse_gdi(const char *tocfname, cdrom_toc &outtoc, chdcd_ std::string name; - tok=strtok(NULL," "); + tok=strtok(nullptr," "); name = tok; if (tok[0]=='"') { do { - tok=strtok(NULL," "); - if (tok!=NULL) { + tok=strtok(nullptr," "); + if (tok!=nullptr) { name += " "; name += tok; } - } while(tok!=NULL && (strrchr(tok,'"')-tok !=(strlen(tok)-1))); + } while(tok!=nullptr && (strrchr(tok,'"')-tok !=(strlen(tok)-1))); strdelchr(name,'"'); } outinfo.track[trknum].fname.assign(path).append(name); @@ -869,7 +869,7 @@ chd_error chdcd_parse_cue(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i infile = fopen(tocfname, "rt"); path = get_file_path(path); - if (infile == (FILE *)NULL) + if (infile == (FILE *)nullptr) { return CHDERR_FILE_NOT_FOUND; } @@ -931,7 +931,7 @@ chd_error chdcd_parse_cue(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i { /* get the track number */ TOKENIZE - trknum = strtoul(token, NULL, 10) - 1; + trknum = strtoul(token, nullptr, 10) - 1; /* next token on the line is the track type */ TOKENIZE @@ -978,7 +978,7 @@ chd_error chdcd_parse_cue(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i /* get index number */ TOKENIZE - idx = strtoul(token, NULL, 10); + idx = strtoul(token, nullptr, 10); /* get index */ TOKENIZE @@ -1191,7 +1191,7 @@ chd_error chdcd_parse_toc(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i infile = fopen(tocfname, "rt"); path = get_file_path(path); - if (infile == (FILE *)NULL) + if (infile == (FILE *)nullptr) { return CHDERR_FILE_NOT_FOUND; } @@ -1241,7 +1241,7 @@ chd_error chdcd_parse_toc(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i if (token[0] == '#') { /* it's a decimal offset, use it */ - f = strtoul(&token[1], NULL, 10); + f = strtoul(&token[1], nullptr, 10); } else if (isdigit((UINT8)token[0])) { diff --git a/src/lib/util/chdcd.h b/src/lib/util/chdcd.h index be585aad87e..6adcf29ce7b 100644 --- a/src/lib/util/chdcd.h +++ b/src/lib/util/chdcd.h @@ -27,7 +27,7 @@ struct chdcd_track_input_entry struct chdcd_track_input_info { - void reset() { for (int i = 0; i < CD_MAX_TRACKS; i++) track[i].reset(); } + void reset() { for (auto & elem : track) elem.reset(); } chdcd_track_input_entry track[CD_MAX_TRACKS]; }; diff --git a/src/lib/util/chdcodec.cpp b/src/lib/util/chdcodec.cpp index 9f013609133..be1d2022cd7 100644 --- a/src/lib/util/chdcodec.cpp +++ b/src/lib/util/chdcodec.cpp @@ -67,7 +67,7 @@ public: ~chd_zlib_compressor(); // core functionality - virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); + virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override; private: // internal state @@ -87,7 +87,7 @@ public: ~chd_zlib_decompressor(); // core functionality - virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen); + virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override; private: // internal state @@ -127,7 +127,7 @@ public: ~chd_lzma_compressor(); // core functionality - virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); + virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override; // helpers static void configure_properties(CLzmaEncProps &props, UINT32 hunkbytes); @@ -150,7 +150,7 @@ public: ~chd_lzma_decompressor(); // core functionality - virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen); + virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override; private: // internal state @@ -169,7 +169,7 @@ public: chd_huffman_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy); // core functionality - virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); + virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override; private: // internal state @@ -187,7 +187,7 @@ public: chd_huffman_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy); // core functionality - virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen); + virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override; private: // internal state @@ -205,7 +205,7 @@ public: chd_flac_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy); // core functionality - virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); + virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override; // static helpers static UINT32 blocksize(UINT32 bytes); @@ -227,7 +227,7 @@ public: chd_flac_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy); // core functionality - virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen); + virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override; private: // internal state @@ -247,7 +247,7 @@ public: ~chd_cd_flac_compressor(); // core functionality - virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); + virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override; // static helpers static UINT32 blocksize(UINT32 bytes); @@ -273,7 +273,7 @@ public: ~chd_cd_flac_decompressor(); // core functionality - virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen); + virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override; private: // internal state @@ -304,7 +304,7 @@ public: } // core functionality - virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) + virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override { // determine header bytes UINT32 frames = srclen / CD_FRAME_SIZE; @@ -373,7 +373,7 @@ public: } // core functionality - virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) + virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override { // determine header bytes UINT32 frames = destlen / CD_FRAME_SIZE; @@ -424,7 +424,7 @@ public: chd_avhuff_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy); // core functionality - virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest); + virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override; private: // internal helpers @@ -446,8 +446,8 @@ public: chd_avhuff_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy); // core functionality - virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen); - virtual void configure(int param, void *config); + virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override; + virtual void configure(int param, void *config) override; private: // internal state @@ -560,7 +560,7 @@ chd_compressor *chd_codec_list::new_compressor(chd_codec_type type, chd_file &ch { // find in the list and construct the class const codec_entry *entry = find_in_list(type); - return (entry == NULL) ? NULL : (*entry->m_construct_compressor)(chd, chd.hunk_bytes(), entry->m_lossy); + return (entry == nullptr) ? nullptr : (*entry->m_construct_compressor)(chd, chd.hunk_bytes(), entry->m_lossy); } @@ -573,7 +573,7 @@ chd_decompressor *chd_codec_list::new_decompressor(chd_codec_type type, chd_file { // find in the list and construct the class const codec_entry *entry = find_in_list(type); - return (entry == NULL) ? NULL : (*entry->m_construct_decompressor)(chd, chd.hunk_bytes(), entry->m_lossy); + return (entry == nullptr) ? nullptr : (*entry->m_construct_decompressor)(chd, chd.hunk_bytes(), entry->m_lossy); } @@ -586,7 +586,7 @@ const char *chd_codec_list::codec_name(chd_codec_type type) { // find in the list and construct the class const codec_entry *entry = find_in_list(type); - return (entry == NULL) ? NULL : entry->m_name; + return (entry == nullptr) ? nullptr : entry->m_name; } @@ -598,10 +598,10 @@ const char *chd_codec_list::codec_name(chd_codec_type type) const chd_codec_list::codec_entry *chd_codec_list::find_in_list(chd_codec_type type) { // find in the list and construct the class - for (int listnum = 0; listnum < ARRAY_LENGTH(s_codec_list); listnum++) - if (s_codec_list[listnum].m_type == type) - return &s_codec_list[listnum]; - return NULL; + for (auto & elem : s_codec_list) + if (elem.m_type == type) + return &elem; + return nullptr; } @@ -624,11 +624,11 @@ chd_compressor_group::chd_compressor_group(chd_file &chd, UINT32 compressor_list // verify the compression types and initialize the codecs for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compressor); codecnum++) { - m_compressor[codecnum] = NULL; + m_compressor[codecnum] = nullptr; if (compressor_list[codecnum] != CHD_CODEC_NONE) { m_compressor[codecnum] = chd_codec_list::new_compressor(compressor_list[codecnum], chd); - if (m_compressor[codecnum] == NULL) + if (m_compressor[codecnum] == nullptr) throw CHDERR_UNKNOWN_COMPRESSION; #if CHDCODEC_VERIFY_COMPRESSION m_decompressor[codecnum] = chd_codec_list::new_decompressor(compressor_list[codecnum], chd); @@ -647,8 +647,8 @@ chd_compressor_group::chd_compressor_group(chd_file &chd, UINT32 compressor_list chd_compressor_group::~chd_compressor_group() { // delete the codecs and the test buffer - for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compressor); codecnum++) - delete m_compressor[codecnum]; + for (auto & elem : m_compressor) + delete elem; } @@ -664,7 +664,7 @@ INT8 chd_compressor_group::find_best_compressor(const UINT8 *src, UINT8 *compres complen = m_hunkbytes; INT8 compression = -1; for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compressor); codecnum++) - if (m_compressor[codecnum] != NULL) + if (m_compressor[codecnum] != nullptr) { // attempt to compress, swallowing errors try @@ -735,8 +735,8 @@ chd_zlib_allocator::chd_zlib_allocator() chd_zlib_allocator::~chd_zlib_allocator() { // free our memory - for (int memindex = 0; memindex < ARRAY_LENGTH(m_allocptr); memindex++) - delete[] m_allocptr[memindex]; + for (auto & elem : m_allocptr) + delete[] elem; } @@ -769,7 +769,7 @@ voidpf chd_zlib_allocator::fast_alloc(voidpf opaque, uInt items, uInt size) for (int scan = 0; scan < MAX_ZLIB_ALLOCS; scan++) { UINT32 *ptr = codec->m_allocptr[scan]; - if (ptr != NULL && size == *ptr) + if (ptr != nullptr && size == *ptr) { // set the low bit of the size so we don't match next time *ptr |= 1; @@ -780,7 +780,7 @@ voidpf chd_zlib_allocator::fast_alloc(voidpf opaque, uInt items, uInt size) // alloc a new one and put it into the list UINT32 *ptr = reinterpret_cast(new UINT8[size + sizeof(UINT32)]); for (int scan = 0; scan < MAX_ZLIB_ALLOCS; scan++) - if (codec->m_allocptr[scan] == NULL) + if (codec->m_allocptr[scan] == nullptr) { codec->m_allocptr[scan] = ptr; break; @@ -968,8 +968,8 @@ chd_lzma_allocator::chd_lzma_allocator() chd_lzma_allocator::~chd_lzma_allocator() { // free our memory - for (int memindex = 0; memindex < ARRAY_LENGTH(m_allocptr); memindex++) - delete[] m_allocptr[memindex]; + for (auto & elem : m_allocptr) + delete[] elem; } @@ -989,7 +989,7 @@ void *chd_lzma_allocator::fast_alloc(void *p, size_t size) for (int scan = 0; scan < MAX_LZMA_ALLOCS; scan++) { UINT32 *ptr = codec->m_allocptr[scan]; - if (ptr != NULL && size == *ptr) + if (ptr != nullptr && size == *ptr) { // set the low bit of the size so we don't match next time *ptr |= 1; @@ -1000,7 +1000,7 @@ void *chd_lzma_allocator::fast_alloc(void *p, size_t size) // alloc a new one and put it into the list UINT32 *ptr = reinterpret_cast(new UINT8[size + sizeof(UINT32)]); for (int scan = 0; scan < MAX_LZMA_ALLOCS; scan++) - if (codec->m_allocptr[scan] == NULL) + if (codec->m_allocptr[scan] == nullptr) { codec->m_allocptr[scan] = ptr; break; @@ -1019,7 +1019,7 @@ void *chd_lzma_allocator::fast_alloc(void *p, size_t size) void chd_lzma_allocator::fast_free(void *p, void *address) { - if (address == NULL) + if (address == nullptr) return; chd_lzma_allocator *codec = reinterpret_cast(p); @@ -1070,7 +1070,7 @@ UINT32 chd_lzma_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des { // allocate the encoder CLzmaEncHandle encoder = LzmaEnc_Create(&m_allocator); - if (encoder == NULL) + if (encoder == nullptr) throw CHDERR_COMPRESSION_ERROR; try @@ -1082,7 +1082,7 @@ UINT32 chd_lzma_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des // run it SizeT complen = srclen; - res = LzmaEnc_MemEncode(encoder, dest, &complen, src, srclen, 0, NULL, &m_allocator, &m_allocator); + res = LzmaEnc_MemEncode(encoder, dest, &complen, src, srclen, 0, nullptr, &m_allocator, &m_allocator); if (res != SZ_OK) throw CHDERR_COMPRESSION_ERROR; @@ -1645,7 +1645,7 @@ UINT32 chd_avhuff_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *d postinit(); // make sure short frames are padded with 0 - if (src != NULL) + if (src != nullptr) { int size = avhuff_encoder::raw_data_size(src); while (size < srclen) @@ -1745,7 +1745,7 @@ void chd_avhuff_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 throw CHDERR_DECOMPRESSION_ERROR; // pad short frames with 0 - if (dest != NULL) + if (dest != nullptr) { int size = avhuff_encoder::raw_data_size(dest); if (size < destlen) diff --git a/src/lib/util/chdcodec.h b/src/lib/util/chdcodec.h index 144fba8641f..f517cdedeeb 100644 --- a/src/lib/util/chdcodec.h +++ b/src/lib/util/chdcodec.h @@ -108,7 +108,7 @@ public: static chd_decompressor *new_decompressor(chd_codec_type type, chd_file &file); // utilities - static bool codec_exists(chd_codec_type type) { return (find_in_list(type) != NULL); } + static bool codec_exists(chd_codec_type type) { return (find_in_list(type) != nullptr); } static const char *codec_name(chd_codec_type type); private: diff --git a/src/lib/util/corealloc.cpp b/src/lib/util/corealloc.cpp index a635803e463..9ca7af380d3 100644 --- a/src/lib/util/corealloc.cpp +++ b/src/lib/util/corealloc.cpp @@ -90,11 +90,11 @@ const zeromem_t zeromem = { }; // globals for memory_entry UINT64 memory_entry::s_curid = 1; -osd_lock *memory_entry::s_lock = NULL; +osd_lock *memory_entry::s_lock = nullptr; bool memory_entry::s_lock_alloc = false; bool memory_entry::s_tracking = false; -memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL }; -memory_entry *memory_entry::s_freehead = NULL; +memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { nullptr }; +memory_entry *memory_entry::s_freehead = nullptr; //************************************************************************** // OPERATOR REPLACEMENTS @@ -103,15 +103,15 @@ memory_entry *memory_entry::s_freehead = NULL; #ifndef NO_MEM_TRACKING // standard new/delete operators (try to avoid using) -void *operator new(std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, NULL, 0, false, true, false); } -void *operator new[](std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, NULL, 0, true, true, false); } -void operator delete(void *ptr) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, false); } -void operator delete[](void *ptr) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, true); } +void *operator new(std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, nullptr, 0, false, true, false); } +void *operator new[](std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, nullptr, 0, true, true, false); } +void operator delete(void *ptr) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, false); } +void operator delete[](void *ptr) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, true); } -void* operator new(std::size_t size,const std::nothrow_t&) throw() { return malloc_file_line(size, NULL, 0, false, false, false); } -void* operator new[](std::size_t size, const std::nothrow_t&) throw() { return malloc_file_line(size, NULL, 0, true, false, false); } -void operator delete(void* ptr, const std::nothrow_t&) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, false); } -void operator delete[](void* ptr, const std::nothrow_t&) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, true); } +void* operator new(std::size_t size,const std::nothrow_t&) throw() { return malloc_file_line(size, nullptr, 0, false, false, false); } +void* operator new[](std::size_t size, const std::nothrow_t&) throw() { return malloc_file_line(size, nullptr, 0, true, false, false); } +void operator delete(void* ptr, const std::nothrow_t&) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, false); } +void operator delete[](void* ptr, const std::nothrow_t&) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, true); } #endif @@ -122,14 +122,14 @@ void operator delete[](void* ptr, const std::nothrow_t&) throw() { if (ptr != NU // file/line new/delete operators void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc) { return malloc_file_line(size, file, line, false, true, false); } void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc) { return malloc_file_line(size, file, line, true, true, false); } -void operator delete(void *ptr, const char *file, int line) { if (ptr != NULL) free_file_line(ptr, file, line, false); } -void operator delete[](void *ptr, const char *file, int line) { if (ptr != NULL) free_file_line(ptr, file, line, true); } +void operator delete(void *ptr, const char *file, int line) { if (ptr != nullptr) free_file_line(ptr, file, line, false); } +void operator delete[](void *ptr, const char *file, int line) { if (ptr != nullptr) free_file_line(ptr, file, line, true); } // file/line new/delete operators with zeroing void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc) { return malloc_file_line(size, file, line, false, true, true); } void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc) { return malloc_file_line(size, file, line, true, true, true); } -void operator delete(void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != NULL) free_file_line(ptr, file, line, false); } -void operator delete[](void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != NULL) free_file_line(ptr, file, line, true); } +void operator delete(void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != nullptr) free_file_line(ptr, file, line, false); } +void operator delete[](void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != nullptr) free_file_line(ptr, file, line, true); } @@ -146,13 +146,13 @@ void *malloc_file_line(size_t size, const char *file, int line, bool array, bool { // allocate the memory and fail if we can't void *result = array ? osd_malloc_array(size) : osd_malloc(size); - if (result == NULL) + if (result == nullptr) { fprintf(stderr, "Failed to allocate %d bytes (%s:%d)\n", UINT32(size), file, line); osd_break_into_debugger("Failed to allocate RAM"); if (throw_on_fail) throw std::bad_alloc(); - return NULL; + return nullptr; } // zap the memory if requested @@ -183,7 +183,7 @@ void free_file_line(void *memory, const char *file, int line, bool array) memory_entry *entry = memory_entry::find(memory); // warn about untracked frees - if (entry == NULL) + if (entry == nullptr) { fprintf(stderr, "Error: attempt to free untracked memory %p in %s(%d)!\n", memory, file, line); osd_break_into_debugger("Error: attempt to free untracked memory"); @@ -267,7 +267,7 @@ void memory_entry::acquire_lock() { // allocate a lock on first usage // note that osd_lock_alloc() may re-enter this path, so protect against recursion! - if (s_lock == NULL) + if (s_lock == nullptr) { if (s_lock_alloc) return; @@ -298,14 +298,14 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, acquire_lock(); // if we're out of free entries, allocate a new chunk - if (s_freehead == NULL) + if (s_freehead == nullptr) { // create a new chunk, and fail if we can't memory_entry *entry = reinterpret_cast(osd_malloc_array(memory_block_alloc_chunk * sizeof(memory_entry))); - if (entry == NULL) + if (entry == nullptr) { release_lock(); - return NULL; + return nullptr; } // add all the entries to the list @@ -323,7 +323,7 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, // populate it entry->m_size = size; entry->m_base = base; - entry->m_file = s_tracking ? file : NULL; + entry->m_file = s_tracking ? file : nullptr; entry->m_line = s_tracking ? line : 0; entry->m_id = s_curid++; entry->m_array = array; @@ -333,9 +333,9 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, // add it to the alloc list int hashval = reinterpret_cast(base) % k_hash_prime; entry->m_next = s_hash[hashval]; - if (entry->m_next != NULL) + if (entry->m_next != nullptr) entry->m_next->m_prev = entry; - entry->m_prev = NULL; + entry->m_prev = nullptr; s_hash[hashval] = entry; release_lock(); @@ -350,15 +350,15 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, memory_entry *memory_entry::find(void *ptr) { // NULL maps to nothing - if (ptr == NULL) - return NULL; + if (ptr == nullptr) + return nullptr; // scan the list under the lock acquire_lock(); int hashval = reinterpret_cast(ptr) % k_hash_prime; memory_entry *entry; - for (entry = s_hash[hashval]; entry != NULL; entry = entry->m_next) + for (entry = s_hash[hashval]; entry != nullptr; entry = entry->m_next) if (entry->m_base == ptr) break; @@ -380,11 +380,11 @@ void memory_entry::release(memory_entry *entry, const char *file, int line) // remove ourselves from the alloc list int hashval = reinterpret_cast(entry->m_base) % k_hash_prime; - if (entry->m_prev != NULL) + if (entry->m_prev != nullptr) entry->m_prev->m_next = entry->m_next; else s_hash[hashval] = entry->m_next; - if (entry->m_next != NULL) + if (entry->m_next != nullptr) entry->m_next->m_prev = entry->m_prev; // add ourself to the free list @@ -411,9 +411,9 @@ void memory_entry::report_unfreed(UINT64 start) // check for leaked memory UINT32 total = 0; - for (int hashnum = 0; hashnum < k_hash_prime; hashnum++) - for (memory_entry *entry = s_hash[hashnum]; entry != NULL; entry = entry->m_next) - if (entry->m_file != NULL && entry->m_id >= start) + for (auto entry : s_hash) + for (; entry != nullptr; entry = entry->m_next) + if (entry->m_file != nullptr && entry->m_id >= start) { if (total == 0) fprintf(stderr, "--- memory leak warning ---\n"); diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp index 797805ac768..b7e389a35f7 100644 --- a/src/lib/util/corefile.cpp +++ b/src/lib/util/corefile.cpp @@ -126,7 +126,7 @@ file_error core_fopen(const char *filename, UINT32 openflags, core_file **file) /* allocate the file itself */ *file = (core_file *)malloc(sizeof(**file)); - if (*file == NULL) + if (*file == nullptr) return FILERR_OUT_OF_MEMORY; memset(*file, 0, sizeof(**file)); @@ -138,7 +138,7 @@ file_error core_fopen(const char *filename, UINT32 openflags, core_file **file) if (filerr != FILERR_NONE) { core_fclose(*file); - *file = NULL; + *file = nullptr; } return filerr; } @@ -160,7 +160,7 @@ static file_error core_fopen_ram_internal(const void *data, size_t length, int c /* allocate the file itself */ *file = (core_file *)malloc(sizeof(**file) + (copy_buffer ? length : 0)); - if (*file == NULL) + if (*file == nullptr) return FILERR_OUT_OF_MEMORY; memset(*file, 0, sizeof(**file)); @@ -210,11 +210,11 @@ file_error core_fopen_ram_copy(const void *data, size_t length, UINT32 openflags void core_fclose(core_file *file) { /* close files and free memory */ - if (file->zdata != NULL) + if (file->zdata != nullptr) core_fcompress(file, FCOMPRESS_NONE); - if (file->file != NULL) + if (file->file != nullptr) osd_close(file->file); - if (file->data != NULL && file->data_allocated) + if (file->data != nullptr && file->data_allocated) free(file->data); free(file); } @@ -235,7 +235,7 @@ file_error core_fcompress(core_file *file, int level) return FILERR_INVALID_ACCESS; /* if we have been compressing, flush and free the data */ - if (file->zdata != NULL && level == FCOMPRESS_NONE) + if (file->zdata != nullptr && level == FCOMPRESS_NONE) { int zerr = Z_OK; @@ -273,17 +273,17 @@ file_error core_fcompress(core_file *file, int level) /* free memory */ free(file->zdata); - file->zdata = NULL; + file->zdata = nullptr; } /* if we are just starting to compress, allocate a new buffer */ - if (file->zdata == NULL && level > FCOMPRESS_NONE) + if (file->zdata == nullptr && level > FCOMPRESS_NONE) { int zerr; /* allocate memory */ file->zdata = (zlib_data *)malloc(sizeof(*file->zdata)); - if (file->zdata == NULL) + if (file->zdata == nullptr) return FILERR_OUT_OF_MEMORY; memset(file->zdata, 0, sizeof(*file->zdata)); @@ -301,7 +301,7 @@ file_error core_fcompress(core_file *file, int level) if (zerr != Z_OK) { free(file->zdata); - file->zdata = NULL; + file->zdata = nullptr; return FILERR_OUT_OF_MEMORY; } @@ -331,7 +331,7 @@ int core_fseek(core_file *file, INT64 offset, int whence) int err = 0; /* error if compressing */ - if (file->zdata != NULL) + if (file->zdata != nullptr) return 1; /* flush any buffered char */ @@ -412,7 +412,7 @@ UINT32 core_fread(core_file *file, void *buffer, UINT32 length) file->back_char_tail = 0; /* handle real files */ - if (file->file && file->data == NULL) + if (file->file && file->data == nullptr) { /* if we're within the buffer, consume that first */ if (file->offset >= file->bufferbase && file->offset < file->bufferbase + file->bufferbytes) @@ -638,7 +638,7 @@ char *core_fgets(char *s, int n, core_file *file) /* if we put nothing in, return NULL */ if (cur == s) - return NULL; + return nullptr; /* otherwise, terminate */ if (n > 0) @@ -659,13 +659,13 @@ const void *core_fbuffer(core_file *file) UINT32 read_length; /* if we already have data, just return it */ - if (file->data != NULL || !file->length) + if (file->data != nullptr || !file->length) return file->data; /* allocate some memory */ file->data = (UINT8 *)malloc(file->length); - if (file->data == NULL) - return NULL; + if (file->data == nullptr) + return nullptr; file->data_allocated = TRUE; /* read the file */ @@ -673,13 +673,13 @@ const void *core_fbuffer(core_file *file) if (filerr != FILERR_NONE || read_length != file->length) { free(file->data); - file->data = NULL; - return NULL; + file->data = nullptr; + return nullptr; } /* close the file because we don't need it anymore */ osd_close(file->file); - file->file = NULL; + file->file = nullptr; return file->data; } @@ -692,7 +692,7 @@ const void *core_fbuffer(core_file *file) file_error core_fload(const char *filename, void **data, UINT32 *length) { - core_file *file = NULL; + core_file *file = nullptr; file_error err; UINT64 size; @@ -711,7 +711,7 @@ file_error core_fload(const char *filename, void **data, UINT32 *length) /* allocate memory */ *data = osd_malloc(size); - if (length != NULL) + if (length != nullptr) *length = (UINT32)size; /* read the data */ @@ -729,7 +729,7 @@ file_error core_fload(const char *filename, void **data, UINT32 *length) file_error core_fload(const char *filename, dynamic_buffer &data) { - core_file *file = NULL; + core_file *file = nullptr; file_error err; UINT64 size; @@ -777,7 +777,7 @@ UINT32 core_fwrite(core_file *file, const void *buffer, UINT32 length) UINT32 bytes_written = 0; /* can't write to RAM-based stuff */ - if (file->data != NULL) + if (file->data != nullptr) return 0; /* flush any buffered char */ @@ -978,7 +978,7 @@ static UINT32 safe_buffer_copy(const void *source, UINT32 sourceoffs, UINT32 sou static file_error osd_or_zlib_read(core_file *file, void *buffer, UINT64 offset, UINT32 length, UINT32 *actual) { /* if no compression, just pass through */ - if (file->zdata == NULL) + if (file->zdata == nullptr) return osd_read(file->file, buffer, offset, length, actual); /* if the offset doesn't match the next offset, fail */ @@ -1045,7 +1045,7 @@ static file_error osd_or_zlib_read(core_file *file, void *buffer, UINT64 offset, static file_error osd_or_zlib_write(core_file *file, const void *buffer, UINT64 offset, UINT32 length, UINT32 *actual) { /* if no compression, just pass through */ - if (file->zdata == NULL) + if (file->zdata == nullptr) return osd_write(file->file, buffer, offset, length, actual); /* if the offset doesn't match the next offset, fail */ diff --git a/src/lib/util/corestr.cpp b/src/lib/util/corestr.cpp index b4a75a3bc48..336d788cabb 100644 --- a/src/lib/util/corestr.cpp +++ b/src/lib/util/corestr.cpp @@ -114,11 +114,11 @@ int core_strwildcmp(const char *sp1, const char *sp2) char *core_strdup(const char *str) { - char *cpy = NULL; - if (str != NULL) + char *cpy = nullptr; + if (str != nullptr) { cpy = (char *)osd_malloc_array(strlen(str) + 1); - if (cpy != NULL) + if (cpy != nullptr) strcpy(cpy, str); } return cpy; @@ -261,18 +261,18 @@ void strdelchr(std::string& str, char chr) void strreplacechr(std::string& str, char ch, char newch) { - for (size_t i = 0; i < str.length(); i++) + for (auto & elem : str) { - if (str[i] == ch) str[i] = newch; + if (elem == ch) elem = newch; } } std::string strtrimspace(std::string& str) { int start = 0; - for (size_t i = 0; i < str.length(); i++) + for (auto & elem : str) { - if (!isspace(UINT8(str[i]))) break; + if (!isspace(UINT8(elem))) break; start++; } int end = str.length(); diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index 703eba077da..afbd3dcf9a1 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -42,8 +42,8 @@ class simple_list public: // construction/destruction simple_list() - : m_head(NULL), - m_tail(NULL), + : m_head(nullptr), + m_tail(nullptr), m_count(0) { } virtual ~simple_list() { reset(); } @@ -56,7 +56,7 @@ public: // remove (free) all objects in the list, leaving an empty list void reset() { - while (m_head != NULL) + while (m_head != nullptr) remove(*m_head); } @@ -65,7 +65,7 @@ public: { object.m_next = m_head; m_head = &object; - if (m_tail == NULL) + if (m_tail == nullptr) m_tail = m_head; m_count++; return object; @@ -81,7 +81,7 @@ public: _ElementType *head = list.detach_all(); tail->m_next = m_head; m_head = head; - if (m_tail == NULL) + if (m_tail == nullptr) m_tail = tail; m_count += count; } @@ -89,8 +89,8 @@ public: // add the given object to the tail of the list _ElementType &append(_ElementType &object) { - object.m_next = NULL; - if (m_tail != NULL) + object.m_next = nullptr; + if (m_tail != nullptr) m_tail = m_tail->m_next = &object; else m_tail = m_head = &object; @@ -106,7 +106,7 @@ public: return; _ElementType *tail = list.last(); _ElementType *head = list.detach_all(); - if (m_tail != NULL) + if (m_tail != nullptr) m_tail->m_next = head; else m_head = head; @@ -117,7 +117,7 @@ public: // insert the given object after a particular object (NULL means prepend) _ElementType &insert_after(_ElementType &object, _ElementType *insert_after) { - if (insert_after == NULL) + if (insert_after == nullptr) return prepend(object); object.m_next = insert_after->m_next; insert_after->m_next = &object; @@ -130,9 +130,9 @@ public: // insert the given object before a particular object (NULL means append) _ElementType &insert_before(_ElementType &object, _ElementType *insert_before) { - if (insert_before == NULL) + if (insert_before == nullptr) return append(object); - for (_ElementType **curptr = &m_head; *curptr != NULL; curptr = &(*curptr)->m_next) + for (_ElementType **curptr = &m_head; *curptr != nullptr; curptr = &(*curptr)->m_next) if (*curptr == insert_before) { object.m_next = insert_before; @@ -148,11 +148,11 @@ public: // replace an item in the list at the same location, and remove it _ElementType &replace_and_remove(_ElementType &object, _ElementType &toreplace) { - _ElementType *prev = NULL; - for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next) + _ElementType *prev = nullptr; + for (_ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next) if (cur == &toreplace) { - if (prev != NULL) + if (prev != nullptr) prev->m_next = &object; else m_head = &object; @@ -169,12 +169,12 @@ public: _ElementType *detach_head() { _ElementType *result = m_head; - if (result != NULL) + if (result != nullptr) { m_head = result->m_next; m_count--; - if (m_head == NULL) - m_tail = NULL; + if (m_head == nullptr) + m_tail = nullptr; } return result; } @@ -182,11 +182,11 @@ public: // detach the given item from the list, but don't free its memory _ElementType &detach(_ElementType &object) { - _ElementType *prev = NULL; - for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next) + _ElementType *prev = nullptr; + for (_ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next) if (cur == &object) { - if (prev != NULL) + if (prev != nullptr) prev->m_next = object.m_next; else m_head = object.m_next; @@ -202,7 +202,7 @@ public: _ElementType *detach_all() { _ElementType *result = m_head; - m_head = m_tail = NULL; + m_head = m_tail = nullptr; m_count = 0; return result; } @@ -216,17 +216,17 @@ public: // find an object by index in the list _ElementType *find(int index) const { - for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next) + for (_ElementType *cur = m_head; cur != nullptr; cur = cur->m_next) if (index-- == 0) return cur; - return NULL; + return nullptr; } // return the index of the given object in the list int indexof(const _ElementType &object) const { int index = 0; - for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next) + for (_ElementType *cur = m_head; cur != nullptr; cur = cur->m_next) { if (cur == &object) return index; @@ -256,7 +256,7 @@ public: // construction/destruction simple_list_wrapper(_ObjectType *object) - : m_next(NULL), + : m_next(nullptr), m_object(object) { } // operators @@ -294,13 +294,13 @@ public: _ItemType *alloc() { _ItemType *result = m_freelist.detach_head(); - if (result == NULL) + if (result == nullptr) result = global_alloc(_ItemType); return result; } // reclaim an item by adding it to the free list - void reclaim(_ItemType *item) { if (item != NULL) m_freelist.append(*item); } + void reclaim(_ItemType *item) { if (item != nullptr) m_freelist.append(*item); } void reclaim(_ItemType &item) { m_freelist.append(item); } // reclaim all items from a list diff --git a/src/lib/util/cstrpool.cpp b/src/lib/util/cstrpool.cpp index dfb41e25232..242c33380de 100644 --- a/src/lib/util/cstrpool.cpp +++ b/src/lib/util/cstrpool.cpp @@ -37,16 +37,16 @@ const char *const_string_pool::add(const char *string) return string; // scan to find space - for (pool_chunk *chunk = m_chunklist.first(); chunk != NULL; chunk = chunk->next()) + for (pool_chunk *chunk = m_chunklist.first(); chunk != nullptr; chunk = chunk->next()) { const char *result = chunk->add(string); - if (result != NULL) + if (result != nullptr) return result; } // no space anywhere, create a new pool and prepend it (so it gets used first) const char *result = m_chunklist.prepend(*global_alloc(pool_chunk)).add(string); - assert(result != NULL); + assert(result != nullptr); return result; } @@ -63,7 +63,7 @@ bool const_string_pool::contains(const char *string) return true; // scan to find it - for (pool_chunk *chunk = m_chunklist.first(); chunk != NULL; chunk = chunk->next()) + for (pool_chunk *chunk = m_chunklist.first(); chunk != nullptr; chunk = chunk->next()) if (chunk->contains(string)) return true; @@ -79,7 +79,7 @@ bool const_string_pool::contains(const char *string) */ const_string_pool::pool_chunk::pool_chunk() - : m_next(NULL), + : m_next(nullptr), m_used(0) { } @@ -104,7 +104,7 @@ const char *const_string_pool::pool_chunk::add(const char *string) // if too big, return NULL if (m_used + bytes > POOL_SIZE) - return NULL; + return nullptr; // allocate, copy, and return the memory char *dest = &m_buffer[m_used]; diff --git a/src/lib/util/delegate.h b/src/lib/util/delegate.h index 85a1628409c..ec10a5c268d 100644 --- a/src/lib/util/delegate.h +++ b/src/lib/util/delegate.h @@ -631,16 +631,16 @@ public: typedef MEMBER_ABI generic_static_func generic_member_func; // generic constructor delegate_base() - : m_function(NULL), - m_object(NULL), - m_name(NULL), - m_latebinder(NULL), - m_raw_function(NULL) { } + : m_function(nullptr), + m_object(nullptr), + m_name(nullptr), + m_latebinder(nullptr), + m_raw_function(nullptr) { } // copy constructor delegate_base(const delegate_base &src) : m_function(src.m_function), - m_object(NULL), + m_object(nullptr), m_name(src.m_name), m_latebinder(src.m_latebinder), m_raw_function(src.m_raw_function), @@ -652,7 +652,7 @@ public: // copy constructor with late bind delegate_base(const delegate_base &src, delegate_late_bind &object) : m_function(src.m_function), - m_object(NULL), + m_object(nullptr), m_name(src.m_name), m_latebinder(src.m_latebinder), m_raw_function(src.m_raw_function), @@ -664,12 +664,12 @@ public: // construct from member function with object pointer template delegate_base(typename traits<_FunctionClass>::member_func_type funcptr, const char *name, _FunctionClass *object) - : m_function(NULL), - m_object(NULL), + : m_function(nullptr), + m_object(nullptr), m_name(name), m_latebinder(&late_bind_helper<_FunctionClass>), - m_raw_function(NULL), - m_raw_mfp(funcptr, object, (_ReturnType *)0, (generic_static_func)0) + m_raw_function(nullptr), + m_raw_mfp(funcptr, object, (_ReturnType *)nullptr, (generic_static_func)nullptr) { bind(reinterpret_cast(object)); } @@ -678,7 +678,7 @@ public: template delegate_base(typename traits<_FunctionClass>::static_func_type funcptr, const char *name, _FunctionClass *object) : m_function(reinterpret_cast(funcptr)), - m_object(NULL), + m_object(nullptr), m_name(name), m_latebinder(&late_bind_helper<_FunctionClass>), m_raw_function(reinterpret_cast(funcptr)) @@ -690,7 +690,7 @@ public: template delegate_base(typename traits<_FunctionClass>::static_ref_func_type funcptr, const char *name, _FunctionClass *object) : m_function(reinterpret_cast(funcptr)), - m_object(NULL), + m_object(nullptr), m_name(name), m_latebinder(&late_bind_helper<_FunctionClass>), m_raw_function(reinterpret_cast(funcptr)) @@ -704,7 +704,7 @@ public: if (this != &src) { m_function = src.m_function; - m_object = NULL; + m_object = nullptr; m_name = src.m_name; m_latebinder = src.m_latebinder; m_raw_function = src.m_raw_function; @@ -744,11 +744,11 @@ public: _ReturnType operator()(_P1Type p1, _P2Type p2, _P3Type p3, _P4Type p4, _P5Type p5, _P6Type p6, _P7Type p7, _P8Type p8, _P9Type p9, _P10Type p10, _P11Type p11, _P12Type p12) const { DELEGATE_CALL((m_object, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); } // getters - bool has_object() const { return (object() != NULL); } + bool has_object() const { return (object() != nullptr); } const char *name() const { return m_name; } // helpers - bool isnull() const { return (m_raw_function == NULL && m_raw_mfp.isnull()); } + bool isnull() const { return (m_raw_function == nullptr && m_raw_mfp.isnull()); } bool is_mfp() const { return !m_raw_mfp.isnull(); } // late binding @@ -766,7 +766,7 @@ protected: static delegate_generic_class *late_bind_helper(delegate_late_bind &object) { _FunctionClass *result = dynamic_cast<_FunctionClass *>(&object); - if (result == NULL) { + if (result == nullptr) { throw binding_type_exception(typeid(_FunctionClass), typeid(object)); } return reinterpret_cast(result); @@ -778,7 +778,7 @@ protected: m_object = object; // if we're wrapping a member function pointer, handle special stuff - if (m_object != NULL && is_mfp()) + if (m_object != nullptr && is_mfp()) m_raw_mfp.update_after_bind(m_function, m_object); } diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp index 49fc667a184..f70ae709978 100644 --- a/src/lib/util/flac.cpp +++ b/src/lib/util/flac.cpp @@ -78,7 +78,7 @@ bool flac_encoder::reset() FLAC__stream_encoder_set_blocksize(m_encoder, m_block_size); // re-start processing - return (FLAC__stream_encoder_init_stream(m_encoder, write_callback_static, NULL, NULL, NULL, this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK); + return (FLAC__stream_encoder_init_stream(m_encoder, write_callback_static, nullptr, nullptr, nullptr, this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK); } @@ -91,7 +91,7 @@ bool flac_encoder::reset(void *buffer, UINT32 buflength) // configure the output m_compressed_start = reinterpret_cast(buffer); m_compressed_length = buflength; - m_file = NULL; + m_file = nullptr; return reset(); } @@ -103,7 +103,7 @@ bool flac_encoder::reset(void *buffer, UINT32 buflength) bool flac_encoder::reset(core_file &file) { // configure the output - m_compressed_start = NULL; + m_compressed_start = nullptr; m_compressed_length = 0; m_file = &file; return reset(); @@ -185,7 +185,7 @@ UINT32 flac_encoder::finish() { // process the data and return the amount written FLAC__stream_encoder_finish(m_encoder); - return (m_file != NULL) ? core_ftell(m_file) : m_compressed_offset; + return (m_file != nullptr) ? core_ftell(m_file) : m_compressed_offset; } @@ -197,13 +197,13 @@ void flac_encoder::init_common() { // allocate the encoder m_encoder = FLAC__stream_encoder_new(); - if (m_encoder == NULL) + if (m_encoder == nullptr) throw std::bad_alloc(); // initialize default state - m_file = NULL; + m_file = nullptr; m_compressed_offset = 0; - m_compressed_start = NULL; + m_compressed_start = nullptr; m_compressed_length = 0; m_sample_rate = 44100; m_channels = 2; @@ -251,7 +251,7 @@ FLAC__StreamEncoderWriteStatus flac_encoder::write_callback(const FLAC__byte buf else { int count = bytes - offset; - if (m_file != NULL) + if (m_file != nullptr) core_fwrite(m_file, buffer, count); else { @@ -277,11 +277,11 @@ FLAC__StreamEncoderWriteStatus flac_encoder::write_callback(const FLAC__byte buf flac_decoder::flac_decoder() : m_decoder(FLAC__stream_decoder_new()), - m_file(NULL), + m_file(nullptr), m_compressed_offset(0), - m_compressed_start(NULL), + m_compressed_start(nullptr), m_compressed_length(0), - m_compressed2_start(NULL), + m_compressed2_start(nullptr), m_compressed2_length(0) { } @@ -293,7 +293,7 @@ flac_decoder::flac_decoder() flac_decoder::flac_decoder(const void *buffer, UINT32 length, const void *buffer2, UINT32 length2) : m_decoder(FLAC__stream_decoder_new()), - m_file(NULL), + m_file(nullptr), m_compressed_offset(0), m_compressed_start(reinterpret_cast(buffer)), m_compressed_length(length), @@ -312,9 +312,9 @@ flac_decoder::flac_decoder(core_file &file) : m_decoder(FLAC__stream_decoder_new()), m_file(&file), m_compressed_offset(0), - m_compressed_start(NULL), + m_compressed_start(nullptr), m_compressed_length(0), - m_compressed2_start(NULL), + m_compressed2_start(nullptr), m_compressed2_length(0) { reset(); @@ -341,10 +341,10 @@ bool flac_decoder::reset() m_compressed_offset = 0; if (FLAC__stream_decoder_init_stream(m_decoder, &flac_decoder::read_callback_static, - NULL, + nullptr, &flac_decoder::tell_callback_static, - NULL, - NULL, + nullptr, + nullptr, &flac_decoder::write_callback_static, &flac_decoder::metadata_callback_static, &flac_decoder::error_callback_static, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK) @@ -359,7 +359,7 @@ bool flac_decoder::reset() bool flac_decoder::reset(const void *buffer, UINT32 length, const void *buffer2, UINT32 length2) { - m_file = NULL; + m_file = nullptr; m_compressed_start = reinterpret_cast(buffer); m_compressed_length = length; m_compressed2_start = reinterpret_cast(buffer2); @@ -401,7 +401,7 @@ bool flac_decoder::reset(UINT32 sample_rate, UINT8 num_channels, UINT32 block_si m_custom_header[0x14] = (sample_rate << 4) | ((num_channels - 1) << 1); // configure the header ahead of the provided buffer - m_file = NULL; + m_file = nullptr; m_compressed_start = reinterpret_cast(m_custom_header); m_compressed_length = sizeof(m_custom_header); m_compressed2_start = reinterpret_cast(buffer); @@ -417,9 +417,9 @@ bool flac_decoder::reset(UINT32 sample_rate, UINT8 num_channels, UINT32 block_si bool flac_decoder::reset(core_file &file) { m_file = &file; - m_compressed_start = NULL; + m_compressed_start = nullptr; m_compressed_length = 0; - m_compressed2_start = NULL; + m_compressed2_start = nullptr; m_compressed2_length = 0; return reset(); } @@ -510,7 +510,7 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s UINT32 expected = *bytes; // if a file, just read - if (m_file != NULL) + if (m_file != nullptr) *bytes = core_fread(m_file, buffer, expected); // otherwise, copy from memory @@ -589,7 +589,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame // interleaved case int shift = m_uncompressed_swap ? 8 : 0; int blocksize = frame->header.blocksize; - if (m_uncompressed_start[1] == NULL) + if (m_uncompressed_start[1] == nullptr) { INT16 *dest = m_uncompressed_start[0] + m_uncompressed_offset * frame->header.channels; for (int sampnum = 0; sampnum < blocksize && m_uncompressed_offset < m_uncompressed_length; sampnum++, m_uncompressed_offset++) @@ -602,7 +602,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame { for (int sampnum = 0; sampnum < blocksize && m_uncompressed_offset < m_uncompressed_length; sampnum++, m_uncompressed_offset++) for (int chan = 0; chan < frame->header.channels; chan++) - if (m_uncompressed_start[chan] != NULL) + if (m_uncompressed_start[chan] != nullptr) m_uncompressed_start[chan][m_uncompressed_offset] = INT16((UINT16(buffer[chan][sampnum]) << shift) | (UINT16(buffer[chan][sampnum]) >> shift)); } return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; diff --git a/src/lib/util/flac.h b/src/lib/util/flac.h index 24290b7649e..563c40974e0 100644 --- a/src/lib/util/flac.h +++ b/src/lib/util/flac.h @@ -92,7 +92,7 @@ class flac_decoder public: // construction/destruction flac_decoder(); - flac_decoder(const void *buffer, UINT32 length, const void *buffer2 = NULL, UINT32 length2 = 0); + flac_decoder(const void *buffer, UINT32 length, const void *buffer2 = nullptr, UINT32 length2 = 0); flac_decoder(core_file &file); ~flac_decoder(); @@ -106,7 +106,7 @@ public: // reset bool reset(); - bool reset(const void *buffer, UINT32 length, const void *buffer2 = NULL, UINT32 length2 = 0); + bool reset(const void *buffer, UINT32 length, const void *buffer2 = nullptr, UINT32 length2 = 0); bool reset(UINT32 sample_rate, UINT8 num_channels, UINT32 block_size, const void *buffer, UINT32 length); bool reset(core_file &file); diff --git a/src/lib/util/harddisk.cpp b/src/lib/util/harddisk.cpp index b1082f3234f..6bb121f36b2 100644 --- a/src/lib/util/harddisk.cpp +++ b/src/lib/util/harddisk.cpp @@ -44,22 +44,22 @@ hard_disk_file *hard_disk_open(chd_file *chd) chd_error err; /* punt if no CHD */ - if (chd == NULL) - return NULL; + if (chd == nullptr) + return nullptr; /* read the hard disk metadata */ err = chd->read_metadata(HARD_DISK_METADATA_TAG, 0, metadata); if (err != CHDERR_NONE) - return NULL; + return nullptr; /* parse the metadata */ if (sscanf(metadata.c_str(), HARD_DISK_METADATA_FORMAT, &cylinders, &heads, §ors, §orbytes) != 4) - return NULL; + return nullptr; /* allocate memory for the hard disk file */ file = (hard_disk_file *)malloc(sizeof(hard_disk_file)); - if (file == NULL) - return NULL; + if (file == nullptr) + return nullptr; /* fill in the data */ file->chd = chd; diff --git a/src/lib/util/hashing.cpp b/src/lib/util/hashing.cpp index e7f315ecc53..785127e01e8 100644 --- a/src/lib/util/hashing.cpp +++ b/src/lib/util/hashing.cpp @@ -63,13 +63,13 @@ bool sha1_t::from_string(const char *string, int length) return false; // iterate through our raw buffer - for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++) + for (auto & elem : m_raw) { int upper = char_to_hex(*string++); int lower = char_to_hex(*string++); if (upper == -1 || lower == -1) return false; - m_raw[bytenum] = (upper << 4) | lower; + elem = (upper << 4) | lower; } return true; } @@ -82,8 +82,8 @@ bool sha1_t::from_string(const char *string, int length) const char *sha1_t::as_string(std::string &buffer) const { buffer.clear(); - for (int i = 0; i < ARRAY_LENGTH(m_raw); i++) - strcatprintf(buffer, "%02x", m_raw[i]); + for (auto & elem : m_raw) + strcatprintf(buffer, "%02x", elem); return buffer.c_str(); } @@ -106,13 +106,13 @@ bool md5_t::from_string(const char *string, int length) return false; // iterate through our raw buffer - for (int bytenum = 0; bytenum < sizeof(m_raw); bytenum++) + for (auto & elem : m_raw) { int upper = char_to_hex(*string++); int lower = char_to_hex(*string++); if (upper == -1 || lower == -1) return false; - m_raw[bytenum] = (upper << 4) | lower; + elem = (upper << 4) | lower; } return true; } @@ -125,8 +125,8 @@ bool md5_t::from_string(const char *string, int length) const char *md5_t::as_string(std::string &buffer) const { buffer.clear(); - for (int i = 0; i < ARRAY_LENGTH(m_raw); i++) - strcatprintf(buffer, "%02x", m_raw[i]); + for (auto & elem : m_raw) + strcatprintf(buffer, "%02x", elem); return buffer.c_str(); } diff --git a/src/lib/util/huffman.cpp b/src/lib/util/huffman.cpp index 9205264f9eb..8aa32bd3b4d 100644 --- a/src/lib/util/huffman.cpp +++ b/src/lib/util/huffman.cpp @@ -563,7 +563,7 @@ int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight) // create new node node_t &newnode = m_huffnode[nextalloc++]; - newnode.m_parent = NULL; + newnode.m_parent = nullptr; node0.m_parent = node1.m_parent = &newnode; newnode.m_weight = node0.m_weight + node1.m_weight; @@ -591,7 +591,7 @@ int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight) if (node.m_weight > 0) { // determine the number of bits for this node - for (node_t *curnode = &node; curnode->m_parent != NULL; curnode = curnode->m_parent) + for (node_t *curnode = &node; curnode->m_parent != nullptr; curnode = curnode->m_parent) node.m_numbits++; if (node.m_numbits == 0) node.m_numbits = 1; diff --git a/src/lib/util/huffman.h b/src/lib/util/huffman.h index 76ee1b9c23b..a2bed42bbf9 100644 --- a/src/lib/util/huffman.h +++ b/src/lib/util/huffman.h @@ -98,7 +98,7 @@ class huffman_encoder : public huffman_context_base public: // pass through to the underlying constructor huffman_encoder() - : huffman_context_base(_NumCodes, _MaxBits, NULL, m_datahisto_array, m_huffnode_array) { histo_reset(); } + : huffman_context_base(_NumCodes, _MaxBits, nullptr, m_datahisto_array, m_huffnode_array) { histo_reset(); } // single item operations void histo_reset() { memset(m_datahisto_array, 0, sizeof(m_datahisto_array)); } @@ -126,7 +126,7 @@ class huffman_decoder : public huffman_context_base public: // pass through to the underlying constructor huffman_decoder() - : huffman_context_base(_NumCodes, _MaxBits, m_lookup_array, NULL, m_huffnode_array) { } + : huffman_context_base(_NumCodes, _MaxBits, m_lookup_array, nullptr, m_huffnode_array) { } // single item operations UINT32 decode_one(bitstream_in &bitbuf); diff --git a/src/lib/util/opresolv.cpp b/src/lib/util/opresolv.cpp index 91c6f1a9cbd..4764d6955e3 100644 --- a/src/lib/util/opresolv.cpp +++ b/src/lib/util/opresolv.cpp @@ -116,7 +116,7 @@ static optreserr_t resolve_single_param(const char *specification, int *param_va range++; flags &= ~FLAG_HALF_RANGE; if (--range_count == 0) - range = NULL; + range = nullptr; } } else if (*s == ';') @@ -179,14 +179,14 @@ static const char *lookup_in_specification(const char *specification, const opti { const char *s; s = strchr(specification, option->parameter); - return s ? s + 1 : NULL; + return s ? s + 1 : nullptr; } option_resolution *option_resolution_create(const option_guide *guide, const char *specification) { - option_resolution *resolution = NULL; + option_resolution *resolution = nullptr; const option_guide *guide_entry; int option_count; int opt = -1; @@ -198,7 +198,7 @@ option_resolution *option_resolution_create(const option_guide *guide, const cha option_count = option_resolution_countoptions(guide, specification); /* create a memory pool for this structure */ - pool = pool_alloc_lib(NULL); + pool = pool_alloc_lib(nullptr); if (!pool) goto outofmemory; @@ -244,7 +244,7 @@ unexpected: outofmemory: if (resolution) option_resolution_close(resolution); - return NULL; + return nullptr; } @@ -255,7 +255,7 @@ optreserr_t option_resolution_add_param(option_resolution *resolution, const cha int must_resolve; optreserr_t err; const char *option_specification; - struct option_resolution_entry *entry = NULL; + struct option_resolution_entry *entry = nullptr; for (i = 0; i < resolution->option_count; i++) { @@ -317,7 +317,7 @@ optreserr_t option_resolution_add_param(option_resolution *resolution, const cha if (must_resolve) { option_specification = lookup_in_specification(resolution->specification, entry->guide_entry); - err = resolve_single_param(option_specification, &entry->u.int_value, NULL, 0); + err = resolve_single_param(option_specification, &entry->u.int_value, nullptr, 0); if (err) goto done; @@ -363,7 +363,7 @@ optreserr_t option_resolution_finish(option_resolution *resolution) option_specification = lookup_in_specification(resolution->specification, entry->guide_entry); assert(option_specification); entry->u.int_value = -1; - err = resolve_single_param(option_specification, &entry->u.int_value, NULL, 0); + err = resolve_single_param(option_specification, &entry->u.int_value, nullptr, 0); if (err) return err; break; @@ -403,10 +403,10 @@ static const struct option_resolution_entry *option_resolution_lookup_entry(opti default: assert(FALSE); - return NULL; + return nullptr; } } - return NULL; + return nullptr; } @@ -424,7 +424,7 @@ const char *option_resolution_lookup_string(option_resolution *resolution, int o { const struct option_resolution_entry *entry; entry = option_resolution_lookup_entry(resolution, option_char); - return entry ? entry->u.str_value : NULL; + return entry ? entry->u.str_value : nullptr; } @@ -440,7 +440,7 @@ const option_guide *option_resolution_find_option(option_resolution *resolution, { const struct option_resolution_entry *entry; entry = option_resolution_lookup_entry(resolution, option_char); - return entry ? entry->guide_entry : NULL; + return entry ? entry->guide_entry : nullptr; } @@ -448,7 +448,7 @@ const option_guide *option_resolution_find_option(option_resolution *resolution, const option_guide *option_resolution_index_option(option_resolution *resolution, int indx) { if ((indx < 0) || (indx >= resolution->option_count)) - return NULL; + return nullptr; return resolution->entries[indx].guide_entry; } @@ -495,7 +495,7 @@ optreserr_t option_resolution_listranges(const char *specification, int option_c return OPTIONRESOLUTION_ERROR_SYNTAX; } - return resolve_single_param(specification + 1, NULL, range, range_count); + return resolve_single_param(specification + 1, nullptr, range, range_count); } @@ -513,7 +513,7 @@ optreserr_t option_resolution_getdefault(const char *specification, int option_c return OPTIONRESOLUTION_ERROR_SYNTAX; } - return resolve_single_param(specification + 1, val, NULL, 0); + return resolve_single_param(specification + 1, val, nullptr, 0); } @@ -549,7 +549,7 @@ optreserr_t option_resolution_isvalidvalue(const char *specification, int option int option_resolution_contains(const char *specification, int option_char) { - return strchr(specification, option_char) != NULL; + return strchr(specification, option_char) != nullptr; } /** @@ -578,6 +578,6 @@ const char *option_resolution_error_string(optreserr_t err) }; if ((err < 0) || (err >= ARRAY_LENGTH(errors))) - return NULL; + return nullptr; return errors[err]; } diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp index 69e7189f50b..c644fef9657 100644 --- a/src/lib/util/options.cpp +++ b/src/lib/util/options.cpp @@ -53,7 +53,7 @@ const char *const core_options::s_option_unadorned[MAX_UNADORNED_OPTIONS] = //------------------------------------------------- core_options::entry::entry(const char *name, const char *description, UINT32 flags, const char *defvalue) - : m_next(NULL), + : m_next(nullptr), m_flags(flags), m_seqid(0), m_error_reported(false), @@ -61,7 +61,7 @@ core_options::entry::entry(const char *name, const char *description, UINT32 fla m_description(description) { // copy in the name(s) as appropriate - if (name != NULL) + if (name != nullptr) { // first extract any range std::string namestr(name); @@ -90,7 +90,7 @@ core_options::entry::entry(const char *name, const char *description, UINT32 fla } // set the default value - if (defvalue != NULL) + if (defvalue != nullptr) m_defdata = defvalue; m_data = m_defdata; } @@ -225,7 +225,7 @@ core_options &core_options::operator=(const core_options &rhs) bool core_options::operator==(const core_options &rhs) { // iterate over options in the first list - for (entry *curentry = m_entrylist.first(); curentry != NULL; curentry = curentry->next()) + for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next()) if (!curentry->is_header()) { // if the values differ, return false @@ -255,12 +255,12 @@ bool core_options::operator!=(const core_options &rhs) void core_options::add_entry(const char *name, const char *description, UINT32 flags, const char *defvalue, bool override_existing) { // allocate a new entry - entry *newentry = global_alloc(entry(name, description, flags, defvalue)); - if (newentry->name() != NULL) + auto newentry = global_alloc(entry(name, description, flags, defvalue)); + if (newentry->name() != nullptr) { // see if we match an existing entry entry *existing = m_entrymap.find(newentry->name()); - if (existing != NULL) + if (existing != nullptr) { // if we're overriding existing entries, then remove the old one if (override_existing) @@ -289,7 +289,7 @@ void core_options::add_entry(const char *name, const char *description, UINT32 f void core_options::add_entries(const options_entry *entrylist, bool override_existing) { // loop over entries until we hit a NULL name - for ( ; entrylist->name != NULL || (entrylist->flags & OPTION_HEADER) != 0; entrylist++) + for ( ; entrylist->name != nullptr || (entrylist->flags & OPTION_HEADER) != 0; entrylist++) add_entry(*entrylist, override_existing); } @@ -303,7 +303,7 @@ void core_options::set_default_value(const char *name, const char *defvalue) { // find the entry and bail if we can't entry *curentry = m_entrymap.find(name); - if (curentry == NULL) + if (curentry == nullptr) return; // update the data and default data @@ -320,7 +320,7 @@ void core_options::set_description(const char *name, const char *description) { // find the entry and bail if we can't entry *curentry = m_entrymap.find(name); - if (curentry == NULL) + if (curentry == nullptr) return; // update the data and default data @@ -351,7 +351,7 @@ bool core_options::parse_command_line(int argc, char **argv, int priority, std:: // find our entry; if not found, indicate invalid option entry *curentry = m_entrymap.find(optionname); - if (curentry == NULL) + if (curentry == nullptr) { strcatprintf(error_string, "Error: unknown option: %s\n", curarg); retval = false; @@ -402,7 +402,7 @@ bool core_options::parse_ini_file(core_file &inifile, int priority, int ignore_p { // loop over lines in the file char buffer[4096]; - while (core_fgets(buffer, ARRAY_LENGTH(buffer), &inifile) != NULL) + while (core_fgets(buffer, ARRAY_LENGTH(buffer), &inifile) != nullptr) { // find the extent of the name char *optionname; @@ -444,7 +444,7 @@ bool core_options::parse_ini_file(core_file &inifile, int priority, int ignore_p // find our entry entry *curentry = m_entrymap.find(optionname); - if (curentry == NULL) + if (curentry == nullptr) { if (priority >= ignore_priority) strcatprintf(error_string, "Warning: unknown option in INI: %s\n", optionname); @@ -466,7 +466,7 @@ bool core_options::parse_ini_file(core_file &inifile, int priority, int ignore_p void core_options::revert(int priority) { // iterate over options and revert to defaults if below the given priority - for (entry *curentry = m_entrylist.first(); curentry != NULL; curentry = curentry->next()) + for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next()) curentry->revert(priority); } @@ -484,10 +484,10 @@ const char *core_options::output_ini(std::string &buffer, const core_options *di int num_valid_headers = 0; int unadorned_index = 0; - const char *last_header = NULL; + const char *last_header = nullptr; // loop over all items - for (entry *curentry = m_entrylist.first(); curentry != NULL; curentry = curentry->next()) + for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next()) { const char *name = curentry->name(); const char *value = curentry->value(); @@ -510,21 +510,21 @@ const char *core_options::output_ini(std::string &buffer, const core_options *di if ( !curentry->is_internal() ) { // look up counterpart in diff, if diff is specified - if (diff == NULL || strcmp(value, diff->value(name)) != 0) + if (diff == nullptr || strcmp(value, diff->value(name)) != 0) { // output header, if we have one - if (last_header != NULL) + if (last_header != nullptr) { if (num_valid_headers++) strcatprintf(buffer,"\n"); strcatprintf(buffer, "#\n# %s\n#\n", last_header); - last_header = NULL; + last_header = nullptr; } // and finally output the data, skip if unadorned if (!is_unadorned) { - if (strchr(value, ' ') != NULL) + if (strchr(value, ' ') != nullptr) strcatprintf(buffer,"%-25s \"%s\"\n", name, value); else strcatprintf(buffer,"%-25s %s\n", name, value); @@ -547,14 +547,14 @@ const char *core_options::output_help(std::string &buffer) buffer.clear(); // loop over all items - for (entry *curentry = m_entrylist.first(); curentry != NULL; curentry = curentry->next()) + for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next()) { // header: just print if (curentry->is_header()) strcatprintf(buffer,"\n#\n# %s\n#\n", curentry->description()); // otherwise, output entries for all non-deprecated items - else if (curentry->description() != NULL) + else if (curentry->description() != nullptr) strcatprintf(buffer,"-%-20s%s\n", curentry->name(), curentry->description()); } return buffer.c_str(); @@ -568,7 +568,7 @@ const char *core_options::output_help(std::string &buffer) const char *core_options::value(const char *name) const { entry *curentry = m_entrymap.find(name); - return (curentry != NULL) ? curentry->value() : ""; + return (curentry != nullptr) ? curentry->value() : ""; } @@ -579,7 +579,7 @@ const char *core_options::value(const char *name) const const char *core_options::description(const char *name) const { entry *curentry = m_entrymap.find(name); - return (curentry != NULL) ? curentry->description() : ""; + return (curentry != nullptr) ? curentry->description() : ""; } @@ -590,7 +590,7 @@ const char *core_options::description(const char *name) const int core_options::priority(const char *name) const { entry *curentry = m_entrymap.find(name); - return (curentry != NULL) ? curentry->priority() : 0; + return (curentry != nullptr) ? curentry->priority() : 0; } @@ -601,7 +601,7 @@ int core_options::priority(const char *name) const UINT32 core_options::seqid(const char *name) const { entry *curentry = m_entrymap.find(name); - return (curentry != NULL) ? curentry->seqid() : 0; + return (curentry != nullptr) ? curentry->seqid() : 0; } //------------------------------------------------- @@ -611,7 +611,7 @@ UINT32 core_options::seqid(const char *name) const bool core_options::exists(const char *name) const { entry *curentry = m_entrymap.find(name); - return (curentry != NULL); + return (curentry != nullptr); } //------------------------------------------------- @@ -622,7 +622,7 @@ bool core_options::set_value(const char *name, const char *value, int priority, { // find the entry first entry *curentry = m_entrymap.find(name); - if (curentry == NULL) + if (curentry == nullptr) { strcatprintf(error_string, "Attempted to set unknown option %s\n", name); return false; @@ -651,7 +651,7 @@ void core_options::set_flag(const char *name, UINT32 mask, UINT32 flag) { // find the entry first entry *curentry = m_entrymap.find(name); - if ( curentry == NULL ) + if ( curentry == nullptr ) { return; } @@ -682,7 +682,7 @@ void core_options::append_entry(core_options::entry &newentry) // if we have names, add them to the map for (int name = 0; name < ARRAY_LENGTH(newentry.m_name); name++) - if (newentry.name(name) != NULL) + if (newentry.name(name) != nullptr) { m_entrymap.add(newentry.name(name), &newentry); @@ -725,7 +725,7 @@ void core_options::copyfrom(const core_options &src) reset(); // iterate through the src options and make our own - for (entry *curentry = src.m_entrylist.first(); curentry != NULL; curentry = curentry->next()) + for (entry *curentry = src.m_entrylist.first(); curentry != nullptr; curentry = curentry->next()) append_entry(*global_alloc(entry(curentry->name(), curentry->description(), curentry->flags(), curentry->default_value()))); } diff --git a/src/lib/util/options.h b/src/lib/util/options.h index 1ef4636e1e6..a03e8217abf 100644 --- a/src/lib/util/options.h +++ b/src/lib/util/options.h @@ -70,12 +70,12 @@ public: friend class simple_list; // construction/destruction - entry(const char *name, const char *description, UINT32 flags = 0, const char *defvalue = NULL); + entry(const char *name, const char *description, UINT32 flags = 0, const char *defvalue = nullptr); public: // getters entry *next() const { return m_next; } - const char *name(int index = 0) const { return (index < ARRAY_LENGTH(m_name) && !m_name[index].empty()) ? m_name[index].c_str() : NULL; } + const char *name(int index = 0) const { return (index < ARRAY_LENGTH(m_name) && !m_name[index].empty()) ? m_name[index].c_str() : nullptr; } const char *description() const { return m_description; } const char *value() const { return m_data.c_str(); } const char *default_value() const { return m_defdata.c_str(); } @@ -130,7 +130,7 @@ public: const char *command() const { return m_command.c_str(); } // configuration - void add_entry(const char *name, const char *description, UINT32 flags = 0, const char *defvalue = NULL, bool override_existing = false); + void add_entry(const char *name, const char *description, UINT32 flags = 0, const char *defvalue = nullptr, bool override_existing = false); void add_entry(const options_entry &data, bool override_existing = false) { add_entry(data.name, data.description, data.flags, data.defvalue, override_existing); } void add_entries(const options_entry *entrylist, bool override_existing = false); void set_default_value(const char *name, const char *defvalue); @@ -145,7 +145,7 @@ public: void revert(int priority = OPTION_PRIORITY_MAXIMUM); // output - const char *output_ini(std::string &buffer, const core_options *diff = NULL); + const char *output_ini(std::string &buffer, const core_options *diff = nullptr); const char *output_help(std::string &buffer); // reading diff --git a/src/lib/util/palette.cpp b/src/lib/util/palette.cpp index cafdce24ebd..bd3c2d45ede 100644 --- a/src/lib/util/palette.cpp +++ b/src/lib/util/palette.cpp @@ -66,7 +66,7 @@ const UINT32 *palette_client::dirty_state::dirty_list(UINT32 &mindirty, UINT32 & maxdirty = m_maxdirty; // if nothing to report, report nothing - return (m_mindirty > m_maxdirty) ? NULL : &m_dirty[0]; + return (m_mindirty > m_maxdirty) ? nullptr : &m_dirty[0]; } @@ -128,7 +128,7 @@ void palette_client::dirty_state::reset() palette_client::palette_client(palette_t &palette) : m_palette(palette), - m_next(NULL), + m_next(nullptr), m_live(&m_dirty[0]), m_previous(&m_dirty[1]) { @@ -153,7 +153,7 @@ palette_client::palette_client(palette_t &palette) palette_client::~palette_client() { // first locate and remove ourself from our palette's list - for (palette_client **curptr = &m_palette.m_client_list; *curptr != NULL; curptr = &(*curptr)->m_next) + for (palette_client **curptr = &m_palette.m_client_list; *curptr != nullptr; curptr = &(*curptr)->m_next) if (*curptr == this) { *curptr = m_next; @@ -174,8 +174,8 @@ const UINT32 *palette_client::dirty_list(UINT32 &mindirty, UINT32 &maxdirty) { // if nothing to report, report nothing and don't swap const UINT32 *result = m_live->dirty_list(mindirty, maxdirty); - if (result == NULL) - return NULL; + if (result == nullptr) + return nullptr; // swap the live and previous lists dirty_state *temp = m_live; @@ -220,7 +220,7 @@ palette_t::palette_t(UINT32 numcolors, UINT32 numgroups) m_adjusted_rgb15(numcolors * numgroups + 2), m_group_bright(numgroups), m_group_contrast(numgroups), - m_client_list(NULL) + m_client_list(nullptr) { // initialize gamma map for (UINT32 index = 0; index < 256; index++) @@ -556,6 +556,6 @@ void palette_t::update_adjusted_color(UINT32 group, UINT32 index) m_adjusted_rgb15[finalindex] = adjusted.as_rgb15(); // mark dirty in all clients - for (palette_client *client = m_client_list; client != NULL; client = client->next()) + for (palette_client *client = m_client_list; client != nullptr; client = client->next()) client->mark_dirty(finalindex); } diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp index 706dfb5e50f..6e57d949f47 100644 --- a/src/lib/util/png.cpp +++ b/src/lib/util/png.cpp @@ -115,26 +115,26 @@ INLINE int compute_rowbytes(const png_info *pnginfo) void png_free(png_info *pnginfo) { - while (pnginfo->textlist != NULL) + while (pnginfo->textlist != nullptr) { png_text *temp = pnginfo->textlist; pnginfo->textlist = temp->next; - if (temp->keyword != NULL) + if (temp->keyword != nullptr) free((void *)temp->keyword); free(temp); } - if (pnginfo->palette != NULL) + if (pnginfo->palette != nullptr) free(pnginfo->palette); - pnginfo->palette = NULL; + pnginfo->palette = nullptr; - if (pnginfo->trans != NULL) + if (pnginfo->trans != nullptr) free(pnginfo->trans); - pnginfo->trans = NULL; + pnginfo->trans = nullptr; - if (pnginfo->image != NULL) + if (pnginfo->image != nullptr) free(pnginfo->image); - pnginfo->image = NULL; + pnginfo->image = nullptr; } @@ -191,19 +191,19 @@ static png_error read_chunk(core_file *fp, UINT8 **data, UINT32 *type, UINT32 *l crc = crc32(0, tempbuff, 4); /* read the chunk itself into an allocated memory buffer */ - *data = NULL; + *data = nullptr; if (*length != 0) { /* allocate memory for this chunk */ *data = (UINT8 *)malloc(*length); - if (*data == NULL) + if (*data == nullptr) return PNGERR_OUT_OF_MEMORY; /* read the data from the file */ if (core_fread(fp, *data, *length) != *length) { free(*data); - *data = NULL; + *data = nullptr; return PNGERR_FILE_TRUNCATED; } @@ -215,7 +215,7 @@ static png_error read_chunk(core_file *fp, UINT8 **data, UINT32 *type, UINT32 *l if (core_fread(fp, tempbuff, 4) != 4) { free(*data); - *data = NULL; + *data = nullptr; return PNGERR_FILE_TRUNCATED; } chunk_crc = fetch_32bit(tempbuff); @@ -224,7 +224,7 @@ static png_error read_chunk(core_file *fp, UINT8 **data, UINT32 *type, UINT32 *l if (crc != chunk_crc) { free(*data); - *data = NULL; + *data = nullptr; return PNGERR_FILE_CORRUPT; } return PNGERR_NONE; @@ -273,11 +273,11 @@ static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT3 /* allocate a new image data descriptor */ *png->idata_next = (image_data_chunk *)malloc(sizeof(**png->idata_next)); - if (*png->idata_next == NULL) + if (*png->idata_next == nullptr) return PNGERR_OUT_OF_MEMORY; /* add it to the tail of the list */ - (*png->idata_next)->next = NULL; + (*png->idata_next)->next = nullptr; (*png->idata_next)->length = length; (*png->idata_next)->data = data; png->idata_next = &(*png->idata_next)->next; @@ -303,17 +303,17 @@ static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT3 /* allocate a new text item */ text = (png_text *)malloc(sizeof(*text)); - if (text == NULL) + if (text == nullptr) return PNGERR_OUT_OF_MEMORY; /* set the elements */ text->keyword = (char *)data; text->text = text->keyword + strlen(text->keyword) + 1; - text->next = NULL; + text->next = nullptr; /* add to the end of the list */ - for (pt = NULL, ct = png->pnginfo->textlist; ct != NULL; pt = ct, ct = ct->next) ; - if (pt == NULL) + for (pt = nullptr, ct = png->pnginfo->textlist; ct != nullptr; pt = ct, ct = ct->next) ; + if (pt == nullptr) png->pnginfo->textlist = text; else pt->next = text; @@ -359,7 +359,7 @@ static png_error unfilter_row(int type, UINT8 *src, UINT8 *dst, UINT8 *dstprev, /* UP = pixel above */ case PNG_PF_Up: - if (dstprev == NULL) + if (dstprev == nullptr) return unfilter_row(PNG_PF_None, src, dst, dstprev, bpp, rowbytes); for (x = 0; x < rowbytes; x++, dst++) *dst = *src++ + *dstprev++; @@ -367,7 +367,7 @@ static png_error unfilter_row(int type, UINT8 *src, UINT8 *dst, UINT8 *dstprev, /* AVERAGE = average of pixel above and previous pixel */ case PNG_PF_Average: - if (dstprev == NULL) + if (dstprev == nullptr) { for (x = 0; x < bpp; x++) *dst++ = *src++; @@ -388,8 +388,8 @@ static png_error unfilter_row(int type, UINT8 *src, UINT8 *dst, UINT8 *dstprev, for (x = 0; x < rowbytes; x++) { INT32 pa = (x < bpp) ? 0 : dst[-bpp]; - INT32 pc = (x < bpp || dstprev == NULL) ? 0 : dstprev[-bpp]; - INT32 pb = (dstprev == NULL) ? 0 : *dstprev++; + INT32 pc = (x < bpp || dstprev == nullptr) ? 0 : dstprev[-bpp]; + INT32 pb = (dstprev == nullptr) ? 0 : *dstprev++; INT32 prediction = pa + pb - pc; INT32 da = abs(prediction - pa); INT32 db = abs(prediction - pb); @@ -432,7 +432,7 @@ static png_error process_image(png_private *png) /* allocate memory for the filtered image */ png->pnginfo->image = (UINT8 *)malloc(imagesize); - if (png->pnginfo->image == NULL) + if (png->pnginfo->image == nullptr) return PNGERR_OUT_OF_MEMORY; /* initialize the stream */ @@ -447,7 +447,7 @@ static png_error process_image(png_private *png) } /* loop over IDAT and decompress each as part of a larger stream */ - for (idat = png->idata; idat != NULL; idat = idat->next) + for (idat = png->idata; idat != nullptr; idat = idat->next) { /* decompress this chunk */ stream.next_in = idat->data; @@ -482,7 +482,7 @@ static png_error process_image(png_private *png) { /* first byte of each row is the filter type */ int filter = *src++; - error = unfilter_row(filter, src, dst, (y == 0) ? NULL : &dst[-rowbytes], bpp, rowbytes); + error = unfilter_row(filter, src, dst, (y == 0) ? nullptr : &dst[-rowbytes], bpp, rowbytes); src += rowbytes; dst += rowbytes; } @@ -492,7 +492,7 @@ handle_error: if (error != PNGERR_NONE) { free(png->pnginfo->image); - png->pnginfo->image = NULL; + png->pnginfo->image = nullptr; } return error; } @@ -504,7 +504,7 @@ handle_error: png_error png_read_file(core_file *fp, png_info *pnginfo) { - UINT8 *chunk_data = NULL; + UINT8 *chunk_data = nullptr; png_private png; png_error error; @@ -542,7 +542,7 @@ png_error png_read_file(core_file *fp, png_info *pnginfo) /* free memory if we didn't want to keep it */ if (!keepmem) free(chunk_data); - chunk_data = NULL; + chunk_data = nullptr; } /* finish processing the image */ @@ -553,15 +553,15 @@ png_error png_read_file(core_file *fp, png_info *pnginfo) handle_error: /* free all intermediate data */ - while (png.idata != NULL) + while (png.idata != nullptr) { image_data_chunk *next = png.idata->next; - if (png.idata->data != NULL) + if (png.idata->data != nullptr) free(png.idata->data); free(png.idata); png.idata = next; } - if (chunk_data != NULL) + if (chunk_data != nullptr) free(chunk_data); /* if we have an error, free all the other data as well */ @@ -665,7 +665,7 @@ png_error png_expand_buffer_8bit(png_info *pnginfo) /* allocate a new buffer at 8-bit */ outbuf = (UINT8 *)malloc(pnginfo->width * pnginfo->height); - if (outbuf == NULL) + if (outbuf == nullptr) return PNGERR_OUT_OF_MEMORY; inp = pnginfo->image; @@ -710,13 +710,13 @@ png_error png_add_text(png_info *pnginfo, const char *keyword, const char *text) /* allocate a new text element */ newtext = (png_text *)malloc(sizeof(*newtext)); - if (newtext == NULL) + if (newtext == nullptr) return PNGERR_OUT_OF_MEMORY; /* allocate a string long enough to hold both */ keylen = (int)strlen(keyword); textdata = (char *)malloc(keylen + 1 + strlen(text) + 1); - if (textdata == NULL) + if (textdata == nullptr) { free(newtext); return PNGERR_OUT_OF_MEMORY; @@ -729,11 +729,11 @@ png_error png_add_text(png_info *pnginfo, const char *keyword, const char *text) /* text follows a trailing NULL */ newtext->keyword = textdata; newtext->text = textdata + keylen + 1; - newtext->next = NULL; + newtext->next = nullptr; /* add us to the end of the linked list */ - for (pt = NULL, ct = pnginfo->textlist; ct != NULL; pt = ct, ct = ct->next) ; - if (pt == NULL) + for (pt = nullptr, ct = pnginfo->textlist; ct != nullptr; pt = ct, ct = ct->next) ; + if (pt == nullptr) pnginfo->textlist = newtext; else pt->next = newtext; @@ -884,7 +884,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap /* allocate memory for the palette */ pnginfo->palette = (UINT8 *)malloc(3 * 256); - if (pnginfo->palette == NULL) + if (pnginfo->palette == nullptr) return PNGERR_OUT_OF_MEMORY; /* build the palette */ @@ -899,7 +899,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap /* allocate memory for the image */ pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1)); - if (pnginfo->image == NULL) + if (pnginfo->image == nullptr) { free(pnginfo->palette); return PNGERR_OUT_OF_MEMORY; @@ -941,7 +941,7 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t & /* allocate memory for the image */ pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1)); - if (pnginfo->image == NULL) + if (pnginfo->image == nullptr) return PNGERR_OUT_OF_MEMORY; /* copy in the pixels, specifying a NULL filter */ @@ -1046,7 +1046,7 @@ static png_error write_png_stream(core_file *fp, png_info *pnginfo, const bitmap goto handle_error; /* write TEXT chunks */ - for (text = pnginfo->textlist; text != NULL; text = text->next) + for (text = pnginfo->textlist; text != nullptr; text = text->next) { error = write_chunk(fp, (UINT8 *)text->keyword, PNG_CN_tEXt, (UINT32)strlen(text->keyword) + 1 + (UINT32)strlen(text->text)); if (error != PNGERR_NONE) @@ -1054,7 +1054,7 @@ static png_error write_png_stream(core_file *fp, png_info *pnginfo, const bitmap } /* write an IEND chunk */ - error = write_chunk(fp, NULL, PNG_CN_IEND, 0); + error = write_chunk(fp, nullptr, PNG_CN_IEND, 0); handle_error: return error; @@ -1067,7 +1067,7 @@ png_error png_write_bitmap(core_file *fp, png_info *info, bitmap_t &bitmap, int png_error error; /* use a dummy pnginfo if none passed to us */ - if (info == NULL) + if (info == nullptr) { info = &pnginfo; memset(&pnginfo, 0, sizeof(pnginfo)); @@ -1161,5 +1161,5 @@ png_error mng_capture_frame(core_file *fp, png_info *info, bitmap_t &bitmap, int png_error mng_capture_stop(core_file *fp) { - return write_chunk(fp, NULL, MNG_CN_MEND, 0); + return write_chunk(fp, nullptr, MNG_CN_MEND, 0); } diff --git a/src/lib/util/pool.cpp b/src/lib/util/pool.cpp index ab62f47c6aa..e004f236b76 100644 --- a/src/lib/util/pool.cpp +++ b/src/lib/util/pool.cpp @@ -115,11 +115,11 @@ INLINE objtype_entry *get_object_type(object_pool *pool, object_type type) { objtype_entry *entry; - for (entry = pool->typelist; entry != NULL; entry = entry->next) + for (entry = pool->typelist; entry != nullptr; entry = entry->next) if (entry->type == type) return entry; - return NULL; + return nullptr; } @@ -138,8 +138,8 @@ object_pool *pool_alloc_lib(void (*fail)(const char *message)) /* allocate memory for the pool itself */ pool = (object_pool *)malloc(sizeof(*pool)); - if (pool == NULL) - return NULL; + if (pool == nullptr) + return nullptr; memset(pool, 0, sizeof(*pool)); /* set the failure handler */ @@ -162,11 +162,11 @@ void pool_type_register(object_pool *pool, object_type type, const char *friendl objtype_entry *newtype = get_object_type(pool, type); /* if the type doesn't already exist... */ - if (newtype == NULL) + if (newtype == nullptr) { /* allocate a new entry */ newtype = (objtype_entry *)malloc(sizeof(*newtype)); - if (newtype == NULL) + if (newtype == nullptr) { report_failure(pool, "Error adding new type %s\n", friendly); return; @@ -195,7 +195,7 @@ void pool_clear(object_pool *pool) object_entry *entry, *next; /* iterate over all entries in the global list and free them */ - for (entry = pool->globallist; entry != NULL; entry = next) + for (entry = pool->globallist; entry != nullptr; entry = next) { /* remember the next entry */ next = entry->globalnext; @@ -205,7 +205,7 @@ void pool_clear(object_pool *pool) /* add ourself to the free list */ entry->next = pool->freelist; - entry->globalnext = entry->globalprev = NULL; + entry->globalnext = entry->globalprev = nullptr; pool->freelist = entry; } @@ -228,14 +228,14 @@ void pool_free_lib(object_pool *pool) pool_clear(pool); /* free all entry blocks */ - for (block = pool->blocklist; block != NULL; block = nextblock) + for (block = pool->blocklist; block != nullptr; block = nextblock) { nextblock = block->next; free(block); } /* free all types */ - for (type = pool->typelist; type != NULL; type = nexttype) + for (type = pool->typelist; type != nullptr; type = nexttype) { nexttype = type->next; free(type); @@ -263,29 +263,29 @@ void *pool_object_add_file_line(object_pool *pool, object_type _type, void *obje object_entry *entry; /* if we have an invalid type, fail */ - if (type == NULL) + if (type == nullptr) { report_failure(pool, "pool_object_add (via %s:%d): Attempted to add object of unknown type with size %d", file, line, (int)size); return object; } /* if we get a NULL object, fail */ - if (object == NULL) + if (object == nullptr) { report_failure(pool, "pool_object_add (via %s:%d): Attempted to add a NULL object of size %d", file, line, (int)size); return object; } /* allocate a new entry */ - if (pool->freelist == NULL) + if (pool->freelist == nullptr) { object_entry_block *block; int entrynum; /* if we need a new block, allocate that now */ block = (object_entry_block *)malloc(sizeof(*block)); - if (block == NULL) - return NULL; + if (block == nullptr) + return nullptr; memset(block, 0, sizeof(*block)); /* hook us into the blocklist */ @@ -312,9 +312,9 @@ void *pool_object_add_file_line(object_pool *pool, object_type _type, void *obje entry->line = line; /* hook us into the global list */ - if (pool->globallist != NULL) + if (pool->globallist != nullptr) pool->globallist->globalprev = entry; - entry->globalprev = NULL; + entry->globalprev = nullptr; entry->globalnext = pool->globallist; pool->globallist = entry; @@ -336,7 +336,7 @@ void *pool_object_remove(object_pool *pool, void *object, int destruct) object_entry **entryptr; /* find the object in question and remove it */ - for (entryptr = &pool->hashtable[hashnum]; *entryptr != NULL; entryptr = &(*entryptr)->next) + for (entryptr = &pool->hashtable[hashnum]; *entryptr != nullptr; entryptr = &(*entryptr)->next) if ((*entryptr)->object == object) { object_entry *entry = *entryptr; @@ -346,9 +346,9 @@ void *pool_object_remove(object_pool *pool, void *object, int destruct) (*entry->type->destructor)(entry->object, entry->size); /* remove us from the global list */ - if (entry->globalprev != NULL) + if (entry->globalprev != nullptr) entry->globalprev->globalnext = entry->globalnext; - if (entry->globalnext != NULL) + if (entry->globalnext != nullptr) entry->globalnext->globalprev = entry->globalprev; if (pool->globallist == entry) pool->globallist = entry->globalnext; @@ -362,7 +362,7 @@ void *pool_object_remove(object_pool *pool, void *object, int destruct) break; } - return NULL; + return nullptr; } @@ -377,7 +377,7 @@ int pool_object_exists(object_pool *pool, object_type type, void *object) object_entry *entry; /* find the object in question */ - for (entry = pool->hashtable[hashnum]; entry != NULL; entry = entry->next) + for (entry = pool->hashtable[hashnum]; entry != nullptr; entry = entry->next) if (entry->object == object && (type == OBJTYPE_WILDCARD || entry->type->type == type)) return TRUE; @@ -401,14 +401,14 @@ object_pool_iterator *pool_iterate_begin(object_pool *pool, object_type type) /* allocate the iterator */ iter = (object_pool_iterator *)malloc(sizeof(*iter)); - if (iter == NULL) - return NULL; + if (iter == nullptr) + return nullptr; memset(iter, 0, sizeof(*iter)); /* fill it in */ iter->pool = pool; iter->type = type; - iter->last = NULL; + iter->last = nullptr; return iter; } @@ -421,19 +421,19 @@ object_pool_iterator *pool_iterate_begin(object_pool *pool, object_type type) int pool_iterate_next(object_pool_iterator *iter, void **objectptr, size_t *sizeptr, object_type *typeptr) { /* if no previous entry, find the first */ - if (iter->last == NULL) + if (iter->last == nullptr) iter->last = iter->pool->globallist; else iter->last = iter->last->globalnext; /* stop when we get one */ - if (iter->last != NULL) + if (iter->last != nullptr) { - if (objectptr != NULL) + if (objectptr != nullptr) *objectptr = iter->last; - if (sizeptr != NULL) + if (sizeptr != nullptr) *sizeptr = iter->last->size; - if (typeptr != NULL) + if (typeptr != nullptr) *typeptr = iter->last->type->type; return TRUE; } @@ -478,7 +478,7 @@ void *pool_malloc_file_line(object_pool *pool, size_t size, const char *file, in void *pool_realloc_file_line(object_pool *pool, void *ptr, size_t size, const char *file, int line) { - if (ptr != NULL) + if (ptr != nullptr) pool_object_remove(pool, ptr, FALSE); ptr = realloc(ptr, size); if (size != 0) @@ -495,7 +495,7 @@ void *pool_realloc_file_line(object_pool *pool, void *ptr, size_t size, const ch char *pool_strdup_file_line(object_pool *pool, const char *str, const char *file, int line) { char *ptr = (char *)pool_malloc_file_line(pool, strlen(str) + 1, file, line); - if (ptr != NULL) + if (ptr != nullptr) strcpy(ptr, str); return ptr; } @@ -530,7 +530,7 @@ static void memory_destruct(void *object, size_t size) static void report_failure(object_pool *pool, const char *format, ...) { /* only do the work if we have a callback */ - if (pool->fail != NULL) + if (pool->fail != nullptr) { char message[1024]; va_list argptr; diff --git a/src/lib/util/tagmap.h b/src/lib/util/tagmap.h index 50550f3e6c3..600cc230985 100644 --- a/src/lib/util/tagmap.h +++ b/src/lib/util/tagmap.h @@ -16,6 +16,7 @@ #include "osdcore.h" #include "coretmpl.h" #include +#include #ifdef MAME_DEBUG #include "eminline.h" #endif @@ -61,10 +62,10 @@ public: public: // construction/destruction entry_t(const char *tag, UINT32 fullhash, _ElementType object) - : m_next(NULL), + : m_next(nullptr), m_fullhash(fullhash), m_tag(tag), - m_object(object) { } + m_object(std::move(object)) { } // accessors const std::string &tag() const { return m_tag; } @@ -101,9 +102,9 @@ public: // empty the list void reset() { - for (UINT32 hashindex = 0; hashindex < ARRAY_LENGTH(m_table); hashindex++) - while (m_table[hashindex] != NULL) - remove_common(&m_table[hashindex]); + for (auto & elem : m_table) + while (elem != nullptr) + remove_common(&elem); } // add/remove @@ -114,7 +115,7 @@ public: void remove(const char *tag) { UINT32 fullhash = hash(tag); - for (entry_t **entryptr = &m_table[fullhash % ARRAY_LENGTH(m_table)]; *entryptr != NULL; entryptr = &(*entryptr)->m_next) + for (entry_t **entryptr = &m_table[fullhash % ARRAY_LENGTH(m_table)]; *entryptr != nullptr; entryptr = &(*entryptr)->m_next) if ((*entryptr)->fullhash() == fullhash && (*entryptr)->tag() == tag) return remove_common(entryptr); } @@ -122,8 +123,8 @@ public: // remove by object void remove(_ElementType object) { - for (UINT32 hashindex = 0; hashindex < ARRAY_LENGTH(m_table); hashindex++) - for (entry_t **entryptr = &m_table[hashindex]; *entryptr != NULL; entryptr = &(*entryptr)->m_next) + for (auto & elem : m_table) + for (entry_t **entryptr = &elem; *entryptr != nullptr; entryptr = &(*entryptr)->m_next) if ((*entryptr)->object() == object) return remove_common(entryptr); } @@ -138,10 +139,10 @@ public: if (g_tagmap_counter_enabled) atomic_increment32(&g_tagmap_finds); #endif - for (entry_t *entry = m_table[fullhash % ARRAY_LENGTH(m_table)]; entry != NULL; entry = entry->next()) + for (entry_t *entry = m_table[fullhash % ARRAY_LENGTH(m_table)]; entry != nullptr; entry = entry->next()) if (entry->fullhash() == fullhash && entry->tag() == tag) return entry->object(); - return _ElementType(NULL); + return _ElementType(nullptr); } // find by tag without checking anything but the hash @@ -152,10 +153,10 @@ public: atomic_increment32(&g_tagmap_finds); #endif UINT32 fullhash = hash(tag); - for (entry_t *entry = m_table[fullhash % ARRAY_LENGTH(m_table)]; entry != NULL; entry = entry->next()) + for (entry_t *entry = m_table[fullhash % ARRAY_LENGTH(m_table)]; entry != nullptr; entry = entry->next()) if (entry->fullhash() == fullhash) return entry->object(); - return NULL; + return nullptr; } // return first object in the table @@ -288,7 +289,7 @@ public: // operations by tag _ElementType &replace_and_remove(const char *tag, _ElementType &object) { _ElementType *existing = find(tag); return (existing == NULL) ? append(tag, object) : replace_and_remove(tag, object, *existing); } - void remove(const char *tag) { _ElementType *object = find(tag); if (object != NULL) remove(*object); } + void remove(const char *tag) { _ElementType *object = find(tag); if (object != nullptr) remove(*object); } _ElementType *find(const char *tag) const { return m_map.find_hash_only(tag); } int indexof(const char *tag) const { _ElementType *object = find(tag); return (object != NULL) ? m_list.indexof(*object) : NULL; } @@ -316,7 +317,7 @@ tagmap_error tagmap_t<_ElementType, _HashSize>::add_common(const char *tag, _Ele UINT32 hashindex = fullhash % ARRAY_LENGTH(m_table); // first make sure we don't have a duplicate - for (entry_t *entry = m_table[hashindex]; entry != NULL; entry = entry->next()) + for (entry_t *entry = m_table[hashindex]; entry != nullptr; entry = entry->next()) if (entry->fullhash() == fullhash) if (unique_hash || entry->tag() == tag) { @@ -326,7 +327,7 @@ tagmap_error tagmap_t<_ElementType, _HashSize>::add_common(const char *tag, _Ele } // now allocate a new entry and add to the head of the list - entry_t *entry = global_alloc(entry_t(tag, fullhash, object)); + auto entry = global_alloc(entry_t(tag, fullhash, object)); entry->m_next = m_table[hashindex]; m_table[hashindex] = entry; return TMERR_NONE; diff --git a/src/lib/util/un7z.cpp b/src/lib/util/un7z.cpp index bbae440e0ff..b9cfa13eafe 100644 --- a/src/lib/util/un7z.cpp +++ b/src/lib/util/un7z.cpp @@ -24,7 +24,7 @@ void *SZipAlloc(void *p, size_t size) { if (size == 0) - return 0; + return nullptr; return malloc(size); } @@ -38,7 +38,7 @@ void SZipFree(void *p, void *address) void File_Construct(CSzFile *p) { - p->_7z_osdfile = NULL; + p->_7z_osdfile = nullptr; } static WRes File_Open(CSzFile *p, const char *name, int writeMode) @@ -186,7 +186,7 @@ static void free__7z_file(_7z_file *_7z); int _7z_search_crc_match(_7z_file *new_7z, UINT32 search_crc, const char* search_filename, int search_filename_length, bool matchcrc, bool matchname) { - UInt16 *temp = NULL; + UInt16 *temp = nullptr; size_t tempSize = 0; for (int i = 0; i < new_7z->db.db.NumFiles; i++) @@ -194,7 +194,7 @@ int _7z_search_crc_match(_7z_file *new_7z, UINT32 search_crc, const char* search const CSzFileItem *f = new_7z->db.db.Files + i; size_t len; - len = SzArEx_GetFileNameUtf16(&new_7z->db, i, NULL); + len = SzArEx_GetFileNameUtf16(&new_7z->db, i, nullptr); // if it's a directory entry we don't care about it.. if (f->IsDir) @@ -202,10 +202,10 @@ int _7z_search_crc_match(_7z_file *new_7z, UINT32 search_crc, const char* search if (len > tempSize) { - SZipFree(NULL, temp); + SZipFree(nullptr, temp); tempSize = len; - temp = (UInt16 *)SZipAlloc(NULL, tempSize * sizeof(temp[0])); - if (temp == 0) + temp = (UInt16 *)SZipAlloc(nullptr, tempSize * sizeof(temp[0])); + if (temp == nullptr) { return -1; // memory error } @@ -265,12 +265,12 @@ int _7z_search_crc_match(_7z_file *new_7z, UINT32 search_crc, const char* search new_7z->uncompressed_length = size; new_7z->crc = crc; - SZipFree(NULL, temp); + SZipFree(nullptr, temp); return i; } } - SZipFree(NULL, temp); + SZipFree(nullptr, temp); return -1; } @@ -288,7 +288,7 @@ _7z_error _7z_file_open(const char *filename, _7z_file **_7z) SRes res; /* ensure we start with a NULL result */ - *_7z = NULL; + *_7z = nullptr; /* see if we are in the cache, and reopen if so */ for (cachenum = 0; cachenum < ARRAY_LENGTH(_7z_cache); cachenum++) @@ -296,17 +296,17 @@ _7z_error _7z_file_open(const char *filename, _7z_file **_7z) _7z_file *cached = _7z_cache[cachenum]; /* if we have a valid entry and it matches our filename, use it and remove from the cache */ - if (cached != NULL && cached->filename != NULL && strcmp(filename, cached->filename) == 0) + if (cached != nullptr && cached->filename != nullptr && strcmp(filename, cached->filename) == 0) { *_7z = cached; - _7z_cache[cachenum] = NULL; + _7z_cache[cachenum] = nullptr; return _7ZERR_NONE; } } /* allocate memory for the _7z_file structure */ new_7z = (_7z_file *)malloc(sizeof(*new_7z)); - if (new_7z == NULL) + if (new_7z == nullptr) return _7ZERR_OUT_OF_MEMORY; memset(new_7z, 0, sizeof(*new_7z)); @@ -350,12 +350,12 @@ _7z_error _7z_file_open(const char *filename, _7z_file **_7z) } new_7z->blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */ - new_7z->outBuffer = 0; /* it must be 0 before first call for each new archive. */ + new_7z->outBuffer = nullptr; /* it must be 0 before first call for each new archive. */ new_7z->outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */ /* make a copy of the filename for caching purposes */ string = (char *)malloc(strlen(filename) + 1); - if (string == NULL) + if (string == nullptr) { _7zerr = _7ZERR_OUT_OF_MEMORY; goto error; @@ -381,13 +381,13 @@ void _7z_file_close(_7z_file *_7z) int cachenum; /* close the open files */ - if (_7z->archiveStream.file._7z_osdfile != NULL) + if (_7z->archiveStream.file._7z_osdfile != nullptr) osd_close(_7z->archiveStream.file._7z_osdfile); - _7z->archiveStream.file._7z_osdfile = NULL; + _7z->archiveStream.file._7z_osdfile = nullptr; /* find the first NULL entry in the cache */ for (cachenum = 0; cachenum < ARRAY_LENGTH(_7z_cache); cachenum++) - if (_7z_cache[cachenum] == NULL) + if (_7z_cache[cachenum] == nullptr) break; /* if no room left in the cache, free the bottommost entry */ @@ -412,10 +412,10 @@ void _7z_file_cache_clear(void) /* clear call cache entries */ for (cachenum = 0; cachenum < ARRAY_LENGTH(_7z_cache); cachenum++) - if (_7z_cache[cachenum] != NULL) + if (_7z_cache[cachenum] != nullptr) { free__7z_file(_7z_cache[cachenum]); - _7z_cache[cachenum] = NULL; + _7z_cache[cachenum] = nullptr; } } @@ -432,7 +432,7 @@ _7z_error _7z_file_decompress(_7z_file *new_7z, void *buffer, UINT32 length) int index = new_7z->curr_file_idx; /* make sure the file is open.. */ - if (new_7z->archiveStream.file._7z_osdfile==NULL) + if (new_7z->archiveStream.file._7z_osdfile==nullptr) { new_7z->archiveStream.file._7z_currfpos = 0; err = osd_open(new_7z->filename, OPEN_FLAG_READ, &new_7z->archiveStream.file._7z_osdfile, &new_7z->archiveStream.file._7z_length); @@ -477,11 +477,11 @@ _7z_error _7z_file_decompress(_7z_file *new_7z, void *buffer, UINT32 length) static void free__7z_file(_7z_file *_7z) { - if (_7z != NULL) + if (_7z != nullptr) { - if (_7z->archiveStream.file._7z_osdfile != NULL) + if (_7z->archiveStream.file._7z_osdfile != nullptr) osd_close(_7z->archiveStream.file._7z_osdfile); - if (_7z->filename != NULL) + if (_7z->filename != nullptr) free((void *)_7z->filename); diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp index 5f375337b34..e2c3956cedb 100644 --- a/src/lib/util/unicode.cpp +++ b/src/lib/util/unicode.cpp @@ -34,7 +34,7 @@ int uchar_from_utf8(unicode_char *uchar, const char *utf8char, size_t count) char auxchar; /* validate parameters */ - if (utf8char == NULL || count == 0) + if (utf8char == nullptr || count == 0) return 0; /* start with the first byte */ @@ -127,7 +127,7 @@ int uchar_from_utf16(unicode_char *uchar, const utf16_char *utf16char, size_t co int rc = -1; /* validate parameters */ - if (utf16char == NULL || count == 0) + if (utf16char == nullptr || count == 0) return 0; /* handle the two-byte case */ diff --git a/src/lib/util/unzip.cpp b/src/lib/util/unzip.cpp index 21e137b9f24..a8f3ca434e2 100644 --- a/src/lib/util/unzip.cpp +++ b/src/lib/util/unzip.cpp @@ -185,7 +185,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) int cachenum; /* ensure we start with a NULL result */ - *zip = NULL; + *zip = nullptr; /* see if we are in the cache, and reopen if so */ for (cachenum = 0; cachenum < ARRAY_LENGTH(zip_cache); cachenum++) @@ -193,17 +193,17 @@ zip_error zip_file_open(const char *filename, zip_file **zip) zip_file *cached = zip_cache[cachenum]; /* if we have a valid entry and it matches our filename, use it and remove from the cache */ - if (cached != NULL && cached->filename != NULL && strcmp(filename, cached->filename) == 0) + if (cached != nullptr && cached->filename != nullptr && strcmp(filename, cached->filename) == 0) { *zip = cached; - zip_cache[cachenum] = NULL; + zip_cache[cachenum] = nullptr; return ZIPERR_NONE; } } /* allocate memory for the zip_file structure */ newzip = (zip_file *)malloc(sizeof(*newzip)); - if (newzip == NULL) + if (newzip == nullptr) return ZIPERR_OUT_OF_MEMORY; memset(newzip, 0, sizeof(*newzip)); @@ -229,7 +229,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) /* allocate memory for the central directory */ newzip->cd = (UINT8 *)malloc(newzip->ecd.cd_size + 1); - if (newzip->cd == NULL) + if (newzip->cd == nullptr) { ziperr = ZIPERR_OUT_OF_MEMORY; goto error; @@ -245,7 +245,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) /* make a copy of the filename for caching purposes */ string = (char *)malloc(strlen(filename) + 1); - if (string == NULL) + if (string == nullptr) { ziperr = ZIPERR_OUT_OF_MEMORY; goto error; @@ -279,13 +279,13 @@ void zip_file_close(zip_file *zip) int cachenum; /* close the open files */ - if (zip->file != NULL) + if (zip->file != nullptr) osd_close(zip->file); - zip->file = NULL; + zip->file = nullptr; /* find the first NULL entry in the cache */ for (cachenum = 0; cachenum < ARRAY_LENGTH(zip_cache); cachenum++) - if (zip_cache[cachenum] == NULL) + if (zip_cache[cachenum] == nullptr) break; /* if no room left in the cache, free the bottommost entry */ @@ -316,10 +316,10 @@ void zip_file_cache_clear(void) /* clear call cache entries */ for (cachenum = 0; cachenum < ARRAY_LENGTH(zip_cache); cachenum++) - if (zip_cache[cachenum] != NULL) + if (zip_cache[cachenum] != nullptr) { free_zip_file(zip_cache[cachenum]); - zip_cache[cachenum] = NULL; + zip_cache[cachenum] = nullptr; } } @@ -370,15 +370,15 @@ const zip_file_header *zip_file_first_file(zip_file *zip) const zip_file_header *zip_file_next_file(zip_file *zip) { /* fix up any modified data */ - if (zip->header.raw != NULL) + if (zip->header.raw != nullptr) { zip->header.raw[ZIPCFN + zip->header.filename_length] = zip->header.saved; - zip->header.raw = NULL; + zip->header.raw = nullptr; } /* if we're at or past the end, we're done */ if (zip->cd_pos >= zip->ecd.cd_size) - return NULL; + return nullptr; /* extract file header info */ zip->header.raw = zip->cd + zip->cd_pos; @@ -407,7 +407,7 @@ const zip_file_header *zip_file_next_file(zip_file *zip) zip->header.rawlength += zip->header.extra_field_length; zip->header.rawlength += zip->header.file_comment_length; if (zip->cd_pos + zip->header.rawlength > zip->ecd.cd_size) - return NULL; + return nullptr; /* NULL terminate the filename */ zip->header.saved = zip->header.raw[ZIPCFN + zip->header.filename_length]; @@ -493,15 +493,15 @@ zip_error zip_file_decompress(zip_file *zip, void *buffer, UINT32 length) static void free_zip_file(zip_file *zip) { - if (zip != NULL) + if (zip != nullptr) { - if (zip->file != NULL) + if (zip->file != nullptr) osd_close(zip->file); - if (zip->filename != NULL) + if (zip->filename != nullptr) free((void *)zip->filename); - if (zip->ecd.raw != NULL) + if (zip->ecd.raw != nullptr) free(zip->ecd.raw); - if (zip->cd != NULL) + if (zip->cd != nullptr) free(zip->cd); free(zip); } @@ -545,7 +545,7 @@ static zip_error read_ecd(zip_file *zip) /* allocate buffer */ buffer = (UINT8 *)malloc(buflen + 1); - if (buffer == NULL) + if (buffer == nullptr) return ZIPERR_OUT_OF_MEMORY; /* read in one buffers' worth of data */ @@ -618,7 +618,7 @@ static zip_error get_compressed_data_offset(zip_file *zip, UINT64 *offset) UINT32 read_length; /* make sure the file handle is open */ - if (zip->file == NULL) + if (zip->file == nullptr) { int filerr = osd_open(zip->filename, OPEN_FLAG_READ, &zip->file, &zip->length); if (filerr != FILERR_NONE) diff --git a/src/lib/util/vbiparse.cpp b/src/lib/util/vbiparse.cpp index 9c6c39fc4ea..ff523ee4265 100644 --- a/src/lib/util/vbiparse.cpp +++ b/src/lib/util/vbiparse.cpp @@ -398,7 +398,7 @@ void vbi_metadata_pack(UINT8 *dest, UINT32 framenum, const vbi_metadata *vbi) void vbi_metadata_unpack(vbi_metadata *vbi, UINT32 *framenum, const UINT8 *source) { - if (framenum != NULL) + if (framenum != nullptr) *framenum = (source[0] << 16) | (source[1] << 8) | source[2]; vbi->white = source[3]; vbi->line16 = (source[4] << 16) | (source[5] << 8) | source[6]; diff --git a/src/lib/util/xmlfile.cpp b/src/lib/util/xmlfile.cpp index cb674abfa2b..620f12a66b3 100644 --- a/src/lib/util/xmlfile.cpp +++ b/src/lib/util/xmlfile.cpp @@ -71,12 +71,12 @@ static const char *copystring(const char *input) char *newstr; /* NULL just passes through */ - if (input == NULL) - return NULL; + if (input == nullptr) + return nullptr; /* make a lower-case copy if the allocation worked */ newstr = (char *)malloc(strlen(input) + 1); - if (newstr != NULL) + if (newstr != nullptr) strcpy(newstr, input); return newstr; @@ -95,12 +95,12 @@ static const char *copystring_lower(const char *input) int i; /* NULL just passes through */ - if (input == NULL) - return NULL; + if (input == nullptr) + return nullptr; /* make a lower-case copy if the allocation worked */ newstr = (char *)malloc(strlen(input) + 1); - if (newstr != NULL) + if (newstr != nullptr) { for (i = 0; input[i] != 0; i++) newstr[i] = tolower((UINT8)input[i]); @@ -127,8 +127,8 @@ xml_data_node *xml_file_create(void) /* create a root node */ rootnode = (xml_data_node *)malloc(sizeof(*rootnode)); - if (rootnode == NULL) - return NULL; + if (rootnode == nullptr) + return nullptr; memset(rootnode, 0, sizeof(*rootnode)); return rootnode; } @@ -146,7 +146,7 @@ xml_data_node *xml_file_read(core_file *file, xml_parse_options *opts) /* set up the parser */ if (!expat_setup_parser(&parse_info, opts)) - return NULL; + return nullptr; /* loop through the file and parse it */ do @@ -160,7 +160,7 @@ xml_data_node *xml_file_read(core_file *file, xml_parse_options *opts) /* parse the data */ if (XML_Parse(parse_info.parser, tempbuf, bytes, done) == XML_STATUS_ERROR) { - if (opts != NULL && opts->error != NULL) + if (opts != nullptr && opts->error != nullptr) { opts->error->error_message = XML_ErrorString(XML_GetErrorCode(parse_info.parser)); opts->error->error_line = XML_GetCurrentLineNumber(parse_info.parser); @@ -169,7 +169,7 @@ xml_data_node *xml_file_read(core_file *file, xml_parse_options *opts) xml_file_free(parse_info.rootnode); XML_ParserFree(parse_info.parser); - return NULL; + return nullptr; } } while (!done); @@ -194,12 +194,12 @@ xml_data_node *xml_string_read(const char *string, xml_parse_options *opts) /* set up the parser */ if (!expat_setup_parser(&parse_info, opts)) - return NULL; + return nullptr; /* parse the data */ if (XML_Parse(parse_info.parser, string, length, TRUE) == XML_STATUS_ERROR) { - if (opts != NULL && opts->error != NULL) + if (opts != nullptr && opts->error != nullptr) { opts->error->error_message = XML_ErrorString(XML_GetErrorCode(parse_info.parser)); opts->error->error_line = XML_GetCurrentLineNumber(parse_info.parser); @@ -208,7 +208,7 @@ xml_data_node *xml_string_read(const char *string, xml_parse_options *opts) xml_file_free(parse_info.rootnode); XML_ParserFree(parse_info.parser); - return NULL; + return nullptr; } /* free the parser */ @@ -226,7 +226,7 @@ xml_data_node *xml_string_read(const char *string, xml_parse_options *opts) void xml_file_write(xml_data_node *node, core_file *file) { /* ensure this is a root node */ - if (node->name != NULL) + if (node->name != nullptr) return; /* output a simple header */ @@ -246,7 +246,7 @@ void xml_file_write(xml_data_node *node, core_file *file) void xml_file_free(xml_data_node *node) { /* ensure this is a root node */ - if (node->name != NULL) + if (node->name != nullptr) return; free_node_recursive(node); @@ -285,7 +285,7 @@ xml_data_node *xml_get_sibling(xml_data_node *node, const char *name) for ( ; node; node = node->next) if (strcmp(node->name, name) == 0) return node; - return NULL; + return nullptr; } @@ -301,15 +301,15 @@ xml_data_node *xml_find_matching_sibling(xml_data_node *node, const char *name, for ( ; node; node = node->next) { /* can pass NULL as a wildcard for the node name */ - if (name == NULL || strcmp(name, node->name) == 0) + if (name == nullptr || strcmp(name, node->name) == 0) { /* find a matching attribute */ xml_attribute_node *attr = xml_get_attribute(node, attribute); - if (attr != NULL && strcmp(attr->value, matchval) == 0) + if (attr != nullptr && strcmp(attr->value, matchval) == 0) return node; } } - return NULL; + return nullptr; } @@ -336,7 +336,7 @@ xml_data_node *xml_get_or_add_child(xml_data_node *node, const char *name, const /* find the child first */ child = xml_get_sibling(node->child, name); - if (child != NULL) + if (child != nullptr) return child; /* if not found, do a standard add child */ @@ -384,7 +384,7 @@ xml_attribute_node *xml_get_attribute(xml_data_node *node, const char *attribute for (anode = node->attribute; anode; anode = anode->next) if (strcmp(anode->name, attribute) == 0) return anode; - return NULL; + return nullptr; } @@ -409,11 +409,11 @@ const char *xml_get_attribute_string(xml_data_node *node, const char *attribute, int xml_get_attribute_int(xml_data_node *node, const char *attribute, int defvalue) { - const char *string = xml_get_attribute_string(node, attribute, NULL); + const char *string = xml_get_attribute_string(node, attribute, nullptr); int value; unsigned int uvalue; - if (string == NULL) + if (string == nullptr) return defvalue; if (string[0] == '$') return (sscanf(&string[1], "%X", &uvalue) == 1) ? uvalue : defvalue; @@ -432,9 +432,9 @@ int xml_get_attribute_int(xml_data_node *node, const char *attribute, int defval int xml_get_attribute_int_format(xml_data_node *node, const char *attribute) { - const char *string = xml_get_attribute_string(node, attribute, NULL); + const char *string = xml_get_attribute_string(node, attribute, nullptr); - if (string == NULL) + if (string == nullptr) return XML_INT_FORMAT_DECIMAL; if (string[0] == '$') return XML_INT_FORMAT_HEX_DOLLAR; @@ -466,10 +466,10 @@ int xml_get_attribute_int_format(xml_data_node *node, const char *attribute) float xml_get_attribute_float(xml_data_node *node, const char *attribute, float defvalue) { - const char *string = xml_get_attribute_string(node, attribute, NULL); + const char *string = xml_get_attribute_string(node, attribute, nullptr); float value; - if (string == NULL || sscanf(string, "%f", &value) != 1) + if (string == nullptr || sscanf(string, "%f", &value) != 1) return defvalue; return value; } @@ -500,9 +500,9 @@ xml_attribute_node *xml_set_attribute(xml_data_node *node, const char *name, con anode = xml_get_attribute(node, name); /* if we found it, free the old value and replace it */ - if (anode != NULL) + if (anode != nullptr) { - if (anode->value != NULL) + if (anode->value != nullptr) free((void *)anode->value); anode->value = copystring(value); } @@ -590,7 +590,7 @@ const char *xml_normalize_string(const char *string) static char buffer[1024]; char *d = &buffer[0]; - if (string != NULL) + if (string != nullptr) { while (*string) { @@ -650,7 +650,7 @@ static void *expat_malloc(size_t size) static void expat_free(void *ptr) { - if (ptr != NULL) + if (ptr != nullptr) free(&((UINT32 *)ptr)[-4]); } @@ -668,9 +668,9 @@ static void expat_free(void *ptr) static void *expat_realloc(void *ptr, size_t size) { void *newptr = expat_malloc(size); - if (newptr == NULL) - return NULL; - if (ptr != NULL) + if (newptr == nullptr) + return nullptr; + if (ptr != nullptr) { UINT32 oldsize = ((UINT32 *)ptr)[-4]; memcpy(newptr, ptr, oldsize); @@ -701,12 +701,12 @@ static int expat_setup_parser(xml_parse_info *parse_info, xml_parse_options *opt /* setup parse_info structure */ memset(parse_info, 0, sizeof(*parse_info)); - if (opts != NULL) + if (opts != nullptr) { parse_info->flags = opts->flags; - if (opts->error != NULL) + if (opts->error != nullptr) { - opts->error->error_message = NULL; + opts->error->error_message = nullptr; opts->error->error_line = 0; opts->error->error_column = 0; } @@ -714,7 +714,7 @@ static int expat_setup_parser(xml_parse_info *parse_info, xml_parse_options *opt /* create a root node */ parse_info->rootnode = xml_file_create(); - if (parse_info->rootnode == NULL) + if (parse_info->rootnode == nullptr) return FALSE; parse_info->curnode = parse_info->rootnode; @@ -722,8 +722,8 @@ static int expat_setup_parser(xml_parse_info *parse_info, xml_parse_options *opt memcallbacks.malloc_fcn = expat_malloc; memcallbacks.realloc_fcn = expat_realloc; memcallbacks.free_fcn = expat_free; - parse_info->parser = XML_ParserCreate_MM(NULL, &memcallbacks, NULL); - if (parse_info->parser == NULL) + parse_info->parser = XML_ParserCreate_MM(nullptr, &memcallbacks, nullptr); + if (parse_info->parser == nullptr) { free(parse_info->rootnode); return FALSE; @@ -735,7 +735,7 @@ static int expat_setup_parser(xml_parse_info *parse_info, xml_parse_options *opt XML_SetUserData(parse_info->parser, parse_info); /* optional parser initialization step */ - if (opts != NULL && opts->init_parser != NULL) + if (opts != nullptr && opts->init_parser != nullptr) (*opts->init_parser)(parse_info->parser); return TRUE; } @@ -764,8 +764,8 @@ static void expat_element_start(void *data, const XML_Char *name, const XML_Char int attr; /* add a new child node to the current node */ - newnode = add_child(*curnode, name, NULL); - if (newnode == NULL) + newnode = add_child(*curnode, name, nullptr); + if (newnode == nullptr) return; /* remember the line number */ @@ -807,14 +807,14 @@ static void expat_data(void *data, const XML_Char *s, int len) return; /* determine how much data we currently have */ - if ((*curnode)->value != NULL) + if ((*curnode)->value != nullptr) oldlen = (int)strlen((*curnode)->value); /* realloc */ newdata = (char *)malloc(oldlen + len + 1); - if (newdata == NULL) + if (newdata == nullptr) return; - if ((*curnode)->value != NULL) + if ((*curnode)->value != nullptr) { memcpy(newdata, (*curnode)->value, oldlen); free((void *)(*curnode)->value); @@ -850,7 +850,7 @@ static void expat_element_end(void *data, const XML_Char *name) /* strip leading/trailing spaces from the value data */ orig = (char *)(*curnode)->value; - if (orig != NULL && !(parse_info->flags & XML_PARSE_FLAG_WHITESPACE_SIGNIFICANT)) + if (orig != nullptr && !(parse_info->flags & XML_PARSE_FLAG_WHITESPACE_SIGNIFICANT)) { char *start = orig; char *end = start + strlen(start); @@ -867,7 +867,7 @@ static void expat_element_end(void *data, const XML_Char *name) if (start == end) { free(orig); - (*curnode)->value = NULL; + (*curnode)->value = nullptr; } /* otherwise, memmove the data */ @@ -911,27 +911,27 @@ static xml_data_node *add_child(xml_data_node *parent, const char *name, const c /* new element: create a new node */ node = (xml_data_node *)malloc(sizeof(*node)); - if (node == NULL) - return NULL; + if (node == nullptr) + return nullptr; /* initialize the members */ - node->next = NULL; + node->next = nullptr; node->parent = parent; - node->child = NULL; + node->child = nullptr; node->name = copystring_lower(name); - if (node->name == NULL) + if (node->name == nullptr) { free(node); - return NULL; + return nullptr; } node->value = copystring(value); - if (node->value == NULL && value != NULL) + if (node->value == nullptr && value != nullptr) { free((void *)node->name); free(node); - return NULL; + return nullptr; } - node->attribute = NULL; + node->attribute = nullptr; /* add us to the end of the list of siblings */ for (pnode = &parent->child; *pnode; pnode = &(*pnode)->next) ; @@ -964,23 +964,23 @@ static xml_attribute_node *add_attribute(xml_data_node *node, const char *name, /* allocate a new attribute node */ anode = (xml_attribute_node *)malloc(sizeof(*anode)); - if (anode == NULL) - return NULL; + if (anode == nullptr) + return nullptr; /* fill it in */ - anode->next = NULL; + anode->next = nullptr; anode->name = copystring_lower(name); - if (anode->name == NULL) + if (anode->name == nullptr) { free(anode); - return NULL; + return nullptr; } anode->value = copystring(value); - if (anode->value == NULL) + if (anode->value == nullptr) { free((void *)anode->name); free(anode); - return NULL; + return nullptr; } /* add us to the end of the list of attributes */ @@ -1024,7 +1024,7 @@ static void write_node_recursive(xml_data_node *node, int indent, core_file *fil core_fprintf(file, " %s=\"%s\"", anode->name, anode->value); /* if there are no children and no value, end the tag here */ - if (node->child == NULL && node->value == NULL) + if (node->child == nullptr && node->value == nullptr) core_fprintf(file, " />\n"); /* otherwise, close this tag and output more stuff */ @@ -1033,11 +1033,11 @@ static void write_node_recursive(xml_data_node *node, int indent, core_file *fil core_fprintf(file, ">\n"); /* if there is a value, output that here */ - if (node->value != NULL) + if (node->value != nullptr) core_fprintf(file, "%*s%s\n", indent + 4, "", node->value); /* loop over children and output them as well */ - if (node->child != NULL) + if (node->child != nullptr) { for (child = node->child; child; child = child->next) write_node_recursive(child, indent + 4, file); @@ -1068,18 +1068,18 @@ static void free_node_recursive(xml_data_node *node) xml_data_node *child, *nchild; /* free name/value */ - if (node->name != NULL) + if (node->name != nullptr) free((void *)node->name); - if (node->value != NULL) + if (node->value != nullptr) free((void *)node->value); /* free attributes */ for (anode = node->attribute; anode; anode = nanode) { /* free name/value */ - if (anode->name != NULL) + if (anode->name != nullptr) free((void *)anode->name); - if (anode->value != NULL) + if (anode->value != nullptr) free((void *)anode->value); /* note the next node and free this node */ diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp index 36c9470ed92..84674eb1fe2 100644 --- a/src/lib/util/zippath.cpp +++ b/src/lib/util/zippath.cpp @@ -47,10 +47,10 @@ class zippath_directory public: zippath_directory() : returned_parent(false), - directory(NULL), + directory(nullptr), called_zip_first(false), - zipfile(NULL), - returned_dirlist(NULL) { } + zipfile(nullptr), + returned_dirlist(nullptr) { } /* common */ /** @brief true to returned parent. */ @@ -130,7 +130,7 @@ static void parse_parent_path(const char *path, int *beginpos, int *endpos) pos--; /* return endpos */ - if (endpos != NULL) + if (endpos != nullptr) *endpos = pos; /* now skip until we find a path separator */ @@ -138,7 +138,7 @@ static void parse_parent_path(const char *path, int *beginpos, int *endpos) pos--; /* return beginpos */ - if (beginpos != NULL) + if (beginpos != nullptr) *beginpos = pos; } @@ -162,7 +162,7 @@ static void parse_parent_path(const char *path, int *beginpos, int *endpos) std::string &zippath_parent(std::string &dst, const char *path) { int pos; - parse_parent_path(path, &pos, NULL); + parse_parent_path(path, &pos, nullptr); /* return the result */ if (pos >= 0) { @@ -316,7 +316,7 @@ static file_error create_core_file_from_zip(zip_file *zip, const zip_file_header void *ptr; ptr = malloc(header->uncompressed_length); - if (ptr == NULL) + if (ptr == nullptr) { filerr = FILERR_OUT_OF_MEMORY; goto done; @@ -334,7 +334,7 @@ static file_error create_core_file_from_zip(zip_file *zip, const zip_file_header goto done; done: - if (ptr != NULL) + if (ptr != nullptr) free(ptr); return filerr; } @@ -361,19 +361,19 @@ file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&fil { file_error filerr = FILERR_NOT_FOUND; zip_error ziperr; - zip_file *zip = NULL; + zip_file *zip = nullptr; const zip_file_header *header; osd_dir_entry_type entry_type; - char *alloc_fullpath = NULL; + char *alloc_fullpath = nullptr; int len; /* first, set up the two types of paths */ std::string mainpath(filename); std::string subpath; - file = NULL; + file = nullptr; /* loop through */ - while((file == NULL) && (mainpath.length() > 0) + while((file == nullptr) && (mainpath.length() > 0) && ((openflags == OPEN_FLAG_READ) || (subpath.length() == 0))) { /* is the mainpath a ZIP path? */ @@ -395,7 +395,7 @@ file_error zippath_fopen(const char *filename, UINT32 openflags, core_file *&fil else header = zip_file_first_file(zip); - if (header == NULL) + if (header == nullptr) { filerr = FILERR_NOT_FOUND; goto done; @@ -470,9 +470,9 @@ done: } } - if (zip != NULL) + if (zip != nullptr) zip_file_close(zip); - if (alloc_fullpath != NULL) + if (alloc_fullpath != nullptr) osd_free(alloc_fullpath); return filerr; } @@ -531,7 +531,7 @@ static int is_root(const char *path) static int is_7z_file(const char *path) { const char *s = strrchr(path, '.'); - return (s != NULL) && !core_stricmp(s, ".7z"); + return (s != nullptr) && !core_stricmp(s, ".7z"); } @@ -553,7 +553,7 @@ static int is_7z_file(const char *path) static int is_zip_file(const char *path) { const char *s = strrchr(path, '.'); - return (s != NULL) && !core_stricmp(s, ".zip"); + return (s != nullptr) && !core_stricmp(s, ".zip"); } @@ -678,12 +678,12 @@ static const zip_file_header *zippath_find_sub_path(zip_file *zipfile, const cha char c1, c2, last_char; const zip_file_header *header; - for (header = zip_file_first_file(zipfile); header != NULL; header = zip_file_next_file(zipfile)) + for (header = zip_file_first_file(zipfile); header != nullptr; header = zip_file_next_file(zipfile)) { /* special case */ - if (subpath == NULL) + if (subpath == nullptr) { - if (type != NULL) + if (type != nullptr) *type = ENTTYPE_FILE; return header; } @@ -700,22 +700,22 @@ static const zip_file_header *zippath_find_sub_path(zip_file *zipfile, const cha { if (c1 == '\0') { - if (type != NULL) + if (type != nullptr) *type = ENTTYPE_FILE; return header; } else if ((last_char == '/') || (c1 == '/')) { - if (type != NULL) + if (type != nullptr) *type = ENTTYPE_DIR; return header; } } } - if (type != NULL) + if (type != nullptr) *type = ENTTYPE_NONE; - return NULL; + return nullptr; } @@ -741,7 +741,7 @@ static const zip_file_header *zippath_find_sub_path(zip_file *zipfile, const cha static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, zip_file *&zipfile, std::string &newpath) { file_error err; - osd_directory_entry *current_entry = NULL; + osd_directory_entry *current_entry = nullptr; osd_dir_entry_type current_entry_type; int went_up = FALSE; int i; @@ -750,7 +750,7 @@ static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_ty /* be conservative */ entry_type = ENTTYPE_NONE; - zipfile = NULL; + zipfile = nullptr; std::string apath(path); std::string apath_trimmed; @@ -767,12 +767,12 @@ static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_ty current_entry = osd_stat(apath_trimmed.c_str()); /* did we find anything? */ - if (current_entry != NULL) + if (current_entry != nullptr) { /* get the entry type and free the stat entry */ current_entry_type = current_entry->type; osd_free(current_entry); - current_entry = NULL; + current_entry = nullptr; } else { @@ -849,7 +849,7 @@ file_error zippath_opendir(const char *path, zippath_directory **directory) file_error err; /* allocate a directory */ - zippath_directory *result = NULL; + zippath_directory *result = nullptr; try { result = new zippath_directory; @@ -873,11 +873,11 @@ file_error zippath_opendir(const char *path, zippath_directory **directory) } /* was the result a ZIP? */ - if (result->zipfile == NULL) + if (result->zipfile == nullptr) { /* a conventional directory */ result->directory = osd_opendir(path); - if (result->directory == NULL) + if (result->directory == nullptr) { err = FILERR_FAILURE; goto done; @@ -889,12 +889,12 @@ file_error zippath_opendir(const char *path, zippath_directory **directory) } done: - if ((directory == NULL || err != FILERR_NONE) && result != NULL) + if ((directory == nullptr || err != FILERR_NONE) && result != nullptr) { zippath_closedir(result); - result = NULL; + result = nullptr; } - if (directory != NULL) + if (directory != nullptr) *directory = result; return err; } @@ -914,13 +914,13 @@ done: void zippath_closedir(zippath_directory *directory) { - if (directory->directory != NULL) + if (directory->directory != nullptr) osd_closedir(directory->directory); - if (directory->zipfile != NULL) + if (directory->zipfile != nullptr) zip_file_close(directory->zipfile); - while (directory->returned_dirlist != NULL) + while (directory->returned_dirlist != nullptr) { zippath_returned_directory *dirlist = directory->returned_dirlist; directory->returned_dirlist = directory->returned_dirlist->next; @@ -950,7 +950,7 @@ void zippath_closedir(zippath_directory *directory) static const char *get_relative_path(zippath_directory *directory, const zip_file_header *header) { - const char *result = NULL; + const char *result = nullptr; int len = directory->zipprefix.length(); if ((len <= strlen(header->filename)) @@ -981,7 +981,7 @@ static const char *get_relative_path(zippath_directory *directory, const zip_fil const osd_directory_entry *zippath_readdir(zippath_directory *directory) { - const osd_directory_entry *result = NULL; + const osd_directory_entry *result = nullptr; const zip_file_header *header; const char *relpath; const char *separator; @@ -997,17 +997,17 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) directory->returned_entry.type = ENTTYPE_DIR; result = &directory->returned_entry; } - else if (directory->directory != NULL) + else if (directory->directory != nullptr) { /* a normal directory read */ do { result = osd_readdir(directory->directory); } - while((result != NULL) && (!strcmp(result->name, ".") || !strcmp(result->name, ".."))); + while((result != nullptr) && (!strcmp(result->name, ".") || !strcmp(result->name, ".."))); /* special case - is this entry a ZIP file? if so we need to return it as a "directory" */ - if ((result != NULL) && is_zip_file(result->name)) + if ((result != nullptr) && is_zip_file(result->name)) { /* copy; but change the entry type */ directory->returned_entry = *result; @@ -1015,7 +1015,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) result = &directory->returned_entry; } } - else if (directory->zipfile != NULL) + else if (directory->zipfile != nullptr) { do { @@ -1027,27 +1027,27 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) else header = zip_file_next_file(directory->zipfile); directory->called_zip_first = true; - relpath = NULL; + relpath = nullptr; } - while((header != NULL) && ((relpath = get_relative_path(directory, header)) == NULL)); + while((header != nullptr) && ((relpath = get_relative_path(directory, header)) == nullptr)); - if (relpath != NULL) + if (relpath != nullptr) { /* we've found a ZIP entry; but this may be an entry deep within the target directory */ for (s = relpath; *s && !is_zip_file_separator(*s); s++) ; - separator = *s ? s : NULL; + separator = *s ? s : nullptr; - if (separator != NULL) + if (separator != nullptr) { /* a nested entry; loop through returned_dirlist to see if we've returned the parent directory */ - for (rdent = directory->returned_dirlist; rdent != NULL; rdent = rdent->next) + for (rdent = directory->returned_dirlist; rdent != nullptr; rdent = rdent->next) { if (!core_strnicmp(rdent->name.c_str(), relpath, separator - relpath)) break; } - if (rdent == NULL) + if (rdent == nullptr) { /* we've found a new directory; add this to returned_dirlist */ rdent = new zippath_returned_directory; @@ -1073,7 +1073,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) } } } - while((relpath != NULL) && (result == NULL)); + while((relpath != nullptr) && (result == nullptr)); } return result; } @@ -1097,5 +1097,5 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) int zippath_is_zip(zippath_directory *directory) { - return directory->zipfile != NULL; + return directory->zipfile != nullptr; } diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index 982cfbf2234..d39e49d3bff 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -962,7 +962,7 @@ enum osd_output_channel class osd_output { public: - osd_output() : m_chain(NULL) { } + osd_output() : m_chain(nullptr) { } virtual ~osd_output() { } virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) = 0; @@ -973,7 +973,7 @@ protected: void chain_output(osd_output_channel channel, const char *msg, va_list args) { - if (m_chain != NULL) + if (m_chain != nullptr) m_chain->output_callback(channel, msg, args); } private: -- cgit v1.2.3-70-g09d2