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
10 //#include <unistd.h> // Is this necessary anymore?
11 //Looks like the answer is no...
19 #include "sdlemu_opengl.h"
20 #include "settings.h" // Pull in "vjs" struct
25 // Uncomment this to use built-in BIOS/CD-ROM BIOS
26 // You'll need a copy of jagboot.h & jagcd.h for this to work...!
27 //#define USE_BUILT_IN_BIOS
29 #ifdef USE_BUILT_IN_BIOS
34 // Private function prototypes
38 extern uint8 * jaguar_mainRam;
39 extern uint8 * jaguar_mainRom;
40 extern uint8 * jaguar_bootRom;
41 extern uint8 * jaguar_CDBootROM;
43 // Global variables (export capable)
44 //should these even be here anymore? prolly not...
46 bool finished = false;
48 bool showMessage = false;
49 uint32 showMessageTimeout;
50 char messageBuffer[200];
51 bool BIOSLoaded = false;
52 bool CDBIOSLoaded = false;
55 // The main emulator loop (what else?)
57 //Maybe we should move the video stuff to TOM? Makes more sense to put it there...
58 //Actually, it would probably be better served in VIDEO.CPP... !!! FIX !!! [DONE]
59 uint32 totalFrames;//temp, so we can grab this from elsewhere...
60 int main(int argc, char * argv[])
62 //NOTE: This isn't actually used anywhere... !!! FIX !!!
63 int32 nFrameskip = 0; // Default: Show every frame
65 printf("Virtual Jaguar GCC/SDL Portable Jaguar Emulator v1.1.0\n");
66 printf("Based upon Virtual Jaguar core v1.0.0 by David Raingeard.\n");
67 printf("Written by Niels Wagenaar (Linux/WIN32), Carwin Jones (BeOS),\n");
68 printf("James L. Hammons (WIN32) and Adam Green (MacOS)\n");
69 printf("Contact: http://sdlemu.ngemu.com/ | sdlemu@ngemu.com\n");
71 bool haveCart = false; // Assume there is no cartridge...!
74 LoadVJSettings(); // Get config file settings...
76 // Check the switches... ;-)
77 // NOTE: Command line switches can override any config file settings, thus the
78 // proliferation of the noXXX switches. ;-)
80 for(int i=1; i<argc || argv[i]!=NULL; i++)
82 // This would be the most likely place to do the cart loading...
83 if (argv[i][0] != '-')
84 haveCart = true; // It looks like we have a cartridge!
86 if (!strcmp(argv[i], "-joystick"))
87 vjs.useJoystick = true;
89 if (!strcmp(argv[i], "-joyport"))
91 vjs.joyport = atoi(argv[++i]) + 1;
96 if (!strcmp(argv[i], "-frameskip"))
98 nFrameskip = atoi(argv[++i]) + 1;
103 if (!strcmp(argv[i], "-bios"))
104 vjs.useJaguarBIOS = true;
106 if (!strcmp(argv[i], "-nobios"))
107 vjs.useJaguarBIOS = false;
109 if (!strcmp(argv[i], "-dsp"))
110 vjs.DSPEnabled = true;
112 if (!strcmp(argv[i], "-nodsp"))
113 vjs.DSPEnabled = false;
115 if (!strcmp(argv[i], "-pipeline"))
116 vjs.usePipelinedDSP = true;
118 if (!strcmp(argv[i], "-nopipeline"))
119 vjs.usePipelinedDSP = false;
121 if (!strcmp(argv[i], "-gl"))
122 vjs.useOpenGL = true;
124 if (!strcmp(argv[i], "-nogl"))
125 vjs.useOpenGL = false;
127 if (!strcmp(argv[i], "-fullscreen"))
128 vjs.fullscreen = true;
130 if (!strcmp(argv[i], "-window"))
131 vjs.fullscreen = false;
133 if (!strcmp(argv[i], "-pal"))
134 vjs.hardwareTypeNTSC = false;
136 if (!strcmp(argv[i], "-ntsc"))
137 vjs.hardwareTypeNTSC = true;
139 if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-?"))
141 printf("Usage: \n\n");
142 printf("vj [romfile] [switches]\n");
143 printf(" -? or --help : Display usage and switches \n");
144 printf(" -frameskip 1-10 : Enable frameskip 1 - 10 (default: none) \n");
145 printf(" -joystick : Enable joystick/gamepad \n");
146 printf(" -joyport 0-3 : Select desired joystick port \n");
147 printf(" -bios : Boot cart using Jaguar BIOS ROM \n");
148 printf(" -nobios : Boot cart without using Jaguar BIOS ROM \n");
149 printf(" -dsp : Force VJ to use the DSP \n");
150 printf(" -nodsp : Force VJ to run without the DSP \n");
151 printf(" -pipeline : Use the DSP pipelined core \n");
152 printf(" -nopipeline : Use the DSP non-pipelined core \n");
153 printf(" -gl : Use OpenGL rendering \n");
154 printf(" -nogl : Use old non-OpenGL rendering \n");
155 printf(" -fullscreen : Enable fullscreen mode (default: windowed)\n");
156 printf(" -window : Enable windowed mode \n");
157 printf(" -pal : Force VJ to PAL mode (default: NTSC) \n");
158 printf(" -ntsc : Force VJ to NTSC mode \n");
159 printf("\nInvoking Virtual Jagaur with no ROM file will cause it to boot up\n");
160 printf("with the VJ GUI.\n");
165 // Set up SDL library
166 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
168 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
172 WriteLog("VJ: SDL successfully initialized.\n");
174 WriteLog("Initializing memory subsystem...\n");
176 WriteLog("Initializing version...\n");
178 version_display(log_get());
179 WriteLog("Initializing jaguar subsystem...\n");
183 #ifdef USE_BUILT_IN_BIOS
184 WriteLog("VJ: Using built in BIOS/CD BIOS...\n");
185 memcpy(jaguar_bootRom, jagBootROM, 0x20000);
186 memcpy(jaguar_CDBootROM, jagCDROM, 0x40000);
187 BIOSLoaded = CDBIOSLoaded = true;
189 // if (vjs.useJaguarBIOS)
190 // What would be nice here would be a way to check if the BIOS was loaded so that we
191 // could disable the pushbutton on the Misc Options menu... !!! FIX !!! [DONE here, but needs to be fixed in GUI as well!]
192 WriteLog("About to attempt to load BIOSes...\n");
193 BIOSLoaded = (JaguarLoadROM(jaguar_bootRom, vjs.jagBootPath) == 0x20000 ? true : false);
194 WriteLog("VJ: BIOS is %savailable...\n", (BIOSLoaded ? "" : "not "));
195 CDBIOSLoaded = (JaguarLoadROM(jaguar_CDBootROM, vjs.CDBootPath) == 0x40000 ? true : false);
196 WriteLog("VJ: CD BIOS is %savailable...\n", (CDBIOSLoaded ? "" : "not "));
199 SET32(jaguar_mainRam, 0, 0x00200000); // Set top of stack...
201 WriteLog("Initializing video subsystem...\n");
203 WriteLog("Initializing GUI subsystem...\n");
206 // Now with crunchy GUI goodness!
207 WriteLog("About to start GUI...\n");
208 GUIMain(haveCart ? argv[1] : NULL);
210 //This is no longer accurate...!
211 // int elapsedTime = clock() - startTime;
212 // int fps = (1000 * totalFrames) / elapsedTime;
213 // WriteLog("VJ: Ran at an average of %i FPS.\n", fps);
221 // Free SDL components last...!
222 SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER);