home *** CD-ROM | disk | FTP | other *** search
- /* This was written way back in Dec. 86 for Lattice C under WB 1.1 */
- /* It may work if re-compiled under other compilers or versions of */
- /* Kickstart, but then again.... */
-
- /* Besides, it works as is under 1.2.... just type "All4096" */
-
-
- /* 'C' Header files required */
-
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <graphics/gfxbase.h>
- #include <graphics/display.h>
- #include <lattice/stdio.h>
-
-
- #define WE_SURVIVED 0 /* My names for exit codes */
- #define NO_INTUITION 1
- #define NO_GRAPHICS 2
- #define NO_MAKEE_SCREEN 3
- #define NO_MAKEE_WINDOW 4
-
-
- struct IntuitionBase *IntuitionBase; /* These are all pointers to system */
- struct GfxBase *GfxBase; /* data structures I need access to */
- struct RastPort *drawport;
- struct ViewPort *my_view;
-
- #define INTUITION_REV 0 /* yeah, yeah... I know */
- #define MILLION 1000000
-
- struct NewScreen my_screen_needs= /* This is the structure I pass to */
- { /* the OpenScreen() function to */
- 0, /* open my own screen */
- 0,
- 320,
- 200,
- 6,
- 0, 1,
- HAM,
- CUSTOMSCREEN,
- NULL,
- "4096, count em, 4096 colours!",
- NULL,
- NULL
- };
-
- main()
- {
- struct Screen *my_screen_pointer;/* This will point at my new screen */
- struct NewWindow my_window_needs;/* This is my window request structure*/
- struct Window *my_window_pointer;/* Will point at my new window */
- long i,x,y,y2;
-
- IntuitionBase= /* Open up Intuition... */
- (struct IntuitionBase *)OpenLibrary("intuition.library",INTUITION_REV);
- if(IntuitionBase==NULL) exit(NO_INTUITION);
-
- GfxBase= /* ...and the Graphics Library... */
- (struct GfxBase *)OpenLibrary("graphics.library",0);
- if(GfxBase==NULL)
- {
- CloseLibrary(IntuitionBase);
- exit(NO_GRAPHICS);
- };
-
- my_screen_pointer= /* ...and a new screen... */
- (struct Screen *)OpenScreen(&my_screen_needs);
- if (my_screen_pointer==NULL)
- {
- CloseLibrary(GfxBase);
- CloseLibrary(IntuitionBase);
- exit(NO_MAKEE_SCREEN);
- };
-
-
- my_window_needs.LeftEdge=0; /* setting my requirements */
- my_window_needs.TopEdge=11;
- my_window_needs.Width=280;
- my_window_needs.Height=173;
- my_window_needs.DetailPen=0;
- my_window_needs.BlockPen=1;
- my_window_needs.Title="Blitter Assisted Jet Takeoff!";
- my_window_needs.Flags=
- SMART_REFRESH | WINDOWCLOSE | ACTIVATE | NOCAREREFRESH |
- WINDOWDRAG;
- my_window_needs.IDCMPFlags= CLOSEWINDOW;
- my_window_needs.Type=CUSTOMSCREEN;
- my_window_needs.FirstGadget=NULL;
- my_window_needs.CheckMark=NULL;
- my_window_needs.Screen=my_screen_pointer; /* link it to my new screen */
- my_window_needs.BitMap=NULL;
- my_window_needs.MinWidth=278;
- my_window_needs.MinHeight=173;
- my_window_needs.MaxWidth=278;
- my_window_needs.MaxHeight=173;
-
- /* ...and open the bastard!*/
- if ( (my_window_pointer=(struct Window *)OpenWindow(&my_window_needs))
- == NULL)
- {
- CloseScreen(my_screen_pointer);
- CloseLibrary(GfxBase);
- CloseLibrary(IntuitionBase);
- exit(NO_MAKEE_WINDOW);
- };
- my_view=&my_screen_pointer->ViewPort; /* extract ViewPort pointer...*/
- drawport=my_window_pointer->RPort; /* and RastPort pointer */
-
-
- /* AND LET THE GAMES BEGIN!!! */
-
- WritePixel(drawport,5,11); /* First pixel */
-
- /* first draw a 17 pixel line using HAM & going from no to full blue */
- for(x=6;x<22;x++)
- {
- SetAPen(drawport,(x-6)+16);
- WritePixel(drawport,x,11);
- };
-
- /* now Blitterize it - copy it sixteen times across the screen */
- for(x=1;x<16;x++)
- BltBitMap(drawport->BitMap,5,22,
- drawport->BitMap,5+(x*17),22,
- 17,1,
- 0xca,0xff,NULL);
-
- /* change every 17'th pixel to a different red value */
- for(x=0;x<16;x++)
- {
- SetAPen(drawport,x+32);
- WritePixel(drawport,5+(x*17),11);
- };
-
- /* copy this line 10 times to make a rectangle (using the Blitter) */
- for(y=23;y<32;y++)
- BltBitMap(drawport->BitMap,5,22,
- drawport->BitMap,5,y,
- 274,1,
- 0xca,0xff,NULL);
-
- /* copy this rectangle 16 times (Blitterly), and the window's full */
- /* elapsed time so far, about 1/10 second */
- for(y=1;y<16;y++)
- BltBitMap(drawport->BitMap,5,22,
- drawport->BitMap,5,22+(y*10),
- 274,10,
- 0xca,0xff,NULL);
-
-
- /* all I do now is adjust the first pixel in each line to an appropriate
- green value, et voila! 40960 pixels & 4096 colors before you can blink */
- for(y=11;y<171;y++)
- {
- SetAPen(drawport,((y-11)/10)+48);
- WritePixel(drawport,4,y);
- };
-
- for(i=0;i<200000;i++); /* wait for blink */
-
-
- /* Change Window & Screen titles */
- SetWindowTitles(my_window_pointer,
- "Window on the World",
- "Hold & Modify Demo"
- );
-
-
- /* Wait until window is closed */
- Wait(1<<my_window_pointer->UserPort->mp_SigBit);
-
- /* Temporary titles */
- SetWindowTitles(my_window_pointer,
- "Blitter Assisted Landing!",
- "4096, count em, 4096 colours"
- );
-
-
- /* Roller-blind scrolling algorithm */
- for(i=171;i>=11;i-=2)
- {
- WaitBOVP(my_view);
- /* The WaitBOVP() is to try and eliminate flicker when scrolling */
- /* didn't work too good though... any ideas out there? */
- ScrollRaster(drawport,0,2,4,11,275,i);
- };
-
- /* Closing Titles & Credits */
- SetWindowTitles(my_window_pointer,
- "'C' you later!",
- "Coded by Pete Patterson"
- );
-
- for(i=0;i<200000;i++); /* Give em a good look */
-
-
- /* Close up shop, clean up & go home */
- CloseWindow(my_window_pointer);
- CloseScreen(my_screen_pointer);
- CloseLibrary(GfxBase);
- CloseLibrary(IntuitionBase);
- exit(WE_SURVIVED);
- }
-
-
-