Cursor? Work this code?

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

Moderators: cheriff, TyRaNiD

Post Reply
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Cursor? Work this code?

Post by _.-noel-._ »

Hey, hey...

I don't know, what is wrong...


If I start the program, the PSP LCD is Black, but the Callbacks work.
But when i will exit the Program over the Callbacks, the PSP LCD freeze...

Got the code:

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspumd.h>
#include <string.h>
#include <stdlib.h>
#include "wait.h"
//#include "callbacks.h"
//#include "dumpers.h"
#include "graphics.h"
#include "framebuffer.h"
#include <png.h>

PSP_MODULE_INFO&#40;"lol", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;

#define printf pspDebugScreenPrintf
#define MAX&#40;X, Y&#41; &#40;&#40;X&#41; > &#40;Y&#41; ? &#40;X&#41; &#58; &#40;Y&#41;&#41;

void dump_threadstatus&#40;void&#41;;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread,
				     0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

int x = 0;
int y = 0;
int ox;
int oy;


int main&#40;void&#41;
&#123;

	pspDebugScreenInit&#40;&#41;;
	pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
	pspDebugScreenSetTextColor&#40;0&#41;;
	SetupCallbacks&#40;&#41;;
	initGraphics&#40;&#41;;
	SceCtrlData pad;
	sceCtrlSetSamplingMode&#40;1&#41;;
	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;
	sceCtrlReadBufferPositive&#40;&pad, 1&#41;; 
	
	Image* cursor;
	cursor = loadImage&#40;"cursor.png"&#41;;
	
	while&#40;1&#41;
	&#123;
		
		if &#40;pad.Lx > 150&#41; &#123;
			wait&#40;1&#41;;
			x++;
		&#125;
		if &#40;pad.Lx < 110&#41; &#123;
			wait&#40;1&#41;;
			x--;
		&#125;
		if &#40;pad.Ly > 150&#41; &#123;
			wait&#40;1&#41;;
			y++;
		&#125;
		if &#40;pad.Ly < 110&#41; &#123;
			wait&#40;1&#41;;
			y--;
		&#125;
/*
		if &#40;pad.Lx == 255&#41; &#123;
			pad.Lx = 255;
		&#125;
		if &#40;pad.Lx == 0&#41; &#123;
			pad.Lx = 0;
		&#125;
		if &#40;pad.Ly == 255&#41; &#123;
			pad.Ly = 255;
		&#125;
		if &#40;pad.Ly == 0&#41; &#123;
			pad.Ly = 0;
		&#125;
*/	
		if&#40;x != ox & y != oy&#41;
			&#123;
				if &#40;!cursor&#41;
				&#123;
                    //Image load failed
                    printf&#40;"Error!\n"&#41;;
          		&#125;
				else
				&#123;
					  sceDisplayWaitVblankStart&#40;&#41;;
					  blitImageToScreen&#40;0 ,0 ,10 , 10, cursor, x, y&#41;;
					  flipScreen&#40;&#41;;
				&#125;
			&#125;
ox = x;
oy = y;
&#125;
...
I hope someone can help me ;)
Sry for my english
AllSystemGo
Posts: 26
Joined: Sat Jun 02, 2007 1:15 am

Post by AllSystemGo »

You cannot make a infinit loop like that

Code: Select all

while&#40;1&#41;
you should use something like

Code: Select all

while&#40;running&#41;
I'm trying to get you the thread that is talking ab out that but I just can't find one . I'll post the link a bit later.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

The common idiom (replacement) for
while (1)
is
for (;;)
Quite a few compilers warn about the former but happily accept the latter.
You use 'break' to get out of the infinite loop as usual.

Jim
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

thx, if i have understand all, i must replace

Code: Select all

while&#40;1&#41;
with

Code: Select all

for&#40;;;&#41;
but what did you mean with
Quite a few compilers warn about the former but happily accept the latter.
You use 'break' to get out of the infinite loop as usual.
?
Sry for my english
b1G
Posts: 5
Joined: Wed Sep 19, 2007 8:07 am

Post by b1G »

What he means is that sometimes your compiler may give a warning when using while(1) and that they don't give any warnings when using for(;;) even though they do the same thing.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

It's black because you don't blit the cursor until it moves, and it never moves because you don't read the pad inside the loop.

Here's some "fixed" code that works. It shows the cursor to begin, reads the pad in the loop, and exits if you push O as well. Note that your code doesn't erase the cursor. Something to add in. :)

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspumd.h>
#include <string.h>
#include <stdlib.h>

#include "graphics.h"
#include "framebuffer.h"

#include <png.h>

PSP_MODULE_INFO&#40;"lol", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;

#define printf pspDebugScreenPrintf
#define MAX&#40;X, Y&#41; &#40;&#40;X&#41; > &#40;Y&#41; ? &#40;X&#41; &#58; &#40;Y&#41;&#41;

void dump_threadstatus&#40;void&#41;;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
   sceKernelExitGame&#40;&#41;;
   return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
   int cbid;

   cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
   sceKernelRegisterExitCallback&#40;cbid&#41;;
   sceKernelSleepThreadCB&#40;&#41;;

   return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
   int thid = 0;

   thid = sceKernelCreateThread&#40;"update_thread", CallbackThread,
                 0x11, 0xFA0, 0, 0&#41;;
   if&#40;thid >= 0&#41;
   &#123;
      sceKernelStartThread&#40;thid, 0, 0&#41;;
   &#125;

   return thid;
&#125;

int x = 0;
int y = 0;
int ox;
int oy;


