mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-15 13:05:35 +00:00
"idlewait" support for Linux and NewWorld ROMs
This commit is contained in:
parent
237ab8ffc6
commit
28eb840182
@ -53,6 +53,9 @@ typedef off_t loff_t;
|
||||
typedef uint32 uintptr;
|
||||
typedef int32 intptr;
|
||||
|
||||
// Timing functions
|
||||
extern void Delay_usec(uint32 usec);
|
||||
|
||||
// Macro for calling MacOS routines
|
||||
#define CallMacOS(type, proc) (*(type)proc)()
|
||||
#define CallMacOS1(type, proc, arg1) (*(type)proc)(arg1)
|
||||
|
@ -40,6 +40,7 @@ prefs_desc platform_prefs_items[] = {
|
||||
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
|
||||
{"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"},
|
||||
#endif
|
||||
{"idlewait", TYPE_BOOLEAN, false, "sleep when idle"},
|
||||
{NULL, TYPE_END, false, NULL} // End of list
|
||||
};
|
||||
|
||||
@ -122,4 +123,5 @@ void AddPlatformPrefsDefaults(void)
|
||||
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
|
||||
PrefsAddBool("ignoresegv", false);
|
||||
#endif
|
||||
PrefsAddBool("idlewait", true);
|
||||
}
|
||||
|
@ -456,15 +456,19 @@ void EmulOp(M68kRegisters *r, uint32 pc, int selector)
|
||||
break;
|
||||
|
||||
case OP_IDLE_TIME:
|
||||
#if __BEOS__
|
||||
// Sleep if no events pending
|
||||
if (ReadMacInt32(0x14c) == 0) {
|
||||
sleep(16667);
|
||||
}
|
||||
#endif
|
||||
if (ReadMacInt32(0x14c) == 0)
|
||||
Delay_usec(16667);
|
||||
r->a[0] = ReadMacInt32(0x2b6);
|
||||
break;
|
||||
|
||||
case OP_IDLE_TIME_2:
|
||||
// Sleep if no events pending
|
||||
if (ReadMacInt32(0x14c) == 0)
|
||||
Delay_usec(16667);
|
||||
r->d[0] = (uint32)-2;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("FATAL: EMUL_OP called with bogus selector %08x\n", selector);
|
||||
QuitEmulator();
|
||||
|
@ -48,7 +48,7 @@ enum { // Selectors for EMUL_OP opcodes
|
||||
OP_DEBUG_STR, OP_INSTALL_DRIVERS, OP_NAME_REGISTRY, OP_RESET, OP_IRQ,
|
||||
OP_SCSI_DISPATCH, OP_SCSI_ATOMIC,
|
||||
OP_NTRB_17_PATCH, OP_NTRB_17_PATCH2, OP_NTRB_17_PATCH3, OP_CHECKLOAD,
|
||||
OP_EXTFS_COMM, OP_EXTFS_HFS, OP_IDLE_TIME,
|
||||
OP_EXTFS_COMM, OP_EXTFS_HFS, OP_IDLE_TIME, OP_IDLE_TIME_2,
|
||||
OP_MAX
|
||||
};
|
||||
const uint16 M68K_EMUL_RETURN = 0xfe40; // Extended opcodes
|
||||
@ -103,6 +103,7 @@ const uint16 M68K_EMUL_OP_CHECKLOAD = M68K_EMUL_BREAK + OP_CHECKLOAD;
|
||||
const uint16 M68K_EMUL_OP_EXTFS_COMM = M68K_EMUL_BREAK + OP_EXTFS_COMM;
|
||||
const uint16 M68K_EMUL_OP_EXTFS_HFS = M68K_EMUL_BREAK + OP_EXTFS_HFS;
|
||||
const uint16 M68K_EMUL_OP_IDLE_TIME = M68K_EMUL_BREAK + OP_IDLE_TIME;
|
||||
const uint16 M68K_EMUL_OP_IDLE_TIME_2 = M68K_EMUL_BREAK + OP_IDLE_TIME_2;
|
||||
|
||||
extern "C" void EmulOp(M68kRegisters *r, uint32 pc, int selector);
|
||||
|
||||
|
@ -2228,19 +2228,20 @@ static bool patch_68k(void)
|
||||
lp = (uint32 *)(ROM_BASE + ntohl(*lp));
|
||||
lp[0xa9fd & 0x3ff] = htonl(GET_SCRAP_PATCH_SPACE);
|
||||
|
||||
#if __BEOS__
|
||||
// Patch SynchIdleTime()
|
||||
if (PrefsFindBool("idlewait")) {
|
||||
wp = (uint16 *)(ROM_BASE + find_rom_trap(0xabf7) + 4); // SynchIdleTime()
|
||||
D(bug("SynchIdleTime at %08lx\n", wp));
|
||||
if (ntohs(*wp) == 0x2078) {
|
||||
if (ntohs(*wp) == 0x2078) { // movea.l ExpandMem,a0
|
||||
*wp++ = htons(M68K_EMUL_OP_IDLE_TIME);
|
||||
*wp = htons(M68K_NOP);
|
||||
} else {
|
||||
}
|
||||
else if (ntohs(*wp) == 0x70fe) // moveq #-2,d0
|
||||
*wp++ = htons(M68K_EMUL_OP_IDLE_TIME_2);
|
||||
else {
|
||||
D(bug("SynchIdleTime patch not installed\n"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Construct list of all sifters used by sound components in ROM
|
||||
D(bug("Searching for sound components with type sdev in ROM\n"));
|
||||
|
Loading…
Reference in New Issue
Block a user