ReactOS  0.4.15-dev-1206-g731eddf
vga.c File Reference
#include "precomp.h"
Include dependency graph for vga.c:

Go to the source code of this file.

Macros

#define SET_PIXELS(_PixelPtr, _PixelMask, _TextColor)
 

Functions

static VOID NTAPI ReadWriteMode (_In_ UCHAR Mode)
 
VOID PrepareForSetPixel (VOID)
 
VOID NTAPI DisplayCharacter (_In_ CHAR Character, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG TextColor, _In_ ULONG BackColor)
 
static VOID NTAPI SetPaletteEntryRGB (_In_ ULONG Id, _In_ RGBQUAD Rgb)
 
VOID NTAPI InitPaletteWithTable (_In_ PULONG Table, _In_ ULONG Count)
 
VOID NTAPI DoScroll (_In_ ULONG Scroll)
 
VOID NTAPI PreserveRow (_In_ ULONG CurrentTop, _In_ ULONG TopDelta, _In_ BOOLEAN Restore)
 
VOID NTAPI VidCleanUp (VOID)
 
VOID NTAPI VidScreenToBufferBlt (_Out_writes_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ ULONG Delta)
 
VOID NTAPI VidSolidColorFill (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR Color)
 

Variables

static UCHAR lMaskTable [8]
 
static UCHAR rMaskTable [8]
 
UCHAR PixelMask [8]
 
static ULONG lookup [16]
 
ULONG_PTR VgaRegisterBase = 0
 
ULONG_PTR VgaBase = 0
 

Macro Definition Documentation

◆ SET_PIXELS

#define SET_PIXELS (   _PixelPtr,
  _PixelMask,
  _TextColor 
)
Value:
do { \
/* Select the bitmask register and write the mask */ \
__outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, ((_PixelMask) << 8) | IND_BIT_MASK); \
/* Dummy read to load latch registers */ \
(VOID)READ_REGISTER_UCHAR((_PixelPtr)); \
/* Set the new color */ \
WRITE_REGISTER_UCHAR((_PixelPtr), (UCHAR)(_TextColor)); \
} while (0);
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
#define VGA_BASE_IO_PORT
Definition: vga.h:38
unsigned char UCHAR
Definition: xmlstorage.h:181
#define VOID
Definition: acefi.h:82
#define IND_BIT_MASK
Definition: vga.h:114
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)

Definition at line 93 of file vga.c.

Function Documentation

◆ DisplayCharacter()

VOID NTAPI DisplayCharacter ( _In_ CHAR  Character,
_In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  TextColor,
_In_ ULONG  BackColor 
)

Definition at line 105 of file vga.c.

