Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site amiga.amiga.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!nsc!pyramid!amiga!dale From: dale@amiga.UUCP (Dale Luck) Newsgroups: net.micro.amiga Subject: source from Amiga Message-ID: <135@amiga.amiga.UUCP> Date: Wed, 23-Oct-85 21:22:36 EDT Article-I.D.: amiga.135 Posted: Wed Oct 23 21:22:36 1985 Date-Received: Fri, 25-Oct-85 02:58:24 EDT References: <489@puff.UUCP> Reply-To: dale@tooter.UUCP (Dale Luck) Distribution: net Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030 Lines: 155 Since there is no net.sources.amiga at this time I am taking the liberty of dropping this demo on ya'all. It is a copy of source to one of the simple graphics demos. This was available on the Amiga support bulletin board about 1 month ago. If there is going to be good quantity of amiga source shared then maybe the powers that be should consider a source.amiga group. We are still a little timid about using this net. We do not want to abuse it. Suggestions and encouragement are welcome. This listing is a few pages. Good luck and have fun. Dale Luck #include #include #include #include #include #include #include #include #include #include struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; #define DEPTH 2 #define WIDTH 100 #define HEIGHT 50 int waiting_for_message = FALSE; char dotty[] = "Dotty Window"; int usable_width(w) struct Window *w; { return (w->Width - w->BorderLeft - w->BorderRight); } int usable_height(w) struct Window *w; { return(w->Height - w->BorderTop - w->BorderBottom); } main() { struct RastPort *rp; struct Window *window; struct NewWindow nw; int x,y,c; int xoffset,yoffset; int width,height; struct IntuiMessage *message; ULONG MessageClass; if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",1))) { printf("no graphics library!!!\n"); exit(1); } if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",1)) ) { CloseLibrary(GfxBase); printf("no intuition here!!\n"); exit(1); } nw.LeftEdge = 50; nw.TopEdge = 50; nw.Width = WIDTH; nw.Height = HEIGHT; nw.DetailPen = -1; nw.BlockPen = -1; nw.IDCMPFlags = CLOSEWINDOW | REFRESHWINDOW | SIZEVERIFY | NEWSIZE; nw.Flags = WINDOWDEPTH | WINDOWSIZING | WINDOWDRAG | WINDOWCLOSE | SIMPLE_REFRESH; nw.FirstGadget = NULL; nw.CheckMark = NULL; nw.Title = dotty; nw.Screen = NULL; nw.BitMap = NULL; nw.MinHeight = 10; nw.MinWidth = 10; nw.MaxHeight = 200; nw.MaxWidth = 640; nw.Type = WBENCHSCREEN; if (!(window = (struct Window *)OpenWindow(&nw) )) { printf("could not open the window\n"); CloseLibrary(IntuitionBase); CloseLibrary(GfxBase); exit(2); } width = usable_width(window); height = usable_height(window); rp = window->RPort; xoffset = window->BorderLeft; yoffset = window->BorderTop; while (TRUE) /* do this forever, or until user gets bored */ { while (!(message = (struct IntuiMessage *)GetMsg(window->UserPort)) ) { if (waiting_for_message) Wait(1<UserPort->mp_SigBit); else { x = RangeRand(width); y = RangeRand(height); c = RangeRand(32); SetAPen(rp,c); WritePixel(rp,xoffset+x,yoffset+y); } } MessageClass = message->Class; ReplyMsg(message); switch (MessageClass) { case CLOSEWINDOW : CloseWindow(window); CloseLibrary(IntuitionBase); CloseLibrary(GfxBase); exit(0); case SIZEVERIFY : waiting_for_message = TRUE; break; case REFRESHWINDOW: BeginRefresh(window); SetAPen(rp,0); /* should not have to recalculate these */ width = usable_width(window); height = usable_height(window); RectFill(rp,xoffset,yoffset, xoffset+width-1,yoffset+height-1); EndRefresh(window,TRUE); break; case NEWSIZE : waiting_for_message = FALSE; width = usable_width(window); height = usable_height(window); break; } } } end of source listing