27 |
|
|
28 |
|
#include "cpu_emulation.h" |
29 |
|
#include "sys.h" |
30 |
+ |
#include "rom_patches.h" |
31 |
|
#include "xpram.h" |
32 |
|
#include "timer.h" |
32 |
– |
#include "sony.h" |
33 |
– |
#include "disk.h" |
34 |
– |
#include "cdrom.h" |
35 |
– |
#include "scsi.h" |
36 |
– |
#include "audio.h" |
33 |
|
#include "video.h" |
38 |
– |
#include "serial.h" |
39 |
– |
#include "ether.h" |
40 |
– |
#include "clip.h" |
41 |
– |
#include "rom_patches.h" |
34 |
|
#include "prefs.h" |
35 |
|
#include "prefs_editor.h" |
36 |
|
#include "macos_util.h" |
38 |
|
#include "version.h" |
39 |
|
#include "main.h" |
40 |
|
|
41 |
< |
#define DEBUG 1 |
41 |
> |
#define DEBUG 0 |
42 |
|
#include "debug.h" |
43 |
|
|
44 |
|
|
199 |
|
QuitEmulator(); |
200 |
|
} |
201 |
|
|
202 |
< |
// Check ROM version |
203 |
< |
if (!CheckROM()) { |
212 |
< |
ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR)); |
202 |
> |
// Initialize everything |
203 |
> |
if (!InitAll()) |
204 |
|
QuitEmulator(); |
214 |
– |
} |
215 |
– |
|
216 |
– |
// Set CPU and FPU type (UAE emulation) |
217 |
– |
switch (ROMVersion) { |
218 |
– |
case ROM_VERSION_64K: |
219 |
– |
case ROM_VERSION_PLUS: |
220 |
– |
case ROM_VERSION_CLASSIC: |
221 |
– |
CPUType = 0; |
222 |
– |
FPUType = 0; |
223 |
– |
TwentyFourBitAddressing = true; |
224 |
– |
break; |
225 |
– |
case ROM_VERSION_II: |
226 |
– |
CPUType = 2; |
227 |
– |
FPUType = PrefsFindBool("fpu") ? 1 : 0; |
228 |
– |
TwentyFourBitAddressing = true; |
229 |
– |
break; |
230 |
– |
case ROM_VERSION_32: |
231 |
– |
CPUType = 3; |
232 |
– |
FPUType = PrefsFindBool("fpu") ? 1 : 0; |
233 |
– |
TwentyFourBitAddressing = false; |
234 |
– |
break; |
235 |
– |
} |
236 |
– |
CPUIs68060 = false; |
237 |
– |
|
238 |
– |
// Load XPRAM |
239 |
– |
XPRAMInit(); |
240 |
– |
|
241 |
– |
// Set boot volume |
242 |
– |
int16 i16 = PrefsFindInt16("bootdrive"); |
243 |
– |
XPRAM[0x78] = i16 >> 8; |
244 |
– |
XPRAM[0x79] = i16 & 0xff; |
245 |
– |
i16 = PrefsFindInt16("bootdriver"); |
246 |
– |
XPRAM[0x7a] = i16 >> 8; |
247 |
– |
XPRAM[0x7b] = i16 & 0xff; |
205 |
|
|
206 |
|
// Start XPRAM watchdog thread |
207 |
|
xpram_thread_active = (pthread_create(&xpram_thread, NULL, xpram_func, NULL) == 0); |
208 |
|
|
252 |
– |
// Init drivers |
253 |
– |
SonyInit(); |
254 |
– |
DiskInit(); |
255 |
– |
CDROMInit(); |
256 |
– |
SCSIInit(); |
257 |
– |
|
258 |
– |
// Init serial ports |
259 |
– |
SerialInit(); |
260 |
– |
|
261 |
– |
// Init network |
262 |
– |
EtherInit(); |
263 |
– |
|
264 |
– |
// Init Time Manager |
265 |
– |
TimerInit(); |
266 |
– |
|
267 |
– |
// Init clipboard |
268 |
– |
ClipInit(); |
269 |
– |
|
270 |
– |
// Init audio |
271 |
– |
AudioInit(); |
272 |
– |
|
273 |
– |
// Init video |
274 |
– |
if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC)) |
275 |
– |
QuitEmulator(); |
276 |
– |
|
277 |
– |
// Init 680x0 emulation (this also activates the memory system which is needed for PatchROM()) |
278 |
– |
if (!Init680x0()) |
279 |
– |
QuitEmulator(); |
280 |
– |
|
281 |
– |
// Install ROM patches |
282 |
– |
if (!PatchROM()) { |
283 |
– |
ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR)); |
284 |
– |
QuitEmulator(); |
285 |
– |
} |
286 |
– |
|
209 |
|
#if defined(HAVE_TIMER_CREATE) && defined(_POSIX_REALTIME_SIGNALS) |
210 |
|
// Start 60Hz timer |
211 |
|
sigemptyset(&timer_sa.sa_mask); |
292 |
|
pthread_join(xpram_thread, NULL); |
293 |
|
} |
294 |
|
|
295 |
< |
// Save XPRAM |
296 |
< |
XPRAMExit(); |
375 |
< |
|
376 |
< |
// Exit video |
377 |
< |
VideoExit(); |
378 |
< |
|
379 |
< |
// Exit audio |
380 |
< |
AudioExit(); |
381 |
< |
|
382 |
< |
// Exit clipboard |
383 |
< |
ClipExit(); |
384 |
< |
|
385 |
< |
// Exit Time Manager |
386 |
< |
TimerExit(); |
387 |
< |
|
388 |
< |
// Exit serial ports |
389 |
< |
SerialExit(); |
390 |
< |
|
391 |
< |
// Exit network |
392 |
< |
EtherExit(); |
393 |
< |
|
394 |
< |
// Exit drivers |
395 |
< |
SCSIExit(); |
396 |
< |
CDROMExit(); |
397 |
< |
DiskExit(); |
398 |
< |
SonyExit(); |
295 |
> |
// Deinitialize everything |
296 |
> |
ExitAll(); |
297 |
|
|
298 |
|
// Delete ROM area |
299 |
|
delete[] ROMBaseHost; |