static void Main() { Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Trace.WriteLine(string.Format("Environment.OSVersion.Platform: {0}", Environment.OSVersion.Platform)); Trace.WriteLine(string.Format("Environment.OSVersion.VersionString: {0}", Environment.OSVersion.VersionString)); Trace.WriteLine(string.Format("RuntimeInformation.FrameworkDescription: {0}", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription)); Form1 form = new Form1(); osdcore_WinForms osdcore = new osdcore_WinForms(); osd_file_WinForms osdfile = new osd_file_WinForms(); osd_directory_static_WinForms osddirectory = new osd_directory_static_WinForms(); osd_options_WinForms options = new osd_options_WinForms(); osd_interface_WinForms osd = new osd_interface_WinForms(options); osd.register_options(); cli_frontend frontend = new cli_frontend(options, osd); // to jump to a specific game on startup //string gamename = "___empty"; //string gamename = "puckman"; //string gamename = "pacman"; //string gamename = "mspacman"; //string gamename = "pacplus"; //string gamename = "galaga"; //string gamename = "xevious"; //string gamename = "digdug"; //string gamename = "1942"; //string gamename = "paperboy"; //options.set_value(emu_options.OPTION_SYSTEMNAME, gamename, g.OPTION_PRIORITY_MAXIMUM); osdcore_global.set_osdcore(osdcore); osdfile_global.set_osdfile(osdfile); osdfile_global.set_osddirectory(osddirectory); mame_machine_manager.instance(options, osd); new Thread(() => { Thread.CurrentThread.IsBackground = true; Thread.CurrentThread.Name = "machine_manager.execute()"; int ret = frontend.execute(new std.vector <string>(Environment.GetCommandLineArgs())); // tell form that it should close form.Invoke((MethodInvoker) delegate { form.Close(); }); }).Start(); Application.Run(form); mame_machine_manager.close_instance(); osd.Dispose(); }
/*----------------------------------------------------------------------------- * osd_close: close an open file * * Parameters: * * file - handle to a file previously opened via osd_open * * Return value: * * a file_error describing any error that occurred while closing * the file, or FILERR_NONE if no error occurred * -----------------------------------------------------------------------------*/ public std.error_condition osd_close(ref osd_file file) { throw new emu_fatalerror("Fix inheritence"); osd_file_WinForms fileWinForms = (osd_file_WinForms)file; if (fileWinForms.m_file != null) { fileWinForms.m_file.Close(); } file = null; return(new std.error_condition()); }
/*----------------------------------------------------------------------------- * osd_open: open a new file. * * Parameters: * * path - path to the file to open * * openflags - some combination of: * * OPEN_FLAG_READ - open the file for read access * OPEN_FLAG_WRITE - open the file for write access * OPEN_FLAG_CREATE - create/truncate the file when opening * OPEN_FLAG_CREATE_PATHS - specifies that non-existant paths * should be created if necessary * * file - pointer to an osd_file * to receive the newly-opened file * handle; this is only valid if the function returns FILERR_NONE * * filesize - pointer to a UINT64 to receive the size of the opened * file; this is only valid if the function returns FILERR_NONE * * Return value: * * a file_error describing any error that occurred while opening * the file, or FILERR_NONE if no error occurred * * Notes: * * This function is called by core_fopen and several other places in * the core to access files. These functions will construct paths by * concatenating various search paths held in the options.c options * database with partial paths specified by the core. The core assumes * that the path separator is the first character of the string * PATH_SEPARATOR, but does not interpret any path separators in the * search paths, so if you use a different path separator in a search * path, you may get a mixture of PATH_SEPARATORs (from the core) and * alternate path separators (specified by users and placed into the * options database). * -----------------------------------------------------------------------------*/ public std.error_condition osd_open(string path, UInt32 openflags, out osd_file file, out UInt64 filesize) { throw new emu_fatalerror("Fix inheritence"); osd_file_WinForms fileWinForms = new osd_file_WinForms(); file = fileWinForms; try { fileWinForms.m_file = File.OpenRead(path); } catch (Exception) { filesize = 0; return(std.errc.no_such_file_or_directory); } filesize = (UInt64)fileWinForms.m_file.Length; return(new std.error_condition()); }
/*----------------------------------------------------------------------------- * osd_read: read from an open file * * Parameters: * * file - handle to a file previously opened via osd_open * * buffer - pointer to memory that will receive the data read * * offset - offset within the file to read from * * length - number of bytes to read from the file * * actual - pointer to a UINT32 to receive the number of bytes actually * read during the operation; valid only if the function returns * FILERR_NONE * * Return value: * * a file_error describing any error that occurred while reading * from the file, or FILERR_NONE if no error occurred * -----------------------------------------------------------------------------*/ public std.error_condition osd_read(osd_file file, Pointer <byte> buffer, UInt64 offset, UInt32 length, out UInt32 actual) { throw new emu_fatalerror("Fix inheritence"); osd_file_WinForms fileWinForms = (osd_file_WinForms)file; fileWinForms.m_file.Position = 0; // read until we get to the correct offset (HACK) while (offset-- > 0) { fileWinForms.m_file.ReadByte(); } // read one byte at a time (HACK) for (UInt32 i = 0; i < length; i++) { buffer[i] = (byte)fileWinForms.m_file.ReadByte(); } actual = length; return(new std.error_condition()); }