home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d571 / gwin.lha / Gwin / Examples / bug-e.c < prev    next >
C/C++ Source or Header  |  1991-12-22  |  3KB  |  147 lines

  1.  
  2. /*
  3.  
  4.   bug-e
  5.  
  6.   by Howard C. Anderson
  7.  
  8.   A program to demonstrate an Amiga bug involving an
  9.   interaction between AreaEllipse, AreaMove,
  10.   AreaDraw, and AreaEnd.
  11.  
  12.   Symptoms:   AreaEllipse works fine until
  13.   an AreaMove, AreaDraw, AreaEnd sequence is issued.
  14.   After that, AreaEllipse produces strange results.
  15.   Results shown here are only one type of strange
  16.   result.  We have seen many others.
  17.  
  18.  
  19. Makefile for Manx 5.0:
  20.  bug-e: bug-e.o
  21.       ln bug-e.o -lmfl -lcl
  22.  
  23.  bug-e.o: bug-e.c
  24.       cc -mc -md -ff bug-e.c
  25.  
  26.  
  27. */
  28.  
  29. #include <exec/types.h>
  30. #include <graphics/gfxbase.h>
  31. #include <graphics/display.h>
  32. #include <graphics/regions.h>
  33. #include <graphics/gfx.h>
  34. #include <graphics/gfxmacros.h>
  35. #include <intuition/intuitionbase.h>
  36. #include <intuition/intuition.h>
  37. #include <stdio.h>
  38. #include <exec/memory.h>
  39. #include <math.h>
  40.  
  41. extern struct IntuitionBase *OpenLibrary();
  42. extern struct Window *OpenWindow();
  43. extern struct InitTmpRas *TmpRas();
  44.  
  45. #define INTUITION_REV 29
  46.  
  47. struct IntuitionBase *IntuitionBase;
  48. struct Window *NoBorder;
  49. struct GfxBase *GfxBase;
  50. struct RastPort *r;
  51.  
  52. struct Border lines={0,0,
  53.                      5,0,
  54.                      JAM1,
  55.                      5,
  56.                      NULL,
  57.                      NULL};
  58.  
  59. struct NewWindow mywindow = {0,0,640,200,-1,-1,NULL,
  60.                           ACTIVATE|SMART_REFRESH|BORDERLESS,
  61.                           NULL,NULL,NULL,NULL,
  62.                           NULL,0,0,0,0,WBENCHSCREEN};
  63.  
  64. struct AreaInfo myareainfo;
  65. UBYTE *areabuffer;
  66. static int rastad[1];
  67. static struct TmpRas TRas[6];
  68. float x,y;
  69. int error;
  70. char ikey;
  71. int ievent,loop;
  72.  
  73.  
  74. main()
  75. {
  76. int i;
  77.    IntuitionBase = (struct IntuitionBase *)
  78.       OpenLibrary("intuition.library",29);
  79.  
  80.    if(IntuitionBase == NULL) exit(FALSE);
  81.  
  82.    GfxBase = (struct GfxBase *)
  83.       OpenLibrary("graphics.library",29);
  84.  
  85.    if(GfxBase == NULL) exit(FALSE);
  86.  
  87.    NoBorder = (struct Window *) OpenWindow(&mywindow);
  88.  
  89.    r = NoBorder->RPort;
  90.  
  91.    areabuffer = (UBYTE *)AllocMem(10000,MEMF_CLEAR);
  92.  
  93.    InitArea(&myareainfo,areabuffer,1000);
  94.    r->AreaInfo = &myareainfo;
  95.    rastad[0] = AllocMem(32000,MEMF_CHIP);
  96.  
  97.    if(rastad[0] == 0){
  98.       printf("Can't allocate temporary raster space.\n");
  99.       exit(1);
  100.    }
  101.  
  102.    InitTmpRas(&TRas[0],rastad[0],
  103.               RASSIZE(200,200));
  104.    r->TmpRas = &TRas[0];
  105.  
  106.    SetRGB4(r,2);
  107.  
  108.    for(i=0;i<100;i++){
  109.       SetAPen(r,i%4);
  110.       drawstuff();
  111.    }
  112.  
  113.    CloseWindow(NoBorder);
  114.  
  115.    FreeMem(rastad[0],32000);
  116.    FreeMem(areabuffer,10000);
  117.  
  118.  
  119. }
  120.  
  121. drawstuff()
  122. {
  123. int j;
  124.       AreaEllipse(r,50,60,30,40);
  125.       AreaEnd(r);
  126.  
  127.       AreaMove(r,300,100);
  128.       AreaDraw(r,300+20,100);
  129.       AreaDraw(r,300+20,100+20);
  130.       AreaDraw(r,300,100+20);
  131.       AreaDraw(r,300,100);
  132.  
  133.       AreaEnd(r);
  134.  
  135. /* The following two lines, when uncommented,  fix the bug */
  136. /*      FreeMem(areabuffer,10000); */
  137. /*      areabuffer = (UBYTE *)AllocMem(10000,MEMF_CLEAR); */
  138.  
  139.       AreaEllipse(r,580,60,30,40);
  140.       AreaEnd(r);
  141.       AreaEllipse(r,580,150,30,40);
  142.       AreaEnd(r);
  143.       AreaEllipse(r,50,150,30,40);
  144.       AreaEnd(r);
  145. }
  146.  
  147.