1 |
/* |
2 |
* main.cpp - Main program |
3 |
* |
4 |
* Frodo (C) 1994-1997,2002-2003 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 "sysdeps.h" |
22 |
|
23 |
#include "main.h" |
24 |
#include "C64.h" |
25 |
#include "Display.h" |
26 |
#include "Prefs.h" |
27 |
#include "SAM.h" |
28 |
|
29 |
|
30 |
// Global variables |
31 |
char AppDirPath[1024]; // Path of application directory |
32 |
|
33 |
|
34 |
// ROM file names |
35 |
#ifndef DATADIR |
36 |
#define DATADIR |
37 |
#endif |
38 |
|
39 |
#ifdef __riscos__ |
40 |
#define BASIC_ROM_FILE "FrodoRsrc:Basic_ROM" |
41 |
#define KERNAL_ROM_FILE "FrodoRsrc:Kernal_ROM" |
42 |
#define CHAR_ROM_FILE "FrodoRsrc:Char_ROM" |
43 |
#define DRIVE_ROM_FILE "FrodoRsrc:1541_ROM" |
44 |
#else |
45 |
#define BASIC_ROM_FILE DATADIR "Basic ROM" |
46 |
#define KERNAL_ROM_FILE DATADIR "Kernal ROM" |
47 |
#define CHAR_ROM_FILE DATADIR "Char ROM" |
48 |
#define DRIVE_ROM_FILE DATADIR "1541 ROM" |
49 |
#endif |
50 |
|
51 |
|
52 |
// Builtin ROMs |
53 |
#include "Basic_ROM.h" |
54 |
#include "Kernal_ROM.h" |
55 |
#include "Char_ROM.h" |
56 |
#include "1541_ROM.h" |
57 |
|
58 |
|
59 |
/* |
60 |
* Load C64 ROM files |
61 |
*/ |
62 |
|
63 |
void Frodo::load_rom(const char *which, const char *path, uint8 *where, size_t size, const uint8 *builtin) |
64 |
{ |
65 |
FILE *f = fopen(path, "rb"); |
66 |
if (f) { |
67 |
size_t actual = fread(where, 1, size, f); |
68 |
fclose(f); |
69 |
if (actual == size) |
70 |
return; |
71 |
} |
72 |
|
73 |
// Use builtin ROM |
74 |
printf("%s ROM file (%s) not readable, using builtin.\n", which, path); |
75 |
memcpy(where, builtin, size); |
76 |
} |
77 |
|
78 |
void Frodo::load_rom_files() |
79 |
{ |
80 |
load_rom("Basic", BASIC_ROM_FILE, TheC64->Basic, BASIC_ROM_SIZE, builtin_basic_rom); |
81 |
load_rom("Kernal", KERNAL_ROM_FILE, TheC64->Kernal, KERNAL_ROM_SIZE, builtin_kernal_rom); |
82 |
load_rom("Char", CHAR_ROM_FILE, TheC64->Char, CHAR_ROM_SIZE, builtin_char_rom); |
83 |
load_rom("1541", DRIVE_ROM_FILE, TheC64->ROM1541, DRIVE_ROM_SIZE, builtin_drive_rom); |
84 |
} |
85 |
|
86 |
|
87 |
#ifdef __BEOS__ |
88 |
#include "main_Be.h" |
89 |
#endif |
90 |
|
91 |
#ifdef AMIGA |
92 |
#include "main_Amiga.h" |
93 |
#endif |
94 |
|
95 |
#ifdef __unix |
96 |
#include "main_x.h" |
97 |
#endif |
98 |
|
99 |
#ifdef __mac__ |
100 |
#include "main_mac.h" |
101 |
#endif |
102 |
|
103 |
#ifdef WIN32 |
104 |
#include "main_WIN32.h" |
105 |
#endif |
106 |
|
107 |
#ifdef __riscos__ |
108 |
#include "main_Acorn.h" |
109 |
#endif |