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 

Unswizzling a texture

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



Joined: 08 Oct 2005
Posts: 186

PostPosted: Tue Apr 03, 2007 7:12 am    Post subject: Unswizzling a texture Reply with quote

Hello ^^

I'm trying to unswizzle a texture but I can't understand correctly what is written here :( It's sooo complicated, especially for me who doesn't understand english very well :(
I've searched a lot but didn't found any code that does unswizzling.
So I'm asking here: can someone post a routine for unswizzling a texture please? :)

Thank you very much in advance,
Brunni
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Tue Apr 03, 2007 9:43 am    Post subject: Reply with quote

Code:

void unswizzle_fast(u8* out, const u8* in, unsigned int width, unsigned int height)
{
   unsigned int blockx, blocky;
   unsigned int i,j;
 
   unsigned int width_blocks = (width / 16);
   unsigned int height_blocks = (height / 8);
 
   unsigned int dst_pitch = (width-16)/4;
   unsigned int dst_row = width * 8;
 
   u32* src = (u32*)in;
   u8* ydst = out;
 
   for (blocky = 0; blocky < height_blocks; ++blocky)
   {
      const u8* xdst = ydst;
      for (blockx = 0; blockx < width_blocks; ++blockx)
      {
         const u32* dst= (u32*)xdst;
         for (j = 0; j < 8; ++j)
         {
            *(dst++) = *(src++);
            *(dst++) = *(src++);
            *(dst++) = *(src++);
            *(dst++) = *(src++);
            dst += dst_pitch;
         }
         xdst += 16;
     }
     ydst += dst_row;
   }
}


Try with that. It's untested though, but you can work from there if it doesn't give correct results immediately. Basically, you just revert the code from the swizzle function.
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Wed Apr 04, 2007 2:37 am    Post subject: Reply with quote

Soooo kind of you :)
It works, thank you so much :D
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
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