int main&#40;void&#41;
&#123;
   SceCtrlData pad;

   pspDebugScreenInit&#40;&#41;;
   pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
   pspDebugScreenSetTextColor&#40;0&#41;;

   SetupCallbacks&#40;&#41;;

   initGraphics&#40;&#41;;
   sceCtrlSetSamplingMode&#40;1&#41;;
   sceCtrlSetSamplingCycle&#40;0&#41;;
   sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;

   Image* cursor;
   cursor = loadImage&#40;"cursor.png"&#41;;
   if &#40;!cursor&#41;
   &#123;
      printf&#40;" Couldn't load cursor.png!\n"&#41;;
      sceKernelExitGame&#40;&#41;;
   &#125;
   blitImageToScreen&#40;0 ,0 ,10 , 10, cursor, x, y&#41;; // show initially

   while&#40;1&#41;
   &#123;
      sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
      if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; break;

      if &#40;pad.Lx > 150&#41; x++;
      if &#40;pad.Lx < 110&#41; x--;
      if &#40;pad.Ly > 150&#41; y++;
      if &#40;pad.Ly < 110&#41; y--;
      if &#40;x < 0&#41; x = 0;
      else if &#40;x > 479&#41; x = 479;
      if &#40;y < 0&#41; y = 0;
      else if &#40;y > 271&#41; y = 271;

      if&#40;x != ox && y != oy&#41;
      &#123;
         sceDisplayWaitVblankStart&#40;&#41;;
         blitImageToScreen&#40;0 ,0 ,10 , 10, cursor, x, y&#41;;
         flipScreen&#40;&#41;;
      &#125;
      ox = x;
      oy = y;
   &#125;
   sceKernelExitGame&#40;&#41;;
   return 0;
&#125;
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

nice job, thx...

lol...the pad is realy not read inside the loop...

but how did I erase the cursor, befor it moves?

with

Code: Select all

pspDebugScreenClear&#40;&#41;;
i clean the complete LCD...

may be i must disable graphics? and then enable it ?

And a question to a animation:

can i use:

Code: Select all

int x = 0;
int i;

Image* array&#91;3&#93;;
array&#91;0&#93; = loadImage&#40;"1.png"&#41;;
array&#91;1&#93; = loadImage&#40;"2.png"&#41;;
array&#91;2&#93; = loadImage&#40;"3.png"&#41;;

blitImageToScreen&#40;0 ,0 ,479 , 271, x, 0, 0&#41;;
for&#40;i=0;i<3;i++&#41; x++
what is wrong?
the PSP freeze...

or can i use animated gifs in Homebrew, with SDL ?
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

_.-noel-._ wrote:nice job, thx...

lol...the pad is realy not read inside the loop...

but how did I erase the cursor, befor it moves?
Erasing the cursor means you save what is under where the cursor is about to be drawn, then redraw that before drawing the cursor at its new location.
And a question to a animation:

can i use:

Code: Select all

int x = 0;
int i;

Image* array&#91;3&#93;;
array&#91;0&#93; = loadImage&#40;"1.png"&#41;;
array&#91;1&#93; = loadImage&#40;"2.png"&#41;;
array&#91;2&#93; = loadImage&#40;"3.png"&#41;;

blitImageToScreen&#40;0 ,0 ,479 , 271, x, 0, 0&#41;;
for&#40;i=0;i<3;i++&#41; x++
what is wrong?
the PSP freeze...

or can i use animated gifs in Homebrew, with SDL ?
With anigifs, you'd have to decode each frame into an array, rather like how you load the three pngs above. Your code for that SHOULD be:

Code: Select all

   for&#40;i=0;i<3;i++&#41;
  &#123;
      blitImageToScreen&#40;0 ,0 ,479 , 271, array&#91;i&#93;, 0, 0&#41;;
      sceDisplayWaitVblankStart&#40;&#41;;
      flipScreen&#40;&#41;;
      sceKernelDelayThread&#40;100*1000&#41;;
   &#125;
The delay sets the frames per second. 100 ms yields ten frames per second. If you want a second per frame, use 1*1000*1000 instead.
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

cool, thx...

my last question(i hope) is:

what is the last parameter for

Code: Select all

blitImageToImage&#40;0, 0, 10, 10, cursor, x, y, *?*&#41;;
must this be the picture, where "cursor" is over the picture, may be "bg" ?
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

_.-noel-._ wrote:cool, thx...

my last question(i hope) is:

what is the last parameter for

Code: Select all

blitImageToImage&#40;0, 0, 10, 10, cursor, x, y, *?*&#41;;
must this be the picture, where "cursor" is over the picture, may be "bg" ?
On Image to Image, the last parameter is the destination image of course.

Here's the latest fixes I made to the code above. This one shows a background behind the cursor, and I remembered to take into account the cursor alpha. Take a look at the cursor in the arc. Notice that all unset pixels are transparent. When you load a png using loadImage(), it sets an alpha based on the transparency in the png. That way you can do blitAlphaImageToScreen() and have the transparent parts work right. That allows for sprites and cursors and such. Oh, and I fixed the boolean operator on the cursor move test so that it shows the move if EITHER x OR y is different.

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspumd.h>
#include <string.h>
#include <stdlib.h>

#include "graphics.h"
#include "framebuffer.h"

#include <png.h>

PSP_MODULE_INFO&#40;"lol", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;

#define printf pspDebugScreenPrintf
#define MAX&#40;X, Y&#41; &#40;&#40;X&#41; > &#40;Y&#41; ? &#40;X&#41; &#58; &#40;Y&#41;&#41;

