ReactOS 0.4.16-dev-2104-gb84fa49
pcvideo.c File Reference
#include <freeldr.h>
#include <suppress.h>
#include <debug.h>
#include <pshpack2.h>
#include <poppack.h>
Include dependency graph for pcvideo.c:

Go to the source code of this file.

Classes

struct  SVGA_MODE_INFORMATION
 

Macros

#define VIDEOPORT_PALETTE_READ   0x03C7
 
#define VIDEOPORT_PALETTE_WRITE   0x03C8
 
#define VIDEOPORT_PALETTE_DATA   0x03C9
 
#define VIDEOPORT_VERTICAL_RETRACE   0x03DA
 
#define VIDEOVGA_MEM_ADDRESS   0xA0000
 
#define VIDEOTEXT_MEM_ADDRESS   0xB8000
 
#define VIDEOTEXT_MEM_SIZE   0x8000
 
#define VIDEOCARD_CGA_OR_OTHER   0
 
#define VIDEOCARD_EGA   1
 
#define VIDEOCARD_VGA   2
 
#define VIDEOMODE_NORMAL_TEXT   0
 
#define VIDEOMODE_EXTENDED_TEXT   1
 
#define VIDEOMODE_80X28   0x501C
 
#define VIDEOMODE_80X30   0x501E
 
#define VIDEOMODE_80X34   0x5022
 
#define VIDEOMODE_80X43   0x502B
 
#define VIDEOMODE_80X60   0x503C
 
#define VIDEOMODE_132X25   0x8419
 
#define VIDEOMODE_132X43   0x842B
 
#define VIDEOMODE_132X50   0x8432
 
#define VIDEOMODE_132X60   0x843C
 
#define VERTRES_200_SCANLINES   0x00
 
#define VERTRES_350_SCANLINES   0x01
 
#define VERTRES_400_SCANLINES   0x02
 
#define TRACE_printf(Format, ...)
 

Typedefs

typedef struct SVGA_MODE_INFORMATIONPSVGA_MODE_INFORMATION
 

Enumerations

enum  {
  INT1FhFont = 0x00 , INT43hFont = 0x01 , ROM_8x14CharacterFont = 0x02 , ROM_8x8DoubleDotFontLo = 0x03 ,
  ROM_8x8DoubleDotFontHi = 0x04 , ROM_AlphaAlternate = 0x05 , ROM_8x16Font = 0x06 , ROM_Alternate9x16Font = 0x07 ,
  UltraVision_8x20Font = 0x11 , UltraVision_8x10Font = 0x12
}
 

Functions

 DBG_DEFAULT_CHANNEL (UI)
 
 C_ASSERT (sizeof(SVGA_MODE_INFORMATION)==256)
 
static ULONG PcVideoDetectVideoCard (VOID)
 
static BOOLEAN PcVideoVesaGetSVGAModeInformation (_In_ USHORT Mode, _Out_ PSVGA_MODE_INFORMATION ModeInformation)
 
static BOOLEAN PcVideoVesaGetCurrentSVGAMode (_Out_ PUSHORT Mode)
 
static BOOLEAN PcVideoGetBiosMode (_Out_ PUSHORT Mode)
 
static VOID PcVideoGetDisplayMode (VOID)
 
static BOOLEAN PcVideoSetBiosVesaMode (USHORT Mode)
 
static VOID PcVideoSetBiosMode (UCHAR VideoMode)
 
static VOID PcVideoSetFont8x8 (VOID)
 
static VOID PcVideoSetFont8x14 (VOID)
 
static VOID PcVideoSelectAlternatePrintScreen (VOID)
 
static VOID PcVideoDisableCursorEmulation (VOID)
 
static VOID PcVideoDefineCursor (UCHAR StartScanLine, UCHAR EndScanLine)
 
static VOID PcVideoSetVerticalResolution (UCHAR VerticalResolutionMode)
 
static VOID PcVideoSet480ScanLines (VOID)
 
static VOID PcVideoSetDisplayEnd (VOID)
 
static BOOLEAN PcVideoSetMode80x25 (VOID)
 
static BOOLEAN PcVideoSetMode80x50_80x43 (VOID)
 
static BOOLEAN PcVideoSetMode80x28 (VOID)
 
static BOOLEAN PcVideoSetMode80x30 (VOID)
 
static BOOLEAN PcVideoSetMode80x34 (VOID)
 
static BOOLEAN PcVideoSetMode80x43 (VOID)
 
static BOOLEAN PcVideoSetMode80x60 (VOID)
 
static BOOLEAN PcVideoSetMode (USHORT NewMode)
 
static VOID PcVideoSetBlinkBit (BOOLEAN Enable)
 
static VOID PcVideoSetMemoryBank (USHORT BankNumber)
 
VOID PcVideoInit (VOID)
 
VIDEODISPLAYMODE PcVideoSetDisplayMode (PCSTR DisplayModeName, BOOLEAN Init)
 
VOID PcVideoGetDisplaySize (PULONG Width, PULONG Height, PULONG Depth)
 
ULONG PcVideoGetBufferSize (VOID)
 
VOID PcVideoGetFontsFromFirmware (PULONG RomFontPointers)
 
VOID PcVideoSetTextCursorPosition (UCHAR X, UCHAR Y)
 
VOID PcVideoHideShowTextCursor (BOOLEAN Show)
 
VOID PcVideoCopyOffScreenBufferToVRAM (PVOID Buffer)
 
VOID PcVideoClearScreen (UCHAR Attr)
 
VOID PcVideoPutChar (int Ch, UCHAR Attr, unsigned X, unsigned Y)
 
BOOLEAN PcVideoIsPaletteFixed (VOID)
 
