1 |
|
/* |
2 |
|
* emul_op.cpp - 68k opcodes for ROM patches |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 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 |
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 |
+ |
VideoQuitFullScreen(); |
72 |
|
#ifdef ENABLE_MON |
73 |
|
char *arg[4] = {"mon", "-m", "-r", NULL}; |
74 |
|
mon(3, arg); |
236 |
|
|
237 |
|
// Install PutScrap() patch |
238 |
|
M68kRegisters r; |
239 |
< |
r.d[0] = 0xa9fe; |
240 |
< |
r.a[0] = PutScrapPatch; |
241 |
< |
Execute68kTrap(0xa647, &r); // SetToolTrap() |
239 |
> |
if (PutScrapPatch) { |
240 |
> |
r.d[0] = 0xa9fe; |
241 |
> |
r.a[0] = PutScrapPatch; |
242 |
> |
Execute68kTrap(0xa647, &r); // SetToolTrap() |
243 |
> |
} |
244 |
> |
|
245 |
> |
// Install GetScrap() patch |
246 |
> |
if (GetScrapPatch) { |
247 |
> |
r.d[0] = 0xa9fd; |
248 |
> |
r.a[0] = GetScrapPatch; |
249 |
> |
Execute68kTrap(0xa647, &r); // SetToolTrap() |
250 |
> |
} |
251 |
|
|
252 |
|
// Setup fake ASC registers |
253 |
|
if (ROMVersion == ROM_VERSION_32) { |
355 |
|
break; |
356 |
|
|
357 |
|
case M68K_EMUL_OP_ETHER_READ_PACKET: |
358 |
< |
EtherReadPacket((uint8 **)&r->a[0], r->a[3], r->d[3], r->d[1]); |
358 |
> |
EtherReadPacket(r->a[0], r->a[3], r->d[3], r->d[1]); |
359 |
|
break; |
360 |
|
|
361 |
|
case M68K_EMUL_OP_SOUNDIN_OPEN: // Sound input driver functions |
446 |
|
|
447 |
|
if (InterruptFlags & INTFLAG_60HZ) { |
448 |
|
ClearInterruptFlag(INTFLAG_60HZ); |
449 |
+ |
|
450 |
+ |
// Increment Ticks variable |
451 |
+ |
WriteMacInt32(0x16a, ReadMacInt32(0x16a) + 1); |
452 |
+ |
|
453 |
|
if (HasMacStarted()) { |
454 |
|
|
455 |
|
// Mac has started, execute all 60Hz interrupt functions |
442 |
– |
ADBInterrupt(); |
456 |
|
TimerInterrupt(); |
457 |
|
VideoInterrupt(); |
458 |
|
|
469 |
|
|
470 |
|
if (InterruptFlags & INTFLAG_1HZ) { |
471 |
|
ClearInterruptFlag(INTFLAG_1HZ); |
459 |
– |
|
472 |
|
if (HasMacStarted()) { |
473 |
|
SonyInterrupt(); |
474 |
|
DiskInterrupt(); |
491 |
|
AudioInterrupt(); |
492 |
|
} |
493 |
|
|
494 |
+ |
if (InterruptFlags & INTFLAG_ADB) { |
495 |
+ |
ClearInterruptFlag(INTFLAG_ADB); |
496 |
+ |
if (HasMacStarted()) |
497 |
+ |
ADBInterrupt(); |
498 |
+ |
} |
499 |
+ |
|
500 |
|
if (InterruptFlags & INTFLAG_NMI) { |
501 |
|
ClearInterruptFlag(INTFLAG_NMI); |
502 |
< |
if (HasMacStarted()) { |
502 |
> |
if (HasMacStarted()) |
503 |
|
TriggerNMI(); |
486 |
– |
} |
504 |
|
} |
505 |
|
break; |
506 |
|
|
512 |
|
break; |
513 |
|
} |
514 |
|
|
515 |
+ |
case M68K_EMUL_OP_GET_SCRAP: { // GetScrap() patch |
516 |
+ |
void **scrap_handle = (void **)Mac2HostAddr(ReadMacInt32(r->a[7] + 4)); |
517 |
+ |
uint32 type = ReadMacInt32(r->a[7] + 8); |
518 |
+ |
int32 length = ReadMacInt32(r->a[7] + 12); |
519 |
+ |
GetScrap(scrap_handle, type, length); |
520 |
+ |
break; |
521 |
+ |
} |
522 |
+ |
|
523 |
|
case M68K_EMUL_OP_CHECKLOAD: { // vCheckLoad() patch (resource loader) |
524 |
|
uint32 type = r->d[1]; |
525 |
|
int16 id = ReadMacInt16(r->a[2]); |
557 |
|
r->d[0] = DebugUtil(r->d[0]); |
558 |
|
break; |
559 |
|
|
560 |
+ |
case M68K_EMUL_OP_IDLE_TIME: // SynchIdleTime() patch |
561 |
+ |
// Sleep if no events pending |
562 |
+ |
if (ReadMacInt32(0x14c) == 0) |
563 |
+ |
idle_wait(); |
564 |
+ |
r->a[0] = ReadMacInt32(0x2b6); |
565 |
+ |
break; |
566 |
+ |
|
567 |
|
default: |
568 |
|
printf("FATAL: EMUL_OP called with bogus opcode %08x\n", opcode); |
569 |
< |
printf("d0 %08lx d1 %08lx d2 %08lx d3 %08lx\n" |
570 |
< |
"d4 %08lx d5 %08lx d6 %08lx d7 %08lx\n" |
571 |
< |
"a0 %08lx a1 %08lx a2 %08lx a3 %08lx\n" |
572 |
< |
"a4 %08lx a5 %08lx a6 %08lx a7 %08lx\n" |
569 |
> |
printf("d0 %08x d1 %08x d2 %08x d3 %08x\n" |
570 |
> |
"d4 %08x d5 %08x d6 %08x d7 %08x\n" |
571 |
> |
"a0 %08x a1 %08x a2 %08x a3 %08x\n" |
572 |
> |
"a4 %08x a5 %08x a6 %08x a7 %08x\n" |
573 |
|
"sr %04x\n", |
574 |
|
r->d[0], r->d[1], r->d[2], r->d[3], r->d[4], r->d[5], r->d[6], r->d[7], |
575 |
|
r->a[0], r->a[1], r->a[2], r->a[3], r->a[4], r->a[5], r->a[6], r->a[7], |