]> 4ch.mooo.com Git - 16.git/blob - src/lib/timer.c
many improvements for testing have been added ^^
[16.git] / src / lib / timer.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #include "src/lib/timer.h"\r
24 \r
25 clock_t start_timer(global_game_variables_t *gv)\r
26 {\r
27         gv->kurokku.t = clock();\r
28         gv->kurokku.tiku = 0;\r
29         gv->kurokku.clock_start = *clockw;\r
30         gv->kurokku.clock = clockw;\r
31         gv->kurokku.frames_per_second = 60;\r
32         //turn this off if XT\r
33         switch(detectcpu())\r
34         {\r
35                 case 0:\r
36                         gv->kurokku.fpscap=0;\r
37                 break;\r
38                 default:\r
39                         gv->kurokku.fpscap=1;\r
40                 break;\r
41         }\r
42         return gv->kurokku.t;\r
43 }\r
44 \r
45 double elapsed_timer(global_game_variables_t *gv)\r
46 {\r
47         return (clock() - gv->kurokku.t) / CLOCKS_PER_SEC;\r
48 }\r
49 \r
50 double ticktock(global_game_variables_t *gv)\r
51 {\r
52         double clocku;\r
53         clocku = (clock() - gv->kurokku.t) / CLOCKS_PER_SEC;\r
54         gv->kurokku.t = clock();\r
55         return clocku;\r
56 }\r
57 \r
58 double time_in_seconds(global_game_variables_t *gv)\r
59 {\r
60         return (gv->kurokku.t) / CLOCKS_PER_SEC;\r
61 }\r
62 \r
63 /*double time_in_seconds(time_t in_t)\r
64 {\r
65         return (in_t) / CLOCKS_PER_SEC;\r
66 }*/\r