111 {
112  PUCHAR FontChar, PixelPtr;
113  ULONG Height;
114  UCHAR Shift;
115 
117 
118  /* Calculate shift */
119  Shift = Left & 7;
120 
121  /* Get the font and pixel pointer */
122  FontChar = GetFontPtr(Character);
123  PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
124 
125  /* Loop all pixel rows */
126  for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
127  {
128  SET_PIXELS(PixelPtr, *FontChar >> Shift, TextColor);
129  PixelPtr += (SCREEN_WIDTH / 8);
130  FontChar += FONT_PTR_DELTA;
131  }
132 
133  /* Check if we need to update neighbor bytes */
134  if (Shift)
135  {
136  /* Calculate shift for 2nd byte */
137  Shift = 8 - Shift;
138 
139  /* Get the font and pixel pointer (2nd byte) */
140  FontChar = GetFontPtr(Character);
141  PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)) + 1);
142 
143  /* Loop all pixel rows */
144  for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
145  {
146  SET_PIXELS(PixelPtr, *FontChar << Shift, TextColor);
147  PixelPtr += (SCREEN_WIDTH / 8);
148  FontChar += FONT_PTR_DELTA;
149  }
150  }
151 
152  /* Check if the background color is transparent */
153  if (BackColor >= BV_COLOR_NONE)
154  {
155  /* We are done */
156  return;
157  }
158 
159  /* Calculate shift */
160  Shift = Left & 7;
161 
162  /* Get the font and pixel pointer */
163  FontChar = GetFontPtr(Character);
164  PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
165 
166  /* Loop all pixel rows */
167  for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
168  {
169  SET_PIXELS(PixelPtr, ~*FontChar >> Shift, BackColor);
170  PixelPtr += (SCREEN_WIDTH / 8);
171  FontChar += FONT_PTR_DELTA;
172  }
173 
174  /* Check if we need to update neighbor bytes */
175  if (Shift)
176  {
177  /* Calculate shift for 2nd byte */
178  Shift = 8 - Shift;
179 
180  /* Get the font and pixel pointer (2nd byte) */
181  FontChar = GetFontPtr(Character);
182  PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)) + 1);
183 
184  /* Loop all pixel rows */
185  for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
186  {
187  SET_PIXELS(PixelPtr, ~*FontChar << Shift, BackColor);
188  PixelPtr += (SCREEN_WIDTH / 8);
189  FontChar += FONT_PTR_DELTA;
190  }
191  }
192 }
unsigned char * PUCHAR
Definition: retypes.h:3
#define SCREEN_WIDTH
Definition: pc98video.c:27
#define FONT_PTR_DELTA
Definition: precomp.h:75
#define BOOTCHAR_HEIGHT
Definition: precomp.h:27
#define BV_COLOR_NONE
Definition: display.h:31
#define GetFontPtr(_Char)
Definition: precomp.h:74
ULONG_PTR VgaBase
Definition: vga.c:59
#define SET_PIXELS(_PixelPtr, _PixelMask, _TextColor)
Definition: vga.c:93
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID PrepareForSetPixel(VOID)
Definition: vga.c:81
_In_ ULONG Shift
Definition: rtlfuncs.h:2683
unsigned int ULONG
Definition: retypes.h:1
static LPHIST_ENTRY Top
Definition: history.c:53

◆ DoScroll()

VOID NTAPI DoScroll ( _In_ ULONG  Scroll)

Definition at line 226 of file vga.c.

228 {
229  ULONG Top, RowSize;
230  PUCHAR OldPosition, NewPosition;
231 
232  /* Clear the 4 planes */
234 
235  /* Set the bitmask to 0xFF for all 4 planes */
237 
238  /* Set Mode 1 */
239  ReadWriteMode(1);
240 
241  RowSize = (VidpScrollRegion[2] - VidpScrollRegion[0] + 1) / 8;
242 
243  /* Calculate the position in memory for the row */
244  OldPosition = (PUCHAR)(VgaBase + (VidpScrollRegion[1] + Scroll) * (SCREEN_WIDTH / 8) + VidpScrollRegion[0] / 8);
245  NewPosition = (PUCHAR)(VgaBase + VidpScrollRegion[1] * (SCREEN_WIDTH / 8) + VidpScrollRegion[0] / 8);
246 
247  /* Start loop */
248  for (Top = VidpScrollRegion[1]; Top <= VidpScrollRegion[3]; ++Top)
249  {
250 #if defined(_M_IX86) || defined(_M_AMD64)
251  __movsb(NewPosition, OldPosition, RowSize);
252 #else
253  ULONG i;
254 
255  /* Scroll the row */
256  for (i = 0; i < RowSize; ++i)
257  WRITE_REGISTER_UCHAR(NewPosition + i, READ_REGISTER_UCHAR(OldPosition + i));
258 #endif
259  OldPosition += (SCREEN_WIDTH / 8);
260  NewPosition += (SCREEN_WIDTH / 8);
261  }
262 }
unsigned char * PUCHAR
Definition: retypes.h:3
static VOID NTAPI ReadWriteMode(_In_ UCHAR Mode)
Definition: vga.c:65
#define SCREEN_WIDTH
Definition: pc98video.c:27
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
ULONG VidpScrollRegion[4]
Definition: common.c:10
#define VGA_BASE_IO_PORT
Definition: vga.h:38
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
PPC_QUAL void __movsb(unsigned char *Destination, const unsigned char *Source, unsigned long Count)
Definition: intrin_ppc.h:323
ULONG_PTR VgaBase
Definition: vga.c:59
#define SEQ_ADDRESS_PORT
Definition: vga.h:69
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
unsigned int ULONG
Definition: retypes.h:1
#define __outpw(Port, Value)
Definition: pc.h:19
static LPHIST_ENTRY Top
Definition: history.c:53
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)

