ReactOS 0.4.15-dev-5667-ged97270
vgavideo.c File Reference
#include <vgaddi.h>
Include dependency graph for vgavideo.c:

Go to the source code of this file.

Functions

UCHAR bytesPerPixel (ULONG Format)
 
VOID vgaPreCalc ()
 
void get_masks (int x, int w)
 
VOID vgaPutPixel (INT x, INT y, UCHAR c)
 
VOID vgaPutByte (INT x, INT y, UCHAR c)
 
VOID vgaGetByte (IN ULONG offset, OUT UCHAR *b, OUT UCHAR *g, OUT UCHAR *r, OUT UCHAR *i)
 
INT vgaGetPixel (IN INT x, IN INT y)
 
BOOL vgaHLine (INT x, INT y, INT len, UCHAR c)
 
BOOL vgaVLine (INT x, INT y, INT len, UCHAR c)
 
BOOL VGADDIIntersectRect (PRECTL prcDst, PRECTL prcSrc1, PRECTL prcSrc2)
 
void DIB_BltFromVGA (int x, int y, int w, int h, void *b, int Dest_lDelta)
 
void DIB_BltToVGA (int x, int y, int w, int h, void *b, int Source_lDelta, int StartMod)
 
void DIB_BltToVGAWithXlate (int x, int y, int w, int h, void *b, int Source_lDelta, XLATEOBJ *Xlate)
 
void DIB_TransparentBltToVGA (int x, int y, int w, int h, void *b, int Source_lDelta, ULONG trans)
 
void FASTCALL vgaReadScan (int x, int y, int w, void *b)
 
void FASTCALL vgaWriteScan (int x, int y, int w, void *b)
 
void DFB_BltFromVGA (int x, int y, int w, int h, void *b, int bw)
 
void DFB_BltToVGA (int x, int y, int w, int h, void *b, int bw)
 
void DFB_BltToVGA_Transparent (int x, int y, int w, int h, void *b, int bw, char Trans)
 
void DFB_BltToDIB (int x, int y, int w, int h, void *b, int bw, void *bdib, int dibw)
 
void DIB_BltToDFB (int x, int y, int w, int h, void *b, int bw, void *bdib, int dibw)
 

Variables

UCHAR PreCalcReverseByte [256]
 
int maskbit [640]
 
int y80 [480]
 
int xconv [640]
 
int bit8 [640]
 
int startmasks [8]
 
int endmasks [8]
 
PBYTE vidmem
 
static ULONG UnpackPixel [256]
 
static unsigned char leftMask
 
static int byteCounter
 
static unsigned char rightMask
 
static const RECTL rclEmpty = { 0, 0, 0, 0 }
 

Function Documentation

◆ bytesPerPixel()

UCHAR bytesPerPixel ( ULONG  Format)

Definition at line 25 of file vgavideo.c.

26{
27 /* This function is taken from /subsys/win32k/eng/surface.c
28 * FIXME: GDI bitmaps are supposed to be pixel-packed. Right now if the
29 * pixel size if < 1 byte we expand it to 1 byte for simplicities sake */
30
31 switch (Format)
32 {
33 case BMF_1BPP:
34 return 1;
35
36 case BMF_4BPP:
37 case BMF_4RLE:
38 return 1;
39
40 case BMF_8BPP:
41 case BMF_8RLE:
42 return 1;
43
44 case BMF_16BPP:
45 return 2;
46
47 case BMF_24BPP:
48 return 3;
49
50 case BMF_32BPP:
51 return 4;
52
53 default:
54 return 0;
55 }
56}
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
#define BMF_1BPP
Definition: winddi.h:355
#define BMF_24BPP
Definition: winddi.h:359
#define BMF_32BPP
Definition: winddi.h:360
#define BMF_8RLE
Definition: winddi.h:362
#define BMF_4RLE
Definition: winddi.h:361
#define BMF_4BPP
Definition: winddi.h:356

◆ DFB_BltFromVGA()

void DFB_BltFromVGA ( int  x,
int  y,
int  w,
int  h,
void b,
int  bw 
)

Definition at line 709 of file vgavideo.c.

