Restored MakeCriticalSectionGlobal that got lost somewhere.
[wine/multimedia.git] / msdos / int1a.c
blob3c4a10d27aafc121371b96b941656d6584ec97c8
1 /*
2 * BIOS interrupt 1ah handler
4 * Copyright 1993 Erik Bos
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.
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.
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
21 #include <time.h>
22 #include <sys/time.h>
23 #include <stdlib.h>
24 #include "miscemu.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(int);
29 #define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
30 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
33 /**********************************************************************
34 * INT1A_GetTicksSinceMidnight
36 * Return number of clock ticks since midnight.
38 DWORD INT1A_GetTicksSinceMidnight(void)
40 struct tm *bdtime;
41 struct timeval tvs;
42 time_t seconds;
44 /* This should give us the (approximately) correct
45 * 18.206 clock ticks per second since midnight.
47 gettimeofday( &tvs, NULL );
48 seconds = tvs.tv_sec;
49 bdtime = localtime( &seconds );
50 return (((bdtime->tm_hour * 3600 + bdtime->tm_min * 60 +
51 bdtime->tm_sec) * 18206) / 1000) +
52 (tvs.tv_usec / 54927);
56 /**********************************************************************
57 * INT_Int1aHandler (WPROCS.126)
59 * Handler for int 1ah
60 * 0x00 - 0x07 - date and time
61 * 0x?? - 0x?? - Microsoft Real Time Compression Interface
63 void WINAPI INT_Int1aHandler( CONTEXT86 *context )
65 time_t ltime;
66 DWORD ticks;
67 struct tm *bdtime;
69 switch(AH_reg(context))
71 case 0x00:
72 ticks = INT1A_GetTicksSinceMidnight();
73 CX_reg(context) = HIWORD(ticks);
74 DX_reg(context) = LOWORD(ticks);
75 AX_reg(context) = 0; /* No midnight rollover */
76 TRACE("int1a: AH=00 -- ticks=%ld\n", ticks);
77 break;
79 case 0x02:
80 ltime = time(NULL);
81 bdtime = localtime(&ltime);
83 CX_reg(context) = (BIN_TO_BCD(bdtime->tm_hour)<<8) |
84 BIN_TO_BCD(bdtime->tm_min);
85 DX_reg(context) = (BIN_TO_BCD(bdtime->tm_sec)<<8);
87 case 0x04:
88 ltime = time(NULL);
89 bdtime = localtime(&ltime);
90 CX_reg(context) = (BIN_TO_BCD(bdtime->tm_year/100)<<8) |
91 BIN_TO_BCD((bdtime->tm_year-1900)%100);
92 DX_reg(context) = (BIN_TO_BCD(bdtime->tm_mon)<<8) |
93 BIN_TO_BCD(bdtime->tm_mday);
94 break;
96 /* setting the time,date or RTC is not allow -EB */
97 case 0x01:
98 /* set system time */
99 case 0x03:
100 /* set RTC time */
101 case 0x05:
102 /* set RTC date */
103 case 0x06:
104 /* set ALARM */
105 case 0x07:
106 /* cancel ALARM */
107 break;
109 case 0xb0: /* Microsoft Real Time Compression */
110 switch AL_reg(context)
112 case 0x01:
113 /* not present */
114 break;
115 default:
116 INT_BARF(context, 0x1a);
118 break;
120 default:
121 INT_BARF( context, 0x1a );