1 |
cebix |
1.1 |
/* |
2 |
|
|
* main_x.h - Main program, Unix specific stuff |
3 |
|
|
* |
4 |
cebix |
1.2 |
* Frodo (C) 1994-1997,2002-2003 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 |
|
|
|
24 |
|
|
extern int init_graphics(void); |
25 |
|
|
|
26 |
|
|
|
27 |
|
|
// Global variables |
28 |
|
|
char Frodo::prefs_path[256] = ""; |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/* |
32 |
|
|
* Create application object and start it |
33 |
|
|
*/ |
34 |
|
|
|
35 |
|
|
int main(int argc, char **argv) |
36 |
|
|
{ |
37 |
|
|
Frodo *the_app; |
38 |
|
|
|
39 |
|
|
timeval tv; |
40 |
|
|
gettimeofday(&tv, NULL); |
41 |
|
|
srand(tv.tv_usec); |
42 |
|
|
|
43 |
|
|
printf("%s by Christian Bauer\n", VERSION_STRING); |
44 |
|
|
if (!init_graphics()) |
45 |
|
|
return 0; |
46 |
|
|
fflush(stdout); |
47 |
|
|
|
48 |
|
|
the_app = new Frodo(); |
49 |
|
|
the_app->ArgvReceived(argc, argv); |
50 |
|
|
the_app->ReadyToRun(); |
51 |
|
|
delete the_app; |
52 |
|
|
|
53 |
|
|
return 0; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
|
57 |
|
|
/* |
58 |
|
|
* Constructor: Initialize member variables |
59 |
|
|
*/ |
60 |
|
|
|
61 |
|
|
Frodo::Frodo() |
62 |
|
|
{ |
63 |
|
|
TheC64 = NULL; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
|
67 |
|
|
/* |
68 |
|
|
* Process command line arguments |
69 |
|
|
*/ |
70 |
|
|
|
71 |
|
|
void Frodo::ArgvReceived(int argc, char **argv) |
72 |
|
|
{ |
73 |
|
|
if (argc == 2) |
74 |
|
|
strncpy(prefs_path, argv[1], 255); |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
|
78 |
|
|
/* |
79 |
|
|
* Arguments processed, run emulation |
80 |
|
|
*/ |
81 |
|
|
|
82 |
|
|
void Frodo::ReadyToRun(void) |
83 |
|
|
{ |
84 |
|
|
getcwd(AppDirPath, 256); |
85 |
|
|
|
86 |
|
|
// Load preferences |
87 |
|
|
if (!prefs_path[0]) { |
88 |
|
|
char *home = getenv("HOME"); |
89 |
|
|
if (home != NULL && strlen(home) < 240) { |
90 |
|
|
strncpy(prefs_path, home, 200); |
91 |
|
|
strcat(prefs_path, "/"); |
92 |
|
|
} |
93 |
|
|
strcat(prefs_path, ".frodorc"); |
94 |
|
|
} |
95 |
|
|
ThePrefs.Load(prefs_path); |
96 |
|
|
|
97 |
|
|
// Create and start C64 |
98 |
|
|
TheC64 = new C64; |
99 |
cebix |
1.3 |
load_rom_files(); |
100 |
|
|
TheC64->Run(); |
101 |
cebix |
1.1 |
delete TheC64; |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
|
105 |
|
|
Prefs *Frodo::reload_prefs(void) |
106 |
|
|
{ |
107 |
|
|
static Prefs newprefs; |
108 |
|
|
newprefs.Load(prefs_path); |
109 |
|
|
return &newprefs; |
110 |
|
|
} |