◆ InitPaletteWithTable()

VOID NTAPI InitPaletteWithTable ( _In_ PULONG  Table,
_In_ ULONG  Count 
)

Definition at line 211 of file vga.c.

214 {
215  ULONG i;
216  PULONG Entry = Table;
217 
218  for (i = 0; i < Count; i++, Entry++)
219  {
221  }
222 }
static VOID NTAPI SetPaletteEntryRGB(_In_ ULONG Id, _In_ RGBQUAD Rgb)
Definition: vga.c:196
ASMGENDATA Table[]
Definition: genincdata.c:61
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1223
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
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82

◆ PrepareForSetPixel()

VOID PrepareForSetPixel ( VOID  )

Definition at line 81 of file vga.c.

82 {
83  /* Switch to mode 10 */
84  ReadWriteMode(10);
85 
86  /* Clear the 4 planes (we're already in unchained mode here) */
88 
89  /* Select the color don't care register */
91 }
static VOID NTAPI ReadWriteMode(_In_ UCHAR Mode)
Definition: vga.c:65
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
#define VGA_BASE_IO_PORT
Definition: vga.h:38
#define SEQ_ADDRESS_PORT
Definition: vga.h:69
#define __outpw(Port, Value)
Definition: pc.h:19

Referenced by DisplayCharacter(), and VidSolidColorFill().

◆ PreserveRow()

VOID NTAPI PreserveRow ( _In_ ULONG  CurrentTop,
_In_ ULONG  TopDelta,
_In_ BOOLEAN  Restore 
)

Definition at line 266 of file vga.c.

270 {
271  PUCHAR Position1, Position2;
272  ULONG Count;
273 
274  /* Clear the 4 planes */
276 
277  /* Set the bitmask to 0xFF for all 4 planes */
279 
280  /* Set Mode 1 */
281  ReadWriteMode(1);
282 
283  /* Calculate the position in memory for the row */
284  if (Restore)
285  {
286  /* Restore the row by copying back the contents saved off-screen */
287  Position1 = (PUCHAR)(VgaBase + CurrentTop * (SCREEN_WIDTH / 8));
288  Position2 = (PUCHAR)(VgaBase + SCREEN_HEIGHT * (SCREEN_WIDTH / 8));
289  }
290  else
291  {
292  /* Preserve the row by saving its contents off-screen */
293  Position1 = (PUCHAR)(VgaBase + SCREEN_HEIGHT * (SCREEN_WIDTH / 8));
294  Position2 = (PUCHAR)(VgaBase + CurrentTop * (SCREEN_WIDTH / 8));
295  }
296 
297  /* Set the count and loop every pixel */
298  Count = TopDelta * (SCREEN_WIDTH / 8);
299 #if defined(_M_IX86) || defined(_M_AMD64)
300  __movsb(Position1, Position2, Count);
301 #else
302  while (Count--)
303  {
304  /* Write the data back on the other position */
305  WRITE_REGISTER_UCHAR(Position1, READ_REGISTER_UCHAR(Position2));
306 
307  /* Increase both positions */
308  Position1++;
309  Position2++;
310  }
311 #endif
312 }
unsigned char * PUCHAR
Definition: retypes.h:3
static VOID NTAPI ReadWriteMode(_In_ UCHAR Mode)
Definition: vga.c:65
#define SCREEN_WIDTH
Definition: pc98video.c:27
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1223
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
#define VGA_BASE_IO_PORT
Definition: vga.h:38
PPC_QUAL void __movsb(unsigned char *Destination, const unsigned char *Source, unsigned long Count)
Definition: intrin_ppc.h:323
#define SCREEN_HEIGHT
Definition: pc98video.c:28
ULONG_PTR VgaBase
Definition: vga.c:59
#define SEQ_ADDRESS_PORT
Definition: vga.h:69
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
unsigned int ULONG
Definition: retypes.h:1
#define __outpw(Port, Value)
Definition: pc.h:19
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)

