ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/main_x.h
Revision: 1.5
Committed: 2004-01-13T19:52:49Z (20 years, 2 months ago) by cebix
Content type: text/plain
Branch: MAIN
Changes since 1.4: +19 -8 lines
Log Message:
first attempt at Glade-based prefs editor for Unix

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * main_x.h - Main program, Unix specific stuff
3     *
4 cebix 1.4 * Frodo (C) 1994-1997,2002-2004 Christian Bauer
5 cebix 1.1 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #include "Version.h"
22    
23 cebix 1.5 #ifdef HAVE_GLADE
24     #include <gnome.h>
25     #endif
26    
27 cebix 1.1
28     extern int init_graphics(void);
29    
30    
31     // Global variables
32     char Frodo::prefs_path[256] = "";
33    
34    
35     /*
36     * Create application object and start it
37     */
38    
39     int main(int argc, char **argv)
40     {
41 cebix 1.5 #ifdef HAVE_GLADE
42     gnome_program_init(PACKAGE_NAME, PACKAGE_VERSION, LIBGNOMEUI_MODULE, argc, argv,
43     GNOME_PARAM_APP_DATADIR, DATADIR, NULL);
44     #endif
45 cebix 1.1
46     timeval tv;
47     gettimeofday(&tv, NULL);
48     srand(tv.tv_usec);
49    
50     printf("%s by Christian Bauer\n", VERSION_STRING);
51     if (!init_graphics())
52 cebix 1.5 return 1;
53 cebix 1.1 fflush(stdout);
54    
55 cebix 1.5 Frodo *the_app = new Frodo();
56 cebix 1.1 the_app->ArgvReceived(argc, argv);
57     the_app->ReadyToRun();
58     delete the_app;
59    
60     return 0;
61     }
62    
63    
64     /*
65     * Constructor: Initialize member variables
66     */
67    
68     Frodo::Frodo()
69     {
70     TheC64 = NULL;
71     }
72    
73    
74     /*
75     * Process command line arguments
76     */
77    
78     void Frodo::ArgvReceived(int argc, char **argv)
79     {
80     if (argc == 2)
81     strncpy(prefs_path, argv[1], 255);
82     }
83    
84    
85     /*
86     * Arguments processed, run emulation
87     */
88    
89     void Frodo::ReadyToRun(void)
90     {
91     getcwd(AppDirPath, 256);
92    
93     // Load preferences
94     if (!prefs_path[0]) {
95     char *home = getenv("HOME");
96     if (home != NULL && strlen(home) < 240) {
97     strncpy(prefs_path, home, 200);
98     strcat(prefs_path, "/");
99     }
100     strcat(prefs_path, ".frodorc");
101     }
102     ThePrefs.Load(prefs_path);
103    
104 cebix 1.5 // Show preferences editor
105     if (ThePrefs.ShowEditor(true, prefs_path)) {
106    
107     // Create and start C64
108     TheC64 = new C64;
109     load_rom_files();
110     TheC64->Run();
111     delete TheC64;
112     }
113 cebix 1.1 }
114    
115    
116     Prefs *Frodo::reload_prefs(void)
117     {
118     static Prefs newprefs;
119     newprefs.Load(prefs_path);
120     return &newprefs;
121     }