![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Timers in C within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; ^^ topic could someone write me an example of creating, starting and getting the time of a timer in C? ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() |
^^ topic
could someone write me an example of creating, starting and getting the time of a timer in C? thanks
__________________
[IMG]http://img121.imageshack.us/img121/3852/untitled1copy7rf.png[/IMG] [IMG]http://img99.imageshack.us/img99/9711/newavatarjb9.gif[/IMG] [URL=http://forums.qj.net/showthread.php?t=9733][COLOR=DarkRed]Operation Positive Posting[/COLOR][/URL] [URL=http://forums.qj.net/showthread.php?t=49762][COLOR=Red]Guide to All Guides[/COLOR][/URL] [URL=http://forums.qj.net/showthread.php?t=13798][COLOR=Blue]Posting Guidelines[/COLOR][/URL] [URL=http://forums.qj.net/showthread.php?t=4394][COLOR=Green]Piracy Policy[/COLOR][/URL] [SIZE="3"][URL=http://forums.qj.net/f-general-psp-help-22/t-guide-opening-psp-disassembly-assembly-video-104303.html][COLOR=Red][B][U]PSP Disassembly Assembly Video Tutorial[/U][/B][/COLOR][/URL][/SIZE] |
|
|
|
|
|
#2 |
![]() ![]() ...in a dream...
|
...Your joking... You have the internet, resources, and your asking? PS2dev.org has the resources for such a thing, PSP-OSS's source has it, and your still asking?
Please do not ask around here to be spoon fed. you will not learn anything, Plus, i say you actually look at your freekin setup, the SDK has example already. Im sensing some script kiddies around lately... P.S. In the C/C++ help thread, i am asking for help on rotation, which is not documented in the SDK, or in any source i can find (except rotating frames), or anywhere i could find (google), so this is not a hypicritical statement.
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#3 |
![]() ![]() Muppet Magnet
|
Oh come on, you were far worse when you first started coding. This forum is here for us to help each other.
To answer the original poster's question: I can't remember seeing any specific timer functions in the PSP API, nor do I remember any in stdlib. However, you can easily do what you want by keeping an array of times. To start a timer, just read the current time into a slot in the array. To get how long the timer has been running, get the current time and subtract the value from the array slot. So long as you don't want to receive an event when the timer reaches a certain value, this is a nice simple way to do it. The choice of which timer function to use is up to you. If 1-second resolution is sufficient, then you might as well use stdlib's time() function, and have your array as an array of 32-bit ints. If you need finer resolution, then you might want to use one of the native PSP API functions, from psprtc.h.
__________________
Using firmware v2.00-v3.50? Open up a whole world of homebrew here
The PSP Homebrew Database needs YOU! Your ISP may be illegally wiretapping all your web activity. Stop Phorm Now! Visiting the Edinburgh Festivals? Get practical advice from experts. |
|
|
|
|
|
#4 |
![]() |
im not a programmer yet but i dont like seing the lazyness of people ...thats why i started to program in c+ even though i dont have any experince its very easy
__________________
"The True Master Paralyzes His Opponent Leaving Him Vulnerable to Attack" M.Shinoda V.3.52 M33 [B][FONT="Times New Roman"]Thanks Deturb For Premium.[/FONT][/B] [IMG]http://i118.photobucket.com/albums/o106/ghostENVY/Untitled-2.jpg[/IMG] |
|
|
|
|
|
#5 |
![]() ![]() Psp Dev
|
Whats C+??
|
|
|
|
|
|
#6 | |
![]() |
Quote:
__________________
[URL="http://www.newlilwayne.com"]www.NewLilWayne.com[/URL] |
|
|
|
|
|
|
#7 | |
![]() ![]() Developer
|
Quote:
Code:
// wait for 5 seconds to pass while doing other things
clock_t start_time = sceKernelLibcClock();
while(sceKernelLibcClock() - start_time < 5000000)
{
// do other chores
sceKernelDelayThread(10000); // wait 10 milliseconds (optional)
}
|
|
|
|
|
|
|
#8 |
![]() |
Erm, well, I just want to have something to be able to countdown any number of hours and minutes, and display the remaining time. But from looking at your code, if my desired interval was one second, I would just put that where 5000000 is right now, in microseconds?
__________________
[URL="http://www.newlilwayne.com"]www.NewLilWayne.com[/URL] |
|
|
|
|
|
#9 | |
![]() ![]() Developer
|
Quote:
|
|
|
|
|
|
|
#10 | |
![]() |
Quote:
@SG57 i have searched on google and looked at the pspsdk documentation, but couldnt find any timer functions, so thats why i asked
__________________
[IMG]http://img121.imageshack.us/img121/3852/untitled1copy7rf.png[/IMG] [IMG]http://img99.imageshack.us/img99/9711/newavatarjb9.gif[/IMG] [URL=http://forums.qj.net/showthread.php?t=9733][COLOR=DarkRed]Operation Positive Posting[/COLOR][/URL] [URL=http://forums.qj.net/showthread.php?t=49762][COLOR=Red]Guide to All Guides[/COLOR][/URL] [URL=http://forums.qj.net/showthread.php?t=13798][COLOR=Blue]Posting Guidelines[/COLOR][/URL] [URL=http://forums.qj.net/showthread.php?t=4394][COLOR=Green]Piracy Policy[/COLOR][/URL] [SIZE="3"][URL=http://forums.qj.net/f-general-psp-help-22/t-guide-opening-psp-disassembly-assembly-video-104303.html][COLOR=Red][B][U]PSP Disassembly Assembly Video Tutorial[/U][/B][/COLOR][/URL][/SIZE] |
|
|
|
|
|
|
#11 |
![]() |
int timer;
float timer2; while(1) do{ timer++; timer2 = timer/1000; printf("The timer is currently at %f milliseconds",timer2); pspDebugScreenClear; } I think that would work, not sure about the function stuff, also needs some includes and defines.
__________________
HELP ME HAIRY LEG!!!! I have a 1.5 (downgraded) US PSP [code] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( P | S | P | - | P | r | o | g | r | a | m | m | i | n | g ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ _ _ _ _ _ / \ / \ / \ / \ / \ ( A | d | m | i | n ) \_/ \_/ \_/ \_/ \_/ [/code] Last edited by nathan42100; 04-30-2006 at 11:02 AM.. |
|
|
|
|
|
#12 | |
![]() |
Quote:
__________________
[b][center] [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL] [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center] |
|
|
|
|
|
|
#13 |
|
personally I used this in my C code:
Code:
int timer =time(NULL);
int count = 0;
void main(){
while (1){
int count = (( timer - time (NULL))* -1);
}
return 0;
}
|
|
|
|
|
![]() |
| Tags |
| timers |
| Thread Tools | |
|
|