ReactOS 0.4.17-dev-683-g0dafdc5
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 VERTRES_480_SCANLINES   0x03
 
#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, _Out_ PUSHORT WidthInChars)
 
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 = (80 * 2)
 
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 1018 of file pcvideo.c.

◆ VERTRES_200_SCANLINES

#define VERTRES_200_SCANLINES   0x00

Definition at line 51 of file pcvideo.c.

◆ VERTRES_350_SCANLINES

#define VERTRES_350_SCANLINES   0x01

Definition at line 52 of file pcvideo.c.

◆ VERTRES_400_SCANLINES

#define VERTRES_400_SCANLINES   0x02

Definition at line 53 of file pcvideo.c.

◆ VERTRES_480_SCANLINES

#define VERTRES_480_SCANLINES   0x03

Definition at line 54 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 126 of file pcvideo.c.

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

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 1216 of file pcvideo.c.

1217{
1218 USHORT AttrChar;
1219 USHORT *BufPtr;
1220
1221 AttrChar = ((USHORT)Attr << 8) | ' ';
1222 for (BufPtr = (USHORT*)VIDEOTEXT_MEM_ADDRESS;
1224 BufPtr++)
1225 {
1227 *BufPtr = AttrChar;
1228 }
1229}
#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 1175 of file pcvideo.c.

1176{
1177 USHORT BanksToCopy;
1178 ULONG BytesInLastBank;
1179 USHORT CurrentBank;
1180 ULONG BankSize;
1181
1182 /* PcVideoWaitForVerticalRetrace(); */
1183
1184 /* Text mode (BIOS or VESA) */
1186 {
1188 }
1189 /* VESA graphics mode */
1191 {
1195
1196 /* Copy all the banks but the last one because
1197 * it is probably a partial bank */
1198 for (CurrentBank = 0; CurrentBank < BanksToCopy; CurrentBank++)
1199 {
1200 PcVideoSetMemoryBank(CurrentBank);
1201 RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, (char*)Buffer + CurrentBank * BankSize, BankSize);
1202 }
1203
1204 /* Copy the remaining bytes into the last bank */
1205 PcVideoSetMemoryBank(CurrentBank);
1206 RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, (char*)Buffer + CurrentBank * BankSize, BytesInLastBank);
1207 }
1208 /* BIOS graphics mode */
1209 else
1210 {
1212 }
1213}
#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:123
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:121
#define VIDEOVGA_MEM_ADDRESS
Definition: pcvideo.c:30
static BOOLEAN VesaVideoMode
Definition: pcvideo.c:122
static VOID PcVideoSetMemoryBank(USHORT BankNumber)
Definition: pcvideo.c:964
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:1101
USHORT HeightInPixels
Definition: pcvideo.c:70
USHORT BytesPerScanLine
Definition: pcvideo.c:67
USHORT WindowGranularity
Definition: pcvideo.c:62
#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 617 of file pcvideo.c.

618{
619 REGS Regs;
620
621 /* Int 10h AH=01h
622 * VIDEO - SET TEXT-MODE CURSOR SHAPE
623 *
624 * AH = 01h
625 * CH = cursor start and options
626 * CL = bottom scan line containing cursor (bits 0-4)
627 * Return:
628 * Nothing
629 *
630 * Specify the starting and ending scan lines to be occupied
631 * by the hardware cursor in text modes.
632 *
633 * AMI 386 BIOS and AST Premier 386 BIOS will lock up the
634 * system if AL is not equal to the current video mode.
635 *
636 * Bitfields for cursor start and options:
637 *
638 * Bit(s) Description
639 * 7 should be zero
640 * 6,5 cursor blink
641 * (00=normal, 01=invisible, 10=erratic, 11=slow).
642 * (00=normal, other=invisible on EGA/VGA)
643 * 4-0 topmost scan line containing cursor
644 */
645 Regs.b.ah = 0x01;
646 Regs.b.al = 0x03;
647 Regs.b.ch = StartScanLine;
648 Regs.b.cl = EndScanLine;
649 Int386(0x10, &Regs, &Regs);
650}
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 141 of file pcvideo.c.

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

