-
Notifications
You must be signed in to change notification settings - Fork 0
/
WTIME.C
69 lines (54 loc) · 1.27 KB
/
WTIME.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
char _asm_1(char *);
/* DOS */
#define c_INT_21() _asm_1("\n\tINT\t33\n")
#define c_AH_08() _asm_1("\n\tMOV\tAH,8\n")
#define c_AH_0B() _asm_1("\n\tMOV\tAH,11\n")
/* PC-98 BIOS */
#define c_INT_18() _asm_1("\n\tINT\t24\n")
#define c_AH_11() _asm_1("\n\tMOV\tAH,17\n")
#define c_AH_12() _asm_1("\n\tMOV\tAH,18\n")
int main(int argc, char *argv[])
{
time_t cur_time = 0;
time_t prev_time = 0;
char c_key;
long wait_time;
long delta_time;
if (argc != 2) {
printf("Please specify time. WTIME.EXE time[s]\n");
exit(1);
}
else {
wait_time = atoi(argv[1]);
}
c_AH_12(); /* cursor off */
c_INT_18();
while (wait_time > 0) {
printf("%5d\r", wait_time);
cur_time = clock();
delta_time = cur_time - prev_time;
if (delta_time > 0) {
if (prev_time != 0) {
wait_time -= delta_time;
}
prev_time = cur_time;
}
c_AH_0B();
if (c_INT_21()==0xFF) {
c_AH_08();
c_key = c_INT_21();
if (c_key=='q' || c_key=='Q') {
printf("Aborting.\n");
c_AH_11();
c_INT_18();
exit(0);
}
}
}
c_AH_11(); /* cursor on */
c_INT_18();
return 0;
}