Release 940301
[wine/gsoc-2012-control.git] / miscemu / int1a.c
blobaddfdbcbb923c5293f203aa909684c7f77e5bf64
1 #include <time.h>
2 #include <stdio.h>
3 #include "wine.h"
5 #ifdef linux
6 #include <linux/sched.h> /* needed for HZ */
7 #endif
9 #define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
10 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
12 int do_int1A(struct sigcontext_struct * context){
13 time_t ltime;
14 struct tm *bdtime;
15 int ticks;
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;
26 case 2:
27 ltime = time(NULL);
28 bdtime = localtime(&ltime);
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);
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;
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;
53 default:
54 fprintf(stderr,"Unable to handle int 0x1A AX %04x\n", context->sc_eax & 0xffffL);
55 return 1;
57 return 1;