34 |
|
#include "cpu_emulation.h" |
35 |
|
#include "xpram.h" |
36 |
|
#include "timer.h" |
37 |
– |
#include "sony.h" |
38 |
– |
#include "disk.h" |
39 |
– |
#include "cdrom.h" |
40 |
– |
#include "scsi.h" |
41 |
– |
#include "audio.h" |
37 |
|
#include "video.h" |
43 |
– |
#include "serial.h" |
44 |
– |
#include "ether.h" |
45 |
– |
#include "clip.h" |
38 |
|
#include "rom_patches.h" |
39 |
|
#include "prefs.h" |
40 |
|
#include "prefs_editor.h" |
268 |
|
return; |
269 |
|
} |
270 |
|
|
271 |
< |
// Check ROM version |
272 |
< |
if (!CheckROM()) { |
281 |
< |
ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR)); |
282 |
< |
PostMessage(B_QUIT_REQUESTED); |
283 |
< |
return; |
284 |
< |
} |
285 |
< |
|
286 |
< |
// Set CPU and FPU type (UAE emulation) |
287 |
< |
switch (ROMVersion) { |
288 |
< |
case ROM_VERSION_64K: |
289 |
< |
case ROM_VERSION_PLUS: |
290 |
< |
case ROM_VERSION_CLASSIC: |
291 |
< |
CPUType = 0; |
292 |
< |
FPUType = 0; |
293 |
< |
TwentyFourBitAddressing = true; |
294 |
< |
break; |
295 |
< |
case ROM_VERSION_II: |
296 |
< |
CPUType = 2; |
297 |
< |
FPUType = PrefsFindBool("fpu") ? 1 : 0; |
298 |
< |
TwentyFourBitAddressing = true; |
299 |
< |
break; |
300 |
< |
case ROM_VERSION_32: |
301 |
< |
CPUType = 3; |
302 |
< |
FPUType = PrefsFindBool("fpu") ? 1 : 0; |
303 |
< |
TwentyFourBitAddressing = false; |
304 |
< |
break; |
305 |
< |
} |
306 |
< |
CPUIs68060 = false; |
307 |
< |
|
308 |
< |
// Load XPRAM |
309 |
< |
XPRAMInit(); |
310 |
< |
|
311 |
< |
// Set boot volume |
312 |
< |
int16 i16 = PrefsFindInt16("bootdrive"); |
313 |
< |
XPRAM[0x78] = i16 >> 8; |
314 |
< |
XPRAM[0x79] = i16 & 0xff; |
315 |
< |
i16 = PrefsFindInt16("bootdriver"); |
316 |
< |
XPRAM[0x7a] = i16 >> 8; |
317 |
< |
XPRAM[0x7b] = i16 & 0xff; |
318 |
< |
|
319 |
< |
// Start XPRAM watchdog thread |
320 |
< |
xpram_thread = spawn_thread(xpram_func, "XPRAM Watchdog", B_LOW_PRIORITY, this); |
321 |
< |
resume_thread(xpram_thread); |
322 |
< |
|
323 |
< |
// Init drivers |
324 |
< |
SonyInit(); |
325 |
< |
DiskInit(); |
326 |
< |
CDROMInit(); |
327 |
< |
SCSIInit(); |
328 |
< |
|
329 |
< |
// Init network |
330 |
< |
EtherInit(); |
331 |
< |
|
332 |
< |
// Init serial ports |
333 |
< |
SerialInit(); |
334 |
< |
|
335 |
< |
// Init Time Manager |
336 |
< |
TimerInit(); |
337 |
< |
|
338 |
< |
// Init clipboard |
339 |
< |
ClipInit(); |
340 |
< |
|
341 |
< |
// Init audio |
342 |
< |
AudioInit(); |
343 |
< |
|
344 |
< |
// Init video |
345 |
< |
if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC)) { |
346 |
< |
PostMessage(B_QUIT_REQUESTED); |
347 |
< |
return; |
348 |
< |
} |
349 |
< |
|
350 |
< |
// Init 680x0 emulation (this also activates the memory system which is needed for PatchROM()) |
351 |
< |
if (!Init680x0()) { |
352 |
< |
PostMessage(B_QUIT_REQUESTED); |
353 |
< |
return; |
354 |
< |
} |
355 |
< |
|
356 |
< |
// Install ROM patches |
357 |
< |
if (!PatchROM()) { |
358 |
< |
ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR)); |
271 |
> |
// Initialize everything |
272 |
> |
if (!InitAll()) { |
273 |
|
PostMessage(B_QUIT_REQUESTED); |
274 |
|
return; |
275 |
|
} |
280 |
|
// Disallow quitting with Alt-Q from now on |
281 |
|
AllowQuitting = false; |
282 |
|
|
283 |
+ |
// Start XPRAM watchdog thread |
284 |
+ |
xpram_thread = spawn_thread(xpram_func, "XPRAM Watchdog", B_LOW_PRIORITY, this); |
285 |
+ |
resume_thread(xpram_thread); |
286 |
+ |
|
287 |
|
// Start 60Hz interrupt |
288 |
|
tick_thread = spawn_thread(tick_func, "60Hz", B_REAL_TIME_PRIORITY, this); |
289 |
|
resume_thread(tick_thread); |
339 |
|
wait_for_thread(xpram_thread, &l); |
340 |
|
} |
341 |
|
|
342 |
< |
// Save XPRAM |
343 |
< |
XPRAMExit(); |
426 |
< |
|
427 |
< |
// Exit video |
428 |
< |
VideoExit(); |
429 |
< |
|
430 |
< |
// Exit audio |
431 |
< |
AudioExit(); |
432 |
< |
|
433 |
< |
// Exit clipboard |
434 |
< |
ClipExit(); |
435 |
< |
|
436 |
< |
// Exit Time Manager |
437 |
< |
TimerExit(); |
438 |
< |
|
439 |
< |
// Exit serial ports |
440 |
< |
SerialExit(); |
441 |
< |
|
442 |
< |
// Exit network |
443 |
< |
EtherExit(); |
444 |
< |
|
445 |
< |
// Exit drivers |
446 |
< |
SCSIExit(); |
447 |
< |
CDROMExit(); |
448 |
< |
DiskExit(); |
449 |
< |
SonyExit(); |
342 |
> |
// Deinitialize everything |
343 |
> |
ExitAll(); |
344 |
|
|
345 |
|
// Delete ROM area |
346 |
|
if (rom_area >= 0) |