home *** CD-ROM | disk | FTP | other *** search
-
- /*
-
- bug-e
-
- by Howard C. Anderson
-
- A program to demonstrate an Amiga bug involving an
- interaction between AreaEllipse, AreaMove,
- AreaDraw, and AreaEnd.
-
- Symptoms: AreaEllipse works fine until
- an AreaMove, AreaDraw, AreaEnd sequence is issued.
- After that, AreaEllipse produces strange results.
- Results shown here are only one type of strange
- result. We have seen many others.
-
-
- Makefile for Manx 5.0:
- bug-e: bug-e.o
- ln bug-e.o -lmfl -lcl
-
- bug-e.o: bug-e.c
- cc -mc -md -ff bug-e.c
-
-
- */
-
- #include <exec/types.h>
- #include <graphics/gfxbase.h>
- #include <graphics/display.h>
- #include <graphics/regions.h>
- #include <graphics/gfx.h>
- #include <graphics/gfxmacros.h>
- #include <intuition/intuitionbase.h>
- #include <intuition/intuition.h>
- #include <stdio.h>
- #include <exec/memory.h>
- #include <math.h>
-
- extern struct IntuitionBase *OpenLibrary();
- extern struct Window *OpenWindow();
- extern struct InitTmpRas *TmpRas();
-
- #define INTUITION_REV 29
-
- struct IntuitionBase *IntuitionBase;
- struct Window *NoBorder;
- struct GfxBase *GfxBase;
- struct RastPort *r;
-
- struct Border lines={0,0,
- 5,0,
- JAM1,
- 5,
- NULL,
- NULL};
-
- struct NewWindow mywindow = {0,0,640,200,-1,-1,NULL,
- ACTIVATE|SMART_REFRESH|BORDERLESS,
- NULL,NULL,NULL,NULL,
- NULL,0,0,0,0,WBENCHSCREEN};
-
- struct AreaInfo myareainfo;
- UBYTE *areabuffer;
- static int rastad[1];
- static struct TmpRas TRas[6];
- float x,y;
- int error;
- char ikey;
- int ievent,loop;
-
-
- main()
- {
- int i;
- IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library",29);
-
- if(IntuitionBase == NULL) exit(FALSE);
-
- GfxBase = (struct GfxBase *)
- OpenLibrary("graphics.library",29);
-
- if(GfxBase == NULL) exit(FALSE);
-
- NoBorder = (struct Window *) OpenWindow(&mywindow);
-
- r = NoBorder->RPort;
-
- areabuffer = (UBYTE *)AllocMem(10000,MEMF_CLEAR);
-
- InitArea(&myareainfo,areabuffer,1000);
- r->AreaInfo = &myareainfo;
- rastad[0] = AllocMem(32000,MEMF_CHIP);
-
- if(rastad[0] == 0){
- printf("Can't allocate temporary raster space.\n");
- exit(1);
- }
-
- InitTmpRas(&TRas[0],rastad[0],
- RASSIZE(200,200));
- r->TmpRas = &TRas[0];
-
- SetRGB4(r,2);
-
- for(i=0;i<100;i++){
- SetAPen(r,i%4);
- drawstuff();
- }
-
- CloseWindow(NoBorder);
-
- FreeMem(rastad[0],32000);
- FreeMem(areabuffer,10000);
-
-
- }
-
- drawstuff()
- {
- int j;
- AreaEllipse(r,50,60,30,40);
- AreaEnd(r);
-
- AreaMove(r,300,100);
- AreaDraw(r,300+20,100);
- AreaDraw(r,300+20,100+20);
- AreaDraw(r,300,100+20);
- AreaDraw(r,300,100);
-
- AreaEnd(r);
-
- /* The following two lines, when uncommented, fix the bug */
- /* FreeMem(areabuffer,10000); */
- /* areabuffer = (UBYTE *)AllocMem(10000,MEMF_CLEAR); */
-
- AreaEllipse(r,580,60,30,40);
- AreaEnd(r);
- AreaEllipse(r,580,150,30,40);
- AreaEnd(r);
- AreaEllipse(r,50,150,30,40);
- AreaEnd(r);
- }
-
-