void dump_threadstatus&#40;void&#41;;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
   sceKernelExitGame&#40;&#41;;
   return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
   int cbid;

   cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
   sceKernelRegisterExitCallback&#40;cbid&#41;;
   sceKernelSleepThreadCB&#40;&#41;;

   return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
   int thid = 0;

   thid = sceKernelCreateThread&#40;"update_thread", CallbackThread,
                 0x11, 0xFA0, 0, 0&#41;;
   if&#40;thid >= 0&#41;
   &#123;
      sceKernelStartThread&#40;thid, 0, 0&#41;;
   &#125;

   return thid;
&#125;

int x = 0;
int y = 0;
int ox;
int oy;


int main&#40;void&#41;
&#123;
   SceCtrlData pad;
   Image* cursor;
   Image* background;

   pspDebugScreenInit&#40;&#41;;
   pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
   pspDebugScreenSetTextColor&#40;0&#41;;

   SetupCallbacks&#40;&#41;;

   initGraphics&#40;&#41;;
   sceCtrlSetSamplingMode&#40;1&#41;;
   sceCtrlSetSamplingCycle&#40;0&#41;;
   sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;

   background = loadImage&#40;"background.png"&#41;;
   if &#40;!background&#41;
   &#123;
      printf&#40;" Couldn't load background.png!\n"&#41;;
      sceKernelExitGame&#40;&#41;;
   &#125;
   cursor = loadImage&#40;"cursor.png"&#41;;
   if &#40;!cursor&#41;
   &#123;
      printf&#40;" Couldn't load cursor.png!\n"&#41;;
      sceKernelExitGame&#40;&#41;;
   &#125;
   blitImageToScreen&#40;0 ,0 , 480, 272, background, 0, 0&#41;;
   blitAlphaImageToScreen&#40;0 ,0 , 10, 10, cursor, x, y&#41;; // show initially
   sceDisplayWaitVblankStart&#40;&#41;;
   flipScreen&#40;&#41;;

   while&#40;1&#41;
   &#123;
      sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
      if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; break;

      if &#40;pad.Lx > 150&#41; x++;
      if &#40;pad.Lx < 110&#41; x--;
      if &#40;pad.Ly > 150&#41; y++;
      if &#40;pad.Ly < 110&#41; y--;
      if &#40;x < 0&#41; x = 0;
      else if &#40;x > 479&#41; x = 479;
      if &#40;y < 0&#41; y = 0;
      else if &#40;y > 271&#41; y = 271;

      if&#40;x != ox || y != oy&#41;
      &#123;
         blitImageToScreen&#40;0 ,0 , 480, 272, background, 0, 0&#41;;
         blitAlphaImageToScreen&#40;0 ,0 , 10, 10, cursor, x, y&#41;;
         sceDisplayWaitVblankStart&#40;&#41;;
         flipScreen&#40;&#41;;
      &#125;
      ox = x;
      oy = y;
   &#125;
   sceKernelExitGame&#40;&#41;;
   return 0;
&#125;
EBOOT.PBP, background.png, and cursor.png:
http://www.mediafire.com/?8g0tuzjmnmo
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Oh, if you want a faster cursor, you can change the pad code to be like this:

Code: Select all

      if &#40;pad.Lx > 144&#41; x+=&#40;pad.Lx-128&#41;>>4;
      if &#40;pad.Lx < 112&#41; x-=&#40;128-pad.Lx&#41;>>4;
      if &#40;pad.Ly > 144&#41; y+=&#40;pad.Ly-128&#41;>>4;
      if &#40;pad.Ly < 112&#41; y-=&#40;128-pad.Ly&#41;>>4;
That makes the cursor move farther the more you push the analog pad.
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

wow...
thanks...

"i love u"
JoKe

you have help me a lot...

and all the others ;)

next question comes in

8-16 hurs
(i musst sleep...
at my time its 11.38 pm [or 23.38])

CyA all
/=0
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Another update. You asked about anigif earlier - well here's a compile of giflib for the PSP and modifications to the test app to show how to use anigifs in the program. Maybe not the most efficient method, but simple. It creates one image for the anigif, then converts the current frame into image format before blitting it. If you had more anigifs to deal with, maybe you'd allocate enough images to hold all the frames, then convert them at the start of the app.

Two archives.

The test app - code as well as EBOOT and required files.
http://www.mediafire.com/?0pkxfndolbz

GIFLIB - the whole directory already compiled. You can just decompress it, cd to lib and "make install" to install the lib and include.
http://www.mediafire.com/?etzdjrhxuzd

Making giflib was pretty much like making flac (or many other libs).

Code: Select all

Making giflib on the PSP
========================

1 - Download latest giflib source archive from SourceForge.

http&#58;//sourceforge.net/project/showfiles.php?group_id=102202&package_id=119585

2 - Unpack archive.

3 - Edit config.sub&#58; look for

	ps2&#41;
		basic_machine=i386-ibm
		;;


and paste this right after it

	psp&#41;
		basic_machine=mipsallegrexel-psp
		os=-elf
		;;

4 - Run&#58;

CFLAGS="-ffast-math -fsigned-char -G0" LDFLAGS="-L$&#40;psp-config --pspsdk-path&#41;/lib -lc -lpspuser" ./configure --host=psp --prefix=$&#40;psp-config --psp-prefix&#41;
cd lib
make
make install
The only odd thing is gif_err.c uses fprintf(stderr,...), and I wasn't sure what to do about stderr, so if you look at main.c for the code, you'll see I just fake it. If anyone has better stderr code, please post it. :)
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

