xref: /reactos/drivers/base/bootvid/i386/pc/pc.h (revision 37b2c145)
1 
2 #pragma once
3 
4 extern ULONG_PTR VgaRegisterBase;
5 extern ULONG_PTR VgaBase;
6 extern USHORT AT_Initialization[];
7 extern USHORT VGA_640x480[];
8 extern UCHAR PixelMask[8];
9 
10 #define __inpb(Port) \
11     READ_PORT_UCHAR((PUCHAR)(VgaRegisterBase + (Port)))
12 
13 #define __inpw(Port) \
14     READ_PORT_USHORT((PUSHORT)(VgaRegisterBase + (Port)))
15 
16 #define __outpb(Port, Value) \
17     WRITE_PORT_UCHAR((PUCHAR)(VgaRegisterBase + (Port)), (UCHAR)(Value))
18 
19 #define __outpw(Port, Value) \
20     WRITE_PORT_USHORT((PUSHORT)(VgaRegisterBase + (Port)), (USHORT)(Value))
21 
22 FORCEINLINE
23 VOID
24 SetPixel(
25     _In_ ULONG Left,
26     _In_ ULONG Top,
27     _In_ UCHAR Color)
28 {
29     PUCHAR PixelPosition;
30 
31     /* Calculate the pixel position */
32     PixelPosition = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
33 
34     /* Select the bitmask register and write the mask */
35     __outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, (PixelMask[Left & 7] << 8) | IND_BIT_MASK);
36 
37     /* Read the current pixel value and add our color */
38     WRITE_REGISTER_UCHAR(PixelPosition, READ_REGISTER_UCHAR(PixelPosition) & Color);
39 }
40