Release 940815
[wine/gsoc-2012-control.git] / miscemu / int1a.c
blobf43fef3c30ad74294bd0d50bd511195f7e3362ed
1 #include <time.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "registers.h"
5 #include "wine.h"
6 #include "options.h"
8 #ifdef linux
9 #include <linux/sched.h> /* needed for HZ */
10 #endif
12 #define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
13 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
15 int do_int1A(struct sigcontext_struct * context){
16 time_t ltime;
17 struct tm *bdtime;
18 int ticks;
20 if (Options.relay_debug) {
21 printf("int1A: AX %04x, BX %04x, CX %04x, DX %04x, "
22 "SI %04x, DI %04x, DS %04x, ES %04x\n",
23 AX, BX, CX, DX, SI, DI, DS, ES);
26 switch(AH) {
27 case 0:
28 ltime = time(NULL);
29 ticks = (int) (ltime * HZ);
30 CX = ticks >> 16;
31 DX = ticks & 0x0000FFFF;
32 AX = 0; /* No midnight rollover */
33 printf("int1a_00 // ltime=%ld ticks=%ld\n", ltime, ticks);
34 break;
36 case 2:
37 ltime = time(NULL);
38 bdtime = localtime(&ltime);
40 CX = (BIN_TO_BCD(bdtime->tm_hour)<<8) | BIN_TO_BCD(bdtime->tm_min);
41 DX = (BIN_TO_BCD(bdtime->tm_sec)<<8);
43 case 4:
44 ltime = time(NULL);
45 bdtime = localtime(&ltime);
46 CX = (BIN_TO_BCD(bdtime->tm_year/100)<<8) | BIN_TO_BCD((bdtime->tm_year-1900)%100);
47 DX = (BIN_TO_BCD(bdtime->tm_mon)<<8) | BIN_TO_BCD(bdtime->tm_mday);
48 break;
50 /* setting the time,date or RTC is not allow -EB */
51 case 1:
52 /* set system time */
53 case 3:
54 /* set RTC time */
55 case 5:
56 /* set RTC date */
57 case 6:
58 /* set ALARM */
59 case 7:
60 /* cancel ALARM */
61 break;
63 default:
64 IntBarf(0x1a, context);
65 return 1;
67 return 1;