edited!

Post by _.-noel-._ »

J.F. wrote:
_.-noel-._ wrote:cool, thx...

my last question(i hope) is:

what is the last parameter for

Code: Select all

blitImageToImage&#40;0, 0, 10, 10, cursor, x, y, *?*&#41;;
must this be the picture, where "cursor" is over the picture, may be "bg" ?
On Image to Image, the last parameter is the destination image of course.

Okay, but what is "destination image" i don't understand it...

---

Can i use in

Code: Select all

blitImageToScreen
this:

Code: Select all

blitImageToScreen&#40;0 ,0 ,cusror->imageHeight , cursor->imageWidth, cursor, 0, 0&#41;;
And, in

Code: Select all

      if&#40;x != ox || y != oy&#41;
      &#123;
         blitImageToScreen&#40;0 ,0 , 480, 272, background, 0, 0&#41;;
         blitAlphaImageToScreen&#40;0 ,0 , 10, 10, cursor, x, y&#41;;
         sceDisplayWaitVblankStart&#40;&#41;;
         flipScreen&#40;&#41;;
      &#125;
must there the

Code: Select all

blitImageToScreen&#40;0 ,0 , 480, 272, background, 0, 0&#41;;
because i have an animated background, and if i move the pad, it load the animation new... or not ?

--edit--

okay, new problem...

i want to load 22 pictures, but when i start the program, it load not all images.. then the psp freeze and shut down....

is the psp ram full?
what is happened?

my code:

Code: Select all

void load&#40;void&#41;
&#123;

     Image* load&#91;22&#93;;

     load&#91;0&#93; = loadImage&#40;"images/load/1.png"&#41;;

     load&#91;1&#93; = loadImage&#40;"images/load/2.png"&#41;;

     load&#91;2&#93; = loadImage&#40;"images/load/3.png"&#41;;
	 load&#91;3&#93; = loadImage&#40;"images/load/4.png"&#41;;
	 load&#91;4&#93; = loadImage&#40;"images/load/5.png"&#41;;
	 load&#91;5&#93; = loadImage&#40;"images/load/6.png"&#41;;
	 load&#91;6&#93; = loadImage&#40;"images/load/7.png"&#41;;
	 load&#91;7&#93; = loadImage&#40;"images/load/8.png"&#41;;
	 load&#91;8&#93; = loadImage&#40;"images/load/9.png"&#41;;
	 load&#91;9&#93; = loadImage&#40;"images/load/10.png"&#41;;
	 load&#91;10&#93; = loadImage&#40;"images/load/11.png"&#41;;
	 load&#91;11&#93; = loadImage&#40;"images/load/12.png"&#41;;
	 load&#91;12&#93; = loadImage&#40;"images/load/13.png"&#41;;
	 load&#91;13&#93; = loadImage&#40;"images/load/14.png"&#41;;
	 load&#91;14&#93; = loadImage&#40;"images/load/15.png"&#41;;
	 load&#91;15&#93; = loadImage&#40;"images/load/16.png"&#41;;
	 load&#91;16&#93; = loadImage&#40;"images/load/17.png"&#41;;
	 load&#91;17&#93; = loadImage&#40;"images/load/18.png"&#41;;
	 load&#91;18&#93; = loadImage&#40;"images/load/19.png"&#41;;
	 load&#91;19&#93; = loadImage&#40;"images/load/20.png"&#41;;
	 load&#91;20&#93; = loadImage&#40;"images/load/21.png"&#41;;
	 load&#91;21&#93; = loadImage&#40;"images/load/22.png"&#41;;
	for&#40;i=0;i<20;i++&#41;
	&#123;
	if &#40;!load&#91;i&#93;&#41;
	&#123;
		printf&#40;" Couldn't load&#58; load&#91;i&#93;!\n"&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	&#125;

	for&#40;i=0;i<22;i++&#41;
	&#123;
		blitImageToScreen&#40;0 ,0 ,479 , 271, load&#91;i&#93;, 0, 0&#41;;
		sceDisplayWaitVblankStart&#40;&#41;;
		flipScreen&#40;&#41;;
                freeImage&#40;load&#91;i&#93;&#41;;
		sceKernelDelayThread&#40;100*1000&#41;;
	&#125;

&#125;
but the psp freeze may be after image 19 or 20 ...
Sry for my english
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

okay, i have tested, it show all images...
but, now, i have a new problem...
hire is my code...
i don't know, what is wrong?
after

Code: Select all

splash&#40;&#41;;
the psp LCD is black, and it goes to the XMB...

Code:

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspumd.h>
#include <string.h>
#include <stdlib.h>
#include "wait.h"
#include "graphics.h"
#include "framebuffer.h"
#include <png.h>

PSP_MODULE_INFO&#40;"lol", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;

#define printf pspDebugScreenPrintf

void dump_threadstatus&#40;void&#41;;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread,
				     0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

int x = 0;
int y = 0;
int ox;
int oy;
int i;

void splash&#40;void&#41; &#123;
	Image* splash;
	splash = loadImage&#40;"images/splash.png"&#41;;
	if &#40;!splash&#41;
	&#123;
		printf&#40;" Couldn't load splash!\n"&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	sceDisplayWaitVblankStart&#40;&#41;;
	blitImageToScreen&#40;0 ,0 ,480 , 272, splash, 0, 0&#41;;
	flipScreen&#40;&#41;;
	wait&#40;240&#41;;
&#125;

