annotate mytype.c @ 95:b0249b856488

change_ps2util
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 26 May 2011 18:13:40 +0900
parents 8edae89a3877
children 0b65ca27f113
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>
90
8edae89a3877 compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
6 #include <stdbool.h>
8edae89a3877 compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
7 //#include "libps2.h"
8edae89a3877 compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
8 //#include "ps2util.h"
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
9 #include "mytype.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
10
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
11 static clock_t start;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
12 static clock_t race_start;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
13
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
14 void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
15 wait_init()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
16 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
17 start = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
18 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
19
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
20 /*
88
ce9ef7dcf2f0 convert UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
21 * wait_init()から
ce9ef7dcf2f0 convert UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
22 * time秒(マイクロ秒?)すぎたらTRUEを返す
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
23 */
90
8edae89a3877 compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
24 bool
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
25 wait(double time)
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
26 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
27 clock_t t;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
28 double a;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
29
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
30 t = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
31 a = (t-start)/(double)CLOCKS_PER_SEC;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
32 if (a > time) {
90
8edae89a3877 compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
33 return true;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
34 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
35
90
8edae89a3877 compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
36 return false;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
37 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
38
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
39 void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
40 time_RaceStart()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
41 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
42 race_start = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
43 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
44
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
45 double
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
46 time_RaceTime()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
47 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
48 clock_t t;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
49 double a;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
50
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
51 t = clock();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
52 a = (t-race_start)/(double)CLOCKS_PER_SEC;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
53
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
54 return a;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
55 }