home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CD32 / CD32_Support / examples / SA_Examples / graphics / wchunky / wchunky.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-17  |  35.0 KB  |  1,294 lines

  1. /*
  2.     wchunky.c -- Mark Dolecki
  3.     Program to test WritePixelArray8 on new hardware
  4. */
  5.  
  6. /* Includes */
  7. #include <exec/types.h>
  8. #include <exec/memory.h>
  9. #include <graphics/gfx.h>
  10. #include <graphics/gfxbase.h>
  11. #include <graphics/gfxmacros.h>
  12. #include <graphics/rastport.h>
  13. #include <graphics/displayinfo.h>
  14. #include <intuition/intuition.h>
  15. #include <intuition/classes.h>
  16. #include <intuition/classusr.h>
  17. #include <intuition/gadgetclass.h>
  18. #include <intuition/intuitionbase.h>
  19. #include <intuition/screens.h>
  20. #include <libraries/asl.h>
  21. #include <libraries/gadtools.h>
  22. #include <clib/alib_protos.h>
  23. #include <clib/alib_stdio_protos.h>
  24. #include <clib/asl_protos.h>
  25. #include <clib/dos_protos.h>
  26. #include <clib/exec_protos.h>
  27. #include <clib/gadtools_protos.h>
  28. #include <clib/graphics_protos.h>
  29. #include <clib/intuition_protos.h>
  30. #include <clib/layers_protos.h>
  31. #include <stddef.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34.  
  35. #include <pragmas/exec_pragmas.h>
  36. #include <pragmas/intuition_pragmas.h>
  37. #include <pragmas/gadtools_pragmas.h>
  38. #include <pragmas/graphics_pragmas.h>
  39.  
  40. /* Defines */
  41. #define DEBUG TRUE
  42. #define NUMWINS 10
  43. #define MAXDEPTH 8
  44. #define NUMREFRESH 3
  45. #define RECTWIDTH 10
  46. #define RECTHEIGHT 10
  47.  
  48. #define GD_Depth                               0
  49. #define GD_depth1                              1
  50. #define GD_depth2                              2
  51. #define GD_depth3                              3
  52. #define GD_depth4                              4
  53. #define GD_depth5                              5
  54. #define GD_depth6                              6
  55. #define GD_depth7                              7
  56. #define GD_depth8                              8
  57. #define GD_layered                             9
  58. #define GD_nonlayered                          10
  59. #define GD_simple                              11
  60. #define GD_smart                               12
  61. #define GD_super                               13
  62. #define GD_lay                                 14
  63. #define GD_refresh                             15
  64. #define GD_mask                                16
  65. #define GD_ranmask                             17
  66. #define GD_negmask                             18
  67. #define GD_nummasks                            19
  68.  
  69. #define GDX_Depth                              0
  70. #define GDX_depth1                             1
  71. #define GDX_depth2                             2
  72. #define GDX_depth3                             3
  73. #define GDX_depth4                             4
  74. #define GDX_depth5                             5
  75. #define GDX_depth6                             6
  76. #define GDX_depth7                             7
  77. #define GDX_depth8                             8
  78. #define GDX_layered                            9
  79. #define GDX_nonlayered                         10
  80. #define GDX_simple                             11
  81. #define GDX_smart                              12
  82. #define GDX_super                              13
  83. #define GDX_lay                                14
  84. #define GDX_refresh                            15
  85. #define GDX_mask                               16
  86. #define GDX_ranmask                            17
  87. #define GDX_negmask                            18
  88. #define GDX_nummasks                           19
  89.  
  90.  /* Globals */
  91. extern struct ExecBase *SysBase;
  92. struct GadToolsBase *GadToolsBase = NULL;
  93. struct IntuitionBase *IntuitionBase = NULL;
  94. struct GfxBase *GfxBase = NULL;
  95. struct LayersBase *LayersBase = NULL;
  96.  
  97. struct Screen *TestScreen = NULL;
  98. struct Window *TestWins[NUMWINS];
  99. struct RastPort *RPs[NUMWINS];
  100. struct BitMap *TempBMs[NUMWINS];
  101. struct RastPort *TempRPs[NUMWINS];
  102.  
  103. UBYTE *vers = "$VER: wchunky 1.0 (13-May-1993) by Mark Dolecki";
  104.  
  105. /* struct Window *TestWindow1 = NULL;
  106. struct Window *TestWindow2 = NULL;
  107. struct RastPort *rp1 = NULL;
  108. struct RastPort *rp2 = NULL;
  109. struct BitMap   *tempbm1 = NULL;
  110. struct BitMap   *tempbm2 = NULL;
  111. struct RastPort *temprp1 = NULL;
  112. struct RastPort *temprp2 = NULL; */
  113.  
  114. UBYTE *pixelarray = NULL;      /* [((((RECTWIDTH+15)>>4)<<4)*(RECTHEIGHT + 1))]; */
  115. long pixelarraywidth = 0L;
  116. long pixelarrayheight = 0L;
  117. struct ScreenModeRequester *smr;
  118. ULONG PixCheckSum = 0;
  119. int NumTests = 0;
  120. int numbytes = 0;
  121. int depth = 0;
  122. BOOL deptharray[8] = { TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE };
  123. BOOL layerarray[2] = { TRUE,TRUE };
  124. BOOL refresharray[3] = { TRUE,TRUE,TRUE };
  125. BOOL maskarray[2] = { TRUE,TRUE };
  126. int nummasks = 3;
  127. int rectwidth = 10;
  128. int rectheight = 10;
  129.  
  130. struct Screen        *Scr = NULL;
  131. APTR                  VisualInfo = NULL;
  132. struct Window        *WPWnd = NULL;
  133. struct Gadget        *WPGList = NULL;
  134. struct Gadget        *WPGadgets[20];
  135. UWORD                 OffX = 0, OffY = 0;
  136. UWORD                 WPLeft = 1;
  137. UWORD                 WPTop = 11;
  138. UWORD                 WPWidth = 286;
  139. UWORD                 WPHeight = 147;
  140. UBYTE                *WPWdt = (UBYTE *)"WChunky";
  141. struct TextAttr      *Font = NULL, Attr;
  142. UWORD                 FontX = 0, FontY = 0;
  143. UWORD                 OffX, OffY;
  144.  
  145. /* Function Protos */
  146. void dPrintf(char *s);
  147. void unclipWindow(struct Window *);
  148. struct Region *clipWindowToBorders(struct Window *win);
  149. struct Region *clipWindow(struct Window *,LONG,LONG,LONG,LONG);
  150. int SetupScreen( void );
  151. void CloseDownScreen( void );
  152. int OpenWPWindow( void );
  153. void CloseWPWindow( void );
  154. void OpenLibs(void);
  155. void CloseLibs(void);
  156. void ChooseScreenMode(void);
  157. void KillTestWindow(struct Window *, struct RastPort *, struct BitMap *);
  158. ULONG GetChecksum(struct Window *);
  159. void PrintScreenAttrs(struct Screen *);
  160. void showTestParams(int,int,int,int,int,ULONG, ULONG);
  161. void allocatePixelArray(struct Window *);
  162. void freePixelArray(void);
  163. void initPixelArray(void);
  164. void DoPlot(struct Window *, struct RastPort *, struct RastPort *);
  165. void DoTest(int,int,int,int,int);
  166. void showSelections(void);
  167. void QUIT(void);
  168. extern void KPrintF(STRPTR,...);
  169.  
  170. /*----------------------------------------------------------------------------
  171. ----------------------------------------------------------------------------*/
  172.  
  173.  
  174. /*----------------------------------------------------------------------------
  175.     OpenLibs() -
  176.         Input -
  177.             none
  178.         Function -
  179.             Opens all necessary disk and rom based libraries.
  180. ----------------------------------------------------------------------------*/
  181. void OpenLibs()
  182. {
  183.     if (! (IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L))) {
  184.         dPrintf("Couldn't open intuition.library\n");
  185.         QUIT();
  186.     }
  187.     if (! (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",36L))) {
  188.         dPrintf("Couldn't open graphics.library\n");
  189.         QUIT();
  190.     }
  191.     if (! (GadToolsBase = (struct GadToolsBase *)OpenLibrary("gadtools.library",0L))) {
  192.         dPrintf("Couldn't open gadtools.library\n");
  193.         QUIT();
  194.     }
  195.     if (! (LayersBase = (struct LayersBase *)OpenLibrary("layers.library",0L))) {
  196.         dPrintf("Couldn't open layers.library\n");
  197.         QUIT();
  198.     }
  199. }
  200.  
  201.  
  202. /*----------------------------------------------------------------------------
  203.     CloseLibs()
  204.     Input -
  205.         none
  206.     Function -
  207.         Close all opened libraries.
  208. ----------------------------------------------------------------------------*/
  209. void CloseLibs()
  210. {
  211.     if (LayersBase ) {
  212.         CloseLibrary((struct Library *)LayersBase);
  213.     }
  214.     if (GadToolsBase) {
  215.         CloseLibrary((struct Library *)GadToolsBase);
  216.     }
  217.     if (GfxBase) {
  218.         CloseLibrary((struct Library *)GfxBase);
  219.     }
  220.     if (IntuitionBase) {
  221.         CloseLibrary((struct Library *)IntuitionBase);
  222.     }
  223. }
  224.  
  225.  
  226. /*----------------------------------------------------------------------------
  227.     dPrintf()
  228.     Input -
  229.         char *s
  230.     Function -
  231.         print a string to stdout and out the serial port
  232. ----------------------------------------------------------------------------*/
  233. void dPrintf(char *s)
  234. {
  235.     KPrintF("%s",s);
  236.     printf("%s",s);
  237. }
  238.  
  239.  
  240. /*----------------------------------------------------------------------------
  241.     ChooseScreenMode() -
  242.         Input -
  243.         Function -
  244.             Open an ASL screenmode requester to allow user to select screen mode
  245.             for the test.
  246. ----------------------------------------------------------------------------*/
  247. void ChooseScreenMode()
  248. {
  249.     if (!(smr = (struct ScreenModeRequester *)AllocAslRequestTags( ASL_ScreenModeRequest,
  250.         ASLSM_TitleText, "Choose Screen Mode",
  251.         TAG_DONE ))) {
  252.         dPrintf("Could not allocate asl request tags\n");
  253.         QUIT();
  254.     }
  255.     if (!(AslRequest(smr,0L))) {
  256.         dPrintf("No screen mode chosen - program aborted.\n");
  257.         FreeAslRequest(smr);
  258.         QUIT();
  259.     }
  260. }
  261.  
  262.  
  263. /*----------------------------------------------------------------------------
  264.     KillTestWindow() -
  265.         Input -
  266.             struct Window *wnd
  267.             struct RastPort *rp
  268.             struct BitMap *bm
  269.         Function -
  270.             Generic function that:
  271.                 Sets RastPort Write Mask to -1 (default)
  272.                 Frees memory allocated for bitmap planes
  273.                 Frees memory allocated for bitmap
  274.                 Frees memory allocated for rastport
  275.                 Closes window
  276. ----------------------------------------------------------------------------*/
  277. void KillTestWindow(struct Window *wnd,struct RastPort *rp, struct BitMap *bm)
  278. {
  279.     int i = 0;
  280.     LONG mask = -1;
  281.  
  282.     if (rp) {
  283.         SetWrMsk(rp, (ULONG)mask);
  284.     }
  285.     if (wnd) {
  286.         if (rp) {
  287.             rp->BitMap = NULL;
  288.             FreeMem(rp,sizeof(struct RastPort));
  289.         }
  290.         if (bm) {
  291.             for (i = 0; i < depth; i++) {
  292.                 if (bm->Planes[i]) {
  293.                     FreeRaster((PLANEPTR)bm->Planes[i],(ULONG)wnd->Width, (ULONG)wnd->Height);
  294.                 }
  295.          }
  296.             FreeMem(bm,sizeof(struct BitMap));
  297.         }
  298.        CloseWindow(wnd);
  299.     }
  300. }
  301.  
  302.  
  303. /*----------------------------------------------------------------------------
  304.     GetChecksum() -
  305.         Input -
  306.             struct Window *win
  307.         Function -
  308.             Calculates the checksum of all pixels in given window
  309. ----------------------------------------------------------------------------*/
  310. ULONG GetChecksum(struct Window *win)
  311. {
  312.     int x = 0;
  313.     int y = 0;
  314.     register ULONG checksum = 0;
  315.     register ULONG tmp = 0;
  316.     register ULONG tmp2 = 0;
  317.  
  318.     for (x = 0; x <= (win->Width); x++) {
  319.         for (y = 0; y <= (win->Height); y++) {
  320.             tmp = checksum << 1;
  321.             tmp2 = (checksum & 0x80000000) >> 31;
  322. /*            KPrintF("tmp = 0x%08lx,tmp2 = 0x%08lx\n",tmp,tmp2); */
  323.             checksum = tmp + tmp2 + (ULONG)ReadPixel(win->RPort,x,y);
  324.         }
  325.     }
  326.     return(checksum);
  327. }
  328.  
  329.  
  330. /*----------------------------------------------------------------------------
  331.     PrintScrAttrs() -
  332.         Input -
  333.             struct Screen *scr
  334.         Function -
  335.             Prints out info about given screen structure
  336. ----------------------------------------------------------------------------*/
  337. void PrintScrAttrs(struct Screen *scr)
  338. {
  339.     if (scr) {
  340.         printf("\tscr->LeftEdge   %ld\n",scr->LeftEdge);
  341.         KPrintF("\tscr->LeftEdge   %ld\n",scr->LeftEdge);
  342.         printf("\tscr->TopEdge    %ld\n",scr->TopEdge);
  343.         KPrintF("\tscr->TopEdge    %ld\n",scr->TopEdge);
  344.         printf("\tscr->Width      %ld\n",scr->Width);
  345.         KPrintF("\tscr->Width      %ld\n",scr->Width);
  346.         printf("\tscr->Height     %ld\n",scr->Height);
  347.         KPrintF("\tscr->Height     %ld\n",scr->Height);
  348.         printf("\tscr->Flags      %ld\n",scr->Flags);
  349.         KPrintF("\tscr->Flags      %ld\n",scr->Flags);
  350.         printf("\tscr->WBorTop    %ld\n",scr->WBorTop);
  351.         KPrintF("\tscr->WBorTop    %ld\n",scr->WBorTop);
  352.         printf("\tscr->WBorLeft   %ld\n",scr->WBorLeft);
  353.         KPrintF("\tscr->WBorLeft   %ld\n",scr->WBorLeft);
  354.         printf("\tscr->WBorRight  %ld\n",scr->WBorRight);
  355.         KPrintF("\tscr->WBorRight  %ld\n",scr->WBorRight);
  356.         printf("\tscr->WBorBottom %ld\n",scr->WBorBottom );
  357.         KPrintF("\tscr->WBorBottom %ld\n",scr->WBorBottom );
  358.     }
  359. }
  360.  
  361.  
  362. /*----------------------------------------------------------------------------
  363.     allocatePixelArray()
  364.         Function -
  365.             Allocates memory for the Pixel Array
  366. ----------------------------------------------------------------------------*/
  367. void allocatePixelArray(struct Window *win)
  368. {
  369.     pixelarraywidth = RangeRand(win->Width - 1) + 1;
  370.     pixelarrayheight = RangeRand(win->Height - 1) + 1;
  371.     KPrintF("\tpixelarraywidth = %ld, pixelarrayheight = %ld\n",pixelarraywidth,pixelarrayheight);
  372.     printf("\tpixelarraywidth = %ld, pixelarrayheight = %ld\n",pixelarraywidth,pixelarrayheight);
  373.     pixelarray = (UBYTE *)AllocMem(sizeof(long) * (((pixelarraywidth + 15) >> 4) << 4) * (pixelarrayheight + 1), MEMF_CHIP | MEMF_CLEAR);
  374.     if (! pixelarray) {
  375.         dPrintf("Couldn't allocate memory for pixelarray\n");
  376.         QUIT();
  377.     }
  378.  
  379.     initPixelArray();
  380. }
  381.  
  382.  
  383. /*----------------------------------------------------------------------------
  384.     freePixelArray
  385.         Function - free memory allocated for Pixel Array
  386. ----------------------------------------------------------------------------*/
  387. void freePixelArray()
  388. {
  389.     if (pixelarray) {
  390.         FreeMem(pixelarray, sizeof(long) * (((pixelarraywidth + 15) >> 4) << 4) * (pixelarrayheight + 1));
  391.         pixelarray = NULL;
  392.         pixelarraywidth = 0;
  393.         pixelarrayheight = 0;
  394.     }
  395. }
  396.  
  397.  
  398. /*----------------------------------------------------------------------------
  399.     initPixelArray()
  400.     Input -
  401.         UBYTE *pixelarray
  402.         int rectwidth
  403.         int rectheight
  404.     Function -
  405.         To initialize or re-initialize the pixel array for WritePixelArray8()
  406. ----------------------------------------------------------------------------*/
  407. void initPixelArray()
  408. {
  409.     int i = 0;
  410.     int k = 0;
  411.  
  412.     numbytes = ((((pixelarraywidth+15)>>4)<<4)*(pixelarrayheight + 1));
  413.     for (i = 0; i < numbytes; i++) {
  414.         k++;
  415.         if (k > 255) {
  416.             k = 0;
  417.         }
  418.         pixelarray[i] = k;
  419.     }
  420. }
  421.  
  422.  
  423. /*----------------------------------------------------------------------------
  424.     DoPlot() -
  425.         Input -
  426.             struct Window *win
  427.             struct RastPort *rp
  428.             struct RastPort *tmprp
  429. ----------------------------------------------------------------------------*/
  430. void DoPlot(struct Window *win, struct RastPort *rp, struct RastPort *tmprp) {
  431.     int x = 0;
  432.     int y = 0;
  433.     int i = 0;
  434.     int numplots = 0;
  435.  
  436.     allocatePixelArray(win);
  437.  
  438.     /* Do Random plotting of the pixelarray */
  439.  
  440.     numplots = 1000;
  441.     for (i = 0; i < numplots; i++) {
  442.         x = RangeRand(win->Width);
  443.         y = RangeRand(win->Height);
  444.         if (((pixelarraywidth + x) < win->Width) && ((pixelarrayheight + y) < win->Height)) {
  445.             WriteChunkyPixels(rp, x, y, x + pixelarraywidth, y + pixelarrayheight, pixelarray, pixelarraywidth);
  446.             initPixelArray();
  447.         }
  448.     }
  449.  
  450.     freePixelArray();
  451. }
  452.  
  453.  
  454. /*----------------------------------------------------------------------------
  455.     showTestParams()
  456.         Input -
  457.             int depth
  458.             int layered
  459.             int refresh
  460.             int randomSize
  461.             int maskval
  462.             int wflags
  463.             ULONG Mask
  464. ----------------------------------------------------------------------------*/
  465. void showTestParams(int depth,int layered,int refresh,int randomSize,int maskval,ULONG wflags, ULONG Mask)
  466. {
  467.     dPrintf("Screen Attributes:\n");
  468.     PrintScrAttrs(TestScreen);
  469.  
  470.     KPrintF("%3ld> ", (LONG)depth);
  471.     printf("%3d> ", depth);
  472.  
  473.     switch (layered)
  474.     {
  475.         case 0:
  476.             dPrintf("Non-layered -- ");
  477.             break;
  478.         case 1:
  479.             dPrintf("Layered -- ");
  480.             break;
  481.         default:
  482.             break;
  483.     }
  484.     switch (refresh)
  485.     {
  486.         case 0:
  487.             dPrintf("Simple Refresh -- ");
  488.             wflags = wflags || WFLG_SIMPLE_REFRESH;
  489.             break;
  490.         case 1:
  491.             dPrintf("Smart Refresh -- ");
  492.             wflags = wflags || WFLG_SMART_REFRESH;
  493.             break;
  494.         case 2:
  495.             dPrintf("SuperBitMap -- ");
  496.             wflags = wflags || WFLG_SUPER_BITMAP;
  497.             break;
  498.         default:
  499.             break;
  500.     }
  501.     KPrintF("Mask value = 0x%lx\n",Mask);
  502.     printf("Mask value = 0x%lx\n",Mask);
  503. }
  504.  
  505.  
  506. /*----------------------------------------------------------------------------
  507.     DoTest() -
  508.     Input -
  509.         int depth
  510.         int layered
  511.         int refresh
  512.         int randomSize
  513.         int maskval
  514.     Function -
  515.         Collect all options and perform the test
  516. ----------------------------------------------------------------------------*/
  517. void DoTest(int depth,int layered,int refresh,int randomSize,int maskval)
  518. {
  519.     ULONG wflags = 0;
  520.     LONG Mask = 0;
  521.     int i = 0;
  522.     int k = 0;
  523.  
  524.     KPrintF("Display ID = 0x%08lx\n",(LONG)smr->sm_DisplayID);
  525.     printf("Display ID = 0x%08lx\n",smr->sm_DisplayID);
  526.  
  527.     /* Open Screen with depth of depth */
  528.     if (!(TestScreen = OpenScreenTags(NULL,
  529.         SA_DisplayID, (smr->sm_DisplayID),
  530.         SA_Depth, depth,
  531.         SA_ShowTitle, TRUE,
  532.         SA_Title, "WriteChunkyPixels Test Screen",
  533.           TAG_END)))
  534.     {
  535.           dPrintf("Could not open test screen\n");
  536.         QUIT();
  537.     }
  538.  
  539.     switch (maskval) {
  540.         case 0:
  541.             Mask = RangeRand(255);
  542.             break;
  543.         case 1:
  544.             Mask = -1;
  545.             break;
  546.         default:
  547.             break;
  548.     }
  549.  
  550.     showTestParams(depth,layered,refresh,randomSize,maskval,wflags,Mask);
  551.  
  552.  
  553.     /* Open Windows on the screen */
  554.     for (i = 0; i < NUMWINS; i++) {
  555.         TestWins[i] = OpenWindowTags(NULL,
  556.             WA_Flags, wflags,
  557.             WA_Borderless, FALSE,
  558.             WA_CustomScreen, TestScreen,
  559.             WA_Top, RangeRand(TestScreen->Height),
  560.             WA_Left, RangeRand(TestScreen->Width),
  561.             WA_Width, RangeRand(TestScreen->Width) + 10,
  562.             WA_Height, RangeRand(TestScreen->Height) + 10,
  563.             WA_Title, "TestWindow",
  564.             TAG_END);
  565.         if (! TestWins[i]) {
  566.             KPrintF("Couldn't open test window %ld\n",i);
  567.             printf("Couldn't open test window %ld\n",i);
  568.         }
  569.         else {
  570.             RPs[i] = TestWins[i]->RPort;
  571.             SetWrMsk(RPs[i],Mask);
  572.             TempBMs[i] = (struct BitMap *)AllocMem(sizeof(struct BitMap), MEMF_CHIP || MEMF_CLEAR);
  573.             if    (! TempBMs[i]) {
  574.                 dPrintf("Couldn't allocate temporary bitmap\n");
  575.                 QUIT();
  576.             }
  577.             InitBitMap(TempBMs[i],depth,(LONG)TestWins[i]->Width,(LONG)TestWins[i]->Height);
  578.             TempRPs[i] = (struct RastPort *)AllocMem(sizeof(struct RastPort), MEMF_CHIP || MEMF_CLEAR);
  579.             if (! TempRPs[i]) {
  580.                 QUIT();
  581.             }
  582.             InitRastPort(TempRPs[i]);
  583.             /* copy RPs[i] info to TempRPs[i] */
  584.             TempRPs[i]->AreaPtrn = RPs[i]->AreaPtrn;
  585.             TempRPs[i]->AreaInfo = RPs[i]->AreaInfo;
  586.             TempRPs[i]->GelsInfo = RPs[i]->GelsInfo;
  587.             TempRPs[i]->Mask = RPs[i]->Mask;
  588.             TempRPs[i]->FgPen = RPs[i]->FgPen;
  589.             TempRPs[i]->BgPen = RPs[i]->BgPen;
  590.             TempRPs[i]->AOlPen = RPs[i]->AOlPen;
  591.             TempRPs[i]->DrawMode = RPs[i]->DrawMode;
  592.             TempRPs[i]->AreaPtSz = RPs[i]->AreaPtSz;
  593.             TempRPs[i]->linpatcnt = RPs[i]->linpatcnt;
  594.             TempRPs[i]->Flags = RPs[i]->Flags;
  595.             TempRPs[i]->LinePtrn = RPs[i]->LinePtrn;
  596.             TempRPs[i]->cp_x = RPs[i]->cp_x;
  597.             TempRPs[i]->cp_y = RPs[i]->cp_y;
  598.             TempRPs[i]->PenWidth = RPs[i]->PenWidth;
  599.             TempRPs[i]->PenHeight = RPs[i]->PenHeight;
  600.  
  601.             TempRPs[i]->BitMap = TempBMs[i];
  602.             TempRPs[i]->Layer = NULL;
  603.             TempRPs[i]->BitMap->BytesPerRow = numbytes;
  604.             for (k = 0; k < depth; k++) {
  605.                 TempBMs[i]->Planes[k] = NULL;
  606.             }
  607.             for (k = 0; k < depth; k++) {
  608.                 TempBMs[i]->Planes[k] = (PLANEPTR)AllocRaster((ULONG)TestWins[i]->Width, (ULONG)TestWins[i]->Height);
  609.                 if (!TempBMs[i]->Planes[k]) {
  610.                     KPrintF("Couldn't allocate plane for TempBMs[%ld]\n",i);
  611.                     printf("Couldn't allocate plane for TempBMs[%ld]\n",i);
  612.                     QUIT();
  613.                 }
  614.             }
  615.         }
  616.     }
  617.  
  618.  
  619.  
  620.  
  621.     /**************** Do plotting *******************/
  622.     for (i = 0; i < NUMWINS; i++) {
  623.         if (TestWins[i]) {
  624.             DoPlot(TestWins[i], RPs[i], TempRPs[i]);
  625.             PixCheckSum = GetChecksum(TestWins[i]);
  626.             KPrintF("\tChecksum for Window %ld = 0x%08lx\n",i,PixCheckSum);
  627.             printf("\tChecksum for Window %ld = 0x%08lx\n",i,PixCheckSum);
  628.             PixCheckSum = 0;
  629.         }
  630.     }
  631.  
  632.  
  633.  
  634.     /* Close all of the open windows and the screen */
  635.     dPrintf("Closing Windows...\n");
  636.     Delay(100);
  637.     for (i = 0; i < NUMWINS; i++) {
  638.         if (TestWins[i]) {
  639.             KillTestWindow(TestWins[i], TempRPs[i], TempBMs[i]);
  640.             TestWins[i] = NULL;
  641.             TempRPs[i] = NULL;
  642.             TempBMs[i] = NULL;
  643.             RPs[i] = NULL;
  644.         }
  645.     }
  646.  
  647.     if (TestScreen) {
  648.           CloseScreen(TestScreen);
  649.         TestScreen = NULL;
  650.    }
  651. }
  652.  
  653.  
  654.  
  655. /*----------------------------------------------------------------------------
  656.     QUIT() -
  657.     Input -
  658.         none
  659.     Function -
  660.         Deallocate screen mode requester
  661.         Close Screen
  662.         Close Libraries
  663. ----------------------------------------------------------------------------*/
  664. void QUIT()
  665. {
  666.     int i = 0;
  667.  
  668.     if (smr) {
  669.         FreeAslRequest(smr);
  670.     }
  671.  
  672.     for ( i = 0; i < NUMWINS; i++) {
  673.         if (TestWins[i]) {
  674.             KillTestWindow(TestWins[i], TempRPs[i], TempBMs[i]);
  675.             TestWins[i] = NULL;
  676.             TempRPs[i] = NULL;
  677.             TempBMs[i] = NULL;
  678.             RPs[i] = NULL;
  679.         }
  680.     }
  681.  
  682.     if (pixelarray) {
  683.         freePixelArray();
  684.     }
  685.  
  686.     if (TestScreen) {
  687.           CloseScreen(TestScreen);
  688.         TestScreen = NULL;
  689.    }
  690.     CloseLibs();
  691.  
  692.    exit(0);
  693. }
  694.  
  695.  
  696. /*----------------------------------------------------------------------------
  697.     ComputeX -
  698.     Input -
  699.         UWORD value
  700.     Function -
  701.         Calculate font sensitive X value
  702. ----------------------------------------------------------------------------*/
  703. static UWORD ComputeX( UWORD value )
  704. {
  705.     return(( UWORD )(( FontX * value ) / 8 ));
  706. }
  707.  
  708.  
  709. /*----------------------------------------------------------------------------
  710.     ComputeY -
  711.     Input -
  712.         UWORD value
  713.     Function -
  714.         Calculate font sensitive Y value
  715. ----------------------------------------------------------------------------*/
  716. static UWORD ComputeY( UWORD value )
  717. {
  718.     return(( UWORD )(( FontY * value ) / 8 ));
  719. }
  720.  
  721.  
  722. /*----------------------------------------------------------------------------
  723.     ComputeFont()
  724.     Input -
  725.         UWORD width
  726.         UWORD height
  727.     Function -
  728.         Select font for display
  729. ----------------------------------------------------------------------------*/
  730. static void ComputeFont( UWORD width, UWORD height )
  731. {
  732.     Font = &Attr;
  733.     Font->ta_Name = GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
  734.     Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
  735.     FontX = GfxBase->DefaultFont->tf_XSize;
  736.  
  737.     OffY = Scr->Font->ta_YSize + Scr->WBorTop + 1;
  738.     OffX = Scr->WBorLeft;
  739.  
  740.     if ( width && height ) {
  741.         if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
  742.             goto UseTopaz;
  743.         if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
  744.             goto UseTopaz;
  745.     }
  746.     return;
  747.  
  748. UseTopaz:
  749.     Font->ta_Name = (STRPTR)"topaz.font";
  750.     FontX = FontY = Font->ta_YSize = 8;
  751. }
  752.  
  753.  
  754. /*----------------------------------------------------------------------------
  755.     SetupScreen() -
  756.     Input -
  757.         none
  758.     Function -
  759.         Lock the workbench screen in order to open initial options window
  760.         Choose display font
  761. ----------------------------------------------------------------------------*/
  762. int SetupScreen( void )
  763. {
  764.     if ( ! ( Scr = LockPubScreen((UBYTE * )"Workbench" ))) {
  765.        return( 1L );
  766.     }
  767.  
  768.     ComputeFont( 0L, 0L );
  769.  
  770.     if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE ))) {
  771.         return( 2L );
  772.     }
  773.     return( 0L );
  774. }
  775.  
  776.  
  777. /*----------------------------------------------------------------------------
  778.     CloseDownScreen() -
  779.         Input -
  780.             none
  781.         Function -
  782.             Unlock the workbench screen
  783. ----------------------------------------------------------------------------*/
  784. void CloseDownScreen( void )
  785. {
  786.     if ( VisualInfo ) {
  787.         FreeVisualInfo( VisualInfo );
  788.         VisualInfo = NULL;
  789.     }
  790.  
  791.     if ( Scr        ) {
  792.         UnlockPubScreen( NULL, Scr );
  793.         Scr = NULL;
  794.     }
  795. }
  796.  
  797.  
  798. /*----------------------------------------------------------------------------
  799.     OpenWPWindow()
  800.         Input -
  801.             none
  802.         Function -
  803.             Setup up gadtools gadgets and open the initial test options window
  804. ----------------------------------------------------------------------------*/
  805. int OpenWPWindow( void )
  806. {
  807.     struct NewGadget     ng;
  808.     struct Gadget       *g;
  809.     UWORD               wleft = WPLeft, wtop = WPTop, ww, wh;
  810.  
  811.     ComputeFont( WPWidth, WPHeight );
  812.  
  813.     ww = ComputeX( WPWidth );
  814.     wh = ComputeY( WPHeight );
  815.  
  816.     if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  817.     if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  818.  
  819.     if ( ! ( g = CreateContext( &WPGList )))
  820.         return( 1L );
  821.  
  822.     ng.ng_LeftEdge        =    OffX + ComputeX( 4 );
  823.     ng.ng_TopEdge         =    OffY + ComputeY( 5 );
  824.     ng.ng_Width           =    ComputeX( 45 );
  825.     ng.ng_Height          =    ComputeY( 18 );
  826.     ng.ng_GadgetText      =    NULL;
  827.     ng.ng_TextAttr        =    Font;
  828.     ng.ng_GadgetID        =    GD_Depth;
  829.     ng.ng_Flags           =    0;
  830.     ng.ng_VisualInfo      =    VisualInfo;
  831.  
  832.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Depth:", TAG_DONE );
  833.  
  834.     WPGadgets[ 0 ] = g;
  835.  
  836.     ng.ng_LeftEdge        =    OffX + ComputeX( 63 );
  837.     ng.ng_TopEdge         =    OffY + ComputeY( 6 );
  838.     ng.ng_GadgetText      =    (UBYTE *)"1";
  839.     ng.ng_GadgetID        =    GD_depth1;
  840.     ng.ng_Flags           =    PLACETEXT_BELOW;
  841.  
  842.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  843.  
  844.     WPGadgets[ 1 ] = g;
  845.  
  846.     ng.ng_LeftEdge        =    OffX + ComputeX( 90 );
  847.     ng.ng_GadgetText      =    (UBYTE *)"2";
  848.     ng.ng_GadgetID        =    GD_depth2;
  849.  
  850.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  851.  
  852.     WPGadgets[ 2 ] = g;
  853.  
  854.     ng.ng_LeftEdge        =    OffX + ComputeX( 117 );
  855.     ng.ng_GadgetText      =    (UBYTE *)"3";
  856.     ng.ng_GadgetID        =    GD_depth3;
  857.  
  858.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  859.  
  860.     WPGadgets[ 3 ] = g;
  861.  
  862.     ng.ng_LeftEdge        =    OffX + ComputeX( 144 );
  863.     ng.ng_GadgetText      =    (UBYTE *)"4";
  864.     ng.ng_GadgetID        =    GD_depth4;
  865.  
  866.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  867.  
  868.     WPGadgets[ 4 ] = g;
  869.  
  870.     ng.ng_LeftEdge        =    OffX + ComputeX( 171 );
  871.     ng.ng_GadgetText      =    (UBYTE *)"5";
  872.     ng.ng_GadgetID        =    GD_depth5;
  873.  
  874.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  875.  
  876.     WPGadgets[ 5 ] = g;
  877.  
  878.     ng.ng_LeftEdge        =    OffX + ComputeX( 198 );
  879.     ng.ng_GadgetText      =    (UBYTE *)"6";
  880.     ng.ng_GadgetID        =    GD_depth6;
  881.  
  882.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  883.  
  884.     WPGadgets[ 6 ] = g;
  885.  
  886.     ng.ng_LeftEdge        =    OffX + ComputeX( 225 );
  887.     ng.ng_GadgetText      =    (UBYTE *)"7";
  888.     ng.ng_GadgetID        =    GD_depth7;
  889.  
  890.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  891.  
  892.     WPGadgets[ 7 ] = g;
  893.  
  894.     ng.ng_LeftEdge        =    OffX + ComputeX( 252 );
  895.     ng.ng_GadgetText      =    (UBYTE *)"8";
  896.     ng.ng_GadgetID        =    GD_depth8;
  897.  
  898.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  899.  
  900.     WPGadgets[ 8 ] = g;
  901.  
  902.     ng.ng_LeftEdge        =    OffX + ComputeX( 79 );
  903.     ng.ng_TopEdge         =    OffY + ComputeY( 39 );
  904.     ng.ng_GadgetText      =    (UBYTE *)"Layered";
  905.     ng.ng_GadgetID        =    GD_layered;
  906.     ng.ng_Flags           =    PLACETEXT_RIGHT;
  907.  
  908.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  909.  
  910.     WPGadgets[ 9 ] = g;
  911.  
  912.     ng.ng_TopEdge         =    OffY + ComputeY( 51 );
  913.     ng.ng_GadgetText      =    (UBYTE *)"Non-Layered";
  914.     ng.ng_GadgetID        =    GD_nonlayered;
  915.  
  916.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  917.  
  918.     WPGadgets[ 10 ] = g;
  919.  
  920.     ng.ng_TopEdge         =    OffY + ComputeY( 74 );
  921.     ng.ng_GadgetText      =    (UBYTE *)"Simple Refresh";
  922.     ng.ng_GadgetID        =    GD_simple;
  923.  
  924.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  925.  
  926.     WPGadgets[ 11 ] = g;
  927.  
  928.     ng.ng_TopEdge         =    OffY + ComputeY( 86 );
  929.     ng.ng_GadgetText      =    (UBYTE *)"Smart Refresh";
  930.     ng.ng_GadgetID        =    GD_smart;
  931.  
  932.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  933.  
  934.     WPGadgets[ 12 ] = g;
  935.  
  936.     ng.ng_TopEdge         =    OffY + ComputeY( 98 );
  937.     ng.ng_GadgetText      =    (UBYTE *)"Super Refresh";
  938.     ng.ng_GadgetID        =    GD_super;
  939.  
  940.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  941.  
  942.     WPGadgets[ 13 ] = g;
  943.  
  944.     ng.ng_LeftEdge        =    OffX + ComputeX( 5 );
  945.     ng.ng_TopEdge         =    OffY + ComputeY( 35 );
  946.     ng.ng_Width           =    ComputeX( 45 );
  947.     ng.ng_Height          =    ComputeY( 18 );
  948.     ng.ng_GadgetText      =    NULL;
  949.     ng.ng_GadgetID        =    GD_lay;
  950.     ng.ng_Flags           =    0;
  951.  
  952.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Layered:", TAG_DONE );
  953.  
  954.     WPGadgets[ 14 ] = g;
  955.  
  956.     ng.ng_LeftEdge        =    OffX + ComputeX( 4 );
  957.     ng.ng_TopEdge         =    OffY + ComputeY( 71 );
  958.     ng.ng_GadgetID        =    GD_refresh;
  959.  
  960.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Refresh:", TAG_DONE );
  961.  
  962.     WPGadgets[ 15 ] = g;
  963.  
  964.     ng.ng_TopEdge         =    OffY + ComputeY( 115 );
  965.     ng.ng_GadgetID        =    GD_mask;
  966.  
  967.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Mask:", TAG_DONE );
  968.  
  969.     WPGadgets[ 16 ] = g;
  970.  
  971.     ng.ng_LeftEdge        =    OffX + ComputeX( 79 );
  972.     ng.ng_TopEdge         =    OffY + ComputeY( 120 );
  973.     ng.ng_GadgetText      =    (UBYTE *)"Random Masks";
  974.     ng.ng_GadgetID        =    GD_ranmask;
  975.     ng.ng_Flags           =    PLACETEXT_RIGHT;
  976.  
  977.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  978.  
  979.     WPGadgets[ 17 ] = g;
  980.  
  981.     ng.ng_TopEdge         =    OffY + ComputeY( 132 );
  982.     ng.ng_GadgetText      =    (UBYTE *)"-1 Mask";
  983.     ng.ng_GadgetID        =    GD_negmask;
  984.  
  985.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  986.  
  987. /*    WPGadgets[ 18 ] = g;
  988.  
  989.     ng.ng_LeftEdge        =    OffX + ComputeX( 240 );
  990.     ng.ng_TopEdge         =    OffY + ComputeY( 119 );
  991.     ng.ng_Width           =    ComputeX( 38 );
  992.     ng.ng_Height          =    ComputeY( 13 );
  993.     ng.ng_GadgetText      =    (UBYTE *)"#";
  994.     ng.ng_GadgetID        =    GD_nummasks;
  995.     ng.ng_Flags           =    PLACETEXT_LEFT;
  996.  
  997.     g = CreateGadget( STRING_KIND, g, &ng, GTST_String, "3", GTST_MaxChars, 3, TAG_DONE ); */
  998.  
  999.     WPGadgets[ 18 ] = g;
  1000.  
  1001.     if ( ! g )
  1002.         return( 2L );
  1003.  
  1004.     if ( ! ( WPWnd = OpenWindowTags( NULL,
  1005.                     WA_Left,          wleft,
  1006.                     WA_Top,           wtop,
  1007.                     WA_Width,         ww + OffX + Scr->WBorRight,
  1008.                     WA_Height,        wh + OffY + Scr->WBorBottom,
  1009.                     WA_IDCMP,         TEXTIDCMP|CHECKBOXIDCMP|STRINGIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
  1010.                     WA_Flags,         WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  1011.                     WA_Gadgets,       WPGList,
  1012.                     WA_Title,         WPWdt,
  1013.                     WA_ScreenTitle,   "WPixel",
  1014.                     TAG_DONE )))
  1015.         return( 4L );
  1016.  
  1017.     GT_RefreshWindow( WPWnd, NULL );
  1018.  
  1019.     return( 0L );
  1020. }
  1021.  
  1022.  
  1023. /*----------------------------------------------------------------------------
  1024.     handleWPIDCMP()
  1025.         Input -
  1026.             none
  1027.         Function -
  1028.             Handle the IDCMP event loop for the initial options window
  1029. ----------------------------------------------------------------------------*/
  1030. void handleWPIDCMP(void)
  1031. {
  1032.     struct IntuiMessage *imsg;
  1033.     struct Gadget *gad;
  1034.     int done = FALSE;
  1035.  
  1036.     while (!done)
  1037.     {
  1038.         Wait(1 << WPWnd->UserPort->mp_SigBit);
  1039.         while ((!done) && (imsg =
  1040.         GT_GetIMsg(WPWnd->UserPort)))
  1041.         {
  1042.             if (imsg != NULL)
  1043.             {
  1044.                 GT_ReplyIMsg(imsg);
  1045.                 switch(imsg->Class)
  1046.                 {
  1047.                     case IDCMP_CLOSEWINDOW:
  1048.                         done = TRUE;
  1049.                         break;
  1050.                     case IDCMP_GADGETUP:
  1051.                         gad = (struct Gadget *)imsg->IAddress;
  1052.                         switch(gad->GadgetID)
  1053.                         {
  1054.                             case GD_depth1:
  1055.                                 deptharray[0] = (deptharray[0] == FALSE) ? TRUE : FALSE;
  1056.                                 break;
  1057.                             case GD_depth2:
  1058.                                 deptharray[1] = (deptharray[1] == FALSE) ? TRUE : FALSE;
  1059.                                 break;
  1060.                             case GD_depth3:
  1061.                                 deptharray[2] = (deptharray[2] == FALSE) ? TRUE : FALSE;
  1062.                                 break;
  1063.                             case GD_depth4:
  1064.                                 deptharray[3] = (deptharray[3] == FALSE) ? TRUE : FALSE;
  1065.                                 break;
  1066.                             case GD_depth5:
  1067.                                 deptharray[4] = (deptharray[4] == FALSE) ? TRUE : FALSE;
  1068.                                 break;
  1069.                             case GD_depth6:
  1070.                                 deptharray[5] = (deptharray[5] == FALSE) ? TRUE : FALSE;
  1071.                                 break;
  1072.                             case GD_depth7:
  1073.                                 deptharray[6] = (deptharray[6] == FALSE) ? TRUE : FALSE;
  1074.                                 break;
  1075.                             case GD_depth8:
  1076.                                 deptharray[7] = (deptharray[7] == FALSE) ? TRUE : FALSE;
  1077.                                 break;
  1078.                             case GD_layered:
  1079.                                 layerarray[0] = (layerarray[0] == FALSE) ? TRUE : FALSE;
  1080.                                 break;
  1081.                             case GD_nonlayered:
  1082.                                 layerarray[1] = (layerarray[1] == FALSE) ? TRUE : FALSE;
  1083.                                 break;
  1084.                             case GD_simple:
  1085.                                 refresharray[0] = (refresharray[0] == FALSE) ?  TRUE : FALSE;
  1086.                                 break;
  1087.                             case GD_smart:
  1088.                                 refresharray[1] = (refresharray[1] == FALSE) ?  TRUE : FALSE;
  1089.                                 break;
  1090.                             case GD_super:
  1091.                                 refresharray[2] = (refresharray[2] == FALSE) ?  TRUE : FALSE;
  1092.                                 break;
  1093.                             case GD_ranmask:
  1094.                                 maskarray[0] = (maskarray[0] == FALSE) ? TRUE : FALSE;
  1095.                                 break;
  1096.                             case GD_negmask:
  1097.                                 maskarray[1] = (maskarray[1] == FALSE) ? TRUE : FALSE;
  1098.                                 break;
  1099. /*                            case GD_nummasks:
  1100.                                 break; */
  1101.                             default:
  1102.                                 break;
  1103.                         }
  1104.                        break;
  1105.                     case IDCMP_REFRESHWINDOW:
  1106.                         GT_BeginRefresh(WPWnd);
  1107.                         GT_EndRefresh(WPWnd,TRUE);
  1108.                         break;
  1109.                     default:
  1110.                         break;
  1111.                 }
  1112.             }
  1113.         }
  1114.     }
  1115. }
  1116.  
  1117.  
  1118. /*----------------------------------------------------------------------------
  1119.     CloseWPWindow()
  1120.     Input -
  1121.         none
  1122.     Function -
  1123.         Close the initial options window and free its gadgets
  1124. ----------------------------------------------------------------------------*/
  1125. void CloseWPWindow( void )
  1126. {
  1127.     if ( WPWnd        ) {
  1128.         CloseWindow( WPWnd );
  1129.         WPWnd = NULL;
  1130.     }
  1131.  
  1132.     if ( WPGList      ) {
  1133.         FreeGadgets( WPGList );
  1134.         WPGList = NULL;
  1135.     }
  1136. }
  1137.  
  1138.  
  1139. /*----------------------------------------------------------------------------
  1140.     showSelections()
  1141.     Input -
  1142.         none
  1143.     Function -
  1144.         Display user choices for test parameters
  1145. ----------------------------------------------------------------------------*/
  1146. void showSelections()
  1147. {
  1148.     int i = 0;
  1149.  
  1150.     /* print out results of user selections */
  1151.  
  1152.     dPrintf("\tdepths selected = ");
  1153.     for (i = 0; i < 8; i++) {
  1154.         if (deptharray[i]) {
  1155.             KPrintF("%ld ",i + 1);
  1156.             printf("%ld ",i + 1);
  1157.         }
  1158.     }
  1159.  
  1160.     dPrintf("\n\tLayer types selected = ");
  1161.     if (layerarray[0]) {
  1162.         dPrintf("Layered ");
  1163.     }
  1164.     if (layerarray[1]) {
  1165.         dPrintf("Non-layered ");
  1166.     }
  1167.  
  1168.     dPrintf("\n\tMasks selected = ");
  1169.     if (maskarray[0]) {
  1170.         dPrintf("Random ");
  1171.     }
  1172.     if (maskarray[1]) {
  1173.         dPrintf("-1 ");
  1174.     }
  1175.  
  1176.     dPrintf("\n\tRefresh modes selected = ");
  1177.     for (i = 0; i < 3; i++) {
  1178.         if (refresharray[i]) {
  1179.             switch(i) {
  1180.                 case 0:
  1181.                     dPrintf("Simple ");
  1182.                     break;
  1183.                 case 1:
  1184.                     dPrintf("Smart ");
  1185.                     break;
  1186.                 case 2:
  1187.                     dPrintf("Super ");
  1188.                     break;
  1189.                 default:
  1190.                     break;
  1191.             }
  1192.         }
  1193.     }
  1194.     dPrintf("\n");
  1195. }
  1196.  
  1197.  
  1198. /*----------------------------------------------------------------------------
  1199.     DoUserSelect()
  1200.     Input -
  1201.         none
  1202.     Function -
  1203.         Open the initial options window, get the options, and then display them.
  1204. ----------------------------------------------------------------------------*/
  1205. void DoUserSelect(void)
  1206. {
  1207.     SetupScreen();
  1208.     OpenWPWindow();
  1209.     handleWPIDCMP();
  1210.     CloseWPWindow();
  1211.     CloseDownScreen();
  1212. }
  1213.  
  1214.  
  1215. /*----------------------------------------------------------------------------
  1216.     DoAll()
  1217.     Input -
  1218.         none
  1219.     Function -
  1220.         Setup up test options so that all choices are picked.
  1221.         Display the options chosen.
  1222. ----------------------------------------------------------------------------*/
  1223. void DoAll(void)
  1224. {
  1225.     int i = 0;
  1226.  
  1227.     for (i = 0; i < 8; i++) {
  1228.         deptharray[i] = TRUE;
  1229.     }
  1230.     for (i = 0; i < 2; i++) {
  1231.         layerarray[i] = TRUE;
  1232.     }
  1233.     for (i = 0; i < 3; i++) {
  1234.         refresharray[i] = TRUE;
  1235.     }
  1236.     for (i = 0; i < 2; i++) {
  1237.         maskarray[i] = TRUE;
  1238.     }
  1239. }
  1240.  
  1241.  
  1242. /*----------------------------------------------------------------------------
  1243. ==============================================================================
  1244.     main()
  1245.         Input -
  1246.             int argc
  1247.             char **argv
  1248.         Function -
  1249.             main entry point
  1250. ==============================================================================
  1251. ----------------------------------------------------------------------------*/
  1252. void main(int argc, char **argv)
  1253. {
  1254.     int layered = 0;
  1255.     int refresh = 0;
  1256.     int randomSize = 0;
  1257.     int maskval = 0;
  1258.  
  1259.     OpenLibs();
  1260.  
  1261.  
  1262.     dPrintf("\n *** wchunky v1.0 - WriteChunkyPixels test ***\n");
  1263.  
  1264.     if (argc >= 2) {
  1265.         if (0 == strcmp(argv[1],"all")) {
  1266.             DoAll();
  1267.         }
  1268.     }
  1269.     else {
  1270.         DoUserSelect();
  1271.     }
  1272.  
  1273.     showSelections();
  1274.     ChooseScreenMode();
  1275.  
  1276.     /* The 'tie up the machine' test */
  1277.     for (depth = 1; depth <= 8; depth++) {
  1278.         for (layered = 0; layered < 2; layered++) {
  1279.             for (refresh = 0; refresh < NUMREFRESH; refresh++) {
  1280.                 for (maskval = 0; maskval < 2; maskval++) {
  1281.                     if ((deptharray[depth - 1]) && (layerarray[layered]) && (refresharray[refresh]) && (maskarray[maskval])) {
  1282.                         NumTests++;
  1283.                         DoTest(depth, layered, refresh, randomSize, maskval);
  1284.                     }
  1285.                 }
  1286.             }
  1287.         }
  1288.     }
  1289.  
  1290.     KPrintF("total tests = %ld\n", (LONG)NumTests);
  1291.     printf("total tests = %ld\n", (LONG)NumTests);
  1292.  
  1293.     QUIT();
  1294. }