710{
711 unsigned char *vp, *vpY, *vpP;
712 unsigned char data, mask, maskP;
713 unsigned char *bp, *bpY;
714 unsigned char plane_mask;
715 int byte_per_line = SCREEN_X >> 3;
716 int plane, i, j;
717
718 ASSIGNVP4(x, y, vpP)
719 ASSIGNMK4(x, y, maskP)
720 get_masks(x, w);
721 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); // read mode 0
723 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x04); // read map select
724
725 /* clear buffer */
726 bp = b;
727 for (j = h; j > 0; j--)
728 {
729 memset(bp, 0, w);
730 bp += bw;
731 }
732
733 for (plane = 0, plane_mask = 1; plane < 4; plane++, plane_mask <<= 1)
734 {
735 WRITE_PORT_UCHAR((PUCHAR)GRA_D, plane); // read map select
736 vpY = vpP;
737 bpY = b;
738 for (j = h; j > 0; j--)
739 {
740 vp = vpY;
741 bp = bpY;
742 if (leftMask)
743 {
744 mask = maskP;
745 data = *vp++;
746 do
747 {
748 if (data & mask)
749 *bp |= plane_mask;
750 bp++;
751 mask >>= 1;
752 } while (mask & leftMask);
753 }
754 if (byteCounter)
755 {
756 for (i=byteCounter; i>0; i--)
757 {
758 data = *vp++;
759 if (data & 0x80) *bp |= plane_mask;
760 bp++;
761 if (data & 0x40) *bp |= plane_mask;
762 bp++;
763 if (data & 0x20) *bp |= plane_mask;
764 bp++;
765 if (data & 0x10) *bp |= plane_mask;
766 bp++;
767 if (data & 0x08) *bp |= plane_mask;
768 bp++;
769 if (data & 0x04) *bp |= plane_mask;
770 bp++;
771 if (data & 0x02) *bp |= plane_mask;
772 bp++;
773 if (data & 0x01) *bp |= plane_mask;
774 bp++;
775 }
776 }
777 if (rightMask)
778 {
779 mask = 0x80;
780 data = *vp;
781 do
782 {
783 if (data & mask) *bp |= plane_mask;
784 bp++;
785 mask >>= 1;
786 } while (mask & rightMask);
787 }
788 bpY += bw;
789 vpY += byte_per_line;
790 }
791 }
792
793 // We don't need this if the next call is a DFB blt to VGA (as in the case of moving the mouse pointer)
794 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); // write mode 2
796 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); // replace
798}
static int bw
Definition: maze.c:120
#define GRA_D
Definition: vgavideo.h:60
#define SCREEN_X
Definition: vgavideo.h:2
#define ASSIGNMK4(x, y, mask)
Definition: vgavideo.h:66
#define ASSIGNVP4(x, y, vp)
Definition: vgavideo.h:65
#define GRA_I
Definition: vgavideo.h:59
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLint GLuint mask
Definition: glext.h:6028
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum plane
Definition: glfuncs.h:270
#define b
Definition: ke_i.h:79
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define memset(x, y, z)
Definition: compat.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
void get_masks(int x, int w)
Definition: vgavideo.c:133
static unsigned char rightMask
Definition: vgavideo.c:23
static int byteCounter
Definition: vgavideo.c:22
static unsigned char leftMask
Definition: vgavideo.c:21

◆ DFB_BltToDIB()

void DFB_BltToDIB ( int  x,
int  y,
int  w,
int  h,
void b,
int  bw,
void bdib,
int  dibw 
)

Definition at line 891 of file vgavideo.c.

892{
893 unsigned char *bp, *bpX, *dib, *dibTmp;
894 int i, j, dib_shift;
895
896 bpX = b;
897 dib = (unsigned char *)bdib + y * dibw + (x / 2);
898
899 for (i=w; i>0; i--)
900 {
901 /* determine the bit shift for the DIB pixel */
902 dib_shift = mod2(w-i);
903 if(dib_shift > 0)
904 dib_shift = 4;
905 dibTmp = dib;
906
907 bp = bpX;
908 for (j = h; j > 0; j--)
909 {
910 *dibTmp = *bp << dib_shift | *(bp + 1);
911 dibTmp += dibw;
912 bp += bw;
913 }
914 bpX++;
915 if(dib_shift == 0)
916 dib++;
917 }
918}
#define mod2(n)
Definition: vgavideo.h:71
static const BYTE dib[]
Definition: ole2.c:201

◆ DFB_BltToVGA()

void DFB_BltToVGA ( int  x,
int  y,
int  w,
int  h,
void b,
int  bw 
)

Definition at line 802 of file vgavideo.c.

