home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <graphics/gfx.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
- #include <graphics/gfxmacros.h>
-
-
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/graphics_pragmas.h>
- #include <pragmas/intuition_pragmas.h>
-
- #include <clib/exec_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/diskfont_protos.h>
-
- #include "gfx_pragmas.h"
- #include "graphics.h"
-
- /* could be any bitmap you want, see pic4.c */
- #include "pic1.c"
- #include "pic2.c"
- #include "pic3.c"
- #include "pic4.c"
-
- //#define Custom
-
- struct IntuitionBase *IntuitionBase=NULL;
- struct Library *GfxBase=NULL,*AslBase=NULL;
- struct Library *GspGfxBase=NULL,*GraphicsBase=NULL,*DiskfontBase=NULL;
- struct Screen *screen;
- struct Window *window=NULL,*window2,*window3;
- struct RastPort *RP;
- struct Rectangle *bounds;
- struct ClipRect *cliprect;
- long x0,y0,x1,y1;
- BOOL Amiga = FALSE;
-
- void CleanUp(void);
- void TestFunction(void);
-
- void main(int argc,char *argv[])
- {
- int i;
- struct TextFont *txtfnt;
- struct TextAttr mytxt;
-
- onbreak(CleanUp);
-
- if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L))) CleanUp();
- if (!(GfxBase = (struct Library *)OpenLibrary("graphics.library",0L))) CleanUp();
- if (!(GraphicsBase = (struct Library *)OpenLibrary("gfx.library",0L))) CleanUp();
-
- for (i = 1; i <= argc; i++)
- if (strncmp(argv[i],"ami",3)==0) Amiga=TRUE;
-
- window=(struct Window *)OpenWindowTags(NULL,
- WA_Title,"Test",
- WA_DragBar,TRUE,
- WA_AutoAdjust,TRUE,
- WA_Left,0,
- WA_Top,0,
- WA_Width,640,
- WA_Height,400,
- WA_MinWidth,256,
- WA_MinHeight,256,
- WA_MaxWidth,2000,
- WA_MaxHeight,2000,
- WA_DepthGadget,TRUE,
- WA_CloseGadget,TRUE,
- WA_SizeGadget,TRUE,
- WA_IDCMP,IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE,
- #ifdef Custom
- WA_CustomScreen,screen,
- #endif
- TAG_DONE);
-
- TestFunction();
-
- CleanUp();
- }
-
- void CleanUp(void)
- {
- if (window) CloseWindow(window);
-
- if (GraphicsBase) CloseLibrary(GraphicsBase);
- if (GfxBase) CloseLibrary(GfxBase);
- if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
- if (DiskfontBase) CloseLibrary(DiskfontBase);
-
- exit(0);
- }
-
- int event(void)
- {
- struct IntuiMessage *message;
-
- chkabort();
- if(window->UserPort->mp_SigBit)
- {
- if (message = (struct IntuiMessage *)GetMsg(window->UserPort))
- {
- switch(message->Class)
- {
- case CLOSEWINDOW:
- ReplyMsg((struct Message *)message);
- return(0);
- case NEWSIZE:
- ReplyMsg((struct Message *)message);
- return(1);
- }
- }
- }
- return(1);
- }
-
- void TestFunction(void)
- {
- #define AREA_SIZE 200
-
- USHORT areaptrn[] = { 0xf0f0, /*0*/ 0x0f0f, /*1*/ 0xf0f0, 0xf0f0, /*2*/ 0x0f0f, 0x0f0f, 0xf0f0, 0xf0f0,/*3*/
- 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF /*4*/ };
-
- struct BitMap *bm;
- struct Screen *sc;
- WORD areabuffer[AREA_SIZE];
- struct AreaInfo areainfo = {0};
- PLANEPTR planebuffer;
- long planesize;
- struct TmpRas tmpras;
- int i,x,y,x0,y0,width,height;
-
- if (Amiga)
- {
- bm = window->RPort->BitMap;
- do
- {
- x0 = window->LeftEdge;
- y0 = window->TopEdge;
- width = window->Width;
- height = window->Height;
-
- x = (rand() % (width-pic1_width))+x0;
- y = (rand() % (height-pic1_height))+y0;
- BltBitMap(&pic1,0,0,bm,x,y,pic1_width,pic1_height,0xc0,~0,NULL);
-
- x = (rand() % (width-pic2_width))+x0;
- y = (rand() % (height-pic2_height))+y0;
- BltBitMap(&pic2,0,0,bm,x,y,pic2_width,pic2_height,0xc0,~0,NULL);
-
- x = (rand() % (width-pic3_width))+x0;
- y = (rand() % (height-pic3_height))+y0;
- BltBitMap(&pic3,0,0,bm,x,y,pic3_width,pic3_height,0xc0,~0,NULL);
-
- x = (rand() % (width-pic4_width))+x0;
- y = (rand() % (height-pic4_height))+y0;
- BltBitMap(&pic4,0,0,bm,x,y,pic4_width,pic4_height,0xc0,~0,NULL);
- }while (event());
- }
- else
- {
- sc = IntuitionBase->ActiveScreen;
- bm = sc->RastPort.BitMap;
- GfxSetUpScreen(sc);
- do
- {
- x0 = window->LeftEdge;
- y0 = window->TopEdge;
- width = window->Width;
- height = window->Height;
-
- // pic1.Depth = 4;
- x = (rand() % (width-pic1_width))+x0;
- y = (rand() % (height-pic1_height))+y0;
- GfxBltBitMap(&pic1,0,0,bm,x,y,pic1_width,pic1_height,0xc0,~0,NULL);
-
- x = (rand() % (width-pic2_width))+x0;
- y = (rand() % (height-pic2_height))+y0;
- GfxBltBitMap(&pic2,0,0,bm,x,y,pic2_width,pic2_height,0xc0,~0,NULL);
-
- x = (rand() % (width-pic3_width))+x0;
- y = (rand() % (height-pic3_height))+y0;
- GfxBltBitMap(&pic3,0,0,bm,x,y,pic3_width,pic3_height,0xc0,~0,NULL);
-
- x = (rand() % (width-pic4_width))+x0;
- y = (rand() % (height-pic4_height))+y0;
- GfxBltBitMap(&pic4,0,0,bm,x,y,pic4_width,pic4_height,0xc0,~0,NULL);
-
- }while (event());
- }
- }