VOID PcVideoSetPaletteColor (UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
 
VOID PcVideoGetPaletteColor (UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
 
VOID PcVideoSync (VOID)
 
VOID PcVideoPrepareForReactOS (VOID)
 

Variables

UCHAR MachDefaultTextColor = COLOR_GRAY
 
static ULONG VideoCard = VIDEOCARD_CGA_OR_OTHER
 
static USHORT BiosVideoMode = VIDEOMODE_NORMAL_TEXT
 
static ULONG ScreenWidth = 80
 
static ULONG ScreenHeight = 25
 
static ULONG BytesPerScanLine = 160
 
static VIDEODISPLAYMODE DisplayMode = VideoTextMode
 
static BOOLEAN VesaVideoMode = FALSE
 
static SVGA_MODE_INFORMATION VesaVideoModeInformation
 
static ULONG CurrentMemoryBank = 0
 

Macro Definition Documentation

◆ TRACE_printf

#define TRACE_printf (   Format,
  ... 
)
Value:
do { \
TRACE(Format, ##__VA_ARGS__); \
printf(Format, ##__VA_ARGS__); \
} while (0)

Definition at line 1038 of file pcvideo.c.

◆ VERTRES_200_SCANLINES

#define VERTRES_200_SCANLINES   0x00

Definition at line 50 of file pcvideo.c.

◆ VERTRES_350_SCANLINES

#define VERTRES_350_SCANLINES   0x01

Definition at line 51 of file pcvideo.c.

◆ VERTRES_400_SCANLINES

#define VERTRES_400_SCANLINES   0x02

Definition at line 52 of file pcvideo.c.

◆ VIDEOCARD_CGA_OR_OTHER

#define VIDEOCARD_CGA_OR_OTHER   0

Definition at line 34 of file pcvideo.c.

◆ VIDEOCARD_EGA

#define VIDEOCARD_EGA   1

Definition at line 35 of file pcvideo.c.

◆ VIDEOCARD_VGA

#define VIDEOCARD_VGA   2

Definition at line 36 of file pcvideo.c.

◆ VIDEOMODE_132X25

#define VIDEOMODE_132X25   0x8419

Definition at line 45 of file pcvideo.c.

◆ VIDEOMODE_132X43

#define VIDEOMODE_132X43   0x842B

Definition at line 46 of file pcvideo.c.

◆ VIDEOMODE_132X50

#define VIDEOMODE_132X50   0x8432

Definition at line 47 of file pcvideo.c.

◆ VIDEOMODE_132X60

#define VIDEOMODE_132X60   0x843C

Definition at line 48 of file pcvideo.c.

◆ VIDEOMODE_80X28

#define VIDEOMODE_80X28   0x501C

Definition at line 40 of file pcvideo.c.

◆ VIDEOMODE_80X30

#define VIDEOMODE_80X30   0x501E

Definition at line 41 of file pcvideo.c.

◆ VIDEOMODE_80X34

#define VIDEOMODE_80X34   0x5022

Definition at line 42 of file pcvideo.c.

◆ VIDEOMODE_80X43

#define VIDEOMODE_80X43   0x502B

Definition at line 43 of file pcvideo.c.

◆ VIDEOMODE_80X60

#define VIDEOMODE_80X60   0x503C

Definition at line 44 of file pcvideo.c.

◆ VIDEOMODE_EXTENDED_TEXT

#define VIDEOMODE_EXTENDED_TEXT   1

Definition at line 39 of file pcvideo.c.

◆ VIDEOMODE_NORMAL_TEXT

#define VIDEOMODE_NORMAL_TEXT   0

Definition at line 38 of file pcvideo.c.

◆ VIDEOPORT_PALETTE_DATA

#define VIDEOPORT_PALETTE_DATA   0x03C9

Definition at line 27 of file pcvideo.c.

◆ VIDEOPORT_PALETTE_READ

#define VIDEOPORT_PALETTE_READ   0x03C7

Definition at line 25 of file pcvideo.c.

◆ VIDEOPORT_PALETTE_WRITE

#define VIDEOPORT_PALETTE_WRITE   0x03C8

Definition at line 26 of file pcvideo.c.

◆ VIDEOPORT_VERTICAL_RETRACE

#define VIDEOPORT_VERTICAL_RETRACE   0x03DA

Definition at line 28 of file pcvideo.c.

◆ VIDEOTEXT_MEM_ADDRESS

#define VIDEOTEXT_MEM_ADDRESS   0xB8000

Definition at line 31 of file pcvideo.c.

◆ VIDEOTEXT_MEM_SIZE

#define VIDEOTEXT_MEM_SIZE   0x8000

Definition at line 32 of file pcvideo.c.

◆ VIDEOVGA_MEM_ADDRESS

#define VIDEOVGA_MEM_ADDRESS   0xA0000

Definition at line 30 of file pcvideo.c.

Typedef Documentation

◆ PSVGA_MODE_INFORMATION

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
INT1FhFont 
INT43hFont 
ROM_8x14CharacterFont 
ROM_8x8DoubleDotFontLo 
ROM_8x8DoubleDotFontHi 
ROM_AlphaAlternate 
ROM_8x16Font 
ROM_Alternate9x16Font 
UltraVision_8x20Font 
UltraVision_8x10Font 

Definition at line 124 of file pcvideo.c.

125{
126 INT1FhFont = 0x00,
127 INT43hFont = 0x01,
131 ROM_AlphaAlternate = 0x05,
132 ROM_8x16Font = 0x06,
136};
@ INT43hFont
Definition: pcvideo.c:127
@ UltraVision_8x20Font
Definition: pcvideo.c:134
@ ROM_AlphaAlternate
Definition: pcvideo.c:131
@ ROM_8x16Font
Definition: pcvideo.c:132
@ ROM_8x14CharacterFont
Definition: pcvideo.c:128
@ INT1FhFont
Definition: pcvideo.c:126
@ UltraVision_8x10Font
Definition: pcvideo.c:135
@ ROM_8x8DoubleDotFontHi
Definition: pcvideo.c:130
@ ROM_8x8DoubleDotFontLo
Definition: pcvideo.c:129
@ ROM_Alternate9x16Font
Definition: pcvideo.c:133

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(SVGA_MODE_INFORMATION = =256)

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UI  )

◆ PcVideoClearScreen()

VOID PcVideoClearScreen ( UCHAR  Attr)

Definition at line 1236 of file pcvideo.c.

1237{
1238 USHORT AttrChar;
1239 USHORT *BufPtr;
1240
1241 AttrChar = ((USHORT)Attr << 8) | ' ';
1242 for (BufPtr = (USHORT*)VIDEOTEXT_MEM_ADDRESS;
1244 BufPtr++)
1245 {
1247 *BufPtr = AttrChar;
1248 }
1249}
#define VIDEOTEXT_MEM_ADDRESS
Definition: pcvideo.c:31
#define VIDEOTEXT_MEM_SIZE
Definition: pcvideo.c:32
unsigned short USHORT
Definition: pedump.c:61
#define __WARNING_DEREF_NULL_PTR
Definition: suppress.h:32
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28

Referenced by MachInit().

◆ PcVideoCopyOffScreenBufferToVRAM()

VOID PcVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 1195 of file pcvideo.c.

1196{
1197 USHORT BanksToCopy;
1198 ULONG BytesInLastBank;
1199 USHORT CurrentBank;
1200 ULONG BankSize;
1201
1202 /* PcVideoWaitForVerticalRetrace(); */
1203
1204 /* Text mode (BIOS or VESA) */
1206 {
1208 }
1209 /* VESA graphics mode */
1211 {
1215
1216 /* Copy all the banks but the last one because
1217 * it is probably a partial bank */
1218 for (CurrentBank = 0; CurrentBank < BanksToCopy; CurrentBank++)
1219 {
1220 PcVideoSetMemoryBank(CurrentBank);
1221 RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, (char*)Buffer + CurrentBank * BankSize, BankSize);
1222 }
1223
1224 /* Copy the remaining bytes into the last bank */
1225 PcVideoSetMemoryBank(CurrentBank);
1226 RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, (char*)Buffer + CurrentBank * BankSize, BytesInLastBank);
1227 }
1228 /* BIOS graphics mode */
1229 else
1230 {
1232 }
1233}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
@ VideoTextMode
Definition: machine.h:35
@ VideoGraphicsMode
Definition: machine.h:36
Definition: bufpool.h:45
static SVGA_MODE_INFORMATION VesaVideoModeInformation
Definition: pcvideo.c:121
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:119
#define VIDEOVGA_MEM_ADDRESS
Definition: pcvideo.c:30
static BOOLEAN VesaVideoMode
Definition: pcvideo.c:120
static VOID PcVideoSetMemoryBank(USHORT BankNumber)
Definition: pcvideo.c:984
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:1121
USHORT HeightInPixels
Definition: pcvideo.c:68
USHORT BytesPerScanLine
Definition: pcvideo.c:65
USHORT WindowGranularity
Definition: pcvideo.c:60
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59

Referenced by MachInit().

◆ PcVideoDefineCursor()

static VOID PcVideoDefineCursor ( UCHAR  StartScanLine,
UCHAR  EndScanLine 
)
static

Definition at line 638 of file pcvideo.c.

639{
640 REGS Regs;
641
642 /* Int 10h AH=01h
643 * VIDEO - SET TEXT-MODE CURSOR SHAPE
644 *
645 * AH = 01h
646 * CH = cursor start and options
647 * CL = bottom scan line containing cursor (bits 0-4)
648 * Return:
649 * Nothing
650 *
651 * Specify the starting and ending scan lines to be occupied
652 * by the hardware cursor in text modes.
653 *
654 * AMI 386 BIOS and AST Premier 386 BIOS will lock up the
655 * system if AL is not equal to the current video mode.
656 *
657 * Bitfields for cursor start and options:
658 *
659 * Bit(s) Description
660 * 7 should be zero
661 * 6,5 cursor blink
662 * (00=normal, 01=invisible, 10=erratic, 11=slow).
663 * (00=normal, other=invisible on EGA/VGA)
664 * 4-0 topmost scan line containing cursor
665 */
666 Regs.b.ah = 0x01;
667 Regs.b.al = 0x03;
668 Regs.b.ch = StartScanLine;
669 Regs.b.cl = EndScanLine;
670 Int386(0x10, &Regs, &Regs);
671}
int __cdecl Int386(int ivec, REGS *in, REGS *out)
unsigned char ch
Definition: pcbios.h:140
unsigned char cl
Definition: pcbios.h:139
unsigned char al
Definition: pcbios.h:133
unsigned char ah
Definition: pcbios.h:134
Definition: pcbios.h:161
BYTEREGS b
Definition: pcbios.h:165

