Fix some types and function prototypes according to Platform SDK
[wine/multimedia.git] / msdos / int1a.c
blob735c2ccd577fa326a1dc3eb9086e956a9a8b0a22
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 "config.h"
22 #include "wine/port.h"
24 #include <time.h>
25 #ifdef HAVE_SYS_TIME_H
26 # include <sys/time.h>
27 #endif
28 #include <stdlib.h>
29 #include "miscemu.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(int);
34 #define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
35 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
38 /**********************************************************************
39 * INT1A_GetTicksSinceMidnight
41 * Return number of clock ticks since midnight.
43 DWORD INT1A_GetTicksSinceMidnight(void)
45 struct tm *bdtime;
46 struct timeval tvs;
47 time_t seconds;
49 /* This should give us the (approximately) correct
50 * 18.206 clock ticks per second since midnight.
52 gettimeofday( &tvs, NULL );
53 seconds = tvs.tv_sec;
54 bdtime = localtime( &seconds );
55 return (((bdtime->tm_hour * 3600 + bdtime->tm_min * 60 +
56 bdtime->tm_sec) * 18206) / 1000) +
57 (tvs.tv_usec / 54927);
61 /**********************************************************************
62 * INT_Int1aHandler (WPROCS.126)
64 * Handler for int 1ah
65 * 0x00 - 0x07 - date and time
66 * 0x?? - 0x?? - Microsoft Real Time Compression Interface
68 void WINAPI INT_Int1aHandler( CONTEXT86 *context )
70 time_t ltime;
71 DWORD ticks;
72 struct tm *bdtime;
74 switch(AH_reg(context))
76 case 0x00:
77 ticks = INT1A_GetTicksSinceMidnight();
78 SET_CX( context, HIWORD(ticks) );
79 SET_DX( context, LOWORD(ticks) );
80 SET_AX( context, 0 ); /* No midnight rollover */
81 TRACE("int1a: AH=00 -- ticks=%ld\n", ticks);
82 break;
84 case 0x02:
85 ltime = time(NULL);
86 bdtime = localtime(&ltime);
88 SET_CX( context, (BIN_TO_BCD(bdtime->tm_hour)<<8) |
89 BIN_TO_BCD(bdtime->tm_min) );
90 SET_DX( context, (BIN_TO_BCD(bdtime->tm_sec)<<8) );
92 case 0x04:
93 ltime = time(NULL);
94 bdtime = localtime(&ltime);
95 SET_CX( context, (BIN_TO_BCD(bdtime->tm_year/100)<<8) |
96 BIN_TO_BCD((bdtime->tm_year-1900)%100) );
97 SET_DX( context, (BIN_TO_BCD(bdtime->tm_mon)<<8) |
98 BIN_TO_BCD(bdtime->tm_mday) );
99 break;
101 /* setting the time,date or RTC is not allow -EB */
102 case 0x01:
103 /* set system time */
104 case 0x03:
105 /* set RTC time */
106 case 0x05:
107 /* set RTC date */
108 case 0x06:
109 /* set ALARM */
110 case 0x07:
111 /* cancel ALARM */
112 break;
114 case 0xb0: /* Microsoft Real Time Compression */
115 switch AL_reg(context)
117 case 0x01:
118 /* not present */
119 break;
120 default:
121 INT_BARF(context, 0x1a);
123 break;
125 default:
126 INT_BARF( context, 0x1a );