ReactOS 0.4.15-dev-7953-g1f49173
vidbios.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include <reactos/buildno.h>
#include <reactos/version.h>
#include "emulator.h"
#include "cpu/cpu.h"
#include "cpu/bop.h"
#include "memory.h"
#include "bios.h"
#include "bios32/bios32p.h"
#include "rom.h"
#include "bios32/vbe.h"
#include "bios32/vidbios32.h"
#include "io.h"
#include "hardware/video/svga.h"
#include "../console/video.h"
Include dependency graph for vidbios.c:

Go to the source code of this file.

Classes

struct  _VGA_MODE
 

Macros

#define NDEBUG
 
#define USE_REACTOS_COLORS
 
#define IS_TEXT_MODE(ModeNumber)    (((ModeNumber) >= 0x00 && (ModeNumber) <= 0x03) || ((ModeNumber) == 0x07))
 

Typedefs

typedef struct _VGA_MODE VGA_MODE
 
typedef struct _VGA_MODEPVGA_MODE
 

Functions

 C_ASSERT (sizeof(BiosInfo) -1<=0xFF-0x05)
 
static BOOLEAN VidBiosScrollWindow (SCROLL_DIRECTION Direction, DWORD Amount, SMALL_RECT Rectangle, BYTE Page, BYTE FillAttribute)
 
static __inline VOID VgaSetSinglePaletteRegister (BYTE Index, BYTE Value)
 
static BOOLEAN VgaSetRegisters (PVGA_REGISTERS Registers)
 
static VOID VgaSetPalette (const COLORREF *Palette, ULONG Size)
 
static VOID VgaChangePalette (BYTE ModeNumber)
 
static __inline VOID VidBiosGetCursorPosition (PBYTE Row, PBYTE Column, BYTE Page)
 
static VOID VidBiosSetCursorPosition (BYTE Row, BYTE Column, BYTE Page)
 
static VOID VidBiosSetCursorShape (WORD CursorStartEnd)
 
static VOID VidBiosSyncCursorPosition (VOID)
 
static BYTE VidBiosGetVideoMode (VOID)
 
static VOID VidBiosClearScreen (VOID)
 
static BOOLEAN VidBiosSetVideoMode (BYTE ModeNumber)
 
static BOOLEAN VidBiosSetVideoPage (BYTE PageNumber)
 
static VOID VidBiosDrawGlyph (WORD CharData, BOOLEAN UseAttr, BYTE Page, BYTE Row, BYTE Column)
 
static VOID VidBiosPrintCharacter (CHAR Character, BYTE Attribute, BOOLEAN UseAttr, BYTE Page)
 
VOID WINAPI VidBiosVideoService (LPWORD Stack)
 
VOID VidBiosAttachToConsole (VOID)
 
VOID VidBiosDetachFromConsole (VOID)
 
VOID VidBiosPost (VOID)
 
BOOLEAN VidBiosInitialize (VOID)
 
VOID VidBiosCleanup (VOID)
 

Variables

static const CHAR BiosInfo []
 
static VGA_REGISTERS VideoMode_40x25_text
 
static VGA_REGISTERS VideoMode_80x25_text
 
static VGA_REGISTERS VideoMode_320x200_4color
 
static VGA_REGISTERS VideoMode_640x200_2color
 
static VGA_REGISTERS VideoMode_320x200_16color
 
static VGA_REGISTERS VideoMode_640x200_16color
 
static VGA_REGISTERS VideoMode_640x350_16color
 
static VGA_REGISTERS VideoMode_640x480_2color
 
static VGA_REGISTERS VideoMode_640x480_16color
 
static VGA_REGISTERS VideoMode_320x200_256color
 
static CONST COLORREF EgaPalette__16Colors [VGA_MAX_COLORS/4]
 
static CONST COLORREF EgaPalette__HiRes [VGA_MAX_COLORS/4]
 
static CONST COLORREF VgaPalette [VGA_MAX_COLORS]
 
static CONST UCHAR Font8x8 [VGA_FONT_CHARACTERS *8]
 
static CONST UCHAR Font8x14 [VGA_FONT_CHARACTERS *14]
 
static CONST UCHAR Font8x16 [VGA_FONT_CHARACTERS *16]
 
static CONST VGA_MODE VideoModes [BIOS_MAX_VIDEO_MODE+1]
 
static PVGA_STATIC_FUNC_TABLE VgaStaticFuncTable
 
static BOOLEAN VbeInitialized = FALSE
 
static BOOL Attached = TRUE
 

Macro Definition Documentation

◆ IS_TEXT_MODE

#define IS_TEXT_MODE (   ModeNumber)     (((ModeNumber) >= 0x00 && (ModeNumber) <= 0x03) || ((ModeNumber) == 0x07))

Definition at line 1965 of file vidbios.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file vidbios.c.

◆ USE_REACTOS_COLORS

#define USE_REACTOS_COLORS

Definition at line 479 of file vidbios.c.

Typedef Documentation

◆ PVGA_MODE

◆ VGA_MODE

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(BiosInfo) -1<=0xFF-  0x05)

◆ VgaChangePalette()

static VOID VgaChangePalette ( BYTE  ModeNumber)
static

Definition at line 2272 of file vidbios.c.

2273{
2274 const COLORREF* Palette;
2275 ULONG Size;
2276
2277 if (ModeNumber >= 0x13)
2278 {
2279 /* VGA modes */
2280 Palette = VgaPalette;
2282 }
2283 else if (ModeNumber == 0x10) // || (ModeNumber == 0x0D) || (ModeNumber == 0x0E)
2284 {
2285 /* EGA HiRes mode */
2286 Palette = EgaPalette__HiRes;
2288 }
2289#if 0
2290 else if ((ModeNumber == 0x04) || (ModeNumber == 0x05))
2291 {
2292 /*
2293 * CGA modes; this palette contains both normal and
2294 * bright versions of CGA palettes 0 and 1
2295 */
2296 Palette = CgaPalette2;
2297 Size = ARRAYSIZE(CgaPalette2);
2298 }
2299#endif
2300 else // if ((ModeNumber == 0x0D) || (ModeNumber == 0x0E))
2301 {
2302 /* EGA modes */
2303 Palette = EgaPalette__16Colors;
2305 }
2306
2307 VgaSetPalette(Palette, Size);
2308}
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
uint32_t ULONG
Definition: typedefs.h:59
static VOID VgaSetPalette(const COLORREF *Palette, ULONG Size)
Definition: vidbios.c:2242
static CONST COLORREF EgaPalette__HiRes[VGA_MAX_COLORS/4]
Definition: vidbios.c:455
static CONST COLORREF VgaPalette[VGA_MAX_COLORS]
Definition: vidbios.c:488
static CONST COLORREF EgaPalette__16Colors[VGA_MAX_COLORS/4]
Definition: vidbios.c:423
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
DWORD COLORREF
Definition: windef.h:300

Referenced by VidBiosSetVideoMode().

◆ VgaSetPalette()

static VOID VgaSetPalette ( const COLORREF Palette,
ULONG  Size 
)
static

Definition at line 2242 of file vidbios.c.

2243{
2244 ULONG i;
2245
2246 // /* Disable screen and enable palette access */
2247 // IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
2248 // IOWriteB(VGA_AC_INDEX, 0x00);
2249
2250 for (i = 0; i < Size; i++)
2251 {
2256 }
2257
2258 /* The following step might be optional */
2259 for (i = Size; i < VGA_MAX_COLORS; i++)
2260 {
2265 }
2266
2267 /* Enable screen and disable palette access */
2268 // IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
2269 // IOWriteB(VGA_AC_INDEX, 0x20);
2270}
#define GetBValue(quad)
Definition: precomp.h:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
#define VGA_COLOR_TO_DAC(x)
Definition: svga.h:22
#define VGA_DAC_DATA
Definition: svga.h:61
#define VGA_DAC_WRITE_INDEX
Definition: svga.h:60
#define VGA_MAX_COLORS
Definition: svga.h:16

Referenced by VgaChangePalette().

◆ VgaSetRegisters()

static BOOLEAN VgaSetRegisters ( PVGA_REGISTERS  Registers)
static

Definition at line 2147 of file vidbios.c.

2148{
2149 UINT i;
2150
2151 if (Registers == NULL) return FALSE;
2152
2153 /* Disable interrupts */
2154 setIF(0);
2155
2156 /*
2157 * Set the CRT base address according to the selected mode,
2158 * monochrome or color. The following macros:
2159 * VGA_INSTAT1_READ, VGA_CRTC_INDEX and VGA_CRTC_DATA are then
2160 * used to access the correct VGA I/O ports.
2161 */
2162 Bda->CrtBasePort = (Registers->Misc & 0x01) ? VGA_CRTC_INDEX_COLOR
2164 /* Bit 1 indicates whether display is color (0) or monochrome (1) */
2165 Bda->VGAOptions = (Bda->VGAOptions & 0xFD) | (!(Registers->Misc & 0x01) << 1);
2166 Bda->CrtModeControl = (Bda->CrtModeControl & 0xFB) | (!(Registers->Misc & 0x01) << 1);
2167
2168 /* Update blink bit in BDA */
2170 Bda->CrtModeControl |= (1 << 5);
2171 else
2172 Bda->CrtModeControl &= ~(1 << 5);
2173
2174 /* Turn the video off */
2177
2178 /* Write the misc register */
2179 IOWriteB(VGA_MISC_WRITE, Registers->Misc);
2180
2181 /* Synchronous reset on */
2184
2185 /* Write the sequencer registers */
2186 for (i = 1; i < VGA_SEQ_MAX_REG; i++)
2187 {
2189 IOWriteB(VGA_SEQ_DATA , Registers->Sequencer[i]);
2190 }
2191
2192 /* Synchronous reset off */
2195
2196 /* Unlock CRTC registers 0-7 */
2201 // Make sure they remain unlocked
2202 Registers->CRT[VGA_CRTC_END_HORZ_BLANKING_REG] |= 0x80;
2203 Registers->CRT[VGA_CRTC_END_VERT_RETRACE_REG] &= ~0x80;
2204
2205 /* Write the CRTC registers */
2206 for (i = 0; i < VGA_CRTC_MAX_REG; i++)
2207 {
2209 IOWriteB(VGA_CRTC_DATA , Registers->CRT[i]);
2210 }
2211
2212 /* Write the GC registers */
2213 for (i = 0; i < VGA_GC_MAX_REG; i++)
2214 {
2216 IOWriteB(VGA_GC_DATA , Registers->Graphics[i]);
2217 }
2218
2219 /* Write the AC registers */
2220 for (i = 0; i < VGA_AC_MAX_REG; i++)
2221 {
2223 }
2224
2225 /* Set the PEL mask */
2226 IOWriteB(VGA_DAC_MASK, 0xFF);
2227
2228 /* Enable screen and disable palette access */
2229 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
2230 IOWriteB(VGA_AC_INDEX, 0x20);
2231
2232 /* Turn the video on */
2235
2236 /* Enable interrupts */
2237 setIF(1);
2238
2239 return TRUE;
2240}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int UINT
Definition: ndis.h:50
BYTE CrtModeControl
Definition: bios.h:68
WORD CrtBasePort
Definition: bios.h:67
BYTE VGAOptions
Definition: bios.h:91
UCHAR CRT[24]
Definition: blue.c:46
UCHAR Attribute[21]
Definition: blue.c:47
UCHAR Sequencer[5]
Definition: blue.c:49
UCHAR Misc
Definition: blue.c:50
UCHAR Graphics[9]
Definition: blue.c:48
PBIOS_DATA_AREA Bda
Definition: bios.c:42
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
#define VGA_SEQ_DATA
Definition: svga.h:56
#define VGA_DAC_MASK
Definition: svga.h:58
#define VGA_GC_DATA
Definition: svga.h:69
#define VGA_SEQ_INDEX
Definition: svga.h:55
#define VGA_MISC_WRITE
Definition: svga.h:40
#define VGA_AC_INDEX
Definition: svga.h:51
#define VGA_CRTC_INDEX_COLOR
Definition: svga.h:65
@ VGA_CRTC_END_VERT_RETRACE_REG
Definition: svga.h:220
@ VGA_CRTC_MAX_REG
Definition: svga.h:228
@ VGA_CRTC_END_HORZ_BLANKING_REG
Definition: svga.h:206
#define VGA_CRTC_INDEX_MONO
Definition: svga.h:63
@ VGA_SEQ_MAX_REG
Definition: svga.h:136
@ VGA_SEQ_CLOCK_REG
Definition: svga.h:132
@ VGA_SEQ_RESET_REG
Definition: svga.h:131
@ VGA_GC_MAX_REG
Definition: svga.h:277
@ VGA_AC_MAX_REG
Definition: svga.h:362
@ VGA_AC_CONTROL_REG
Definition: svga.h:357
#define VGA_AC_CONTROL_BLINK
Definition: svga.h:334
#define VGA_GC_INDEX
Definition: svga.h:68
#define VGA_SEQ_CLOCK_SD
Definition: svga.h:108
#define VGA_SEQ_RESET_SR
Definition: svga.h:101
#define VGA_SEQ_RESET_AR
Definition: svga.h:100
VOID WINAPI setIF(ULONG)
Definition: registers.c:643
static __inline VOID VgaSetSinglePaletteRegister(BYTE Index, BYTE Value)
Definition: vidbios.c:2137
#define VGA_INSTAT1_READ
Definition: vidbios.h:113
#define VGA_CRTC_DATA
Definition: vidbios.h:115
#define VGA_CRTC_INDEX
Definition: vidbios.h:114

