home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / U-Z / VideoToolBox Folder / VideoToolboxSources / GDInfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-22  |  5.3 KB  |  152 lines  |  [TEXT/KAHL]

  1. /*
  2. GDInfo.c
  3. Gets various bits of useful information from the driver, if possible, or,
  4. failing that, from the GDevice record, and puts them into the user-supplied
  5. record. Under 1-bit QuickDraw it ignores the "device" argument.
  6.  
  7. This routine gets all the information that can be had quickly without disturbing
  8. the screens. TimeVideo.c and TestClut.c get further information. I'd like to end
  9. up with a few low level subroutines, like this one, that just fill in the
  10. VideoCard structure, so that the demo programs would mainly just print out the
  11. information in an intelligible way.
  12. */
  13. #include <VideoToolbox.h>
  14. #include <GDInfo.h>
  15.  
  16. OSErr GDInfo(GDHandle device,VideoCard *card)
  17. {
  18.     OSErr error;
  19.     GammaTbl *gamma;
  20.     Boolean ok;
  21.     short pageCount,j;
  22.     Rect r;
  23.     long quickDraw;
  24.     ColorSpec cSpec;
  25.     
  26.     Gestalt(gestaltQuickdrawVersion,&quickDraw);
  27.     if(quickDraw<gestalt8BitQD){
  28.         sprintf(card->cardName,"%s","Original 1-bit QuickDraw");
  29.         sprintf(card->driverName,"%s","Original 1-bit QuickDraw");
  30.         card->depth[0].pixelSize=1;
  31.         for(j=1;j<6;j++)card->depth[j].pixelSize=0;
  32.         card->slot=0;
  33.         CopyQuickDrawGlobals();    // make sure qd is valid.
  34.         r=qd.screenBits.bounds;
  35.         card->width=r.right-r.left;
  36.         card->height=r.bottom-r.top;
  37.         card->isGray=0;
  38.         card->depth[0].colors=2;
  39.         card->depth[0].framesPerClutUpdate=NAN;
  40.         card->depth[0].framesPerClutUpdateHighPriority=NAN;
  41.         card->depth[0].framesPerClutUpdateQuickly=NAN;
  42.         card->depth[0].vblPerFrame=1.0;
  43.         card->gdType=fixedType;
  44.         card->mode=oneBitMode;
  45.         card->m=card->mode&7;
  46.         card->dacSize=1;
  47.         card->dacMask=((1<<card->dacSize)-1)<<(16 - card->dacSize);
  48.         return 0;
  49.     }
  50.     sprintf(card->cardName,"%s",GDCardName(device));
  51.     if(GDVersion(device)==0)sprintf(card->driverName,"%#s",GDName(device));
  52.     else sprintf(card->driverName,"%#s version %d",GDName(device),GDVersion(device));
  53.     for(j=0;j<6;j++){
  54.         if(NewPaletteManager()){
  55.             ok=HasDepth(device,1<<j,0,0);
  56.         }else{
  57.             error=GDGetPageCnt(device,0x80+j,&pageCount);
  58.             ok=(!error && pageCount>0);
  59.         }
  60.         if(ok){
  61.             card->depth[j].pixelSize=1<<j;
  62.             GDGetPageCnt(device,0x80+j,&card->depth[j].pages);
  63.         }else{
  64.             card->depth[j].pixelSize=0;
  65.             card->depth[j].pages=0;
  66.         }
  67.     }
  68.     card->slot=GetDeviceSlot(device);
  69.     r=(**(**device).gdPMap).bounds;
  70.     card->width=r.right-r.left;
  71.     card->height=r.bottom-r.top;
  72.     // Quadra 900 built-in video gives misleading answer on portrait? monitor, always gray.
  73. //    error=GDGetGray(device,&card->isGray);
  74. //    if(error);
  75.     card->isGray=!TestDeviceAttribute(device,gdDevType);
  76.     error=GDGetMode(device,&card->mode,NULL,NULL);
  77.     if(error)card->mode=(**device).gdMode;
  78.     card->m=card->mode&7;
  79.     card->depth[card->m].colors=GDClutSize(device);
  80.     card->gdType=(*device)->gdType;
  81.     if(card->gdType!=fixedType) switch(card->mode){
  82.         default:
  83.         case oneBitMode:
  84.         case twoBitMode:
  85.         case fourBitMode:
  86.         case eightBitMode:
  87.             card->gdType=clutType;
  88.             break;
  89.         case sixteenBitMode:
  90.         case thirtyTwoBitMode:
  91.             card->gdType=directType;
  92.             break;
  93.     }
  94.     error=GDGetGamma(device,&gamma);        // Takes 200 µs.
  95.     if(error)card->dacSize=8;
  96.     else card->dacSize=gamma->gDataWidth;
  97.     card->dacMask=((1<<card->dacSize)-1)<<(16 - card->dacSize);
  98.     card->setEntriesQuickly=(GetCardType(device)!=0);
  99.     card->gdGetEntries=(0==GDGetEntries(device,0,0,&cSpec));
  100.     card->basicTest=1;
  101.     return 0;
  102. }
  103.  
  104. OSErr GDTime(GDHandle device,VideoCard *card)
  105. {
  106.     OSErr error;
  107.     short colors=0,m=card->m;
  108.     double frames,s,missingFrames,frameRate;
  109.     long cpu,quickDraw;
  110.     
  111.     printf("%d-bit pixels: timing CopyBits . . .             \r",card->depth[m].pixelSize);
  112.     card->depth[m].movieRate=GDMovieRate(device,0);
  113.     printf("%d-bit pixels: timing CopyBitsQuickly . . .      \r",card->depth[m].pixelSize);
  114.     card->depth[m].movieRateQuickly=GDMovieRate(device,1);
  115.  
  116.     Gestalt(gestaltQuickdrawVersion,&quickDraw);
  117.     Gestalt(gestaltProcessorType,&cpu);
  118.     if(quickDraw>=gestalt8BitQD){
  119.         printf("%d-bit pixels: timing GDSetEntries . . .     \r",card->depth[m].pixelSize);
  120.         error=GDTimeClut(device,GDSetEntries,colors,&s,&frames,&missingFrames,&frameRate);
  121.         if(error)frameRate=GDFrameRate(device);
  122.         card->depth[m].frameRate=frameRate;
  123.         card->depth[m].vblPerFrame=GDVBLRate(device)/frameRate;
  124.         card->depth[m].framesPerClutUpdate=frames;
  125.         card->depth[m].missingFramesPerClutUpdate=missingFrames;
  126.     }else{
  127.         card->depth[m].frameRate=GDFrameRate(NULL);
  128.         card->depth[m].vblPerFrame=1.0;
  129.         card->depth[m].framesPerClutUpdate=NAN;
  130.         card->depth[m].missingFramesPerClutUpdate=NAN;
  131.     }
  132.     if(quickDraw>=gestalt8BitQD){
  133.         printf("%d-bit pixels: timing GDSetEntriesByTypeHighPriority . . . \r",card->depth[m].pixelSize);
  134.         error=GDTimeClut(device,GDSetEntriesByTypeHighPriority,colors,&s,&frames,&missingFrames,&frameRate);
  135.         card->depth[m].framesPerClutUpdateHighPriority=frames;
  136.         card->depth[m].missingFramesPerClutUpdateHighPriority=missingFrames;
  137.     }else{
  138.         card->depth[m].framesPerClutUpdateHighPriority=NAN;
  139.         card->depth[m].missingFramesPerClutUpdateHighPriority=NAN;
  140.     }
  141.     if(quickDraw>=gestalt8BitQD && cpu>=gestalt68020 && GetCardType(device)){
  142.         printf("%d-bit pixels: timing SetEntriesQuickly . . . \r",card->depth[m].pixelSize);
  143.         error=GDTimeClut(device,SetEntriesQuickly,colors,&s,&frames,&missingFrames,&frameRate);
  144.         card->depth[m].framesPerClutUpdateQuickly=frames;
  145.         card->depth[m].missingFramesPerClutUpdateQuickly=missingFrames;
  146.     }else{
  147.         card->depth[m].framesPerClutUpdateQuickly=NAN;
  148.         card->depth[m].missingFramesPerClutUpdateQuickly=NAN;
  149.     }
  150.     printf("                                                   \r");
  151.     card->timeTest=1;
  152. }