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 

Problem getting Image to display.

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



Joined: 17 Jan 2006
Posts: 80
Location: Ontario, Canada

PostPosted: Thu Feb 09, 2006 1:24 pm    Post subject: Problem getting Image to display. Reply with quote

Hi guys... I'll post my code here, and maybe you can let me know whats wrong, I'm trying to get a picture to display and than control him with the d-pad. This is just mashing together stuff I learned from the scriptscribbler.com/psp tut's...

Code:

/*   
   Program Name: Fuckin Around - Part Deux
   Author: Mark Pereira
   Date: Wed Feb 8, 1:19AM
*/

#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"

#define printf pspDebugScreenPrintf
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

PSP_MODULE_INFO("Fuckin Around - Part Deux", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common){
   sceKernelExitGame();
   return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp){
   int cbid;
   
   cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
   sceKernelRegisterExitCallback(cbid);
   
   sceKernelSleepThreadCB();
   
   return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void){
   int thid = 0;
   
   thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
   if(thid >= 0){
      sceKernelStartThread(thid, 0, 0);
   }
   
   return thid;
}

int main(){

   SceCtrlData pad;
   char buffer[200];
   Image* ourImage;
   
   pspDebugScreenInit();
   SetupCallbacks();
   initGraphics();
   
   sprintf(buffer, "meDude.png");
   ourImage = loadImage(buffer);
   
   if(!ourImage){
      //Image load failed
      printf("Image load failed!\n");
   }else{
      int x = 0;
      int y = 0;

      sceDisplayWaitVblank();
      blitAlphaImageToScreen(0, 0, 32, 32, ourImage, x, y);
      while(1){
         sceDisplayWaitVblankStart();
         
         sceCtrlReadBufferPositive(&pad, 1);

         if(pad.Buttons & PSP_CTRL_LEFT){
            if(x>0){x--;}
         }

         if(pad.Buttons & PSP_CTRL_RIGHT){
            if(x<480-32){x++;}
         }
         
         if(pad.Buttons & PSP_CTRL_UP){
            if(y>0){y--;}
         }
         
         if(pad.Buttons & PSP_CTRL_DOWN){
            if(y<272-32){y++;}
         }
         
      }   
      
      flipScreen();
   }
   
   sceKernelSleepThread();
   return 0;
}



I havent got a clue, please help.... I have compiled (make kxploit) I have placed theDude.png in the same folders on the psp (/fuckinround , /fuckinround2%), No clue now what to do, Any help would be greatly appreciated, thanks.
Back to top
View user's profile Send private message MSN Messenger
NovaCaine



Joined: 20 Dec 2005
Posts: 34
Location: New Zealand

PostPosted: Thu Feb 09, 2006 1:33 pm    Post subject: Reply with quote

Hey JesusXP,

Well for starters your loading an image called meDude.png. Are you able to just load up the image and show it without moving it around?

Is the code just exiting right away or is it just giving you a black screen?

Other than that, I can't see any problems with your code at this point

EDIT: Just trying to run your code now, and noticed that above blitAlphaImageToScreen you should have sceDisplayWaitVblankStart, not sceDisplayWaitVblank.

EDIT2: Hmm, Ok got it compiling now, but I just get a black screen.....

Have to go now, and I don't have the net at home atm, so I'll give it another try tomorrow, unless you've fixed it by then :P
_________________
My work:
TrackBundler for Gripshift


Last edited by NovaCaine on Thu Feb 09, 2006 1:57 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Thu Feb 09, 2006 1:50 pm    Post subject: Reply with quote

Can't see anything special there too. More information would be good, at least what actually happens when you start the program.

Then, my first guess would be the image isn't loaded correctly, so try giving the complete path to your image to the loader first, ie "ms0:/PSP/GAME/YOURFOLDER/meDude.png". That seems to often be the problem with getting data from the stick loaded.
Back to top
View user's profile Send private message Visit poster's website
NovaCaine



Joined: 20 Dec 2005
Posts: 34
Location: New Zealand

PostPosted: Thu Feb 09, 2006 1:59 pm    Post subject: Reply with quote

Thats what I originally thought too, but it loads something, it just doesn't render to the screen. And correct me if I'm wrong JesusXP, but this code looks exactly like lesson 4 from Yeldarb site
_________________
My work:
TrackBundler for Gripshift
Back to top
View user's profile Send private message Visit poster's website
Wil



