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