Referenced by VidBiosSetVideoMode().

◆ VgaSetSinglePaletteRegister()

static __inline VOID VgaSetSinglePaletteRegister ( BYTE  Index,
BYTE  Value 
)
static

Definition at line 2137 of file vidbios.c.

2138{
2139 /* Write the index */
2140 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
2142
2143 /* Write the data */
2145}
#define VGA_AC_WRITE
Definition: svga.h:52
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by VgaSetRegisters(), and VidBiosVideoService().

◆ VidBiosAttachToConsole()

VOID VidBiosAttachToConsole ( VOID  )

Definition at line 3907 of file vidbios.c.

3908{
3909 if (!Attached)
3910 {
3912 Attached = TRUE;
3913 }
3914
3915 /* Refresh display */
3918}
BOOL VgaAttachToConsole(VOID)
Definition: video.c:496
VOID VgaRefreshDisplay(VOID)
Definition: svga.c:1783
static VOID VidBiosSyncCursorPosition(VOID)
Definition: vidbios.c:2381
static BOOL Attached
Definition: vidbios.c:3905

Referenced by DosProcessConsoleAttach().

◆ VidBiosCleanup()

VOID VidBiosCleanup ( VOID  )

Definition at line 4036 of file vidbios.c.

4037{
4038}

◆ VidBiosClearScreen()

static VOID VidBiosClearScreen ( VOID  )
inlinestatic

Definition at line 2409 of file vidbios.c.

2410{
2411 static const DWORD MemoryMaps[4] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
2412 static const DWORD MemorySizes[4] = { 0x20000, 0x10000, 0x08000, 0x08000 };
2413
2414 DWORD VideoAddress;
2416 BYTE Misc;
2417 BYTE Buffer[0x20000];
2418
2419 /* Read the misc register */
2421 Misc = IOReadB(VGA_GC_DATA);
2422
2423 /* Get the video address and buffer size */
2424 VideoAddress = MemoryMaps[(Misc >> 2) & 3];
2425 BufferSize = MemorySizes[(Misc >> 2) & 3];
2426
2427 // !IS_TEXT_MODE(Bda->VideoMode)
2428 if (Misc & 1)
2429 {
2430 /* Graphics mode */
2432 }
2433 else
2434 {
2435 /* Text mode */
2436 UINT i;
2437 for (i = 0; i < (BufferSize >> 1); i++)
2438 {
2440 }
2441 }
2442
2443 /* Write to video memory */
2445}
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD * PWORD
Definition: pedump.c:67
FAST486_STATE EmulatorContext
Definition: cpu.c:39
VOID FASTCALL EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
Definition: memory.c:186
@ VGA_GC_MISC_REG
Definition: svga.h:274
#define MAKEWORD(a, b)
Definition: typedefs.h:248
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DEFAULT_ATTRIBUTE
Definition: vidbios.h:21
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
unsigned char BYTE
Definition: xxhash.c:193

Referenced by VidBiosSetVideoMode().

◆ VidBiosDetachFromConsole()

VOID VidBiosDetachFromConsole ( VOID  )

Definition at line 3920 of file vidbios.c.

3921{
3922 if (!Attached) return;
3923
3924 /* Refresh display */
3926
3927 /* Detach from the console */
3929 Attached = FALSE;
3930}
VOID VgaDetachFromConsole(VOID)
Definition: video.c:537

Referenced by DosProcessConsoleDetach().

◆ VidBiosDrawGlyph()

static VOID VidBiosDrawGlyph ( WORD  CharData,
BOOLEAN  UseAttr,
BYTE  Page,
BYTE  Row,
BYTE  Column 
)
static

Definition at line 2619 of file vidbios.c.

2620{
2621 switch (Bda->VideoMode)
2622 {
2623 /* Alphanumeric mode */
2624 case 0x00:
2625 case 0x01:
2626 case 0x02:
2627 case 0x03:
2628 case 0x07:
2629 {
2633 (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
2634 (LPVOID)&CharData,
2635 UseAttr ? sizeof(WORD) : sizeof(BYTE));
2636 break;
2637 }
2638
2639 /* 4-color CGA */
2640 case 0x04:
2641 case 0x05:
2642 {
2643 WORD i;
2644 WORD CgaSegment[] = { CGA_EVEN_VIDEO_SEG, CGA_ODD_VIDEO_SEG };
2646 PUCHAR Glyph = &Font[LOBYTE(CharData) * Bda->CharacterHeight];
2647 BOOLEAN Xor = (HIBYTE(CharData) & 0x80) ? TRUE : FALSE;
2648 BYTE OldRotate;
2649 BYTE DoubledBits[] =
2650 {
2651 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F,
2652 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF
2653 };
2654
2655 if (Xor)
2656 {
2657 /* Set the logical operation to XOR */
2659 OldRotate = IOReadB(VGA_GC_DATA);
2660 IOWriteB(VGA_GC_DATA, OldRotate | 0x18);
2661 }
2662
2663 for (i = 0; i < Bda->CharacterHeight; i++)
2664 {
2665 WORD Pixel = MAKEWORD(DoubledBits[Glyph[i] >> 4],
2666 DoubledBits[Glyph[i] & 0x0F]);
2667 if (Xor)
2668 {
2669 USHORT Dummy;
2670
2671 /* Read from VGA memory to load the latch register */
2673 TO_LINEAR(CgaSegment[(Row * Bda->CharacterHeight + i) & 1],
2674 (((Row * Bda->CharacterHeight + i) >> 1)
2675 * Bda->ScreenColumns + Column) * 2),
2676 (LPVOID)&Dummy,
2677 sizeof(USHORT));
2678 }
2679
2681 TO_LINEAR(CgaSegment[(Row * Bda->CharacterHeight + i) & 1],
2682 (((Row * Bda->CharacterHeight + i) >> 1)
2683 * Bda->ScreenColumns + Column) * 2),
2684 (LPVOID)&Pixel,
2685 sizeof(USHORT));
2686 }
2687
2688 if (Xor)
2689 {
2691 IOWriteB(VGA_GC_DATA, OldRotate);
2692 }
2693
2694 break;
2695 }
2696
2697 /* 2-color CGA */
2698 case 0x06:
2699 {
2700 WORD i;
2701 WORD CgaSegment[] = { CGA_EVEN_VIDEO_SEG, CGA_ODD_VIDEO_SEG };
2703 PUCHAR Glyph = &Font[LOBYTE(CharData) * Bda->CharacterHeight];
2704 BOOLEAN Xor = (HIBYTE(CharData) & 0x80) ? TRUE : FALSE;
2705 BYTE OldRotate;
2706
2707 if (Xor)
2708 {
2709 /* Set the logical operation to XOR */
2711 OldRotate = IOReadB(VGA_GC_DATA);
2712 IOWriteB(VGA_GC_DATA, OldRotate | 0x18);
2713 }
2714
2715 for (i = 0; i < Bda->CharacterHeight; i++)
2716 {
2717 if (Xor)
2718 {
2719 UCHAR Dummy;
2720
2721 /* Read from VGA memory to load the latch register */
2723 TO_LINEAR(CgaSegment[(Row * Bda->CharacterHeight + i) & 1],
2724 (((Row * Bda->CharacterHeight + i) >> 1)
2725 * Bda->ScreenColumns) + Column),
2726 (LPVOID)&Dummy,
2727 sizeof(UCHAR));
2728 }
2729
2731 TO_LINEAR(CgaSegment[(Row * Bda->CharacterHeight + i) & 1],
2732 (((Row * Bda->CharacterHeight + i) >> 1)
2733 * Bda->ScreenColumns) + Column),
2734 (LPVOID)&Glyph[i],
2735 sizeof(UCHAR));
2736 }
2737
2738 if (Xor)
2739 {
2741 IOWriteB(VGA_GC_DATA, OldRotate);
2742 }
2743
2744 break;
2745 }
2746
2747 /* 16-color modes */
2748 case 0x0D:
2749 case 0x0E:
2750 case 0x10:
2751 case 0x11:
2752 case 0x12:
2753 {
2754 WORD i;
2756 PUCHAR Glyph = &Font[LOBYTE(CharData) * Bda->CharacterHeight];
2757 BOOLEAN Xor = (HIBYTE(CharData) & 0x80) ? TRUE : FALSE;
2758 BYTE OldPlaneWrite, OldReset, OldEnableReset, OldRotate, OldMode;
2759
2760 /* Write to all planes */
2762 OldPlaneWrite = IOReadB(VGA_SEQ_DATA);
2763 IOWriteB(VGA_SEQ_DATA, 0x0F);
2764
2765 /* Zero the planes whose bits are set in the enable set/reset register */
2767 OldReset = IOReadB(VGA_GC_DATA);
2768 IOWriteB(VGA_GC_DATA, 0x00);
2769
2770 /* Set the enable set/reset register to the inverse of the color */
2772 OldEnableReset = IOReadB(VGA_GC_DATA);
2773 IOWriteB(VGA_GC_DATA, (~HIBYTE(CharData)) & 0x0F);
2774
2775 /* Make sure we're in write mode 0 */
2777 OldMode = IOReadB(VGA_GC_DATA);
2778 IOWriteB(VGA_GC_DATA, 0x00);
2779
2780 if (Xor)
2781 {
2782 /* Set the logical operation to XOR */
2784 OldRotate = IOReadB(VGA_GC_DATA);
2785 IOWriteB(VGA_GC_DATA, OldRotate | 0x18);
2786 }
2787
2788 for (i = 0; i < Bda->CharacterHeight; i++)
2789 {
2790 if (Xor)
2791 {
2792 UCHAR Dummy;
2793
2794 /* Read from VGA memory to load the latch register */
2797 ((Row * Bda->CharacterHeight + i)
2798 * Bda->ScreenColumns) + Column),
2799 (LPVOID)&Dummy,
2800 sizeof(UCHAR));
2801 }
2802
2805 ((Row * Bda->CharacterHeight + i)
2806 * Bda->ScreenColumns) + Column),
2807 (LPVOID)&Glyph[i],
2808 sizeof(UCHAR));
2809 }
2810
2811 /* Restore the registers */
2813 IOWriteB(VGA_SEQ_DATA, OldPlaneWrite);
2815 IOWriteB(VGA_GC_DATA, OldReset);
2817 IOWriteB(VGA_GC_DATA, OldEnableReset);
2819 IOWriteB(VGA_GC_DATA, OldMode);
2820
2821 if (Xor)
2822 {
2824 IOWriteB(VGA_GC_DATA, OldRotate);
2825 }
2826
2827 break;
2828 }
2829
2830 /* 256-color mode */
2831 case 0x13:
2832 {
2833 WORD i, j;
2835 PUCHAR Glyph = &Font[LOBYTE(CharData) * Bda->CharacterHeight];
2836 BYTE PixelBuffer[8]; // 8 == CharacterWidth
2837
2838 for (i = 0; i < Bda->CharacterHeight; i++)
2839 {
2840 for (j = 0; j < ARRAYSIZE(PixelBuffer); j++)
2841 {
2842 PixelBuffer[j] = (Glyph[i] & (1 << (7 - j))) ? HIBYTE(CharData) : 0;
2843 }
2844
2847 ((Row * Bda->CharacterHeight + i)
2848 * Bda->ScreenColumns + Column) * 8),
2849 (LPVOID)PixelBuffer,
2850 sizeof(PixelBuffer));
2851 }
2852
2853 break;
2854 }
2855
2856 default:
2857 {
2858 DPRINT1("Drawing glyphs in mode %02Xh is not supported.\n", Bda->VideoMode);
2859 }
2860 }
2861}
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
#define TO_LINEAR(seg, off)
Definition: emulator.h:26
#define FAR_POINTER(x)
Definition: emulator.h:35
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
unsigned short USHORT
Definition: pedump.c:61
WORD VideoPageSize
Definition: bios.h:61
BYTE VideoMode
Definition: bios.h:59
WORD CharacterHeight
Definition: bios.h:90
WORD ScreenColumns
Definition: bios.h:60
VOID FASTCALL EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
Definition: memory.c:142
@ VGA_SEQ_MASK_REG
Definition: svga.h:133
@ VGA_GC_ENABLE_RESET_REG
Definition: svga.h:269
@ VGA_GC_ROTATE_REG
Definition: svga.h:271
@ VGA_GC_RESET_REG
Definition: svga.h:268
@ VGA_GC_MODE_REG
Definition: svga.h:273
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PUCHAR
Definition: typedefs.h:53
#define CGA_EVEN_VIDEO_SEG
Definition: vidbios.h:25
#define GRAPHICS_VIDEO_SEG
Definition: vidbios.h:23
#define TEXT_VIDEO_SEG
Definition: vidbios.h:24
#define CGA_ODD_VIDEO_SEG
Definition: vidbios.h:26
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by VidBiosPrintCharacter(), and VidBiosVideoService().

