![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Time Program within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I compiled a program for the PSP from the example here and when I run on my PSP all that ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() PSP User
|
I compiled a program for the PSP from the example here and when I run on my PSP all that is displayed is a blank black screen. I was wondering if anyone could help me make the program run correctly. If it helps, I compiled the program using the envioronment from Yeldarb's tutorials. I have little knowledge in C and C++ so I could not determine why it would not work. I attached the source code I used. Thanks!
Code:
// Time - Displays the date and time
/*
This program was created by Josh Valdez using a GNU C libarary
example.
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#include <time.h>
#define SIZE 256
PSP_MODULE_INFO("Hello World", 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(void) {
pspDebugScreenInit();
SetupCallbacks();
char buffer[SIZE];
time_t curtime;
struct tm *loctime;
/* Get the current time. */
curtime = time (NULL);
/* Convert it to local time representation. */
loctime = localtime (&curtime);
/* Print out the date and time in the standard format. */
fputs (asctime (loctime), stdout);
/* Print it out in a nice format. */
strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
fputs (buffer, stdout);
strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
fputs (buffer, stdout);
sceKernelSleepThread();
return 0;
}
|
|
|
|
|
|
#3 |
![]() PSP User
|
If what you meant by increasing the buffer was to make SIZE bigger than it did not help. I tried 512, 1024, 2048, and 4096 in place of 256 but it still displayed a blank screen. Any other suggestions? :wall:
Oh, and by the way great tutorials!
|
|
|
|
|
|
#5 |
![]() ![]() Developer
|
Ok i fixed your script so it heres the code and i made the eboot that is in the link.
http://uploadhut.com/success.php?id=243109 // Time - Displays the date and time /* This program was created by Josh Valdez using a GNU C libarary example. */ #include <pspkernel.h> #include <pspdebug.h> #include <stdio.h> #include <time.h> #define SIZE 256 PSP_MODULE_INFO("Hello World", 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); sceKernelRegisterExitCall back(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("up date_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid , 0, 0); } return thid; } int main(void) { pspDebugScreenInit(); SetupCallbacks(); char buffer[SIZE]; time_t curtime; struct tm *loctime; /* Get the current time. */ curtime = time (NULL); /* Convert it to local time representation. */ loctime = localtime (&curtime); /* Print out the date and time in the standard format. */ printf (asctime (loctime), stdout); /* Print it out in a nice format. */ strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime); printf (buffer, stdout); strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime); printf (buffer, stdout); sceKernelSleepThread(); return 0; } But theres one problem. It stays on the exact time and doesnt update..so you might wanna fix that |
|
|
|
|
|
#6 |
![]() NDS Mod
|
Oh man, I'm disappointed.
I came rushing in here thinking someone made a time machine.
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] |
|
|
|
|
|
#7 |
![]() |
Here's a version that will update the time. (Untested)
Code:
// Time - Displays the date and time
/*
This program was created by Josh Valdez using a GNU C libarary
example.
Editted by Yeldarb
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#include <time.h>
PSP_MODULE_INFO("Hello World", 0, 1, 1);
#define printf pspDebugScreenPrintf
#define SIZE 256
/* 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(void) {
pspDebugScreenInit();
SetupCallbacks();
char buffer[SIZE];
time_t curtime, oldtime;
struct tm *loctime;
while(1) {
do {
/* Get the current time. */
curtime = time (NULL);
} while(curtime == oldtime);
oldtime = curtime;
/* Convert it to local time representation. */
loctime = localtime (&curtime);
/* Print out the date and time in the standard format. */
printf (asctime (loctime), stdout);
/* Print it out in a nice format. */
strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
printf (buffer, stdout);
strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
printf (buffer, stdout);
}
sceKernelSleepThread();
return 0;
}
|
|
|
|
|
|
#8 | |
![]() ![]() Developer
|
Quote:
Got some errors with that code.
|
|
|
|
|
|
|
#10 |
![]() ![]() Developer
|
Alright it works now but... its one giant list like it updates by the second going:
Today is... Today is... Today is... It gets pretty hard to read. Oh and the home button doesnt work cuz it freezes on please wait... |
|
|
|
|
|
#14 |
![]() PSP User
|
I altered the code to update the time, but when I run the app on the PSP it adds a day to the current date and changes the hour. This also happens with Yeldarb's edited code. Here's the code I used.
Code:
// Time - Displays the date and time
/*
This program was created by Josh Valdez using a GNU C libarary
example.
Editted by Yeldarb
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#include <time.h>
PSP_MODULE_INFO("Hello World", 0, 1, 1);
#define printf pspDebugScreenPrintf
#define clrscr pspDebugScreenClear
#define SIZE 256
/* 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(void) {
pspDebugScreenInit();
SetupCallbacks();
char buffer[SIZE];
time_t curtime, oldtime;
struct tm *loctime;
while(1) {
do {
/* Get the current time. */
curtime = time (NULL);
} while(curtime == oldtime);
oldtime = curtime;
clrscr();
/* Convert it to local time representation. */
loctime = localtime (&curtime);
/* Print out the date and time in the standard format. */
printf (asctime (loctime), stdout);
/* Print it out in a nice format. */
strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
printf (buffer, stdout);
strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
printf (buffer, stdout);
}
sceKernelSleepThread();
return 0;
}
|
|
|
|
|
|
#15 | |
![]() |
Quote:
Oh, and by the way... your sig is... uhmm... disturbing. Lol, j/k, it's quite funny. Who said that?
__________________
[CENTER] [url=http://www.indepthhacks.info/forums/index.php?][COLOR=DarkSlateGray][SIZE="3"][b]The Banned Club[/SIZE][/COLOR][/url] - join or die[/b] [url=http://www.blingo.com/friends?ref=3DxJIw6buw61_I3ZGGrrYqoaNz0][COLOR=DarkSlateGray][SIZE="3"][b]Blingo[/SIZE][/COLOR][/url] - win stuff while searching Google[/b] [/CENTER] |
|
|
|
|
|
|
#16 | |
![]() |
Quote:
__________________
[CENTER] [url=http://gearsofwar.xbox360.gamebattles.com/stats/10774][img]http://gearsofwar.xbox360.gamebattles.com/card/10774|basic[/img][/url][/center]F*** Pillowpants! Honk if you love or like ****y![/center] |
|
|
|
|
|
|
#17 |
![]() ![]() Developer
|
Come on stay on topic. You shouldn't be posting here unless you are going to be talking about developing the app,helping him, or congratulating him. The spam in the DEVELOPMENT section is getting very annoying. Its starting to become like a general psp chat and speculation(all the topics about" Could someome make me a program for the psp").
Anyways ExxonValdeez Im going to compile your code and see what your talking bout then i try to find whats wrong in the code |
|
|
|
|
|
#18 |
![]() ![]() Developer
|
is yours showing in the 1 am area? because if it is i know what has to be done. If it is we either need to start it out on a certain time so it will match the psp's or find out to use the psp clock because its not right now. It also seems that the date goes up because its using seconds instead.
|
|
|
|
|
|
#20 | |
![]() ![]() Developer
|
Quote:
|
|
|
|
|
|
|
#21 |
![]() |
It's showing GMT guys; (I think) all of the date functions do
![]() You need to set the time zone. You can either hard code it to subtract hours, or I think I saw something about a localtime function on the PSP; run a search on PS2dev forums.
__________________
[url=http://www.barbdwyer.com/footer.php][img]http://www.barbdwyer.com/8Ball.jpg[/img][/url] [FONT=Verdana][SIZE=1] [b]PSP Developer Resource Site:[/b] [url=http://www.psp-programming.com]PSP-Programming.com[/url] [b]Other:[/b] [url=http://wake-boarding.org]Wakeboarding[/url], [url=http://water-skiing.org]Waterskiing[/url], [url=http://wake-surfing.org]Wake Surfing[/url], [url=http://www.guitarhero-4.com]Guitar Hero IV[/url][/SIZE][/FONT] |
|
|
|
|
|
#22 |
![]() PSP User
|
You are right Yeldarb, it is using the GMT time. I put %Z into the code to display what the timezone was and sure enough it was GMT. Now to figure out how to change that to the correct timezone. Here is the updated code:
Code:
// Time - Displays the date and time
/*
This program was created by Josh Valdez using a GNU C libarary
example.
Editted by Yeldarb and Twenty 2
Updated 8/6/2005 1:22PM CST: Added %Z to display timezone.
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#include <time.h>
PSP_MODULE_INFO("Hello World", 0, 1, 1);
#define printf pspDebugScreenPrintf
#define clrscr pspDebugScreenClear
#define SIZE 256
/* 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(void) {
pspDebugScreenInit();
SetupCallbacks();
char buffer[SIZE];
time_t curtime, oldtime;
struct tm *loctime;
while(1) {
do {
/* Get the current time. */
curtime = time (NULL);
} while(curtime == oldtime);
oldtime = curtime;
clrscr();
/* Convert it to local time representation. */
loctime = localtime (&curtime);
/* Print out the date and time in the standard format. */
printf (asctime (loctime), stdout);
/* Print it out in a nice format. */
strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
printf (buffer, stdout);
strftime (buffer, SIZE, "The time is %I:%M %p. %Z\n", loctime);
printf (buffer, stdout);
}
sceKernelSleepThread();
return 0;
}
|
|
|
|
|
|
#23 | |
![]() |
Quote:
|
|
|
|
|
|
|
#25 |
![]() PSP User
|
To Twenty 2: I won't be able to work as much on this project as I am starting school tomorrow so this thread may not be updated often. I hope it is okay if I send you a private message for help if I need it. Thanks!
|
|
|
|
![]() |
| Tags |
| program , time |
| Thread Tools | |
|
|