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

Last change on this file since 617 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 9.7 KB
RevLine 
[41]1; Project name : AssemblyLibrary
2; Description : Defines for display library.
3%ifndef DISPLAY_INC
4%define DISPLAY_INC
5
[186]6%ifndef MODULE_STRINGS_COMPRESSED_PRECOMPRESS
[41]7;--------------------------------------------------------------------
[505]8; Display Library users need to use these macros since it will provide
[41]9; compatibility with future library versions.
10;
11; CALL_DISPLAY_LIBRARY
[505]12; JMP_DISPLAY_LIBRARY
[41]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
[52]26 %elifidn %1, PrepareOffScreenBufferInESBXwithLengthInCX
27 call DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX
[41]28 %else
[177]29 mov di, %1
[41]30 call Display_FunctionFromDI
31 %endif
32%endmacro
33
[505]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
[177]52%if 0
53;;;
54;;; struc no longer needed with direct calls to functions
55;;;
[41]56
57; Display library functions
58struc DISPLAY_LIB
59 .PushDisplayContext:
60 .PopDisplayContext:
[44]61 .InitializeDisplayContext resb 2
[41]62
[592]63%ifndef EXCLUDE_FROM_XUB
[44]64 .SetCharacterPointerFromBXAX resb 2
[133]65%endif
[45]66 .SetCharOutputFunctionFromAXwithAttribFlagInBL resb 2
[44]67 .SetCharacterOutputParameterFromAX resb 2
68 .SetCharacterAttributeFromAL resb 2
69 .SetCursorShapeFromAX resb 2
70 .SetCursorCoordinatesFromAX resb 2
[370]71%ifndef EXCLUDE_FROM_XTIDECFG
[44]72 .SetNewPageFromAL resb 2
[370]73%endif
[44]74 .SynchronizeDisplayContextToHardware resb 2
[41]75
[592]76%ifndef EXCLUDE_FROM_XUB
[44]77 .GetCharacterPointerToBXAX resb 2
[133]78%endif
[44]79 .GetSoftwareCoordinatesToAX resb 2
80 .GetColumnsToALandRowsToAH resb 2
[41]81
[44]82 .FormatNullTerminatedStringFromCSSI resb 2
[592]83%ifndef EXCLUDE_FROM_XUB
[590]84 .PrintSignedWordFromAXWithBaseInBL resb 2
[134]85%endif
[590]86 .PrintWordFromAXWithBaseInBL resb 2
[592]87%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
[323]88 .PrintQWordFromSSBPwithBaseInBX resb 2
89%endif
[44]90 .PrintCharBufferFromBXSIwithLengthInCX resb 2
91 .PrintNullTerminatedStringFromBXSI resb 2
92 .PrintNullTerminatedStringFromCSSI resb 2
93 .PrintRepeatedCharacterFromALwithCountInCX resb 2
94 .PrintCharacterFromAL resb 2
95 .PrintNewlineCharacters resb 2
[592]96%ifndef EXCLUDE_FROM_XUB
[44]97 .ClearAreaWithHeightInAHandWidthInAL resb 2
[134]98%endif
[67]99 .ClearScreenWithCharInALandAttrInAH resb 2
[41]100endstruc
[177]101%endif
[41]102
[390]103; Attribute flags for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInBL
[44]104ATTRIBUTES_NOT_USED EQU 0
105ATTRIBUTES_ARE_USED EQU FLG_CONTEXT_ATTRIBUTES
106
[390]107; Character output functions for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInBL
[41]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
[44]140 .bFlags resb 1 ; Display context flags
[41]141endstruc
142
[44]143; Display context flags
144FLG_CONTEXT_ATTRIBUTES EQU (1<<0) ; Character output function uses attributes
[50]145FLG_CONTEXT_CGA EQU (1<<1) ; CGA detected so prevent CGA snow
[41]146
[44]147
[41]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
[407]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
[41]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
[48]222OFFSET_TO_CGA_STATUS_REGISTER EQU 6 ; Base port 3D4h + 6 = 3DAh
223CGA_STATUS_REGISTER EQU 3DAh
[41]224
[186]225%endif ; MODULE_STRINGS_COMPRESS_PRECOMPRESS
[48]226
[41]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)
[287]239BETA EQU 225
[91]240QUOTATION_MARK EQU 34
[41]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
[85]251SINGLE_VERTICAL EQU 179
[41]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
[44]257BLOCK_MOSTLY_BACKGROUND EQU 176
258BLOCK_EVEN_BACKGROUND_AND_FOREGROUND EQU 177
259BLOCK_MOSTLY_FOREGROUND EQU 178
260BLOCK_FULL_FOREGROUND EQU 219
[91]261ONE_HALF EQU 171
262ONE_QUARTER EQU 172
[41]263
264
[44]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
[67]272%define SCREEN_BACKGROUND_CHARACTER_AND_ATTRIBUTE (SCREEN_BACKGROUND_CHARACTER | (SCREEN_BACKGROUND_ATTRIBUTE<<8))
273%define DOS_BACKGROUND_CHARACTER_AND_ATTRIBUTE (' ' | (MONO_NORMAL<<8))
[44]274
[41]275%endif ; DISPLAY_INC
Note: See TracBrowser for help on using the repository browser.