 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
JesusXP
Joined: 17 Jan 2006 Posts: 80 Location: Ontario, Canada
|
Posted: Thu Feb 09, 2006 1:24 pm Post subject: Problem getting Image to display. |
|
|
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 |
|
 |
NovaCaine
Joined: 20 Dec 2005 Posts: 34 Location: New Zealand
|
Posted: Thu Feb 09, 2006 1:33 pm Post subject: |
|
|
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 |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Thu Feb 09, 2006 1:50 pm Post subject: |
|
|
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 |
|
 |
NovaCaine
Joined: 20 Dec 2005 Posts: 34 Location: New Zealand
|
Posted: Thu Feb 09, 2006 1:59 pm Post subject: |
|
|
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 |
|
 |
Wil
Joined: 23 Feb 2005 Posts: 15 Location: Las Vegas
|
Posted: Thu Feb 09, 2006 2:15 pm Post subject: |
|
|
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 |
|
 |
JesusXP
Joined: 17 Jan 2006 Posts: 80 Location: Ontario, Canada
|
Posted: Thu Feb 09, 2006 2:33 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|