void load&#40;void&#41;
&#123;

     Image* load&#91;22&#93;;

     load&#91;0&#93; = loadImage&#40;"images/load/1.png"&#41;;

     load&#91;1&#93; = loadImage&#40;"images/load/2.png"&#41;;

     load&#91;2&#93; = loadImage&#40;"images/load/3.png"&#41;;
	 load&#91;3&#93; = loadImage&#40;"images/load/4.png"&#41;;
	 load&#91;4&#93; = loadImage&#40;"images/load/5.png"&#41;;
	 load&#91;5&#93; = loadImage&#40;"images/load/6.png"&#41;;
	 load&#91;6&#93; = loadImage&#40;"images/load/7.png"&#41;;
	 load&#91;7&#93; = loadImage&#40;"images/load/8.png"&#41;;
	 load&#91;8&#93; = loadImage&#40;"images/load/9.png"&#41;;
	 load&#91;9&#93; = loadImage&#40;"images/load/10.png"&#41;;
	 load&#91;10&#93; = loadImage&#40;"images/load/11.png"&#41;;
	 load&#91;11&#93; = loadImage&#40;"images/load/12.png"&#41;;
	 load&#91;12&#93; = loadImage&#40;"images/load/13.png"&#41;;
	 load&#91;13&#93; = loadImage&#40;"images/load/14.png"&#41;;
	 load&#91;14&#93; = loadImage&#40;"images/load/15.png"&#41;;
	 load&#91;15&#93; = loadImage&#40;"images/load/16.png"&#41;;
	 load&#91;16&#93; = loadImage&#40;"images/load/17.png"&#41;;
	 load&#91;17&#93; = loadImage&#40;"images/load/18.png"&#41;;
	 load&#91;18&#93; = loadImage&#40;"images/load/19.png"&#41;;
	 load&#91;19&#93; = loadImage&#40;"images/load/20.png"&#41;;
	 load&#91;20&#93; = loadImage&#40;"images/load/21.png"&#41;;
	 load&#91;21&#93; = loadImage&#40;"images/load/22.png"&#41;;
	for&#40;i=0;i<22;i++&#41;
	&#123;
	if &#40;!load&#91;i&#93;&#41;
	&#123;
		printf&#40;" Couldn't load&#58; load!\n"&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	&#125;

	for&#40;i=0;i<22;i++&#41;
	&#123;
		blitImageToScreen&#40;0 ,0 ,479 , 271, load&#91;i&#93;, 0, 0&#41;;
		sceDisplayWaitVblankStart&#40;&#41;;
		flipScreen&#40;&#41;;
		sceKernelDelayThread&#40;1*1000*1000&#41;;
	&#125;

&#125;

void border&#40;void&#41;
&#123;
	Image* border;
	border = loadImage&#40;"images/border.png"&#41;;
	if &#40;!border&#41;
	&#123;
		printf&#40;" Couldn't load border.png!\n"&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	sceDisplayWaitVblankStart&#40;&#41;;
	blitImageToScreen&#40;0 ,0 ,480 , 272, border, 0, 0&#41;;
	flipScreen&#40;&#41;;
&#125;
int main&#40;void&#41;
&#123;
	
	SceCtrlData pad;
	
	Image* cursor;

	pspDebugScreenInit&#40;&#41;;
	pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
	pspDebugScreenSetTextColor&#40;0&#41;;

	SetupCallbacks&#40;&#41;;

	initGraphics&#40;&#41;;
	sceCtrlSetSamplingMode&#40;1&#41;;
	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;; 
	
	cursor = loadImage&#40;"images/cursor.png"&#41;;
	if &#40;!cursor&#41;
	&#123;
		printf&#40;" Couldn't load cursor.png!\n"&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;


	splash&#40;&#41;;
	load&#40;&#41;;
	
	Image* lines&#91;20&#93;;
	lines&#91;0&#93; = loadImage&#40;"images/lines/1.png"&#41;;

    lines&#91;1&#93; = loadImage&#40;"images/lines/2.png"&#41;;

    lines&#91;2&#93; = loadImage&#40;"images/lines/3.png"&#41;;
	lines&#91;3&#93; = loadImage&#40;"images/lines/4.png"&#41;;
	lines&#91;4&#93; = loadImage&#40;"images/lines/5.png"&#41;;
	lines&#91;5&#93; = loadImage&#40;"images/lines/6.png"&#41;;
	lines&#91;6&#93; = loadImage&#40;"images/lines/7.png"&#41;;
	lines&#91;7&#93; = loadImage&#40;"images/lines/8.png"&#41;;
	lines&#91;8&#93; = loadImage&#40;"images/lines/9.png"&#41;;
	lines&#91;9&#93; = loadImage&#40;"images/lines/10.png"&#41;;
	lines&#91;10&#93; = loadImage&#40;"images/lines/11.png"&#41;;
	lines&#91;11&#93; = loadImage&#40;"images/lines/12.png"&#41;;
	lines&#91;12&#93; = loadImage&#40;"images/lines/13.png"&#41;;
	lines&#91;13&#93; = loadImage&#40;"images/lines/14.png"&#41;;
	lines&#91;14&#93; = loadImage&#40;"images/lines/15.png"&#41;;
	lines&#91;15&#93; = loadImage&#40;"images/lines/16.png"&#41;;
	lines&#91;16&#93; = loadImage&#40;"images/lines/17.png"&#41;;
	lines&#91;17&#93; = loadImage&#40;"images/lines/18.png"&#41;;
	lines&#91;18&#93; = loadImage&#40;"images/lines/19.png"&#41;;
	lines&#91;19&#93; = loadImage&#40;"images/lines/20.png"&#41;;
	for&#40;i=0;i<20;i++&#41;
	&#123;
	if &#40;!lines&#91;i&#93;&#41;
	&#123;
		printf&#40;" Couldn't load&#58; lines&#91;i&#93;!\n"&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	&#125;
	
	//border&#40;&#41;;
	blitAlphaImageToScreen&#40;0 ,0 , 10, 10, cursor, x, y&#41;;
	sceDisplayWaitVblankStart&#40;&#41;;
	flipScreen&#40;&#41;;
	
	for&#40;i=0;i<20;i++&#41;
	&#123;
		blitImageToScreen&#40;0 ,0 ,479 , 271, lines&#91;i&#93;, 0, 0&#41;;
		sceDisplayWaitVblankStart&#40;&#41;;
		flipScreen&#40;&#41;;
		sceKernelDelayThread&#40;1*1000*1000&#41;;
	
	while&#40;1&#41;
	&#123;
	
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
		if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; sceKernelExitGame&#40;&#41;;

		if &#40;pad.Lx > 150&#41; x++;
		if &#40;pad.Lx < 110&#41; x--;
		if &#40;pad.Ly > 150&#41; y++;
		if &#40;pad.Ly < 110&#41; y--;
		if &#40;x < 0&#41; x = 0;
		else if &#40;x > 479&#41; x = 479;
		if &#40;y < 0&#41; y = 0;
		else if &#40;y > 271&#41; y = 271;

		if&#40;x != ox || y != oy&#41;
		&#123;
			blitImageToScreen&#40;0 ,0 , 480, 272, lines&#91;i&#93;, 0, 0&#41;;
			blitAlphaImageToScreen&#40;0 ,0 , 10, 10, cursor, x, y&#41;;
			sceDisplayWaitVblankStart&#40;&#41;;
			flipScreen&#40;&#41;;
		&#125;
		ox = x;
		oy = y;
	&#125;
	if&#40;i==20&#41; i=0;
	&#125;
	return 0;
