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: Sprite Help. Warning lots of code Date: Tue, 03 Jun 1997 14:12:04 GMT Organization: SCEA Net Yaroze News Lines: 140 Message-ID: <33942078.589075@205.149.189.29> References: <01bc6fb1$8104ef10$7b7b7bcc@bank> NNTP-Posting-Host: filter-hrtc1.nortel.net X-Newsreader: Forte Free Agent 1.1/32.230 Hi Mark, Let's take a look at what you have. On 2 Jun 1997 23:59:09 GMT, "Mark Cooke" wrote: >// 2D Display Playstation Sprite > >#include >#include "pad.h" > >GsOT WorldOT[2]; // How Many sprites in world & where draw >GsOT_TAG OTtag[2][1<<1]; >int activeBuffer; // Which buffer are we drawing to? > >#define SPRITE_CNT 7 >PACKET GpuPacketArea[2][1*sizeof(GsSPRITE)]; I think this line came from one of my examples. I thought I fixed that. I'd try using a multiple of 24 (the average packet size) here. Since you're not too worried about space yet, make it large; 2400 should do. PACKET GpuPacketArea[2][2400]; or PACKET GpuPacketArea[2][100*24]; >#define OUR_SPRITE_ADDRESS 0x80090000 >GsSPRITE ourSprite; // Guess what this is? >GsIMAGE ourSpriteInfo; > >void main() >{ > int i; > int padData; > RECT rect; > u_short texturePage; > int hsync = 0; > > SetVideoMode( MODE_NTSC ); // For American TV's > > ResetGraph(0); > > GsInitGraph(320, 240, 4, 0, 0); // 320x240, GPU Doublebuffer, No dither > // 16-bit color > GsDefDispBuff(0, 0, 0, 240); // Front Buffer starts at 0,0 > // Back Buffer starts at 0,240 > // Initialize the ordering table > > PadInit(); > > for (i = 0; i < 2; i++) > { > WorldOT[i].length = 1; > WorldOT[i].org = OTtag[i]; > } > > ourSprite.r = 128; > ourSprite.g = 128; > ourSprite.b = 128; > ourSprite.scalex = ONE; > ourSprite.scaley = ONE; > ourSprite.rotate = 0; > > ourSprite.tpage = GetTPage(1, 0, 320, 0); > ourSprite.attribute |= 1 << 25; > ourSprite.x = 0; > ourSprite.y = 0; > ourSprite.w = 128; > ourSprite.h = 240; > ourSprite.u = 0; > ourSprite.v = 0; > > setRECT( &rect, 960, 0, 128, 240 ); > > GsGetTimInfo( (u_long *)(OUR_SPRITE_ADDRESS+4), &ourSpriteInfo); > > rect.x = ourSpriteInfo.px; > rect.y = ourSpriteInfo.py; > rect.w = ourSpriteInfo.pw; > rect.h = ourSpriteInfo.ph; > > LoadImage(&rect, ourSpriteInfo.pixel); > > if ((ourSpriteInfo.pmode >> 3) & 0x01) > { > rect.x = ourSpriteInfo.cx; > rect.y = ourSpriteInfo.cy; > rect.w = ourSpriteInfo.cw; > rect.h = ourSpriteInfo.ch; > > LoadImage( &rect, ourSpriteInfo.clut); > } It looks like you're OK to here. The next two lines are wrong. Both should be performed inside the while loop. Get rid of them here. > DrawSync(0); > activeBuffer = GsGetActiveBuff(); > while (1) > { > padData = PadRead(); > if (padData & PADselect) > break; Get the active buffer before you do anything with the frame buffer. activeBuffer = GsGetActiveBuff(); > GsSetWorkBase((PACKET *)GpuPacketArea[activeBuffer]); > GsClearOt(0,0,&WorldOT[activeBuffer]); > GsSortSprite(&ourSprite, &WorldOT[activeBuffer], 3); Wait for all drawing to stop before waiting for VSync. DrawSync(0); > hsync = VSync(0); > ResetGraph(1); > GsSwapDispBuff(); > GsSortClear(0,0,4,&WorldOT[activeBuffer]); You need to do the GsDrawOt(). Remove the comment. > //GsDrawOt(&WorldOT[activeBuffer]); Get rid of this. The active buffer is read at the beginning of the loop. > activeBuffer ^= 1; > } Get rid of the ResetGraph() here. > ResetGraph(3); > } I hope that helps. Mario