◆ VidBiosGetCursorPosition()

static __inline VOID VidBiosGetCursorPosition ( PBYTE  Row,
PBYTE  Column,
BYTE  Page 
)
static

Definition at line 2310 of file vidbios.c.

2311{
2312 *Row = HIBYTE(Bda->CursorPosition[Page]);
2313 *Column = LOBYTE(Bda->CursorPosition[Page]);
2314}
WORD CursorPosition[BIOS_MAX_PAGES]
Definition: bios.h:63

Referenced by VidBiosPrintCharacter(), VidBiosSetVideoPage(), and VidBiosVideoService().

◆ VidBiosGetVideoMode()

static BYTE VidBiosGetVideoMode ( VOID  )
inlinestatic

Definition at line 2403 of file vidbios.c.

2404{
2405 /* Bit 7 of VideoMode is determined by bit 7 of VGAOptions */
2406 return Bda->VideoMode | (Bda->VGAOptions & 0x80);
2407}

Referenced by VidBiosVideoService().

◆ VidBiosInitialize()

BOOLEAN VidBiosInitialize ( VOID  )

Definition at line 3981 of file vidbios.c.

3982{
3983 UCHAR Checksum;
3984
3985 /*
3986 * Initialize VGA BIOS32 static data
3987 */
3988
3989 /* This is a ROM of size 'VIDEO_BIOS_ROM_SIZE' */
3990 *(PWORD)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0x0000)) = 0xAA55;
3991 *(PBYTE)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0x0002)) = VIDEO_BIOS_ROM_SIZE / 512; // Size in blocks of 512 bytes
3992
3993 /* Bootstrap code */
3994 *(PWORD)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0x0003)) = 0x90CB; // retf, nop
3995 // RtlCopyMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0xFFF0), Bootstrap, sizeof(Bootstrap));
3996
3997 /* Video BIOS Information */
3999
4000 /* Initialize the VGA static function table */
4003 VgaStaticFuncTable->SupportedModes[0] = 0xFF; // Modes 0x00 to 0x07 supported
4004 VgaStaticFuncTable->SupportedModes[1] = 0xFF; // Modes 0x08 to 0x0F supported
4005 VgaStaticFuncTable->SupportedModes[2] = 0x0F; // Modes 0x10 to 0x13 supported
4006 VgaStaticFuncTable->SupportedScanlines = 0x07; // Scanlines 200, 350 and 400 supported
4009 VgaStaticFuncTable->VGAFuncSupportFlags = 0x0CFD; // See: http://www.ctyme.com/intr/rb-0221.htm#Table46
4010 VgaStaticFuncTable->VGASavePtrFuncFlags = 0x18; // See: http://www.ctyme.com/intr/rb-0221.htm#Table47
4011
4012 /* Fill the font tables */
4014 Font8x8, sizeof(Font8x8));
4016 Font8x16, sizeof(Font8x16));
4018 Font8x14, sizeof(Font8x14));
4019
4020 /* Make another copy of the lower half of the 8x8 font at F000:FA6E for compatibility */
4022
4024
4025 /* Compute the ROM checksum and store it */
4028 *(PBYTE)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, VIDEO_BIOS_ROM_SIZE - 1)) = (0xFF - Checksum + 1) & 0xFF;
4029
4032
4033 return TRUE;
4034}
#define BIOS_SEGMENT
Definition: bios.h:29
#define SEG_OFF_TO_PTR(seg, off)
Definition: emulator.h:32
BYTE * PBYTE
Definition: pedump.c:66
UCHAR CalcRomChecksum(IN ULONG RomLocation, IN ULONG RomSize)
Definition: rom.c:153
BOOLEAN WriteProtectRom(IN PVOID RomLocation, IN ULONG RomSize)
Definition: rom.c:138
BYTE MaxActiveTextCharBlocksNumber
Definition: vidbios.h:56
BYTE SupportedModes[3]
Definition: vidbios.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
BOOLEAN VidBios32Initialize(VOID)
Definition: vidbios32.c:60
static PVGA_STATIC_FUNC_TABLE VgaStaticFuncTable
Definition: vidbios.c:1968
static CONST UCHAR Font8x8[VGA_FONT_CHARACTERS *8]
Definition: vidbios.c:632
static CONST UCHAR Font8x14[VGA_FONT_CHARACTERS *14]
Definition: vidbios.c:892
static const CHAR BiosInfo[]
Definition: vidbios.c:44
static CONST UCHAR Font8x16[VGA_FONT_CHARACTERS *16]
Definition: vidbios.c:1408
#define FONT_8x14_OFFSET
Definition: vidbios.h:32
#define VIDEO_STATE_INFO_OFFSET
Definition: vidbios.h:36
#define FONT_8x16_OFFSET
Definition: vidbios.h:31
#define FONT_8x8_OFFSET
Definition: vidbios.h:29
#define VIDEO_BIOS_ROM_SIZE
Definition: vidbios.h:38
#define VIDEO_BIOS_DATA_SEG
Definition: vidbios.h:27
#define FONT_8x8_COMPAT_OFFSET
Definition: vidbios.h:34

Referenced by Bios32Initialize().

◆ VidBiosPost()

VOID VidBiosPost ( VOID  )

Definition at line 3932 of file vidbios.c.

3933{
3934 /*
3935 * Initialize VGA BIOS32 RAM dynamic data
3936 */
3937
3938 /* Some vectors are in fact addresses to tables */
3939 ((PULONG)BaseAddress)[0x1D] = NULL32; // Video Parameter Tables
3940 // Far pointer to the 8x8 graphics font for the 8x8 characters 80h-FFh
3942 // Far pointer to the character table (EGA, MCGA, VGA) for the 8x16 characters 00h-...
3944 ((PULONG)BaseAddress)[0x44] = NULL32; // ROM BIOS Character Font, Characters 00h-7Fh (PCjr)
3945
3946 /* Relocated services by the BIOS (when needed) */
3947 ((PULONG)BaseAddress)[0x42] = NULL32; // Relocated Default INT 10h Video Services
3948 ((PULONG)BaseAddress)[0x6D] = NULL32; // Video BIOS Entry Point
3949
3950 //
3951 // FIXME: At the moment we always set a VGA mode. In the future,
3952 // we should set this mode **only** when:
3953 // - an app starts to use directly the video memory
3954 // (that should be done in emulator.c)
3955 // - or starts to use non-stream I/O interrupts
3956 // (that should be done here, or maybe in VGA ??)
3957 //
3958
3959 Bda->CrtModeControl = 0x00;
3960 Bda->CrtColorPaletteMask = 0x00;
3961 Bda->VGADccIDActive = 0x08; // VGA w/ color analog active display
3962
3963 /* Set the default video mode */
3965
3966 /* Synchronize our cursor position with VGA */
3968
3969 /* Register the BIOS 32-bit Interrupts */
3971
3972 /* Vectors that should be implemented */
3973 RegisterBiosInt32(0x42, NULL); // Relocated Default INT 10h Video Services
3974 RegisterBiosInt32(0x6D, NULL); // Video BIOS Entry Point
3975
3976 /* Initialize VBE */
3978 if (!VbeInitialized) DPRINT1("Couldn't initialize VBE!\n");
3979}
#define RegisterBiosInt32(IntNumber, IntHandler)
Definition: bios32p.h:34
#define NULL32
Definition: emulator.h:21
BYTE CrtColorPaletteMask
Definition: bios.h:69
BYTE VGADccIDActive
Definition: bios.h:94
BOOLEAN VbeInitialize(VOID)
Definition: vbe.c:763
#define MAKELONG(a, b)
Definition: typedefs.h:249
static BOOLEAN VbeInitialized
Definition: vidbios.c:1969
static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber)
Definition: vidbios.c:2447
VOID WINAPI VidBiosVideoService(LPWORD Stack)
Definition: vidbios.c:2947
#define FONT_8x8_HIGH_OFFSET
Definition: vidbios.h:30
#define BIOS_VIDEO_INTERRUPT
Definition: vidbios.h:15
#define BIOS_DEFAULT_VIDEO_MODE
Definition: vidbios.h:18

Referenced by Bios32Post().

◆ VidBiosPrintCharacter()

static VOID VidBiosPrintCharacter ( CHAR  Character,
BYTE  Attribute,
BOOLEAN  UseAttr,
BYTE  Page 
)
static

Definition at line 2863 of file vidbios.c.

2864{
2865 WORD CharData = MAKEWORD(Character, Attribute);
2866 BYTE Row, Column;
2867
2868 /* Get the cursor position */
2869 VidBiosGetCursorPosition(&Row, &Column, Page);
2870
2871 if (Character == '\a')
2872 {
2873 /* Bell control character */
2874 // NOTE: We may use what the terminal emulator offers to us...
2875 Beep(800, 200);
2876 return;
2877 }
2878 else if (Character == '\b')
2879 {
2880 /* Backspace control character */
2881 if (Column > 0)
2882 {
2883 Column--;
2884 }
2885 else if (Row > 0)
2886 {
2887 Column = Bda->ScreenColumns - 1;
2888 Row--;
2889 }
2890
2891 /* Erase the existing character */
2892 CharData = MAKEWORD(' ', Attribute);
2893 VidBiosDrawGlyph(CharData, UseAttr, Page, Row, Column);
2894 }
2895 else if (Character == '\t')
2896 {
2897 /* Horizontal Tabulation control character */
2898 do
2899 {
2900 // Taken from DOSBox
2901 VidBiosPrintCharacter(' ', Attribute, UseAttr, Page);
2902 VidBiosGetCursorPosition(&Row, &Column, Page);
2903 } while (Column % 8);
2904 }
2905 else if (Character == '\n')
2906 {
2907 /* Line Feed control character */
2908 Row++;
2909 }
2910 else if (Character == '\r')
2911 {
2912 /* Carriage Return control character */
2913 Column = 0;
2914 }
2915 else
2916 {
2917 /* Default character */
2918
2919 /* Write the character and advance the cursor */
2920 VidBiosDrawGlyph(CharData, UseAttr, Page, Row, Column);
2921 Column++;
2922 }
2923
2924 /* Check if it passed the end of the row */
2925 if (Column >= Bda->ScreenColumns)
2926 {
2927 /* Return to the first column and go to the next line */
2928 Column = 0;
2929 Row++;
2930 }
2931
2932 /* Scroll the screen up if needed */
2933 if (Row > Bda->ScreenRows)
2934 {
2935 /* The screen must be scrolled up */
2938 Row--;
2939 }
2940
2941 /* Set the cursor position */
2942 VidBiosSetCursorPosition(Row, Column, Page);
2943}
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define SCROLL_UP
Definition: listview.c:3932
BYTE ScreenRows
Definition: bios.h:89
static BOOLEAN VidBiosScrollWindow(SCROLL_DIRECTION Direction, DWORD Amount, SMALL_RECT Rectangle, BYTE Page, BYTE FillAttribute)
Definition: vidbios.c:1973
static VOID VidBiosDrawGlyph(WORD CharData, BOOLEAN UseAttr, BYTE Page, BYTE Row, BYTE Column)
Definition: vidbios.c:2619
static VOID VidBiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page)
Definition: vidbios.c:2316
static VOID VidBiosPrintCharacter(CHAR Character, BYTE Attribute, BOOLEAN UseAttr, BYTE Page)
Definition: vidbios.c:2863
static __inline VOID VidBiosGetCursorPosition(PBYTE Row, PBYTE Column, BYTE Page)
Definition: vidbios.c:2310
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by VidBiosPrintCharacter(), and VidBiosVideoService().