◆ ReadWriteMode()

static VOID NTAPI ReadWriteMode ( _In_ UCHAR  Mode)
static

Definition at line 65 of file vga.c.

67 {
68  UCHAR Value;
69 
70  /* Switch to graphics mode register */
72 
73  /* Get the current register value, minus the current mode */
75 
76  /* Set the new mode */
78 }
_In_ ULONG Mode
Definition: hubbusif.h:303
#define GRAPH_DATA_PORT
Definition: vga.h:82
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
IN UCHAR Value
Definition: halp.h:394
#define VGA_BASE_IO_PORT
Definition: vga.h:38
#define __outpb(Port, Value)
Definition: pc.h:16
#define IND_GRAPH_MODE
Definition: vga.h:112
unsigned char UCHAR
Definition: xmlstorage.h:181
#define __inpb(Port)
Definition: pc.h:10

Referenced by DoScroll(), PitReadData(), PitWriteCommand(), PitWriteData(), PrepareForSetPixel(), PreserveRow(), and VidScreenToBufferBlt().

◆ SetPaletteEntryRGB()

static VOID NTAPI SetPaletteEntryRGB ( _In_ ULONG  Id,
_In_ RGBQUAD  Rgb 
)
static

Definition at line 196 of file vga.c.

199 {
200  /* Set the palette index */
202 
203  /* Set RGB colors */
207 }
#define GetRValue(quad)
Definition: precomp.h:64
DWORD Id
#define VGA_BASE_IO_PORT
Definition: vga.h:38
#define __outpb(Port, Value)
Definition: pc.h:16
#define GetBValue(quad)
Definition: precomp.h:66
#define DAC_DATA_REG_PORT
Definition: vga.h:77
#define DAC_ADDRESS_WRITE_PORT
Definition: vga.h:76
#define GetGValue(quad)
Definition: precomp.h:65
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by InitPaletteWithTable().

◆ VidCleanUp()

VOID NTAPI VidCleanUp ( VOID  )

Definition at line 321 of file vga.c.

322 {
323  /* Select bit mask register and clear it */
326 }
#define GRAPH_DATA_PORT
Definition: vga.h:82
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
#define VGA_BASE_IO_PORT
Definition: vga.h:38
#define __outpb(Port, Value)
Definition: pc.h:16
#define IND_BIT_MASK
Definition: vga.h:114
#define BIT_MASK_DEFAULT
Definition: vga.h:167

◆ VidScreenToBufferBlt()

VOID NTAPI VidScreenToBufferBlt ( _Out_writes_bytes_(Delta *Height) PUCHAR  Buffer,
_In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_ ULONG  Delta 
)

Definition at line 333 of file vga.c.

