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

main_WIN32.i

Go to the documentation of this file.
00001 /*
00002  *  main_WIN32.i - Main program, WIN32 specific stuff
00003  *
00004  *  Frodo (C) 1994-1997 Christian Bauer
00005  *  WIN32 code by J. Richard Sladkey <jrs@world.std.com>
00006  */
00007 
00008 #include <math.h>
00009 
00010 // The application.
00011 Frodo *TheApp;
00012 
00013 // WinMain args.
00014 HINSTANCE hInstance;
00015 int nCmdShow;
00016 HWND hwnd;
00017 
00018 int PASCAL WinMain(HINSTANCE hInstance_arg, HINSTANCE /* hPrevInstance */, LPSTR lpCmdLine, int nCmdShow_arg)
00019 {
00020         hInstance = hInstance_arg;
00021         nCmdShow = nCmdShow_arg;
00022         TheApp = new Frodo();
00023         TheApp->ArgvReceived(__argc, __argv);
00024         TheApp->ReadyToRun();
00025         delete TheApp;
00026         DestroyWindow(hwnd);
00027         return 0;
00028 }
00029 
00030 /*
00031  *  Constructor: Initialize member variables
00032  */
00033 
00034 Frodo::Frodo()
00035 {
00036         TheC64 = NULL;
00037         prefs_path[0] = 0;
00038 }
00039 
00040 
00041 Frodo::~Frodo()
00042 {
00043         delete TheC64;
00044 }
00045 
00046 
00047 /*
00048  *  Process command line arguments
00049  */
00050 
00051 void Frodo::ArgvReceived(int argc, char **argv)
00052 {
00053         char *progname = argv[0];
00054         argc--, argv++;
00055         if (argc >= 1 && argv[0][0] != '\0') {
00056 
00057                 // XXX: This should be a function.
00058                 char cwd[256];
00059                 GetCurrentDirectory(sizeof(cwd), cwd);
00060                 int cwd_len = strlen(cwd);
00061                 if (cwd_len > 0 && cwd[cwd_len - 1] != '\\') {
00062                         strcat(cwd, "\\");
00063                         cwd_len++;
00064                 }
00065                 if (strnicmp(argv[0], cwd, cwd_len) == 0)
00066                         strncpy(prefs_path, argv[0] + cwd_len, 255);
00067                 else
00068                         strncpy(prefs_path, argv[0], 255);
00069                 int length = strlen(prefs_path);
00070                 if (length > 4 && strchr(prefs_path, '.') == NULL)
00071                         strcat(prefs_path, ".fpr");
00072         }
00073 }
00074 
00075 
00076 /*
00077  *  Arguments processed, run emulation
00078  */
00079 
00080 void Frodo::ReadyToRun(void)
00081 {
00082         getcwd(AppDirPath, 256);
00083 
00084         // Load preferences
00085         if (!prefs_path[0])
00086                 strcpy(prefs_path, "Frodo.fpr");
00087         ThePrefs.Load(prefs_path);
00088 
00089         if (ThePrefs.PrefsAtStartup) {
00090                 if (!ThePrefs.ShowEditor(TRUE, prefs_path))
00091                         return;
00092         }
00093 
00094         // Create and start C64
00095         TheC64 = new C64;
00096         if (load_rom_files())
00097                 TheC64->Run();
00098 }
00099 
00100 
00101 /*
00102  *  Run preferences editor
00103  */
00104 
00105 void Frodo::RunPrefsEditor(void)
00106 {
00107         Prefs *prefs = new Prefs(ThePrefs);
00108         if (prefs->ShowEditor(FALSE, prefs_path)) {
00109                 TheC64->NewPrefs(prefs);
00110                 ThePrefs = *prefs;
00111         }
00112         delete prefs;
00113 }

Generated on Tue Feb 8 04:07:59 2005 for E32frodo by doxygen 1.3.3