593{
594 REGS Regs;
595
596 /* Int 10h AH=12h BL=34h
597 * VIDEO - ALTERNATE FUNCTION SELECT (VGA) - CURSOR EMULATION
598 *
599 * AH = 12h
600 * BL = 34h
601 * AL = new state
602 * 00h enable alphanumeric cursor emulation
603 * 01h disable alphanumeric cursor emulation
604 * Return:
605 * AL = 12h if function supported
606 *
607 * Specify whether the BIOS should automatically remap cursor start/end
608 * according to the current character height in text modes.
609 */
610 Regs.b.ah = 0x12;
611 Regs.b.bl = 0x34;
612 Regs.b.al = 0x01;
613 Int386(0x10, &Regs, &Regs);
614}

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

◆ PcVideoGetBiosMode()

static BOOLEAN PcVideoGetBiosMode ( _Out_ PUSHORT  Mode,
_Out_ PUSHORT  WidthInChars 
)
static

Definition at line 335 of file pcvideo.c.

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

1102{
1104}
static ULONG ScreenHeight
Definition: pcvideo.c:119
static ULONG BytesPerScanLine
Definition: pcvideo.c:120

Referenced by MachInit(), and PcVideoCopyOffScreenBufferToVRAM().

◆ PcVideoGetDisplayMode()

static VOID PcVideoGetDisplayMode ( VOID  )
static

Definition at line 384 of file pcvideo.c.

385{
386 USHORT Mode = 0;
387 USHORT WidthInChars;
388
389 /* Is the current mode VESA? */
392 {
393 TRACE("VESA mode detected\n");
398 DisplayMode = (0x0108 <= Mode && Mode <= 0x010C) ? VideoTextMode : VideoGraphicsMode;
400 }
401 /* If not, it should be a regular BIOS mode */
402 else if (PcVideoGetBiosMode(&Mode, &WidthInChars))
403 {
404 /*
405 * The BIOS data area 0x400 holds information about the current video mode.
406 * Infos at: https://web.archive.org/web/20240119203029/http://www.bioscentral.com/misc/bda.htm
407 * https://stanislavs.org/helppc/bios_data_area.html
408 * http://www.techhelpmanual.com/93-rom_bios_variables.html
409 */
410 UCHAR BiosMode = (*(PUCHAR)0x449) & 0x7F; /* Current video mode */
411 ASSERT(BiosMode == Mode);
413 TRACE("BIOS mode detected\n");
414
415 ScreenWidth = *(PUSHORT)0x44A; /* Number of screen columns */
416 ASSERT(ScreenWidth == WidthInChars);
417 ScreenHeight = 1 + *(PUCHAR)0x484; /* 1 + "Rows on the screen (less 1, EGA+)" */
418 BytesPerScanLine = (ScreenWidth * 2); /* Text mode: one byte for character, one byte for attribute */
421 }
422 else
423 {
424 /* Set the values for the default text mode.
425 * If a graphics mode is set, these values will be changed. */
426 TRACE("Fallback mode detected\n");
428 ScreenWidth = 80;
429 ScreenHeight = 25;
433 }
434
435 TRACE("This is a %s video mode\n", VesaVideoMode ? "VESA" : "BIOS");
436 TRACE("BiosVideoMode = 0x%x\n", BiosVideoMode);
437 TRACE("DisplayMode = %sMode\n", DisplayMode == VideoTextMode ? "Text" : "Graphics");
438 TRACE("ScreenWidth = %lu\n", ScreenWidth);
439 TRACE("ScreenHeight = %lu\n", ScreenHeight);
440 TRACE("BytesPerScanLine = %lu\n", BytesPerScanLine);
441}
#define ASSERT(a)
Definition: mode.c:44
static ULONG ScreenWidth
Definition: pcvideo.c:118
#define VIDEOMODE_NORMAL_TEXT
Definition: pcvideo.c:38
static BOOLEAN PcVideoVesaGetSVGAModeInformation(_In_ USHORT Mode, _Out_ PSVGA_MODE_INFORMATION ModeInformation)
Definition: pcvideo.c:208
static BOOLEAN PcVideoVesaGetCurrentSVGAMode(_Out_ PUSHORT Mode)
Definition: pcvideo.c:299
static BOOLEAN PcVideoGetBiosMode(_Out_ PUSHORT Mode, _Out_ PUSHORT WidthInChars)
Definition: pcvideo.c:335
static USHORT BiosVideoMode
Definition: pcvideo.c:117
#define TRACE(s)
Definition: solgame.cpp:4
USHORT WidthInPixels
Definition: pcvideo.c:69
unsigned char UCHAR
Definition: typedefs.h:53
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by PcVideoInit().

