ReactOS 0.4.16-dev-92-g0c2cdca
svga.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "svga.h"
#include <bios/vidbios.h>
#include "memory.h"
#include "io.h"
#include "clock.h"
#include "../../console/video.h"
#include "../../console/video.c"
Include dependency graph for svga.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define WRAP_OFFSET(x)
 
#define USE_REACTOS_COLORS
 

Typedefs

typedef enum _SCREEN_MODE SCREEN_MODE
 
typedef enum _SCREEN_MODEPSCREEN_MODE
 

Enumerations

enum  _SCREEN_MODE { TEXT_MODE , GRAPHICS_MODE }
 

Functions

static DWORD VgaGetVideoBaseAddress (VOID)
 
static DWORD VgaGetAddressSize (VOID)
 
static DWORD VgaTranslateAddress (DWORD Address)
 
static BYTE VgaTranslateByteForWriting (BYTE Data, BYTE Plane)
 
static ULONG VgaGetClockFrequency (VOID)
 
static VOID VgaResetSequencer (VOID)
 
static VOID VgaRestoreDefaultPalette (PPALETTEENTRY Entries, USHORT NumOfEntries)
 
static BOOLEAN VgaInitializePalette (VOID)
 
static VOID VgaResetPalette (VOID)
 
static BOOL VgaEnterNewMode (SCREEN_MODE NewScreenMode, PCOORD Resolution)
 
static VOID VgaLeaveCurrentMode (VOID)
 
static VOID VgaChangeMode (VOID)
 
static VOID VgaMarkForUpdate (SHORT Row, SHORT Column)
 
static VOID VgaUpdateFramebuffer (VOID)
 
static VOID VgaUpdateTextCursor (VOID)
 
static BYTE WINAPI VgaReadPort (USHORT Port)
 
static VOID VgaWriteSequencer (BYTE Data)
 
static VOID VgaWriteGc (BYTE Data)
 
static VOID VgaWriteCrtc (BYTE Data)
 
static VOID VgaWriteDac (BYTE Data)
 
static VOID VgaWriteAc (BYTE Data)
 
static VOID WINAPI VgaWritePort (USHORT Port, BYTE Data)
 
static VOID VgaVerticalRetrace (VOID)
 
static VOID FASTCALL VgaHorizontalRetrace (ULONGLONG ElapsedTime)
 
COORD VgaGetDisplayResolution (VOID)
 
VOID VgaRefreshDisplay (VOID)
 
VOID FASTCALL VgaReadMemory (ULONG Address, PVOID Buffer, ULONG Size)
 
BOOLEAN FASTCALL VgaWriteMemory (ULONG Address, PVOID Buffer, ULONG Size)
 
VOID VgaClearMemory (VOID)
 
VOID VgaWriteTextModeFont (UINT FontNumber, CONST UCHAR *FontData, UINT Height)
 
BOOLEAN VgaInitialize (HANDLE TextHandle)
 
VOID VgaCleanup (VOID)
 

Variables

static CONST DWORD MemoryBase [] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 }
 
static CONST DWORD MemorySize [] = { 0x20000, 0x10000, 0x08000, 0x08000 }
 
static CONST COLORREF VgaDefaultPalette [VGA_MAX_COLORS]
 
static const COLORREF ConsoleColors [16]
 
static PVOID ActiveFramebuffer = NULL
 ConsoleFramebuffer.
 
static HPALETTE TextPaletteHandle = NULL
 
static HPALETTE PaletteHandle = NULL
 
static PCHAR_CELL TextFramebuffer = NULL
 
static PBYTE GraphicsFramebuffer = NULL
 
static BYTE VgaMemory [VGA_NUM_BANKS *SVGA_BANK_SIZE]
 
static BYTE VgaLatchRegisters [VGA_NUM_BANKS] = {0, 0, 0, 0}
 
static BYTE VgaMiscRegister
 
static BYTE VgaFeatureRegister
 
static BYTE VgaSeqIndex = VGA_SEQ_RESET_REG
 
static BYTE VgaSeqRegisters [SVGA_SEQ_MAX_REG]
 
static BYTE VgaCrtcIndex = VGA_CRTC_HORZ_TOTAL_REG
 
static BYTE VgaCrtcRegisters [SVGA_CRTC_MAX_REG]
 
static BYTE VgaGcIndex = VGA_GC_RESET_REG
 
static BYTE VgaGcRegisters [SVGA_GC_MAX_REG]
 
static BOOLEAN VgaAcLatch = FALSE
 
static BOOLEAN VgaAcPalDisable = TRUE
 
static BYTE VgaAcIndex = VGA_AC_PAL_0_REG
 
static BYTE VgaAcRegisters [VGA_AC_MAX_REG]
 
static BYTE VgaDacMask = 0xFF
 
static BYTE VgaDacLatchCounter = 0
 
static BYTE VgaDacLatch [3]
 
static BOOLEAN VgaDacReadWrite = FALSE
 
static WORD VgaDacIndex = 0
 
static BYTE VgaDacRegisters [VGA_PALETTE_SIZE]
 
static ULONGLONG HorizontalRetraceCycle = 0ULL
 
static PHARDWARE_TIMER HSyncTimer
 
static DWORD ScanlineCounter = 0
 
static DWORD StartAddressLatch = 0
 
static DWORD ScanlineSizeLatch = 0
 
static BOOLEAN NeedsUpdate = FALSE
 
static BOOLEAN ModeChanged = FALSE
 
static BOOLEAN CursorChanged = FALSE
 
static BOOLEAN PaletteChanged = FALSE
 
static UINT SvgaHdrCounter = 0
 
static BYTE SvgaHiddenRegister = 0
 
static SCREEN_MODE ScreenMode = TEXT_MODE
 
static COORD CurrResolution = {0}
 
static SMALL_RECT UpdateRectangle = { 0, 0, 0, 0 }
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file svga.c.

◆ USE_REACTOS_COLORS

#define USE_REACTOS_COLORS

Definition at line 34 of file svga.c.

◆ WRAP_OFFSET

#define WRAP_OFFSET (   x)
Value:
? ((x) & 0xFFFFF) : LOWORD(x))
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define LOWORD(l)
Definition: pedump.c:82
static BYTE VgaCrtcRegisters[SVGA_CRTC_MAX_REG]
Definition: svga.c:255
#define SVGA_CRTC_EXT_ADDR_WRAP
Definition: svga.h:194
@ SVGA_CRTC_EXT_DISPLAY_REG
Definition: svga.h:231

Definition at line 28 of file svga.c.

Typedef Documentation

◆ PSCREEN_MODE

◆ SCREEN_MODE

Enumeration Type Documentation

◆ _SCREEN_MODE

Enumerator
TEXT_MODE 
GRAPHICS_MODE 

Definition at line 289 of file svga.c.

