summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/windows/winmain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/windows/winmain.cpp')
-rw-r--r--src/osd/windows/winmain.cpp132
1 files changed, 67 insertions, 65 deletions
diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp
index a7fda58c835..5277fcec3d0 100644
--- a/src/osd/windows/winmain.cpp
+++ b/src/osd/windows/winmain.cpp
@@ -58,15 +58,15 @@ class dynamic_bind
public:
// constructor which looks up the function
dynamic_bind(const TCHAR *dll, const char *symbol)
- : m_function(NULL)
+ : m_function(nullptr)
{
HMODULE module = LoadLibrary(dll);
- if (module != NULL)
+ if (module != nullptr)
m_function = reinterpret_cast<_FunctionPtr>(GetProcAddress(module, symbol));
}
- // bool to test if the function is NULL or not
- operator bool() const { return (m_function != NULL); }
+ // bool to test if the function is nullptr or not
+ operator bool() const { return (m_function != nullptr); }
// dereference to get the underlying pointer
_FunctionPtr operator *() const { return m_function; }
@@ -132,14 +132,14 @@ private:
bool parse_sym_line(const char *line, FPTR &address, std::string &symbol);
bool parse_map_line(const char *line, FPTR &address, std::string &symbol);
void scan_cache_for_address(FPTR address);
- void format_symbol(const char *name, UINT32 displacement, const char *filename = NULL, int linenumber = 0);
+ void format_symbol(const char *name, UINT32 displacement, const char *filename = nullptr, int linenumber = 0);
static FPTR get_text_section_base();
struct cache_entry
{
cache_entry(FPTR address, const char *symbol) :
- m_next(NULL), m_address(address), m_name(symbol) { }
+ m_next(nullptr), m_address(address), m_name(symbol) { }
cache_entry *next() const { return m_next; }
cache_entry * m_next;
@@ -206,11 +206,11 @@ public:
char buffer[1024];
// if we are in fullscreen mode, go to windowed mode
- if ((video_config.windowed == 0) && (win_window_list != NULL))
+ if ((video_config.windowed == 0) && (win_window_list != nullptr))
winwindow_toggle_full_screen();
vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args);
- win_message_box_utf8(win_window_list ? win_window_list->m_hwnd : NULL, buffer, emulator_info::get_appname(), MB_OK);
+ win_message_box_utf8(win_window_list ? win_window_list->m_hwnd : nullptr, buffer, emulator_info::get_appname(), MB_OK);
}
else
chain_output(channel, msg, args);
@@ -242,8 +242,8 @@ static running_machine *g_current_machine;
static int timeresult = !TIMERR_NOERROR;
static TIMECAPS timecaps;
-static sampling_profiler *profiler = NULL;
-static symbol_manager *symbols = NULL;
+static sampling_profiler *profiler = nullptr;
+static symbol_manager *symbols = nullptr;
bool stack_walker::s_initialized = false;
@@ -267,23 +267,23 @@ static LONG WINAPI exception_filter(struct _EXCEPTION_POINTERS *info);
const options_entry windows_options::s_option_entries[] =
{
// performance options
- { NULL, NULL, OPTION_HEADER, "WINDOWS PERFORMANCE OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "WINDOWS PERFORMANCE OPTIONS" },
{ WINOPTION_PRIORITY "(-15-1)", "0", OPTION_INTEGER, "thread priority for the main game thread; range from -15 to 1" },
{ WINOPTION_PROFILE, "0", OPTION_INTEGER, "enables profiling, specifying the stack depth to track" },
// video options
- { NULL, NULL, OPTION_HEADER, "WINDOWS VIDEO OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "WINDOWS VIDEO OPTIONS" },
{ WINOPTION_MENU, "0", OPTION_BOOLEAN, "enables menu bar if available by UI implementation" },
// DirectDraw-specific options
- { NULL, NULL, OPTION_HEADER, "DIRECTDRAW-SPECIFIC OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "DIRECTDRAW-SPECIFIC OPTIONS" },
{ WINOPTION_HWSTRETCH ";hws", "1", OPTION_BOOLEAN, "enables hardware stretching" },
// post-processing options
- { NULL, NULL, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" },
{ WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enables HLSL post-processing (PS3.0 required)" },
{ WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" },
- { WINOPTION_HLSL_WRITE, NULL, OPTION_STRING, "enables HLSL AVI writing (huge disk bandwidth suggested)" },
+ { WINOPTION_HLSL_WRITE, nullptr, OPTION_STRING, "enables HLSL AVI writing (huge disk bandwidth suggested)" },
{ WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" },
{ WINOPTION_HLSL_SNAP_HEIGHT, "1536", OPTION_STRING, "HLSL upscaled-snapshot height" },
{ WINOPTION_SHADOW_MASK_TILE_MODE, "0", OPTION_INTEGER, "shadow mask tile mode (0 for screen based, 1 for source based)" },
@@ -324,7 +324,7 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_FLOOR";fs_floor", "0.05,0.05,0.05", OPTION_STRING, "signal floor level" },
{ WINOPTION_PHOSPHOR";fs_phosphor", "0.4,0.4,0.4", OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
/* NTSC simulation below this line */
- { NULL, NULL, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" },
{ WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enables YIQ-space HLSL post-processing" },
{ WINOPTION_YIQ_JITTER";yiqj", "0.0", OPTION_FLOAT, "Jitter for the NTSC signal processing" },
{ WINOPTION_YIQ_CCVALUE";yiqcc", "3.57954545", OPTION_FLOAT, "Color Carrier frequency for NTSC signal processing" },
@@ -339,11 +339,11 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_YIQ_SCAN_TIME";yiqsc", "52.6", OPTION_FLOAT, "Horizontal scanline duration for NTSC signal processing (in usec)" },
{ WINOPTION_YIQ_PHASE_COUNT";yiqp", "2", OPTION_INTEGER, "Phase Count value for NTSC signal processing" },
/* Vector simulation below this line */
- { NULL, NULL, OPTION_HEADER, "VECTOR POST-PROCESSING OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "VECTOR POST-PROCESSING OPTIONS" },
{ WINOPTION_VECTOR_LENGTH_SCALE";veclength", "0.5", OPTION_FLOAT, "How much length affects vector fade" },
{ WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "500.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
/* Bloom below this line */
- { NULL, NULL, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" },
{ WINOPTION_BLOOM_BLEND_MODE, "0", OPTION_INTEGER, "bloom blend mode (0 for addition, 1 for darken)" },
{ WINOPTION_BLOOM_SCALE, "0.25", OPTION_FLOAT, "Intensity factor for bloom" },
{ WINOPTION_BLOOM_OVERDRIVE, "1.0,1.0,1.0", OPTION_STRING, "Overdrive factor for bloom" },
@@ -360,18 +360,18 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_BLOOM_LEVEL10_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 10 (1x1 target) weight" },
// full screen options
- { NULL, NULL, OPTION_HEADER, "FULL SCREEN OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "FULL SCREEN OPTIONS" },
{ WINOPTION_TRIPLEBUFFER ";tb", "0", OPTION_BOOLEAN, "enables triple buffering" },
{ WINOPTION_FULLSCREENBRIGHTNESS ";fsb(0.1-2.0)", "1.0", OPTION_FLOAT, "brightness value in full screen mode" },
{ WINOPTION_FULLSCREENCONTRAST ";fsc(0.1-2.0)", "1.0", OPTION_FLOAT, "contrast value in full screen mode" },
{ WINOPTION_FULLSCREENGAMMA ";fsg(0.1-3.0)", "1.0", OPTION_FLOAT, "gamma value in full screen mode" },
// input options
- { NULL, NULL, OPTION_HEADER, "INPUT DEVICE OPTIONS" },
+ { nullptr, nullptr, OPTION_HEADER, "INPUT DEVICE OPTIONS" },
{ WINOPTION_GLOBAL_INPUTS ";global_inputs", "0", OPTION_BOOLEAN, "enables global inputs" },
{ WINOPTION_DUAL_LIGHTGUN ";dual", "0", OPTION_BOOLEAN, "enables dual lightgun input" },
- { NULL }
+ { nullptr }
};
//**************************************************************************
@@ -387,9 +387,9 @@ int main(int argc, char *argv[])
{
// use small output buffers on non-TTYs (i.e. pipes)
if (!isatty(fileno(stdout)))
- setvbuf(stdout, (char *) NULL, _IOFBF, 64);
+ setvbuf(stdout, (char *) nullptr, _IOFBF, 64);
if (!isatty(fileno(stderr)))
- setvbuf(stderr, (char *) NULL, _IOFBF, 64);
+ setvbuf(stderr, (char *) nullptr, _IOFBF, 64);
// initialize common controls
InitCommonControls();
@@ -432,7 +432,7 @@ int main(int argc, char *argv[])
osd_output::pop(&winerror);
}
// free symbols
- symbols = NULL;
+ symbols = nullptr;
return result;
}
@@ -467,7 +467,7 @@ static BOOL WINAPI control_handler(DWORD type)
// if we don't have a machine yet, or if we are handling ctrl+c/ctrl+break,
// just terminate hard, without throwing or handling any atexit stuff
- if (g_current_machine == NULL || type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)
+ if (g_current_machine == nullptr || type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)
{
fprintf(stderr, ", exiting\n");
TerminateProcess(GetCurrentProcess(), MAMERR_FATALERROR);
@@ -503,7 +503,9 @@ static void output_oslog(const running_machine &machine, const char *buffer)
//============================================================
windows_osd_interface::windows_osd_interface(windows_options &options)
-: osd_common_t(options), m_options(options)
+ : osd_common_t(options)
+ , m_options(options)
+ , m_sliders(nullptr)
{
}
@@ -523,10 +525,10 @@ windows_osd_interface::~windows_osd_interface()
void windows_osd_interface::video_register()
{
- video_options_add("gdi", NULL);
- video_options_add("d3d", NULL);
- video_options_add("bgfx", NULL);
- //video_options_add("auto", NULL); // making d3d video default one
+ video_options_add("gdi", nullptr);
+ video_options_add("d3d", nullptr);
+ video_options_add("bgfx", nullptr);
+ //video_options_add("auto", nullptr); // making d3d video default one
}
//============================================================
@@ -587,7 +589,7 @@ void windows_osd_interface::init(running_machine &machine)
// notify listeners of screen configuration
std::string tempstring;
- for (win_window_info *info = win_window_list; info != NULL; info = info->m_next)
+ for (win_window_info *info = win_window_list; info != nullptr; info = info->m_next)
{
strprintf(tempstring, "Orientation(%s)", info->m_monitor->devicename());
machine.output().set_value(tempstring.c_str(), info->m_targetorient);
@@ -607,12 +609,12 @@ void windows_osd_interface::init(running_machine &machine)
int watchdog = options.watchdog();
if (watchdog != 0)
{
- watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL);
- assert_always(watchdog_reset_event != NULL, "Failed to create watchdog reset event");
- watchdog_exit_event = CreateEvent(NULL, TRUE, FALSE, NULL);
- assert_always(watchdog_exit_event != NULL, "Failed to create watchdog exit event");
- watchdog_thread = CreateThread(NULL, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, NULL);
- assert_always(watchdog_thread != NULL, "Failed to create watchdog thread");
+ watchdog_reset_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+ assert_always(watchdog_reset_event != nullptr, "Failed to create watchdog reset event");
+ watchdog_exit_event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
+ assert_always(watchdog_exit_event != nullptr, "Failed to create watchdog exit event");
+ watchdog_thread = CreateThread(nullptr, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, nullptr);
+ assert_always(watchdog_thread != nullptr, "Failed to create watchdog thread");
}
// create and start the profiler
@@ -637,7 +639,7 @@ void windows_osd_interface::init(running_machine &machine)
void windows_osd_interface::osd_exit()
{
// no longer have a machine
- g_current_machine = NULL;
+ g_current_machine = nullptr;
// cleanup sockets
win_cleanup_sockets();
@@ -645,20 +647,20 @@ void windows_osd_interface::osd_exit()
osd_common_t::osd_exit();
// take down the watchdog thread if it exists
- if (watchdog_thread != NULL)
+ if (watchdog_thread != nullptr)
{
SetEvent(watchdog_exit_event);
WaitForSingleObject(watchdog_thread, INFINITE);
CloseHandle(watchdog_reset_event);
CloseHandle(watchdog_exit_event);
CloseHandle(watchdog_thread);
- watchdog_reset_event = NULL;
- watchdog_exit_event = NULL;
- watchdog_thread = NULL;
+ watchdog_reset_event = nullptr;
+ watchdog_exit_event = nullptr;
+ watchdog_thread = nullptr;
}
// stop the profiler
- if (profiler != NULL)
+ if (profiler != nullptr)
{
profiler->stop();
profiler->print_results(*symbols);
@@ -686,7 +688,7 @@ void winmain_dump_stack()
// walk the stack
while (walker.unwind())
- fprintf(stderr, " %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == NULL) ? "" : symbols->symbol_for_address(walker.ip()));
+ fprintf(stderr, " %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == nullptr) ? "" : symbols->symbol_for_address(walker.ip()));
}
@@ -751,7 +753,7 @@ static DWORD WINAPI watchdog_thread_entry(LPVOID lpParameter)
void winmain_watchdog_ping(void)
{
// if we have a watchdog, reset it
- if (watchdog_reset_event != NULL)
+ if (watchdog_reset_event != nullptr)
SetEvent(watchdog_reset_event);
}
@@ -864,7 +866,7 @@ static LONG WINAPI exception_filter(struct _EXCEPTION_POINTERS *info)
// walk the stack
while (walker.unwind())
- fprintf(stderr, " %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == NULL) ? "" : symbols->symbol_for_address(walker.ip()));
+ fprintf(stderr, " %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == nullptr) ? "" : symbols->symbol_for_address(walker.ip()));
// flush stderr, so the data is actually written when output is being redirected
fflush(stderr);
@@ -899,7 +901,7 @@ stack_walker::stack_walker()
// initialize the symbols
if (!s_initialized && m_sym_initialize && m_stack_walk_64 && m_sym_function_table_access_64 && m_sym_get_module_base_64)
{
- (*m_sym_initialize)(m_process, NULL, TRUE);
+ (*m_sym_initialize)(m_process, nullptr, TRUE);
s_initialized = true;
}
}
@@ -973,9 +975,9 @@ bool stack_walker::unwind()
if (s_initialized)
{
#ifdef PTR64
- return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_AMD64, m_process, m_thread, &m_stackframe, &m_context, NULL, *m_sym_function_table_access_64, *m_sym_get_module_base_64, NULL);
+ return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_AMD64, m_process, m_thread, &m_stackframe, &m_context, nullptr, *m_sym_function_table_access_64, *m_sym_get_module_base_64, nullptr);
#else
- return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_I386, m_process, m_thread, &m_stackframe, &m_context, NULL, *m_sym_function_table_access_64, *m_sym_get_module_base_64, NULL);
+ return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_I386, m_process, m_thread, &m_stackframe, &m_context, nullptr, *m_sym_function_table_access_64, *m_sym_get_module_base_64, nullptr);
#endif
}
@@ -1054,7 +1056,7 @@ const char *symbol_manager::symbol_for_address(FPTR address)
if (!query_system_for_address(address))
{
// if that fails, scan the cache if we have one
- if (m_cache.first() != NULL)
+ if (m_cache.first() != nullptr)
scan_cache_for_address(address);
// or else try to open a sym/map file and find it there
@@ -1111,20 +1113,20 @@ bool symbol_manager::query_system_for_address(FPTR address)
void symbol_manager::scan_file_for_address(FPTR address, bool create_cache)
{
bool is_symfile = false;
- FILE *srcfile = NULL;
+ FILE *srcfile = nullptr;
#ifdef __GNUC__
// see if we have a symbol file (gcc only)
srcfile = fopen(m_symfile.c_str(), "r");
- is_symfile = (srcfile != NULL);
+ is_symfile = (srcfile != nullptr);
#endif
// if not, see if we have a map file
- if (srcfile == NULL)
+ if (srcfile == nullptr)
srcfile = fopen(m_mapfile.c_str(), "r");
// if not, fail
- if (srcfile == NULL)
+ if (srcfile == nullptr)
return;
// reset the best info
@@ -1177,7 +1179,7 @@ void symbol_manager::scan_cache_for_address(FPTR address)
FPTR best_addr = 0;
// walk the cache, looking for valid entries
- for (cache_entry *entry = m_cache.first(); entry != NULL; entry = entry->next())
+ for (cache_entry *entry = m_cache.first(); entry != nullptr; entry = entry->next())
// if this is the best one so far, remember it
if (entry->m_address <= address && entry->m_address > best_addr)
@@ -1210,7 +1212,7 @@ bool symbol_manager::parse_sym_line(const char *line, FPTR &address, std::string
// first look for a (ty) entry
const char *type = strstr(line, "(ty 20)");
- if (type == NULL)
+ if (type == nullptr)
return false;
// scan forward in the line to find the address
@@ -1297,7 +1299,7 @@ void symbol_manager::format_symbol(const char *name, UINT32 displacement, const
strcatprintf(m_buffer, "+0x%04x", (UINT32)displacement);
// append file/line if present
- if (filename != NULL)
+ if (filename != nullptr)
strcatprintf(m_buffer, ", %s:%d", filename, linenumber);
// close up the string
@@ -1317,18 +1319,18 @@ FPTR symbol_manager::get_text_section_base()
// start with the image base
PVOID base = reinterpret_cast<PVOID>(GetModuleHandleUni());
- assert(base != NULL);
+ assert(base != nullptr);
// make sure we have the functions we need
if (image_nt_header && image_rva_to_section)
{
// get the NT header
PIMAGE_NT_HEADERS headers = (*image_nt_header)(base);
- assert(headers != NULL);
+ assert(headers != nullptr);
// look ourself up (assuming we are in the .text section)
PIMAGE_SECTION_HEADER section = (*image_rva_to_section)(headers, base, reinterpret_cast<FPTR>(get_text_section_base) - reinterpret_cast<FPTR>(base));
- if (section != NULL)
+ if (section != nullptr)
return reinterpret_cast<FPTR>(base) + section->VirtualAddress;
}
@@ -1347,8 +1349,8 @@ FPTR symbol_manager::get_text_section_base()
//-------------------------------------------------
sampling_profiler::sampling_profiler(UINT32 max_seconds, UINT8 stack_depth = 0)
- : m_target_thread(NULL),
- m_thread(NULL),
+ : m_target_thread(nullptr),
+ m_thread(nullptr),
m_thread_id(0),
m_thread_exit(false),
m_stack_depth(stack_depth),
@@ -1384,8 +1386,8 @@ void sampling_profiler::start()
m_thread_exit = false;
// start the thread
- m_thread = CreateThread(NULL, 0, thread_entry, (LPVOID)this, 0, &m_thread_id);
- assert_always(m_thread != NULL, "Failed to create profiler thread\n");
+ m_thread = CreateThread(nullptr, 0, thread_entry, (LPVOID)this, 0, &m_thread_id);
+ assert_always(m_thread != nullptr, "Failed to create profiler thread\n");
// max out the priority
SetThreadPriority(m_thread, THREAD_PRIORITY_TIME_CRITICAL);
@@ -1553,7 +1555,7 @@ void sampling_profiler::thread_run()
*count += 1;
}
- // fill in any missing parts with NULLs
+ // fill in any missing parts with nulls
for (; frame <= m_stack_depth; frame++)
*m_buffer_ptr++ = 0;