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
16 #include "sdlemu_opengl.h"
17 #include "settings.h" // Pull in "vjs" struct
20 // Uncomment this to use built-in BIOS/CD-ROM BIOS
21 // You'll need a copy of jagboot.h & jagcd.h for this to work...!
22 //#define USE_BUILT_IN_BIOS
24 // Uncomment this for an official Virtual Jaguar release
25 //#define VJ_RELEASE_VERSION "1.1.0"
26 #warning !!! FIX !!! Figure out how to use this in GUI.CPP as well!
28 #ifdef USE_BUILT_IN_BIOS
34 // Private function prototypes
37 // The main emulator loop (what else?)
39 //Maybe we should move the video stuff to TOM? Makes more sense to put it there...
40 //Actually, it would probably be better served in VIDEO.CPP... !!! FIX !!! [DONE]
41 //uint32 totalFrames;//temp, so we can grab this from elsewhere...
42 int main_old(int argc, char * argv[])
44 //NOTE: This isn't actually used anywhere... !!! FIX !!!
45 int32 nFrameskip = 0; // Default: Show every frame
47 #ifdef VJ_RELEASE_VERSION
48 printf("Virtual Jaguar GCC/SDL Portable Jaguar Emulator v%s\n", VJ_RELEASE_VERSION);
50 printf("Virtual Jaguar GCC/SDL Portable Jaguar Emulator SVN %s\n", __DATE__);
52 printf("Based upon Virtual Jaguar core v1.0.0 by David Raingeard.\n");
53 printf("Written by Niels Wagenaar (Linux/WIN32), Carwin Jones (BeOS),\n");
54 printf("James L. Hammons (WIN32) and Adam Green (MacOS)\n");
55 printf("Contact: http://sdlemu.ngemu.com/ | sdlemu@ngemu.com\n");
57 bool haveCart = false; // Assume there is no cartridge...!
60 LoadVJSettings(); // Get config file settings...
62 // Check the switches... ;-)
63 // NOTE: Command line switches can override any config file settings, thus the
64 // proliferation of the noXXX switches. ;-)
66 for(int i=1; i<argc || argv[i]!=NULL; i++)
68 // This would be the most likely place to do the cart loading...
69 if (argv[i][0] != '-')
70 haveCart = true; // It looks like we have a cartridge!
72 if (!strcmp(argv[i], "-joystick"))
73 vjs.useJoystick = true;
75 if (!strcmp(argv[i], "-joyport"))
77 vjs.joyport = atoi(argv[++i]) + 1;
82 if (!strcmp(argv[i], "-frameskip"))
84 nFrameskip = atoi(argv[++i]) + 1;
89 if (!strcmp(argv[i], "-bios"))
90 vjs.useJaguarBIOS = true;
92 if (!strcmp(argv[i], "-nobios"))
93 vjs.useJaguarBIOS = false;
95 if (!strcmp(argv[i], "-dsp"))
96 vjs.DSPEnabled = true;
98 if (!strcmp(argv[i], "-nodsp"))
99 vjs.DSPEnabled = false;
101 if (!strcmp(argv[i], "-pipeline"))
102 vjs.usePipelinedDSP = true;
104 if (!strcmp(argv[i], "-nopipeline"))
105 vjs.usePipelinedDSP = false;
107 if (!strcmp(argv[i], "-gl"))
108 vjs.useOpenGL = true;
110 if (!strcmp(argv[i], "-nogl"))
111 vjs.useOpenGL = false;
113 if (!strcmp(argv[i], "-fullscreen"))
114 vjs.fullscreen = true;
116 if (!strcmp(argv[i], "-window"))
117 vjs.fullscreen = false;
119 if (!strcmp(argv[i], "-pal"))
120 vjs.hardwareTypeNTSC = false;
122 if (!strcmp(argv[i], "-ntsc"))
123 vjs.hardwareTypeNTSC = true;
125 if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-?"))
127 printf("Usage: \n\n");
128 printf("vj [romfile] [switches]\n");
129 printf(" -? or --help : Display usage and switches \n");
130 printf(" -frameskip 1-10 : Enable frameskip 1 - 10 (default: none) \n");
131 printf(" -joystick : Enable joystick/gamepad \n");
132 printf(" -joyport 0-3 : Select desired joystick port \n");
133 printf(" -bios : Boot cart using Jaguar BIOS ROM \n");
134 printf(" -nobios : Boot cart without using Jaguar BIOS ROM \n");
135 printf(" -dsp : Force VJ to use the DSP \n");
136 printf(" -nodsp : Force VJ to run without the DSP \n");
137 printf(" -pipeline : Use the DSP pipelined core \n");
138 printf(" -nopipeline : Use the DSP non-pipelined core \n");
139 printf(" -gl : Use OpenGL rendering \n");
140 printf(" -nogl : Use old non-OpenGL rendering \n");
141 printf(" -fullscreen : Enable fullscreen mode (default: windowed)\n");
142 printf(" -window : Enable windowed mode \n");
143 printf(" -pal : Force VJ to PAL mode (default: NTSC) \n");
144 printf(" -ntsc : Force VJ to NTSC mode \n");
145 printf("\nInvoking Virtual Jagaur with no ROM file will cause it to boot up\n");
146 printf("with the VJ GUI.\n");
151 // Set up SDL library
152 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
154 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
158 WriteLog("VJ: SDL successfully initialized.\n");
160 // WriteLog("Initializing memory subsystem...\n");
162 #ifdef VJ_RELEASE_VERSION
163 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
165 WriteLog("Virtual Jaguar SVN %s (Last full build was on %s %s)\n", __DATE__, __DATE__, __TIME__);
167 WriteLog("Initializing jaguar subsystem...\n");
171 #ifdef USE_BUILT_IN_BIOS
172 WriteLog("VJ: Using built in BIOS/CD BIOS...\n");
173 memcpy(jaguarBootROM, jagBootROM, 0x20000);
174 memcpy(jaguarCDBootROM, jagCDROM, 0x40000);
175 BIOSLoaded = CDBIOSLoaded = true;
177 // What would be nice here would be a way to check if the BIOS was loaded so that we
178 // could disable the pushbutton on the Misc Options menu... !!! FIX !!! [DONE here, but needs to be fixed in GUI as well!]
179 WriteLog("About to attempt to load BIOSes...\n");
180 BIOSLoaded = (JaguarLoadROM(jaguarBootROM, vjs.jagBootPath) == 0x20000 ? true : false);
181 WriteLog("VJ: BIOS is %savailable...\n", (BIOSLoaded ? "" : "not "));
182 CDBIOSLoaded = (JaguarLoadROM(jaguarCDBootROM, vjs.CDBootPath) == 0x40000 ? true : false);
183 WriteLog("VJ: CD BIOS is %savailable...\n", (CDBIOSLoaded ? "" : "not "));
186 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
188 WriteLog("Initializing video subsystem...\n");
190 WriteLog("Initializing GUI subsystem...\n");
191 #warning "!!! FIX !!! (GUIInit())"
194 // Now with crunchy GUI goodness!
195 WriteLog("About to start GUI...\n");
196 #warning "!!! FIX !!! (GUIMain(...))"
197 // GUIMain(haveCart ? argv[1] : NULL);
199 //This is no longer accurate...!
200 // int elapsedTime = clock() - startTime;
201 // int fps = (1000 * totalFrames) / elapsedTime;
202 // WriteLog("VJ: Ran at an average of %i FPS.\n", fps);
209 // Free SDL components last...!
210 SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER);