Am I going crazy? (probably)

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
jboldiga
Posts: 27
Joined: Mon Jun 20, 2005 10:16 am

Am I going crazy? (probably)

Post by jboldiga »

Soo today I decided to muck around with some PSP dev stufff and I managed to compile Nem's hello world (yay!) but I wasnt satified so I got a cool little image of Link @ 300x170 res. I modified the hello code to load a non-interleaved image (raw data) but everytime I ran it the image was greyscale. Here is the function:

Code: Select all

void pgBitBlt32(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int mag,const unsigned int *d)
{
	unsigned char *vptr0;		//pointer to vram
	unsigned char *vptr;		//pointer to vram
	unsigned long xx,yy,mx,my;
	const unsigned char *ddr, *ddg, *ddb;
	
	vptr0=pgGetVramAddr(x,y);
	ddr=(const unsigned char*)d;
	ddg=ddr+(w*h);
	ddb=ddg+(w*h);
		
	for &#40;yy=0; yy<h; yy++&#41; &#123;
		for &#40;my=0; my<mag; my++&#41; &#123;
			vptr=vptr0;
			for &#40;xx=0; xx<w; xx++&#41; &#123;
				for &#40;mx=0; mx<mag; mx++&#41; &#123;
					unsigned short pixel;
					unsigned char  r, g, b;
					r = &#40;&#40;*ddr&#41; >> 3&#41;; ddr++;
					g = &#40;&#40;*ddg&#41; >> 3&#41;; ddg++;
					b = &#40;&#40;*ddb&#41; >> 3&#41;; ddb++;
					pixel = &#40;&#40;r&#41; | &#40;g << 5&#41; | &#40;b << 10&#41;&#41;; //| &#40;1 << 15&#41;&#41;;
					*&#40;unsigned short *&#41;vptr=pixel;
					vptr+=PIXELSIZE*2;
				&#125;
			&#125;
			vptr0+=LINESIZE*2;	
		&#125;
	&#125;
	
&#125;
now if you look in particular at the line

Code: Select all

ddg=ddr+&#40;w*h&#41;;
ddb=ddg+&#40;w*h&#41;;
when I put constant values of (300*170), the image showed up fine, if I left it as w*h it was greyscale. I called the function like so:

Code: Select all

pgBitBlt32&#40;0,0,300,170,1,image_seclogo&#41;;
What the hell is going on??? Tried on the pspe AND on my physical PSP, same results on both. Do you think its the compiler??

Note: I am using the ps2 tool chain with the elf patch for psp.

Thanks in advance.
Post Reply