◆ VidBiosScrollWindow()

static BOOLEAN VidBiosScrollWindow ( SCROLL_DIRECTION  Direction,
DWORD  Amount,
SMALL_RECT  Rectangle,
BYTE  Page,
BYTE  FillAttribute 
)
static

Definition at line 1973 of file vidbios.c.

1978{
1979 INT i, j;
1980 DWORD VideoAddress = TO_LINEAR(TEXT_VIDEO_SEG, Page * Bda->VideoPageSize);
1981 WORD FillCharacter = MAKEWORD(' ', FillAttribute);
1982
1983 WORD WindowWidth, WindowHeight;
1984
1985 /* TODO: This function doesn't work in non-alphanumeric modes yet */
1986 if (Bda->VideoMode > 3)
1987 {
1988 DPRINT1("VidBiosScrollWindow: not implemented for mode 0%Xh\n", Bda->VideoMode);
1989 return FALSE;
1990 }
1991
1992 /* Fixup the rectangle if needed */
1993 Rectangle.Left = min(max(Rectangle.Left , 0), Bda->ScreenColumns - 1);
1994 Rectangle.Right = min(max(Rectangle.Right , 0), Bda->ScreenColumns - 1);
1995 Rectangle.Top = min(max(Rectangle.Top , 0), Bda->ScreenRows);
1996 Rectangle.Bottom = min(max(Rectangle.Bottom, 0), Bda->ScreenRows);
1997
1998 WindowWidth = Rectangle.Right - Rectangle.Left + 1;
1999 WindowHeight = Rectangle.Bottom - Rectangle.Top + 1;
2000
2001 /* Amount == 0 means we clear all the rectangle */
2002 if ((Amount == 0) ||
2003 (((Direction == SCROLL_UP ) || (Direction == SCROLL_DOWN )) && (Amount >= WindowHeight)) ||
2004 (((Direction == SCROLL_LEFT) || (Direction == SCROLL_RIGHT)) && (Amount >= WindowWidth )))
2005 {
2006 /* Fill the rectangle */
2007 for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
2008 {
2009 for (j = Rectangle.Left; j <= Rectangle.Right; j++)
2010 {
2012 VideoAddress + (i * Bda->ScreenColumns + j) * sizeof(WORD),
2013 (LPVOID)&FillCharacter,
2014 sizeof(FillCharacter));
2015 }
2016 }
2017
2018 return TRUE;
2019 }
2020
2021 switch (Direction)
2022 {
2023 case SCROLL_UP:
2024 {
2025 /* Move text lines up */
2026 for (i = Rectangle.Top + Amount; i <= Rectangle.Bottom; i++)
2027 {
2029 VideoAddress + ((i - Amount) * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
2030 VideoAddress + ( i * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
2031 (Rectangle.Right - Rectangle.Left + 1) * sizeof(WORD));
2032 }
2033
2034 /* Fill the bottom of the rectangle */
2035 for (i = Rectangle.Bottom - Amount + 1; i <= Rectangle.Bottom; i++)
2036 {
2037 for (j = Rectangle.Left; j <= Rectangle.Right; j++)
2038 {
2040 VideoAddress + (i * Bda->ScreenColumns + j) * sizeof(WORD),
2041 (LPVOID)&FillCharacter,
2042 sizeof(FillCharacter));
2043 }
2044 }
2045
2046 break;
2047 }
2048
2049 case SCROLL_DOWN:
2050 {
2051 INT Bottom;
2052
2053 /* Move text lines down */
2054 for (i = Rectangle.Bottom - Amount; i >= Rectangle.Top; i--)
2055 {
2057 VideoAddress + ((i + Amount) * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
2058 VideoAddress + ( i * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
2059 (Rectangle.Right - Rectangle.Left + 1) * sizeof(WORD));
2060 }
2061
2062 /* Fill the top of the rectangle */
2063 Bottom = Rectangle.Top + Amount - 1;
2064 for (i = Rectangle.Top; i <= Bottom; i++)
2065 {
2066 for (j = Rectangle.Left; j <= Rectangle.Right; j++)
2067 {
2069 VideoAddress + (i * Bda->ScreenColumns + j) * sizeof(WORD),
2070 (LPVOID)&FillCharacter,
2071 sizeof(FillCharacter));
2072 }
2073 }
2074
2075 break;
2076 }
2077
2078 case SCROLL_LEFT:
2079 {
2080 /* Move text lines left */
2081 for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
2082 {
2084 VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left ) * sizeof(WORD),
2085 VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left + Amount) * sizeof(WORD),
2086 (Rectangle.Right - Rectangle.Left - Amount + 1) * sizeof(WORD));
2087 }
2088
2089 /* Fill the right of the rectangle */
2090 for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
2091 {
2092 for (j = Rectangle.Right - Amount + 1; j <= Rectangle.Right; j++)
2093 {
2095 VideoAddress + (i * Bda->ScreenColumns + j) * sizeof(WORD),
2096 (LPVOID)&FillCharacter,
2097 sizeof(FillCharacter));
2098 }
2099 }
2100
2101 break;
2102 }
2103
2104 case SCROLL_RIGHT:
2105 {
2106 INT Right;
2107
2108 /* Move text lines right */
2109 for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
2110 {
2112 VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left + Amount) * sizeof(WORD),
2113 VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left ) * sizeof(WORD),
2114 (Rectangle.Right - Rectangle.Left - Amount + 1) * sizeof(WORD));
2115 }
2116
2117 /* Fill the left of the rectangle */
2118 Right = Rectangle.Left + Amount - 1;
2119 for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
2120 {
2121 for (j = Rectangle.Left; j <= Right; j++)
2122 {
2124 VideoAddress + (i * Bda->ScreenColumns + j) * sizeof(WORD),
2125 (LPVOID)&FillCharacter,
2126 sizeof(FillCharacter));
2127 }
2128 }
2129
2130 break;
2131 }
2132 }
2133
2134 return TRUE;
2135}
static LPHIST_ENTRY Bottom
Definition: history.c:54
#define SCROLL_DOWN
Definition: listview.c:3933
#define SCROLL_LEFT
Definition: listview.c:3930
#define SCROLL_RIGHT
Definition: listview.c:3931
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:551
#define min(a, b)
Definition: monoChain.cc:55
VOID FASTCALL EmulatorCopyMemory(PFAST486_STATE State, ULONG DestAddress, ULONG SrcAddress, ULONG Size)
Definition: memory.c:219
#define max(a, b)
Definition: svc.c:63
int32_t INT
Definition: typedefs.h:58
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction

Referenced by VidBiosPrintCharacter(), and VidBiosVideoService().

◆ VidBiosSetCursorPosition()

static VOID VidBiosSetCursorPosition ( BYTE  Row,
BYTE  Column,
BYTE  Page 
)
static

Definition at line 2316 of file vidbios.c.

2317{
2318 /* Update the position in the BDA */
2319 Bda->CursorPosition[Page] = MAKEWORD(Column, Row);
2320
2321 /* Check if this is the current video page */
2322 if (Page == Bda->VideoPage)
2323 {
2324 WORD Offset = Row * Bda->ScreenColumns + Column;
2325
2326 /* Modify the CRTC registers */
2331 }
2332}
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
BYTE VideoPage
Definition: bios.h:66
@ VGA_CRTC_CURSOR_LOC_HIGH_REG
Definition: svga.h:217
@ VGA_CRTC_CURSOR_LOC_LOW_REG
Definition: svga.h:218

Referenced by VidBiosPrintCharacter(), VidBiosSetVideoMode(), VidBiosSetVideoPage(), VidBiosSyncCursorPosition(), and VidBiosVideoService().

◆ VidBiosSetCursorShape()

static VOID VidBiosSetCursorShape ( WORD  CursorStartEnd)
static

Definition at line 2334 of file vidbios.c.

2335{
2336 /* Only valid in text-mode */
2337 if (!IS_TEXT_MODE(Bda->VideoMode)) return;
2338
2339 /* Update the BDA */
2340 Bda->CursorStartLine = HIBYTE(CursorStartEnd) & 0x1F;
2341 Bda->CursorEndLine = LOBYTE(CursorStartEnd) & 0x1F;
2342
2343 /*
2344 * In cursor emulation mode, we suppose the cursor scanlines
2345 * to be in CGA mode, so that we need to adjust them
2346 *
2347 * WARNING!!
2348 * =========
2349 * Contrary to what is mentioned in lots of literature out there, e.g. in:
2350 * http://webpages.charter.net/danrollins/techhelp/0072.HTM
2351 * http://www.bioscentral.com/misc/bda.htm
2352 * and in other various places, bit 0 of Bda->VGAOptions is 0 when
2353 * cursor emulation is ENABLED, and is 1 when it is DISABLED.
2354 *
2355 * The following documentation is right about this fact:
2356 * http://www.cs.nyu.edu/~mwalfish/classes/ut/s12-cs372h/ref/hardware/vgadoc/VGABIOS.TXT
2357 * https://sites.google.com/site/pcdosretro/biosdata
2358 *
2359 * A proof that it is OK is that in the following code samples it is
2360 * explicitly mentioned that setting bit 0 disables cursor emulation:
2361 * - Code snippets in PC Magazine vol.5 num.15 of 16/09/1986, p.291-292;
2362 * - CardFile DOS utility (Jeff Prosise, PC Magazine vol.6 num.17 of 13/10/1987, p.403-416):
2363 * https://ia600700.us.archive.org/1/items/srccode-00000020/cardfile.asm.txt
2364 * (function 'show_cursor', "or ega_info,1 ;disable EGA cursor emulation")
2365 */
2366 if (!(Bda->VGAOptions & 0x01))
2367 {
2368 // HACK: Quick "fix" for cursor scanline adjustment. This must be reworked.
2369 DPRINT1("HACK: Using HACK for cursor scanlines adjustment\n");
2370 CursorStartEnd = MAKEWORD((LOBYTE(CursorStartEnd) & 0x1F) * 2,
2371 (HIBYTE(CursorStartEnd) & 0x1F) * 2 | (HIBYTE(CursorStartEnd) & 0xE0));
2372 }
2373
2374 /* Modify the CRTC registers */
2376 IOWriteB(VGA_CRTC_DATA , HIBYTE(CursorStartEnd));
2378 IOWriteB(VGA_CRTC_DATA , LOBYTE(CursorStartEnd));
2379}
BYTE CursorEndLine
Definition: bios.h:64
BYTE CursorStartLine
Definition: bios.h:65
@ VGA_CRTC_CURSOR_START_REG
Definition: svga.h:213
@ VGA_CRTC_CURSOR_END_REG
Definition: svga.h:214
#define IS_TEXT_MODE(ModeNumber)
Definition: vidbios.c:1965

Referenced by VidBiosSetVideoMode(), and VidBiosVideoService().

◆ VidBiosSetVideoMode()

static BOOLEAN VidBiosSetVideoMode ( BYTE  ModeNumber)
static

Definition at line 2447 of file vidbios.c.