290{
291 TEXT_MODE,
enum _SCREEN_MODE SCREEN_MODE
@ GRAPHICS_MODE
Definition: svga.c:292
@ TEXT_MODE
Definition: svga.c:291
enum _SCREEN_MODE * PSCREEN_MODE

Function Documentation

◆ VgaChangeMode()

static VOID VgaChangeMode ( VOID  )
static

Definition at line 674 of file svga.c.

675{
676 COORD NewResolution = VgaGetDisplayResolution();
677 SCREEN_MODE NewScreenMode =
680
681 /*
682 * Do not switch to a different screen mode + resolution if the new settings
683 * are the same as the old ones. Just repaint the full screen.
684 */
685 if ((ScreenMode == NewScreenMode) && // CurrResolution == NewResolution
686 (CurrResolution.X == NewResolution.X && CurrResolution.Y == NewResolution.Y))
687 {
688 goto Quit;
689 }
690
691 // FIXME: Wouldn't it be preferrable to switch to the new console SB
692 // *ONLY* if we succeeded in setting the new mode??
693
694 /* Leave the current video mode */
695 VgaLeaveCurrentMode(); // ScreenMode
696
697 /* Update the current resolution */
698 CurrResolution = NewResolution;
699
700 /* Change the screen mode */
701 if (!VgaEnterNewMode(NewScreenMode, &CurrResolution))
702 return;
703
704Quit:
705
706 /* Trigger a full update of the screen */
712
713 /* Reset the mode change flag */
715}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
SHORT Top
Definition: tui.c:25
SHORT Right
Definition: tui.c:26
SHORT Left
Definition: tui.c:24
SHORT Bottom
Definition: tui.c:27
static COORD CurrResolution
Definition: svga.c:296
static VOID VgaLeaveCurrentMode(VOID)
Definition: svga.c:651
static BOOL VgaEnterNewMode(SCREEN_MODE NewScreenMode, PCOORD Resolution)
Definition: svga.c:604
static SCREEN_MODE ScreenMode
Definition: svga.c:295
static BOOLEAN NeedsUpdate
Definition: svga.c:281
static BYTE VgaGcRegisters[SVGA_GC_MAX_REG]
Definition: svga.c:258
static SMALL_RECT UpdateRectangle
Definition: svga.c:298
static BOOLEAN ModeChanged
Definition: svga.c:282
COORD VgaGetDisplayResolution(VOID)
Definition: svga.c:1727
#define VGA_GC_MISC_NOALPHA
Definition: svga.h:259
@ VGA_GC_MISC_REG
Definition: svga.h:274

Referenced by VgaVerticalRetrace().

◆ VgaCleanup()

VOID VgaCleanup ( VOID  )

Definition at line 2145 of file svga.c.

2146{
2147 /* Do a final display refresh */
2149
2151
2152 /* Leave the current video mode */
2153 VgaLeaveCurrentMode(); // ScreenMode
2154
2155 MemRemoveFastMemoryHook((PVOID)0xA0000, 0x20000);
2156
2158}
VOID DestroyHardwareTimer(PHARDWARE_TIMER Timer)
Definition: clock.c:210
VOID VgaConsoleCleanup(VOID)
Definition: video.c:807
BOOL MemRemoveFastMemoryHook(PVOID Address, ULONG Size)
Definition: memory.c:353
static PHARDWARE_TIMER HSyncTimer
Definition: svga.c:276
VOID VgaRefreshDisplay(VOID)
Definition: svga.c:1783

Referenced by EmulatorCleanup().

◆ VgaClearMemory()

VOID VgaClearMemory ( VOID  )

Definition at line 2074 of file svga.c.

2075{
2077}
static BYTE VgaMemory[VGA_NUM_BANKS *SVGA_BANK_SIZE]
Definition: svga.c:244
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by VbeSetExtendedVideoMode(), VgaInitialize(), and VidBiosSetVideoMode().

◆ VgaEnterNewMode()

static BOOL VgaEnterNewMode ( SCREEN_MODE  NewScreenMode,
PCOORD  Resolution 
)
static

Definition at line 604 of file svga.c.

605{
606 /* Check if the new mode is alphanumeric */
607 if (NewScreenMode == TEXT_MODE)
608 {
609 /* Enter new text mode */
610
611 if (!VgaConsoleCreateTextScreen(// &TextFramebuffer,
614 {
615 DisplayMessage(L"An unexpected VGA error occurred while switching into text mode. Error: %u", GetLastError());
617 return FALSE;
618 }
619
620 /* The active framebuffer is now the text framebuffer */
622
623 /* Set the screen mode flag */
625
626 return TRUE;
627 }
628 else
629 {
630 /* Enter graphics mode */
631
632 if (!VgaConsoleCreateGraphicsScreen(// &GraphicsFramebuffer,
635 {
636 DisplayMessage(L"An unexpected VGA error occurred while switching into graphics mode. Error: %u", GetLastError());
638 return FALSE;
639 }
640
641 /* The active framebuffer is now the graphics framebuffer */
643
644 /* Set the screen mode flag */
646
647 return TRUE;
648 }
649}
INT __cdecl DisplayMessage(_In_opt_ HWND hWnd, _In_ UINT uType, _In_opt_ PCWSTR pszTitle, _In_opt_ PCWSTR pszFormatMessage,...)
Definition: reactos.c:211
VOID EmulatorTerminate(VOID)
Definition: emulator.c:503
#define L(x)
Definition: ntvdm.h:50
BOOL VgaConsoleCreateGraphicsScreen(IN PCOORD Resolution, IN HANDLE PaletteHandle)
Definition: video.c:610
BOOL VgaConsoleCreateTextScreen(IN PCOORD Resolution, IN HANDLE PaletteHandle)
Definition: video.c:698
static BYTE Resolution
Definition: mouse.c:35
static HPALETTE TextPaletteHandle
Definition: svga.c:214
static HPALETTE PaletteHandle
Definition: svga.c:215
static PCHAR_CELL TextFramebuffer
Definition: svga.c:224
static PBYTE GraphicsFramebuffer
Definition: svga.c:229
static PVOID ActiveFramebuffer
ConsoleFramebuffer.
Definition: svga.c:211
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by VgaChangeMode().

◆ VgaGetAddressSize()

static DWORD VgaGetAddressSize ( VOID  )
inlinestatic

Definition at line 318 of file svga.c.

319{
321 {
322 /* Packed pixel addressing */
323 return 1;
324 }
326 {
327 /* Double-word addressing */
328 return 4; // sizeof(DWORD)
329 }
331 {
332 /* Byte addressing */
333 return 1; // sizeof(BYTE)
334 }
335 else
336 {
337 /* Word addressing */
338 return 2; // sizeof(WORD)
339 }
340}
static BYTE VgaSeqRegisters[SVGA_SEQ_MAX_REG]
Definition: svga.c:252
#define VGA_CRTC_UNDERLINE_DWORD
Definition: svga.h:181
@ SVGA_SEQ_EXT_MODE_REG
Definition: svga.h:138
#define VGA_CRTC_MODE_CONTROL_BYTE
Definition: svga.h:189
@ VGA_CRTC_UNDERLINE_REG
Definition: svga.h:223
@ VGA_CRTC_MODE_CONTROL_REG
Definition: svga.h:226
#define SVGA_SEQ_EXT_MODE_HIGH_RES
Definition: svga.h:120

Referenced by VgaUpdateFramebuffer().

◆ VgaGetClockFrequency()

static ULONG VgaGetClockFrequency ( VOID  )
inlinestatic

Definition at line 432 of file svga.c.

433{
434 BYTE Numerator, Denominator;
435
437 {
438 /* The VCLK is being generated using the MCLK */
440
442 {
443 /* Use only half of the MCLK as the VCLK */
444 Clock >>= 1;
445 }
446
447 return Clock;
448 }
449
450 switch ((VgaMiscRegister >> 2) & 3)
451 {
452 case 0:
453 {
456 break;
457 }
458
459 case 1:
460 {
463 break;
464 }
465
466 case 2:
467 {
470 break;
471 }
472
473 case 3:
474 {
477 break;
478 }
479 }
480
481 /* The numerator is 7-bit */
482 Numerator &= ~(1 << 7);
483
484 /* If bit 7 is clear, the denominator is 5-bit */
485 if (!(Denominator & (1 << 7))) Denominator &= ~(1 << 6);
486
487 /* Bit 0 of the denominator is the post-scalar bit */
488 if (Denominator & 1) Denominator &= ~1;
489 else Denominator >>= 1;
490
491 /* Return the clock frequency in Hz */
492 return (VGA_CLOCK_BASE * Numerator) / Denominator;
493}
time_t Clock
Definition: output.c:18
static BYTE VgaMiscRegister
Definition: svga.c:248
@ SVGA_SEQ_VCLK1_DENOMINATOR_REG
Definition: svga.h:159
@ SVGA_SEQ_VCLK0_DENOMINATOR_REG
Definition: svga.h:158
@ SVGA_SEQ_VCLK2_NUMERATOR_REG
Definition: svga.h:144
@ SVGA_SEQ_VCLK3_NUMERATOR_REG
Definition: svga.h:145
@ SVGA_SEQ_VCLK3_DENOMINATOR_REG
Definition: svga.h:161
@ SVGA_SEQ_MCLK_REG
Definition: svga.h:162
@ SVGA_SEQ_VCLK2_DENOMINATOR_REG
Definition: svga.h:160
@ SVGA_SEQ_VCLK0_NUMERATOR_REG
Definition: svga.h:142
@ SVGA_SEQ_VCLK1_NUMERATOR_REG
Definition: svga.h:143
#define VGA_CLOCK_BASE
Definition: svga.h:28
#define SVGA_SEQ_MCLK_VCLK
Definition: svga.h:127
uint32_t ULONG
Definition: typedefs.h:59
unsigned char BYTE
Definition: xxhash.c:193

Referenced by VgaHorizontalRetrace(), and VgaReadPort().

◆ VgaGetDisplayResolution()

COORD VgaGetDisplayResolution ( VOID  )

Definition at line 1727 of file svga.c.

1728{
1730 BYTE MaximumScanLine = 1 + (VgaCrtcRegisters[VGA_CRTC_MAX_SCAN_LINE_REG] & 0x1F);
1731
1732 /* The low 8 bits are in the display registers */
1735
1736 /* Set the top bits from the overflow register */
1738 {
1739 Resolution.Y |= 1 << 8;
1740 }
1742 {
1743 Resolution.Y |= 1 << 9;
1744 }
1745
1746 /* Increase the values by 1 */
1747 Resolution.X++;
1748 Resolution.Y++;
1749
1751 {
1752 /* In "High Resolution" mode, the width of a character is always 8 pixels */
1754 {
1755 Resolution.X *= 8;
1756 }
1757 else
1758 {
1759 /* Multiply the horizontal resolution by the 9/8 dot mode */
1761 ? 8 : 9;
1762
1763 /* The horizontal resolution is halved in 8-bit mode */
1765 }
1766 }
1767
1769 {
1770 /* Halve the vertical resolution */
1771 Resolution.Y >>= 1;
1772 }
1773 else
1774 {
1775 /* Divide the vertical resolution by the maximum scan line (== font size in text mode) */
1776 Resolution.Y /= MaximumScanLine;
1777 }
1778
1779 /* Return the resolution */
1780 return Resolution;
1781}
static BYTE VgaAcRegisters[VGA_AC_MAX_REG]
Definition: svga.c:263
#define VGA_CRTC_OVERFLOW_VDE8
Definition: svga.h:172
#define VGA_CRTC_MAXSCANLINE_DOUBLE
Definition: svga.h:184
#define VGA_SEQ_CLOCK_98DM
Definition: svga.h:104
#define VGA_CRTC_OVERFLOW_VDE9
Definition: svga.h:177
#define VGA_AC_CONTROL_8BIT
Definition: svga.h:336
@ VGA_AC_CONTROL_REG
Definition: svga.h:357
@ VGA_SEQ_CLOCK_REG
Definition: svga.h:132
@ VGA_CRTC_MAX_SCAN_LINE_REG
Definition: svga.h:212
@ VGA_CRTC_VERT_DISP_END_REG
Definition: svga.h:221
@ VGA_CRTC_OVERFLOW_REG
Definition: svga.h:210
@ VGA_CRTC_END_HORZ_DISP_REG
Definition: svga.h:204

Referenced by DosUpdatePosition(), FromMouseCoordinates(), ToMouseCoordinates(), VgaChangeMode(), and VidBiosSetVideoMode().

◆ VgaGetVideoBaseAddress()

static DWORD VgaGetVideoBaseAddress ( VOID  )
inlinestatic

HACK!! HACK!!

Definition at line 313 of file svga.c.

314{
315 return MemoryBase[(VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03];
316}
static CONST DWORD MemoryBase[]
Definition: svga.c:31

Referenced by VgaTranslateAddress().

◆ VgaHorizontalRetrace()

static VOID FASTCALL VgaHorizontalRetrace ( ULONGLONG  ElapsedTime)
static

Definition at line 1655 of file svga.c.

1656{
1659 BOOLEAN BeforeVSync;
1661 ULONG Dots = (VgaSeqRegisters[VGA_SEQ_CLOCK_REG] & 1) ? 9 : 8;
1662 ULONG HorizTotalDots = ((ULONG)VgaCrtcRegisters[VGA_CRTC_HORZ_TOTAL_REG] + 5) * Dots;
1663 BYTE MaximumScanLine = 1 + (VgaCrtcRegisters[VGA_CRTC_MAX_SCAN_LINE_REG] & 0x1F);
1664 ULONG HSyncsPerSecond, HSyncs;
1665 UNREFERENCED_PARAMETER(ElapsedTime);
1666
1667 if (VgaAcRegisters[VGA_AC_CONTROL_REG] & VGA_AC_CONTROL_8BIT) HorizTotalDots >>= 1;
1668
1669 HSyncsPerSecond = VgaGetClockFrequency() / HorizTotalDots;
1670 HSyncs = (ElapsedCycles * HSyncsPerSecond + (CurrentIps >> 1)) / CurrentIps;
1671 if (HSyncs == 0) HSyncs = 1;
1672
1675
1676 VerticalRetraceStart |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VRS8) << 6;
1677 VerticalRetraceStart |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VRS9) << 2;
1678
1680 {
1682 {
1683 VerticalRetraceStart <<= 1;
1684 VerticalTotal <<= 1;
1685 }
1686 else
1687 {
1688 VerticalRetraceStart *= MaximumScanLine;
1689 VerticalTotal *= MaximumScanLine;
1690 }
1691 }
1692
1693 /* Set the cycle */
1695
1696 /* Increment the scanline counter, but make sure we don't skip any part of the vertical retrace */
1697 BeforeVSync = (ScanlineCounter < VerticalRetraceStart);
1698 ScanlineCounter += HSyncs;
1699 if (BeforeVSync && ScanlineCounter >= VerticalRetraceStart) ScanlineCounter = VerticalRetraceStart;
1700
1701 if (ScanlineCounter == VerticalRetraceStart)
1702 {
1703 /* Save the scanline size */
1707
1708 /* Save the starting address */
1716 }
1717
1718 if (ScanlineCounter > VerticalTotal)
1719 {
1720 ScanlineCounter = 0;
1722 }
1723}
unsigned char BOOLEAN
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
ULONGLONG CurrentIps
Definition: clock.c:49
ULONGLONG CurrentCycleCount
Definition: clock.c:48
static DWORD ScanlineSizeLatch
Definition: svga.c:279
static DWORD ScanlineCounter
Definition: svga.c:277
static ULONGLONG HorizontalRetraceCycle
Definition: svga.c:275
static ULONG VgaGetClockFrequency(VOID)
Definition: svga.c:432
static VOID VgaVerticalRetrace(VOID)
Definition: svga.c:1613
static DWORD StartAddressLatch
Definition: svga.c:278
#define SVGA_CRTC_EXT_ADDR_BIT16
Definition: svga.h:193
#define SVGA_CRTC_EXT_OFFSET_BIT8
Definition: svga.h:196
#define VGA_CRTC_OVERFLOW_VRS9
Definition: svga.h:178
#define VGA_CRTC_OVERFLOW_VRS8
Definition: svga.h:173
#define SVGA_CRTC_EXT_ADDR_BIT19
Definition: svga.h:199
#define VGA_CRTC_OVERFLOW_VT9
Definition: svga.h:176
#define VGA_CRTC_OVERFLOW_VT8
Definition: svga.h:171
@ VGA_CRTC_VERT_TOTAL_REG
Definition: svga.h:209
@ VGA_CRTC_START_ADDR_LOW_REG
Definition: svga.h:216
@ VGA_CRTC_PRESET_ROW_SCAN_REG
Definition: svga.h:211
@ SVGA_CRTC_OVERLAY_REG
Definition: svga.h:233
@ VGA_CRTC_START_VERT_RETRACE_REG
Definition: svga.h:219
@ VGA_CRTC_OFFSET_REG
Definition: svga.h:222
@ VGA_CRTC_START_ADDR_HIGH_REG
Definition: svga.h:215
@ VGA_CRTC_HORZ_TOTAL_REG
Definition: svga.h:203
#define SVGA_CRTC_EXT_ADDR_BITS1718
Definition: svga.h:195
#define MAKEWORD(a, b)
Definition: typedefs.h:248

Referenced by VgaInitialize().

◆ VgaInitialize()

BOOLEAN NTAPI VgaInitialize ( HANDLE  TextHandle)

Definition at line 2100 of file svga.c.

2101{
2102 if (!VgaConsoleInitialize(TextHandle)) return FALSE;
2103
2104 /* Clear the SEQ, GC, CRTC and AC registers */
2109
2110 /* Initialize the VGA palette and fail if it isn't successfully created */
2111 if (!VgaInitializePalette()) return FALSE;
2112 /***/ VgaResetPalette(); /***/
2113
2114 /* Reset the sequencer */
2116
2117 /* Clear the VGA memory */
2119
2120 /* Register the I/O Ports */
2121 RegisterIoPort(0x3CC, VgaReadPort, NULL); // VGA_MISC_READ
2122 RegisterIoPort(0x3C2, VgaReadPort, VgaWritePort); // VGA_MISC_WRITE, VGA_INSTAT0_READ
2123 RegisterIoPort(0x3CA, VgaReadPort, NULL); // VGA_FEATURE_READ
2124 RegisterIoPort(0x3C0, VgaReadPort, VgaWritePort); // VGA_AC_INDEX, VGA_AC_WRITE
2125 RegisterIoPort(0x3C1, VgaReadPort, NULL); // VGA_AC_READ
2126 RegisterIoPort(0x3C4, VgaReadPort, VgaWritePort); // VGA_SEQ_INDEX
2127 RegisterIoPort(0x3C5, VgaReadPort, VgaWritePort); // VGA_SEQ_DATA
2128 RegisterIoPort(0x3C6, VgaReadPort, VgaWritePort); // VGA_DAC_MASK
2129 RegisterIoPort(0x3C7, VgaReadPort, VgaWritePort); // VGA_DAC_READ_INDEX
2130 RegisterIoPort(0x3C8, VgaReadPort, VgaWritePort); // VGA_DAC_WRITE_INDEX
2131 RegisterIoPort(0x3C9, VgaReadPort, VgaWritePort); // VGA_DAC_DATA
2132 RegisterIoPort(0x3CE, VgaReadPort, VgaWritePort); // VGA_GC_INDEX
2133 RegisterIoPort(0x3CF, VgaReadPort, VgaWritePort); // VGA_GC_DATA
2134
2135 /* CGA ports for compatibility, unimplemented */
2136 RegisterIoPort(0x3D8, VgaReadPort, VgaWritePort); // CGA_MODE_CTRL_REG
2137 RegisterIoPort(0x3D9, VgaReadPort, VgaWritePort); // CGA_PAL_CTRL_REG
2138
2140
2141 /* Return success */
2142 return TRUE;
2143}
#define HARDWARE_TIMER_ENABLED
Definition: clock.h:15
#define HZ_TO_NS(Freq)
Definition: clock.h:20
#define NULL
Definition: types.h:112
PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONGLONG Delay, PHARDWARE_TIMER_PROC Callback)
Definition: clock.c:144
BOOLEAN VgaConsoleInitialize(HANDLE TextHandle)
Definition: video.c:783
VOID RegisterIoPort(USHORT Port, EMULATOR_INB_PROC InHandler, EMULATOR_OUTB_PROC OutHandler)
Definition: io.c:320
static VOID VgaResetPalette(VOID)
Definition: svga.c:594
static BYTE WINAPI VgaReadPort(USHORT Port)
Definition: svga.c:1104
static BOOLEAN VgaInitializePalette(VOID)
Definition: svga.c:534
static VOID FASTCALL VgaHorizontalRetrace(ULONGLONG ElapsedTime)
Definition: svga.c:1655
static VOID VgaResetSequencer(VOID)
Definition: svga.c:495
static VOID WINAPI VgaWritePort(USHORT Port, BYTE Data)
Definition: svga.c:1420
VOID VgaClearMemory(VOID)
Definition: svga.c:2074

Referenced by EmulatorInitialize().

◆ VgaInitializePalette()

static BOOLEAN VgaInitializePalette ( VOID  )
static

Definition at line 534 of file svga.c.

535{
536 UINT i;
538 LPLOGPALETTE Palette, TextPalette;
539
540 /* Allocate storage space for the palettes */
541 Palette = RtlAllocateHeap(RtlGetProcessHeap(),
543 sizeof(LOGPALETTE) +
544 VGA_MAX_COLORS * sizeof(PALETTEENTRY));
545 TextPalette = RtlAllocateHeap(RtlGetProcessHeap(),
547 sizeof(LOGPALETTE) +
548 (VGA_AC_PAL_F_REG + 1) * sizeof(PALETTEENTRY));
549 if ((Palette == NULL) || (TextPalette == NULL)) goto Cleanup;
550
551 /* Initialize the palettes */
552 Palette->palVersion = TextPalette->palVersion = 0x0300;
553 Palette->palNumEntries = VGA_MAX_COLORS;
554 TextPalette->palNumEntries = VGA_AC_PAL_F_REG + 1;
555
556 /* Restore the default graphics palette */
557 VgaRestoreDefaultPalette(Palette->palPalEntry, Palette->palNumEntries);
558
559 /* Set the default text palette */
560 for (i = 0; i < TextPalette->palNumEntries; i++)
561 {
562 /* Set the palette entries */
563 TextPalette->palPalEntry[i].peRed = GetRValue(ConsoleColors[i]);
564 TextPalette->palPalEntry[i].peGreen = GetGValue(ConsoleColors[i]);
565 TextPalette->palPalEntry[i].peBlue = GetBValue(ConsoleColors[i]);
566 TextPalette->palPalEntry[i].peFlags = 0;
567 }
568
569 /* Create the palettes */
570 PaletteHandle = CreatePalette(Palette);
571 TextPaletteHandle = CreatePalette(TextPalette);
572
574 {
575 /* The palettes have been created successfully */
576 Result = TRUE;
577 }
578
579Cleanup:
580 /* Free the palettes */
581 if (Palette) RtlFreeHeap(RtlGetProcessHeap(), 0, Palette);
582 if (TextPalette) RtlFreeHeap(RtlGetProcessHeap(), 0, TextPalette);
583
584 if (!Result)
585 {
586 /* Something failed, delete the palettes */
589 }
590
591 return Result;
592}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const WCHAR Cleanup[]
Definition: register.c:80
#define GetBValue(quad)
Definition: precomp.h:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
pKey DeleteObject()
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
WORD palNumEntries
Definition: wingdi.h:1834
WORD palVersion
Definition: wingdi.h:1833
static const COLORREF ConsoleColors[16]
Definition: svga.c:189
static VOID VgaRestoreDefaultPalette(PPALETTEENTRY Entries, USHORT NumOfEntries)
Definition: svga.c:514
@ VGA_AC_PAL_F_REG
Definition: svga.h:356
#define VGA_MAX_COLORS
Definition: svga.h:16
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by VgaInitialize().

◆ VgaLeaveCurrentMode()

static VOID VgaLeaveCurrentMode ( VOID  )
static

Definition at line 651 of file svga.c.

652{
653 /* Leave the current video mode */
655 {
657
658 /* Cleanup the video data */
660 }
661 else
662 {
664
665 /* Cleanup the video data */
666 // TextFramebuffer = NULL;
667 // NEVER SET the ALWAYS-SET TextFramebuffer pointer to NULL!!
668 }
669
670 /* Reset the active framebuffer */
672}
VOID VgaConsoleDestroyTextScreen(VOID)
Definition: video.c:744
VOID VgaConsoleDestroyGraphicsScreen(VOID)
Definition: video.c:675

Referenced by VgaChangeMode(), and VgaCleanup().

◆ VgaMarkForUpdate()

static VOID VgaMarkForUpdate ( SHORT  Row,
SHORT  Column 
)
inlinestatic

Definition at line 717 of file svga.c.

718{
719 /* Check if this is the first time the rectangle is updated */
720 if (!NeedsUpdate)
721 {
724 }
725
726 /* Expand the rectangle to include the point */
731
732 /* Set the update request flag */
734}
#define min(a, b)
Definition: monoChain.cc:55
#define max(a, b)
Definition: svc.c:63
#define MAXSHORT
Definition: umtypes.h:114
#define MINSHORT
Definition: umtypes.h:113

Referenced by VgaUpdateFramebuffer().

◆ VgaReadMemory()

VOID FASTCALL VgaReadMemory ( ULONG  Address,
PVOID  Buffer,
ULONG  Size 
)

Definition at line 1802 of file svga.c.

1803{
1804 DWORD i;
1805 DWORD VideoAddress;
1806 PUCHAR BufPtr = (PUCHAR)Buffer;
1807
1808 DPRINT("VgaReadMemory: Address 0x%08X, Size %lu\n", Address, Size);
1809
1810 /* Ignore if video RAM access is disabled */
1811 if (!Size) return;
1812 if ((VgaMiscRegister & VGA_MISC_RAM_ENABLED) == 0) return;
1813
1815 {
1816 VideoAddress = VgaTranslateAddress(Address);
1817
1818 /* Check for packed pixel, chain-4, and odd-even mode */
1820 {
1821 /* Just copy from the video memory */
1822 PVOID VideoMemory = &VgaMemory[VideoAddress + (Address & 3)];
1823
1824 switch (Size)
1825 {
1826 case sizeof(UCHAR):
1827 *(PUCHAR)Buffer = *(PUCHAR)VideoMemory;
1828 return;
1829
1830 case sizeof(USHORT):
1831 *(PUSHORT)Buffer = *(PUSHORT)VideoMemory;
1832 return;
1833
1834 case sizeof(ULONG):
1835 *(PULONG)Buffer = *(PULONG)VideoMemory;
1836 return;
1837
1838 case sizeof(ULONGLONG):
1839 *(PULONGLONG)Buffer = *(PULONGLONG)VideoMemory;
1840 return;
1841
1842 default:
1843#if defined(__GNUC__)
1844 __builtin_memcpy(Buffer, VideoMemory, Size);
1845#else
1846 RtlCopyMemory(Buffer, VideoMemory, Size);
1847#endif
1848 }
1849 }
1851 {
1852 i = 0;
1853
1854 /* Write the unaligned part first */
1855 if (Address & 3)
1856 {
1857 switch (Address & 3)
1858 {
1859 case 1:
1860 BufPtr[i++] = VgaMemory[VideoAddress * VGA_NUM_BANKS + 1];
1861 case 2:
1862 BufPtr[i++] = VgaMemory[VideoAddress * VGA_NUM_BANKS + 2];
1863 case 3:
1864 BufPtr[i++] = VgaMemory[VideoAddress * VGA_NUM_BANKS + 3];
1865 }
1866
1867 VideoAddress += 4;
1868 }
1869
1870 /* Copy the aligned dwords */
1871 while ((i + 3) < Size)
1872 {
1873 *(PULONG)&BufPtr[i] = *(PULONG)&VgaMemory[VideoAddress * VGA_NUM_BANKS];
1874
1875 i += 4;
1876 VideoAddress += 4;
1877 }
1878
1879 /* Write the remaining part */
1880 if (i < Size)
1881 {
1882 switch (Size - i - 3)
1883 {
1884 case 3:
1885 BufPtr[i] = VgaMemory[VideoAddress * VGA_NUM_BANKS + ((Address + i) & 3)];
1886 i++;
1887 case 2:
1888 BufPtr[i] = VgaMemory[VideoAddress * VGA_NUM_BANKS + ((Address + i) & 3)];
1889 i++;
1890 case 1:
1891 BufPtr[i] = VgaMemory[VideoAddress * VGA_NUM_BANKS + ((Address + i) & 3)];
1892 i++;
1893 }
1894 }
1895 }
1897 {
1898 i = 0;
1899
1900 /* Check if the starting address is odd */
1901 if (Address & 1)
1902 {
1903 BufPtr[i++] = VgaMemory[VideoAddress * VGA_NUM_BANKS + 1];
1904 VideoAddress += 2;
1905 }
1906
1907 while (i < (Size - 1))
1908 {
1909 *(PUSHORT)&BufPtr[i] = *(PUSHORT)&VgaMemory[VideoAddress * VGA_NUM_BANKS];
1910
1911 i += 2;
1912 VideoAddress += 2;
1913 }
1914
1915 /* Check if there is one more byte to read */
1916 if (i == Size - 1) BufPtr[i] = VgaMemory[VideoAddress * VGA_NUM_BANKS + ((Address + i) & 1)];
1917 }
1918 else
1919 {
1920 /* Use the selected map */
1922
1923 for (i = 0; i < Size; i++)
1924 {
1925 /* Copy the value to the buffer */
1926 BufPtr[i] = VgaMemory[(VideoAddress++) * VGA_NUM_BANKS + Plane];
1927 }
1928 }
1929 }
1930 else
1931 {
1932 const ULONG BitExpandInvertTable[] =
1933 {
1934 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF00FF, 0xFFFF0000,
1935 0xFF00FFFF, 0xFF00FF00, 0xFF0000FF, 0xFF000000,
1936 0x00FFFFFF, 0x00FFFF00, 0x00FF00FF, 0x00FF0000,
1937 0x0000FFFF, 0x0000FF00, 0x000000FF, 0x00000000
1938 };
1939
1940 ULONG ColorCompareBytes = BitExpandInvertTable[VgaGcRegisters[VGA_GC_COLOR_COMPARE_REG] & 0x0F];
1941 ULONG ColorIgnoreBytes = BitExpandInvertTable[VgaGcRegisters[VGA_GC_COLOR_IGNORE_REG] & 0x0F];
1942
1943 /*
1944 * These values can also be computed in the following way, but using the table seems to be faster:
1945 *
1946 * ColorCompareBytes = VgaGcRegisters[VGA_GC_COLOR_COMPARE_REG] * 0x000204081;
1947 * ColorCompareBytes &= 0x01010101;
1948 * ColorCompareBytes = ~((ColorCompareBytes << 8) - ColorCompareBytes);
1949 *
1950 * ColorIgnoreBytes = VgaGcRegisters[VGA_GC_COLOR_IGNORE_REG] * 0x000204081;
1951 * ColorIgnoreBytes &= 0x01010101;
1952 * ColorIgnoreBytes = ~((ColorIgnoreBytes << 8) - ColorIgnoreBytes);
1953 */
1954
1955 /* Loop through each byte */
1956 for (i = 0; i < Size; i++)
1957 {
1958 ULONG PlaneData = 0;
1959
1960 /* This should always return a plane 0 address */
1961 VideoAddress = VgaTranslateAddress(Address + i);
1962
1963 /* Read all 4 planes */
1964 PlaneData = *(PULONG)&VgaMemory[VideoAddress * VGA_NUM_BANKS];
1965
1966 /* Reverse the bytes for which the color compare register is zero */
1967 PlaneData ^= ColorCompareBytes;
1968
1969 /* Apply the color ignore register */
1970 PlaneData |= ColorIgnoreBytes;
1971
1972 /* Store the value in the buffer */
1973 BufPtr[i] = (PlaneData & (PlaneData >> 8) & (PlaneData >> 16) & (PlaneData >> 24)) & 0xFF;
1974 }
1975 }
1976
1977 /* Load the latch registers */
1978 VideoAddress = VgaTranslateAddress(Address + Size - 1);
1980}
Definition: bufpool.h:45
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:383
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
#define DPRINT
Definition: sndvol32.h:73
static DWORD VgaTranslateAddress(DWORD Address)
Definition: svga.c:342
static BYTE VgaLatchRegisters[VGA_NUM_BANKS]
Definition: svga.c:246
#define WRAP_OFFSET(x)
Definition: svga.c:28
#define VGA_MISC_RAM_ENABLED
Definition: svga.h:83
@ VGA_SEQ_MEM_REG
Definition: svga.h:135
#define VGA_GC_MODE_OE
Definition: svga.h:254
#define VGA_NUM_BANKS
Definition: svga.h:14
#define VGA_GC_MODE_READ
Definition: svga.h:253
@ VGA_GC_READ_MAP_SEL_REG
Definition: svga.h:272
@ VGA_GC_COLOR_IGNORE_REG
Definition: svga.h:275
@ VGA_GC_COLOR_COMPARE_REG
Definition: svga.h:270
@ VGA_GC_MODE_REG
Definition: svga.h:273
#define VGA_SEQ_MEM_C4
Definition: svga.h:113
uint32_t * PULONG
Definition: typedefs.h:59
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
uint64_t ULONGLONG
Definition: typedefs.h:67
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by VgaWriteGc(), and VgaWritePort().

◆ VgaReadPort()

static BYTE WINAPI VgaReadPort ( USHORT  Port)
static

Definition at line 1104 of file svga.c.

1105{
1106 DPRINT("VgaReadPort: Port 0x%X\n", Port);
1107
1108 if (Port != VGA_DAC_MASK) SvgaHdrCounter = 0;
1109
1110 switch (Port)
1111 {
1112 case VGA_MISC_READ:
1113 return VgaMiscRegister;
1114
1115 case VGA_INSTAT0_READ:
1116 return 0; // Not implemented
1117
1120 {
1121 BYTE Result = 0;
1122 BOOLEAN Vsync, Hsync;
1124 ULONG CyclesPerMicrosecond = (ULONG)((CurrentIps + 500000ULL) / 1000000ULL);
1125 ULONG Dots = (VgaSeqRegisters[VGA_SEQ_CLOCK_REG] & 1) ? 9 : 8;
1126 ULONG Clock = VgaGetClockFrequency() / 1000000;
1127 ULONG HblankStart, HblankEnd;
1128 ULONG HblankDuration;
1130 ULONG VerticalRetraceEnd;
1131
1132 VerticalRetraceStart |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VRS8) << 6;
1133 VerticalRetraceStart |= (VgaCrtcRegisters[VGA_CRTC_OVERFLOW_REG] & VGA_CRTC_OVERFLOW_VRS9) << 2;
1134
1135 VerticalRetraceEnd = VerticalRetraceStart + (VgaCrtcRegisters[VGA_CRTC_END_VERT_RETRACE_REG] & 0x0F);
1136
1138 {
1139 BYTE MaximumScanLine = 1 + (VgaCrtcRegisters[VGA_CRTC_MAX_SCAN_LINE_REG] & 0x1F);
1140
1142 {
1143 VerticalRetraceStart <<= 1;
1144 VerticalRetraceEnd <<= 1;
1145 }
1146 else
1147 {
1148 VerticalRetraceStart *= MaximumScanLine;
1149 VerticalRetraceEnd *= MaximumScanLine;
1150 }
1151 }
1152
1153 /* Calculate the horizontal blanking duration in cycles */
1156 if (HblankEnd < HblankStart) HblankEnd |= 0x20;
1157 HblankDuration = ((HblankEnd - HblankStart) * Dots
1158 * CyclesPerMicrosecond + (Clock >> 1)) / Clock;
1159
1160 Vsync = ScanlineCounter >= VerticalRetraceStart && ScanlineCounter <= VerticalRetraceEnd;
1161 Hsync = (Cycles - HorizontalRetraceCycle) < (ULONGLONG)HblankDuration;
1162
1163 /* Reset the AC latch */
1164 VgaAcLatch = FALSE;
1165
1166 /* Set a flag if there is a vertical or horizontal retrace */
1167 if (Vsync || Hsync) Result |= VGA_STAT_DD;
1168
1169 /* Set an additional flag if there was a vertical retrace */
1170 if (Vsync) Result |= VGA_STAT_VRETRACE;
1171
1172 return Result;
1173 }
1174
1175 case VGA_FEATURE_READ:
1176 return VgaFeatureRegister;
1177
1178 case VGA_AC_INDEX:
1179 return VgaAcIndex | (VgaAcPalDisable ? 0x20 : 0x00);
1180
1181 case VGA_AC_READ:
1182 return VgaAcRegisters[VgaAcIndex];
1183
1184 case VGA_SEQ_INDEX:
1185 return VgaSeqIndex;
1186
1187 case VGA_SEQ_DATA:
1189
1190 case VGA_DAC_MASK:
1191 {
1192 if (SvgaHdrCounter == 4)
1193 {
1194 SvgaHdrCounter = 0;
1195 return SvgaHiddenRegister;
1196 }
1197 else
1198 {
1200 return VgaDacMask;
1201 }
1202 }
1203
1204 case VGA_DAC_READ_INDEX:
1205 /* This returns the read/write state */
1206 return (VgaDacReadWrite ? 0 : 3);
1207
1209 return VgaDacIndex;
1210
1211 case VGA_DAC_DATA:
1212 {
1213 /* Ignore reads in write mode */
1214 if (!VgaDacReadWrite)
1215 {
1218
1219 if (VgaDacLatchCounter == 3)
1220 {
1221 /* Reset the latch counter and increment the palette index */
1223 VgaDacIndex++;
1225 }
1226
1227 return Data;
1228 }
1229
1230 break;
1231 }
1232
1235 return VgaCrtcIndex;
1236
1237 case VGA_CRTC_DATA_MONO:
1240
1241 case VGA_GC_INDEX:
1242 return VgaGcIndex;
1243
1244 case VGA_GC_DATA:
1245 return VgaGcRegisters[VgaGcIndex];
1246
1247 default:
1248 DPRINT1("VgaReadPort: Unknown port 0x%X\n", Port);
1249 break;
1250 }
1251
1252 return 0;
1253}
#define DPRINT1
Definition: precomp.h:8
CPPORT Port[4]
Definition: headless.c:35
static BYTE VgaDacRegisters[VGA_PALETTE_SIZE]
Definition: svga.c:271
static BOOLEAN VgaAcPalDisable
Definition: svga.c:261
static BYTE VgaDacLatchCounter
Definition: svga.c:266
static BYTE VgaGcIndex
Definition: svga.c:257
static BYTE VgaAcIndex
Definition: svga.c:262
static BYTE VgaDacMask
Definition: svga.c:265
static WORD VgaDacIndex
Definition: svga.c:270
static BYTE VgaFeatureRegister
Definition: svga.c:249
static BYTE VgaSeqIndex
Definition: svga.c:251
static BYTE SvgaHiddenRegister
Definition: svga.c:287
static UINT SvgaHdrCounter
Definition: svga.c:286
static BOOLEAN VgaDacReadWrite
Definition: svga.c:269
static BYTE VgaCrtcIndex
Definition: svga.c:254
static BOOLEAN VgaAcLatch
Definition: svga.c:260
#define VGA_CRTC_DATA_MONO
Definition: svga.h:64
#define VGA_SEQ_DATA
Definition: svga.h:56
#define VGA_DAC_MASK
Definition: svga.h:58
#define VGA_AC_READ
Definition: svga.h:53
#define VGA_INSTAT0_READ
Definition: svga.h:42
#define VGA_GC_DATA
Definition: svga.h:69
#define VGA_INSTAT1_READ_COLOR
Definition: svga.h:45
#define VGA_SEQ_INDEX
Definition: svga.h:55
#define VGA_FEATURE_READ
Definition: svga.h:47
#define VGA_DAC_READ_INDEX
Definition: svga.h:59
#define VGA_DAC_DATA
Definition: svga.h:61
#define VGA_STAT_VRETRACE
Definition: svga.h:92
#define VGA_DAC_WRITE_INDEX
Definition: svga.h:60
#define VGA_MISC_READ
Definition: svga.h:39
#define VGA_AC_INDEX
Definition: svga.h:51
#define VGA_CRTC_INDEX_COLOR
Definition: svga.h:65
#define VGA_INSTAT1_READ_MONO
Definition: svga.h:44
#define VGA_CRTC_INDEX_MONO
Definition: svga.h:63
#define VGA_CRTC_DATA_COLOR
Definition: svga.h:66
@ VGA_CRTC_START_HORZ_BLANKING_REG
Definition: svga.h:205
@ VGA_CRTC_END_VERT_RETRACE_REG
Definition: svga.h:220
@ VGA_CRTC_END_HORZ_BLANKING_REG
Definition: svga.h:206
#define VGA_GC_INDEX
Definition: svga.h:68
#define VGA_STAT_DD
Definition: svga.h:91

Referenced by VgaInitialize(), and VgaWritePort().

◆ VgaRefreshDisplay()

◆ VgaResetPalette()

static VOID VgaResetPalette ( VOID  )
static

Definition at line 594 of file svga.c.

595{
597
598 /* Restore the default palette */
602}
static const ENTRY Entries[]
static BOOLEAN PaletteChanged
Definition: svga.c:284
UINT WINAPI SetPaletteEntries(_In_ HPALETTE hpal, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) CONST PALETTEENTRY *pPalEntries)

Referenced by VgaInitialize().

◆ VgaResetSequencer()

static VOID VgaResetSequencer ( VOID  )
static

Definition at line 495 of file svga.c.

496{
497 /* Lock extended SVGA registers */
499
500 /* Initialize the VCLKs */
509
510 /* 50 MHz MCLK, not being used as the VCLK */
512}
@ SVGA_SEQ_UNLOCK_REG
Definition: svga.h:137
#define SVGA_SEQ_LOCKED
Definition: svga.h:115

Referenced by VgaInitialize().

◆ VgaRestoreDefaultPalette()

static VOID VgaRestoreDefaultPalette ( PPALETTEENTRY  Entries,
USHORT  NumOfEntries 
)
static

Definition at line 514 of file svga.c.

515{
516 USHORT i;
517
518 /* Copy the colors of the default palette to the DAC and console palette */
519 for (i = 0; i < NumOfEntries; i++)
520 {
521 /* Set the palette entries */
525 Entries[i].peFlags = 0;
526
527 /* Set the DAC registers */
531 }
532}
static CONST COLORREF VgaDefaultPalette[VGA_MAX_COLORS]
Definition: svga.c:40
#define VGA_COLOR_TO_DAC(x)
Definition: svga.h:22

Referenced by VgaInitializePalette(), and VgaResetPalette().

◆ VgaTranslateAddress()

static DWORD VgaTranslateAddress ( DWORD  Address)
inlinestatic

Definition at line 342 of file svga.c.

343{
345 DWORD ExtOffset = ((VgaGcRegisters[SVGA_GC_EXT_MODE_REG] & SVGA_GC_EXT_MODE_WND_B) && (Offset & (1 << 15)))
348
349 /* Check for chain-4 and odd-even mode */
351 {
352 /* Clear the lowest two bits since they're used to select the bank */
353 Offset &= ~3;
354 }
356 {
357 /* Clear the lowest bit since it's used to select odd/even */
358 Offset &= ~1;
359 }
360
361 if (ExtOffset)
362 {
363 /* Add the extended offset */
364 Offset += ExtOffset << ((VgaGcRegisters[SVGA_GC_EXT_MODE_REG] & SVGA_GC_EXT_MODE_GRAN) ? 14 : 12);
365 }
366
367 /* Return the offset on plane 0 */
368 return Offset;
369}
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static DWORD VgaGetVideoBaseAddress(VOID)
Definition: svga.c:313
#define SVGA_GC_EXT_MODE_WND_B
Definition: svga.h:263
#define SVGA_GC_EXT_MODE_GRAN
Definition: svga.h:264
@ SVGA_GC_EXT_MODE_REG
Definition: svga.h:280
@ SVGA_GC_OFFSET_0_REG
Definition: svga.h:278
@ SVGA_GC_OFFSET_1_REG
Definition: svga.h:279

Referenced by VgaReadMemory(), and VgaWriteMemory().

◆ VgaTranslateByteForWriting()

static BYTE VgaTranslateByteForWriting ( BYTE  Data,
BYTE  Plane 
)
inlinestatic

Definition at line 371 of file svga.c.

372{
373 BYTE WriteMode = VgaGcRegisters[VGA_GC_MODE_REG] & 0x03;
375
376 if (WriteMode == 1)
377 {
378 /* In write mode 1 just return the latch register */
379 return VgaLatchRegisters[Plane];
380 }
381
382 if (WriteMode != 2)
383 {
384 /* Write modes 0 and 3 rotate the data to the right first */
385 BYTE RotateCount = VgaGcRegisters[VGA_GC_ROTATE_REG] & 0x07;
386 Data = LOBYTE(((DWORD)Data >> RotateCount) | ((DWORD)Data << (8 - RotateCount)));
387 }
388 else
389 {
390 /* Write mode 2 expands the appropriate bit to all 8 bits */
391 Data = (Data & (1 << Plane)) ? 0xFF : 0x00;
392 }
393
394 if (WriteMode == 0)
395 {
396 /*
397 * In write mode 0, the enable set/reset register decides if the
398 * set/reset bit should be expanded to all 8 bits.
399 */
400 if (VgaGcRegisters[VGA_GC_ENABLE_RESET_REG] & (1 << Plane))
401 {
402 /* Copy the bit from the set/reset register to all 8 bits */
403 Data = (VgaGcRegisters[VGA_GC_RESET_REG] & (1 << Plane)) ? 0xFF : 0x00;
404 }
405 }
406
407 if (WriteMode != 3)
408 {
409 /* Write modes 0 and 2 then perform a logical operation on the data and latch */
410 BYTE LogicalOperation = (VgaGcRegisters[VGA_GC_ROTATE_REG] >> 3) & 0x03;
411
412 if (LogicalOperation == 1) Data &= VgaLatchRegisters[Plane];
413 else if (LogicalOperation == 2) Data |= VgaLatchRegisters[Plane];
414 else if (LogicalOperation == 3) Data ^= VgaLatchRegisters[Plane];
415 }
416 else
417 {
418 /* For write mode 3, we AND the bitmask with the data, which is used as the new bitmask */
419 BitMask &= Data;
420
421 /* Then we expand the bit in the set/reset field */
422 Data = (VgaGcRegisters[VGA_GC_RESET_REG] & (1 << Plane)) ? 0xFF : 0x00;
423 }
424
425 /* Bits cleared in the bitmask are replaced with latch register bits */
426 Data = (Data & BitMask) | (VgaLatchRegisters[Plane] & (~BitMask));
427
428 /* Return the byte */
429 return Data;
430}
#define LOBYTE(W)
Definition: jmemdos.c:487
@ VGA_GC_ENABLE_RESET_REG
Definition: svga.h:269
@ VGA_GC_ROTATE_REG
Definition: svga.h:271
@ VGA_GC_BITMASK_REG
Definition: svga.h:276
@ VGA_GC_RESET_REG
Definition: svga.h:268

Referenced by VgaWriteMemory().

◆ VgaUpdateFramebuffer()

static VOID VgaUpdateFramebuffer ( VOID  )
static

Definition at line 736 of file svga.c.

737{
738 SHORT i, j, k;
739 DWORD AddressSize = VgaGetAddressSize();
741 BYTE BytePanning = (VgaCrtcRegisters[VGA_CRTC_PRESET_ROW_SCAN_REG] >> 5) & 3;
745 BYTE PixelShift = VgaAcRegisters[VGA_AC_HORZ_PANNING_REG] & 0x0F;
746
747 /*
748 * If the console framebuffer is NULL, that means something
749 * went wrong earlier and this is the final display refresh.
750 */
751 if (ActiveFramebuffer == NULL) return;
752
753 /* Check if we are in text or graphics mode */
755 {
756 /* Graphics mode */
757 PBYTE GraphicsBuffer = (PBYTE)ActiveFramebuffer;
758 DWORD InterlaceHighBit = VGA_INTERLACE_HIGH_BIT;
759 SHORT X;
760
761 /*
762 * Synchronize access to the graphics framebuffer
763 * with the console framebuffer mutex.
764 */
766
767 /* Shift the high bit right by 1 in odd/even mode */
769 {
770 InterlaceHighBit >>= 1;
771 }
772
774 {
775 /* Halve the line compare value */
776 LineCompare >>= 1;
777 }
778 else
779 {
780 /* Divide the line compare value by the maximum scan line */
781 LineCompare /= 1 + (VgaCrtcRegisters[VGA_CRTC_MAX_SCAN_LINE_REG] & 0x1F);
782 }
783
784 /* Loop through the scanlines */
785 for (i = 0; i < CurrResolution.Y; i++)
786 {
787 if (i == LineCompare)
788 {
790 {
791 /*
792 * Disable the pixel shift count and byte panning
793 * for the rest of the display cycle
794 */
795 PixelShift = 0;
796 BytePanning = 0;
797 }
798
799 /* Reset the address, but assume the preset row scan is 0 */
800 Address = BytePanning;
801 }
802
804 {
805 /* Odd-numbered line in interlaced mode - set the high bit */
806 Address |= InterlaceHighBit;
807 }
808
809 /* Loop through the pixels */
810 for (j = 0; j < CurrResolution.X; j++)
811 {
812 BYTE PixelData = 0;
813
814 /* Apply horizontal pixel panning */
816 {
817 X = j + ((PixelShift >> 1) & 0x03);
818 }
819 else
820 {
821 X = j + ((PixelShift < 8) ? PixelShift : -1);
822 }
823
825 {
826 // TODO: Check for high color modes
827
828 /* 256 color mode */
829 PixelData = VgaMemory[Address + X];
830 }
831 else
832 {
833 /* Check the shifting mode */
835 {
836 /* 4 bits shifted from each plane */
837
838 /* Check if this is 16 or 256 color mode */
840 {
841 /* One byte per pixel */
842 PixelData = VgaMemory[WRAP_OFFSET((Address + (X / VGA_NUM_BANKS)) * AddressSize)
844 }
845 else
846 {
847 /* 4-bits per pixel */
848
849 PixelData = VgaMemory[WRAP_OFFSET((Address + (X / (VGA_NUM_BANKS * 2))) * AddressSize)
850 * VGA_NUM_BANKS + ((X / 2) % VGA_NUM_BANKS)];
851
852 /* Check if we should use the highest 4 bits or lowest 4 */
853 if ((X % 2) == 0)
854 {
855 /* Highest 4 */
856 PixelData >>= 4;
857 }
858 else
859 {
860 /* Lowest 4 */
861 PixelData &= 0x0F;
862 }
863 }
864 }
866 {
867 /* Check if this is 16 or 256 color mode */
869 {
870 // TODO: NOT IMPLEMENTED
871 DPRINT1("8-bit interleaved mode is not implemented!\n");
872 }
873 else
874 {
875 /*
876 * 2 bits shifted from plane 0 and 2 for the first 4 pixels,
877 * then 2 bits shifted from plane 1 and 3 for the next 4
878 */
879 DWORD BankNumber = (X / 4) % 2;
880 DWORD Offset = Address + (X / 8);
881 BYTE LowPlaneData = VgaMemory[WRAP_OFFSET(Offset * AddressSize) * VGA_NUM_BANKS + BankNumber];
882 BYTE HighPlaneData = VgaMemory[WRAP_OFFSET(Offset * AddressSize) * VGA_NUM_BANKS + (BankNumber + 2)];
883
884 /* Extract the two bits from each plane */
885 LowPlaneData = (LowPlaneData >> (6 - ((X % 4) * 2))) & 0x03;
886 HighPlaneData = (HighPlaneData >> (6 - ((X % 4) * 2))) & 0x03;
887
888 /* Combine them into the pixel */
889 PixelData = LowPlaneData | (HighPlaneData << 2);
890 }
891 }
892 else
893 {
894 /* 1 bit shifted from each plane */
895
896 /* Check if this is 16 or 256 color mode */
898 {
899 /* 8 bits per pixel, 2 on each plane */
900
901 for (k = 0; k < VGA_NUM_BANKS; k++)
902 {
903 /* The data is on plane k, 4 pixels per byte */
904 BYTE PlaneData = VgaMemory[WRAP_OFFSET((Address + (X >> 2)) * AddressSize) * VGA_NUM_BANKS + k];
905
906 /* The mask of the first bit in the pair */
907 BYTE BitMask = 1 << (((3 - (X % VGA_NUM_BANKS)) * 2) + 1);
908
909 /* Bits 0, 1, 2 and 3 come from the first bit of the pair */
910 if (PlaneData & BitMask) PixelData |= 1 << k;
911
912 /* Bits 4, 5, 6 and 7 come from the second bit of the pair */
913 if (PlaneData & (BitMask >> 1)) PixelData |= 1 << (k + 4);
914 }
915 }
916 else
917 {
918 /* 4 bits per pixel, 1 on each plane */
919
920 for (k = 0; k < VGA_NUM_BANKS; k++)
921 {
922 BYTE PlaneData = VgaMemory[WRAP_OFFSET((Address + (X >> 3)) * AddressSize) * VGA_NUM_BANKS + k];
923
924 /* If the bit on that plane is set, set it */
925 if (PlaneData & (1 << (7 - (X % 8)))) PixelData |= 1 << k;
926 }
927 }
928 }
929 }
930
932 {
933 /*
934 * In 16 color mode, the value is an index to the AC registers
935 * if external palette access is disabled, otherwise (in case
936 * of palette loading) it is a blank pixel.
937 */
938
939 if (VgaAcPalDisable)
940 {
942 {
943 /* Bits 4 and 5 are taken from the palette register */
944 PixelData = ((VgaAcRegisters[VGA_AC_COLOR_SEL_REG] << 4) & 0xC0)
945 | (VgaAcRegisters[PixelData & 0x0F] & 0x3F);
946 }
947 else
948 {
949 /* Bits 4 and 5 are taken from the color select register */
950 PixelData = (VgaAcRegisters[VGA_AC_COLOR_SEL_REG] << 4)
951 | (VgaAcRegisters[PixelData & 0x0F] & 0x0F);
952 }
953 }
954 else
955 {
956 PixelData = 0;
957 }
958 }
959
960 /* Take into account DoubleVision mode when checking for pixel updates */
962 {
963 /* Now check if the resulting pixel data has changed */
964 if (GraphicsBuffer[(i * 2 * CurrResolution.X * 2) + (j * 2)] != PixelData)
965 {
966 /* Yes, write the new value */
967 GraphicsBuffer[(i * 2 * CurrResolution.X * 2) + (j * 2)] = PixelData;
968 GraphicsBuffer[(i * 2 * CurrResolution.X * 2) + (j * 2 + 1)] = PixelData;
969 GraphicsBuffer[((i * 2 + 1) * CurrResolution.X * 2) + (j * 2)] = PixelData;
970 GraphicsBuffer[((i * 2 + 1) * CurrResolution.X * 2) + (j * 2 + 1)] = PixelData;
971
972 /* Mark the specified pixel as changed */
974 }
975 }
976 else if (DoubleWidth && !DoubleHeight)
977 {
978 /* Now check if the resulting pixel data has changed */
979 if (GraphicsBuffer[(i * CurrResolution.X * 2) + (j * 2)] != PixelData)
980 {
981 /* Yes, write the new value */
982 GraphicsBuffer[(i * CurrResolution.X * 2) + (j * 2)] = PixelData;
983 GraphicsBuffer[(i * CurrResolution.X * 2) + (j * 2 + 1)] = PixelData;
984
985 /* Mark the specified pixel as changed */
987 }
988 }
989 else if (!DoubleWidth && DoubleHeight)
990 {
991 /* Now check if the resulting pixel data has changed */
992 if (GraphicsBuffer[(i * 2 * CurrResolution.X) + j] != PixelData)
993 {
994 /* Yes, write the new value */
995 GraphicsBuffer[(i * 2 * CurrResolution.X) + j] = PixelData;
996 GraphicsBuffer[((i * 2 + 1) * CurrResolution.X) + j] = PixelData;
997
998 /* Mark the specified pixel as changed */
1000 }
1001 }
1002 else // if (!DoubleWidth && !DoubleHeight)
1003 {
1004 /* Now check if the resulting pixel data has changed */
1005 if (GraphicsBuffer[i * CurrResolution.X + j] != PixelData)
1006 {
1007 /* Yes, write the new value */
1008 GraphicsBuffer[i * CurrResolution.X + j] = PixelData;
1009
1010 /* Mark the specified pixel as changed */
1012 }
1013 }
1014 }
1015
1017 {
1018 /* Clear the high bit */
1019 Address &= ~InterlaceHighBit;
1020 }
1021
1023 {
1024 /* Move to the next scanline */
1026 }
1027 }
1028
1029 /*
1030 * Release the console framebuffer mutex
1031 * so that we allow for repainting.
1032 */
1034 }
1035 else
1036 {
1037 /* Text mode */
1038 DWORD CurrentAddr;
1040 CHAR_CELL CharInfo;
1041
1042 /*
1043 * Technically, the horizontal panning and preset row count should
1044 * affect text mode too. However, it works on pixels and not characters,
1045 * so we can't support it currently.
1046 */
1047
1048 /* Loop through the scanlines */
1049 for (i = 0; i < CurrResolution.Y; i++)
1050 {
1051 /* Loop through the characters */
1052 for (j = 0; j < CurrResolution.X; j++)
1053 {
1054 CurrentAddr = WRAP_OFFSET((Address + j) * AddressSize);
1055
1056 /* Plane 0 holds the character itself */
1057 CharInfo.Char = VgaMemory[CurrentAddr * VGA_NUM_BANKS];
1058
1059 /* Plane 1 holds the attribute */
1060 CharInfo.Attributes = VgaMemory[CurrentAddr * VGA_NUM_BANKS + 1];
1061
1062 /* Now check if the resulting character data has changed */
1063 if ((CharBuffer[i * CurrResolution.X + j].Char != CharInfo.Char) ||
1064 (CharBuffer[i * CurrResolution.X + j].Attributes != CharInfo.Attributes))
1065 {
1066 /* Yes, write the new value */
1067 CharBuffer[i * CurrResolution.X + j] = CharInfo;
1068
1069 /* Mark the specified cell as changed */
1071 }
1072 }
1073
1074 /* Move to the next scanline */
1076 }
1077 }
1078}
#define INFINITE
Definition: serial.h:102
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 X(b, s)
int k
Definition: mpi.c:3369
BYTE * PBYTE
Definition: pedump.c:66
short SHORT
Definition: pedump.c:59
BYTE Attributes
Definition: svga.h:393
CHAR Char
Definition: svga.h:392
static BOOLEAN DoubleHeight
Definition: video.c:59
static HANDLE ConsoleMutex
static PVOID GraphicsFramebuffer = NULL;
Definition: video.c:56
static BOOLEAN DoubleWidth
Definition: video.c:58
static VOID VgaMarkForUpdate(SHORT Row, SHORT Column)
Definition: svga.c:717
static DWORD VgaGetAddressSize(VOID)
Definition: svga.c:318
#define VGA_GC_MODE_SHIFTREG
Definition: svga.h:255
#define VGA_CRTC_OVERFLOW_LC8
Definition: svga.h:175
@ VGA_AC_HORZ_PANNING_REG
Definition: svga.h:360
@ VGA_AC_COLOR_SEL_REG
Definition: svga.h:361
#define VGA_INTERLACE_HIGH_BIT
Definition: svga.h:23
#define VGA_CRTC_MAXSCANLINE_LC9
Definition: svga.h:185
#define VGA_GC_MODE_SHIFT256
Definition: svga.h:256
@ VGA_CRTC_LINE_COMPARE_REG
Definition: svga.h:227
#define VGA_AC_CONTROL_PPM
Definition: svga.h:335
struct _CHAR_CELL * PCHAR_CELL
#define VGA_AC_CONTROL_P54S
Definition: svga.h:337
#define VGA_GC_MISC_OE
Definition: svga.h:260
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618

Referenced by VgaVerticalRetrace().

◆ VgaUpdateTextCursor()

static VOID VgaUpdateTextCursor ( VOID  )
static

Definition at line 1080 of file svga.c.

1081{
1082 BOOL CursorVisible = !(VgaCrtcRegisters[VGA_CRTC_CURSOR_START_REG] & 0x20);
1083 BYTE CursorStart = VgaCrtcRegisters[VGA_CRTC_CURSOR_START_REG] & 0x1F;
1084 BYTE CursorEnd = VgaCrtcRegisters[VGA_CRTC_CURSOR_END_REG] & 0x1F;
1085
1086 DWORD ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2;
1087 BYTE TextSize = 1 + (VgaCrtcRegisters[VGA_CRTC_MAX_SCAN_LINE_REG] & 0x1F);
1090
1091 /* Just return if we are not in text mode */
1092 if (ScreenMode != TEXT_MODE) return;
1093
1094 /* Add the cursor skew to the location */
1095 Location += (VgaCrtcRegisters[VGA_CRTC_CURSOR_END_REG] >> 5) & 0x03;
1096
1097 VgaConsoleUpdateTextCursor(CursorVisible, CursorStart, CursorEnd,
1098 TextSize, ScanlineSize, Location);
1099
1100 /* Reset the cursor changed flag */
1102}
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID VgaConsoleUpdateTextCursor(BOOL CursorVisible, BYTE CursorStart, BYTE CursorEnd, BYTE TextSize, DWORD ScanlineSize, WORD Location)
Definition: video.c:575
static BOOLEAN CursorChanged
Definition: svga.c:283
@ VGA_CRTC_CURSOR_START_REG
Definition: svga.h:213
@ VGA_CRTC_CURSOR_LOC_HIGH_REG
Definition: svga.h:217
@ VGA_CRTC_CURSOR_LOC_LOW_REG
Definition: svga.h:218
@ VGA_CRTC_CURSOR_END_REG
Definition: svga.h:214

Referenced by VgaVerticalRetrace().

◆ VgaVerticalRetrace()

static VOID VgaVerticalRetrace ( VOID  )
inlinestatic

Definition at line 1613 of file svga.c.

1614{
1615 /* If nothing has changed, just return */
1616 // if (!ModeChanged && !CursorChanged && !PaletteChanged && !NeedsUpdate)
1617 // return;
1618
1619 /* Change the display mode */
1621
1622 /* Change the text cursor appearance */
1624
1625 if (PaletteChanged)
1626 {
1627 /* Trigger a full update of the screen */
1628 NeedsUpdate = TRUE;
1630 UpdateRectangle.Top = 0;
1633
1635 }
1636
1637 /* Update the contents of the framebuffer */
1639
1640 /* Ignore if there's nothing to update */
1641 if (!NeedsUpdate) return;
1642
1643 DPRINT("Updating screen rectangle (%d, %d, %d, %d)\n",
1648
1650
1651 /* Clear the update flag */
1653}
VOID VgaConsoleRepaintScreen(PSMALL_RECT Rect)
Definition: video.c:750
static VOID VgaChangeMode(VOID)
Definition: svga.c:674
static VOID VgaUpdateFramebuffer(VOID)
Definition: svga.c:736
static VOID VgaUpdateTextCursor(VOID)
Definition: svga.c:1080

Referenced by VgaHorizontalRetrace(), and VgaRefreshDisplay().

◆ VgaWriteAc()

static VOID VgaWriteAc ( BYTE  Data)
inlinestatic

Definition at line 1386 of file svga.c.

1387{
1389
1391
1392 /* Save the value */
1394 {
1395 if (VgaAcPalDisable) return;
1396
1397 // DbgPrint(" AC Palette Writing %d to index %d\n", Data, VgaAcIndex);
1399 {
1400 /* Update the AC register */
1402
1403 /* Fill the entry structure */
1405 Entry.peGreen = VGA_DAC_TO_COLOR(VgaDacRegisters[Data * 3 + 1]);
1406 Entry.peBlue = VGA_DAC_TO_COLOR(VgaDacRegisters[Data * 3 + 2]);
1407 Entry.peFlags = 0;
1408
1409 /* Update the palette entry and set the palette change flag */
1412 }
1413 }
1414 else
1415 {
1417 }
1418}
#define ASSERT(a)
Definition: mode.c:44
base of all file and directory entries
Definition: entries.h:83
@ VGA_AC_MAX_REG
Definition: svga.h:362
#define VGA_DAC_TO_COLOR(x)
Definition: svga.h:21

Referenced by VgaWritePort().

◆ VgaWriteCrtc()

static VOID VgaWriteCrtc ( BYTE  Data)
inlinestatic

Definition at line 1312 of file svga.c.

1313{
1314 /* Save the value */
1316
1317 /* Check the index */
1319 {
1324 {
1325 /* The video mode has changed */
1326 ModeChanged = TRUE;
1327 break;
1328 }
1329
1334 {
1335 /* Set the cursor changed flag */
1337 break;
1338 }
1339 }
1340}
#define VGA_CRTC_INDEX_MASK
Definition: svga.h:73

Referenced by VgaWritePort().

◆ VgaWriteDac()

static VOID VgaWriteDac ( BYTE  Data)
inlinestatic

Definition at line 1342 of file svga.c.

1343{
1344 UINT i;
1346
1347 /* Store the value in the latch */
1349 if (VgaDacLatchCounter < 3) return;
1350
1351 /* Reset the latch counter */
1353
1354 /* Set the DAC register values */
1358
1359 /* Fill the entry structure */
1361 Entry.peGreen = VGA_DAC_TO_COLOR(VgaDacLatch[1]);
1362 Entry.peBlue = VGA_DAC_TO_COLOR(VgaDacLatch[2]);
1363 Entry.peFlags = 0;
1364
1365 /* Update the palette entry */
1367
1368 /* Check which text palette entries are affected */
1369 for (i = 0; i <= VGA_AC_PAL_F_REG; i++)
1370 {
1372 {
1373 /* Update the text palette entry */
1375 }
1376 }
1377
1378 /* Set the palette changed flag */
1380
1381 /* Update the index */
1382 VgaDacIndex++;
1384}
static BYTE VgaDacLatch[3]
Definition: svga.c:267

Referenced by VgaWritePort().

◆ VgaWriteGc()

static VOID VgaWriteGc ( BYTE  Data)
inlinestatic

Definition at line 1281 of file svga.c.

1282{
1283 /* Save the value */
1285
1286 /* Check the index */
1287 switch (VgaGcIndex & VGA_GC_INDEX_MASK)
1288 {
1289 case VGA_GC_MISC_REG:
1290 {
1291 /* Remove any existing VGA memory hook */
1292 MemRemoveFastMemoryHook((PVOID)0xA0000, 0x20000);
1293
1295 {
1297
1298 /* Register a memory hook */
1303 }
1304
1305 /* The GC misc register decides if it's text or graphics mode */
1306 ModeChanged = TRUE;
1307 break;
1308 }
1309 }
1310}
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
#define UlongToPtr(u)
Definition: config.h:106
BOOL MemInstallFastMemoryHook(PVOID Address, ULONG Size, PMEMORY_READ_HANDLER ReadHandler, PMEMORY_WRITE_HANDLER WriteHandler)
Definition: memory.c:299
static CONST DWORD MemorySize[]
Definition: svga.c:32
BOOLEAN FASTCALL VgaWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
Definition: svga.c:1982
VOID FASTCALL VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
Definition: svga.c:1802
#define VGA_GC_INDEX_MASK
Definition: svga.h:72

Referenced by VgaWritePort().

◆ VgaWriteMemory()

BOOLEAN FASTCALL VgaWriteMemory ( ULONG  Address,
PVOID  Buffer,
ULONG  Size 
)

Definition at line 1982 of file svga.c.

1983{
1984 DWORD i, j;
1985 DWORD VideoAddress;
1986 PUCHAR BufPtr = (PUCHAR)Buffer;
1987
1988 DPRINT("VgaWriteMemory: Address 0x%08X, Size %lu\n", Address, Size);
1989
1990 /* Ignore if video RAM access is disabled */
1991 if ((VgaMiscRegister & VGA_MISC_RAM_ENABLED) == 0) return TRUE;
1992
1993 /* Also ignore if write access to all planes is disabled */
1994 if ((VgaSeqRegisters[VGA_SEQ_MASK_REG] & 0x0F) == 0x00) return TRUE;
1995
1997 {
1998 /* Loop through each byte */
1999 for (i = 0; i < Size; i++)
2000 {
2001 VideoAddress = VgaTranslateAddress(Address + i);
2002
2003 for (j = 0; j < VGA_NUM_BANKS; j++)
2004 {
2005 /* Make sure the page is writeable */
2006 if (!(VgaSeqRegisters[VGA_SEQ_MASK_REG] & (1 << j))) continue;
2007
2008 /* Check if this is chain-4 mode */
2010 {
2011 if (((Address + i) & 0x03) != j)
2012 {
2013 /* This plane will not be accessed */
2014 continue;
2015 }
2016 }
2017
2018 /* Check if this is odd-even mode */
2020 {
2021 if (((Address + i) & 0x01) != (j & 1))
2022 {
2023 /* This plane will not be accessed */
2024 continue;
2025 }
2026 }
2027
2028 /* Copy the value to the VGA memory */
2029 VgaMemory[VideoAddress * VGA_NUM_BANKS + j] = VgaTranslateByteForWriting(BufPtr[i], j);
2030 }
2031 }
2032 }
2033 else
2034 {
2035 PVOID VideoMemory;
2036
2037 // TODO: Apply the page write mask!
2038 // TODO: Check whether the write mode stuff applies to packed-pixel modes
2039
2040 /* Just copy to the video memory */
2041 VideoAddress = VgaTranslateAddress(Address);
2042 VideoMemory = &VgaMemory[VideoAddress + (Address & 3)];
2043
2044 switch (Size)
2045 {
2046 case sizeof(UCHAR):
2047 *(PUCHAR)VideoMemory = *(PUCHAR)Buffer;
2048 return TRUE;
2049
2050 case sizeof(USHORT):
2051 *(PUSHORT)VideoMemory = *(PUSHORT)Buffer;
2052 return TRUE;
2053
2054 case sizeof(ULONG):
2055 *(PULONG)VideoMemory = *(PULONG)Buffer;
2056 return TRUE;
2057
2058 case sizeof(ULONGLONG):
2059 *(PULONGLONG)VideoMemory = *(PULONGLONG)Buffer;
2060 return TRUE;
2061
2062 default:
2063#if defined(__GNUC__)
2064 __builtin_memcpy(VideoMemory, Buffer, Size);
2065#else
2066 RtlCopyMemory(VideoMemory, Buffer, Size);
2067#endif
2068 }
2069 }
2070
2071 return TRUE;
2072}
static BYTE VgaTranslateByteForWriting(BYTE Data, BYTE Plane)
Definition: svga.c:371
@ VGA_SEQ_MASK_REG
Definition: svga.h:133

Referenced by VgaWriteGc(), and VgaWritePort().

◆ VgaWritePort()

static VOID WINAPI VgaWritePort ( USHORT  Port,
BYTE  Data 
)
static

Definition at line 1420 of file svga.c.

1421{
1422 DPRINT("VgaWritePort: Port 0x%X, Data 0x%02X\n", Port, Data);
1423
1424 switch (Port)
1425 {
1426 case VGA_MISC_WRITE:
1427 {
1429
1430 if (VgaMiscRegister & 0x01)
1431 {
1432 /* Color emulation */
1433 DPRINT1("Color emulation\n");
1434
1435 /* Register the new I/O Ports */
1436 RegisterIoPort(0x3D4, VgaReadPort, VgaWritePort); // VGA_CRTC_INDEX_COLOR
1437 RegisterIoPort(0x3D5, VgaReadPort, VgaWritePort); // VGA_CRTC_DATA_COLOR
1438 RegisterIoPort(0x3DA, VgaReadPort, VgaWritePort); // VGA_INSTAT1_READ_COLOR, VGA_FEATURE_WRITE_COLOR
1439
1440 /* Unregister the old ones */
1441 UnregisterIoPort(0x3B4); // VGA_CRTC_INDEX_MONO
1442 UnregisterIoPort(0x3B5); // VGA_CRTC_DATA_MONO
1443 UnregisterIoPort(0x3BA); // VGA_INSTAT1_READ_MONO, VGA_FEATURE_WRITE_MONO
1444 }
1445 else
1446 {
1447 /* Monochrome emulation */
1448 DPRINT1("Monochrome emulation\n");
1449
1450 /* Register the new I/O Ports */
1451 RegisterIoPort(0x3B4, VgaReadPort, VgaWritePort); // VGA_CRTC_INDEX_MONO
1452 RegisterIoPort(0x3B5, VgaReadPort, VgaWritePort); // VGA_CRTC_DATA_MONO
1453 RegisterIoPort(0x3BA, VgaReadPort, VgaWritePort); // VGA_INSTAT1_READ_MONO, VGA_FEATURE_WRITE_MONO
1454
1455 /* Unregister the old ones */
1456 UnregisterIoPort(0x3D4); // VGA_CRTC_INDEX_COLOR
1457 UnregisterIoPort(0x3D5); // VGA_CRTC_DATA_COLOR
1458 UnregisterIoPort(0x3DA); // VGA_INSTAT1_READ_COLOR, VGA_FEATURE_WRITE_COLOR
1459 }
1460
1461 /* Remove any existing VGA memory hook */
1462 MemRemoveFastMemoryHook((PVOID)0xA0000, 0x20000);
1463
1465 {
1467
1468 /* Register a memory hook */
1473 }
1474
1475 break;
1476 }
1477
1480 {
1482 break;
1483 }
1484
1485 case VGA_AC_INDEX:
1486 // case VGA_AC_WRITE:
1487 {
1488 if (!VgaAcLatch)
1489 {
1490 /* Change the index */
1491 BYTE Index = Data & 0x1F;
1493
1494 /*
1495 * Change palette protection by checking for
1496 * the Palette Address Source bit.
1497 */
1498 VgaAcPalDisable = (Data & 0x20) ? TRUE : FALSE;
1499 }
1500 else
1501 {
1502 /* Write the data */
1504 }
1505
1506 /* Toggle the latch */
1508 break;
1509 }
1510
1511 case VGA_SEQ_INDEX:
1512 {
1513 /* Set the sequencer index register */
1514 if ((Data & 0x1F) < SVGA_SEQ_MAX_UNLOCKED_REG
1515 && (Data & 0x1F) != VGA_SEQ_MAX_REG)
1516 {
1517 VgaSeqIndex = Data;
1518 }
1519
1520 break;
1521 }
1522
1523 case VGA_SEQ_DATA:
1524 {
1525 /* Call the sequencer function */
1527 break;
1528 }
1529
1530 case VGA_DAC_MASK:
1531 {
1533 else VgaDacMask = Data;
1534
1535 break;
1536 }
1537
1538 case VGA_DAC_READ_INDEX:
1539 {
1541 VgaDacIndex = Data;
1543 break;
1544 }
1545
1547 {
1549 VgaDacIndex = Data;
1551 break;
1552 }
1553
1554 case VGA_DAC_DATA:
1555 {
1556 /* Ignore writes in read mode */
1557 if (VgaDacReadWrite) VgaWriteDac(Data & 0x3F);
1558 break;
1559 }
1560
1563 {
1564 /* Set the CRTC index register */
1569 {
1571 }
1572
1573 break;
1574 }
1575
1576 case VGA_CRTC_DATA_MONO:
1578 {
1579 /* Call the CRTC function */
1581 break;
1582 }
1583
1584 case VGA_GC_INDEX:
1585 {
1586 /* Set the GC index register */
1591 {
1592 VgaGcIndex = Data;
1593 }
1594
1595 break;
1596 }
1597
1598 case VGA_GC_DATA:
1599 {
1600 /* Call the GC function */
1602 break;
1603 }
1604
1605 default:
1606 DPRINT1("VgaWritePort: Unknown port 0x%X, Data 0x%02X\n", Port, Data);
1607 break;
1608 }
1609
1610 SvgaHdrCounter = 0;
1611}
VOID UnregisterIoPort(USHORT Port)
Definition: io.c:338
static VOID VgaWriteCrtc(BYTE Data)
Definition: svga.c:1312
static VOID VgaWriteAc(BYTE Data)
Definition: svga.c:1386
static VOID VgaWriteSequencer(BYTE Data)
Definition: svga.c:1255
static VOID VgaWriteGc(BYTE Data)
Definition: svga.c:1281
static VOID VgaWriteDac(BYTE Data)
Definition: svga.c:1342
#define VGA_MISC_WRITE
Definition: svga.h:40
#define SVGA_GC_MAX_UNLOCKED_REG
Definition: svga.h:35
#define VGA_FEATURE_WRITE_COLOR
Definition: svga.h:49
@ VGA_SEQ_MAX_REG
Definition: svga.h:136
#define SVGA_SEQ_MAX_UNLOCKED_REG
Definition: svga.h:33
#define VGA_FEATURE_WRITE_MONO
Definition: svga.h:48
@ SVGA_CRTC_UNUSED7_REG
Definition: svga.h:242
@ SVGA_CRTC_UNUSED0_REG
Definition: svga.h:234
@ SVGA_CRTC_UNUSED6_REG
Definition: svga.h:240
@ SVGA_GC_UNUSED1_REG
Definition: svga.h:291
@ SVGA_GC_UNUSED0_REG
Definition: svga.h:284
@ SVGA_GC_UNUSED10_REG
Definition: svga.h:300
#define SVGA_CRTC_MAX_UNLOCKED_REG
Definition: svga.h:34
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by VgaInitialize(), and VgaWritePort().

◆ VgaWriteSequencer()

static VOID VgaWriteSequencer ( BYTE  Data)
inlinestatic

Definition at line 1255 of file svga.c.

1256{
1257 /* Save the value */
1259
1260 /* Check the index */
1262 {
1264 {
1266 {
1267 /* Unlock SVGA extensions */
1269 }
1270 else
1271 {
1272 /* Lock SVGA extensions */
1274 }
1275
1276 break;
1277 }
1278 }
1279}
#define SVGA_SEQ_UNLOCK_MASK
Definition: svga.h:116
#define SVGA_SEQ_UNLOCKED
Definition: svga.h:117
#define VGA_SEQ_INDEX_MASK
Definition: svga.h:71

Referenced by VgaWritePort().

◆ VgaWriteTextModeFont()

VOID VgaWriteTextModeFont ( UINT  FontNumber,
CONST UCHAR FontData,
UINT  Height 
)

Definition at line 2079 of file svga.c.

2080{
2081 UINT i, j;
2083
2084 for (i = 0; i < VGA_FONT_CHARACTERS; i++)
2085 {
2086 /* Write the character */
2087 for (j = 0; j < Height; j++)
2088 {
2090 }
2091
2092 /* Clear the unused part */
2093 for (j = Height; j < VGA_MAX_FONT_HEIGHT; j++)
2094 {
2096 }
2097 }
2098}
#define VGA_FONT_BANK
Definition: svga.h:24
#define VGA_MAX_FONT_HEIGHT
Definition: svga.h:26
#define VGA_FONT_CHARACTERS
Definition: svga.h:25
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88

Referenced by VidBiosSetVideoMode(), and VidBiosVideoService().

Variable Documentation

◆ ActiveFramebuffer

PVOID ActiveFramebuffer = NULL
static

ConsoleFramebuffer.

Definition at line 211 of file svga.c.

Referenced by VgaAttachToConsole(), VgaDetachFromConsole(), VgaEnterNewMode(), VgaLeaveCurrentMode(), and VgaUpdateFramebuffer().

◆ ConsoleColors

const COLORREF ConsoleColors[16]
static
Initial value:
=
{
RGB(0, 0, 0),
RGB(0, 0, 128),
RGB(0, 128, 0),
RGB(0, 128, 128),
RGB(128, 0, 0),
RGB(128, 0, 128),
RGB(128, 128, 0),
RGB(192, 192, 192),
RGB(128, 128, 128),
RGB(0, 0, 255),
RGB(0, 255, 0),
RGB(0, 255, 255),
RGB(255, 0, 0),
RGB(255, 0, 255),
RGB(255, 255, 0),
}
#define RGB(r, g, b)
Definition: precomp.h:71

Definition at line 189 of file svga.c.

Referenced by VgaInitializePalette().

◆ CurrResolution

COORD CurrResolution = {0}
static

◆ CursorChanged

BOOLEAN CursorChanged = FALSE
static

Definition at line 283 of file svga.c.

Referenced by VgaUpdateTextCursor(), VgaVerticalRetrace(), and VgaWriteCrtc().

◆ GraphicsFramebuffer

PBYTE GraphicsFramebuffer = NULL
static

Definition at line 229 of file svga.c.

Referenced by VgaConsoleCreateGraphicsScreen(), VgaEnterNewMode(), and VgaLeaveCurrentMode().

◆ HorizontalRetraceCycle

ULONGLONG HorizontalRetraceCycle = 0ULL
static

Definition at line 275 of file svga.c.

Referenced by VgaHorizontalRetrace(), and VgaReadPort().

◆ HSyncTimer

PHARDWARE_TIMER HSyncTimer
static

Definition at line 276 of file svga.c.

Referenced by VgaCleanup(), and VgaInitialize().

◆ MemoryBase

CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 }
static

Definition at line 31 of file svga.c.

Referenced by VgaGetVideoBaseAddress(), VgaWriteGc(), and VgaWritePort().

◆ MemorySize

◆ ModeChanged

◆ NeedsUpdate

BOOLEAN NeedsUpdate = FALSE
static

Definition at line 281 of file svga.c.

Referenced by ScreenEventHandler(), VgaChangeMode(), VgaMarkForUpdate(), and VgaVerticalRetrace().

◆ PaletteChanged

BOOLEAN PaletteChanged = FALSE
static

◆ PaletteHandle

◆ ScanlineCounter

DWORD ScanlineCounter = 0
static

Definition at line 277 of file svga.c.

Referenced by VgaHorizontalRetrace(), and VgaReadPort().

◆ ScanlineSizeLatch

DWORD ScanlineSizeLatch = 0
static

Definition at line 279 of file svga.c.

Referenced by VgaHorizontalRetrace(), VgaRefreshDisplay(), and VgaUpdateFramebuffer().

◆ ScreenMode

◆ StartAddressLatch

DWORD StartAddressLatch = 0
static

Definition at line 278 of file svga.c.

Referenced by VgaHorizontalRetrace(), VgaRefreshDisplay(), and VgaUpdateFramebuffer().

◆ SvgaHdrCounter

UINT SvgaHdrCounter = 0
static

Definition at line 286 of file svga.c.

Referenced by VgaReadPort(), and VgaWritePort().

◆ SvgaHiddenRegister

BYTE SvgaHiddenRegister = 0
static

Definition at line 287 of file svga.c.

Referenced by VgaReadPort(), and VgaWritePort().

◆ TextFramebuffer

PCHAR_CELL TextFramebuffer = NULL
static

◆ TextPaletteHandle

HPALETTE TextPaletteHandle = NULL
static

Definition at line 214 of file svga.c.

Referenced by VgaEnterNewMode(), VgaInitializePalette(), VgaWriteAc(), and VgaWriteDac().

◆ UpdateRectangle

SMALL_RECT UpdateRectangle = { 0, 0, 0, 0 }
static

◆ VgaAcIndex

BYTE VgaAcIndex = VGA_AC_PAL_0_REG
static

Definition at line 262 of file svga.c.

Referenced by VgaReadPort(), VgaWriteAc(), and VgaWritePort().

◆ VgaAcLatch

BOOLEAN VgaAcLatch = FALSE
static

Definition at line 260 of file svga.c.

Referenced by VgaReadPort(), and VgaWritePort().

◆ VgaAcPalDisable

BOOLEAN VgaAcPalDisable = TRUE
static

Definition at line 261 of file svga.c.

Referenced by VgaReadPort(), VgaUpdateFramebuffer(), VgaWriteAc(), and VgaWritePort().

◆ VgaAcRegisters

◆ VgaCrtcIndex

BYTE VgaCrtcIndex = VGA_CRTC_HORZ_TOTAL_REG
static

Definition at line 254 of file svga.c.

Referenced by VgaReadPort(), VgaWriteCrtc(), and VgaWritePort().

◆ VgaCrtcRegisters

◆ VgaDacIndex

WORD VgaDacIndex = 0
static

Definition at line 270 of file svga.c.

Referenced by VgaReadPort(), VgaWriteDac(), and VgaWritePort().

◆ VgaDacLatch

BYTE VgaDacLatch[3]
static

Definition at line 267 of file svga.c.

Referenced by VgaWriteDac().

◆ VgaDacLatchCounter

BYTE VgaDacLatchCounter = 0
static

Definition at line 266 of file svga.c.

Referenced by VgaReadPort(), VgaWriteDac(), and VgaWritePort().

◆ VgaDacMask

BYTE VgaDacMask = 0xFF
static

Definition at line 265 of file svga.c.

Referenced by VgaReadPort(), and VgaWritePort().

◆ VgaDacReadWrite

BOOLEAN VgaDacReadWrite = FALSE
static

Definition at line 269 of file svga.c.

Referenced by VgaReadPort(), and VgaWritePort().

◆ VgaDacRegisters

BYTE VgaDacRegisters[VGA_PALETTE_SIZE]
static

Definition at line 271 of file svga.c.

Referenced by VgaReadPort(), VgaRestoreDefaultPalette(), VgaWriteAc(), and VgaWriteDac().

◆ VgaDefaultPalette

CONST COLORREF VgaDefaultPalette[VGA_MAX_COLORS]
static

Definition at line 40 of file svga.c.

Referenced by VgaRestoreDefaultPalette().

◆ VgaFeatureRegister

BYTE VgaFeatureRegister
static

Definition at line 249 of file svga.c.

Referenced by VgaReadPort(), and VgaWritePort().

◆ VgaGcIndex

BYTE VgaGcIndex = VGA_GC_RESET_REG
static

Definition at line 257 of file svga.c.

Referenced by VgaReadPort(), VgaWriteGc(), and VgaWritePort().

◆ VgaGcRegisters

◆ VgaLatchRegisters

BYTE VgaLatchRegisters[VGA_NUM_BANKS] = {0, 0, 0, 0}
static

Definition at line 246 of file svga.c.

Referenced by VgaReadMemory(), and VgaTranslateByteForWriting().

◆ VgaMemory

◆ VgaMiscRegister

BYTE VgaMiscRegister
static

◆ VgaSeqIndex

BYTE VgaSeqIndex = VGA_SEQ_RESET_REG
static

Definition at line 251 of file svga.c.

Referenced by VgaReadPort(), VgaWritePort(), and VgaWriteSequencer().

◆ VgaSeqRegisters