diff options
Diffstat (limited to 'docs/release/src/osd/windows')
-rw-r--r-- | docs/release/src/osd/windows/winmain.cpp | 700 | ||||
-rw-r--r-- | docs/release/src/osd/windows/winmain.h | 360 |
2 files changed, 1060 insertions, 0 deletions
diff --git a/docs/release/src/osd/windows/winmain.cpp b/docs/release/src/osd/windows/winmain.cpp new file mode 100644 index 00000000000..10fa5e3b836 --- /dev/null +++ b/docs/release/src/osd/windows/winmain.cpp @@ -0,0 +1,700 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +//============================================================ +// +// winmain.cpp - Win32 main program +// +//============================================================ + +// MAME headers +#include "emu.h" +#include "emuopts.h" +#include "strconv.h" + +// MAMEOS headers +#include "winmain.h" +#include "window.h" +#include "winutf8.h" +#include "winutil.h" +#include "winfile.h" +#include "modules/diagnostics/diagnostics_module.h" +#include "modules/monitor/monitor_common.h" + +// standard C headers +#include <ctype.h> +#include <stdarg.h> +#include <stdio.h> + +// standard windows headers +#include <windows.h> +#include <commctrl.h> +#include <mmsystem.h> +#include <tchar.h> +#include <io.h> + +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#include <wrl/client.h> +using namespace Windows::Storage; +using namespace Platform; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Core; +using namespace Windows::UI::Popups; +#endif + +#define DEBUG_SLOW_LOCKS 0 + +//************************************************************************** +// MACROS +//************************************************************************** + +#ifdef UNICODE +#define UNICODE_POSTFIX "W" +#else +#define UNICODE_POSTFIX "A" +#endif + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +//============================================================ +// winui_output_error +//============================================================ + +class winui_output_error : public osd_output +{ +public: + virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override + { + if (channel == OSD_OUTPUT_CHANNEL_ERROR) + { + char buffer[1024]; + + // if we are in fullscreen mode, go to windowed mode + if ((video_config.windowed == 0) && !osd_common_t::s_window_list.empty()) + winwindow_toggle_full_screen(); + + vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args); + win_message_box_utf8(!osd_common_t::s_window_list.empty() ? std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window() : nullptr, buffer, emulator_info::get_appname(), MB_OK); + } + else + chain_output(channel, msg, args); + } +}; + +#else + +//============================================================ +// winuniversal_output_error +//============================================================ + +class winuniversal_output_error : public osd_output +{ +public: + virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override + { + char buffer[2048]; + if (channel == OSD_OUTPUT_CHANNEL_ERROR) + { + vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args); + + std::wstring wcbuffer(osd::text::to_wstring(buffer)); + std::wstring wcappname(osd::text::to_wstring(emulator_info::get_appname())); + + auto dlg = ref new MessageDialog(ref new Platform::String(wcbuffer.data()), ref new Platform::String(wcbuffer.data())); + dlg->ShowAsync(); + } + else if (channel == OSD_OUTPUT_CHANNEL_VERBOSE) + { + vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args); + std::wstring wcbuffer = osd::text::to_wstring(buffer); + OutputDebugString(wcbuffer.c_str()); + + // Chain to next anyway + chain_output(channel, msg, args); + } + else + chain_output(channel, msg, args); + } +}; + +#endif + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// this line prevents globbing on the command line +int _CRT_glob = 0; + +//************************************************************************** +// LOCAL VARIABLES +//************************************************************************** + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +static int timeresult = !TIMERR_NOERROR; +static TIMECAPS timecaps; +#endif + +static running_machine *g_current_machine; + + +//************************************************************************** +// FUNCTION PROTOTYPES +//************************************************************************** + +static BOOL WINAPI control_handler(DWORD type); +static int is_double_click_start(int argc); + + +//************************************************************************** +// OPTIONS +//************************************************************************** + +// struct definitions +const options_entry windows_options::s_option_entries[] = +{ + // 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 + { nullptr, nullptr, OPTION_HEADER, "WINDOWS VIDEO OPTIONS" }, + { WINOPTION_MENU, "0", OPTION_BOOLEAN, "enables menu bar if available by UI implementation" }, + + // post-processing options + { nullptr, nullptr, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" }, + { WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to HLSL support files" }, + { WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enable HLSL post-processing (PS3.0 required)" }, + { WINOPTION_HLSL_OVERSAMPLING, "0", OPTION_BOOLEAN, "enable HLSL oversampling" }, + { WINOPTION_HLSL_WRITE, OSDOPTVAL_AUTO, OPTION_STRING, "enable 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)" }, + { WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" }, + { WINOPTION_SHADOW_MASK_TEXTURE";fs_shadwt(0.0-1.0)", "shadow-mask.png", OPTION_STRING, "shadow mask texture name" }, + { WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww", "6", OPTION_INTEGER, "shadow mask tile width, in screen dimensions" }, + { WINOPTION_SHADOW_MASK_COUNT_Y";fs_shadwh", "4", OPTION_INTEGER, "shadow mask tile height, in screen dimensions" }, + { WINOPTION_SHADOW_MASK_USIZE";fs_shadwu(0.0-1.0)", "0.1875", OPTION_FLOAT, "shadow mask texture width, in U/V dimensions" }, + { WINOPTION_SHADOW_MASK_VSIZE";fs_shadwv(0.0-1.0)", "0.25", OPTION_FLOAT, "shadow mask texture height, in U/V dimensions" }, + { WINOPTION_SHADOW_MASK_UOFFSET";fs_shadwou(-1.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask texture offset, in U direction" }, + { WINOPTION_SHADOW_MASK_VOFFSET";fs_shadwov(-1.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask texture offset, in V direction" }, + { WINOPTION_DISTORTION";fs_dist(-1.0-1.0)", "0.0", OPTION_FLOAT, "screen distortion amount" }, + { WINOPTION_CUBIC_DISTORTION";fs_cubedist(-1.0-1.0)", "0.0", OPTION_FLOAT, "screen cubic distortion amount" }, + { WINOPTION_DISTORT_CORNER";fs_distc(0.0-1.0)", "0.0", OPTION_FLOAT, "screen distort corner amount" }, + { WINOPTION_ROUND_CORNER";fs_rndc(0.0-1.0)", "0.0", OPTION_FLOAT, "screen round corner amount" }, + { WINOPTION_SMOOTH_BORDER";fs_smob(0.0-1.0)", "0.0", OPTION_FLOAT, "screen smooth border amount" }, + { WINOPTION_REFLECTION";fs_ref(0.0-1.0)", "0.0", OPTION_FLOAT, "screen reflection amount" }, + { WINOPTION_VIGNETTING";fs_vig(0.0-1.0)", "0.0", OPTION_FLOAT, "image vignetting amount" }, + /* Beam-related values below this line*/ + { WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for scanlines" }, + { WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)", "1.0", OPTION_FLOAT, "overall height scaling value for scanlines" }, + { WINOPTION_SCANLINE_HEIGHT";fs_scanh(0.0-4.0)", "1.0", OPTION_FLOAT, "individual height scaling value for scanlines" }, + { WINOPTION_SCANLINE_VARIATION";fs_scanv(0.0-4.0)", "1.0", OPTION_FLOAT, "individual height varying value for scanlines" }, + { WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-2.0)", "1.0", OPTION_FLOAT, "overall brightness scaling value for scanlines (multiplicative)" }, + { WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)", "0.0", OPTION_FLOAT, "overall brightness offset value for scanlines (additive)" }, + { WINOPTION_SCANLINE_JITTER";fs_scanjt(0.0-4.0)", "0.0", OPTION_FLOAT, "overall interlace jitter scaling value for scanlines" }, + { WINOPTION_HUM_BAR_ALPHA";fs_humba(0.0-1.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for hum bar" }, + { WINOPTION_DEFOCUS";fs_focus", "0.0,0.0", OPTION_STRING, "overall defocus value in screen-relative coords" }, + { WINOPTION_CONVERGE_X";fs_convx", "0.0,0.0,0.0", OPTION_STRING, "convergence in screen-relative X direction" }, + { WINOPTION_CONVERGE_Y";fs_convy", "0.0,0.0,0.0", OPTION_STRING, "convergence in screen-relative Y direction" }, + { WINOPTION_RADIAL_CONVERGE_X";fs_rconvx", "0.0,0.0,0.0", OPTION_STRING, "radial convergence in screen-relative X direction" }, + { WINOPTION_RADIAL_CONVERGE_Y";fs_rconvy", "0.0,0.0,0.0", OPTION_STRING, "radial convergence in screen-relative Y direction" }, + /* RGB colorspace convolution below this line */ + { WINOPTION_RED_RATIO";fs_redratio", "1.0,0.0,0.0", OPTION_STRING, "red output signal generated by input signal" }, + { WINOPTION_GRN_RATIO";fs_grnratio", "0.0,1.0,0.0", OPTION_STRING, "green output signal generated by input signal" }, + { WINOPTION_BLU_RATIO";fs_bluratio", "0.0,0.0,1.0", OPTION_STRING, "blue output signal generated by input signal" }, + { WINOPTION_SATURATION";fs_sat(0.0-4.0)", "1.0", OPTION_FLOAT, "saturation scaling value" }, + { WINOPTION_OFFSET";fs_offset", "0.0,0.0,0.0", OPTION_STRING, "signal offset value (additive)" }, + { WINOPTION_SCALE";fs_scale", "1.0,1.0,1.0", OPTION_STRING, "signal scaling value (multiplicative)" }, + { WINOPTION_POWER";fs_power", "1.0,1.0,1.0", OPTION_STRING, "signal power value (exponential)" }, + { WINOPTION_FLOOR";fs_floor", "0.0,0.0,0.0", OPTION_STRING, "signal floor level" }, + { WINOPTION_PHOSPHOR";fs_phosphor", "0.0,0.0,0.0", OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" }, + { WINOPTION_CHROMA_MODE, "3", OPTION_INTEGER, "number of phosphors to use: 1 - monochrome, 2 - dichrome, 3 - trichrome (color)" }, + { WINOPTION_CHROMA_CONVERSION_GAIN, "0.299,0.587,0.114", OPTION_STRING, "gain to be applied when summing RGB signal for monochrome and dichrome modes" }, + { WINOPTION_CHROMA_A, "0.64,0.33", OPTION_STRING, "chromaticity coordinate for first phosphor" }, + { WINOPTION_CHROMA_B, "0.30,0.60", OPTION_STRING, "chromaticity coordinate for second phosphor" }, + { WINOPTION_CHROMA_C, "0.15,0.06", OPTION_STRING, "chromaticity coordinate for third phosphor" }, + { WINOPTION_CHROMA_Y_GAIN, "0.2126,0.7152,0.0722", OPTION_STRING, "gain to be applied for each phosphor" }, + /* NTSC simulation below this line */ + { nullptr, nullptr, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" }, + { WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enable 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" }, + { WINOPTION_YIQ_AVALUE";yiqa", "0.5", OPTION_FLOAT, "A value for NTSC signal processing" }, + { WINOPTION_YIQ_BVALUE";yiqb", "0.5", OPTION_FLOAT, "B value for NTSC signal processing" }, + { WINOPTION_YIQ_OVALUE";yiqo", "0.0", OPTION_FLOAT, "outgoing Color Carrier phase offset for NTSC signal processing" }, + { WINOPTION_YIQ_PVALUE";yiqp", "1.0", OPTION_FLOAT, "incoming Pixel Clock scaling value for NTSC signal processing" }, + { WINOPTION_YIQ_NVALUE";yiqn", "1.0", OPTION_FLOAT, "Y filter notch width for NTSC signal processing" }, + { WINOPTION_YIQ_YVALUE";yiqy", "6.0", OPTION_FLOAT, "Y filter cutoff frequency for NTSC signal processing" }, + { WINOPTION_YIQ_IVALUE";yiqi", "1.2", OPTION_FLOAT, "I filter cutoff frequency for NTSC signal processing" }, + { WINOPTION_YIQ_QVALUE";yiqq", "0.6", OPTION_FLOAT, "Q filter cutoff frequency for NTSC signal processing" }, + { WINOPTION_YIQ_SCAN_TIME";yiqsc", "52.6", OPTION_FLOAT, "horizontal scanline duration for NTSC signal processing (microseconds)" }, + { WINOPTION_YIQ_PHASE_COUNT";yiqpc", "2", OPTION_INTEGER, "phase count value for NTSC signal processing" }, + /* Vector simulation below this line */ + { nullptr, nullptr, OPTION_HEADER, "VECTOR POST-PROCESSING OPTIONS" }, + { WINOPTION_VECTOR_BEAM_SMOOTH";vecsmooth", "0.0", OPTION_FLOAT, "vector beam smoothness" }, + { WINOPTION_VECTOR_LENGTH_SCALE";vecscale", "0.5", OPTION_FLOAT, "maximum vector attenuation" }, + { WINOPTION_VECTOR_LENGTH_RATIO";vecratio", "0.5", OPTION_FLOAT, "minimum vector length affected by attenuation (vector length to screen size ratio)" }, + /* Bloom below this line */ + { nullptr, nullptr, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" }, + { WINOPTION_BLOOM_BLEND_MODE, "0", OPTION_INTEGER, "bloom blend mode (0 for brighten, 1 for darken)" }, + { WINOPTION_BLOOM_SCALE, "0.0", OPTION_FLOAT, "intensity factor for bloom" }, + { WINOPTION_BLOOM_OVERDRIVE, "1.0,1.0,1.0", OPTION_STRING, "overdrive factor for bloom" }, + { WINOPTION_BLOOM_LEVEL0_WEIGHT, "1.0", OPTION_FLOAT, "bloom level 0 weight (full-size target)" }, + { WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.64", OPTION_FLOAT, "bloom level 1 weight (1/4 smaller that level 0 target)" }, + { WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.32", OPTION_FLOAT, "bloom level 2 weight (1/4 smaller that level 1 target)" }, + { WINOPTION_BLOOM_LEVEL3_WEIGHT, "0.16", OPTION_FLOAT, "bloom level 3 weight (1/4 smaller that level 2 target)" }, + { WINOPTION_BLOOM_LEVEL4_WEIGHT, "0.08", OPTION_FLOAT, "bloom level 4 weight (1/4 smaller that level 3 target)" }, + { WINOPTION_BLOOM_LEVEL5_WEIGHT, "0.06", OPTION_FLOAT, "bloom level 5 weight (1/4 smaller that level 4 target)" }, + { WINOPTION_BLOOM_LEVEL6_WEIGHT, "0.04", OPTION_FLOAT, "bloom level 6 weight (1/4 smaller that level 5 target)" }, + { WINOPTION_BLOOM_LEVEL7_WEIGHT, "0.02", OPTION_FLOAT, "bloom level 7 weight (1/4 smaller that level 6 target)" }, + { WINOPTION_BLOOM_LEVEL8_WEIGHT, "0.01", OPTION_FLOAT, "bloom level 8 weight (1/4 smaller that level 7 target)" }, + { WINOPTION_LUT_TEXTURE, "", OPTION_STRING, "3D LUT texture filename for screen, PNG format" }, + { WINOPTION_LUT_ENABLE, "0", OPTION_BOOLEAN, "Enables 3D LUT to be applied to screen after post-processing" }, + { WINOPTION_UI_LUT_TEXTURE, "", OPTION_STRING, "3D LUT texture filename of UI, PNG format" }, + { WINOPTION_UI_LUT_ENABLE, "0", OPTION_BOOLEAN, "enable 3D LUT to be applied to UI and artwork after post-processing" }, + + // full screen options + { nullptr, nullptr, OPTION_HEADER, "FULL SCREEN OPTIONS" }, + { WINOPTION_TRIPLEBUFFER ";tb", "0", OPTION_BOOLEAN, "enable 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 + { nullptr, nullptr, OPTION_HEADER, "INPUT DEVICE OPTIONS" }, + { WINOPTION_GLOBAL_INPUTS, "0", OPTION_BOOLEAN, "enable global inputs" }, + { WINOPTION_DUAL_LIGHTGUN ";dual", "0", OPTION_BOOLEAN, "enable dual lightgun input" }, + + { nullptr } +}; + +//************************************************************************** +// MAIN ENTRY POINT +//************************************************************************** + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +//============================================================ +// main +//============================================================ +//HBMAME start +int main_(int argc, char *argv[]) +{ + std::vector<std::string> args = osd_get_command_line(argc, argv); + + // use small output buffers on non-TTYs (i.e. pipes) + if (!isatty(fileno(stdout))) + setvbuf(stdout, (char *) nullptr, _IOFBF, 64); + if (!isatty(fileno(stderr))) + setvbuf(stderr, (char *) nullptr, _IOFBF, 64); + + // initialize common controls + InitCommonControls(); + + // set a handler to catch ctrl-c + SetConsoleCtrlHandler(control_handler, TRUE); + + // Initialize crash diagnostics + diagnostics_module::get_instance()->init_crash_diagnostics(); + + // parse config and cmdline options + DWORD result; + { + windows_options options; + windows_osd_interface osd(options); + // if we're a GUI app, out errors to message boxes + // Initialize this after the osd interface so that we are first in the + // output order + winui_output_error winerror; + if (win_is_gui_application() || is_double_click_start(args.size())) + { + // if we are a GUI app, output errors to message boxes + osd_output::push(&winerror); + // make sure any console window that opened on our behalf is nuked + FreeConsole(); + } + osd.register_options(); + result = emulator_info::start_frontend(options, osd, args); + osd_output::pop(&winerror); + } + + return result; +} +//HBMAME end +int main(int argc, char *argv[]) +{ + std::vector<std::string> args = osd_get_command_line(argc, argv); + + // use small output buffers on non-TTYs (i.e. pipes) + if (!isatty(fileno(stdout))) + setvbuf(stdout, (char *) nullptr, _IOFBF, 64); + if (!isatty(fileno(stderr))) + setvbuf(stderr, (char *) nullptr, _IOFBF, 64); + + // initialize common controls + InitCommonControls(); + + // set a handler to catch ctrl-c + SetConsoleCtrlHandler(control_handler, TRUE); + + // Initialize crash diagnostics + diagnostics_module::get_instance()->init_crash_diagnostics(); + + // parse config and cmdline options + DWORD result; + { + windows_options options; + windows_osd_interface osd(options); + // if we're a GUI app, out errors to message boxes + // Initialize this after the osd interface so that we are first in the + // output order + winui_output_error winerror; + if (win_is_gui_application() || is_double_click_start(args.size())) + { + // if we are a GUI app, output errors to message boxes + osd_output::push(&winerror); + // make sure any console window that opened on our behalf is nuked + FreeConsole(); + } + osd.register_options(); + result = emulator_info::start_frontend(options, osd, args); + osd_output::pop(&winerror); + } + + return result; +} + +//============================================================ +// control_handler +//============================================================ + +static BOOL WINAPI control_handler(DWORD type) +{ + // indicate to the user that we detected something + switch (type) + { + case CTRL_C_EVENT: fprintf(stderr, "Caught Ctrl+C"); break; + case CTRL_BREAK_EVENT: fprintf(stderr, "Caught Ctrl+break"); break; + case CTRL_CLOSE_EVENT: fprintf(stderr, "Caught console close"); break; + case CTRL_LOGOFF_EVENT: fprintf(stderr, "Caught logoff"); break; + case CTRL_SHUTDOWN_EVENT: fprintf(stderr, "Caught shutdown"); 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, + // just terminate hard, without throwing or handling any atexit stuff + if (g_current_machine == nullptr || type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT) + { + fprintf(stderr, ", exiting\n"); + TerminateProcess(GetCurrentProcess(), EMU_ERR_FATALERROR); + } + + // all other situations attempt to do a clean exit + else + { + fprintf(stderr, ", exit requested\n"); + g_current_machine->schedule_exit(); + } + + // in all cases we handled it + return TRUE; +} + +#else + +// The main function is only used to initialize our IFrameworkView class. +[Platform::MTAThread] +int main(Platform::Array<Platform::String^>^ args) +{ + auto direct3DApplicationSource = ref new MameViewSource(); + CoreApplication::Run(direct3DApplicationSource); + return 0; +} + +MameMainApp::MameMainApp() +{ + // Turn off application view scaling so XBOX gets full screen + Windows::UI::ViewManagement::ApplicationViewScaling::TrySetDisableLayoutScaling(true); +} + +void MameMainApp::Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView) +{ + // Register event handlers for app lifecycle. +} + +// Called when the CoreWindow object is created (or re-created). +void MameMainApp::SetWindow(Windows::UI::Core::CoreWindow^ window) +{ + // Attach event handlers on the window for input, etc. +} + +// Initializes scene resources, or loads a previously saved app state. +void MameMainApp::Load(Platform::String^ entryPoint) +{ +} + +void MameMainApp::Run() +{ + // use small output buffers on non-TTYs (i.e. pipes) + if (!isatty(fileno(stdout))) + setvbuf(stdout, (char *) nullptr, _IOFBF, 64); + if (!isatty(fileno(stderr))) + setvbuf(stderr, (char *) nullptr, _IOFBF, 64); + + // parse config and cmdline options + m_options = std::make_unique<windows_options>(); + m_osd = std::make_unique<windows_osd_interface>(*m_options.get()); + + // Since we're a GUI app, out errors to message boxes + // Initialize this after the osd interface so that we are first in the + // output order + winuniversal_output_error winerror; + osd_output::push(&winerror); + + m_osd->register_options(); + + // To satisfy the latter things, pass in the module path name + char exe_path[MAX_PATH]; + GetModuleFileNameA(nullptr, exe_path, MAX_PATH); + char* args[3] = { exe_path, (char*)"-verbose", (char*)"-mouse" }; + + DWORD result = emulator_info::start_frontend(*m_options.get(), *m_osd.get(), ARRAY_LENGTH(args), args); + osd_output::pop(&winerror); +} + +// Required for IFrameworkView. +void MameMainApp::Uninitialize() +{ + // Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView + // class is torn down while the app is in the foreground. +} + +IFrameworkView^ MameViewSource::CreateView() +{ + return ref new MameMainApp(); +} + +#endif + + +//============================================================ +// windows_options +//============================================================ + +windows_options::windows_options() +: osd_options() +{ + add_entries(s_option_entries); +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + String^ path = ApplicationData::Current->LocalFolder->Path + L"\\"; + set_default_value(OPTION_INIPATH, (osd::text::from_wstring((LPCWSTR)path->Data()) + ";" + ini_path()).c_str()); + set_default_value(OPTION_CFG_DIRECTORY, (osd::text::from_wstring((LPCWSTR)path->Data()) + cfg_directory()).c_str()); + set_default_value(OPTION_NVRAM_DIRECTORY, (osd::text::from_wstring((LPCWSTR)path->Data()) + nvram_directory()).c_str()); + set_default_value(OPTION_INPUT_DIRECTORY, (osd::text::from_wstring((LPCWSTR)path->Data()) + input_directory()).c_str()); + set_default_value(OPTION_STATE_DIRECTORY, (osd::text::from_wstring((LPCWSTR)path->Data()) + state_directory()).c_str()); + set_default_value(OPTION_SNAPSHOT_DIRECTORY, (osd::text::from_wstring((LPCWSTR)path->Data()) + snapshot_directory()).c_str()); + set_default_value(OPTION_DIFF_DIRECTORY, (osd::text::from_wstring((LPCWSTR)path->Data()) + diff_directory()).c_str()); + set_default_value(OPTION_COMMENT_DIRECTORY, (osd::text::from_wstring((LPCWSTR)path->Data()) + comment_directory()).c_str()); + + set_default_value(OPTION_HOMEPATH, osd::text::from_wstring((LPCWSTR)path->Data()).c_str()); + set_default_value(OPTION_MEDIAPATH, (osd::text::from_wstring((LPCWSTR)path->Data()) + media_path()).c_str()); +#endif +} + + +//============================================================ +// output_oslog +//============================================================ + +void windows_osd_interface::output_oslog(const char *buffer) +{ + if (IsDebuggerPresent()) + win_output_debug_string_utf8(buffer); + else + fputs(buffer, stderr); +} + + +//============================================================ +// constructor +//============================================================ + +windows_osd_interface::windows_osd_interface(windows_options &options) + : osd_common_t(options) + , m_options(options) +{ +} + + +//============================================================ +// destructor +//============================================================ + +windows_osd_interface::~windows_osd_interface() +{ +} + + +//============================================================ +// video_register +//============================================================ + +void windows_osd_interface::video_register() +{ + video_options_add("gdi", nullptr); + video_options_add("d3d", nullptr); +#if USE_OPENGL + video_options_add("opengl", nullptr); +#endif + video_options_add("bgfx", nullptr); + //video_options_add("auto", nullptr); // making d3d video default one +} + +//============================================================ +// init +//============================================================ + +void windows_osd_interface::init(running_machine &machine) +{ + // call our parent + osd_common_t::init(machine); + + const char *stemp; + windows_options &options = downcast<windows_options &>(machine.options()); + + // determine if we are benchmarking, and adjust options appropriately + int bench = options.bench(); + if (bench > 0) + { + options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); + options.set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM); + options.set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM); + options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM); + } + + // determine if we are profiling, and adjust options appropriately + int profile = options.profile(); + if (profile > 0) + { + options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); + options.set_value(OSDOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM); + } + + // thread priority + if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) + SetThreadPriority(GetCurrentThread(), options.priority()); + + // get number of processors + stemp = options.numprocessors(); + + osd_num_processors = 0; + + if (strcmp(stemp, "auto") != 0) + { + osd_num_processors = atoi(stemp); + if (osd_num_processors < 1) + { + osd_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n"); + osd_num_processors = 0; + } + } + + // initialize the subsystems + osd_common_t::init_subsystems(); + + // notify listeners of screen configuration + for (auto info : osd_common_t::s_window_list) + { + machine.output().set_value(string_format("Orientation(%s)", info->monitor()->devicename()).c_str(), std::static_pointer_cast<win_window_info>(info)->m_targetorient); + } + + // hook up the debugger log + if (options.oslog()) + machine.add_logerror_callback(&windows_osd_interface::output_oslog); + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + // crank up the multimedia timer resolution to its max + // this gives the system much finer timeslices + timeresult = timeGetDevCaps(&timecaps, sizeof(timecaps)); + if (timeresult == TIMERR_NOERROR) + timeBeginPeriod(timecaps.wPeriodMin); +#endif + + // create and start the profiler + if (profile > 0) + { + diagnostics_module::get_instance()->start_profiler(1000, profile - 1); + } + + // initialize sockets + win_init_sockets(); + + // note the existence of a machine + g_current_machine = &machine; +} + + +//============================================================ +// osd_exit +//============================================================ + +void windows_osd_interface::osd_exit() +{ + // no longer have a machine + g_current_machine = nullptr; + + // cleanup sockets + win_cleanup_sockets(); + + osd_common_t::osd_exit(); + + // stop the profiler + diagnostics_module::get_instance()->stop_profiler(); + diagnostics_module::get_instance()->print_profiler_results(); + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + // restore the timer resolution + if (timeresult == TIMERR_NOERROR) + timeEndPeriod(timecaps.wPeriodMin); +#endif + + // one last pass at events + winwindow_process_events(machine(), false, false); +} + + +//============================================================ +// osd_setup_osd_specific_emu_options +//============================================================ + +void osd_setup_osd_specific_emu_options(emu_options &opts) +{ + opts.add_entries(osd_options::s_option_entries); + opts.add_entries(windows_options::s_option_entries); +} + + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +//============================================================ +// 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)); +} + +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) diff --git a/docs/release/src/osd/windows/winmain.h b/docs/release/src/osd/windows/winmain.h new file mode 100644 index 00000000000..f6afec3bb2b --- /dev/null +++ b/docs/release/src/osd/windows/winmain.h @@ -0,0 +1,360 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +//============================================================ +// +// winmain.h - Win32 main program and core headers +// +//============================================================ + +#ifndef __WINDOWS_WINMAIN_H__ +#define __WINDOWS_WINMAIN_H__ + +#include <winapifamily.h> +#include "osdepend.h" +#include "modules/lib/osdobj_common.h" + + +//============================================================ +// CONSTANTS +//============================================================ + +// performance options +#define WINOPTION_PRIORITY "priority" +#define WINOPTION_PROFILE "profile" + +// video options +#define WINOPTION_MENU "menu" + +// core post-processing options +#define WINOPTION_HLSLPATH "hlslpath" +#define WINOPTION_HLSL_ENABLE "hlsl_enable" +#define WINOPTION_HLSL_OVERSAMPLING "hlsl_oversampling" +#define WINOPTION_HLSL_WRITE "hlsl_write" +#define WINOPTION_HLSL_SNAP_WIDTH "hlsl_snap_width" +#define WINOPTION_HLSL_SNAP_HEIGHT "hlsl_snap_height" +#define WINOPTION_SHADOW_MASK_TILE_MODE "shadow_mask_tile_mode" +#define WINOPTION_SHADOW_MASK_ALPHA "shadow_mask_alpha" +#define WINOPTION_SHADOW_MASK_TEXTURE "shadow_mask_texture" +#define WINOPTION_SHADOW_MASK_COUNT_X "shadow_mask_x_count" +#define WINOPTION_SHADOW_MASK_COUNT_Y "shadow_mask_y_count" +#define WINOPTION_SHADOW_MASK_USIZE "shadow_mask_usize" +#define WINOPTION_SHADOW_MASK_VSIZE "shadow_mask_vsize" +#define WINOPTION_SHADOW_MASK_UOFFSET "shadow_mask_uoffset" +#define WINOPTION_SHADOW_MASK_VOFFSET "shadow_mask_voffset" +#define WINOPTION_REFLECTION "reflection" +#define WINOPTION_DISTORTION "distortion" +#define WINOPTION_CUBIC_DISTORTION "cubic_distortion" +#define WINOPTION_DISTORT_CORNER "distort_corner" +#define WINOPTION_ROUND_CORNER "round_corner" +#define WINOPTION_SMOOTH_BORDER "smooth_border" +#define WINOPTION_VIGNETTING "vignetting" +#define WINOPTION_SCANLINE_AMOUNT "scanline_alpha" +#define WINOPTION_SCANLINE_SCALE "scanline_size" +#define WINOPTION_SCANLINE_HEIGHT "scanline_height" +#define WINOPTION_SCANLINE_VARIATION "scanline_variation" +#define WINOPTION_SCANLINE_BRIGHT_SCALE "scanline_bright_scale" +#define WINOPTION_SCANLINE_BRIGHT_OFFSET "scanline_bright_offset" +#define WINOPTION_SCANLINE_JITTER "scanline_jitter" +#define WINOPTION_HUM_BAR_ALPHA "hum_bar_alpha" +#define WINOPTION_DEFOCUS "defocus" +#define WINOPTION_CONVERGE_X "converge_x" +#define WINOPTION_CONVERGE_Y "converge_y" +#define WINOPTION_RADIAL_CONVERGE_X "radial_converge_x" +#define WINOPTION_RADIAL_CONVERGE_Y "radial_converge_y" +#define WINOPTION_RED_RATIO "red_ratio" +#define WINOPTION_GRN_RATIO "grn_ratio" +#define WINOPTION_BLU_RATIO "blu_ratio" +#define WINOPTION_OFFSET "offset" +#define WINOPTION_SCALE "scale" +#define WINOPTION_POWER "power" +#define WINOPTION_FLOOR "floor" +#define WINOPTION_PHOSPHOR "phosphor_life" +#define WINOPTION_SATURATION "saturation" +#define WINOPTION_CHROMA_MODE "chroma_mode" +#define WINOPTION_CHROMA_CONVERSION_GAIN "chroma_conversion_gain" +#define WINOPTION_CHROMA_A "chroma_a" +#define WINOPTION_CHROMA_B "chroma_b" +#define WINOPTION_CHROMA_C "chroma_c" +#define WINOPTION_CHROMA_Y_GAIN "chroma_y_gain" +#define WINOPTION_YIQ_ENABLE "yiq_enable" +#define WINOPTION_YIQ_JITTER "yiq_jitter" +#define WINOPTION_YIQ_CCVALUE "yiq_cc" +#define WINOPTION_YIQ_AVALUE "yiq_a" +#define WINOPTION_YIQ_BVALUE "yiq_b" +#define WINOPTION_YIQ_OVALUE "yiq_o" +#define WINOPTION_YIQ_PVALUE "yiq_p" +#define WINOPTION_YIQ_NVALUE "yiq_n" +#define WINOPTION_YIQ_YVALUE "yiq_y" +#define WINOPTION_YIQ_IVALUE "yiq_i" +#define WINOPTION_YIQ_QVALUE "yiq_q" +#define WINOPTION_YIQ_SCAN_TIME "yiq_scan_time" +#define WINOPTION_YIQ_PHASE_COUNT "yiq_phase_count" +#define WINOPTION_VECTOR_BEAM_SMOOTH "vector_beam_smooth" +#define WINOPTION_VECTOR_LENGTH_SCALE "vector_length_scale" +#define WINOPTION_VECTOR_LENGTH_RATIO "vector_length_ratio" +#define WINOPTION_BLOOM_BLEND_MODE "bloom_blend_mode" +#define WINOPTION_BLOOM_SCALE "bloom_scale" +#define WINOPTION_BLOOM_OVERDRIVE "bloom_overdrive" +#define WINOPTION_BLOOM_LEVEL0_WEIGHT "bloom_lvl0_weight" +#define WINOPTION_BLOOM_LEVEL1_WEIGHT "bloom_lvl1_weight" +#define WINOPTION_BLOOM_LEVEL2_WEIGHT "bloom_lvl2_weight" +#define WINOPTION_BLOOM_LEVEL3_WEIGHT "bloom_lvl3_weight" +#define WINOPTION_BLOOM_LEVEL4_WEIGHT "bloom_lvl4_weight" +#define WINOPTION_BLOOM_LEVEL5_WEIGHT "bloom_lvl5_weight" +#define WINOPTION_BLOOM_LEVEL6_WEIGHT "bloom_lvl6_weight" +#define WINOPTION_BLOOM_LEVEL7_WEIGHT "bloom_lvl7_weight" +#define WINOPTION_BLOOM_LEVEL8_WEIGHT "bloom_lvl8_weight" +#define WINOPTION_LUT_TEXTURE "lut_texture" +#define WINOPTION_LUT_ENABLE "lut_enable" +#define WINOPTION_UI_LUT_TEXTURE "ui_lut_texture" +#define WINOPTION_UI_LUT_ENABLE "ui_lut_enable" + +// full screen options +#define WINOPTION_TRIPLEBUFFER "triplebuffer" +#define WINOPTION_FULLSCREENBRIGHTNESS "full_screen_brightness" +#define WINOPTION_FULLSCREENCONTRAST "full_screen_contrast" +#define WINOPTION_FULLSCREENGAMMA "full_screen_gamma" + +// input options +#define WINOPTION_GLOBAL_INPUTS "global_inputs" +#define WINOPTION_DUAL_LIGHTGUN "dual_lightgun" + +//============================================================ +// TYPE DEFINITIONS +//============================================================ + +class windows_options : public osd_options +{ +public: + // construction/destruction + windows_options(); + + // performance options + int priority() const { return int_value(WINOPTION_PRIORITY); } + int profile() const { return int_value(WINOPTION_PROFILE); } + + // video options + bool menu() const { return bool_value(WINOPTION_MENU); } + + // core post-processing options + const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); } + bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); } + bool d3d_hlsl_oversampling() const { return bool_value(WINOPTION_HLSL_OVERSAMPLING); } + const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); } + int d3d_snap_width() const { return int_value(WINOPTION_HLSL_SNAP_WIDTH); } + int d3d_snap_height() const { return int_value(WINOPTION_HLSL_SNAP_HEIGHT); } + int screen_shadow_mask_tile_mode() const { return int_value(WINOPTION_SHADOW_MASK_TILE_MODE); } + float screen_shadow_mask_alpha() const { return float_value(WINOPTION_SHADOW_MASK_ALPHA); } + const char *screen_shadow_mask_texture() const { return value(WINOPTION_SHADOW_MASK_TEXTURE); } + int screen_shadow_mask_count_x() const { return int_value(WINOPTION_SHADOW_MASK_COUNT_X); } + int screen_shadow_mask_count_y() const { return int_value(WINOPTION_SHADOW_MASK_COUNT_Y); } + float screen_shadow_mask_u_size() const { return float_value(WINOPTION_SHADOW_MASK_USIZE); } + float screen_shadow_mask_v_size() const { return float_value(WINOPTION_SHADOW_MASK_VSIZE); } + float screen_shadow_mask_u_offset() const { return float_value(WINOPTION_SHADOW_MASK_UOFFSET); } + float screen_shadow_mask_v_offset() const { return float_value(WINOPTION_SHADOW_MASK_VOFFSET); } + float screen_scanline_amount() const { return float_value(WINOPTION_SCANLINE_AMOUNT); } + float screen_scanline_scale() const { return float_value(WINOPTION_SCANLINE_SCALE); } + float screen_scanline_height() const { return float_value(WINOPTION_SCANLINE_HEIGHT); } + float screen_scanline_variation() const { return float_value(WINOPTION_SCANLINE_VARIATION); } + float screen_scanline_bright_scale() const { return float_value(WINOPTION_SCANLINE_BRIGHT_SCALE); } + float screen_scanline_bright_offset() const { return float_value(WINOPTION_SCANLINE_BRIGHT_OFFSET); } + float screen_scanline_jitter() const { return float_value(WINOPTION_SCANLINE_JITTER); } + float screen_hum_bar_alpha() const { return float_value(WINOPTION_HUM_BAR_ALPHA); } + float screen_reflection() const { return float_value(WINOPTION_REFLECTION); } + float screen_distortion() const { return float_value(WINOPTION_DISTORTION); } + float screen_cubic_distortion() const { return float_value(WINOPTION_CUBIC_DISTORTION); } + float screen_distort_corner() const { return float_value(WINOPTION_DISTORT_CORNER); } + float screen_round_corner() const { return float_value(WINOPTION_ROUND_CORNER); } + float screen_smooth_border() const { return float_value(WINOPTION_SMOOTH_BORDER); } + float screen_vignetting() const { return float_value(WINOPTION_VIGNETTING); } + const char *screen_defocus() const { return value(WINOPTION_DEFOCUS); } + const char *screen_converge_x() const { return value(WINOPTION_CONVERGE_X); } + const char *screen_converge_y() const { return value(WINOPTION_CONVERGE_Y); } + const char *screen_radial_converge_x() const { return value(WINOPTION_RADIAL_CONVERGE_X); } + const char *screen_radial_converge_y() const { return value(WINOPTION_RADIAL_CONVERGE_Y); } + const char *screen_red_ratio() const { return value(WINOPTION_RED_RATIO); } + const char *screen_grn_ratio() const { return value(WINOPTION_GRN_RATIO); } + const char *screen_blu_ratio() const { return value(WINOPTION_BLU_RATIO); } + bool screen_yiq_enable() const { return bool_value(WINOPTION_YIQ_ENABLE); } + float screen_yiq_jitter() const { return float_value(WINOPTION_YIQ_JITTER); } + float screen_yiq_cc() const { return float_value(WINOPTION_YIQ_CCVALUE); } + float screen_yiq_a() const { return float_value(WINOPTION_YIQ_AVALUE); } + float screen_yiq_b() const { return float_value(WINOPTION_YIQ_BVALUE); } + float screen_yiq_o() const { return float_value(WINOPTION_YIQ_OVALUE); } + float screen_yiq_p() const { return float_value(WINOPTION_YIQ_PVALUE); } + float screen_yiq_n() const { return float_value(WINOPTION_YIQ_NVALUE); } + float screen_yiq_y() const { return float_value(WINOPTION_YIQ_YVALUE); } + float screen_yiq_i() const { return float_value(WINOPTION_YIQ_IVALUE); } + float screen_yiq_q() const { return float_value(WINOPTION_YIQ_QVALUE); } + float screen_yiq_scan_time() const { return float_value(WINOPTION_YIQ_SCAN_TIME); } + int screen_yiq_phase_count() const { return int_value(WINOPTION_YIQ_PHASE_COUNT); } + float screen_vector_beam_smooth() const { return float_value(WINOPTION_VECTOR_BEAM_SMOOTH); } + float screen_vector_length_scale() const { return float_value(WINOPTION_VECTOR_LENGTH_SCALE); } + float screen_vector_length_ratio() const { return float_value(WINOPTION_VECTOR_LENGTH_RATIO); } + int screen_bloom_blend_mode() const { return int_value(WINOPTION_BLOOM_BLEND_MODE); } + float screen_bloom_scale() const { return float_value(WINOPTION_BLOOM_SCALE); } + const char *screen_bloom_overdrive() const { return value(WINOPTION_BLOOM_OVERDRIVE); } + float screen_bloom_lvl0_weight() const { return float_value(WINOPTION_BLOOM_LEVEL0_WEIGHT); } + float screen_bloom_lvl1_weight() const { return float_value(WINOPTION_BLOOM_LEVEL1_WEIGHT); } + float screen_bloom_lvl2_weight() const { return float_value(WINOPTION_BLOOM_LEVEL2_WEIGHT); } + float screen_bloom_lvl3_weight() const { return float_value(WINOPTION_BLOOM_LEVEL3_WEIGHT); } + float screen_bloom_lvl4_weight() const { return float_value(WINOPTION_BLOOM_LEVEL4_WEIGHT); } + float screen_bloom_lvl5_weight() const { return float_value(WINOPTION_BLOOM_LEVEL5_WEIGHT); } + float screen_bloom_lvl6_weight() const { return float_value(WINOPTION_BLOOM_LEVEL6_WEIGHT); } + float screen_bloom_lvl7_weight() const { return float_value(WINOPTION_BLOOM_LEVEL7_WEIGHT); } + float screen_bloom_lvl8_weight() const { return float_value(WINOPTION_BLOOM_LEVEL8_WEIGHT); } + const char *screen_offset() const { return value(WINOPTION_OFFSET); } + const char *screen_scale() const { return value(WINOPTION_SCALE); } + const char *screen_power() const { return value(WINOPTION_POWER); } + const char *screen_floor() const { return value(WINOPTION_FLOOR); } + const char *screen_phosphor() const { return value(WINOPTION_PHOSPHOR); } + float screen_saturation() const { return float_value(WINOPTION_SATURATION); } + int screen_chroma_mode() const { return int_value(WINOPTION_CHROMA_MODE); } + const char *screen_chroma_a() const { return value(WINOPTION_CHROMA_A); } + const char *screen_chroma_b() const { return value(WINOPTION_CHROMA_B); } + const char *screen_chroma_c() const { return value(WINOPTION_CHROMA_C); } + const char *screen_chroma_conversion_gain() const { return value(WINOPTION_CHROMA_CONVERSION_GAIN); } + const char *screen_chroma_y_gain() const { return value(WINOPTION_CHROMA_Y_GAIN); } + const char *screen_lut_texture() const { return value(WINOPTION_LUT_TEXTURE); } + bool screen_lut_enable() const { return bool_value(WINOPTION_LUT_ENABLE); } + const char *ui_lut_texture() const { return value(WINOPTION_UI_LUT_TEXTURE); } + bool ui_lut_enable() const { return bool_value(WINOPTION_UI_LUT_ENABLE); } + + // full screen options + bool triple_buffer() const { return bool_value(WINOPTION_TRIPLEBUFFER); } + float full_screen_brightness() const { return float_value(WINOPTION_FULLSCREENBRIGHTNESS); } + float full_screen_contrast() const { return float_value(WINOPTION_FULLSCREENCONTRAST); } + float full_screen_gamma() const { return float_value(WINOPTION_FULLSCREENGAMMA); } + + // input options + bool global_inputs() const { return bool_value(WINOPTION_GLOBAL_INPUTS); } + bool dual_lightgun() const { return bool_value(WINOPTION_DUAL_LIGHTGUN); } + + static const options_entry s_option_entries[]; +}; + +//============================================================ +// TYPE DEFINITIONS +//============================================================ + +enum input_event +{ + INPUT_EVENT_KEYDOWN, + INPUT_EVENT_KEYUP, + INPUT_EVENT_RAWINPUT, + INPUT_EVENT_MOUSE_BUTTON +}; + +struct KeyPressEventArgs +{ + input_event event_id; + uint8_t vkey; + uint8_t scancode; +}; + +struct MouseButtonEventArgs +{ + int button; + int keydown; + int xpos; + int ypos; +}; + +// Forward declarations +struct _EXCEPTION_POINTERS; + +class windows_osd_interface : public osd_common_t +{ +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + // Access to exception filter static method + friend int main(int argc, char *argv[]); + friend int main_(int argc, char *argv[]); //HBMAME +#endif + +public: + // construction/destruction + windows_osd_interface(windows_options &options); + virtual ~windows_osd_interface(); + + // general overridables + virtual void init(running_machine &machine) override; + virtual void update(bool skip_redraw) override; + + // input overrideables + virtual void customize_input_type_list(simple_list<input_type_entry> &typelist) override; + + // video overridables + virtual void add_audio_to_recording(const int16_t *buffer, int samples_this_frame) override; + + virtual void video_register() override; + + virtual bool video_init() override; + virtual bool window_init() override; + + virtual void video_exit() override; + virtual void window_exit() override; + + void extract_video_config(); + + // windows osd specific + bool handle_input_event(input_event eventid, void *eventdata) const; + bool should_hide_mouse() const; + void poll_input(running_machine &machine) const; + + virtual windows_options &options() override { return m_options; } + + int window_count(); + +protected: + virtual void build_slider_list() override; + virtual void update_slider_list() override; + + void check_osd_inputs(); + +private: + virtual void osd_exit() override; + static void output_oslog(const char *buffer); + + windows_options & m_options; + + static const int DEFAULT_FONT_HEIGHT = 200; +}; + +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +ref class MameMainApp sealed : public Windows::ApplicationModel::Core::IFrameworkView +{ +private: + std::unique_ptr<windows_options> m_options; + std::unique_ptr<windows_osd_interface> m_osd; + +public: + MameMainApp(); + + // IFrameworkView Methods. + virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); + virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); + virtual void Load(Platform::String^ entryPoint); + virtual void Run(); + virtual void Uninitialize(); +}; + +ref class MameViewSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource +{ +public: + virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView(); +}; + +#endif + +//============================================================ +// GLOBAL VARIABLES +//============================================================ + +extern const options_entry mame_win_options[]; + +// defined in winwork.c +extern int osd_num_processors; + + +#endif |