ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/main_WIN32.h
Revision: 1.5
Committed: 2005-06-27T19:55:48Z (19 years, 4 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: VERSION_4_2, HEAD
Changes since 1.4: +1 -1 lines
Log Message:
updated copyright dates

File Contents

# Content
1 /*
2 * main_WIN32.h - Main program, WIN32 specific stuff
3 *
4 * Frodo (C) 1994-1997,2002-2005 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 <math.h>
22
23 // The application.
24 Frodo *TheApp;
25
26 // WinMain args.
27 HINSTANCE hInstance;
28 int nCmdShow;
29 HWND hwnd;
30
31 int PASCAL WinMain(HINSTANCE hInstance_arg, HINSTANCE /* hPrevInstance */, LPSTR lpCmdLine, int nCmdShow_arg)
32 {
33 hInstance = hInstance_arg;
34 nCmdShow = nCmdShow_arg;
35 TheApp = new Frodo();
36 TheApp->ArgvReceived(__argc, __argv);
37 TheApp->ReadyToRun();
38 delete TheApp;
39 DestroyWindow(hwnd);
40 return 0;
41 }
42
43 /*
44 * Constructor: Initialize member variables
45 */
46
47 Frodo::Frodo()
48 {
49 TheC64 = NULL;
50 prefs_path[0] = 0;
51 }
52
53
54 Frodo::~Frodo()
55 {
56 delete TheC64;
57 }
58
59
60 /*
61 * Process command line arguments
62 */
63
64 void Frodo::ArgvReceived(int argc, char **argv)
65 {
66 char *progname = argv[0];
67 argc--, argv++;
68 if (argc >= 1 && argv[0][0] != '\0') {
69
70 // XXX: This should be a function.
71 char cwd[256];
72 GetCurrentDirectory(sizeof(cwd), cwd);
73 int cwd_len = strlen(cwd);
74 if (cwd_len > 0 && cwd[cwd_len - 1] != '\\') {
75 strcat(cwd, "\\");
76 cwd_len++;
77 }
78 if (strnicmp(argv[0], cwd, cwd_len) == 0)
79 strncpy(prefs_path, argv[0] + cwd_len, 255);
80 else
81 strncpy(prefs_path, argv[0], 255);
82 int length = strlen(prefs_path);
83 if (length > 4 && strchr(prefs_path, '.') == NULL)
84 strcat(prefs_path, ".fpr");
85 }
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 strcpy(prefs_path, "Frodo.fpr");
100 ThePrefs.Load(prefs_path);
101
102 if (ThePrefs.PrefsAtStartup) {
103 if (!ThePrefs.ShowEditor(TRUE, prefs_path))
104 return;
105 }
106
107 // Create and start C64
108 TheC64 = new C64;
109 load_rom_files();
110 TheC64->Run();
111 }
112
113
114 /*
115 * Run preferences editor
116 */
117
118 void Frodo::RunPrefsEditor(void)
119 {
120 Prefs *prefs = new Prefs(ThePrefs);
121 if (prefs->ShowEditor(FALSE, prefs_path)) {
122 TheC64->NewPrefs(prefs);
123 ThePrefs = *prefs;
124 }
125 delete prefs;
126 }