Lines Matching +full:x +full:- +full:offset
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1991-1997 Søren Schmidt
44 #define ABS(a) (((a)<0) ? -(a) : (a))
45 #define SGN(a) (((a)<0) ? -1 : 1)
46 #define min(x, y) (((x) < (y)) ? (x) : (y)) argument
47 #define max(x, y) (((x) > (y)) ? (x) : (y)) argument
50 VGLSetXY(VGLBitmap *object, int x, int y, u_long color) in VGLSetXY() argument
52 int offset, soffset, undermouse; in VGLSetXY() local
55 if (x>=0 && x<object->VXsize && y>=0 && y<object->VYsize) { in VGLSetXY()
57 undermouse = VGLMouseFreezeXY(x, y); in VGLSetXY()
58 VGLSetXY(&VGLVDisplay, x, y, color); in VGLSetXY()
59 } else if (object->Type != MEMBUF) in VGLSetXY()
64 offset = (y * object->VXsize + x) * object->PixelBytes; in VGLSetXY()
65 switch (object->Type) { in VGLSetXY()
69 offset = VGLSetSegment(offset); in VGLSetXY()
77 switch (object->PixelBytes) { in VGLSetXY()
79 memcpy(&object->Bitmap[offset], &color, 1); in VGLSetXY()
82 memcpy(&object->Bitmap[offset], &color, 2); in VGLSetXY()
85 memcpy(&object->Bitmap[offset], &color, 3); in VGLSetXY()
88 memcpy(&object->Bitmap[offset], &color, 4); in VGLSetXY()
93 soffset = VGLSetSegment(offset); in VGLSetXY()
95 switch (VGLAdpInfo.va_window_size - soffset) { in VGLSetXY()
97 memcpy(&object->Bitmap[soffset], &color, 1); in VGLSetXY()
98 soffset = VGLSetSegment(offset + 1); in VGLSetXY()
99 memcpy(&object->Bitmap[soffset], (byte *)&color + 1, 2); in VGLSetXY()
102 memcpy(&object->Bitmap[soffset], &color, 2); in VGLSetXY()
103 soffset = VGLSetSegment(offset + 2); in VGLSetXY()
104 memcpy(&object->Bitmap[soffset], (byte *)&color + 2, 1); in VGLSetXY()
107 memcpy(&object->Bitmap[soffset], &color, 3); in VGLSetXY()
113 outb(0x3c5, 0x01 << (x&0x3)); in VGLSetXY()
114 object->Bitmap[(unsigned)(VGLAdpInfo.va_line_width*y)+(x/4)] = ((byte)color); in VGLSetXY()
117 offset = VGLSetSegment(y*VGLAdpInfo.va_line_width + x/8); in VGLSetXY()
120 offset = y*VGLAdpInfo.va_line_width + x/8; in VGLSetXY()
125 outb(0x3ce, 0x08); outb(0x3cf, 0x80 >> (x%8)); /* bit mask */ in VGLSetXY()
126 object->Bitmap[offset] |= (byte)color; in VGLSetXY()
135 VGLGetXY(VGLBitmap *object, int x, int y) in VGLGetXY() argument
138 int offset; in VGLGetXY() local
141 if (x<0 || x>=object->VXsize || y<0 || y>=object->VYsize) in VGLGetXY()
145 else if (object->Type != MEMBUF) in VGLGetXY()
147 offset = (y * object->VXsize + x) * object->PixelBytes; in VGLGetXY()
148 switch (object->PixelBytes) { in VGLGetXY()
150 memcpy(&color, &object->Bitmap[offset], 1); in VGLGetXY()
153 memcpy(&color, &object->Bitmap[offset], 2); in VGLGetXY()
156 memcpy(&color, &object->Bitmap[offset], 3); in VGLGetXY()
159 memcpy(&color, &object->Bitmap[offset], 4); in VGLGetXY()
171 #define SL_ABSOLUTE(i,j,k) ( (i-j)*(k = ( (i-j)<0 ? -1 : 1)))
174 plot(VGLBitmap * object, int x, int y, int flag, u_long color) in plot() argument
176 /* non-zero flag indicates the pixels need swapping back. */ in plot()
178 VGLSetXY(object, y, x, color); in plot()
180 VGLSetXY(object, x, y, color); in plot()
187 int dx, dy, incr1, incr2, D, x, y, xend, c, pixels_left; in VGLLine() local
196 step = -1; in VGLLine()
207 x = x2; in VGLLine()
212 x = x1; in VGLLine()
219 /* Note dx=n implies 0 - n or (dx+1) pixels to be set */ in VGLLine()
221 /* In fact (dx-1)/4 as 2 pixels are already plotted */ in VGLLine()
222 xend = (dx - 1) / 4; in VGLLine()
223 pixels_left = (dx - 1) % 4; /* number of pixels left over at the in VGLLine()
225 plot(object, x, y, reverse, color); in VGLLine()
230 incr2 = 4 * dy - 2 * dx; in VGLLine()
234 D = incr1 - dx; in VGLLine()
237 ++x; in VGLLine()
238 --x1; in VGLLine()
241 plot(object, x, y, reverse, color); in VGLLine()
242 plot(object, ++x, y, reverse, color); in VGLLine()
245 plot(object, --x1, y1, reverse, color); in VGLLine()
250 plot(object, x, y, reverse, color); in VGLLine()
251 plot(object, ++x, y += step, reverse, in VGLLine()
255 plot(object, --x1, y1 -= step, reverse, in VGLLine()
259 plot(object, x, y += step, reverse, color); in VGLLine()
260 plot(object, ++x, y, reverse, color); in VGLLine()
262 plot(object, x1, y1 -= step, reverse, in VGLLine()
264 plot(object, --x1, y1, reverse, color); in VGLLine()
273 plot(object, ++x, y, reverse, color); /* pattern 1 */ in VGLLine()
275 plot(object, ++x, y, reverse, color); in VGLLine()
277 plot(object, --x1, y1, reverse, color); in VGLLine()
280 plot(object, ++x, y, reverse, color); /* pattern 2 */ in VGLLine()
282 plot(object, ++x, y += step, reverse, color); in VGLLine()
284 plot(object, --x1, y1, reverse, color); in VGLLine()
287 plot(object, ++x, y += step, reverse, color); in VGLLine()
289 plot(object, ++x, y, reverse, color); in VGLLine()
291 plot(object, --x1, y1 -= step, reverse, color); in VGLLine()
298 c = 2 * (dy - dx); in VGLLine()
302 ++x; in VGLLine()
303 --x1; in VGLLine()
306 plot(object, x, y += step, reverse, color); in VGLLine()
307 plot(object, ++x, y += step, reverse, color); in VGLLine()
309 plot(object, x1, y1 -= step, reverse, color); in VGLLine()
310 plot(object, --x1, y1 -= step, reverse, color); in VGLLine()
315 plot(object, x, y, reverse, color); in VGLLine()
316 plot(object, ++x, y += step, reverse, in VGLLine()
321 plot(object, --x1, y1 -= step, reverse, in VGLLine()
325 plot(object, x, y += step, reverse, color); in VGLLine()
326 plot(object, ++x, y, reverse, color); in VGLLine()
328 plot(object, x1, y1 -= step, reverse, color); in VGLLine()
329 plot(object, --x1, y1, reverse, color); in VGLLine()
337 plot(object, ++x, y += step, reverse, color); /* pattern 4 */ in VGLLine()
339 plot(object, ++x, y += step, reverse, in VGLLine()
342 plot(object, --x1, y1 -= step, reverse, in VGLLine()
346 plot(object, ++x, y, reverse, color); /* pattern 2 */ in VGLLine()
348 plot(object, ++x, y += step, reverse, color); in VGLLine()
350 plot(object, --x1, y1, reverse, color); in VGLLine()
353 plot(object, ++x, y += step, reverse, color); in VGLLine()
355 plot(object, ++x, y, reverse, color); in VGLLine()
358 plot(object, --x1, y1 -= step, reverse, color); in VGLLine()
360 plot(object, --x1, y1, reverse, color); in VGLLine()
386 set4pixels(VGLBitmap *object, int x, int y, int xc, int yc, u_long color) in set4pixels() argument
388 if (x!=0) { in set4pixels()
389 VGLSetXY(object, xc+x, yc+y, color); in set4pixels()
390 VGLSetXY(object, xc-x, yc+y, color); in set4pixels()
392 VGLSetXY(object, xc+x, yc-y, color); in set4pixels()
393 VGLSetXY(object, xc-x, yc-y, color); in set4pixels()
399 VGLSetXY(object, xc, yc-y, color); in set4pixels()
406 int x = 0, y = b, asq = a*a, asq2 = a*a*2, bsq = b*b; in VGLEllipse() local
407 int bsq2 = b*b*2, d = bsq-asq*b+asq/4, dx = 0, dy = asq2*b; in VGLEllipse()
410 set4pixels(object, x, y, xc, yc, color); in VGLEllipse()
412 y--; dy-=asq2; d-=dy; in VGLEllipse()
414 x++; dx+=bsq2; d+=bsq+dx; in VGLEllipse()
416 d+=(3*(asq-bsq)/2-(dx+dy))/2; in VGLEllipse()
418 set4pixels(object, x, y, xc, yc, color); in VGLEllipse()
420 x++; dx+=bsq2; d+=dx; in VGLEllipse()
422 y--; dy-=asq2; d+=asq-dy; in VGLEllipse()
427 set2lines(VGLBitmap *object, int x, int y, int xc, int yc, u_long color) in set2lines() argument
429 if (x!=0) { in set2lines()
430 VGLLine(object, xc+x, yc+y, xc-x, yc+y, color); in set2lines()
432 VGLLine(object, xc+x, yc-y, xc-x, yc-y, color); in set2lines()
435 VGLLine(object, xc, yc+y, xc, yc-y, color); in set2lines()
442 int x = 0, y = b, asq = a*a, asq2 = a*a*2, bsq = b*b; in VGLFilledEllipse() local
443 int bsq2 = b*b*2, d = bsq-asq*b+asq/4, dx = 0, dy = asq2*b; in VGLFilledEllipse()
446 set2lines(object, x, y, xc, yc, color); in VGLFilledEllipse()
448 y--; dy-=asq2; d-=dy; in VGLFilledEllipse()
450 x++; dx+=bsq2; d+=bsq+dx; in VGLFilledEllipse()
452 d+=(3*(asq-bsq)/2-(dx+dy))/2; in VGLFilledEllipse()
454 set2lines(object, x, y, xc, yc, color); in VGLFilledEllipse()
456 x++; dx+=bsq2; d+=dx; in VGLFilledEllipse()
458 y--; dy-=asq2; d+=asq-dy; in VGLFilledEllipse()
466 int i, len, mousemode, offset; in VGLClear() local
472 } else if (object->Type != MEMBUF) in VGLClear()
474 switch (object->Type) { in VGLClear()
485 src.Xsize = object->Xsize; in VGLClear()
486 src.VXsize = object->VXsize; in VGLClear()
491 src.Bitmap = alloca(object->VXsize * object->PixelBytes); in VGLClear()
492 src.PixelBytes = object->PixelBytes; in VGLClear()
494 for (i = 0; i < object->VXsize; i++) in VGLClear()
495 bcopy(&color, src.Bitmap + i * object->PixelBytes, object->PixelBytes); in VGLClear()
496 for (i = 0; i < object->VYsize; i++) in VGLClear()
497 __VGLBitmapCopy(&src, 0, 0, object, 0, i, object->VXsize, -1); in VGLClear()
505 memset(object->Bitmap, (byte)color, VGLAdpInfo.va_line_width*object->VYsize); in VGLClear()
517 for (offset = 0; offset < VGLAdpInfo.va_line_width*object->VYsize; ) { in VGLClear()
518 VGLSetSegment(offset); in VGLClear()
519 len = min(object->VXsize*object->VYsize - offset, in VGLClear()
521 memset(object->Bitmap, (byte)color, len); in VGLClear()
522 offset += len; in VGLClear()
540 return (r >> (16 - nr) << (ng + nb)) | (g >> (16 - ng) << nb) | in VGLrgbToNative()
541 (b >> (16 - nb) << 0); in VGLrgbToNative()