Path: chuka.playstation.co.uk!news From: Mark Green Newsgroups: scee.yaroze.beginners Subject: Ok, truly stuck again. Date: Sun, 10 Aug 1997 12:50:15 +0100 Organization: No Lines: 142 Message-ID: <33EDAAF7.7E00@antelope.demon.co.uk> NNTP-Posting-Host: antelope.demon.co.uk Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------26CC511B519D" X-Mailer: Mozilla 3.0 (Win95; I) This is a multi-part message in MIME format. --------------26CC511B519D Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 --------------26CC511B519D Content-Type: text/plain; charset=us-ascii; name="main.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="main.c" #include #include "pad.h" #define VH_ADDR 0x80100000 /* 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][10]; 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 = 1; 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]); } } --------------26CC511B519D--