+ if (_fileno(stdout) == -1)
+ freopen("CONOUT$","wb",stdout);
+ if (_fileno(stderr) == -1)
+ freopen("CONOUT$","wb",stderr);
+ if (_fileno(stdin) == -1)
+ freopen("CONIN$","rb",stdin);
+
+ // Fix C++
+ std::ios::sync_with_stdio();
+ }
+#endif
+
+ // Normally, this would be read in from the settings module... :-P
+ vjs.hardwareTypeAlpine = false;
+ // This is stuff we pass into the mainWindow...
+// noUntunedTankPlease = false;
+
+ // Check for options that must be in place be constructing the App object
+ if (!ParseCommandLine(argc, argv))
+ {
+ return 0;
+ }
+
+ Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename
+//or is it the .qrc filename???
+ // This is so we can pass this stuff using signal/slot mechanism...
+//this is left here to remind me not to try doing this again :-P
+//ick int id = qRegisterMetaType<uint32>();
+
+ int retVal = -1; // Default is failure
+
+ if (useLogfile)
+ {
+ bool success = (bool)LogInit("./virtualjaguar.log"); // Init logfile
+
+ if (!success)
+ printf("Failed to open virtualjaguar.log for writing!\n");
+ }
+
+ // Set up SDL library
+ if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
+ {
+ WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
+ }
+ else
+ {
+ WriteLog("VJ: SDL (joystick, audio) successfully initialized.\n");
+ App app(argc, argv); // Declare an instance of the application
+ Gamepad::AllocateJoysticks();
+ retVal = app.exec(); // And run it!
+ Gamepad::DeallocateJoysticks();
+
+ // Free SDL components last...!
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO);
+ SDL_Quit();
+ }
+
+#ifdef __GCCWIN32__
+#if 0
+ fclose(ctt);
+#endif
+#endif
+ LogDone(); // Close logfile
+ return retVal;
+}
+
+//
+// Main app constructor--we stick globally accessible stuff here... (?)
+//
+App::App(int & argc, char * argv[]): QApplication(argc, argv)
+{
+ bool loadAndGo = !filename.isEmpty();
+
+ mainWindow = new MainWin(loadAndGo);
+ mainWindow->plzDontKillMyComputer = noUntunedTankPlease;
+ ParseOptions(argc, argv); // Override defaults with command line (if any)
+ mainWindow->SyncUI();
+
+ if (loadAndGo)
+ mainWindow->LoadFile(filename);
+
+ mainWindow->show();
+}
+
+
+//
+// Here we parse out stuff that needs to be looked at *before* we construct the
+// App object.
+//
+bool ParseCommandLine(int argc, char * argv[])
+{
+ for(int i=1; i<argc; i++)
+ {
+ if ((strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "-h") == 0)
+ || (strcmp(argv[i], "-?") == 0))