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 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 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;
83 if (!strcmp(argv[i], "-frameskip"))
85 nFrameskip = atoi(argv[++i]) + 1;
91 if (!strcmp(argv[i], "-bios"))
92 vjs.useJaguarBIOS = true;
94 if (!strcmp(argv[i], "-nobios"))
95 vjs.useJaguarBIOS = false;
97 if (!strcmp(argv[i], "-dsp"))
98 vjs.DSPEnabled = true;
100 if (!strcmp(argv[i], "-nodsp"))
101 vjs.DSPEnabled = false;
103 if (!strcmp(argv[i], "-pipeline"))
104 vjs.usePipelinedDSP = true;
106 if (!strcmp(argv[i], "-nopipeline"))
107 vjs.usePipelinedDSP = false;
109 if (!strcmp(argv[i], "-gl"))
110 vjs.useOpenGL = true;
112 if (!strcmp(argv[i], "-nogl"))
113 vjs.useOpenGL = false;
115 if (!strcmp(argv[i], "-fullscreen"))
116 vjs.fullscreen = true;
118 if (!strcmp(argv[i], "-window"))
119 vjs.fullscreen = false;
121 if (!strcmp(argv[i], "-pal"))
122 vjs.hardwareTypeNTSC = false;
124 if (!strcmp(argv[i], "-ntsc"))
125 vjs.hardwareTypeNTSC = true;
127 if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-?"))
129 printf("Usage: \n\n");
130 printf("vj [romfile] [switches]\n");
131 printf(" -? or --help : Display usage and switches \n");
132 printf(" -frameskip 1-10 : Enable frameskip 1 - 10 (default: none) \n");
133 printf(" -joystick : Enable joystick/gamepad \n");
134 printf(" -joyport 0-3 : Select desired joystick port \n");
135 printf(" -bios : Boot cart using Jaguar BIOS ROM \n");
136 printf(" -nobios : Boot cart without using Jaguar BIOS ROM \n");
137 printf(" -dsp : Force VJ to use the DSP \n");
138 printf(" -nodsp : Force VJ to run without the DSP \n");
139 printf(" -pipeline : Use the DSP pipelined core \n");
140 printf(" -nopipeline : Use the DSP non-pipelined core \n");
141 printf(" -gl : Use OpenGL rendering \n");
142 printf(" -nogl : Use old non-OpenGL rendering \n");
143 printf(" -fullscreen : Enable fullscreen mode (default: windowed)\n");
144 printf(" -window : Enable windowed mode \n");
145 printf(" -pal : Force VJ to PAL mode (default: NTSC) \n");
146 printf(" -ntsc : Force VJ to NTSC mode \n");
147 printf("\nInvoking Virtual Jagaur with no ROM file will cause it to boot up\n");
148 printf("with the VJ GUI.\n");
153 // Set up SDL library
154 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
156 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
160 WriteLog("VJ: SDL successfully initialized.\n");
162 // WriteLog("Initializing memory subsystem...\n");
164 #ifdef VJ_RELEASE_VERSION
165 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
167 WriteLog("Virtual Jaguar SVN %s (Last full build was on %s %s)\n", __DATE__, __DATE__, __TIME__);
169 WriteLog("Initializing jaguar subsystem...\n");
173 #ifdef USE_BUILT_IN_BIOS
174 WriteLog("VJ: Using built in BIOS/CD BIOS...\n");
175 memcpy(jaguarBootROM, jagBootROM, 0x20000);
176 memcpy(jaguarCDBootROM, jagCDROM, 0x40000);
177 BIOSLoaded = CDBIOSLoaded = true;
179 // What would be nice here would be a way to check if the BIOS was loaded so that we
180 // could disable the pushbutton on the Misc Options menu... !!! FIX !!! [DONE here, but needs to be fixed in GUI as well!]
181 WriteLog("About to attempt to load BIOSes...\n");
182 BIOSLoaded = (JaguarLoadROM(jaguarBootROM, vjs.jagBootPath) == 0x20000 ? true : false);
183 WriteLog("VJ: BIOS is %savailable...\n", (BIOSLoaded ? "" : "not "));
184 CDBIOSLoaded = (JaguarLoadROM(jaguarCDBootROM, vjs.CDBootPath) == 0x40000 ? true : false);
185 WriteLog("VJ: CD BIOS is %savailable...\n", (CDBIOSLoaded ? "" : "not "));
188 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
190 WriteLog("Initializing video subsystem...\n");
192 WriteLog("Initializing GUI subsystem...\n");
193 #warning "!!! FIX !!! (GUIInit())"
196 // Now with crunchy GUI goodness!
197 WriteLog("About to start GUI...\n");
198 #warning "!!! FIX !!! (GUIMain(...))"
199 // GUIMain(haveCart ? argv[1] : NULL);
201 //This is no longer accurate...!
202 // int elapsedTime = clock() - startTime;
203 // int fps = (1000 * totalFrames) / elapsedTime;
204 // WriteLog("VJ: Ran at an average of %i FPS.\n", fps);
211 // Free SDL components last...!
212 SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER);