ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/main.cpp
Revision: 1.1
Committed: 1999-10-19T17:41:17Z (24 years, 8 months ago) by cebix
Branch: MAIN
CVS Tags: snapshot-21101999
Log Message:
- added external file system
- moved most init/deinit code to InitAll()/ExitAll() in main.cpp

File Contents

# Content
1 /*
2 * main.cpp - Startup/shutdown code
3 *
4 * Basilisk II (C) 1997-1999 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 "cpu_emulation.h"
24 #include "xpram.h"
25 #include "timer.h"
26 #include "sony.h"
27 #include "disk.h"
28 #include "cdrom.h"
29 #include "scsi.h"
30 #include "extfs.h"
31 #include "audio.h"
32 #include "video.h"
33 #include "serial.h"
34 #include "ether.h"
35 #include "clip.h"
36 #include "rom_patches.h"
37 #include "user_strings.h"
38 #include "prefs.h"
39 #include "main.h"
40
41 #define DEBUG 0
42 #include "debug.h"
43
44
45 /*
46 * Initialize everything, returns false on error
47 */
48
49 bool InitAll(void)
50 {
51 // Check ROM version
52 if (!CheckROM()) {
53 ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
54 return false;
55 }
56
57 #if EMULATED_68K
58 // Set CPU and FPU type (UAE emulation)
59 switch (ROMVersion) {
60 case ROM_VERSION_64K:
61 case ROM_VERSION_PLUS:
62 case ROM_VERSION_CLASSIC:
63 CPUType = 0;
64 FPUType = 0;
65 TwentyFourBitAddressing = true;
66 break;
67 case ROM_VERSION_II:
68 CPUType = 2;
69 FPUType = PrefsFindBool("fpu") ? 1 : 0;
70 TwentyFourBitAddressing = true;
71 break;
72 case ROM_VERSION_32:
73 CPUType = 3;
74 FPUType = PrefsFindBool("fpu") ? 1 : 0;
75 TwentyFourBitAddressing = false;
76 break;
77 }
78 CPUIs68060 = false;
79 #endif
80
81 // Load XPRAM
82 XPRAMInit();
83
84 // Set boot volume
85 int16 i16 = PrefsFindInt16("bootdrive");
86 XPRAM[0x78] = i16 >> 8;
87 XPRAM[0x79] = i16 & 0xff;
88 i16 = PrefsFindInt16("bootdriver");
89 XPRAM[0x7a] = i16 >> 8;
90 XPRAM[0x7b] = i16 & 0xff;
91
92 // Init drivers
93 SonyInit();
94 DiskInit();
95 CDROMInit();
96 SCSIInit();
97
98 // Init external file system
99 ExtFSInit();
100
101 // Init serial ports
102 SerialInit();
103
104 // Init network
105 EtherInit();
106
107 // Init Time Manager
108 TimerInit();
109
110 // Init clipboard
111 ClipInit();
112
113 // Init audio
114 AudioInit();
115
116 // Init video
117 if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC))
118 return false;
119
120 #if EMULATED_68K
121 // Init 680x0 emulation (this also activates the memory system which is needed for PatchROM())
122 if (!Init680x0())
123 return false;
124 #endif
125
126 // Install ROM patches
127 if (!PatchROM()) {
128 ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
129 return false;
130 }
131 return true;
132 }
133
134
135 /*
136 * Deinitialize everything
137 */
138
139 void ExitAll(void)
140 {
141 // Save XPRAM
142 XPRAMExit();
143
144 // Exit video
145 VideoExit();
146
147 // Exit audio
148 AudioExit();
149
150 // Exit clipboard
151 ClipExit();
152
153 // Exit Time Manager
154 TimerExit();
155
156 // Exit serial ports
157 SerialExit();
158
159 // Exit network
160 EtherExit();
161
162 // Exit external file system
163 ExtFSExit();
164
165 // Exit drivers
166 SCSIExit();
167 CDROMExit();
168 DiskExit();
169 SonyExit();
170 }