803{
804 unsigned char *bp, *bpX;
805 unsigned char *vp, *vpX;
806 unsigned char mask;
807 //volatile unsigned char dummy;
808 int byte_per_line;
809 int i, j;
810
811 bpX = b;
812 ASSIGNVP4(x, y, vpX)
813 ASSIGNMK4(x, y, mask)
814 byte_per_line = SCREEN_X >> 3;
815
816 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); // write mode 2
818 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); // replace
820 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); // bit mask
821
822 for (i=w; i>0; i--)
823 {
825 bp = bpX;
826 vp = vpX;
827 for (j = h; j > 0; j--)
828 {
829 //dummy = *vp;
830 *vp = *bp;
831 bp += bw;
832 vp += byte_per_line;
833 }
834 bpX++;
835 if ((mask >>= 1) == 0)
836 {
837 vpX++;
838 mask = 0x80;
839 }
840 }
841}

◆ DFB_BltToVGA_Transparent()

void DFB_BltToVGA_Transparent ( int  x,
int  y,
int  w,
int  h,
void b,
int  bw,
char  Trans 
)

Definition at line 845 of file vgavideo.c.

846{
847 unsigned char *bp, *bpX;
848 unsigned char *vp, *vpX;
849 unsigned char mask;
850 //volatile unsigned char dummy;
851 int byte_per_line;
852 int i, j;
853
854 bpX = b;
855 ASSIGNVP4(x, y, vpX)
856 ASSIGNMK4(x, y, mask)
857 byte_per_line = SCREEN_X >> 3;
858
859 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); // write mode 2
861 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); // replace
863 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); // bit mask
864
865 for (i=w; i>0; i--)
866 {
868 bp = bpX;
869 vp = vpX;
870 for (j=h; j>0; j--)
871 {
872 if (*bp != Trans)
873 {
874 //dummy = *vp;
875 *vp = *bp;
876 }
877 bp += bw;
878 vp += byte_per_line;
879 }
880 bpX++;
881 if ((mask >>= 1) == 0)
882 {
883 vpX++;
884 mask = 0x80;
885 }
886 }
887}

◆ DIB_BltFromVGA()

void DIB_BltFromVGA ( int  x,
int  y,
int  w,
int  h,
void b,
int  Dest_lDelta 
)

Definition at line 352 of file vgavideo.c.

353{
354 ULONG plane;
355 ULONG left = x >> 3;
356 ULONG shift = x - (x & ~0x7);
357 UCHAR pixel, nextpixel;
358 LONG rightcount;
359 INT i, j;
360 LONG stride = w >> 3;
361
362 /* Calculate the number of rightmost bytes not in a dword block. */
363 if (w >= 8)
364 {
365 rightcount = w % 8;
366 }
367 else
368 {
369 stride = 0;
370 rightcount = w;
371 }
372 rightcount = (rightcount + 1) / 2;
373
374 /* Reset the destination. */
375 for (j = 0; j < h; j++)
376 memset((PVOID)((ULONG_PTR)b + (j * Dest_lDelta)), 0, abs(Dest_lDelta));
377
378 for (plane = 0; plane < 4; plane++)
379 {
380 PUCHAR dest = b;
381
382 /* Select the plane we are reading in this iteration. */
385
386 for (j = 0; j < h; j++)
387 {
388 PULONG destline = (PULONG)dest;
389 PUCHAR src = vidmem + (y + j) * SCREEN_STRIDE + left;
390 /* Read the data for one plane for an eight aligned pixel block. */
392 for (i = 0; i < stride; i++, src++, destline++)
393 {
394 /* Form the data for one plane for an aligned block in the destination. */
395 pixel = nextpixel;
396 pixel >>= shift;
397
399 pixel |= (nextpixel << (8 - shift));
400
401 /* Expand the plane data to 'chunky' format and store. */
402 *destline |= (UnpackPixel[pixel] << plane);
403 }
404 /* Handle any pixels not falling into a full block. */
405 if (rightcount != 0)
406 {
407 ULONG row;
408
409 /* Form the data for a complete block. */
410 pixel = nextpixel;
411 pixel >>= shift;
412
414 pixel |= (nextpixel << (8 - shift));
415
416 row = UnpackPixel[pixel] << plane;
417
418 /* Store the data for each byte in the destination. */
419 for (i = 0; i < rightcount; i++)
420 {
421 ((PUCHAR)destline)[i] |= (row & 0xFF);
422 row >>= 8;
423 }
424 }
425 dest += Dest_lDelta;
426 }
427 }
428
429#ifdef VGA_VERIFY
430 for (j = 0; j < h; j++)
431 {
432 for (i = 0; i < w; i += 2)
433 {
434 UCHAR c1, c2;
435 ULONG mask = (i < (w - 1)) ? 0xFF : 0xF0;
436
437 c1 = (vgaGetPixel(x + i, y + j) << 4) | (vgaGetPixel(x + i + 1, y + j));
438 c2 = ((PUCHAR)b)[(j * Dest_lDelta) + (i >> 1)];
439 if ((c1 & mask) != (c2 & mask))
441 }
442 }
443#endif /* VGA_VERIFY */
444}
#define SCREEN_STRIDE
Definition: vgavideo.h:5
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
#define ULONG_PTR
Definition: config.h:101
#define abs(i)
Definition: fconv.c:206
GLsizei stride
Definition: glext.h:5848
GLenum src
Definition: glext.h:6340
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLint left
Definition: glext.h:7726
static char * dest
Definition: rtl.c:135
#define shift
Definition: input.c:1755
long LONG
Definition: pedump.c:60
uint32_t * PULONG
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
static ULONG UnpackPixel[256]
Definition: vgavideo.c:19
INT vgaGetPixel(IN INT x, IN INT y)
Definition: vgavideo.c:206
PBYTE vidmem
Definition: vgavideo.c:18
UCHAR PreCalcReverseByte[256]
Definition: vgavideo.c:11
_Analysis_noreturn_ ENGAPI VOID APIENTRY EngDebugBreak(VOID)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DrvCopyBits(), and VGAtoDIB().

