I ran into trouble when compiling as I get various errors where Cywin says that the header psprtc.h supplied with the pspsdk toolchain has syntax errors on almost every line. I also recieve an error due to the command
Code: Select all
pspTime time
Thanks
Code: Select all
/*
System Clock Example
Date: 13 may 2006, 12:15pm GMT
Thanks to www.ps2dev.org for the PSP SDK
*** - - - - IMPORTANT - - - - ***
Copyright (c) 2005 adresd
Copyright (c) 2005 Marcus R. Brown
Copyright (c) 2005 James Forshaw
Copyright (c) 2005 John Kelley
Copyright (c) 2005 Jesper Svennevid
All rights reserved.
*/
#include <psprtc.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("SYS Clock", 0, 0, 1);
//----------------- Callbacks -------------------------------------------------
/* 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;
}
// -------------------- END of Callbacks -------------------------------------
// Main Function
int main(){
// Aditional setup for screen output and control input from pad
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;
// time initialised
pspTime time;
// ~~~~~~~~~~~~~~~~~~~~~ Game loop ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
while (1){
// Get System clock time
sceRtcGetCurrentClockLocalTime(&time);
// Display on screen
printf("The current time is:");
printf("\nhours: %d",time.hour);
printf("\nminutes: %d",time.minutes);
printf("\nseconds: %d",time.seconds);
printf("\tpress x to exit to menu"); // Option to finish program
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS) {
break;
}
for(i=0; i<5; i++) {
sceDisplayWaitVblankStart();
}
pspDebugScreenClear();
}
// ~~~~~~~~~~~~~~~~~~~~~ END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sceKernelExitGame(); // quits back to psp menu
return 0; /* just for good practice as this technically
the program doesnt get to this point */
}