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