19a57b7d2SSøren Schmidt /*- 25e53a4f9SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 35e53a4f9SPedro F. Giffuni * 4bf3f9db6SUlrich Spörlein * Copyright (c) 1991-1997 Søren Schmidt 59a57b7d2SSøren Schmidt * All rights reserved. 69a57b7d2SSøren Schmidt * 79a57b7d2SSøren Schmidt * Redistribution and use in source and binary forms, with or without 89a57b7d2SSøren Schmidt * modification, are permitted provided that the following conditions 99a57b7d2SSøren Schmidt * are met: 109a57b7d2SSøren Schmidt * 1. Redistributions of source code must retain the above copyright 119a57b7d2SSøren Schmidt * notice, this list of conditions and the following disclaimer 129a57b7d2SSøren Schmidt * in this position and unchanged. 139a57b7d2SSøren Schmidt * 2. Redistributions in binary form must reproduce the above copyright 149a57b7d2SSøren Schmidt * notice, this list of conditions and the following disclaimer in the 159a57b7d2SSøren Schmidt * documentation and/or other materials provided with the distribution. 169a57b7d2SSøren Schmidt * 3. The name of the author may not be used to endorse or promote products 1721dc7d4fSJens Schweikhardt * derived from this software without specific prior written permission 189a57b7d2SSøren Schmidt * 199a57b7d2SSøren Schmidt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 209a57b7d2SSøren Schmidt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 219a57b7d2SSøren Schmidt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 229a57b7d2SSøren Schmidt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 239a57b7d2SSøren Schmidt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 249a57b7d2SSøren Schmidt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 259a57b7d2SSøren Schmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 269a57b7d2SSøren Schmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 279a57b7d2SSøren Schmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 289a57b7d2SSøren Schmidt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 299a57b7d2SSøren Schmidt */ 309a57b7d2SSøren Schmidt 31e67f5b9fSMatthew Dillon #include <sys/cdefs.h> 32e67f5b9fSMatthew Dillon __FBSDID("$FreeBSD$"); 33e67f5b9fSMatthew Dillon 349a57b7d2SSøren Schmidt #include <signal.h> 3500d25f51SPoul-Henning Kamp #include <sys/fbio.h> 3680b4b86eSBruce Evans #include <sys/kbio.h> 375cf92d7aSBruce Evans #include <sys/endian.h> 389a57b7d2SSøren Schmidt #include "vgl.h" 399a57b7d2SSøren Schmidt 40e848f3d1SBruce Evans static int VGLBlank; 41e848f3d1SBruce Evans static byte VGLBorderColor; 429a57b7d2SSøren Schmidt static byte VGLSavePaletteRed[256]; 439a57b7d2SSøren Schmidt static byte VGLSavePaletteGreen[256]; 449a57b7d2SSøren Schmidt static byte VGLSavePaletteBlue[256]; 459a57b7d2SSøren Schmidt 469a57b7d2SSøren Schmidt #define ABS(a) (((a)<0) ? -(a) : (a)) 479a57b7d2SSøren Schmidt #define SGN(a) (((a)<0) ? -1 : 1) 485acf51eaSKazutaka YOKOTA #define min(x, y) (((x) < (y)) ? (x) : (y)) 495acf51eaSKazutaka YOKOTA #define max(x, y) (((x) > (y)) ? (x) : (y)) 509a57b7d2SSøren Schmidt 519a57b7d2SSøren Schmidt void 52933d455fSNicolas Souchu VGLSetXY(VGLBitmap *object, int x, int y, u_long color) 539a57b7d2SSøren Schmidt { 54*ea0a9905SBruce Evans int offset, soffset, undermouse; 555acf51eaSKazutaka YOKOTA 569a57b7d2SSøren Schmidt VGLCheckSwitch(); 575acf51eaSKazutaka YOKOTA if (x>=0 && x<object->VXsize && y>=0 && y<object->VYsize) { 58c7432537SBruce Evans if (object == VGLDisplay) { 59c7432537SBruce Evans undermouse = VGLMouseFreezeXY(x, y); 601fa51420SBruce Evans VGLSetXY(&VGLVDisplay, x, y, color); 61c7432537SBruce Evans } else if (object->Type != MEMBUF) 62c7432537SBruce Evans return; /* invalid */ 63c7432537SBruce Evans else 64c7432537SBruce Evans undermouse = 0; 65c7432537SBruce Evans if (!undermouse) { 665cf92d7aSBruce Evans offset = (y * object->VXsize + x) * object->PixelBytes; 679a57b7d2SSøren Schmidt switch (object->Type) { 685acf51eaSKazutaka YOKOTA case VIDBUF8S: 69933d455fSNicolas Souchu case VIDBUF16S: 70933d455fSNicolas Souchu case VIDBUF32S: 715cf92d7aSBruce Evans offset = VGLSetSegment(offset); 725cf92d7aSBruce Evans /* FALLTHROUGH */ 735cf92d7aSBruce Evans case MEMBUF: 745cf92d7aSBruce Evans case VIDBUF8: 755cf92d7aSBruce Evans case VIDBUF16: 765cf92d7aSBruce Evans case VIDBUF24: 775cf92d7aSBruce Evans case VIDBUF32: 785cf92d7aSBruce Evans color = htole32(color); 795cf92d7aSBruce Evans switch (object->PixelBytes) { 805cf92d7aSBruce Evans case 1: 815cf92d7aSBruce Evans memcpy(&object->Bitmap[offset], &color, 1); 825cf92d7aSBruce Evans break; 835cf92d7aSBruce Evans case 2: 845cf92d7aSBruce Evans memcpy(&object->Bitmap[offset], &color, 2); 855cf92d7aSBruce Evans break; 865cf92d7aSBruce Evans case 3: 875cf92d7aSBruce Evans memcpy(&object->Bitmap[offset], &color, 3); 885cf92d7aSBruce Evans break; 895cf92d7aSBruce Evans case 4: 905cf92d7aSBruce Evans memcpy(&object->Bitmap[offset], &color, 4); 915cf92d7aSBruce Evans break; 925cf92d7aSBruce Evans } 939a57b7d2SSøren Schmidt break; 94*ea0a9905SBruce Evans case VIDBUF24S: 95*ea0a9905SBruce Evans soffset = VGLSetSegment(offset); 96*ea0a9905SBruce Evans color = htole32(color); 97*ea0a9905SBruce Evans switch (VGLAdpInfo.va_window_size - soffset) { 98*ea0a9905SBruce Evans case 1: 99*ea0a9905SBruce Evans memcpy(&object->Bitmap[soffset], &color, 1); 100*ea0a9905SBruce Evans soffset = VGLSetSegment(offset + 1); 101*ea0a9905SBruce Evans memcpy(&object->Bitmap[soffset], (byte *)&color + 1, 2); 102*ea0a9905SBruce Evans break; 103*ea0a9905SBruce Evans case 2: 104*ea0a9905SBruce Evans memcpy(&object->Bitmap[soffset], &color, 2); 105*ea0a9905SBruce Evans soffset = VGLSetSegment(offset + 2); 106*ea0a9905SBruce Evans memcpy(&object->Bitmap[soffset], (byte *)&color + 2, 1); 107*ea0a9905SBruce Evans break; 108*ea0a9905SBruce Evans default: 109*ea0a9905SBruce Evans memcpy(&object->Bitmap[soffset], &color, 3); 110*ea0a9905SBruce Evans break; 111*ea0a9905SBruce Evans } 112*ea0a9905SBruce Evans break; 1139a57b7d2SSøren Schmidt case VIDBUF8X: 1149a57b7d2SSøren Schmidt outb(0x3c4, 0x02); 1159a57b7d2SSøren Schmidt outb(0x3c5, 0x01 << (x&0x3)); 116933d455fSNicolas Souchu object->Bitmap[(unsigned)(VGLAdpInfo.va_line_width*y)+(x/4)] = ((byte)color); 1179a57b7d2SSøren Schmidt break; 1185acf51eaSKazutaka YOKOTA case VIDBUF4S: 1195acf51eaSKazutaka YOKOTA offset = VGLSetSegment(y*VGLAdpInfo.va_line_width + x/8); 1205acf51eaSKazutaka YOKOTA goto set_planar; 1219a57b7d2SSøren Schmidt case VIDBUF4: 1225acf51eaSKazutaka YOKOTA offset = y*VGLAdpInfo.va_line_width + x/8; 1235acf51eaSKazutaka YOKOTA set_planar: 1245acf51eaSKazutaka YOKOTA outb(0x3c4, 0x02); outb(0x3c5, 0x0f); 125933d455fSNicolas Souchu outb(0x3ce, 0x00); outb(0x3cf, (byte)color & 0x0f); /* set/reset */ 1265acf51eaSKazutaka YOKOTA outb(0x3ce, 0x01); outb(0x3cf, 0x0f); /* set/reset enable */ 1275acf51eaSKazutaka YOKOTA outb(0x3ce, 0x08); outb(0x3cf, 0x80 >> (x%8)); /* bit mask */ 128933d455fSNicolas Souchu object->Bitmap[offset] |= (byte)color; 1299a57b7d2SSøren Schmidt } 1309a57b7d2SSøren Schmidt } 131c7432537SBruce Evans if (object == VGLDisplay) 1329a57b7d2SSøren Schmidt VGLMouseUnFreeze(); 1339a57b7d2SSøren Schmidt } 1349a57b7d2SSøren Schmidt } 1359a57b7d2SSøren Schmidt 136014ddcbcSBruce Evans static u_long 137014ddcbcSBruce Evans __VGLGetXY(VGLBitmap *object, int x, int y) 1389a57b7d2SSøren Schmidt { 1395acf51eaSKazutaka YOKOTA int offset; 140933d455fSNicolas Souchu u_long color; 1415acf51eaSKazutaka YOKOTA 1425cf92d7aSBruce Evans offset = (y * object->VXsize + x) * object->PixelBytes; 1435cf92d7aSBruce Evans switch (object->PixelBytes) { 1445cf92d7aSBruce Evans case 1: 1455cf92d7aSBruce Evans memcpy(&color, &object->Bitmap[offset], 1); 1465cf92d7aSBruce Evans return le32toh(color) & 0xff; 1475cf92d7aSBruce Evans case 2: 1485cf92d7aSBruce Evans memcpy(&color, &object->Bitmap[offset], 2); 1495cf92d7aSBruce Evans return le32toh(color) & 0xffff; 1505cf92d7aSBruce Evans case 3: 1515cf92d7aSBruce Evans memcpy(&color, &object->Bitmap[offset], 3); 1525cf92d7aSBruce Evans return le32toh(color) & 0xffffff; 1535cf92d7aSBruce Evans case 4: 1545cf92d7aSBruce Evans memcpy(&color, &object->Bitmap[offset], 4); 1555cf92d7aSBruce Evans return le32toh(color); 1565cf92d7aSBruce Evans } 1571fa51420SBruce Evans return 0; /* invalid */ 1589a57b7d2SSøren Schmidt } 1599a57b7d2SSøren Schmidt 160014ddcbcSBruce Evans u_long 161014ddcbcSBruce Evans VGLGetXY(VGLBitmap *object, int x, int y) 162014ddcbcSBruce Evans { 163014ddcbcSBruce Evans VGLCheckSwitch(); 164014ddcbcSBruce Evans if (x<0 || x>=object->VXsize || y<0 || y>=object->VYsize) 165014ddcbcSBruce Evans return 0; 1661fa51420SBruce Evans if (object == VGLDisplay) 1671fa51420SBruce Evans object = &VGLVDisplay; 168c7432537SBruce Evans else if (object->Type != MEMBUF) 1691fa51420SBruce Evans return 0; /* invalid */ 1701fa51420SBruce Evans return __VGLGetXY(object, x, y); 171014ddcbcSBruce Evans } 172014ddcbcSBruce Evans 1734c995944SPedro F. Giffuni /* 1744c995944SPedro F. Giffuni * Symmetric Double Step Line Algorithm by Brian Wyvill from 1754c995944SPedro F. Giffuni * "Graphics Gems", Academic Press, 1990. 1764c995944SPedro F. Giffuni */ 1774c995944SPedro F. Giffuni 1784c995944SPedro F. Giffuni #define SL_SWAP(a,b) {a^=b; b^=a; a^=b;} 1794c995944SPedro F. Giffuni #define SL_ABSOLUTE(i,j,k) ( (i-j)*(k = ( (i-j)<0 ? -1 : 1))) 1804c995944SPedro F. Giffuni 1814c995944SPedro F. Giffuni void 1825ee94e99SBruce Evans plot(VGLBitmap * object, int x, int y, int flag, u_long color) 1834c995944SPedro F. Giffuni { 1844c995944SPedro F. Giffuni /* non-zero flag indicates the pixels need swapping back. */ 1854c995944SPedro F. Giffuni if (flag) 1864c995944SPedro F. Giffuni VGLSetXY(object, y, x, color); 1874c995944SPedro F. Giffuni else 1884c995944SPedro F. Giffuni VGLSetXY(object, x, y, color); 1894c995944SPedro F. Giffuni } 1904c995944SPedro F. Giffuni 1914c995944SPedro F. Giffuni 1929a57b7d2SSøren Schmidt void 193933d455fSNicolas Souchu VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color) 1949a57b7d2SSøren Schmidt { 1954c995944SPedro F. Giffuni int dx, dy, incr1, incr2, D, x, y, xend, c, pixels_left; 1964c995944SPedro F. Giffuni int sign_x, sign_y, step, reverse, i; 1979a57b7d2SSøren Schmidt 1984c995944SPedro F. Giffuni dx = SL_ABSOLUTE(x2, x1, sign_x); 1994c995944SPedro F. Giffuni dy = SL_ABSOLUTE(y2, y1, sign_y); 2004c995944SPedro F. Giffuni /* decide increment sign by the slope sign */ 2014c995944SPedro F. Giffuni if (sign_x == sign_y) 2024c995944SPedro F. Giffuni step = 1; 2034c995944SPedro F. Giffuni else 2044c995944SPedro F. Giffuni step = -1; 2059a57b7d2SSøren Schmidt 2064c995944SPedro F. Giffuni if (dy > dx) { /* chooses axis of greatest movement (make dx) */ 2074c995944SPedro F. Giffuni SL_SWAP(x1, y1); 2084c995944SPedro F. Giffuni SL_SWAP(x2, y2); 2094c995944SPedro F. Giffuni SL_SWAP(dx, dy); 2104c995944SPedro F. Giffuni reverse = 1; 2114c995944SPedro F. Giffuni } else 2124c995944SPedro F. Giffuni reverse = 0; 2134c995944SPedro F. Giffuni /* note error check for dx==0 should be included here */ 2144c995944SPedro F. Giffuni if (x1 > x2) { /* start from the smaller coordinate */ 2154c995944SPedro F. Giffuni x = x2; 2164c995944SPedro F. Giffuni y = y2; 21783057bafSPedro F. Giffuni /* x1 = x1; 21883057bafSPedro F. Giffuni y1 = y1; */ 2194c995944SPedro F. Giffuni } else { 2204c995944SPedro F. Giffuni x = x1; 2214c995944SPedro F. Giffuni y = y1; 2224c995944SPedro F. Giffuni x1 = x2; 2234c995944SPedro F. Giffuni y1 = y2; 2249a57b7d2SSøren Schmidt } 2254c995944SPedro F. Giffuni 2264c995944SPedro F. Giffuni 2274c995944SPedro F. Giffuni /* Note dx=n implies 0 - n or (dx+1) pixels to be set */ 2284c995944SPedro F. Giffuni /* Go round loop dx/4 times then plot last 0,1,2 or 3 pixels */ 2294c995944SPedro F. Giffuni /* In fact (dx-1)/4 as 2 pixels are already plotted */ 2304c995944SPedro F. Giffuni xend = (dx - 1) / 4; 2314c995944SPedro F. Giffuni pixels_left = (dx - 1) % 4; /* number of pixels left over at the 2324c995944SPedro F. Giffuni * end */ 2334c995944SPedro F. Giffuni plot(object, x, y, reverse, color); 2344c995944SPedro F. Giffuni if (pixels_left < 0) 2354c995944SPedro F. Giffuni return; /* plot only one pixel for zero length 2364c995944SPedro F. Giffuni * vectors */ 2374c995944SPedro F. Giffuni plot(object, x1, y1, reverse, color); /* plot first two points */ 2384c995944SPedro F. Giffuni incr2 = 4 * dy - 2 * dx; 2394c995944SPedro F. Giffuni if (incr2 < 0) { /* slope less than 1/2 */ 2404c995944SPedro F. Giffuni c = 2 * dy; 2414c995944SPedro F. Giffuni incr1 = 2 * c; 2424c995944SPedro F. Giffuni D = incr1 - dx; 2434c995944SPedro F. Giffuni 2444c995944SPedro F. Giffuni for (i = 0; i < xend; i++) { /* plotting loop */ 2454c995944SPedro F. Giffuni ++x; 2464c995944SPedro F. Giffuni --x1; 2474c995944SPedro F. Giffuni if (D < 0) { 2484c995944SPedro F. Giffuni /* pattern 1 forwards */ 2494c995944SPedro F. Giffuni plot(object, x, y, reverse, color); 2504c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); 2514c995944SPedro F. Giffuni /* pattern 1 backwards */ 2524c995944SPedro F. Giffuni plot(object, x1, y1, reverse, color); 2534c995944SPedro F. Giffuni plot(object, --x1, y1, reverse, color); 2544c995944SPedro F. Giffuni D += incr1; 2554c995944SPedro F. Giffuni } else { 2564c995944SPedro F. Giffuni if (D < c) { 2574c995944SPedro F. Giffuni /* pattern 2 forwards */ 2584c995944SPedro F. Giffuni plot(object, x, y, reverse, color); 2594c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, 2604c995944SPedro F. Giffuni color); 2614c995944SPedro F. Giffuni /* pattern 2 backwards */ 2624c995944SPedro F. Giffuni plot(object, x1, y1, reverse, color); 2634c995944SPedro F. Giffuni plot(object, --x1, y1 -= step, reverse, 2644c995944SPedro F. Giffuni color); 2654c995944SPedro F. Giffuni } else { 2664c995944SPedro F. Giffuni /* pattern 3 forwards */ 2674c995944SPedro F. Giffuni plot(object, x, y += step, reverse, color); 2684c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); 2694c995944SPedro F. Giffuni /* pattern 3 backwards */ 2704c995944SPedro F. Giffuni plot(object, x1, y1 -= step, reverse, 2714c995944SPedro F. Giffuni color); 2724c995944SPedro F. Giffuni plot(object, --x1, y1, reverse, color); 2734c995944SPedro F. Giffuni } 2744c995944SPedro F. Giffuni D += incr2; 2754c995944SPedro F. Giffuni } 2764c995944SPedro F. Giffuni } /* end for */ 2774c995944SPedro F. Giffuni 2784c995944SPedro F. Giffuni /* plot last pattern */ 2794c995944SPedro F. Giffuni if (pixels_left) { 2804c995944SPedro F. Giffuni if (D < 0) { 2814c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); /* pattern 1 */ 2824c995944SPedro F. Giffuni if (pixels_left > 1) 2834c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); 2844c995944SPedro F. Giffuni if (pixels_left > 2) 2854c995944SPedro F. Giffuni plot(object, --x1, y1, reverse, color); 2864c995944SPedro F. Giffuni } else { 2874c995944SPedro F. Giffuni if (D < c) { 2884c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); /* pattern 2 */ 2894c995944SPedro F. Giffuni if (pixels_left > 1) 2904c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, color); 2914c995944SPedro F. Giffuni if (pixels_left > 2) 2924c995944SPedro F. Giffuni plot(object, --x1, y1, reverse, color); 2934c995944SPedro F. Giffuni } else { 2944c995944SPedro F. Giffuni /* pattern 3 */ 2954c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, color); 2964c995944SPedro F. Giffuni if (pixels_left > 1) 2974c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); 2984c995944SPedro F. Giffuni if (pixels_left > 2) 2994c995944SPedro F. Giffuni plot(object, --x1, y1 -= step, reverse, color); 3009a57b7d2SSøren Schmidt } 3019a57b7d2SSøren Schmidt } 3024c995944SPedro F. Giffuni } /* end if pixels_left */ 3039a57b7d2SSøren Schmidt } 3044c995944SPedro F. Giffuni /* end slope < 1/2 */ 3054c995944SPedro F. Giffuni else { /* slope greater than 1/2 */ 3064c995944SPedro F. Giffuni c = 2 * (dy - dx); 3074c995944SPedro F. Giffuni incr1 = 2 * c; 3084c995944SPedro F. Giffuni D = incr1 + dx; 3094c995944SPedro F. Giffuni for (i = 0; i < xend; i++) { 3104c995944SPedro F. Giffuni ++x; 3114c995944SPedro F. Giffuni --x1; 3124c995944SPedro F. Giffuni if (D > 0) { 3134c995944SPedro F. Giffuni /* pattern 4 forwards */ 3144c995944SPedro F. Giffuni plot(object, x, y += step, reverse, color); 3154c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, color); 3164c995944SPedro F. Giffuni /* pattern 4 backwards */ 3174c995944SPedro F. Giffuni plot(object, x1, y1 -= step, reverse, color); 3184c995944SPedro F. Giffuni plot(object, --x1, y1 -= step, reverse, color); 3194c995944SPedro F. Giffuni D += incr1; 3204c995944SPedro F. Giffuni } else { 3214c995944SPedro F. Giffuni if (D < c) { 3224c995944SPedro F. Giffuni /* pattern 2 forwards */ 3234c995944SPedro F. Giffuni plot(object, x, y, reverse, color); 3244c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, 3254c995944SPedro F. Giffuni color); 3264c995944SPedro F. Giffuni 3274c995944SPedro F. Giffuni /* pattern 2 backwards */ 3284c995944SPedro F. Giffuni plot(object, x1, y1, reverse, color); 3294c995944SPedro F. Giffuni plot(object, --x1, y1 -= step, reverse, 3304c995944SPedro F. Giffuni color); 3314c995944SPedro F. Giffuni } else { 3324c995944SPedro F. Giffuni /* pattern 3 forwards */ 3334c995944SPedro F. Giffuni plot(object, x, y += step, reverse, color); 3344c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); 3354c995944SPedro F. Giffuni /* pattern 3 backwards */ 3364c995944SPedro F. Giffuni plot(object, x1, y1 -= step, reverse, color); 3374c995944SPedro F. Giffuni plot(object, --x1, y1, reverse, color); 3384c995944SPedro F. Giffuni } 3394c995944SPedro F. Giffuni D += incr2; 3404c995944SPedro F. Giffuni } 3414c995944SPedro F. Giffuni } /* end for */ 3424c995944SPedro F. Giffuni /* plot last pattern */ 3434c995944SPedro F. Giffuni if (pixels_left) { 3444c995944SPedro F. Giffuni if (D > 0) { 3454c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, color); /* pattern 4 */ 3464c995944SPedro F. Giffuni if (pixels_left > 1) 3474c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, 3484c995944SPedro F. Giffuni color); 3494c995944SPedro F. Giffuni if (pixels_left > 2) 3504c995944SPedro F. Giffuni plot(object, --x1, y1 -= step, reverse, 3514c995944SPedro F. Giffuni color); 3524c995944SPedro F. Giffuni } else { 3534c995944SPedro F. Giffuni if (D < c) { 3544c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); /* pattern 2 */ 3554c995944SPedro F. Giffuni if (pixels_left > 1) 3564c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, color); 3574c995944SPedro F. Giffuni if (pixels_left > 2) 3584c995944SPedro F. Giffuni plot(object, --x1, y1, reverse, color); 3594c995944SPedro F. Giffuni } else { 3604c995944SPedro F. Giffuni /* pattern 3 */ 3614c995944SPedro F. Giffuni plot(object, ++x, y += step, reverse, color); 3624c995944SPedro F. Giffuni if (pixels_left > 1) 3634c995944SPedro F. Giffuni plot(object, ++x, y, reverse, color); 3644c995944SPedro F. Giffuni if (pixels_left > 2) { 3654c995944SPedro F. Giffuni if (D > c) /* step 3 */ 3664c995944SPedro F. Giffuni plot(object, --x1, y1 -= step, reverse, color); 3674c995944SPedro F. Giffuni else /* step 2 */ 3684c995944SPedro F. Giffuni plot(object, --x1, y1, reverse, color); 3694c995944SPedro F. Giffuni } 3704c995944SPedro F. Giffuni } 3714c995944SPedro F. Giffuni } 3729a57b7d2SSøren Schmidt } 3739a57b7d2SSøren Schmidt } 3749a57b7d2SSøren Schmidt } 3759a57b7d2SSøren Schmidt 3769a57b7d2SSøren Schmidt void 377933d455fSNicolas Souchu VGLBox(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color) 3789a57b7d2SSøren Schmidt { 3799a57b7d2SSøren Schmidt VGLLine(object, x1, y1, x2, y1, color); 3809a57b7d2SSøren Schmidt VGLLine(object, x2, y1, x2, y2, color); 3819a57b7d2SSøren Schmidt VGLLine(object, x2, y2, x1, y2, color); 3829a57b7d2SSøren Schmidt VGLLine(object, x1, y2, x1, y1, color); 3839a57b7d2SSøren Schmidt } 3849a57b7d2SSøren Schmidt 3859a57b7d2SSøren Schmidt void 386933d455fSNicolas Souchu VGLFilledBox(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color) 3879a57b7d2SSøren Schmidt { 3889a57b7d2SSøren Schmidt int y; 3899a57b7d2SSøren Schmidt 3909a57b7d2SSøren Schmidt for (y=y1; y<=y2; y++) VGLLine(object, x1, y, x2, y, color); 3919a57b7d2SSøren Schmidt } 3929a57b7d2SSøren Schmidt 393e7032b4cSDimitry Andric static inline void 394e7032b4cSDimitry Andric set4pixels(VGLBitmap *object, int x, int y, int xc, int yc, u_long color) 3959a57b7d2SSøren Schmidt { 3969a57b7d2SSøren Schmidt if (x!=0) { 3979a57b7d2SSøren Schmidt VGLSetXY(object, xc+x, yc+y, color); 3989a57b7d2SSøren Schmidt VGLSetXY(object, xc-x, yc+y, color); 3999a57b7d2SSøren Schmidt if (y!=0) { 4009a57b7d2SSøren Schmidt VGLSetXY(object, xc+x, yc-y, color); 4019a57b7d2SSøren Schmidt VGLSetXY(object, xc-x, yc-y, color); 4029a57b7d2SSøren Schmidt } 4039a57b7d2SSøren Schmidt } 4049a57b7d2SSøren Schmidt else { 4059a57b7d2SSøren Schmidt VGLSetXY(object, xc, yc+y, color); 4069a57b7d2SSøren Schmidt if (y!=0) 4079a57b7d2SSøren Schmidt VGLSetXY(object, xc, yc-y, color); 4089a57b7d2SSøren Schmidt } 4099a57b7d2SSøren Schmidt } 4109a57b7d2SSøren Schmidt 4119a57b7d2SSøren Schmidt void 412933d455fSNicolas Souchu VGLEllipse(VGLBitmap *object, int xc, int yc, int a, int b, u_long color) 4139a57b7d2SSøren Schmidt { 4149a57b7d2SSøren Schmidt int x = 0, y = b, asq = a*a, asq2 = a*a*2, bsq = b*b; 4159a57b7d2SSøren Schmidt int bsq2 = b*b*2, d = bsq-asq*b+asq/4, dx = 0, dy = asq2*b; 4169a57b7d2SSøren Schmidt 4179a57b7d2SSøren Schmidt while (dx<dy) { 4189a57b7d2SSøren Schmidt set4pixels(object, x, y, xc, yc, color); 4199a57b7d2SSøren Schmidt if (d>0) { 4209a57b7d2SSøren Schmidt y--; dy-=asq2; d-=dy; 4219a57b7d2SSøren Schmidt } 4229a57b7d2SSøren Schmidt x++; dx+=bsq2; d+=bsq+dx; 4239a57b7d2SSøren Schmidt } 4249a57b7d2SSøren Schmidt d+=(3*(asq-bsq)/2-(dx+dy))/2; 4259a57b7d2SSøren Schmidt while (y>=0) { 4269a57b7d2SSøren Schmidt set4pixels(object, x, y, xc, yc, color); 4279a57b7d2SSøren Schmidt if (d<0) { 4289a57b7d2SSøren Schmidt x++; dx+=bsq2; d+=dx; 4299a57b7d2SSøren Schmidt } 4309a57b7d2SSøren Schmidt y--; dy-=asq2; d+=asq-dy; 4319a57b7d2SSøren Schmidt } 4329a57b7d2SSøren Schmidt } 4339a57b7d2SSøren Schmidt 434e7032b4cSDimitry Andric static inline void 435e7032b4cSDimitry Andric set2lines(VGLBitmap *object, int x, int y, int xc, int yc, u_long color) 4369a57b7d2SSøren Schmidt { 4379a57b7d2SSøren Schmidt if (x!=0) { 4389a57b7d2SSøren Schmidt VGLLine(object, xc+x, yc+y, xc-x, yc+y, color); 4399a57b7d2SSøren Schmidt if (y!=0) 4409a57b7d2SSøren Schmidt VGLLine(object, xc+x, yc-y, xc-x, yc-y, color); 4419a57b7d2SSøren Schmidt } 4429a57b7d2SSøren Schmidt else { 4439a57b7d2SSøren Schmidt VGLLine(object, xc, yc+y, xc, yc-y, color); 4449a57b7d2SSøren Schmidt } 4459a57b7d2SSøren Schmidt } 4469a57b7d2SSøren Schmidt 4479a57b7d2SSøren Schmidt void 448933d455fSNicolas Souchu VGLFilledEllipse(VGLBitmap *object, int xc, int yc, int a, int b, u_long color) 4499a57b7d2SSøren Schmidt { 4509a57b7d2SSøren Schmidt int x = 0, y = b, asq = a*a, asq2 = a*a*2, bsq = b*b; 4519a57b7d2SSøren Schmidt int bsq2 = b*b*2, d = bsq-asq*b+asq/4, dx = 0, dy = asq2*b; 4529a57b7d2SSøren Schmidt 4539a57b7d2SSøren Schmidt while (dx<dy) { 4549a57b7d2SSøren Schmidt set2lines(object, x, y, xc, yc, color); 4559a57b7d2SSøren Schmidt if (d>0) { 4569a57b7d2SSøren Schmidt y--; dy-=asq2; d-=dy; 4579a57b7d2SSøren Schmidt } 4589a57b7d2SSøren Schmidt x++; dx+=bsq2; d+=bsq+dx; 4599a57b7d2SSøren Schmidt } 4609a57b7d2SSøren Schmidt d+=(3*(asq-bsq)/2-(dx+dy))/2; 4619a57b7d2SSøren Schmidt while (y>=0) { 4629a57b7d2SSøren Schmidt set2lines(object, x, y, xc, yc, color); 4639a57b7d2SSøren Schmidt if (d<0) { 4649a57b7d2SSøren Schmidt x++; dx+=bsq2; d+=dx; 4659a57b7d2SSøren Schmidt } 4669a57b7d2SSøren Schmidt y--; dy-=asq2; d+=asq-dy; 4679a57b7d2SSøren Schmidt } 4689a57b7d2SSøren Schmidt } 4699a57b7d2SSøren Schmidt 4709a57b7d2SSøren Schmidt void 471933d455fSNicolas Souchu VGLClear(VGLBitmap *object, u_long color) 4729a57b7d2SSøren Schmidt { 4735cf92d7aSBruce Evans VGLBitmap src; 474c7432537SBruce Evans int i, len, mouseoverlap, offset; 4755acf51eaSKazutaka YOKOTA 4769a57b7d2SSøren Schmidt VGLCheckSwitch(); 4771fa51420SBruce Evans if (object == VGLDisplay) { 478c7432537SBruce Evans VGLMouseFreeze(); 479c7432537SBruce Evans mouseoverlap = VGLMouseOverlap(0, 0, object->Xsize, object->Ysize); 480c7432537SBruce Evans if (mouseoverlap) 481c7432537SBruce Evans VGLMousePointerHide(); 4821fa51420SBruce Evans VGLClear(&VGLVDisplay, color); 4831fa51420SBruce Evans } else if (object->Type != MEMBUF) 4841fa51420SBruce Evans return; /* invalid */ 4859a57b7d2SSøren Schmidt switch (object->Type) { 4869a57b7d2SSøren Schmidt case MEMBUF: 4879a57b7d2SSøren Schmidt case VIDBUF8: 4885acf51eaSKazutaka YOKOTA case VIDBUF8S: 489933d455fSNicolas Souchu case VIDBUF16: 490933d455fSNicolas Souchu case VIDBUF16S: 4915cf92d7aSBruce Evans case VIDBUF24: 492933d455fSNicolas Souchu case VIDBUF24S: 4935cf92d7aSBruce Evans case VIDBUF32: 494933d455fSNicolas Souchu case VIDBUF32S: 4955cf92d7aSBruce Evans src.Type = MEMBUF; 4965cf92d7aSBruce Evans src.Xsize = object->Xsize; 4975cf92d7aSBruce Evans src.VXsize = object->VXsize; 4985cf92d7aSBruce Evans src.Ysize = 1; 4995cf92d7aSBruce Evans src.VYsize = 1; 5005cf92d7aSBruce Evans src.Xorigin = 0; 5015cf92d7aSBruce Evans src.Yorigin = 0; 5025cf92d7aSBruce Evans src.Bitmap = alloca(object->VXsize * object->PixelBytes); 5035cf92d7aSBruce Evans src.PixelBytes = object->PixelBytes; 5045cf92d7aSBruce Evans color = htole32(color); 5055cf92d7aSBruce Evans for (i = 0; i < object->VXsize; i++) 5065cf92d7aSBruce Evans bcopy(&color, src.Bitmap + i * object->PixelBytes, object->PixelBytes); 5075cf92d7aSBruce Evans for (i = 0; i < object->VYsize; i++) 5089db56319SBruce Evans __VGLBitmapCopy(&src, 0, 0, object, 0, i, object->VXsize, 1); 5095acf51eaSKazutaka YOKOTA break; 5105acf51eaSKazutaka YOKOTA 5119a57b7d2SSøren Schmidt case VIDBUF8X: 5129a57b7d2SSøren Schmidt /* XXX works only for Xsize % 4 = 0 */ 5135acf51eaSKazutaka YOKOTA outb(0x3c6, 0xff); 5149a57b7d2SSøren Schmidt outb(0x3c4, 0x02); outb(0x3c5, 0x0f); 515933d455fSNicolas Souchu memset(object->Bitmap, (byte)color, VGLAdpInfo.va_line_width*object->VYsize); 5169a57b7d2SSøren Schmidt break; 5179a57b7d2SSøren Schmidt 5189a57b7d2SSøren Schmidt case VIDBUF4: 5195acf51eaSKazutaka YOKOTA case VIDBUF4S: 5209a57b7d2SSøren Schmidt /* XXX works only for Xsize % 8 = 0 */ 5215acf51eaSKazutaka YOKOTA outb(0x3c4, 0x02); outb(0x3c5, 0x0f); 5225acf51eaSKazutaka YOKOTA outb(0x3ce, 0x05); outb(0x3cf, 0x02); /* mode 2 */ 5235acf51eaSKazutaka YOKOTA outb(0x3ce, 0x01); outb(0x3cf, 0x00); /* set/reset enable */ 5245acf51eaSKazutaka YOKOTA outb(0x3ce, 0x08); outb(0x3cf, 0xff); /* bit mask */ 5255acf51eaSKazutaka YOKOTA for (offset = 0; offset < VGLAdpInfo.va_line_width*object->VYsize; ) { 5265acf51eaSKazutaka YOKOTA VGLSetSegment(offset); 5275acf51eaSKazutaka YOKOTA len = min(object->VXsize*object->VYsize - offset, 5285acf51eaSKazutaka YOKOTA VGLAdpInfo.va_window_size); 529933d455fSNicolas Souchu memset(object->Bitmap, (byte)color, len); 5305acf51eaSKazutaka YOKOTA offset += len; 5315acf51eaSKazutaka YOKOTA } 5325acf51eaSKazutaka YOKOTA outb(0x3ce, 0x05); outb(0x3cf, 0x00); 5339a57b7d2SSøren Schmidt break; 5349a57b7d2SSøren Schmidt } 535c7432537SBruce Evans if (object == VGLDisplay) { 536c7432537SBruce Evans if (mouseoverlap) 537c7432537SBruce Evans VGLMousePointerShow(); 5389a57b7d2SSøren Schmidt VGLMouseUnFreeze(); 5399a57b7d2SSøren Schmidt } 540c7432537SBruce Evans } 5419a57b7d2SSøren Schmidt 542a93ca07aSBruce Evans static inline u_long 543a93ca07aSBruce Evans VGLrgbToNative(uint16_t r, uint16_t g, uint16_t b) 544a93ca07aSBruce Evans { 545a93ca07aSBruce Evans int nr, ng, nb; 546a93ca07aSBruce Evans 547a93ca07aSBruce Evans nr = VGLModeInfo.vi_pixel_fsizes[2]; 548a93ca07aSBruce Evans ng = VGLModeInfo.vi_pixel_fsizes[1]; 549a93ca07aSBruce Evans nb = VGLModeInfo.vi_pixel_fsizes[0]; 550a93ca07aSBruce Evans return (r >> (16 - nr) << (ng + nb)) | (g >> (16 - ng) << nb) | 551a93ca07aSBruce Evans (b >> (16 - nb) << 0); 552a93ca07aSBruce Evans } 553a93ca07aSBruce Evans 554a93ca07aSBruce Evans u_long 555a93ca07aSBruce Evans VGLrgb332ToNative(byte c) 556a93ca07aSBruce Evans { 557a93ca07aSBruce Evans uint16_t r, g, b; 558a93ca07aSBruce Evans 559a93ca07aSBruce Evans /* 3:3:2 to 16:16:16 */ 560a93ca07aSBruce Evans r = ((c & 0xe0) >> 5) * 0xffff / 7; 561a93ca07aSBruce Evans g = ((c & 0x1c) >> 2) * 0xffff / 7; 562a93ca07aSBruce Evans b = ((c & 0x03) >> 0) * 0xffff / 3; 563a93ca07aSBruce Evans 564a93ca07aSBruce Evans return VGLrgbToNative(r, g, b); 565a93ca07aSBruce Evans } 566a93ca07aSBruce Evans 5679a57b7d2SSøren Schmidt void 5689a57b7d2SSøren Schmidt VGLRestorePalette() 5699a57b7d2SSøren Schmidt { 5709a57b7d2SSøren Schmidt int i; 5719a57b7d2SSøren Schmidt 57280b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) 57380b4b86eSBruce Evans return; 5749a57b7d2SSøren Schmidt outb(0x3C6, 0xFF); 5759a57b7d2SSøren Schmidt inb(0x3DA); 5769a57b7d2SSøren Schmidt outb(0x3C8, 0x00); 5779a57b7d2SSøren Schmidt for (i=0; i<256; i++) { 5789a57b7d2SSøren Schmidt outb(0x3C9, VGLSavePaletteRed[i]); 5799a57b7d2SSøren Schmidt inb(0x84); 5809a57b7d2SSøren Schmidt outb(0x3C9, VGLSavePaletteGreen[i]); 5819a57b7d2SSøren Schmidt inb(0x84); 5829a57b7d2SSøren Schmidt outb(0x3C9, VGLSavePaletteBlue[i]); 5839a57b7d2SSøren Schmidt inb(0x84); 5849a57b7d2SSøren Schmidt } 5859a57b7d2SSøren Schmidt inb(0x3DA); 5869a57b7d2SSøren Schmidt outb(0x3C0, 0x20); 5879a57b7d2SSøren Schmidt } 5889a57b7d2SSøren Schmidt 5899a57b7d2SSøren Schmidt void 5909a57b7d2SSøren Schmidt VGLSavePalette() 5919a57b7d2SSøren Schmidt { 5929a57b7d2SSøren Schmidt int i; 5939a57b7d2SSøren Schmidt 59480b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) 59580b4b86eSBruce Evans return; 5969a57b7d2SSøren Schmidt outb(0x3C6, 0xFF); 5979a57b7d2SSøren Schmidt inb(0x3DA); 5989a57b7d2SSøren Schmidt outb(0x3C7, 0x00); 5999a57b7d2SSøren Schmidt for (i=0; i<256; i++) { 6009a57b7d2SSøren Schmidt VGLSavePaletteRed[i] = inb(0x3C9); 6019a57b7d2SSøren Schmidt inb(0x84); 6029a57b7d2SSøren Schmidt VGLSavePaletteGreen[i] = inb(0x3C9); 6039a57b7d2SSøren Schmidt inb(0x84); 6049a57b7d2SSøren Schmidt VGLSavePaletteBlue[i] = inb(0x3C9); 6059a57b7d2SSøren Schmidt inb(0x84); 6069a57b7d2SSøren Schmidt } 6079a57b7d2SSøren Schmidt inb(0x3DA); 6089a57b7d2SSøren Schmidt outb(0x3C0, 0x20); 6099a57b7d2SSøren Schmidt } 6109a57b7d2SSøren Schmidt 6119a57b7d2SSøren Schmidt void 6129a57b7d2SSøren Schmidt VGLSetPalette(byte *red, byte *green, byte *blue) 6139a57b7d2SSøren Schmidt { 6149a57b7d2SSøren Schmidt int i; 6159a57b7d2SSøren Schmidt 61680b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) 61780b4b86eSBruce Evans return; 6189a57b7d2SSøren Schmidt for (i=0; i<256; i++) { 6199a57b7d2SSøren Schmidt VGLSavePaletteRed[i] = red[i]; 6209a57b7d2SSøren Schmidt VGLSavePaletteGreen[i] = green[i]; 6219a57b7d2SSøren Schmidt VGLSavePaletteBlue[i] = blue[i]; 6229a57b7d2SSøren Schmidt } 6239a57b7d2SSøren Schmidt VGLCheckSwitch(); 6249a57b7d2SSøren Schmidt outb(0x3C6, 0xFF); 6259a57b7d2SSøren Schmidt inb(0x3DA); 6269a57b7d2SSøren Schmidt outb(0x3C8, 0x00); 6279a57b7d2SSøren Schmidt for (i=0; i<256; i++) { 6289a57b7d2SSøren Schmidt outb(0x3C9, VGLSavePaletteRed[i]); 6299a57b7d2SSøren Schmidt inb(0x84); 6309a57b7d2SSøren Schmidt outb(0x3C9, VGLSavePaletteGreen[i]); 6319a57b7d2SSøren Schmidt inb(0x84); 6329a57b7d2SSøren Schmidt outb(0x3C9, VGLSavePaletteBlue[i]); 6339a57b7d2SSøren Schmidt inb(0x84); 6349a57b7d2SSøren Schmidt } 6359a57b7d2SSøren Schmidt inb(0x3DA); 6369a57b7d2SSøren Schmidt outb(0x3C0, 0x20); 6379a57b7d2SSøren Schmidt } 6389a57b7d2SSøren Schmidt 6399a57b7d2SSøren Schmidt void 6409a57b7d2SSøren Schmidt VGLSetPaletteIndex(byte color, byte red, byte green, byte blue) 6419a57b7d2SSøren Schmidt { 64280b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) 64380b4b86eSBruce Evans return; 6449a57b7d2SSøren Schmidt VGLSavePaletteRed[color] = red; 6459a57b7d2SSøren Schmidt VGLSavePaletteGreen[color] = green; 6469a57b7d2SSøren Schmidt VGLSavePaletteBlue[color] = blue; 6479a57b7d2SSøren Schmidt VGLCheckSwitch(); 6489a57b7d2SSøren Schmidt outb(0x3C6, 0xFF); 6499a57b7d2SSøren Schmidt inb(0x3DA); 6509a57b7d2SSøren Schmidt outb(0x3C8, color); 6519a57b7d2SSøren Schmidt outb(0x3C9, red); outb(0x3C9, green); outb(0x3C9, blue); 6529a57b7d2SSøren Schmidt inb(0x3DA); 6539a57b7d2SSøren Schmidt outb(0x3C0, 0x20); 6549a57b7d2SSøren Schmidt } 6559a57b7d2SSøren Schmidt 6569a57b7d2SSøren Schmidt void 657e848f3d1SBruce Evans VGLRestoreBorder(void) 658e848f3d1SBruce Evans { 659e848f3d1SBruce Evans VGLSetBorder(VGLBorderColor); 660e848f3d1SBruce Evans } 661e848f3d1SBruce Evans 662e848f3d1SBruce Evans void 6639a57b7d2SSøren Schmidt VGLSetBorder(byte color) 6649a57b7d2SSøren Schmidt { 66580b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT && ioctl(0, KDENABIO, 0)) 66680b4b86eSBruce Evans return; 6679a57b7d2SSøren Schmidt VGLCheckSwitch(); 6689a57b7d2SSøren Schmidt inb(0x3DA); 6699a57b7d2SSøren Schmidt outb(0x3C0,0x11); outb(0x3C0, color); 6709a57b7d2SSøren Schmidt inb(0x3DA); 6719a57b7d2SSøren Schmidt outb(0x3C0, 0x20); 672e848f3d1SBruce Evans VGLBorderColor = color; 67380b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) 67480b4b86eSBruce Evans ioctl(0, KDDISABIO, 0); 6759a57b7d2SSøren Schmidt } 6769a57b7d2SSøren Schmidt 6779a57b7d2SSøren Schmidt void 678e848f3d1SBruce Evans VGLRestoreBlank(void) 679e848f3d1SBruce Evans { 680e848f3d1SBruce Evans VGLBlankDisplay(VGLBlank); 681e848f3d1SBruce Evans } 682e848f3d1SBruce Evans 683e848f3d1SBruce Evans void 6849a57b7d2SSøren Schmidt VGLBlankDisplay(int blank) 6859a57b7d2SSøren Schmidt { 6869a57b7d2SSøren Schmidt byte val; 6879a57b7d2SSøren Schmidt 68880b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT && ioctl(0, KDENABIO, 0)) 68980b4b86eSBruce Evans return; 6909a57b7d2SSøren Schmidt VGLCheckSwitch(); 6919a57b7d2SSøren Schmidt outb(0x3C4, 0x01); val = inb(0x3C5); outb(0x3C4, 0x01); 6929a57b7d2SSøren Schmidt outb(0x3C5, ((blank) ? (val |= 0x20) : (val &= 0xDF))); 693e848f3d1SBruce Evans VGLBlank = blank; 69480b4b86eSBruce Evans if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) 69580b4b86eSBruce Evans ioctl(0, KDDISABIO, 0); 6969a57b7d2SSøren Schmidt } 697