◆ DIB_BltToDFB()

void DIB_BltToDFB ( int  x,
int  y,
int  w,
int  h,
void b,
int  bw,
void bdib,
int  dibw 
)

Definition at line 921 of file vgavideo.c.

922{
923 unsigned char *bp, *bpX, *dib, *dibTmp;
924 int i, j, dib_shift, dib_and;
925
926 bpX = b;
927 dib = (unsigned char *)bdib + y * dibw + (x / 2);
928
929 for (i=w; i>0; i--)
930 {
931 /* determine the bit shift for the DIB pixel */
932 dib_shift = mod2(w-i);
933 if(dib_shift > 0)
934 {
935 dib_shift = 0;
936 dib_and = 0x0f;
937 }
938 else
939 {
940 dib_shift = 4;
941 dib_and = 0xf0;
942 }
943
944 dibTmp = dib;
945 bp = bpX;
946
947 for (j=h; j>0; j--)
948 {
949 *bp = (*dibTmp & dib_and) >> dib_shift;
950 dibTmp += dibw;
951 bp += bw;
952 }
953
954 bpX++;
955 if (dib_shift == 0)
956 dib++;
957 }
958}

◆ DIB_BltToVGA()

void DIB_BltToVGA ( int  x,
int  y,
int  w,
int  h,
void b,
int  Source_lDelta,
int  StartMod 
)

Definition at line 447 of file vgavideo.c.

448{
449 PUCHAR pb, opb = b;
450 LONG i, j;
451 LONG x2 = x + w;
452 LONG y2 = y + h;
454
455 for (i = x; i < x2; i++)
456 {
457 pb = opb;
458 offset = xconv[i] + y80[y];
459
460 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); // set the mask
462
463 if (StartMod == ((i - x) % 2))
464 {
465 for (j = y; j < y2; j++)
466 {
468 WRITE_REGISTER_UCHAR(vidmem + offset, (*pb & 0xf0) >> 4);
469 offset += 80;
470 pb += Source_lDelta;
471 }
472 }
473 else
474 {
475 for (j = y; j < y2; j++)
476 {
478 WRITE_REGISTER_UCHAR(vidmem + offset, *pb & 0x0f);
479 offset += 80;
480 pb += Source_lDelta;
481 }
482 }
483
484 if (StartMod != ((i - x) % 2))
485 opb++;
486 }
487}
GLintptr offset
Definition: glext.h:5920
int xconv[640]
Definition: vgavideo.c:14
int maskbit[640]
Definition: vgavideo.c:12
int y80[480]
Definition: vgavideo.c:13
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)

Referenced by DIBtoVGA(), and DrvCopyBits().

◆ DIB_BltToVGAWithXlate()

void DIB_BltToVGAWithXlate ( int  x,
int  y,
int  w,
int  h,
void b,
int  Source_lDelta,
XLATEOBJ Xlate 
)

