]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/app.cpp
Fixed software loading to load independently of Jaguar ROM space, added new
[virtualjaguar] / src / gui / app.cpp
1 //
2 // app.cpp - Qt-based GUI for Virtual Jaguar
3 //
4 // by James L. Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -------------------------------------------------------------
11 // JLH  12/23/2009  Created this file
12 // JLH  01/21/2011  Added SDL initialization
13 // JLH  06/26/2011  Added fix to keep SDL from hijacking main() on win32
14 //
15
16 #include "app.h"
17
18 #include <SDL.h>
19 #include <QApplication>
20 #include "log.h"
21 #include "mainwin.h"
22 #include "settings.h"
23 #include "types.h"
24
25 #ifdef __GCCWIN32__
26 // Apparently on win32, SDL is hijacking main from Qt. So let's do this:
27 #undef main
28 #endif
29
30 // Here's the main application loop--short and simple...
31 int main(int argc, char * argv[])
32 {
33         // Normally, this would be read in from the settings module... :-P
34         vjs.hardwareTypeAlpine = false;
35
36         if (argc > 1)
37         {
38                 if ((strcmp(argv[1], "--help") == 0) || (strcmp(argv[1], "-h") == 0)
39                         || (strcmp(argv[1], "-?") == 0))
40                 {
41                         printf("Virtual Jaguar 2.0.0 help\n");
42                         printf("\n");
43                         printf("Command line interface is non-functional ATM, but may return if there is\n"
44                                 "enough demand for it. :-)\n");
45                         return 0;
46                 }
47                 if ((strcmp(argv[1], "--alpine") == 0) || (strcmp(argv[1], "-a") == 0))
48                 {
49                         printf("Alpine Mode enabled.\n");
50                         vjs.hardwareTypeAlpine = true;
51                 }
52         }
53
54         Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename
55 //or is it the .qrc filename???
56         // This is so we can pass this stuff using signal/slot mechanism...
57 //ick   int id = qRegisterMetaType<uint32>();
58
59         LogInit("virtualjaguar.log");                           // Init logfile
60         int retVal = -1;                                                        // Default is failure
61
62         // Set up SDL library
63         if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
64         {
65                 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
66         }
67         else
68         {
69                 WriteLog("VJ: SDL (joystick, audio) successfully initialized.\n");
70                 App app(argc, argv);                                    // Declare an instance of the application
71                 retVal = app.exec();                                    // And run it!
72
73                 // Free SDL components last...!
74                 SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO);
75                 SDL_Quit();
76         }
77
78         LogDone();                                                                      // Close logfile
79         return retVal;
80 }
81
82 // Main app constructor--we stick globally accessible stuff here...
83
84 App::App(int argc, char * argv[]): QApplication(argc, argv)
85 {
86         mainWindow = new MainWin();
87         mainWindow->show();
88 }