forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

noobifull BitBlt Clipping

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Shito



Joined: 11 May 2005
Posts: 21

PostPosted: Tue May 17, 2005 6:35 am    Post subject: noobifull BitBlt Clipping Reply with quote

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
View user's profile Send private message
Smiths



Joined: 15 May 2005
Posts: 30

PostPosted: Tue May 17, 2005 1:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
alonetrio



Joined: 15 May 2005
Posts: 34

PostPosted: Tue May 17, 2005 1:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Shito



Joined: 11 May 2005
Posts: 21

PostPosted: Tue May 17, 2005 5:21 pm    Post subject: Reply with quote

:)

Smiths, here's the one I use, "full green" being the transparent color :
Code:
#define      KEYCOLOR   0x03E0         //transparent color (full green)
Back to top
View user's profile Send private message
Smiths



Joined: 15 May 2005
Posts: 30

PostPosted: Tue May 17, 2005 11:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
Shito



Joined: 11 May 2005
Posts: 21

PostPosted: Tue May 17, 2005 11:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
subbie



Joined: 05 May 2005
Posts: 122

PostPosted: Wed May 18, 2005 12:36 am    Post subject: Reply with quote

-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
View user's profile Send private message
Grover



Joined: 23 Feb 2005
Posts: 50

PostPosted: Wed May 18, 2005 1:58 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group