ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/main.cpp
Revision: 1.3
Committed: 1999-10-25T08:07:45Z (24 years, 6 months ago) by cebix
Branch: MAIN
Changes since 1.2: +27 -0 lines
Log Message:
- now uses "mon" if present (currently on breakpoints only)

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 #if ENABLE_MON
45 #include "mon.h"
46
47 static uint32 mon_read_byte_b2(uint32 adr)
48 {
49 return ReadMacInt8(adr);
50 }
51
52 static void mon_write_byte_b2(uint32 adr, uint32 b)
53 {
54 WriteMacInt8(adr, b);
55 }
56 #endif
57
58
59 /*
60 * Initialize everything, returns false on error
61 */
62
63 bool InitAll(void)
64 {
65 // Check ROM version
66 if (!CheckROM()) {
67 ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
68 return false;
69 }
70
71 #if EMULATED_68K
72 // Set CPU and FPU type (UAE emulation)
73 switch (ROMVersion) {
74 case ROM_VERSION_64K:
75 case ROM_VERSION_PLUS:
76 case ROM_VERSION_CLASSIC:
77 CPUType = 0;
78 FPUType = 0;
79 TwentyFourBitAddressing = true;
80 break;
81 case ROM_VERSION_II:
82 CPUType = 2;
83 FPUType = PrefsFindBool("fpu") ? 1 : 0;
84 TwentyFourBitAddressing = true;
85 break;
86 case ROM_VERSION_32:
87 CPUType = 3;
88 FPUType = PrefsFindBool("fpu") ? 1 : 0;
89 TwentyFourBitAddressing = false;
90 break;
91 }
92 CPUIs68060 = false;
93 #endif
94
95 // Load XPRAM
96 XPRAMInit();
97
98 // Set boot volume
99 int16 i16 = PrefsFindInt16("bootdrive");
100 XPRAM[0x78] = i16 >> 8;
101 XPRAM[0x79] = i16 & 0xff;
102 i16 = PrefsFindInt16("bootdriver");
103 XPRAM[0x7a] = i16 >> 8;
104 XPRAM[0x7b] = i16 & 0xff;
105
106 // Init drivers
107 SonyInit();
108 DiskInit();
109 CDROMInit();
110 SCSIInit();
111
112 #if SUPPORTS_EXTFS
113 // Init external file system
114 ExtFSInit();
115 #endif
116
117 // Init serial ports
118 SerialInit();
119
120 // Init network
121 EtherInit();
122
123 // Init Time Manager
124 TimerInit();
125
126 // Init clipboard
127 ClipInit();
128
129 // Init audio
130 AudioInit();
131
132 // Init video
133 if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC))
134 return false;
135
136 #if EMULATED_68K
137 // Init 680x0 emulation (this also activates the memory system which is needed for PatchROM())
138 if (!Init680x0())
139 return false;
140 #endif
141
142 // Install ROM patches
143 if (!PatchROM()) {
144 ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
145 return false;
146 }
147
148 #if ENABLE_MON
149 // Initialize mon
150 mon_init();
151 mon_read_byte = mon_read_byte_b2;
152 mon_write_byte = mon_write_byte_b2;
153 #endif
154
155 return true;
156 }
157
158
159 /*
160 * Deinitialize everything
161 */
162
163 void ExitAll(void)
164 {
165 #if ENABLE_MON
166 // Deinitialize mon
167 mon_exit();
168 #endif
169
170 // Save XPRAM
171 XPRAMExit();
172
173 // Exit video
174 VideoExit();
175
176 // Exit audio
177 AudioExit();
178
179 // Exit clipboard
180 ClipExit();
181
182 // Exit Time Manager
183 TimerExit();
184
185 // Exit serial ports
186 SerialExit();
187
188 // Exit network
189 EtherExit();
190
191 #if SUPPORTS_EXTFS
192 // Exit external file system
193 ExtFSExit();
194 #endif
195
196 // Exit drivers
197 SCSIExit();
198 CDROMExit();
199 DiskExit();
200 SonyExit();
201 }