00001
00002
00003
00004
00005
00006
00007 #include "Version.h"
00008
00009
00010 extern int init_graphics(void);
00011
00012
00013
00014 char Frodo::prefs_path[256] = "";
00015
00016
00017
00018
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
00045
00046
00047 Frodo::Frodo()
00048 {
00049 TheC64 = NULL;
00050 }
00051
00052
00053
00054
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
00066
00067
00068 void Frodo::ReadyToRun(void)
00069 {
00070 getcwd(AppDirPath, 256);
00071
00072
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
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 }