// Graphics.c - a generic graphics framework for the Playstation //////////////////////////////////////////////////////////////// #include "Graphics.h" #include "MyAssert.h" //--------------------------------------------------------------- DEFINITIONS #define OT_LENGTH 1 //--------------------------------------------------------------- DECLARATIONS static int m_nScreenWidth, m_nScreenHeight; static GsOT m_WorldOT[2]; static GsOT_TAG m_OTTags[2][1<px; Dest.y = Image->py; Dest.w = Image->pw; Dest.h = Image->ph; LoadImage( &Dest, Image->pixel ); // Then our nice safe colour lookup table Dest.x = Image->cx; Dest.y = Image->cy; Dest.w = Image->cw; Dest.h = Image->ch; DrawSync(0); // The image data could still be being copied. LoadImage( &Dest, Image->clut ); // now go ahead and setup the standard sprite info. for ( nIndex = 0 ; nIndex < 2 ; nIndex ++ ) { BackGround[nIndex]->attribute = 0x01000000; BackGround[nIndex]->w = Image->pw; // Don't need to double, each sprite takes half BackGround[nIndex]->h = Image->ph; BackGround[nIndex]->cx = Image->cx; BackGround[nIndex]->cy = Image->cy; BackGround[nIndex]->r = BackGround[nIndex]->g = BackGround[nIndex]->b = 128; BackGround[nIndex]->scalex = BackGround[nIndex]->scaley = ONE; BackGround[nIndex] ->y = BackGround[nIndex]->v = BackGround[nIndex]->mx = BackGround[nIndex]->my = BackGround[nIndex]->rotate = 0; BackGround[nIndex]->tpage = GetTPage( 1, 0, Image->px, Image->py ); BackGround[nIndex]->x = nIndex * Image->pw; BackGround[nIndex]->u = nIndex * Image->pw; } DrawSync(0); } //////////////////////////////////////////////////////////////////// void SetupSprite( GsSPRITE * Sprite, GsIMAGE * Image, u_long * ImageData ) // Sets up the passed in sprite and image structures // Use this routine to set up a standard sprite, where we can assume that the first // colour of used in the sprite is the one that we want to be transparent. { RECT Dest; // Used in data copies // The following variables are all used in making the palette safe u_short * ColourAddress; u_char ColourIndex; int nIndex; // Get the info on the image into a format that we can use GsGetTimInfo( ImageData, Image ); // Make the palette useable // Before loading the sprite, set the colour used as 0,0 to be the transparent one ColourAddress = (u_short *)Image->clut; ColourIndex = *Image->pixel; for ( nIndex = 0 ; nIndex < 256 ; nIndex ++ ) { // Changed the first colour used to be the transparent one if ( nIndex == ColourIndex ) *ColourAddress = 0; else if ( *ColourAddress == 0 ) // If any other colours are transparent, fix 'em *ColourAddress = 1<<15; ColourAddress++; } // Data copies - first the image...... Dest.x = Image->px; Dest.y = Image->py; Dest.w = Image->pw; Dest.h = Image->ph; LoadImage( &Dest, Image->pixel ); // Then our nice safe colour lookup table Dest.x = Image->cx; Dest.y = Image->cy; Dest.w = Image->cw; Dest.h = Image->ch; DrawSync(0); // The image data could still be being copied. LoadImage( &Dest, Image->clut ); // now go ahead and setup the standard sprite info. Sprite->attribute = 0x01000000; Sprite->w = Image->pw * 2; Sprite->h = Image->ph; Sprite->cx = Image->cx; Sprite->cy = Image->cy; Sprite->r = Sprite->g = Sprite->b = 128; Sprite->scalex = Sprite->scaley = ONE; Sprite->x = Sprite ->y = Sprite->u = Sprite->v = Sprite->mx = Sprite->my = Sprite->rotate = 0; Sprite->tpage = GetTPage( 1, 0, Image->px, Image->py ); DrawSync(0); }