Deleted Added
full compact
simple.c (50476) simple.c (53013)
1/*-
2 * Copyright (c) 1991-1997 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 1991-1997 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/lib/libvgl/simple.c 50476 1999-08-28 00:22:10Z peter $
28 * $FreeBSD: head/lib/libvgl/simple.c 53013 1999-11-08 11:37:46Z yokota $
29 */
30
31#include <signal.h>
32#include <machine/console.h>
33#include "vgl.h"
34
35static byte VGLSavePaletteRed[256];
36static byte VGLSavePaletteGreen[256];
37static byte VGLSavePaletteBlue[256];
38
39#define ABS(a) (((a)<0) ? -(a) : (a))
40#define SGN(a) (((a)<0) ? -1 : 1)
29 */
30
31#include <signal.h>
32#include <machine/console.h>
33#include "vgl.h"
34
35static byte VGLSavePaletteRed[256];
36static byte VGLSavePaletteGreen[256];
37static byte VGLSavePaletteBlue[256];
38
39#define ABS(a) (((a)<0) ? -(a) : (a))
40#define SGN(a) (((a)<0) ? -1 : 1)
41#define min(x, y) (((x) < (y)) ? (x) : (y))
42#define max(x, y) (((x) > (y)) ? (x) : (y))
41
43
42
43void
44VGLSetXY(VGLBitmap *object, int x, int y, byte color)
45{
44void
45VGLSetXY(VGLBitmap *object, int x, int y, byte color)
46{
47 int offset;
48
46 VGLCheckSwitch();
49 VGLCheckSwitch();
47 if (x>=0 && x<object->Xsize && y>=0 && y<object->Ysize) {
50 if (x>=0 && x<object->VXsize && y>=0 && y<object->VYsize) {
48 if (!VGLMouseFreeze(x, y, 1, 1, color)) {
49 switch (object->Type) {
50 case MEMBUF:
51 case VIDBUF8:
51 if (!VGLMouseFreeze(x, y, 1, 1, color)) {
52 switch (object->Type) {
53 case MEMBUF:
54 case VIDBUF8:
52 object->Bitmap[y*object->Xsize+x]=(color);
55 object->Bitmap[y*object->VXsize+x]=(color);
53 break;
56 break;
57 case VIDBUF8S:
58 object->Bitmap[VGLSetSegment(y*object->VXsize+x)]=(color);
59 break;
54 case VIDBUF8X:
55 outb(0x3c4, 0x02);
56 outb(0x3c5, 0x01 << (x&0x3));
60 case VIDBUF8X:
61 outb(0x3c4, 0x02);
62 outb(0x3c5, 0x01 << (x&0x3));
57 object->Bitmap[(unsigned)(object->Xsize/2*y)+(x/4)] = (color);
63 object->Bitmap[(unsigned)(VGLAdpInfo.va_line_width*y)+(x/4)] = (color);
58 break;
64 break;
65 case VIDBUF4S:
66 offset = VGLSetSegment(y*VGLAdpInfo.va_line_width + x/8);
67 goto set_planar;
59 case VIDBUF4:
68 case VIDBUF4:
60 outb(0x3c4, 0x02); outb(0x3c5, 0x01);
61 outb(0x3ce, 0x04); outb(0x3cf, 0x00);
62 object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] =
63 ( object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] & ~(0x80>>(x%8)) )
64 | ((color & 0x01) ? (0x80>>(x%8)) : 0);
65 outb(0x3c4, 0x02); outb(0x3c5, 0x02);
66 outb(0x3ce, 0x04); outb(0x3cf, 0x01);
67 object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] =
68 ( object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] & ~(0x80>>(x%8)) )
69 | ((color & 0x02) ? (0x80>>(x%8)) : 0);
70 outb(0x3c4, 0x02); outb(0x3c5, 0x04);
71 outb(0x3ce, 0x04); outb(0x3cf, 0x02);
72 object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] =
73 ( object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] & ~(0x80>>(x%8)) )
74 | ((color & 0x04) ? (0x80>>(x%8)) : 0);
75 outb(0x3c4, 0x02); outb(0x3c5, 0x08);
76 outb(0x3ce, 0x04); outb(0x3cf, 0x03);
77 object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] =
78 ( object->Bitmap[(y*object->Xsize/8+x/8)&0xffff] & ~(0x80>>(x%8)) )
79 | ((color & 0x08) ? (0x80>>(x%8)) : 0);
69 offset = y*VGLAdpInfo.va_line_width + x/8;
70set_planar:
71 outb(0x3c4, 0x02); outb(0x3c5, 0x0f);
72 outb(0x3ce, 0x00); outb(0x3cf, color & 0x0f); /* set/reset */
73 outb(0x3ce, 0x01); outb(0x3cf, 0x0f); /* set/reset enable */
74 outb(0x3ce, 0x08); outb(0x3cf, 0x80 >> (x%8)); /* bit mask */
75 object->Bitmap[offset] |= color;
80 }
81 }
82 VGLMouseUnFreeze();
83 }
84}
85
86byte
87VGLGetXY(VGLBitmap *object, int x, int y)
88{
76 }
77 }
78 VGLMouseUnFreeze();
79 }
80}
81
82byte
83VGLGetXY(VGLBitmap *object, int x, int y)
84{
85 int offset;
86#if 0
87 int i;
88 byte color;
89 byte mask;
90#endif
91
89 VGLCheckSwitch();
92 VGLCheckSwitch();
93 if (x<0 || x>=object->VXsize || y<0 || y>=object->VYsize)
94 return 0;
90 switch (object->Type) {
91 case MEMBUF:
92 case VIDBUF8:
95 switch (object->Type) {
96 case MEMBUF:
97 case VIDBUF8:
93 return object->Bitmap[((y*object->Xsize)+x)];
94 break;
98 return object->Bitmap[((y*object->VXsize)+x)];
99 case VIDBUF8S:
100 return object->Bitmap[VGLSetSegment(y*object->VXsize+x)];
95 case VIDBUF8X:
96 outb(0x3ce, 0x04); outb(0x3cf, x & 0x3);
101 case VIDBUF8X:
102 outb(0x3ce, 0x04); outb(0x3cf, x & 0x3);
97 return object->Bitmap[(unsigned)(object->Xsize/2*y)+(x/4)];
98 break;
103 return object->Bitmap[(unsigned)(VGLAdpInfo.va_line_width*y)+(x/4)];
104 case VIDBUF4S:
105 offset = VGLSetSegment(y*VGLAdpInfo.va_line_width + x/8);
106 goto get_planar;
99 case VIDBUF4:
107 case VIDBUF4:
100 return (object->Bitmap[((y*object->Xsize/8)+x/8)]&(0x80>>(x%8))) ? 1 : 0;
101 break;
108 offset = y*VGLAdpInfo.va_line_width + x/8;
109get_planar:
110#if 1
111 return (object->Bitmap[offset]&(0x80>>(x%8))) ? 1 : 0; /* XXX */
112#else
113 color = 0;
114 mask = 0x80 >> (x%8);
115 for (i = 0; i < VGLModeInfo.vi_planes; i++) {
116 outb(0x3ce, 0x04); outb(0x3cf, i);
117 color |= (object->Bitmap[offset] & mask) ? (1 << i) : 0;
118 }
119 return color;
120#endif
102 }
103 return 0;
104}
105
106void
107VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2, byte color)
108{
109 int d, x, y, ax, ay, sx, sy, dx, dy;

--- 119 unchanged lines hidden (view full) ---

229 }
230 y--; dy-=asq2; d+=asq-dy;
231 }
232}
233
234void
235VGLClear(VGLBitmap *object, byte color)
236{
121 }
122 return 0;
123}
124
125void
126VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2, byte color)
127{
128 int d, x, y, ax, ay, sx, sy, dx, dy;

--- 119 unchanged lines hidden (view full) ---

248 }
249 y--; dy-=asq2; d+=asq-dy;
250 }
251}
252
253void
254VGLClear(VGLBitmap *object, byte color)
255{
256 int offset;
257 int len;
258
237 VGLCheckSwitch();
238 VGLMouseFreeze(0, 0, object->Xsize, object->Ysize, color);
239 switch (object->Type) {
240 case MEMBUF:
241 case VIDBUF8:
259 VGLCheckSwitch();
260 VGLMouseFreeze(0, 0, object->Xsize, object->Ysize, color);
261 switch (object->Type) {
262 case MEMBUF:
263 case VIDBUF8:
242 memset(object->Bitmap, color, object->Xsize*object->Ysize);
264 memset(object->Bitmap, color, object->VXsize*object->VYsize);
243 break;
265 break;
266
267 case VIDBUF8S:
268 for (offset = 0; offset < object->VXsize*object->VYsize; ) {
269 VGLSetSegment(offset);
270 len = min(object->VXsize*object->VYsize - offset,
271 VGLAdpInfo.va_window_size);
272 memset(object->Bitmap, color, len);
273 offset += len;
274 }
275 break;
276
244 case VIDBUF8X:
245 /* XXX works only for Xsize % 4 = 0 */
277 case VIDBUF8X:
278 /* XXX works only for Xsize % 4 = 0 */
279 outb(0x3c6, 0xff);
246 outb(0x3c4, 0x02); outb(0x3c5, 0x0f);
280 outb(0x3c4, 0x02); outb(0x3c5, 0x0f);
247 memset(object->Bitmap, color, object->Xsize*object->Ysize/4);
281 memset(object->Bitmap, color, VGLAdpInfo.va_line_width*object->VYsize);
248 break;
249
250 case VIDBUF4:
282 break;
283
284 case VIDBUF4:
285 case VIDBUF4S:
251 /* XXX works only for Xsize % 8 = 0 */
286 /* XXX works only for Xsize % 8 = 0 */
252 memset(object->Bitmap, color, object->Xsize/8*object->Ysize);
287 outb(0x3c4, 0x02); outb(0x3c5, 0x0f);
288 outb(0x3ce, 0x05); outb(0x3cf, 0x02); /* mode 2 */
289 outb(0x3ce, 0x01); outb(0x3cf, 0x00); /* set/reset enable */
290 outb(0x3ce, 0x08); outb(0x3cf, 0xff); /* bit mask */
291 for (offset = 0; offset < VGLAdpInfo.va_line_width*object->VYsize; ) {
292 VGLSetSegment(offset);
293 len = min(object->VXsize*object->VYsize - offset,
294 VGLAdpInfo.va_window_size);
295 memset(object->Bitmap, color, len);
296 offset += len;
297 }
298 outb(0x3ce, 0x05); outb(0x3cf, 0x00);
253 break;
254 }
255 VGLMouseUnFreeze();
256}
257
258void
259VGLRestorePalette()
260{

--- 97 unchanged lines hidden ---
299 break;
300 }
301 VGLMouseUnFreeze();
302}
303
304void
305VGLRestorePalette()
306{

--- 97 unchanged lines hidden ---