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
|
---|
58 | struc 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 | .PrintSignedWordFromAXWithBaseInBL resb 2
|
---|
85 | %endif
|
---|
86 | .PrintWordFromAXWithBaseInBL 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
|
---|
100 | endstruc
|
---|
101 | %endif
|
---|
102 |
|
---|
103 | ; Attribute flags for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInBL
|
---|
104 | ATTRIBUTES_NOT_USED EQU 0
|
---|
105 | ATTRIBUTES_ARE_USED EQU FLG_CONTEXT_ATTRIBUTES
|
---|
106 |
|
---|
107 | ; Character output functions for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInBL
|
---|
108 | TELETYPE_OUTPUT_WITH_ATTRIBUTE EQU DisplayCharOut_TeletypeOutputWithAttribute
|
---|
109 | TELETYPE_OUTPUT_WITHOUT_ATTRIBUTE EQU DisplayCharOut_TeletypeOutput
|
---|
110 | TELETYPE_OUTPUT_USING_BIOS EQU DisplayCharOut_BiosTeletypeOutput
|
---|
111 | FAST_OUTPUT_WITH_ATTRIBUTE_ONLY EQU DisplayCharOut_Attribute
|
---|
112 | FAST_OUTPUT_WITH_CHAR_ONLY EQU DisplayCharOut_Character
|
---|
113 | FAST_OUTPUT_WITH_CHAR_AND_ATTRIBUTE EQU DisplayCharOut_CharacterWithAttribute
|
---|
114 | BUFFER_OUTPUT_WITH_CHAR_ONLY EQU DisplayCharOut_WriteCharacterToBuffer
|
---|
115 |
|
---|
116 | DEFAULT_CHARACTER_OUTPUT EQU TELETYPE_OUTPUT_WITH_ATTRIBUTE
|
---|
117 |
|
---|
118 |
|
---|
119 | struc 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
|
---|
132 | endstruc
|
---|
133 |
|
---|
134 | struc 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
|
---|
141 | endstruc
|
---|
142 |
|
---|
143 | ; Display context flags
|
---|
144 | FLG_CONTEXT_ATTRIBUTES EQU (1<<0) ; Character output function uses attributes
|
---|
145 | FLG_CONTEXT_CGA EQU (1<<1) ; CGA detected so prevent CGA snow
|
---|
146 |
|
---|
147 |
|
---|
148 | ; Text mode character attribute byte bits for CGA+ (color adapters)
|
---|
149 | FLG_COLOR_FORE_BLUE EQU (1<<0)
|
---|
150 | FLG_COLOR_FORE_GREEN EQU (1<<1)
|
---|
151 | FLG_COLOR_FORE_RED EQU (1<<2)
|
---|
152 | FLG_COLOR_FORE_INTENSITY EQU (1<<3)
|
---|
153 | FLG_COLOR_FORE_FONT_B EQU (1<<3) ; Select font set B (if available, EGA+)
|
---|
154 | FLG_COLOR_BACK_BLUE EQU (1<<4)
|
---|
155 | FLG_COLOR_BACK_GREEN EQU (1<<5)
|
---|
156 | FLG_COLOR_BACK_RED EQU (1<<6)
|
---|
157 | FLG_COLOR_BACK_INTENSITY EQU (1<<7) ; Intensity when blinking is disabled
|
---|
158 | FLG_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) )
|
---|
162 | COLOR_BLACK EQU 0
|
---|
163 | COLOR_BLUE EQU 1
|
---|
164 | COLOR_GREEN EQU 2
|
---|
165 | COLOR_CYAN EQU 3
|
---|
166 | COLOR_RED EQU 4
|
---|
167 | COLOR_MAGENTA EQU 5
|
---|
168 | COLOR_BROWN EQU 6
|
---|
169 | COLOR_WHITE EQU 7 ; Last background color if blinking enabled
|
---|
170 | COLOR_GRAY EQU 8
|
---|
171 | COLOR_LIGHT_BLUE EQU 9
|
---|
172 | COLOR_LIGHT_GREEN EQU 10
|
---|
173 | COLOR_LIGHT_CYAN EQU 11
|
---|
174 | COLOR_LIGHT_RED EQU 12
|
---|
175 | COLOR_LIGHT_MAGENTA EQU 13
|
---|
176 | COLOR_YELLOW EQU 14
|
---|
177 | COLOR_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)
|
---|
182 | FLG_MONO_UNDERLINE EQU (1<<1)
|
---|
183 | FLG_MONO_INTENSITY EQU (1<<3)
|
---|
184 | FLG_MONO_BLINK EQU (1<<7)
|
---|
185 |
|
---|
186 | ; Text mode character attribute bytes for MDA/Hercules (monochrome adapters)
|
---|
187 | ; *Not displayed on some monitors
|
---|
188 | MONO_HIDDEN EQU 00h ; Not displayed (same for 08h, 80h and 88h)
|
---|
189 | MONO_UNDERLINE EQU 01h ; Underlined
|
---|
190 | MONO_NORMAL EQU 07h ; Normal (white on black)
|
---|
191 | MONO_BRIGHT_UNDERLINE EQU 09h ; High intensity, underlined
|
---|
192 | MONO_BRIGHT EQU 0Fh ; High intensity
|
---|
193 | MONO_REVERSE EQU 70h ; Reverse video (black on white)
|
---|
194 | MONO_REVERSE_DARK EQU 78h ; (dark green on green)
|
---|
195 | MONO_BLINK EQU 87h ; Blinking white on black*
|
---|
196 | MONO_BRIGHT_BLINK EQU 8Fh ; Blinking high intensity*
|
---|
197 | MONO_REVERSE_BLINK EQU 0F0h ; Blinking reverse video
|
---|
198 | MONO_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
|
---|
205 | CURSOR_NORMAL_COLOR EQU 0607h ; Two line cursor near or at the bottom of cell (not valid for IBM MDA)
|
---|
206 | CURSOR_NORMAL_MDA EQU 0B0Ch ; Scanlines 11 and 12
|
---|
207 | CURSOR_HIDDEN EQU 2000h
|
---|
208 |
|
---|
209 |
|
---|
210 | ; Display modes
|
---|
211 | CGA_TEXT_MODE_BW40 EQU 0 ; Applications should use...
|
---|
212 | CGA_TEXT_MODE_CO40 EQU 1
|
---|
213 | CGA_TEXT_MODE_BW80 EQU 2 ; ..black, white and bright white attributes only
|
---|
214 | CGA_TEXT_MODE_CO80 EQU 3
|
---|
215 | MDA_TEXT_MODE EQU 7 ; Real monochrome attributes available
|
---|
216 |
|
---|
217 |
|
---|
218 | ; Display segments
|
---|
219 | COLOR_TEXT_SEGMENT EQU 0B800h ; Text modes 0...3 (CGA+)
|
---|
220 | MONO_TEXT_SEGMENT EQU 0B000h ; Text mode 7 (MDA, Hercules)
|
---|
221 |
|
---|
222 | OFFSET_TO_CGA_STATUS_REGISTER EQU 6 ; Base port 3D4h + 6 = 3DAh
|
---|
223 | CGA_STATUS_REGISTER EQU 3DAh
|
---|
224 |
|
---|
225 | %endif ; MODULE_STRINGS_COMPRESS_PRECOMPRESS
|
---|
226 |
|
---|
227 | ; Control characters for teletype output
|
---|
228 | NULL EQU 00h
|
---|
229 | SOH EQU 01h ; Start of heading
|
---|
230 | STX EQU 02h ; Start of text
|
---|
231 | BELL EQU 07h ; Bell
|
---|
232 | BS EQU 08h ; Backspace
|
---|
233 | TAB EQU 09h ; Horizontal TAB
|
---|
234 | LF EQU 0Ah ; Line feed (newline)
|
---|
235 | CR EQU 0Dh ; Carriage return
|
---|
236 | ESC EQU 1Bh ; Escape
|
---|
237 |
|
---|
238 | ; Non ASCII characters (code page 437)
|
---|
239 | BETA EQU 225
|
---|
240 | QUOTATION_MARK EQU 34
|
---|
241 | DOUBLE_TOP_RIGHT_CORNER EQU 187
|
---|
242 | DOUBLE_TOP_LEFT_CORNER EQU 201
|
---|
243 | DOUBLE_BOTTOM_RIGHT_CORNER EQU 188
|
---|
244 | DOUBLE_BOTTOM_LEFT_CORNER EQU 200
|
---|
245 | DOUBLE_VERTICAL EQU 186
|
---|
246 | DOUBLE_HORIZONTAL EQU 205
|
---|
247 | DOUBLE_VERTICAL_TO_RIGHT_SINGLE EQU 199
|
---|
248 | DOUBLE_VERTICAL_TO_LEFT_SINGLE EQU 182
|
---|
249 | DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL EQU 181
|
---|
250 | DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL EQU 198
|
---|
251 | SINGLE_VERTICAL EQU 179
|
---|
252 | SINGLE_HORIZONTAL EQU 196
|
---|
253 | SINGLE_LEFT_HORIZONTAL_TO_VERTICAL EQU 180
|
---|
254 | SINGLE_RIGHT_HORIZONTAL_TO_VERTICAL EQU 195
|
---|
255 | ANGLE_QUOTE_LEFT EQU 174
|
---|
256 | ANGLE_QUOTE_RIGHT EQU 175
|
---|
257 | BLOCK_MOSTLY_BACKGROUND EQU 176
|
---|
258 | BLOCK_EVEN_BACKGROUND_AND_FOREGROUND EQU 177
|
---|
259 | BLOCK_MOSTLY_FOREGROUND EQU 178
|
---|
260 | BLOCK_FULL_FOREGROUND EQU 219
|
---|
261 | ONE_HALF EQU 171
|
---|
262 | ONE_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
|
---|