◆ PcVideoGetDisplaySize()

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

Definition at line 1077 of file pcvideo.c.

1078{
1079 *Width = ScreenWidth;
1082 {
1084 {
1085 /* 16-bit color modes give green an extra bit (5:6:5)
1086 * 15-bit color modes have just 5:5:5 for R:G:B */
1087 *Depth = (VesaVideoModeInformation.GreenMaskSize == 6 ? 16 : 15);
1088 }
1089 else
1090 {
1092 }
1093 }
1094 else
1095 {
1096 *Depth = 0;
1097 }
1098}
_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 1107 of file pcvideo.c.

1108{
1109 REGS BiosRegs;
1110
1111 /* Get the address of the BIOS ROM fonts.
1112 * Int 10h, AX=1130h, BH = pointer specifier
1113 * Returns: es:bp = address */
1114 BiosRegs.d.eax = 0x1130;
1115 BiosRegs.b.bh = ROM_8x14CharacterFont;
1116 Int386(0x10, &BiosRegs, &BiosRegs);
1117 RomFontPointers[0] = BiosRegs.w.es << 4 | BiosRegs.w.bp;
1118
1119 BiosRegs.b.bh = ROM_8x8DoubleDotFontLo;
1120 Int386(0x10, &BiosRegs, &BiosRegs);
1121 RomFontPointers[1] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1122
1123 BiosRegs.b.bh = ROM_8x8DoubleDotFontHi;
1124 Int386(0x10, &BiosRegs, &BiosRegs);
1125 RomFontPointers[2] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1126
1127 BiosRegs.b.bh = ROM_AlphaAlternate;
1128 Int386(0x10, &BiosRegs, &BiosRegs);
1129 RomFontPointers[3] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1130
1131 BiosRegs.b.bh = ROM_8x16Font;
1132 Int386(0x10, &BiosRegs, &BiosRegs);
1133 RomFontPointers[4] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1134
1135 BiosRegs.b.bh = ROM_Alternate9x16Font;
1136 Int386(0x10, &BiosRegs, &BiosRegs);
1137 RomFontPointers[5] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
1138}
#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 1256 of file pcvideo.c.

1257{
1262}
#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 1166 of file pcvideo.c.

1167{
1168 if (Show)
1169 PcVideoDefineCursor(0x0D, 0x0E);
1170 else
1171 PcVideoDefineCursor(0x20, 0x00);
1172}
static VOID PcVideoDefineCursor(UCHAR StartScanLine, UCHAR EndScanLine)
Definition: pcvideo.c:617

Referenced by MachInit(), and PcVideoPrepareForReactOS().

◆ PcVideoInit()

VOID PcVideoInit ( VOID  )

Definition at line 1000 of file pcvideo.c.

1001{
1002 /* Detect the installed video card */
1004
1005 /* Retrieve the initial display mode parameters */
1007
1008 /* If any video options have been specified, try to set a display mode */
1011
1012 // FIXME: We don't support graphics modes yet!
1013 // Revert to 80x25 text mode.
1016}
BOOTMGRINFO BootMgrInfo
Definition: settings.c:19
static ULONG PcVideoDetectVideoCard(VOID)
Definition: pcvideo.c:141
static ULONG VideoCard
Definition: pcvideo.c:116
static BOOLEAN PcVideoSetMode(USHORT NewMode)
Definition: pcvideo.c:864
VIDEODISPLAYMODE PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:1025
static VOID PcVideoGetDisplayMode(VOID)
Definition: pcvideo.c:384
PCSTR VideoOptions
Definition: settings.h:13

