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