Referenced by PcVideoHideShowTextCursor(), PcVideoSetMode80x28(), PcVideoSetMode80x34(), PcVideoSetMode80x43(), PcVideoSetMode80x50_80x43(), and PcVideoSetMode80x60().

◆ PcVideoDetectVideoCard()

static ULONG PcVideoDetectVideoCard ( VOID  )
static

Definition at line 139 of file pcvideo.c.

140{
141 REGS Regs;
142
143 /* Int 10h AH=12h BL=10h
144 * VIDEO - ALTERNATE FUNCTION SELECT (PS,EGA,VGA,MCGA) - GET EGA INFO
145 *
146 * AH = 12h
147 * BL = 10h
148 * Return:
149 * BH = video state
150 * 00h color mode in effect (I/O port 3Dxh)
151 * 01h mono mode in effect (I/O port 3Bxh)
152 * BL = installed memory (00h = 64K, 01h = 128K, 02h = 192K, 03h = 256K)
153 * CH = feature connector bits
154 * CL = switch settings
155 * AH destroyed (at least by Tseng ET4000 BIOS v8.00n)
156 *
157 * Installation check;EGA
158 */
159 Regs.b.ah = 0x12;
160 Regs.b.bl = 0x10;
161 Int386(0x10, &Regs, &Regs);
162
163 /* If BL is still equal to 0x10 then there is no EGA/VGA present */
164 if (Regs.b.bl == 0x10)
166
167 /* Int 10h AX=1A00h
168 * VIDEO - GET DISPLAY COMBINATION CODE (PS,VGA/MCGA)
169 *
170 * AX = 1A00h
171 * Return:
172 * AL = 1Ah if function was supported
173 * BL = active display code
174 * BH = alternate display code
175 *
176 * This function is commonly used to check for the presence of a VGA.
177 *
178 * Installation check;VGA
179 *
180 * Values for display combination code:
181 * 00h no display
182 * 01h monochrome adapter w/ monochrome display
183 * 02h CGA w/ color display
184 * 03h reserved
185 * 04h EGA w/ color display
186 * 05h EGA w/ monochrome display
187 * 06h PGA w/ color display
188 * 07h VGA w/ monochrome analog display
189 * 08h VGA w/ color analog display
190 * 09h reserved
191 * 0Ah MCGA w/ digital color display
192 * 0Bh MCGA w/ monochrome analog display
193 * 0Ch MCGA w/ color analog display
194 * FFh unknown display type
195 */
196 Regs.w.ax = 0x1A00;
197 Int386(0x10, &Regs, &Regs);
198
199 if (Regs.b.al == 0x1a)
200 return VIDEOCARD_VGA;
201 else
202 return VIDEOCARD_EGA;
203}
#define VIDEOCARD_VGA
Definition: pcvideo.c:36
#define VIDEOCARD_CGA_OR_OTHER
Definition: pcvideo.c:34
#define VIDEOCARD_EGA
Definition: pcvideo.c:35
unsigned char bl
Definition: pcbios.h:136
unsigned short ax
Definition: pcbios.h:113
WORDREGS w
Definition: pcbios.h:164

Referenced by PcVideoInit().

◆ PcVideoDisableCursorEmulation()

static VOID PcVideoDisableCursorEmulation ( VOID  )
static

Definition at line 613 of file pcvideo.c.

614{
615 REGS Regs;
616
617 /* Int 10h AH=12h BL=34h
618 * VIDEO - ALTERNATE FUNCTION SELECT (VGA) - CURSOR EMULATION
619 *
620 * AH = 12h
621 * BL = 34h
622 * AL = new state
623 * 00h enable alphanumeric cursor emulation
624 * 01h disable alphanumeric cursor emulation
625 * Return:
626 * AL = 12h if function supported
627 *
628 * Specify whether the BIOS should automatically remap cursor start/end
629 * according to the current character height in text modes.
630 */
631 Regs.b.ah = 0x12;
632 Regs.b.bl = 0x34;
633 Regs.b.al = 0x01;
634 Int386(0x10, &Regs, &Regs);
635}

Referenced by PcVideoSetMode80x43(), PcVideoSetMode80x50_80x43(), and PcVideoSetMode80x60().

◆ PcVideoGetBiosMode()

static BOOLEAN PcVideoGetBiosMode ( _Out_ PUSHORT  Mode)
static

Definition at line 333 of file pcvideo.c.

335{
336 REGS Regs;
337
338 /* Int 10h AH=0Fh
339 * VIDEO - GET CURRENT VIDEO MODE
340 *
341 * AH = 0Fh
342 * Return:
343 * AH = number of character columns
344 * AL = display mode (see #00010 at AH=00h)
345 * BH = active page (see AH=05h)
346 *
347 * Notes: If mode was set with bit 7 set ("no blanking"), the returned
348 * mode will also have bit 7 set. EGA, VGA, and UltraVision return either
349 * AL=03h (color) or AL=07h (monochrome) in all extended-row text modes.
350 * HP 200LX returns AL=07h (monochrome) if mode was set to AL=21h and
351 * always 80 resp. 40 columns in all text modes regardless of current
352 * zoom setting (see AH=D0h). When using a Hercules Graphics Card,
353 * additional checks are necessary:
354 *
355 * mode 05h:
356 * If WORD 0040h:0063h is 03B4h, may be in graphics page 1
357 * (as set by DOSSHELL and other Microsoft software)
358 *
359 * mode 06h:
360 * If WORD 0040h:0063h is 03B4h, may be in graphics page 0
361 * (as set by DOSSHELL and other Microsoft software)
362 *
363 * mode 07h:
364 * If BYTE 0040h:0065h bit 1 is set, Hercules card is in
365 * graphics mode, with bit 7 indicating the page (mode set by
366 * Hercules driver for Borland Turbo C).
367 * The Tandy 2000 BIOS is only documented as returning AL, not AH or BH
368 */
369 Regs.b.ah = 0x0F;
370 Int386(0x10, &Regs, &Regs);
371
372 if (Regs.b.ah == 0)
373 return FALSE;
374
375 *Mode = Regs.b.al;
376 return TRUE;
377}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ ULONG Mode
Definition: hubbusif.h:303

Referenced by PcVideoGetDisplayMode().

◆ PcVideoGetBufferSize()

ULONG PcVideoGetBufferSize ( VOID  )

Definition at line 1121 of file pcvideo.c.

1122{
1124}
static ULONG ScreenHeight
Definition: pcvideo.c:117
static ULONG BytesPerScanLine
Definition: pcvideo.c:118

Referenced by MachInit(), and PcVideoCopyOffScreenBufferToVRAM().

◆ PcVideoGetDisplayMode()

static VOID PcVideoGetDisplayMode ( VOID  )
static

Definition at line 380 of file pcvideo.c.

