1997-08-17 21:09:35 +00:00
|
|
|
/*-
|
2017-11-26 02:00:33 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
2012-01-07 16:13:56 +00:00
|
|
|
* Copyright (c) 1991-1997 Søren Schmidt
|
1997-08-17 21:09:35 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
|
|
|
* in this position and unchanged.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
2002-06-02 20:05:59 +00:00
|
|
|
* derived from this software without specific prior written permission
|
1997-08-17 21:09:35 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-09-16 21:35:07 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1997-08-17 21:09:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/signal.h>
|
2000-10-08 21:34:00 +00:00
|
|
|
#include <sys/consio.h>
|
|
|
|
#include <sys/fbio.h>
|
1997-08-17 21:09:35 +00:00
|
|
|
#include "vgl.h"
|
|
|
|
|
2019-04-29 14:13:53 +00:00
|
|
|
static void VGLMouseAction(int dummy);
|
|
|
|
|
2019-04-22 19:31:16 +00:00
|
|
|
#define BORDER 0xff /* default border -- light white in rgb 3:3:2 */
|
|
|
|
#define INTERIOR 0xa0 /* default interior -- red in rgb 3:3:2 */
|
2019-04-29 16:26:29 +00:00
|
|
|
#define LARGE_MOUSE_IMG_XSIZE 19
|
|
|
|
#define LARGE_MOUSE_IMG_YSIZE 32
|
|
|
|
#define SMALL_MOUSE_IMG_XSIZE 10
|
|
|
|
#define SMALL_MOUSE_IMG_YSIZE 16
|
2019-04-22 19:31:16 +00:00
|
|
|
#define X 0xff /* any nonzero in And mask means part of cursor */
|
|
|
|
#define B BORDER
|
|
|
|
#define I INTERIOR
|
2019-04-29 16:26:29 +00:00
|
|
|
static byte LargeAndMask[] = {
|
|
|
|
X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
X,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
X,X,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
X,X,X,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
X,X,X,X,X,X,0,0,0,0,0,0,0,0,0,0,0,0,0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,X,0,0,
|
|
|
|
X,X,X,X,X,X,X,X,X,0,
|
|
|
|
X,X,X,X,X,X,X,X,X,X,
|
|
|
|
X,X,X,X,X,X,X,X,X,X,
|
|
|
|
X,X,X,X,X,X,X,0,0,0,
|
|
|
|
X,X,X,0,X,X,X,X,0,0,
|
|
|
|
X,X,0,0,X,X,X,X,0,0,
|
|
|
|
0,0,0,0,0,X,X,X,X,0,
|
|
|
|
0,0,0,0,0,X,X,X,X,0,
|
|
|
|
0,0,0,0,0,0,X,X,0,0,
|
|
|
|
};
|
|
|
|
static byte SmallOrMask[] = {
|
|
|
|
B,B,0,0,0,0,0,0,0,0,
|
|
|
|
B,I,B,0,0,0,0,0,0,0,
|
|
|
|
B,I,I,B,0,0,0,0,0,0,
|
|
|
|
B,I,I,I,B,0,0,0,0,0,
|
|
|
|
B,I,I,I,I,B,0,0,0,0,
|
|
|
|
B,I,I,I,I,I,B,0,0,0,
|
|
|
|
B,I,I,I,I,I,I,B,0,0,
|
|
|
|
B,I,I,I,I,I,I,I,B,0,
|
|
|
|
B,I,I,I,I,I,I,I,I,B,
|
|
|
|
B,I,I,I,I,I,B,B,B,B,
|
|
|
|
B,I,I,B,I,I,B,0,0,0,
|
|
|
|
B,I,B,0,B,I,I,B,0,0,
|
|
|
|
B,B,0,0,B,I,I,B,0,0,
|
|
|
|
0,0,0,0,0,B,I,I,B,0,
|
|
|
|
0,0,0,0,0,B,I,I,B,0,
|
|
|
|
0,0,0,0,0,0,B,B,0,0,
|
1997-08-17 21:09:35 +00:00
|
|
|
};
|
|
|
|
#undef X
|
2019-04-22 19:31:16 +00:00
|
|
|
#undef B
|
|
|
|
#undef I
|
2019-04-29 16:26:29 +00:00
|
|
|
static VGLBitmap VGLMouseLargeAndMask =
|
|
|
|
VGLBITMAP_INITIALIZER(MEMBUF, LARGE_MOUSE_IMG_XSIZE, LARGE_MOUSE_IMG_YSIZE,
|
|
|
|
LargeAndMask);
|
|
|
|
static VGLBitmap VGLMouseLargeOrMask =
|
|
|
|
VGLBITMAP_INITIALIZER(MEMBUF, LARGE_MOUSE_IMG_XSIZE, LARGE_MOUSE_IMG_YSIZE,
|
|
|
|
LargeOrMask);
|
|
|
|
static VGLBitmap VGLMouseSmallAndMask =
|
|
|
|
VGLBITMAP_INITIALIZER(MEMBUF, SMALL_MOUSE_IMG_XSIZE, SMALL_MOUSE_IMG_YSIZE,
|
|
|
|
SmallAndMask);
|
|
|
|
static VGLBitmap VGLMouseSmallOrMask =
|
|
|
|
VGLBITMAP_INITIALIZER(MEMBUF, SMALL_MOUSE_IMG_XSIZE, SMALL_MOUSE_IMG_YSIZE,
|
|
|
|
SmallOrMask);
|
1997-08-17 21:09:35 +00:00
|
|
|
static VGLBitmap *VGLMouseAndMask, *VGLMouseOrMask;
|
2019-04-24 15:35:29 +00:00
|
|
|
static int VGLMouseShown = VGL_MOUSEHIDE;
|
1997-08-17 21:09:35 +00:00
|
|
|
static int VGLMouseXpos = 0;
|
|
|
|
static int VGLMouseYpos = 0;
|
|
|
|
static int VGLMouseButtons = 0;
|
2019-03-29 15:20:48 +00:00
|
|
|
static volatile sig_atomic_t VGLMintpending;
|
|
|
|
static volatile sig_atomic_t VGLMsuppressint;
|
|
|
|
|
|
|
|
#define INTOFF() (VGLMsuppressint++)
|
|
|
|
#define INTON() do { \
|
|
|
|
if (--VGLMsuppressint == 0 && VGLMintpending) \
|
|
|
|
VGLMouseAction(0); \
|
|
|
|
} while (0)
|
1997-08-17 21:09:35 +00:00
|
|
|
|
2019-04-29 14:13:53 +00:00
|
|
|
int
|
|
|
|
__VGLMouseMode(int mode)
|
1997-08-17 21:09:35 +00:00
|
|
|
{
|
2019-04-29 14:13:53 +00:00
|
|
|
int oldmode;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
2019-04-29 14:13:53 +00:00
|
|
|
INTOFF();
|
|
|
|
oldmode = VGLMouseShown;
|
1997-08-17 21:09:35 +00:00
|
|
|
if (mode == VGL_MOUSESHOW) {
|
|
|
|
if (VGLMouseShown == VGL_MOUSEHIDE) {
|
|
|
|
VGLMouseShown = VGL_MOUSESHOW;
|
2019-04-29 16:26:29 +00:00
|
|
|
__VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos,
|
|
|
|
VGLDisplay, VGLMouseXpos, VGLMouseYpos,
|
|
|
|
VGLMouseAndMask->VXsize, -VGLMouseAndMask->VYsize);
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (VGLMouseShown == VGL_MOUSESHOW) {
|
|
|
|
VGLMouseShown = VGL_MOUSEHIDE;
|
2019-04-29 16:26:29 +00:00
|
|
|
__VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos,
|
|
|
|
VGLDisplay, VGLMouseXpos, VGLMouseYpos,
|
|
|
|
VGLMouseAndMask->VXsize, VGLMouseAndMask->VYsize);
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-29 14:13:53 +00:00
|
|
|
INTON();
|
|
|
|
return oldmode;
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-04-29 14:13:53 +00:00
|
|
|
VGLMouseMode(int mode)
|
|
|
|
{
|
|
|
|
__VGLMouseMode(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLMouseAction(int dummy)
|
|
|
|
{
|
|
|
|
struct mouse_info mouseinfo;
|
2019-04-29 14:13:53 +00:00
|
|
|
int mousemode;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
2019-03-29 15:20:48 +00:00
|
|
|
if (VGLMsuppressint) {
|
|
|
|
VGLMintpending = 1;
|
1997-08-17 21:09:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-03-29 15:20:48 +00:00
|
|
|
again:
|
|
|
|
INTOFF();
|
|
|
|
VGLMintpending = 0;
|
1997-08-17 21:09:35 +00:00
|
|
|
mouseinfo.operation = MOUSE_GETINFO;
|
|
|
|
ioctl(0, CONS_MOUSECTL, &mouseinfo);
|
2019-04-29 14:13:53 +00:00
|
|
|
if (VGLMouseXpos != mouseinfo.u.data.x ||
|
|
|
|
VGLMouseYpos != mouseinfo.u.data.y) {
|
|
|
|
mousemode = __VGLMouseMode(VGL_MOUSEHIDE);
|
|
|
|
VGLMouseXpos = mouseinfo.u.data.x;
|
|
|
|
VGLMouseYpos = mouseinfo.u.data.y;
|
|
|
|
__VGLMouseMode(mousemode);
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLMouseButtons = mouseinfo.u.data.buttons;
|
2019-03-29 15:20:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop to handle any new (suppressed) signals. This is INTON() without
|
|
|
|
* recursion. !SA_RESTART prevents recursion in signal handling. So the
|
|
|
|
* maximum recursion is 2 levels.
|
|
|
|
*/
|
|
|
|
VGLMsuppressint = 0;
|
|
|
|
if (VGLMintpending)
|
|
|
|
goto again;
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VGLMouseSetImage(VGLBitmap *AndMask, VGLBitmap *OrMask)
|
|
|
|
{
|
2019-04-29 14:13:53 +00:00
|
|
|
int mousemode;
|
|
|
|
|
|
|
|
mousemode = __VGLMouseMode(VGL_MOUSEHIDE);
|
2019-04-22 19:31:16 +00:00
|
|
|
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLMouseAndMask = AndMask;
|
2019-04-22 19:31:16 +00:00
|
|
|
|
|
|
|
if (VGLMouseOrMask != NULL) {
|
|
|
|
free(VGLMouseOrMask->Bitmap);
|
|
|
|
free(VGLMouseOrMask);
|
|
|
|
}
|
|
|
|
VGLMouseOrMask = VGLBitmapCreate(MEMBUF, OrMask->VXsize, OrMask->VYsize, 0);
|
|
|
|
VGLBitmapAllocateBits(VGLMouseOrMask);
|
|
|
|
VGLBitmapCvt(OrMask, VGLMouseOrMask);
|
|
|
|
|
2019-04-29 14:13:53 +00:00
|
|
|
__VGLMouseMode(mousemode);
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VGLMouseSetStdImage()
|
|
|
|
{
|
2019-04-29 16:26:29 +00:00
|
|
|
if (VGLDisplay->VXsize > 800)
|
|
|
|
VGLMouseSetImage(&VGLMouseLargeAndMask, &VGLMouseLargeOrMask);
|
|
|
|
else
|
|
|
|
VGLMouseSetImage(&VGLMouseSmallAndMask, &VGLMouseSmallOrMask);
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
VGLMouseInit(int mode)
|
|
|
|
{
|
|
|
|
struct mouse_info mouseinfo;
|
2019-04-29 16:26:29 +00:00
|
|
|
VGLBitmap *ormask;
|
2019-04-22 19:31:16 +00:00
|
|
|
int andmask, border, error, i, interior;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
2019-03-27 08:02:55 +00:00
|
|
|
switch (VGLModeInfo.vi_mem_model) {
|
|
|
|
case V_INFO_MM_PACKED:
|
|
|
|
case V_INFO_MM_PLANAR:
|
2019-04-22 19:31:16 +00:00
|
|
|
andmask = 0x0f;
|
|
|
|
border = 0x0f;
|
|
|
|
interior = 0x04;
|
2019-03-27 08:02:55 +00:00
|
|
|
break;
|
|
|
|
case V_INFO_MM_VGAX:
|
2019-04-22 19:31:16 +00:00
|
|
|
andmask = 0x3f;
|
|
|
|
border = 0x3f;
|
|
|
|
interior = 0x24;
|
2019-03-27 08:02:55 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-04-22 19:31:16 +00:00
|
|
|
andmask = 0xff;
|
|
|
|
border = BORDER;
|
|
|
|
interior = INTERIOR;
|
2019-03-27 08:02:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-04-22 19:31:16 +00:00
|
|
|
if (VGLModeInfo.vi_mode == M_BG640x480)
|
|
|
|
border = 0; /* XXX (palette makes 0x04 look like 0x0f) */
|
|
|
|
if (getenv("VGLMOUSEBORDERCOLOR") != NULL)
|
|
|
|
border = strtoul(getenv("VGLMOUSEBORDERCOLOR"), NULL, 0);
|
|
|
|
if (getenv("VGLMOUSEINTERIORCOLOR") != NULL)
|
|
|
|
interior = strtoul(getenv("VGLMOUSEINTERIORCOLOR"), NULL, 0);
|
2019-04-29 16:26:29 +00:00
|
|
|
ormask = &VGLMouseLargeOrMask;
|
|
|
|
for (i = 0; i < ormask->VXsize * ormask->VYsize; i++)
|
|
|
|
ormask->Bitmap[i] = ormask->Bitmap[i] == BORDER ? border :
|
|
|
|
ormask->Bitmap[i] == INTERIOR ? interior : 0;
|
|
|
|
ormask = &VGLMouseSmallOrMask;
|
|
|
|
for (i = 0; i < ormask->VXsize * ormask->VYsize; i++)
|
|
|
|
ormask->Bitmap[i] = ormask->Bitmap[i] == BORDER ? border :
|
|
|
|
ormask->Bitmap[i] == INTERIOR ? interior : 0;
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLMouseSetStdImage();
|
|
|
|
mouseinfo.operation = MOUSE_MODE;
|
|
|
|
mouseinfo.u.mode.signal = SIGUSR2;
|
|
|
|
if ((error = ioctl(0, CONS_MOUSECTL, &mouseinfo)))
|
|
|
|
return error;
|
|
|
|
signal(SIGUSR2, VGLMouseAction);
|
|
|
|
mouseinfo.operation = MOUSE_GETINFO;
|
|
|
|
ioctl(0, CONS_MOUSECTL, &mouseinfo);
|
|
|
|
VGLMouseXpos = mouseinfo.u.data.x;
|
|
|
|
VGLMouseYpos = mouseinfo.u.data.y;
|
|
|
|
VGLMouseButtons = mouseinfo.u.data.buttons;
|
|
|
|
VGLMouseMode(mode);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-21 10:33:09 +00:00
|
|
|
void
|
|
|
|
VGLMouseRestore(void)
|
|
|
|
{
|
|
|
|
struct mouse_info mouseinfo;
|
|
|
|
|
|
|
|
INTOFF();
|
|
|
|
mouseinfo.operation = MOUSE_GETINFO;
|
|
|
|
if (ioctl(0, CONS_MOUSECTL, &mouseinfo) == 0) {
|
|
|
|
mouseinfo.operation = MOUSE_MOVEABS;
|
|
|
|
mouseinfo.u.data.x = VGLMouseXpos;
|
|
|
|
mouseinfo.u.data.y = VGLMouseYpos;
|
|
|
|
ioctl(0, CONS_MOUSECTL, &mouseinfo);
|
|
|
|
}
|
|
|
|
INTON();
|
|
|
|
}
|
|
|
|
|
1997-08-17 21:09:35 +00:00
|
|
|
int
|
|
|
|
VGLMouseStatus(int *x, int *y, char *buttons)
|
|
|
|
{
|
2019-03-29 15:20:48 +00:00
|
|
|
INTOFF();
|
1997-08-17 21:09:35 +00:00
|
|
|
*x = VGLMouseXpos;
|
|
|
|
*y = VGLMouseYpos;
|
|
|
|
*buttons = VGLMouseButtons;
|
2019-03-29 15:20:48 +00:00
|
|
|
INTON();
|
1997-08-17 21:09:35 +00:00
|
|
|
return VGLMouseShown;
|
|
|
|
}
|
|
|
|
|
2019-04-24 15:35:29 +00:00
|
|
|
void
|
|
|
|
VGLMouseFreeze(void)
|
1997-08-17 21:09:35 +00:00
|
|
|
{
|
2019-04-24 15:35:29 +00:00
|
|
|
INTOFF();
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
|
2019-04-24 15:35:29 +00:00
|
|
|
int
|
|
|
|
VGLMouseFreezeXY(int x, int y)
|
|
|
|
{
|
|
|
|
INTOFF();
|
|
|
|
if (VGLMouseShown != VGL_MOUSESHOW)
|
|
|
|
return 0;
|
2019-04-29 16:26:29 +00:00
|
|
|
if (x >= VGLMouseXpos && x < VGLMouseXpos + VGLMouseAndMask->VXsize &&
|
|
|
|
y >= VGLMouseYpos && y < VGLMouseYpos + VGLMouseAndMask->VYsize &&
|
|
|
|
VGLMouseAndMask->Bitmap[(y-VGLMouseYpos)*VGLMouseAndMask->VXsize+
|
|
|
|
(x-VGLMouseXpos)])
|
2019-04-24 15:35:29 +00:00
|
|
|
return 1;
|
1997-08-17 21:09:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-24 15:35:29 +00:00
|
|
|
int
|
|
|
|
VGLMouseOverlap(int x, int y, int width, int hight)
|
|
|
|
{
|
|
|
|
int overlap;
|
|
|
|
|
|
|
|
if (VGLMouseShown != VGL_MOUSESHOW)
|
|
|
|
return 0;
|
|
|
|
if (x > VGLMouseXpos)
|
2019-04-29 16:26:29 +00:00
|
|
|
overlap = (VGLMouseXpos + VGLMouseAndMask->VXsize) - x;
|
2019-04-24 15:35:29 +00:00
|
|
|
else
|
|
|
|
overlap = (x + width) - VGLMouseXpos;
|
|
|
|
if (overlap <= 0)
|
|
|
|
return 0;
|
|
|
|
if (y > VGLMouseYpos)
|
2019-04-29 16:26:29 +00:00
|
|
|
overlap = (VGLMouseYpos + VGLMouseAndMask->VYsize) - y;
|
2019-04-24 15:35:29 +00:00
|
|
|
else
|
|
|
|
overlap = (y + hight) - VGLMouseYpos;
|
|
|
|
return overlap > 0;
|
|
|
|
}
|
|
|
|
|
2019-04-24 16:03:35 +00:00
|
|
|
void
|
|
|
|
VGLMouseMerge(int x, int y, int width, byte *line)
|
|
|
|
{
|
|
|
|
int pos, x1, xend, xstart;
|
|
|
|
|
|
|
|
xstart = x;
|
|
|
|
if (xstart < VGLMouseXpos)
|
|
|
|
xstart = VGLMouseXpos;
|
|
|
|
xend = x + width;
|
2019-04-29 16:26:29 +00:00
|
|
|
if (xend > VGLMouseXpos + VGLMouseAndMask->VXsize)
|
|
|
|
xend = VGLMouseXpos + VGLMouseAndMask->VXsize;
|
2019-04-24 16:03:35 +00:00
|
|
|
for (x1 = xstart; x1 < xend; x1++) {
|
2019-04-29 16:26:29 +00:00
|
|
|
pos = (y - VGLMouseYpos) * VGLMouseAndMask->VXsize + x1 - VGLMouseXpos;
|
2019-04-24 16:03:35 +00:00
|
|
|
if (VGLMouseAndMask->Bitmap[pos])
|
|
|
|
bcopy(&VGLMouseOrMask->Bitmap[pos * VGLDisplay->PixelBytes],
|
|
|
|
&line[(x1 - x) * VGLDisplay->PixelBytes], VGLDisplay->PixelBytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-08-17 21:09:35 +00:00
|
|
|
void
|
|
|
|
VGLMouseUnFreeze()
|
|
|
|
{
|
2019-04-24 15:35:29 +00:00
|
|
|
INTON();
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|