2448{
2449 BYTE Page;
2451 BYTE OrgModeNumber = ModeNumber;
2452
2453 /*
2454 * IBM standard modes do not clear the screen if the
2455 * high bit of AL is set (EGA or higher only).
2456 * See Ralf Brown: http://www.ctyme.com/intr/rb-0069.htm
2457 * for more information.
2458 */
2459 BOOLEAN DoNotClear = !!(ModeNumber & 0x80);
2460
2461 /* Retrieve the real mode number and check its validity */
2462 ModeNumber &= 0x7F;
2463 // if (ModeNumber >= ARRAYSIZE(VideoModes))
2464
2465 DPRINT1("Switching to mode %02Xh (%02Xh) %s clearing the screen; VgaRegisters = 0x%p\n",
2466 ModeNumber, OrgModeNumber, (DoNotClear ? "without" : "and"), VideoModes[ModeNumber].VgaRegisters);
2467
2468 if (ModeNumber > BIOS_MAX_VIDEO_MODE)
2469 {
2470 /* This could be an extended video mode, so call the VBE BIOS */
2471 return VbeSetExtendedVideoMode(ModeNumber);
2472 }
2473
2474 if (!VgaSetRegisters(VideoModes[ModeNumber].VgaRegisters)) return FALSE;
2476 {
2477 /*
2478 * Since we're switching from an extended video mode to a standard VGA
2479 * mode, tell the VBE BIOS to reset the extended registers.
2480 */
2482 }
2483
2484 VgaChangePalette(ModeNumber);
2485
2486 /* Clear the VGA memory if needed */
2487 if (!DoNotClear) VgaClearMemory();
2488
2489 /* Update the values in the BDA */
2490 Bda->VideoMode = ModeNumber;
2491 Bda->VideoPageSize = VideoModes[ModeNumber].PageSize;
2492 Bda->VideoPage = 0;
2494
2495 /* 256 KB Video RAM; set bit 7 if we do not clear the screen */
2496 Bda->VGAOptions = 0x60 | (Bda->VGAOptions & 0x7F) | (DoNotClear ? 0x80 : 0x00);
2497 Bda->VGASwitches = 0xF9; /* High-resolution */
2498
2499 // Bda->VGAFlags;
2500 // Bda->CrtModeControl;
2501 // Bda->CrtColorPaletteMask;
2502
2503 /* Set the start address in the CRTC */
2508
2509 /* Update the screen size */
2511 // This could be simplified if the VGA helper always returned the resolution
2512 // in number of pixels, instead of in number of cells for text-modes only...
2513 if (!IS_TEXT_MODE(ModeNumber))
2514 {
2515 Resolution.X /= VideoModes[ModeNumber].CharacterWidth ;
2516 Resolution.Y /= VideoModes[ModeNumber].CharacterHeight;
2517 }
2519 Bda->ScreenRows = Resolution.Y - 1;
2520
2521 /* Update the current font */
2523 switch (Bda->CharacterHeight)
2524 {
2525 /*
2526 * Write the default font to the VGA font plane for text-modes only.
2527 * Update the BIOS INT 43h vector (far pointer to the character range 00h-...).
2528 */
2529 case 8:
2530 {
2531 if (IS_TEXT_MODE(ModeNumber))
2533
2535 break;
2536 }
2537 case 14:
2538 {
2539 if (IS_TEXT_MODE(ModeNumber))
2541
2543 break;
2544 }
2545 case 16:
2546 {
2547 if (IS_TEXT_MODE(ModeNumber))
2549
2551 break;
2552 }
2553 }
2554
2555#if 0 // Commented, because I need to think about how to change correctly the ScreenRows
2556 // in the code that really use it (the Font generator functions of INT 10h, AH=11h)
2557 // so that it also changes the screen resolution *in text mode only*.
2558 switch (getBL())
2559 {
2560 case 0x00: Bda->ScreenRows = getDL()-1; break;
2561 case 0x01: Bda->ScreenRows = 13; break;
2562 case 0x03: Bda->ScreenRows = 42; break;
2563 case 0x02:
2564 default : Bda->ScreenRows = 24; break;
2565 }
2566#endif
2567
2568 /*
2569 * Update the cursor shape (text-mode only).
2570 * Use the default CGA cursor scanline values,
2571 * see: http://vitaly_filatov.tripod.com/ng/asm/asm_023.2.html
2572 */
2573 if (IS_TEXT_MODE(ModeNumber))
2574 // FIXME: we might read the CRT registers and do the adjustment?
2575 VidBiosSetCursorShape(MAKEWORD(0x07, 0x06));
2576
2577 /* Set the cursor position for each page */
2578 for (Page = 0; Page < BIOS_MAX_PAGES; ++Page)
2580
2581 if (!DoNotClear) VidBiosClearScreen();
2582
2583 /* Refresh display */
2585
2586 return TRUE;
2587}
BYTE VGASwitches
Definition: bios.h:92
WORD VideoPageOffset
Definition: bios.h:62
Definition: bl.h:1338
WORD PageSize
Definition: vidbios.c:1935
WORD CharacterWidth
Definition: vidbios.c:1936
WORD CharacterHeight
Definition: vidbios.c:1937
VOID WINAPI VbeResetExtendedRegisters(VOID)
Definition: vbe.c:380
BOOLEAN WINAPI VbeSetExtendedVideoMode(BYTE ModeNumber)
Definition: vbe.c:356
static BYTE Resolution
Definition: mouse.c:35
COORD VgaGetDisplayResolution(VOID)
Definition: svga.c:1727
VOID VgaWriteTextModeFont(UINT FontNumber, CONST UCHAR *FontData, UINT Height)
Definition: svga.c:2079
VOID VgaClearMemory(VOID)
Definition: svga.c:2074
@ VGA_CRTC_START_ADDR_LOW_REG
Definition: svga.h:216
@ VGA_CRTC_START_ADDR_HIGH_REG
Definition: svga.h:215
#define VGA_FONT_CHARACTERS
Definition: svga.h:25
UCHAR WINAPI getDL(VOID)
Definition: registers.c:314
UCHAR WINAPI getBL(VOID)
Definition: registers.c:198
static VOID VgaChangePalette(BYTE ModeNumber)
Definition: vidbios.c:2272
static VOID VidBiosSetCursorShape(WORD CursorStartEnd)
Definition: vidbios.c:2334
static VOID VidBiosClearScreen(VOID)
Definition: vidbios.c:2409
static BOOLEAN VgaSetRegisters(PVGA_REGISTERS Registers)
Definition: vidbios.c:2147
static CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE+1]
Definition: vidbios.c:1941
#define BIOS_MAX_PAGES
Definition: vidbios.h:19
#define BIOS_MAX_VIDEO_MODE
Definition: vidbios.h:20

Referenced by VidBiosPost(), and VidBiosVideoService().

◆ VidBiosSetVideoPage()

static BOOLEAN VidBiosSetVideoPage ( BYTE  PageNumber)
static

Definition at line 2589 of file vidbios.c.

2590{
2591 BYTE Row, Column;
2592
2593 /* Check if the page exists */
2594 if (PageNumber >= BIOS_MAX_PAGES) return FALSE;
2595
2596 /* Check if this is the same page */
2597 if (PageNumber == Bda->VideoPage) return TRUE;
2598
2599 /* Update the values in the BDA */
2600 Bda->VideoPage = PageNumber;
2602
2603 /* Set the start address in the CRTC */
2608
2609 /*
2610 * Get the cursor position (we don't update anything on the BIOS side
2611 * but we update the cursor position on the VGA side).
2612 */
2613 VidBiosGetCursorPosition(&Row, &Column, PageNumber);
2614 VidBiosSetCursorPosition( Row, Column, PageNumber);
2615
2616 return TRUE;
2617}

Referenced by VidBiosVideoService().

◆ VidBiosSyncCursorPosition()

static VOID VidBiosSyncCursorPosition ( VOID  )
static

Definition at line 2381 of file vidbios.c.

2382{
2383 BYTE Row, Column;
2384 BYTE Low, High;
2385 SHORT ScreenColumns = Bda->ScreenColumns;
2386 WORD Offset;
2387
2388 /* Get the cursor position */
2393
2394 Offset = MAKEWORD(Low, High);
2395
2396 Row = (BYTE)(Offset / ScreenColumns);
2397 Column = (BYTE)(Offset % ScreenColumns);
2398
2399 /* Synchronize our cursor position with VGA */
2400 VidBiosSetCursorPosition(Row, Column, Bda->VideoPage);
2401}
short SHORT
Definition: pedump.c:59
@ High
Definition: strmini.h:378
@ Low
Definition: strmini.h:380

Referenced by VidBiosAttachToConsole(), and VidBiosPost().

◆ VidBiosVideoService()

VOID WINAPI VidBiosVideoService ( LPWORD  Stack)

Definition at line 2947 of file vidbios.c.

