Path: chuka.playstation.co.uk!news From: "SCEE" Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: Sprites don't display black? Date: Mon, 2 Feb 1998 09:12:52 -0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 135 Message-ID: <6b437u$b28@chuka.playstation.co.uk> References: <34D38E33.3A92@concentric.net> NNTP-Posting-Host: 194.203.13.10 X-Newsreader: Microsoft Outlook Express 4.71.1712.3 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Hi, Any pixel with colour 0,0,0 will be transparent, regardless of the setting of the transparency flag ( This controls semi-transparency ) If you want a black pixel, set bit 15 of the CLUT entry ( ie. Colour is $8000 instead of 0 ) Cheers, Colin. Scott Cartier wrote in message <34D38E33.3A92@concentric.net>... >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)); >}