Definition at line 491 of file vgavideo.c.

492{
493 PUCHAR pb, opb = b;
494 ULONG i, j;
495 ULONG x2 = x + w;
496 ULONG y2 = y + h;
498
499 for (i = x; i < x2; i++)
500 {
501 pb = opb;
502 offset = xconv[i] + y80[y];
503
504 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); // set the mask
506
507 if (0 == ((i - x) % 2))
508 {
509 for (j = y; j < y2; j++)
510 {
512 WRITE_REGISTER_UCHAR(vidmem + offset, XLATEOBJ_iXlate(Xlate, (*pb & 0xf0) >> 4));
513 offset += 80;
514 pb += Source_lDelta;
515 }
516 }
517 else
518 {
519 for (j = y; j < y2; j++)
520 {
522 WRITE_REGISTER_UCHAR(vidmem + offset, XLATEOBJ_iXlate(Xlate, *pb & 0x0f));
523 offset += 80;
524 pb += Source_lDelta;
525 }
526 }
527
528 if (0 != ((i - x) % 2))
529 opb++;
530 }
531}
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:664

Referenced by DIBtoVGA().

◆ DIB_TransparentBltToVGA()

void DIB_TransparentBltToVGA ( int  x,
int  y,
int  w,
int  h,
void b,
int  Source_lDelta,
ULONG  trans 
)

Definition at line 536 of file vgavideo.c.

538{
539 PUCHAR pb = b, opb = b;
540 BOOLEAN edgePixel = FALSE;
541 ULONG i, j;
542 ULONG x2 = x + w;
543 ULONG y2 = y + h;
544 UCHAR b1, b2;
545
546 /* Check if the width is odd */
547 if(mod2(w) > 0)
548 {
549 edgePixel = TRUE;
550 x2 -= 1;
551 }
552
553 for (j=y; j<y2; j++)
554 {
555 for (i=x; i<x2; i+=2)
556 {
557 b1 = (*pb & 0xf0) >> 4;
558 b2 = *pb & 0x0f;
559 if(b1 != trans) vgaPutPixel(i, j, b1);
560 if(b2 != trans) vgaPutPixel(i+1, j, b2);
561 pb++;
562 }
563
564 if (edgePixel)
565 {
566 b1 = *pb;
567 if(b1 != trans) vgaPutPixel(x2, j, b1);
568 pb++;
569 }
570
571 opb += Source_lDelta;
572 pb = opb; // new test code
573 }
574}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
VOID vgaPutPixel(INT x, INT y, UCHAR c)
Definition: vgavideo.c:163

Referenced by DrvTransparentBlt().

◆ get_masks()

void get_masks ( int  x,
int  w 
)

Definition at line 133 of file vgavideo.c.

134{
135 register int tmp;
136
137 leftMask = rightMask = 0;
138 byteCounter = w;
139 /* right margin */
140 tmp = (x+w) & 7;
141 if (tmp)
142 {
143 byteCounter -= tmp;
144 rightMask = (unsigned char)(0xff00 >> tmp);
145 }
146 /* left margin */
147 tmp = x & 7;
148 if (tmp)
149 {
150 byteCounter -= (8 - tmp);
151 leftMask = (0xff >> tmp);
152 }
153 /* too small ? */
154 if (byteCounter < 0)
155 {
157 rightMask = 0;
158 byteCounter = 0;
159 }
160 byteCounter /= 8;
161}
unsigned char
Definition: typeof.h:29

Referenced by DFB_BltFromVGA(), and vgaReadScan().

◆ VGADDIIntersectRect()

BOOL VGADDIIntersectRect ( PRECTL  prcDst,
PRECTL  prcSrc1,
PRECTL  prcSrc2 
)

Definition at line 333 of file vgavideo.c.

334{
335 prcDst->left = max(prcSrc1->left, prcSrc2->left);
336 prcDst->right = min(prcSrc1->right, prcSrc2->right);
337
338 if (prcDst->left < prcDst->right)
339 {
340 prcDst->top = max(prcSrc1->top, prcSrc2->top);
341 prcDst->bottom = min(prcSrc1->bottom, prcSrc2->bottom);
342
343 if (prcDst->top < prcDst->bottom)
344 return TRUE;
345 }
346
347 *prcDst = rclEmpty;
348
349 return FALSE;
350}
#define min(a, b)
Definition: monoChain.cc:55
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
#define max(a, b)
Definition: svc.c:63
static const RECTL rclEmpty
Definition: vgavideo.c:331

