1 |
|
/* |
2 |
|
* emul_op.cpp - 68k opcodes for ROM patches |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 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 |
|
|
60 |
|
switch (opcode) { |
61 |
|
case M68K_EMUL_BREAK: { // Breakpoint |
62 |
|
printf("*** Breakpoint\n"); |
63 |
< |
printf("d0 %08lx d1 %08lx d2 %08lx d3 %08lx\n" |
64 |
< |
"d4 %08lx d5 %08lx d6 %08lx d7 %08lx\n" |
65 |
< |
"a0 %08lx a1 %08lx a2 %08lx a3 %08lx\n" |
66 |
< |
"a4 %08lx a5 %08lx a6 %08lx a7 %08lx\n" |
63 |
> |
printf("d0 %08x d1 %08x d2 %08x d3 %08x\n" |
64 |
> |
"d4 %08x d5 %08x d6 %08x d7 %08x\n" |
65 |
> |
"a0 %08x a1 %08x a2 %08x a3 %08x\n" |
66 |
> |
"a4 %08x a5 %08x a6 %08x a7 %08x\n" |
67 |
|
"sr %04x\n", |
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] = {"rmon", NULL}; |
73 |
< |
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) |
198 |
– |
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 |
434 |
|
|
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 |
+ |
|
441 |
+ |
// Increment Ticks variable |
442 |
+ |
WriteMacInt32(0x16a, ReadMacInt32(0x16a) + 1); |
443 |
+ |
|
444 |
|
if (HasMacStarted()) { |
445 |
|
|
446 |
|
// Mac has started, execute all 60Hz interrupt functions |
420 |
– |
ADBInterrupt(); |
447 |
|
TimerInterrupt(); |
448 |
|
VideoInterrupt(); |
423 |
– |
SonyInterrupt(); |
424 |
– |
DiskInterrupt(); |
425 |
– |
CDROMInterrupt(); |
449 |
|
|
450 |
|
// Call DoVBLTask(0) |
451 |
|
if (ROMVersion == ROM_VERSION_32) { |
457 |
|
r->d[0] = 1; // Flag: 68k interrupt routine executes VBLTasks etc. |
458 |
|
} |
459 |
|
} |
460 |
+ |
|
461 |
+ |
if (InterruptFlags & INTFLAG_1HZ) { |
462 |
+ |
ClearInterruptFlag(INTFLAG_1HZ); |
463 |
+ |
if (HasMacStarted()) { |
464 |
+ |
SonyInterrupt(); |
465 |
+ |
DiskInterrupt(); |
466 |
+ |
CDROMInterrupt(); |
467 |
+ |
} |
468 |
+ |
} |
469 |
+ |
|
470 |
|
if (InterruptFlags & INTFLAG_SERIAL) { |
471 |
|
ClearInterruptFlag(INTFLAG_SERIAL); |
472 |
|
SerialInterrupt(); |
473 |
|
} |
474 |
+ |
|
475 |
|
if (InterruptFlags & INTFLAG_ETHER) { |
476 |
|
ClearInterruptFlag(INTFLAG_ETHER); |
477 |
|
EtherInterrupt(); |
478 |
|
} |
479 |
+ |
|
480 |
|
if (InterruptFlags & INTFLAG_AUDIO) { |
481 |
|
ClearInterruptFlag(INTFLAG_AUDIO); |
482 |
|
AudioInterrupt(); |
483 |
|
} |
484 |
+ |
|
485 |
+ |
if (InterruptFlags & INTFLAG_ADB) { |
486 |
+ |
ClearInterruptFlag(INTFLAG_ADB); |
487 |
+ |
if (HasMacStarted()) |
488 |
+ |
ADBInterrupt(); |
489 |
+ |
} |
490 |
+ |
|
491 |
+ |
if (InterruptFlags & INTFLAG_NMI) { |
492 |
+ |
ClearInterruptFlag(INTFLAG_NMI); |
493 |
+ |
if (HasMacStarted()) |
494 |
+ |
TriggerNMI(); |
495 |
+ |
} |
496 |
|
break; |
497 |
|
|
498 |
|
case M68K_EMUL_OP_PUT_SCRAP: { // PutScrap() patch |
531 |
|
break; |
532 |
|
#endif |
533 |
|
|
534 |
< |
case M68K_EMUL_OP_BLOCK_MOVE: // BlockMove() replacement |
535 |
< |
memmove(Mac2HostAddr(r->a[1]), Mac2HostAddr(r->a[0]), r->d[0]); |
534 |
> |
case M68K_EMUL_OP_BLOCK_MOVE: // BlockMove() cache flushing |
535 |
> |
FlushCodeCache(Mac2HostAddr(r->a[0]), r->a[1]); |
536 |
> |
break; |
537 |
> |
|
538 |
> |
case M68K_EMUL_OP_DEBUGUTIL: |
539 |
> |
// printf("DebugUtil d0=%08lx a5=%08lx\n", r->d[0], r->a[5]); |
540 |
> |
r->d[0] = DebugUtil(r->d[0]); |
541 |
|
break; |
542 |
|
|
543 |
|
default: |
544 |
|
printf("FATAL: EMUL_OP called with bogus opcode %08x\n", opcode); |
545 |
< |
printf("d0 %08lx d1 %08lx d2 %08lx d3 %08lx\n" |
546 |
< |
"d4 %08lx d5 %08lx d6 %08lx d7 %08lx\n" |
547 |
< |
"a0 %08lx a1 %08lx a2 %08lx a3 %08lx\n" |
548 |
< |
"a4 %08lx a5 %08lx a6 %08lx a7 %08lx\n" |
545 |
> |
printf("d0 %08x d1 %08x d2 %08x d3 %08x\n" |
546 |
> |
"d4 %08x d5 %08x d6 %08x d7 %08x\n" |
547 |
> |
"a0 %08x a1 %08x a2 %08x a3 %08x\n" |
548 |
> |
"a4 %08x a5 %08x a6 %08x a7 %08x\n" |
549 |
|
"sr %04x\n", |
550 |
|
r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7], |
551 |
|
r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7], |
552 |
|
r->sr); |
553 |
< |
#if ENABLE_MON |
554 |
< |
char *arg[2] = {"rmon", NULL}; |
555 |
< |
mon(1, arg); |
553 |
> |
#ifdef ENABLE_MON |
554 |
> |
char *arg[4] = {"mon", "-m", "-r", NULL}; |
555 |
> |
mon(3, arg); |
556 |
|
#endif |
557 |
|
QuitEmulator(); |
558 |
|
break; |