2 // Virtual Jaguar Emulator
4 // Original codebase by David Raingeard (Cal2)
5 // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
6 // Cleanups/fixes/enhancements by James L. Hammons and Adam Green
14 #include "sdlemu_opengl.h"
15 #include "settings.h" // Pull in "vjs" struct
21 // Uncomment this to use built-in BIOS/CD-ROM BIOS
22 // You'll need a copy of jagboot.h & jagcd.h for this to work...!
23 //#define USE_BUILT_IN_BIOS
25 #ifdef USE_BUILT_IN_BIOS
30 // Private function prototypes
33 // The main emulator loop (what else?)
35 //Maybe we should move the video stuff to TOM? Makes more sense to put it there...
36 //Actually, it would probably be better served in VIDEO.CPP... !!! FIX !!! [DONE]
37 //uint32 totalFrames;//temp, so we can grab this from elsewhere...
38 int main(int argc, char * argv[])
40 //NOTE: This isn't actually used anywhere... !!! FIX !!!
41 int32 nFrameskip = 0; // Default: Show every frame
43 printf("Virtual Jaguar GCC/SDL Portable Jaguar Emulator v1.1.0\n");
44 printf("Based upon Virtual Jaguar core v1.0.0 by David Raingeard.\n");
45 printf("Written by Niels Wagenaar (Linux/WIN32), Carwin Jones (BeOS),\n");
46 printf("James L. Hammons (WIN32) and Adam Green (MacOS)\n");
47 printf("Contact: http://sdlemu.ngemu.com/ | sdlemu@ngemu.com\n");
49 bool haveCart = false; // Assume there is no cartridge...!
52 LoadVJSettings(); // Get config file settings...
54 // Check the switches... ;-)
55 // NOTE: Command line switches can override any config file settings, thus the
56 // proliferation of the noXXX switches. ;-)
58 for(int i=1; i<argc || argv[i]!=NULL; i++)
60 // This would be the most likely place to do the cart loading...
61 if (argv[i][0] != '-')
62 haveCart = true; // It looks like we have a cartridge!
64 if (!strcmp(argv[i], "-joystick"))
65 vjs.useJoystick = true;
67 if (!strcmp(argv[i], "-joyport"))
69 vjs.joyport = atoi(argv[++i]) + 1;
74 if (!strcmp(argv[i], "-frameskip"))
76 nFrameskip = atoi(argv[++i]) + 1;
81 if (!strcmp(argv[i], "-bios"))
82 vjs.useJaguarBIOS = true;
84 if (!strcmp(argv[i], "-nobios"))
85 vjs.useJaguarBIOS = false;
87 if (!strcmp(argv[i], "-dsp"))
88 vjs.DSPEnabled = true;
90 if (!strcmp(argv[i], "-nodsp"))
91 vjs.DSPEnabled = false;
93 if (!strcmp(argv[i], "-pipeline"))
94 vjs.usePipelinedDSP = true;
96 if (!strcmp(argv[i], "-nopipeline"))
97 vjs.usePipelinedDSP = false;
99 if (!strcmp(argv[i], "-gl"))
100 vjs.useOpenGL = true;
102 if (!strcmp(argv[i], "-nogl"))
103 vjs.useOpenGL = false;
105 if (!strcmp(argv[i], "-fullscreen"))
106 vjs.fullscreen = true;
108 if (!strcmp(argv[i], "-window"))
109 vjs.fullscreen = false;
111 if (!strcmp(argv[i], "-pal"))
112 vjs.hardwareTypeNTSC = false;
114 if (!strcmp(argv[i], "-ntsc"))
115 vjs.hardwareTypeNTSC = true;
117 if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-?"))
119 printf("Usage: \n\n");
120 printf("vj [romfile] [switches]\n");
121 printf(" -? or --help : Display usage and switches \n");
122 printf(" -frameskip 1-10 : Enable frameskip 1 - 10 (default: none) \n");
123 printf(" -joystick : Enable joystick/gamepad \n");
124 printf(" -joyport 0-3 : Select desired joystick port \n");
125 printf(" -bios : Boot cart using Jaguar BIOS ROM \n");
126 printf(" -nobios : Boot cart without using Jaguar BIOS ROM \n");
127 printf(" -dsp : Force VJ to use the DSP \n");
128 printf(" -nodsp : Force VJ to run without the DSP \n");
129 printf(" -pipeline : Use the DSP pipelined core \n");
130 printf(" -nopipeline : Use the DSP non-pipelined core \n");
131 printf(" -gl : Use OpenGL rendering \n");
132 printf(" -nogl : Use old non-OpenGL rendering \n");
133 printf(" -fullscreen : Enable fullscreen mode (default: windowed)\n");
134 printf(" -window : Enable windowed mode \n");
135 printf(" -pal : Force VJ to PAL mode (default: NTSC) \n");
136 printf(" -ntsc : Force VJ to NTSC mode \n");
137 printf("\nInvoking Virtual Jagaur with no ROM file will cause it to boot up\n");
138 printf("with the VJ GUI.\n");
143 // Set up SDL library
144 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
146 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
150 WriteLog("VJ: SDL successfully initialized.\n");
152 WriteLog("Initializing memory subsystem...\n");
154 WriteLog("Initializing version...\n");
156 version_display(log_get());
157 WriteLog("Initializing jaguar subsystem...\n");
161 #ifdef USE_BUILT_IN_BIOS
162 WriteLog("VJ: Using built in BIOS/CD BIOS...\n");
163 memcpy(jaguar_bootRom, jagBootROM, 0x20000);
164 memcpy(jaguar_CDBootROM, jagCDROM, 0x40000);
165 BIOSLoaded = CDBIOSLoaded = true;
167 // What would be nice here would be a way to check if the BIOS was loaded so that we
168 // could disable the pushbutton on the Misc Options menu... !!! FIX !!! [DONE here, but needs to be fixed in GUI as well!]
169 WriteLog("About to attempt to load BIOSes...\n");
170 BIOSLoaded = (JaguarLoadROM(jaguar_bootRom, vjs.jagBootPath) == 0x20000 ? true : false);
171 WriteLog("VJ: BIOS is %savailable...\n", (BIOSLoaded ? "" : "not "));
172 CDBIOSLoaded = (JaguarLoadROM(jaguar_CDBootROM, vjs.CDBootPath) == 0x40000 ? true : false);
173 WriteLog("VJ: CD BIOS is %savailable...\n", (CDBIOSLoaded ? "" : "not "));
176 SET32(jaguar_mainRam, 0, 0x00200000); // Set top of stack...
178 WriteLog("Initializing video subsystem...\n");
180 WriteLog("Initializing GUI subsystem...\n");
183 // Now with crunchy GUI goodness!
184 WriteLog("About to start GUI...\n");
185 GUIMain(haveCart ? argv[1] : NULL);
187 //This is no longer accurate...!
188 // int elapsedTime = clock() - startTime;
189 // int fps = (1000 * totalFrames) / elapsedTime;
190 // WriteLog("VJ: Ran at an average of %i FPS.\n", fps);
198 // Free SDL components last...!
199 SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER);