 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Davidov
Joined: 13 May 2006 Posts: 2 Location: Scotland, UK
|
Posted: Sat May 13, 2006 11:02 pm Post subject: Help with PSP system clock |
|
|
Hello today I started to make a small app that acts as a clock for the PSP.
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
In the code below I have left out the initialisation of time. If anyone knows where Im going wrong whether it be coding or something else that works.
Thanks
| Code: | /*
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 */
} |
Last edited by Davidov on Mon May 15, 2006 5:06 am; edited 1 time in total |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sun May 14, 2006 11:09 am Post subject: |
|
|
Putting this line
#include <psprtc.h>
after this line
#include <pspkernel.h>
might help.
If you're compiling as .c then this
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;
pspTime time;
is all back to front. You can't have declarations inline with the code.
SceCtrlData pad;
pspTime time;
pspDebugScreenInit();
SetupCallbacks();
That will help a bit.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
Davidov
Joined: 13 May 2006 Posts: 2 Location: Scotland, UK
|
Posted: Sun May 14, 2006 10:14 pm Post subject: |
|
|
Ok thanks jim that got rid of that error. However I now get a
make: *** [Clock.elf] Error 1 message when compiling.
I remember I had this problem with another project which occured cause I missed out a required library on the makefile.
So far Ive got -lz but I dont know what other libs I need since just lz worked fine for similar coding,
yet this project includes the psprtc.h file so either Its not working or I need to state the lib for psprtc.h in the makefile.
But thanks jim.
EDIT: Ok i should have done this first but I did a google search there and found the lib i needed to add was -lpsprtc. And it works :) |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Mon May 15, 2006 9:27 am Post subject: |
|
|
| Davidov wrote: | Ok thanks jim that got rid of that error. However I now get a
make: *** [Clock.elf] Error 1 message when compiling.
|
For future reference, thats not the actual error message, just make informing you that it's quiting because something earlier failed.. It is completely unhelpful when trying to figure out what went wrong... You need to read up a bit higher to get the error message ;) _________________ Shoot Pixels Not People!
Makeshift Development |
|
| 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
|