| View previous topic :: View next topic |
| Author |
Message |
Shito
Joined: 11 May 2005 Posts: 21
|
Posted: Tue May 17, 2005 6:35 am Post subject: noobifull BitBlt Clipping |
|
|
Ok, first of all I'm not really used to hardcore coding and all, I'm more used to nice graphical APIs, so sorry in advance for any noobiness that could emerge from this topic. ^^
Sooo, since we're accessing the video memory to blit an image on screen, I can easily understand how some things could go wrong if we try to blit something *outside* the screen.
In facts, with nem's function, only negative y's seem to be the problem and lead to a crash.
x's just seem to loop from one side of the screen to the other, and SCREENHEIGHT+ y's go weirdy weirdo after a certain value.
Hence this quick fix to nem's function :
| Code: | void pgBitBlt(unsigned long x,long y,unsigned long w,unsigned long h,unsigned long mag,const unsigned short *d)
{
unsigned char *vptr0; //pointer to vram
unsigned char *vptr; //pointer to vram
unsigned long xx,yy,mx,my,sy,ry;
const unsigned short *dd;
////////////////////////////////
// [Shito] Clip negative y's
ry = y ;
sy = 0 ;
if (y < 0)
{
ry = 0 ;
sy = -y ;
d+=w*sy ;
}
////////////////////////////////
vptr0=pgGetVramAddr(x,ry);
for (yy=sy; yy<h; yy++) {
for (my=0; my<mag; my++) {
vptr=vptr0;
dd=d;
for (xx=0; xx<w; xx++) {
for (mx=0; mx<mag; mx++) {
if (*dd != KEYCOLOR) // [Shito] discard keycolor pixels
*(unsigned short *)vptr=*dd;
vptr+=PIXELSIZE*2;
}
dd++;
}
vptr0+=LINESIZE*2;
}
d+=w;
}
} |
(Plus as an added bonus, the extra difficult transparent keycolor handling ^^)
Works fine on pspe, have yet to test it on my psp, but I just wanted to know : do you think I should also check the other edges, or since it doesn't seem to crash let's just leave at that and save us a little (*little*) cpu time ?
If you have an even easier solution, I'm begging of you, please go ahead and show me. :) |
|
| Back to top |
|
 |
Smiths
Joined: 15 May 2005 Posts: 30
|
Posted: Tue May 17, 2005 1:02 pm Post subject: |
|
|
Am trying to import this function into RIN's source, but there's an error because there's no definition of KEYCOLOR.
What should it be defined as? |
|
| Back to top |
|
 |
alonetrio

Joined: 15 May 2005 Posts: 34
|
Posted: Tue May 17, 2005 1:19 pm Post subject: |
|
|
just assign to it the color you want to be transparent ;)
it's seem the "the extra difficult" joke was too much ;) |
|
| Back to top |
|
 |
Shito
Joined: 11 May 2005 Posts: 21
|
Posted: Tue May 17, 2005 5:21 pm Post subject: |
|
|
:)
Smiths, here's the one I use, "full green" being the transparent color :
| Code: | | #define KEYCOLOR 0x03E0 //transparent color (full green) |
|
|
| Back to top |
|
 |
Smiths
Joined: 15 May 2005 Posts: 30
|
Posted: Tue May 17, 2005 11:20 pm Post subject: |
|
|
i threw it in RIN, setting white as a transparent color. it all compiled fine and ran without any noticable glitches, so I guess the routine works :)
Didn't notice much in the way of changes/speedups but I didn't really test it insanely.
Still, when it works, it works. |
|
| Back to top |
|
 |
Shito
Joined: 11 May 2005 Posts: 21
|
Posted: Tue May 17, 2005 11:34 pm Post subject: |
|
|
| If you want to see what it changes, try to blit an image at (0,-10) with and without this little fix. ;) |
|
| Back to top |
|
 |
subbie
Joined: 05 May 2005 Posts: 122
|
Posted: Wed May 18, 2005 12:36 am Post subject: |
|
|
| -Y results in a write to a location before the Screen Address. Hense the crash. -X just wraps back into current space (unless Y is 0, in witch it writes outside of screen address). |
|
| Back to top |
|
 |
Grover
Joined: 23 Feb 2005 Posts: 50
|
Posted: Wed May 18, 2005 1:58 am Post subject: |
|
|
Hi.. I added a similar thing to nems PG library. Source here:
http://forums.ps2dev.org/viewtopic.php?t=1752
it adds a clip flag to the function - there are times you will want to bitblt to an offscreen buffer (esp for things like the panorama sky map used in my terrain src) and they wont necessarily be a screens dimension size. _________________ Bye. |
|
| Back to top |
|
 |
|