mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
winmain compile for UWP
This commit is contained in:
parent
a05af7500f
commit
eae8eb8b00
@ -47,7 +47,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
HMONITOR m_handle; // handle to the monitor
|
HMONITOR m_handle; // handle to the monitor
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
MONITORINFOEX m_info; // most recently retrieved info
|
MONITORINFOEX m_info; // most recently retrieved info
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct osd_video_config
|
struct osd_video_config
|
||||||
|
@ -57,14 +57,22 @@ public:
|
|||||||
|
|
||||||
virtual bool win_has_menu() override
|
virtual bool win_has_menu() override
|
||||||
{
|
{
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
return GetMenu(m_hwnd) ? true : false;
|
return GetMenu(m_hwnd) ? true : false;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual osd_dim get_size() override
|
virtual osd_dim get_size() override
|
||||||
{
|
{
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
RECT client;
|
RECT client;
|
||||||
GetClientRect(m_hwnd, &client);
|
GetClientRect(m_hwnd, &client);
|
||||||
return osd_dim(client.right - client.left, client.bottom - client.top);
|
return osd_dim(client.right - client.left, client.bottom - client.top);
|
||||||
|
#else
|
||||||
|
throw ref new Platform::NotImplementedException();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual osd_monitor_info *monitor() const override { return m_monitor; }
|
virtual osd_monitor_info *monitor() const override { return m_monitor; }
|
||||||
|
@ -52,6 +52,8 @@
|
|||||||
// TYPE DEFINITIONS
|
// TYPE DEFINITIONS
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
|
|
||||||
template<typename _FunctionPtr>
|
template<typename _FunctionPtr>
|
||||||
class dynamic_bind
|
class dynamic_bind
|
||||||
{
|
{
|
||||||
@ -217,6 +219,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -231,22 +234,24 @@ int _CRT_glob = 0;
|
|||||||
// LOCAL VARIABLES
|
// LOCAL VARIABLES
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
static LPTOP_LEVEL_EXCEPTION_FILTER pass_thru_filter;
|
static LPTOP_LEVEL_EXCEPTION_FILTER pass_thru_filter;
|
||||||
|
|
||||||
|
static sampling_profiler *profiler = nullptr;
|
||||||
|
static symbol_manager *symbols = nullptr;
|
||||||
|
|
||||||
|
bool stack_walker::s_initialized = false;
|
||||||
|
|
||||||
|
static int timeresult = !TIMERR_NOERROR;
|
||||||
|
static TIMECAPS timecaps;
|
||||||
|
#endif
|
||||||
|
|
||||||
static HANDLE watchdog_reset_event;
|
static HANDLE watchdog_reset_event;
|
||||||
static HANDLE watchdog_exit_event;
|
static HANDLE watchdog_exit_event;
|
||||||
static HANDLE watchdog_thread;
|
static HANDLE watchdog_thread;
|
||||||
|
|
||||||
static running_machine *g_current_machine;
|
static running_machine *g_current_machine;
|
||||||
|
|
||||||
static int timeresult = !TIMERR_NOERROR;
|
|
||||||
static TIMECAPS timecaps;
|
|
||||||
|
|
||||||
static sampling_profiler *profiler = nullptr;
|
|
||||||
static symbol_manager *symbols = nullptr;
|
|
||||||
|
|
||||||
bool stack_walker::s_initialized = false;
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// FUNCTION PROTOTYPES
|
// FUNCTION PROTOTYPES
|
||||||
@ -374,6 +379,7 @@ const options_entry windows_options::s_option_entries[] =
|
|||||||
// MAIN ENTRY POINT
|
// MAIN ENTRY POINT
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// utf8_main
|
// utf8_main
|
||||||
@ -432,18 +438,6 @@ int main(int argc, char *argv[])
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// windows_options
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
windows_options::windows_options()
|
|
||||||
: osd_options()
|
|
||||||
{
|
|
||||||
add_entries(s_option_entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// control_handler
|
// control_handler
|
||||||
//============================================================
|
//============================================================
|
||||||
@ -453,12 +447,12 @@ static BOOL WINAPI control_handler(DWORD type)
|
|||||||
// indicate to the user that we detected something
|
// indicate to the user that we detected something
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CTRL_C_EVENT: fprintf(stderr, "Caught Ctrl+C"); break;
|
case CTRL_C_EVENT: fprintf(stderr, "Caught Ctrl+C"); break;
|
||||||
case CTRL_BREAK_EVENT: fprintf(stderr, "Caught Ctrl+break"); break;
|
case CTRL_BREAK_EVENT: fprintf(stderr, "Caught Ctrl+break"); break;
|
||||||
case CTRL_CLOSE_EVENT: fprintf(stderr, "Caught console close"); break;
|
case CTRL_CLOSE_EVENT: fprintf(stderr, "Caught console close"); break;
|
||||||
case CTRL_LOGOFF_EVENT: fprintf(stderr, "Caught logoff"); break;
|
case CTRL_LOGOFF_EVENT: fprintf(stderr, "Caught logoff"); break;
|
||||||
case CTRL_SHUTDOWN_EVENT: fprintf(stderr, "Caught shutdown"); break;
|
case CTRL_SHUTDOWN_EVENT: fprintf(stderr, "Caught shutdown"); break;
|
||||||
default: fprintf(stderr, "Caught unexpected console event"); break;
|
default: fprintf(stderr, "Caught unexpected console event"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we don't have a machine yet, or if we are handling ctrl+c/ctrl+break,
|
// if we don't have a machine yet, or if we are handling ctrl+c/ctrl+break,
|
||||||
@ -480,8 +474,19 @@ static BOOL WINAPI control_handler(DWORD type)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// windows_options
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
windows_options::windows_options()
|
||||||
|
: osd_options()
|
||||||
|
{
|
||||||
|
add_entries(s_option_entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// output_oslog
|
// output_oslog
|
||||||
@ -592,11 +597,13 @@ void windows_osd_interface::init(running_machine &machine)
|
|||||||
if (options.oslog())
|
if (options.oslog())
|
||||||
machine.add_logerror_callback(output_oslog);
|
machine.add_logerror_callback(output_oslog);
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
// crank up the multimedia timer resolution to its max
|
// crank up the multimedia timer resolution to its max
|
||||||
// this gives the system much finer timeslices
|
// this gives the system much finer timeslices
|
||||||
timeresult = timeGetDevCaps(&timecaps, sizeof(timecaps));
|
timeresult = timeGetDevCaps(&timecaps, sizeof(timecaps));
|
||||||
if (timeresult == TIMERR_NOERROR)
|
if (timeresult == TIMERR_NOERROR)
|
||||||
timeBeginPeriod(timecaps.wPeriodMin);
|
timeBeginPeriod(timecaps.wPeriodMin);
|
||||||
|
#endif
|
||||||
|
|
||||||
// if a watchdog thread is requested, create one
|
// if a watchdog thread is requested, create one
|
||||||
int watchdog = options.watchdog();
|
int watchdog = options.watchdog();
|
||||||
@ -611,11 +618,13 @@ void windows_osd_interface::init(running_machine &machine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create and start the profiler
|
// create and start the profiler
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
if (profile > 0)
|
if (profile > 0)
|
||||||
{
|
{
|
||||||
profiler = global_alloc(sampling_profiler(1000, profile - 1));
|
profiler = global_alloc(sampling_profiler(1000, profile - 1));
|
||||||
profiler->start();
|
profiler->start();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// initialize sockets
|
// initialize sockets
|
||||||
win_init_sockets();
|
win_init_sockets();
|
||||||
@ -652,6 +661,7 @@ void windows_osd_interface::osd_exit()
|
|||||||
watchdog_thread = nullptr;
|
watchdog_thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
// stop the profiler
|
// stop the profiler
|
||||||
if (profiler != nullptr)
|
if (profiler != nullptr)
|
||||||
{
|
{
|
||||||
@ -663,43 +673,12 @@ void windows_osd_interface::osd_exit()
|
|||||||
// restore the timer resolution
|
// restore the timer resolution
|
||||||
if (timeresult == TIMERR_NOERROR)
|
if (timeresult == TIMERR_NOERROR)
|
||||||
timeEndPeriod(timecaps.wPeriodMin);
|
timeEndPeriod(timecaps.wPeriodMin);
|
||||||
|
#endif
|
||||||
|
|
||||||
// one last pass at events
|
// one last pass at events
|
||||||
winwindow_process_events(machine(), 0, 0);
|
winwindow_process_events(machine(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// winmain_dump_stack
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
void winmain_dump_stack()
|
|
||||||
{
|
|
||||||
// set up the stack walker
|
|
||||||
stack_walker walker;
|
|
||||||
if (!walker.reset())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// walk the stack
|
|
||||||
while (walker.unwind())
|
|
||||||
fprintf(stderr, " %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == nullptr) ? "" : symbols->symbol_for_address(walker.ip()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// check_for_double_click_start
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
static int is_double_click_start(int argc)
|
|
||||||
{
|
|
||||||
STARTUPINFO startup_info = { sizeof(STARTUPINFO) };
|
|
||||||
|
|
||||||
// determine our startup information
|
|
||||||
GetStartupInfo(&startup_info);
|
|
||||||
|
|
||||||
// try to determine if MAME was simply double-clicked
|
|
||||||
return (argc <= 1 && startup_info.dwFlags && !(startup_info.dwFlags & STARTF_USESTDHANDLES));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// watchdog_thread_entry
|
// watchdog_thread_entry
|
||||||
@ -751,6 +730,40 @@ void winmain_watchdog_ping(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// winmain_dump_stack
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
void winmain_dump_stack()
|
||||||
|
{
|
||||||
|
// set up the stack walker
|
||||||
|
stack_walker walker;
|
||||||
|
if (!walker.reset())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// walk the stack
|
||||||
|
while (walker.unwind())
|
||||||
|
fprintf(stderr, " %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == nullptr) ? "" : symbols->symbol_for_address(walker.ip()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================
|
||||||
|
// check_for_double_click_start
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
static int is_double_click_start(int argc)
|
||||||
|
{
|
||||||
|
STARTUPINFO startup_info = { sizeof(STARTUPINFO) };
|
||||||
|
|
||||||
|
// determine our startup information
|
||||||
|
GetStartupInfo(&startup_info);
|
||||||
|
|
||||||
|
// try to determine if MAME was simply double-clicked
|
||||||
|
return (argc <= 1 && startup_info.dwFlags && !(startup_info.dwFlags & STARTF_USESTDHANDLES));
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// exception_filter
|
// exception_filter
|
||||||
//============================================================
|
//============================================================
|
||||||
@ -1559,3 +1572,5 @@ void sampling_profiler::thread_run()
|
|||||||
Sleep(1);
|
Sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user