Referenced by MachInit().

◆ PcVideoIsPaletteFixed()

BOOLEAN PcVideoIsPaletteFixed ( VOID  )

Definition at line 1241 of file pcvideo.c.

1242{
1243 return FALSE;
1244}

Referenced by MachInit().

◆ PcVideoPrepareForReactOS()

VOID PcVideoPrepareForReactOS ( VOID  )

Definition at line 1288 of file pcvideo.c.

1289{
1290 // PcVideoSetMode80x50_80x43();
1293}
static BOOLEAN PcVideoSetMode80x25(VOID)
Definition: pcvideo.c:749
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1166

Referenced by PcPrepareForReactOS().

◆ PcVideoPutChar()

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

Definition at line 1232 of file pcvideo.c.

1233{
1234 USHORT *BufPtr;
1235
1236 BufPtr = (USHORT*)(ULONG_PTR)(VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
1237 *BufPtr = ((USHORT)Attr << 8) | (Ch & 0xff);
1238}
#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 568 of file pcvideo.c.

569{
570 REGS Regs;
571
572 /* Int 10h AH=12h BL=20h
573 * VIDEO - ALTERNATE FUNCTION SELECT (PS,EGA,VGA,MCGA) - ALTERNATE PRTSC
574 *
575 * AH = 12h
576 * BL = 20h select alternate print screen routine
577 * Return:
578 * Nothing
579 *
580 * Installs a PrtSc routine from the video card's BIOS to replace the
581 * default PrtSc handler from the ROM BIOS, which usually does not
582 * understand screen heights other than 25 lines.
583 *
584 * Some adapters disable print-screen instead of enhancing it.
585 */
586 Regs.b.ah = 0x12;
587 Regs.b.bl = 0x20;
588 Int386(0x10, &Regs, &Regs);
589}

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

◆ PcVideoSet480ScanLines()

static VOID PcVideoSet480ScanLines ( VOID  )
static

Definition at line 680 of file pcvideo.c.

681{
683
684 /* Read CRTC port */
685 CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
686 if (CRTC & 1)
687 CRTC = 0x3D4;
688 else
689 CRTC = 0x3B4;
690
691 /* Vertical sync end (also unlocks CR0-7) */
693 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0C);
694
695 /* Vertical total */
697 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0B);
698
699 /* (vertical) overflow */
701 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x3E);
702
703 /* Vertical sync start */
705 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xEA);
706
707 /* Vertical display end */
709 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
710
711 /* Vertical blank start */
713 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xE7);
714
715 /* Vertical blank end */
717 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x04);
718
719 /* Misc output register (read) */
720 CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
721
722 /* Preserve clock select bits and color bit */
723 CRTC = (CRTC & 0x0D);
724 /* Set correct sync polarity */
725 CRTC = (CRTC | 0xE2);
726
727 /* (write) */
729}
#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 510 of file pcvideo.c.

511{
512 REGS Regs;
513
514 /* Int 10h AH=00h
515 * VIDEO - SET VIDEO MODE
516 *
517 * AH = 00h
518 * AL = desired video mode
519 * Return:
520 * AL = video mode flag (Phoenix, AMI BIOS)
521 * 20h mode > 7
522 * 30h modes 0-5 and 7
523 * 3Fh mode 6
524 * AL = CRT controller mode byte (Phoenix 386 BIOS v1.10)
525 */
526 Regs.b.ah = 0x00;
527 Regs.b.al = VideoMode;
528 Int386(0x10, &Regs, &Regs);
529}
struct _VideoMode VideoMode

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

◆ PcVideoSetBiosVesaMode()

static BOOLEAN PcVideoSetBiosVesaMode ( USHORT  Mode)
static

Definition at line 444 of file pcvideo.c.

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

Referenced by PcVideoSetMode().

◆ PcVideoSetBlinkBit()

static VOID PcVideoSetBlinkBit ( BOOLEAN  Enable)
static

Definition at line 939 of file pcvideo.c.