&#125;

i dont know, how i must load the animated background...
i have tried this....but i think it dont work...

but so far, i didn't come ^^
because after "splash" the psp goto the XMB...
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

To answer a few questions:

blitImage2Image() blits one image into a second image. You would use this if the image you wanted to blit to the screen was made of multiple images that you wanted to put together at the start rather than during the main loop.

Your program clearly exits in splash because it didn't load. You couldn't see the printf because you don't wait after printing - you just exit. Put a wait after any printing so you have time to read the message.

In my example, I had one background image, but you can have as many as you like (or have memory for). You could have

Code: Select all

blitImageToScreen&#40;0 ,0 , 480, 272, background&#91;currBack&#93;, 0, 0&#41;;
and change currBack under various conditions. You could also construct the background image from lots of smaller images. That is common in 2D games. The main 480x272 background could be drawn from 60x34 smaller images of 8x8 each. Rather than describe the background, you describe which 8x8 cell makes each spot in the 60x34 map. That is where the blitImage2Image comes in handy. You go in a loop of 60x34 where you look up which source cell to blit into the background image.
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

thx, bit the last thing i didnt understand...

i have edited my code, befor you post...

now, i load, the "load", and after that, the cursor, the border(at top) and the animated background...

but i won't work fine...
here is my code:

Code: Select all

#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspumd.h>
#include <string.h>
#include <stdlib.h>
#include "wait.h"
#include "graphics.h"
#include "framebuffer.h"
#include <png.h>

PSP_MODULE_INFO&#40;"--", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;

#define printf pspDebugScreenPrintf

void dump_threadstatus&#40;void&#41;;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread,
				     0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

int x = 0;
int y = 0;
int i;
int error = 0;

