1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669
\r
4 * This file is part of Project 16.
\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
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
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
23 #include "src/lib/16_timer.h"
\r
25 clock_t start_timer(global_game_variables_t *gv)
\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 gv->pee = _nmalloc(sizeof(byte)*16);
\r
33 //turn this off if XT
\r
37 gv->kurokku.fpscap=0;
\r
38 gv->kurokku.frames_per_second=1;
\r
41 gv->kurokku.fpscap=1;
\r
42 gv->kurokku.frames_per_second=60;
\r
45 return gv->kurokku.t;
\r
48 double elapsed_timer(global_game_variables_t *gv)
\r
50 return (clock() - gv->kurokku.t) / CLOCKS_PER_SEC;
\r
53 double ticktock(global_game_variables_t *gv)
\r
56 clocku = (clock() - gv->kurokku.t) / CLOCKS_PER_SEC;
\r
57 gv->kurokku.t = clock();
\r
61 double time_in_seconds(global_game_variables_t *gv)
\r
63 return (gv->kurokku.t) / CLOCKS_PER_SEC;
\r
66 /*double time_in_seconds(time_t in_t)
\r
68 return (in_t) / CLOCKS_PER_SEC;
\r
72 void shinkutxt(global_game_variables_t *gv)
\r
75 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
77 //t=(((*(gv->clock))-gv->clock_start) /18.2);
\r
78 sprintf(gv->pee, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
79 fprintf(stderr, "%s\n", gv->pee);
\r
80 //(gv->clock_start)=*(gv->clock);
\r
84 // switch(gv->kurokku.fpscap)
\r
87 // gv->kurokku.frames_per_second=1;
\r
90 // //turn this off if XT
\r
92 // gv->kurokku.frames_per_second=60;
\r
99 while(inp(INPUT_STATUS_1) & 8) {
\r
103 while(!(inp(INPUT_STATUS_1) & 8)) {
\r