◆ vgaGetByte()

VOID vgaGetByte ( IN ULONG  offset,
OUT UCHAR b,
OUT UCHAR g,
OUT UCHAR r,
OUT UCHAR i 
)

Definition at line 189 of file vgavideo.c.

195{
204}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115
uint16_t * PUSHORT
Definition: typedefs.h:56

Referenced by vgaGetPixel().

◆ vgaGetPixel()

INT vgaGetPixel ( IN INT  x,
IN INT  y 
)

Definition at line 206 of file vgavideo.c.

209{
210 UCHAR mask, b, g, r, i;
212
213 offset = xconv[x] + y80[y];
214 vgaGetByte(offset, &b, &g, &r, &i);
215
216 mask = maskbit[x];
217 b = b & mask;
218 g = g & mask;
219 r = r & mask;
220 i = i & mask;
221
222 mask = bit8[x];
223 g = g >> mask;
224 b = b >> mask;
225 r = r >> mask;
226 i = i >> mask;
227
228 return (b + 2 * g + 4 * r + 8 * i);
229}
int bit8[640]
Definition: vgavideo.c:15
VOID vgaGetByte(IN ULONG offset, OUT UCHAR *b, OUT UCHAR *g, OUT UCHAR *r, OUT UCHAR *i)
Definition: vgavideo.c:189

Referenced by DIB_BltFromVGA(), and VGAtoDIB().

◆ vgaHLine()

BOOL vgaHLine ( INT  x,
INT  y,
INT  len,
UCHAR  c 
)

Definition at line 231 of file vgavideo.c.

232{
233 ULONG orgx, pre1, midpre1;
234 //ULONG orgpre1;
235 LONG ileftpix, imidpix, irightpix;
236
237 orgx = x;
238
239 /*if ( len < 8 )
240 {
241 for (i = x; i < x+len; i++ )
242 vgaPutPixel ( i, y, c );
243
244 return TRUE;
245 }*/
246
247 /* Calculate the left mask pixels, middle bytes and right mask pixel */
248 ileftpix = 7 - mod8(x-1);
249 irightpix = mod8(x+len);
250 imidpix = (len-ileftpix-irightpix) / 8;
251
252 pre1 = xconv[(x-1)&~7] + y80[y];
253 //orgpre1=pre1;
254
255 /* check for overlap ( very short line ) */
256 if ( (ileftpix+irightpix) > len )
257 {
258 int mask = startmasks[ileftpix] & endmasks[irightpix];
259 /* Write left pixels */
260 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
262
265
266 return TRUE;
267 }
268
269 /* Left */
270 if ( ileftpix > 0 )
271 {
272 /* Write left pixels */
273 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
275
278
279 /* Prepare new x for the middle */
280 x = orgx + 8;
281 }
282
283 if ( imidpix > 0 )
284 {
285 midpre1 = xconv[x] + y80[y];
286
287 /* Set mask to all pixels in byte */
290 memset(vidmem+midpre1, c, imidpix); // write middle pixels, no need to read in latch because of the width
291 }
292
293 if ( irightpix > 0 )
294 {
295 x = orgx + len - irightpix;
296 pre1 = xconv[x] + y80[y];
297
298 /* Write right pixels */
299 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask bits
303 }
304
305 return TRUE;
306}
#define mod8(n)
Definition: vgavideo.h:70
const GLubyte * c
Definition: glext.h:8905
GLenum GLsizei len
Definition: glext.h:6722
int endmasks[8]
Definition: vgavideo.c:17
int startmasks[8]
Definition: vgavideo.c:16

Referenced by DrvLineTo().

◆ vgaPreCalc()

VOID vgaPreCalc ( )

Definition at line 58 of file vgavideo.c.