Joined: 23 Feb 2005
Posts: 15
Location: Las Vegas

PostPosted: Thu Feb 09, 2006 2:15 pm    Post subject: Reply with quote

Uhm... wow. Try this.

Code:
/*   
   Program Name: Fuckin Around - Part Deux
   Author: Mark Pereira
   Date: Wed Feb 8, 1:19AM
*/

#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"

#define printf pspDebugScreenPrintf
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

PSP_MODULE_INFO("Fuckin Around - Part Deux", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common){
   sceKernelExitGame();
   return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp){
   int cbid;
   
   cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
   sceKernelRegisterExitCallback(cbid);
   
   sceKernelSleepThreadCB();
   
   return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void){
   int thid = 0;
   
   thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
   if(thid >= 0){
      sceKernelStartThread(thid, 0, 0);
   }
   
   return thid;
}

int main(){

   SceCtrlData pad;
   Image* ourImage;
   int x = 0;
   int y = 0;
   
   pspDebugScreenInit();
   SetupCallbacks();
   initGraphics();

   ourImage = loadImage("meDude.png");

   while(1){
     
      sceCtrlReadBufferPositive(&pad, 1);

      if(pad.Buttons & PSP_CTRL_LEFT){
         if(x>0){x--;}
      }

      if(pad.Buttons & PSP_CTRL_RIGHT){
         if(x<480-32){x++;}
      }
         
      if(pad.Buttons & PSP_CTRL_UP){
         if(y>0){y--;}
      }
         
      if(pad.Buttons & PSP_CTRL_DOWN){
         if(y<272-32){y++;}
      }

      blitAlphaImageToScreen(0, 0, 32, 32, ourImage, x, y);
      flipScreen();
         
   }

   return 0;
}


*SHOULD* work -- see, you sent the image to the screen buffer and then entered an infinate loop. You never got to flipScreen() so it never displayed. Good luck.

Wil
_________________
Wil
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
JesusXP



Joined: 17 Jan 2006
Posts: 80
Location: Ontario, Canada

PostPosted: Thu Feb 09, 2006 2:33 pm    Post subject: Reply with quote

I was on the irc room with Loco-san and we were able to get it working!!



This is the newly modified code, I really appreciate all the fast feedback, I used #pspdev on efnet as well though, and was able to get some real-time interaction and help. Thanks again though..


And you are correct, this is mostly made up of the code from Lesson 4



Code:


/*   
   Program Name: Fuckin Around - Part Deux
   Author: Mark Pereira
   Date: Wed Feb 8, 1:19AM
*/

#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"

#define printf pspDebugScreenPrintf
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

PSP_MODULE_INFO("Fuckin Around - Part Deux", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common){
   sceKernelExitGame();
   return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp){
   int cbid;
   
   cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
   sceKernelRegisterExitCallback(cbid);
   
   sceKernelSleepThreadCB();
   
   return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void){
   int thid = 0;
   
   thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
   if(thid >= 0){
      sceKernelStartThread(thid, 0, 0);
   }
   
   return thid;
}

int main(){

   SceCtrlData pad;
   char buffer[200];
   Image* ourImage;
   
   pspDebugScreenInit();
   SetupCallbacks();
   initGraphics();
   
   sprintf(buffer, "meDude.png");
   ourImage = loadImage(buffer);
   
   if(!ourImage){
      //Image load failed
      printf("Image load failed!\n");
   }else{
      int x = 0;
      int y = 0;
      sceDisplayWaitVblankStart();
      
      while(1){
         clearScreen(0);
         blitAlphaImageToScreen(0, 0, 32, 32, ourImage, x, y);
         
         
         sceCtrlReadBufferPositive(&pad, 1);

         if(pad.Buttons & PSP_CTRL_LEFT){
            if(x>0){x--;}
         }

         if(pad.Buttons & PSP_CTRL_RIGHT){
            if(x<(480-32)){x++;}
         }
         
         if(pad.Buttons & PSP_CTRL_UP){
            if(y>0){y--;}
         }
         
         if(pad.Buttons & PSP_CTRL_DOWN){
            if(y<(272-32)){y++;}
         }
         sceDisplayWaitVblank();
         flipScreen();
      }   
   
   }
   
   sceKernelSleepThread();
   return 0;
}
Back to top
View user's profile Send private message MSN Messenger
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