940{
941 REGS Regs;
942
943 /* Int 10h AX=1003h
944 * VIDEO - TOGGLE INTENSITY/BLINKING BIT (Jr, PS, TANDY 1000, EGA, VGA)
945 *
946 * AX = 1003h
947 * BL = new state
948 * 00h background intensity enabled
949 * 01h blink enabled
950 * BH = 00h to avoid problems on some adapters
951 * Return:
952 * Nothing
953 *
954 * Note: although there is no function to get
955 * the current status, bit 5 of 0040h:0065h
956 * indicates the state.
957 */
958 Regs.w.ax = 0x1003;
959 Regs.w.bx = Enable ? 0x0001 : 0x0000;
960 Int386(0x10, &Regs, &Regs);
961}
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142

Referenced by PcVideoSetDisplayMode().

◆ PcVideoSetDisplayEnd()

static VOID PcVideoSetDisplayEnd ( VOID  )
static

Definition at line 732 of file pcvideo.c.

733{
735
736 /* Read CRTC port */
737 CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
738 if (CRTC & 1)
739 CRTC = 0x3D4;
740 else
741 CRTC = 0x3B4;
742
743 /* Vertical display end */
745 WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
746}

Referenced by PcVideoSetMode80x34(), and PcVideoSetMode80x60().

◆ PcVideoSetDisplayMode()

VIDEODISPLAYMODE PcVideoSetDisplayMode ( PCSTR  DisplayModeName,
BOOLEAN  Init 
)

Definition at line 1025 of file pcvideo.c.

1026{
1028
1029 if (!DisplayModeName || *DisplayModeName == '\0')
1030 goto Quit;
1031
1033 {
1034 TRACE_printf("CGA or other display adapter detected.\n");
1035 TRACE_printf("Using 80x25 text mode.\n");
1037 }
1038 else if (VideoCard == VIDEOCARD_EGA)
1039 {
1040 TRACE_printf("EGA display adapter detected.\n");
1041 TRACE_printf("Using 80x25 text mode.\n");
1043 }
1044 else /* VIDEOCARD_VGA */
1045 {
1046 TRACE_printf("VGA display adapter detected.\n");
1047
1048 /* Get the video option separator, if any */
1049 size_t NameLen = strcspn(DisplayModeName, ",");
1050 if (!NameLen)
1051 goto Quit;
1052
1053 if (_strnicmp(DisplayModeName, "NORMAL_VGA", NameLen) == 0)
1055 else if (_strnicmp(DisplayModeName, "EXTENDED_VGA", NameLen) == 0)
1057 else
1058 VideoMode = (USHORT)strtoul(DisplayModeName, NULL, 0);
1059 }
1060
1062 {
1063 TRACE_printf("Error: unable to set video display mode 0x%x\n", VideoMode);
1064 TRACE_printf("Defaulting to 80x25 text mode.\n");
1065 printf("Press any key to continue.\n");
1066 PcConsGetCh();
1067
1069 }
1070
1071Quit:
1073 return DisplayMode;
1074}
#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:1864
_ACRTIMP size_t __cdecl strcspn(const char *, const char *)
Definition: string.c:3498
#define printf
Definition: freeldr.h:103
int PcConsGetCh(void)
Definition: pccons.c:84
#define TRACE_printf(Format,...)
Definition: pcvideo.c:1018
#define VIDEOMODE_EXTENDED_TEXT
Definition: pcvideo.c:39
static VOID PcVideoSetBlinkBit(BOOLEAN Enable)
Definition: pcvideo.c:939

Referenced by MachInit(), and PcVideoInit().

◆ PcVideoSetFont8x14()

static VOID PcVideoSetFont8x14 ( VOID  )
static

Definition at line 550 of file pcvideo.c.

551{
552 REGS Regs;
553
554 /* Int 10h AX=1111h
555 * VIDEO - TEXT-MODE CHARGEN - LOAD ROM MONOCHROME PATTERNS (PS,EGA,VGA)
556 *
557 * AX = 1111h
558 * BL = block to load
559 * Return:
560 * Nothing
561 */
562 Regs.w.ax = 0x1111;
563 Regs.b.bl = 0;
564 Int386(0x10, &Regs, &Regs);
565}