2948{
2949 switch (getAH())
2950 {
2951 /* Set Video Mode */
2952 case 0x00:
2953 {
2955 break;
2956 }
2957
2958 /* Set Text-Mode Cursor Shape */
2959 case 0x01:
2960 {
2962 break;
2963 }
2964
2965 /* Set Cursor Position */
2966 case 0x02:
2967 {
2968 BYTE Page = getBH();
2969
2970 /* Validate the selected video page */
2971 if (Page >= BIOS_MAX_PAGES) break;
2972
2974 break;
2975 }
2976
2977 /* Get Cursor Position and Shape */
2978 case 0x03:
2979 {
2980 BYTE Page = getBH();
2981
2982 /* Validate the selected video page */
2983 if (Page == 0xFF) // Special case: use the current video page
2984 Page = Bda->VideoPage;
2985 else if (Page >= BIOS_MAX_PAGES)
2986 break;
2987
2988 /* Return the result */
2991 break;
2992 }
2993
2994 /* Query Light Pen */
2995 case 0x04:
2996 {
2997 /*
2998 * On modern BIOSes, this function returns 0
2999 * so that we can ignore the other registers.
3000 */
3001 setAX(0);
3002 break;
3003 }
3004
3005 /* Select Active Display Page */
3006 case 0x05:
3007 {
3009 break;
3010 }
3011
3012 /* Scroll Window Up/Down */
3013 case 0x06:
3014 case 0x07:
3015 {
3016 SMALL_RECT Rectangle = { getCL(), getCH(), getDL(), getDH() };
3017
3020
3021 break;
3022 }
3023
3024 /* Read Character and Attribute at Cursor Position */
3025 case 0x08:
3026 {
3027 WORD CharData;
3028 BYTE Page = getBH();
3029 DWORD Offset;
3030
3031 /* Validate the selected video page */
3032 if (Page == 0xFF) // Special case: use the current video page
3033 Page = Bda->VideoPage;
3034 else if (Page >= BIOS_MAX_PAGES)
3035 break;
3036
3037 /* Find the offset of the character */
3040 LOBYTE(Bda->CursorPosition[Page])) * 2;
3041
3042 /* Read from the video memory */
3045 (LPVOID)&CharData,
3046 sizeof(WORD));
3047
3048 /* Return the character data in AX */
3049 setAX(CharData);
3050
3051 break;
3052 }
3053
3054 /* Write Character and Attribute at Cursor Position */
3055 case 0x09:
3056 /* Write Character only (PCjr: + Attribute) at Cursor Position */
3057 case 0x0A:
3058 {
3059 WORD Counter = getCX();
3060 WORD CharData = MAKEWORD(getAL(), getBL());
3061 BOOLEAN UseAttr = (getAH() == 0x09);
3062 BYTE Page = getBH();
3063 BYTE Row, Column;
3064
3065 /* Validate the selected video page */
3066 if (Page == 0xFF) // Special case: use the current video page
3067 Page = Bda->VideoPage;
3068 else if (Page >= BIOS_MAX_PAGES)
3069 break;
3070
3071 /* Get the cursor position */
3072 VidBiosGetCursorPosition(&Row, &Column, Page);
3073
3074 /* Write to video memory a certain number of times */
3075 while (Counter-- > 0)
3076 {
3077 /* Write the character and advance the position */
3078 VidBiosDrawGlyph(CharData, UseAttr, Page, Row, Column);
3079 Column++;
3080
3081 /* Check if it passed the end of the row */
3082 if (Column >= Bda->ScreenColumns)
3083 {
3084 /* Return to the first column and go to the next line */
3085 Column = 0;
3086 Row++;
3087 }
3088
3089 /* Contrary to the "Teletype Output" function, the screen is not scrolled */
3090 if (Row > Bda->ScreenRows)
3091 {
3092 Row = Bda->ScreenRows;
3093 }
3094 }
3095
3096 break;
3097 }
3098
3099 /* Set Video Colors */
3100 case 0x0B:
3101 {
3102 if (Bda->VideoMode < 0x04 || Bda->VideoMode > 0x06)
3103 {
3104 DPRINT1("BIOS Function INT 10h, AH = 0Bh, BH = 0x%02X is unsupported for non-CGA modes\n",
3105 getBH());
3106 break;
3107 }
3108
3109 switch (getBH())
3110 {
3111 case 0x00: /* Set Background/Border Color */
3112 {
3113#ifdef DOSBOX
3114 BYTE Index = getBL();
3115
3116 /* See: http://www.bioscentral.com/misc/bda.htm */
3117 Bda->CrtColorPaletteMask = (Bda->CrtColorPaletteMask & 0xE0) | (Index & 0x1F);
3118
3119 Index = ((Index << 1) & 0x10) | (Index & 0x7);
3120
3121 /* Always set the overscan color */
3123
3124 /* Don't set any extra colors when in text mode */
3125 if (Bda->VideoMode <= 0x03) break;
3126
3128
3129 Index = (Bda->CrtColorPaletteMask & 0x10) | 0x02 | ((Bda->CrtColorPaletteMask & 0x20) >> 5);
3130
3132 Index += 2;
3134 Index += 2;
3136#else
3137 /* Background/Border Color is modifiable via the first index */
3139#endif
3140
3141 /* Enable screen and disable palette access */
3142 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3143 IOWriteB(VGA_AC_INDEX, 0x20);
3144 break;
3145 }
3146
3147 case 0x01: /* Set Palette */
3148 {
3149 BYTE Index = getBL();
3150
3151 /* See: http://www.bioscentral.com/misc/bda.htm */
3152 /* Reset bit 5: foreground colors index (0: green/red/yellow; 1: cyan/magenta/white) */
3153 Bda->CrtColorPaletteMask = (Bda->CrtColorPaletteMask & 0xDF) | ((Index & 1) ? 0x20 : 0x00);
3154
3155 /* Don't set any extra colors when in text mode */
3156 if (Bda->VideoMode <= 0x03) break;
3157
3158 Index = (Bda->CrtColorPaletteMask & 0x10) | 0x02 | Index;
3159
3161 Index += 2;
3163 Index += 2;
3165
3166 /* Enable screen and disable palette access */
3167 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3168 IOWriteB(VGA_AC_INDEX, 0x20);
3169 break;
3170 }
3171
3172 default:
3173 DPRINT1("BIOS Function INT 10h, AH = 0Bh, BH = 0x%02X NOT IMPLEMENTED\n",
3174 getAH(), getBH());
3175 break;
3176 }
3177
3178 break;
3179 }
3180
3181 /* Teletype Output */
3182 case 0x0E:
3183 {
3184 BYTE Page = getBH();
3185
3186 /* Validate the selected video page */
3187 if (Page == 0xFF) // Special case: use the current video page
3188 Page = Bda->VideoPage;
3189 else if (Page >= BIOS_MAX_PAGES)
3190 break;
3191
3193 break;
3194 }
3195
3196 /* Get Current Video Mode */
3197 case 0x0F:
3198 {
3201 break;
3202 }
3203
3204 /* Palette Control */
3205 case 0x10:
3206 {
3207 switch (getAL())
3208 {
3209 /* Set Single Palette Register */
3210 case 0x00:
3211 {
3213
3214 /* Enable screen and disable palette access */
3215 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3216 IOWriteB(VGA_AC_INDEX, 0x20);
3217 break;
3218 }
3219
3220 /* Set Overscan Color */
3221 case 0x01:
3222 {
3224
3225 /* Enable screen and disable palette access */
3226 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3227 IOWriteB(VGA_AC_INDEX, 0x20);
3228 break;
3229 }
3230
3231 /* Set All Palette Registers */
3232 case 0x02:
3233 {
3234 UINT i;
3236
3237 /* Set the palette registers */
3238 for (i = 0; i <= VGA_AC_PAL_F_REG; i++)
3239 {
3241 }
3242
3243 /* Set the overscan register */
3244 // VgaSetSinglePaletteRegister(VGA_AC_OVERSCAN_REG, Buffer[VGA_AC_PAL_F_REG + 1]);
3248
3249 /* Enable screen and disable palette access */
3250 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3251 IOWriteB(VGA_AC_INDEX, 0x20);
3252 break;
3253 }
3254
3255 /* Toggle Intensity/Blinking Bit */
3256 case 0x03:
3257 {
3258 /* Read the old AC mode control register value */
3259 BYTE VgaAcControlReg;
3260
3263 VgaAcControlReg = IOReadB(VGA_AC_READ);
3264
3265 /* Toggle the blinking bit and write the new value */
3266 if (getBL())
3267 {
3268 VgaAcControlReg |= VGA_AC_CONTROL_BLINK;
3269 Bda->CrtModeControl |= (1 << 5);
3270 }
3271 else
3272 {
3273 VgaAcControlReg &= ~VGA_AC_CONTROL_BLINK;
3274 Bda->CrtModeControl &= ~(1 << 5);
3275 }
3276
3279 IOWriteB(VGA_AC_WRITE, VgaAcControlReg);
3280
3281 /* Enable screen and disable palette access */
3282 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3283 IOWriteB(VGA_AC_INDEX, 0x20);
3284 break;
3285 }
3286
3287 /* Get Single Palette Register */
3288 case 0x07:
3289 {
3290 /* Write the index */
3291 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3293
3294 /* Read the data */
3296
3297 /* Enable screen and disable palette access */
3298 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3299 IOWriteB(VGA_AC_INDEX, 0x20);
3300 break;
3301 }
3302
3303 /* Get Overscan Color */
3304 case 0x08:
3305 {
3306 /* Write the index */
3307 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3309
3310 /* Read the data */
3312
3313 /* Enable screen and disable palette access */
3314 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3315 IOWriteB(VGA_AC_INDEX, 0x20);
3316 break;
3317 }
3318
3319 /* Get All Palette Registers */
3320 case 0x09:
3321 {
3322 UINT i;
3324
3325 /* Get the palette registers */
3326 for (i = 0; i <= VGA_AC_PAL_F_REG; i++)
3327 {
3328 /* Write the index */
3329 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3331
3332 /* Read the data */
3334 }
3335
3336 /* Get the overscan register */
3340
3341 /* Enable screen and disable palette access */
3342 IOReadB(VGA_INSTAT1_READ); // Put the AC register into index state
3343 IOWriteB(VGA_AC_INDEX, 0x20);
3344 break;
3345 }
3346
3347 /* Set Individual DAC Register */
3348 case 0x10:
3349 {
3350 /* Write the index */
3351 // Certainly in BL and not in BX as said by Ralf Brown...
3353
3354 /* Write the data in this order: Red, Green, Blue */
3358
3359 break;
3360 }
3361
3362 /* Set Block of DAC Registers */
3363 case 0x12:
3364 {
3365 UINT i;
3367
3368 /* Write the index */
3369 // Certainly in BL and not in BX as said by Ralf Brown...
3371
3372 for (i = 0; i < getCX(); i++)
3373 {
3374 /* Write the data in this order: Red, Green, Blue */
3378 }
3379
3380 break;
3381 }
3382
3383 /* Set Video DAC Color Page */
3384 case 0x13:
3385 {
3386 if (getBL() == 0)
3387 {
3388 /* Set the highest bit of the AC Mode Control register to BH */
3391 IOWriteB(VGA_AC_WRITE, (IOReadB(VGA_AC_READ) & 0x7F) | (getBH() << 7));
3392 }
3393 else if (getBL() == 1)
3394 {
3395 /* Set the AC Color Select register to BH */
3399 }
3400 else
3401 {
3402 DPRINT1("BIOS Palette Control Sub-sub-command BL = 0x%02X INVALID\n", getBL());
3403 }
3404
3405 break;
3406 }
3407
3408 /* Get Individual DAC Register */
3409 case 0x15:
3410 {
3411 /* Write the index */
3413
3414 /* Read the data in this order: Red, Green, Blue */
3418
3419 break;
3420 }
3421
3422 /* Get Block of DAC Registers */
3423 case 0x17:
3424 {
3425 UINT i;
3427
3428 /* Write the index */
3429 // Certainly in BL and not in BX as said by Ralf Brown...
3431
3432 for (i = 0; i < getCX(); i++)
3433 {
3434 /* Write the data in this order: Red, Green, Blue */
3438 }
3439
3440 break;
3441 }
3442
3443 /* Set PEL Mask */
3444 case 0x18:
3445 {
3447 break;
3448 }
3449
3450 /* Get PEL Mask */
3451 case 0x19:
3452 {
3454 break;
3455 }
3456
3457 default:
3458 {
3459 DPRINT1("BIOS Palette Control Sub-command AL = 0x%02X NOT IMPLEMENTED\n",
3460 getAL());
3461 break;
3462 }
3463 }
3464
3465 break;
3466 }
3467
3468 /* Font Control */
3469 case 0x11:
3470 {
3471 switch (getAL())
3472 {
3473 // FIXME: At the moment we support only graphics-mode functions!
3474
3475 /* Load User-specified Patterns (Character Set) for Text Mode */
3476 case 0x00:
3477 case 0x10: // FIXME: 0x1x performs a full mode reset
3478 {
3479 // FIXME: BL == ??
3480
3481 /* Write the default font to the VGA font plane */
3482 // VgaWriteTextModeFont(0, Font8x8, ARRAYSIZE(Font8x8) / VGA_FONT_CHARACTERS);
3483
3485 break;
3486 }
3487
3488 /* Load ROM Monochrome 8x14 Patterns (Character Set) for Text Mode */
3489 case 0x01:
3490 case 0x11: // FIXME: 0x1x performs a full mode reset
3491 {
3492 // FIXME: BL == ??
3493
3494 /* Write the default font to the VGA font plane */
3496
3498 break;
3499 }
3500
3501 /* Load ROM 8x8 Double-dot Patterns (Character Set) for Text Mode */
3502 case 0x02:
3503 case 0x12: // FIXME: 0x1x performs a full mode reset
3504 {
3505 // FIXME: BL == ??
3506
3507 /* Write the default font to the VGA font plane */
3509
3511 break;
3512 }
3513
3514 /* Load ROM 8x16 Character Set for Text Mode */
3515 case 0x04:
3516 case 0x14: // FIXME: 0x1x performs a full mode reset
3517 {
3518 // FIXME: BL == ??
3519
3520 /* Write the default font to the VGA font plane */
3522
3524 break;
3525 }
3526
3527 /* Set User 8x8 Graphics Chars (Setup INT 1Fh Vector) */
3528 case 0x20:
3529 {
3530 /* Update the BIOS INT 1Fh vector to user-defined ES:BP pointer */
3531 // Far pointer to the 8x8 characters 80h-FFh
3532 ((PULONG)BaseAddress)[0x1F] = MAKELONG(getBP(), getES());
3533 break;
3534 }
3535
3536 /* Set User Graphics Characters */
3537 case 0x21:
3538 {
3539 /*
3540 * Update the BIOS INT 43h vector (far pointer
3541 * to the character range 00h-...)
3542 */
3543 ((PULONG)BaseAddress)[0x43] = MAKELONG(getBP(), getES());
3544
3545 /* Update BDA */
3547 switch (getBL())
3548 {
3549 case 0x00: Bda->ScreenRows = getDL()-1; break;
3550 case 0x01: Bda->ScreenRows = 13; break;
3551 case 0x03: Bda->ScreenRows = 42; break;
3552 case 0x02:
3553 default : Bda->ScreenRows = 24; break;
3554 }
3555
3556 break;
3557 }
3558
3559 /* Setup ROM 8x14 Font for Graphics Mode */
3560 case 0x22:
3561 {
3562 /*
3563 * Update the BIOS INT 43h vector (far pointer
3564 * to the character range 00h-...)
3565 */
3567
3568 /* Update BDA */
3569 Bda->CharacterHeight = 14;
3570 switch (getBL())
3571 {
3572 case 0x00: Bda->ScreenRows = getDL()-1; break;
3573 case 0x01: Bda->ScreenRows = 13; break;
3574 case 0x03: Bda->ScreenRows = 42; break;
3575 case 0x02:
3576 default : Bda->ScreenRows = 24; break;
3577 }
3578
3579 break;
3580 }
3581
3582 /* Setup ROM 8x8 Font for Graphics Mode */
3583 case 0x23:
3584 {
3585 /*
3586 * Update the BIOS INT 43h vector (far pointer
3587 * to the character range 00h-...)
3588 */
3590
3591 /* Update BDA */
3592 Bda->CharacterHeight = 8;
3593 switch (getBL())
3594 {
3595 case 0x00: Bda->ScreenRows = getDL()-1; break;
3596 case 0x01: Bda->ScreenRows = 13; break;
3597 case 0x03: Bda->ScreenRows = 42; break;
3598 case 0x02:
3599 default : Bda->ScreenRows = 24; break;
3600 }
3601
3602 break;
3603 }
3604
3605 /* Setup ROM 8x16 Font for Graphics Mode */
3606 case 0x24:
3607 {
3608 /*
3609 * Update the BIOS INT 43h vector (far pointer
3610 * to the character range 00h-...).
3611 */
3613
3614 /* Update BDA */
3615 Bda->CharacterHeight = 16;
3616 switch (getBL())
3617 {
3618 case 0x00: Bda->ScreenRows = getDL()-1; break;
3619 case 0x01: Bda->ScreenRows = 13; break;
3620 case 0x03: Bda->ScreenRows = 42; break;
3621 case 0x02:
3622 default : Bda->ScreenRows = 24; break;
3623 }
3624
3625 break;
3626 }
3627
3628 /* Get Current Character Font Information */
3629 case 0x30:
3630 {
3632
3633 switch (getBH())
3634 {
3635 /* 00h - INT 0x1F pointer */
3636 case 0x00:
3637 Address = ((PULONG)BaseAddress)[0x1F];
3638 break;
3639
3640 /* 01h - INT 0x43 pointer */
3641 case 0x01:
3642 Address = ((PULONG)BaseAddress)[0x43];
3643 break;
3644
3645 /* 02h - 8x14 font */
3646 case 0x02:
3648 break;
3649
3650 /* 03h - 8x8 font */
3651 case 0x03:
3653 break;
3654
3655 /* 04h - 8x8 font, upper half */
3656 case 0x04:
3658 break;
3659
3660 /* 05h - NOT IMPLEMENTED - 9x14 font */
3661 case 0x05:
3662 break;
3663
3664 /* 06h - 8x16 font */
3665 case 0x06:
3667 break;
3668
3669 /* 07h - NOT IMPLEMENTED - 9x16 font */
3670 case 0x07:
3671 break;
3672
3673 default:
3674 DPRINT1("INT 10h, AL=30h Function BH = 0x%02X NOT IMPLEMENTED\n",
3675 getBH());
3676 }
3677
3678 /* Return the data */
3683
3684 break;
3685 }
3686
3687 default:
3688 {
3689 DPRINT1("BIOS Font Control Sub-command AL = 0x%02X NOT IMPLEMENTED\n",
3690 getAL());
3691 }
3692 }
3693
3694 break;
3695 }
3696
3697 /* Alternate Function Select */
3698 case 0x12:
3699 {
3700 switch (getBL())
3701 {
3702 /* Get EGA/VGA Information */
3703 case 0x10:
3704 {
3705 setBH((Bda->VGAOptions & 0x02) >> 1); /* Color (0) or monochrome (1) display */
3706 setBL((Bda->VGAOptions & 0x60) >> 5); /* Video RAM size */
3707 setCH((Bda->VGASwitches & 0xF0) >> 4); /* Features settings */
3708 setCL( Bda->VGASwitches & 0x0F); /* Switches settings */
3709 break;
3710 }
3711
3712 /* Enable/Disable Cursor Emulation */
3713 case 0x34:
3714 {
3715 BYTE State = getAL();
3716
3717 /* Check for validity */
3718 if (State > 1) break;
3719
3720 /*
3721 * Enable (State == 0) or disable (State == 1) cursor emulation.
3722 * Please read the WARNING in the 'VidBiosSetCursorShape'
3723 * function for more details.
3724 */
3725 Bda->VGAOptions = (Bda->VGAOptions & 0xFE) | (State & 0x01);
3726
3727 /* Return success */
3728 setAL(0x12);
3729 break;
3730 }
3731
3732 /* Enable/Disable screen refresh */
3733 case 0x36:
3734 {
3735 BYTE State = getAL();
3736 BYTE Clocking;
3737
3738 /* Check for validity */
3739 if (State > 1) break;
3740
3741 /* Turn the video on (State == 0) or off (State == 1) */
3743 Clocking = IOReadB(VGA_SEQ_DATA);
3744
3745 if (State == 0)
3746 Clocking &= ~VGA_SEQ_CLOCK_SD;
3747 else
3748 Clocking |= VGA_SEQ_CLOCK_SD;
3749
3750 IOWriteB(VGA_SEQ_DATA, Clocking);
3751
3752 /* Return success */
3753 setAL(0x12);
3754 break;
3755 }
3756
3757 default:
3758 {
3759 DPRINT1("BIOS Function INT 10h, AH = 12h (Alternate Function Select), BX = 0x%04X NOT IMPLEMENTED\n",
3760 getBX());
3761 break;
3762 }
3763 }
3764
3765 break;
3766 }
3767
3768 /* Write String */
3769 case 0x13:
3770 {
3772 WORD Counter = getCX();
3773 BYTE Row, Column;
3774 BYTE OldRow, OldColumn;
3775 CHAR Character;
3776 BYTE Attribute = getBL(); // Default attribute in case the string contains only characters.
3777 BYTE Page = getBH();
3778 BYTE Flags = getAL();
3779
3780 /* Validate the selected video page */
3781 if (Page == 0xFF) // Special case: use the current video page
3782 Page = Bda->VideoPage;
3783 else if (Page >= BIOS_MAX_PAGES)
3784 break;
3785
3786 /* Get the original cursor position */
3787 VidBiosGetCursorPosition(&OldRow, &OldColumn, Page);
3788
3789 /* Set the new cursor position */
3790 Row = getDH();
3791 Column = getDL();
3792 if (Row == 0xFF) // Special case: use the current cursor position
3793 {
3794 Row = OldRow;
3795 Column = OldColumn;
3796 }
3797 VidBiosSetCursorPosition(Row, Column, Page);
3798
3799 while (Counter-- > 0)
3800 {
3801 Character = *String++;
3802 if (Flags & 0x02) Attribute = *String++;
3803 VidBiosPrintCharacter(Character, Attribute, TRUE, Page);
3804 }
3805
3806 /* Reset the cursor position to its original value if we don't want to update it */
3807 if (!(Flags & 0x01)) VidBiosSetCursorPosition(OldRow, OldColumn, Page);
3808
3809 break;
3810 }
3811
3812 /* Get/Set Display combination code */
3813 case 0x1A:
3814 {
3815 switch (getAL())
3816 {
3817 case 0x00: /* Get Display combination code */
3818 {
3820 setBH(0x00); // No alternate display
3821
3822 /* Return success */
3823 setAL(0x1A);
3824 break;
3825 }
3826 case 0x01: /* Set Display combination code */
3827 {
3828 DPRINT1("Set Display combination code - Unsupported\n");
3829 break;
3830 }
3831 default:
3832 break;
3833 }
3834 break;
3835 }
3836
3837 /* Functionality/State Information (VGA) */
3838 case 0x1B:
3839 {
3841
3842 /* Check for only supported subfunction */
3843 if (getBX() != 0x0000)
3844 {
3845 DPRINT1("INT 10h, AH=1Bh, unsupported subfunction 0x%04x\n", getBX());
3846 break;
3847 }
3848
3849 /* Fill the VGA dynamic functionality table with our information */
3850
3852
3853 Table->VideoMode = Bda->VideoMode;
3854 Table->ScreenColumns = Bda->ScreenColumns;
3855 Table->VideoPageSize = Bda->VideoPageSize;
3856 Table->VideoPageOffset = Bda->VideoPageOffset;
3857 RtlCopyMemory(Table->CursorPosition, Bda->CursorPosition, sizeof(Bda->CursorPosition));
3858 Table->CursorEndLine = Bda->CursorEndLine;
3859 Table->CursorStartLine = Bda->CursorStartLine;
3860 Table->VideoPage = Bda->VideoPage;
3861 Table->CrtBasePort = Bda->CrtBasePort;
3862 Table->CrtModeControl = Bda->CrtModeControl;
3863 Table->CrtColorPaletteMask = Bda->CrtColorPaletteMask;
3864 Table->ScreenRows = Bda->ScreenRows;
3865 Table->CharacterHeight = Bda->CharacterHeight;
3866
3867 Table->VGADccIDActive = Bda->VGADccIDActive;
3868 Table->VGADccIDAlternate = 0x00; // No alternate display
3869 // Table->CurrModeSupportedColorsNum;
3870 // Table->CurrModeSupportedPagesNum;
3871 // Table->Scanlines;
3872 // Table->PrimaryCharTable;
3873 // Table->SecondaryCharTable;
3874 // Table->VGAFlags;
3875 Table->VGAAvailMemory = (Bda->VGAOptions & 0x60) >> 5;
3876 // Table->VGASavePtrStateFlags;
3877 // Table->VGADispInfo;
3879
3880 /* Return success */
3881 setAL(0x1B);
3882 break;
3883 }
3884
3885 /* VESA BIOS Extensions */
3886 case 0x4F:
3887 {
3889 break;
3890 }
3891
3892 default:
3893 {
3894 DPRINT1("BIOS Function INT 10h, AH = 0x%02X, AL = 0x%02X, BH = 0x%02X NOT IMPLEMENTED\n",
3895 getAH(), getAL(), getBH());
3896 }
3897 }
3898}
#define UNIMPLEMENTED
Definition: debug.h:115
ASMGENDATA Table[]
Definition: genincdata.c:61
#define PCHAR
Definition: match.c:90
#define LOWORD(l)
Definition: pedump.c:82
static WCHAR Address[46]
Definition: ping.c:68
VOID WINAPI VbeService(LPWORD Stack)
Definition: vbe.c:472
static LARGE_INTEGER Counter
Definition: clock.c:43
#define VGA_AC_READ
Definition: svga.h:53
#define VGA_DAC_READ_INDEX
Definition: svga.h:59
@ VGA_AC_PAL_F_REG
Definition: svga.h:356
@ VGA_AC_OVERSCAN_REG
Definition: svga.h:358
@ VGA_AC_COLOR_SEL_REG
Definition: svga.h:361
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HIWORD(l)
Definition: typedefs.h:247
char * PCHAR
Definition: typedefs.h:51
UCHAR WINAPI getBH(VOID)
Definition: registers.c:184
VOID WINAPI setCX(USHORT)
Definition: registers.c:235
VOID WINAPI setCH(UCHAR)
Definition: registers.c:249
VOID WINAPI setDX(USHORT)
Definition: registers.c:293
USHORT WINAPI getBX(VOID)
Definition: registers.c:170
VOID WINAPI setAL(UCHAR)
Definition: registers.c:149
UCHAR WINAPI getCH(VOID)
Definition: registers.c:242
VOID WINAPI setDL(UCHAR)
Definition: registers.c:321
UCHAR WINAPI getAL(VOID)
Definition: registers.c:142
USHORT WINAPI getCX(VOID)
Definition: registers.c:228
USHORT WINAPI getDX(VOID)
Definition: registers.c:286
VOID WINAPI setBL(UCHAR)
Definition: registers.c:205
UCHAR WINAPI getCL(VOID)
Definition: registers.c:256
VOID WINAPI setBH(UCHAR)
Definition: registers.c:191
USHORT WINAPI getES(VOID)
Definition: registers.c:522
USHORT WINAPI getBP(VOID)
Definition: registers.c:374
VOID WINAPI setDH(UCHAR)
Definition: registers.c:307
USHORT WINAPI getDI(VOID)
Definition: registers.c:434
VOID WINAPI setBP(USHORT)
Definition: registers.c:381
VOID WINAPI setAX(USHORT)
Definition: registers.c:121
VOID WINAPI setES(USHORT)
Definition: registers.c:529
VOID WINAPI setCL(UCHAR)
Definition: registers.c:263
UCHAR WINAPI getAH(VOID)
Definition: registers.c:128
UCHAR WINAPI getDH(VOID)
Definition: registers.c:300
static BYTE VidBiosGetVideoMode(VOID)
Definition: vidbios.c:2403
static BOOLEAN VidBiosSetVideoPage(BYTE PageNumber)
Definition: vidbios.c:2589
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
char CHAR
Definition: xmlstorage.h:175

