Path: chuka.playstation.co.uk!news From: "Maurice Sibrandi" Newsgroups: scee.yaroze.programming.2d_graphics Subject: Displaying 4/8/16 bit TIMs Date: Thu, 1 Oct 1998 10:09:06 +0200 Organization: PlayStation Net Yaroze (SCEE) Lines: 126 Message-ID: <6uvd90$gul12@chuka.playstation.co.uk> NNTP-Posting-Host: 212.206.211.33 X-Newsreader: Microsoft Outlook Express 4.72.2106.4 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Hi Yarozians, I have a 4 bit TIM which is loaded at 680,384. The size is 160,128. The actual size is off course 40,128 since it is 4 bit. The problem occurs when I display the sprite : the left side of the sprite is distorted. When I multiply the u value with 4 the left side will be ok, but sprite's right side is clipped. What am I doing wrong? I think it has something to do with with the u and v parameters. Should sprite's be alligned to some value? If so, why doesn't timtool tell me so! The same occurs also for 8 bit TIMs, but when I multiply u by 2 it will display correctly. All is swell for 16 bit TIMs. I use the following function to setup my GsSPRITE structure and just a normal GsSortSprite to 'draw' it. #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); }