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

Last change on this file since 184 was 177, checked in by gregli@…, 13 years ago

Optimiztion, replaced the jump tables for MENU_LIB and DISPLAY_LIB with direct jump offsets

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