381{
382 USHORT Mode = 0;
383
384 /* Is the current mode VESA? */
387 {
388 TRACE("VESA mode detected\n");
393 DisplayMode = (0x0108 <= Mode && Mode <= 0x010C) ? VideoTextMode : VideoGraphicsMode;
395 }
396 /* If not, it should be a regular BIOS mode */
397 else if (PcVideoGetBiosMode(&Mode))
398 {
399 /*
400 * The BIOS data area 0x400 holds information about the current video mode.
401 * Infos at: https://web.archive.org/web/20240119203029/http://www.bioscentral.com/misc/bda.htm
402 * https://stanislavs.org/helppc/bios_data_area.html
403 */
404
405 UCHAR BiosMode = (*(PUCHAR)0x449) & 0x7F; /* Current video mode */
406 ASSERT(BiosMode == Mode);
408 TRACE("BIOS mode detected\n");
409
410 ScreenWidth = *(PUSHORT)0x44A; /* Number of screen columns */
411 ScreenHeight = 1 + *(PUCHAR)0x484; /* 1 + "Rows on the screen (less 1, EGA+)" */
412
413 /*
414 * Select bits 7 and 4 of "Video display data area (MCGA and VGA)"
415 * |7|6|5|4|3|2|1|0|
416 * | `------ see table below
417 * `--------- alphanumeric scan lines (see table below)
418 *
419 * then convert to a number and map it to the scanline number:
420 * Bit7 Bit4 Scan Lines
421 * 0 0 350 line mode
422 * 0 1 400 line mode
423 * 1 0 200 line mode
424 * 1 1 reserved
425 */
426 BytesPerScanLine = (*(PUCHAR)0x489) & 0x90;
427 BytesPerScanLine = ((BytesPerScanLine & 0x80) >> 6) | ((BytesPerScanLine & 0x10) >> 4);
428 switch (BytesPerScanLine)
429 {
431 BytesPerScanLine = 200; break;
433 BytesPerScanLine = 350; break;
435 BytesPerScanLine = 400; break;
436 default:
437 BytesPerScanLine = 160; break;
438 }
439
442 }
443 else
444 {
445 /* Set the values for the default text mode.
446 * If a graphics mode is set, these values will be changed. */
447 TRACE("Fallback mode detected\n");
449 ScreenWidth = 80;
450 ScreenHeight = 25;
451 BytesPerScanLine = 160;
454 }
455
456 TRACE("This is a %s video mode\n", VesaVideoMode ? "VESA" : "BIOS");
457 TRACE("BiosVideoMode = 0x%x\n", BiosVideoMode);
458 TRACE("DisplayMode = %sMode\n", DisplayMode == VideoTextMode ? "Text" : "Graphics");
459 TRACE("ScreenWidth = %lu\n", ScreenWidth);
460 TRACE("ScreenHeight = %lu\n", ScreenHeight);
461 TRACE("BytesPerScanLine = %lu\n", BytesPerScanLine);
462}
#define ASSERT(a)
Definition: mode.c:44
static BOOLEAN PcVideoGetBiosMode(_Out_ PUSHORT Mode)
Definition: pcvideo.c:333
static ULONG ScreenWidth
Definition: pcvideo.c:116
#define VIDEOMODE_NORMAL_TEXT
Definition: pcvideo.c:38
#define VERTRES_200_SCANLINES
Definition: pcvideo.c:50
static BOOLEAN PcVideoVesaGetSVGAModeInformation(_In_ USHORT Mode, _Out_ PSVGA_MODE_INFORMATION ModeInformation)
Definition: pcvideo.c:206
#define VERTRES_350_SCANLINES
Definition: pcvideo.c:51
#define VERTRES_400_SCANLINES
Definition: pcvideo.c:52
static BOOLEAN PcVideoVesaGetCurrentSVGAMode(_Out_ PUSHORT Mode)
Definition: pcvideo.c:297
static USHORT BiosVideoMode
Definition: pcvideo.c:115
#define TRACE(s)
Definition: solgame.cpp:4
USHORT WidthInPixels
Definition: pcvideo.c:67
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by PcVideoInit().

◆ PcVideoGetDisplaySize()

VOID PcVideoGetDisplaySize ( PULONG  Width,
PULONG  Height,
PULONG  Depth 
)

Definition at line 1097 of file pcvideo.c.

1098{
1099 *Width = ScreenWidth;
1102 {
1104 {
1105 /* 16-bit color modes give green an extra bit (5:6:5)
1106 * 15-bit color modes have just 5:5:5 for R:G:B */
1107 *Depth = (VesaVideoModeInformation.GreenMaskSize == 6 ? 16 : 15);
1108 }
1109 else
1110 {
1112 }
1113 }
1114 else
1115 {
1116 *Depth = 0;
1117 }
1118}
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by MachInit().

◆ PcVideoGetFontsFromFirmware()

VOID PcVideoGetFontsFromFirmware ( PULONG  RomFontPointers)

Definition at line 1127 of file pcvideo.c.

1128{
1129 REGS BiosRegs;
1130
1131 /* Get the address of the BIOS ROM fonts.
1132 * Int 10h, AX=1130h, BH = pointer specifier
1133 * Returns: es:bp = address */
1134 BiosRegs.d.eax = 0x1130;
1135 BiosRegs.b.bh = ROM_8x14CharacterFont;
1136 Int386(0x10, &BiosRegs, &BiosRegs);
1137 RomFontPointers[0] = BiosRegs.w.es << 4 | BiosRegs.w.bp;
1138
1139 BiosRegs.b.bh = ROM_8x8DoubleDotFontLo;
1140 Int386(0x10, &BiosRegs, &BiosRegs);
1141 RomFontPointers[1] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1142
1143 BiosRegs.b.bh = ROM_8x8DoubleDotFontHi;
1144 Int386(0x10, &BiosRegs, &BiosRegs);
1145 RomFontPointers[2] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1146
1147 BiosRegs.b.bh = ROM_AlphaAlternate;
1148 Int386(0x10, &BiosRegs, &BiosRegs);
1149 RomFontPointers[3] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1150
1151 BiosRegs.b.bh = ROM_8x16Font;
1152 Int386(0x10, &BiosRegs, &BiosRegs);
1153 RomFontPointers[4] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1154
1155 BiosRegs.b.bh = ROM_Alternate9x16Font;
1156 Int386(0x10, &BiosRegs, &BiosRegs);
1157 RomFontPointers[5] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1158}
#define RomFontPointers
Definition: winldr.c:348
unsigned char bh
Definition: pcbios.h:137
unsigned long eax
Definition: pcbios.h:93
unsigned short bp
Definition: pcbios.h:120
unsigned short es
Definition: pcbios.h:123
DWORDREGS d
Definition: pcbios.h:163

Referenced by MachInit().

◆ PcVideoGetPaletteColor()

VOID PcVideoGetPaletteColor ( UCHAR  Color,
UCHAR Red,
UCHAR Green,
UCHAR Blue 
)

Definition at line 1276 of file pcvideo.c.

1277{
1282}
@ Green
Definition: bl.h:199
@ Red
Definition: bl.h:201
@ Blue
Definition: bl.h:198
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define VIDEOPORT_PALETTE_READ
Definition: pcvideo.c:25
#define VIDEOPORT_PALETTE_DATA
Definition: pcvideo.c:27

Referenced by MachInit().

◆ PcVideoHideShowTextCursor()

VOID PcVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 1186 of file pcvideo.c.

1187{
1188 if (Show)
1189 PcVideoDefineCursor(0x0D, 0x0E);
1190 else
1191 PcVideoDefineCursor(0x20, 0x00);
1192}
static VOID PcVideoDefineCursor(UCHAR StartScanLine, UCHAR EndScanLine)
Definition: pcvideo.c:638

Referenced by MachInit(), and PcVideoPrepareForReactOS().

◆ PcVideoInit()

VOID PcVideoInit ( VOID  )

Definition at line 1020 of file pcvideo.c.

1021{
1022 /* Detect the installed video card */
1024
1025 /* Retrieve the initial display mode parameters */
1027
1028 /* If any video options have been specified, try to set a display mode */
1031
1032 // FIXME: We don't support graphics modes yet!
1033 // Revert to 80x25 text mode.
1036}
BOOTMGRINFO BootMgrInfo
Definition: settings.c:19
static ULONG PcVideoDetectVideoCard(VOID)
Definition: pcvideo.c:139
static ULONG VideoCard
Definition: pcvideo.c:114
static BOOLEAN PcVideoSetMode(USHORT NewMode)
Definition: pcvideo.c:878
VIDEODISPLAYMODE PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:1045
static VOID PcVideoGetDisplayMode(VOID)
Definition: pcvideo.c:380
PCSTR VideoOptions
Definition: settings.h:13

Referenced by MachInit().

◆ PcVideoIsPaletteFixed()

BOOLEAN PcVideoIsPaletteFixed ( VOID  )

Definition at line 1261 of file pcvideo.c.

1262{
1263 return FALSE;
1264}

Referenced by MachInit().

◆ PcVideoPrepareForReactOS()

