| I'm still having troubles opening a window after running the display
program. I'm going to include a copy of my c program. It is basically
the same program which is in the rom kernel manual. If anyone would
like to take a look, here it is...
#include "exec/types.h"
#include "graphics/gfx.h"
#include "hardware/dmabits.h"
#include "hardware/custom.h"
#include "hardware/blit.h"
#include "graphics/copper.h"
#include "graphics/view.h"
#include "graphics/gels.h"
#include "graphics/regions.h"
#include "exec/exec.h"
#include "graphics/text.h"
#include "graphics/gfxbase.h"
#include "graphics/clip.h"
#include "graphics/rastport.h"
#define DEPTH 3
#define WIDTH 320
#define HEIGHT 200
#define NOT_ENOUGH_MEMORY - 1000
/* CONSTRUCT A SIMPLE DISPLAY */
struct View v;
struct ViewPort vp;
struct ColorMap *cm; /* pointer to colormap structure,dynamic alloc */
struct RasInfo ri;
struct BitMap b;
struct RastPort rp;
LONG i,kk;
SHORT j,k,n;
extern struct ColorMap *GetColorMap();
struct GfxBase *GfxBase;
struct View *oldview; /*save pointer to old View so can restore */
/* black,white,red,green,blue,yellow,brown,light blue */
USHORT colortable[] = {0x000,0xeca,0xb00,0x080,0x24c,0xdc2,0xc82,0x0cc}; /* my own colors */
SHORT boxoffsets[] = {802,2010,3218}; /* where to draw boxes */
union {
UBYTE *displaymem;
UWORD *w;
} ptr;
UWORD *colorpalette;
main()
{
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
if(GfxBase == NULL)exit(1);
oldview = GfxBase->ActiView; /*save current View to restore later */
/* example steals screen from Intuition if Intuition is around */
InitView(&v); /* initialize View */
InitVPort(&vp); /* init ViewPort */
v.ViewPort = &vp; /* link View into ViewPort */
/* init bit map (for RasInfo and RastPort) */
InitBitMap(&b,DEPTH,WIDTH,HEIGHT);
/* (init RasInfo) */
ri.BitMap = &b;
ri.RxOffset = 0;
ri.RyOffset = 0;
ri.Next = NULL;
/* now specify critical characteristics */
vp.DWidth = WIDTH;
vp.DHeight = HEIGHT;
vp.RasInfo = &ri;
/* (init color table) */
cm = GetColorMap(8); /* 4 entries, since only 2 planes deep */
colorpalette = (UWORD *)cm->ColorTable;
for(i=0;i<8;i++) {
*colorpalette++ = colortable[i];
}
/* copy my colors into this data structure */
vp.ColorMap = cm; /* link it with the ViewPort */
/* allocate space for bitmap */
for(i=0;i<DEPTH;i++)
{
b.Planes[i] = (PLANEPTR)AllocRaster(WIDTH,HEIGHT);
if(b.Planes[i] == NULL)exit(NOT_ENOUGH_MEMORY);
}
MakeVPort(&v,&vp); /* construct Copper instruction (prelim) list */
MrgCop(&v); /* merge preliminary lists together into a real
* Copper list in the view structure */
for(i=0;i<DEPTH;i++)
{
ptr.displaymem = (UBYTE *)b.Planes[i];
BltClear(ptr.displaymem,RASSIZE(WIDTH,HEIGHT),0);
}
LoadView(&v);
DisplayMem();
Delay(50*10); /* wait for 10 seconds */
LoadView(oldview); /* put back the old View */
for(i=0; i<3; i++)
{
FreeRaster(b.Planes[i],320,200);
}
/* free the color map created by GetColorMap() */
FreeColorMap(cm);
/* free dynamically created structures */
FreeVPortCopLists(&vp);
FreeCprList(v.LOFCprList);
CloseLibrary(GfxBase); /* since program opened library, close it */
} /* end of main() */
DisplayMem()
{
/* Paint the sky blue and the grass green */
ptr.displaymem = b.Planes[0];
for(i=0;i < 3200;i++)
{
*ptr.w++ = 0xffff;
}
for(i=0;i < 4800;i++)
{
*ptr.w++ = 0xffff;
}
ptr.displaymem = b.Planes[1];
for(i=0;i < 3200;i++)
{
*ptr.w++ = 0xffff;
}
for(i=0;i < 4800;i++)
{
*ptr.w++ = 0xffff;
}
ptr.displaymem = b.Planes[2];
for(i=0;i < 3200;i++)
{
*ptr.w++ = 0xffff;
}
for(i=0;i < 4800;i++)
{
*ptr.w++ = 0x0000;
}
ptr.displaymem = b.Planes[2];
}
|
| It has been posted. All of the utilities are in one file. I have
successfully compiled the functions.
ReadyGels(* gelsinfo, *rastport);
PurgeGels(* gelsinfo);
struct VSprite *makeVSprite(lineheight, *image, *colorset, x, y,
wordwidth, imagedepth, flags);
DeleteVSprite(&VSprite);
struct Bob *MakeBob(bitwidth, lineheight, imagedepth, *image,
planePick, planeOnOff, x, y);
DeleteBob(&Bob);
ReadyGels sets up the defaults of the gel system by initializing
the GelsInfo structure you provide. First it allocates room for
and links in lastcolor and nextline. It then uses information in
your RastPort structure to establish boundary collision defaults
at the outer edges of the raster. It then links together the GelsInfo
and the RastPort which you provide. Next it allocates space for
two dummy virtual sprite structures, calls InitGels and SetCollision.
You must already have run LoadView before ReadyGels is called.
PurgeGels deallocates all memory which ReadyGels and NewGelList
have allocated. The system will crash if you have not used these
routines to allocate the space (you can't deallocate something which
you haven't allocated in the first place).
MakeVSprite allocates enough space for and inits a normal vsprite.
DeleteVSprite deallocates the memory it used.
MakeBob initializes a standard bob and allocates as much memory
as is needed for a normal bob and its vsprite structure, links them
together. To find the associated vsprite, look at the back-pointer.
DeleteBob deallocates the memory it used.
|