1 /**
2 ** et400.cC ---- Tseng ET4000 video driver
3 **
4 ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
5 ** [e-mail: csaba@vuse.vanderbilt.edu]
6 **
7 ** This file is part of the GRX graphics library.
8 **
9 ** The GRX graphics library is free software; you can redistribute it
10 ** and/or modify it under some conditions; see the "copying.grx" file
11 ** for details.
12 **
13 ** This library is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 **
17 ** Contributions by: (See "doc/credits.doc" for details)
18 ** Christian Domp (alma.student.uni-kl.de)
19 **
20 **/
21
22 #include "libgrx.h"
23 #include "grdriver.h"
24 #include "arith.h"
25 #include "int86.h"
26 #include "ioport.h"
27 #include "memfill.h"
28
setbank(int bk)29 static void setbank(int bk)
30 {
31 outport_b(0x3cd,((bk & 15) | ((bk & 15) << 4)));
32 }
33
setrwbanks(int rb,int wb)34 static void setrwbanks(int rb,int wb)
35 {
36 outport_b(0x3cd,((wb & 15) | ((rb & 15) << 4)));
37 }
38
39 static GrVideoModeExt gr4ext = {
40 GR_frameSVGA4, /* frame driver */
41 NULL, /* frame driver override */
42 MK_FP(0xa000,0), /* frame buffer address */
43 { 6, 6, 6 }, /* color precisions */
44 { 0, 0, 0 }, /* color component bit positions */
45 0, /* mode flag bits */
46 _GrViDrvSetEGAVGAmode, /* mode set */
47 _GrViDrvVESAsetVirtualSize, /* virtual size set */
48 _GrViDrvVESAvirtualScroll, /* virtual scroll */
49 setbank, /* bank set function */
50 setrwbanks, /* double bank set function */
51 _GrViDrvLoadColorVGA4 /* color loader */
52 };
53
54 static GrVideoModeExt gr8ext = {
55 GR_frameSVGA8, /* frame driver */
56 NULL, /* frame driver override */
57 MK_FP(0xa000,0), /* frame buffer address */
58 { 6, 6, 6 }, /* color precisions */
59 { 0, 0, 0 }, /* color component bit positions */
60 GR_VMODEF_FAST_SVGA8, /* mode flag bits */
61 _GrViDrvSetEGAVGAmode, /* mode set */
62 _GrViDrvVESAsetVirtualSize, /* virtual size set */
63 _GrViDrvVESAvirtualScroll, /* virtual scroll */
64 setbank, /* bank set function */
65 setrwbanks, /* double bank set function */
66 _GrViDrvLoadColorVGA8 /* color loader */
67 };
68
setmode15(GrVideoMode * mp,int noclear)69 static int setmode15(GrVideoMode *mp,int noclear)
70 {
71 if(_GrViDrvSetEGAVGAmode(mp,noclear)) {
72 Int86Regs r;
73 sttzero(&r);
74 IREG_AX(r) = 0x10f0;
75 IREG_BX(r) = mp->mode;
76 int10(&r);
77 if(IREG_AX(r) == 0x10) return(TRUE);
78 }
79 return(FALSE);
80 }
81
82 static GrVideoModeExt gr15ext = {
83 GR_frameSVGA16, /* frame driver */
84 NULL, /* frame driver override */
85 MK_FP(0xa000,0), /* frame buffer address */
86 { 5, 5, 5 }, /* color precisions */
87 { 10, 5, 0 }, /* color component bit positions */
88 0, /* mode flag bits */
89 setmode15, /* mode set */
90 _GrViDrvVESAsetVirtualSize, /* virtual size set */
91 _GrViDrvVESAvirtualScroll, /* virtual scroll */
92 setbank, /* bank set function */
93 setrwbanks, /* double bank set function */
94 NULL /* color loader */
95 };
96
setmode16(GrVideoMode * mp,int noclear)97 static int setmode16(GrVideoMode *mp,int noclear)
98 {
99 if(setmode15(mp,noclear)) { /* set 15-bit mode */
100 Int86Regs r;
101 sttzero(&r);
102 IREG_AX(r) = 0x10f2;
103 IREG_BX(r) = 2;
104 int10(&r); /* switch to 16-bit mode */
105 if(IREG_AX(r) == 0x10) return(TRUE);
106 }
107 return(FALSE);
108 }
109
110 static GrVideoModeExt gr16ext = {
111 GR_frameSVGA16, /* frame driver */
112 NULL, /* frame driver override */
113 MK_FP(0xa000,0), /* frame buffer address */
114 { 5, 6, 5 }, /* color precisions */
115 { 11, 5, 0 }, /* color component bit positions */
116 0, /* mode flag bits */
117 setmode16, /* mode set */
118 _GrViDrvVESAsetVirtualSize, /* virtual size set */
119 _GrViDrvVESAvirtualScroll, /* virtual scroll */
120 setbank, /* bank set function */
121 setrwbanks, /* double bank set function */
122 NULL /* color loader */
123 };
124
setmode24(GrVideoMode * mp,int noclear)125 static int setmode24(GrVideoMode *mp,int noclear)
126 {
127 if(_GrViDrvSetEGAVGAmode(mp,noclear)) {
128 Int86Regs r;
129 sttzero(&r);
130 IREG_AX(r) = 0x10f0;
131 IREG_BX(r) = (mp->mode<<8)|0xff;
132 int10(&r);
133 if(IREG_AX(r) == 0x10) return(TRUE);
134 }
135 return(FALSE);
136 }
137
138 static GrVideoModeExt gr24ext = {
139 GR_frameSVGA24, /* frame driver */
140 NULL, /* frame driver override */
141 MK_FP(0xa000,0), /* frame buffer address */
142 { 8, 8, 8 }, /* color precisions */
143 { 16, 8, 0 }, /* color component bit positions */
144 0, /* mode flag bits */
145 setmode24, /* mode set */
146 _GrViDrvVESAsetVirtualSize, /* virtual size set */
147 _GrViDrvVESAvirtualScroll, /* virtual scroll */
148 setbank, /* bank set function */
149 setrwbanks, /* double bank set function */
150 NULL /* color loader */
151 };
152
153 static GrVideoMode modes[] = {
154 /* pres. bpp wdt hgt BIOS scan priv. &ext */
155 { TRUE, 4, 80, 60, 0x26, 160, 0, &_GrViDrvEGAVGAtextModeExt },
156 { TRUE, 4, 100, 40, 0x2a, 200, 0, &_GrViDrvEGAVGAtextModeExt },
157 { TRUE, 4, 132, 25, 0x23, 264, 0, &_GrViDrvEGAVGAtextModeExt },
158 { TRUE, 4, 132, 28, 0x24, 264, 0, &_GrViDrvEGAVGAtextModeExt },
159 { TRUE, 4, 132, 44, 0x22, 264, 0, &_GrViDrvEGAVGAtextModeExt },
160 { TRUE, 4, 132, 50, 0x61, 264, 0, &_GrViDrvEGAVGAtextModeExt },
161 { TRUE, 4, 132, 60, 0x21, 264, 0, &_GrViDrvEGAVGAtextModeExt },
162 { TRUE, 4, 800, 600, 0x29, 100, 0, &gr4ext },
163 { TRUE, 4, 1024, 768, 0x37, 128, 0, &gr4ext },
164 { TRUE, 4, 1280, 1024, 0x3d, 160, 0, &gr4ext },
165 { TRUE, 8, 640, 350, 0x2d, 640, 0, &gr8ext },
166 { TRUE, 8, 640, 400, 0x2f, 640, 0, &gr8ext },
167 { TRUE, 8, 640, 480, 0x2e, 640, 0, &gr8ext },
168 { TRUE, 8, 800, 600, 0x30, 800, 0, &gr8ext },
169 { TRUE, 8, 1024, 768, 0x38, 1024, 0, &gr8ext },
170 { FALSE, 15, 320, 200, 0x13, 640, 0, &gr15ext },
171 { FALSE, 15, 640, 350, 0x2d, 1280, 0, &gr15ext },
172 { FALSE, 15, 640, 400, 0x2f, 1280, 0, &gr15ext },
173 { FALSE, 15, 640, 480, 0x2e, 1280, 0, &gr15ext },
174 { FALSE, 15, 800, 600, 0x30, 1600, 0, &gr15ext },
175 { FALSE, 16, 320, 200, 0x13, 640, 0, &gr16ext },
176 { FALSE, 16, 640, 350, 0x2d, 1280, 0, &gr16ext },
177 { FALSE, 16, 640, 400, 0x2f, 1280, 0, &gr16ext },
178 { FALSE, 16, 640, 480, 0x2e, 1280, 0, &gr16ext },
179 { FALSE, 16, 800, 600, 0x30, 1600, 0, &gr16ext },
180 { FALSE, 24, 640, 350, 0x2d, 1920, 0, &gr24ext },
181 { FALSE, 24, 640, 400, 0x2f, 1920, 0, &gr24ext },
182 { FALSE, 24, 640, 480, 0x2e, 1920, 0, &gr24ext }
183 };
184
init(char * options)185 static int init(char *options)
186 {
187 if(_GrViDrvInitEGAVGA(options)) {
188 Int86Regs r;
189 sttzero(&r);
190 IREG_AX(r) = 0x10f1;
191 int10(&r);
192 if((IREG_AX(r) == 0x10) && (IREG_BX(r) >= 1)) {
193 GrVideoMode *mp = &modes[itemsof(modes)];
194 while(--mp >= modes) {
195 switch(mp->bpp) {
196 case 24:
197 if(IREG_BX(r) < 3) break;
198 case 16:
199 if(IREG_BX(r) < 2) break;
200 case 15:
201 mp->present = TRUE;
202 }
203 }
204 }
205 return(TRUE);
206 }
207 return(FALSE);
208 }
209
210 GrVideoDriver _GrVideoDriverET4000 = {
211 "et4000", /* name */
212 GR_VGA, /* adapter type */
213 &_GrVideoDriverSTDVGA, /* inherit modes from this driver */
214 modes, /* mode table */
215 itemsof(modes), /* # of modes */
216 NULL, /* detection routine */
217 init, /* initialization routine */
218 _GrViDrvResetEGAVGA, /* reset routine */
219 _gr_selectmode, /* standard mode select routine */
220 0 /* no additional capabilities */
221 };
222
223