VOID PcVideoPrepareForReactOS ( VOID  )

Definition at line 1308 of file pcvideo.c.

1309{
1310 // PcVideoSetMode80x50_80x43();
1313}
static BOOLEAN PcVideoSetMode80x25(VOID)
Definition: pcvideo.c:770
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1186

Referenced by PcPrepareForReactOS().

◆ PcVideoPutChar()

VOID PcVideoPutChar ( int  Ch,
UCHAR  Attr,
unsigned  X,
unsigned  Y 
)

Definition at line 1252 of file pcvideo.c.

1253{
1254 USHORT *BufPtr;
1255
1256 BufPtr = (USHORT*)(ULONG_PTR)(VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
1257 *BufPtr = ((USHORT)Attr << 8) | (Ch & 0xff);
1258}
#define Y(I)
#define Ch(x, y, z)
Definition: sha2.c:141
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by MachInit().

◆ PcVideoSelectAlternatePrintScreen()

static VOID PcVideoSelectAlternatePrintScreen ( VOID  )
static

Definition at line 589 of file pcvideo.c.

590{
591 REGS Regs;
592
593 /* Int 10h AH=12h BL=20h
594 * VIDEO - ALTERNATE FUNCTION SELECT (PS,EGA,VGA,MCGA) - ALTERNATE PRTSC
595 *
596 * AH = 12h
597 * BL = 20h select alternate print screen routine
598 * Return:
599 * Nothing
600 *
601 * Installs a PrtSc routine from the video card's BIOS to replace the
602 * default PrtSc handler from the ROM BIOS, which usually does not
603 * understand screen heights other than 25 lines.
604 *
605 * Some adapters disable print-screen instead of enhancing it.
606 */
607 Regs.b.ah = 0x12;
608 Regs.b.bl = 0x20;
609 Int386(0x10, &Regs, &Regs);
610}

Referenced by PcVideoSetMode80x43(), PcVideoSetMode80x50_80x43(), and PcVideoSetMode80x60().

◆ PcVideoSet480ScanLines()

static VOID PcVideoSet480ScanLines ( VOID  )
static

Definition at line 701 of file pcvideo.c.

702{
704
705 /* Read CRTC port */
706 CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
707 if (CRTC & 1)
708 CRTC = 0x3D4;
709 else
710 CRTC = 0x3B4;
711
712 /* Vertical sync end (also unlocks CR0-7) */
714 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0C);
715
716 /* Vertical total */
718 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0B);
719
720 /* (vertical) overflow */
722 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x3E);
723
724 /* Vertical sync start */
726 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xEA);
727
728 /* Vertical display end */
730 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
731
732 /* Vertical blank start */
734 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xE7);
735
736 /* Vertical blank end */
738 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x04);
739
740 /* Misc output register (read) */
741 CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
742
743 /* Preserve clock select bits and color bit */
744 CRTC = (CRTC & 0x0D);
745 /* Set correct sync polarity */
746 CRTC = (CRTC | 0xE2);
747
748 /* (write) */
750}
#define CRTC
Definition: blue.h:111
int32_t INT_PTR
Definition: typedefs.h:64

Referenced by PcVideoSetMode80x30(), PcVideoSetMode80x34(), and PcVideoSetMode80x60().

◆ PcVideoSetBiosMode()

static VOID PcVideoSetBiosMode ( UCHAR  VideoMode)
static

Definition at line 531 of file pcvideo.c.

532{
533 REGS Regs;
534
535 /* Int 10h AH=00h
536 * VIDEO - SET VIDEO MODE
537 *
538 * AH = 00h
539 * AL = desired video mode
540 * Return:
541 * AL = video mode flag (Phoenix, AMI BIOS)
542 * 20h mode > 7
543 * 30h modes 0-5 and 7
544 * 3Fh mode 6
545 * AL = CRT controller mode byte (Phoenix 386 BIOS v1.10)
546 */
547 Regs.b.ah = 0x00;
548 Regs.b.al = VideoMode;
549 Int386(0x10, &Regs, &Regs);
550}
struct _VideoMode VideoMode

Referenced by PcVideoSetMode(), PcVideoSetMode80x25(), and PcVideoSetMode80x50_80x43().

◆ PcVideoSetBiosVesaMode()

static BOOLEAN PcVideoSetBiosVesaMode ( USHORT  Mode)
static

Definition at line 465 of file pcvideo.c.

466{
467 REGS Regs;
468
469 /* Int 10h AX=4F02h
470 * VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE
471 *
472 * AX = 4F02h
473 * BX = new video mode
474 * ES:DI -> (VBE 3.0+) CRTC information block, bit mode bit 11 set
475 * Return:
476 * AL = 4Fh if function supported
477 * AH = status
478 * 00h successful
479 * 01h failed
480 *
481 * Values for VESA video mode:
482 * 00h-FFh OEM video modes (see #00010 at AH=00h)
483 * 100h 640x400x256
484 * 101h 640x480x256
485 * 102h 800x600x16
486 * 103h 800x600x256
487 * 104h 1024x768x16
488 * 105h 1024x768x256
489 * 106h 1280x1024x16
490 * 107h 1280x1024x256
491 * 108h 80x60 text
492 * 109h 132x25 text
493 * 10Ah 132x43 text
494 * 10Bh 132x50 text
495 * 10Ch 132x60 text
496 * ---VBE v1.2+ ---
497 * 10Dh 320x200x32K
498 * 10Eh 320x200x64K
499 * 10Fh 320x200x16M
500 * 110h 640x480x32K
501 * 111h 640x480x64K
502 * 112h 640x480x16M
503 * 113h 800x600x32K
504 * 114h 800x600x64K
505 * 115h 800x600x16M
506 * 116h 1024x768x32K
507 * 117h 1024x768x64K
508 * 118h 1024x768x16M
509 * 119h 1280x1024x32K (1:5:5:5)
510 * 11Ah 1280x1024x64K (5:6:5)
511 * 11Bh 1280x1024x16M
512 * ---VBE 2.0+ ---
513 * 120h 1600x1200x256
514 * 121h 1600x1200x32K
515 * 122h 1600x1200x64K
516 * 81FFh special full-memory access mode
517 *
518 * Notes: The special mode 81FFh preserves the contents of the video memory and gives
519 * access to all of the memory; VESA recommends that the special mode be a packed-pixel
520 * mode. For VBE 2.0+, it is required that the VBE implement the mode, but not place it
521 * in the list of available modes (mode information for this mode can be queried
522 * directly, however). As of VBE 2.0, VESA will no longer define video mode numbers.
523 */
524 Regs.w.ax = 0x4F02;
525 Regs.w.bx = Mode;
526 Int386(0x10, &Regs, &Regs);
527 return (Regs.w.ax == 0x004F);
528}
unsigned short bx
Definition: pcbios.h:114

Referenced by PcVideoSetMode().

◆ PcVideoSetBlinkBit()

static VOID PcVideoSetBlinkBit ( BOOLEAN  Enable)
static

Definition at line 959 of file pcvideo.c.

960{
961 REGS Regs;
962
963 /* Int 10h AX=1003h
964 * VIDEO - TOGGLE INTENSITY/BLINKING BIT (Jr, PS, TANDY 1000, EGA, VGA)
965 *
966 * AX = 1003h
967 * BL = new state
968 * 00h background intensity enabled
969 * 01h blink enabled
970 * BH = 00h to avoid problems on some adapters
971 * Return:
972 * Nothing
973 *
974 * Note: although there is no function to get
975 * the current status, bit 5 of 0040h:0065h
976 * indicates the state.
977 */
978 Regs.w.ax = 0x1003;
979 Regs.w.bx = Enable ? 0x0001 : 0x0000;
980 Int386(0x10, &Regs, &Regs);
981}
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142

Referenced by PcVideoSetDisplayMode().

◆ PcVideoSetDisplayEnd()

static VOID PcVideoSetDisplayEnd ( VOID  )
static

Definition at line 753 of file pcvideo.c.

