Fix copying of bitmaps in depths > 8. This fix is complete, except different

depths for the source and target are not supported.  The bits for higher
numbered planes (mostly for red) were either not copied or were copied to
lower numbered planes for nearby pixels.

Quick fix for creation of mouse cursor bitmaps in all depths.   This fix is
only complete for the default lightwhite cursor with a black frame.

Even the lightwhite and black colors are hard to find.  The templates
use 0xff for lightwhite, but that means brightblue in the simplest mode
(Truecolor depth 24).  Other modes are even more complicated -- they are
singly or doubly indirect throught palette(s) and changing of the palettes
by applications is supported.

Details:

Replicate the template value for Truecolor modes to fill out the target
depth (and more for depths not a multiple of 8).  Do this for every
drawing of the cursor so that it sort of works for mouse cursor bitmaps
set by applications.

Use 0xf for lightwhite in most other modes.  Only do this for the
default cursor so that it doesn't affect mouse cursor bitmaps set by
applications.  0xf mostly works because it was originally for CGA
lightwhite and is emulated using 1 or 2 indirections on EGA and VGA.
0x3f (EGA white) and 0xff (VGA black) direct palette indexes mostly
don't work since backwards compatibility inhibits or prevents them
representing lightwhite.  But 0x3f (EGA white) must be used for mode
37 (VGA_MODEX) (320x240x8 V) since this mode is closer to EGA than VGA.
This commit is contained in:
Bruce Evans 2019-03-27 08:02:55 +00:00
parent 8207def158
commit aa1ce985e4
2 changed files with 33 additions and 9 deletions

View File

@ -325,13 +325,13 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy,
if (src->Type == MEMBUF) {
for (srcline=srcy, dstline=dsty; srcline<srcy+hight; srcline++, dstline++) {
WriteVerticalLine(dst, dstx, dstline, width,
(src->Bitmap+(srcline*src->VXsize)+srcx));
src->Bitmap+(srcline*src->VXsize+srcx)*dst->PixelBytes);
}
}
else if (dst->Type == MEMBUF) {
for (srcline=srcy, dstline=dsty; srcline<srcy+hight; srcline++, dstline++) {
ReadVerticalLine(src, srcx, srcline, width,
(dst->Bitmap+(dstline*dst->VXsize)+dstx));
dst->Bitmap+(dstline*dst->VXsize+dstx)*src->PixelBytes);
}
}
else {

View File

@ -99,7 +99,7 @@ VGLMousePointerShow()
VGLBitmap buffer =
VGLBITMAP_INITIALIZER(MEMBUF, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE, buf);
byte crtcidx, crtcval, gdcidx, gdcval;
int pos;
int i, pos, pos1;
if (!VGLMouseVisible) {
VGLMouseVisible = 1;
@ -109,10 +109,15 @@ VGLMousePointerShow()
gdcval = inb(0x3cf);
__VGLBitmapCopy(VGLDisplay, VGLMouseXpos, VGLMouseYpos,
&VGLMouseSave, 0, 0, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE);
bcopy(VGLMouseSave.Bitmap, buffer.Bitmap, MOUSE_IMG_SIZE*MOUSE_IMG_SIZE);
bcopy(VGLMouseSave.Bitmap, buffer.Bitmap,
MOUSE_IMG_SIZE*MOUSE_IMG_SIZE*VGLDisplay->PixelBytes);
for (pos = 0; pos < MOUSE_IMG_SIZE*MOUSE_IMG_SIZE; pos++)
buffer.Bitmap[pos]=(buffer.Bitmap[pos]&~(VGLMouseAndMask->Bitmap[pos])) |
VGLMouseOrMask->Bitmap[pos];
for (i = 0; i < VGLDisplay->PixelBytes; i++) {
pos1 = pos * VGLDisplay->PixelBytes + i;
buffer.Bitmap[pos1] = (buffer.Bitmap[pos1] &
~VGLMouseAndMask->Bitmap[pos]) |
VGLMouseOrMask->Bitmap[pos];
}
__VGLBitmapCopy(&buffer, 0, 0, VGLDisplay,
VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE);
outb(0x3c4, crtcidx);
@ -205,8 +210,22 @@ int
VGLMouseInit(int mode)
{
struct mouse_info mouseinfo;
int error;
int error, i, mask;
switch (VGLModeInfo.vi_mem_model) {
case V_INFO_MM_PACKED:
case V_INFO_MM_PLANAR:
mask = 0x0f;
break;
case V_INFO_MM_VGAX:
mask = 0x3f;
break;
default:
mask = 0xff;
break;
}
for (i = 0; i < 256; i++)
VGLMouseStdOrMask.Bitmap[i] &= mask;
VGLMouseSetStdImage();
mouseinfo.operation = MOUSE_MODE;
mouseinfo.u.mode.signal = SIGUSR2;
@ -236,6 +255,8 @@ VGLMouseStatus(int *x, int *y, char *buttons)
int
VGLMouseFreeze(int x, int y, int width, int hight, u_long color)
{
int i, xstride, ystride;
if (!VGLMouseFrozen) {
VGLMouseFrozen = 1;
if (width > 1 || hight > 1) { /* bitmap */
@ -260,8 +281,11 @@ VGLMouseFreeze(int x, int y, int width, int hight, u_long color)
if (VGLMouseShown &&
x >= VGLMouseXpos && x < VGLMouseXpos + MOUSE_IMG_SIZE &&
y >= VGLMouseYpos && y < VGLMouseYpos + MOUSE_IMG_SIZE) {
VGLMouseSave.Bitmap[(y-VGLMouseYpos)*MOUSE_IMG_SIZE+(x-VGLMouseXpos)] =
(color);
xstride = VGLDisplay->PixelBytes;
ystride = MOUSE_IMG_SIZE * xstride;
for (i = 0; i < xstride; i++, color >>= 8)
VGLMouseSave.Bitmap[(y-VGLMouseYpos)*ystride+
(x-VGLMouseXpos)*xstride+i] = color;
if (VGLMouseAndMask->Bitmap
[(y-VGLMouseYpos)*MOUSE_IMG_SIZE+(x-VGLMouseXpos)]) {
return 1;