Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Scott Cartier Newsgroups: scea.yaroze.programming.2d_graphics Subject: Sprites don't display black? Date: Sat, 31 Jan 1998 12:48:51 -0800 Organization: SCEA News Server Lines: 121 Message-ID: <34D38E33.3A92@concentric.net> Reply-To: dsyaroze@concentric.net NNTP-Posting-Host: ts006d47.cup-ca.concentric.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0C-GZone (Win95; I) Hi, I'm seeing some strange behavior I was hoping someone could explain. The code to duplicate it is attached below. Basically I have three 4-bit sprites which are 64x64. I use ClearImage to clear all the pixels to 0 (so all pixels point to CLUT #0). I set up three CLUTs for the sprites. The first has white for CLUT entry 0, the second has black, and the third is cyan. If you run the the program you'll be able to see the two outer sprites, but not the middle one. For some reason the SortSprite routine doesn't paint the black pixels. Note I do *not* have transparency turned on so it *should* paint them as black. Can someone take a look and explain it to me? Thanks, Scott --------------------------------------------------------------------- #include #include #include "libps.h" #include "pad.h" #define OT_LENGTH 1 volatile u_char *bb0, *bb1; GsOT OT[2]; GsOT_TAG OT_tags[2][1 << OT_LENGTH]; PACKET gpu_packet_area[2][10 * (24)]; static u_long PadRead(); main() { GsSPRITE sprt[3]; int cnt, i, active_buffer, cont = 1; u_long clut_init, cur_pad; RECT rect; for (cnt = 0; cnt <= 1; cnt++) { OT[cnt].length = OT_LENGTH; OT[cnt].org = OT_tags[cnt]; } SetVideoMode(MODE_NTSC); GetPadBuf(&bb0, &bb1); GsInitGraph(640, 480, 5, 0, 0); GsDefDispBuff(0, 0, 0, 0); for (i = 0; i <= 2; i++) { sprt[i].attribute = 0; sprt[i].x = 100 + i * 128; sprt[i].y = 100; sprt[i].h = 64; sprt[i].w = 64; sprt[i].u = 0; sprt[i].v = 0; sprt[i].tpage = 15 - i; sprt[i].cx = 0; sprt[i].cy = 480 + i; sprt[i].r = sprt[i].g = sprt[i].b = 0x80; sprt[i].rotate = 0; sprt[i].mx = 0; sprt[i].my = 0; sprt[i].scalex = ONE; sprt[i].scaley = ONE; switch(i) { case 0: clut_init = 0xFFFF; break; case 1: clut_init = 0x0000; break; case 2: clut_init = 0xFF00; break; } rect.x = 0; rect.y = 480 + i; rect.h = 1; rect.w = 16; DrawSync(0); LoadImage(&rect, &clut_init); DrawSync(0); rect.x = sprt[i].tpage << 6; rect.y = 0; rect.h = 64; rect.w = 16; // 4-bit TIM DrawSync(0); ClearImage(&rect, 0, 0, 0); DrawSync(0); } while (cont) { active_buffer = GsGetActiveBuff(); GsSetWorkBase((PACKET *)gpu_packet_area[active_buffer]); GsClearOt(0, 0, &OT[active_buffer]); cur_pad = PadRead(); if (cur_pad & PADselect) cont = 0; for (i = 0; i <= 2; i++) GsSortSprite(&sprt[i], &OT[active_buffer], 0); VSync(0); ResetGraph(1); GsSwapDispBuff(); GsDrawOt(&OT[active_buffer]); } } //********************************************************************** static u_long PadRead() { return(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); }