Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

main_x.i

Go to the documentation of this file.
00001 /*
00002  *  main_x.i - Main program, X specific stuff
00003  *
00004  *  Frodo (C) 1994-1997 Christian Bauer
00005  */
00006 
00007 #include "Version.h"
00008 
00009 
00010 extern int init_graphics(void);
00011 
00012 
00013 // Global variables
00014 char Frodo::prefs_path[256] = "";
00015 
00016 
00017 /*
00018  *  Create application object and start it
00019  */
00020 
00021 int main(int argc, char **argv)
00022 {
00023         Frodo *the_app;
00024 
00025         timeval tv;
00026         gettimeofday(&tv, NULL);
00027         srand(tv.tv_usec);
00028 
00029         printf("%s by Christian Bauer\n", VERSION_STRING);
00030         if (!init_graphics())
00031                 return 0;
00032         fflush(stdout);
00033 
00034         the_app = new Frodo();
00035         the_app->ArgvReceived(argc, argv);
00036         the_app->ReadyToRun();
00037         delete the_app;
00038 
00039         return 0;
00040 }
00041 
00042 
00043 /*
00044  *  Constructor: Initialize member variables
00045  */
00046 
00047 Frodo::Frodo()
00048 {
00049         TheC64 = NULL;
00050 }
00051 
00052 
00053 /*
00054  *  Process command line arguments
00055  */
00056 
00057 void Frodo::ArgvReceived(int argc, char **argv)
00058 {
00059         if (argc == 2)
00060                 strncpy(prefs_path, argv[1], 255);
00061 }
00062 
00063 
00064 /*
00065  *  Arguments processed, run emulation
00066  */
00067 
00068 void Frodo::ReadyToRun(void)
00069 {
00070         getcwd(AppDirPath, 256);
00071 
00072         // Load preferences
00073         if (!prefs_path[0]) {
00074                 char *home = getenv("HOME");
00075                 if (home != NULL && strlen(home) < 240)
00076                 {
00077                                 strncpy(prefs_path, home, 200);
00078                 strcat(prefs_path, "/");
00079                 }
00080                 strcat(prefs_path, ".frodorc");
00081         }
00082 
00084 
00085         // Create and start C64
00086         TheC64 = new C64(this);
00087         if (load_rom_files()) {
00088                 TheC64->Run();
00089         }
00090         delete TheC64;
00091 }
00092 
00093 
00094 Prefs *Frodo::reload_prefs(void)
00095 {
00096         static Prefs newprefs;
00097         newprefs.Load(prefs_path);
00098         return &newprefs;
00099 }

Generated on Tue Feb 8 04:08:00 2005 for E32frodo by doxygen 1.3.3