340 {
341  ULONG Plane;
342  ULONG XDistance;
343  ULONG LeftDelta, RightDelta;
344  ULONG PixelOffset;
345  PUCHAR PixelPosition;
346  PUCHAR k, i;
347  PULONG m;
348  UCHAR Value, Value2;
349  UCHAR a;
350  ULONG b;
351  ULONG x, y;
352 
353  /* Calculate total distance to copy on X */
354  XDistance = Left + Width - 1;
355 
356  /* Calculate the 8-byte left and right deltas */
357  LeftDelta = Left & 7;
358  RightDelta = 8 - LeftDelta;
359 
360  /* Clear the destination buffer */
361  RtlZeroMemory(Buffer, Delta * Height);
362 
363  /* Calculate the pixel offset and convert the X distance into byte form */
364  PixelOffset = Top * (SCREEN_WIDTH / 8) + (Left >> 3);
365  XDistance >>= 3;
366 
367  /* Loop the 4 planes */
368  for (Plane = 0; Plane < 4; ++Plane)
369  {
370  /* Set the current pixel position and reset buffer loop variable */
371  PixelPosition = (PUCHAR)(VgaBase + PixelOffset);
372  i = Buffer;
373 
374  /* Set Mode 0 */
375  ReadWriteMode(0);
376 
377  /* Set the current plane */
379 
380  /* Start the outer Y height loop */
381  for (y = Height; y > 0; --y)
382  {
383  /* Read the current value */
384  m = (PULONG)i;
385  Value = READ_REGISTER_UCHAR(PixelPosition);
386 
387  /* Set Pixel Position loop variable */
388  k = PixelPosition + 1;
389 
390  /* Check if we're still within bounds */
391  if (Left <= XDistance)
392  {
393  /* Start the X inner loop */
394  for (x = (XDistance - Left) + 1; x > 0; --x)
395  {
396  /* Read the current value */
397  Value2 = READ_REGISTER_UCHAR(k);
398 
399  /* Increase pixel position */
400  k++;
401 
402  /* Do the blt */
403  a = Value2 >> (UCHAR)RightDelta;
404  a |= Value << (UCHAR)LeftDelta;
405  b = lookup[a & 0xF];
406  a >>= 4;
407  b <<= 16;
408  b |= lookup[a];
409 
410  /* Save new value to buffer */
411  *m |= (b << Plane);
412 
413  /* Move to next destination location */
414  m++;
415 
416  /* Write new value */
417  Value = Value2;
418  }
419  }
420 
421  /* Update pixel position */
422  PixelPosition += (SCREEN_WIDTH / 8);
423  i += Delta;
424  }
425  }
426 }
unsigned char * PUCHAR
Definition: retypes.h:3
static ULONG lookup[16]
Definition: vga.c:38
static VOID NTAPI ReadWriteMode(_In_ UCHAR Mode)
Definition: vga.c:65
#define SCREEN_WIDTH
Definition: pc98video.c:27
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define IND_READ_MAP
Definition: vga.h:111
const GLfloat * m
Definition: glext.h:10848
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
IN UCHAR Value
Definition: halp.h:394
#define VGA_BASE_IO_PORT
Definition: vga.h:38
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
#define a
Definition: ke_i.h:78
Definition: bufpool.h:45
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
ULONG_PTR VgaBase
Definition: vga.c:59
unsigned char UCHAR
Definition: xmlstorage.h:181
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
static ULONG Delta
Definition: xboxvideo.c:33
unsigned int * PULONG
Definition: retypes.h:1
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define __outpw(Port, Value)
Definition: pc.h:19
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
static LPHIST_ENTRY Top
Definition: history.c:53
int k
Definition: mpi.c:3369

◆ VidSolidColorFill()

VOID NTAPI VidSolidColorFill ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Right,
_In_ ULONG  Bottom,
_In_ UCHAR  Color 
)

Definition at line 433 of file vga.c.

