ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/main_x.h
Revision: 1.7
Committed: 2004-01-23T15:07:46Z (20 years, 3 months ago) by cebix
Content type: text/plain
Branch: MAIN
Changes since 1.6: +13 -7 lines
Log Message:
some Qtopia patches

File Contents

# Content
1 /*
2 * main_x.h - Main program, Unix specific stuff
3 *
4 * Frodo (C) 1994-1997,2002-2004 Christian Bauer
5 *
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 #ifdef HAVE_GLADE
24 #include <gnome.h>
25 #endif
26
27 #ifdef QTOPIA
28 extern "C" int main(int argc, char *argv[]);
29 #include <SDL.h>
30 #endif
31
32 extern int init_graphics(void);
33
34
35 // Global variables
36 char Frodo::prefs_path[256] = "";
37
38
39 /*
40 * Create application object and start it
41 */
42
43 int main(int argc, char **argv)
44 {
45 #ifdef HAVE_GLADE
46 gnome_program_init(PACKAGE_NAME, PACKAGE_VERSION, LIBGNOMEUI_MODULE, argc, argv,
47 GNOME_PARAM_APP_DATADIR, DATADIR, NULL);
48 #endif
49
50 timeval tv;
51 gettimeofday(&tv, NULL);
52 srand(tv.tv_usec);
53
54 printf("%s by Christian Bauer\n", VERSION_STRING);
55 if (!init_graphics())
56 return 1;
57 fflush(stdout);
58
59 Frodo *the_app = new Frodo();
60 the_app->ArgvReceived(argc, argv);
61 the_app->ReadyToRun();
62 delete the_app;
63
64 return 0;
65 }
66
67
68 /*
69 * Constructor: Initialize member variables
70 */
71
72 Frodo::Frodo()
73 {
74 TheC64 = NULL;
75 }
76
77
78 /*
79 * Process command line arguments
80 */
81
82 void Frodo::ArgvReceived(int argc, char **argv)
83 {
84 if (argc == 2)
85 strncpy(prefs_path, argv[1], 255);
86 }
87
88
89 /*
90 * Arguments processed, run emulation
91 */
92
93 void Frodo::ReadyToRun(void)
94 {
95 getcwd(AppDirPath, 256);
96
97 // Load preferences
98 if (!prefs_path[0]) {
99 char *home = getenv("HOME");
100 if (home != NULL && strlen(home) < 240) {
101 strncpy(prefs_path, home, 200);
102 strcat(prefs_path, "/");
103 }
104 strcat(prefs_path, ".frodorc");
105 }
106 ThePrefs.Load(prefs_path);
107
108 // Show preferences editor
109 #ifdef HAVE_GLADE
110 if (!ThePrefs.ShowEditor(true, prefs_path))
111 return;
112 #endif
113
114 // Create and start C64
115 TheC64 = new C64;
116 load_rom_files();
117 TheC64->Run();
118 delete TheC64;
119 }
120
121
122 Prefs *Frodo::reload_prefs(void)
123 {
124 static Prefs newprefs;
125 newprefs.Load(prefs_path);
126 return &newprefs;
127 }
128
129
130 /*
131 * Determine whether path name refers to a directory
132 */
133
134 bool IsDirectory(const char *path)
135 {
136 struct stat st;
137 return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
138 }