All pastes #769934 Raw Edit

Someone

public text v1 · immutable
·published 2007-11-11 19:37 UTC
rendered paste body
#include <pspdebug.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdisplay.h>

#define RGB(r, g, b) ((b << 16) | (g << 8) | r)
#define BLUE RGB(0, 0, 255)
#define RED RGB(255, 0, 0)
#define GREEN RGB(0, 255, 0)
#define BLACK RGB(0, 0, 0)
#define WHITE RGB(255, 255, 255)
#define printf pspDebugScreenPrintf
#define SetTextColor pspDebugScreenSetTextColor

PSP_MODULE_INFO("Hello World", 0, 1, 1);

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

int CallbackThread(SceSize args, void *argp) {
	int cbid;
	cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
	sceKernelRegisterExitCallback(cbid);
	sceKernelSleepThreadCB();
	return 0;
}

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() {
	SetupCallbacks();
	pspDebugScreenInit();
	int i = 0;
	SceCtrlData pad;
	printf("Press [X] To Start the Timer");

	while(sceCtrlReadBufferPositive(&pad,1)) {
		if (pad.Buttons & PSP_CTRL_CROSS) { break; }
	}

	pspDebugScreenClear();
	printf("Press [O] To Stop the Timer\n");

	while (!(pad.Buttons & PSP_CTRL_CIRCLE)) {
		pspDebugScreenClear();
		printf("Press [O] To Stop the Timer\nCount: %i\n",i++);
		sceCtrlReadBufferPositive(&pad,1);
		sceKernelDelayThread(1000);
	}

	printf("Finished. Press [X] to exit.\n");
	while(sceCtrlReadBufferPositive(&pad,1)) { 
		if(pad.Buttons & PSP_CTRL_CROSS) sceKernelExitGame(); }

	//sceKernelSleepThread();
	//return 0;
}