home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / mm / fsdive / fsdive.c < prev    next >
Text File  |  1999-05-11  |  41KB  |  1,181 lines

  1. /**************************************************************************
  2. *
  3. * File Name        : FSDIVE.C
  4. *
  5. * Description      : This program provides the sample code of using DIVE APIs.
  6. *
  7. *                    Direct Interface Video Extension is developed for
  8. *                    the entertainment, education, and games software
  9. *                    to give the high-speed perforemance.
  10. *
  11. *
  12. *
  13. * Concepts         :
  14. *
  15. * Entry Points     : DirectMoveMem()
  16. *                    ReadFile()
  17. *                    Main()
  18. *                    MyWindowProc()
  19. *
  20. * DIVE API's       :
  21. *                    DiveSetSourcePalette
  22. *                    DiveBlitImage
  23. *                    DiveAllocImageBuffer
  24. *                    DiveBeginImageBufferAccess
  25. *                    DiveEndImageBufferAccess
  26. *                    DiveOpen
  27. *                    DiveSetDestinationPalette
  28. *                    DiveFreeImageBuffer
  29. *                    DiveClose
  30. *                    DiveSetupBlitter
  31. *
  32. * Copyright        : COPYRIGHT IBM CORPORATION, 1991, 1992, 1993
  33. *
  34. *        DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  35. *        sample code created by IBM Corporation. This sample code is not
  36. *        part of any standard or IBM product and is provided to you solely
  37. *        for  the purpose of assisting you in the development of your
  38. *        applications.  The code is provided "AS IS", without
  39. *        warranty of any kind.  IBM shall not be liable for any damages
  40. *        arising out of your use of the sample code, even if they have been
  41. *        advised of the possibility of such damages.
  42. *
  43. ****************************************************************************/
  44.  
  45. #define INCL_DOS
  46. #define INCL_DOSMISC
  47. #define INCL_GPI
  48. #define INCL_WIN
  49. #define INCL_VIO
  50. #define INCL_GRE_COLORTABLE
  51. #define INCL_GRE_DEVMISC3
  52. #include <os2.h>
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #define  _MEERROR_H_
  56. #include <mmioos2.h>                    /* It is from MMPM toolkit           */
  57. #include <dive.h>
  58. #include <fourcc.h>
  59. #include <builtin.h>
  60. #include <pmddim.h>
  61.  
  62. #define FSBASE 1
  63.  
  64. #include "fsdive.h"
  65.  
  66.  
  67. #define WS_DesktopDive    0x00000000L   // Desktop dive window style
  68. #define WS_MaxDesktopDive 0x00000001L   // Maximized desktop dive window style
  69. #define WS_FullScreenDive 0x00000002L   // Full-screen 320x200x256 dive style
  70.  
  71. // Function prototypes
  72.  
  73. MRESULT EXPENTRY MyWindowProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  74. MRESULT EXPENTRY MyDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 );
  75.  
  76. // Global definitions
  77.  
  78. HAB       hab;                          /* PM anchor block handle            */
  79. ULONG     ulImage[MAX_FILE];            /* Image buffer numbers from Dive    */
  80. PBYTE     pPalette[MAX_FILE];           /* Pointer to bitmap palette area    */
  81. PSZ       pszMyWindow = "MyWindow";     /* Window class name                 */
  82. PSZ       pszTitleText = "DIVE SAMPLE"; /* Title bar text                    */
  83. ULONG     ulToEnd = 0;                  /*                                   */
  84. DIVE_CAPS DiveCaps = {0};
  85. FOURCC    fccFormats[100] = {0};
  86. ULONG     ulFramesToTime=8;             /* Interval of frames to get time    */
  87. ULONG     ulNumFrames=0;                /* Frame counter                     */
  88. ULONG ulWindowStyle = WS_DesktopDive;   // current window style
  89. BOOL      fFSBase = TRUE;               // FS DIVE support in base OS
  90.  
  91. //  Default bitmap file name definitions
  92. //       These files are used only when EXE is called without parameter.
  93.  
  94. PSZ  pszDefFile[] =
  95. {
  96.     {"TPG20000.BMP"},
  97.     {"TPG20001.BMP"},
  98.     {"TPG20002.BMP"},
  99.     {"TPG20003.BMP"},
  100.     {"TPG20004.BMP"},
  101.     {"TPG20005.BMP"},
  102.     {"TPG20006.BMP"},
  103.     {"TPG20007.BMP"},
  104.     {"TPG20008.BMP"},
  105.     {"TPG20009.BMP"},
  106.     {"TPG20010.BMP"},
  107.     {"TPG20011.BMP"},
  108.     {"TPG20012.BMP"},
  109.     {"TPG20013.BMP"},
  110.     {"TPG20014.BMP"},
  111.     {"TPG20015.BMP"}
  112. };
  113.  
  114. //  It is the definition how many time draw each bitmap
  115.  
  116. ULONG ulDrawCnt[] =
  117. {
  118.     1,                                  /* For TPG20000.BMP  */
  119.     1,                                  /* For TPG20001.BMP  */
  120.     1,                                  /* For TPG20002.BMP  */
  121.     1,                                  /* For TPG20003.BMP  */
  122.     1,                                  /* For TPG20004.BMP  */
  123.     1,                                  /* For TPG20005.BMP  */
  124.     1,                                  /* For TPG20006.BMP  */
  125.     1,                                  /* For TPG20007.BMP  */
  126.     1,                                  /* For TPG20008.BMP  */
  127.     1,                                  /* For TPG20009.BMP  */
  128.     1,                                  /* For TPG20010.BMP  */
  129.     1,                                  /* For TPG20011.BMP  */
  130.     1,                                  /* For TPG20012.BMP  */
  131.     1,                                  /* For TPG20013.BMP  */
  132.     1,                                  /* For TPG20014.BMP  */
  133.     1                                   /* For TPG20015.BMP  */
  134. };
  135.  
  136. /****************************************************************************
  137.  *
  138.  * Name          : DirectMoveMem
  139.  *
  140.  * Description   : It is calling DIVE bitblt function periodically.
  141.  *                 And also it calculates how many frames per a second
  142.  *                 is able to be blit to the screen.
  143.  *
  144.  * Concepts      :
  145.  *
  146.  * Parameters    : Pointer to window data
  147.  *
  148.  * Return        : VOID
  149.  *
  150.  ****************************************************************************/
  151.  
  152. VOID APIENTRY DirectMoveMem ( ULONG parm1 )
  153. {
  154.     ULONG    ulTime0, ulTime1;          /* output buffer for DosQierySysInfo      */
  155.     ULONG    ulIndexImage = 0;          /* Index of bitmap data                   */
  156.     CHAR     achFrameRate[48];          /* string buffer for WinSetWindowText     */
  157.     ULONG    ulFirstTime=0;             /* very first time flag for DiveSetSour.. */
  158.  
  159.     PWINDATA pwinData;                  /* pointer to window data                 */
  160.     ULONG    ulCount = 0;               /* Counter for each bitmap                */
  161.  
  162.     pwinData =(PWINDATA)parm1;
  163.  
  164.     while ( !ulToEnd )
  165.     {
  166.  
  167.         /* Check if it's time to start the blit-time counter.
  168.         */
  169.         if ( !ulNumFrames++ )
  170.             DosQuerySysInfo ( QSV_MS_COUNT, QSV_MS_COUNT, &ulTime0, 4L );
  171.  
  172.         /* Check if need to change the source palette.
  173.         **
  174.         ** In this sample case, this API should be called only once at
  175.         ** very first.  After this, it will not be called, because there is
  176.         ** assumption that all bitmap data have the sample palette.
  177.         */
  178.         if (( pwinData->fChgSrcPalette ) || (( !ulFirstTime ) &&
  179.             ( pwinData->ulnumColor  == 256 )) )
  180.         {
  181.             DiveSetSourcePalette ( pwinData->hDive, 0,
  182.                     pwinData->ulnumColor,
  183.                     pPalette[ulIndexImage] );
  184.             ulFirstTime = 0xFFFF;
  185.         }
  186.  
  187.         /* Blit the image.
  188.         */
  189.         DiveBlitImage ( pwinData->hDive,
  190.                 ulImage[ulIndexImage],
  191.                 DIVE_BUFFER_SCREEN );
  192.  
  193.         /* Updated the index for the bitmap data to be drawn next.
  194.         */
  195.         ulCount ++;
  196.         if ( ulCount >=  ulDrawCnt[ulIndexImage] )
  197.         {
  198.             ulIndexImage ++;
  199.             ulCount = 0;
  200.         }
  201.         if ( ulIndexImage >= pwinData->ulMaxFiles )
  202.             ulIndexImage = 0;
  203.  
  204.         /* Check to see if we have enough frames for a fairly accurate read.
  205.         */
  206.         if ( ulNumFrames>=ulFramesToTime )
  207.         {
  208.             DosQuerySysInfo ( QSV_MS_COUNT, QSV_MS_COUNT, &ulTime1, 4L );
  209.             ulTime1 -= ulTime0;
  210.             if ( ulTime1 )
  211.                 sprintf ( achFrameRate, "%d: %d: %5.2f frames per second.",
  212.                         pwinData->hDive, ulFramesToTime,
  213.                         (float)ulFramesToTime * 1000.0 / (float)ulTime1 );
  214.             else
  215.                 sprintf ( achFrameRate, "%d: %d: Lots of frames per second.",
  216.                         pwinData->hDive, ulFramesToTime );
  217.             WinPostMsg ( pwinData->hwndFrame, WM_COMMAND,
  218.                     (PVOID)ID_NEWTEXT, achFrameRate );
  219.             ulNumFrames = 0;
  220.  
  221.             /* Adjust number of frames to time based on last set.
  222.             */
  223.             if ( ulTime1 < 250 )
  224.                 ulFramesToTime <<= 1;
  225.             if ( ulTime1 > 3000 )
  226.                 ulFramesToTime >>= 1;
  227.         }
  228.  
  229.         /* Let other threads and processes have some time.
  230.         */
  231.         DosSleep ( 0 );
  232.     }
  233.     return;
  234. }
  235.  
  236. /****************************************************************************
  237.  *
  238.  * Name          : ReadFile
  239.  *
  240.  * Description   : It opens the file, and reads bitmap header and bitmap
  241.  *                 palette, and reads image data to the buffer allocated
  242.  *                 by DIVE APIs.
  243.  *
  244.  * Concepts      :
  245.  *
  246.  * Parameters    : Index for the file to open
  247.  *                 Pointer to the file name to open
  248.  *                 Pointer to window data
  249.  *
  250.  * Return        : 0 - succeed
  251.  *                 1 - fail
  252.  *
  253.  ****************************************************************************/
  254.  
  255.  
  256. unsigned long ReadFile ( ULONG iFile, unsigned char *pszFile,
  257.         PWINDATA pwinData )
  258. {
  259.     HFILE hFile;                        /* file handke                              */
  260.     ULONG ulNumBytes;                   /* output for number of bytes actually read */
  261.     ULONG ulFileLength;                 /* file length                              */
  262.     PBYTE pbBuffer;                     /* pointer to the image/ temp. palette data */
  263.     ULONG ulScanLineBytes;              /* output for number of bytes a scan line   */
  264.     ULONG ulScanLines;                  /* output for height of the buffer          */
  265.     PBITMAPFILEHEADER2 pImgHdr;         /* pointer to bitmapheader                  */
  266.     ULONG i, j;
  267.     PBYTE pbTmpDst;                     /* temporaly destination pointer            */
  268.  
  269.     /* Attempt to open up the passed filename.
  270.     */
  271.     if ( DosOpen ( pszFile, &hFile, &ulNumBytes, 0L, FILE_NORMAL,
  272.          OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
  273.          OPEN_ACCESS_READONLY | OPEN_SHARE_DENYREADWRITE |
  274.          OPEN_FLAGS_SEQUENTIAL | OPEN_FLAGS_NO_CACHE, 0L ) )
  275.         return( 1 );
  276.  
  277.     /* Get the legnth of the file.
  278.     */
  279.     DosSetFilePtr ( hFile, 0L, FILE_END, &ulFileLength );
  280.     DosSetFilePtr ( hFile, 0L, FILE_BEGIN, &ulNumBytes );
  281.  
  282.                                         /* Allocate memory for bitmap file header
  283.     */
  284.     if ( DosAllocMem ( (PPVOID)&pImgHdr, sizeof(BITMAPFILEHEADER2),
  285.          (ULONG) PAG_COMMIT | PAG_READ | PAG_WRITE) )
  286.     {
  287.         DosClose( hFile );
  288.         return( 1 );
  289.     }
  290.  
  291.     /* Read from the beginning of the header to cbFix in BITMAPINFOHEADER
  292.     ** to know the length of the header.
  293.     */
  294.     if ( DosRead ( hFile, pImgHdr,
  295.          sizeof(BITMAPFILEHEADER2) - sizeof(BITMAPINFOHEADER2) +
  296.          sizeof(ULONG),
  297.          &ulNumBytes ))
  298.     {
  299.         DosFreeMem( (PVOID)pImgHdr );
  300.         DosClose( hFile );
  301.         return( 1 );
  302.     }
  303.  
  304.     /* Read the rest of the header.
  305.     */
  306.     if ( DosRead ( hFile, (PBYTE)pImgHdr + ulNumBytes,
  307.          pImgHdr->bmp2.cbFix - sizeof(ULONG),
  308.          &ulNumBytes ))
  309.     {
  310.         DosFreeMem( (PVOID)pImgHdr );
  311.         DosClose( hFile );
  312.         return( 1 );
  313.     }
  314.  
  315.     pwinData->ulnumColor = 1;
  316.  
  317.     /* Check the bitmap header format --  new or old one.
  318.     */
  319.     if ( pImgHdr->bmp2.cbFix != sizeof(BITMAPINFOHEADER) )
  320.     {
  321.         /*  Bitmap has new format (BITMAPFILEHEADER2)
  322.         */
  323.  
  324.         /* Check bitmap header to see if it can support.
  325.         */
  326.  
  327.         /* Set how many color bitmap data is supporting
  328.         */
  329.         pwinData->ulnumColor <<= pImgHdr->bmp2.cBitCount;
  330.  
  331.         /* Set bitmap width and height in pels.
  332.         */
  333.         pwinData->ulWidth  = pImgHdr->bmp2.cx;
  334.         pwinData->ulHeight = pImgHdr->bmp2.cy;
  335.  
  336.         /* Calculate source line size.  It should be double word boundary.
  337.         */
  338.         pwinData->ulSrcLineSizeBytes = ((( pImgHdr->bmp2.cx *
  339.                 ( pImgHdr->bmp2.cBitCount >> 3 )) + 3 ) / 4 ) * 4;
  340.  
  341.         /* Set bitmap coclor format.
  342.         */
  343.         switch ( pImgHdr->bmp2.cBitCount )
  344.         {
  345.         case 8:
  346.             pwinData->fccColorFormat = FOURCC_LUT8;
  347.             /* Alloate buffer for palette data in bitmap file.
  348.             */
  349.             if ( DosAllocMem ( (PPVOID) &(pPalette[iFile]),
  350.                  pwinData->ulnumColor * sizeof(ULONG),
  351.                  (ULONG) PAG_COMMIT | PAG_READ | PAG_WRITE) )
  352.             {
  353.                 DosFreeMem( (PVOID)pImgHdr );
  354.                 DosClose( hFile );
  355.                 return( 1 );
  356.             }
  357.  
  358.             /* Read palette data.
  359.             */
  360.             if ( DosRead ( hFile, pPalette[iFile],
  361.                  pwinData->ulnumColor * sizeof(ULONG),
  362.                  &ulNumBytes ))
  363.             {
  364.                 DosFreeMem( (PVOID)pImgHdr );
  365.                 DosFreeMem( (PVOID)(pPalette[iFile]) );
  366.                 DosClose( hFile );
  367.                 return( 1 );
  368.             }
  369.             break;
  370.         case 16:
  371.             pwinData->fccColorFormat = FOURCC_R565;
  372.             break;
  373.         case 24:
  374.             pwinData->fccColorFormat = FOURCC_BGR3;
  375.             break;
  376.         default:
  377.             DosFreeMem( (PVOID)pImgHdr );
  378.             DosClose( hFile );
  379.             return( 1 );
  380.         }                               /* endswitch */
  381.  
  382.     }
  383.     else
  384.     {
  385.         /*  Bitmap has old format (BITMAPFILEHEADER)
  386.         */
  387.  
  388.         /* Set how many color bitmap data is supporting
  389.         */
  390.         pwinData->ulnumColor <<= ((PBITMAPFILEHEADER)pImgHdr)->bmp.cBitCount;
  391.  
  392.         /* Set bitmap width and height in pels.
  393.         */
  394.         pwinData->ulWidth  = ((PBITMAPFILEHEADER)pImgHdr)->bmp.cx;
  395.         pwinData->ulHeight = ((PBITMAPFILEHEADER)pImgHdr)->bmp.cy;
  396.  
  397.         /* Calculate source line size.  It should be double word boundary.
  398.         */
  399.         pwinData->ulSrcLineSizeBytes = ((( ((PBITMAPFILEHEADER)pImgHdr)->bmp.cx *
  400.                 ( ((PBITMAPFILEHEADER)pImgHdr)->bmp.cBitCount >> 3 )) + 3 ) / 4 ) * 4;
  401.  
  402.         /* Set bitmap coclor format.
  403.         */
  404.         switch ( ((PBITMAPFILEHEADER)pImgHdr)->bmp.cBitCount )
  405.         {
  406.         case 8:
  407.             pwinData->fccColorFormat = FOURCC_LUT8;
  408.             /* Alloate buffer for temporally palette data in bitmap file
  409.             */
  410.             if ( DosAllocMem( (PPVOID) &pbBuffer,
  411.                  pwinData->ulnumColor * sizeof(RGB),
  412.                  (ULONG) PAG_COMMIT | PAG_READ | PAG_WRITE) )
  413.             {
  414.                 DosFreeMem( (PVOID)pImgHdr );
  415.                 DosClose( hFile );
  416.                 return( 1 );
  417.             }
  418.             if ( DosAllocMem ( (PPVOID) &(pPalette[iFile]),
  419.                  pwinData->ulnumColor * sizeof(ULONG),
  420.                  (ULONG) PAG_COMMIT | PAG_READ | PAG_WRITE) )
  421.             {
  422.                 DosFreeMem( (PVOID)pImgHdr );
  423.                 DosFreeMem( (PVOID)pbBuffer );
  424.                 DosClose( hFile );
  425.                 return( 1 );
  426.             }
  427.  
  428.             /* Read palette data
  429.             */
  430.             if ( DosRead ( hFile, pbBuffer,
  431.                  pwinData->ulnumColor * sizeof(RGB),
  432.                  &ulNumBytes ))
  433.             {
  434.                 DosFreeMem( (PVOID)pImgHdr );
  435.                 DosFreeMem( (PVOID)pbBuffer );
  436.                 DosFreeMem( (PVOID)pPalette[iFile] );
  437.                 DosClose( hFile );
  438.                 return( 1 );
  439.             }
  440.  
  441.             /* Make each color from 3 bytes to 4 bytes.
  442.             */
  443.             pbTmpDst = pPalette[iFile];
  444.             for ( i = 0; i < pwinData->ulnumColor; i++ )
  445.             {
  446.                 *pbTmpDst ++= *pbBuffer++;
  447.                 *pbTmpDst ++= *pbBuffer++;
  448.                 *pbTmpDst ++= *pbBuffer++;
  449.                 *pbTmpDst ++= 0;
  450.             }   /* endfor */
  451.  
  452.             DosFreeMem( (PVOID)pbBuffer );
  453.             break;
  454.         case 16:
  455.             pwinData->fccColorFormat = FOURCC_R565;
  456.             break;
  457.         case 24:
  458.             pwinData->fccColorFormat = FOURCC_BGR3;
  459.             break;
  460.         default:
  461.             {
  462.                 DosFreeMem( (PVOID)pImgHdr );
  463.                 DosClose( hFile );
  464.                 return( 1 );
  465.             }
  466.         } /* endswitch */
  467.  
  468.  
  469.     }
  470.     /* Allocate a buffer for image data
  471.     */
  472.  
  473.     if ( DiveAllocImageBuffer( pwinData->hDive,
  474.          &(ulImage[iFile]),
  475.          pwinData->fccColorFormat,
  476.          pwinData->ulWidth,
  477.          pwinData->ulHeight,
  478.          0, 0 ) )
  479.     {
  480.         if ( pwinData->fccColorFormat == FOURCC_LUT8 )
  481.             DosFreeMem(( PVOID)pPalette[iFile] );
  482.         DosClose( hFile );
  483.         return( 1 );
  484.     }
  485.     if ( DiveBeginImageBufferAccess( pwinData->hDive,
  486.          ulImage[iFile],
  487.          &pbBuffer,
  488.          &ulScanLineBytes,
  489.          &ulScanLines ))
  490.     {
  491.         DiveFreeImageBuffer( pwinData->hDive, ulImage[iFile] );
  492.         if ( pwinData->fccColorFormat == FOURCC_LUT8 )
  493.             DosFreeMem( (PVOID)pPalette[iFile] );
  494.         DosClose( hFile );
  495.         return( 1 );
  496.     }
  497.  
  498.     /* Read image data
  499.     */
  500.     if ( DosRead( hFile, pbBuffer,
  501.          pwinData->ulSrcLineSizeBytes * pwinData->ulHeight,
  502.          &ulNumBytes ) )
  503.     {
  504.         DiveEndImageBufferAccess( pwinData->hDive, ulImage[iFile] );
  505.         DiveFreeImageBuffer( pwinData->hDive, ulImage[iFile] );
  506.         if ( pwinData->fccColorFormat == FOURCC_LUT8 )
  507.         {
  508.             DosFreeMem( (PVOID)pPalette[iFile] );
  509.         }
  510.         DosClose( hFile );
  511.         return( 1 );
  512.     }
  513.  
  514.     /* Close the file and release the access to the image buffer
  515.     */
  516.     DosFreeMem( (PVOID)pImgHdr );
  517.     DosClose( hFile );
  518.  
  519.     DiveEndImageBufferAccess ( pwinData->hDive, ulImage[iFile] );
  520.  
  521.     return( 0 );
  522. }
  523.  
  524. /****************************************************************************
  525.  *
  526.  * Name          : Main
  527.  *
  528.  * Description   : This is main routine of this sample program.
  529.  *
  530.  * Concepts      :
  531.  *
  532.  * Parameters    : At command prompt, when the user start this EXE without
  533.  *                 any parameters, like
  534.  *                    FSDIVE
  535.  *                 it shows 16 default bitmaps which has a sequence.
  536.  *                 When the user specifies the names of bitmap file, like
  537.  *                    FSDIVE XXXXXX.BMP YYYYYY.BMP
  538.  *                 it shows the bitmaps specified at command line in turn.
  539.  *
  540.  * Return        : 1 - fail
  541.  *                 0 - suceed
  542.  *
  543.  ****************************************************************************/
  544.  
  545. main( int argc, char **argv )
  546. {
  547.     TID       tidBlitThread;            /* Thread ID for DirectMemMove          */
  548.     HMQ       hmq;                      /* Message queue handle                 */
  549.     QMSG      qmsg;                     /* Message from message queue           */
  550.     ULONG     flCreate;                 /* Window creation control flags        */
  551.     ULONG     i;                        /* Index for the files to open          */
  552.     PWINDATA  pwinData;                 /* Pointer to window data               */
  553.     PLONG     pPal;                     /* Pointer to system physical palette   */
  554.     LONG      cxWidthBorder;            /* Size of width of vertical border     */
  555.     LONG      cyWidthBorder;            /* Size of width of horizontal border   */
  556.     LONG      cyTitleBar;               /* Size of title bar                    */
  557.     LONG      cyMenu;                   /* Size of menu                         */
  558.     LONG      cxWindowPos;              /* X position of frame window           */
  559.     LONG      cyWindowPos;              /* Y position of frmae window           */
  560.  
  561.     UCHAR     szErrorBuf[256];          // GameSrvr
  562.     HMODULE   hmodGameSrvr;             // GameSrvr
  563.     PFN       pfnInitGameFrameProc;     // GameSrvr
  564.  
  565.     ULONG     aulVersion[2];            // OS/2 version number
  566.  
  567.  
  568. // Initialize the presentation manager, and create a message queue.
  569.  
  570.     hab = WinInitialize ( 0 );
  571.     hmq = WinCreateMsgQueue ( hab, 0 );
  572.  
  573. // Allocate a buffer for the window data
  574.  
  575.     pwinData = (PWINDATA) malloc (sizeof(WINDATA));
  576.  
  577.     /* Get the screen capabilities, and if the system support only 16 colors
  578.     ** the sample should be terminated.
  579.     */
  580.     DiveCaps.pFormatData = fccFormats;
  581.     DiveCaps.ulFormatLength = 120;
  582.     DiveCaps.ulStructLen = sizeof(DIVE_CAPS);
  583.  
  584.     if ( DiveQueryCaps ( &DiveCaps, DIVE_BUFFER_SCREEN ))
  585.     {
  586.         WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  587.                 (PSZ)"usage: The sample program can not run on this system environment.",
  588.                 (PSZ)"FSDIVE.EXE - DIVE Sample", 0, MB_OK | MB_INFORMATION );
  589.         free( pwinData );
  590.         WinDestroyMsgQueue( hmq );
  591.         WinTerminate( hab );
  592.         return( 1 );
  593.     }
  594.  
  595.     if ( DiveCaps.ulDepth < 8 )
  596.     {
  597.         WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  598.                 (PSZ)"usage: The sample program can not run on this system environment.",
  599.                 (PSZ)"FSDIVE.EXE - DIVE Sample", 0, MB_OK | MB_INFORMATION );
  600.         free( pwinData );
  601.         WinDestroyMsgQueue( hmq );
  602.         WinTerminate( hab );
  603.         return( 1 );
  604.     }
  605.  
  606.     /* Get an instance of DIVE APIs.
  607.     */
  608.     if ( DiveOpen( &(pwinData->hDive), FALSE, 0 ) )
  609.     {
  610.  
  611.         WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  612.                 (PSZ)"usage: The sample program can not run on this system environment.",
  613.                 (PSZ)"FSDIVE.EXE - DIVE Sample", 0, MB_OK | MB_INFORMATION );
  614.         free( pwinData );
  615.         WinDestroyMsgQueue( hmq );
  616.         WinTerminate( hab );
  617.         return( 1 );
  618.     }
  619.  
  620.     // Read bitmap files
  621.  
  622.     if ( argc == 1 )      // Default case
  623.     {      // Read BMP file
  624.         for ( i = 0, pwinData->ulMaxFiles = 0; i < MAX_FILE; i ++ )
  625.         {
  626.             if ( ReadFile ( i, pszDefFile[i], pwinData ))
  627.             {
  628.                 WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  629.                         (PSZ)"usage: FSDIVE failed to open bitmaps.",
  630.                         (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  631.  
  632.                 return( 1 );
  633.             }
  634.             else
  635.                 pwinData->ulMaxFiles ++;
  636.         }
  637.     }
  638.     else    // The case which the user specify bitmap file names
  639.     {
  640.         if (( argc > 1 ) && ( argc <= MAX_FILE + 1))
  641.         {
  642.             for ( i = 1; i < (ULONG)(argc); i++ )
  643.             {
  644.                 if ( ReadFile( i-1, (unsigned char *)argv[i], pwinData ) )
  645.                 {
  646.                     WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  647.                             (PSZ)"usage: FSDIVE failed to open bitmaps.",
  648.                             (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  649.                     free ( pwinData );
  650.                     WinDestroyMsgQueue( hmq );
  651.                     WinTerminate( hab );
  652.                     return( 1 );
  653.                 }
  654.             }
  655.             pwinData->ulMaxFiles = argc-1;
  656.         }
  657.         else
  658.         {
  659.             WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  660.                     (PSZ)"usage: FSDIVE failed to open bitmaps.",
  661.                     (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  662.             free( pwinData );
  663.             WinDestroyMsgQueue( hmq );
  664.             WinTerminate( hab );
  665.             return( 1 );
  666.         }
  667.     }
  668.  
  669. // Register a window class, and create a standard window.
  670.  
  671.     WinRegisterClass( hab, pszMyWindow, MyWindowProc, 0, sizeof(ULONG) );
  672.  
  673.     flCreate = FCF_TASKLIST | FCF_SYSMENU  | FCF_TITLEBAR | FCF_ICON |
  674.     FCF_SIZEBORDER | FCF_MINMAX | FCF_MENU | FCF_SHELLPOSITION;
  675.  
  676.     pwinData->hwndFrame = WinCreateStdWindow( HWND_DESKTOP,
  677.             WS_VISIBLE,
  678.             &flCreate,
  679.             pszMyWindow,
  680.             pszTitleText,
  681.             WS_SYNCPAINT | WS_VISIBLE,
  682.             0, ID_MAINWND,
  683.             &(pwinData->hwndClient));
  684.  
  685.     WinSetWindowULong( pwinData->hwndClient, 0, (ULONG)pwinData );
  686.  
  687.  
  688.     DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MINOR, aulVersion, 8 );
  689.  
  690.     if (aulVersion[0] == 20 && aulVersion[1] <= 30 )
  691.     {
  692.        fFSBase = FALSE;
  693.  
  694.        // GameSrvr ----------------------------------------------------begin---
  695.  
  696.        if ( 0 == DosLoadModule( szErrorBuf, 256, "GAMESRVR", &hmodGameSrvr ) )
  697.        {
  698.            if ( 0 == DosQueryProcAddr( hmodGameSrvr, 1, 0, &pfnInitGameFrameProc ) )
  699.            {
  700.                ( pfnInitGameFrameProc )( pwinData->hwndFrame, 0 );
  701.            }
  702.            {
  703.                ULONG pvmi;
  704.                ULONG ul;
  705.  
  706.                WinSendMsg( pwinData->hwndFrame, WM_GetVideoModeTable, (MPARAM)&pvmi, (MPARAM)&ul );
  707.            }
  708.        }
  709.        else
  710.        {
  711.            WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  712.                    (PSZ)"usage: FSDIVE failed to load GAMESRVR.DLL.",
  713.                    (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  714.        }
  715.  
  716.        // GameSrvr ----------------------------------------------------end-----
  717.     }
  718.     else
  719.     {
  720.        fFSBase = TRUE;
  721.        DosLoadModule( szErrorBuf, 256, "PMMERGE", &hmodGameSrvr );
  722.        if ( 0 == DosQueryProcAddr( hmodGameSrvr, 6099, 0, &pfnInitGameFrameProc ) )
  723.        {
  724.            ( pfnInitGameFrameProc )( pwinData->hwndFrame, 0 );
  725.        }
  726.        else
  727.        {
  728.            WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  729.                    (PSZ)"usage: FSDIVE failed to access FS functions.",
  730.                    (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  731.        }
  732.     }
  733.  
  734.  
  735.     cxWidthBorder = (LONG) WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER);
  736.     cyWidthBorder = (LONG) WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
  737.     cyTitleBar    = (LONG) WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
  738.     cyMenu        = (LONG) WinQuerySysValue(HWND_DESKTOP, SV_CYMENU);
  739.  
  740.     pwinData->cxWidthWindow  = pwinData->ulWidth + cxWidthBorder * 2;
  741.     pwinData->cyHeightWindow = pwinData->ulHeight + (cyWidthBorder * 2 +
  742.             cyTitleBar + cyMenu );
  743.  
  744.     cxWindowPos   = ( (LONG)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)
  745.             - pwinData->cxWidthWindow ) / 2;
  746.     cyWindowPos   = ( (LONG)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)
  747.             - pwinData->cyHeightWindow ) / 2;
  748.  
  749.  
  750.     /* Set the window position and size.
  751.     */
  752.     WinSetWindowPos (pwinData->hwndFrame,
  753.             HWND_TOP,
  754.             cxWindowPos, cyWindowPos,
  755.             pwinData->cxWidthWindow, pwinData->cyHeightWindow,
  756.             SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ACTIVATE);
  757.  
  758.  
  759.     /* Turn on visible region notification.
  760.     */
  761.     WinSetVisibleRegionNotify( pwinData->hwndClient, TRUE );
  762.  
  763.     /* set the flag for the first time simulation of palette of bitmap data
  764.     */
  765.     pwinData->fChgSrcPalette = FALSE;
  766.  
  767.     /* Send an invlaidation message to the client.
  768.     */
  769.     WinPostMsg( pwinData->hwndFrame, WM_VRNENABLED, 0L, 0L );
  770.  
  771.     /* Start up the blitting thread.
  772.     */
  773.     if ( DosCreateThread( &(pwinData->tidBlitThread),
  774.          (PFNTHREAD)DirectMoveMem,
  775.          (ULONG)pwinData, 0L, 8192L))
  776.     {
  777.         WinSetVisibleRegionNotify( pwinData->hwndClient, FALSE );
  778.  
  779.         for ( i = 0; i < pwinData->ulMaxFiles; i++ )
  780.         {
  781.             DiveFreeImageBuffer( pwinData->hDive, ulImage[i] );
  782.         }
  783.         DiveClose( pwinData->hDive );
  784.         WinDestroyWindow( pwinData->hwndFrame );
  785.         free( pwinData );
  786.         WinDestroyMsgQueue( hmq );
  787.         WinTerminate( hab );
  788.         return( 1 );
  789.     }
  790.  
  791. // Set the proiroty of the blitting thread
  792.  
  793.     DosSetPriority( PRTYS_THREAD, PRTYC_IDLETIME,
  794.             1, pwinData->tidBlitThread );
  795.  
  796. // While there are still messages, dispatch them.
  797.  
  798.     while ( WinGetMsg( hab, &qmsg, 0, 0, 0 ) )
  799.     {
  800.         WinDispatchMsg( hab, &qmsg );
  801.     }
  802.  
  803. // Set the variable to end the running thread, and wait for it to end.
  804.  
  805.     ulToEnd = 1;
  806.     DosWaitThread( &(pwinData->tidBlitThread), DCWW_WAIT );
  807.  
  808. // Turn off visible region notificationm tidy up, and terminate.
  809.  
  810.     WinSetVisibleRegionNotify( pwinData->hwndClient, FALSE );
  811.  
  812. // Free the buffers allocated by DIVE and close DIVE
  813.  
  814.     for  ( i = 0; i < pwinData->ulMaxFiles; i++ )
  815.     {
  816.         DiveFreeImageBuffer( pwinData->hDive, ulImage[i] );
  817.     }
  818.     DiveClose( pwinData->hDive );
  819.  
  820.     if ( pwinData->fccColorFormat == FOURCC_LUT8 )
  821.     {
  822.         for  ( i = 0; i < pwinData->ulMaxFiles; i++ )
  823.         {
  824.             DosFreeMem( pPalette[i] );
  825.         }
  826.     }
  827.  
  828. // Process termination
  829.  
  830.     WinDestroyWindow( pwinData->hwndFrame );
  831.     free( pwinData );
  832.     WinDestroyMsgQueue( hmq );
  833.     WinTerminate( hab );
  834.     return( 0 );
  835. }
  836.  
  837. /****************************************************************************
  838.  *
  839.  * Name          : MyWindowProc
  840.  *
  841.  * Description   : It is the window procedure of this program.
  842.  *
  843.  * Concepts      :
  844.  *
  845.  * Parameters    : Message parameter 1
  846.  *                 Message parameter 2
  847.  *
  848.  * Return        : calling WinDefWindowProc
  849.  *
  850.  ****************************************************************************/
  851.  
  852. MRESULT EXPENTRY MyWindowProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  853. {
  854.     POINTL    pointl;                   /* Point to offset from Desktop    */
  855.     SWP       swp;                      /* Window position                 */
  856.     HRGN      hrgn;                     /* Region handle                   */
  857.     HPS       hps;                      /* Presentation Space handle       */
  858.     RECTL     rcls[50];                 /* Rectangle coordinates           */
  859.     RGNRECT   rgnCtl;                   /* Processing control structure    */
  860.     PWINDATA  pwinData;                 /* Pointer to window data          */
  861.     SETUP_BLITTER SetupBlitter;         /* structure for DiveSetupBlitter  */
  862.     PLONG     pPal;
  863.     HWND      hwndDialog;
  864.  
  865.     PQMSG     pqmsg;
  866.  
  867.     // Get the pointer to window data
  868.     //
  869.     pwinData = (PWINDATA)WinQueryWindowULong (hwnd, 0);
  870.     if( pwinData  )
  871.     {
  872.         switch( msg )
  873.         {
  874.         case WM_TRANSLATEACCEL: // mp1 is pointer to QMSG with WM_CHAR
  875.  
  876.             if ( fFSBase )
  877.             {
  878.                pqmsg = (PQMSG)mp1;
  879.  
  880.                // Alt-Home to toggle between Full Screen DIVE and desk top
  881.  
  882.                if ( SHORT2FROMMP( pqmsg->mp2 ) == VK_HOME // Alt-Home key
  883.                     && ( SHORT1FROMMP( pqmsg->mp1 )
  884.                     & ( KC_ALT | KC_VIRTUALKEY | KC_KEYUP ) )
  885.                     == ( KC_ALT | KC_VIRTUALKEY ) )
  886.                {
  887.                    if ( ulWindowStyle == WS_DesktopDive )
  888.                    {
  889.                        WinSendMsg( pwinData->hwndFrame, WM_SetVideoMode, (MPARAM)WS_FullScreenDive, 0 );
  890.                        ulWindowStyle = WS_FullScreenDive;
  891.                    }
  892.                    else
  893.                    {
  894.                        WinSendMsg( pwinData->hwndFrame, WM_SetVideoMode, (MPARAM)WS_DesktopDive, 0 );
  895.                        ulWindowStyle = WS_DesktopDive;
  896.                    }
  897.                }
  898.                else
  899.                   return WinDefWindowProc ( hwnd, msg, mp1, mp2 );
  900.             }
  901.             else
  902.                return WinDefWindowProc ( hwnd, msg, mp1, mp2 );
  903.  
  904.             break;
  905.  
  906.         case WM_COMMAND:
  907.             switch ( SHORT1FROMMP ( mp1 ) )
  908.             {
  909.             case ID_SNAP:
  910.                 {
  911.                     /* Use the initial width and height of the window such that
  912.                     ** the actual video area equals the source width and height.
  913.                     */
  914.  
  915.                     /* Set the new size of the window, but don't move it.
  916.                     */
  917.                     WinSetWindowPos ( pwinData->hwndFrame, HWND_TOP,
  918.                             100, 100,
  919.                             pwinData->cxWidthWindow,
  920.                             pwinData->cyHeightWindow,
  921.                             SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
  922.                 }
  923.                 break;
  924.  
  925.             case ID_QUERY:
  926.  
  927.                 // Get the screen capabilities
  928.                 // to display in the dialog box.
  929.  
  930.                 DiveCaps.pFormatData = fccFormats;
  931.                 DiveCaps.ulFormatLength = 120;
  932.                 DiveCaps.ulStructLen = sizeof(DIVE_CAPS);
  933.  
  934.                 if ( DiveQueryCaps ( &DiveCaps, DIVE_BUFFER_SCREEN ))
  935.                 {
  936.                     WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  937.                             (PSZ)"usage: FSDIVE failed to get screen capabilities.",
  938.                             (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  939.                     break;
  940.                 }
  941.  
  942.                 WinDlgBox ( HWND_DESKTOP, pwinData->hwndClient,
  943.                         MyDlgProc, (HMODULE)0,
  944.                         ID_DIALOG, (PVOID)pwinData );
  945.  
  946.                 break;
  947.  
  948.             case ID_FULLSCR:            // GameSrvr
  949.  
  950.                 WinSendMsg( pwinData->hwndFrame, WM_SetVideoMode, (MPARAM)WS_FullScreenDive, 0 ); // GameSrvr
  951.                 if ( fFSBase )
  952.                    ulWindowStyle = WS_FullScreenDive;
  953.                 break;                  // GameSrvr
  954.  
  955.             case ID_EXIT:               // Post to quit the dispatch message loop.
  956.  
  957.                 WinSendMsg( pwinData->hwndFrame, WM_SetVideoMode, (MPARAM)WS_DesktopDive, 0 ); // GameSrvr
  958.                 WinPostMsg ( hwnd, WM_QUIT, 0L, 0L );
  959.                 break;
  960.  
  961.             case ID_NEWTEXT:
  962.                 /* Write new text string to the title bar
  963.                 */
  964.                 WinSetWindowText ( pwinData->hwndFrame, (PSZ)mp2 );
  965.                 break;
  966.  
  967.             default:
  968.                 /* Let PM handle this message.
  969.                 */
  970.                 return WinDefWindowProc ( hwnd, msg, mp1, mp2 );
  971.             }
  972.             break;
  973.  
  974.         case WM_VRNDISABLED:
  975.  
  976.             DiveSetupBlitter ( pwinData->hDive, 0 );
  977.             break;
  978.  
  979.         case WM_VRNENABLED:
  980.  
  981.             hps = WinGetPS ( hwnd );
  982.  
  983.             if ( !hps )
  984.                 break;
  985.  
  986.             hrgn = GpiCreateRegion ( hps, 0L, NULL );
  987.  
  988.             if ( hrgn )
  989.             {
  990.             //      NOTE: If mp1 is zero, then this was just a move message.
  991.             //      Illustrate the visible region on a WM_VRNENABLE.
  992.  
  993.                 WinQueryVisibleRegion ( hwnd, hrgn );
  994.                 rgnCtl.ircStart     = 0;
  995.                 rgnCtl.crc          = 50;
  996.                 rgnCtl.ulDirection  = 1;
  997.  
  998.                 // Get the all ORed rectangles
  999.  
  1000.                 if ( GpiQueryRegionRects ( hps, hrgn, NULL, &rgnCtl, rcls) )
  1001.                 {
  1002.  
  1003.                 // Now find the window position and size, relative to parent.
  1004.  
  1005.                     WinQueryWindowPos ( pwinData->hwndClient, &swp );
  1006.  
  1007.                 // Convert the point to offset from desktop lower left.
  1008.  
  1009.                     pointl.x = swp.x;
  1010.                     pointl.y = swp.y;
  1011.  
  1012.                     WinMapWindowPoints ( pwinData->hwndFrame,
  1013.                             HWND_DESKTOP, &pointl, 1 );
  1014.  
  1015.                 // Tell DIVE about the new settings.
  1016.  
  1017.                     SetupBlitter.ulStructLen       = sizeof( SETUP_BLITTER );
  1018.                     SetupBlitter.fccSrcColorFormat = pwinData->fccColorFormat;
  1019.                     SetupBlitter.ulSrcWidth        = pwinData->ulWidth;
  1020.                     SetupBlitter.ulSrcHeight       = pwinData->ulHeight;
  1021.                     SetupBlitter.ulSrcPosX         = 0;
  1022.                     SetupBlitter.ulSrcPosY         = 0;
  1023.                     SetupBlitter.fInvert           = TRUE;
  1024.                     SetupBlitter.ulDitherType      = 1;
  1025.  
  1026.                     SetupBlitter.fccDstColorFormat = FOURCC_SCRN;
  1027.                     SetupBlitter.ulDstWidth        = swp.cx;
  1028.                     SetupBlitter.ulDstHeight       = swp.cy;
  1029.                     SetupBlitter.lDstPosX          = 0;
  1030.                     SetupBlitter.lDstPosY          = 0;
  1031.                     SetupBlitter.lScreenPosX       = pointl.x;
  1032.                     SetupBlitter.lScreenPosY       = pointl.y;
  1033.                     SetupBlitter.ulNumDstRects     = rgnCtl.crcReturned;
  1034.                     SetupBlitter.pVisDstRects      = rcls;
  1035.  
  1036.                     DiveSetupBlitter ( pwinData->hDive, &SetupBlitter );
  1037.  
  1038.                     ulFramesToTime = 4;
  1039.                     ulNumFrames    = 1;
  1040.                 }
  1041.                 else
  1042.                 {
  1043.                     DiveSetupBlitter ( pwinData->hDive, 0 );
  1044.                 }
  1045.  
  1046.                 GpiDestroyRegion( hps, hrgn );
  1047.             }
  1048.             WinReleasePS( hps );
  1049.             break;
  1050.  
  1051.         case WM_REALIZEPALETTE:
  1052.             /* This tells DIVE that the physical palette may have changed.
  1053.             */
  1054.             DiveSetDestinationPalette ( pwinData->hDive, 0, 0, 0 );
  1055.  
  1056.             break;
  1057.  
  1058.         case WM_CLOSE:
  1059.              // Post to quit the dispatch message loop.
  1060.  
  1061.             WinPostMsg ( hwnd, WM_QUIT, 0L, 0L );
  1062.             break;
  1063.  
  1064.         default:  // Let PM handle this message.
  1065.  
  1066.             return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  1067.         }
  1068.     }
  1069.     else
  1070.     {                                   // Let PM handle this message.
  1071.         return WinDefWindowProc ( hwnd, msg, mp1, mp2 );
  1072.     }
  1073.  
  1074.     return( FALSE );
  1075. }
  1076.  
  1077. /****************************************************************************
  1078.  *
  1079.  * Name          : MyDlgProc
  1080.  *
  1081.  * Description   : It is the dialog procedure of this program.
  1082.  *
  1083.  * Concepts      :
  1084.  *
  1085.  * Parameters    : Message parameter 1
  1086.  *                 Message parameter 2
  1087.  *
  1088.  * Return        : calling WinDefDlgProc
  1089.  *
  1090.  ****************************************************************************/
  1091.  
  1092. MRESULT EXPENTRY MyDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  1093. {
  1094.     CHAR      string[10];
  1095.     CHAR      *pString;
  1096.  
  1097.     switch( msg )
  1098.     {
  1099.     case WM_INITDLG:
  1100.  
  1101.         if ( !DiveCaps.fScreenDirect )
  1102.             WinSetDlgItemText( hwndDlg, ID_EF_11, "NO" );
  1103.         else
  1104.             WinSetDlgItemText( hwndDlg, ID_EF_11, "YES" );
  1105.  
  1106.         if ( !DiveCaps.fBankSwitched )
  1107.             WinSetDlgItemText( hwndDlg, ID_EF_12, "NO" );
  1108.         else
  1109.             WinSetDlgItemText( hwndDlg, ID_EF_12, "YES" );
  1110.  
  1111.         pString = _ultoa ( DiveCaps.ulDepth, string, 10 );
  1112.         WinSetDlgItemText( hwndDlg, ID_EF_13, pString );
  1113.  
  1114.         pString = _ultoa ( DiveCaps.ulHorizontalResolution,
  1115.                 string, 10 );
  1116.         WinSetDlgItemText( hwndDlg, ID_EF_14, pString );
  1117.  
  1118.         pString = _ultoa ( DiveCaps.ulVerticalResolution, string, 10 );
  1119.         WinSetDlgItemText( hwndDlg, ID_EF_15, pString );
  1120.  
  1121.         pString = _ultoa ( DiveCaps.ulScanLineBytes, string, 10 );
  1122.         WinSetDlgItemText( hwndDlg, ID_EF_16, pString );
  1123.  
  1124.         switch (DiveCaps.fccColorEncoding)
  1125.         {
  1126.         case FOURCC_LUT8:
  1127.             WinSetDlgItemText( hwndDlg, ID_EF_17, "256" );
  1128.             break;
  1129.         case FOURCC_R565:
  1130.             WinSetDlgItemText( hwndDlg, ID_EF_17, "64K" );
  1131.             break;
  1132.         case FOURCC_R555:
  1133.             WinSetDlgItemText( hwndDlg, ID_EF_17, "32K" );
  1134.             break;
  1135.         case FOURCC_R664:
  1136.             WinSetDlgItemText( hwndDlg, ID_EF_17, "64K" );
  1137.             break;
  1138.         case FOURCC_RGB3:
  1139.             WinSetDlgItemText( hwndDlg, ID_EF_17, "16M" );
  1140.             break;
  1141.         case FOURCC_BGR3:
  1142.             WinSetDlgItemText( hwndDlg, ID_EF_17, "16M" );
  1143.             break;
  1144.         case FOURCC_RGB4:
  1145.             WinSetDlgItemText( hwndDlg, ID_EF_17, "16M" );
  1146.             break;
  1147.         case FOURCC_BGR4:
  1148.             WinSetDlgItemText( hwndDlg, ID_EF_17, "16M" );
  1149.             break;
  1150.         default:
  1151.             WinSetDlgItemText( hwndDlg, ID_EF_17, "???" );
  1152.         }                               /* endswitch */
  1153.  
  1154.         pString = _ultoa ( DiveCaps.ulApertureSize, string, 10 );
  1155.         WinSetDlgItemText( hwndDlg, ID_EF_18, pString );
  1156.  
  1157.         pString = _ultoa ( DiveCaps.ulInputFormats, string, 10 );
  1158.         WinSetDlgItemText( hwndDlg, ID_EF_19, pString );
  1159.  
  1160.         pString = _ultoa ( DiveCaps.ulOutputFormats, string, 10 );
  1161.         WinSetDlgItemText( hwndDlg, ID_EF_20, pString );
  1162.  
  1163.         break;
  1164.  
  1165.     case WM_COMMAND:
  1166.         switch ( SHORT1FROMMP ( mp1 ) )
  1167.         {
  1168.         case DID_OK:
  1169.  
  1170.             WinDismissDlg( hwndDlg, TRUE );
  1171.             break;
  1172.         }
  1173.  
  1174.     default:
  1175.         return( WinDefDlgProc (hwndDlg, msg, mp1, mp2) );
  1176.  
  1177.     }
  1178.  
  1179.    return( FALSE );
  1180. }
  1181.