-
Notifications
You must be signed in to change notification settings - Fork 6
/
io-pcxtat.c
130 lines (101 loc) · 2.41 KB
/
io-pcxtat.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
//-------------------------------------------------------------------------------
// EMU86 - PC/XT/AT board I/O mapping
//-------------------------------------------------------------------------------
#include "emu-mem-io.h"
#include "int-8xxx.h"
#include "timer-8xxx.h"
#include "mem-io-pcxtat.h"
#include <stdio.h>
extern int info_level;
byte_t crtc_curhi, crtc_curlo; // 6845 CRTC cursor
static byte_t crtc_lastcommand;
//-------------------------------------------------------------------------------
int io_read_byte (word_t p, byte_t * b)
{
/*
if ((p >= 0x20 && p <= 0x21) || (p >= 0xA0 && p <= 0xA1))
printf("[ INB %3xh AL %02xh]\n", p, *b);
*/
switch (p)
{
case 0x1F7: // HD1 status
case 0x177: // HD2 status
*b = 0x7f; // ready, drive not found
break;
default:
*b = 0xFF;
break;
}
if (info_level & 4) printf("[ INB %3xh AL %02xh]\n", p, *b);
return 0;
}
int io_write_byte (word_t p, byte_t b)
{
/*
if ((p >= 0x20 && p <= 0x21) || (p >= 0xA0 && p <= 0xA1))
printf("[OUTB %3xh AL %0xh]\n", p, b);
*/
switch (p)
{
case 0x20: // 8259 PIC
int_io_write (p - 0x20, b);
break;
case TIMER_CTRL_PORT: // 8253/8254 timer
timer_io_write (p, b);
break;
case 0x80: // I/O delay
break;
case CRTC_CTRL_PORT: // 6845 CRTC
crtc_lastcommand = b;
break;
case CRTC_DATA_PORT:
if (crtc_lastcommand == 0x0E)
crtc_curhi = b;
else if (crtc_lastcommand == 0x0F)
crtc_curlo = b;
// set display page 0x0C/0x0D ignored
break;
default:
if (info_level & 4) printf("[OUTB %3xh AL %0xh]\n", p, b);
}
return 0;
}
//-------------------------------------------------------------------------------
int io_read_word (word_t p, word_t * w)
{
int err;
/*
if ((p >= 0x20 && p <= 0x21) || (p >= 0xA0 && p <= 0xA1))
printf("[ INW %3xh AX %04xh]\n", p, *w);
*/
if (p & 0x0001) {
// bad alignment
err = -1;
}
else {
// no port
if (info_level & 4) printf("[ INW %3xh AX %04xh]\n", p, *w);
*w = 0xFFFF;
err = 0;
}
return err;
}
int io_write_word (word_t p, word_t w)
{
int err;
/*
if ((p >= 0x20 && p <= 0x21) || (p >= 0xA0 && p <= 0xA1))
printf("[OUTW %3xh AX %0xh]\n", p, w);
*/
if (p & 0x0001) {
// bad alignment
err = -1;
}
else {
// no port
if (info_level & 4) printf("[OUTW %3xh AX %0xh]\n", p, w);
err = 0;
}
return err;
}
//-------------------------------------------------------------------------------