A1(PRIVATE, DCtlPtr, otherdctl, ParmBlkPtr, pbp) { DCtlHandle h; h = 0; switch (CW(pbp->cntrlParam.ioCRefNum)) { case AINREFNUM: h = GetDCtlEntry(AOUTREFNUM); break; case AOUTREFNUM: h = GetDCtlEntry(AINREFNUM); break; case BINREFNUM: h = GetDCtlEntry(BOUTREFNUM); break; case BOUTREFNUM: h = GetDCtlEntry(BINREFNUM); break; } return h ? STARH(h) : 0; }
int SDL_SYS_CDInit(void) { SInt16 dRefNum = 0; SInt16 first, last; SDL_numcds = 0; /* Check that the software is available */ if (Gestalt(kGestaltAudioCDSelector, &SDL_cdversion) || !SDL_cdversion) return(0); /* Fill in our driver capabilities */ SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; SDL_CDcaps.Status = SDL_SYS_CDStatus; SDL_CDcaps.Play = SDL_SYS_CDPlay; SDL_CDcaps.Pause = SDL_SYS_CDPause; SDL_CDcaps.Resume = SDL_SYS_CDResume; SDL_CDcaps.Stop = SDL_SYS_CDStop; SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; /* Walk the list, count each AudioCD driver, and save the refnums */ first = -1; last = 0 - LMGetUnitTableEntryCount(); for(dRefNum = first; dRefNum >= last; dRefNum--) { Str255 driverName; StringPtr namePtr; DCtlHandle deviceEntry; deviceEntry = GetDCtlEntry(dRefNum); if (! deviceEntry) continue; /* Is this an .AppleCD ? */ namePtr = (*deviceEntry)->dCtlFlags & (1L << dRAMBased) ? ((StringPtr) ((DCtlPtr) deviceEntry)->dCtlDriver + 18) : ((StringPtr) (*deviceEntry)->dCtlDriver + 18); BlockMoveData(namePtr, driverName, namePtr[0]+1); if (driverName[0] > gDriverName[0]) driverName[0] = gDriverName[0]; if (! EqualString(driverName, gDriverName, false, false)) continue; /* Record the basic info for each drive */ SDL_cdlist[SDL_numcds].dRefNum = dRefNum; BlockMoveData(namePtr + 1, SDL_cdlist[SDL_numcds].name, namePtr[0]); SDL_cdlist[SDL_numcds].name[namePtr[0]] = 0; SDL_cdlist[SDL_numcds].hasAudio = false; SDL_numcds++; } return(0); }
int SDL_SYS_CDInit(void) { SInt16 dRefNum = 0; SInt16 first, last; SDL_numcds = 0; if (Gestalt(kGestaltAudioCDSelector, &SDL_cdversion) || !SDL_cdversion) return(0); SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; SDL_CDcaps.Status = SDL_SYS_CDStatus; SDL_CDcaps.Play = SDL_SYS_CDPlay; SDL_CDcaps.Pause = SDL_SYS_CDPause; SDL_CDcaps.Resume = SDL_SYS_CDResume; SDL_CDcaps.Stop = SDL_SYS_CDStop; SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; first = -1; last = 0 - LMGetUnitTableEntryCount(); for(dRefNum = first; dRefNum >= last; dRefNum--) { Str255 driverName; StringPtr namePtr; DCtlHandle deviceEntry; deviceEntry = GetDCtlEntry(dRefNum); if (! deviceEntry) continue; namePtr = (*deviceEntry)->dCtlFlags & (1L << dRAMBased) ? ((StringPtr) ((DCtlPtr) deviceEntry)->dCtlDriver + 18) : ((StringPtr) (*deviceEntry)->dCtlDriver + 18); BlockMoveData(namePtr, driverName, namePtr[0]+1); if (driverName[0] > gDriverName[0]) driverName[0] = gDriverName[0]; if (! EqualString(driverName, gDriverName, false, false)) continue; SDL_cdlist[SDL_numcds].dRefNum = dRefNum; BlockMoveData(namePtr + 1, SDL_cdlist[SDL_numcds].name, namePtr[0]); SDL_cdlist[SDL_numcds].name[namePtr[0]] = 0; SDL_cdlist[SDL_numcds].hasAudio = false; SDL_numcds++; } return(0); }
void GetRequestTheDM1Way (VideoRequestRecPtr requestRecPtr, GDHandle walkDevice) { AuxDCEHandle myAuxDCEHandle; unsigned long depthMode; unsigned long displayMode; OSErr error; OSErr errorEndOfTimings; short height; short jCount = 0; Boolean modeOk; SpBlock spAuxBlock; SpBlock spBlock; unsigned long switchFlags; VPBlock *vpData; short width; myAuxDCEHandle = (AuxDCEHandle) GetDCtlEntry((**walkDevice).gdRefNum); spBlock.spSlot = (**myAuxDCEHandle).dCtlSlot; spBlock.spID = (**myAuxDCEHandle).dCtlSlotId; spBlock.spExtDev = (**myAuxDCEHandle).dCtlExtDev; spBlock.spHwDev = 0; // we are going to get this pup spBlock.spParamData = 1<<foneslot; // this slot, enabled, and it better be here. spBlock.spTBMask = 3; // don't have constants for this yet errorEndOfTimings = SGetSRsrc(&spBlock); // get the spDrvrHW so we know the ID of this puppy. This is important // since some video cards support more than one display, and the spDrvrHW // ID can, and will, be used to differentiate them. if ( noErr == errorEndOfTimings ) { // reinit the param block for the SGetTypeSRsrc loop, keep the spDrvrHW we just got spBlock.spID = 0; // start at zero, spBlock.spTBMask = 2; // 0b0010 - ignore DrvrSW - why ignore the SW side? Is it not important for video? spBlock.spParamData = (1<<fall) + (1<<foneslot) + (1<<fnext); // 0b0111 - this slot, enabled or disabled, so we even get 640x399 on Blackbird spBlock.spCategory=catDisplay; spBlock.spCType=typeVideo; errorEndOfTimings = SGetTypeSRsrc(&spBlock); // but only on 7.0 systems, not a problem since we require DM1.0 // now, loop through all the timings for this GDevice if ( noErr == errorEndOfTimings ) do { // now, loop through all possible depth modes for this timing mode displayMode = (unsigned char)spBlock.spID; // "timing mode, ie:resource ref number" for (jCount = firstVidMode; jCount<= sixthVidMode; jCount++) { depthMode = jCount; // vid mode error = DMCheckDisplayMode(walkDevice,displayMode,depthMode,&switchFlags,0,&modeOk); // only if the mode is safe or we override it with the kAllValidModesBit request flag if ( noErr == error && modeOk && ( switchFlags & 1<<kNoSwitchConfirmBit || requestRecPtr->requestFlags & 1<<kAllValidModesBit ) ) { // have a good displayMode/depthMode combo - now lets look inside spAuxBlock = spBlock; // don't ruin the iteration spBlock!! spAuxBlock.spID = depthMode; // vid mode error=SFindStruct(&spAuxBlock); // get back a new spsPointer if (noErr == error) // keep going if no errorÉ { spAuxBlock.spID = 0x01; // mVidParams request error=SGetBlock (&spAuxBlock); // use the new spPointer and get back...a NewPtr'ed spResult if (noErr == error) // Ékeep going if no errorÉ { // We have data! lets have a look vpData = (VPBlock*)spAuxBlock.spResult; height = vpData->vpBounds.bottom; // left and top are usually zero width = vpData->vpBounds.right; if (FindBestMatch (requestRecPtr, vpData->vpPixelSize, vpData->vpBounds.right, vpData->vpBounds.bottom)) { requestRecPtr->screenDevice = walkDevice; requestRecPtr->availBitDepth = vpData->vpPixelSize; requestRecPtr->availHorizontal = vpData->vpBounds.right; requestRecPtr->availVertical = vpData->vpBounds.bottom; requestRecPtr->displayMode = displayMode; requestRecPtr->depthMode = depthMode; requestRecPtr->switchInfo.csMode = depthMode; // fill in for completeness requestRecPtr->switchInfo.csData = displayMode; requestRecPtr->switchInfo.csPage = 0; requestRecPtr->switchInfo.csBaseAddr = 0; requestRecPtr->switchInfo.csReserved = 0; if (switchFlags & 1<<kNoSwitchConfirmBit) requestRecPtr->availFlags = 0; // mode safe else requestRecPtr->availFlags = 1<<kModeValidNotSafeBit; // mode valid but not safe, requires user validation of mode switch } if (spAuxBlock.spResult) DisposePtr ((Ptr)spAuxBlock.spResult); // toss this puppy when done } } } } // go around again, looking for timing modes for this GDevice spBlock.spTBMask = 2; // ignore DrvrSW spBlock.spParamData = (1<<fall) + (1<<foneslot) + (1<<fnext); // next resource, this slot, whether enabled or disabled errorEndOfTimings = SGetTypeSRsrc(&spBlock); // and get the next timing mode } while ( noErr == errorEndOfTimings ); // until the end of this GDevice } }
OSErr RVGetCurrentVideoSetting (VideoRequestRecPtr requestRecPtr) { unsigned long displayMgrVersion; OSErr error = paramErr; CntrlParam pBlock; VDSwitchInfoRec switchInfo; AuxDCEHandle theDCE; VDSwitchInfoRec videoMode; requestRecPtr->availBitDepth = 0; // init to default - you can do it if it is important to you requestRecPtr->availHorizontal = 0; requestRecPtr->availVertical = 0; requestRecPtr->availFlags = 0; requestRecPtr->displayMode = -1; requestRecPtr->depthMode = -1; requestRecPtr->switchInfo.csMode = 0; requestRecPtr->switchInfo.csData = 0; requestRecPtr->switchInfo.csPage = 0; requestRecPtr->switchInfo.csBaseAddr = 0; requestRecPtr->switchInfo.csReserved = 0; Gestalt(gestaltDisplayMgrVers, (long*)&displayMgrVersion); if (requestRecPtr->screenDevice) { if (displayMgrVersion >= 0x00020000) { // get the info the DM 2.0 way error = DMGetDisplayMode(requestRecPtr->screenDevice, &switchInfo); if (noErr == error) { requestRecPtr->depthMode = switchInfo.csMode; requestRecPtr->displayMode = switchInfo.csData; requestRecPtr->switchInfo.csMode = switchInfo.csMode; requestRecPtr->switchInfo.csData = switchInfo.csData; } return (error); // we (maybe) set the world back to a known setting } else { // get the info the DM 1.0 way videoMode.csMode = -1; // init to bogus value videoMode.csData = -1; // init to bogus value pBlock.ioNamePtr = nil; pBlock.ioCRefNum = (*(requestRecPtr->screenDevice))->gdRefNum; pBlock.csCode = cscGetCurMode; *(Ptr *)&pBlock.csParam[0] = (Ptr)&videoMode; error = PBStatusSync((ParmBlkPtr )&pBlock); // ask the driver first....since we trust it the most if ( noErr == error && ((-1 == videoMode.csMode) || (-1 == videoMode.csData)) ) error = statusErr; if (noErr != error) // if the driver has no clue fill it videoMode by hand as a last resort { theDCE = (AuxDCEHandle)GetDCtlEntry((*(requestRecPtr->screenDevice))->gdRefNum); if( theDCE ) { videoMode.csData = (unsigned char)(*theDCE)->dCtlSlotId; videoMode.csMode = (*(requestRecPtr->screenDevice))->gdMode; error = noErr; } } if (noErr == error) // Set our data { requestRecPtr->displayMode = videoMode.csData; requestRecPtr->depthMode = videoMode.csMode; requestRecPtr->switchInfo.csMode = videoMode.csMode; requestRecPtr->switchInfo.csData = videoMode.csData; } return (error); // we (maybe) set the world back to a known setting } } return (-1); }
P1(PUBLIC pascal trap, INTEGER, OpenDeskAcc, Str255, acc) /* IMI-440 */ { INTEGER retval; DCtlHandle dctlh; WindowPtr wp; if (EqualString (acc, about_box_menu_name_pstr, TRUE, TRUE)) { do_about_box (); retval = 0; goto done; } if (OpenDriver(acc, &retval) == noErr) { retval = CW(retval); dctlh = GetDCtlEntry(retval); if (dctlh) { wp = HxP(dctlh, dCtlWindow); if (wp) { ShowWindow(wp); SelectWindow(wp); } } } done: SEvtEnb = TRUE; return retval; }