summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/vga256/vga/vgaBank.h
blob: c72c6cc837c6290f73f4ceff87279f062a9d56ae (plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* $XConsortium: vgaBank.h,v 1.4 95/01/05 20:51:38 kaleb Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/vga/vgaBank.h,v 3.1 1994/11/26 12:48:17 dawes Exp $ */
/*
 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Thomas Roell not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Thomas Roell makes no representations
 * about the suitability of this software for any purpose.  It is provided
 * "as is" without express or implied warranty.
 *
 * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
 *
 */

#ifndef VGA_BANK_H
#define VGA_BANK_H

extern void *vgaReadBottom;
extern void *vgaReadTop;
extern void *vgaWriteBottom;
extern void *vgaWriteTop;
extern Bool vgaReadFlag, vgaWriteFlag;
extern void *writeseg;

/* vgaBank.s */

void *vgaSetReadWrite(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaReadWriteNext(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaReadWritePrev(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaSetRead(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaReadNext(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaReadPrev(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaSetWrite(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaWriteNext(
#if NeedFunctionPrototypes
    void *
#endif
);

void *vgaWritePrev(
#if NeedFunctionPrototypes
    void *
#endif
);

void vgaSaveBank(
#if NeedFunctionPrototypes
    void
#endif
);

void vgaRestoreBank(
#if NeedFunctionPrototypes
    void
#endif
);

void vgaPushRead(
#if NeedFunctionPrototypes
    void
#endif
);

void vgaPopRead(
#if NeedFunctionPrototypes
    void
#endif
);

extern int vgaSegmentMask;

extern void SpeedUpComputeNext(
#if NeedFunctionPrototypes
    unsigned,
    unsigned
#endif
);

extern void SpeedUpComputePrev(
#if NeedFunctionPrototypes
    unsigned,
    unsigned
#endif
);

extern unsigned SpeedUpRowsNext[];
extern unsigned SpeedUpRowsPrev[];


#ifdef CSRG_BASED
#define VGABASE 0xFF000000
#else
#define VGABASE 0xF0000000
#endif

/* Clear these first -- since they are defined in mfbcustom.h */
#undef CHECKSCREEN
#undef SETRWF
#undef CHECKRWOF
#undef CHECKRWUF
#undef BANK_FLAG
#undef BANK_FLAG_BOTH
#undef SETR
#undef SETW
#undef SETRW
#undef CHECKRO
#undef CHECKWO
#undef CHECKRWO
#undef CHECKRU
#undef CHECKWU
#undef CHECKRWU
#undef NEXTR
#undef NEXTW
#undef PREVR
#undef PREVW
#undef SAVE_BANK
#undef RESTORE_BANK
#undef PUSHR
#undef POPR

#define CHECKSCREEN(x) (((unsigned long)x >= VGABASE) ? TRUE : FALSE)
#define SETRWF(f,x) { if(f) x = vgaSetReadWrite(x); }
#define CHECKRWOF(f,x) { if(f && ((void *)x >= vgaWriteTop)) \
			  x = vgaReadWriteNext(x); }
#define CHECKRWUF(f,x) { if(f && ((void *)x < vgaWriteBottom)) \
			  x = vgaReadWritePrev(x); }
#define BANK_FLAG(a) \
  vgaWriteFlag = (((unsigned long)a >= VGABASE) ? TRUE : FALSE); \
  vgaReadFlag = FALSE; 

#define BANK_FLAG_BOTH(a,b) \
  vgaReadFlag = (((unsigned long)a >= VGABASE) ? TRUE : FALSE); \
  vgaWriteFlag  = (((unsigned long)b >= VGABASE) ? TRUE : FALSE); 

#define SETR(x)  { if(vgaReadFlag) x = vgaSetRead(x); }
#define SETW(x)  { if(vgaWriteFlag) x = vgaSetWrite(x); }
#define SETRW(x) { if(vgaWriteFlag) x = vgaSetReadWrite(x); }
#define CHECKRO(x) { if(vgaReadFlag && ((void *)x >= vgaReadTop)) \
			 x = vgaReadNext(x); }
#define CHECKRU(x) { if(vgaReadFlag && ((void *)x < vgaReadBottom)) \
			 x = vgaReadPrev(x); }
#define CHECKWO(x) { if(vgaWriteFlag && ((void *)x >= vgaWriteTop)) \
			 x = vgaWriteNext(x); }
#define CHECKWU(x) { if(vgaWriteFlag && ((void *)x < vgaWriteBottom)) \
			 x = vgaWritePrev(x); }
#define CHECKRWO(x) { if(vgaWriteFlag && ((void *)x >= vgaWriteTop)) \
			  x = vgaReadWriteNext(x); }
#define CHECKRWU(x) { if(vgaWriteFlag && ((void *)x < vgaWriteBottom)) \
			  x = vgaReadWritePrev(x); }

#define NEXTR(x) { x = vgaReadNext(x);}
#define NEXTW(x) { x = vgaWriteNext(x); }
#define PREVR(x) { x = vgaReadPrev(x); }
#define PREVW(x) { x = vgaWritePrev(x); }

#define SAVE_BANK()     { if (vgaWriteFlag) vgaSaveBank(); }
#define RESTORE_BANK()  { if (vgaWriteFlag) vgaRestoreBank(); }

#define PUSHR()         { if(vgaWriteFlag) vgaPushRead(); }
#define POPR()          { if(vgaWriteFlag) vgaPopRead(); }


#endif /* VGA_BANK_H */