home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / divempeg.zip / DIMPSRC.ZIP / DIMP.C < prev    next >
Text File  |  1995-07-10  |  63KB  |  2,115 lines

  1. /* DIMP version 0.9, a multithreaded MPEG-player for OS/2 Warp 3.0 using DIVE
  2.  * written by:
  3.  *
  4.  * Peter Van Geit
  5.  * vg@iris.elis.rug.ac.be
  6.  *
  7.  * See the accompanying readme.txt file for more information
  8.  */
  9.  
  10. #define INCL_DOS
  11. #define INCL_GPI
  12. #define INCL_WIN
  13. #include <os2.h>
  14. #include <sys/types.h>
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #define  _MEERROR_H_
  19. #include <mmioos2.h>
  20. #include <dive.h>
  21. #include <fourcc.h>
  22.  
  23. #include "dimp.h"
  24. #include "pvgdith.h"
  25. #include "pvgvideo.h"
  26.  
  27. #define WM_USER_POSITION    WM_USER + 1
  28. #define WM_SHOWSTAT         WM_USER + 2
  29. #define WM_SHOWALL          WM_USER + 3
  30. #define WM_NEWTEXT          WM_USER + 4
  31. #define WM_NOSHOW           WM_USER + 5
  32. #define WM_DOSHOW           WM_USER + 6
  33. #define WM_NOLOOP           WM_USER + 7
  34. #define WM_DOLOOP           WM_USER + 8
  35.  
  36. /* needed for drawing about dialog box */
  37. #define DB_RAISED       0x0400
  38. #define DB_DEPRESSED    0x0800
  39.  
  40. /* Define buffer length. */
  41.  
  42. #define BUF_LENGTH 80000
  43.  
  44. /* Function return type declarations */
  45. void usage();
  46.  
  47. /* PVG */
  48. static int ditherType;
  49. static int oldDitherType;
  50. static int lum_range, cr_range, cb_range;
  51. static VidStream *theVidStream;
  52. static char fileName[80];
  53. static FILE *fin;
  54. static int h_size, v_size;
  55. static unsigned char * frame;
  56. static char * ditherFlags; /* used when ditherType == MBORDERED_DITHER */
  57. static int nob=0, nop=0;
  58.  
  59. static int condition = ID_NONE;
  60.  
  61. /* Loop flag. */
  62. static int loop = 0;
  63.  
  64. /* Quiet flag. */
  65. static int quiet = 0;
  66.  
  67. /* Display image on screen ? */
  68. static int noDisplay = 0;
  69.  
  70. DIVE_CAPS DiveCaps = {0};
  71. FOURCC    fccFormats[100] = {0};
  72.  
  73. MRESULT EXPENTRY MyWindowProc ( HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  74. MRESULT EXPENTRY ToolBarDlgProc (HWND,ULONG,MPARAM,MPARAM);
  75. MRESULT EXPENTRY DiveDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 );
  76. MRESULT EXPENTRY MpegDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 );
  77. MRESULT EXPENTRY UsageDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 );
  78. MRESULT EXPENTRY AboutDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  79.  
  80. #ifdef ANALYSIS
  81.  
  82. MRESULT EXPENTRY OneStatDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 );
  83. MRESULT EXPENTRY AllStatDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 );
  84.  
  85. static void ShowOneStat();
  86. static void ShowAllStats();
  87.  
  88. #endif
  89.  
  90.  
  91. /* Global definitions */
  92.  
  93. HAB   hab;                             /* PM anchor block handle            */
  94. ULONG ulImage;                         /* Image buffer numbers from Dive    */
  95. PBYTE pPalette=NULL, pPal2=NULL;       /* Pointer to bitmap palette area    */
  96. PSZ   pszMyWindow = "MyWindow";        /* Window class name                 */
  97. CHAR   pszTitleText [64];              /* Title bar text                    */
  98. ULONG ulToEnd = 0;                     /*                                   */
  99. PWINDATA  pwinData;                    /* Pointer to window data            */
  100.  
  101. /* Needed for DIVE-calls */
  102.  
  103.    ULONG ulNumBytes;            /* output for number of bytes actually read */
  104.    PBYTE pbBuffer;              /* pointer to the image/ temp. palette data */
  105.    ULONG ulScanLineBytes;       /* output for number of bytes a scan line   */
  106.    ULONG ulScanLines;           /* output for height of the buffer          */
  107.    PBYTE pbTmp1, pbTmp2;
  108.  
  109. /******************* usage() *****************/
  110. void usage(s)
  111. char *s;        /* program name */
  112. {
  113.    WinDlgBox ( HWND_DESKTOP, pwinData->hwndClient,
  114.           UsageDlgProc, (HMODULE)0,
  115.           IDD_USAGE, (PVOID)pwinData );
  116.  
  117. }
  118.  
  119. /********************************************/
  120.  
  121.  
  122. VOID APIENTRY Decode ( ULONG parm1 )
  123.    {
  124.    ULONG    ulTime0, ulTime1;     /* output buffer for DosQierySysInfo      */
  125.    ULONG    ulFramesToTime=8;     /* Interval of frames to get time         */
  126.    ULONG    ulNumFrames=0;        /* Frame counter                          */
  127.    CHAR     achFrameRate[32];     /* string buffer for WinSetWindowText     */
  128.    int      status;
  129.  
  130.    PWINDATA pwinData;             /* pointer to window data                 */
  131.  
  132.  
  133.    pwinData =(PWINDATA)parm1;
  134.  
  135.    do
  136.       {
  137.      do {
  138.       /* Check if it's time to start the blit-time counter. */
  139.  
  140.       if ( !ulNumFrames )
  141.      DosQuerySysInfo ( QSV_MS_COUNT, QSV_MS_COUNT, &ulTime0, 4L );
  142.  
  143.       /* PVG: decode next frame & transfer to DIVE-allocated buffer */
  144.       status = mpegVidRsrc(0, theVidStream, &ditherFlags); /* decode next picture */
  145.       
  146.       switch (status) {
  147.       case MPEG_MB_QUANTUM: break;
  148.       case MPEG_SLICE: break;
  149.       case MPEG_FRAME_SKIP: break;
  150.       case MPEG_FRAME_DISP:
  151.     ulNumFrames++;
  152.       if (ditherType != NO_DITHER) {
  153.     DiveBeginImageBufferAccess(pwinData->hDive, ulImage,
  154.           &pbBuffer, &ulScanLineBytes, &ulScanLines);
  155.     DoDitherImage(theVidStream->current->luminance, theVidStream->current->Cr,
  156.               theVidStream->current->Cb, (unsigned char*) pbBuffer,
  157.               theVidStream->mb_height*16, theVidStream->mb_width*16, ditherFlags);
  158.     DiveEndImageBufferAccess(pwinData->hDive, ulImage);
  159.  
  160.     if (!noDisplay) {
  161.       DiveBlitImage ( pwinData->hDive,  ulImage, DIVE_BUFFER_SCREEN );
  162.     }
  163.       }
  164.     break;
  165.       case MPEG_FRAME_NODISP: break;
  166.       case MPEG_ERROR: break;
  167.       case MPEG_DONE_DISP:
  168.     ulNumFrames++;
  169.       if (ditherType != NO_DITHER) {
  170.     DiveBeginImageBufferAccess(pwinData->hDive, ulImage,
  171.           &pbBuffer, &ulScanLineBytes, &ulScanLines);
  172.     DoDitherImage(theVidStream->current->luminance, theVidStream->current->Cr,
  173.               theVidStream->current->Cb, (unsigned char*) pbBuffer,
  174.               theVidStream->mb_height * 16, theVidStream->mb_width * 16, ditherFlags);
  175.     DiveEndImageBufferAccess(pwinData->hDive, ulImage);
  176.  
  177.     if (!noDisplay) {
  178.       DiveBlitImage ( pwinData->hDive,  ulImage, DIVE_BUFFER_SCREEN );
  179.     }
  180.       }
  181.     /* no break */
  182.       case MPEG_DONE_NODISP:
  183.       DestroyVidStream(theVidStream);
  184.       if (!loop) {
  185.         condition = ID_END;
  186.         return; /* this was the last frame */
  187.       }
  188.       else { /* if looping */
  189.         ResetVidStream();
  190.         theVidStream = NewVidStream(fileName, BUF_LENGTH, loop, quiet, noDisplay,
  191.                   ditherType);
  192.         mpegVidRsrc(0, theVidStream, &ditherFlags);
  193.       }
  194.  
  195.     break;
  196.  
  197.       } /* switch */
  198.  
  199.       /* Check to see if we have enough frames for a fairly accurate read. */
  200.  
  201.       if ( ulNumFrames>=ulFramesToTime )
  202.      {
  203.      DosQuerySysInfo ( QSV_MS_COUNT, QSV_MS_COUNT, &ulTime1, 4L );
  204.      ulTime1 -= ulTime0;
  205.      if ( ulTime1 )
  206.         sprintf ( achFrameRate, "%5.2f frames per second.",
  207.             (float)ulFramesToTime * 1000.0 / (float)ulTime1 );
  208.      else
  209.         sprintf ( achFrameRate, "Lots of frames per second.");
  210.      WinPostMsg ( pwinData->hwndFrame, WM_NEWTEXT,
  211.             achFrameRate, 0L);
  212.      ulNumFrames = 0;
  213.  
  214.      /* Adjust number of frames to time based on last set. */
  215.  
  216.      if ( ulTime1 < 250 )
  217.         ulFramesToTime <<= 1;
  218.      if ( ulTime1 > 3000 )
  219.         ulFramesToTime >>= 1;
  220.      }
  221.  
  222.       /* Let other threads and processes have some time. */
  223.  
  224.       DosSleep ( 0 );
  225.      }
  226.      while((status != MPEG_FRAME_DISP) && (status != MPEG_DONE_DISP)
  227.         && (status != MPEG_DONE_NODISP) );
  228.     }
  229.     while ( (!ulToEnd)  );
  230.  
  231.    return;
  232.    }
  233.  
  234.  
  235. main ( int argc, char *argv[] )
  236.    {
  237.    TID       tidBlitThread;        /* Thread ID for DirectMemMove          */
  238.    HMQ       hmq;                  /* Message queue handle                 */
  239.    QMSG      qmsg;                 /* Message from message queue           */
  240.    ULONG     flCreate;             /* Window creation control flags        */
  241.    PLONG     pPal;
  242.  
  243.  
  244.   char *name;
  245.   int mark;
  246.   int i;
  247.  
  248. #ifdef ANALYSIS
  249. int showEachFlg = 1; /* default statistics each decoded frame */
  250. #endif
  251.  
  252.   mark = 1;
  253.   argc--;
  254.  
  255.   /* default values */
  256.   name = "";
  257.   ditherType = ORDERED2_DITHER;
  258.   lum_range = 8;
  259.   cr_range = cb_range = 4;
  260.   noDisplay = 0;
  261.  
  262.  
  263.    /* Initialize the presentation manager, and create a message queue. */
  264.    hab = WinInitialize ( 0 );
  265.    hmq = WinCreateMsgQueue ( hab, 0 );
  266.  
  267.    /* Allocate a buffer for the window data */
  268.    pwinData = (PWINDATA) malloc (sizeof(WINDATA));
  269.  
  270.  
  271.     if (argc < 1) {
  272.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  273.       (PSZ)"usage: must specify a MPEG file",
  274.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  275.  
  276.     usage(argv[0]);
  277.  
  278.    /* free allocated structures */
  279.     free ( pwinData );
  280.     WinDestroyMsgQueue ( hmq );
  281.     WinTerminate ( hab );
  282.     exit(-1);
  283.  
  284.       }
  285.  
  286.   while (argc) {
  287.     if (strcmp(argv[mark], "-nop") == 0) {
  288.       TogglePFlag();
  289.       nop = 1;
  290.       argc--; mark++;
  291.     } else if (strcmp(argv[mark], "-nob") == 0) {
  292.       ToggleBFlag();
  293.       nob = 1;
  294.       argc--; mark++;
  295.     } else if (strcmp(argv[mark], "-display") == 0) {
  296.       name = argv[++mark];
  297.       argc -= 2; mark++;
  298.     } else if (strcmp(argv[mark], "-dither") == 0) {
  299.       argc--; mark++;
  300.  
  301.     if (argc < 1) {
  302.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  303.       (PSZ)"usage: must specify dither option after -dither flag.",
  304.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  305.  
  306.     usage(argv[0]);
  307.  
  308.    /* free allocated structures */
  309.     free ( pwinData );
  310.     WinDestroyMsgQueue ( hmq );
  311.     WinTerminate ( hab );
  312.     exit(-1);
  313.  
  314.       }
  315.       if (strcmp(argv[mark], "hybrid") == 0) {
  316.     argc--; mark++;
  317.     ditherType = HYBRID_DITHER;
  318.       } else if (strcmp(argv[mark], "hybrid2") == 0) {
  319.     argc--; mark++;
  320.     ditherType = HYBRID2_DITHER;
  321.       } else if (strcmp(argv[mark], "fs4") == 0) {
  322.     argc--; mark++;
  323.     ditherType = FS4_DITHER;
  324.       } else if (strcmp(argv[mark], "fs2") == 0) {
  325.     argc--; mark++;
  326.     ditherType = FS2_DITHER;
  327.       } else if (strcmp(argv[mark], "fs2fast") == 0) {
  328.     argc--; mark++;
  329.     ditherType = FS2FAST_DITHER;
  330.       } else if (strcmp(argv[mark], "hybrid2") == 0) {
  331.     argc--; mark++;
  332.     ditherType = HYBRID2_DITHER;
  333.       /* }  else if (strcmp(argv[mark], "2x2") == 0) {
  334.     argc--; mark++;
  335.     ditherType = Twox2_DITHER; */
  336.     /* PVG: not implemented */
  337.  
  338.       } else if (strcmp(argv[mark], "gray") == 0) {
  339.     argc--; mark++;
  340.     ditherType = GRAY_DITHER;
  341.      /* } else if (strcmp(argv[mark], "color") == 0) {
  342.     argc--; mark++;
  343.     ditherType = FULL_COLOR_DITHER; */
  344.     /* PVG: not implemented */
  345.  
  346.       } else if (strcmp(argv[mark], "none") == 0) {
  347.     argc--; mark++;
  348.     ditherType = NO_DITHER;
  349.     noDisplay = 1;
  350.       } else if (strcmp(argv[mark], "ordered") == 0) {
  351.     argc--; mark++;
  352.     ditherType = ORDERED_DITHER;
  353.       } else if (strcmp(argv[mark], "ordered2") == 0) {
  354.     argc--; mark++;
  355.     ditherType = ORDERED2_DITHER;
  356.       } else if (strcmp(argv[mark], "mbordered") == 0) {
  357.     argc--; mark++;
  358.     ditherType = MBORDERED_DITHER;
  359.     /*  } else if (strcmp(argv[mark], "mono") == 0) {
  360.     argc--; mark++;
  361.     ditherType = MONO_DITHER; **/
  362.     /* PVG: not implemented */
  363.  
  364.     /*  } else if (strcmp(argv[mark], "threshold") == 0) {
  365.     argc--; mark++;
  366.     ditherType = MONO_THRESHOLD; */
  367.     /* PVG: not implemented */
  368.  
  369.       } else {
  370.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  371.       (PSZ)"usage: illegal dither option.",
  372.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  373.     usage(argv[0]);
  374.  
  375.  
  376.    /* free allocated structures */
  377.     free ( pwinData );
  378.     WinDestroyMsgQueue ( hmq );
  379.     WinTerminate ( hab );
  380.     exit(-1);
  381.  
  382.       }
  383.     } 
  384.     else if (strcmp(argv[mark], "-no_eachstat") == 0) {
  385.       argc--; mark++;
  386.  
  387. #ifdef ANALYSIS
  388.       showEachFlg = 0;
  389. #else
  390.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  391.       (PSZ)"usage: to use -eachstat, recompile with -DANALYSIS in CFLAGS.",
  392.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  393.  
  394.    /* free allocated structures */
  395.       free ( pwinData );
  396.       WinDestroyMsgQueue ( hmq );
  397.       WinTerminate ( hab );
  398.  
  399.    /* Terminate program */
  400.       exit(1);
  401. #endif
  402. /*    }
  403.     else if (strcmp(argv[mark], "-quiet") == 0) {
  404.       argc--; mark++;
  405.       quiet = 1; */
  406.   /* PVG: not implemented */
  407.  
  408.  
  409.     }
  410.     else if (strcmp(argv[mark], "-loop") == 0) {
  411.       argc--; mark++;
  412.       loop = 1;
  413.     }
  414.     else if (strcmp(argv[mark], "-no_display") == 0) {
  415.       argc--; mark++;
  416.       noDisplay = 1;
  417.     }
  418.     else if (strcmp(argv[mark], "-l_range") == 0) {
  419.       argc--; mark++;
  420.       lum_range = atoi(argv[mark]);
  421.       if (lum_range < 1) {
  422.  
  423.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  424.       (PSZ)"usage: illegal luminance range value.",
  425.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  426.  
  427.    /* free allocated structures */
  428.       free ( pwinData );
  429.       WinDestroyMsgQueue ( hmq );
  430.       WinTerminate ( hab );
  431.  
  432.     exit(1);
  433.       }
  434.       argc--; mark++;
  435.     }
  436.     else if (strcmp(argv[mark], "-cr_range") == 0) {
  437.       argc--; mark++;
  438.       cr_range = atoi(argv[mark]);
  439.       if (cr_range < 1) {
  440.  
  441.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  442.       (PSZ)"usage: illegal cr range value.",
  443.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  444.  
  445.    /* free allocated structures */
  446.       free ( pwinData );
  447.       WinDestroyMsgQueue ( hmq );
  448.       WinTerminate ( hab );
  449.  
  450.       exit(1);
  451.       }
  452.       argc--; mark++;
  453.     }
  454.     else if (strcmp(argv[mark], "-cb_range") == 0) {
  455.       argc--; mark++;
  456.       cb_range = atoi(argv[mark]);
  457.       if (cb_range < 1) {
  458.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  459.       (PSZ)"usage: illegal cb range value.",
  460.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  461.  
  462.    /* free allocated structures */
  463.       free ( pwinData );
  464.       WinDestroyMsgQueue ( hmq );
  465.       WinTerminate ( hab );
  466.  
  467.       exit(1);
  468.       }
  469.       argc--; mark++;
  470.     }
  471.     else if (argv[mark][0] == '-') {
  472.  
  473.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  474.       (PSZ)"usage: un-recognized flag.",
  475.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  476.       usage(argv[0]);
  477.  
  478.    /* free allocated structures */
  479.     free ( pwinData );
  480.     WinDestroyMsgQueue ( hmq );
  481.     WinTerminate ( hab );
  482.     exit(-1);
  483.     }
  484.     else {
  485.       strcpy(fileName, argv[mark]);
  486.       fin = fopen(fileName, "rb");
  487.  
  488.       if (fin == NULL) {
  489.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  490.       (PSZ)"usage: could not open file.",
  491.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  492.     usage(argv[0]);
  493.  
  494.    /* free allocated structures */
  495.     free ( pwinData );
  496.     WinDestroyMsgQueue ( hmq );
  497.     WinTerminate ( hab );
  498.     exit(-1);
  499.  
  500.       }
  501.       argc--; mark++;
  502.       fclose(fin);
  503.     }
  504.   }
  505. /****************** Real start of the main program ***********************/
  506.  
  507. /* Get the screen capabilities, and if the system support only 16 colors
  508.    the sample should be terminated. */
  509.  
  510.    DiveCaps.pFormatData = fccFormats;
  511.    DiveCaps.ulFormatLength = 120;
  512.    DiveCaps.ulStructLen = sizeof(DIVE_CAPS);
  513.  
  514.    if ( DiveQueryCaps ( &DiveCaps, DIVE_BUFFER_SCREEN ))
  515.       {
  516.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  517.       (PSZ)"usage: This program can not run on this system environment.",
  518.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  519.       free ( pwinData );
  520.       WinDestroyMsgQueue ( hmq );
  521.       WinTerminate ( hab );
  522.       return ( 1 );
  523.       }
  524.  
  525.    /* if no more than 16 colors supported -> abort program */
  526.    if ( DiveCaps.ulDepth < 8 )
  527.       {
  528.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  529.       (PSZ)"usage: This program can not run on this system environment.",
  530.       (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  531.       free ( pwinData );
  532.       WinDestroyMsgQueue ( hmq );
  533.       WinTerminate ( hab );
  534.       return ( 1 );
  535.       }
  536.  
  537.    /* Get a linear address to the screen. */
  538.    if ( DiveOpen ( &(pwinData->hDive), FALSE, 0 ) )
  539.       {
  540.       WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  541.                (PSZ)"usage: This program can not run on this system environment.",
  542.                (PSZ)"DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_INFORMATION );
  543.       free ( pwinData );
  544.       WinDestroyMsgQueue ( hmq );
  545.       WinTerminate ( hab );
  546.       return ( 1 );
  547.       }
  548.  
  549.  
  550.   /* Initialize Huffman tables */
  551.   init_tables();
  552.  
  553. #ifdef ANALYSIS
  554.   /* Set stats flag */
  555.   PassStats(showEachFlg, ShowOneStat, ShowAllStats);
  556. #endif
  557.  
  558.   /* Initialize Dithering + make an appropiate palette */
  559.   if (ditherType != NO_DITHER)
  560.     InitDither(ditherType, lum_range, cr_range, cb_range, &pPalette, &pPal2);
  561.  
  562.   /* Create a new VidStream */
  563.   theVidStream = NewVidStream(fileName, BUF_LENGTH, loop, quiet, noDisplay,
  564.                   ditherType);
  565.  
  566.   /* Try to get info about the VidStream */
  567.   if (mpegVidRsrc(0, theVidStream, &ditherFlags) == MPEG_INVALID) {
  568.     DestroyVidStream(theVidStream);
  569.  
  570.     WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (PSZ) "Invalid mpeg file",
  571.     (PSZ) "DIMP.EXE - DIVE MPEG Player", 0, MB_OK | MB_MOVEABLE);
  572.  
  573.    /* free allocated structures */
  574.  
  575.       TerminateDither(pPalette, pPal2);
  576.       free ( pwinData );
  577.       WinDestroyMsgQueue ( hmq );
  578.       WinTerminate ( hab );
  579.     exit(1);
  580.   }
  581.  
  582.    /* Register a window class, and create a standard window.
  583.    */
  584.    WinRegisterClass ( hab, pszMyWindow, MyWindowProc, 0, sizeof(ULONG) );
  585.    WinLoadString(hab, 0, ID_APPNAME, sizeof(pszTitleText), pszTitleText);
  586.  
  587.  
  588.    flCreate = FCF_TASKLIST | FCF_SYSMENU  | FCF_TITLEBAR |
  589.           FCF_SIZEBORDER | FCF_MINMAX | FCF_MENU | FCF_SHELLPOSITION;
  590.    pwinData->hwndFrame = WinCreateStdWindow ( HWND_DESKTOP,
  591.                           WS_VISIBLE, &flCreate,
  592.                           pszMyWindow,
  593.                           pszTitleText,
  594.                           WS_SYNCPAINT | WS_VISIBLE,
  595.                           0, ID_MAINWND,
  596.                           &(pwinData->hwndClient));
  597.  
  598.    WinSetWindowULong (pwinData->hwndClient, 0, (ULONG)pwinData);
  599.  
  600.    /* load toolbar dialog from resource */
  601.    pwinData->hwndToolBar = WinLoadDlg(HWND_DESKTOP, pwinData->hwndClient,
  602.      ToolBarDlgProc, 0L, IDD_TOOLBAR, NULL);
  603.  
  604. #ifdef ANALYSIS
  605.    pwinData->hwndOneStat = WinLoadDlg(HWND_DESKTOP, pwinData->hwndClient,
  606.      OneStatDlgProc, 0L, IDD_ONESTAT, NULL);
  607.  
  608.    pwinData->hwndAllStat = WinLoadDlg(HWND_DESKTOP, pwinData->hwndClient,
  609.      AllStatDlgProc, 0L, IDD_ALLSTAT, NULL);
  610. #endif
  611.  
  612.    /* set window data */
  613.    WinSetWindowULong (pwinData->hwndToolBar, 0, (ULONG)pwinData);
  614.  
  615.    /* set on its initial position */
  616.    WinPostMsg(pwinData->hwndToolBar, WM_USER_POSITION, 0L, 0L);
  617.  
  618.    /* Turn on visible region notification. */
  619.    WinSetVisibleRegionNotify ( pwinData->hwndClient, TRUE );
  620.  
  621.    DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  622.  
  623.    /* Query the physical palette and tell DIVE */
  624.    {
  625.    HPS hps= WinBeginPaint ( pwinData->hwndFrame, NULLHANDLE, NULL );
  626.  
  627.    pPal = (PLONG) malloc (sizeof(LONG) * 256);
  628.    GpiQueryRealColors ( hps, 0L, 0L, 256, pPal );
  629.  
  630.    DiveSetDestinationPalette ( pwinData->hDive, 0,256, (PBYTE)pPal );
  631.    free ( pPal );
  632.    WinEndPaint ( hps );
  633.    }
  634.  
  635.    /* Allocate a buffer for image data */
  636.  
  637.    if
  638.    (DiveAllocImageBuffer(pwinData->hDive,&(ulImage), FOURCC_LUT8,
  639.               theVidStream->h_size, theVidStream->v_size,
  640.                 theVidStream->h_size,0))
  641.       {
  642.    /* free allocated structures */
  643.  
  644.       DestroyVidStream(theVidStream);
  645.       DosFreeMem( (PVOID)pPalette );
  646.       free ( pwinData );
  647.       WinDestroyMsgQueue ( hmq );
  648.       WinTerminate ( hab );
  649.       return( 1 );
  650.       }
  651.  
  652.    /* Send an invlaidation message to the client. */
  653.  
  654.    WinPostMsg ( pwinData->hwndFrame, WM_VRNENABLED, 0L, 0L );
  655.  
  656.  
  657.    /* Start up the blitting thread. */
  658.    if ( DosCreateThread ( &(pwinData->tidBlitThread),
  659.                 (PFNTHREAD) Decode,
  660.                 (ULONG)pwinData, 0L, 4096L))
  661.       {
  662.    /* free allocated structures */
  663.       DestroyVidStream(theVidStream);
  664.       WinSetVisibleRegionNotify ( pwinData->hwndClient, FALSE );
  665.  
  666.       DiveFreeImageBuffer ( pwinData->hDive, ulImage );
  667.  
  668.       DiveClose ( pwinData->hDive );
  669.       WinDestroyWindow ( pwinData->hwndFrame );
  670.  
  671.       DosFreeMem( (PVOID)pPalette );
  672.       free ( pwinData);
  673.       WinDestroyMsgQueue ( hmq );
  674.       WinTerminate ( hab );
  675.  
  676.       return ( 1 );
  677.       }
  678.  
  679.    /* player will start to play by default */
  680.    condition = ID_PLAY;
  681.  
  682.    /* Set the proiroty of the blitting thread */
  683.    DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  684.               0, pwinData->tidBlitThread );
  685.  
  686.  
  687.    /* While there are still messages, dispatch them. */
  688.    while ( WinGetMsg ( hab, &qmsg, 0, 0, 0 ) )
  689.       WinDispatchMsg ( hab, &qmsg );
  690.  
  691.    /* Set the variable to end the running thread, and wait for it to end. */
  692.    ulToEnd = 1;
  693.    DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  694.  
  695.    DestroyVidStream(theVidStream);
  696.  
  697.    /* Turn off visible region notificationm tidy up, and terminate.
  698.    */
  699.    WinSetVisibleRegionNotify ( pwinData->hwndClient, FALSE );
  700.  
  701.    /* Free the buffers allocated by DIVE and close DIVE */
  702.    DiveFreeImageBuffer ( pwinData->hDive, ulImage );
  703.    DiveClose ( pwinData->hDive );
  704.  
  705.    TerminateDither(pPalette, pPal2);
  706.  
  707.    /* Process for termination  */
  708.    WinDestroyWindow ( pwinData->hwndFrame );
  709.    free ( pwinData );
  710.    WinDestroyMsgQueue ( hmq );
  711.    WinTerminate ( hab );
  712.    return ( 0 );
  713. }
  714.  
  715.  
  716. MRESULT EXPENTRY MyWindowProc ( HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  717.    {
  718.    POINTL    pointl;                /* Point to offset from Desktop         */
  719.    SWP       swp;                   /* Window position                      */
  720.    HRGN      hrgn;                  /* Region handle                        */
  721.    HPS       hps;                   /* Presentation Space handle            */
  722.    RECTL     rcls[50];              /* Rectangle coordinates                */
  723.    RGNRECT   rgnCtl;                /* Processing control structure         */
  724.    PWINDATA  pwinData;              /* Pointer to window data               */
  725.    SETUP_BLITTER SetupBlitter;      /* structure for DiveSetupBlitter       */
  726.    PLONG     pPal;
  727.    HWND      hwndDialog;
  728.  
  729.    /* Get the pointer to window data
  730.    */
  731.    if ( pwinData = (PWINDATA)WinQueryWindowULong (hWnd, 0))
  732.       {
  733.       switch( msg )
  734.      {
  735.      case WM_NEWTEXT:
  736.        /* Write new text string to the title bar */
  737.          WinSetWindowText ( pwinData->hwndFrame, (PSZ)mp1 );
  738.          break;
  739.  
  740.      case WM_COMMAND:
  741.         switch ( SHORT1FROMMP ( mp1 ) )
  742.            {
  743.            case ID_EXIT:
  744.           /* Post to quit the dispatch message loop.
  745.           */
  746.           WinPostMsg ( hWnd, WM_QUIT, 0L, 0L );
  747.           break;
  748.            case ID_SNAP1:
  749.           {
  750.           /* Find the total width and height of the window such that
  751.           ** the actual video area equals the source width and height.
  752.           */
  753.           ULONG ulHeight = theVidStream->v_size;
  754.           ULONG ulWidth = theVidStream->h_size;
  755.           ulHeight +=
  756.                WinQuerySysValue ( HWND_DESKTOP, SV_CYSIZEBORDER ) * 2;
  757.           ulHeight +=
  758.                WinQuerySysValue ( HWND_DESKTOP, SV_CYBORDER ) * 2;
  759.           ulHeight +=
  760.                WinQuerySysValue ( HWND_DESKTOP, SV_CYMENU );
  761.           ulHeight +=
  762.                WinQuerySysValue ( HWND_DESKTOP, SV_CYTITLEBAR );
  763.           ulWidth +=
  764.                WinQuerySysValue ( HWND_DESKTOP, SV_CXSIZEBORDER ) * 2;
  765.  
  766.           /* Set the new size of the window, but don't move it.
  767.           */
  768.           WinSetWindowPos ( pwinData->hwndFrame, HWND_TOP,
  769.                     100, 100, ulWidth, ulHeight,
  770.                     SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
  771.           }
  772.           break;
  773.            case ID_SNAP2:
  774.           {
  775.           /* Find the total width and height of the window such that
  776.           ** the actual video area equals the source width and height.
  777.           */
  778.           ULONG ulHeight = theVidStream->v_size*2;
  779.           ULONG ulWidth = theVidStream->h_size*2;
  780.           ulHeight +=
  781.                WinQuerySysValue ( HWND_DESKTOP, SV_CYSIZEBORDER ) * 2;
  782.           ulHeight +=
  783.                WinQuerySysValue ( HWND_DESKTOP, SV_CYBORDER ) * 2;
  784.           ulHeight +=
  785.                WinQuerySysValue ( HWND_DESKTOP, SV_CYMENU );
  786.           ulHeight +=
  787.                WinQuerySysValue ( HWND_DESKTOP, SV_CYTITLEBAR );
  788.           ulWidth +=
  789.                WinQuerySysValue ( HWND_DESKTOP, SV_CXSIZEBORDER ) * 2;
  790.  
  791.           /* Set the new size of the window, but don't move it.
  792.           */
  793.           WinSetWindowPos ( pwinData->hwndFrame, HWND_TOP,
  794.                     100, 100, ulWidth, ulHeight,
  795.                     SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
  796.           }
  797.           break;
  798.            case ID_SNAP3:
  799.           {
  800.           /* Find the total width and height of the window such that
  801.           ** the actual video area equals the source width and height.
  802.           */
  803.           ULONG ulHeight = theVidStream->v_size*3;
  804.           ULONG ulWidth = theVidStream->h_size*3;
  805.           ulHeight +=
  806.                WinQuerySysValue ( HWND_DESKTOP, SV_CYSIZEBORDER ) * 2;
  807.           ulHeight +=
  808.                WinQuerySysValue ( HWND_DESKTOP, SV_CYBORDER ) * 2;
  809.           ulHeight +=
  810.                WinQuerySysValue ( HWND_DESKTOP, SV_CYMENU );
  811.           ulHeight +=
  812.                WinQuerySysValue ( HWND_DESKTOP, SV_CYTITLEBAR );
  813.           ulWidth +=
  814.                WinQuerySysValue ( HWND_DESKTOP, SV_CXSIZEBORDER ) * 2;
  815.  
  816.           /* Set the new size of the window, but don't move it.
  817.           */
  818.           WinSetWindowPos ( pwinData->hwndFrame, HWND_TOP,
  819.                     100, 100, ulWidth, ulHeight,
  820.                     SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
  821.           }
  822.           break;
  823.  
  824.            case ID_PAUSE:
  825.  
  826.           ulToEnd = 1;
  827.           condition = ID_PAUSE;
  828.           break;
  829.  
  830.            case ID_PLAY:
  831.          if (condition == ID_PAUSE) {
  832.             ulToEnd = 0;
  833.             DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  834.             DosCreateThread ( &(pwinData->tidBlitThread),
  835.                 (PFNTHREAD) Decode,
  836.                 (ULONG)pwinData, 0L, 4096L);
  837.             condition = ID_PLAY;
  838.             DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  839.               0, pwinData->tidBlitThread );
  840.          }
  841.          break;
  842.  
  843.            case ID_ADVANCE: /* PVG: what if condition == ID_END ? */
  844.  
  845.          if (condition == ID_PAUSE) {
  846.            ulToEnd = 1;
  847.  
  848.          DosCreateThread ( &(pwinData->tidBlitThread),
  849.                 (PFNTHREAD) Decode,
  850.                 (ULONG)pwinData, 0L, 4096L);
  851.          condition = ID_PAUSE;
  852.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  853.               0, pwinData->tidBlitThread );
  854.          }
  855.          break;
  856.            case ID_RESET:
  857.          if (condition == ID_PLAY) {
  858.             ulToEnd = 1;
  859.             DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  860.          }
  861.          DestroyVidStream(theVidStream);
  862.          ResetVidStream();
  863.          theVidStream = NewVidStream(fileName, BUF_LENGTH, loop, quiet, noDisplay,
  864.                 ditherType);
  865.  
  866.          /* display first frame */
  867.          DosCreateThread ( &(pwinData->tidBlitThread),
  868.                 (PFNTHREAD) Decode,
  869.                 (ULONG)pwinData, 0L, 4096L);
  870.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  871.               0, pwinData->tidBlitThread );
  872.          ulToEnd = 1;
  873.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  874.          condition = ID_PAUSE;
  875.          break;
  876.  
  877.            case ID_ORDERED_DITHER:
  878.            if (condition == ID_PLAY) {
  879.          ulToEnd = 1;
  880.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  881.          ulToEnd = 0;
  882.            }
  883.  
  884.          ditherType = ORDERED_DITHER;
  885.          InitDither(ditherType, lum_range, cr_range, cb_range,
  886.          &pPalette, &pPal2);
  887.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  888.          VidStreamFlags(ditherType, loop, noDisplay);
  889.          DosCreateThread ( &(pwinData->tidBlitThread),
  890.                 (PFNTHREAD) Decode,
  891.                 (ULONG)pwinData, 0L, 4096L);
  892.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  893.               0, pwinData->tidBlitThread );
  894.  
  895.          break;
  896.  
  897.            case ID_ORDERED2_DITHER:
  898.            if (condition == ID_PLAY) {
  899.          ulToEnd = 1;
  900.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  901.          ulToEnd = 0;
  902.            }
  903.          ditherType = ORDERED2_DITHER;
  904.          InitDither(ditherType, lum_range, cr_range, cb_range,
  905.          &pPalette,&pPal2);
  906.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  907.          VidStreamFlags(ditherType, loop, noDisplay);
  908.          DosCreateThread ( &(pwinData->tidBlitThread),
  909.                 (PFNTHREAD) Decode,
  910.                 (ULONG)pwinData, 0L, 4096L);
  911.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  912.               0, pwinData->tidBlitThread );
  913.  
  914.          break;
  915.  
  916.            case ID_HYBRID_DITHER:
  917.            if (condition == ID_PLAY) {
  918.          ulToEnd = 1;
  919.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  920.          ulToEnd = 0;
  921.            }
  922.          ditherType = HYBRID_DITHER;
  923.          InitDither(ditherType, lum_range, cr_range, cb_range,
  924.          &pPalette,&pPal2);
  925.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  926.          VidStreamFlags(ditherType, loop, noDisplay);
  927.          DosCreateThread ( &(pwinData->tidBlitThread),
  928.                 (PFNTHREAD) Decode,
  929.                 (ULONG)pwinData, 0L, 4096L);
  930.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  931.               0, pwinData->tidBlitThread );
  932.  
  933.          break;
  934.  
  935.            case ID_HYBRID2_DITHER:
  936.            if (condition == ID_PLAY) {
  937.          ulToEnd = 1;
  938.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  939.          ulToEnd = 0;
  940.            }
  941.          ditherType = HYBRID2_DITHER;
  942.          InitDither(ditherType, lum_range, cr_range, cb_range,
  943.          &pPalette,&pPal2);
  944.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  945.          VidStreamFlags(ditherType, loop, noDisplay);
  946.          DosCreateThread ( &(pwinData->tidBlitThread),
  947.                 (PFNTHREAD) Decode,
  948.                 (ULONG)pwinData, 0L, 4096L);
  949.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  950.               0, pwinData->tidBlitThread );
  951.  
  952.          break;
  953.  
  954.            case ID_FS4_DITHER:
  955.            if (condition == ID_PLAY) {
  956.          ulToEnd = 1;
  957.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  958.          ulToEnd = 0;
  959.            }
  960.          ditherType = FS4_DITHER;
  961.          InitDither(ditherType, lum_range, cr_range, cb_range,
  962.          &pPalette,&pPal2);
  963.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  964.          VidStreamFlags(ditherType, loop, noDisplay);
  965.          DosCreateThread ( &(pwinData->tidBlitThread),
  966.                 (PFNTHREAD) Decode,
  967.                 (ULONG)pwinData, 0L, 4096L);
  968.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  969.               0, pwinData->tidBlitThread );
  970.  
  971.          break;
  972.  
  973.            case ID_FS2_DITHER:
  974.            if (condition == ID_PLAY) {
  975.          ulToEnd = 1;
  976.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  977.          ulToEnd = 0;
  978.            }
  979.          ditherType = FS2_DITHER;
  980.          InitDither(ditherType, lum_range, cr_range, cb_range,
  981.          &pPalette,&pPal2);
  982.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  983.          VidStreamFlags(ditherType, loop, noDisplay);
  984.          DosCreateThread ( &(pwinData->tidBlitThread),
  985.                 (PFNTHREAD) Decode,
  986.                 (ULONG)pwinData, 0L, 4096L);
  987.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  988.               0, pwinData->tidBlitThread );
  989.  
  990.          break;
  991.  
  992.            case ID_FS2FAST_DITHER:
  993.            if (condition == ID_PLAY) {
  994.          ulToEnd = 1;
  995.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  996.          ulToEnd = 0;
  997.            }
  998.          ditherType = FS2FAST_DITHER;
  999.          InitDither(ditherType, lum_range, cr_range, cb_range,
  1000.          &pPalette,&pPal2);
  1001.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  1002.          VidStreamFlags(ditherType, loop, noDisplay);
  1003.          DosCreateThread ( &(pwinData->tidBlitThread),
  1004.                 (PFNTHREAD) Decode,
  1005.                 (ULONG)pwinData, 0L, 4096L);
  1006.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  1007.               0, pwinData->tidBlitThread );
  1008.  
  1009.          break;
  1010.  
  1011.            case ID_MBORDERED_DITHER:
  1012.            if (condition == ID_PLAY) {
  1013.          ulToEnd = 1;
  1014.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  1015.          ulToEnd = 0;
  1016.            }
  1017.          ditherType = MBORDERED_DITHER;
  1018.          InitDither(ditherType, lum_range, cr_range, cb_range,
  1019.          &pPalette,&pPal2);
  1020.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  1021.          /* Start from beginning because video.c needs to initialize
  1022.          vars needed for this type of dither */
  1023.          DestroyVidStream(theVidStream);
  1024.          ResetVidStream();
  1025.          theVidStream = NewVidStream(fileName, BUF_LENGTH, loop, quiet, noDisplay,
  1026.                   ditherType);
  1027.          mpegVidRsrc(0, theVidStream, &ditherFlags);
  1028.          DosCreateThread ( &(pwinData->tidBlitThread),
  1029.                 (PFNTHREAD) Decode,
  1030.                 (ULONG)pwinData, 0L, 4096L);
  1031.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  1032.               0, pwinData->tidBlitThread );
  1033.  
  1034.          break;
  1035.  
  1036.            case ID_GRAY_DITHER:
  1037.            if (condition == ID_PLAY) {
  1038.          ulToEnd = 1;
  1039.          DosWaitThread ( &(pwinData->tidBlitThread), DCWW_WAIT );
  1040.          ulToEnd = 0;
  1041.            }
  1042.          ditherType = GRAY_DITHER;
  1043.          InitDither(ditherType, lum_range, cr_range, cb_range,
  1044.          &pPalette,&pPal2);
  1045.          DiveSetSourcePalette ( pwinData->hDive, 0, 256, pPalette );
  1046.          VidStreamFlags(ditherType, loop, noDisplay);
  1047.  
  1048.          DosCreateThread ( &(pwinData->tidBlitThread),
  1049.                 (PFNTHREAD) Decode,
  1050.                 (ULONG)pwinData, 0L, 4096L);
  1051.          DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  1052.               0, pwinData->tidBlitThread );
  1053.          break;
  1054.  
  1055.            case ID_LOOP:
  1056.          if (loop == 1)
  1057.            WinPostMsg(pwinData->hwndToolBar, WM_DOLOOP, 0L, 0L);
  1058.          else
  1059.            WinPostMsg(pwinData->hwndToolBar, WM_NOLOOP, 0L, 0L);
  1060.          loop = (loop? 0: 1);
  1061.          VidStreamFlags(ditherType, loop, noDisplay);
  1062.          if (condition == ID_END) { /* play-thread has done playing */
  1063.            ResetVidStream();
  1064.            theVidStream = NewVidStream(fileName, BUF_LENGTH, loop, quiet, noDisplay,
  1065.                   ditherType);
  1066.            mpegVidRsrc(0, theVidStream, &ditherFlags);
  1067.            DosCreateThread ( &(pwinData->tidBlitThread),
  1068.                   (PFNTHREAD) Decode,
  1069.                   (ULONG)pwinData, 0L, 4096L);
  1070.            DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  1071.             0, pwinData->tidBlitThread );
  1072.            condition = ID_PLAY;
  1073.          }
  1074.          break;
  1075.  
  1076.            case ID_NO_DISPLAY: /* show / don't show video sequence */
  1077.          if (noDisplay == 1)
  1078.            WinPostMsg(pwinData->hwndToolBar, WM_DOSHOW, 0L, 0L);
  1079.          else
  1080.            WinPostMsg(pwinData->hwndToolBar, WM_NOSHOW, 0L, 0L);
  1081.  
  1082.          noDisplay = (noDisplay?0:1); /* PVG: noDisplay can also be acessed
  1083.                                in play !!! */
  1084.          VidStreamFlags(ditherType, loop, noDisplay);
  1085.          break;
  1086.  
  1087.            case ID_NO_DITHER:
  1088.          WinPostMsg(pwinData->hwndToolBar, WM_NOSHOW, 0L, 0L);
  1089.          noDisplay = 1;
  1090.          ditherType = NO_DITHER;
  1091.          VidStreamFlags(ditherType, loop, noDisplay);
  1092.          break;
  1093.  
  1094.            case ID_DIVE_INFO:
  1095.           /* Get the screen capabilities, and display them
  1096.           in the dialog box. */
  1097.  
  1098.           DiveCaps.pFormatData = fccFormats;
  1099.           DiveCaps.ulFormatLength = 120;
  1100.           DiveCaps.ulStructLen = sizeof(DIVE_CAPS);
  1101.  
  1102.           if ( DiveQueryCaps ( &DiveCaps, DIVE_BUFFER_SCREEN ))
  1103.              {
  1104.              WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  1105.              (PSZ)"usage: DIMP failed to get screen capabilities.",
  1106.              (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  1107.              break;
  1108.              }
  1109.  
  1110.           WinDlgBox ( HWND_DESKTOP, pwinData->hwndClient,
  1111.                    DiveDlgProc, (HMODULE)0,
  1112.                    ID_DIALOG, (PVOID)pwinData );
  1113.  
  1114.           break;
  1115.  
  1116.            case ID_MPEG_INFO:
  1117.  
  1118.           WinDlgBox ( HWND_DESKTOP, pwinData->hwndClient,
  1119.                    MpegDlgProc, (HMODULE)0,
  1120.                    ID_DIALOG2, (PVOID)pwinData );
  1121.           break;
  1122.  
  1123.            case ID_PROG_USAGE:
  1124.           WinDlgBox ( HWND_DESKTOP, pwinData->hwndClient,
  1125.                    UsageDlgProc, (HMODULE)0,
  1126.                    IDD_USAGE, (PVOID)pwinData );
  1127.           break;
  1128.  
  1129.            case ID_ABOUT:
  1130.          WinDlgBox (HWND_DESKTOP, pwinData->hwndClient, AboutDlgProc,
  1131.            (HMODULE) 0, IDD_ABOUT, (PVOID) pszTitleText);
  1132.          break;
  1133.  
  1134.            default:
  1135.           /* Let PM handle this message.
  1136.           */
  1137.           return WinDefWindowProc ( hWnd, msg, mp1, mp2 );
  1138.            }
  1139.         break;
  1140.  
  1141.  
  1142.      case WM_VRNDISABLED:
  1143.  
  1144.         DiveSetupBlitter ( pwinData->hDive, 0 );
  1145.         break;
  1146.  
  1147.      case WM_VRNENABLED:
  1148.         hps = WinGetPS ( hWnd );
  1149.         if ( !hps )
  1150.            break;
  1151.         hrgn = GpiCreateRegion ( hps, 0L, NULL );
  1152.         if ( hrgn )
  1153.            {
  1154.            /* NOTE: If mp1 is zero, then this was just a move message.
  1155.            ** Illustrate the visible region on a WM_VRNENABLE.
  1156.            */
  1157.            WinQueryVisibleRegion ( hWnd, hrgn );
  1158.            rgnCtl.ircStart     = 0;
  1159.            rgnCtl.crc          = 50;
  1160.            rgnCtl.ulDirection  = 1;
  1161.  
  1162.            /* Get the all ORed rectangles
  1163.            */
  1164.            if ( GpiQueryRegionRects ( hps, hrgn, NULL, &rgnCtl, rcls) )
  1165.           {
  1166.           /* Now find the window position and size, relative to parent.
  1167.           */
  1168.           WinQueryWindowPos ( pwinData->hwndClient, &swp );
  1169.  
  1170.           /* Convert the point to offset from desktop lower left.
  1171.           */
  1172.           pointl.x = swp.x;
  1173.           pointl.y = swp.y;
  1174.           WinMapWindowPoints ( pwinData->hwndFrame,
  1175.                        HWND_DESKTOP, &pointl, 1 );
  1176.  
  1177.           /* Tell DIVE about the new settings.
  1178.           */
  1179.           SetupBlitter.ulStructLen = sizeof ( SETUP_BLITTER );
  1180.           SetupBlitter.fccSrcColorFormat = FOURCC_LUT8;
  1181.           SetupBlitter.ulSrcWidth = theVidStream->h_size;
  1182.           SetupBlitter.ulSrcHeight = theVidStream->v_size;
  1183.           SetupBlitter.ulSrcPosX = 0;
  1184.           SetupBlitter.ulSrcPosY = 0;
  1185.           SetupBlitter.fInvert = FALSE;
  1186.           SetupBlitter.ulDitherType = 0;
  1187.  
  1188.           SetupBlitter.fccDstColorFormat = FOURCC_SCRN;
  1189.           SetupBlitter.ulDstWidth = swp.cx;
  1190.           SetupBlitter.ulDstHeight = swp.cy;
  1191.           SetupBlitter.lDstPosX = 0;
  1192.           SetupBlitter.lDstPosY = 0;
  1193.           SetupBlitter.lScreenPosX = pointl.x;
  1194.           SetupBlitter.lScreenPosY = pointl.y;
  1195.           SetupBlitter.ulNumDstRects = rgnCtl.crcReturned;
  1196.           SetupBlitter.pVisDstRects = rcls;
  1197.           DiveSetupBlitter ( pwinData->hDive, &SetupBlitter );
  1198.  
  1199.           }
  1200.            else
  1201.           DiveSetupBlitter ( pwinData->hDive, 0 );
  1202.  
  1203.            GpiDestroyRegion( hps, hrgn );
  1204.            }
  1205.         WinReleasePS( hps );
  1206.         break;
  1207.  
  1208.      case WM_CHAR:
  1209.         /* Character input: first two byte of message is the character code.
  1210.         */
  1211.         if ( SHORT2FROMMP ( mp2 ) == VK_F4 )
  1212.            WinPostMsg ( hWnd, WM_QUIT, 0L, 0L );
  1213.         else if ( SHORT2FROMMP ( mp2 ) == VK_F1 )
  1214.            WinPostMsg ( hWnd, WM_COMMAND, (PVOID)ID_SNAP1, 0L );
  1215.         else if ( SHORT2FROMMP ( mp2 ) == VK_F2 )
  1216.            WinPostMsg ( hWnd, WM_COMMAND, (PVOID)ID_SNAP2, 0L );
  1217.         else if ( SHORT2FROMMP ( mp2 ) == VK_F3 )
  1218.            WinPostMsg ( hWnd, WM_COMMAND, (PVOID)ID_SNAP3, 0L );
  1219.         break;
  1220.  
  1221.      case WM_REALIZEPALETTE:
  1222.  
  1223.         hps= WinBeginPaint ( pwinData->hwndFrame, NULLHANDLE, NULL );
  1224.  
  1225.         pPal = (PLONG) malloc (sizeof(LONG) * 256);
  1226.         GpiQueryRealColors ( hps, 0L, 0L, 256, pPal );
  1227.  
  1228.         DiveSetDestinationPalette (pwinData->hDive,0,256,(PBYTE)pPal );
  1229.         free ( pPal );
  1230.  
  1231.         WinEndPaint ( hps );
  1232.  
  1233.         break;
  1234.  
  1235.      case WM_CLOSE:
  1236.         /* Post to quit the dispatch message loop.
  1237.         */
  1238.         WinPostMsg ( hWnd, WM_QUIT, 0L, 0L );
  1239.         break;
  1240.  
  1241.      default:
  1242.         /* Let PM handle this message.
  1243.         */
  1244.         return WinDefWindowProc ( hWnd, msg, mp1, mp2 );
  1245.      }
  1246.       }
  1247.    else
  1248.       /* Let PM handle this message.
  1249.       */
  1250.       return WinDefWindowProc ( hWnd, msg, mp1, mp2 );
  1251.  
  1252.    return ( FALSE );
  1253.    }
  1254.  
  1255.  
  1256. MRESULT EXPENTRY ToolBarDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1257. {
  1258.     MRESULT mReturn  = 0L;
  1259.     BOOL    bHandled = TRUE;
  1260.     RECTL   Rectl;
  1261.     PWINDATA pwinData;
  1262.  
  1263.    /* Get the pointer to window data
  1264.    */
  1265.     pwinData = (PWINDATA)WinQueryWindowULong (hWnd, 0);
  1266.  
  1267.     switch (msg)
  1268.     {
  1269.     case WM_INITDLG:
  1270.         WinSendDlgItemMsg (hWnd, IDC_RED, SPBM_SETTEXTLIMIT, 
  1271.         (MPARAM)3, (MPARAM)0);
  1272.         WinSendDlgItemMsg (hWnd, IDC_RED, SPBM_SETLIMITS,
  1273.         (MPARAM)200L, (MPARAM)0L);
  1274.         WinSendDlgItemMsg (hWnd, IDC_BLUE, SPBM_SETTEXTLIMIT, 
  1275.         (MPARAM)3, (MPARAM)0);
  1276.         WinSendDlgItemMsg (hWnd, IDC_BLUE, SPBM_SETLIMITS,
  1277.         (MPARAM)200L, (MPARAM)0L);
  1278.         WinSendDlgItemMsg (hWnd, IDC_GREEN, SPBM_SETTEXTLIMIT, 
  1279.         (MPARAM)3, (MPARAM)0);
  1280.         WinSendDlgItemMsg (hWnd, IDC_GREEN, SPBM_SETLIMITS,
  1281.         (MPARAM)200L, (MPARAM)0L);
  1282.         WinSendDlgItemMsg (hWnd, IDC_BRIGHTNESS, SPBM_SETTEXTLIMIT,
  1283.         (MPARAM)3, (MPARAM)0);
  1284.         WinSendDlgItemMsg (hWnd, IDC_BRIGHTNESS, SPBM_SETLIMITS,
  1285.         (MPARAM)200L, (MPARAM)0L);
  1286.         WinSendDlgItemMsg (hWnd, IDC_CONTRAST, SPBM_SETTEXTLIMIT,
  1287.         (MPARAM)3, (MPARAM)0);
  1288.         WinSendDlgItemMsg (hWnd, IDC_CONTRAST, SPBM_SETLIMITS,
  1289.         (MPARAM)400L, (MPARAM)0L);
  1290.  
  1291.         WinSendDlgItemMsg(hWnd, IDC_RED, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1292.         (MPARAM) 0L);
  1293.         WinSendDlgItemMsg(hWnd, IDC_GREEN, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1294.         (MPARAM) 0L);
  1295.         WinSendDlgItemMsg(hWnd, IDC_BLUE, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1296.         (MPARAM) 0L);
  1297.         WinSendDlgItemMsg(hWnd, IDC_BRIGHTNESS, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1298.         (MPARAM) 0L);
  1299.         WinSendDlgItemMsg(hWnd, IDC_CONTRAST, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1300.         (MPARAM) 0L);
  1301.  
  1302.         /* set all five check-buttons */
  1303.           WinCheckButton(hWnd, IDC_SHOW, 1);
  1304.         if (nop !=1)
  1305.           WinCheckButton(hWnd, IDC_PFRAME, 1);
  1306.         if (nob !=1)
  1307.           WinCheckButton(hWnd, IDC_BFRAME, 1);
  1308.         if (noDisplay == 0)
  1309.           WinCheckButton(hWnd, IDC_SHOW, 1);
  1310.         else
  1311.           WinCheckButton(hWnd, IDC_SHOW, 0);
  1312.         if (loop == 1)
  1313.           WinCheckButton(hWnd, IDC_LOOP, 1);
  1314.  
  1315.  
  1316.         break;
  1317.  
  1318.     case WM_USER_POSITION:
  1319.         WinQueryWindowRect (HWND_DESKTOP, &Rectl);
  1320.         WinSetWindowPos (hWnd, 0, Rectl.xRight-150, Rectl.yBottom+10, 0L, 0L,
  1321.         SWP_MOVE | SWP_SHOW);
  1322.         break;
  1323.     case WM_NOSHOW:
  1324.         WinCheckButton(hWnd, IDC_SHOW, 0);
  1325.         break;
  1326.     case WM_DOSHOW:
  1327.         WinCheckButton(hWnd, IDC_SHOW, 1);
  1328.         break;
  1329.     case WM_NOLOOP:
  1330.         WinCheckButton(hWnd, IDC_LOOP, 0);
  1331.         break;
  1332.     case WM_DOLOOP:
  1333.         WinCheckButton(hWnd, IDC_LOOP, 1);
  1334.         break;
  1335.  
  1336.     case WM_CONTROL:
  1337.           {
  1338.         BOOL bChecked;
  1339.         switch (SHORT1FROMMP(mp1))
  1340.         {
  1341.             case IDC_SHOW:
  1342.             if (SHORT2FROMMP(mp1) == BN_CLICKED)
  1343.             {
  1344.                noDisplay = (noDisplay==0?1:0);
  1345.                VidStreamFlags(ditherType, loop, noDisplay);
  1346.             }
  1347.             break;
  1348.             case IDC_LOOP:
  1349.             if (SHORT2FROMMP(mp1) == BN_CLICKED)
  1350.             {
  1351.                loop = (loop==0?1:0);
  1352.                VidStreamFlags(ditherType, loop, noDisplay);
  1353.                if (condition == ID_END) { /* play-thread has done playing */
  1354.                  ResetVidStream();
  1355.                  theVidStream = NewVidStream(fileName, BUF_LENGTH, loop, quiet, noDisplay,
  1356.                         ditherType);
  1357.                  mpegVidRsrc(0, theVidStream, &ditherFlags);
  1358.                  DosCreateThread ( &(pwinData->tidBlitThread),
  1359.                    (PFNTHREAD) Decode,
  1360.                    (ULONG)pwinData, 0L, 4096L);
  1361.                  DosSetPriority ( PRTYS_THREAD, PRTYC_IDLETIME,
  1362.                  0, pwinData->tidBlitThread );
  1363.                  condition = ID_PLAY;
  1364.                }
  1365.             }
  1366.             break;
  1367.  
  1368.             case IDC_BFRAME:
  1369.             if (SHORT2FROMMP(mp1) == BN_CLICKED)
  1370.             {
  1371.                ToggleBFlag();
  1372.                nob = (nob==0?1:0);
  1373.             }
  1374.             break;
  1375.  
  1376.             case IDC_PFRAME:
  1377.             if (SHORT2FROMMP(mp1) == BN_CLICKED)
  1378.             {
  1379.                TogglePFlag();
  1380.                nop = (nop==0?1:0);
  1381.             }
  1382.             break;
  1383.  
  1384.             case IDC_RED:
  1385.  
  1386.             if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN)
  1387.             {
  1388.                 ULONG ulRed;
  1389.                 USHORT i;
  1390.                 int p;
  1391.                 PBYTE pTemp = pPalette, pTmp2 = pPal2;
  1392.  
  1393.                 WinSendDlgItemMsg (hWnd, IDC_RED,
  1394.                 SPBM_QUERYVALUE, (MPARAM)&ulRed, 0L);
  1395.  
  1396.                 for(i=0;i<256;i++) {
  1397.                   p=(int) *pTmp2;
  1398.                   if (p<0) p+=256; /* if sign bit was 1 */
  1399.                   p += p*(((int)ulRed)-100)/100;
  1400.                   if (p<0) p=0;
  1401.                   if (p>255) p=255;
  1402.  
  1403.                   *pTemp = (BYTE) p;
  1404.                   pTemp++; pTmp2++;
  1405.                   pTemp++; pTmp2++;
  1406.                   pTemp++; pTmp2++;
  1407.                   pTemp++; pTmp2++;
  1408.                 }
  1409.                 DiveSetSourcePalette ( pwinData->hDive,0, 256, (PBYTE) pPalette );
  1410.               }
  1411.               break;
  1412.             case IDC_GREEN:
  1413.  
  1414.             if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN)
  1415.             {
  1416.                 ULONG  ulGreen;
  1417.                 USHORT i;
  1418.                 int p;
  1419.                 PBYTE pTemp = pPalette, pTmp2 = pPal2;
  1420.  
  1421.                 WinSendDlgItemMsg (hWnd, IDC_GREEN,
  1422.                 SPBM_QUERYVALUE, (MPARAM)&ulGreen, 0L);
  1423.  
  1424.                 for(i=0;i<256;i++) {
  1425.                   pTmp2++;
  1426.                   p=(int) *pTmp2;
  1427.                   if (p<0) p+=256; /* if sign bit was 1 */
  1428.                   p += p*(((int)ulGreen)-100)/100;
  1429.                   if (p<0) p=0;
  1430.                   if (p>255) p=255;
  1431.  
  1432.                   pTemp++;
  1433.                   *pTemp = (BYTE) p;
  1434.                   pTemp++; pTmp2++;
  1435.                   pTemp++; pTmp2++;
  1436.                   pTemp++; pTmp2++;
  1437.                 }
  1438.                 DiveSetSourcePalette ( pwinData->hDive,0, 256, (PBYTE) pPalette );
  1439.               }
  1440.               break;
  1441.  
  1442.             case IDC_BLUE:
  1443.  
  1444.             if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN)
  1445.             {
  1446.                 ULONG  ulBlue;
  1447.                 USHORT i;
  1448.                 int p;
  1449.                 PBYTE pTemp = pPalette, pTmp2 = pPal2;
  1450.  
  1451.                 WinSendDlgItemMsg (hWnd, IDC_BLUE,
  1452.                 SPBM_QUERYVALUE, (MPARAM)&ulBlue, 0L);
  1453.  
  1454.                 for(i=0;i<256;i++) {
  1455.                   pTmp2++;
  1456.                   pTmp2++;
  1457.                   p=(int) *pTmp2;
  1458.                   if (p<0) p+=256; /* if sign bit was 1 */
  1459.                   p += p*(((int)ulBlue)-100)/100;
  1460.                   if (p<0) p=0;
  1461.                   if (p>255) p=255;
  1462.  
  1463.                   pTemp++;
  1464.                   pTemp++;
  1465.                   *pTemp = (BYTE) p;
  1466.                   pTemp++; pTmp2++;
  1467.                   pTemp++; pTmp2++;
  1468.                 }
  1469.                 DiveSetSourcePalette ( pwinData->hDive,0, 256, (PBYTE) pPalette );
  1470.               }
  1471.               break;
  1472.  
  1473.             case IDC_BRIGHTNESS:
  1474.             if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN)
  1475.             {
  1476.                 ULONG ulBright;
  1477.                 USHORT i;
  1478.                 int p;
  1479.                 PBYTE pTemp = pPalette, pTmp2 = pPal2;
  1480.  
  1481.                 WinSendDlgItemMsg (hWnd, IDC_BRIGHTNESS,
  1482.                 SPBM_QUERYVALUE, (MPARAM)&ulBright, 0L);
  1483.  
  1484.                 for(i=0;i<256;i++) {
  1485.                   p=(int) *pTmp2;
  1486.                   if (p<0) p+=256; /* if sign bit was 1 */
  1487.                   p += p*(((int)ulBright)-100)/100;
  1488.                   if (p<0) p=0;
  1489.                   if (p>255) p=255;
  1490.                   *pTemp = (BYTE) p;
  1491.  
  1492.                   pTemp++; pTmp2++;
  1493.                   p=(int) *pTmp2;
  1494.                   if (p<0) p+=256; /* if sign bit was 1 */
  1495.                   p += p*(((int)ulBright)-100)/100;
  1496.                   if (p<0) p=0;
  1497.                   if (p>255) p=255;
  1498.                   *pTemp = (BYTE) p;
  1499.  
  1500.                   pTemp++; pTmp2++;
  1501.                   p=(int) *pTmp2;
  1502.                   if (p<0) p+=256; /* if sign bit was 1 */
  1503.                   p += p*(((int)ulBright)-100)/100;
  1504.                   if (p<0) p=0;
  1505.                   if (p>255) p=255;
  1506.                   *pTemp = (BYTE) p;
  1507.  
  1508.                   pTemp++; pTmp2++;
  1509.                   pTemp++; pTmp2++;
  1510.                 }
  1511.                 DiveSetSourcePalette ( pwinData->hDive,0, 256, (PBYTE) pPalette );
  1512.               }
  1513.               break;
  1514.  
  1515.             case IDC_CONTRAST:
  1516.  
  1517.             if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN)
  1518.             {
  1519.                 ULONG ulCont;
  1520.                 USHORT i;
  1521.                 int p;
  1522.                 PBYTE pTemp = pPalette, pTmp2 = pPal2;
  1523.  
  1524.                 WinSendDlgItemMsg (hWnd, IDC_CONTRAST,
  1525.                 SPBM_QUERYVALUE, (MPARAM)&ulCont, 0L);
  1526.  
  1527.                 for(i=0;i<256;i++) {
  1528.                   p=(int) *pTmp2;
  1529.                   if (p<0) p+=256; /* if sign bit was 1 */
  1530.  
  1531.                   if (p<128) {
  1532.                 p -= p*(((int)ulCont)-100)/100;
  1533.                 if (p<0) p=0;
  1534.                 if (p>127) p=127;
  1535.                   }
  1536.                   else {
  1537.                 p += p*(((int)ulCont)-100)/100;
  1538.                 if (p>255) p=255;
  1539.                 if (p<128) p=128;
  1540.                   }
  1541.                   *pTemp = (BYTE) p;
  1542.                   pTemp++; pTmp2++;
  1543.  
  1544.                   p=(int) *pTmp2;
  1545.                   if (p<0) p+=256; /* if sign bit was 1 */
  1546.  
  1547.                   if (p<128) {
  1548.                 p -= p*(((int)ulCont)-100)/100;
  1549.                 if (p<0) p=0;
  1550.                 if (p>127) p=127;
  1551.                   }
  1552.                   else {
  1553.                 p += p*(((int)ulCont)-100)/100;
  1554.                 if (p>255) p=255;
  1555.                 if (p<128) p=128;
  1556.                   }
  1557.                   *pTemp = (BYTE) p;
  1558.                   pTemp++; pTmp2++;
  1559.  
  1560.                   p=(int) *pTmp2;
  1561.                   if (p<0) p+=256; /* if sign bit was 1 */
  1562.                   if (p<128) {
  1563.                 p -= p*(((int)ulCont)-100)/100;
  1564.                 if (p<0) p=0;
  1565.                 if (p>127) p=127;
  1566.                   }
  1567.                   else {
  1568.                 p += p*(((int)ulCont)-100)/100;
  1569.                 if (p>255) p=255;
  1570.                 if (p<128) p=128;
  1571.                   }
  1572.                   *pTemp = (BYTE) p;
  1573.  
  1574.                   pTemp++; pTmp2++;
  1575.                   pTemp++; pTmp2++;
  1576.                 }
  1577.  
  1578.                 DiveSetSourcePalette ( pwinData->hDive,0, 256, (PBYTE) pPalette );
  1579.               }
  1580.               break;
  1581.               }
  1582.         }
  1583.         break;
  1584.  
  1585.           case WM_COMMAND:
  1586.               switch (LOUSHORT(mp1))
  1587.         {
  1588.         case IDC_PLAY:
  1589.  
  1590.           WinPostMsg (pwinData->hwndFrame, WM_COMMAND,
  1591.             (PVOID)ID_PLAY, 0L );
  1592.             /*    WinEnableWindow (hWndFrame, FALSE);
  1593.             WinDlgBox (HWND_DESKTOP, hWnd, WinInfoDlgProc,
  1594.                 0L, IDD_WININFO, NULL);
  1595.             WinEnableWindow (hWndFrame, TRUE);
  1596.             */
  1597.             break;
  1598.  
  1599.         case IDC_PAUSE:
  1600.           WinPostMsg (pwinData->hwndFrame, WM_COMMAND,
  1601.             (PVOID)ID_PAUSE, 0L );
  1602.           break;
  1603.  
  1604.         case IDC_RESET:
  1605.           WinPostMsg (pwinData->hwndFrame, WM_COMMAND,
  1606.             (PVOID)ID_RESET, 0L );
  1607.           break;
  1608.  
  1609.         case IDC_ADVANCE:
  1610.           WinPostMsg (pwinData->hwndFrame, WM_COMMAND,
  1611.             (PVOID)ID_ADVANCE, 0L );
  1612.           break;
  1613.  
  1614.         case IDC_UNDO:
  1615.           memcpy(pPalette, pPal2, 256*sizeof(ULONG));
  1616.           DiveSetSourcePalette ( pwinData->hDive,0, 256, (PBYTE) pPalette );
  1617.          WinSendDlgItemMsg(hWnd, IDC_RED, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1618.         (MPARAM) 0L);
  1619.         WinSendDlgItemMsg(hWnd, IDC_GREEN, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1620.         (MPARAM) 0L);
  1621.         WinSendDlgItemMsg(hWnd, IDC_BLUE, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1622.         (MPARAM) 0L);
  1623.         WinSendDlgItemMsg(hWnd, IDC_BRIGHTNESS, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1624.         (MPARAM) 0L);
  1625.         WinSendDlgItemMsg(hWnd, IDC_CONTRAST, SPBM_SETCURRENTVALUE, (MPARAM) 100L,
  1626.         (MPARAM) 0L);
  1627.           break;
  1628.  
  1629.  
  1630.            case IDC_DIVEINFO:
  1631.  
  1632.           /* Get the screen capabilities, and display them
  1633.           ** in the dialog box.
  1634.           */
  1635.           DiveCaps.pFormatData = fccFormats;
  1636.           DiveCaps.ulFormatLength = 120;
  1637.           DiveCaps.ulStructLen = sizeof(DIVE_CAPS);
  1638.  
  1639.           if ( DiveQueryCaps ( &DiveCaps, DIVE_BUFFER_SCREEN ))
  1640.              {
  1641.              WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  1642.              (PSZ)"usage: DIMP failed to get screen capabilities.",
  1643.              (PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
  1644.              break;
  1645.              }
  1646.  
  1647.           WinDlgBox ( HWND_DESKTOP, pwinData->hwndClient,
  1648.                    DiveDlgProc, (HMODULE)0,
  1649.                    ID_DIALOG, (PVOID)pwinData );
  1650.  
  1651.  
  1652.           break;
  1653.  
  1654.            case IDC_MPEGINFO:
  1655.  
  1656.           WinDlgBox ( HWND_DESKTOP, pwinData->hwndClient,
  1657.                    MpegDlgProc, (HMODULE)0,
  1658.                    ID_DIALOG2, (PVOID)pwinData );
  1659.  
  1660.           break;
  1661.         }
  1662.         break;
  1663.  
  1664.     default:
  1665.        bHandled = FALSE;
  1666.        break;
  1667.     }
  1668.  
  1669.  
  1670.     if (!bHandled)
  1671.     mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);
  1672.  
  1673.     return (mReturn);
  1674. }
  1675.  
  1676.  
  1677. MRESULT EXPENTRY UsageDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  1678.    {
  1679.    switch( msg )
  1680.       {
  1681.       case WM_INITDLG:
  1682.      WinSetFocus(HWND_DESKTOP,hwndDlg);
  1683.      break;
  1684.  
  1685.       case WM_COMMAND:
  1686.      switch ( SHORT1FROMMP ( mp1 ) )
  1687.         {
  1688.         case DID_OK:
  1689.  
  1690.            WinDismissDlg ( hwndDlg, TRUE );
  1691.            break;
  1692.         }
  1693.       default:
  1694.      return ( WinDefDlgProc (hwndDlg, msg, mp1, mp2) );
  1695.  
  1696.       }
  1697.    }
  1698.  
  1699. MRESULT EXPENTRY DiveDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  1700.    {
  1701.    CHAR      string[10];
  1702.    CHAR      *pString;
  1703.  
  1704.    switch( msg )
  1705.       {
  1706.       case WM_INITDLG:
  1707.  
  1708.      if ( !DiveCaps.fScreenDirect )
  1709.         WinSetDlgItemText ( hwndDlg, ID_EF_11, "NO" );
  1710.      else
  1711.         WinSetDlgItemText ( hwndDlg, ID_EF_11, "YES" );
  1712.  
  1713.      if ( !DiveCaps.fBankSwitched )
  1714.         WinSetDlgItemText ( hwndDlg, ID_EF_12, "NO" );
  1715.      else
  1716.         WinSetDlgItemText ( hwndDlg, ID_EF_12, "YES" );
  1717.  
  1718.      pString = _ultoa ( DiveCaps.ulDepth, string, 10 );
  1719.      WinSetDlgItemText ( hwndDlg, ID_EF_13, pString );
  1720.  
  1721.      pString = _ultoa ( DiveCaps.ulHorizontalResolution,
  1722.                  string, 10 );
  1723.      WinSetDlgItemText ( hwndDlg, ID_EF_14, pString );
  1724.  
  1725.      pString = _ultoa ( DiveCaps.ulVerticalResolution, string, 10 );
  1726.      WinSetDlgItemText ( hwndDlg, ID_EF_15, pString );
  1727.  
  1728.      pString = _ultoa ( DiveCaps.ulScanLineBytes, string, 10 );
  1729.      WinSetDlgItemText ( hwndDlg, ID_EF_16, pString );
  1730.  
  1731.      switch (DiveCaps.fccColorEncoding)
  1732.         {
  1733.         case FOURCC_LUT8:
  1734.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "256" );
  1735.            break;
  1736.         case FOURCC_R565:
  1737.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "64K" );
  1738.            break;
  1739.         case FOURCC_R555:
  1740.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "32K" );
  1741.            break;
  1742.         case FOURCC_R664:
  1743.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "64K" );
  1744.            break;
  1745.         case FOURCC_RGB3:
  1746.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "16M" );
  1747.            break;
  1748.         case FOURCC_BGR3:
  1749.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "16M" );
  1750.            break;
  1751.         case FOURCC_RGB4:
  1752.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "16M" );
  1753.            break;
  1754.         case FOURCC_BGR4:
  1755.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "16M" );
  1756.            break;
  1757.         default:
  1758.            WinSetDlgItemText ( hwndDlg, ID_EF_17, "???" );
  1759.         } /* endswitch */
  1760.  
  1761.      pString = _ultoa ( DiveCaps.ulApertureSize, string, 10 );
  1762.      WinSetDlgItemText ( hwndDlg, ID_EF_18, pString );
  1763.  
  1764.      pString = _ultoa ( DiveCaps.ulInputFormats, string, 10 );
  1765.      WinSetDlgItemText ( hwndDlg, ID_EF_19, pString );
  1766.  
  1767.      pString = _ultoa ( DiveCaps.ulOutputFormats, string, 10 );
  1768.      WinSetDlgItemText ( hwndDlg, ID_EF_20, pString );
  1769.      WinSetFocus(HWND_DESKTOP,hwndDlg);
  1770.      break;
  1771.  
  1772.       case WM_COMMAND:
  1773.      switch ( SHORT1FROMMP ( mp1 ) )
  1774.         {
  1775.         case DID_OK:
  1776.  
  1777.            WinDismissDlg ( hwndDlg, TRUE );
  1778.            break;
  1779.         }
  1780.  
  1781.       default:
  1782.      return ( WinDefDlgProc (hwndDlg, msg, mp1, mp2) );
  1783.  
  1784.       }
  1785.    }
  1786.  
  1787. MRESULT EXPENTRY MpegDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  1788.    {
  1789.    CHAR      string[10];
  1790.    CHAR      *pString;
  1791.  
  1792.    switch( msg )
  1793.       {
  1794.       case WM_INITDLG:
  1795.      pString = _ultoa (theVidStream->h_size, string, 10 );
  1796.      WinSetDlgItemText ( hwndDlg, ID_EF_21, pString );
  1797.      pString = _ultoa (theVidStream->v_size, string, 10 );
  1798.      WinSetDlgItemText ( hwndDlg, ID_EF_22, pString );
  1799.      pString = _ultoa (theVidStream->mb_height, string, 10 );
  1800.      WinSetDlgItemText ( hwndDlg, ID_EF_23, pString );
  1801.      pString = _ultoa (theVidStream->mb_width, string, 10 );
  1802.      WinSetDlgItemText ( hwndDlg, ID_EF_24, pString );
  1803.      pString = _ultoa (theVidStream->aspect_ratio, string, 10 );
  1804.      WinSetDlgItemText ( hwndDlg, ID_EF_25, pString );
  1805.      pString = _ultoa (theVidStream->picture_rate, string, 10 );
  1806.      WinSetDlgItemText ( hwndDlg, ID_EF_26, pString );
  1807.      pString = _ultoa (theVidStream->bit_rate, string, 10 );
  1808.      WinSetDlgItemText ( hwndDlg, ID_EF_27, pString );
  1809.      pString = _ultoa (theVidStream->vbv_buffer_size, string, 10 );
  1810.      WinSetDlgItemText ( hwndDlg, ID_EF_28, pString );
  1811.      WinSetFocus(HWND_DESKTOP,hwndDlg);
  1812.      break;
  1813.  
  1814.       case WM_COMMAND:
  1815.      switch ( SHORT1FROMMP ( mp1 ) )
  1816.         {
  1817.         case DID_OK:
  1818.  
  1819.            WinDismissDlg ( hwndDlg, TRUE );
  1820.            break;
  1821.         }
  1822.       default:
  1823.      return ( WinDefDlgProc (hwndDlg, msg, mp1, mp2) );
  1824.  
  1825.       }
  1826.    }
  1827.  
  1828.  
  1829. MRESULT EXPENTRY AboutDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1830. {
  1831.     BOOL    bHandled = TRUE;
  1832.     MRESULT mReturn  = 0;
  1833.     ULONG   ulScrWidth, ulScrHeight;
  1834.     RECTL   Rectl;
  1835.     SWP     Swp;
  1836.     HPS     hps;
  1837.  
  1838.     switch (msg)
  1839.     {           
  1840.     case WM_INITDLG:
  1841.  
  1842.         /* Center dialog on screen */
  1843.         ulScrWidth  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
  1844.         ulScrHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
  1845.         WinQueryWindowRect (hWnd, &Rectl);
  1846.         WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight)/2,
  1847.         (ulScrHeight-Rectl.yTop)/2, 0, 0, SWP_MOVE | SWP_ACTIVATE);
  1848.  
  1849.         /* Set application title */
  1850.         WinSetDlgItemText (hWnd, 10001, (PSZ)mp2);
  1851.         break;
  1852.  
  1853.     case WM_PAINT:
  1854.  
  1855.         hps = WinBeginPaint (hWnd,0,0);
  1856.         WinQueryWindowRect (hWnd, &Rectl);
  1857.         WinFillRect (hps, &Rectl, CLR_PALEGRAY);
  1858.         WinDrawBorder (hps, &Rectl, 
  1859.         WinQuerySysValue(HWND_DESKTOP,SV_CXDLGFRAME), 
  1860.         WinQuerySysValue(HWND_DESKTOP,SV_CYDLGFRAME), 
  1861.         CLR_DARKGRAY, CLR_WHITE, DB_RAISED);
  1862.         GpiMove (hps, (PPOINTL)&Rectl);
  1863.         Rectl.xRight--;
  1864.         Rectl.yTop--;
  1865.         GpiBox (hps, DRO_OUTLINE, (PPOINTL)&Rectl.xRight, 0L, 0L);
  1866.         WinQueryWindowPos (WinWindowFromID (hWnd, 10002), &Swp);
  1867.         Rectl.xLeft   = Swp.x-1;
  1868.         Rectl.yBottom = Swp.y-1;
  1869.         Rectl.xRight  = Swp.x + Swp.cx + 1;
  1870.         Rectl.yTop    = Swp.y + Swp.cy + 1;
  1871.         WinDrawBorder (hps, &Rectl, 1L, 1L,
  1872.         CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
  1873.         WinQueryWindowPos (WinWindowFromID (hWnd, 10003), &Swp);
  1874.         Rectl.xLeft   = Swp.x-1;
  1875.         Rectl.yBottom = Swp.y-1;
  1876.         Rectl.xRight  = Swp.x + Swp.cx + 1;
  1877.         Rectl.yTop    = Swp.y + Swp.cy + 1;
  1878.         WinDrawBorder (hps, &Rectl, 1L, 1L,
  1879.         CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
  1880.         WinEndPaint (hps);
  1881.         break;
  1882.  
  1883.           case WM_COMMAND:
  1884.         WinDismissDlg (hWnd, DID_OK);
  1885.         break;
  1886.  
  1887.     default:
  1888.         bHandled = FALSE;
  1889.         break;
  1890.     }
  1891.  
  1892.     if (!bHandled)
  1893.     mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);
  1894.  
  1895.     return (mReturn);
  1896. }
  1897.  
  1898.  
  1899. #ifdef ANALYSIS
  1900.  
  1901. MRESULT EXPENTRY OneStatDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  1902.    {
  1903.    CHAR      string[10];
  1904.    CHAR      *pString;
  1905.    switch( msg )
  1906.       {
  1907.       case WM_INITDLG:
  1908.        {
  1909.      RECTL   Rectl;
  1910.      WinQueryWindowRect (HWND_DESKTOP, &Rectl);
  1911.      WinSetWindowPos (hwndDlg, 0, Rectl.xLeft+5, Rectl.yBottom, 0L, 0L,
  1912.           SWP_MOVE | SWP_SHOW);
  1913.       }
  1914.       break;
  1915.       case WM_SHOWSTAT:
  1916. {  int i;
  1917.    static Statval *stat_a;
  1918.    GetStats(&stat_a);
  1919.  
  1920.   switch (stat_a[0].frametype) {
  1921.   case I_TYPE:
  1922.     WinSetDlgItemText ( hwndDlg, IE_FRAME, "I FRAME" );
  1923.     break;
  1924.   case P_TYPE:
  1925.     WinSetDlgItemText ( hwndDlg, IE_FRAME, "P FRAME" );
  1926.     break;
  1927.   case B_TYPE:
  1928.     WinSetDlgItemText ( hwndDlg, IE_FRAME, "B FRAME" );
  1929.     break;
  1930.   }
  1931.  
  1932.   pString = _ultoa (stat_a[0].totsize /8, string, 10 );
  1933.   WinSetDlgItemText ( hwndDlg, IE_BYTES, pString );
  1934.   pString = _ultoa (stat_a[0].totsize % 8, string, 10 );
  1935.   WinSetDlgItemText ( hwndDlg, IE_BITS, pString );
  1936.  
  1937.   if (stat_a[0].i_mbnum > 0) {
  1938.   pString = _ultoa (stat_a[0].i_mbnum, string, 10 );
  1939.   WinSetDlgItemText ( hwndDlg, IE_I, pString );
  1940.  
  1941.   pString = _ultoa (stat_a[0].i_mbsize / (8 * stat_a[0].i_mbnum), string, 10 );
  1942.   WinSetDlgItemText ( hwndDlg, IE_IBYTES, pString );
  1943.   pString = _ultoa ( (stat_a[0].i_mbsize * stat_a[0].i_mbnum) % 8, string, 10 );
  1944.   WinSetDlgItemText ( hwndDlg, IE_IBITS, pString );
  1945.  
  1946.   }
  1947.   else {
  1948.   WinSetDlgItemText ( hwndDlg, IE_I, "0" );
  1949.   WinSetDlgItemText ( hwndDlg, IE_IBYTES, "" );
  1950.   WinSetDlgItemText ( hwndDlg, IE_IBITS, "" );
  1951.   }
  1952.   if (stat_a[0].p_mbnum > 0) {
  1953.  
  1954.   pString = _ultoa (stat_a[0].p_mbnum, string, 10 );
  1955.   WinSetDlgItemText ( hwndDlg, IE_P, pString );
  1956.  
  1957.   pString = _ultoa (stat_a[0].p_mbsize / (8 * stat_a[0].p_mbnum), string, 10 );
  1958.   WinSetDlgItemText ( hwndDlg, IE_PBYTES, pString );
  1959.   pString = _ultoa ( (stat_a[0].p_mbsize * stat_a[0].p_mbnum) % 8, string, 10 );
  1960.   WinSetDlgItemText ( hwndDlg, IE_PBITS, pString );
  1961.  
  1962.   }
  1963.  
  1964.   else {
  1965.   WinSetDlgItemText ( hwndDlg, IE_P, "0" );
  1966.   WinSetDlgItemText ( hwndDlg, IE_PBYTES, "" );
  1967.   WinSetDlgItemText ( hwndDlg, IE_PBITS, "" );
  1968.   }
  1969.   if (stat_a[0].b_mbnum > 0) {
  1970.  
  1971.   pString = _ultoa (stat_a[0].b_mbnum, string, 10 );
  1972.   WinSetDlgItemText ( hwndDlg, IE_B, pString );
  1973.  
  1974.   pString = _ultoa (stat_a[0].b_mbsize / (8 * stat_a[0].b_mbnum), string, 10 );
  1975.   WinSetDlgItemText ( hwndDlg, IE_BBYTES, pString );
  1976.   pString = _ultoa ( (stat_a[0].b_mbsize * stat_a[0].b_mbnum) % 8, string, 10 );
  1977.   WinSetDlgItemText ( hwndDlg, IE_BBITS, pString );
  1978.  
  1979.   }
  1980.  
  1981.   else {
  1982.   WinSetDlgItemText ( hwndDlg, IE_B, "0" );
  1983.   WinSetDlgItemText ( hwndDlg, IE_BBYTES, "" );
  1984.   WinSetDlgItemText ( hwndDlg, IE_BBITS, "" );
  1985.   }
  1986.   if (stat_a[0].bi_mbnum > 0) {
  1987.   pString = _ultoa (stat_a[0].bi_mbnum, string, 10 );
  1988.   WinSetDlgItemText ( hwndDlg, IE_BI, pString );
  1989.  
  1990.   pString = _ultoa (stat_a[0].bi_mbsize / (8 * stat_a[0].bi_mbnum), string, 10 );
  1991.   WinSetDlgItemText ( hwndDlg, IE_BIBYTES, pString );
  1992.   pString = _ultoa ( (stat_a[0].bi_mbsize * stat_a[0].bi_mbnum) % 8, string, 10 );
  1993.   WinSetDlgItemText ( hwndDlg, IE_BIBITS, pString );
  1994.  
  1995.   }
  1996.  
  1997.   else {
  1998.   WinSetDlgItemText ( hwndDlg, IE_BI, "0" );
  1999.   WinSetDlgItemText ( hwndDlg, IE_BIBYTES, "" );
  2000.   WinSetDlgItemText ( hwndDlg, IE_BIBITS, "" );
  2001.   }
  2002.   sprintf(string,"%2.3g",(double)stat_a[0].tottime);
  2003.   WinSetDlgItemText ( hwndDlg, IE_TIME, (CHAR*)string );
  2004.  
  2005.   printf("\nTime to Decode: %g secs.\n", stat_a[0].tottime);
  2006.   printf("****************\n");
  2007. }
  2008.      break;
  2009.  
  2010.       default:
  2011.      return ( WinDefDlgProc (hwndDlg, msg, mp1, mp2) );
  2012.  
  2013.       }
  2014.    }
  2015.  
  2016.  
  2017. MRESULT EXPENTRY AllStatDlgProc ( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  2018.    {
  2019.    CHAR      string[10];
  2020.    CHAR      *pString;
  2021.    switch( msg )
  2022.       {
  2023.       case WM_INITDLG:
  2024.        {
  2025.      RECTL   Rectl;
  2026.      WinQueryWindowRect (HWND_DESKTOP, &Rectl);
  2027.      WinSetWindowPos (hwndDlg, 0, Rectl.xLeft+5, Rectl.yBottom+290, 0L, 0L,
  2028.           SWP_MOVE);
  2029.       }
  2030.       break;
  2031.       case WM_SHOWALL:
  2032. {
  2033.   int i, j;
  2034.   unsigned int supertot, supernum;
  2035.   double supertime;
  2036.  
  2037.   static Statval *stat_a;
  2038.   GetStats(&stat_a);
  2039.  
  2040.   /* I-frames */
  2041.   pString = _ultoa (stat_a[1].number, string, 10 );
  2042.   WinSetDlgItemText ( hwndDlg, IA_I, pString );
  2043.  
  2044.   if (stat_a[1].number != 0) {
  2045.     pString = _ultoa ( stat_a[1].totsize / (8 * stat_a[1].number), string, 10 );
  2046.     WinSetDlgItemText ( hwndDlg, IA_IBYTES, pString );
  2047.     pString = _ultoa ( (stat_a[1].totsize / stat_a[1].number) % 8, string, 10 );
  2048.     WinSetDlgItemText ( hwndDlg, IA_IBITS, pString );
  2049.   }
  2050.   /* P-frames */
  2051.   pString = _ultoa (stat_a[2].number, string, 10 );
  2052.   WinSetDlgItemText ( hwndDlg, IA_P, pString );
  2053.  
  2054.   if (stat_a[2].number != 0) {
  2055.     pString = _ultoa ( stat_a[2].totsize / (8 * stat_a[2].number), string, 10 );
  2056.     WinSetDlgItemText ( hwndDlg, IA_PBYTES, pString );
  2057.     pString = _ultoa ( (stat_a[2].totsize / stat_a[2].number) % 8, string, 10 );
  2058.     WinSetDlgItemText ( hwndDlg, IA_PBITS, pString );
  2059.   }
  2060.   /* B-frames */
  2061.   pString = _ultoa (stat_a[3].number, string, 10 );
  2062.   WinSetDlgItemText ( hwndDlg, IA_B, pString );
  2063.  
  2064.   if (stat_a[3].number != 0) {
  2065.     pString = _ultoa ( stat_a[3].totsize / (8 * stat_a[3].number), string, 10 );
  2066.     WinSetDlgItemText ( hwndDlg, IA_BBYTES, pString );
  2067.     pString = _ultoa ( (stat_a[3].totsize / stat_a[3].number) % 8, string, 10 );
  2068.     WinSetDlgItemText ( hwndDlg, IA_BBITS, pString );
  2069.   }
  2070.  
  2071.   supertot = stat_a[1].totsize + stat_a[2].totsize + stat_a[3].totsize;
  2072.   supernum = stat_a[1].number + stat_a[2].number + stat_a[3].number;
  2073.   supertime = stat_a[1].tottime + stat_a[2].tottime + stat_a[3].tottime;
  2074.  
  2075.   pString = _ultoa ( supernum, string, 10 );
  2076.   WinSetDlgItemText ( hwndDlg, IA_TOTFRAMES, pString );
  2077.  
  2078.   pString = _ultoa ( supertot / (8 * supernum), string, 10 );
  2079.   WinSetDlgItemText ( hwndDlg, IA_TOTBYTES, pString );
  2080.  
  2081.   pString = _ultoa (( supertot / supernum) % 8, string, 10 );
  2082.   WinSetDlgItemText ( hwndDlg, IA_TOTBITS, pString );
  2083.  
  2084.   sprintf(string,"%2.3g",supertime );
  2085.   WinSetDlgItemText ( hwndDlg, IA_TOTTIME, string );
  2086.  
  2087.   sprintf(string,"%2.3g",supertime / ((double) supernum));
  2088.   WinSetDlgItemText ( hwndDlg, IA_DECTIME, string );
  2089.  
  2090.   sprintf(string,"%2.3g",((double) supernum) / supertime);
  2091.   WinSetDlgItemText ( hwndDlg, IA_DECFRAMES, string );
  2092.  
  2093.  
  2094.   }
  2095.        break;
  2096.  
  2097.       default:
  2098.      return ( WinDefDlgProc (hwndDlg, msg, mp1, mp2) );
  2099.  
  2100.       }
  2101.    }
  2102.  
  2103. static void ShowOneStat()
  2104. {
  2105.    WinPostMsg(pwinData->hwndOneStat, WM_SHOWSTAT, 0L, 0L);
  2106. }
  2107.  
  2108.  
  2109. static void ShowAllStats()
  2110. {
  2111.    WinPostMsg(pwinData->hwndAllStat, WM_SHOWALL, 0L, 0L);
  2112. }
  2113.  
  2114. #endif
  2115.