home *** CD-ROM | disk | FTP | other *** search
- /*Add global strings (tempstr, errstring) without testing.... check it */
- /*#define Debugging 1 Uncomment to debug. Must change the Project type to APPL*/
-
- #ifndef nil
- #define nil 0L
- #endif nil
- #define ThinkC
- #define numfuncs 7 /* The number of external functions in this file */
- #include "ThinkCGlue.h" /* THE HEADER IN THIS FILE MUST BE CHANGED WHENEVER ANY CODE IS ADDED */
- /* Note: The headers sound.h and soundInput.h where in beta when this code was
- begin developed. These files are probably different from what Apple/Symantec
- is currently shipping. */
- #include "sound.h"
- #include "soundInput.h"
-
-
- /* constants */
- /* STR# rsrc*/
- enum {sRoutineNames=5000, sErrStrings, sSMErrStrings};
-
- /* STR# items */
- enum { siRecordRoutine=1, siDeleteRoutine, siGetQualityRoutine,siSetQualityRoutine,
- siCopyPICTRoutine,siGetSoundsRoutine,siMySFGetFile};
-
- enum { siMemErr=1, siResErr, siNoSoundErr,siWrongRecVersion, siWrongPlayVersion,
- siSoundPlayErr, siSoundRecErr, siFileErr, siNeedClosedSpeadSheet, siAlreadyInUse,
- siNoSoundErrOrFileErr, siCancelled,siBadQuality};
-
- #define kQualID 5000 /* rsrcID of our quality resource */
-
- /*Globals*/
- short gOurResFile; /* tools rsrc file */
- GrafPtr gOurPort; /* tools graph port */
- OSType **gQualRsrc; /* stores the current quality at which to record */
- Str255 gGlobalStr; /* when returning a string to Resolve, the string must be global*/
- short gSndIndex; /* used by getSounds() to keep track of next sound when repeatedly*/
-
- /*These are our function names that we read in from the rsrc fork. They must exist in global variables and cannot
- be changed after set. */
- typedef char Str31[32];
- Str31 gFuncName[numfuncs];
-
- /* MACROS */
- #define FILENAME parg[0].val.string
- #define SNDNAME parg[1].val.string
- #define ABS(val) ((val < 0) ? (-val) : (val))
- #define TopLeft(r) (* (Point *) &(r).top)
- #define BotRight(r) (* (Point *) &(r).bottom)
- #define SETPT(pt, x, y) (*(pt)).h = (x); (*(pt)).v = (y)
- #define SETRECT(r, left, top, right, bottom) \
- SETPT(&TopLeft(*(r)), (left), (top)); \
- SETPT(&BotRight(*(r)), (right), (bottom))
-
- /* return an error from function to Resolve*/
- #define DoErr(num) {pret[0].flag = ERR;pret[0].val.err =(short) num;RestoreA4();return;}
-
- /* Set up an error for returning but don't return */
- #define SetErr(num) {pret[0].flag = ERR;pret[0].val.err = num;}
-
- /* Set up a string for returning but don't return */
- #define SetReturnStr(str) {pret[0].flag = STRING;pret[0].val.string =(char *) StripAddress(str);}
-
- #define _Unimplemented 0xA89F /*traps */
- #define _SoundInput 0xA800
- #define _SndPlay 0xA805
-
-
- Boolean TrapAvailable(short tNumber,short tType){
- return NGetTrapAddress(tNumber, tType) != GetTrapAddress(_Unimplemented);
- }
-
- Boolean InputManagerInstalled(void){
- return (( TrapAvailable(_SoundInput, 1)) && (MACEVersion() !=0));
- }
-
- Boolean SndPlayInstalled(void){
- return (TrapAvailable(_SndPlay, 1));
- }
-
- /******************Window Centering Code *******************/
-
- void PositionTwoRects(Rect outerRect, Rect *innerRect, Fixed horzRatio, Fixed vertRatio){
- short outerRectHeight;
- short outerRectWidth;
- short innerRectHeight;
- short innerRectWidth;
- short yLocation;
- short xLocation;
-
- outerRectHeight = outerRect.bottom - outerRect.top;
- outerRectWidth = outerRect.right - outerRect.left;
-
- innerRectHeight = (*innerRect).bottom - (*innerRect).top;
- innerRectWidth = (*innerRect).right - (*innerRect).left;
- yLocation = Fix2Long (FixMul (Long2Fix (outerRectHeight - innerRectHeight), vertRatio))
- + outerRect.top;
- xLocation = Fix2Long (FixMul (Long2Fix (outerRectWidth - innerRectWidth), horzRatio))
- + outerRect.left;
-
- (*innerRect).top = yLocation;
- (*innerRect).left = xLocation;
- (*innerRect).bottom = yLocation + innerRectHeight;
- (*innerRect).right = xLocation + innerRectWidth;
- }
-
-
- /* This procedure is used to get the rectangle that surrounds the entire structure of a
- window, given the rectangle that would be used for the portRect. It does this by
- temporarily creating a window way offscreen, and getting the rgnBBox of its strucRgn.
- The window is disposed of afterwards, and the port set back to the original port. */
-
- void GetWindowStrucRect(short procID, Rect boundsRect, Rect *strucRect){
- #define kOffscreenLoc 0x4000
-
- GrafPtr oldPort;
- WindowPtr tempWindow;
- Point offsetAmount;
-
- GetPort(&oldPort);
- SETPT(&offsetAmount, kOffscreenLoc, kOffscreenLoc);
- SubPt(TopLeft(boundsRect), &offsetAmount);
- OffsetRect(&boundsRect, offsetAmount.h, offsetAmount.v);
- tempWindow = NewWindow(nil, &boundsRect, '', true, procID, (WindowPtr)nil, true, 0);
- (*strucRect) = (**(*(WindowPeek)tempWindow).strucRgn).rgnBBox;
- DisposeWindow(tempWindow);
- OffsetRect(strucRect, -offsetAmount.h, -offsetAmount.v);
- SetPort(oldPort);
- }
-
-
- void CenterWindowRectTo (short procID, Rect screenRect, Rect *theRect){
- Point windowSize;
- Rect strucRect, newStrucRect;
-
- GetWindowStrucRect(procID, *theRect, &strucRect);
- newStrucRect = strucRect;
- PositionTwoRects(screenRect, &newStrucRect, FixRatio (1, 2), FixRatio (1, 3));
- windowSize = BotRight(*theRect);
- SubPt(TopLeft(*theRect), &windowSize);
- (*theRect).top = newStrucRect.top + ((*theRect).top - strucRect.top);
- (*theRect).left = newStrucRect.left + ((*theRect).left - strucRect.left);
- (*theRect).bottom = (*theRect).top + windowSize.v;
- (*theRect).right = (*theRect).left + windowSize.h;
- }
-
- void CenterWindowRect (short procID, Rect *theRect){
- Rect screenRect;
-
- screenRect = screenBits.bounds;
- screenRect.top += GetMBarHeight();
- CenterWindowRectTo(procID, screenRect, theRect);
- }
-
-
- Point CenteredDLOG(short ID){
- DialogTHndl dlogH;
- short itemHit;
- Point pt;
-
- dlogH = (DialogTHndl)Get1Resource('DLOG',ID);
- SETPT(&pt,30,40);
- if (dlogH) {
- MoveHHi((Handle)dlogH);
- HLock((Handle)dlogH);
- CenterWindowRect(dBoxProc, &((**dlogH).boundsRect));
- SETPT(&pt,((**dlogH).boundsRect.left),((**dlogH).boundsRect.top));
- HUnlock((Handle)dlogH);
- }
- return (pt);
- }
-
- /******************SFResult to FullPathName Code**************/
- /* given a working directory, this call returns a volumen and folder */
- OSErr SFVolDir(short wd, short *volume, long *folder){
- WDPBRec pb;
- unsigned char name[72];
-
- pb.ioNamePtr = (StringPtr)name;
- pb.ioVRefNum = wd;
- pb.ioWDIndex = 0;
- pb.ioWDProcID = 0;
- pb.ioWDVRefNum = 0;
- PBGetWDInfo(&pb, false);
- if (pb.ioResult) return pb.ioResult;
- *volume = pb.ioWDVRefNum;
- *folder = pb.ioWDDirID;
- return noErr;
- }
-
- /*given a filename, volume, and dirId it returns a fullpathname in fullName*/
- OSErr FullFileName(StringPtr fullName, StringPtr fName, short volume, long dirID){
- StringHandle tempName;
- Str255 text, volname;
- HVolumeParam hvp;
- CInfoPBRec di;
- long size;
- short err;
-
- /* extract the volume Name */
- volname[0]='\0';
- hvp.ioNamePtr = volname;
- hvp.ioVRefNum = volume;
- hvp.ioVolIndex = 0;
- PBHGetVInfo((HParmBlkPtr)&hvp, false);
-
- /* create and initialize the name handle */
- if ((tempName = (StringHandle) NewHandle(256)) == 0)
- return MemError();
- BlockMove((Ptr)fName+1,(Ptr)*tempName,fName[0]);
- size = fName[0];
- /* now start extracting the dirs and prepending them to the handle*/
- for ( ; dirID != 2; dirID = di.dirInfo.ioDrParID) {
- text[0] = 0;
- di.dirInfo.ioNamePtr = text;
- di.dirInfo.ioVRefNum = volume;
- di.dirInfo.ioFDirIndex = -1;
- di.dirInfo.ioDrDirID = dirID;
- PBGetCatInfo(&di, false);
- text[++text[0]] = ':';
- SetHandleSize(tempName,size +=text[0]);
- BlockMove((Ptr)*tempName, (Ptr)(*tempName) + text[0], size - text[0]);
- BlockMove((Ptr)text + 1, (Ptr)*tempName, text[0]);
- }
-
- /* prepend the volume name onto the handle */
- volname[++volname[0]] = ':';
- SetHandleSize(tempName, size += volname[0]);
- BlockMove((Ptr)*tempName, (Ptr)(*tempName) + volname[0], size - volname[0]);
- BlockMove((Ptr)volname + 1, (Ptr)*tempName, volname[0]);
-
- /* copy and delete the handle */
- if (size > 255) {
- DisposHandle(tempName);
- SysBeep(12);
- fullName[0] = 0;
- return -1; /*too big... fail*/
- }
- fullName[0] = size;
- BlockMove((Ptr)*tempName, (Ptr)fullName + 1, size);
- DisposHandle(tempName);
- return noErr;
- }
-
- /*simple takes a SFReply and uses it to call SFVolDir and then FullFileName */
- void GetFullPathName(SFReply sf,Str255 fullName){
- short volume;
- long folder;
-
- fullName[0]='\0';
-
- if (!SFVolDir(sf.vRefNum, &volume,&folder))
- FullFileName((StringPtr)fullName,sf.fName,volume,folder);
- }
-
-
- /******************Error handling function ******************/
- /* Return an error string to Resolve that is found in the tools STR# rsrc*/
- void getErrString(OSErr err,short messageID,Str255 errString){
- short savedResFile;
- Str255 errNumStr;
-
- savedResFile=CurResFile();
- UseResFile(gOurResFile);
-
- if (messageID > 0 ){
- GetIndString(errString, sErrStrings, messageID);
- }
- if (err!=0)
- NumToString(err, errNumStr);
- if (err){ /* combine the strings */
- BlockMove(StripAddress(" Error Nº "),&(errString[errString[0]+1]),11);
- errString[0]+=11;
-
- BlockMove(&(errNumStr[1]),&(errString[errString[0]+1]),errNumStr[0]);
- errString[0]+=errNumStr[0];
- }
-
- UseResFile(savedResFile);
- }
-
- /**********************Delete A Sound From the File ************/
- void delete1Sound(StringPtr name,short sndResFile){
- Handle sndH;
- short rsrcID;
- OSType rsrcType;
- short attribs;
- Str31 tempStr;
-
- SetResLoad(false); /* don't need to load in data to delete it. */
- sndH=(Handle)Get1NamedResource('snd ',name);
- if (sndH){
- GetResInfo(sndH, &rsrcID, &rsrcType, &tempStr); /* get the rsrcID */
- RmveResource(sndH); /* remove it */
- ChangedResource(sndH);
- UpdateResFile(sndResFile);
- attribs=GetResFileAttrs(sndResFile); /* compact the rsrc file*/
- attribs &= mapCompact;
- SetResFileAttrs(sndResFile,attribs);
- UpdateResFile(sndResFile);
- }
- SetResLoad(true);
- }
-
- /********************Tool ROUTINES********************/
- /* Dispose of our global stuff*/
- void cleanup(void){
-
- SetUpA4();
- UseResFile(gOurResFile);
- ChangedResource(gQualRsrc);
- WriteResource(gQualRsrc); /* we're assuming that we can write to the tools rsrc fork */
- HUnlock(gQualRsrc);
- ReleaseResource(gQualRsrc);
- RestoreA4();
- }
-
-
- /* gets quality form global */
- void recordSound(PVAL pret, PVAL parg){
- OSErr err;
- short rsrcID;
- Handle sndH;
- Point pt={50,60};
- short sndResFile;
- short vRefNum;
- GrafPtr savedport;
- short savedResFile;
- short tempFileRefNum;
-
- SetUpA4();
- sndH=nil;
- sndResFile=-1;
- SETPT(&pt, 40, 50);
- gGlobalStr[0]=0;
- SetReturnStr(gGlobalStr);/*whatever is in this sting will be returned when tool's function returns*/
- if ((parg[0].flag != STRING )&&( parg[1].flag != STRING ))
- DoErr(12);
-
- if (!InputManagerInstalled()){
- getErrString(0, siWrongRecVersion,gGlobalStr);
- goto recordReturnPoint;
- }
-
- GetPort(&savedport);
- savedResFile=CurResFile();
-
- SetPort(gOurPort);
- UseResFile(gOurResFile);
-
- GetVol(nil,&vRefNum);
- tempFileRefNum=0;
- err=FSOpen(FILENAME, vRefNum, &tempFileRefNum); /* note: we don't need the fileNum just check
- to see if it's open*/
- if (err==-49){
- getErrString(err, siNeedClosedSpeadSheet,gGlobalStr);
- goto recordReturnPoint;
- }
- else if (err==-54){
- getErrString(err, siAlreadyInUse,gGlobalStr);
- goto recordReturnPoint;
- }
- else if (err){
- getErrString(err, siFileErr,gGlobalStr);
- goto recordReturnPoint;
- }
- /*else we opened it. This means we can write to it's rsrc fork.
- well close it when we're done!*/
- CreateResFile(FILENAME); /*Does nothing if file already exists*/
- if ((sndResFile=OpenRFPerm(FILENAME,vRefNum,fsRdWrPerm))==-1){
- getErrString(ResError(), siResErr,gGlobalStr);
- goto recordReturnPoint;
- }
-
- sndH=NewHandle(MaxBlock()*3/4-20000); /* leave some free space, Note: I don't know how much. */
- if (sndH==nil){
- getErrString(MemError(), siMemErr,gGlobalStr);
- goto recordReturnPoint;
- }
- InitCursor();
- HLock((Handle)gQualRsrc); /* don't let it move*/
- err=SndRecord(nil, pt, *(OSType *)StripAddress(*gQualRsrc), &sndH); /* allow other quals?*/
- HUnlock((Handle)gQualRsrc); /* don't let it move*/
-
- if (err == -128){ /*user cancelled*/
- getErrString(0,siCancelled,gGlobalStr);
- goto recordReturnPoint;
- }
- else if (err){
- getErrString(err, siSoundRecErr,gGlobalStr);
- goto recordReturnPoint;
- } /* delete any existing sound with the same name*/
-
- delete1Sound((StringPtr )SNDNAME,sndResFile);
-
- while((rsrcID=UniqueID('snd '))<5000); /* get a unique resource rsrcID > 5000 */
-
- AddResource(sndH, 'snd ', rsrcID, SNDNAME);
- if (err=ResError()){
- getErrString(err, siResErr,gGlobalStr);
- goto recordReturnPoint;
- }
- UpdateResFile(sndResFile);
- ReleaseResource(sndH);
- sndH=nil;
-
- recordReturnPoint:
- if (sndH){
- DetachResource(sndH);
- DisposHandle(sndH);
- sndH=nil; /* leave it memory?*/
- }
- if (sndResFile!=-1)
- CloseResFile(sndResFile);
- if (tempFileRefNum)
- FSClose(tempFileRefNum);
- SetPort(savedport);
- UseResFile(savedResFile);
- RestoreA4();
- }
-
-
- void deleteSound(PVAL pret, PVAL parg){
- short savedResFile;
- short sndResFile;
- short vRefNum,tempFileRefNum;
- OSErr err;
-
- SetUpA4();
- sndResFile=-1;
- gGlobalStr[0]=0;
- SetReturnStr(gGlobalStr);/*whatever is in this sting will be returned when tool's function returns*/
-
- if ((parg[0].flag != STRING )&&( parg[1].flag != STRING ))
- DoErr(12);
-
- savedResFile=CurResFile();
- tempFileRefNum=0;
- GetVol(nil,&vRefNum);
- err=FSOpen(FILENAME, vRefNum, &tempFileRefNum); /* note: we don't need the fileNum just check
- to see if it's open*/
- if (err==-49){
- getErrString(err, siNeedClosedSpeadSheet,gGlobalStr);
- goto deleteReturnPoint;
- }
- else if (err==-54){
- getErrString(err, siAlreadyInUse,gGlobalStr);
- goto deleteReturnPoint;
- }
- else if (err){
- getErrString(err, siFileErr,gGlobalStr);
- goto deleteReturnPoint;
- }
- /*else we opened it. This means we can write to it's rsrc fork.
- well close it when we're done!*/
-
- if ((sndResFile=OpenRFPerm(FILENAME,vRefNum,fsRdWrPerm))==-1){
- getErrString(ResError(), siResErr,gGlobalStr);
- goto deleteReturnPoint;
- }
-
-
- delete1Sound((StringPtr)SNDNAME,sndResFile);
-
- deleteReturnPoint:
- if (sndResFile!=-1)
- CloseResFile(sndResFile);
- if (tempFileRefNum)
- FSClose(tempFileRefNum);
- UseResFile(savedResFile);
- RestoreA4();
- }
-
-
- void getSoundQuality(PVAL pret, PVAL parg){
- short savedResFile;
- OSErr err;
-
- SetUpA4();
-
- gGlobalStr[0]=0;
- SetReturnStr(gGlobalStr);/*whatever is in this sting will be returned when tool's function returns*/
-
- /* put the global quality into the return string */
- BlockMove(StripAddress(*gQualRsrc),&(gGlobalStr[1]),4L); /* convert OSType to pascal String */
- gGlobalStr[0]=4;
-
- }
-
- /* check that the quality passed to this routine is in ('good','betr','best') and set the global gQualRsrc to it.
- Note that the values 'good', 'betr', 'best' are hard coded and may present incompatalities with future sound input
- drivers*/
- void setSoundQuality(PVAL pret, PVAL parg){
- short savedResFile;
- short count;
- OSType tempQual;
-
- SetUpA4();
-
- if (parg[0].flag != STRING )
- DoErr(12);
-
- savedResFile=CurResFile();
- UseResFile(gOurResFile);
-
- if (parg[0].val.string[0] != 4) /* should be only 4 characters long for an OSType */
- getErrString(0,siBadQuality,gGlobalStr);
-
- BlockMove(&(parg[0].val.string[1]),&tempQual,4L); /* load the quality into a temp variable */
- /* since an OSType is actually a long, compare longs to see it they match */
- switch (tempQual) {
- case ('good'):
- case ('betr'):
- case ('best'):
- **gQualRsrc=tempQual; /* valid quality so assign it to our global */
- break;
- default:
- getErrString(0,siBadQuality,gGlobalStr); /* not a valid quality so return an error*/
- }
-
- UseResFile(savedResFile);
- RestoreA4();
- }
-
- void copyPict(PVAL pret,PVAL parg){
- OSErr err;
- Handle pictH;
- long size;
- short savedResFile;
-
- SetUpA4();
- pictH=nil;
-
- if ( parg[0].flag != STRING )
- DoErr(12);
-
- savedResFile=CurResFile();
- UseResFile(gOurResFile);
- pictH=Get1NamedResource('PICT',parg[0].val.string);
- if (pictH==nil){
- SetResLoad(false);
- pictH=Get1NamedResource('PICT',parg[0].val.string);
- SetResLoad(true);
- if (pictH==nil){
- SetErr(8); /* insufficient data error*/
- }
- else{
- SetErr(21); /* Out-o-mem*/
- }
- goto pictReturnPoint; /* complete normally*/
- }
- size=GetHandleSize(pictH);
- HLock(pictH);
- if (err=ZeroScrap())
- goto pictReturnPoint;
- if (size & 1) /* make sure not odd (by checking bit 0) */
- size++;
- err=PutScrap(size,'PICT',*pictH);
- err=SystemEdit(3);
-
- pictReturnPoint:
- if (pictH){
- HUnlock(pictH);
- ReleaseResource(pictH);
- }
- UseResFile(savedResFile);
- RestoreA4();
- }
-
- void getSounds(PVAL pret, PVAL parg){
- OSErr err;
- short rsrcID;
- OSType rsrcType;
- Handle sndH;
- short sndResFile;
- short vRefNum;
- short tempFileRefNum,savedResFile;
-
-
- SetUpA4();
- sndH=nil;
- sndResFile=-1;
- savedResFile=CurResFile();
-
- gGlobalStr[0]=0;
- SetReturnStr(gGlobalStr);/*whatever is in this sting will be returned when tool's function returns*/
-
- if (parg[0].flag != STRING )
- DoErr(12);
- UseResFile(gOurResFile);
-
- GetVol(nil,&vRefNum);
- err=FSOpen(FILENAME, vRefNum, &tempFileRefNum); /* note: we don't need the fileNum just check
- to see if it's open*/
- if (err==-49){
- getErrString(err, siNeedClosedSpeadSheet,gGlobalStr);
- goto getSoundsReturnPoint;
- }
- else if (err==-54){
- getErrString(err, siAlreadyInUse,gGlobalStr);
- goto getSoundsReturnPoint;
- }
- else if (err){
- getErrString(err, siFileErr,gGlobalStr);
- goto getSoundsReturnPoint;
- }
- /*else we opened it. This means we can write to it's rsrc fork.
- well close it when we're done!*/
-
- if ((sndResFile=OpenRFPerm(FILENAME,vRefNum,fsRdWrPerm))==-1){
- getErrString(ResError(), siResErr,gGlobalStr);
- goto getSoundsReturnPoint;
- }
-
- SetResLoad(false); /* don't need to load in data to delete it. */
- sndH=(Handle)Get1IndResource('snd ',gSndIndex);
- gSndIndex++;
- if (sndH){
- GetResInfo(sndH, &rsrcID, &rsrcType, &gGlobalStr); /* get the rsrcID */
- }
- /*else we return an empty string*/
- SetResLoad(true);
-
- getSoundsReturnPoint:
- if (sndResFile!=-1)
- CloseResFile(sndResFile);
- if (tempFileRefNum)
- FSClose(tempFileRefNum);
-
- UseResFile(savedResFile);
- RestoreA4();
- }
-
- /* param 0 is the prompt, 1-4 is the file type filter */
- void sfGetFile(PVAL pret,PVAL parg){
- SFReply sf;
- Point pt;
- SFTypeList sflist;
- short count;
- GrafPtr savedport;
- short savedResFile;
-
- SetUpA4();
- GetPort(&savedport);
- savedResFile=CurResFile();
- SetPort(gOurPort);
-
- if ((parg[0].flag != STRING) &&(parg[1].flag != STRING) &&(parg[2].flag != STRING) &&
- (parg[3].flag != STRING) &&(parg[4].flag != STRING))
- DoErr(12);
- count=0;
- while((parg[count+1].val.string)[0] != 0){ /* copy the data into sflist struct, while it's not empty */
- count++;
- BlockMove((Ptr)&((parg[count].val.string)[1]),(Ptr)&(sflist[count-1]),4L);
- }
- if (count == 0 )
- count=-1; /* show all files */
-
- ParamText(nil,nil,nil,parg[0].val.string); /* Use position 4 to minimize impact on Bat*/
- pt=CenteredDLOG(14000); /* center the SFGet dialog*/
- SFPGetFile(pt,parg[0].val.string,nil,count,sflist,nil,&sf,14000,nil);
-
- ParamText(nil,nil,nil,"\p"); /*zero it out*/
- pret[0].flag = STRING;
- if (sf.good){
- GetFullPathName(sf,gGlobalStr);
- }
- else{
- gGlobalStr[0] = '\0';
- }
- pret[0].val.string =(char *) StripAddress(gGlobalStr);
- SetPort(savedport);
- UseResFile(savedResFile);
- RestoreA4();
- }
-
-
- ROUT myROUT;
-
- #ifdef Debugging
- _main(void){
- #else
- main(void){
- #endif Debugging
- ROUT *PROut;
-
- RememberA0();
- SetUpA4();
-
- /* Tell about our Functions*/
- PROut=&myROUT;
- PROut->nrout = numfuncs;
- PROut->exitfunc = (ProcPtr)cleanup;
-
- /* Load in function names from our rsrc fork. Note that these strings MUST be placed into
- seperate globals since Resolve doesn't copy them into there own memory*/
- GetIndString(gFuncName[0], sRoutineNames, siRecordRoutine);
- GetIndString(gFuncName[1], sRoutineNames, siDeleteRoutine);
- GetIndString(gFuncName[2], sRoutineNames, siSetQualityRoutine);
- GetIndString(gFuncName[3], sRoutineNames, siGetQualityRoutine);
- GetIndString(gFuncName[4], sRoutineNames, siCopyPICTRoutine);
- GetIndString(gFuncName[5], sRoutineNames, siGetSoundsRoutine);
- GetIndString(gFuncName[6], sRoutineNames, siMySFGetFile);
-
- /* Set info that Resolve uses when calling the function*/
- PROut->relts[0].pfunc = (ProcPtr)recordSound; /* location */
- PROut->relts[0].name = gFuncName[0];/* name of function in Resolve script*/
- PROut->relts[0].narg = 2; /* number of parameters that the function requires*/
-
- PROut->relts[1].pfunc = (ProcPtr) deleteSound;
- PROut->relts[1].name = gFuncName[1];
- PROut->relts[1].narg = 2;
-
- PROut->relts[2].pfunc = (ProcPtr)setSoundQuality;
- PROut->relts[2].name = gFuncName[2];
- PROut->relts[2].narg = 1;
-
- PROut->relts[3].pfunc = (ProcPtr)getSoundQuality;
- PROut->relts[3].name = gFuncName[3];
- PROut->relts[3].narg = 0;
-
- PROut->relts[4].pfunc = (ProcPtr)copyPict;
- PROut->relts[4].name = gFuncName[4];
- PROut->relts[4].narg = 1;
-
- PROut->relts[5].pfunc = (ProcPtr)getSounds;
- PROut->relts[5].name = gFuncName[5];
- PROut->relts[5].narg = 1;
-
- PROut->relts[6].pfunc = (ProcPtr)sfGetFile;
- PROut->relts[6].name = gFuncName[6]; /* later make these be able to be read in from the rsrc fork */
- PROut->relts[6].narg = 5;
-
- /* init globals*/
- gOurResFile=CurResFile();
- InitGraf(&thePort);
- GetPort(&gOurPort);
-
- /* install our qual global */
- gSndIndex=1;
- gQualRsrc=nil;
- gQualRsrc=(OSType **)GetResource('qual', kQualID);
- HNoPurge((Handle)gQualRsrc); /*leave it around */
- RestoreA4();
- asm{
- MOVEA.L 0X316, A1;
- MOVEA.L 4(A1), A0;
- MOVE.L PROut, 0xE(A0);
- }
- }
-
-
- #ifdef Debugging
- void InitMac(void){
- MoreMasters();
- MoreMasters();
- MaxApplZone();
-
- SetResLoad(true);
- /*InitGraf(&thePort); general setup */
- /*InitResources();*/
- InitFonts();
- FlushEvents(everyEvent, 0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
- }
-
- main(){
- VAL dummy;
- Boolean b;
- short parent;
- OSErr err;
- Str255 str="\pMacHog";
-
- _main();
- InitMac();
-
- /*dummy.val.string=gFuncName2;
- dummy.flag=STRING;
- copyPict(&dummy, &dummy);*/
- Debugger();
-
- }
- #endif Debugging
-