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