Referenced by VidBiosINT(), and VidBiosPost().

Variable Documentation

◆ Attached

◆ BiosInfo

const CHAR BiosInfo[]
static
Initial value:
=
"00000000000 Emulation of IBM VGA Compatible ROM\0"
"CL-GD5434 VGA BIOS Version 1.41 \r\n"
"Copyright (C) ReactOS Team 1996-"COPYRIGHT_YEAR"\r\n"
"The original CL-GD5434 card was created by Cirrus Logic, Inc.\r\n\0"
"BIOS Date: 06/17/13\0"

Definition at line 44 of file vidbios.c.

Referenced by VidBiosInitialize().

◆ EgaPalette__16Colors

CONST COLORREF EgaPalette__16Colors[VGA_MAX_COLORS/4]
static
Initial value:
=
{
RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0xAA), RGB(0x00, 0xAA, 0x00), RGB(0x00, 0xAA, 0xAA),
RGB(0xAA, 0x00, 0x00), RGB(0xAA, 0x00, 0xAA), RGB(0xAA, 0x55, 0x00), RGB(0xAA, 0xAA, 0xAA),
RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0xAA), RGB(0x00, 0xAA, 0x00), RGB(0x00, 0xAA, 0xAA),
RGB(0xAA, 0x00, 0x00), RGB(0xAA, 0x00, 0xAA), RGB(0xAA, 0x55, 0x00), RGB(0xAA, 0xAA, 0xAA),
RGB(0x55, 0x55, 0x55), RGB(0x55, 0x55, 0xFF), RGB(0x55, 0xFF, 0x55), RGB(0x55, 0xFF, 0xFF),
RGB(0xFF, 0x55, 0x55), RGB(0xFF, 0x55, 0xFF), RGB(0xFF, 0xFF, 0x55), RGB(0xFF, 0xFF, 0xFF),
RGB(0x55, 0x55, 0x55), RGB(0x55, 0x55, 0xFF), RGB(0x55, 0xFF, 0x55), RGB(0x55, 0xFF, 0xFF),
RGB(0xFF, 0x55, 0x55), RGB(0xFF, 0x55, 0xFF), RGB(0xFF, 0xFF, 0x55), RGB(0xFF, 0xFF, 0xFF),
RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0xAA), RGB(0x00, 0xAA, 0x00), RGB(0x00, 0xAA, 0xAA),
RGB(0xAA, 0x00, 0x00), RGB(0xAA, 0x00, 0xAA), RGB(0xAA, 0x55, 0x00), RGB(0xAA, 0xAA, 0xAA),
RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0xAA), RGB(0x00, 0xAA, 0x00), RGB(0x00, 0xAA, 0xAA),
RGB(0xAA, 0x00, 0x00), RGB(0xAA, 0x00, 0xAA), RGB(0xAA, 0x55, 0x00), RGB(0xAA, 0xAA, 0xAA),
RGB(0x55, 0x55, 0x55), RGB(0x55, 0x55, 0xFF), RGB(0x55, 0xFF, 0x55), RGB(0x55, 0xFF, 0xFF),
RGB(0xFF, 0x55, 0x55), RGB(0xFF, 0x55, 0xFF), RGB(0xFF, 0xFF, 0x55), RGB(0xFF, 0xFF, 0xFF),
RGB(0x55, 0x55, 0x55), RGB(0x55, 0x55, 0xFF), RGB(0x55, 0xFF, 0x55), RGB(0x55, 0xFF, 0xFF),
RGB(0xFF, 0x55, 0x55), RGB(0xFF, 0x55, 0xFF), RGB(0xFF, 0xFF, 0x55), RGB(0xFF, 0xFF, 0xFF)
}
#define RGB(r, g, b)
Definition: precomp.h:71

