source: xtideuniversalbios/trunk/Assembly_Library/Inc/Display.inc@ 572

Last change on this file since 572 was 505, checked in by krille_n_@…, 12 years ago

Changes:

  • Reverted the changes to MenuEvents.inc done in r492 since they broke the F1 key function in XTIDECFG.
  • Added a tail-call optimized variant of the CALL_DISPLAY_LIBRARY macro (JMP_DISPLAY_LIBRARY).
  • Put a block size limit in AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL. I think it's needed but if not, it's easy to remove.
  • Other optimizations and fixes.
File size: 9.8 KB
Line 
1; Project name : AssemblyLibrary
2; Description : Defines for display library.
3%ifndef DISPLAY_INC
4%define DISPLAY_INC
5
6%ifndef MODULE_STRINGS_COMPRESSED_PRECOMPRESS
7;--------------------------------------------------------------------
8; Display Library users need to use these macros since it will provide
9; compatibility with future library versions.
10;
11; CALL_DISPLAY_LIBRARY
12; JMP_DISPLAY_LIBRARY
13; Parameters:
14; %1: Function to call (functionName from DISPLAY_LIB)
15; Registers: Depends on function to call
16; Returns:
17; Depends on function to call
18; Corrupts registers:
19; AX (unless used as a return register), DI
20;--------------------------------------------------------------------
21%macro CALL_DISPLAY_LIBRARY 1
22 %ifidn %1, PushDisplayContext
23 call DisplayContext_Push
24 %elifidn %1, PopDisplayContext
25 call DisplayContext_Pop
26 %elifidn %1, PrepareOffScreenBufferInESBXwithLengthInCX
27 call DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX
28 %else
29 mov di, %1
30 call Display_FunctionFromDI
31 %endif
32%endmacro
33
34%macro JMP_DISPLAY_LIBRARY 1
35 %ifidn %1, PushDisplayContext
36 jmp DisplayContext_Push
37 %elifidn %1, PopDisplayContext
38 call DisplayContext_Pop
39 ret
40 %elifidn %1, PrepareOffScreenBufferInESBXwithLengthInCX
41 jmp DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX
42 %elifidn %1, FormatNullTerminatedStringFromCSSI
43 mov di, %1
44 call Display_FunctionFromDI
45 ret
46 %else
47 mov di, %1
48 jmp Display_FunctionFromDI
49 %endif
50%endmacro
51
52%if 0
53;;;
54;;; struc no longer needed with direct calls to functions
55;;;
56
57; Display library functions
58struc DISPLAY_LIB
59 .PushDisplayContext:
60 .PopDisplayContext:
61 .InitializeDisplayContext resb 2
62
63%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
64 .SetCharacterPointerFromBXAX resb 2
65%endif
66 .SetCharOutputFunctionFromAXwithAttribFlagInBL resb 2
67 .SetCharacterOutputParameterFromAX resb 2
68 .SetCharacterAttributeFromAL resb 2
69 .SetCursorShapeFromAX resb 2
70 .SetCursorCoordinatesFromAX resb 2
71%ifndef EXCLUDE_FROM_XTIDECFG
72 .SetNewPageFromAL resb 2
73%endif
74 .SynchronizeDisplayContextToHardware resb 2
75
76%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
77 .GetCharacterPointerToBXAX resb 2
78%endif
79 .GetSoftwareCoordinatesToAX resb 2
80 .GetColumnsToALandRowsToAH resb 2
81
82 .FormatNullTerminatedStringFromCSSI resb 2
83%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
84 .PrintSignedWordFromAXWithBaseInBX resb 2
85%endif
86 .PrintWordFromAXwithBaseInBX resb 2
87%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
88 .PrintQWordFromSSBPwithBaseInBX resb 2
89%endif
90 .PrintCharBufferFromBXSIwithLengthInCX resb 2
91 .PrintNullTerminatedStringFromBXSI resb 2
92 .PrintNullTerminatedStringFromCSSI resb 2
93 .PrintRepeatedCharacterFromALwithCountInCX resb 2
94 .PrintCharacterFromAL resb 2
95 .PrintNewlineCharacters resb 2
96%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
97 .ClearAreaWithHeightInAHandWidthInAL resb 2
98%endif
99 .ClearScreenWithCharInALandAttrInAH resb 2
100endstruc
101%endif
102
103; Attribute flags for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInBL
104ATTRIBUTES_NOT_USED EQU 0
105ATTRIBUTES_ARE_USED EQU FLG_CONTEXT_ATTRIBUTES
106
107; Character output functions for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInBL
108TELETYPE_OUTPUT_WITH_ATTRIBUTE EQU DisplayCharOut_TeletypeOutputWithAttribute
109TELETYPE_OUTPUT_WITHOUT_ATTRIBUTE EQU DisplayCharOut_TeletypeOutput
110TELETYPE_OUTPUT_USING_BIOS EQU DisplayCharOut_BiosTeletypeOutput
111FAST_OUTPUT_WITH_ATTRIBUTE_ONLY EQU DisplayCharOut_Attribute
112FAST_OUTPUT_WITH_CHAR_ONLY EQU DisplayCharOut_Character
113FAST_OUTPUT_WITH_CHAR_AND_ATTRIBUTE EQU DisplayCharOut_CharacterWithAttribute
114BUFFER_OUTPUT_WITH_CHAR_ONLY EQU DisplayCharOut_WriteCharacterToBuffer
115
116DEFAULT_CHARACTER_OUTPUT EQU TELETYPE_OUTPUT_WITH_ATTRIBUTE
117
118
119struc VIDEO_BDA
120 resb 449h
121 .bMode resb 1 ; 0:449h, Video, Mode
122 .wColumns resb 2 ; 0:44Ah, Video, Number of columns
123 .wBytesPerPage resb 2 ; 0:44Ch, Video, Total number of bytes per page
124 .wPageOffset resb 2 ; 0:44Eh, Video, Current page offset
125 .rgwCursors resb 4 ; 0:450h, Video, Cursor position, pages 0...1
126 .displayContext resb 12 ; Our own display context (normally cursors for pages 2...7)
127 .wCursorShape resb 2 ; 0:460h, Video, Cursor shape
128 .bActivePage resb 1 ; 0:462h, Video, Active display page
129 .wVideoPort resb 2 ; 0:463h, Video, I/O Port number base
130 .bInternalModeReg resb 1 ; 0:465h, Video, Internal mode register
131 .bColorPalette resb 1 ; 0:466h, Video, Color palette
132endstruc
133
134struc DISPLAY_CONTEXT
135 .fpCursorPosition resb 4 ; Far pointer to cursor position in video memory
136 .fnCharOut resb 2 ; Function to draw character with
137 .wCharOutParam resb 2 ; User parameter for custom character output function
138 .wCursorShape resb 2 ; Current cursor shape
139 .bAttribute resb 1 ; Selected character attribute
140 .bFlags resb 1 ; Display context flags
141endstruc
142
143; Display context flags
144FLG_CONTEXT_ATTRIBUTES EQU (1<<0) ; Character output function uses attributes
145FLG_CONTEXT_CGA EQU (1<<1) ; CGA detected so prevent CGA snow
146
147
148; Text mode character attribute byte bits for CGA+ (color adapters)
149FLG_COLOR_FORE_BLUE EQU (1<<0)
150FLG_COLOR_FORE_GREEN EQU (1<<1)
151FLG_COLOR_FORE_RED EQU (1<<2)
152FLG_COLOR_FORE_INTENSITY EQU (1<<3)
153FLG_COLOR_FORE_FONT_B EQU (1<<3) ; Select font set B (if available, EGA+)
154FLG_COLOR_BACK_BLUE EQU (1<<4)
155FLG_COLOR_BACK_GREEN EQU (1<<5)
156FLG_COLOR_BACK_RED EQU (1<<6)
157FLG_COLOR_BACK_INTENSITY EQU (1<<7) ; Intensity when blinking is disabled
158FLG_COLOR_BLINK EQU (1<<7) ; Blinking color when enabled (enabled by default)
159
160; CGA colors
161%define COLOR_ATTRIBUTE(foreground, background) ( (foreground) | ((background)<<4) )
162COLOR_BLACK EQU 0
163COLOR_BLUE EQU 1
164COLOR_GREEN EQU 2
165COLOR_CYAN EQU 3
166COLOR_RED EQU 4
167COLOR_MAGENTA EQU 5
168COLOR_BROWN EQU 6
169COLOR_WHITE EQU 7 ; Last background color if blinking enabled
170COLOR_GRAY EQU 8
171COLOR_LIGHT_BLUE EQU 9
172COLOR_LIGHT_GREEN EQU 10
173COLOR_LIGHT_CYAN EQU 11
174COLOR_LIGHT_RED EQU 12
175COLOR_LIGHT_MAGENTA EQU 13
176COLOR_YELLOW EQU 14
177COLOR_BRIGHT_WHITE EQU 15
178
179
180; Text mode character attribute byte bits for MDA (monochrome adapters)
181; (attributes 00h, 08h, 80h, 88h, 70h, 78h, F0h and F8h are exceptions)
182FLG_MONO_UNDERLINE EQU (1<<1)
183FLG_MONO_INTENSITY EQU (1<<3)
184FLG_MONO_BLINK EQU (1<<7)
185
186; Text mode character attribute bytes for MDA/Hercules (monochrome adapters)
187; *Not displayed on some monitors
188MONO_HIDDEN EQU 00h ; Not displayed (same for 08h, 80h and 88h)
189MONO_UNDERLINE EQU 01h ; Underlined
190MONO_NORMAL EQU 07h ; Normal (white on black)
191MONO_BRIGHT_UNDERLINE EQU 09h ; High intensity, underlined
192MONO_BRIGHT EQU 0Fh ; High intensity
193MONO_REVERSE EQU 70h ; Reverse video (black on white)
194MONO_REVERSE_DARK EQU 78h ; (dark green on green)
195MONO_BLINK EQU 87h ; Blinking white on black*
196MONO_BRIGHT_BLINK EQU 8Fh ; Blinking high intensity*
197MONO_REVERSE_BLINK EQU 0F0h ; Blinking reverse video
198MONO_REVERSE_DARK_BLINK EQU 0F8h ; (blinking dark green on green)
199
200
201; Cursor position macro for DX register
202%define CURSOR_XY(x, y) ( (x) | ((y)<<8) )
203
204; Cursor shapes
205CURSOR_NORMAL_COLOR EQU 0607h ; Two line cursor near or at the bottom of cell (not valid for IBM MDA)
206CURSOR_NORMAL_MDA EQU 0B0Ch ; Scanlines 11 and 12
207CURSOR_HIDDEN EQU 2000h
208
209
210; Display modes
211CGA_TEXT_MODE_BW40 EQU 0 ; Applications should use...
212CGA_TEXT_MODE_CO40 EQU 1
213CGA_TEXT_MODE_BW80 EQU 2 ; ..black, white and bright white attributes only
214CGA_TEXT_MODE_CO80 EQU 3
215MDA_TEXT_MODE EQU 7 ; Real monochrome attributes available
216
217
218; Display segments
219COLOR_TEXT_SEGMENT EQU 0B800h ; Text modes 0...3 (CGA+)
220MONO_TEXT_SEGMENT EQU 0B000h ; Text mode 7 (MDA, Hercules)
221
222OFFSET_TO_CGA_STATUS_REGISTER EQU 6 ; Base port 3D4h + 6 = 3DAh
223CGA_STATUS_REGISTER EQU 3DAh
224
225%endif ; MODULE_STRINGS_COMPRESS_PRECOMPRESS
226
227; Control characters for teletype output
228NULL EQU 00h
229SOH EQU 01h ; Start of heading
230STX EQU 02h ; Start of text
231BELL EQU 07h ; Bell
232BS EQU 08h ; Backspace
233TAB EQU 09h ; Horizontal TAB
234LF EQU 0Ah ; Line feed (newline)
235CR EQU 0Dh ; Carriage return
236ESC EQU 1Bh ; Escape
237
238; Non ASCII characters (code page 437)
239BETA EQU 225
240QUOTATION_MARK EQU 34
241DOUBLE_TOP_RIGHT_CORNER EQU 187
242DOUBLE_TOP_LEFT_CORNER EQU 201
243DOUBLE_BOTTOM_RIGHT_CORNER EQU 188
244DOUBLE_BOTTOM_LEFT_CORNER EQU 200
245DOUBLE_VERTICAL EQU 186
246DOUBLE_HORIZONTAL EQU 205
247DOUBLE_VERTICAL_TO_RIGHT_SINGLE EQU 199
248DOUBLE_VERTICAL_TO_LEFT_SINGLE EQU 182
249DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL EQU 181
250DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL EQU 198
251SINGLE_VERTICAL EQU 179
252SINGLE_HORIZONTAL EQU 196
253SINGLE_LEFT_HORIZONTAL_TO_VERTICAL EQU 180
254SINGLE_RIGHT_HORIZONTAL_TO_VERTICAL EQU 195
255ANGLE_QUOTE_LEFT EQU 174
256ANGLE_QUOTE_RIGHT EQU 175
257BLOCK_MOSTLY_BACKGROUND EQU 176
258BLOCK_EVEN_BACKGROUND_AND_FOREGROUND EQU 177
259BLOCK_MOSTLY_FOREGROUND EQU 178
260BLOCK_FULL_FOREGROUND EQU 219
261ONE_HALF EQU 171
262ONE_QUARTER EQU 172
263
264
265; Background character for clearing screen
266%ifndef SCREEN_BACKGROUND_CHARACTER
267 %define SCREEN_BACKGROUND_CHARACTER BLOCK_MOSTLY_BACKGROUND
268%endif
269%ifndef SCREEN_BACKGROUND_ATTRIBUTE
270 %define SCREEN_BACKGROUND_ATTRIBUTE MONO_NORMAL
271%endif
272%define SCREEN_BACKGROUND_CHARACTER_AND_ATTRIBUTE (SCREEN_BACKGROUND_CHARACTER | (SCREEN_BACKGROUND_ATTRIBUTE<<8))
273%define DOS_BACKGROUND_CHARACTER_AND_ATTRIBUTE (' ' | (MONO_NORMAL<<8))
274
275%endif ; DISPLAY_INC
Note: See TracBrowser for help on using the repository browser.