Add Bocfel interpreter
[projects/chimara/chimara.git] / interpreters / bocfel / zoom.c
1 /*-
2  * Copyright 2010-2012 Chris Spiegel.
3  *
4  * This file is part of Bocfel.
5  *
6  * Bocfel is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License, version
8  * 2 or 3, as published by the Free Software Foundation.
9  *
10  * Bocfel is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Bocfel.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include <stdio.h>
20 #include <time.h>
21
22 #include "zoom.h"
23 #include "screen.h"
24 #include "zterp.h"
25
26 static clock_t start_clock, end_clock;
27
28 void zstart_timer(void)
29 {
30   start_clock = clock();
31 }
32
33 void zstop_timer(void)
34 {
35   end_clock = clock();
36 }
37
38 void zread_timer(void)
39 {
40   store(100 * (end_clock - start_clock) / CLOCKS_PER_SEC);
41 }
42
43 void zprint_timer(void)
44 {
45   char buf[32];
46   snprintf(buf, sizeof buf, "%.2f seconds", (end_clock - start_clock) / (double)CLOCKS_PER_SEC);
47   for(int i = 0; buf[i] != 0; i++) put_char(buf[i]);
48 }