Release 940201
[wine] / misc / int1a.c
1 #include <time.h>
2 #include <stdio.h>
3 #include "wine.h"
4
5 #ifdef linux
6 #include <linux/sched.h> /* needed for HZ */
7 #endif
8
9 #define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
10 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
11
12 int do_int1A(struct sigcontext_struct * context){
13         time_t ltime;
14         struct tm *bdtime;
15         int ticks;
16
17         switch((context->sc_eax >> 8) & 0xff){
18         case 0:
19                 ltime = time(NULL);
20                 ticks = (int) (ltime * HZ);
21                 context->sc_ecx = ticks >> 16;
22                 context->sc_edx = ticks & 0x0000FFFF;
23                 context->sc_eax = 0;  /* No midnight rollover */
24                 break;
25                 
26         case 2: 
27                 ltime = time(NULL);
28                 bdtime = localtime(&ltime);
29                 
30                 context->sc_ecx = (BIN_TO_BCD(bdtime->tm_hour)<<8) | BIN_TO_BCD(bdtime->tm_min);
31                 context->sc_edx = (BIN_TO_BCD(bdtime->tm_sec)<<8);
32
33         case 4:
34                 ltime = time(NULL);
35                 bdtime = localtime(&ltime);
36                 context->sc_ecx = (BIN_TO_BCD(bdtime->tm_year/100)<<8) | BIN_TO_BCD((bdtime->tm_year-1900)%100);
37                 context->sc_edx = (BIN_TO_BCD(bdtime->tm_mon)<<8) | BIN_TO_BCD(bdtime->tm_mday);
38                 break;
39
40                 /* setting the time,date or RTC is not allow -EB */
41         case 1:
42                 /* set system time */
43         case 3: 
44                 /* set RTC time */
45         case 5:
46                 /* set RTC date */
47         case 6:
48                 /* set ALARM */
49         case 7:
50                 /* cancel ALARM */
51                 break;
52
53         default:
54                 fprintf(stderr,"Unable to handle int 0x1A AX %04x\n", context->sc_eax & 0xffffL);
55                 return 1;
56         };
57         return 1;
58 }