Referenced by PcVideoSetMode80x28(), and PcVideoSetMode80x34().

◆ PcVideoSetFont8x8()

static VOID PcVideoSetFont8x8 ( VOID  )
static

Definition at line 532 of file pcvideo.c.

533{
534 REGS Regs;
535
536 /* Int 10h AX=1112h
537 * VIDEO - TEXT-MODE CHARGEN - LOAD ROM 8x8 DBL-DOT PATTERNS (PS,EGA,VGA)
538 *
539 * AX = 1112h
540 * BL = block to load
541 * Return:
542 * Nothing
543 */
544 Regs.w.ax = 0x1112;
545 Regs.b.bl = 0x00;
546 Int386(0x10, &Regs, &Regs);
547}

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

◆ PcVideoSetMemoryBank()

static VOID PcVideoSetMemoryBank ( USHORT  BankNumber)
static

Definition at line 964 of file pcvideo.c.

965{
966 REGS Regs;
967
968 if (CurrentMemoryBank == BankNumber)
969 return;
970
971 /* Int 10h AX=4F05h
972 * VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL
973 *
974 * AX = 4F05h
975 * BH = subfunction
976 * 00h select video memory window
977 * 01h get video memory window
978 * DX = window address in video memory (in granularity units)
979 * Return:
980 * DX = window address in video memory (in gran. units)
981 * BL = window number
982 * 00h window A
983 * 01h window B.
984 * Return:
985 * AL = 4Fh if function supported
986 * AH = status
987 * 00h successful
988 * 01h failed
989 */
990 Regs.w.ax = 0x4F05;
991 Regs.w.bx = 0x0000;
992 Regs.w.dx = BankNumber;
993 Int386(0x10, &Regs, &Regs);
994
995 if (Regs.w.ax == 0x004F)
996 CurrentMemoryBank = BankNumber;
997}
static ULONG CurrentMemoryBank
Definition: pcvideo.c:124
unsigned short dx
Definition: pcbios.h:116

Referenced by PcVideoCopyOffScreenBufferToVRAM().

◆ PcVideoSetMode()

static BOOLEAN PcVideoSetMode ( USHORT  NewMode)
static

Definition at line 864 of file pcvideo.c.

865{
867
868 /* Set the values for the default text modes
869 * If they are setting a graphics mode then
870 * these values will be changed. */
871 BiosVideoMode = NewMode;
872 ScreenWidth = 80;
873 ScreenHeight = 25;
877
878 switch (NewMode)
879 {
881 case 0x03: /* BIOS 80x25 text mode number */
882 return PcVideoSetMode80x25();
885 case VIDEOMODE_80X28:
886 return PcVideoSetMode80x28();
887 case VIDEOMODE_80X30:
888 return PcVideoSetMode80x30();
889 case VIDEOMODE_80X34:
890 return PcVideoSetMode80x34();
891 case VIDEOMODE_80X43:
892 return PcVideoSetMode80x43();
893 case VIDEOMODE_80X60:
894 return PcVideoSetMode80x60();
895 }
896
897 if (NewMode == 0x12)
898 {
899 /* 640x480x16 */
900 PcVideoSetBiosMode((UCHAR)NewMode);
901 WRITE_PORT_USHORT((USHORT*)0x03CE, 0x0F01); /* For some reason this is necessary? */
902 ScreenWidth = 640;
903 ScreenHeight = 480;
904 BytesPerScanLine = 80; // 8 pixels per byte (4 planes)
905 BiosVideoMode = NewMode;
907 }
908 else if (NewMode == 0x13)
909 {
910 /* 320x200x256 */
911 PcVideoSetBiosMode((UCHAR)NewMode);
912 ScreenWidth = 320;
913 ScreenHeight = 200;
914 BytesPerScanLine = 320; // 1 pixel per byte
915 BiosVideoMode = NewMode;
917 }
918 else
919 {
920 /* VESA Text/Graphics Mode */
922 return FALSE;
923
924 if (!PcVideoSetBiosVesaMode(NewMode))
925 return FALSE;
926
930 BiosVideoMode = NewMode;
931 DisplayMode = (0x0108 <= NewMode && NewMode <= 0x010C) ? VideoTextMode : VideoGraphicsMode;
933 }
934
935 return TRUE;
936}
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:816
#define VIDEOMODE_80X34
Definition: pcvideo.c:42
#define VIDEOMODE_80X43
Definition: pcvideo.c:43
static BOOLEAN PcVideoSetMode80x60(VOID)
Definition: pcvideo.c:847
static BOOLEAN PcVideoSetMode80x30(VOID)
Definition: pcvideo.c:804
#define VIDEOMODE_80X60
Definition: pcvideo.c:44
#define VIDEOMODE_80X30
Definition: pcvideo.c:41
static VOID PcVideoSetBiosMode(UCHAR VideoMode)
Definition: pcvideo.c:510
static BOOLEAN PcVideoSetMode80x43(VOID)
Definition: pcvideo.c:831
static BOOLEAN PcVideoSetBiosVesaMode(USHORT Mode)
Definition: pcvideo.c:444
static BOOLEAN PcVideoSetMode80x50_80x43(VOID)
Definition: pcvideo.c:759
static BOOLEAN PcVideoSetMode80x28(VOID)
Definition: pcvideo.c:791

