1 |
|
/* |
2 |
|
* emul_op.cpp - 68k opcodes for ROM patches |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2001 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 |
42 |
|
#include "extfs.h" |
43 |
|
#include "emul_op.h" |
44 |
|
|
45 |
< |
#if ENABLE_MON |
45 |
> |
#ifdef ENABLE_MON |
46 |
|
#include "mon.h" |
47 |
|
#endif |
48 |
|
|
68 |
|
r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7], |
69 |
|
r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7], |
70 |
|
r->sr); |
71 |
< |
#if ENABLE_MON |
72 |
< |
char *arg[2]; |
73 |
< |
arg[0] = "rmon"; |
74 |
< |
arg[1] = NULL; |
75 |
< |
mon(1, arg); |
71 |
> |
VideoQuitFullScreen(); |
72 |
> |
#ifdef ENABLE_MON |
73 |
> |
char *arg[4] = {"mon", "-m", "-r", NULL}; |
74 |
> |
mon(3, arg); |
75 |
|
#endif |
76 |
|
QuitEmulator(); |
77 |
|
break; |
85 |
|
D(bug("*** RESET ***\n")); |
86 |
|
TimerReset(); |
87 |
|
EtherReset(); |
88 |
+ |
AudioReset(); |
89 |
|
|
90 |
|
// Create BootGlobs at top of memory |
91 |
< |
memset((void *)(RAMBaseHost + RAMSize - 4096), 0, 4096); |
91 |
> |
Mac_memset(RAMBaseMac + RAMSize - 4096, 0, 4096); |
92 |
|
uint32 boot_globs = RAMBaseMac + RAMSize - 0x1c; |
93 |
|
WriteMacInt32(boot_globs + 0x00, RAMBaseMac); // First RAM bank |
94 |
|
WriteMacInt32(boot_globs + 0x04, RAMSize); |
197 |
|
break; |
198 |
|
|
199 |
|
case M68K_EMUL_OP_FIX_BOOTSTACK: // Set boot stack to 3/4 of RAM (7.5) |
200 |
– |
D(bug("Fix boot stack\n")); |
200 |
|
r->a[1] = RAMBaseMac + RAMSize * 3 / 4; |
201 |
+ |
D(bug("Fix boot stack %08x\n", r->a[1])); |
202 |
|
break; |
203 |
|
|
204 |
|
case M68K_EMUL_OP_FIX_MEMSIZE: { // Set correct logical and physical memory size |
349 |
|
EtherReadPacket((uint8 **)&r->a[0], r->a[3], r->d[3], r->d[1]); |
350 |
|
break; |
351 |
|
|
352 |
+ |
case M68K_EMUL_OP_SOUNDIN_OPEN: // Sound input driver functions |
353 |
+ |
r->d[0] = SoundInOpen(r->a[0], r->a[1]); |
354 |
+ |
break; |
355 |
+ |
|
356 |
+ |
case M68K_EMUL_OP_SOUNDIN_PRIME: |
357 |
+ |
r->d[0] = SoundInPrime(r->a[0], r->a[1]); |
358 |
+ |
break; |
359 |
+ |
|
360 |
+ |
case M68K_EMUL_OP_SOUNDIN_CONTROL: |
361 |
+ |
r->d[0] = SoundInControl(r->a[0], r->a[1]); |
362 |
+ |
break; |
363 |
+ |
|
364 |
+ |
case M68K_EMUL_OP_SOUNDIN_STATUS: |
365 |
+ |
r->d[0] = SoundInStatus(r->a[0], r->a[1]); |
366 |
+ |
break; |
367 |
+ |
|
368 |
+ |
case M68K_EMUL_OP_SOUNDIN_CLOSE: |
369 |
+ |
r->d[0] = SoundInClose(r->a[0], r->a[1]); |
370 |
+ |
break; |
371 |
+ |
|
372 |
|
case M68K_EMUL_OP_SCSI_DISPATCH: { // SCSIDispatch() replacement |
373 |
|
uint32 ret = ReadMacInt32(r->a[7]); // Get return address |
374 |
|
uint16 sel = ReadMacInt16(r->a[7] + 4); // Get selector |
432 |
|
break; |
433 |
|
} |
434 |
|
|
415 |
– |
case M68K_EMUL_OP_MEMORY_DISPATCH: { // MemoryDispatch() replacement routine |
416 |
– |
int16 sel = r->d[0]; |
417 |
– |
D(bug("MemoryDispatch(%d)\n", sel)); |
418 |
– |
switch (sel) { |
419 |
– |
case -6: // GetLogicalRAMSize |
420 |
– |
r->d[0] = RAMSize; |
421 |
– |
break; |
422 |
– |
case -3: |
423 |
– |
r->d[0] = 0x1000; |
424 |
– |
break; |
425 |
– |
case 0: // HoldMemory |
426 |
– |
case 1: // UnholdMemory |
427 |
– |
case 2: // LockMemory |
428 |
– |
case 3: // UnlockMemory |
429 |
– |
case 4: // LockMemoryContiguous |
430 |
– |
case 6: // ProtectMemory |
431 |
– |
case 7: // UnprotectMemory |
432 |
– |
r->d[0] = 0; |
433 |
– |
break; |
434 |
– |
default: |
435 |
– |
printf("FATAL: MemoryDispatch(%d): illegal selector\n", sel); |
436 |
– |
r->d[0] = (uint32)-502; |
437 |
– |
break; |
438 |
– |
} |
439 |
– |
break; |
440 |
– |
} |
441 |
– |
|
435 |
|
case M68K_EMUL_OP_IRQ: // Level 1 interrupt |
436 |
|
r->d[0] = 0; |
437 |
+ |
|
438 |
|
if (InterruptFlags & INTFLAG_60HZ) { |
439 |
|
ClearInterruptFlag(INTFLAG_60HZ); |
440 |
|
if (HasMacStarted()) { |
443 |
|
ADBInterrupt(); |
444 |
|
TimerInterrupt(); |
445 |
|
VideoInterrupt(); |
452 |
– |
SonyInterrupt(); |
453 |
– |
DiskInterrupt(); |
454 |
– |
CDROMInterrupt(); |
446 |
|
|
447 |
|
// Call DoVBLTask(0) |
448 |
|
if (ROMVersion == ROM_VERSION_32) { |
454 |
|
r->d[0] = 1; // Flag: 68k interrupt routine executes VBLTasks etc. |
455 |
|
} |
456 |
|
} |
457 |
+ |
|
458 |
+ |
if (InterruptFlags & INTFLAG_1HZ) { |
459 |
+ |
ClearInterruptFlag(INTFLAG_1HZ); |
460 |
+ |
|
461 |
+ |
if (HasMacStarted()) { |
462 |
+ |
SonyInterrupt(); |
463 |
+ |
DiskInterrupt(); |
464 |
+ |
CDROMInterrupt(); |
465 |
+ |
} |
466 |
+ |
} |
467 |
+ |
|
468 |
|
if (InterruptFlags & INTFLAG_SERIAL) { |
469 |
|
ClearInterruptFlag(INTFLAG_SERIAL); |
470 |
|
SerialInterrupt(); |
471 |
|
} |
472 |
+ |
|
473 |
|
if (InterruptFlags & INTFLAG_ETHER) { |
474 |
|
ClearInterruptFlag(INTFLAG_ETHER); |
475 |
|
EtherInterrupt(); |
476 |
|
} |
477 |
+ |
|
478 |
|
if (InterruptFlags & INTFLAG_AUDIO) { |
479 |
|
ClearInterruptFlag(INTFLAG_AUDIO); |
480 |
|
AudioInterrupt(); |
481 |
|
} |
482 |
+ |
|
483 |
+ |
if (InterruptFlags & INTFLAG_NMI) { |
484 |
+ |
ClearInterruptFlag(INTFLAG_NMI); |
485 |
+ |
if (HasMacStarted()) { |
486 |
+ |
TriggerNMI(); |
487 |
+ |
} |
488 |
+ |
} |
489 |
|
break; |
490 |
|
|
491 |
|
case M68K_EMUL_OP_PUT_SCRAP: { // PutScrap() patch |
524 |
|
break; |
525 |
|
#endif |
526 |
|
|
527 |
< |
case M68K_EMUL_OP_BLOCK_MOVE: // BlockMove() replacement |
528 |
< |
memmove(Mac2HostAddr(r->a[1]), Mac2HostAddr(r->a[0]), r->d[0]); |
527 |
> |
case M68K_EMUL_OP_BLOCK_MOVE: // BlockMove() cache flushing |
528 |
> |
FlushCodeCache(Mac2HostAddr(r->a[0]), r->a[1]); |
529 |
> |
break; |
530 |
> |
|
531 |
> |
case M68K_EMUL_OP_DEBUGUTIL: |
532 |
> |
// printf("DebugUtil d0=%08lx a5=%08lx\n", r->d[0], r->a[5]); |
533 |
> |
r->d[0] = DebugUtil(r->d[0]); |
534 |
|
break; |
535 |
|
|
536 |
|
default: |
543 |
|
r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7], |
544 |
|
r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7], |
545 |
|
r->sr); |
546 |
+ |
#ifdef ENABLE_MON |
547 |
+ |
char *arg[4] = {"mon", "-m", "-r", NULL}; |
548 |
+ |
mon(3, arg); |
549 |
+ |
#endif |
550 |
|
QuitEmulator(); |
551 |
|
break; |
552 |
|
} |