rendered paste body//Counter App
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
PSP_MODULE_INFO("Counter Program", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* 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();
int i = 0, check = 1;
SceCtrlData pad;
while(check == 1)
{
check = 0;
int counter = 0, cd = 10, del = 0;
printf("Press [X] to start counter.");
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
{
break;
}
}
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CIRCLE)
{
break;
}
pspDebugScreenClear();
printf("Press [O] to stop the timer.\n");
printf("Counter: %i", counter);
counter++;
for(i=0; i<5; i++)
{
sceDisplayWaitVblankStart();
}
}
pspDebugScreenClear();
printf("Counter finished.\n");
printf("Final count: %i\n", counter);
printf("Press [X] to play again or wait 10 seconds to quit.\n");
while(check == 0)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
{
check = 1;
break;
}
for(del=0; del<70; del++)
{
sceDisplayWaitVblankStart();
}
printf("Restart in: %i seconds.\n", cd);
cd--;
if(cd == 1)
{
exit(0);
}
}
}
}