Replace calls to WaitForMultipleObjects with a 0 count by calls to
[wine] / dlls / winedos / int1a.c
1 /*
2  * BIOS interrupt 1ah handler
3  *
4  * Copyright 1993 Erik Bos
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <time.h>
25 #ifdef HAVE_SYS_TIME_H
26 # include <sys/time.h>
27 #endif
28 #include <stdlib.h>
29 #include "winternl.h"
30 #include "miscemu.h"
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(int);
34
35 #define        BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
36 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
37
38
39 /**********************************************************************
40  *         INT1A_GetTicksSinceMidnight
41  *
42  * Return number of clock ticks since midnight.
43  */
44 DWORD INT1A_GetTicksSinceMidnight(void)
45 {
46     LARGE_INTEGER time;
47     TIME_FIELDS tf;
48
49     NtQuerySystemTime( &time );
50     RtlSystemTimeToLocalTime( &time, &time );
51     RtlTimeToTimeFields( &time, &tf );
52     return ((tf.Hour * 3600 + tf.Minute * 60 + tf.Second) * 18206 / 1000 +
53             tf.Milliseconds * 1000 / 54927);
54 }
55
56
57 /**********************************************************************
58  *         DOSVM_Int1aHandler (WINEDOS16.126)
59  *
60  * Handler for int 1ah
61  *     0x00 - 0x07 - date and time
62  *     0x?? - 0x?? - Microsoft Real Time Compression Interface
63  */
64 void WINAPI DOSVM_Int1aHandler( CONTEXT86 *context )
65 {
66     time_t ltime;
67     DWORD ticks;
68     struct tm *bdtime;
69
70     switch(AH_reg(context))
71     {
72        case 0x00:
73             ticks = INT1A_GetTicksSinceMidnight();
74             SET_CX( context, HIWORD(ticks) );
75             SET_DX( context, LOWORD(ticks) );
76             SET_AX( context, 0 );  /* No midnight rollover */
77             TRACE("int1a: AH=00 -- ticks=%ld\n", ticks);
78             break;
79
80        case 0x02:
81                ltime = time(NULL);
82                bdtime = localtime(&ltime);
83
84                SET_CX( context, (BIN_TO_BCD(bdtime->tm_hour)<<8) |
85                                   BIN_TO_BCD(bdtime->tm_min) );
86                SET_DX( context, (BIN_TO_BCD(bdtime->tm_sec)<<8) );
87
88        case 0x04:
89                ltime = time(NULL);
90                bdtime = localtime(&ltime);
91                SET_CX( context, (BIN_TO_BCD(bdtime->tm_year/100)<<8) |
92                                   BIN_TO_BCD((bdtime->tm_year-1900)%100) );
93                SET_DX( context, (BIN_TO_BCD(bdtime->tm_mon)<<8) |
94                                   BIN_TO_BCD(bdtime->tm_mday) );
95                break;
96
97                /* setting the time,date or RTC is not allow -EB */
98        case 0x01:
99                /* set system time */
100        case 0x03:
101                /* set RTC time */
102        case 0x05:
103                /* set RTC date */
104        case 0x06:
105                /* set ALARM */
106        case 0x07:
107                /* cancel ALARM */
108                break;
109
110         case 0xb0: /* Microsoft Real Time Compression */
111                 switch AL_reg(context)
112                 {
113                     case 0x01:
114                         /* not present */
115                         break;
116                     default:
117                         INT_BARF(context, 0x1a);
118                 }
119                 break;
120
121        default:
122                INT_BARF( context, 0x1a );
123     }
124 }