Referenced by PcVideoInit(), and PcVideoSetDisplayMode().

◆ PcVideoSetMode80x25()

static BOOLEAN PcVideoSetMode80x25 ( VOID  )
static

◆ PcVideoSetMode80x28()

static BOOLEAN PcVideoSetMode80x28 ( VOID  )
static

Definition at line 791 of file pcvideo.c.

792{
793 /* FIXME: Is this VGA-only? */
796 PcVideoDefineCursor(11, 12);
797 ScreenWidth = 80;
798 ScreenHeight = 28;
800 return TRUE;
801}
static VOID PcVideoSetFont8x14(VOID)
Definition: pcvideo.c:550

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x30()

static BOOLEAN PcVideoSetMode80x30 ( VOID  )
static

Definition at line 804 of file pcvideo.c.

805{
806 /* FIXME: Is this VGA-only? */
809 ScreenWidth = 80;
810 ScreenHeight = 30;
812 return TRUE;
813}
static VOID PcVideoSet480ScanLines(VOID)
Definition: pcvideo.c:680

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x34()

static BOOLEAN PcVideoSetMode80x34 ( VOID  )
static

Definition at line 816 of file pcvideo.c.

817{
818 /* FIXME: Is this VGA-only? */
822 PcVideoDefineCursor(11, 12);
824 ScreenWidth = 80;
825 ScreenHeight = 34;
827 return TRUE;
828}
static VOID PcVideoSetDisplayEnd(VOID)
Definition: pcvideo.c:732

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x43()

static BOOLEAN PcVideoSetMode80x43 ( VOID  )
static

Definition at line 831 of file pcvideo.c.

832{
833 /* FIXME: Is this VGA-only? */
840 ScreenWidth = 80;
841 ScreenHeight = 43;
843 return TRUE;
844}
static VOID PcVideoDisableCursorEmulation(VOID)
Definition: pcvideo.c:592
static VOID PcVideoSetFont8x8(VOID)
Definition: pcvideo.c:532
static VOID PcVideoSetVerticalResolution(UCHAR VerticalResolutionMode)
Definition: pcvideo.c:653
static VOID PcVideoSelectAlternatePrintScreen(VOID)
Definition: pcvideo.c:568
#define VERTRES_350_SCANLINES
Definition: pcvideo.c:52

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x50_80x43()

static BOOLEAN PcVideoSetMode80x50_80x43 ( VOID  )
static

Definition at line 759 of file pcvideo.c.

760{
762 {
763 PcVideoSetBiosMode(0x03);
768 ScreenWidth = 80;
769 ScreenHeight = 50;
770 }
771 else if (VideoCard == VIDEOCARD_EGA)
772 {
773 PcVideoSetBiosMode(0x03);
778 ScreenWidth = 80;
779 ScreenHeight = 43;
780 }
781 else /* VIDEOCARD_CGA_OR_OTHER */
782 {
783 return FALSE;
784 }
786
787 return TRUE;
788}

