Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: mperdue@iquest.net (Mario Perdue) Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: Coding ? Date: Sun, 20 Jul 1997 01:58:02 GMT Organization: SCEA Net Yaroze News Lines: 174 Message-ID: <33d16bb7.9449511@205.149.189.29> References: <33D120A8.63D0@earthlink.net> NNTP-Posting-Host: firewall.hrtc.net X-Newsreader: Forte Free Agent 1.1/32.230 First of all, I like to ask if your name is Linda or Austin? I've been assuming that your name is Linda because of the name on the tag line. If your name is really Austin, I appologize for all the times I've called you Linda. Anyway, Linda/Austin, here's my answer. On Sat, 19 Jul 1997 13:16:40 -0700, "Linda J. Hodge" wrote: >What is wrong with this source code?It is supposed to display a bunch of >colored lines. > >/******************************************************** > * * > * * > * LINES!!!! * > * * > * By Austin Kottke * > *******************************************************/ > > > // include libraries >#include > >#include "pad.h" > > > // constants > > // GPU packet space >#define PACKETMAX (10000) >#define PACKETMAX2 (PACKETMAX*24) > > // size of ordering table: 2 << OT_LENGTH > // i.e. 16384 levels of z resolution >#define OT_LENGTH 1 > > > // globals > > // Ordering Table handlers >GsOT WorldOrderingTable[2]; > // actual Ordering Tables themselves >GsOT_TAG zSortTable[2][1< // GPU packet work area >PACKET GpuOutputPacket[2][PACKETMAX2]; > > > > // main function > // see pad.h and pad.c for the controller pad interface > >int main (void) >{ > u_long PadStatus = 0; // state of controller pad > TheBuff; // which buffer is active (drawn on) It might be nice to tell the compiler what type of variable TheBuff is. int TheBuff; > GsGLINE *sp; //Line drawing function,the sp bites! > int index; > // initialisation > SetVideoMode( MODE_NTSC ); // NTSC mode > > // screen resolution 640 by 480, > > GsInitGraph(640 ,480, 4, 0, 0); > GsDefDispBuff(0, 0, 0, 480); For now, I'd use a resolution of 320x240. If you want, you can try a higher res later. GsInitGraph(320, 240, 4, 0, 0); GsDefDispBuff(0, 0, 0, 240); > // set up the controller pad > PadInit(); You havn't shown the PadInit() function here, so I assume it works. > // set up the ordering table handlers > WorldOrderingTable[0].length = OT_LENGTH; > WorldOrderingTable[1].length = OT_LENGTH; > WorldOrderingTable[0].org = zSortTable[0]; > WorldOrderingTable[1].org = zSortTable[1]; > > for (;;) // main loop > { > // find status of controller pad > PadStatus = PadRead(); You also havn't shown the PadRead() function here, so I assume it works too. > // if 'select' pressed, exit main loop > if (PadStatus & PADselect) > break; > > // find which buffer is active > TheBuff = GsGetActiveBuff(); > > // set address for GPU scratchpad area > GsSetWorkBase( (PACKET*)GpuOutputPacket[TheBuff]); > > // clear the ordering table > GsClearOt(0, 0, &WorldOrderingTable[TheBuff]); > > //The program !!! > for(index=0;index<1000;index++) > { sp->attribute = 0; //This is the core of the program > //which is pretty basic. > sp->x0 = rand()%640; > sp->y0 = rand()%480; > sp->x1 = rand()%640; > sp->y1 = rand()%480; Change for new screen size. sp->x0 = rand()%320; sp->y0 = rand()%240; sp->x1 = rand()%320; sp->y1 = rand()%240; > sp->r0 = sp->g0 = sp->b0 = rand()%16; > sp->r1 = sp->g1 = sp->b1 = rand()%16; The way this is written you will get 16 shades of very dark grey. I think you probably want something more like this. sp->r0 = rand()%256; sp->g0 = rand()%256; sp->b0 = rand()%256; sp->r1 = rand()%256; sp->g1 = rand()%256; sp->b1 = rand()%256; Now for the most important thing. You have to tell the system to draw the line. Try this: GsSortGLine(sp, &WorldOrderingTable[TheBuff], 0); > } > > > > // wait for end of drawing to the ot > DrawSync(0); > > // wait for V_BLANK interrupt > VSync(0); > > // swap double buffers > GsSwapDispBuff(); > > // register clear-command: clear to some weird combo > GsSortClear(16,36,43, &WorldOrderingTable[TheBuff]); > > // register request to draw ordering table > GsDrawOt(&WorldOrderingTable[TheBuff]); > > } > > > // clean up > ResetGraph(3); > return 0; >} I hope that gets you going, Mario