jenlan@eos (Jennifer S Lanham) (03/21/90)
I am timing graphics using a VblTask installed into one of the video card vbl queues. The task's addr field points to a routine which increments a counter and resets the vblCount. I collected a couple of articles from this group on how to go about installing and using the routine. One method I tried uses the Cache (A5) stuff and one does not. The Cache(A5) stuff causes a crash. The other routine seems to work if I set the vblCount to a large number ( say 30000). It will bomb if my synchronization routine catches thevblCount at 0. ( Note that is the symptom not necessarily the cause of the bomb.) I have also checked the tech note ( 180?) which has an example similar to what I am doing. A kmodified version of that code also crashes the Mac( like the Cache(A5) above crash.) Using MacII, Think C 4.0, System 6.03, and Think C Debugger. The program is a short term, specific user ( ME) thing so compatibility is not an issue. I want it to work on my machine with my software and that's it. Questions: According to the tech. note it is technically not necessary to carry A5 around except for future compatibility. Does the simple fact of running multifinder require carrying A5? ( I do not switch in and out of my application, though multifinder IS running. Does the Think C Debugger affect any part of the vbl routine? When do the tasks in the vbl queue(s) execute? Is it when SystemTask() is called? Is there (another) place where help for this stuff can be found? Anyone? Anyone?....... Thanks, Jennifer. jenlan@eos.arc.nasa.gov Below,for anyone who could help, there's the code for two of the methods that I have tried. Other wise ^n.... /********No A5 stuff in this version**********/ long gCounter; VBLTask *vTrace; pascal void DummyTask() { gCounter ++; vTrace->vblCount = 1; } /*To start up the counter, fill the fields, allocate the record*/ void InstallVideoRT() { OSErr errOR; gCounter = 0; vTrace = (VBLQElPtr) NewPtr(sizeof(VBLTask)); vTrace->qType = vType; vTrace->vblAddr = (ProcPtr) &DummyTask; vTrace->vblCount = 1; /*If I set this very high and use it instead of the gCounter in the synch routine, then it only sometimes crashes*/ vTrace->vblPhase = 0; errOR = SlotVInstall(vTrace, 14); } /*To synchronize with the vbl of my video card*/ void SynchVideo() { int wait = gCounter; while(gCounter == wait); } void RemoveVideoRT() { OSErr errOR; errOR =SlotVRemove(vTrace, 14); } /*******Modified from tech. notes***********/ long gCounter; struct VBLRec{ VBLTask theVTask; long VBLA5; }; typedef struct VBLRec VBLRec ,*VBLRecPtr; VBLRec theRec; VBLRecPtr GetVBLRec() { asm { move.l a0,d0 } } void DoVBL(VRP) VBLRecPtr VRP; { gCounter++; VRP->theVTask.vblCount = 1; } pascal void StartVBL() { long curA5; VBLRecPtr recPtr; recPtr = GetVBLRec(); curA5 = SetA5 (recPtr->VBLA5); DoVBL(recPtr); (void) SetA5 (curA5); } void InstallVideoRT() { OSErr theErr; gCounter = 0; theRec.theVTask.vblAddr = (ProcPtr) &StartVBL; theRec.theVTask.vblCount = 1; theRec.theVTask.qType = vType; theRec.theVTask.vblPhase = 0; theErr= SlotVInstall((QElemPtr)&theRec.theVTask, 14); } void RemoveVideoRT() { OSErr theErr; theErr = SlotVRemove((QElemPtr) &theRec.theVTask, 14); } void SynchVideo() { long wait; wait = gCounter; while(wait == gCounter); }