Referenced by PcVideoSetMode().

◆ PcVideoSetMode80x60()

static BOOLEAN PcVideoSetMode80x60 ( VOID  )
static

Definition at line 847 of file pcvideo.c.

848{
849 /* FIXME: Is this VGA-only? */
857 ScreenWidth = 80;
858 ScreenHeight = 60;
860 return TRUE;
861}

Referenced by PcVideoSetMode().

◆ PcVideoSetPaletteColor()

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

Definition at line 1247 of file pcvideo.c.

Referenced by MachInit().

◆ PcVideoSetTextCursorPosition()

VOID PcVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 1141 of file pcvideo.c.

1142{
1143 REGS Regs;
1144
1145 /* Int 10h AH=02h
1146 * VIDEO - SET CURSOR POSITION
1147 *
1148 * AH = 02h
1149 * BH = page number
1150 * 0-3 in modes 2&3
1151 * 0-7 in modes 0&1
1152 * 0 in graphics modes
1153 * DH = row (00h is top)
1154 * DL = column (00h is left)
1155 * Return:
1156 * Nothing
1157 */
1158 Regs.b.ah = 0x02;
1159 Regs.b.bh = 0x00;
1160 Regs.b.dh = Y;
1161 Regs.b.dl = X;
1162 Int386(0x10, &Regs, &Regs);
1163}
#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 653 of file pcvideo.c.

654{
655 REGS Regs;
656
657 /* Int 10h AH=12h BL=30h
658 * VIDEO - ALTERNATE FUNCTION SELECT (VGA) - SELECT VERTICAL RESOLUTION
659 *
660 * AH = 12h
661 * BL = 30h
662 * AL = vertical resolution
663 * 00h 200 scan lines
664 * 01h 350 scan lines
665 * 02h 400 scan lines
666 * Return:
667 * AL = 12h if function supported
668 *
669 * Specify the number of scan lines used to display text modes.
670 *
671 * The specified resolution will take effect on the next mode set.
672 */
673 Regs.b.ah = 0x12;
674 Regs.b.bl = 0x30;
675 Regs.b.al = VerticalResolutionMode;
676 Int386(0x10, &Regs, &Regs);
677}

Referenced by PcVideoSetMode80x43().

◆ PcVideoSync()

VOID PcVideoSync ( VOID  )

Definition at line 1265 of file pcvideo.c.

1266{
1268 {
1269 /*
1270 * Keep reading the port until bit 3 is clear
1271 * This waits for the current retrace to end and
1272 * we can catch the next one so we know we are
1273 * getting a full retrace.
1274 */
1275 }
1276
1278 {
1279 /*
1280 * Keep reading the port until bit 3 is set
1281 * Now that we know we aren't doing a vertical
1282 * retrace we need to wait for the next one.
1283 */
1284 }
1285}
#define VIDEOPORT_VERTICAL_RETRACE
Definition: pcvideo.c:28

Referenced by MachInit().

◆ PcVideoVesaGetCurrentSVGAMode()

static BOOLEAN PcVideoVesaGetCurrentSVGAMode ( _Out_ PUSHORT  Mode)
static

Definition at line 299 of file pcvideo.c.

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

Referenced by PcVideoGetDisplayMode().

◆ PcVideoVesaGetSVGAModeInformation()

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

Definition at line 208 of file pcvideo.c.

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

Referenced by PcVideoGetDisplayMode(), and PcVideoSetMode().

◆ BytesPerScanLine

◆ CurrentMemoryBank

ULONG CurrentMemoryBank = 0
static

Definition at line 124 of file pcvideo.c.

Referenced by PcVideoSetMemoryBank(), and PcVideoSetMode().

◆ DisplayMode

◆ MachDefaultTextColor

UCHAR MachDefaultTextColor = COLOR_GRAY

Definition at line 114 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 116 of file pcvideo.c.

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