439 {
440  ULONG rMask, lMask;
441  ULONG LeftOffset, RightOffset, Distance;
442  PUCHAR Offset;
443  ULONG i, j;
444 
445  /* Get the left and right masks, shifts, and delta */
446  LeftOffset = Left >> 3;
447  lMask = (lMaskTable[Left & 0x7] << 8) | IND_BIT_MASK;
448  RightOffset = Right >> 3;
449  rMask = (rMaskTable[Right & 0x7] << 8) | IND_BIT_MASK;
450  Distance = RightOffset - LeftOffset;
451 
452  /* If there is no distance, then combine the right and left masks */
453  if (!Distance) lMask &= rMask;
454 
456 
457  /* Calculate pixel position for the read */
458  Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + LeftOffset);
459 
460  /* Select the bitmask register and write the mask */
462 
463  /* Check if the top coord is below the bottom one */
464  if (Top <= Bottom)
465  {
466  /* Start looping each line */
467  for (i = (Bottom - Top) + 1; i > 0; --i)
468  {
469  /* Read the previous value and add our color */
471 
472  /* Move to the next line */
473  Offset += (SCREEN_WIDTH / 8);
474  }
475  }
476 
477  /* Check if we have a delta */
478  if (Distance > 0)
479  {
480  /* Calculate new pixel position */
481  Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + RightOffset);
482  Distance--;
483 
484  /* Select the bitmask register and write the mask */
486 
487  /* Check if the top coord is below the bottom one */
488  if (Top <= Bottom)
489  {
490  /* Start looping each line */
491  for (i = (Bottom - Top) + 1; i > 0; --i)
492  {
493  /* Read the previous value and add our color */
495 
496  /* Move to the next line */
497  Offset += (SCREEN_WIDTH / 8);
498  }
499  }
500 
501  /* Check if we still have a delta */
502  if (Distance > 0)
503  {
504  /* Calculate new pixel position */
505  Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + LeftOffset + 1);
506 
507  /* Set the bitmask to 0xFF for all 4 planes */
509 
510  /* Check if the top coord is below the bottom one */
511  if (Top <= Bottom)
512  {
513  /* Start looping each line */
514  for (i = (Bottom - Top) + 1; i > 0; --i)
515  {
516  /* Loop the shift delta */
517  for (j = Distance; j > 0; Offset++, --j)
518  {
519  /* Write the color */
521  }
522 
523  /* Update position in memory */
524  Offset += ((SCREEN_WIDTH / 8) - Distance);
525  }
526  }
527  }
528  }
529 }
unsigned char * PUCHAR
Definition: retypes.h:3
#define SCREEN_WIDTH
Definition: pc98video.c:27
#define GRAPH_ADDRESS_PORT
Definition: vga.h:81
#define VGA_BASE_IO_PORT
Definition: vga.h:38
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static UCHAR lMaskTable[8]
Definition: vga.c:5
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
ULONG_PTR VgaBase
Definition: vga.c:59
static UCHAR rMaskTable[8]
Definition: vga.c:16
#define IND_BIT_MASK
Definition: vga.h:114
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
static LPHIST_ENTRY Bottom
Definition: history.c:54
unsigned short USHORT
Definition: pedump.c:61
VOID PrepareForSetPixel(VOID)
Definition: vga.c:81
unsigned int ULONG
Definition: retypes.h:1
#define __outpw(Port, Value)
Definition: pc.h:19
static LPHIST_ENTRY Top
Definition: history.c:53
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)

Variable Documentation

◆ lMaskTable

UCHAR lMaskTable[8]
static
Initial value:
=
{
(1 << 8) - (1 << 0),
(1 << 7) - (1 << 0),
(1 << 6) - (1 << 0),
(1 << 5) - (1 << 0),
(1 << 4) - (1 << 0),
(1 << 3) - (1 << 0),
(1 << 2) - (1 << 0),
(1 << 1) - (1 << 0)
}

Definition at line 5 of file vga.c.

Referenced by VidSolidColorFill().

◆ lookup

◆ PixelMask

UCHAR PixelMask[8]
Initial value:
=
{
(1 << 7),
(1 << 6),
(1 << 5),
(1 << 4),
(1 << 3),
(1 << 2),
(1 << 1),
(1 << 0),
}

Definition at line 27 of file vga.c.

Referenced by ConsoleEfiGopIsPixelFormatSupported(), DisplayCharacter(), and SetPixel().

◆ rMaskTable

UCHAR rMaskTable[8]
static
Initial value:
=
{
(1 << 7),
(1 << 7) + (1 << 6),
(1 << 7) + (1 << 6) + (1 << 5),
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4),
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3),
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2),
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1),
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1) + (1 << 0),
}

Definition at line 16 of file vga.c.

Referenced by VidSolidColorFill().

◆ VgaBase

◆ VgaRegisterBase

ULONG_PTR VgaRegisterBase = 0

Definition at line 58 of file vga.c.

Referenced by VgaInterpretCmdStream(), and VidInitialize().