3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define VIDEOCARD_CGA_OR_OTHER 0
26 #define VIDEOCARD_EGA 1
27 #define VIDEOCARD_VGA 2
29 #define VERTRES_200_SCANLINES 0x00
30 #define VERTRES_350_SCANLINES 0x01
31 #define VERTRES_400_SCANLINES 0x02
33 #define MODETYPE_TEXT 0
34 #define MODETYPE_GRAPHICS 1
36 #define VIDEOMODE_NORMAL_TEXT 0
37 #define VIDEOMODE_EXTENDED_TEXT 1
38 #define VIDEOMODE_80X28 0x501C
39 #define VIDEOMODE_80X30 0x501E
40 #define VIDEOMODE_80X34 0x5022
41 #define VIDEOMODE_80X43 0x502B
42 #define VIDEOMODE_80X60 0x503C
43 #define VIDEOMODE_132X25 0x8419
44 #define VIDEOMODE_132X43 0x842B
45 #define VIDEOMODE_132X50 0x8432
46 #define VIDEOMODE_132X60 0x843C
48 #define VIDEOPORT_PALETTE_READ 0x03C7
49 #define VIDEOPORT_PALETTE_WRITE 0x03C8
50 #define VIDEOPORT_PALETTE_DATA 0x03C9
51 #define VIDEOPORT_VERTICAL_RETRACE 0x03DA
53 #define VIDEOVGA_MEM_ADDRESS 0xA0000
54 #define VIDEOTEXT_MEM_ADDRESS 0xB8000
61 } PACKED PALETTE_ENTRY
, *PPALETTE_ENTRY
;
65 U16 ModeAttributes
; // mode attributes (see #00080)
66 U8 WindowAttributesA
; // window attributes, window A (see #00081)
67 U8 WindowsAttributesB
; // window attributes, window B (see #00081)
68 U16 WindowGranularity
; // window granularity in KB
69 U16 WindowSize
; // window size in KB
70 U16 WindowAStartSegment
; // start segment of window A (0000h if not supported)
71 U16 WindowBStartSegment
; // start segment of window B (0000h if not supported)
72 U32 WindowPositioningFunction
; // -> FAR window positioning function (equivalent to AX=4F05h)
73 U16 BytesPerScanLine
; // bytes per scan line
74 //---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes---
75 U16 WidthInPixels
; // width in pixels (graphics) or characters (text)
76 U16 HeightInPixels
; // height in pixels (graphics) or characters (text)
77 U8 CharacterWidthInPixels
; // width of character cell in pixels
78 U8 CharacterHeightInPixels
; // height of character cell in pixels
79 U8 NumberOfMemoryPlanes
; // number of memory planes
80 U8 BitsPerPixel
; // number of bits per pixel
81 U8 NumberOfBanks
; // number of banks
82 U8 MemoryModel
; // memory model type (see #00082)
83 U8 BankSize
; // size of bank in KB
84 U8 NumberOfImagePanes
; // number of image pages (less one) that will fit in video RAM
85 U8 Reserved1
; // reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0)
87 U8 RedMaskSize
; // red mask size
88 U8 RedMaskPosition
; // red field position
89 U8 GreenMaskSize
; // green mask size
90 U8 GreenMaskPosition
; // green field size
91 U8 BlueMaskSize
; // blue mask size
92 U8 BlueMaskPosition
; // blue field size
93 U8 ReservedMaskSize
; // reserved mask size
94 U8 ReservedMaskPosition
; // reserved mask position
95 U8 DirectColorModeInfo
; // direct color mode info
96 // bit 0:Color ramp is programmable
97 // bit 1:Bytes in reserved field may be used by application
99 U32 LinearVideoBufferAddress
; // physical address of linear video buffer
100 U32 OffscreenMemoryPointer
; // pointer to start of offscreen memory
101 U16 OffscreenMemorySize
; // KB of offscreen memory
103 U16 LinearBytesPerScanLine
; // bytes per scan line in linear modes
104 U8 BankedNumberOfImages
; // number of images (less one) for banked video modes
105 U8 LinearNumberOfImages
; // number of images (less one) for linear video modes
106 U8 LinearRedMaskSize
; // linear modes:Size of direct color red mask (in bits)
107 U8 LinearRedMaskPosition
; // linear modes:Bit position of red mask LSB (e.g. shift count)
108 U8 LinearGreenMaskSize
; // linear modes:Size of direct color green mask (in bits)
109 U8 LinearGreenMaskPosition
; // linear modes:Bit position of green mask LSB (e.g. shift count)
110 U8 LinearBlueMaskSize
; // linear modes:Size of direct color blue mask (in bits)
111 U8 LinearBlueMaskPosition
; // linear modes:Bit position of blue mask LSB (e.g. shift count)
112 U8 LinearReservedMaskSize
; // linear modes:Size of direct color reserved mask (in bits)
113 U8 LinearReservedMaskPosition
; // linear modes:Bit position of reserved mask LSB
114 U32 MaximumPixelClock
; // maximum pixel clock for graphics video mode, in Hz
115 U8 Reserved2
[190]; // 190 BYTEs reserved (0)
116 } PACKED SVGA_MODE_INFORMATION
, *PSVGA_MODE_INFORMATION
;
119 extern U32 CurrentMemoryBank
;
120 extern SVGA_MODE_INFORMATION VesaVideoModeInformation
;
122 extern PVOID VideoOffScreenBuffer
;
127 VOID
BiosSetVideoMode(U32 VideoMode
); // Implemented in i386vid.S
128 VOID
BiosSetVideoFont8x8(VOID
); // Implemented in i386vid.S
129 VOID
BiosSetVideoFont8x14(VOID
); // Implemented in i386vid.S
130 VOID
BiosSetVideoFont8x16(VOID
); // Implemented in i386vid.S
131 VOID
BiosSelectAlternatePrintScreen(VOID
); // Implemented in i386vid.S
132 VOID
BiosDisableCursorEmulation(VOID
); // Implemented in i386vid.S
133 VOID
BiosDefineCursor(U32 StartScanLine
, U32 EndScanLine
); // Implemented in i386vid.S
134 U32
BiosDetectVideoCard(VOID
); // Implemented in i386vid.S
135 VOID
BiosSetVerticalResolution(U32 ScanLines
); // Implemented in i386vid.S, must be called right before BiosSetVideoMode()
136 VOID
BiosSet480ScanLines(VOID
); // Implemented in i386vid.S, must be called right after BiosSetVideoMode()
137 VOID
BiosSetVideoDisplayEnd(VOID
); // Implemented in i386vid.S
138 VOID
BiosVideoDisableBlinkBit(VOID
); // Implemented in i386vid.S
139 VOID
BiosVideoEnableBlinkBit(VOID
); // Implemented in i386vid.S
141 U16
BiosIsVesaSupported(VOID
); // Implemented in i386vid.S, returns the VESA version
142 BOOL
BiosVesaSetBank(U16 Bank
); // Implemented in i386vid.S
143 BOOL
BiosVesaSetVideoMode(U16 Mode
); // Implemented in i386vid.S
144 BOOL
BiosVesaGetSVGAModeInformation(U16 Mode
, PSVGA_MODE_INFORMATION ModeInformation
); // Implemented in i386vid.S
146 VOID
VideoSetTextCursorPosition(U32 X
, U32 Y
); // Implemented in i386vid.S
147 VOID
VideoHideTextCursor(VOID
); // Implemented in i386vid.S
148 VOID
VideoShowTextCursor(VOID
); // Implemented in i386vid.S
149 U32
VideoGetTextCursorPositionX(VOID
); // Implemented in i386vid.S
150 U32
VideoGetTextCursorPositionY(VOID
); // Implemented in i386vid.S
152 BOOL
VideoSetMode(U32 VideoMode
);
153 BOOL
VideoSetMode80x25(VOID
); // Sets 80x25
154 BOOL
VideoSetMode80x50_80x43(VOID
); // Sets 80x50 (VGA) or 80x43 (EGA) 8-pixel mode
155 BOOL
VideoSetMode80x28(VOID
); // Sets 80x28. Works on all VGA's. Standard 80x25 with 14-point font
156 BOOL
VideoSetMode80x43(VOID
); // Sets 80x43. Works on all VGA's. It's a 350-scanline mode with 8-pixel font.
157 BOOL
VideoSetMode80x30(VOID
); // Sets 80x30. Works on all VGA's. 480 scanlines, 16-pixel font.
158 BOOL
VideoSetMode80x34(VOID
); // Sets 80x34. Works on all VGA's. 480 scanlines, 14-pixel font.
159 BOOL
VideoSetMode80x60(VOID
); // Sets 80x60. Works on all VGA's. 480 scanlines, 8-pixel font.
160 U32
VideoGetCurrentModeResolutionX(VOID
);
161 U32
VideoGetCurrentModeResolutionY(VOID
);
162 U32
VideoGetBytesPerScanLine(VOID
);
163 U32
VideoGetCurrentMode(VOID
);
164 U32
VideoGetCurrentModeType(VOID
); // MODETYPE_TEXT or MODETYPE_GRAPHICS
165 BOOL
VideoIsCurrentModeVesa(VOID
);
166 U32
VideoGetCurrentModeColorDepth(VOID
); // Returns 0 for text mode, 16 for 4-bit, 256 for 8-bit, 32768 for 15-bit, 65536 for 16-bit, etc.
168 VOID
VideoClearScreen(VOID
);
169 VOID
VideoWaitForVerticalRetrace(VOID
);
170 PVOID
VideoAllocateOffScreenBuffer(VOID
); // Returns a pointer to an off-screen buffer sufficient for the current video mode
172 U32
VideoGetMemoryBankForPixel(U32 X
, U32 Y
);
173 U32
VideoGetMemoryBankForPixel16(U32 X
, U32 Y
);
174 U32
VideoGetBankOffsetForPixel(U32 X
, U32 Y
);
175 U32
VideoGetBankOffsetForPixel16(U32 X
, U32 Y
);
176 VOID
VideoSetMemoryBank(U16 BankNumber
);
177 U32
VideoGetOffScreenMemoryOffsetForPixel(U32 X
, U32 Y
);
178 VOID
VideoCopyOffScreenBufferToVRAM(VOID
);
180 VOID
VideoSetPaletteColor(U8 Color
, U8 Red
, U8 Green
, U8 Blue
);
181 VOID
VideoGetPaletteColor(U8 Color
, U8
* Red
, U8
* Green
, U8
* Blue
);
182 VOID
VideoSavePaletteState(PPALETTE_ENTRY Palette
, U32 ColorCount
);
183 VOID
VideoRestorePaletteState(PPALETTE_ENTRY Palette
, U32 ColorCount
);
185 VOID
VideoSetPixel16(U32 X
, U32 Y
, U8 Color
);
186 VOID
VideoSetPixel256(U32 X
, U32 Y
, U8 Color
);
187 VOID
VideoSetPixelRGB(U32 X
, U32 Y
, U8 Red
, U8 Green
, U8 Blue
);
188 VOID
VideoSetPixel16_OffScreen(U32 X
, U32 Y
, U8 Color
);
189 VOID
VideoSetPixel256_OffScreen(U32 X
, U32 Y
, U8 Color
);
190 VOID
VideoSetPixelRGB_OffScreen(U32 X
, U32 Y
, U8 Red
, U8 Green
, U8 Blue
);
192 VOID
VideoSetAllColorsToBlack(U32 ColorCount
);
193 VOID
VideoFadeIn(PPALETTE_ENTRY Palette
, U32 ColorCount
);
194 VOID
VideoFadeOut(U32 ColorCount
);
197 #endif // defined __VIDEO_H