annotate mytype.c @ 55:8cef655f3bf9

*** empty log message ***
author gongo
date Wed, 08 Nov 2006 08:14:39 +0000
parents 0fae5658fb0b
children ce9ef7dcf2f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
1 /*
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
2 * $Id$
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
3 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
4 #include <time.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
5 #include <stdio.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
6 #include "libps2.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
7 #include "ps2util.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
8 #include "mytype.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
9
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
10 static clock_t start;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
11 static clock_t race_start;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
12
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
13 void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
14 wait_init()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
15 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
16 start = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
17 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
18
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
19 /*
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
20 * wait_init()から
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
21 * time秒(マイクロ秒?)すぎたらTRUEを返す
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
22 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
23 Bool
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
24 wait(double time)
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
25 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
26 clock_t t;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
27 double a;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
28
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
29 t = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
30 a = (t-start)/(double)CLOCKS_PER_SEC;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
31 if (a > time) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
32 return TRUE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
33 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
34
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
35 return FALSE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
36 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
37
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
38 void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
39 time_RaceStart()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
40 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
41 race_start = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
42 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
43
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
44 double
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
45 time_RaceTime()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
46 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
47 clock_t t;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
48 double a;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
49
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
50 t = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
51 a = (t-race_start)/(double)CLOCKS_PER_SEC;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
52
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
53 return a;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
54 }