59{
60 ULONG j;
61
62 startmasks[0] = 255;
63 startmasks[1] = 1;
64 startmasks[2] = 3;
65 startmasks[3] = 7;
66 startmasks[4] = 15;
67 startmasks[5] = 31;
68 startmasks[6] = 63;
69 startmasks[7] = 127;
70
71 endmasks[0] = 0;
72 endmasks[1] = 128;
73 endmasks[2] = 192;
74 endmasks[3] = 224;
75 endmasks[4] = 240;
76 endmasks[5] = 248;
77 endmasks[6] = 252;
78 endmasks[7] = 254;
79
80 for (j = 0; j < 80; j++)
81 {
82 maskbit[j*8] = 128;
83 maskbit[j*8+1] = 64;
84 maskbit[j*8+2] = 32;
85 maskbit[j*8+3] = 16;
86 maskbit[j*8+4] = 8;
87 maskbit[j*8+5] = 4;
88 maskbit[j*8+6] = 2;
89 maskbit[j*8+7] = 1;
90
91 bit8[j*8] = 7;
92 bit8[j*8+1] = 6;
93 bit8[j*8+2] = 5;
94 bit8[j*8+3] = 4;
95 bit8[j*8+4] = 3;
96 bit8[j*8+5] = 2;
97 bit8[j*8+6] = 1;
98 bit8[j*8+7] = 0;
99 }
100 for (j = 0; j < SCREEN_Y; j++)
101 y80[j] = j*80;
102 for (j = 0; j < SCREEN_X; j++)
103 xconv[j] = j >> 3;
104
105 for (j = 0; j < 256; j++)
106 {
108 (((j >> 0) & 0x1) << 7) |
109 (((j >> 1) & 0x1) << 6) |
110 (((j >> 2) & 0x1) << 5) |
111 (((j >> 3) & 0x1) << 4) |
112 (((j >> 4) & 0x1) << 3) |
113 (((j >> 5) & 0x1) << 2) |
114 (((j >> 6) & 0x1) << 1) |
115 (((j >> 7) & 0x1) << 0);
116 }
117
118 for (j = 0; j < 256; j++)
119 {
120 UnpackPixel[j] =
121 (((j >> 0) & 0x1) << 4) |
122 (((j >> 1) & 0x1) << 0) |
123 (((j >> 2) & 0x1) << 12) |
124 (((j >> 3) & 0x1) << 8) |
125 (((j >> 4) & 0x1) << 20) |
126 (((j >> 5) & 0x1) << 16) |
127 (((j >> 6) & 0x1) << 28) |
128 (((j >> 7) & 0x1) << 24);
129 }
130}
#define SCREEN_Y
Definition: vgavideo.h:3

Referenced by DrvEnableDriver().

◆ vgaPutByte()

VOID vgaPutByte ( INT  x,
INT  y,
UCHAR  c 
)

Definition at line 176 of file vgavideo.c.

177{
179
180 offset = xconv[x]+y80[y];
181
182 /* Set the write mode */
185
187}

◆ vgaPutPixel()

VOID vgaPutPixel ( INT  x,
INT  y,
UCHAR  c 
)

◆ vgaReadScan()

void FASTCALL vgaReadScan ( int  x,
int  y,
int  w,
void b 
)

Definition at line 579 of file vgavideo.c.

580{
581 unsigned char *vp, *vpP;
582 unsigned char data, mask, maskP;
583 unsigned char *bp;
584 unsigned char plane_mask;
585 int plane, i;
586
587 ASSIGNVP4(x, y, vpP)
588 ASSIGNMK4(x, y, maskP)
589 get_masks(x, w);
590 WRITE_PORT_USHORT((PUSHORT)GRA_I, 0x0005); // read mode 0
591 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x04); // read map select
592
593 memset ( b, 0, w );
594
595 for ( plane=0, plane_mask=1; plane < 4; plane++, plane_mask<<=1 )
596 {
597 WRITE_PORT_UCHAR((PUCHAR)GRA_D, plane); // read map select
598
599 vp = vpP;
600 bp = b;
601 if ( leftMask )
602 {
603 mask = maskP;
604 data = *vp++;
605 do
606 {
607 if (data & mask)
608 *bp |= plane_mask;
609 bp++;
610 mask >>= 1;
611 } while (mask & leftMask);
612 }
613 if (byteCounter)
614 {
615 for (i=byteCounter; i>0; i--)
616 {
617 data = *vp++;
618 if (data & 0x80) *bp |= plane_mask;
619 bp++;
620
621 if (data & 0x40) *bp |= plane_mask;
622 bp++;
623 if (data & 0x20) *bp |= plane_mask;
624 bp++;
625 if (data & 0x10) *bp |= plane_mask;
626 bp++;
627 if (data & 0x08) *bp |= plane_mask;
628 bp++;
629 if (data & 0x04) *bp |= plane_mask;
630 bp++;
631 if (data & 0x02) *bp |= plane_mask;
632 bp++;
633 if (data & 0x01) *bp |= plane_mask;
634 bp++;
635 }
636 }
637 if (rightMask)
638 {
639 mask = 0x80;
640 data = *vp;
641 do
642 {
643 if (data & mask)
644 *bp |= plane_mask;
645 bp++;
646 mask >>= 1;
647 } while (mask & rightMask);
648 }
649 }
650}

