-
Notifications
You must be signed in to change notification settings - Fork 22
/
distortc.c
153 lines (131 loc) · 3.44 KB
/
distortc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
Copyright 2015 by Joseph Forgione
This file is part of VCC (Virtual Color Computer).
VCC (Virtual Color Computer) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
VCC (Virtual Color Computer) is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VCC (Virtual Color Computer). If not, see <http://www.gnu.org/licenses/>.
*/
#include "windows.h"
#include "stdio.h"
#include "stdlib.h"
#include "distoRTC.h"
#include "windows.h"
/* Table description: Bit3 Bit2 Bit1 Bit0
Write to $FF51 read from $FF50
0x00 1-second digit register S8 S4 S2 S1
0x01 10-second digit register x S40 S20 S10
0x02 1-minute digit register Mi8 Mi4 Mi2 Mi1
0x03 10-minute digit register x Mi40 Mi20 Mi10
0x04 1-hour digit register H8 H4 H2 H1
0x05 PM/AM, 10-hour digit register x P/A H20 H10
0x06 1-day digit register D8 D4 D2 D1
0x07 10-day digit register x x D20 D10
0x08 1-month digit register Mo8 Mo4 Mo2 Mo1
0x09 10-month digit register Mo80 Mo40 Mo20 Mo10
0x0A 1-year digit register Y8 Y4 Y2 Y1
0x0B 10-yead digit register Y80 Y40 Y20 Y10
0x0C Week register x W4 W2 W1
30
0x0D Control register D Sec IRQ Busy Hold
adj Flag
ITRP
0x0E Control register E T1 T0 /STND Mask
0x0F Control register F Test 24/12 Stop Rest
Note: Digits are BDC. Registers only four bits wide.
X denotes 'not used'
*/
static unsigned char time_register=0;
static SYSTEMTIME now;
static unsigned char Hour12=0;
unsigned char read_time(unsigned short port)
{
unsigned char ret_val=0;
if (port == 0x50)
{
GetLocalTime(&now);
switch (time_register)
{
case 0:
ret_val= now.wSecond % 10;
break;
case 1:
ret_val= now.wSecond / 10;
break;
case 2:
ret_val = now.wMinute % 10;
break;
case 3:
ret_val = now.wMinute / 10;
break;
case 4:
ret_val = now.wHour % 10;
break;
case 5:
ret_val = now.wHour / 10;
break;
case 6:
ret_val = now.wDay % 10;
break;
case 7:
ret_val = now.wDay /10;
break;
case 8:
ret_val = now.wMonth % 10;
break;
case 9:
ret_val = now.wMonth /10 ;
break;
case 0xA:
ret_val = now.wYear%10;
break;
case 0xB:
ret_val = (now.wYear%100)/10;
break;
case 0xC:
ret_val=(unsigned char)now.wDayOfWeek; //May not be right
break;
case 0xD:
break;
case 0xE:
break;
case 0xF:
// Hour12
break;
default:
ret_val=0;
break;
}
}
return(ret_val);
}
void write_time(unsigned char data,unsigned char port)
{
switch (port)
{
case 0x50:
switch (time_register)
{
case 0x0F:
Hour12=!((data & 4)>>2);
// if (Hour12==0)
// MessageBox(0,"Setting format 0","Ok",0);
// else
// MessageBox(0,"Setting format 1","Ok",0);
break;
default:
break;
}
break;
case 0x51:
time_register=(data & 0xF);
break;
}
return;
}