754{
756
757 /* Read CRTC port */
758 CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
759 if (CRTC & 1)
760 CRTC = 0x3D4;
761 else
762 CRTC = 0x3B4;
763
764 /* Vertical display end */
766 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
767}

Referenced by PcVideoSetMode80x34(), and PcVideoSetMode80x60().

◆ PcVideoSetDisplayMode()

VIDEODISPLAYMODE PcVideoSetDisplayMode ( PCSTR  DisplayModeName,
BOOLEAN  Init 
)

Definition at line 1045 of file pcvideo.c.

1046{
1048
1049 if (!DisplayModeName || *DisplayModeName == '\0')
1050 goto Quit;
1051
1053 {
1054 TRACE_printf("CGA or other display adapter detected.\n");
1055 TRACE_printf("Using 80x25 text mode.\n");
1057 }
1058 else if (VideoCard == VIDEOCARD_EGA)
1059 {
1060 TRACE_printf("EGA display adapter detected.\n");
1061 TRACE_printf("Using 80x25 text mode.\n");
1063 }
1064 else /* VIDEOCARD_VGA */
1065 {
1066 TRACE_printf("VGA display adapter detected.\n");
1067
1068 /* Get the video option separator, if any */
1069 size_t NameLen = strcspn(DisplayModeName, ",");
1070 if (!NameLen)
1071 goto Quit;
1072
1073 if (_strnicmp(DisplayModeName, "NORMAL_VGA", NameLen) == 0)
1075 else if (_strnicmp(DisplayModeName, "EXTENDED_VGA", NameLen) == 0)
1077 else
1078 VideoMode = (USHORT)strtoul(DisplayModeName, NULL, 0);
1079 }
1080
1082 {
1083 TRACE_printf("Error: unable to set video display mode 0x%x\n", VideoMode);
1084 TRACE_printf("Defaulting to 80x25 text mode.\n");
1085 printf("Press any key to continue.\n");
1086 PcConsGetCh();
1087
1089 }
1090
1091Quit:
1093 return DisplayMode;
1094}
#define NULL
Definition: types.h:112
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
_ACRTIMP __msvcrt_ulong __cdecl strtoul(const char *, char **, int)
Definition: string.c:1859
_ACRTIMP size_t __cdecl strcspn(const char *, const char *)
Definition: string.c:3493
#define printf
Definition: freeldr.h:97
int PcConsGetCh(void)
Definition: pccons.c:84
#define TRACE_printf(Format,...)
Definition: pcvideo.c:1038
#define VIDEOMODE_EXTENDED_TEXT
Definition: pcvideo.c:39
static VOID PcVideoSetBlinkBit(BOOLEAN Enable)
Definition: pcvideo.c:959

Referenced by MachInit(), and PcVideoInit().

◆ PcVideoSetFont8x14()

static VOID PcVideoSetFont8x14 ( VOID  )
static

Definition at line 571 of file pcvideo.c.

572{
573 REGS Regs;
574
575 /* Int 10h AX=1111h
576 * VIDEO - TEXT-MODE CHARGEN - LOAD ROM MONOCHROME PATTERNS (PS,EGA,VGA)
577 *
578 * AX = 1111h
579 * BL = block to load
580 * Return:
581 * Nothing
582 */
583 Regs.w.ax = 0x1111;
584 Regs.b.bl = 0;
585 Int386(0x10, &Regs, &Regs);
586}

Referenced by PcVideoSetMode80x28(), and PcVideoSetMode80x34().

◆ PcVideoSetFont8x8()

static VOID PcVideoSetFont8x8 ( VOID  )
static

Definition at line 553 of file pcvideo.c.

554{
555 REGS Regs;
556
557 /* Int 10h AX=1112h
558 * VIDEO - TEXT-MODE CHARGEN - LOAD ROM 8x8 DBL-DOT PATTERNS (PS,EGA,VGA)
559 *
560 * AX = 1112h
561 * BL = block to load
562 * Return:
563 * Nothing
564 */
565 Regs.w.ax = 0x1112;
566 Regs.b.bl = 0x00;
567 Int386(0x10, &Regs, &Regs);
568}

Referenced by PcVideoSetMode80x43(), PcVideoSetMode80x50_80x43(), and PcVideoSetMode80x60().

◆ PcVideoSetMemoryBank()

static VOID PcVideoSetMemoryBank ( USHORT  BankNumber)
static

Definition at line 984 of file pcvideo.c.

985{
986 REGS Regs;
987
988 if (CurrentMemoryBank == BankNumber)
989 return;
990
991 /* Int 10h AX=4F05h
992 * VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL
993 *
994 * AX = 4F05h
995 * BH = subfunction
996 * 00h select video memory window
997 * 01h get video memory window
998 * DX = window address in video memory (in granularity units)
999 * Return:
1000 * DX = window address in video memory (in gran. units)
1001 * BL = window number
1002 * 00h window A
1003 * 01h window B.
1004 * Return:
1005 * AL = 4Fh if function supported
1006 * AH = status
1007 * 00h successful
1008 * 01h failed
1009 */
1010 Regs.w.ax = 0x4F05;
1011 Regs.w.bx = 0x0000;
1012 Regs.w.dx = BankNumber;
1013 Int386(0x10, &Regs, &Regs);
1014
1015 if (Regs.w.ax == 0x004F)
1016 CurrentMemoryBank = BankNumber;
1017}
static ULONG CurrentMemoryBank
Definition: pcvideo.c:122
unsigned short dx
Definition: pcbios.h:116

Referenced by PcVideoCopyOffScreenBufferToVRAM().

◆ PcVideoSetMode()

static BOOLEAN PcVideoSetMode ( USHORT  NewMode)
static

Definition at line 878 of file pcvideo.c.

879{
881
882 /* Set the values for the default text modes
883 * If they are setting a graphics mode then
884 * these values will be changed. */
885 BiosVideoMode = NewMode;
886 ScreenWidth = 80;
887 ScreenHeight = 25;
888 BytesPerScanLine = 160;
891
892 switch (NewMode)
893 {
895 case 0x03: /* BIOS 80x25 text mode number */
896 return PcVideoSetMode80x25();
899 case VIDEOMODE_80X28:
900 return PcVideoSetMode80x28();
901 case VIDEOMODE_80X30:
902 return PcVideoSetMode80x30();
903 case VIDEOMODE_80X34:
904 return PcVideoSetMode80x34();
905 case VIDEOMODE_80X43:
906 return PcVideoSetMode80x43();
907 case VIDEOMODE_80X60:
908 return PcVideoSetMode80x60();
909 }
910
911 if (NewMode == 0x12)
912 {
913 /* 640x480x16 */
914 PcVideoSetBiosMode((UCHAR)NewMode);
915 WRITE_PORT_USHORT((USHORT*)0x03CE, 0x0F01); /* For some reason this is necessary? */
916 ScreenWidth = 640;
917 ScreenHeight = 480;
918 BytesPerScanLine = 80;
919 BiosVideoMode = NewMode;
921
922 return TRUE;
923 }
924 else if (NewMode == 0x13)
925 {
926 /* 320x200x256 */
927 PcVideoSetBiosMode((UCHAR)NewMode);
928 ScreenWidth = 320;
929 ScreenHeight = 200;
930 BytesPerScanLine = 320;
931 BiosVideoMode = NewMode;
933
934 return TRUE;
935 }
936 else
937 {
938 /* VESA Text/Graphics Mode */
940 return FALSE;
941
942 if (!PcVideoSetBiosVesaMode(NewMode))
943 return FALSE;
944
948 BiosVideoMode = NewMode;
949 DisplayMode = (0x0108 <= NewMode && NewMode <= 0x010C) ? VideoTextMode : VideoGraphicsMode;
951
952 return TRUE;
953 }
954
955 return FALSE;
956}
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115
#define VIDEOMODE_80X28
Definition: pcvideo.c:40
static BOOLEAN PcVideoSetMode80x34(VOID)
Definition: pcvideo.c:833
#define VIDEOMODE_80X34
Definition: pcvideo.c:42
#define VIDEOMODE_80X43
Definition: pcvideo.c:43
static BOOLEAN PcVideoSetMode80x60(VOID)
Definition: pcvideo.c:862
static BOOLEAN PcVideoSetMode80x30(VOID)
Definition: pcvideo.c:822
#define VIDEOMODE_80X60
Definition: pcvideo.c:44
#define VIDEOMODE_80X30
Definition: pcvideo.c:41
static VOID PcVideoSetBiosMode(UCHAR VideoMode)
Definition: pcvideo.c:531
static BOOLEAN PcVideoSetMode80x43(VOID)
Definition: pcvideo.c:847
static BOOLEAN PcVideoSetBiosVesaMode(USHORT Mode)
Definition: pcvideo.c:465
static BOOLEAN PcVideoSetMode80x50_80x43(VOID)
Definition: pcvideo.c:779
static BOOLEAN PcVideoSetMode80x28(VOID)
Definition: pcvideo.c:810

