int TkSelGetSelection( Tcl_Interp *interp, /* Interpreter to use for reporting * errors. */ Tk_Window tkwin, /* Window on whose behalf to retrieve * the selection (determines display * from which to retrieve). */ Atom selection, /* Selection to retrieve. */ Atom target, /* Desired form in which selection * is to be returned. */ Tk_GetSelProc *proc, /* Procedure to call to process the * selection, once it has been retrieved. */ ClientData clientData) /* Arbitrary value to pass to proc. */ { int result; long length, offset = 0; Handle handle; if ((selection == Tk_InternAtom(tkwin, "CLIPBOARD")) && (target == XA_STRING)) { /* * Get the scrap from the Macintosh global clipboard. */ handle = NewHandle(1); length = GetScrap(handle, 'TEXT', &offset); if (length > 0) { Tcl_DString encodedText; SetHandleSize(handle, (Size) length + 1); HLock(handle); (*handle)[length] = '\0'; Tcl_ExternalToUtfDString(NULL, *handle, length, &encodedText); result = (*proc)(clientData, interp, Tcl_DStringValue(&encodedText)); Tcl_DStringFree(&encodedText); HUnlock(handle); DisposeHandle(handle); return result; } DisposeHandle(handle); } Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection), " selection doesn't exist or form \"", Tk_GetAtomName(tkwin, target), "\" not defined", (char *) NULL); return TCL_ERROR; }
void isdf07Mission::handlePlayerMistakes() { if (missionState < 6) { //Not enough scrap if ((missionState>3) && (GetScrap(1) < 6) && (GetTime() > errorRemTime1)) { ClearObjectives(); AddObjective("isdf0709.otf", WHITE); AudioMessage("isdf0709.wav"); errorRemTime1 = (GetTime() + 60.0f); } } if (!IsAlive(shabayev)) { //kills shabayev // AudioMessage("Demo0304.wav"); // "Cooke. You're being shipped back to Earth where you'll face court marshall for killing a commanding officer. // FailMission(GetTime() + 15.0f); } /* if (!IsAlive(player)) { //gets killed // AudioMessage("Demo0304.wav"); // you loose go to shell screen FailMission(GetTime() + 15.0f); }*/ if (missionState == 6) {//does not follow shabayev if ((GetDistance(player, shabayev) > 400.0f) && (GetTime() < timeToFail)) { // AudioMessage("tooFar.wav"); //"Cooke, you're getting too far from my wing. Fall in. timeToFail = GetTime() + 60.0f; } else if (GetDistance(player, shabayev) < 400.0f) { timeToFail = 0.0f; } } if (missionState == 7) {//does not get out of his vehicle } if (missionState == 9) {//ignores shabayev's need for help if ((GetDistance(player, shabayev) > 40.0f) && (GetTime() < timeToFail)) { // AudioMessage("tooFar.wav"); //"Cooke, you're getting too far from my wing. Fall in. timeToFail = GetTime() + 60.0f; } if (GetDistance(player, shabayev) < 40.0f) { timeToFail = 0.0f; } } }
boolean getscrap (tyscraptype scraptype, Handle hscrap) { /* return true if something was loaded from the scrap, false otherwise. 12/26/91 dmb: return true if scraptype exists; generate error alert on real error. 5.0a16 dmb: need to scan more than last 32 bytes for NUL char */ #ifdef MACVERSION #if TARGET_API_MAC_CARBON == 1 ScrapRef theScrap; ScrapFlavorType flavorType = (ScrapFlavorType)scraptype; Size byteCount; OSStatus status; ScrapFlavorFlags flavorFlags; boolean retVal = true; Size prevCount; status = GetCurrentScrap(&theScrap); if(status != noErr) oserror (status); status = GetScrapFlavorFlags(theScrap, flavorType, &flavorFlags); if(status == noTypeErr) { retVal = false; } else if(status < 0) { retVal = false; oserror (status); } //if we get here and the handles nil, we really don't want the data //also if retVal is false, it means the type does not exist if(hscrap == nil || !retVal) return retVal; status = GetScrapFlavorSize(theScrap, flavorType, &byteCount); if(status != noErr) oserror (status); prevCount = byteCount; SetHandleSize(hscrap, byteCount); if (MemError () != noErr) return (false); //lock the handle before getting the data HLock(hscrap); status = GetScrapFlavorData(theScrap, flavorType, &byteCount, *(hscrap)); HUnlock(hscrap); if(status != noErr) oserror (status); //only return true if we got all the data. return (byteCount == prevCount); #else //precarbon mac long result; long offset; result = GetScrap (hscrap, scraptype, &offset); if (result == noTypeErr) return (false); if (result < 0) oserror (result); return (true); /*there was something on the scrap of the given type*/ #endif #endif #ifdef WIN95VERSION Handle hdata; long ctbytes; char *pdata; boolean fl; /*long i;*/ UINT wintype; wintype = shell2winscraptype (scraptype); if (wintype == 0) return (false); releasethreadglobals (); //getting clipboard data can send us a WM_RENDERFORMAT msg hdata = GetClipboardData (wintype); grabthreadglobals (); if (hdata == NULL) { oserror (GetLastError ()); // may be no error return (false); } ctbytes = GlobalSize (hdata); pdata = GlobalLock (hdata); if (pdata == NULL) return (false); if (scraptype == textscraptype) { //Handle reducing the scrap size to the NULL /* i = 0x40; if (i > ctbytes) i = ctbytes; while (i > 0) { if (*(pdata + ctbytes - i) == 0) { ctbytes = ctbytes - i; break; } --i; } /%while%/ */ ctbytes = strlen (pdata); /*7.1b23: call strlen to find the first terminator: removes junk from end*/ } /*if*/ fl = sethandlecontents (pdata, ctbytes, hscrap); GlobalUnlock (hdata); return (fl); #endif } /*getscrap*/
/*** ADJUST MENUS ***/ OSStatus AdjustMenus( void ) { register WindowRef theWin; short windowKind; Boolean isDA, isObjectWin, selection, scrapExists, undoExists, isGotoWin, isFindWin; EditWindowPtr dWin = NULL; Str31 menuStr; short i; long scrapSize; // LR: v1.6.5 Str255 frontWindowName, menuItemTitle; Boolean namesMatch; theWin = FrontNonFloatingWindow(); if( theWin ) { isGotoWin = (g.gotoDlg && theWin == GetDialogWindow( g.gotoDlg )); //LR: 1.7 - don't get window info on NULL! isFindWin = (g.searchDlg && theWin == GetDialogWindow( g.searchDlg )); windowKind = GetWindowKind( theWin ); isDA = ( windowKind < 0 ); isObjectWin = GetWindowKind( theWin ) == kHexEditWindowTag; if( isObjectWin ) { dWin = (EditWindowPtr)GetWRefCon( theWin ); //LR: 1.66 - don't set unless an edit window! selection = dWin->endSel > dWin->startSel; } else { selection = (isGotoWin || isFindWin); } } else // LR: v1.6.5 if no window is visible, then nothing is true! { isGotoWin = isFindWin = isObjectWin = isDA = selection = 0; } // LR: v1.6.5 - rewrite of scrap check if( isObjectWin || isFindWin || isGotoWin ) { #if TARGET_API_MAC_CARBON ScrapFlavorFlags flavorFlags; ScrapRef scrapRef; OSErr anErr; anErr = GetCurrentScrap( &scrapRef ); if( !anErr ) anErr = GetScrapFlavorFlags( scrapRef, kScrapFlavorTypeText, &flavorFlags ); // non-blocking check for scrap data if( !anErr ) anErr = GetScrapFlavorSize( scrapRef, kScrapFlavorTypeText, &scrapSize ); // blocking call to get size #else long offset; scrapSize = GetScrap( NULL, 'TEXT', &offset ); #endif scrapExists = scrapSize > 0; } else scrapExists = false; undoExists = (isObjectWin && gUndo.type != 0 && gUndo.theWin == dWin); // check for NULL gUndo! // LR: - enable file menu items during search, via Aaron D. // LR: _enableMenuItem( fileMenu, FM_New, g.searchDlg == NULL ); // LR: _enableMenuItem( fileMenu, FM_Open, g.searchDlg == NULL ); // LR: 1.65 moved print names to string for localization GetIndString( menuStr, strPrint, (isObjectWin && dWin->startSel < dWin->endSel) ? 2 : 1 ); SetMenuItemText( fileMenu, FM_Print, menuStr ); //LR 188 -- page setup should always be enabled // _enableMenuItem( fileMenu, FM_PageSetup, isObjectWin ); //SEL: 1.7 - enabled for carbon _enableMenuItem( fileMenu, FM_Print, isObjectWin ); // HR/LR 050328 - Enable and check FM_Disassemble menu item _enableMenuItem( fileMenu, FM_Disassemble, isObjectWin ); CheckMenuItem( fileMenu, FM_Disassemble, g.disassemble ); _enableMenuItem( fileMenu, FM_OtherFork, isObjectWin ); _enableMenuItem( fileMenu, FM_Close, isDA || isObjectWin || isFindWin || isGotoWin ); // LR: v1.6.5 rewrite via Max Horn _enableMenuItem( fileMenu, FM_Save, isObjectWin && dWin->dirtyFlag ); _enableMenuItem( fileMenu, FM_SaveAs, isObjectWin ); _enableMenuItem( fileMenu, FM_Revert, isObjectWin && dWin->refNum && dWin->dirtyFlag ); _enableMenuItem( editMenu, 0, theWin != NULL ); _enableMenuItem( editMenu, EM_Undo, isDA || undoExists ); _enableMenuItem( editMenu, EM_Cut, isDA || (selection && (!gPrefs.overwrite || (gPrefs.overwrite && !gPrefs.nonDestructive))) ); _enableMenuItem( editMenu, EM_Copy, isDA || selection ); _enableMenuItem( editMenu, EM_Paste, isDA || (scrapExists && (!gPrefs.overwrite || (gPrefs.overwrite && !gPrefs.nonDestructive))) ); _enableMenuItem( editMenu, EM_Clear, isDA || selection ); _enableMenuItem( editMenu, EM_SelectAll, isDA || isObjectWin || isFindWin || isGotoWin ); _enableMenuItem( findMenu, 0, isObjectWin || isFindWin || isGotoWin ); /* 1.65 _enableMenuItem( findMenu, SM_Find, isObjectWin ); _enableMenuItem( findMenu, SM_GotoAddress, isObjectWin ); */ _enableMenuItem( findMenu, SM_FindForward, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) ); //LR 1.72 -- only enable w/something to search :) _enableMenuItem( findMenu, SM_FindBackward, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) ); _enableMenuItem( findMenu, SM_Replace, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) ); _enableMenuItem( optionsMenu, OM_NonDestructive, gPrefs.overwrite ); //LR 1.74 -- only available in overwrite mode CheckMenuItem( optionsMenu, OM_HiAscii, gPrefs.asciiMode ); CheckMenuItem( optionsMenu, OM_DecimalAddr, gPrefs.decimalAddr ); CheckMenuItem( optionsMenu, OM_Backups, gPrefs.backupFlag ); CheckMenuItem( optionsMenu, OM_WinSize, gPrefs.constrainSize ); CheckMenuItem( optionsMenu, OM_Overwrite, gPrefs.overwrite ); CheckMenuItem( optionsMenu, OM_NonDestructive, !gPrefs.nonDestructive ); //LR 190 -- REVERSE (updated text, not code) CheckMenuItem( optionsMenu, OM_MoveOnlyPaging, gPrefs.moveOnlyPaging ); //LR 180 -- optional move only paging CheckMenuItem( optionsMenu, OM_Unformatted, !gPrefs.formatCopies ); CheckMenuItem( optionsMenu, OM_VertBars, gPrefs.vertBars ); CheckMenuItem( optionsMenu, OM_OpenOnLaunch, gPrefs.dialogAtLaunch ); //WD_rpw 12-18-04 // LR: v1.6.5 Lots of re-writing on handling the color scheme menu #if !TARGET_API_MAC_CARBON // no color usage if not displayable! if( !g.colorQDFlag ) gPrefs.useColor = false; #endif // LR: v1.6.5 CheckMenuItem( gColorMenu, CM_UseColor, gPrefs.useColor ); // allow turning on even if not usable // LR: v1.6.5 Try to show status of color in new windows to help "intuitive" nature of menu GetIndString( menuStr, strColor, (gPrefs.useColor) ? 2 : 1 ); SetMenuItemText( colorMenu, CM_UseColor, menuStr ); //LR 181 -- show the current window color (or default if no windows) if( _cmCheckedItem ) CheckMenuItem( colorMenu, _cmCheckedItem, false ); _cmCheckedItem = isObjectWin ? dWin->csMenuID : gPrefs.csMenuID; CheckMenuItem( colorMenu, _cmCheckedItem, true ); selection = gPrefs.useColor; //LR 190 -- && isObjectWin && dWin->csResID > 0; i = CountMenuItems( colorMenu ); do { _enableMenuItem( colorMenu, i, selection ); // LR: v1.6.5 only enable for color windows } while( --i > 2 ); // NS: v1.6.6 checkmark front window in window menu if( theWin ) GetWTitle( theWin, frontWindowName ); //LR: 1.66 - don't use NULL window! else frontWindowName[0] = 0; i = CountMenuItems( windowMenu ); _enableMenuItem(windowMenu, 0, i != 0); // dim out Window menu if no windows up. while( i ) { GetMenuItemText( windowMenu, i, menuItemTitle ); // if you open more than one file with the same name (or edit the other fork)É namesMatch = EqualPStrings( frontWindowName, menuItemTitle ); // Éyou will have multiple items in the menu with the same text, and all will be checkmarked CheckMenuItem( windowMenu, i, namesMatch ); i--; } return( noErr ); }
void EmulOp(M68kRegisters *r, uint32 pc, int selector) { D(bug("EmulOp %04x at %08x\n", selector, pc)); switch (selector) { case OP_BREAK: // Breakpoint printf("*** Breakpoint\n"); Dump68kRegs(r); break; case OP_XPRAM1: { // Read/write from/to XPRam uint32 len = r->d[3]; uint8 *adr = Mac2HostAddr(r->a[3]); D(bug("XPRAMReadWrite d3: %08lx, a3: %p\n", len, adr)); int ofs = len & 0xffff; len >>= 16; if (len & 0x8000) { len &= 0x7fff; for (uint32 i=0; i<len; i++) XPRAM[((ofs + i) & 0xff) + 0x1300] = *adr++; } else { for (uint32 i=0; i<len; i++) *adr++ = XPRAM[((ofs + i) & 0xff) + 0x1300]; } break; } case OP_XPRAM2: // Read from XPRam r->d[1] = XPRAM[(r->d[1] & 0xff) + 0x1300]; break; case OP_XPRAM3: // Write to XPRam XPRAM[(r->d[1] & 0xff) + 0x1300] = r->d[2]; break; case OP_NVRAM1: { // Read from NVRAM int ofs = r->d[0]; r->d[0] = XPRAM[ofs & 0x1fff]; bool localtalk = !(XPRAM[0x13e0] || XPRAM[0x13e1]); // LocalTalk enabled? switch (ofs) { case 0x13e0: // Disable LocalTalk (use EtherTalk instead) if (localtalk) r->d[0] = 0x00; break; case 0x13e1: if (localtalk) r->d[0] = 0x01; break; case 0x13e2: if (localtalk) r->d[0] = 0x00; break; case 0x13e3: if (localtalk) r->d[0] = 0x0a; break; } break; } case OP_NVRAM2: // Write to NVRAM XPRAM[r->d[0] & 0x1fff] = r->d[1]; break; case OP_NVRAM3: // Read/write from/to NVRAM if (r->d[3]) { r->d[0] = XPRAM[(r->d[4] + 0x1300) & 0x1fff]; } else { XPRAM[(r->d[4] + 0x1300) & 0x1fff] = r->d[5]; r->d[0] = 0; } break; case OP_FIX_MEMTOP: // Fixes MemTop in BootGlobs during startup D(bug("Fix MemTop\n")); WriteMacInt32(BootGlobsAddr - 20, RAMBase + RAMSize); // MemTop r->a[6] = RAMBase + RAMSize; break; case OP_FIX_MEMSIZE: { // Fixes physical/logical RAM size during startup D(bug("Fix MemSize\n")); uint32 diff = ReadMacInt32(0x1ef8) - ReadMacInt32(0x1ef4); WriteMacInt32(0x1ef8, RAMSize); // Physical RAM size WriteMacInt32(0x1ef4, RAMSize - diff); // Logical RAM size break; } case OP_FIX_BOOTSTACK: // Fixes boot stack pointer in boot 3 resource D(bug("Fix BootStack\n")); r->a[1] = r->a[7] = RAMBase + RAMSize * 3 / 4; break; case OP_SONY_OPEN: // Floppy driver functions r->d[0] = SonyOpen(r->a[0], r->a[1]); break; case OP_SONY_PRIME: r->d[0] = SonyPrime(r->a[0], r->a[1]); break; case OP_SONY_CONTROL: r->d[0] = SonyControl(r->a[0], r->a[1]); break; case OP_SONY_STATUS: r->d[0] = SonyStatus(r->a[0], r->a[1]); break; case OP_DISK_OPEN: // Disk driver functions r->d[0] = DiskOpen(r->a[0], r->a[1]); break; case OP_DISK_PRIME: r->d[0] = DiskPrime(r->a[0], r->a[1]); break; case OP_DISK_CONTROL: r->d[0] = DiskControl(r->a[0], r->a[1]); break; case OP_DISK_STATUS: r->d[0] = DiskStatus(r->a[0], r->a[1]); break; case OP_CDROM_OPEN: // CD-ROM driver functions r->d[0] = CDROMOpen(r->a[0], r->a[1]); break; case OP_CDROM_PRIME: r->d[0] = CDROMPrime(r->a[0], r->a[1]); break; case OP_CDROM_CONTROL: r->d[0] = CDROMControl(r->a[0], r->a[1]); break; case OP_CDROM_STATUS: r->d[0] = CDROMStatus(r->a[0], r->a[1]); break; case OP_AUDIO_DISPATCH: // Audio component functions r->d[0] = gMacAudio->Dispatch(r->a[3], r->a[4]); break; case OP_SOUNDIN_OPEN: // Sound input driver functions r->d[0] = gMacAudio->InOpen(r->a[0], r->a[1]); break; case OP_SOUNDIN_PRIME: r->d[0] = gMacAudio->InPrime(r->a[0], r->a[1]); break; case OP_SOUNDIN_CONTROL: r->d[0] = gMacAudio->InControl(r->a[0], r->a[1]); break; case OP_SOUNDIN_STATUS: r->d[0] = gMacAudio->InStatus(r->a[0], r->a[1]); break; case OP_SOUNDIN_CLOSE: r->d[0] = gMacAudio->InClose(r->a[0], r->a[1]); break; case OP_ADBOP: // ADBOp() replacement gADBInput->Op(r->d[0], Mac2HostAddr(ReadMacInt32(r->a[0]))); break; case OP_INSTIME: // InsTime() replacement r->d[0] = InsTime(r->a[0], r->d[1]); break; case OP_RMVTIME: // RmvTime() replacement r->d[0] = RmvTime(r->a[0]); break; case OP_PRIMETIME: // PrimeTime() replacement r->d[0] = PrimeTime(r->a[0], r->d[0]); break; case OP_MICROSECONDS: // Microseconds() replacement Microseconds(r->a[0], r->d[0]); break; case OP_PUT_SCRAP: // PutScrap() patch PutScrap(ReadMacInt32(r->a[7] + 8), Mac2HostAddr(ReadMacInt32(r->a[7] + 4)), ReadMacInt32(r->a[7] + 12)); break; case OP_GET_SCRAP: // GetScrap() patch GetScrap((void **)Mac2HostAddr(ReadMacInt32(r->a[7] + 4)), ReadMacInt32(r->a[7] + 8), ReadMacInt32(r->a[7] + 12)); break; case OP_DEBUG_STR: // DebugStr() shows warning message if (PrefsFindBool("nogui")) { uint8 *pstr = Mac2HostAddr(ReadMacInt32(r->a[7] + 4)); char str[256]; int i; for (i=0; i<pstr[0]; i++) str[i] = pstr[i+1]; str[i] = 0; WarningAlert(str); } break; case OP_INSTALL_DRIVERS: { // Patch to install our own drivers during startup // Install drivers InstallDrivers(); // Patch MakeExecutable() MakeExecutableTvec = FindLibSymbol("\023PrivateInterfaceLib", "\016MakeExecutable"); D(bug("MakeExecutable TVECT at %08x\n", MakeExecutableTvec)); WriteMacInt32(MakeExecutableTvec, NativeFunction(NATIVE_MAKE_EXECUTABLE)); #if defined(__powerpc__) /* Native PowerPC */ WriteMacInt32(MakeExecutableTvec + 4, (uint32)TOC); #endif // Patch DebugStr() static const uint8 proc_template[] = { M68K_EMUL_OP_DEBUG_STR >> 8, M68K_EMUL_OP_DEBUG_STR & 0xFF, 0x4e, 0x74, // rtd #4 0x00, 0x04 }; BUILD_SHEEPSHAVER_PROCEDURE(proc); WriteMacInt32(0x1dfc, proc); break; } case OP_NAME_REGISTRY: // Patch Name Registry and initialize CallUniversalProc r->d[0] = (uint32)-1; PatchNameRegistry(); InitCallUniversalProc(); break; case OP_RESET: // Early in MacOS reset D(bug("*** RESET ***\n")); TimerReset(); MacOSUtilReset(); gMacAudio->Reset(); // Enable DR emulator (disabled for now) if (PrefsFindBool("jit68k") && 0) { D(bug("DR activated\n")); WriteMacInt32(KernelDataAddr + 0x17a0, 3); // Prepare for DR emulator activation WriteMacInt32(KernelDataAddr + 0x17c0, DR_CACHE_BASE); WriteMacInt32(KernelDataAddr + 0x17c4, DR_CACHE_SIZE); WriteMacInt32(KernelDataAddr + 0x1b04, DR_CACHE_BASE); WriteMacInt32(KernelDataAddr + 0x1b00, DR_EMULATOR_BASE); memcpy((void *)DR_EMULATOR_BASE, (void *)(ROMBase + 0x370000), DR_EMULATOR_SIZE); MakeExecutable(0, DR_EMULATOR_BASE, DR_EMULATOR_SIZE); } break; case OP_IRQ: // Level 1 interrupt WriteMacInt16(ReadMacInt32(KernelDataAddr + 0x67c), 0); // Clear interrupt r->d[0] = 0; if (HasMacStarted()) { if (InterruptFlags & INTFLAG_VIA) { ClearInterruptFlag(INTFLAG_VIA); #if !PRECISE_TIMING TimerInterrupt(); #endif ExecuteNative(NATIVE_VIDEO_VBL); static int tick_counter = 0; if (++tick_counter >= 60) { tick_counter = 0; SonyInterrupt(); DiskInterrupt(); CDROMInterrupt(); } r->d[0] = 1; // Flag: 68k interrupt routine executes VBLTasks etc. } if (InterruptFlags & INTFLAG_SERIAL) { ClearInterruptFlag(INTFLAG_SERIAL); SerialInterrupt(); } if (InterruptFlags & INTFLAG_ETHER) { ClearInterruptFlag(INTFLAG_ETHER); ExecuteNative(NATIVE_ETHER_IRQ); } if (InterruptFlags & INTFLAG_TIMER) { ClearInterruptFlag(INTFLAG_TIMER); TimerInterrupt(); } if (InterruptFlags & INTFLAG_AUDIO) { ClearInterruptFlag(INTFLAG_AUDIO); gMacAudio->Interrupt(); } if (InterruptFlags & INTFLAG_ADB) { ClearInterruptFlag(INTFLAG_ADB); gADBInput->Interrupt(); } } else r->d[0] = 1; break; case OP_SCSI_DISPATCH: { // SCSIDispatch() replacement uint32 ret = ReadMacInt32(r->a[7]); uint16 sel = ReadMacInt16(r->a[7] + 4); r->a[7] += 6; // D(bug("SCSIDispatch(%d)\n", sel)); int stack; switch (sel) { case 0: // SCSIReset WriteMacInt16(r->a[7], SCSIReset()); stack = 0; break; case 1: // SCSIGet WriteMacInt16(r->a[7], SCSIGet()); stack = 0; break; case 2: // SCSISelect case 11: // SCSISelAtn WriteMacInt16(r->a[7] + 2, SCSISelect(ReadMacInt8(r->a[7] + 1))); stack = 2; break; case 3: // SCSICmd WriteMacInt16(r->a[7] + 6, SCSICmd(ReadMacInt16(r->a[7]), Mac2HostAddr(ReadMacInt32(r->a[7] + 2)))); stack = 6; break; case 4: // SCSIComplete WriteMacInt16(r->a[7] + 12, SCSIComplete(ReadMacInt32(r->a[7]), ReadMacInt32(r->a[7] + 4), ReadMacInt32(r->a[7] + 8))); stack = 12; break; case 5: // SCSIRead case 8: // SCSIRBlind WriteMacInt16(r->a[7] + 4, SCSIRead(ReadMacInt32(r->a[7]))); stack = 4; break; case 6: // SCSIWrite case 9: // SCSIWBlind WriteMacInt16(r->a[7] + 4, SCSIWrite(ReadMacInt32(r->a[7]))); stack = 4; break; case 10: // SCSIStat WriteMacInt16(r->a[7], SCSIStat()); stack = 0; break; case 12: // SCSIMsgIn WriteMacInt16(r->a[7] + 4, 0); stack = 4; break; case 13: // SCSIMsgOut WriteMacInt16(r->a[7] + 2, 0); stack = 2; break; case 14: // SCSIMgrBusy WriteMacInt16(r->a[7], SCSIMgrBusy()); stack = 0; break; default: printf("FATAL: SCSIDispatch: illegal selector\n"); stack = 0; //!! SysError(12) } r->a[0] = ret; r->a[7] += stack; break; } case OP_SCSI_ATOMIC: // SCSIAtomic() replacement D(bug("SCSIAtomic\n")); r->d[0] = (uint32)-7887; break; case OP_CHECK_SYSV: { // Check we are not using MacOS < 8.1 with a NewWorld ROM r->a[1] = r->d[1]; r->a[0] = ReadMacInt32(r->d[1]); uint32 sysv = ReadMacInt16(r->a[0]); D(bug("Detected MacOS version %d.%d.%d\n", (sysv >> 8) & 0xf, (sysv >> 4) & 0xf, sysv & 0xf)); if (ROMType == ROMTYPE_NEWWORLD && sysv < 0x0801) r->d[1] = 0; break; } case OP_NTRB_17_PATCH: r->a[2] = ReadMacInt32(r->a[7]); r->a[7] += 4; if (ReadMacInt16(r->a[2] + 6) == 17) PatchNativeResourceManager(); break; case OP_NTRB_17_PATCH2: r->a[7] += 8; PatchNativeResourceManager(); break; case OP_NTRB_17_PATCH3: r->a[2] = ReadMacInt32(r->a[7]); r->a[7] += 4; D(bug("%d %d\n", ReadMacInt16(r->a[2]), ReadMacInt16(r->a[2] + 6))); if (ReadMacInt16(r->a[2]) == 11 && ReadMacInt16(r->a[2] + 6) == 17) PatchNativeResourceManager(); break; case OP_NTRB_17_PATCH4: r->d[0] = ReadMacInt16(r->a[7]); r->a[7] += 2; D(bug("%d %d\n", ReadMacInt16(r->a[2]), ReadMacInt16(r->a[2] + 6))); if (ReadMacInt16(r->a[2]) == 11 && ReadMacInt16(r->a[2] + 6) == 17) PatchNativeResourceManager(); break; case OP_CHECKLOAD: { // vCheckLoad() patch uint32 type = ReadMacInt32(r->a[7]); r->a[7] += 4; int16 id = ReadMacInt16(r->a[2]); if (r->a[0] == 0) break; uint32 adr = ReadMacInt32(r->a[0]); if (adr == 0) break; uint16 *p = (uint16 *)Mac2HostAddr(adr); uint32 size = ReadMacInt32(adr - 8) & 0xffffff; CheckLoad(type, id, p, size); break; } case OP_EXTFS_COMM: // External file system routines WriteMacInt16(r->a[7] + 14, ExtFSComm(ReadMacInt16(r->a[7] + 12), ReadMacInt32(r->a[7] + 8), ReadMacInt32(r->a[7] + 4))); break; case OP_EXTFS_HFS: WriteMacInt16(r->a[7] + 20, ExtFSHFS(ReadMacInt32(r->a[7] + 16), ReadMacInt16(r->a[7] + 14), ReadMacInt32(r->a[7] + 10), ReadMacInt32(r->a[7] + 6), ReadMacInt16(r->a[7] + 4))); break; case OP_IDLE_TIME: // Sleep if no events pending if (ReadMacInt32(0x14c) == 0) idle_wait(); r->a[0] = ReadMacInt32(0x2b6); break; case OP_IDLE_TIME_2: // Sleep if no events pending if (ReadMacInt32(0x14c) == 0) idle_wait(); r->d[0] = (uint32)-2; break; default: printf("FATAL: EMUL_OP called with bogus selector %08x\n", selector); QuitEmulator(); break; } }