Release 941017
[wine/gsoc-2012-control.git] / miscemu / int1a.c
blob0e0a9fa8c474f1f916148a47cf99ea4832854d4c
1 #include <time.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "registers.h"
5 #include "wine.h"
6 #include "options.h"
7 #include "stddebug.h"
8 /* #define DEBUG_INT */
9 /* #undef DEBUG_INT */
10 #include "debug.h"
12 #ifdef linux
13 #define inline __inline__ /* So we can compile with -ansi */
14 #include <linux/sched.h> /* needed for HZ */
15 #undef inline
16 #endif
18 #define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
19 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
21 void IntBarf(int i, struct sigcontext_struct *context);
23 int do_int1A(struct sigcontext_struct * context){
24 time_t ltime;
25 struct tm *bdtime;
26 int ticks;
28 if (Options.relay_debug) {
29 fprintf(stddeb,"int1A: AX %04x, BX %04x, CX %04x, DX %04x, "
30 "SI %04x, DI %04x, DS %04x, ES %04x\n",
31 AX, BX, CX, DX, SI, DI, DS, ES);
34 switch(AH) {
35 case 0:
36 ltime = time(NULL);
37 ticks = (int) (ltime * HZ);
38 CX = ticks >> 16;
39 DX = ticks & 0x0000FFFF;
40 AX = 0; /* No midnight rollover */
41 dprintf_int(stddeb,"int1a_00 // ltime=%ld ticks=%ld\n",
42 ltime, ticks);
43 break;
45 case 2:
46 ltime = time(NULL);
47 bdtime = localtime(&ltime);
49 CX = (BIN_TO_BCD(bdtime->tm_hour)<<8) | BIN_TO_BCD(bdtime->tm_min);
50 DX = (BIN_TO_BCD(bdtime->tm_sec)<<8);
52 case 4:
53 ltime = time(NULL);
54 bdtime = localtime(&ltime);
55 CX = (BIN_TO_BCD(bdtime->tm_year/100)<<8) | BIN_TO_BCD((bdtime->tm_year-1900)%100);
56 DX = (BIN_TO_BCD(bdtime->tm_mon)<<8) | BIN_TO_BCD(bdtime->tm_mday);
57 break;
59 /* setting the time,date or RTC is not allow -EB */
60 case 1:
61 /* set system time */
62 case 3:
63 /* set RTC time */
64 case 5:
65 /* set RTC date */
66 case 6:
67 /* set ALARM */
68 case 7:
69 /* cancel ALARM */
70 break;
72 default:
73 IntBarf(0x1a, context);
74 return 1;
76 return 1;