Desktop window queue handling adapted.
[wine/multimedia.git] / msdos / int1a.c
blob3504f67e357c141b6d9375db39861299348569b6
1 /*
2 * BIOS interrupt 1ah handler
3 */
5 #include <time.h>
6 #include <sys/time.h>
7 #include <stdlib.h>
8 #include "options.h"
9 #include "miscemu.h"
10 #include "debug.h"
12 #define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
13 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
16 /**********************************************************************
17 * INT1A_GetTicksSinceMidnight
19 * Return number of clock ticks since midnight.
21 DWORD INT1A_GetTicksSinceMidnight(void)
23 struct tm *bdtime;
24 struct timeval tvs;
25 time_t seconds;
27 /* This should give us the (approximately) correct
28 * 18.206 clock ticks per second since midnight.
30 gettimeofday( &tvs, NULL );
31 seconds = tvs.tv_sec;
32 bdtime = localtime( &seconds );
33 return (((bdtime->tm_hour * 3600 + bdtime->tm_min * 60 +
34 bdtime->tm_sec) * 18206) / 1000) +
35 (tvs.tv_usec / 54927);
39 /**********************************************************************
40 * INT_Int1aHandler
42 * Handler for int 1ah
43 * 0x00 - 0x07 - date and time
44 * 0x?? - 0x?? - Microsoft Real Time Compression Interface
45 */
46 void WINAPI INT_Int1aHandler( CONTEXT *context )
48 time_t ltime;
49 DWORD ticks;
50 struct tm *bdtime;
52 switch(AH_reg(context))
54 case 0x00:
55 ticks = INT1A_GetTicksSinceMidnight();
56 CX_reg(context) = HIWORD(ticks);
57 DX_reg(context) = LOWORD(ticks);
58 AX_reg(context) = 0; /* No midnight rollover */
59 TRACE(int,"int1a: AH=00 -- ticks=%ld\n", ticks);
60 break;
62 case 0x02:
63 ltime = time(NULL);
64 bdtime = localtime(&ltime);
66 CX_reg(context) = (BIN_TO_BCD(bdtime->tm_hour)<<8) |
67 BIN_TO_BCD(bdtime->tm_min);
68 DX_reg(context) = (BIN_TO_BCD(bdtime->tm_sec)<<8);
70 case 0x04:
71 ltime = time(NULL);
72 bdtime = localtime(&ltime);
73 CX_reg(context) = (BIN_TO_BCD(bdtime->tm_year/100)<<8) |
74 BIN_TO_BCD((bdtime->tm_year-1900)%100);
75 DX_reg(context) = (BIN_TO_BCD(bdtime->tm_mon)<<8) |
76 BIN_TO_BCD(bdtime->tm_mday);
77 break;
79 /* setting the time,date or RTC is not allow -EB */
80 case 0x01:
81 /* set system time */
82 case 0x03:
83 /* set RTC time */
84 case 0x05:
85 /* set RTC date */
86 case 0x06:
87 /* set ALARM */
88 case 0x07:
89 /* cancel ALARM */
90 break;
92 case 0xb0: /* Microsoft Real Time Compression */
93 switch AL_reg(context)
95 case 0x01:
96 /* not present */
97 break;
98 default:
99 INT_BARF(context, 0x1a);
101 break;
103 default:
104 INT_BARF( context, 0x1a );