Path: chuka.playstation.co.uk!news From: loonybit Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Displaying 4/8/16 bit TIMs Date: Fri, 02 Oct 1998 19:37:33 +0200 Organization: PlayStation Net Yaroze (SCEE) Lines: 132 Message-ID: <36150F5D.3B7DB795@augsburg.baynet.de> References: <6uvd90$gul12@chuka.playstation.co.uk> NNTP-Posting-Host: dial085.augsburg.baynet.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.05 [de] (WinNT; I) I don't know, if the following is the reason for your problem, but i think the following code you're using is wrong: pSprite->w = img.pw; instead you have to use something like that: int pixelsPerWord; switch (img.pmode & 0x7) { case 0: pixelsPerWord = 4; break; case 1: pixelsPerWord = 2; break; case 2: pixelsPerWord = 1; break; default: // Unexpected pmode value pixelsPerWord = 0; break; } pSprite->w = img.pw * pixelsPerWord; Cheers, Andy Maurice Sibrandi schrieb: > #define IMAGE_4BIT (0x00000000) > #define IMAGE_8BIT (0x00000001) > #define IMAGE_16BIT (0x00000002) > #define IMAGE_24BIT (0x00000003) > #define IMAGE_CLUT (0x00000008) // bitfield! > > #define IMAGE_MODEMASK (0x00000007) > > #define SPRITE_BRIGHTNESS_ON (0) > #define SPRITE_BRIGHTNESS_OFF (1<<6) > #define SPRITE_4BIT_CLUT (0) > #define SPRITE_8BIT_CLUT (1<<24) > #define SPRITE_16BIT_DIRECT (1<<25) > #define SPRITE_ROTATE_ON (0) > #define SPRITE_ROTATE_OFF (1<<27) > #define SPRITE_STR_50_50 (0) > #define SPRITE_STR_100_100 (1<<28) > #define SPRITE_STR_100_MIN100 (1<<29) > #define SPRITE_STR_100_25 ((1<<28) + (1<<29)) > #define SPRITE_SEMITRANSPARENT_OFF (0) > #define SPRITE_SEMITRANSPARENT_ON (1<<30) > #define SPRITE_DISPLAY_ON (0) > #define SPRITE_DISPLAY_OFF (1<<31) > > void InitSprite(u_long* pAddr, GsSPRITE* pSprite) > { > GsIMAGE img; > RECT rc; > > // get info from image > GsGetTimInfo(pAddr+1, &img); > > // load image into VRAM > SetRECT(&rc, img.px, img.py, img.pw, img.ph); > LoadImage(&rc, img.pixel); > printf("Image : pos = %d, %d, size = %d, %d\n", img.px, img.py, img.pw, > img.ph); > > // load clut into VRAM > if (img.pmode & IMAGE_CLUT) > { > SetRECT(&rc, img.cx, img.cy, img.cw, img.ch); > LoadImage(&rc, img.clut); > printf("Clut : pos = %d, %d, size = %d, %d\n", img.cx, img.cy, img.cw, > img.ch); > }; > > DrawSync(0); > > // setup sprite structure > memset((void*)pSprite, 0, sizeof(GsSPRITE)); > > pSprite->x = 0; > pSprite->y = 0; > pSprite->w = img.pw; > pSprite->h = img.ph; > pSprite->tpage = GetTPage(img.pmode & IMAGE_MODEMASK, 0, img.px, > img.py) & 31; > pSprite->u = img.px % 64; > pSprite->v = img.py % 256; > pSprite->r = 128; > pSprite->g = 128; > pSprite->b = 128; > pSprite->scalex = ONE; > pSprite->scaley = ONE; > > switch(img.pmode & IMAGE_MODEMASK) > > case IMAGE_4BIT : > pSprite->attribute |= SPRITE_4BIT_CLUT; > pSprite->w *= 4; > //pSprite->u *= 4; > pSprite->cx = img.cx; > pSprite->cy = img.cy; > break; > > case IMAGE_8BIT : > pSprite->attribute |= SPRITE_8BIT_CLUT; > pSprite->w *= 2; > //pSprite->u *= 2; > pSprite->cx = img.cx; > pSprite->cy = img.cy; > break; > > case IMAGE_16BIT : > pSprite->attribute |= SPRITE_16BIT_DIRECT; > break; > > case IMAGE_24BIT : > ErrorExit("Sprite can't be 24 bit!!!"); > break; > }; > > printf("Sprite : size = %d, %d, tpage = %d, %d, %d\n", pSprite->w, > pSprite->h, pSprite->tpage, pSprite->u, pSprite->v); > }