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

Last change on this file since 46 was 45, checked in by Tomi Tilli, 14 years ago

Changes to assembly library:
Changed SetCharOutputFunctionFromAXwithAttribFlagInDL to SetCharOutputFunctionFromAXwithAttribFlagInBL since DX register gets corrupted by Display_FunctionFromDI.
Implemented quicksort.

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