diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2016-04-24 12:57:58 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2016-04-24 12:58:31 +0200 |
commit | 89c5e1f681107b6d9f8ba7f761c388d1e2052fe4 (patch) | |
tree | c5ce4530d0c03fa1c04021844272b82b7b7ebcbc /src/osd | |
parent | ef0968b87042040e1f0e18c84ce804f744f8e23e (diff) |
Various cleanups suggested by static analyzer (nw)
Diffstat (limited to 'src/osd')
104 files changed, 734 insertions, 720 deletions
diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp index 5c49d2df9a3..4cbca2cf5fc 100644 --- a/src/osd/modules/debugger/debugimgui.cpp +++ b/src/osd/modules/debugger/debugimgui.cpp @@ -79,8 +79,16 @@ class debug_imgui : public osd_module, public debug_module public: debug_imgui() : osd_module(OSD_DEBUG_PROVIDER, "imgui"), debug_module(), - m_machine(nullptr), - m_hide(false), + m_machine(nullptr), + m_mouse_x(0), + m_mouse_y(0), + m_mouse_button(false), + m_prev_mouse_button(false), + m_running(false), + font_name(nullptr), + font_size(0), + m_key_char(0), + m_hide(false), m_win_count(0) { } @@ -322,7 +330,7 @@ void debug_imgui::handle_keys() else io.KeyAlt = false; - for(input_item_id id = ITEM_ID_A; id <= ITEM_ID_CANCEL; id++) + for(input_item_id id = ITEM_ID_A; id <= ITEM_ID_CANCEL; ++id) { if(m_machine->input().code_pressed(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id))) io.KeysDown[id] = true; @@ -610,13 +618,13 @@ void debug_imgui::draw_disasm(debug_area* view_ptr, bool* opened) debug_view_disasm* disasm = downcast<debug_view_disasm*>(view_ptr->view); int rightcol = disasm->right_column(); - if(ImGui::MenuItem("Raw opcodes",NULL,(rightcol == DASM_RIGHTCOL_RAW) ? true : false)) + if(ImGui::MenuItem("Raw opcodes", nullptr,(rightcol == DASM_RIGHTCOL_RAW) ? true : false)) disasm->set_right_column(DASM_RIGHTCOL_RAW); - if(ImGui::MenuItem("Encrypted opcodes",NULL,(rightcol == DASM_RIGHTCOL_ENCRYPTED) ? true : false)) + if(ImGui::MenuItem("Encrypted opcodes", nullptr,(rightcol == DASM_RIGHTCOL_ENCRYPTED) ? true : false)) disasm->set_right_column(DASM_RIGHTCOL_ENCRYPTED); - if(ImGui::MenuItem("No opcodes",NULL,(rightcol == DASM_RIGHTCOL_NONE) ? true : false)) + if(ImGui::MenuItem("No opcodes", nullptr,(rightcol == DASM_RIGHTCOL_NONE) ? true : false)) disasm->set_right_column(DASM_RIGHTCOL_NONE); - if(ImGui::MenuItem("Comments",NULL,(rightcol == DASM_RIGHTCOL_COMMENTS) ? true : false)) + if(ImGui::MenuItem("Comments", nullptr,(rightcol == DASM_RIGHTCOL_COMMENTS) ? true : false)) disasm->set_right_column(DASM_RIGHTCOL_COMMENTS); ImGui::EndMenu(); @@ -748,27 +756,27 @@ void debug_imgui::draw_memory(debug_area* view_ptr, bool* opened) int format = mem->get_data_format(); UINT32 chunks = mem->chunks_per_row(); - if(ImGui::MenuItem("1-byte chunks",NULL,(format == 1) ? true : false)) + if(ImGui::MenuItem("1-byte chunks", nullptr,(format == 1) ? true : false)) mem->set_data_format(1); - if(ImGui::MenuItem("2-byte chunks",NULL,(format == 2) ? true : false)) + if(ImGui::MenuItem("2-byte chunks", nullptr,(format == 2) ? true : false)) mem->set_data_format(2); - if(ImGui::MenuItem("4-byte chunks",NULL,(format == 4) ? true : false)) + if(ImGui::MenuItem("4-byte chunks", nullptr,(format == 4) ? true : false)) mem->set_data_format(4); - if(ImGui::MenuItem("8-byte chunks",NULL,(format == 8) ? true : false)) + if(ImGui::MenuItem("8-byte chunks", nullptr,(format == 8) ? true : false)) mem->set_data_format(8); - if(ImGui::MenuItem("32-bit floating point",NULL,(format == 9) ? true : false)) + if(ImGui::MenuItem("32-bit floating point", nullptr,(format == 9) ? true : false)) mem->set_data_format(9); - if(ImGui::MenuItem("64-bit floating point",NULL,(format == 10) ? true : false)) + if(ImGui::MenuItem("64-bit floating point", nullptr,(format == 10) ? true : false)) mem->set_data_format(10); - if(ImGui::MenuItem("80-bit floating point",NULL,(format == 11) ? true : false)) + if(ImGui::MenuItem("80-bit floating point", nullptr,(format == 11) ? true : false)) mem->set_data_format(11); ImGui::Separator(); - if(ImGui::MenuItem("Logical addresses",NULL,!physical)) + if(ImGui::MenuItem("Logical addresses", nullptr,!physical)) mem->set_physical(false); - if(ImGui::MenuItem("Physical addresses",NULL,physical)) + if(ImGui::MenuItem("Physical addresses", nullptr,physical)) mem->set_physical(true); ImGui::Separator(); - if(ImGui::MenuItem("Reverse view",NULL,rev)) + if(ImGui::MenuItem("Reverse view", nullptr,rev)) mem->set_reverse(!rev); ImGui::Separator(); if(ImGui::MenuItem("Increase bytes per line")) @@ -894,7 +902,7 @@ void debug_imgui::draw_console() ImGuiWindowFlags flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; ImGui::SetNextWindowSize(ImVec2(view_main_regs->width + view_main_disasm->width,view_main_disasm->height + view_main_console->height + ImGui::GetTextLineHeight()*3),ImGuiSetCond_Once); - if(ImGui::Begin(view_main_console->title.c_str(),NULL,flags)) + if(ImGui::Begin(view_main_console->title.c_str(), nullptr,flags)) { const debug_view_char *viewdata; debug_view_xy vsize,totalsize; @@ -975,7 +983,7 @@ void debug_imgui::draw_console() collapsed = true; ImGui::End(); } - if(ImGui::MenuItem((*view_ptr)->title.c_str(),NULL,!collapsed)) + if(ImGui::MenuItem((*view_ptr)->title.c_str(), nullptr,!collapsed)) ImGui::SetWindowCollapsed((*view_ptr)->title.c_str(),false); } ImGui::EndMenu(); @@ -1176,7 +1184,7 @@ void debug_imgui::update() to_delete = (*view_ptr); break; } - view_ptr++; + ++view_ptr; count++; } // check for a closed window diff --git a/src/osd/modules/debugger/debugint.cpp b/src/osd/modules/debugger/debugint.cpp index 6ac60b81b41..b894f84f1a0 100644 --- a/src/osd/modules/debugger/debugint.cpp +++ b/src/osd/modules/debugger/debugint.cpp @@ -33,8 +33,8 @@ class debug_internal : public osd_module, public debug_module public: debug_internal() : osd_module(OSD_DEBUG_PROVIDER, "internal"), debug_module(), - m_machine(nullptr) - { + m_machine(nullptr), font_name(nullptr), font_size(0) +{ } virtual ~debug_internal() { } diff --git a/src/osd/modules/debugger/debugosx.mm b/src/osd/modules/debugger/debugosx.mm index 598a85dd569..56e85e21105 100644 --- a/src/osd/modules/debugger/debugosx.mm +++ b/src/osd/modules/debugger/debugosx.mm @@ -41,7 +41,7 @@ class debugger_osx : public osd_module, public debug_module public: debugger_osx() : osd_module(OSD_DEBUG_PROVIDER, "osx"), debug_module(), - m_machine(NULL), + m_machine(nullptr), m_console(nil) { } @@ -95,7 +95,7 @@ void debugger_osx::exit() userInfo:info]; [m_console release]; m_console = nil; - m_machine = NULL; + m_machine = nullptr; } [pool release]; } diff --git a/src/osd/modules/debugger/debugqt.cpp b/src/osd/modules/debugger/debugqt.cpp index ac6c6a9d95c..e9abe538981 100644 --- a/src/osd/modules/debugger/debugqt.cpp +++ b/src/osd/modules/debugger/debugqt.cpp @@ -40,7 +40,7 @@ class debug_qt : public osd_module, public debug_module public: debug_qt() : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(), - m_machine(NULL) + m_machine(nullptr) { } @@ -64,10 +64,10 @@ private: //============================================================ int qtArgc = 0; -char** qtArgv = NULL; +char** qtArgv = nullptr; bool oneShot = true; -static MainWindow* mainQtWindow = NULL; +static MainWindow* mainQtWindow = nullptr; //============================================================ // XML configuration save/load @@ -84,7 +84,7 @@ static void xml_configuration_load(running_machine &machine, config_type cfg_typ return; // Might not have any data - if (parentnode == NULL) + if (parentnode == nullptr) return; for (int i = 0; i < xmlConfigurations.size(); i++) @@ -92,8 +92,8 @@ static void xml_configuration_load(running_machine &machine, config_type cfg_typ xmlConfigurations.clear(); // Configuration load - xml_data_node* wnode = NULL; - for (wnode = xml_get_sibling(parentnode->child, "window"); wnode != NULL; wnode = xml_get_sibling(wnode->next, "window")) + xml_data_node* wnode = nullptr; + for (wnode = xml_get_sibling(parentnode->child, "window"); wnode != nullptr; wnode = xml_get_sibling(wnode->next, "window")) { WindowQtConfig::WindowType type = (WindowQtConfig::WindowType)xml_get_attribute_int(wnode, "type", WindowQtConfig::WIN_TYPE_UNKNOWN); switch (type) @@ -124,8 +124,8 @@ static void xml_configuration_save(running_machine &machine, config_type cfg_typ // Create an xml node xml_data_node *debugger_node; - debugger_node = xml_add_child(parentnode, "window", NULL); - if (debugger_node == NULL) + debugger_node = xml_add_child(parentnode, "window", nullptr); + if (debugger_node == nullptr) continue; // Insert the appropriate information @@ -195,7 +195,7 @@ static void setup_additional_startup_windows(running_machine& machine, std::vect { WindowQtConfig* config = configList[i]; - WindowQt* foo = NULL; + WindowQt* foo = nullptr; switch (config->m_type) { case WindowQtConfig::WIN_TYPE_MEMORY: @@ -246,7 +246,7 @@ bool debug_qt::nativeEventFilter(const QByteArray &eventType, void *message, lon void debug_qt::init_debugger(running_machine &machine) { - if (qApp == NULL) + if (qApp == nullptr) { // If you're starting from scratch, create a new qApp new QApplication(qtArgc, qtArgv); diff --git a/src/osd/modules/debugger/debugwin.cpp b/src/osd/modules/debugger/debugwin.cpp index a32405c4aa8..1f68e6989eb 100644 --- a/src/osd/modules/debugger/debugwin.cpp +++ b/src/osd/modules/debugger/debugwin.cpp @@ -35,11 +35,11 @@ public: debugger_windows() : osd_module(OSD_DEBUG_PROVIDER, "windows"), debug_module(), - m_machine(NULL), + m_machine(nullptr), m_metrics(), m_waiting_for_debugger(false), m_window_list(), - m_main_console(NULL) + m_main_console(nullptr) { } @@ -83,12 +83,12 @@ private: void debugger_windows::exit() { // loop over windows and free them - while (m_window_list.first() != NULL) + while (m_window_list.first() != nullptr) m_window_list.first()->destroy(); - m_main_console = NULL; + m_main_console = nullptr; m_metrics.reset(); - m_machine = NULL; + m_machine = nullptr; } @@ -102,15 +102,15 @@ void debugger_windows::init_debugger(running_machine &machine) void debugger_windows::wait_for_debugger(device_t &device, bool firststop) { // create a console window - if (m_main_console == NULL) + if (m_main_console == nullptr) m_main_console = create_window<consolewin_info>(); // update the views in the console to reflect the current CPU - if (m_main_console != NULL) + if (m_main_console != nullptr) m_main_console->set_cpu(device); // when we are first stopped, adjust focus to us - if (firststop && (m_main_console != NULL)) + if (firststop && (m_main_console != nullptr)) { m_main_console->set_foreground(); if (winwindow_has_focus()) @@ -126,7 +126,7 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop) // get and process messages MSG message; - GetMessage(&message, NULL, 0, 0); + GetMessage(&message, nullptr, 0, 0); switch (message.message) { @@ -254,7 +254,7 @@ template <typename T> T *debugger_windows::create_window() else { global_free(info); - return NULL; + return nullptr; } } diff --git a/src/osd/modules/debugger/osx/debugconsole.mm b/src/osd/modules/debugger/osx/debugconsole.mm index 4bd7e029295..dc86bd6f53e 100644 --- a/src/osd/modules/debugger/osx/debugconsole.mm +++ b/src/osd/modules/debugger/osx/debugconsole.mm @@ -236,7 +236,7 @@ // if it doesn't exist, add a new one NSString *command; - if (bp == NULL) + if (bp == nullptr) command = [NSString stringWithFormat:@"bpset 0x%lX", (unsigned long)address]; else command = [NSString stringWithFormat:@"bpclear 0x%X", (unsigned)bp->index()]; @@ -251,7 +251,7 @@ { device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] forDevice:device]; - if (bp != NULL) + if (bp != nullptr) { NSString *command; if (bp->enabled()) @@ -483,7 +483,7 @@ BOOL const haveCursor = [dasmView cursorVisible]; BOOL const isCurrent = (debug_cpu_get_visible_cpu(*machine) == &[dasmView source]->device()); - device_debug::breakpoint *breakpoint = NULL; + device_debug::breakpoint *breakpoint = nullptr; if (haveCursor) { breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] @@ -494,7 +494,7 @@ { if (haveCursor) { - if (breakpoint != NULL) + if (breakpoint != nullptr) { if (inContextMenu) [item setTitle:@"Clear Breakpoint"]; @@ -520,7 +520,7 @@ } else if (action == @selector(debugToggleBreakpointEnable:)) { - if ((breakpoint != NULL) && !breakpoint->enabled()) + if ((breakpoint != nullptr) && !breakpoint->enabled()) { if (inContextMenu) [item setTitle:@"Enable Breakpoint"]; @@ -534,7 +534,7 @@ else [item setTitle:@"Disable Breakpoint at Cursor"]; } - return (breakpoint != NULL) && isCurrent; + return (breakpoint != nullptr) && isCurrent; } else if (action == @selector(debugRunToCursor:)) { diff --git a/src/osd/modules/debugger/osx/debugview.mm b/src/osd/modules/debugger/osx/debugview.mm index 05d2e2dfc17..a32b99794dd 100644 --- a/src/osd/modules/debugger/osx/debugview.mm +++ b/src/osd/modules/debugger/osx/debugview.mm @@ -260,7 +260,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - if (view != NULL) machine->debug_view().free_view(*view); + if (view != nullptr) machine->debug_view().free_view(*view); if (font != nil) [font release]; if (text != nil) [text release]; [super dealloc]; diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm index fd11fa89152..90260914f8e 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.mm +++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm @@ -131,7 +131,7 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD + (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device { device_debug *const cpuinfo = device.debug(); device_debug::breakpoint *bp = cpuinfo->breakpoint_first(); - while ((bp != NULL) && (address != bp->address())) bp = bp->next(); + while ((bp != nullptr) && (address != bp->address())) bp = bp->next(); return bp; } diff --git a/src/osd/modules/debugger/osx/deviceinfoviewer.mm b/src/osd/modules/debugger/osx/deviceinfoviewer.mm index dd1b43ccf60..bbc2ac7d0f5 100644 --- a/src/osd/modules/debugger/osx/deviceinfoviewer.mm +++ b/src/osd/modules/debugger/osx/deviceinfoviewer.mm @@ -166,10 +166,10 @@ // add interfaces if present device_interface *interface = device->interfaces().first(); - if (interface != NULL) + if (interface != nullptr) { NSBox *const interfacesBox = [self makeBox:@"Interfaces" toFit:contentView]; - while (interface != NULL) + while (interface != nullptr) { [self addField:[NSString stringWithUTF8String:interface->interface_type()] toBox:interfacesBox]; diff --git a/src/osd/modules/debugger/osx/devicesviewer.mm b/src/osd/modules/debugger/osx/devicesviewer.mm index 356cc2d1393..8a87dedb1a6 100644 --- a/src/osd/modules/debugger/osx/devicesviewer.mm +++ b/src/osd/modules/debugger/osx/devicesviewer.mm @@ -34,7 +34,7 @@ - (void)wrapChildren { NSMutableArray *const tmp = [[NSMutableArray alloc] init]; - for (device_t *child = device->subdevices().first(); child != NULL; child = child->next()) + for (device_t *child = device->subdevices().first(); child != nullptr; child = child->next()) { MAMEDeviceWrapper *const wrap = [[MAMEDeviceWrapper alloc] initWithMachine:*machine device:*child]; diff --git a/src/osd/modules/debugger/osx/disassemblyview.mm b/src/osd/modules/debugger/osx/disassemblyview.mm index f82eb917fae..212f8194cd6 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.mm +++ b/src/osd/modules/debugger/osx/disassemblyview.mm @@ -43,7 +43,7 @@ - (NSSize)maximumFrameSize { debug_view_xy max(0, 0); debug_view_source const *source = view->source(); - for (debug_view_source const *source = view->first_source(); source != NULL; source = source->next()) + for (debug_view_source const *source = view->first_source(); source != nullptr; source = source->next()) { view->set_source(*source); debug_view_xy const current = view->total_size(); @@ -105,7 +105,7 @@ - (NSString *)selectedSubviewName { const debug_view_source *source = view->source(); - if (source != NULL) + if (source != nullptr) return [NSString stringWithUTF8String:source->name()]; else return @""; @@ -114,7 +114,7 @@ - (int)selectedSubviewIndex { const debug_view_source *source = view->source(); - if (source != NULL) + if (source != nullptr) return view->source_list().indexof(*source); else return -1; @@ -133,7 +133,7 @@ - (BOOL)selectSubviewForDevice:(device_t *)device { debug_view_source const *const source = view->source_for_device(device); - if (source != NULL) + if (source != nullptr) { if (view->source() != source) { @@ -151,11 +151,11 @@ - (BOOL)selectSubviewForSpace:(address_space *)space { - if (space == NULL) return NO; + if (space == nullptr) return NO; debug_view_disasm_source const *source = downcast<debug_view_disasm_source const *>(view->first_source()); - while ((source != NULL) && (&source->space() != space)) + while ((source != nullptr) && (&source->space() != space)) source = downcast<debug_view_disasm_source *>(source->next()); - if (source != NULL) + if (source != nullptr) { if (view->source() != source) { @@ -253,7 +253,7 @@ - (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { - for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) + for (const debug_view_source *source = view->source_list().first(); source != nullptr; source = source->next()) { [[menu insertItemWithTitle:[NSString stringWithUTF8String:source->name()] action:NULL diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.mm b/src/osd/modules/debugger/osx/disassemblyviewer.mm index 83ca9d46c11..10e6c6d2cac 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.mm +++ b/src/osd/modules/debugger/osx/disassemblyviewer.mm @@ -175,9 +175,9 @@ device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device]; // if it doesn't exist, add a new one - if (bp == NULL) + if (bp == nullptr) { - UINT32 const bpnum = device.debug()->breakpoint_set(address, NULL, NULL); + UINT32 const bpnum = device.debug()->breakpoint_set(address, nullptr, nullptr); debug_console_printf(*machine, "Breakpoint %X set\n", bpnum); } else @@ -200,7 +200,7 @@ device_t &device = [dasmView source]->device(); offs_t const address = [dasmView selectedAddress]; device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device]; - if (bp != NULL) + if (bp != nullptr) { device.debug()->breakpoint_enable(bp->index(), !bp->enabled()); debug_console_printf(*machine, @@ -231,7 +231,7 @@ BOOL const inContextMenu = ([item menu] == [dasmView menu]); BOOL const haveCursor = [dasmView cursorVisible]; - device_debug::breakpoint *breakpoint = NULL; + device_debug::breakpoint *breakpoint = nullptr; if (haveCursor) { breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] @@ -242,7 +242,7 @@ { if (haveCursor) { - if (breakpoint != NULL) + if (breakpoint != nullptr) { if (inContextMenu) [item setTitle:@"Clear Breakpoint"]; @@ -268,7 +268,7 @@ } else if (action == @selector(debugToggleBreakpointEnable:)) { - if ((breakpoint != NULL) && !breakpoint->enabled()) + if ((breakpoint != nullptr) && !breakpoint->enabled()) { if (inContextMenu) [item setTitle:@"Enable Breakpoint"]; @@ -282,7 +282,7 @@ else [item setTitle:@"Disable Breakpoint at Cursor"]; } - return breakpoint != NULL; + return breakpoint != nullptr; } else { diff --git a/src/osd/modules/debugger/osx/memoryview.mm b/src/osd/modules/debugger/osx/memoryview.mm index c32476bd89b..aac06f3e63a 100644 --- a/src/osd/modules/debugger/osx/memoryview.mm +++ b/src/osd/modules/debugger/osx/memoryview.mm @@ -65,7 +65,7 @@ - (NSSize)maximumFrameSize { debug_view_xy max(0, 0); debug_view_source const *source = view->source(); - for (debug_view_source const *source = view->first_source(); source != NULL; source = source->next()) + for (debug_view_source const *source = view->first_source(); source != nullptr; source = source->next()) { view->set_source(*source); debug_view_xy const current = view->total_size(); @@ -88,7 +88,7 @@ - (NSString *)selectedSubviewName { debug_view_source const *source = view->source(); - if (source != NULL) + if (source != nullptr) return [NSString stringWithUTF8String:source->name()]; else return @""; @@ -97,7 +97,7 @@ - (int)selectedSubviewIndex { debug_view_source const *source = view->source(); - if (source != NULL) + if (source != nullptr) return view->source_list().indexof(*source); else return -1; @@ -116,7 +116,7 @@ - (BOOL)selectSubviewForDevice:(device_t *)device { debug_view_source const *const source = view->source_for_device(device); - if (source != NULL) + if (source != nullptr) { if (view->source() != source) { @@ -134,11 +134,11 @@ - (BOOL)selectSubviewForSpace:(address_space *)space { - if (space == NULL) return NO; + if (space == nullptr) return NO; debug_view_memory_source const *source = downcast<debug_view_memory_source const *>(view->first_source()); - while ((source != NULL) && (source->space() != space)) + while ((source != nullptr) && (source->space() != space)) source = downcast<debug_view_memory_source *>(source->next()); - if (source != NULL) + if (source != nullptr) { if (view->source() != source) { @@ -275,7 +275,7 @@ - (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { - for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) + for (const debug_view_source *source = view->source_list().first(); source != nullptr; source = source->next()) { [[menu insertItemWithTitle:[NSString stringWithUTF8String:source->name()] action:NULL diff --git a/src/osd/modules/debugger/osx/registersview.mm b/src/osd/modules/debugger/osx/registersview.mm index 7e6cfd2dd7a..c1e7dc8dce6 100644 --- a/src/osd/modules/debugger/osx/registersview.mm +++ b/src/osd/modules/debugger/osx/registersview.mm @@ -32,7 +32,7 @@ const debug_view_source *source = view->source_for_device(curcpu); max.x = max.y = 0; - for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) + for (const debug_view_source *source = view->source_list().first(); source != nullptr; source = source->next()) { debug_view_xy current; view->set_source(*source); diff --git a/src/osd/modules/debugger/qt/breakpointswindow.cpp b/src/osd/modules/debugger/qt/breakpointswindow.cpp index 7b30459c8e9..3875d594391 100644 --- a/src/osd/modules/debugger/qt/breakpointswindow.cpp +++ b/src/osd/modules/debugger/qt/breakpointswindow.cpp @@ -15,11 +15,11 @@ BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) + WindowQt(machine, nullptr) { setWindowTitle("Debug: All Breakpoints"); - if (parent != NULL) + if (parent != nullptr) { QPoint parentPos = parent->pos(); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); @@ -75,7 +75,7 @@ void BreakpointsWindow::typeChanged(QAction* changedTo) { // Clean delete m_breakpointsView; - m_breakpointsView = NULL; + m_breakpointsView = nullptr; // Create if (changedTo->text() == "Breakpoints") diff --git a/src/osd/modules/debugger/qt/breakpointswindow.h b/src/osd/modules/debugger/qt/breakpointswindow.h index 6c4335e334c..a45781ea5ce 100644 --- a/src/osd/modules/debugger/qt/breakpointswindow.h +++ b/src/osd/modules/debugger/qt/breakpointswindow.h @@ -15,7 +15,7 @@ class BreakpointsWindow : public WindowQt Q_OBJECT public: - BreakpointsWindow(running_machine* machine, QWidget* parent=NULL); + BreakpointsWindow(running_machine* machine, QWidget* parent=nullptr); virtual ~BreakpointsWindow(); diff --git a/src/osd/modules/debugger/qt/dasmwindow.cpp b/src/osd/modules/debugger/qt/dasmwindow.cpp index 3a430f67a84..3cd1dca65ac 100644 --- a/src/osd/modules/debugger/qt/dasmwindow.cpp +++ b/src/osd/modules/debugger/qt/dasmwindow.cpp @@ -14,11 +14,11 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) + WindowQt(machine, nullptr) { setWindowTitle("Debug: Disassembly View"); - if (parent != NULL) + if (parent != nullptr) { QPoint parentPos = parent->pos(); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); @@ -144,7 +144,7 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo) // Find an existing breakpoint at this address INT32 bpindex = -1; for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - bp != NULL; + bp != nullptr; bp = bp->next()) { if (address == bp->address()) @@ -157,7 +157,7 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo) // If none exists, add a new one if (bpindex == -1) { - bpindex = cpuinfo->breakpoint_set(address, NULL, NULL); + bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr); debug_console_printf(*m_machine, "Breakpoint %X set\n", bpindex); } else @@ -183,10 +183,10 @@ void DasmWindow::enableBreakpointAtCursor(bool changedTo) // Find an existing breakpoint at this address device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != NULL) && (bp->address() != address)) + while ((bp != nullptr) && (bp->address() != address)) bp = bp->next(); - if (bp != NULL) + if (bp != nullptr) { cpuinfo->breakpoint_enable(bp->index(), !bp->enabled()); debug_console_printf(*m_machine, "Breakpoint %X %s\n", (UINT32)bp->index(), bp->enabled() ? "enabled" : "disabled"); @@ -241,10 +241,10 @@ void DasmWindow::dasmViewUpdated() // Find an existing breakpoint at this address device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != NULL) && (bp->address() != address)) + while ((bp != nullptr) && (bp->address() != address)) bp = bp->next(); - if (bp != NULL) + if (bp != nullptr) { haveBreakpoint = true; breakpointEnabled = bp->enabled(); @@ -261,7 +261,7 @@ void DasmWindow::dasmViewUpdated() void DasmWindow::populateComboBox() { - if (m_dasmView == NULL) + if (m_dasmView == nullptr) return; m_cpuComboBox->clear(); diff --git a/src/osd/modules/debugger/qt/dasmwindow.h b/src/osd/modules/debugger/qt/dasmwindow.h index 44368c4e11f..021c72fd2fd 100644 --- a/src/osd/modules/debugger/qt/dasmwindow.h +++ b/src/osd/modules/debugger/qt/dasmwindow.h @@ -18,7 +18,7 @@ class DasmWindow : public WindowQt Q_OBJECT public: - DasmWindow(running_machine* machine, QWidget* parent=NULL); + DasmWindow(running_machine* machine, QWidget* parent=nullptr); virtual ~DasmWindow(); diff --git a/src/osd/modules/debugger/qt/debuggerview.cpp b/src/osd/modules/debugger/qt/debuggerview.cpp index 319ee370392..f1d66abee42 100644 --- a/src/osd/modules/debugger/qt/debuggerview.cpp +++ b/src/osd/modules/debugger/qt/debuggerview.cpp @@ -15,7 +15,7 @@ DebuggerView::DebuggerView(const debug_view_type& type, QWidget* parent) : QAbstractScrollArea(parent), m_preferBottom(false), - m_view(NULL), + m_view(nullptr), m_machine(machine) { // I like setting the font per-view since it doesn't override the menuing fonts. @@ -163,7 +163,7 @@ void DebuggerView::paintEvent(QPaintEvent* event) void DebuggerView::keyPressEvent(QKeyEvent* event) { - if (m_view == NULL) + if (m_view == nullptr) return QWidget::keyPressEvent(event); Qt::KeyboardModifiers keyMods = QApplication::keyboardModifiers(); @@ -233,7 +233,7 @@ void DebuggerView::keyPressEvent(QKeyEvent* event) void DebuggerView::mousePressEvent(QMouseEvent* event) { - if (m_view == NULL) + if (m_view == nullptr) return; if (event->button() == Qt::LeftButton) diff --git a/src/osd/modules/debugger/qt/debuggerview.h b/src/osd/modules/debugger/qt/debuggerview.h index 7b1aed6fd2c..2e1f35eb306 100644 --- a/src/osd/modules/debugger/qt/debuggerview.h +++ b/src/osd/modules/debugger/qt/debuggerview.h @@ -15,7 +15,7 @@ class DebuggerView : public QAbstractScrollArea public: DebuggerView(const debug_view_type& type, running_machine* machine, - QWidget* parent=NULL); + QWidget* parent=nullptr); virtual ~DebuggerView(); void paintEvent(QPaintEvent* event); diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.cpp b/src/osd/modules/debugger/qt/deviceinformationwindow.cpp index 12a286ff2b6..acdddc13fbb 100644 --- a/src/osd/modules/debugger/qt/deviceinformationwindow.cpp +++ b/src/osd/modules/debugger/qt/deviceinformationwindow.cpp @@ -8,11 +8,11 @@ DeviceInformationWindow::DeviceInformationWindow(running_machine* machine, device_t* device, QWidget* parent) : - WindowQt(machine, NULL) + WindowQt(machine, nullptr) { m_device = device; - if (parent != NULL) + if (parent != nullptr) { QPoint parentPos = parent->pos(); setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.h b/src/osd/modules/debugger/qt/deviceinformationwindow.h index b0d9898488a..c7a4c05204d 100644 --- a/src/osd/modules/debugger/qt/deviceinformationwindow.h +++ b/src/osd/modules/debugger/qt/deviceinformationwindow.h @@ -13,7 +13,7 @@ class DeviceInformationWindow : public WindowQt Q_OBJECT public: - DeviceInformationWindow(running_machine* machine, device_t* device = NULL, QWidget* parent=NULL); + DeviceInformationWindow(running_machine* machine, device_t* device = nullptr, QWidget* parent=nullptr); virtual ~DeviceInformationWindow(); void set_device(const char *tag); diff --git a/src/osd/modules/debugger/qt/deviceswindow.cpp b/src/osd/modules/debugger/qt/deviceswindow.cpp index a4d4d74fc3b..18845f15074 100644 --- a/src/osd/modules/debugger/qt/deviceswindow.cpp +++ b/src/osd/modules/debugger/qt/deviceswindow.cpp @@ -46,7 +46,7 @@ QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &pa if(!hasIndex(row, column, parent)) return QModelIndex(); - device_t *target = NULL; + device_t *target = nullptr; if(!parent.isValid()) { if(row == 0) @@ -102,14 +102,14 @@ int DevicesWindowModel::columnCount(const QModelIndex &parent) const DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL), + WindowQt(machine, nullptr), m_devices_model(machine) { - m_selected_device = NULL; + m_selected_device = nullptr; setWindowTitle("Debug: All Devices"); - if (parent != NULL) + if (parent != nullptr) { QPoint parentPos = parent->pos(); setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); diff --git a/src/osd/modules/debugger/qt/deviceswindow.h b/src/osd/modules/debugger/qt/deviceswindow.h index 13965b9dce5..3064354fd2e 100644 --- a/src/osd/modules/debugger/qt/deviceswindow.h +++ b/src/osd/modules/debugger/qt/deviceswindow.h @@ -42,7 +42,7 @@ class DevicesWindow : public WindowQt Q_OBJECT public: - DevicesWindow(running_machine* machine, QWidget* parent=NULL); + DevicesWindow(running_machine* machine, QWidget* parent=nullptr); virtual ~DevicesWindow(); public slots: diff --git a/src/osd/modules/debugger/qt/logwindow.cpp b/src/osd/modules/debugger/qt/logwindow.cpp index b6e704cd5c6..704a029e5ac 100644 --- a/src/osd/modules/debugger/qt/logwindow.cpp +++ b/src/osd/modules/debugger/qt/logwindow.cpp @@ -10,11 +10,11 @@ LogWindow::LogWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) + WindowQt(machine, nullptr) { setWindowTitle("Debug: Machine Log"); - if (parent != NULL) + if (parent != nullptr) { QPoint parentPos = parent->pos(); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); diff --git a/src/osd/modules/debugger/qt/logwindow.h b/src/osd/modules/debugger/qt/logwindow.h index a406cfb8eb3..1c3b18d38bb 100644 --- a/src/osd/modules/debugger/qt/logwindow.h +++ b/src/osd/modules/debugger/qt/logwindow.h @@ -15,7 +15,7 @@ class LogWindow : public WindowQt Q_OBJECT public: - LogWindow(running_machine* machine, QWidget* parent=NULL); + LogWindow(running_machine* machine, QWidget* parent=nullptr); virtual ~LogWindow(); diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp index aeca1d20b63..e366ba77247 100644 --- a/src/osd/modules/debugger/qt/mainwindow.cpp +++ b/src/osd/modules/debugger/qt/mainwindow.cpp @@ -16,7 +16,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL), + WindowQt(machine, nullptr), m_historyIndex(0), m_inputHistory() { @@ -92,7 +92,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) : // Images menu // image_interface_iterator imageIterTest(m_machine->root_device()); - if (imageIterTest.first() != NULL) + if (imageIterTest.first() != nullptr) { createImagesMenu(); } @@ -163,7 +163,7 @@ void MainWindow::closeEvent(QCloseEvent* event) bool MainWindow::eventFilter(QObject* obj, QEvent* event) { // Only filter keypresses - QKeyEvent* keyEvent = NULL; + QKeyEvent* keyEvent = nullptr; if (event->type() == QEvent::KeyPress) { keyEvent = static_cast<QKeyEvent*>(event); @@ -221,7 +221,7 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo) // Find an existing breakpoint at this address INT32 bpindex = -1; for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - bp != NULL; + bp != nullptr; bp = bp->next()) { if (address == bp->address()) @@ -258,10 +258,10 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo) // Find an existing breakpoint at this address device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != NULL) && (bp->address() != address)) + while ((bp != nullptr) && (bp->address() != address)) bp = bp->next(); - if (bp != NULL) + if (bp != nullptr) { INT32 const bpindex = bp->index(); std::string command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex); @@ -346,7 +346,7 @@ void MainWindow::mountImage(bool changedTo) const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt(); image_interface_iterator iter(m_machine->root_device()); device_image_interface *img = iter.byindex(imageIndex); - if (img == NULL) + if (img == nullptr) { debug_console_printf(*m_machine, "Something is wrong with the mount menu.\n"); refreshAll(); @@ -420,10 +420,10 @@ void MainWindow::dasmViewUpdated() // Find an existing breakpoint at this address device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != NULL) && (bp->address() != address)) + while ((bp != nullptr) && (bp->address() != address)) bp = bp->next(); - if (bp != NULL) + if (bp != nullptr) { haveBreakpoint = true; breakpointEnabled = bp->enabled(); diff --git a/src/osd/modules/debugger/qt/mainwindow.h b/src/osd/modules/debugger/qt/mainwindow.h index 4a93608772f..2c8e7feee67 100644 --- a/src/osd/modules/debugger/qt/mainwindow.h +++ b/src/osd/modules/debugger/qt/mainwindow.h @@ -26,7 +26,7 @@ class MainWindow : public WindowQt Q_OBJECT public: - MainWindow(running_machine* machine, QWidget* parent=NULL); + MainWindow(running_machine* machine, QWidget* parent=nullptr); virtual ~MainWindow(); void setProcessor(device_t* processor); @@ -87,7 +87,7 @@ class DasmDockWidget : public QWidget Q_OBJECT public: - DasmDockWidget(running_machine* machine, QWidget* parent=NULL) : + DasmDockWidget(running_machine* machine, QWidget* parent=nullptr) : QWidget(parent), m_machine(machine) { @@ -138,9 +138,9 @@ class ProcessorDockWidget : public QWidget public: ProcessorDockWidget(running_machine* machine, - QWidget* parent=NULL) : + QWidget* parent=nullptr) : QWidget(parent), - m_processorView(NULL), + m_processorView(nullptr), m_machine(machine) { m_processorView = new DebuggerView(DVT_STATE, diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp index 7b86740fe51..9d10dbb5024 100644 --- a/src/osd/modules/debugger/qt/memorywindow.cpp +++ b/src/osd/modules/debugger/qt/memorywindow.cpp @@ -19,11 +19,11 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) + WindowQt(machine, nullptr) { setWindowTitle("Debug: Memory View"); - if (parent != NULL) + if (parent != nullptr) { QPoint parentPos = parent->pos(); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); @@ -278,7 +278,7 @@ void MemoryWindow::decreaseBytesPerLine(bool checked) void MemoryWindow::populateComboBox() { - if (m_memTable == NULL) + if (m_memTable == nullptr) return; m_memoryComboBox->clear(); @@ -312,7 +312,7 @@ QAction* MemoryWindow::dataFormatMenuItem(const QString& itemName) return actions[j]; } } - return NULL; + return nullptr; } @@ -357,7 +357,7 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event) { // TODO: You can specify a box that the tooltip stays alive within - might be good? const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); - QToolTip::showText(QCursor::pos(), addressAndPc, NULL); + QToolTip::showText(QCursor::pos(), addressAndPc, nullptr); // Copy the PC into the clipboard as well QClipboard *clipboard = QApplication::clipboard(); @@ -365,7 +365,7 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event) } else { - QToolTip::showText(QCursor::pos(), "UNKNOWN PC", NULL); + QToolTip::showText(QCursor::pos(), "UNKNOWN PC", nullptr); } } diff --git a/src/osd/modules/debugger/qt/memorywindow.h b/src/osd/modules/debugger/qt/memorywindow.h index d5fb74f677a..7663787e890 100644 --- a/src/osd/modules/debugger/qt/memorywindow.h +++ b/src/osd/modules/debugger/qt/memorywindow.h @@ -20,7 +20,7 @@ class MemoryWindow : public WindowQt Q_OBJECT public: - MemoryWindow(running_machine* machine, QWidget* parent=NULL); + MemoryWindow(running_machine* machine, QWidget* parent=nullptr); virtual ~MemoryWindow(); @@ -56,7 +56,7 @@ class DebuggerMemView : public DebuggerView public: DebuggerMemView(const debug_view_type& type, running_machine* machine, - QWidget* parent=NULL) + QWidget* parent=nullptr) : DebuggerView(type, machine, parent) {} virtual ~DebuggerMemView() {} diff --git a/src/osd/modules/debugger/qt/windowqt.cpp b/src/osd/modules/debugger/qt/windowqt.cpp index adaf96ab2e1..a18fd9885b6 100644 --- a/src/osd/modules/debugger/qt/windowqt.cpp +++ b/src/osd/modules/debugger/qt/windowqt.cpp @@ -15,7 +15,7 @@ bool WindowQt::s_hideAll = false; // Since all debug windows are intended to be top-level, this inherited -// constructor is always called with a NULL parent. The passed-in parent widget, +// constructor is always called with a nullptr parent. The passed-in parent widget, // however, is often used to place each child window & the code to do this can // be found in most of the inherited classes. diff --git a/src/osd/modules/debugger/qt/windowqt.h b/src/osd/modules/debugger/qt/windowqt.h index e2e334792b2..881d5716db1 100644 --- a/src/osd/modules/debugger/qt/windowqt.h +++ b/src/osd/modules/debugger/qt/windowqt.h @@ -18,7 +18,7 @@ class WindowQt : public QMainWindow Q_OBJECT public: - WindowQt(running_machine* machine, QWidget* parent=NULL); + WindowQt(running_machine* machine, QWidget* parent=nullptr); virtual ~WindowQt(); // The interface to an all-window refresh diff --git a/src/osd/modules/debugger/win/consolewininfo.cpp b/src/osd/modules/debugger/win/consolewininfo.cpp index cdd84efeb47..89c3061c688 100644 --- a/src/osd/modules/debugger/win/consolewininfo.cpp +++ b/src/osd/modules/debugger/win/consolewininfo.cpp @@ -20,10 +20,10 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) : - disasmbasewin_info(debugger, true, "Debug", NULL), - m_devices_menu(NULL) + disasmbasewin_info(debugger, true, "Debug", nullptr), + m_devices_menu(nullptr) { - if ((window() == NULL) || (m_views[0] == NULL)) + if ((window() == nullptr) || (m_views[0] == nullptr)) goto cleanup; // create the views @@ -43,7 +43,7 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) : for (device_image_interface &img : iter) { TCHAR *tc_buf = tstring_from_utf8(string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[no image]").c_str()); - if (tc_buf != NULL) + if (tc_buf != nullptr) { AppendMenu(m_devices_menu, MF_ENABLED, 0, tc_buf); osd_free(tc_buf); @@ -159,7 +159,7 @@ void consolewin_info::update_menu() { disasmbasewin_info::update_menu(); - if (m_devices_menu != NULL) + if (m_devices_menu != nullptr) { // create the image menu UINT32 cnt = 0; @@ -186,7 +186,7 @@ void consolewin_info::update_menu() if (img.device().type() == CASSETTE) { cassette_state const state = (cassette_state)(img.exists() ? (downcast<cassette_image_device *>(&img.device())->get_state() & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED); - AppendMenu(devicesubmenu, MF_SEPARATOR, 0, NULL); + AppendMenu(devicesubmenu, MF_SEPARATOR, 0, nullptr); AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, TEXT("Pause/Stop")); AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, TEXT("Play")); AppendMenu(devicesubmenu, flags_for_writing | ((state == CASSETTE_RECORD) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_RECORD, TEXT("Record")); @@ -195,7 +195,7 @@ void consolewin_info::update_menu() } TCHAR *tc_buf = tstring_from_utf8(string_format("%s :%s", img.device().name(), img.exists() ? img.filename() : "[empty slot]").c_str()); - if (tc_buf != NULL) + if (tc_buf != nullptr) { ModifyMenu(m_devices_menu, cnt, MF_BYPOSITION | MF_POPUP, (UINT_PTR)devicesubmenu, tc_buf); osd_free(tc_buf); @@ -214,7 +214,7 @@ bool consolewin_info::handle_command(WPARAM wparam, LPARAM lparam) UINT32 const devid = (LOWORD(wparam) - ID_DEVICE_OPTIONS) / DEVOPTION_MAX; image_interface_iterator iter(machine().root_device()); device_image_interface *const img = iter.byindex(devid); - if (img != NULL) + if (img != nullptr) { switch ((LOWORD(wparam) - ID_DEVICE_OPTIONS) % DEVOPTION_MAX) { @@ -237,21 +237,21 @@ bool consolewin_info::handle_command(WPARAM wparam, LPARAM lparam) OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = NULL; + ofn.hwndOwner = nullptr; ofn.lpstrFile = selectedFilename; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = t_filter; ofn.nFilterIndex = 1; - ofn.lpstrFileTitle = NULL; + ofn.lpstrFileTitle = nullptr; ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = NULL; + ofn.lpstrInitialDir = nullptr; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; if (GetOpenFileName(&ofn)) { char *utf8_buf = utf8_from_tstring(selectedFilename); - if (utf8_buf != NULL) + if (utf8_buf != nullptr) { img->load(utf8_buf); osd_free(utf8_buf); diff --git a/src/osd/modules/debugger/win/debugviewinfo.cpp b/src/osd/modules/debugger/win/debugviewinfo.cpp index 3f355cf8a34..01a300f0733 100644 --- a/src/osd/modules/debugger/win/debugviewinfo.cpp +++ b/src/osd/modules/debugger/win/debugviewinfo.cpp @@ -41,53 +41,53 @@ bool debugview_info::s_window_class_registered = false; debugview_info::debugview_info(debugger_windows_interface &debugger, debugwin_info &owner, HWND parent, debug_view_type type) : debugbase_info(debugger), m_owner(owner), - m_view(NULL), - m_wnd(NULL), - m_hscroll(NULL), - m_vscroll(NULL) + m_view(nullptr), + m_wnd(nullptr), + m_hscroll(nullptr), + m_vscroll(nullptr) { register_window_class(); // create the child view - m_wnd = CreateWindowEx(DEBUG_VIEW_STYLE_EX, TEXT("MAMEDebugView"), NULL, DEBUG_VIEW_STYLE, - 0, 0, 100, 100, parent, NULL, GetModuleHandleUni(), this); - if (m_wnd == NULL) + m_wnd = CreateWindowEx(DEBUG_VIEW_STYLE_EX, TEXT("MAMEDebugView"), nullptr, DEBUG_VIEW_STYLE, + 0, 0, 100, 100, parent, nullptr, GetModuleHandleUni(), this); + if (m_wnd == nullptr) goto cleanup; // create the scroll bars - m_hscroll = CreateWindowEx(HSCROLL_STYLE_EX, TEXT("SCROLLBAR"), NULL, HSCROLL_STYLE, - 0, 0, 100, CW_USEDEFAULT, m_wnd, NULL, GetModuleHandleUni(), this); - m_vscroll = CreateWindowEx(VSCROLL_STYLE_EX, TEXT("SCROLLBAR"), NULL, VSCROLL_STYLE, - 0, 0, CW_USEDEFAULT, 100, m_wnd, NULL, GetModuleHandleUni(), this); - if ((m_hscroll == NULL) || (m_vscroll == NULL)) + m_hscroll = CreateWindowEx(HSCROLL_STYLE_EX, TEXT("SCROLLBAR"), nullptr, HSCROLL_STYLE, + 0, 0, 100, CW_USEDEFAULT, m_wnd, nullptr, GetModuleHandleUni(), this); + m_vscroll = CreateWindowEx(VSCROLL_STYLE_EX, TEXT("SCROLLBAR"), nullptr, VSCROLL_STYLE, + 0, 0, CW_USEDEFAULT, 100, m_wnd, nullptr, GetModuleHandleUni(), this); + if ((m_hscroll == nullptr) || (m_vscroll == nullptr)) goto cleanup; // create the debug view m_view = machine().debug_view().alloc_view(type, &debugview_info::static_update, this); - if (m_view == NULL) + if (m_view == nullptr) goto cleanup; return; cleanup: - if (m_hscroll != NULL) + if (m_hscroll != nullptr) DestroyWindow(m_hscroll); - m_hscroll = NULL; - if (m_vscroll != NULL) + m_hscroll = nullptr; + if (m_vscroll != nullptr) DestroyWindow(m_vscroll); - m_vscroll = NULL; - if (m_wnd != NULL) + m_vscroll = nullptr; + if (m_wnd != nullptr) DestroyWindow(m_wnd); - m_wnd = NULL; - if (m_view != NULL) + m_wnd = nullptr; + if (m_view != nullptr) machine().debug_view().free_view(*m_view); - m_view = NULL; + m_view = nullptr; } debugview_info::~debugview_info() { - if (m_wnd != NULL) + if (m_wnd != nullptr) DestroyWindow(m_wnd); if (m_view) machine().debug_view().free_view(*m_view); @@ -117,7 +117,7 @@ UINT32 debugview_info::maxwidth() if (max < chars) max = chars; } - if (cursource != NULL) + if (cursource != nullptr) m_view->set_source(*cursource); return (max * metrics().debug_font_width()) + metrics().vscroll_width(); } @@ -179,10 +179,10 @@ void debugview_info::send_pagedown() char const *debugview_info::source_name() const { - if (m_view != NULL) + if (m_view != nullptr) { debug_view_source const *const source = m_view->source(); - if (source != NULL) + if (source != nullptr) return source->name(); } return ""; @@ -191,22 +191,22 @@ char const *debugview_info::source_name() const device_t *debugview_info::source_device() const { - if (m_view != NULL) + if (m_view != nullptr) { debug_view_source const *const source = m_view->source(); - if (source != NULL) + if (source != nullptr) return source->device(); } - return NULL; + return nullptr; } bool debugview_info::source_is_visible_cpu() const { - if (m_view != NULL) + if (m_view != nullptr) { const debug_view_source *const source = m_view->source(); - return (source != NULL) && (debug_cpu_get_visible_cpu(machine()) == source->device()); + return (source != nullptr) && (debug_cpu_get_visible_cpu(machine()) == source->device()); } return false; } @@ -214,10 +214,10 @@ bool debugview_info::source_is_visible_cpu() const bool debugview_info::set_source_index(int index) { - if (m_view != NULL) + if (m_view != nullptr) { const debug_view_source *const source = m_view->source_list().find(index); - if (source != NULL) + if (source != nullptr) { m_view->set_source(*source); return true; @@ -229,10 +229,10 @@ bool debugview_info::set_source_index(int index) bool debugview_info::set_source_for_device(device_t &device) { - if (m_view != NULL) + if (m_view != nullptr) { const debug_view_source *const source = m_view->source_for_device(&device); - if (source != NULL) + if (source != nullptr) { m_view->set_source(*source); return true; @@ -245,7 +245,7 @@ bool debugview_info::set_source_for_device(device_t &device) bool debugview_info::set_source_for_visible_cpu() { device_t *const curcpu = debug_cpu_get_visible_cpu(machine()); - if (curcpu != NULL) + if (curcpu != nullptr) return set_source_for_device(*curcpu); else return false; @@ -255,15 +255,15 @@ bool debugview_info::set_source_for_visible_cpu() HWND debugview_info::create_source_combobox(HWND parent, LONG_PTR userdata) { // create a combo box - HWND const result = CreateWindowEx(COMBO_BOX_STYLE_EX, TEXT("COMBOBOX"), NULL, COMBO_BOX_STYLE, - 0, 0, 100, 1000, parent, NULL, GetModuleHandleUni(), NULL); + HWND const result = CreateWindowEx(COMBO_BOX_STYLE_EX, TEXT("COMBOBOX"), nullptr, COMBO_BOX_STYLE, + 0, 0, 100, 1000, parent, nullptr, GetModuleHandleUni(), nullptr); SetWindowLongPtr(result, GWLP_USERDATA, userdata); SendMessage(result, WM_SETFONT, (WPARAM)metrics().debug_font(), (LPARAM)FALSE); // populate the combobox debug_view_source const *const cursource = m_view->source(); int maxlength = 0; - for (debug_view_source const *source = m_view->first_source(); source != NULL; source = source->next()) + for (debug_view_source const *source = m_view->first_source(); source != nullptr; source = source->next()) { int const length = strlen(source->name()); if (length > maxlength) @@ -272,7 +272,7 @@ HWND debugview_info::create_source_combobox(HWND parent, LONG_PTR userdata) SendMessage(result, CB_ADDSTRING, 0, (LPARAM)t_name); osd_free(t_name); } - if (cursource != NULL) + if (cursource != nullptr) { SendMessage(result, CB_SETCURSEL, m_view->source_list().indexof(*cursource), 0); SendMessage(result, CB_SETDROPPEDWIDTH, ((maxlength + 2) * metrics().debug_font_width()) + metrics().vscroll_width(), 0); @@ -293,10 +293,10 @@ void debugview_info::draw_contents(HDC windc) // create a compatible DC and an offscreen bitmap HDC const dc = CreateCompatibleDC(windc); - if (dc == NULL) + if (dc == nullptr) return; HBITMAP const bitmap = CreateCompatibleBitmap(windc, client.right, client.bottom); - if (bitmap == NULL) + if (bitmap == nullptr) { DeleteDC(dc); return; @@ -317,7 +317,7 @@ void debugview_info::draw_contents(HDC windc) { COLORREF fgcolor; COLORREF bgcolor = RGB(0xff,0xff,0xff); - HBRUSH bgbrush = NULL; + HBRUSH bgbrush = nullptr; int last_attrib = -1; TCHAR buffer[256]; int count = 0; @@ -362,7 +362,7 @@ void debugview_info::draw_contents(HDC windc) if (iter == 0) FillRect(dc, &bounds, bgbrush); else - ExtTextOut(dc, bounds.left, bounds.top, 0, NULL, buffer, count, NULL); + ExtTextOut(dc, bounds.left, bounds.top, 0, nullptr, buffer, count, nullptr); bounds.left = bounds.right; count = 0; } @@ -389,7 +389,7 @@ void debugview_info::draw_contents(HDC windc) if (iter == 0) FillRect(dc, &bounds, bgbrush); else - ExtTextOut(dc, bounds.left, bounds.top, 0, NULL, buffer, count, NULL); + ExtTextOut(dc, bounds.left, bounds.top, 0, nullptr, buffer, count, nullptr); } // erase to the end of the line @@ -505,7 +505,7 @@ void debugview_info::update() m_view->set_visible_position(topleft); // invalidate the bounds - InvalidateRect(m_wnd, NULL, FALSE); + InvalidateRect(m_wnd, nullptr, FALSE); // adjust the bounds of the scrollbars and show/hide them if (m_vscroll) @@ -775,10 +775,10 @@ LRESULT CALLBACK debugview_info::static_view_proc(HWND wnd, UINT message, WPARAM } debugview_info *const info = (debugview_info *)(FPTR)GetWindowLongPtr(wnd, GWLP_USERDATA); - if (info == NULL) + if (info == nullptr) return DefWindowProc(wnd, message, wparam, lparam); - assert((info->m_wnd == wnd) || (info->m_wnd == NULL)); + assert((info->m_wnd == wnd) || (info->m_wnd == nullptr)); return info->view_proc(message, wparam, lparam); } @@ -793,10 +793,10 @@ void debugview_info::register_window_class() wc.lpszClassName = TEXT("MAMEDebugView"); wc.hInstance = GetModuleHandleUni(); wc.lpfnWndProc = &debugview_info::static_view_proc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hIcon = LoadIcon(wc.hInstance, MAKEINTRESOURCE(2)); - wc.lpszMenuName = NULL; - wc.hbrBackground = NULL; + wc.lpszMenuName = nullptr; + wc.hbrBackground = nullptr; wc.style = 0; wc.cbClsExtra = 0; wc.cbWndExtra = 0; diff --git a/src/osd/modules/debugger/win/debugviewinfo.h b/src/osd/modules/debugger/win/debugviewinfo.h index ec4eedf2e69..f3ef5f2cfe6 100644 --- a/src/osd/modules/debugger/win/debugviewinfo.h +++ b/src/osd/modules/debugger/win/debugviewinfo.h @@ -35,7 +35,7 @@ public: void send_vscroll(int delta); void send_pageup(); void send_pagedown(); - void set_focus() { SetFocus(m_wnd); } + void set_focus() const { SetFocus(m_wnd); } debug_view_type type() const { return m_view->type(); } debug_view_xy total_size() const { return m_view->total_size(); } diff --git a/src/osd/modules/debugger/win/debugwininfo.cpp b/src/osd/modules/debugger/win/debugwininfo.cpp index 1e75b464b72..d46b5a1d79c 100644 --- a/src/osd/modules/debugger/win/debugwininfo.cpp +++ b/src/osd/modules/debugger/win/debugwininfo.cpp @@ -23,8 +23,8 @@ bool debugwin_info::s_window_class_registered = false; debugwin_info::debugwin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler) : debugbase_info(debugger), m_is_main_console(is_main_console), - m_next(NULL), - m_wnd(NULL), + m_next(nullptr), + m_wnd(nullptr), m_handler(handler), m_minwidth(200), m_maxwidth(0), @@ -36,7 +36,7 @@ debugwin_info::debugwin_info(debugger_windows_interface &debugger, bool is_main_ m_wnd = win_create_window_ex_utf8(DEBUG_WINDOW_STYLE_EX, "MAMEDebugWindow", title, DEBUG_WINDOW_STYLE, 0, 0, 100, 100, win_window_list.front()->platform_window<HWND>(), create_standard_menubar(), GetModuleHandleUni(), this); - if (m_wnd == NULL) + if (m_wnd == nullptr) return; RECT work_bounds; @@ -70,7 +70,7 @@ void debugwin_info::prev_view(debugview_info *curview) int numviews; for (numviews = 0; numviews < MAX_VIEWS; numviews++) { - if (m_views[numviews] == NULL) + if (m_views[numviews] == nullptr) break; } @@ -100,7 +100,7 @@ void debugwin_info::prev_view(debugview_info *curview) // negative numbers mean the focuswnd break; } - else if (curindex >= 0 && m_views[curindex] != NULL && m_views[curindex]->cursor_supported()) + else if (curindex >= 0 && m_views[curindex] != nullptr && m_views[curindex]->cursor_supported()) { // positive numbers mean a view m_views[curindex]->set_focus(); @@ -116,7 +116,7 @@ void debugwin_info::next_view(debugview_info *curview) int numviews; for (numviews = 0; numviews < MAX_VIEWS; numviews++) { - if (m_views[numviews] == NULL) + if (m_views[numviews] == nullptr) break; } @@ -144,7 +144,7 @@ void debugwin_info::next_view(debugview_info *curview) // negative numbers mean the focuswnd break; } - else if (curindex >= 0 && m_views[curindex] != NULL && m_views[curindex]->cursor_supported()) + else if (curindex >= 0 && m_views[curindex] != nullptr && m_views[curindex]->cursor_supported()) { // positive numbers mean a view m_views[curindex]->set_focus(); @@ -248,7 +248,7 @@ bool debugwin_info::handle_key(WPARAM wparam, LPARAM lparam) void debugwin_info::recompute_children() { - if (m_views[0] != NULL) + if (m_views[0] != nullptr) { // compute a client rect RECT bounds; @@ -352,7 +352,7 @@ void debugwin_info::draw_contents(HDC dc) // draw edges around all views for (int curview = 0; curview < MAX_VIEWS; curview++) { - if (m_views[curview] != NULL) + if (m_views[curview] != nullptr) { RECT bounds; m_views[curview]->get_bounds(bounds); @@ -430,7 +430,7 @@ LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam) case WM_SIZE: case WM_SIZING: recompute_children(); - InvalidateRect(m_wnd, NULL, FALSE); + InvalidateRect(m_wnd, nullptr, FALSE); break; // mouse wheel: forward to the first view @@ -458,7 +458,7 @@ LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam) { for (viewnum = 0; viewnum < MAX_VIEWS; viewnum++) { - if ((m_views[viewnum] != NULL) && m_views[viewnum]->owns_window(child)) + if ((m_views[viewnum] != nullptr) && m_views[viewnum]->owns_window(child)) break; } if (viewnum == MAX_VIEWS) @@ -466,7 +466,7 @@ LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam) } // send the appropriate message to this view's scrollbar - if (m_views[viewnum] != NULL) + if (m_views[viewnum] != nullptr) m_views[viewnum]->send_vscroll(delta); break; @@ -498,7 +498,7 @@ LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam) // destroy: close down the window case WM_NCDESTROY: - m_wnd = NULL; + m_wnd = nullptr; debugger().remove_window(*this); break; @@ -515,8 +515,8 @@ HMENU debugwin_info::create_standard_menubar() { // create the debug menu HMENU const debugmenu = CreatePopupMenu(); - if (debugmenu == NULL) - return NULL; + if (debugmenu == nullptr) + return nullptr; AppendMenu(debugmenu, MF_ENABLED, ID_NEW_MEMORY_WND, TEXT("New Memory Window\tCtrl+M")); AppendMenu(debugmenu, MF_ENABLED, ID_NEW_DISASM_WND, TEXT("New Disassembly Window\tCtrl+D")); AppendMenu(debugmenu, MF_ENABLED, ID_NEW_LOG_WND, TEXT("New Error Log Window\tCtrl+L")); @@ -538,10 +538,10 @@ HMENU debugwin_info::create_standard_menubar() // create the menu bar HMENU const menubar = CreateMenu(); - if (menubar == NULL) + if (menubar == nullptr) { DestroyMenu(debugmenu); - return NULL; + return nullptr; } AppendMenu(menubar, MF_ENABLED | MF_POPUP, (UINT_PTR)debugmenu, TEXT("Debug")); @@ -563,10 +563,10 @@ LRESULT CALLBACK debugwin_info::static_window_proc(HWND wnd, UINT message, WPARA } debugwin_info *const info = (debugwin_info *)(FPTR)GetWindowLongPtr(wnd, GWLP_USERDATA); - if (info == NULL) + if (info == nullptr) return DefWindowProc(wnd, message, wparam, lparam); - assert((info->m_wnd == wnd) || (info->m_wnd == NULL)); + assert((info->m_wnd == wnd) || (info->m_wnd == nullptr)); return info->window_proc(message, wparam, lparam); } @@ -581,10 +581,10 @@ void debugwin_info::register_window_class() wc.lpszClassName = TEXT("MAMEDebugWindow"); wc.hInstance = GetModuleHandleUni(); wc.lpfnWndProc = &debugwin_info::static_window_proc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hIcon = LoadIcon(wc.hInstance, MAKEINTRESOURCE(2)); - wc.lpszMenuName = NULL; - wc.hbrBackground = NULL; + wc.lpszMenuName = nullptr; + wc.hbrBackground = nullptr; wc.style = 0; wc.cbClsExtra = 0; wc.cbWndExtra = 0; diff --git a/src/osd/modules/debugger/win/debugwininfo.h b/src/osd/modules/debugger/win/debugwininfo.h index c0825bcf8d1..4bab0e2a3a3 100644 --- a/src/osd/modules/debugger/win/debugwininfo.h +++ b/src/osd/modules/debugger/win/debugwininfo.h @@ -41,9 +41,9 @@ public: } } - void show() { smart_show_window(m_wnd, true); } - void hide() { smart_show_window(m_wnd, false); } - void set_foreground() { SetForegroundWindow(m_wnd); } + void show() const { smart_show_window(m_wnd, true); } + void hide() const { smart_show_window(m_wnd, false); } + void set_foreground() const { SetForegroundWindow(m_wnd); } void destroy(); virtual bool set_default_focus(); diff --git a/src/osd/modules/debugger/win/disasmwininfo.cpp b/src/osd/modules/debugger/win/disasmwininfo.cpp index ae7e3894458..eb6466e437d 100644 --- a/src/osd/modules/debugger/win/disasmwininfo.cpp +++ b/src/osd/modules/debugger/win/disasmwininfo.cpp @@ -15,10 +15,10 @@ disasmwin_info::disasmwin_info(debugger_windows_interface &debugger) : - disasmbasewin_info(debugger, false, "Disassembly", NULL), - m_combownd(NULL) + disasmbasewin_info(debugger, false, "Disassembly", nullptr), + m_combownd(nullptr) { - if ((window() == NULL) || (m_views[0] == NULL)) + if ((window() == nullptr) || (m_views[0] == nullptr)) return; // set up the view to track the initial expression diff --git a/src/osd/modules/debugger/win/editwininfo.cpp b/src/osd/modules/debugger/win/editwininfo.cpp index 279bc68fbe3..6bf98df4352 100644 --- a/src/osd/modules/debugger/win/editwininfo.cpp +++ b/src/osd/modules/debugger/win/editwininfo.cpp @@ -23,18 +23,18 @@ editwin_info::editwin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler) : debugwin_info(debugger, is_main_console, title, handler), - m_editwnd(NULL), + m_editwnd(nullptr), m_edit_defstr(), - m_original_editproc(NULL), + m_original_editproc(nullptr), m_history_count(0), m_last_history(0) { - if (window() == NULL) + if (window() == nullptr) return; // create an edit box and override its key handling - m_editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), NULL, EDIT_BOX_STYLE, - 0, 0, 100, 100, window(), NULL, GetModuleHandleUni(), NULL); + m_editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), nullptr, EDIT_BOX_STYLE, + 0, 0, 100, 100, window(), nullptr, GetModuleHandleUni(), nullptr); m_original_editproc = (WNDPROC)(FPTR)GetWindowLongPtr(m_editwnd, GWLP_WNDPROC); SetWindowLongPtr(m_editwnd, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtr(m_editwnd, GWLP_WNDPROC, (LONG_PTR)&editwin_info::static_edit_proc); @@ -80,7 +80,7 @@ void editwin_info::set_editwnd_bounds(RECT const &bounds) void editwin_info::set_editwnd_text(char const *text) { TCHAR *tc_buffer = tstring_from_utf8(text); - if (tc_buffer != NULL) + if (tc_buffer != nullptr) { SendMessage(m_editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)tc_buffer); osd_free(tc_buffer); @@ -138,20 +138,20 @@ LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam) break; case VK_PRIOR: - if (m_views[0] != NULL) + if (m_views[0] != nullptr) m_views[0]->send_pageup(); break; case VK_NEXT: - if (m_views[0] != NULL) + if (m_views[0] != nullptr) m_views[0]->send_pagedown(); break; case VK_TAB: if (GetAsyncKeyState(VK_SHIFT) & 0x8000) - prev_view(NULL); + prev_view(nullptr); else - next_view(NULL); + next_view(nullptr); set_ignore_char_lparam(lparam); break; @@ -191,7 +191,7 @@ LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam) // process char *utf8_buffer = utf8_from_tstring(buffer); - if (utf8_buffer != NULL) + if (utf8_buffer != nullptr) { process_string(utf8_buffer); osd_free(utf8_buffer); diff --git a/src/osd/modules/debugger/win/memoryviewinfo.h b/src/osd/modules/debugger/win/memoryviewinfo.h index 2245ace307d..a690df6d782 100644 --- a/src/osd/modules/debugger/win/memoryviewinfo.h +++ b/src/osd/modules/debugger/win/memoryviewinfo.h @@ -23,7 +23,6 @@ public: UINT8 data_format() const; UINT32 chunks_per_row() const; bool reverse() const; - bool ascii() const; bool physical() const; void set_expression(char const *string); diff --git a/src/osd/modules/debugger/win/memorywininfo.cpp b/src/osd/modules/debugger/win/memorywininfo.cpp index b6d2b83614b..5ff85a60e60 100644 --- a/src/osd/modules/debugger/win/memorywininfo.cpp +++ b/src/osd/modules/debugger/win/memorywininfo.cpp @@ -16,14 +16,14 @@ memorywin_info::memorywin_info(debugger_windows_interface &debugger) : - editwin_info(debugger, false, "Memory", NULL), - m_combownd(NULL) + editwin_info(debugger, false, "Memory", nullptr), + m_combownd(nullptr) { if (!window()) return; m_views[0].reset(global_alloc(memoryview_info(debugger, *this, window()))); - if ((m_views[0] == NULL) || !m_views[0]->is_valid()) + if ((m_views[0] == nullptr) || !m_views[0]->is_valid()) { m_views[0].reset(); return; diff --git a/src/osd/modules/debugger/win/pointswininfo.cpp b/src/osd/modules/debugger/win/pointswininfo.cpp index 6dd56cc50cc..f055aa211f2 100644 --- a/src/osd/modules/debugger/win/pointswininfo.cpp +++ b/src/osd/modules/debugger/win/pointswininfo.cpp @@ -14,13 +14,13 @@ pointswin_info::pointswin_info(debugger_windows_interface &debugger) : - debugwin_info(debugger, false, std::string("All Breakpoints").c_str(), NULL) + debugwin_info(debugger, false, std::string("All Breakpoints").c_str(), nullptr) { if (!window()) return; m_views[0].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_BREAK_POINTS))); - if ((m_views[0] == NULL) || !m_views[0]->is_valid()) + if ((m_views[0] == nullptr) || !m_views[0]->is_valid()) { m_views[0].reset(); return; diff --git a/src/osd/modules/debugger/win/uimetrics.cpp b/src/osd/modules/debugger/win/uimetrics.cpp index 7da41d6f79f..c2d165c6a94 100644 --- a/src/osd/modules/debugger/win/uimetrics.cpp +++ b/src/osd/modules/debugger/win/uimetrics.cpp @@ -20,8 +20,8 @@ ui_metrics::ui_metrics(osd_options const &options) : m_vscroll_width(GetSystemMetrics(SM_CXVSCROLL)) { // create a temporary DC - HDC const temp_dc = GetDC(NULL); - if (temp_dc != NULL) + HDC const temp_dc = GetDC(nullptr); + if (temp_dc != nullptr) { float const size = options.debugger_font_size(); char const *const face = options.debugger_font(); @@ -32,7 +32,7 @@ ui_metrics::ui_metrics(osd_options const &options) : ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH, t_face); osd_free(t_face); - if (m_debug_font == NULL) + if (m_debug_font == nullptr) fatalerror("Unable to create debugger font\n"); // get the metrics @@ -45,13 +45,13 @@ ui_metrics::ui_metrics(osd_options const &options) : m_debug_font_ascent = metrics.tmAscent + metrics.tmExternalLeading; } SelectObject(temp_dc, old_font); - ReleaseDC(NULL, temp_dc); + ReleaseDC(nullptr, temp_dc); } } ui_metrics::ui_metrics(ui_metrics const &that) : - m_debug_font(NULL), + m_debug_font(nullptr), m_debug_font_height(that.m_debug_font_height), m_debug_font_width(that.m_debug_font_width), m_debug_font_ascent(that.m_debug_font_ascent), diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp index 9695aac7363..9b6ecdc0535 100644 --- a/src/osd/modules/file/winfile.cpp +++ b/src/osd/modules/file/winfile.cpp @@ -65,7 +65,7 @@ public: // then perform the read DWORD result = 0; - if (!ReadFile(m_handle, buffer, length, &result, NULL)) + if (!ReadFile(m_handle, buffer, length, &result, nullptr)) return win_error_to_file_error(GetLastError()); actual = result; @@ -82,7 +82,7 @@ public: // then perform the write DWORD result = 0; - if (!WriteFile(m_handle, buffer, length, &result, NULL)) + if (!WriteFile(m_handle, buffer, length, &result, nullptr)) return win_error_to_file_error(GetLastError()); actual = result; @@ -157,7 +157,7 @@ DWORD create_path_recursive(TCHAR *path) WIN32_FILE_ATTRIBUTE_DATA fileinfo; if (GetFileAttributesEx(path, GetFileExInfoStandard, &fileinfo)) return NO_ERROR; - else if (!CreateDirectory(path, NULL)) + else if (!CreateDirectory(path, nullptr)) return GetLastError(); else return NO_ERROR; @@ -212,7 +212,7 @@ osd_file::error osd_file::open(std::string const &orig_path, UINT32 openflags, p } // attempt to open the file - HANDLE h = CreateFile(t_path, access, sharemode, NULL, disposition, 0, NULL); + HANDLE h = CreateFile(t_path, access, sharemode, nullptr, disposition, 0, nullptr); if (INVALID_HANDLE_VALUE == h) { DWORD err = GetLastError(); @@ -220,7 +220,7 @@ osd_file::error osd_file::open(std::string const &orig_path, UINT32 openflags, p if ((ERROR_PATH_NOT_FOUND == err) && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS)) { TCHAR *pathsep = _tcsrchr(t_path, '\\'); - if (pathsep != NULL) + if (pathsep != nullptr) { // create the path up to the file *pathsep = 0; @@ -230,7 +230,7 @@ osd_file::error osd_file::open(std::string const &orig_path, UINT32 openflags, p // attempt to reopen the file if (err == NO_ERROR) { - h = CreateFile(t_path, access, sharemode, NULL, disposition, 0, NULL); + h = CreateFile(t_path, access, sharemode, nullptr, disposition, 0, nullptr); err = GetLastError(); } } @@ -318,15 +318,15 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN // do a create file on the drive t_filename = tstring_from_utf8(filename); - if (t_filename == NULL) + if (t_filename == nullptr) return FALSE; - file = CreateFile(t_filename, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL); + file = CreateFile(t_filename, GENERIC_READ, FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, nullptr); osd_free(t_filename); if (file == INVALID_HANDLE_VALUE) return FALSE; // device I/O control should return the geometry - result = DeviceIoControl(file, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &dg, sizeof(dg), &bytesRead, NULL); + result = DeviceIoControl(file, IOCTL_DISK_GET_DRIVE_GEOMETRY, nullptr, 0, &dg, sizeof(dg), &bytesRead, nullptr); CloseHandle(file); // if that failed, return false @@ -373,7 +373,7 @@ osd_directory_entry *osd_stat(const std::string &path) else { // attempt to find the first file - HANDLE find = FindFirstFileEx(t_path.get(), FindExInfoStandard, &find_data, FindExSearchNameMatch, NULL, 0); + HANDLE find = FindFirstFileEx(t_path.get(), FindExInfoStandard, &find_data, FindExSearchNameMatch, nullptr, 0); if (find == INVALID_HANDLE_VALUE) return nullptr; FindClose(find); @@ -407,7 +407,7 @@ osd_file::error osd_get_full_path(std::string &dst, std::string const &path) // cannonicalize the path TCHAR buffer[MAX_PATH]; - if (!GetFullPathName(t_path, ARRAY_LENGTH(buffer), buffer, NULL)) + if (!GetFullPathName(t_path, ARRAY_LENGTH(buffer), buffer, nullptr)) return win_error_to_file_error(GetLastError()); // convert the result back to UTF-8 @@ -430,7 +430,7 @@ bool osd_is_absolute_path(std::string const &path) { bool result = false; TCHAR *t_path = tstring_from_utf8(path.c_str()); - if (t_path != NULL) + if (t_path != nullptr) { result = !PathIsRelative(t_path); osd_free(t_path); @@ -454,7 +454,7 @@ const char *osd_get_volume_name(int idx) p = szBuffer; while(idx--) { p += strlen(p) + 1; - if (!*p) return NULL; + if (!*p) return nullptr; } return p; diff --git a/src/osd/modules/file/winptty.cpp b/src/osd/modules/file/winptty.cpp index 52e19491ea5..88920d69099 100644 --- a/src/osd/modules/file/winptty.cpp +++ b/src/osd/modules/file/winptty.cpp @@ -42,7 +42,7 @@ public: virtual error read(void *buffer, std::uint64_t offset, std::uint32_t count, std::uint32_t &actual) override { DWORD bytes_read; - if (!ReadFile(m_handle, buffer, count, &bytes_read, NULL)) + if (!ReadFile(m_handle, buffer, count, &bytes_read, nullptr)) return win_error_to_file_error(GetLastError()); actual = bytes_read; @@ -52,7 +52,7 @@ public: virtual error write(void const *buffer, std::uint64_t offset, std::uint32_t count, std::uint32_t &actual) override { DWORD bytes_written; - if (!WriteFile(m_handle, buffer, count, &bytes_written, NULL)) + if (!WriteFile(m_handle, buffer, count, &bytes_written, nullptr)) return win_error_to_file_error(GetLastError()); actual = bytes_written; @@ -91,7 +91,7 @@ osd_file::error win_open_ptty(std::string const &path, std::uint32_t openflags, if (!t_name) return osd_file::error::OUT_OF_MEMORY; - HANDLE pipe = CreateNamedPipe(t_name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 32, 32, 0, NULL); + HANDLE pipe = CreateNamedPipe(t_name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 32, 32, 0, nullptr); osd_free(t_name); if (INVALID_HANDLE_VALUE == pipe) diff --git a/src/osd/modules/font/font_dwrite.cpp b/src/osd/modules/font/font_dwrite.cpp index e3dfbfdbd85..670986f0cfc 100644 --- a/src/osd/modules/font/font_dwrite.cpp +++ b/src/osd/modules/font/font_dwrite.cpp @@ -109,7 +109,7 @@ void SaveBitmap(IWICBitmap* bitmap, GUID pixelFormat, const WCHAR *filename) reinterpret_cast<void**>(d2dfactory.GetAddressOf()))); // Initialize COM - ignore failure - CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); // Create a DirectWrite factory. HR_RET(pfn_DWriteCreateFactory( @@ -119,7 +119,7 @@ void SaveBitmap(IWICBitmap* bitmap, GUID pixelFormat, const WCHAR *filename) HR_RET(CoCreateInstance( CLSID_WICImagingFactory, - NULL, + nullptr, CLSCTX_INPROC_SERVER, __uuidof(IWICImagingFactory), (void**)&wicFactory)); @@ -128,19 +128,19 @@ void SaveBitmap(IWICBitmap* bitmap, GUID pixelFormat, const WCHAR *filename) HR_RET(stream->InitializeFromFilename(filename, GENERIC_WRITE)); ComPtr<IWICBitmapEncoder> encoder; - HR_RET(wicFactory->CreateEncoder(GUID_ContainerFormatBmp, NULL, &encoder)); + HR_RET(wicFactory->CreateEncoder(GUID_ContainerFormatBmp, nullptr, &encoder)); HR_RET(encoder->Initialize(stream.Get(), WICBitmapEncoderNoCache)); ComPtr<IWICBitmapFrameEncode> frameEncode; - HR_RET(encoder->CreateNewFrame(&frameEncode, NULL)); - HR_RET(frameEncode->Initialize(NULL)); + HR_RET(encoder->CreateNewFrame(&frameEncode, nullptr)); + HR_RET(frameEncode->Initialize(nullptr)); UINT width, height; HR_RET(bitmap->GetSize(&width, &height)); HR_RET(frameEncode->SetSize(width, height)); HR_RET(frameEncode->SetPixelFormat(&pixelFormat)); - HR_RET(frameEncode->WriteSource(bitmap, NULL)); + HR_RET(frameEncode->WriteSource(bitmap, nullptr)); HR_RET(frameEncode->Commit()); HR_RET(encoder->Commit()); @@ -165,7 +165,7 @@ void SaveBitmap2(bitmap_argb32 &bitmap, const WCHAR *filename) ComPtr<IWICImagingFactory> wicFactory; HR_RET(CoCreateInstance( CLSID_WICImagingFactory, - NULL, + nullptr, CLSCTX_INPROC_SERVER, __uuidof(IWICImagingFactory), (void**)&wicFactory)); @@ -710,7 +710,7 @@ public: HR_RET1(CoCreateInstance( CLSID_WICImagingFactory, - NULL, + nullptr, CLSCTX_INPROC_SERVER, __uuidof(IWICImagingFactory), static_cast<void**>(&m_wicFactory))); diff --git a/src/osd/modules/font/font_osx.cpp b/src/osd/modules/font/font_osx.cpp index e1c5137b397..22662d3b8d3 100644 --- a/src/osd/modules/font/font_osx.cpp +++ b/src/osd/modules/font/font_osx.cpp @@ -24,8 +24,8 @@ class osd_font_osx : public osd_font { public: - osd_font_osx() : m_font(NULL) { } - osd_font_osx(osd_font_osx &&obj) : m_font(obj.m_font) { obj.m_font = NULL; } + osd_font_osx() : m_font(nullptr) { } + osd_font_osx(osd_font_osx &&obj) : m_font(obj.m_font) { obj.m_font = nullptr; } virtual ~osd_font_osx() { close(); } virtual bool open(std::string const &font_path, std::string const &name, int &height); @@ -60,14 +60,14 @@ bool osd_font_osx::open(std::string const &font_path, std::string const &name, i } #endif - CFStringRef const font_name = CFStringCreateWithCString(NULL, name.c_str(), kCFStringEncodingUTF8); + CFStringRef const font_name = CFStringCreateWithCString(nullptr, name.c_str(), kCFStringEncodingUTF8); if (font_name && (kCFNotFound != CFStringFind(font_name, CFSTR(".BDF"), kCFCompareCaseInsensitive | kCFCompareBackwards | kCFCompareAnchored | kCFCompareNonliteral).location)) { // handle bdf fonts in the core CFRelease(font_name); return false; } - CTFontRef ct_font = NULL; + CTFontRef ct_font = nullptr; if (font_name) { CTFontDescriptorRef const font_descriptor = CTFontDescriptorCreateWithNameAndSize(font_name, 0.0); @@ -109,9 +109,9 @@ bool osd_font_osx::open(std::string const &font_path, std::string const &name, i void osd_font_osx::close() { - if (m_font != NULL) + if (m_font != nullptr) CFRelease(m_font); - m_font = NULL; + m_font = nullptr; } //------------------------------------------------- @@ -170,10 +170,10 @@ bool osd_font_osx::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, std::in context_ref = CGBitmapContextCreate( bitmap.raw_pixptr(0), bitmap_width, bitmap_height, bits_per_component, bitmap.rowpixels()*4, color_space, bitmap_info ); - if( context_ref != NULL ) + if( context_ref != nullptr ) { CGFontRef font_ref; - font_ref = CTFontCopyGraphicsFont( ct_font, NULL ); + font_ref = CTFontCopyGraphicsFont( ct_font, nullptr ); CGContextSetTextPosition(context_ref, -bounding_rect.origin.x*EXTRA_WIDTH, CTFontGetDescent(ct_font)+CTFontGetLeading(ct_font) ); CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0); CGContextSetFont( context_ref, font_ref ); @@ -202,9 +202,9 @@ public: private: static CFComparisonResult sort_callback(CTFontDescriptorRef first, CTFontDescriptorRef second, void *refCon) { - CFStringRef left = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(first, kCTFontDisplayNameAttribute, NULL); + CFStringRef left = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(first, kCTFontDisplayNameAttribute, nullptr); if (!left) left = (CFStringRef)CTFontDescriptorCopyAttribute(first, kCTFontNameAttribute); - CFStringRef right = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(second, kCTFontDisplayNameAttribute, NULL); + CFStringRef right = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(second, kCTFontDisplayNameAttribute, nullptr); if (!right) right = (CFStringRef)CTFontDescriptorCopyAttribute(second, kCTFontNameAttribute); CFComparisonResult result; @@ -223,8 +223,8 @@ bool font_osx::get_font_families(std::string const &font_path, std::vector<std:: { CFStringRef keys[] = { kCTFontCollectionRemoveDuplicatesOption }; std::uintptr_t values[ARRAY_LENGTH(keys)] = { 1 }; - CFDictionaryRef const options = CFDictionaryCreate(kCFAllocatorDefault, (void const **)keys, (void const **)values, ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, NULL); - CTFontCollectionRef const collection = CTFontCollectionCreateFromAvailableFonts(NULL); + CFDictionaryRef const options = CFDictionaryCreate(kCFAllocatorDefault, (void const **)keys, (void const **)values, ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, nullptr); + CTFontCollectionRef const collection = CTFontCollectionCreateFromAvailableFonts(nullptr); CFRelease(options); if (!collection) return false; @@ -239,7 +239,7 @@ bool font_osx::get_font_families(std::string const &font_path, std::vector<std:: { CTFontDescriptorRef const font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descriptors, i); CFStringRef const name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontNameAttribute); - CFStringRef const display = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontDisplayNameAttribute, NULL); + CFStringRef const display = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontDisplayNameAttribute, nullptr); if (name && display) { diff --git a/src/osd/modules/font/font_windows.cpp b/src/osd/modules/font/font_windows.cpp index 851d3b6d646..5dbae434854 100644 --- a/src/osd/modules/font/font_windows.cpp +++ b/src/osd/modules/font/font_windows.cpp @@ -32,9 +32,9 @@ namespace { class osd_font_windows : public osd_font { public: - osd_font_windows(): m_font(NULL) { } - osd_font_windows(osd_font_windows &&obj) : m_font(obj.m_font) { obj.m_font = NULL; } - virtual ~osd_font_windows() {close(); } + osd_font_windows(): m_font(nullptr) { } + osd_font_windows(osd_font_windows &&obj) : m_font(obj.m_font) { obj.m_font = nullptr; } + virtual ~osd_font_windows() { osd_font_windows::close(); } virtual bool open(std::string const &font_path, std::string const &name, int &height) override; virtual void close() override; @@ -93,11 +93,11 @@ bool osd_font_windows::open(std::string const &font_path, std::string const &_na // create the font height = logfont.lfHeight; m_font = CreateFontIndirect(&logfont); - if (m_font == NULL) + if (m_font == nullptr) return false; // select it into a temp DC and get the real font name - HDC dummyDC = CreateCompatibleDC(NULL); + HDC dummyDC = CreateCompatibleDC(nullptr); HGDIOBJ oldfont = SelectObject(dummyDC, m_font); std::vector<TCHAR> realname((std::max)(GetTextFace(dummyDC, 0, nullptr), 0)); int facelen = GetTextFace(dummyDC, realname.size(), &realname[0]); @@ -106,7 +106,7 @@ bool osd_font_windows::open(std::string const &font_path, std::string const &_na if (facelen <= 0) { DeleteObject(m_font); - m_font = NULL; + m_font = nullptr; return false; } @@ -119,7 +119,7 @@ bool osd_font_windows::open(std::string const &font_path, std::string const &_na if (result != 0) { DeleteObject(m_font); - m_font = NULL; + m_font = nullptr; return false; } return true; @@ -133,9 +133,9 @@ bool osd_font_windows::open(std::string const &font_path, std::string const &_na void osd_font_windows::close() { // delete the font ojbect - if (m_font != NULL) + if (m_font != nullptr) DeleteObject(m_font); - m_font = NULL; + m_font = nullptr; } //------------------------------------------------- @@ -149,7 +149,7 @@ void osd_font_windows::close() bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { // create a dummy DC to work with - HDC dummyDC = CreateCompatibleDC(NULL); + HDC dummyDC = CreateCompatibleDC(nullptr); HGDIOBJ oldfont = SelectObject(dummyDC, m_font); // get the text metrics @@ -191,7 +191,7 @@ bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT // create a DIB to render to BYTE *bits; - HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0); + HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), nullptr, 0); if (dib) { @@ -205,7 +205,7 @@ bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT WCHAR tempchar = chnum; SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff)); SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00)); - ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL); + ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, nullptr, &tempchar, 1, nullptr); // characters are expected to be full-height rectangle actbounds; diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h index 41a9d762838..094f3873f05 100644 --- a/src/osd/modules/input/input_common.h +++ b/src/osd/modules/input/input_common.h @@ -215,10 +215,10 @@ public: // Getters running_machine & machine() const { return m_machine; } - const char * name() { return m_name.c_str(); } - input_device * device() { return m_device; } + const char * name() const { return m_name.c_str(); } + input_device * device() const { return m_device; } input_module & module() const { return m_module; } - input_device_class deviceclass() { return m_deviceclass; } + input_device_class deviceclass() const { return m_deviceclass; } // Poll and reset methods virtual void poll() {}; @@ -289,20 +289,20 @@ public: void poll_devices() { - for (auto iter = m_list.begin(); iter != m_list.end(); iter++) + for (auto iter = m_list.begin(); iter != m_list.end(); ++iter) iter->get()->poll(); } void reset_devices() { - for (auto iter = m_list.begin(); iter != m_list.end(); iter++) + for (auto iter = m_list.begin(); iter != m_list.end(); ++iter) iter->get()->reset(); } void free_device(device_info * devinfo) { // remove us from the list - for (auto iter = m_list.begin(); iter != m_list.end(); iter++) + for (auto iter = m_list.begin(); iter != m_list.end(); ++iter) { if (iter->get() == devinfo) { @@ -316,7 +316,7 @@ public: { // remove us from the list int i = 0; - for (auto iter = m_list.begin(); iter != m_list.end(); iter++) + for (auto iter = m_list.begin(); iter != m_list.end(); ++iter) { if (iter->get() == devinfo) { @@ -336,7 +336,7 @@ public: m_list.pop_back(); } - int size() + int size() const { return m_list.size(); } @@ -419,7 +419,7 @@ public: keyboard_trans_table(std::unique_ptr<key_trans_entry[]> table, unsigned int size); // getters/setters - UINT32 size() { return m_table_size; } + UINT32 size() const { return m_table_size; } // public methods input_item_id lookup_mame_code(const char * scode) const; @@ -436,7 +436,7 @@ public: return s_instance; } - key_trans_entry & operator [](int i) { return m_table[i]; } + key_trans_entry & operator [](int i) const { return m_table[i]; } }; //============================================================ @@ -479,12 +479,12 @@ protected: public: - const osd_options * options() { return m_options; } + const osd_options * options() const { return m_options; } input_device_list * devicelist() { return &m_devicelist; } - bool input_enabled() { return m_input_enabled; } - bool input_paused() { return m_input_paused; } - bool mouse_enabled() { return m_mouse_enabled; } - bool lightgun_enabled() { return m_lightgun_enabled; } + bool input_enabled() const { return m_input_enabled; } + bool input_paused() const { return m_input_paused; } + bool mouse_enabled() const { return m_mouse_enabled; } + bool lightgun_enabled() const { return m_lightgun_enabled; } int init(const osd_options &options) override; diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index dfb63482570..5aa925edefe 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -236,7 +236,7 @@ public: instance.dwSize = sizeof(instance); result = devinfo->dinput.device->GetObjectInfo(&instance, offset, DIPH_BYOFFSET); - // if we got an error and have no default string, just return NULL + // if we got an error and have no default string, just return nullptr if (result != DI_OK) { if (defstring == nullptr) diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index eb9dbae1100..f91d083371d 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -157,7 +157,7 @@ public: auto window = GET_FOCUS_WINDOW(&event.text); //printf("Focus window is %p - wl %p\n", window, sdl_window_list); unicode_char result; - if (window != NULL) + if (window != nullptr) { osd_uchar_from_osdchar(&result, sdlevent.text.text, 1); machine().ui_input().push_char_event(window->target(), result); @@ -212,7 +212,7 @@ public: int cx = -1, cy = -1; auto window = GET_FOCUS_WINDOW(&sdlevent.motion); - if (window != NULL && window->xy_to_render_target(sdlevent.motion.x, sdlevent.motion.y, &cx, &cy)) + if (window != nullptr && window->xy_to_render_target(sdlevent.motion.x, sdlevent.motion.y, &cx, &cy)) machine().ui_input().push_mouse_move_event(window->target(), cx, cy); } break; @@ -229,7 +229,7 @@ public: int cx, cy; osd_ticks_t click = osd_ticks() * 1000 / osd_ticks_per_second(); auto window = GET_FOCUS_WINDOW(&sdlevent.button); - if (window != NULL && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) + if (window != nullptr && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) { machine().ui_input().push_mouse_down_event(window->target(), cx, cy); // FIXME Parameter ? @@ -254,7 +254,7 @@ public: int cx, cy; auto window = GET_FOCUS_WINDOW(&sdlevent.button); - if (window != NULL && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) + if (window != nullptr && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) { machine().ui_input().push_mouse_rdown_event(window->target(), cx, cy); } @@ -270,7 +270,7 @@ public: int cx, cy; auto window = GET_FOCUS_WINDOW(&sdlevent.button); - if (window != NULL && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) + if (window != nullptr && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) { machine().ui_input().push_mouse_up_event(window->target(), cx, cy); } @@ -280,7 +280,7 @@ public: int cx, cy; auto window = GET_FOCUS_WINDOW(&sdlevent.button); - if (window != NULL && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) + if (window != nullptr && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) { machine().ui_input().push_mouse_rup_event(window->target(), cx, cy); } @@ -289,7 +289,7 @@ public: case SDL_MOUSEWHEEL: auto window = GET_FOCUS_WINDOW(&sdlevent.wheel); - if (window != NULL) + if (window != nullptr) machine().ui_input().push_mouse_wheel_event(window->target(), 0, 0, sdlevent.wheel.y, 3); break; } @@ -324,7 +324,7 @@ public: sdl_joystick_device(running_machine &machine, const char *name, input_module &module) : sdl_device(machine, name, DEVICE_CLASS_JOYSTICK, module), joystick({{0}}), - sdl_state({0}) + sdl_state({ nullptr }) { } @@ -492,7 +492,7 @@ class sdl_keyboard_module : public sdl_input_module keyboard_trans_table * m_key_trans_table; public: sdl_keyboard_module() - : sdl_input_module(OSD_KEYBOARDINPUT_PROVIDER) + : sdl_input_module(OSD_KEYBOARDINPUT_PROVIDER), m_key_trans_table(nullptr) { } @@ -553,7 +553,7 @@ private: osd_printf_verbose("Keymap: Start reading keymap_file %s\n", keymap_filename); keymap_file = fopen(keymap_filename, "r"); - if (keymap_file == NULL) + if (keymap_file == nullptr) { osd_printf_warning("Keymap: Unable to open keymap %s, using default\n", keymap_filename); return &default_table; @@ -699,7 +699,7 @@ private: bool m_sixaxis_mode; public: sdl_joystick_module() - : sdl_input_module(OSD_JOYSTICKINPUT_PROVIDER) + : sdl_input_module(OSD_JOYSTICKINPUT_PROVIDER), m_sixaxis_mode(false) { } @@ -740,7 +740,7 @@ public: { sdl_joystick_device *devinfo = create_joystick_device(machine, &m_joy_map, stick, DEVICE_CLASS_JOYSTICK); - if (devinfo == NULL) + if (devinfo == nullptr) continue; physical_stick = m_joy_map.map[stick].physical; @@ -844,7 +844,7 @@ public: private: sdl_joystick_device* create_joystick_device(running_machine &machine, device_map_t *devmap, int index, input_device_class devclass) { - sdl_joystick_device *devinfo = NULL; + sdl_joystick_device *devinfo = nullptr; char tempname[20]; if (devmap->map[index].name.length() == 0) @@ -858,7 +858,7 @@ private: : devicelist()->create_device<sdl_joystick_device>(machine, tempname, *this); } - return NULL; + return nullptr; } else { diff --git a/src/osd/modules/input/input_sdlcommon.cpp b/src/osd/modules/input/input_sdlcommon.cpp index ebc20ddd319..82c470534b2 100644 --- a/src/osd/modules/input/input_sdlcommon.cpp +++ b/src/osd/modules/input/input_sdlcommon.cpp @@ -47,7 +47,7 @@ static inline std::shared_ptr<sdl_window_info> window_from_id(Uint32 windowID) return w; } } - return NULL; + return nullptr; } void sdl_event_manager::process_events(running_machine &machine) @@ -64,7 +64,7 @@ void sdl_event_manager::process_events(running_machine &machine) auto subscribers = m_subscription_index.equal_range(sdlevent.type); // Dispatch the events - for (auto iter = subscribers.first; iter != subscribers.second; iter++) + for (auto iter = subscribers.first; iter != subscribers.second; ++iter) iter->second->handle_event(sdlevent); } } @@ -73,7 +73,7 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event { std::shared_ptr<sdl_window_info> window = GET_WINDOW(&sdlevent.window); - if (window == NULL) + if (window == nullptr) return; switch (sdlevent.window.event) diff --git a/src/osd/modules/input/input_sdlcommon.h b/src/osd/modules/input/input_sdlcommon.h index 2e40199c556..abdc4ddf4ed 100644 --- a/src/osd/modules/input/input_sdlcommon.h +++ b/src/osd/modules/input/input_sdlcommon.h @@ -62,7 +62,8 @@ struct device_map_t class sdl_event_subscriber { public: - virtual void handle_event(SDL_Event &sdlevent) = 0; + virtual ~sdl_event_subscriber() {} + virtual void handle_event(SDL_Event &sdlevent) = 0; }; template <class TSubscriber> @@ -130,7 +131,7 @@ private: public: bool mouse_over_window() const { return m_mouse_over_window; } bool has_focus() const { return m_focus_window != nullptr; } - std::shared_ptr<sdl_window_info> focus_window() { return m_focus_window; } + std::shared_ptr<sdl_window_info> focus_window() const { return m_focus_window; } static sdl_event_manager& instance() { diff --git a/src/osd/modules/input/input_win32.cpp b/src/osd/modules/input/input_win32.cpp index 0b44c510fa0..d02c73c987a 100644 --- a/src/osd/modules/input/input_win32.cpp +++ b/src/osd/modules/input/input_win32.cpp @@ -202,7 +202,7 @@ public: // allocate a device devinfo = devicelist()->create_device<win32_mouse_device>(machine, "Win32 Mouse 1", *this); - if (devinfo == NULL) + if (devinfo == nullptr) return; // populate the axes @@ -377,7 +377,7 @@ public: // allocate a device devinfo = devicelist()->create_device<win32_lightgun_device>(machine, gun_names[gunnum], *this); - if (devinfo == NULL) + if (devinfo == nullptr) break; // populate the axes diff --git a/src/osd/modules/input/input_x11.cpp b/src/osd/modules/input/input_x11.cpp index 91e819eed7b..63563e9b0d8 100644 --- a/src/osd/modules/input/input_x11.cpp +++ b/src/osd/modules/input/input_x11.cpp @@ -130,7 +130,7 @@ find_device_info(Display *display, bool only_extended) { XDeviceInfo *devices; - XDeviceInfo *found = NULL; + XDeviceInfo *found = nullptr; int loop; int num_devices; int len = strlen(name); @@ -287,7 +287,7 @@ public: if (m_display != nullptr) return 0; - m_display = XOpenDisplay(NULL); + m_display = XOpenDisplay(nullptr); if (m_display == nullptr) { osd_printf_verbose("Unable to connect to X server\n"); diff --git a/src/osd/modules/lib/osdlib_macosx.cpp b/src/osd/modules/lib/osdlib_macosx.cpp index 4d1f839cabd..d000a1cb058 100644 --- a/src/osd/modules/lib/osdlib_macosx.cpp +++ b/src/osd/modules/lib/osdlib_macosx.cpp @@ -153,14 +153,14 @@ char *osd_get_clipboard_text(void) PasteboardRef pasteboard_ref; err = PasteboardCreate(kPasteboardClipboard, &pasteboard_ref); if (err) - return NULL; + return nullptr; PasteboardSynchronize(pasteboard_ref); ItemCount item_count; err = PasteboardGetItemCount(pasteboard_ref, &item_count); - char *result = NULL; // core expects a malloced C string of uft8 data + char *result = nullptr; // core expects a malloced C string of uft8 data for (UInt32 item_index = 1; (item_index <= item_count) && !result; item_index++) { PasteboardItemID item_id; diff --git a/src/osd/modules/lib/osdlib_unix.cpp b/src/osd/modules/lib/osdlib_unix.cpp index 3b67e4a2f3a..ea7dd60c203 100644 --- a/src/osd/modules/lib/osdlib_unix.cpp +++ b/src/osd/modules/lib/osdlib_unix.cpp @@ -146,7 +146,7 @@ char *osd_get_clipboard_text(void) char *osd_get_clipboard_text(void) { - char *result = NULL; + char *result = nullptr; if (SDL_HasClipboardText()) { diff --git a/src/osd/modules/lib/osdlib_win32.cpp b/src/osd/modules/lib/osdlib_win32.cpp index c5792f0307d..f778977614a 100644 --- a/src/osd/modules/lib/osdlib_win32.cpp +++ b/src/osd/modules/lib/osdlib_win32.cpp @@ -53,7 +53,7 @@ //============================================================ #ifdef OSD_WINDOWS -void (*s_debugger_stack_crawler)() = NULL; +void (*s_debugger_stack_crawler)() = nullptr; #endif @@ -116,8 +116,8 @@ void *osd_malloc(size_t size) // basic objects just come from the heap UINT8 *const block = reinterpret_cast<UINT8 *>(HeapAlloc(GetProcessHeap(), 0, size)); - if (block == NULL) - return NULL; + if (block == nullptr) + return nullptr; UINT8 *const result = reinterpret_cast<UINT8 *>(reinterpret_cast<FPTR>(block + sizeof(size_t) + MAX_ALIGNMENT) & ~(FPTR(MAX_ALIGNMENT) - 1)); // store the size and return and pointer to the data afterward @@ -145,14 +145,14 @@ void *osd_malloc_array(size_t size) size_t const rounded_size = ((size + sizeof(void *) + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; // reserve that much memory, plus two guard pages - void *page_base = VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS); - if (page_base == NULL) - return NULL; + void *page_base = VirtualAlloc(nullptr, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS); + if (page_base == nullptr) + return nullptr; // now allow access to everything but the first and last pages page_base = VirtualAlloc(reinterpret_cast<UINT8 *>(page_base) + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE); - if (page_base == NULL) - return NULL; + if (page_base == nullptr) + return nullptr; // work backwards from the page base to get to the block base UINT8 *const block = GUARD_ALIGN_START ? reinterpret_cast<UINT8 *>(page_base) : (reinterpret_cast<UINT8 *>(page_base) + rounded_size - size); @@ -231,7 +231,7 @@ void osd_break_into_debugger(const char *message) win_output_debug_string_utf8(message); DebugBreak(); } - else if (s_debugger_stack_crawler != NULL) + else if (s_debugger_stack_crawler != nullptr) (*s_debugger_stack_crawler)(); #else if (IsDebuggerPresent()) @@ -248,7 +248,7 @@ void osd_break_into_debugger(const char *message) static char *get_clipboard_text_by_format(UINT format, char *(*convert)(LPCVOID data)) { - char *result = NULL; + char *result = nullptr; HANDLE data_handle; LPVOID data; @@ -256,15 +256,15 @@ static char *get_clipboard_text_by_format(UINT format, char *(*convert)(LPCVOID if (IsClipboardFormatAvailable(format)) { // open the clipboard - if (OpenClipboard(NULL)) + if (OpenClipboard(nullptr)) { // try to access clipboard data data_handle = GetClipboardData(format); - if (data_handle != NULL) + if (data_handle != nullptr) { // lock the data data = GlobalLock(data_handle); - if (data != NULL) + if (data != nullptr) { // invoke the convert result = (*convert)(data); diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index 099c5fefb77..2afe86869b5 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -450,7 +450,7 @@ void osd_common_t::update(bool skip_redraw) // irregular intervals in some circumstances (e.g., multi-screen games // or games with asynchronous updates). // - if (m_watchdog != NULL) + if (m_watchdog != nullptr) m_watchdog->reset(); update_slider_list(); @@ -644,7 +644,7 @@ void osd_common_t::init_subsystems() m_midi = select_module_options<midi_module *>(options(), OSD_MIDI_PROVIDER); m_output = select_module_options<output_module *>(options(), OSD_OUTPUT_PROVIDER); - machine().output().set_notifier(NULL, output_notifier_callback, this); + machine().output().set_notifier(nullptr, output_notifier_callback, this); m_mod_man.init(options()); diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index 46049d74fe9..fc0d2f7a925 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -155,7 +155,7 @@ public: // BGFX specific options const char *bgfx_path() const { return value(OSDOPTION_BGFX_PATH); } const char *bgfx_backend() const { return value(OSDOPTION_BGFX_BACKEND); } - const bool bgfx_debug() const { return bool_value(OSDOPTION_BGFX_DEBUG); } + bool bgfx_debug() const { return bool_value(OSDOPTION_BGFX_DEBUG); } const char *bgfx_screen_chains() const { return value(OSDOPTION_BGFX_SCREEN_CHAINS); } const char *bgfx_shadow_mask() const { return value(OSDOPTION_BGFX_SHADOW_MASK); } const char *bgfx_avi_name() const { return value(OSDOPTION_BGFX_AVI_NAME); } @@ -209,7 +209,7 @@ public: // this INTERFACE but part of the osd IMPLEMENTATION // getters - running_machine &machine() { assert(m_machine != nullptr); return *m_machine; } + running_machine &machine() const { assert(m_machine != nullptr); return *m_machine; } virtual void debugger_update(); @@ -230,14 +230,14 @@ public: virtual void video_options_add(const char *name, void *type); - osd_options &options() { return m_options; } + virtual osd_options &options() { return m_options; } // osd_output interface ... virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override; bool verbose() const { return m_print_verbose; } void set_verbose(bool print_verbose) { m_print_verbose = print_verbose; } - void notify(const char *outname, INT32 value) { m_output->notify(outname, value); } + void notify(const char *outname, INT32 value) const { m_output->notify(outname, value); } protected: virtual bool input_init(); virtual void input_pause(); diff --git a/src/osd/modules/netdev/pcap.cpp b/src/osd/modules/netdev/pcap.cpp index 4c85c1367c0..541ed422d8a 100644 --- a/src/osd/modules/netdev/pcap.cpp +++ b/src/osd/modules/netdev/pcap.cpp @@ -55,7 +55,7 @@ class pcap_module : public osd_module, public netdev_module public: pcap_module() - : osd_module(OSD_NETDEV_PROVIDER, "pcap"), netdev_module(), handle(NULL) + : osd_module(OSD_NETDEV_PROVIDER, "pcap"), netdev_module(), handle(nullptr) { } virtual ~pcap_module() { } @@ -68,15 +68,15 @@ public: HMODULE handle; }; -static int (*pcap_compile_dl)(pcap_t *, struct bpf_program *, char *, int, bpf_u_int32) = NULL; -static int (*pcap_findalldevs_dl)(pcap_if_t **, char *) = NULL; -static pcap_t *(*pcap_open_live_dl)(const char *name, int, int, int, char *) = NULL; -static int (*pcap_next_ex_dl)(pcap_t *, struct pcap_pkthdr **, const u_char **) = NULL; -static void (*pcap_close_dl)(pcap_t *) = NULL; -static int (*pcap_setfilter_dl)(pcap_t *, struct bpf_program *) = NULL; -static int (*pcap_sendpacket_dl)(pcap_t *, u_char *, int) = NULL; -static int (*pcap_set_datalink_dl)(pcap_t *, int) = NULL; -static int (*pcap_dispatch_dl)(pcap_t *, int, pcap_handler callback, u_char *) = NULL; +static int (*pcap_compile_dl)(pcap_t *, struct bpf_program *, char *, int, bpf_u_int32) = nullptr; +static int (*pcap_findalldevs_dl)(pcap_if_t **, char *) = nullptr; +static pcap_t *(*pcap_open_live_dl)(const char *name, int, int, int, char *) = nullptr; +static int (*pcap_next_ex_dl)(pcap_t *, struct pcap_pkthdr **, const u_char **) = nullptr; +static void (*pcap_close_dl)(pcap_t *) = nullptr; +static int (*pcap_setfilter_dl)(pcap_t *, struct bpf_program *) = nullptr; +static int (*pcap_sendpacket_dl)(pcap_t *, u_char *, int) = nullptr; +static int (*pcap_set_datalink_dl)(pcap_t *, int) = nullptr; +static int (*pcap_dispatch_dl)(pcap_t *, int, pcap_handler callback, u_char *) = nullptr; #if 0 @@ -165,7 +165,7 @@ netdev_pcap::netdev_pcap(const char *name, class device_network_interface *ifdev { osd_printf_error("Unable to set %s to ethernet", name); pcap_close_dl(m_p); - m_p = NULL; + m_p = nullptr; return; } netdev_pcap::set_mac(get_mac()); @@ -174,7 +174,7 @@ netdev_pcap::netdev_pcap(const char *name, class device_network_interface *ifdev m_ctx.head = 0; m_ctx.tail = 0; m_ctx.p = m_p; - pthread_create(&m_thread, NULL, netdev_pcap_blocker, &m_ctx); + pthread_create(&m_thread, nullptr, netdev_pcap_blocker, &m_ctx); #endif } @@ -235,12 +235,12 @@ int netdev_pcap::recv_dev(UINT8 **buf) netdev_pcap::~netdev_pcap() { #ifdef SDLMAME_MACOSX - m_ctx.p = NULL; + m_ctx.p = nullptr; pthread_cancel(m_thread); - pthread_join(m_thread, NULL); + pthread_join(m_thread, nullptr); #endif if(m_p) pcap_close_dl(m_p); - m_p = NULL; + m_p = nullptr; } static CREATE_NETDEV(create_pcap) @@ -251,10 +251,10 @@ static CREATE_NETDEV(create_pcap) bool pcap_module::probe() { - if (handle == NULL) + if (handle == nullptr) { handle = LoadDynamicLibrary(LIB_NAME); - return (handle != NULL); + return (handle != nullptr); } return true; } @@ -315,7 +315,7 @@ void pcap_module::exit() { clear_netdev(); //FreeLibrary(handle); - //handle = NULL; + //handle = nullptr; } #else #include "modules/osdmodule.h" diff --git a/src/osd/modules/opengl/gl_shader_mgr.cpp b/src/osd/modules/opengl/gl_shader_mgr.cpp index 21ee7f9fc54..9f8dc8acd05 100644 --- a/src/osd/modules/opengl/gl_shader_mgr.cpp +++ b/src/osd/modules/opengl/gl_shader_mgr.cpp @@ -122,7 +122,7 @@ glsl_shader_info *glsl_shader_init(osd_gl_context *gl_ctx) int i,j, err; err = gl_shader_loadExtention(gl_ctx); - if(err) return NULL; + if(err) return nullptr; for (i=0; !err && i<GLSL_VERTEX_SHADER_INT_NUMBER; i++) { @@ -137,7 +137,7 @@ glsl_shader_info *glsl_shader_init(osd_gl_context *gl_ctx) #endif } - if(err) return NULL; + if(err) return nullptr; for (j=0; !err && j<GLSL_SHADER_FEAT_INT_NUMBER; j++) { @@ -146,16 +146,16 @@ glsl_shader_info *glsl_shader_init(osd_gl_context *gl_ctx) err = gl_compile_shader_files (&glsl_mamebm_programs[j], &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], &glsl_mamebmfsh_shader[j], - NULL /*precompiled*/, glsl_mamebm_fsh_files[j], 0); + nullptr /*precompiled*/, glsl_mamebm_fsh_files[j], 0); #else if(glsl_mamebm_fsh_sources[j]) err = gl_compile_shader_sources(&glsl_mamebm_programs[j], &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], &glsl_mamebm_fsh_shader[j], - NULL /*precompiled*/, glsl_mamebm_fsh_sources[j]); + nullptr /*precompiled*/, glsl_mamebm_fsh_sources[j]); #endif } - if (err) return NULL; + if (err) return nullptr; return (glsl_shader_info *) malloc(sizeof(glsl_shader_info *)); } @@ -169,29 +169,29 @@ int glsl_shader_free(glsl_shader_info *shinfo) for (i=0; i<GLSL_VERTEX_SHADER_MAX_NUMBER+9; i++) { if ( glsl_mamebm_vsh_shader[i] ) - (void) gl_delete_shader( NULL, &glsl_mamebm_vsh_shader[i], NULL); + (void) gl_delete_shader(nullptr, &glsl_mamebm_vsh_shader[i], nullptr); } for (j=0; j<GLSL_SHADER_FEAT_MAX_NUMBER+9; j++) { if ( glsl_mamebm_fsh_shader[j] ) - (void) gl_delete_shader( NULL, NULL, &glsl_mamebm_fsh_shader[j]); + (void) gl_delete_shader(nullptr, nullptr, &glsl_mamebm_fsh_shader[j]); } for (j=0; j<GLSL_SHADER_FEAT_MAX_NUMBER+9; j++) { if ( glsl_mamebm_programs[j] ) - (void) gl_delete_shader( &glsl_mamebm_programs[j], NULL, NULL); + (void) gl_delete_shader( &glsl_mamebm_programs[j], nullptr, nullptr); } for (i=0; i<10; i++) { if ( glsl_scrn_vsh_shader[i] ) - (void) gl_delete_shader( NULL, &glsl_scrn_vsh_shader[i], NULL); + (void) gl_delete_shader(nullptr, &glsl_scrn_vsh_shader[i], nullptr); if ( glsl_scrn_fsh_shader[i] ) - (void) gl_delete_shader( NULL, NULL, &glsl_scrn_fsh_shader[i]); + (void) gl_delete_shader(nullptr, nullptr, &glsl_scrn_fsh_shader[i]); if ( glsl_scrn_programs[i] ) - (void) gl_delete_shader( &glsl_scrn_programs[i], NULL, NULL); + (void) gl_delete_shader( &glsl_scrn_programs[i], nullptr, nullptr); } free(shinfo); @@ -213,7 +213,7 @@ int glsl_shader_add_mamebm(glsl_shader_info *shinfo, const char * custShaderPref err = gl_compile_shader_files (&glsl_mamebm_programs[GLSL_SHADER_FEAT_CUSTOM+idx], &glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_CUSTOM+idx], &glsl_mamebm_fsh_shader[GLSL_SHADER_FEAT_CUSTOM+idx], - NULL /*precompiled*/, fname, 0); + nullptr /*precompiled*/, fname, 0); return err; } @@ -233,6 +233,6 @@ int glsl_shader_add_scrn(glsl_shader_info *shinfo, const char * custShaderPrefix err = gl_compile_shader_files (&glsl_scrn_programs[idx], &glsl_scrn_vsh_shader[idx], &glsl_scrn_fsh_shader[idx], - NULL /*precompiled*/, fname, 0); + nullptr /*precompiled*/, fname, 0); return err; } diff --git a/src/osd/modules/opengl/gl_shader_mgr.h b/src/osd/modules/opengl/gl_shader_mgr.h index 532d40c30fe..b232243f636 100644 --- a/src/osd/modules/opengl/gl_shader_mgr.h +++ b/src/osd/modules/opengl/gl_shader_mgr.h @@ -26,7 +26,7 @@ struct glsl_shader_info /** - * returns pointer if ok, otherwise NULL + * returns pointer if ok, otherwise nullptr */ glsl_shader_info *glsl_shader_init(osd_gl_context *gl_ctx); diff --git a/src/osd/modules/opengl/gl_shader_tool.cpp b/src/osd/modules/opengl/gl_shader_tool.cpp index 8281691a607..5ee07661aa9 100644 --- a/src/osd/modules/opengl/gl_shader_tool.cpp +++ b/src/osd/modules/opengl/gl_shader_tool.cpp @@ -18,28 +18,28 @@ #include "emu.h" #include "gl_shader_tool.h" -PFNGLGETOBJECTPARAMETERIVARBPROC pfn_glGetObjectParameterivARB=NULL; -PFNGLGETINFOLOGARBPROC pfn_glGetInfoLogARB=NULL; -PFNGLDELETEOBJECTARBPROC pfn_glDeleteObjectARB=NULL; -PFNGLCREATESHADEROBJECTARBPROC pfn_glCreateShaderObjectARB=NULL; -PFNGLSHADERSOURCEARBPROC pfn_glShaderSourceARB=NULL; -PFNGLCOMPILESHADERARBPROC pfn_glCompileShaderARB=NULL; -PFNGLCREATEPROGRAMOBJECTARBPROC pfn_glCreateProgramObjectARB=NULL; -PFNGLATTACHOBJECTARBPROC pfn_glAttachObjectARB=NULL; -PFNGLLINKPROGRAMARBPROC pfn_glLinkProgramARB=NULL; -PFNGLVALIDATEPROGRAMARBPROC pfn_glValidateProgramARB=NULL; -PFNGLUSEPROGRAMOBJECTARBPROC pfn_glUseProgramObjectARB=NULL; -PFNGLGETUNIFORMLOCATIONARBPROC pfn_glGetUniformLocationARB=NULL; -PFNGLUNIFORM1FARBPROC pfn_glUniform1fARB=NULL; -PFNGLUNIFORM1IARBPROC pfn_glUniform1iARB=NULL; -PFNGLUNIFORM1FVARBPROC pfn_glUniform1fvARB=NULL; -PFNGLUNIFORM2FVARBPROC pfn_glUniform2fvARB=NULL; -PFNGLUNIFORM3FVARBPROC pfn_glUniform3fvARB=NULL; -PFNGLUNIFORM4FVARBPROC pfn_glUniform4fvARB=NULL; -PFNGLUNIFORM1IVARBPROC pfn_glUniform1ivARB=NULL; -PFNGLUNIFORM2IVARBPROC pfn_glUniform2ivARB=NULL; -PFNGLUNIFORM3IVARBPROC pfn_glUniform3ivARB=NULL; -PFNGLUNIFORM4IVARBPROC pfn_glUniform4ivARB=NULL; +PFNGLGETOBJECTPARAMETERIVARBPROC pfn_glGetObjectParameterivARB= nullptr; +PFNGLGETINFOLOGARBPROC pfn_glGetInfoLogARB= nullptr; +PFNGLDELETEOBJECTARBPROC pfn_glDeleteObjectARB= nullptr; +PFNGLCREATESHADEROBJECTARBPROC pfn_glCreateShaderObjectARB= nullptr; +PFNGLSHADERSOURCEARBPROC pfn_glShaderSourceARB= nullptr; +PFNGLCOMPILESHADERARBPROC pfn_glCompileShaderARB= nullptr; +PFNGLCREATEPROGRAMOBJECTARBPROC pfn_glCreateProgramObjectARB= nullptr; +PFNGLATTACHOBJECTARBPROC pfn_glAttachObjectARB= nullptr; +PFNGLLINKPROGRAMARBPROC pfn_glLinkProgramARB= nullptr; +PFNGLVALIDATEPROGRAMARBPROC pfn_glValidateProgramARB= nullptr; +PFNGLUSEPROGRAMOBJECTARBPROC pfn_glUseProgramObjectARB= nullptr; +PFNGLGETUNIFORMLOCATIONARBPROC pfn_glGetUniformLocationARB= nullptr; +PFNGLUNIFORM1FARBPROC pfn_glUniform1fARB= nullptr; +PFNGLUNIFORM1IARBPROC pfn_glUniform1iARB= nullptr; +PFNGLUNIFORM1FVARBPROC pfn_glUniform1fvARB= nullptr; +PFNGLUNIFORM2FVARBPROC pfn_glUniform2fvARB= nullptr; +PFNGLUNIFORM3FVARBPROC pfn_glUniform3fvARB= nullptr; +PFNGLUNIFORM4FVARBPROC pfn_glUniform4fvARB= nullptr; +PFNGLUNIFORM1IVARBPROC pfn_glUniform1ivARB= nullptr; +PFNGLUNIFORM2IVARBPROC pfn_glUniform2ivARB= nullptr; +PFNGLUNIFORM3IVARBPROC pfn_glUniform3ivARB= nullptr; +PFNGLUNIFORM4IVARBPROC pfn_glUniform4ivARB= nullptr; int gl_shader_loadExtention(osd_gl_context *gl_ctx) @@ -256,7 +256,7 @@ int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsi glTexImage2D (texTargetProxy, level, internalFormat, width, height, - border, format, type, NULL); + border, format, type, nullptr); if ( 0!=(err=GL_CHECK_ERROR_NORMAL() )) return err; glGetTexLevelParameteriv( texTargetProxy, level, GL_TEXTURE_WIDTH, avail_width); @@ -305,7 +305,7 @@ static int delete_shader_tool( GLhandleARB *program, GLhandleARB *vertex_shader, int res=0; GL_CHECK_ERROR_QUIET(); - if(program!=NULL && *program!=0) + if(program!= nullptr && *program!=0) { pfn_glDeleteObjectARB(*program); if(externalcall) @@ -314,7 +314,7 @@ static int delete_shader_tool( GLhandleARB *program, GLhandleARB *vertex_shader, } *program=0; } - if(vertex_shader!=NULL && *vertex_shader!=0) + if(vertex_shader!= nullptr && *vertex_shader!=0) { pfn_glDeleteObjectARB(*vertex_shader); if(externalcall) @@ -323,7 +323,7 @@ static int delete_shader_tool( GLhandleARB *program, GLhandleARB *vertex_shader, } *vertex_shader=0; } - if(fragment_shader!=NULL && *fragment_shader!=0) + if(fragment_shader!= nullptr && *fragment_shader!=0) { pfn_glDeleteObjectARB(*fragment_shader); if(externalcall) @@ -340,19 +340,19 @@ int gl_compile_shader_source( GLhandleARB *shader, GLenum type, const char * sha { int err = 0; - if(shader==NULL || shader_source==NULL) + if(shader== nullptr || shader_source== nullptr) { - if(shader==NULL) - osd_printf_warning("error: gl_compile_shader_source: NULL shader passed\n"); - if(shader_source==NULL) - osd_printf_warning("error: gl_compile_shader_source: NULL shader source passed\n"); + if(shader== nullptr) + osd_printf_warning("error: gl_compile_shader_source: nullptr shader passed\n"); + if(shader_source== nullptr) + osd_printf_warning("error: gl_compile_shader_source: nullptr shader source passed\n"); return -1; } *shader = pfn_glCreateShaderObjectARB(type); err=GL_SHADER_CHECK(*shader, GL_OBJECT_TYPE_ARB); if(err) goto errout; - pfn_glShaderSourceARB(*shader, 1, (const GLcharARB **)&shader_source, NULL); + pfn_glShaderSourceARB(*shader, 1, (const GLcharARB **)&shader_source, nullptr); pfn_glCompileShaderARB(*shader); err=GL_SHADER_CHECK(*shader, GL_OBJECT_COMPILE_STATUS_ARB); @@ -374,12 +374,12 @@ errout: int gl_compile_shader_file( GLhandleARB *shader, GLenum type, const char * shader_file, int verbose ) { - if(shader==NULL || shader_file==NULL) + if(shader== nullptr || shader_file== nullptr) { - if(shader==NULL) - osd_printf_warning("error: gl_compile_shader_source: NULL shader passed\n"); - if(shader_file==NULL) - osd_printf_warning("error: gl_compile_shader_source: NULL shader file passed\n"); + if(shader== nullptr) + osd_printf_warning("error: gl_compile_shader_source: nullptr shader passed\n"); + if(shader_file== nullptr) + osd_printf_warning("error: gl_compile_shader_source: nullptr shader file passed\n"); return -1; } diff --git a/src/osd/modules/osdmodule.cpp b/src/osd/modules/osdmodule.cpp index 1c745effc6c..8ebf72f4cd4 100644 --- a/src/osd/modules/osdmodule.cpp +++ b/src/osd/modules/osdmodule.cpp @@ -44,7 +44,7 @@ void osd_module_manager::register_module(const module_type &mod_type) } } -bool osd_module_manager::type_has_name(const char *type, const char *name) +bool osd_module_manager::type_has_name(const char *type, const char *name) const { return (get_module_index(type, name) >= 0); } @@ -91,7 +91,7 @@ void osd_module_manager::exit() } } -int osd_module_manager::get_module_index(const char *type, const char *name) +int osd_module_manager::get_module_index(const char *type, const char *name) const { for (int i = 0; m_modules[i] != nullptr; i++) { @@ -101,7 +101,7 @@ int osd_module_manager::get_module_index(const char *type, const char *name) return -1; } -void osd_module_manager::get_module_names(const char *type, const int max, int *num, const char *names[]) +void osd_module_manager::get_module_names(const char *type, const int max, int *num, const char *names[]) const { *num = 0; for (int i = 0; m_modules[i] != nullptr; i++) diff --git a/src/osd/modules/osdmodule.h b/src/osd/modules/osdmodule.h index 1e545aa299b..1aa6c494855 100644 --- a/src/osd/modules/osdmodule.h +++ b/src/osd/modules/osdmodule.h @@ -68,7 +68,7 @@ public: ~osd_module_manager(); void register_module(const module_type &mod_type); - bool type_has_name(const char *type, const char *name); + bool type_has_name(const char *type, const char *name) const; osd_module *get_module_generic(const char *type, const char *name); @@ -80,14 +80,14 @@ public: osd_module *select_module(const char *type, const char *name = ""); - void get_module_names(const char *type, const int max, int *num, const char *names[]); + void get_module_names(const char *type, const int max, int *num, const char *names[]) const; void init(const osd_options &options); void exit(); private: - int get_module_index(const char *type, const char *name); + int get_module_index(const char *type, const char *name) const; osd_module *m_modules[MAX_MODULES]; osd_module *m_selected[MAX_MODULES]; diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h index 05b1020d9ab..7f20c7c7b62 100644 --- a/src/osd/modules/osdwindow.h +++ b/src/osd/modules/osdwindow.h @@ -53,7 +53,7 @@ class osd_monitor_info { public: osd_monitor_info(void *handle, const char *monitor_device, float aspect) - : m_next(NULL), m_handle(handle), m_aspect(aspect) + : m_next(nullptr), m_is_primary(false), m_handle(handle), m_aspect(aspect) { strncpy(m_name, monitor_device, ARRAY_LENGTH(m_name) - 1); } @@ -62,21 +62,21 @@ public: virtual void refresh() = 0; - const void *oshandle() { return m_handle; } + const void *oshandle() const { return m_handle; } - const osd_rect &position_size() { return m_pos_size; } - const osd_rect &usuable_position_size() { return m_usuable_pos_size; } + const osd_rect &position_size() const { return m_pos_size; } + const osd_rect &usuable_position_size() const { return m_usuable_pos_size; } const char *devicename() { return m_name[0] ? m_name : "UNKNOWN"; } - float aspect() { return m_aspect; } - float pixel_aspect() { return m_aspect / ((float)m_pos_size.width() / (float)m_pos_size.height()); } + float aspect() const { return m_aspect; } + float pixel_aspect() const { return m_aspect / ((float)m_pos_size.width() / (float)m_pos_size.height()); } - void update_resolution(const int new_width, const int new_height) { m_pos_size.resize(new_width, new_height); } + void update_resolution(const int new_width, const int new_height) const { m_pos_size.resize(new_width, new_height); } void set_aspect(const float a) { m_aspect = a; } - bool is_primary() { return m_is_primary; } + bool is_primary() const { return m_is_primary; } - osd_monitor_info * next() { return m_next; } // pointer to next monitor in list + osd_monitor_info * next() const { return m_next; } // pointer to next monitor in list static osd_monitor_info *pick_monitor(osd_options &options, int index); static osd_monitor_info *list; @@ -114,7 +114,7 @@ public: osd_window() : #ifndef OSD_SDL - m_dc(0), m_resize_state(0), + m_dc(nullptr), m_resize_state(0), #endif m_primlist(nullptr), m_index(0), @@ -162,7 +162,7 @@ public: m_platform_window = window; } - std::shared_ptr<osd_window> main_window() { return m_main; } + std::shared_ptr<osd_window> main_window() const { return m_main; } void set_main_window(std::shared_ptr<osd_window> main) { m_main = main; } // Clips the pointer to the bounds of this window @@ -176,7 +176,7 @@ public: #ifndef OSD_SDL virtual bool win_has_menu() = 0; - // FIXME: cann we replace winwindow_video_window_monitor(NULL) with monitor() ? + // FIXME: cann we replace winwindow_video_window_monitor(nullptr) with monitor() ? virtual osd_monitor_info *winwindow_video_window_monitor(const osd_rect *proposed) = 0; HDC m_dc; // only used by GDI renderer! @@ -225,7 +225,7 @@ public: return m_window.lock(); } - bool has_flags(const int flag) { return ((m_flags & flag)) == flag; } + bool has_flags(const int flag) const { return ((m_flags & flag)) == flag; } void set_flags(int aflag) { m_flags |= aflag; } void clear_flags(int aflag) { m_flags &= ~aflag; } diff --git a/src/osd/modules/output/network.cpp b/src/osd/modules/output/network.cpp index 3bca29f3dbb..95f898fbf41 100644 --- a/src/osd/modules/output/network.cpp +++ b/src/osd/modules/output/network.cpp @@ -27,8 +27,8 @@ public: virtual ~output_network_server() { delete m_tcp_server; } - void terminate_all() { m_tcp_server->terminate(); } - void send_to_all(const uint8_t* data, size_t len) { m_tcp_server->send_to_all(data,len); } + void terminate_all() const { m_tcp_server->terminate(); } + void send_to_all(const uint8_t* data, size_t len) const { m_tcp_server->send_to_all(data,len); } /* Pure virtual methods inherited from raw_tcp_server::listener. */ virtual void on_raw_tcp_connection_closed(raw_tcp_server* tcpServer, raw_tcp_connection* connection, bool is_closed_by_peer) override { } diff --git a/src/osd/modules/render/bgfx/clearreader.cpp b/src/osd/modules/render/bgfx/clearreader.cpp index 78c3d139d25..3cbd714463c 100644 --- a/src/osd/modules/render/bgfx/clearreader.cpp +++ b/src/osd/modules/render/bgfx/clearreader.cpp @@ -30,10 +30,10 @@ clear_state* clear_reader::read_from_value(const Value& value, std::string prefi for (int i = 0; i < colors.Size(); i++) { if (!READER_CHECK(colors[i].IsNumber(), (prefix + "clearcolor[" + std::to_string(i) + "] must be a numeric value\n").c_str())) return nullptr; - int32_t value = int32_t(float(colors[i].GetDouble()) * 255.0f); - if (value > 255) value = 255; - if (value < 0) value = 0; - clear_color |= value << (24 - (i * 3)); + int32_t val = int32_t(float(colors[i].GetDouble()) * 255.0f); + if (val > 255) val = 255; + if (val < 0) val = 0; + clear_color |= val << (24 - (i * 3)); } clear_flags |= BGFX_CLEAR_COLOR; } diff --git a/src/osd/modules/render/bgfx/target.cpp b/src/osd/modules/render/bgfx/target.cpp index 4d1d3ea6b2a..e6ec9061389 100644 --- a/src/osd/modules/render/bgfx/target.cpp +++ b/src/osd/modules/render/bgfx/target.cpp @@ -57,6 +57,7 @@ bgfx_target::bgfx_target(void *handle, uint16_t width, uint16_t height) , m_double_buffer(false) , m_style(TARGET_STYLE_CUSTOM) , m_filter(false) + , m_scale(0) , m_screen(-1) , m_current_page(0) , m_initialized(true) diff --git a/src/osd/modules/render/blit13.h b/src/osd/modules/render/blit13.h index f199fc0f2ea..22a7a1fcea5 100644 --- a/src/osd/modules/render/blit13.h +++ b/src/osd/modules/render/blit13.h @@ -146,7 +146,7 @@ struct blit_texcopy : public blit_base x = texsource->width / (_len_div); while (x > 0) { *dst++ = m_op.op(*src, palbase); - src++; + ++src; x--; } } diff --git a/src/osd/modules/render/d3d/d3dcomm.h b/src/osd/modules/render/d3d/d3dcomm.h index c4ae5b4ff1d..2fd7477ac43 100644 --- a/src/osd/modules/render/d3d/d3dcomm.h +++ b/src/osd/modules/render/d3d/d3dcomm.h @@ -40,12 +40,12 @@ public: c.y = y; } - vec2f operator+(const vec2f& a) + vec2f operator+(const vec2f& a) const { return vec2f(c.x + a.c.x, c.y + a.c.y); } - vec2f operator-(const vec2f& a) + vec2f operator-(const vec2f& a) const { return vec2f(c.x - a.c.x, c.y - a.c.y); } @@ -59,7 +59,9 @@ public: class d3d_texture_manager { public: - d3d_texture_manager() { } + d3d_texture_manager(): m_renderer(nullptr), m_texlist(nullptr), m_dynamic_supported(0), m_stretch_supported(0), m_yuv_format(), m_texture_caps(0), m_texture_max_aspect(0), m_texture_max_width(0), m_texture_max_height(0), m_vector_texture(nullptr), m_default_texture(nullptr) + { } + d3d_texture_manager(renderer_d3d9 *d3d); ~d3d_texture_manager(); @@ -71,22 +73,22 @@ public: texture_info * find_texinfo(const render_texinfo *texture, UINT32 flags); UINT32 texture_compute_hash(const render_texinfo *texture, UINT32 flags); - texture_info * get_texlist() { return m_texlist; } + texture_info * get_texlist() const { return m_texlist; } void set_texlist(texture_info *texlist) { m_texlist = texlist; } - bool is_dynamic_supported() { return (bool)m_dynamic_supported; } + bool is_dynamic_supported() const { return (bool)m_dynamic_supported; } void set_dynamic_supported(bool dynamic_supported) { m_dynamic_supported = dynamic_supported; } - bool is_stretch_supported() { return (bool)m_stretch_supported; } - D3DFORMAT get_yuv_format() { return m_yuv_format; } + bool is_stretch_supported() const { return (bool)m_stretch_supported; } + D3DFORMAT get_yuv_format() const { return m_yuv_format; } - DWORD get_texture_caps() { return m_texture_caps; } - DWORD get_max_texture_aspect() { return m_texture_max_aspect; } - DWORD get_max_texture_width() { return m_texture_max_width; } - DWORD get_max_texture_height() { return m_texture_max_height; } + DWORD get_texture_caps() const { return m_texture_caps; } + DWORD get_max_texture_aspect() const { return m_texture_max_aspect; } + DWORD get_max_texture_width() const { return m_texture_max_width; } + DWORD get_max_texture_height() const { return m_texture_max_height; } - texture_info * get_default_texture() { return m_default_texture; } - texture_info * get_vector_texture() { return m_vector_texture; } + texture_info * get_default_texture() const { return m_default_texture; } + texture_info * get_vector_texture() const { return m_vector_texture; } - renderer_d3d9 * get_d3d() { return m_renderer; } + renderer_d3d9 * get_d3d() const { return m_renderer; } private: renderer_d3d9 * m_renderer; @@ -248,7 +250,9 @@ class cache_target { public: // construction/destruction - cache_target() { } + cache_target(): last_target(nullptr), last_texture(nullptr), target_width(0), target_height(0), width(0), height(0), screen_index(0), next(nullptr), prev(nullptr) + { } + ~cache_target(); bool init(renderer_d3d9 *d3d, d3d_base *d3dintf, int source_width, int source_height, int target_width, int target_height); @@ -273,7 +277,9 @@ class d3d_render_target { public: // construction/destruction - d3d_render_target() { } + d3d_render_target(): target_width(0), target_height(0), width(0), height(0), screen_index(0), page_index(0), next(nullptr), prev(nullptr), bloom_count(0) + { } + ~d3d_render_target(); bool init(renderer_d3d9 *d3d, d3d_base *d3dintf, int source_width, int source_height, int target_width, int target_height); diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp index 859914d741c..190c324d764 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.cpp +++ b/src/osd/modules/render/d3d/d3dhlsl.cpp @@ -276,7 +276,7 @@ void shaders::render_snapshot(surface *surface) // add two text entries describing the image std::string text1 = std::string(emulator_info::get_appname()).append(" ").append(emulator_info::get_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()); diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h index 8851531678e..c7813122308 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.h +++ b/src/osd/modules/render/d3d/d3dhlsl.h @@ -326,7 +326,7 @@ public: void window_save(); void window_record(); - bool recording() { return avi_output_file != nullptr; } + bool recording() const { return avi_output_file != nullptr; } void avi_update_snap(surface *surface); void render_snapshot(surface *surface); diff --git a/src/osd/modules/render/drawd3d.h b/src/osd/modules/render/drawd3d.h index 0777da977b0..3b1083881b3 100644 --- a/src/osd/modules/render/drawd3d.h +++ b/src/osd/modules/render/drawd3d.h @@ -91,36 +91,36 @@ public: void reset_render_states(); // Setters / getters - int get_adapter() { return m_adapter; } - int get_width() { return m_width; } - vec2f get_dims() { return vec2f(m_width, m_height); } - int get_height() { return m_height; } - int get_refresh() { return m_refresh; } + int get_adapter() const { return m_adapter; } + int get_width() const { return m_width; } + vec2f get_dims() const { return vec2f(m_width, m_height); } + int get_height() const { return m_height; } + int get_refresh() const { return m_refresh; } - device * get_device() { return m_device; } + device * get_device() const { return m_device; } present_parameters * get_presentation() { return &m_presentation; } - vertex_buffer * get_vertex_buffer() { return m_vertexbuf; } - vertex * get_locked_buffer() { return m_lockedbuf; } - VOID ** get_locked_buffer_ptr() { return (VOID **)&m_lockedbuf; } + vertex_buffer * get_vertex_buffer() const { return m_vertexbuf; } + vertex * get_locked_buffer() const { return m_lockedbuf; } + VOID ** get_locked_buffer_ptr()const { return (VOID **)&m_lockedbuf; } void set_locked_buffer(vertex *lockedbuf) { m_lockedbuf = lockedbuf; } void set_restarting(bool restarting) { m_restarting = restarting; } - bool is_mod2x_supported() { return (bool)m_mod2x_supported; } - bool is_mod4x_supported() { return (bool)m_mod4x_supported; } + bool is_mod2x_supported() const { return (bool)m_mod2x_supported; } + bool is_mod4x_supported() const { return (bool)m_mod4x_supported; } - D3DFORMAT get_screen_format() { return m_screen_format; } - D3DFORMAT get_pixel_format() { return m_pixformat; } - D3DDISPLAYMODE get_origmode() { return m_origmode; } + D3DFORMAT get_screen_format() const { return m_screen_format; } + D3DFORMAT get_pixel_format() const { return m_pixformat; } + D3DDISPLAYMODE get_origmode() const { return m_origmode; } - UINT32 get_last_texture_flags() { return m_last_texture_flags; } + UINT32 get_last_texture_flags() const { return m_last_texture_flags; } - d3d_texture_manager * get_texture_manager() { return m_texture_manager; } + d3d_texture_manager * get_texture_manager() const { return m_texture_manager; } texture_info * get_default_texture(); texture_info * get_vector_texture(); - shaders * get_shaders() { return m_shaders; } - hlsl_options * get_shaders_options() { return m_shaders_options; } + shaders * get_shaders() const { return m_shaders; } + hlsl_options * get_shaders_options() const { return m_shaders_options; } private: int m_adapter; // ordinal adapter number diff --git a/src/osd/modules/render/drawogl.h b/src/osd/modules/render/drawogl.h index 6b959f1da35..c96c3a45b1b 100644 --- a/src/osd/modules/render/drawogl.h +++ b/src/osd/modules/render/drawogl.h @@ -42,7 +42,7 @@ public: : hash(0), flags(0), rawwidth(0), rawheight(0), rawwidth_create(0), rawheight_create(0), type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0), - texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL), + texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(nullptr), data_own(0), texCoordBufferName(0) { for (int i=0; i<2; i++) @@ -101,7 +101,7 @@ public: , m_width(0) , m_height(0) , m_blit_dim(0, 0) - , m_gl_context(NULL) + , m_gl_context(nullptr) , m_initialized(0) , m_last_blendmode(0) , m_texture_max_width(0) @@ -122,7 +122,7 @@ public: , m_surf_h(0) { for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++) - m_texhash[i] = NULL; + m_texhash[i] = nullptr; for (int i=0; i < 2*GLSL_SHADER_MAX; i++) m_glsl_program[i] = 0; for (int i=0; i < 8; i++) diff --git a/src/osd/modules/render/drawsdl.cpp b/src/osd/modules/render/drawsdl.cpp index 38d18f42aa8..622c360df7e 100644 --- a/src/osd/modules/render/drawsdl.cpp +++ b/src/osd/modules/render/drawsdl.cpp @@ -59,9 +59,9 @@ static void yuv_RGB_to_YUY2X2(const UINT16 *bitmap, UINT8 *ptr, const int pitch, static const sdl_scale_mode scale_modes[] = { - { "none", 0, 0, 1, 1, DRAW2_SCALEMODE_NEAREST, 0, 0 }, - { "hwblit", 1, 0, 1, 1, DRAW2_SCALEMODE_LINEAR, 0, 0 }, - { "hwbest", 1, 0, 1, 1, DRAW2_SCALEMODE_BEST, 0, 0 }, + { "none", 0, 0, 1, 1, DRAW2_SCALEMODE_NEAREST, 0, nullptr }, + { "hwblit", 1, 0, 1, 1, DRAW2_SCALEMODE_LINEAR, 0, nullptr }, + { "hwbest", 1, 0, 1, 1, DRAW2_SCALEMODE_BEST, 0, nullptr }, /* SDL1.2 uses interpolation as well */ { "yv12", 1, 1, 1, 1, DRAW2_SCALEMODE_BEST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12 }, { "yv12x2", 1, 1, 2, 2, DRAW2_SCALEMODE_BEST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12X2 }, diff --git a/src/osd/modules/render/sdlglcontext.h b/src/osd/modules/render/sdlglcontext.h index 9a3194582ac..e20c351908a 100644 --- a/src/osd/modules/render/sdlglcontext.h +++ b/src/osd/modules/render/sdlglcontext.h @@ -45,7 +45,7 @@ public: virtual const char *LastErrorMsg() override { if (m_error[0] == 0) - return NULL; + return nullptr; else return m_error; } diff --git a/src/osd/modules/render/winglcontext.h b/src/osd/modules/render/winglcontext.h index de8e6537707..843532fe33f 100644 --- a/src/osd/modules/render/winglcontext.h +++ b/src/osd/modules/render/winglcontext.h @@ -18,7 +18,7 @@ class win_gl_context : public osd_gl_context { public: - win_gl_context(HWND window) : osd_gl_context(), m_context(0), m_window(NULL), m_hdc(0) + win_gl_context(HWND window) : osd_gl_context(), m_context(0), m_window(nullptr), m_hdc(0) { m_error[0] = 0; @@ -36,8 +36,8 @@ public: } else { - pfn_wglSwapIntervalEXT = NULL; - pfn_wglGetSwapIntervalEXT = NULL; + pfn_wglSwapIntervalEXT = nullptr; + pfn_wglGetSwapIntervalEXT = nullptr; } m_hdc = GetDC(window); @@ -46,7 +46,7 @@ public: m_context = this->pfn_wglCreateContext(m_hdc); if (!m_context) { - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, m_error, 255, NULL); + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), 0, m_error, 255, nullptr); return; } this->pfn_wglMakeCurrent(m_hdc, m_context); @@ -67,7 +67,7 @@ public: virtual const char *LastErrorMsg() override { if (m_error[0] == 0) - return NULL; + return nullptr; else return m_error; } @@ -75,14 +75,14 @@ public: virtual void *getProcAddress(const char *proc) override { void *ret = (void *) GetProcAddress(m_module, proc); - if (ret == NULL) + if (ret == nullptr) ret = (void *) this->pfn_wglGetProcAddress(proc); return ret; } virtual int SetSwapInterval(const int swap) override { - if (this->pfn_wglSwapIntervalEXT != NULL) + if (this->pfn_wglSwapIntervalEXT != nullptr) { this->pfn_wglSwapIntervalEXT(swap ? 1 : 0); } @@ -141,10 +141,10 @@ private: bool WGLExtensionSupported(const char *extension_name) { - //if (pfn_wglGetExtensionsStringEXT != NULL) + //if (pfn_wglGetExtensionsStringEXT != nullptr) // printf("%s\n", this->pfn_wglGetExtensionsStringEXT()); - if (pfn_wglGetExtensionsStringEXT != NULL && strstr(pfn_wglGetExtensionsStringEXT(), extension_name) != NULL) + if (pfn_wglGetExtensionsStringEXT != nullptr && strstr(pfn_wglGetExtensionsStringEXT(), extension_name) != nullptr) return true; else return false; diff --git a/src/osd/modules/sound/coreaudio_sound.cpp b/src/osd/modules/sound/coreaudio_sound.cpp index ff6303b0df8..88ce712a396 100644 --- a/src/osd/modules/sound/coreaudio_sound.cpp +++ b/src/osd/modules/sound/coreaudio_sound.cpp @@ -39,12 +39,12 @@ public: sound_coreaudio() : osd_module(OSD_SOUND_PROVIDER, "coreaudio"), sound_module(), - m_graph(NULL), + m_graph(nullptr), m_node_count(0), m_sample_bytes(0), m_headroom(0), m_buffer_size(0), - m_buffer(NULL), + m_buffer(nullptr), m_playpos(0), m_writepos(0), m_in_underrun(false), @@ -68,7 +68,7 @@ public: private: struct node_detail { - node_detail() : m_node(0), m_unit(NULL) { } + node_detail() : m_node(0), m_unit(nullptr) { } AUNode m_node; AudioUnit m_unit; @@ -110,7 +110,7 @@ private: return AUGraphNodeInfo( m_graph, m_node_details[m_node_count].m_node, - NULL, + nullptr, &m_node_details[m_node_count].m_unit); } @@ -150,7 +150,7 @@ private: if (!CFStringGetCString(str, result, len + 1, kCFStringEncodingUTF8)) { global_free_array(result); - return NULL; + return nullptr; } return result; } @@ -261,11 +261,11 @@ int sound_coreaudio::init(const osd_options &options) free_buffer_and_return_error: global_free_array(m_buffer); m_buffer_size = 0; - m_buffer = NULL; + m_buffer = nullptr; close_graph_and_return_error: AUGraphClose(m_graph); DisposeAUGraph(m_graph); - m_graph = NULL; + m_graph = nullptr; m_node_count = 0; return -1; } @@ -280,13 +280,13 @@ void sound_coreaudio::exit() AUGraphStop(m_graph); AUGraphUninitialize(m_graph); DisposeAUGraph(m_graph); - m_graph = NULL; + m_graph = nullptr; m_node_count = 0; } if (m_buffer) { global_free_array(m_buffer); - m_buffer = NULL; + m_buffer = nullptr; } if (m_overflows || m_underflows) osd_printf_verbose("Sound buffer: overflows=%u underflows=%u\n", m_overflows, m_underflows); @@ -373,7 +373,7 @@ bool sound_coreaudio::create_graph(osd_options const &options) goto close_graph_and_return_error; } - err = AUGraphUpdate(m_graph, NULL); + err = AUGraphUpdate(m_graph, nullptr); if (noErr != err) { osd_printf_error( @@ -389,7 +389,7 @@ close_graph_and_return_error: dispose_graph_and_return_error: DisposeAUGraph(m_graph); return_error: - m_graph = NULL; + m_graph = nullptr; m_node_count = 0; return false; } @@ -537,7 +537,7 @@ bool sound_coreaudio::add_effect(char const *name) return true; CFPropertyListRef const properties = load_property_list(name); - if (NULL == properties) + if (nullptr == properties) return true; OSType type, subtype, manufacturer; @@ -589,7 +589,7 @@ bool sound_coreaudio::add_effect(char const *name) kAUParameterListener_AnyParameter, 0, 0 }; - err = AUParameterListenerNotify(NULL, NULL, &change); + err = AUParameterListenerNotify(nullptr, nullptr, &change); } if (noErr != err) { @@ -640,7 +640,7 @@ bool sound_coreaudio::get_output_device_id( kAudioObjectSystemObject, &devices_addr, 0, - NULL, + nullptr, &property_size); if (noErr != err) { @@ -654,7 +654,7 @@ bool sound_coreaudio::get_output_device_id( kAudioObjectSystemObject, &devices_addr, 0, - NULL, + nullptr, &property_size, devices); UInt32 const device_count = property_size / sizeof(AudioDeviceID); @@ -669,7 +669,7 @@ bool sound_coreaudio::get_output_device_id( { char *const device_uid = get_device_uid(devices[i]); char *const device_name = get_device_name(devices[i]); - if ((NULL == device_uid) && (NULL == device_name)) + if ((nullptr == device_uid) && (nullptr == device_name)) { osd_printf_warning( "Could not get UID or name for device %lu - skipping\n", @@ -685,10 +685,10 @@ bool sound_coreaudio::get_output_device_id( { osd_printf_verbose( "No output streams found for device %s (%s) - skipping\n", - (NULL != device_name) ? device_name : "<anonymous>", - (NULL != device_uid) ? device_uid : "<unknown>"); - if (NULL != device_uid) global_free_array(device_uid); - if (NULL != device_name) global_free_array(device_name); + (nullptr != device_name) ? device_name : "<anonymous>", + (nullptr != device_uid) ? device_uid : "<unknown>"); + if (nullptr != device_uid) global_free_array(device_uid); + if (nullptr != device_name) global_free_array(device_name); continue; } @@ -697,14 +697,14 @@ bool sound_coreaudio::get_output_device_id( for (std::size_t j = strlen(device_name); (0 < j) && (' ' == device_name[j - 1]); j--) device_name[j - 1] = '\0'; - bool const matched_uid = (NULL != device_uid) && !strcmp(name, device_uid); - bool const matched_name = (NULL != device_name) && !strcmp(name, device_name); + bool const matched_uid = (nullptr != device_uid) && !strcmp(name, device_uid); + bool const matched_name = (nullptr != device_name) && !strcmp(name, device_name); if (matched_uid || matched_name) { osd_printf_verbose( "Matched device %s (%s) with %lu output stream(s)\n", - (NULL != device_name) ? device_name : "<anonymous>", - (NULL != device_uid) ? device_uid : "<unknown>", + (nullptr != device_name) ? device_name : "<anonymous>", + (nullptr != device_uid) ? device_uid : "<unknown>", (unsigned long)streams); } global_free_array(device_uid); @@ -730,26 +730,26 @@ char *sound_coreaudio::get_device_uid(AudioDeviceID id) const kAudioDevicePropertyDeviceUID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; - CFStringRef device_uid = NULL; + CFStringRef device_uid = nullptr; UInt32 property_size = sizeof(device_uid); OSStatus const err = AudioObjectGetPropertyData( id, &uid_addr, 0, - NULL, + nullptr, &property_size, &device_uid); - if ((noErr != err) || (NULL == device_uid)) + if ((noErr != err) || (nullptr == device_uid)) { osd_printf_warning( "Error getting UID for audio device %lu (%ld)\n", (unsigned long)id, (long)err); - return NULL; + return nullptr; } char *const result = convert_cfstring_to_utf8(device_uid); CFRelease(device_uid); - if (NULL == result) + if (nullptr == result) { osd_printf_warning( "Error converting UID for audio device %lu to UTF-8\n", @@ -765,26 +765,26 @@ char *sound_coreaudio::get_device_name(AudioDeviceID id) const kAudioDevicePropertyDeviceNameCFString, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; - CFStringRef device_name = NULL; + CFStringRef device_name = nullptr; UInt32 property_size = sizeof(device_name); OSStatus const err = AudioObjectGetPropertyData( id, &name_addr, 0, - NULL, + nullptr, &property_size, &device_name); - if ((noErr != err) || (NULL == device_name)) + if ((noErr != err) || (nullptr == device_name)) { osd_printf_warning( "Error getting name for audio device %lu (%ld)\n", (unsigned long)id, (long)err); - return NULL; + return nullptr; } char *const result = convert_cfstring_to_utf8(device_name); CFRelease(device_name); - if (NULL == result) + if (nullptr == result) { osd_printf_warning( "Error converting name for audio device %lu to UTF-8\n", @@ -808,14 +808,14 @@ UInt32 sound_coreaudio::get_output_stream_count( id, &streams_addr, 0, - NULL, + nullptr, &property_size); if (noErr != err) { osd_printf_warning( "Error getting output stream count for audio device %s (%s) (%ld)\n", - (NULL != name) ? name : "<anonymous>", - (NULL != uid) ? uid : "<unknown>", + (nullptr != name) ? name : "<anonymous>", + (nullptr != uid) ? uid : "<unknown>", (long)err); return 0; } @@ -840,9 +840,9 @@ bool sound_coreaudio::extract_effect_info( } CFDictionaryRef const desc = (CFDictionaryRef)properties; - CFTypeRef type_val = NULL; - CFTypeRef subtype_val = NULL; - CFTypeRef manufacturer_val = NULL; + CFTypeRef type_val = nullptr; + CFTypeRef subtype_val = nullptr; + CFTypeRef manufacturer_val = nullptr; if (CFDictionaryContainsKey(desc, CFSTR("ComponentType")) && CFDictionaryContainsKey(desc, CFSTR("ComponentSubType")) && CFDictionaryContainsKey(desc, CFSTR("ComponentManufacturer")) @@ -871,10 +871,10 @@ bool sound_coreaudio::extract_effect_info( } SInt64 type_int, subtype_int, manufacturer_int; - if ((NULL == type_val) - || (NULL == subtype_val) - || (NULL == manufacturer_val) - || (NULL == class_info) + if ((nullptr == type_val) + || (nullptr == subtype_val) + || (nullptr == manufacturer_val) + || (nullptr == class_info) || (CFNumberGetTypeID() != CFGetTypeID(type_val)) || (CFNumberGetTypeID() != CFGetTypeID(subtype_val)) || (CFNumberGetTypeID() != CFGetTypeID(manufacturer_val)) @@ -909,23 +909,23 @@ bool sound_coreaudio::extract_effect_info( CFPropertyListRef sound_coreaudio::load_property_list(char const *name) const { CFURLRef const url = CFURLCreateFromFileSystemRepresentation( - NULL, + nullptr, (UInt8 const *)name, strlen(name), false); - if (NULL == url) + if (nullptr == url) { - return NULL; + return nullptr; } - CFDataRef data = NULL; + CFDataRef data = nullptr; SInt32 err; Boolean const status = CFURLCreateDataAndPropertiesFromResource( - NULL, + nullptr, url, &data, - NULL, - NULL, + nullptr, + nullptr, &err); CFRelease(url); if (!status) @@ -934,24 +934,24 @@ CFPropertyListRef sound_coreaudio::load_property_list(char const *name) const "Error reading data from %s (%ld)\n", name, (long)err); - if (NULL != data) CFRelease(data); - return NULL; + if (nullptr != data) CFRelease(data); + return nullptr; } - CFStringRef msg = NULL; + CFStringRef msg = nullptr; CFPropertyListRef const result = CFPropertyListCreateFromXMLData( - NULL, + nullptr, data, kCFPropertyListImmutable, &msg); CFRelease(data); - if ((NULL == result) || (NULL != msg)) + if ((nullptr == result) || (nullptr != msg)) { - char *buf = (NULL != msg) ? convert_cfstring_to_utf8(msg) : NULL; - if (NULL != msg) + char *buf = (nullptr != msg) ? convert_cfstring_to_utf8(msg) : nullptr; + if (nullptr != msg) CFRelease(msg); - if (NULL != buf) + if (nullptr != buf) { osd_printf_error( "Error creating property list from %s: %s\n", @@ -965,8 +965,8 @@ CFPropertyListRef sound_coreaudio::load_property_list(char const *name) const "Error creating property list from %s\n", name); } - if (NULL != result) CFRelease(result); - return NULL; + if (nullptr != result) CFRelease(result); + return nullptr; } return result; diff --git a/src/osd/modules/sound/direct_sound.cpp b/src/osd/modules/sound/direct_sound.cpp index 5b20cfb61fa..25a82146d6b 100644 --- a/src/osd/modules/sound/direct_sound.cpp +++ b/src/osd/modules/sound/direct_sound.cpp @@ -51,7 +51,7 @@ public: sound_direct_sound() : osd_module(OSD_SOUND_PROVIDER, "dsound"), sound_module(), - m_dsound(NULL), + m_dsound(nullptr), m_bytes_per_sample(0), m_primary_buffer(), m_stream_buffer(), @@ -73,13 +73,13 @@ private: class buffer { public: - buffer() : m_buffer(NULL) { } + buffer() : m_buffer(nullptr) { } ~buffer() { release(); } ULONG release() { ULONG const result = m_buffer ? m_buffer->Release() : 0; - m_buffer = NULL; + m_buffer = nullptr; return result; } @@ -99,16 +99,16 @@ private: memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_GETCURRENTPOSITION2; - desc.lpwfxFormat = NULL; - return dsound->CreateSoundBuffer(&desc, &m_buffer, NULL); + desc.lpwfxFormat = nullptr; + return dsound->CreateSoundBuffer(&desc, &m_buffer, nullptr); } - HRESULT get_format(WAVEFORMATEX &format) + HRESULT get_format(WAVEFORMATEX &format) const { assert(m_buffer); - return m_buffer->GetFormat(&format, sizeof(format), NULL); + return m_buffer->GetFormat(&format, sizeof(format), nullptr); } - HRESULT set_format(WAVEFORMATEX const &format) + HRESULT set_format(WAVEFORMATEX const &format) const { assert(m_buffer); return m_buffer->SetFormat(&format); @@ -118,7 +118,7 @@ private: class stream_buffer : public buffer { public: - stream_buffer() : m_size(0), m_bytes1(NULL), m_bytes2(NULL), m_locked1(0), m_locked2(0) { } + stream_buffer() : m_size(0), m_bytes1(nullptr), m_bytes2(nullptr), m_locked1(0), m_locked2(0) { } HRESULT create(LPDIRECTSOUND dsound, DWORD size, WAVEFORMATEX &format) { @@ -130,27 +130,27 @@ private: desc.dwBufferBytes = size; desc.lpwfxFormat = &format; m_size = size; - return dsound->CreateSoundBuffer(&desc, &m_buffer, NULL); + return dsound->CreateSoundBuffer(&desc, &m_buffer, nullptr); } - HRESULT play_looping() + HRESULT play_looping() const { assert(m_buffer); return m_buffer->Play(0, 0, DSBPLAY_LOOPING); } - HRESULT stop() + HRESULT stop() const { assert(m_buffer); return m_buffer->Stop(); } - HRESULT set_volume(LONG volume) + HRESULT set_volume(LONG volume) const { assert(m_buffer); return m_buffer->SetVolume(volume); } HRESULT set_min_volume() { return set_volume(DSBVOLUME_MIN); } - HRESULT get_current_positions(DWORD &play_pos, DWORD &write_pos) + HRESULT get_current_positions(DWORD &play_pos, DWORD &write_pos) const { assert(m_buffer); return m_buffer->GetCurrentPosition(&play_pos, &write_pos); @@ -216,7 +216,7 @@ private: m_locked1, m_bytes2, m_locked2); - m_bytes1 = m_bytes2 = NULL; + m_bytes1 = m_bytes2 = nullptr; m_locked1 = m_locked2 = 0; return result; } @@ -382,7 +382,7 @@ HRESULT sound_direct_sound::dsound_init() HRESULT result; // create the DirectSound object - result = DirectSoundCreate(NULL, &m_dsound, NULL); + result = DirectSoundCreate(nullptr, &m_dsound, nullptr); if (result != DS_OK) { osd_printf_error("Error creating DirectSound: %08x\n", (unsigned)result); @@ -467,7 +467,7 @@ void sound_direct_sound::dsound_kill() // release the object if (m_dsound) m_dsound->Release(); - m_dsound = NULL; + m_dsound = nullptr; } diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp index c1e3e3dff2b..31c2d651f1d 100644 --- a/src/osd/modules/sound/sdl_sound.cpp +++ b/src/osd/modules/sound/sdl_sound.cpp @@ -51,8 +51,8 @@ public: : osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(), stream_in_initialized(0), stream_loop(0), - attenuation(0) - { + attenuation(0), buf_locked(0), stream_buffer(nullptr), stream_playpos(0), stream_buffer_size(0), stream_buffer_in(0), buffer_underflows(0), buffer_overflows(0) +{ sdl_xfer_samples = SDL_XFER_SAMPLES; } virtual ~sound_sdl() { } @@ -200,7 +200,7 @@ void sound_sdl::att_memcpy(void *dest, const INT16 *data, int bytes_to_copy) void sound_sdl::copy_sample_data(bool is_throttled, const INT16 *data, int bytes_to_copy) { - void *buffer1, *buffer2 = (void *)NULL; + void *buffer1, *buffer2 = (void *)nullptr; long length1, length2; int cur_bytes; @@ -529,7 +529,7 @@ void sound_sdl::sdl_destroy_buffers(void) // release the buffer if (stream_buffer) global_free_array(stream_buffer); - stream_buffer = NULL; + stream_buffer = nullptr; } diff --git a/src/osd/modules/sound/sound_module.h b/src/osd/modules/sound/sound_module.h index b467cea8177..c68a943bcce 100644 --- a/src/osd/modules/sound/sound_module.h +++ b/src/osd/modules/sound/sound_module.h @@ -27,7 +27,7 @@ public: virtual void update_audio_stream(bool is_throttled, const INT16 *buffer, int samples_this_frame) = 0; virtual void set_mastervolume(int attenuation) = 0; - int sample_rate() { return m_sample_rate; } + int sample_rate() const { return m_sample_rate; } int m_sample_rate; int m_audio_latency; diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index 623c3ee3f11..c712b3fea8e 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -330,7 +330,7 @@ struct osd_directory_entry upon success, this function should return an osd_directory pointer which contains opaque data necessary to traverse the directory; on - failure, this function should return NULL + failure, this function should return nullptr -----------------------------------------------------------------------------*/ osd_directory *osd_opendir(const char *dirname); @@ -346,7 +346,7 @@ osd_directory *osd_opendir(const char *dirname); Return value: a constant pointer to an osd_directory_entry representing the current item - in the directory, or NULL, indicating that no more entries are + in the directory, or nullptr, indicating that no more entries are present -----------------------------------------------------------------------------*/ const osd_directory_entry *osd_readdir(osd_directory *dir); @@ -901,7 +901,7 @@ public: static void pop(osd_output *delegate); protected: - void chain_output(osd_output_channel channel, const char *msg, va_list args) + void chain_output(osd_output_channel channel, const char *msg, va_list args) const { if (m_chain != nullptr) m_chain->output_callback(channel, msg, args); diff --git a/src/osd/osdsync.cpp b/src/osd/osdsync.cpp index 84c8bac6ccb..20d5151c8a6 100644 --- a/src/osd/osdsync.cpp +++ b/src/osd/osdsync.cpp @@ -269,7 +269,7 @@ osd_work_queue *osd_work_queue_alloc(int flags) else threadnum = (flags & WORK_QUEUE_FLAG_MULTI) ? (numprocs - 1) : 1; - if (osdworkqueuemaxthreads != NULL && sscanf(osdworkqueuemaxthreads, "%d", &osdthreadnum) == 1 && threadnum > osdthreadnum) + if (osdworkqueuemaxthreads != nullptr && sscanf(osdworkqueuemaxthreads, "%d", &osdthreadnum) == 1 && threadnum > osdthreadnum) threadnum = osdthreadnum; // clamp to the maximum @@ -315,7 +315,7 @@ osd_work_queue *osd_work_queue_alloc(int flags) error: osd_work_queue_free(queue); - return NULL; + return nullptr; } @@ -406,7 +406,7 @@ void osd_work_queue_free(osd_work_queue *queue) work_thread_info *thread = queue->thread[threadnum]; // block on the thread going away, then close the handle - if (thread->handle != NULL) + if (thread->handle != nullptr) { thread->handle->join(); delete thread->handle; @@ -439,7 +439,7 @@ void osd_work_queue_free(osd_work_queue *queue) { osd_work_item *item = (osd_work_item *)queue->free; queue->free = item->next; - if (item->event != NULL) + if (item->event != nullptr) delete item->event; delete item; } @@ -449,7 +449,7 @@ void osd_work_queue_free(osd_work_queue *queue) { osd_work_item *item = (osd_work_item *)queue->list; queue->list = item->next; - if (item->event != NULL) + if (item->event != nullptr) delete item->event; delete item; } @@ -472,7 +472,7 @@ void osd_work_queue_free(osd_work_queue *queue) osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_callback callback, INT32 numitems, void *parambase, INT32 paramstep, UINT32 flags) { - osd_work_item *itemlist = NULL, *lastitem = NULL; + osd_work_item *itemlist = nullptr, *lastitem = nullptr; osd_work_item **item_tailptr = &itemlist; int itemnum; @@ -487,16 +487,16 @@ osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_call do { item = (osd_work_item *)queue->free; - } while (item != NULL && !queue->free.compare_exchange_weak(item, item->next, std::memory_order_release, std::memory_order_relaxed)); + } while (item != nullptr && !queue->free.compare_exchange_weak(item, item->next, std::memory_order_release, std::memory_order_relaxed)); } // if nothing, allocate something new - if (item == NULL) + if (item == nullptr) { // allocate the item item = new osd_work_item(*queue); - if (item == NULL) - return NULL; + if (item == nullptr) + return nullptr; } else { @@ -504,10 +504,10 @@ osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_call } // fill in the basics - item->next = NULL; + item->next = nullptr; item->callback = callback; item->param = parambase; - item->result = NULL; + item->result = nullptr; item->flags = flags; // advance to the next @@ -559,7 +559,7 @@ osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_call begin_timing(queue->thread[0]->waittime); } // only return the item if it won't get released automatically - return (flags & WORK_ITEM_FLAG_AUTO_RELEASE) ? NULL : lastitem; + return (flags & WORK_ITEM_FLAG_AUTO_RELEASE) ? nullptr : lastitem; } @@ -574,7 +574,7 @@ int osd_work_item_wait(osd_work_item *item, osd_ticks_t timeout) return TRUE; // if we don't have an event, create one - if (item->event == NULL) + if (item->event == nullptr) { std::lock_guard<std::mutex> lock(item->queue.lock); item->event = new osd_event(TRUE, FALSE); // manual reset, not signalled @@ -583,7 +583,7 @@ int osd_work_item_wait(osd_work_item *item, osd_ticks_t timeout) item->event->reset(); // if we don't have an event, we need to spin (shouldn't ever really happen) - if (item->event == NULL) + if (item->event == nullptr) { // TODO: do we need to measure the spin time here as well? and how can we do it? spin_while<std::atomic<int>,int>(&item->done, 0, timeout); @@ -649,7 +649,7 @@ static int effective_num_processors(void) // if the OSDPROCESSORS environment variable is set, use that value if valid // note that we permit more than the real number of processors for testing const char *procsoverride = osd_getenv(ENV_PROCESSORS); - if (procsoverride != NULL && sscanf(procsoverride, "%d", &numprocs) == 1 && numprocs > 0) + if (procsoverride != nullptr && sscanf(procsoverride, "%d", &numprocs) == 1 && numprocs > 0) return MIN(4 * physprocs, numprocs); // otherwise, return the info from the system @@ -715,7 +715,7 @@ static void *worker_thread_entry(void *param) --queue.livethreads; } - return NULL; + return nullptr; } @@ -732,7 +732,7 @@ static void worker_thread_process(osd_work_queue *queue, work_thread_info *threa // loop until everything is processed while (true) { - osd_work_item *item = NULL; + osd_work_item *item = nullptr; bool end_loop = false; @@ -748,7 +748,7 @@ static void worker_thread_process(osd_work_queue *queue, work_thread_info *threa { // pull the item from the queue item = (osd_work_item *)queue->list; - if (item != NULL) + if (item != nullptr) { queue->list = item->next; if (queue->list.load() == nullptr) @@ -761,7 +761,7 @@ static void worker_thread_process(osd_work_queue *queue, work_thread_info *threa break; // process non-NULL items - if (item != NULL) + if (item != nullptr) { // call the callback and stash the result begin_timing(thread->actruntime); @@ -782,7 +782,7 @@ static void worker_thread_process(osd_work_queue *queue, work_thread_info *threa { std::lock_guard<std::mutex> lock(queue->lock); - if (item->event != NULL) + if (item->event != nullptr) { item->event->set(); add_to_stat(item->queue.setevents, 1); diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index c45c807efd5..46a1faa606b 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -140,7 +140,7 @@ public: bool should_hide_mouse(); void process_events_buf(); - sdl_options &options() { return m_options; } + virtual sdl_options &options() override { return m_options; } protected: virtual void build_slider_list() override; diff --git a/src/osd/sdl/sdldir.cpp b/src/osd/sdl/sdldir.cpp index abf1f126b94..fcae732ed53 100644 --- a/src/osd/sdl/sdldir.cpp +++ b/src/osd/sdl/sdldir.cpp @@ -139,7 +139,7 @@ static UINT64 osd_get_file_size(const char *file) osd_directory *osd_opendir(const char *dirname) { - osd_directory *dir = NULL; + osd_directory *dir = nullptr; char *tmpstr, *envstr; int i, j; @@ -147,7 +147,7 @@ osd_directory *osd_opendir(const char *dirname) if (dir) { memset(dir, 0, sizeof(osd_directory)); - dir->fd = NULL; + dir->fd = nullptr; } tmpstr = (char *) osd_malloc_array(strlen(dirname)+1); @@ -168,7 +168,7 @@ osd_directory *osd_opendir(const char *dirname) envstr[i] = '\0'; const char *envval = osd_getenv(&envstr[1]); - if (envval != NULL) + if (envval != nullptr) { j = strlen(envval) + strlen(tmpstr) + 1; osd_free(tmpstr); @@ -189,11 +189,11 @@ osd_directory *osd_opendir(const char *dirname) dir->fd = opendir(tmpstr); dir->path = tmpstr; - if (dir && (dir->fd == NULL)) + if (dir && (dir->fd == nullptr)) { osd_free(dir->path); osd_free(dir); - dir = NULL; + dir = nullptr; } return dir; @@ -209,8 +209,8 @@ const osd_directory_entry *osd_readdir(osd_directory *dir) char *temp; dir->data = sdl_readdir(dir->fd); - if (dir->data == NULL) - return NULL; + if (dir->data == nullptr) + return nullptr; dir->ent.name = dir->data->d_name; temp = build_full_path(dir->path, dir->data->d_name); @@ -231,7 +231,7 @@ const osd_directory_entry *osd_readdir(osd_directory *dir) void osd_closedir(osd_directory *dir) { - if (dir->fd != NULL) + if (dir->fd != nullptr) closedir(dir->fd); osd_free(dir->path); osd_free(dir); diff --git a/src/osd/sdl/sdlmain.cpp b/src/osd/sdl/sdlmain.cpp index a465e64655a..5112b3a3628 100644 --- a/src/osd/sdl/sdlmain.cpp +++ b/src/osd/sdl/sdlmain.cpp @@ -85,10 +85,10 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_INIPATH, INI_PATH, OPTION_STRING, "path to ini files" }, // performance options - { NULL, NULL, OPTION_HEADER, "SDL PERFORMANCE OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "SDL PERFORMANCE OPTIONS" }, { SDLOPTION_SDLVIDEOFPS, "0", OPTION_BOOLEAN, "show sdl video performance" }, // video options - { NULL, NULL, OPTION_HEADER, "SDL VIDEO OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "SDL VIDEO OPTIONS" }, // OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience { SDLOPTION_CENTERH, "1", OPTION_BOOLEAN, "center horizontally within the view area" }, { SDLOPTION_CENTERV, "1", OPTION_BOOLEAN, "center vertically within the view area" }, @@ -96,17 +96,17 @@ const options_entry sdl_options::s_option_entries[] = // full screen options #ifdef SDLMAME_X11 - { NULL, NULL, OPTION_HEADER, "SDL FULL SCREEN OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "SDL FULL SCREEN OPTIONS" }, { SDLOPTION_USEALLHEADS, "0", OPTION_BOOLEAN, "split full screen image across monitors" }, #endif // keyboard mapping - { NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, + { nullptr, nullptr, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, { SDLOPTION_KEYMAP, "0", OPTION_BOOLEAN, "enable keymap" }, { SDLOPTION_KEYMAP_FILE, "keymap.dat", OPTION_STRING, "keymap filename" }, // joystick mapping - { NULL, NULL, OPTION_HEADER, "SDL JOYSTICK MAPPING" }, + { nullptr, nullptr, OPTION_HEADER, "SDL JOYSTICK MAPPING" }, { SDLOPTION_JOYINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #1" }, { SDLOPTION_JOYINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #2" }, { SDLOPTION_JOYINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #3" }, @@ -119,7 +119,7 @@ const options_entry sdl_options::s_option_entries[] = #if (USE_XINPUT) // lightgun mapping - { NULL, NULL, OPTION_HEADER, "SDL LIGHTGUN MAPPING" }, + { nullptr, nullptr, OPTION_HEADER, "SDL LIGHTGUN MAPPING" }, { SDLOPTION_LIGHTGUNINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #1" }, { SDLOPTION_LIGHTGUNINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #2" }, { SDLOPTION_LIGHTGUNINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #3" }, @@ -130,7 +130,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_LIGHTGUNINDEX "8", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #8" }, #endif - { NULL, NULL, OPTION_HEADER, "SDL MOUSE MAPPING" }, + { nullptr, nullptr, OPTION_HEADER, "SDL MOUSE MAPPING" }, { SDLOPTION_MOUSEINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #1" }, { SDLOPTION_MOUSEINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #2" }, { SDLOPTION_MOUSEINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #3" }, @@ -140,7 +140,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_MOUSEINDEX "7", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #7" }, { SDLOPTION_MOUSEINDEX "8", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #8" }, - { NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, + { nullptr, nullptr, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, { SDLOPTION_KEYBINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #1" }, { SDLOPTION_KEYBINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #2" }, { SDLOPTION_KEYBINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #3" }, @@ -151,7 +151,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_KEYBINDEX "8", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #8" }, // SDL low level driver options - { NULL, NULL, OPTION_HEADER, "SDL LOWLEVEL DRIVER OPTIONS" }, + { nullptr, nullptr, OPTION_HEADER, "SDL LOWLEVEL DRIVER OPTIONS" }, { SDLOPTION_VIDEODRIVER ";vd", OSDOPTVAL_AUTO, OPTION_STRING, "sdl video driver to use ('x11', 'directfb', ... or 'auto' for SDL default" }, { SDLOPTION_RENDERDRIVER ";rd", OSDOPTVAL_AUTO, OPTION_STRING, "sdl render driver to use ('software', 'opengl', 'directfb' ... or 'auto' for SDL default" }, { SDLOPTION_AUDIODRIVER ";ad", OSDOPTVAL_AUTO, OPTION_STRING, "sdl audio driver to use ('alsa', 'arts', ... or 'auto' for SDL default" }, @@ -160,7 +160,7 @@ const options_entry sdl_options::s_option_entries[] = #endif // End of list - { NULL } + { nullptr } }; //============================================================ @@ -193,8 +193,8 @@ int main(int argc, char *argv[]) int res = 0; // disable I/O buffering - setvbuf(stdout, (char *) NULL, _IONBF, 0); - setvbuf(stderr, (char *) NULL, _IONBF, 0); + setvbuf(stdout, (char *) nullptr, _IONBF, 0); + setvbuf(stderr, (char *) nullptr, _IONBF, 0); // Initialize crash diagnostics diagnostics_module::get_instance()->init_crash_diagnostics(); @@ -390,10 +390,10 @@ static void osd_sdl_info(void) void sdl_osd_interface::video_register() { - video_options_add("soft", NULL); - video_options_add("opengl", NULL); - video_options_add("bgfx", NULL); - //video_options_add("auto", NULL); // making d3d video default one + video_options_add("soft", nullptr); + video_options_add("opengl", nullptr); + video_options_add("bgfx", nullptr); + //video_options_add("auto", nullptr); // making d3d video default one } //============================================================ @@ -422,21 +422,21 @@ void sdl_osd_interface::init(running_machine &machine) // Some driver options - must be before audio init! stemp = options().audio_driver(); - if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0) + if (stemp != nullptr && strcmp(stemp, OSDOPTVAL_AUTO) != 0) { osd_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp); osd_setenv(SDLENV_AUDIODRIVER, stemp, 1); } stemp = options().video_driver(); - if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0) + if (stemp != nullptr && strcmp(stemp, OSDOPTVAL_AUTO) != 0) { osd_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp); osd_setenv(SDLENV_VIDEODRIVER, stemp, 1); } stemp = options().render_driver(); - if (stemp != NULL) + if (stemp != nullptr) { if (strcmp(stemp, OSDOPTVAL_AUTO) != 0) { @@ -462,7 +462,7 @@ void sdl_osd_interface::init(running_machine &machine) /* FIXME: move lib loading code from drawogl.c here */ stemp = options().gl_lib(); - if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0) + if (stemp != nullptr && strcmp(stemp, OSDOPTVAL_AUTO) != 0) { osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1); osd_printf_verbose("Setting SDL_VIDEO_GL_DRIVER = '%s' ...\n", stemp); diff --git a/src/osd/sdl/video.cpp b/src/osd/sdl/video.cpp index 61b118e8e1b..418df2cbe89 100644 --- a/src/osd/sdl/video.cpp +++ b/src/osd/sdl/video.cpp @@ -35,7 +35,7 @@ osd_video_config video_config; // monitor info -osd_monitor_info *osd_monitor_info::list = NULL; +osd_monitor_info *osd_monitor_info::list = nullptr; //============================================================ @@ -164,7 +164,7 @@ void sdl_monitor_info::init() osd_monitor_info **tailptr; // make a list of monitors - osd_monitor_info::list = NULL; + osd_monitor_info::list = nullptr; tailptr = &osd_monitor_info::list; { @@ -200,7 +200,7 @@ void sdl_monitor_info::init() void sdl_monitor_info::exit() { // free all of our monitor information - while (sdl_monitor_info::list != NULL) + while (sdl_monitor_info::list != nullptr) { osd_monitor_info *temp = sdl_monitor_info::list; sdl_monitor_info::list = temp->next(); @@ -233,9 +233,9 @@ osd_monitor_info *osd_monitor_info::pick_monitor(osd_options &generic_options, i aspect = get_aspect(options.aspect(), options.aspect(index), TRUE); // look for a match in the name first - if (scrname != NULL && (scrname[0] != 0)) + if (scrname != nullptr && (scrname[0] != 0)) { - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->next()) { moncount++; if (strcmp(scrname, monitor->devicename()) == 0) @@ -245,12 +245,12 @@ osd_monitor_info *osd_monitor_info::pick_monitor(osd_options &generic_options, i // didn't find it; alternate monitors until we hit the jackpot index %= moncount; - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->next()) if (index-- == 0) goto finishit; // return the primary just in case all else fails - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->next()) if (monitor->is_primary()) goto finishit; @@ -421,7 +421,7 @@ void sdl_osd_interface::extract_video_config() strcpy(video_config.glsl_shader_mamebm[i], stemp); video_config.glsl_shader_mamebm_num++; } else { - video_config.glsl_shader_mamebm[i] = NULL; + video_config.glsl_shader_mamebm[i] = nullptr; } } @@ -436,7 +436,7 @@ void sdl_osd_interface::extract_video_config() strcpy(video_config.glsl_shader_scrn[i], stemp); video_config.glsl_shader_scrn_num++; } else { - video_config.glsl_shader_scrn[i] = NULL; + video_config.glsl_shader_scrn[i] = nullptr; } } } else { @@ -445,12 +445,12 @@ void sdl_osd_interface::extract_video_config() video_config.glsl_shader_mamebm_num=0; for(i=0; i<GLSL_SHADER_MAX; i++) { - video_config.glsl_shader_mamebm[i] = NULL; + video_config.glsl_shader_mamebm[i] = nullptr; } video_config.glsl_shader_scrn_num=0; for(i=0; i<GLSL_SHADER_MAX; i++) { - video_config.glsl_shader_scrn[i] = NULL; + video_config.glsl_shader_scrn[i] = nullptr; } } diff --git a/src/osd/sdl/video.h b/src/osd/sdl/video.h index 1c6993c0c0b..82db031aba1 100644 --- a/src/osd/sdl/video.h +++ b/src/osd/sdl/video.h @@ -24,7 +24,7 @@ public: sdl_monitor_info(const UINT64 handle, const char *monitor_device, float aspect) : osd_monitor_info(&m_handle, monitor_device, aspect), m_handle(handle) { - refresh(); + sdl_monitor_info::refresh(); } // STATIC diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp index 8c36ede4d36..b1bd5cc0396 100644 --- a/src/osd/sdl/window.cpp +++ b/src/osd/sdl/window.cpp @@ -1318,12 +1318,12 @@ osd_dim sdl_window_info::get_max_bounds(int constrain) sdl_window_info::sdl_window_info(running_machine &a_machine, int index, osd_monitor_info *a_monitor, const osd_window_config *config) -: osd_window(), m_next(NULL), - // Following three are used by input code to defer resizes +: osd_window(), m_next(nullptr), m_startmaximized(0), + // Following three are used by input code to defer resizes m_minimum_dim(0,0), m_windowed_dim(0,0), - m_rendered_event(0, 1), m_target(0), - m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0) + m_rendered_event(0, 1), m_target(nullptr), m_extra_flags(0), + m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0) { m_win_config = *config; m_index = index; diff --git a/src/osd/strconv.cpp b/src/osd/strconv.cpp index c5c02edd2f5..eec1bcc4059 100644 --- a/src/osd/strconv.cpp +++ b/src/osd/strconv.cpp @@ -26,15 +26,15 @@ CHAR *astring_from_utf8(const char *utf8string) CHAR *result; // convert MAME string (UTF-8) to UTF-16 - char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0); + char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, nullptr, 0); wstring = (WCHAR *)alloca(char_count * sizeof(*wstring)); MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, wstring, char_count); // convert UTF-16 to "ANSI code page" string - char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL); + char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, nullptr, 0, nullptr, nullptr); result = (CHAR *)osd_malloc_array(char_count * sizeof(*result)); - if (result != NULL) - WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL); + if (result != nullptr) + WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, nullptr, nullptr); return result; } @@ -51,15 +51,15 @@ char *utf8_from_astring(const CHAR *astring) CHAR *result; // convert "ANSI code page" string to UTF-16 - char_count = MultiByteToWideChar(CP_ACP, 0, astring, -1, NULL, 0); + char_count = MultiByteToWideChar(CP_ACP, 0, astring, -1, nullptr, 0); wstring = (WCHAR *)alloca(char_count * sizeof(*wstring)); MultiByteToWideChar(CP_ACP, 0, astring, -1, wstring, char_count); // convert UTF-16 to MAME string (UTF-8) - char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL); + char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, nullptr, 0, nullptr, nullptr); result = (CHAR *)osd_malloc_array(char_count * sizeof(*result)); - if (result != NULL) - WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL); + if (result != nullptr) + WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, nullptr, nullptr); return result; } @@ -75,9 +75,9 @@ WCHAR *wstring_from_utf8(const char *utf8string) WCHAR *result; // convert MAME string (UTF-8) to UTF-16 - char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0); + char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, nullptr, 0); result = (WCHAR *)osd_malloc_array(char_count * sizeof(*result)); - if (result != NULL) + if (result != nullptr) MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count); return result; @@ -94,10 +94,10 @@ char *utf8_from_wstring(const WCHAR *wstring) char *result; // convert UTF-16 to MAME string (UTF-8) - char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL); + char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, nullptr, 0, nullptr, nullptr); result = (char *)osd_malloc_array(char_count * sizeof(*result)); - if (result != NULL) - WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL); + if (result != nullptr) + WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, nullptr, nullptr); return result; } diff --git a/src/osd/strconv.h b/src/osd/strconv.h index aaab2527d25..c9674cc486e 100644 --- a/src/osd/strconv.h +++ b/src/osd/strconv.h @@ -35,7 +35,7 @@ char *utf8_from_wstring(const WCHAR *s); struct osd_wstr_deleter { - void operator () (wchar_t* wstr) + void operator () (wchar_t* wstr) const { if (wstr != nullptr) osd_free(wstr); diff --git a/src/osd/watchdog.h b/src/osd/watchdog.h index dbcccf43abf..415c1269882 100644 --- a/src/osd/watchdog.h +++ b/src/osd/watchdog.h @@ -23,8 +23,8 @@ public: void reset() { m_event.set(); } osd_event & event(void) { return m_event; } - INT32 do_exit(void) { return m_do_exit; } - osd_ticks_t getTimeout(void) { return m_timeout; } + INT32 do_exit(void) const { return m_do_exit; } + osd_ticks_t getTimeout(void) const { return m_timeout; } void setTimeout(int timeout); private: osd_event m_event; diff --git a/src/osd/windows/main.cpp b/src/osd/windows/main.cpp index 6e7717349bb..f4be66a2b98 100644 --- a/src/osd/windows/main.cpp +++ b/src/osd/windows/main.cpp @@ -32,12 +32,12 @@ extern "C" int _tmain(int argc, TCHAR **argv) /* convert arguments to UTF-8 */ utf8_argv = (char **) malloc(argc * sizeof(*argv)); - if (utf8_argv == NULL) + if (utf8_argv == nullptr) return 999; for (i = 0; i < argc; i++) { utf8_argv[i] = utf8_from_tstring(argv[i]); - if (utf8_argv[i] == NULL) + if (utf8_argv[i] == nullptr) return 999; } diff --git a/src/osd/windows/video.cpp b/src/osd/windows/video.cpp index 82a756d7dd6..fc6f787b698 100644 --- a/src/osd/windows/video.cpp +++ b/src/osd/windows/video.cpp @@ -36,7 +36,7 @@ osd_video_config video_config; // monitor info -osd_monitor_info *osd_monitor_info::list = NULL; +osd_monitor_info *osd_monitor_info::list = nullptr; //============================================================ @@ -94,7 +94,7 @@ void windows_osd_interface::video_exit() window_exit(); // free all of our monitor information - while (osd_monitor_info::list != NULL) + while (osd_monitor_info::list != nullptr) { osd_monitor_info *temp = osd_monitor_info::list; osd_monitor_info::list = temp->m_next; @@ -149,10 +149,10 @@ osd_monitor_info *win_monitor_info::monitor_from_handle(HMONITOR hmonitor) osd_monitor_info *monitor; // find the matching monitor - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->m_next) if (*((HMONITOR *)monitor->oshandle()) == hmonitor) return monitor; - return NULL; + return nullptr; } @@ -231,14 +231,14 @@ static void init_monitors(void) osd_monitor_info **tailptr; // make a list of monitors - osd_monitor_info::list = NULL; + osd_monitor_info::list = nullptr; tailptr = &osd_monitor_info::list; - EnumDisplayMonitors(NULL, NULL, win_monitor_info::monitor_enum_callback, (LPARAM)&tailptr); + EnumDisplayMonitors(nullptr, nullptr, win_monitor_info::monitor_enum_callback, (LPARAM)&tailptr); // if we're verbose, print the list of monitors { osd_monitor_info *monitor; - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->m_next) { osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->oshandle(), monitor->devicename(), monitor->is_primary() ? "(primary)" : ""); } @@ -270,9 +270,9 @@ osd_monitor_info *osd_monitor_info::pick_monitor(osd_options &osdopts, int index aspect = get_aspect(options.aspect(), options.aspect(index), TRUE); // look for a match in the name first - if (scrname != NULL && (scrname[0] != 0)) + if (scrname != nullptr && (scrname[0] != 0)) { - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->next()) { moncount++; if (strcmp(scrname, monitor->devicename()) == 0) @@ -282,12 +282,12 @@ osd_monitor_info *osd_monitor_info::pick_monitor(osd_options &osdopts, int index // didn't find it; alternate monitors until we hit the jackpot index %= moncount; - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->next()) if (index-- == 0) goto finishit; // return the primary just in case all else fails - for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) + for (monitor = osd_monitor_info::list; monitor != nullptr; monitor = monitor->next()) if (monitor->is_primary()) goto finishit; @@ -411,7 +411,7 @@ void windows_osd_interface::extract_video_config() strcpy(video_config.glsl_shader_mamebm[i], stemp); video_config.glsl_shader_mamebm_num++; } else { - video_config.glsl_shader_mamebm[i] = NULL; + video_config.glsl_shader_mamebm[i] = nullptr; } } @@ -426,7 +426,7 @@ void windows_osd_interface::extract_video_config() strcpy(video_config.glsl_shader_scrn[i], stemp); video_config.glsl_shader_scrn_num++; } else { - video_config.glsl_shader_scrn[i] = NULL; + video_config.glsl_shader_scrn[i] = nullptr; } } } else { @@ -435,12 +435,12 @@ void windows_osd_interface::extract_video_config() video_config.glsl_shader_mamebm_num=0; for(i=0; i<GLSL_SHADER_MAX; i++) { - video_config.glsl_shader_mamebm[i] = NULL; + video_config.glsl_shader_mamebm[i] = nullptr; } video_config.glsl_shader_scrn_num=0; for(i=0; i<GLSL_SHADER_MAX; i++) { - video_config.glsl_shader_scrn[i] = NULL; + video_config.glsl_shader_scrn[i] = nullptr; } } diff --git a/src/osd/windows/video.h b/src/osd/windows/video.h index f47a5260b8e..171cfa1aaec 100644 --- a/src/osd/windows/video.h +++ b/src/osd/windows/video.h @@ -35,7 +35,7 @@ public: static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data); static osd_monitor_info *monitor_from_handle(HMONITOR monitor); - HMONITOR handle() { return m_handle; } + HMONITOR handle() const { return m_handle; } private: HMONITOR m_handle; // handle to the monitor diff --git a/src/osd/windows/windir.cpp b/src/osd/windows/windir.cpp index 87b1b5e05ce..f7b7fd44c6a 100644 --- a/src/osd/windows/windir.cpp +++ b/src/osd/windows/windir.cpp @@ -44,14 +44,14 @@ struct osd_directory osd_directory *osd_opendir(const char *dirname) { - osd_directory *dir = NULL; - TCHAR *t_dirname = NULL; - TCHAR *dirfilter = NULL; + osd_directory *dir = nullptr; + TCHAR *t_dirname = nullptr; + TCHAR *dirfilter = nullptr; size_t dirfilter_size; // allocate memory to hold the osd_tool_directory structure dir = (osd_directory *)malloc(sizeof(*dir)); - if (dir == NULL) + if (dir == nullptr) goto error; memset(dir, 0, sizeof(*dir)); @@ -61,13 +61,13 @@ osd_directory *osd_opendir(const char *dirname) // convert the path to TCHARs t_dirname = tstring_from_utf8(dirname); - if (t_dirname == NULL) + if (t_dirname == nullptr) goto error; // append \*.* to the directory name dirfilter_size = _tcslen(t_dirname) + 5; dirfilter = (TCHAR *)malloc(dirfilter_size * sizeof(*dirfilter)); - if (dirfilter == NULL) + if (dirfilter == nullptr) goto error; _sntprintf(dirfilter, dirfilter_size, TEXT("%s\\*.*"), t_dirname); @@ -76,14 +76,14 @@ osd_directory *osd_opendir(const char *dirname) error: // cleanup - if (t_dirname != NULL) + if (t_dirname != nullptr) osd_free(t_dirname); - if (dirfilter != NULL) + if (dirfilter != nullptr) free(dirfilter); - if (dir != NULL && dir->find == INVALID_HANDLE_VALUE) + if (dir != nullptr && dir->find == INVALID_HANDLE_VALUE) { free(dir); - dir = NULL; + dir = nullptr; } return dir; } @@ -96,17 +96,17 @@ error: const osd_directory_entry *osd_readdir(osd_directory *dir) { // if we've previously allocated a name, free it now - if (dir->entry.name != NULL) + if (dir->entry.name != nullptr) { osd_free((void *)dir->entry.name); - dir->entry.name = NULL; + dir->entry.name = nullptr; } // if this isn't the first file, do a find next if (!dir->is_first) { if (!FindNextFile(dir->find, &dir->data)) - return NULL; + return nullptr; } // otherwise, just use the data we already had @@ -117,7 +117,7 @@ const osd_directory_entry *osd_readdir(osd_directory *dir) dir->entry.name = utf8_from_tstring(dir->data.cFileName); dir->entry.type = win_attributes_to_entry_type(dir->data.dwFileAttributes); dir->entry.size = dir->data.nFileSizeLow | ((UINT64) dir->data.nFileSizeHigh << 32); - return (dir->entry.name != NULL) ? &dir->entry : NULL; + return (dir->entry.name != nullptr) ? &dir->entry : nullptr; } @@ -128,7 +128,7 @@ const osd_directory_entry *osd_readdir(osd_directory *dir) void osd_closedir(osd_directory *dir) { // free any data associated - if (dir->entry.name != NULL) + if (dir->entry.name != nullptr) osd_free((void *)dir->entry.name); if (dir->find != INVALID_HANDLE_VALUE) FindClose(dir->find); diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index f5534a13544..3f3e84b004c 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -1991,7 +1991,7 @@ void win_window_info::set_fullscreen(int fullscreen) // adjust the style SetWindowLong(platform_window<HWND>(), GWL_STYLE, WINDOW_STYLE); SetWindowLong(platform_window<HWND>(), GWL_EXSTYLE, WINDOW_STYLE_EX); - SetWindowPos(platform_window<HWND>(), 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + SetWindowPos(platform_window<HWND>(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // force to the bottom, then back on top SetWindowPos(platform_window<HWND>(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); @@ -2022,7 +2022,7 @@ void win_window_info::set_fullscreen(int fullscreen) // adjust the style SetWindowLong(platform_window<HWND>(), GWL_STYLE, FULLSCREEN_STYLE); SetWindowLong(platform_window<HWND>(), GWL_EXSTYLE, FULLSCREEN_STYLE_EX); - SetWindowPos(platform_window<HWND>(), 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + SetWindowPos(platform_window<HWND>(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // set topmost SetWindowPos(platform_window<HWND>(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index 940746ff484..136daea0636 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -380,7 +380,7 @@ void MameMainApp::Run() // To satisfy the latter things, pass in the module path name char exe_path[MAX_PATH]; - GetModuleFileNameA(NULL, exe_path, MAX_PATH); + GetModuleFileNameA(nullptr, exe_path, MAX_PATH); char* args[2] = { exe_path, (char*)"-verbose" }; DWORD result = emulator_info::start_frontend(*m_options.get(), *m_osd.get(), ARRAY_LENGTH(args), args); diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 8f0bd77f4a7..72e2112a04b 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -291,7 +291,7 @@ public: bool should_hide_mouse() const; void poll_input(running_machine &machine) const; - windows_options &options() { return m_options; } + virtual windows_options &options() override { return m_options; } int window_count(); @@ -307,7 +307,6 @@ private: windows_options & m_options; static const int DEFAULT_FONT_HEIGHT = 200; - static long __stdcall exception_filter(struct _EXCEPTION_POINTERS *info); }; #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) diff --git a/src/osd/windows/winutf8.cpp b/src/osd/windows/winutf8.cpp index cd34b1d12fe..08abcb58dd8 100644 --- a/src/osd/windows/winutf8.cpp +++ b/src/osd/windows/winutf8.cpp @@ -24,7 +24,7 @@ void win_output_debug_string_utf8(const char *string) { TCHAR *t_string = tstring_from_utf8(string); - if (t_string != NULL) + if (t_string != nullptr) { OutputDebugString(t_string); osd_free(t_string); @@ -40,8 +40,8 @@ void win_output_debug_string_utf8(const char *string) int win_message_box_utf8(HWND window, const char *text, const char *caption, UINT type) { int result = IDNO; - TCHAR *t_text = NULL; - TCHAR *t_caption = NULL; + TCHAR *t_text = nullptr; + TCHAR *t_caption = nullptr; if (text) { @@ -76,7 +76,7 @@ done: BOOL win_set_window_text_utf8(HWND window, const char *text) { BOOL result = FALSE; - TCHAR *t_text = NULL; + TCHAR *t_text = nullptr; if (text) { @@ -107,7 +107,7 @@ done: int win_get_window_text_utf8(HWND window, char *buffer, size_t buffer_size) { int result = 0; - char *utf8_buffer = NULL; + char *utf8_buffer = nullptr; TCHAR t_buffer[256]; t_buffer[0] = '\0'; @@ -143,8 +143,8 @@ HWND win_create_window_ex_utf8(DWORD exstyle, const char* classname, const char* HINSTANCE instance, void* param) { TCHAR* t_classname; - TCHAR* t_windowname = NULL; - HWND result = 0; + TCHAR* t_windowname = nullptr; + HWND result = nullptr; t_classname = tstring_from_utf8(classname); if( !t_classname ) diff --git a/src/osd/windows/winutil.cpp b/src/osd/windows/winutil.cpp index 607699749bb..3574f00f398 100644 --- a/src/osd/windows/winutil.cpp +++ b/src/osd/windows/winutil.cpp @@ -122,7 +122,7 @@ lazy_loaded_function::lazy_loaded_function(const char * name, const wchar_t* dll } lazy_loaded_function::lazy_loaded_function(const char * name, const wchar_t** dll_names, int dll_count) - : m_name(name), m_module(NULL), m_initialized(false), m_pfn(nullptr) + : m_name(name), m_module(nullptr), m_initialized(false), m_pfn(nullptr) { for (int i = 0; i < dll_count; i++) m_dll_names.push_back(std::wstring(dll_names[i])); @@ -144,11 +144,11 @@ int lazy_loaded_function::initialize() for (int i = 0; i < m_dll_names.size(); i++) { m_module = LoadLibraryW(m_dll_names[i].c_str()); - if (m_module != NULL) + if (m_module != nullptr) break; } - if (m_module == NULL) + if (m_module == nullptr) { osd_printf_verbose("Could not find DLL to dynamically link function %s.\n", m_name.c_str()); return ERROR_DLL_NOT_FOUND; @@ -170,7 +170,7 @@ int lazy_loaded_function::initialize() return 0; } -void lazy_loaded_function::check_init() +void lazy_loaded_function::check_init() const { if (!m_initialized) fatalerror("Attempt to use function pointer for function %s prior to init!", name()); diff --git a/src/osd/windows/winutil.h b/src/osd/windows/winutil.h index 6cb8297c277..d122679438e 100644 --- a/src/osd/windows/winutil.h +++ b/src/osd/windows/winutil.h @@ -31,7 +31,7 @@ private: bool m_initialized; protected: - void check_init(); + void check_init() const; FARPROC m_pfn; public: @@ -39,7 +39,7 @@ public: lazy_loaded_function(const char * name, const wchar_t** dll_names, int dll_count); ~lazy_loaded_function(); int initialize(); - const char * name() { return m_name.c_str(); } + const char * name() const { return m_name.c_str(); } }; // No parameters |