1 |
|
/* |
2 |
|
* emul_op.cpp - 68k opcodes for ROM patches |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2000 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 |
71 |
> |
#ifdef ENABLE_MON |
72 |
|
char *arg[2] = {"rmon", NULL}; |
73 |
|
mon(1, arg); |
74 |
|
#endif |
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) |
198 |
– |
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 |
411 |
|
break; |
412 |
|
} |
413 |
|
|
413 |
– |
case M68K_EMUL_OP_MEMORY_DISPATCH: { // MemoryDispatch() replacement routine |
414 |
– |
int16 sel = r->d[0]; |
415 |
– |
D(bug("MemoryDispatch(%d)\n", sel)); |
416 |
– |
switch (sel) { |
417 |
– |
case -6: // GetLogicalRAMSize |
418 |
– |
r->d[0] = RAMSize; |
419 |
– |
break; |
420 |
– |
case -3: |
421 |
– |
r->d[0] = 0x1000; |
422 |
– |
break; |
423 |
– |
case 0: // HoldMemory |
424 |
– |
case 1: // UnholdMemory |
425 |
– |
case 2: // LockMemory |
426 |
– |
case 3: // UnlockMemory |
427 |
– |
case 4: // LockMemoryContiguous |
428 |
– |
case 6: // ProtectMemory |
429 |
– |
case 7: // UnprotectMemory |
430 |
– |
r->d[0] = 0; |
431 |
– |
break; |
432 |
– |
default: |
433 |
– |
printf("FATAL: MemoryDispatch(%d): unimplemented selector\n", sel); |
434 |
– |
r->d[0] = (uint32)-502; |
435 |
– |
break; |
436 |
– |
} |
437 |
– |
break; |
438 |
– |
} |
439 |
– |
|
414 |
|
case M68K_EMUL_OP_IRQ: // Level 1 interrupt |
415 |
|
r->d[0] = 0; |
416 |
+ |
|
417 |
|
if (InterruptFlags & INTFLAG_60HZ) { |
418 |
|
ClearInterruptFlag(INTFLAG_60HZ); |
419 |
|
if (HasMacStarted()) { |
422 |
|
ADBInterrupt(); |
423 |
|
TimerInterrupt(); |
424 |
|
VideoInterrupt(); |
450 |
– |
SonyInterrupt(); |
451 |
– |
DiskInterrupt(); |
452 |
– |
CDROMInterrupt(); |
425 |
|
|
426 |
|
// Call DoVBLTask(0) |
427 |
|
if (ROMVersion == ROM_VERSION_32) { |
433 |
|
r->d[0] = 1; // Flag: 68k interrupt routine executes VBLTasks etc. |
434 |
|
} |
435 |
|
} |
436 |
+ |
|
437 |
+ |
if (InterruptFlags & INTFLAG_1HZ) { |
438 |
+ |
ClearInterruptFlag(INTFLAG_1HZ); |
439 |
+ |
|
440 |
+ |
if (HasMacStarted()) { |
441 |
+ |
SonyInterrupt(); |
442 |
+ |
DiskInterrupt(); |
443 |
+ |
CDROMInterrupt(); |
444 |
+ |
} |
445 |
+ |
} |
446 |
+ |
|
447 |
|
if (InterruptFlags & INTFLAG_SERIAL) { |
448 |
|
ClearInterruptFlag(INTFLAG_SERIAL); |
449 |
|
SerialInterrupt(); |
450 |
|
} |
451 |
+ |
|
452 |
|
if (InterruptFlags & INTFLAG_ETHER) { |
453 |
|
ClearInterruptFlag(INTFLAG_ETHER); |
454 |
|
EtherInterrupt(); |
455 |
|
} |
456 |
+ |
|
457 |
|
if (InterruptFlags & INTFLAG_AUDIO) { |
458 |
|
ClearInterruptFlag(INTFLAG_AUDIO); |
459 |
|
AudioInterrupt(); |
501 |
|
break; |
502 |
|
|
503 |
|
default: |
504 |
< |
printf("FATAL: EMUL_OP called with bogus opcode %08x\n", opcode); |
505 |
< |
printf("d0 %08lx d1 %08lx d2 %08lx d3 %08lx\n" |
506 |
< |
"d4 %08lx d5 %08lx d6 %08lx d7 %08lx\n" |
507 |
< |
"a0 %08lx a1 %08lx a2 %08lx a3 %08lx\n" |
508 |
< |
"a4 %08lx a5 %08lx a6 %08lx a7 %08lx\n" |
504 |
> |
printf("FATAL: EMUL_OP called with bogus opcode %04x\n", opcode); |
505 |
> |
printf("d0 %08x d1 %08x d2 %08x d3 %08x\n" |
506 |
> |
"d4 %08x d5 %08x d6 %08x d7 %08x\n" |
507 |
> |
"a0 %08x a1 %08x a2 %08x a3 %08x\n" |
508 |
> |
"a4 %08x a5 %08x a6 %08x a7 %08x\n" |
509 |
|
"sr %04x\n", |
510 |
|
r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7], |
511 |
|
r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7], |
512 |
|
r->sr); |
513 |
< |
#if ENABLE_MON |
513 |
> |
#ifdef ENABLE_MON |
514 |
|
char *arg[2] = {"rmon", NULL}; |
515 |
|
mon(1, arg); |
516 |
|
#endif |