Definition at line 423 of file vidbios.c.

Referenced by VgaChangePalette().

◆ EgaPalette__HiRes

CONST COLORREF EgaPalette__HiRes[VGA_MAX_COLORS/4]
static
Initial value:
=
{
RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0xAA), RGB(0x00, 0xAA, 0x00), RGB(0x00, 0xAA, 0xAA),
RGB(0xAA, 0x00, 0x00), RGB(0xAA, 0x00, 0xAA), RGB(0xAA, 0xAA, 0x00), RGB(0xAA, 0xAA, 0xAA),
RGB(0x00, 0x00, 0x55), RGB(0x00, 0x00, 0xFF), RGB(0x00, 0xAA, 0x55), RGB(0x00, 0xAA, 0xFF),
RGB(0xAA, 0x00, 0x55), RGB(0xAA, 0x00, 0xFF), RGB(0xAA, 0xAA, 0x55), RGB(0xAA, 0xAA, 0xFF),
RGB(0x00, 0x55, 0x00), RGB(0x00, 0x55, 0xAA), RGB(0x00, 0xFF, 0x00), RGB(0x00, 0xFF, 0xAA),
RGB(0xAA, 0x55, 0x00), RGB(0xAA, 0x55, 0xAA), RGB(0xAA, 0xFF, 0x00), RGB(0xAA, 0xFF, 0xAA),
RGB(0x00, 0x55, 0x55), RGB(0x00, 0x55, 0xFF), RGB(0x00, 0xFF, 0x55), RGB(0x00, 0xFF, 0xFF),
RGB(0xAA, 0x55, 0x55), RGB(0xAA, 0x55, 0xFF), RGB(0xAA, 0xFF, 0x55), RGB(0xAA, 0xFF, 0xFF),
RGB(0x55, 0x00, 0x00), RGB(0x55, 0x00, 0xAA), RGB(0x55, 0xAA, 0x00), RGB(0x55, 0xAA, 0xAA),
RGB(0xFF, 0x00, 0x00), RGB(0xFF, 0x00, 0xAA), RGB(0xFF, 0xAA, 0x00), RGB(0xFF, 0xAA, 0xAA),
RGB(0x55, 0x00, 0x55), RGB(0x55, 0x00, 0xFF), RGB(0x55, 0xAA, 0x55), RGB(0x55, 0xAA, 0xFF),
RGB(0xFF, 0x00, 0x55), RGB(0xFF, 0x00, 0xFF), RGB(0xFF, 0xAA, 0x55), RGB(0xFF, 0xAA, 0xFF),
RGB(0x55, 0x55, 0x00), RGB(0x55, 0x55, 0xAA), RGB(0x55, 0xFF, 0x00), RGB(0x55, 0xFF, 0xAA),
RGB(0xFF, 0x55, 0x00), RGB(0xFF, 0x55, 0xAA), RGB(0xFF, 0xFF, 0x00), RGB(0xFF, 0xFF, 0xAA),
RGB(0x55, 0x55, 0x55), RGB(0x55, 0x55, 0xFF), RGB(0x55, 0xFF, 0x55), RGB(0x55, 0xFF, 0xFF),
RGB(0xFF, 0x55, 0x55), RGB(0xFF, 0x55, 0xFF), RGB(0xFF, 0xFF, 0x55), RGB(0xFF, 0xFF, 0xFF)
}

Definition at line 455 of file vidbios.c.

Referenced by VgaChangePalette().

◆ Font8x14

CONST UCHAR Font8x14[VGA_FONT_CHARACTERS *14]
static

Definition at line 892 of file vidbios.c.

Referenced by VidBiosInitialize(), VidBiosSetVideoMode(), and VidBiosVideoService().

◆ Font8x16

CONST UCHAR Font8x16[VGA_FONT_CHARACTERS *16]
static

Definition at line 1408 of file vidbios.c.

Referenced by VidBiosInitialize(), VidBiosSetVideoMode(), and VidBiosVideoService().

◆ Font8x8

CONST UCHAR Font8x8[VGA_FONT_CHARACTERS *8]
static

Definition at line 632 of file vidbios.c.

Referenced by VidBiosInitialize(), VidBiosSetVideoMode(), and VidBiosVideoService().

◆ VbeInitialized

BOOLEAN VbeInitialized = FALSE
static

Definition at line 1969 of file vidbios.c.

Referenced by VidBiosPost(), VidBiosSetVideoMode(), and VidBiosVideoService().

◆ VgaPalette

CONST COLORREF VgaPalette[VGA_MAX_COLORS]
static

Definition at line 488 of file vidbios.c.

Referenced by VgaChangePalette().

◆ VgaStaticFuncTable

PVGA_STATIC_FUNC_TABLE VgaStaticFuncTable
static

Definition at line 1968 of file vidbios.c.

Referenced by VidBiosInitialize().

◆ VideoMode_320x200_16color

VGA_REGISTERS VideoMode_320x200_16color
static
Initial value:
=
{
0x63,
{0x00, 0x09, 0x0F, 0x00, 0x06},
{0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xE3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16, 0x17, 0x01, 0x00, 0x0F, 0x00, 0x00}
}

Definition at line 143 of file vidbios.c.

◆ VideoMode_320x200_256color

VGA_REGISTERS VideoMode_320x200_256color
static
Initial value:
=
{
0x63,
{0x00, 0x01, 0x0F, 0x00, 0x0E},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x41, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00}
}

Definition at line 250 of file vidbios.c.

◆ VideoMode_320x200_4color

VGA_REGISTERS VideoMode_320x200_4color
static
Initial value:
=
{
0x63,
{0x00, 0x09, 0x03, 0x00, 0x02},
{0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00, 0xC1, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA2,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x0F, 0xFF},
{0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16, 0x17, 0x01, 0x00, 0x03, 0x00, 0x00}
}

Definition at line 101 of file vidbios.c.

◆ VideoMode_40x25_text

VGA_REGISTERS VideoMode_40x25_text
static
Initial value:
=
{
0x67,
{0x00, 0x08, 0x03, 0x00, 0x02},
{0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0E,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00}
}

Definition at line 59 of file vidbios.c.

◆ VideoMode_640x200_16color

VGA_REGISTERS VideoMode_640x200_16color
static
Initial value:
=
{
0x63,
{0x00, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16, 0x17, 0x01, 0x00, 0x0F, 0x00, 0x00}
}

Definition at line 164 of file vidbios.c.

◆ VideoMode_640x200_2color

VGA_REGISTERS VideoMode_640x200_2color
static
Initial value:
=
{
0x63,
{0x00, 0x01, 0x01, 0x00, 0x02},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0xC1, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xC2,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0xFF},
{0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
0x17, 0x17, 0x17, 0x17, 0x01, 0x00, 0x01, 0x00, 0x00}
}

Definition at line 122 of file vidbios.c.

◆ VideoMode_640x350_16color

VGA_REGISTERS VideoMode_640x350_16color
static
Initial value:
=
{
0xA3,
{0x00, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x83, 0x85, 0x5D, 0x28, 0x0F, 0x63, 0xBA, 0xE3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x01, 0x00, 0x0F, 0x00, 0x00}
}

Definition at line 185 of file vidbios.c.

◆ VideoMode_640x480_16color

VGA_REGISTERS VideoMode_640x480_16color
static
Initial value:
=
{
0xE3,
{0x00, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xEA, 0x8C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x01, 0x00, 0x0F, 0x00, 0x00}
}

Definition at line 229 of file vidbios.c.

◆ VideoMode_640x480_2color

VGA_REGISTERS VideoMode_640x480_2color
static
Initial value:
=
{
0xE3,
{0x00, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xEA, 0x8C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xC3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F,
0x00, 0x3F, 0x00, 0x3F, 0x01, 0x00, 0x0F, 0x00, 0x00}
}

Definition at line 206 of file vidbios.c.

◆ VideoMode_80x25_text

VGA_REGISTERS VideoMode_80x25_text
static
Initial value:
=
{
0x67,
{0x00, 0x00, 0x03, 0x00, 0x02},
{0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0E,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00}
}

Definition at line 80 of file vidbios.c.

◆ VideoModes

CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE+1]
static
Initial value:
=
{
{&VideoMode_40x25_text, 0x0800, 9, 16},
{&VideoMode_40x25_text, 0x0800, 9, 16},
{&VideoMode_80x25_text, 0x1000, 9, 16},
{&VideoMode_80x25_text, 0x1000, 9, 16},
{&VideoMode_320x200_4color, 0x4000, 8, 8},
{&VideoMode_320x200_4color, 0x4000, 8, 8},
{&VideoMode_640x200_2color, 0x4000, 8, 8},
{NULL, 0x1000, 1, 1},
{NULL, 0x0000, 1, 1},
{NULL, 0x0000, 1, 1},
{NULL, 0x0000, 1, 1},
{NULL, 0x0000, 1, 1},
{NULL, 0x0000, 1, 1},
{&VideoMode_320x200_16color, 0x2000, 8, 8},
{&VideoMode_640x200_16color, 0x4000, 8, 8},
{NULL, 0x8000, 1, 1},
{&VideoMode_640x350_16color, 0x8000, 8, 14},
{&VideoMode_640x480_2color, 0xA000, 8, 16},
{&VideoMode_640x480_16color, 0xA000, 8, 16},
{&VideoMode_320x200_256color, 0x2000, 8, 8},
}
static VGA_REGISTERS VideoMode_640x200_2color
Definition: vidbios.c:122
static VGA_REGISTERS VideoMode_40x25_text
Definition: vidbios.c:59
static VGA_REGISTERS VideoMode_320x200_16color
Definition: vidbios.c:143
static VGA_REGISTERS VideoMode_640x200_16color
Definition: vidbios.c:164
static VGA_REGISTERS VideoMode_640x480_16color
Definition: vidbios.c:229
static VGA_REGISTERS VideoMode_80x25_text
Definition: vidbios.c:80
static VGA_REGISTERS VideoMode_320x200_4color
Definition: vidbios.c:101
static VGA_REGISTERS VideoMode_320x200_256color
Definition: vidbios.c:250
static VGA_REGISTERS VideoMode_640x350_16color
Definition: vidbios.c:185
static VGA_REGISTERS VideoMode_640x480_2color
Definition: vidbios.c:206

Definition at line 1941 of file vidbios.c.

Referenced by Pc98VidQueryMode(), Pc98VidSetCurrentMode(), and VidBiosSetVideoMode().