Referenced by PcVideoInit(), and PcVideoSetDisplayMode().

◆ PcVideoSetMode80x25()

static BOOLEAN PcVideoSetMode80x25 ( VOID  )
static

◆ PcVideoSetMode80x28()

static BOOLEAN PcVideoSetMode80x28 ( VOID  )
static

Definition at line 810 of file pcvideo.c.

811{
812 /* FIXME: Is this VGA-only? */
815 PcVideoDefineCursor(11, 12);
816 ScreenWidth = 80;
817 ScreenHeight = 28;
818 return TRUE;
819}
static VOID PcVideoSetFont8x14(VOID)
Definition: pcvideo.c:571

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x30()

static BOOLEAN PcVideoSetMode80x30 ( VOID  )
static

Definition at line 822 of file pcvideo.c.

823{
824 /* FIXME: Is this VGA-only? */
827 ScreenWidth = 80;
828 ScreenHeight = 30;
829 return TRUE;
830}
static VOID PcVideoSet480ScanLines(VOID)
Definition: pcvideo.c:701

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x34()

static BOOLEAN PcVideoSetMode80x34 ( VOID  )
static

Definition at line 833 of file pcvideo.c.

834{
835 /* FIXME: Is this VGA-only? */
839 PcVideoDefineCursor(11, 12);
841 ScreenWidth = 80;
842 ScreenHeight = 34;
843 return TRUE;
844}
static VOID PcVideoSetDisplayEnd(VOID)
Definition: pcvideo.c:753

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x43()

static BOOLEAN PcVideoSetMode80x43 ( VOID  )
static

Definition at line 847 of file pcvideo.c.

848{
849 /* FIXME: Is this VGA-only? */
856 ScreenWidth = 80;
857 ScreenHeight = 43;
858 return TRUE;
859}
static VOID PcVideoDisableCursorEmulation(VOID)
Definition: pcvideo.c:613
static VOID PcVideoSetFont8x8(VOID)
Definition: pcvideo.c:553
static VOID PcVideoSetVerticalResolution(UCHAR VerticalResolutionMode)
Definition: pcvideo.c:674
static VOID PcVideoSelectAlternatePrintScreen(VOID)
Definition: pcvideo.c:589

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x50_80x43()

static BOOLEAN PcVideoSetMode80x50_80x43 ( VOID  )
static

Definition at line 779 of file pcvideo.c.

780{
782 {
783 PcVideoSetBiosMode(0x03);
788 ScreenWidth = 80;
789 ScreenHeight = 50;
790 }
791 else if (VideoCard == VIDEOCARD_EGA)
792 {
793 PcVideoSetBiosMode(0x03);
798 ScreenWidth = 80;
799 ScreenHeight = 43;
800 }
801 else /* VIDEOCARD_CGA_OR_OTHER */
802 {
803 return FALSE;
804 }
805
806 return TRUE;
807}

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x60()

static BOOLEAN PcVideoSetMode80x60 ( VOID  )
static

Definition at line 862 of file pcvideo.c.

863{
864 /* FIXME: Is this VGA-only? */
872 ScreenWidth = 80;
873 ScreenHeight = 60;
874 return TRUE;
875}

Referenced by PcVideoSetMode().

◆ PcVideoSetPaletteColor()

VOID PcVideoSetPaletteColor ( UCHAR  Color,
UCHAR  Red,
UCHAR  Green,
UCHAR  Blue 
)

◆ PcVideoSetTextCursorPosition()

VOID PcVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 1161 of file pcvideo.c.

1162{
1163 REGS Regs;
1164
1165 /* Int 10h AH=02h
1166 * VIDEO - SET CURSOR POSITION
1167 *
1168 * AH = 02h
1169 * BH = page number
1170 * 0-3 in modes 2&3
1171 * 0-7 in modes 0&1
1172 * 0 in graphics modes
1173 * DH = row (00h is top)
1174 * DL = column (00h is left)
1175 * Return:
1176 * Nothing
1177 */
1178 Regs.b.ah = 0x02;
1179 Regs.b.bh = 0x00;
1180 Regs.b.dh = Y;
1181 Regs.b.dl = X;
1182 Int386(0x10, &Regs, &Regs);
1183}
#define X(b, s)
unsigned char dl
Definition: pcbios.h:142
unsigned char dh
Definition: pcbios.h:143

Referenced by MachInit().

◆ PcVideoSetVerticalResolution()

static VOID PcVideoSetVerticalResolution ( UCHAR  VerticalResolutionMode)
static

Definition at line 674 of file pcvideo.c.

675{
676 REGS Regs;
677
678 /* Int 10h AH=12h BL=30h
679 * VIDEO - ALTERNATE FUNCTION SELECT (VGA) - SELECT VERTICAL RESOLUTION
680 *
681 * AH = 12h
682 * BL = 30h
683 * AL = vertical resolution
684 * 00h 200 scan lines
685 * 01h 350 scan lines
686 * 02h 400 scan lines
687 * Return:
688 * AL = 12h if function supported
689 *
690 * Specify the number of scan lines used to display text modes.
691 *
692 * The specified resolution will take effect on the next mode set.
693 */
694 Regs.b.ah = 0x12;
695 Regs.b.bl = 0x30;
696 Regs.b.al = VerticalResolutionMode;
697 Int386(0x10, &Regs, &Regs);
698}

Referenced by PcVideoSetMode80x43().

◆ PcVideoSync()

VOID PcVideoSync ( VOID  )

Definition at line 1285 of file pcvideo.c.

1286{
1288 {
1289 /*
1290 * Keep reading the port until bit 3 is clear
1291 * This waits for the current retrace to end and
1292 * we can catch the next one so we know we are
1293 * getting a full retrace.
1294 */
1295 }
1296
1298 {
1299 /*
1300 * Keep reading the port until bit 3 is set
1301 * Now that we know we aren't doing a vertical
1302 * retrace we need to wait for the next one.
1303 */
1304 }
1305}
#define VIDEOPORT_VERTICAL_RETRACE
Definition: pcvideo.c:28

Referenced by MachInit().

◆ PcVideoVesaGetCurrentSVGAMode()

static BOOLEAN PcVideoVesaGetCurrentSVGAMode ( _Out_ PUSHORT  Mode)
static

Definition at line 297 of file pcvideo.c.

299{
300 REGS Regs;
301
302 /*
303 * VESA SuperVGA BIOS - GET CURRENT VIDEO MODE
304 *
305 * AX = 4F03h
306 * Return:
307 * AL = 4Fh if function supported
308 * AH = status
309 * 00h successful
310 * BX = video mode (see #00083,#00084)
311 *
312 * bit 13:
313 * VBE/AF v1.0P accelerated video mode
314 *
315 * bit 14:
316 * Linear frame buffer enabled (VBE v2.0+)
317 *
318 * bit 15:
319 * Don't clear video memory
320 * 01h failed
321 */
322 Regs.w.ax = 0x4F03;
323 Int386(0x10, &Regs, &Regs);
324
325 if (Regs.w.ax != 0x004F)
326 return FALSE;
327
328 *Mode = Regs.w.bx;
329 return TRUE;
330}

Referenced by PcVideoGetDisplayMode().

◆ PcVideoVesaGetSVGAModeInformation()

