Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: George_Bain@bc.sympatico.ca (George Bain) Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: Sprite Help. Warning lots of code Date: 3 Jun 1997 07:43:47 GMT Organization: SCEA Net Yaroze News Lines: 140 Message-ID: <5n0hvj$7d012@scea> References: <01bc6fb1$8104ef10$7b7b7bcc@bank> NNTP-Posting-Host: vanc01m05-71.bctel.ca Mime-Version: 1.0 Content-Type: Text/Plain; charset=US-ASCII X-Newsreader: WinVN 0.99.9 (Released Version) (x86 32bit) In article <01bc6fb1$8104ef10$7b7b7bcc@bank>, spider@best.com says... Try this out dude.... // 2D Display Playstation Sprite #include #include "pad.h" #define PACKETMAX (1000*24) // add this GsOT WorldOT[2]; // o.k GsOT_TAG OTtag[2][1<<1]; // o.k int activeBuffer; // o.k #define SPRITE_CNT 7 PACKET GpuPacketArea[2][PACKETMAX]; // try this but it shouldn't matter #define OUR_SPRITE_ADDRESS 0x80090000 GsSPRITE ourSprite; // o.k GsIMAGE ourSpriteInfo; void main() { int i; int padData; RECT rect; u_short texturePage; int hsync = 0; SetVideoMode( MODE_NTSC ); // o.k ResetGraph(0); // o.k GsInitGraph(320, 240, 4, 0, 0); // o.k GsDefDispBuff(0, 0, 0, 240); // o.k // Initialize the ordering table PadInit(); // good for (i = 0; i < 2; i++) // looks good { 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); } // here is the main concern...... //DrawSync(0); // wrong nuke it //activeBuffer = GsGetActiveBuff(); // wrong nuke it while (1) { padData = PadRead(); // sure why not.... if (padData & PADselect) // sure.... break; activeBuffer = GsGetActiveBuff(); // put here, get active buffer GsSetWorkBase((PACKET *)GpuPacketArea[activeBuffer]); // set the workbase GsClearOt(0,0,&WorldOT[activeBuffer]); // clear the OT GsSortSprite(&ourSprite, &WorldOT[activeBuffer], 3); // register sprite in OT DrawSync(0); // add here, wait for all drawing to be completed VSync(0); // wait for V sync // ResetGraph(1); // nuke this GsSwapDispBuff(); // swap the double buffers GsSortClear(0,0,4,&WorldOT[activeBuffer]); // o.k.... clear GsDrawOt(&WorldOT[activeBuffer]); // why did you comment this out? // most important part..... //activeBuffer ^= 1; // nuke } ResetGraph(3); // o.k } That's what I can come up with......I don't claim to be a Sony PlayStation expert so if it don't work don't go crazy on me..... :) Latah....... George Bain