![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on whats going wrong here... within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; ok, so im working my way thought the psp-programming.com tutorials, and trying to write a program.... and so... this is ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
ok, so im working my way thought the psp-programming.com tutorials, and trying to write a program.... and so... this is what my program is supposed to do....
start up display a picture write a greeting on the picture stay up for 5 sec or so... and close exsept... what its doing is all of the above but this time the program stops about 1 or 2 sec after startup.... ok, it almost made it to 1sec (just timed it, came in at .92 sec on my watch) and yea, i have tryed playing with all of the varibles for time... its seen its way up to 10000(0?) even... no effect.... and now your asking yourselves... whats the code look like allrety.... so here it comes Code:
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
PSP_MODULE_INFO("Frogless Toad", 0, 1, 1);
#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))
/* 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() {
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
char buffer[200];
char text[100];
char text2[100];
Image* ourImage;
//main body
sprintf(buffer, "wallpaper.png");
ourImage = loadImage(buffer);
if (!ourImage) {
//Image load failed
printf("Image load failed!\n");
} else {
sceDisplayWaitVblankStart();
blitAlphaImageToScreen(0 ,0 ,480 , 272, ourImage, 0, 0);
}
Color text1 = RGB(0,0,0);
sprintf(text, "Hello User...");
printTextScreen(230,20,text,text1);
flipScreen();
int count = 0;
while (1){
if (count >= 5000) {
break;
}
count++;
}
sceKernelExitGame();
//done
sceKernelSleepThread();
return 0;
}
|
|
|
|
|
|
|
#2 |
![]() |
At first glance: You seemed to have confused going through a loop with delaying for 1 ms. That loop will not take 5 seconds, and will not even complete in the same timeframe if your PSP is over/underclocked. That is, if the loop even ends up in the compiled code at all because it might just be optimized out during compilation into a simple count=5000.
You need to use an actual timer function. If you just want to quick and dirty make sure it actually causes a noticable delay, throw a wait for vblank into the middle of your loop. If you want to ignore the delay portion altogether, move the SleepThread up before the ExitGame. The SleepThread's doing nothing now because of it's position behind the ExitGame. That should cause it to at least leave your image or the error on the screen until you press 'home'. One more thing - you probably want to add "disableGraphics(); pspDebugScreenInit();" right before the portion where you print your errormessage about the image failing to load, and get rid of the earlier pspDebugScreenInit(). I don't think you can use the debugging printf's while you're in graphics mode. Last edited by 3vi1; 08-07-2007 at 07:35 PM.. |
|
|
|
|
|
#4 |
![]() QJ Gamer Green
|
i think it was something like vb blank start and something else which i dont recall atm, i did make something just like this as my first solo C project. erased it on a system restore tho and no main.c or makefile or eboot saved for that specific thing, im so stupid
__________________
PSN ID= elmataplata add me... [b]RIP Colin McRae, We'll never forget you! 555 [/b] |
|
|
|
![]() |
| Tags |
| wrong |
| Thread Tools | |
|
|