static BOOLEAN PcVideoVesaGetSVGAModeInformation ( _In_ USHORT  Mode,
_Out_ PSVGA_MODE_INFORMATION  ModeInformation 
)
static

Definition at line 206 of file pcvideo.c.

209{
210 REGS Regs;
211
212 RtlZeroMemory((PVOID)BIOSCALLBUFFER, sizeof(*ModeInformation));
213
214 /* VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION
215 * AX = 4F01h
216 * CX = SuperVGA video mode (see #04082 for bitfields)
217 * ES:DI -> 256-byte buffer for mode information (see #00079)
218 * Return:
219 * AL = 4Fh if function supported
220 * AH = status
221 * 00h successful
222 * ES:DI buffer filled
223 * 01h failed
224 *
225 * Desc: Determine the attributes of the specified video mode.
226 *
227 * Note: While VBE 1.1 and higher will zero out all unused bytes
228 * of the buffer, v1.0 did not, so applications that want to be
229 * backward compatible should clear the buffer before calling.
230 */
231 Regs.w.ax = 0x4F01;
232 Regs.w.cx = Mode;
233 Regs.w.es = BIOSCALLBUFSEGMENT;
234 Regs.w.di = BIOSCALLBUFOFFSET;
235 Int386(0x10, &Regs, &Regs);
236
237 if (Regs.w.ax != 0x004F)
238 return FALSE;
239
240 RtlCopyMemory(ModeInformation, (PVOID)BIOSCALLBUFFER, sizeof(*ModeInformation));
241
242 TRACE("\n");
243 TRACE("BiosVesaGetSVGAModeInformation(Mode 0x%x)\n", Mode);
244 TRACE("ModeAttributes = 0x%04x\n", ModeInformation->ModeAttributes);
245 TRACE("WindowAttributesA = 0x%02x\n", ModeInformation->WindowAttributesA);
246 TRACE("WindowAttributesB = 0x%02x\n", ModeInformation->WindowsAttributesB);
247 TRACE("WindowGranularity = %huKB\n", ModeInformation->WindowGranularity);
248 TRACE("WindowSize = %huKB\n", ModeInformation->WindowSize);
249 TRACE("WindowAStartSegment = 0x%04x\n", ModeInformation->WindowAStartSegment);
250 TRACE("WindowBStartSegment = 0x%04x\n", ModeInformation->WindowBStartSegment);
251 TRACE("WindowPositioningFunction = 0x%x\n", ModeInformation->WindowPositioningFunction);
252 TRACE("BytesPerScanLine = %hu\n", ModeInformation->BytesPerScanLine);
253 TRACE("WidthInPixels = %hu\n", ModeInformation->WidthInPixels);
254 TRACE("HeightInPixels = %hu\n", ModeInformation->HeightInPixels);
255 TRACE("CharacterWidthInPixels = %u\n", ModeInformation->CharacterWidthInPixels);
256 TRACE("CharacterHeightInPixels = %u\n", ModeInformation->CharacterHeightInPixels);
257 TRACE("NumberOfMemoryPlanes = %u\n", ModeInformation->NumberOfMemoryPlanes);
258 TRACE("BitsPerPixel = %u\n", ModeInformation->BitsPerPixel);
259 TRACE("NumberOfBanks = %u\n", ModeInformation->NumberOfBanks);
260 TRACE("MemoryModel = %u\n", ModeInformation->MemoryModel);
261 TRACE("BankSize = %u\n", ModeInformation->BankSize);
262 TRACE("NumberOfImagePanes = %u\n", ModeInformation->NumberOfImagePanes);
263 TRACE("Reserved1 = 0x%02x\n", ModeInformation->Reserved1);
264 TRACE("---VBE v1.2+ ---\n");
265 TRACE("RedMaskSize = %u\n", ModeInformation->RedMaskSize);
266 TRACE("RedMaskPosition = %u\n", ModeInformation->RedMaskPosition);
267 TRACE("GreenMaskSize = %u\n", ModeInformation->GreenMaskSize);
268 TRACE("GreenMaskPosition = %u\n", ModeInformation->GreenMaskPosition);
269 TRACE("BlueMaskSize = %u\n", ModeInformation->BlueMaskSize);
270 TRACE("BlueMaskPosition = %u\n", ModeInformation->BlueMaskPosition);
271 TRACE("ReservedMaskSize = %u\n", ModeInformation->ReservedMaskSize);
272 TRACE("ReservedMaskPosition = %u\n", ModeInformation->ReservedMaskPosition);
273 TRACE("DirectColorModeInfo = 0x%02x\n", ModeInformation->DirectColorModeInfo);
274 TRACE("---VBE v2.0+ ---\n");
275 TRACE("LinearVideoBufferAddress = 0x%x\n", ModeInformation->LinearVideoBufferAddress);
276 TRACE("OffscreenMemoryPointer = 0x%x\n", ModeInformation->OffscreenMemoryPointer);
277 TRACE("OffscreenMemorySize = %huKB\n", ModeInformation->OffscreenMemorySize);
278 TRACE("---VBE v3.0 ---\n");
279 TRACE("LinearBytesPerScanLine = %hu\n", ModeInformation->LinearBytesPerScanLine);
280 TRACE("BankedNumberOfImages = %u\n", ModeInformation->BankedNumberOfImages);
281 TRACE("LinearNumberOfImages = %u\n", ModeInformation->LinearNumberOfImages);
282 TRACE("LinearRedMaskSize = %u\n", ModeInformation->LinearRedMaskSize);
283 TRACE("LinearRedMaskPosition = %u\n", ModeInformation->LinearRedMaskPosition);
284 TRACE("LinearGreenMaskSize = %u\n", ModeInformation->LinearGreenMaskSize);
285 TRACE("LinearGreenMaskPosition = %u\n", ModeInformation->LinearGreenMaskPosition);
286 TRACE("LinearBlueMaskSize = %u\n", ModeInformation->LinearBlueMaskSize);
287 TRACE("LinearBlueMaskPosition = %u\n", ModeInformation->LinearBlueMaskPosition);
288 TRACE("LinearReservedMaskSize = %u\n", ModeInformation->LinearReservedMaskSize);
289 TRACE("LinearReservedMaskPosition = %u\n", ModeInformation->LinearReservedMaskPosition);
290 TRACE("MaximumPixelClock = %luHz\n", ModeInformation->MaximumPixelClock);
291 TRACE("\n");
292
293 return TRUE;
294}
unsigned short di
Definition: pcbios.h:119
unsigned short cx
Definition: pcbios.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define BIOSCALLBUFSEGMENT
Definition: x86common.h:24
#define BIOSCALLBUFOFFSET
Definition: x86common.h:25
#define BIOSCALLBUFFER
Definition: x86common.h:12

Referenced by PcVideoGetDisplayMode(), and PcVideoSetMode().

Variable Documentation

◆ BiosVideoMode

USHORT BiosVideoMode = VIDEOMODE_NORMAL_TEXT
static

Definition at line 115 of file pcvideo.c.

Referenced by PcVideoGetDisplayMode(), and PcVideoSetMode().

◆ BytesPerScanLine

ULONG BytesPerScanLine = 160
static

◆ CurrentMemoryBank

ULONG CurrentMemoryBank = 0
static

Definition at line 122 of file pcvideo.c.

Referenced by PcVideoSetMemoryBank(), and PcVideoSetMode().

◆ DisplayMode

◆ MachDefaultTextColor

UCHAR MachDefaultTextColor = COLOR_GRAY

Definition at line 112 of file pcvideo.c.

◆ ScreenHeight

◆ ScreenWidth

◆ VesaVideoMode

BOOLEAN VesaVideoMode = FALSE
static

◆ VesaVideoModeInformation

SVGA_MODE_INFORMATION VesaVideoModeInformation
static

◆ VideoCard

ULONG VideoCard = VIDEOCARD_CGA_OR_OTHER
static

Definition at line 114 of file pcvideo.c.

Referenced by PcVideoInit(), PcVideoSetDisplayMode(), and PcVideoSetMode80x50_80x43().