diff --git a/BasiliskII/src/Unix/main_unix.cpp b/BasiliskII/src/Unix/main_unix.cpp index 4ed4dcf7..32900546 100755 --- a/BasiliskII/src/Unix/main_unix.cpp +++ b/BasiliskII/src/Unix/main_unix.cpp @@ -1268,13 +1268,15 @@ static void one_tick(...) } #ifdef USE_PTHREADS_SERVICES +bool tick_inhibit; static void *tick_func(void *arg) { uint64 start = GetTicks_usec(); int64 ticks = 0; uint64 next = start; while (!tick_thread_cancel) { - one_tick(); + if (!tick_inhibit) + one_tick(); next += 16625; int64 delay = next - GetTicks_usec(); if (delay > 0) diff --git a/BasiliskII/src/Windows/main_windows.cpp b/BasiliskII/src/Windows/main_windows.cpp index 06e83b5f..11651b1a 100644 --- a/BasiliskII/src/Windows/main_windows.cpp +++ b/BasiliskII/src/Windows/main_windows.cpp @@ -623,13 +623,15 @@ static void one_tick(...) } } +bool tick_inhibit; static int tick_func(void *arg) { uint64 start = GetTicks_usec(); int64 ticks = 0; uint64 next = GetTicks_usec(); while (!tick_thread_cancel) { - one_tick(); + if (!tick_inhibit) + one_tick(); next += 16625; int64 delay = next - GetTicks_usec(); if (delay > 0) diff --git a/BasiliskII/src/cdrom.cpp b/BasiliskII/src/cdrom.cpp index c4d36451..da664f07 100644 --- a/BasiliskII/src/cdrom.cpp +++ b/BasiliskII/src/cdrom.cpp @@ -32,6 +32,7 @@ #include #include +#include #ifndef NO_STD_NAMESPACE using std::vector; @@ -162,6 +163,7 @@ uint32 CDROMIconAddr; // Flag: Control(accRun) has been called, interrupt routine is now active static bool acc_run_called = false; +static std::map remount_map; /* * Get pointer to drive info or drives.end() if not found @@ -368,6 +370,17 @@ bool CDROMMountVolume(void *fh) return false; } +void CDROMRemount() { + for (std::map::iterator i = remount_map.begin(); i != remount_map.end(); ++i) + for (drive_vec::iterator info = drives.begin(); info != drives.end(); ++info) + if (info->num == i->first) { + last_drive_num = i->first; + info->fh = i->second; + break; + } + remount_map.clear(); +} + /* * Mount volumes for which the to_be_mounted flag is set @@ -568,13 +581,16 @@ int16 CDROMControl(uint32 pb, uint32 dce) case 7: // EjectTheDisc if (ReadMacInt8(info->status + dsDiskInPlace) > 0) { - SysAllowRemoval(info->fh); - SysEject(info->fh); - WriteMacInt8(info->status + dsDiskInPlace, 0); - info->twok_offset = -1; - info->close_fh(); + if (info->drop) { + SysAllowRemoval(info->fh); + SysEject(info->fh); + info->twok_offset = -1; + info->close_fh(); + info->drop = false; + } + else remount_map.insert(std::make_pair(ReadMacInt16(pb + ioVRefNum), info->fh)); info->fh = NULL; - info->drop = false; + WriteMacInt8(info->status + dsDiskInPlace, 0); return noErr; } else { return offLinErr; diff --git a/BasiliskII/src/emul_op.cpp b/BasiliskII/src/emul_op.cpp index c51aed21..30f55d92 100644 --- a/BasiliskII/src/emul_op.cpp +++ b/BasiliskII/src/emul_op.cpp @@ -49,6 +49,8 @@ #define DEBUG 0 #include "debug.h" +extern bool tick_inhibit; + void PlayStartupSound(); /* @@ -57,7 +59,6 @@ void PlayStartupSound(); void EmulOp(uint16 opcode, M68kRegisters *r) { - static bool bootflag; D(bug("EmulOp %04x\n", opcode)); switch (opcode) { case M68K_EMUL_BREAK: { // Breakpoint @@ -84,12 +85,9 @@ void EmulOp(uint16 opcode, M68kRegisters *r) break; case M68K_EMUL_OP_RESET: { // MacOS reset - if (bootflag) { - CDROMExit(); - CDROMInit(); - } - bootflag = true; D(bug("*** RESET ***\n")); + tick_inhibit = true; + CDROMRemount(); // for System 7.x TimerReset(); EtherReset(); AudioReset(); @@ -116,6 +114,7 @@ void EmulOp(uint16 opcode, M68kRegisters *r) r->a[1] = ROMBaseMac + UniversalInfo; // UniversalInfo r->a[6] = boot_globs; // BootGlobs r->a[7] = RAMBaseMac + 0x10000; // Boot stack + tick_inhibit = false; break; } diff --git a/BasiliskII/src/include/cdrom.h b/BasiliskII/src/include/cdrom.h index 2c42769e..24084d12 100644 --- a/BasiliskII/src/include/cdrom.h +++ b/BasiliskII/src/include/cdrom.h @@ -43,5 +43,6 @@ extern int16 CDROMStatus(uint32 pb, uint32 dce); extern void CDROMOpenDone(void); // Called by CDROMOpen() once drives have been to the drive queue void CDROMDrop(const char *path); +void CDROMRemount(); #endif diff --git a/SheepShaver/src/Unix/main_unix.cpp b/SheepShaver/src/Unix/main_unix.cpp index 1c7199b3..0db0cd01 100755 --- a/SheepShaver/src/Unix/main_unix.cpp +++ b/SheepShaver/src/Unix/main_unix.cpp @@ -1438,6 +1438,7 @@ static void *nvram_func(void *arg) * 60Hz thread (really 60.15Hz) */ +bool tick_inhibit; static void *tick_func(void *arg) { int tick_counter = 0; @@ -1454,6 +1455,7 @@ static void *tick_func(void *arg) Delay_usec(delay); else if (delay < -16625) next = GetTicks_usec(); + if (tick_inhibit) continue; ticks++; #if !EMULATED_PPC diff --git a/SheepShaver/src/Windows/main_windows.cpp b/SheepShaver/src/Windows/main_windows.cpp index e8e96654..91e39bd6 100644 --- a/SheepShaver/src/Windows/main_windows.cpp +++ b/SheepShaver/src/Windows/main_windows.cpp @@ -638,6 +638,7 @@ static DWORD nvram_func(void *arg) * 60Hz thread (really 60.15Hz) */ +bool tick_inhibit; static DWORD tick_func(void *arg) { int tick_counter = 0; @@ -654,6 +655,7 @@ static DWORD tick_func(void *arg) Delay_usec(delay); else if (delay < -16625) next = GetTicks_usec(); + if (tick_inhibit) continue; ticks++; // Pseudo Mac 1Hz interrupt, update local time diff --git a/SheepShaver/src/emul_op.cpp b/SheepShaver/src/emul_op.cpp index 2e5aef24..352e4ada 100644 --- a/SheepShaver/src/emul_op.cpp +++ b/SheepShaver/src/emul_op.cpp @@ -50,6 +50,8 @@ #define DEBUG 0 #include "debug.h" +extern bool tick_inhibit; + void PlayStartupSound(); // TVector of MakeExecutable @@ -283,6 +285,8 @@ void EmulOp(M68kRegisters *r, uint32 pc, int selector) case OP_RESET: // Early in MacOS reset D(bug("*** RESET ***\n")); + tick_inhibit = true; + CDROMRemount(); // for System 7.x TimerReset(); MacOSUtilReset(); AudioReset(); @@ -300,6 +304,7 @@ void EmulOp(M68kRegisters *r, uint32 pc, int selector) memcpy((void *)DR_EMULATOR_BASE, (void *)(ROMBase + 0x370000), DR_EMULATOR_SIZE); MakeExecutable(0, DR_EMULATOR_BASE, DR_EMULATOR_SIZE); } + tick_inhibit = false; break; case OP_IRQ: // Level 1 interrupt