Path: chuka.playstation.co.uk!news From: Chris Chadwick Newsgroups: scee.yaroze.beginners Subject: Re: Ok, truly stuck again. Date: Mon, 11 Aug 1997 01:08:57 -0700 Organization: PlayStation Net Yaroze (SCEE) Lines: 151 Message-ID: <33EEC899.5F54@dial.pipex.com> References: <33EDAAF7.7E00@antelope.demon.co.uk> NNTP-Posting-Host: aj241.du.pipex.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.02 (Win95; I; 16bit) Mark Green wrote: > > I'm actually going to post my source here because I really can't see > what's wrong (and worse yet I have to post through Netscape to do a file > include, so it'll probably do that stupid post-it-in-html-twice trick, > but I can't get a decent bit of news software and my telnet won't > transmit files.. many apologies in advance if it has done it). > Basically, this program is supposed to draw a sprite, but it doesn't > work at all. And I can't see why. I have checked against the check > program and against shadow's code and it seems to do everything in the > same order. If I take the GsSortClear() out, it works, but doesn't > clear the screen (of course ;) ) > Any help much appreciated. > > Mg Hi Mark, I've had a quick look through your code and the only problem I can see is regarding the OT length. I've annoted your code, below, to what I think should help... Sorry I couldn't actually try this out but it's too late/early now do so (for reasons I wont bore you with). Anyway, if this makes no difference, or I've missed something else, Im shaw a SCEE tech bod will step in tomorrow (Monday) and help you out! This is me signing off for at least a few days while my laptop goes on a jolly jaunt back to Ireland for repairs :( See ya later Chris > > --------------------------------------------------------------- > > #include > #include "pad.h" > > #define VH_ADDR 0x80100000 #define OT_LENGTH 1 //can be any value from 1 to 14 only! <-- add this line //1 here = just 2 Z planes (see below) > > /* Reserved memory for building packets for the GPU */ > PACKET Packets[2][500]; > > /* Ordering table for planes */ > GsOT OT[2]; > /* Only need a few tags, since we're not using 3D */ > GsOT_TAG Tag[2][1< int frame; > > /* Our sprite record */ > GsSPRITE oursprite; > > /* Where we put the TIM */ > u_long *theTIMfile = (u_long *)VH_ADDR; > > /* Pointers to the PSX control buffers */ > volatile u_char *bb0, *bb1; > > GsIMAGE theimage; > > /* God knows what this does, but it works */ > static u_long PadRead(long id) > { > return(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); > } > > void loadthetexture() { > RECT rect; > int i; > > GsGetTimInfo((u_long *)(VH_ADDR+4),&theimage); > rect.x = theimage.px; rect.y = theimage.py; > rect.w = theimage.pw; rect.h = theimage.ph; > LoadImage(&rect, theimage.pixel); > rect.x = theimage.cx; rect.y = theimage.cy; > rect.w = theimage.cw; rect.h = theimage.ch; > LoadImage(&rect, theimage.clut); > DrawSync(0); > } > > void setupsprite() { > u_long tpage; > > tpage = GetTPage(1,0,640,0); > > oursprite.attribute = 1 << 24; > oursprite.x = 50; oursprite.y = 50; > oursprite.w = theimage.pw*2; oursprite.h = theimage.ph; > oursprite.u = 0; oursprite.v = 0; > oursprite.cx = theimage.cx; oursprite.cy = theimage.cy; > oursprite.tpage = tpage; > oursprite.r = oursprite.g = oursprite.b = 128; > oursprite.scalex = oursprite.scaley = ONE; > oursprite.mx = oursprite.my = 10; > oursprite.rotate = 0; > } > > main() { > > int t; > u_long padval; > /* Set up screen */ > > SetVideoMode(MODE_PAL); > GetPadBuf(&bb0, &bb1); > GsInitGraph(320,256,4,0,0); > > /* Tell system where the double-buffer screen is in the global fbuf */ > GsDefDispBuff(0,0,0,256); > > /* Set up the ordering tables */ > for (t=0; t<2; t++) { > OT[t].length = OT_LENGTH; <-- change to this line > OT[t].org = Tag[t]; > } > > loadthetexture(); > setupsprite(); > > /* ORDER OF DOING THINGS: */ > /* Compute frame X */ > /* Check drawing of frame X-1 is finished */ > /* Wait for vertical blanking */ > /* Shift X-1 into screen, bring X-2 to buffer for overwrite */ > /* Start drawing frame X */ > /* Increment X, go to top */ > > while (padval != PADselect) { > > frame = GsGetActiveBuff(); > GsSetWorkBase((PACKET *)Packets[frame]); > GsClearOt(0,0,&OT[frame]); > > padval = PadRead(1); > if (padval & PADLright) oursprite.rotate += 4096; > if (padval & PADLleft) oursprite.rotate -= 4096; > > GsSortSprite(&oursprite, &OT[frame], 0); > > DrawSync(0); > VSync(0); > GsSwapDispBuff(); > GsSortClear(0,0,0,&OT[frame]); > GsDrawOt(&OT[frame]); > } > > }