Referenced by VGAtoVGA().

◆ vgaVLine()

BOOL vgaVLine ( INT  x,
INT  y,
INT  len,
UCHAR  c 
)

Definition at line 308 of file vgavideo.c.

309{
310 INT offset, i;
311
312 offset = xconv[x]+y80[y];
313
314#ifdef VGA_PERF
315 vgaSetBitMaskRegister ( maskbit[x] );
316#else
317 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
319#endif
320
321 for(i=y; i<y+len; i++)
322 {
325 offset += 80;
326 }
327
328 return TRUE;
329}

Referenced by DrvLineTo().

◆ vgaWriteScan()

void FASTCALL vgaWriteScan ( int  x,
int  y,
int  w,
void b 
)

Definition at line 655 of file vgavideo.c.

656{
657 unsigned char *bp;
658 unsigned char *vp;
659 //unsigned char init_mask;
660 volatile unsigned char dummy;
661 //int byte_per_line;
662 int i, j, off, init_off = x&7;
663
664 bp = b;
665 ASSIGNVP4(x, y, vp)
666 //ASSIGNMK4(x, y, init_mask)
667 //byte_per_line = SCREEN_X >> 3;
668
669 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); // write mode 2
671 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); // replace
673 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); // bit mask
674
675 for ( j = 0; j < 8; j++)
676 {
677 unsigned int mask = 0x80 >> j;
678 WRITE_PORT_UCHAR ( (PUCHAR)GRA_D, (unsigned char)mask );
679 i = j - init_off;
680 off = 0;
681 if (j < init_off)
682 i += 8, off++;
683 while (i < w)
684 {
685 /*
686 * In write mode 2, the incoming data is 4-bit and represents the
687 * value of entire bytes on each of the 4 memory planes. First, VGA
688 * performs a logical operation on these bytes and the value of the
689 * latch register, but in this case there is none. Then, only the
690 * bits that are set in the bit mask are used from the resulting
691 * bytes, and the other bits are taken from the latch register.
692 *
693 * The latch register always contains the value previously read from
694 * VGA memory, and therefore, we must first read from vp[off] to
695 * load the latch register, and then write bp[i] to vp[off], which
696 * will be converted to 4 bytes of VGA memory as described.
697 */
698 dummy = vp[off];
699 dummy = bp[i];
700 vp[off] = dummy;
701 i += 8;
702 off++;
703 }
704 }
705}

Referenced by VGAtoVGA().

Variable Documentation

◆ bit8

int bit8[640]

Definition at line 15 of file vgavideo.c.

Referenced by vgaGetPixel(), and vgaPreCalc().

◆ byteCounter

int byteCounter
static

Definition at line 22 of file vgavideo.c.

Referenced by DFB_BltFromVGA(), get_masks(), and vgaReadScan().

◆ endmasks

int endmasks[8]

Definition at line 17 of file vgavideo.c.

Referenced by VGADDIFillSolid(), vgaHLine(), and vgaPreCalc().

◆ leftMask

unsigned char leftMask
static

Definition at line 21 of file vgavideo.c.

Referenced by DFB_BltFromVGA(), get_masks(), and vgaReadScan().

◆ maskbit

◆ PreCalcReverseByte

UCHAR PreCalcReverseByte[256]

Definition at line 11 of file vgavideo.c.

Referenced by DIB_BltFromVGA(), and vgaPreCalc().

◆ rclEmpty

const RECTL rclEmpty = { 0, 0, 0, 0 }
static

Definition at line 331 of file vgavideo.c.

Referenced by VGADDI_IntersectRect(), and VGADDIIntersectRect().

◆ rightMask

unsigned char rightMask
static

Definition at line 23 of file vgavideo.c.

Referenced by DFB_BltFromVGA(), get_masks(), and vgaReadScan().

◆ startmasks

int startmasks[8]

Definition at line 16 of file vgavideo.c.

Referenced by VGADDIFillSolid(), vgaHLine(), and vgaPreCalc().

◆ UnpackPixel

ULONG UnpackPixel[256]
static

Definition at line 19 of file vgavideo.c.

Referenced by DIB_BltFromVGA(), and vgaPreCalc().

◆ vidmem

◆ xconv

◆ y80