int main&#40;void&#41;
&#123;
	
	SceCtrlData pad;
	
	Image* splash;
	Image* cursor;
	Image* border;
	Image* load&#91;19&#93;;
	Image* lines&#91;19&#93;;
	
	pspDebugScreenInit&#40;&#41;;
	pspDebugScreenClear&#40;&#41;;
	pspDebugScreenSetBackColor&#40;0xFFFFFFFF&#41;;
	pspDebugScreenSetTextColor&#40;0&#41;;

	SetupCallbacks&#40;&#41;;

	initGraphics&#40;&#41;;
	sceCtrlSetSamplingMode&#40;1&#41;;
	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;; 

	cursor = loadImage&#40;"images/cursor.png"&#41;;
	if &#40;!cursor&#41;
	&#123;
		printf&#40;" Couldn't load cursor.png!\n"&#41;;
		wait&#40;240&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	border = loadImage&#40;"images/border.png"&#41;;
	if &#40;!border&#41;
	&#123;
		printf&#40;" Couldn't load border.png!\n"&#41;;
		wait&#40;240&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	splash = loadImage&#40;"images/splash.png"&#41;;
	if &#40;!splash&#41;
	&#123;
		printf&#40;" Couldn't load splash!\n"&#41;;
		wait&#40;240&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	
	
	sceDisplayWaitVblankStart&#40;&#41;;
	blitImageToScreen&#40;0 ,0 , splash->imageWidth, splash->imageHeight, splash, 0, 0&#41;;
	printTextScreen&#40;140, 262, "Please wait, while loading...", 0&#41;;
	flipScreen&#40;&#41;;
	freeImage&#40;splash&#41;;

    load&#91;0&#93; = loadImage&#40;"images/load/1.png"&#41;;

    load&#91;1&#93; = loadImage&#40;"images/load/2.png"&#41;;

    load&#91;2&#93; = loadImage&#40;"images/load/3.png"&#41;;
	load&#91;3&#93; = loadImage&#40;"images/load/4.png"&#41;;
	load&#91;4&#93; = loadImage&#40;"images/load/5.png"&#41;;
	load&#91;5&#93; = loadImage&#40;"images/load/6.png"&#41;;
	load&#91;6&#93; = loadImage&#40;"images/load/7.png"&#41;;
	load&#91;7&#93; = loadImage&#40;"images/load/8.png"&#41;;
	load&#91;8&#93; = loadImage&#40;"images/load/9.png"&#41;;
	load&#91;9&#93; = loadImage&#40;"images/load/10.png"&#41;;
	load&#91;10&#93; = loadImage&#40;"images/load/11.png"&#41;;
	load&#91;11&#93; = loadImage&#40;"images/load/12.png"&#41;;
	load&#91;12&#93; = loadImage&#40;"images/load/13.png"&#41;;
	load&#91;13&#93; = loadImage&#40;"images/load/14.png"&#41;;
	load&#91;14&#93; = loadImage&#40;"images/load/15.png"&#41;;
	load&#91;15&#93; = loadImage&#40;"images/load/16.png"&#41;;
	load&#91;16&#93; = loadImage&#40;"images/load/17.png"&#41;;
	load&#91;17&#93; = loadImage&#40;"images/load/18.png"&#41;;
	load&#91;18&#93; = loadImage&#40;"images/load/19.png"&#41;;
	//load&#91;19&#93; = loadImage&#40;"images/load/20.png"&#41;;
	//load&#91;20&#93; = loadImage&#40;"images/load/21.png"&#41;;
	//load&#91;21&#93; = loadImage&#40;"images/load/22.png"&#41;;
	for&#40;i=0;i<19;i++&#41;
	&#123;
		blitImageToScreen&#40;0 ,0 , load&#91;i&#93;->imageWidth, load&#91;i&#93;->imageHeight, load&#91;i&#93;, 0, 0&#41;;
		sceDisplayWaitVblankStart&#40;&#41;;
		flipScreen&#40;&#41;;
		freeImage&#40;load&#91;i&#93;&#41;;
		sceKernelDelayThread&#40;100*1000&#41;;
	&#125;
	//-----------------------------------------------------------------------------------------------------//
	//-----------------------------------------------------------------------------------------------------//
	lines&#91;0&#93; = loadImage&#40;"images/lines/1.png"&#41;;

    lines&#91;1&#93; = loadImage&#40;"images/lines/2.png"&#41;;

    lines&#91;2&#93; = loadImage&#40;"images/lines/3.png"&#41;;
	lines&#91;3&#93; = loadImage&#40;"images/lines/4.png"&#41;;
	lines&#91;4&#93; = loadImage&#40;"images/lines/5.png"&#41;;
	lines&#91;5&#93; = loadImage&#40;"images/lines/6.png"&#41;;
	lines&#91;6&#93; = loadImage&#40;"images/lines/7.png"&#41;;
	lines&#91;7&#93; = loadImage&#40;"images/lines/8.png"&#41;;
	lines&#91;8&#93; = loadImage&#40;"images/lines/9.png"&#41;;
	lines&#91;9&#93; = loadImage&#40;"images/lines/10.png"&#41;;
	lines&#91;10&#93; = loadImage&#40;"images/lines/11.png"&#41;;
	lines&#91;11&#93; = loadImage&#40;"images/lines/12.png"&#41;;
	lines&#91;12&#93; = loadImage&#40;"images/lines/13.png"&#41;;
	lines&#91;13&#93; = loadImage&#40;"images/lines/14.png"&#41;;
	lines&#91;14&#93; = loadImage&#40;"images/lines/15.png"&#41;;
	lines&#91;15&#93; = loadImage&#40;"images/lines/16.png"&#41;;
	lines&#91;16&#93; = loadImage&#40;"images/lines/17.png"&#41;;
	lines&#91;17&#93; = loadImage&#40;"images/lines/18.png"&#41;;
	lines&#91;18&#93; = loadImage&#40;"images/lines/19.png"&#41;;
	//lines&#91;19&#93; = loadImage&#40;"images/lines/20.png"&#41;;
	pspDebugScreenClear&#40;&#41;;
	while&#40;1&#41;&#123;
	for&#40;i=0;i<19;i++&#41;
	&#123;
		blitImageToScreen&#40;0 ,0 , lines&#91;i&#93;->imageWidth, lines&#91;i&#93;->imageHeight, lines&#91;i&#93;, 0, 0&#41;;
		blitAlphaImageToScreen&#40;0, 0, border->imageWidth, border->imageHeight, border, 0, 0&#41;;
		blitAlphaImageToScreen&#40;0 ,0 , cursor->imageWidth, cursor->imageHeight, cursor, x, y&#41;;
		sceDisplayWaitVblankStart&#40;&#41;;
		flipScreen&#40;&#41;;
		sceDisplayWaitVblankStart&#40;&#41;;
		flipScreen&#40;&#41;;
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
		if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; printf&#40;"lol"&#41;;

		if &#40;pad.Lx > 144&#41; x+=&#40;pad.Lx-128&#41;>>4;
		if &#40;pad.Lx < 112&#41; x-=&#40;128-pad.Lx&#41;>>4;
		if &#40;pad.Ly > 144&#41; y+=&#40;pad.Ly-128&#41;>>4;
		if &#40;pad.Ly < 112&#41; y-=&#40;128-pad.Ly&#41;>>4;
		if &#40;x < 0&#41; x = 0;
		else if &#40;x > 479&#41; x = 479;
		if &#40;y < 0&#41; y = 0;
		else if &#40;y > 271&#41; y = 271;
	&#125;
	&#125;
	return 0;
