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