Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "Mark Cooke" Newsgroups: scea.yaroze.programming.2d_graphics Subject: Sprite Help. Warning lots of code Date: 2 Jun 1997 23:59:09 GMT Organization: SCEA Net Yaroze News Lines: 107 Message-ID: <01bc6fb1$8104ef10$7b7b7bcc@bank> NNTP-Posting-Host: spider.vip.best.com X-Newsreader: Microsoft Internet News 4.70.1155 Hi, I was having some troubles with getting a sprite up on the screen. I can get some weird stuff to happen, but nothing like what I would expect. I suspect that somewhere in the following code my numbers are wrong. Anyone care to give me a hand? // 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)]; #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); } DrawSync(0); activeBuffer = GsGetActiveBuff(); while (1) { padData = PadRead(); if (padData & PADselect) break; GsSetWorkBase((PACKET *)GpuPacketArea[activeBuffer]); GsClearOt(0,0,&WorldOT[activeBuffer]); GsSortSprite(&ourSprite, &WorldOT[activeBuffer], 3); hsync = VSync(0); ResetGraph(1); GsSwapDispBuff(); GsSortClear(0,0,4,&WorldOT[activeBuffer]); //GsDrawOt(&WorldOT[activeBuffer]); activeBuffer ^= 1; } ResetGraph(3); } Mark Cooke