&#125;
i dont know, how i can "make" i++ and the other loop...
...

I hope somebody can fix this for me <3

The background must be animated, the cursor must move, and the border must stay there ^^

at my code, all this work, but it always load "all"...
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, you flip the screen twice in your loop. That means you'll never see anything but the second screen. Only flip once per loop. Get rid of the second

Code: Select all

      sceDisplayWaitVblankStart&#40;&#41;;
      flipScreen&#40;&#41;;
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

oO

and then it works perfectly?
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

_.-noel-._ wrote:oO

and then it works perfectly?
Assuming you made your images right, it should at least show something. :)

Remember when making the pngs to make the background transparent in whatever picture editing software you're using. I use GIMP, and when you make a new image, you have to go into "Advanced options" and set "Fill with:" to "Transparency". If your image is solid, blitAlphaImageToScreen() will simply overwrite everything that was there before.

Look at that cursor in my archive (expand it to 800% for a good view). You'll notice that the area around the cursor is transparent, not filled with a background color.
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

okay..

new problem...

How many Images can i put in an array?

only 19?
(with 480 x 272)

Or can i load the images every time from the MS?
but then the PSP is slower....or?

i have 1 animation with 22 Images ant 1 Animation with 20 Iages...

PlZ Help
Sry for my english
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

J.F. wrote:Another update. You asked about anigif earlier - well here's a compile of giflib for the PSP and modifications to the test app to show how to use anigifs in the program. Maybe not the most efficient method, but simple. It creates one image for the anigif, then converts the current frame into image format before blitting it. If you had more anigifs to deal with, maybe you'd allocate enough images to hold all the frames, then convert them at the start of the app.

Two archives.

The test app - code as well as EBOOT and required files.
http://www.mediafire.com/?0pkxfndolbz

GIFLIB - the whole directory already compiled. You can just decompress it, cd to lib and "make install" to install the lib and include.
http://www.mediafire.com/?etzdjrhxuzd

Making giflib was pretty much like making flac (or many other libs).

Code: Select all

Making giflib on the PSP
========================

1 - Download latest giflib source archive from SourceForge.

http&#58;//sourceforge.net/project/showfiles.php?group_id=102202&package_id=119585

2 - Unpack archive.

3 - Edit config.sub&#58; look for

	ps2&#41;
		basic_machine=i386-ibm
		;;


and paste this right after it

	psp&#41;
		basic_machine=mipsallegrexel-psp
		os=-elf
		;;

4 - Run&#58;

CFLAGS="-ffast-math -fsigned-char -G0" LDFLAGS="-L$&#40;psp-config --pspsdk-path&#41;/lib -lc -lpspuser" ./configure --host=psp --prefix=$&#40;psp-config --psp-prefix&#41;
cd lib
make
make install
The only odd thing is gif_err.c uses fprintf(stderr,...), and I wasn't sure what to do about stderr, so if you look at main.c for the code, you'll see I just fake it. If anyone has better stderr code, please post it. :)
Okay, i can't load the firs file down....

and if i want to compile it at myself, it give me some errors...
and you 2# link goes, but if i want to extract the files, it give me an error...

...
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

_.-noel-._ wrote:okay..

new problem...

How many Images can i put in an array?

only 19?
(with 480 x 272)

Or can i load the images every time from the MS?
but then the PSP is slower....or?

i have 1 animation with 22 Images ant 1 Animation with 20 Iages...

PlZ Help
480x272x4x20 ~ 10MB

Most people don't store the entire image for animations unless they are small. It's better to keep them in some kind of difference format (simple compression) to use less space, then generate them on the fly. You could also load them off the memstick on the fly, but that would slow things down quite a bit. One thing you can do - not use 32 bit images. Using 16 bit images cuts the memory used in half. Especially where you only have opaque/fully transparent pixel data, the 5551 format would be very good for sprites and cursors and such.

MediaFire can get bogged down at times. I've put both directories in a single arc on sendspace here:
http://www.sendspace.com/file/gjlk3c

That link won't last as long as mediafire, but I don't think sendspace bogs down as much BECAUSE they toss old links.
_.-noel-._
Posts: 49
Joined: Mon Aug 13, 2007 12:57 am

Post by _.-noel-._ »

okay, i dont know, what you mean....
Sry for my english
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Look at your images. It's worse than I originally calculated since image dimensions are rounded up to the next power of two so that they can be used as textures. So a 480x272 png loaded as an image will have memory allocated for a 512x512 texture. This is an 8888 (32 bit ABGR) texture, so each texel takes 4 bytes. So the space occupied by one 480x272 image is 512x512x4, or 1MB. So 20 such images will take 20 MB of space. So it's no wonder you're having trouble getting your program to run.

You need to cut back on how you use images. The PSP simply doesn't have the ram for that. You need to compress the images in some manner and only decompress them into a single image when you wish to use it. Or load each image from the memstick when you want it (and put up with the slow down).

First, don't use 480x272 images if you don't need to. Rather than one 480x272 image for borders, make a few small images that handle the corners, a segment of the side, and a segment of the top. Then use those to draw the borders around the screen. One side or the top is all you need - just invert the image to do the other side or bottom. One corner is all you need as well - just flip it around for the corner you want to draw. Do everything you can to conserve space.
Post Reply