Path: chuka.playstation.co.uk!news From: Scott Campbell Newsgroups: scee.yaroze.beginners Subject: Displaying a sprite Date: Sat, 21 Mar 1998 00:56:40 -0800 Organization: PlayStation Net Yaroze (SCEE) Lines: 236 Message-ID: <351380C8.73EA@aol.com> NNTP-Posting-Host: 172-67-26.ipt.aol.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1C5D394338E" X-Mailer: Mozilla 2.02 (Win95; I) This is a multi-part message in MIME format. --------------1C5D394338E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have been beating my head against a brick wall. So before it does any damage........ Could someone PLEASE have a look at the code attached and tell me why when the GsSortClear call is taken out the sprite is displayed against the brick background, BUT when I insert this command back in the same place as in all the examples the screen clears and NO sprite is displayed. AND, why can't I get .h files to work, even if I specify full paths or put them in the same location as the source. Any demo's I download compile fine!! Thanks in advance. ScoTT ------------------------------------------------------------- ScoTT Campbell CS3 Computing Science Dept. E-Mail: campbels@dcs.gla.ac.uk University of Glasgow or SCampb8044@aol.com Visit me: www.dcs.gla.ac.uk/~campbels or www.netyaroze-europe.com/~escotia (Member's only) ------------------------------------------------------------- "The first rule is not to lose. The second rule is never to forget the first rule." - Warren Buffet --------------1C5D394338E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="spriteout" /************************************************************/ /* An attempt at displaying a sprite */ /* Author: ScoTT Campbell */ /* Date: 9/3/98 */ /************************************************************/ #include //#include "c:\WINDOWS\Desktop\sprite16march\Pad.h" //#include "c:\WINDOWS\Desktop\sprite16march\screen.h" #define PADk (1<< 8) #define PADselect PADk // All possible combinations for screen // Choose video mode then one height and one width #define Video_Mode MODE_PAL //#define Video_Mode MODE_NTSC //#define Screen_Height 240 // NTSC //#define Screen_Height 480 // NTSC #define Screen_Height 256 // PAL //#define Screen_Height 512 // PAL //#define Screen_Width 256 #define Screen_Width 320 //#define Screen_Width 384 //#define Screen_Width 512 //#define Screen_Width 640 // Ordering table related definitions #define OT_Multiple 1 #define OT_Length (1 << OT_Multiple) GsOT worldOT[2]; // OT headers GsOT_TAG OTElements[2][OT_Length]; // OT's //Primitive related definitions #define Sprite_Address 0xa0090000 // Where sprite will be placed in memory #define Max_Sprites 1 // Number of sprites to be displayed #define Num_Sprites (Max_Sprites + 1) GsSPRITE sprite; // Sprite handler PACKET packetArray[2][Num_Sprites * sizeof(GsSPRITE)]; // Controller related definitions volatile unsigned char *padbuff1, *padbuff2; // Function definitions void InitialiseGraphics(); // Sets up graphics according to MACROS defined in screen.h void InitialiseOTs(); // Sets up ordering table headers void InitialiseControllers(); // Sets up the controller buffers unsigned long int PadRead(); // Returns value from controller 1 void InitialiseSprite(); // Sets up sprite in frame buffer int main() { int activeBuffer; InitialiseGraphics(); InitialiseOTs(); InitialiseControllers(); InitialiseSprite(); while(!((PadRead()) & PADselect)) // SELECT defined in pad.h { activeBuffer = GsGetActiveBuff(); // Find out which buffer we want to draw in GsSetWorkBase((PACKET*)packetArray[activeBuffer]); // Set drawing command storage address GsClearOt(0,0,&worldOT[activeBuffer]); // Clear the current ordering table GsSortFastSprite(&sprite,&worldOT[activeBuffer],0); // Put sprite into current OT DrawSync(0); // Wait for current drawing to finish VSync(0); // Wait for screen to finish drawing GsSwapDispBuff(); // Swap drawing buffer with display buffer GsSortClear(60,120,120,&worldOT[activeBuffer]); // Clear the screen to cyan GsDrawOt(&worldOT[activeBuffer]); // Draw the OT we just processed } return(0); } void InitialiseGraphics() // Needs global definitions from screen.h { SetVideoMode(Video_Mode); // PAL or NTSC - defined in screen.h GsInitGraph(Screen_Width, Screen_Height,4,0,0); // Defines screen resolution to Screen_Width & Screen_Height, // sets non-interlace with gpu offset, dither off and 16-bit video mode GsDefDispBuff(0,0,0,Screen_Height); // Define double buffers } void InitialiseOTs() // Initialises WorldOT's (headers) { int i; for(i=0;i<2;i++) { worldOT[i].length = OT_Length; worldOT[i].org = OTElements[i]; } } void InitialiseControllers() // Get addresses of controllers' buffers { GetPadBuf(&padbuff1, &padbuff2); } unsigned long int PadRead() // Read from controller 1 { return (~(*(padbuff1+3) | *(padbuff1+2) << 8 | *(padbuff2+3) << 16 | *(padbuff2+2) << 24)); } void InitialiseSprite() { RECT rect; GsIMAGE timData; // Get info at Sprite_Address and put into timData GsGetTimInfo((unsigned long*)(Sprite_Address+4), &timData); // Load sprite into frame buffer rect.x = timData.px; rect.y = timData.py; rect.w = timData.pw; rect.h = timData.ph; LoadImage(&rect, timData.pixel); // Load sprites CLUT into frame buffer rect.x = timData.cx; rect.y = timData.cy; rect.w = timData.cw; rect.h = timData.ch; LoadImage(&rect, timData.clut); sprite.attribute = 0x1000000; sprite.x = ((Screen_Width/2)-timData.pw); sprite.y = ((Screen_Height/2)-timData.ph); sprite.w = (timData.pw * 2); sprite.h = (timData.ph); sprite.tpage = GetTPage(1, 0, timData.px, timData.py); sprite.u = 0; sprite.v = 0; sprite.cx = timData.cx; sprite.cy = timData.cy; sprite.r = 128; sprite.g = 128; sprite.b = 128; sprite.mx = 0; sprite.my = 0; sprite.scalex = ONE; sprite.scaley = ONE; sprite.rotate = 0; DrawSync(0); } --------------1C5D394338E--