home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
066.lha
/
overscan.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-11-20
|
11KB
|
404 lines
/*
graphics demo of overscan
(variation on a theme from Kernighan and Ritchie)
Jan. 15, 1987 by Steve Joust
A lot of this code is from the ROM Kernal Manuals, volume 1
chapter 2, pages 28-31.
The comments are unfortunately mine.
This code does not seem to work under 1.1, *unless* WIDTH and
HEIGHT are changed to "normal" values ie., 320 and 200 respectively
for a lo-res non-interlaced display. Also, VERSION will have to be
bumped down to a 1.1 value.
This program is presented "as is" for demonstration purposes only,
if it breaks something - TOUGH!
To compile under Lattice v3.10:
LC1 -iinclude view.c
LC2 -v -cdb view.q
BLINK c.o+view.o LIBRARY amiga.lib TO view MAP nil:
note on c.o - the one I used was modified a bit so it didn't
need the LC.LIB. It goes something like this:
1) get hold of the 'c.a' file from Lattice 3.03 disk
2) change all __main to _main
3) put 'clr.l d0' before opening DOS
4) delete all lines with _MemCleanup
5) assemble with the Metacomco assembler
6) don't hold your breath - 'though it works for me
Credits:
Mike Farren's "Gi" program, which I used to convert
DPaint brushes to image data. Good job, Mr. Farren!
DPaint 2.0 and the full video (shifted s) mode, which
stimulated the brain cells into action (and created brushes with).
6 brown (now empty) bottles of Henry Weinhards, which stimulated
the rest of the body into action. Good job, Mr. Weinhard!
*/
#include "exec/types.h"
#include "exec/exec.h"
#include "graphics/gfx.h"
#include "hardware/dmabits.h"
#include "hardware/custom.h"
#include "hardware/blit.h"
#include "graphics/gfxmacros.h"
#include "graphics/copper.h"
#include "graphics/view.h"
#include "graphics/gels.h"
#include "graphics/regions.h"
#include "graphics/clip.h"
#include "graphics/text.h"
#include "graphics/gfxbase.h"
#include "intuition/intuition.h"
#include "libraries/dos.h"
#define DEPTH 2 /* number of bit planes */
/* WARNING - the following numbers are larger than the system
software allows for in a low-res, noninterlaced display, BUT they
don't *seem* to do any damage. I chose them because the image data
width and height divide evenly into them. I know it's a poor excuse,
but tough! It's only a demo.
*/
#define WIDTH 384 /* width of display - 352 is the limit */
#define HEIGHT 280 /* height of display - 232 is the limit */
#define VERSION 33 /* as supplied to OpenLibrary() */
#define IW 48 /* Image Width */
#define IH 70 /* Image Height */
/* this is the image data that gets stamped all over the display */
UWORD hw[] = { /* place your owm image data here and adjust */
/* the IW and IH defines accordingly. */
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0001,0x8100,
0x0000,0x0003,0xc380,
0x0000,0x0000,0xc100,
0x0000,0x0002,0xe000,
0x0000,0x0002,0x7800,
0x0000,0x0007,0x1000,
0x0000,0x0183,0x6000,
0x0000,0x03c0,0x8000,
0x0000,0x00c0,0x0000,
0x0000,0x0060,0x0000,
0x0000,0x0078,0x0000,
0x0000,0x1030,0x0000,
0x0000,0x3c00,0x0000,
0x0000,0x6c00,0x0000,
0x0001,0xe000,0x0000,
0x0001,0x6000,0x0000,
0x000e,0x7800,0x0000,
0x001f,0x3000,0x0000,
0x0023,0x0000,0x0000,
0x00b1,0x0000,0x0000,
0x01ba,0x0000,0x0000,
0x00dc,0x0000,0x0000,
0x0a80,0x0000,0x0000,
0x19c0,0x0000,0x0000,
0x0cc0,0x0000,0x0000,
0x0b00,0x0000,0x0000,
0x0200,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0010,
0x0000,0x0000,0x0018,
0x0000,0x0000,0x0c18,
0x0000,0x0000,0x3610,
0x0000,0x0000,0x2700,
0x0000,0x0000,0x7200,
0x0000,0x0018,0x3400,
0x0000,0x003c,0x0800,
0x0000,0x000c,0x0000,
0x0000,0x0006,0x0000,
0x0000,0x0407,0x8000,
0x0000,0x0e03,0x0000,
0x0000,0x0700,0x0000,
0x0000,0x0300,0x0000,
0x0000,0x0180,0x0000,
0x0000,0x01c0,0x0000,
0x0000,0xe180,0x0000,
0x0001,0xf000,0x0000,
0x0023,0x6000,0x0000,
0x0063,0x9000,0x0000,
0x0031,0xa000,0x0000,
0x0339,0x4000,0x0000,
0x03bc,0x0000,0x0000,
0x01cc,0x0000,0x0000,
0x00c4,0x0000,0x0000,
0x00e0,0x0000,0x0000,
0x0060,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,
/* Bit Plane #1 */
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xfff3,0xf7ff,
0xffff,0xffe1,0xe3ff,
0xffff,0xfff8,0x76ff,
0xffff,0xffe8,0x3c7f,
0xffff,0xffec,0x3eff,
0xffff,0xffc5,0x1fff,
0xffff,0xf3e4,0x87ff,
0xffff,0xe1f8,0xefff,
0xffff,0xf87c,0x9fff,
0xffff,0xfc3f,0x7fff,
0xffff,0xfc3f,0xffff,
0xffff,0x7e1f,0xffff,
0xfffe,0x1f87,0xffff,
0xfffc,0x8fcf,0xffff,
0xfff0,0xc3ff,0xffff,
0xfff4,0x93ff,0xffff,
0xff8c,0x1fff,0xffff,
0xff06,0x1fff,0xffff,
0xfee1,0x87ff,0xffff,
0xfa60,0xcfff,0xffff,
0xf20c,0xffff,0xffff,
0xf90e,0xffff,0xffff,
0xaa45,0xffff,0xffff,
0x3123,0xffff,0xffff,
0x917f,0xffff,0xffff,
0xa63f,0xffff,0xffff,
0xe33f,0xffff,0xffff,
0xf4ff,0xffff,0xffff,
0xfdff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xff7f,
0xffff,0xffff,0xff3f,
0xffff,0xffff,0x9f2f,
0xffff,0xfffe,0x4f67,
0xffff,0xfffe,0xc3e7,
0xffff,0xfffc,0x49ef,
0xffff,0xff3e,0x58ff,
0xffff,0xfe1f,0x8dff,
0xffff,0xff87,0xcbff,
0xffff,0xffc3,0xf7ff,
0xffff,0xdfc3,0xffff,
0xffff,0x8fe1,0xffff,
0xffff,0xc3f8,0x7fff,
0xffff,0xe1fc,0xffff,
0xffff,0xf0ff,0xffff,
0xffff,0xf0ff,0xffff,
0xfff8,0xf27f,0xffff,
0xfff0,0x7e3f,0xffff,
0xfee4,0x1e7f,0xffff,
0xfce2,0x0fff,0xffff,
0xfe50,0x9fff,0xffff,
0xe614,0x6fff,0xffff,
0xe20e,0x5fff,0xffff,
0xf086,0xbfff,0xffff,
0xf843,0xffff,0xffff,
0xf833,0xffff,0xffff,
0xfc3b,0xffff,0xffff,
0xff1f,0xffff,0xffff,
0xff9f,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff
};
/* the one and only image struct for above data */
struct Image si =
{
0, 0,
IW, IH, DEPTH,
&hw[0],
0x3, 0x00,
NULL
};
struct View v;
struct ViewPort vp;
struct ColorMap *cm;
struct RasInfo ri;
struct BitMap b;
struct View *oldview; /* the view we will hopefully return to */
struct RastPort my_rast; /* drawing will be done to this rastport */
struct RastPort *rp; /* pointer to my_rast */
ULONG fp; /* file pointer as returned by Open() */
USHORT colortable[] = /* a few simple (rather dull) colors */
{
0x000, 0x778, 0x555, 0x008
};
UBYTE *displaymem;
UWORD *colorpalette;
struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
main(argc, argv)
LONG argc;
char **argv;
{
register USHORT i;
SHORT nx, ny; /* new x, y coordinates to ClipBlit() to */
SHORT x_line; /* number of times to ClipBlit() across display */
SHORT y_line; /* number of times to ClipBlit() down display */
if (!(fp = Open("CON:100/50/300/50/Hello, world.", MODE_OLDFILE)))
Exit(IoErr());
if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", VERSION)))
{
print("Must run under AmigaDOS 1.2\n");
Delay(150);
Close(fp);
Exit(0);
}
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", VERSION);
if (!IntuitionBase)
{
print("How did the graphics library get opened?\n");
Delay(150);
Close(fp);
Exit(0);
}
oldview = GfxBase->ActiView; /* save that view */
/* set up some important structs */
InitView(&v);
InitVPort(&vp);
v.ViewPort = &vp;
InitBitMap(&b, DEPTH, WIDTH, HEIGHT);
/* set up the rastport */
InitRastPort(&my_rast);
my_rast.BitMap = (struct BitMap *)&b;
rp = (struct RastPort *)&my_rast;
/* set up rasinfo stuff */
ri.BitMap = &b;
ri.RxOffset = 0;
ri.RyOffset = 0;
ri.Next = NULL;
/* set up view port stuff */
vp.DWidth = WIDTH;
vp.DHeight = HEIGHT;
vp.DxOffset = -16; /* this is the max negative offset */
vp.DyOffset = -16; /* ditto */
vp.RasInfo = &ri;
/* make room for MY colors */
cm = GetColorMap(4);
colorpalette = (UWORD *)cm->ColorTable;
for (i = 0; i < 4; i++)
*colorpalette++ = colortable[i];
vp.ColorMap = cm; /* tell view port about them */
/* make room for the bit map */
for (i = 0; i < DEPTH; i++)
{
b.Planes[i] = AllocRaster(WIDTH, HEIGHT);
if (b.Planes[i] == NULL)
Exit(1);
}
x_line = (WIDTH / IW) - 1; /* num times to stamp image across display */
y_line = (HEIGHT / IH) - 1; /* number of times to ClipBlit() down display */
SetRast(rp, 0); /* paint it black (the rast port) */
DrawImage(rp, &si, 0, 0); /* draw image in the upper left hand corner */
/* copy that image across the top of the display */
for (i = 0, nx = IW; i < x_line; i++, nx += IW)
ClipBlit(rp, 0, 0, rp, nx, 0, IW, IH, 0xc0); /* 0xc0 = as is */
/* now copy the top line down the rest of the display */
for (i = 0, ny = IH; i < y_line; i++, ny += IH)
ClipBlit(rp, 0, 0, rp, 0, ny, WIDTH, IH, 0xc0);
/* make sure every thing is in its proper place */
MakeVPort(&v, &vp);
MrgCop(&v);
LoadView(&v); /* ta da! */
/* tap our toes until someone hits return */
while (!(WaitForChar(fp, 500000))) /* 500000 = 1/2 sec */
print("Press <RETURN> to exit.\n");
Close(fp);
LoadView(oldview); /* return to the old display */
FreeMemory();
CloseLibrary(GfxBase);
CloseLibrary(IntuitionBase);
}
FreeMemory()
{
USHORT i;
for (i = 0; i < DEPTH; i++)
FreeRaster(b.Planes[i], WIDTH, HEIGHT);
FreeColorMap(cm);
FreeVPortCopLists(&vp);
FreeCprList(v.LOFCprList);
return(0);
}
strlen(s) /* from K&R */
char *s;
{
char *p = s;
while(*p)
p++;
return(p-s);
}
print(str)
char *str;
{
Write(fp, str, strlen(str));
}