diff options
Diffstat (limited to 'v4.0/src/CMD/GRAPHICS/GRCTRL.ASM')
| -rw-r--r-- | v4.0/src/CMD/GRAPHICS/GRCTRL.ASM | 2162 |
1 files changed, 2162 insertions, 0 deletions
diff --git a/v4.0/src/CMD/GRAPHICS/GRCTRL.ASM b/v4.0/src/CMD/GRAPHICS/GRCTRL.ASM new file mode 100644 index 0000000..1deff0a --- /dev/null +++ b/v4.0/src/CMD/GRAPHICS/GRCTRL.ASM | |||
| @@ -0,0 +1,2162 @@ | |||
| 1 | PAGE ,132 ;AN000; | ||
| 2 | ;AN000; | ||
| 3 | TITLE DOS GRAPHICS Command - Print screen Control module | ||
| 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000; | ||
| 5 | ;; DOS - GRAPHICS Command | ||
| 6 | ;; (c) Copyright 1988 Microsoft | ||
| 7 | ;; ;AN000; | ||
| 8 | ;; File Name: GRCTRL.ASM ;AN000; | ||
| 9 | ;; ---------- ;AN000; | ||
| 10 | ;; ;AN000; | ||
| 11 | ;; Description: ;AN000; | ||
| 12 | ;; ------------ ;AN000; | ||
| 13 | ;; This file contains the code for the Print Screen control module. ;AN000; | ||
| 14 | ;; ;AN000; | ||
| 15 | ;; Documentation Reference: ;AN000; | ||
| 16 | ;; ------------------------ ;AN000; | ||
| 17 | ;; OASIS High Level Design ;AN000; | ||
| 18 | ;; OASIS GRAPHICS I1 Overview ;AN000; | ||
| 19 | ;; ;AN000; | ||
| 20 | ;; Procedures Contained in This File: ;AN000; | ||
| 21 | ;; ---------------------------------- ;AN000; | ||
| 22 | ;; PRT_SCR ;AN000; | ||
| 23 | ;; DET_HW_CONFIG ;AN000; | ||
| 24 | ;; DET_MODE_STATE ;AN000; | ||
| 25 | ;; GET_MODE_ATTR ;AN000; | ||
| 26 | ;; SET_UP_XLT_TAB ;AN000; | ||
| 27 | ;; SET_CGA_XLT_TAB ;AN000; | ||
| 28 | ;; CGA_COL2RGB ;AN000; | ||
| 29 | ;; RGB2XLT_TAB ;AN000; | ||
| 30 | ;; SET_EGA_XLT_TAB ;AN000; | ||
| 31 | ;; EGA_COL2RGB ;AN000; | ||
| 32 | ;; SET_MODE_F_XLT_TAB ;AN000; | ||
| 33 | ;; SET_MODE_13H_XLT_TAB ;AN000; | ||
| 34 | ;; SET_ROUNDUP_XLT_TAB ;AN000; | ||
| 35 | ;; SET_BACKG_IN_XLT_TAB ;AN000; | ||
| 36 | ;; RGB2BAND ;AN000; | ||
| 37 | ;; RGB2INT ;AN000; | ||
| 38 | ;; ;AN000; | ||
| 39 | ;; ;AN000; | ||
| 40 | ;; Include Files Required: ;AN000; | ||
| 41 | ;; ----------------------- ;AN000; | ||
| 42 | ;; GRINST.EXT - Externals for GRINST.ASM ;AN000; | ||
| 43 | ;; ;AN000; | ||
| 44 | ;; ;AN000; | ||
| 45 | ;; External Procedure References: ;AN000; | ||
| 46 | ;; ------------------------------ ;AN000; | ||
| 47 | ;; FROM FILE GRINST.ASM: ;AN000; | ||
| 48 | ;; GRAPHICS_INSTALL - Main module for installation. ;AN000; | ||
| 49 | ;; ;AN000; | ||
| 50 | ;; Linkage Instructions: ;AN000; | ||
| 51 | ;; -------------------- ;AN000; | ||
| 52 | ;; Refer to GRAPHICS.ASM ;AN000; | ||
| 53 | ;; ;AN000; | ||
| 54 | ;; Change History: ;AN000; | ||
| 55 | ;; --------------- ;AN000; | ||
| 56 | ;; ;AN000; | ||
| 57 | ;; ;AN000; | ||
| 58 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000; | ||
| 59 | CODE SEGMENT PUBLIC 'CODE' ;AN000; | ||
| 60 | ASSUME CS:CODE,DS:CODE ;AN000; | ||
| 61 | ;AN000; | ||
| 62 | .XLIST ;AN000; | ||
| 63 | INCLUDE GRINT2FH.EXT ;AN000; | ||
| 64 | INCLUDE GRBWPRT.EXT ;AN000; | ||
| 65 | INCLUDE GRCOLPRT.EXT ;AN000; | ||
| 66 | INCLUDE GRSHAR.STR ;AN000; | ||
| 67 | INCLUDE GRPATTRN.STR ;AN000; | ||
| 68 | INCLUDE GRPATTRN.EXT ;AN000; | ||
| 69 | INCLUDE STRUC.INC ;AN000; | ||
| 70 | .LIST ;AN000; | ||
| 71 | PRT_SCR PROC NEAR ;AN000; | ||
| 72 | JMP PRT_SCR_BEGIN ;AN000; | ||
| 73 | PAGE ;AN000; | ||
| 74 | ;===============================================================================;AN000; | ||
| 75 | ; ;AN000; | ||
| 76 | ; GRAPHICS INTERRUPT DRIVER'S DATA: ;AN000; | ||
| 77 | ; ;AN000; | ||
| 78 | ;===============================================================================;AN000; | ||
| 79 | .xlist ;AN000; | ||
| 80 | PUBLIC PRT_SCR,ERROR_CODE,XLT_TAB,MODE_TYPE ;AN000; | ||
| 81 | PUBLIC CUR_MODE_PTR,CUR_MODE,NB_COLORS,SCREEN_HEIGHT,SCREEN_WIDTH ;AN000; | ||
| 82 | PUBLIC CUR_PAGE,CUR_COLUMN,CUR_ROW,NB_SCAN_LINES,SCAN_LINE_MAX_LENGTH ;AN000; | ||
| 83 | PUBLIC CUR_SCAN_LNE_LENGTH ;AN000; | ||
| 84 | PUBLIC PRT_BUF,NB_BOXES_PER_PRT_BUF,CUR_BOX,BOX_H,BOX_W ;AN000; | ||
| 85 | PUBLIC PRINT_SCREEN_ALLOWED,RGB ;AN000; | ||
| 86 | PUBLIC BIOS_INT_5H ;AN000; | ||
| 87 | PUBLIC ROTATE_SW ;AN000; | ||
| 88 | PUBLIC DET_HW_CONFIG ;AN000; | ||
| 89 | PUBLIC NB_CHAR_COLUMNS ;AN000; | ||
| 90 | PUBLIC RGB2INT ;AN000; | ||
| 91 | PUBLIC RGB2BAND ;AN000; | ||
| 92 | .list ;AN000; | ||
| 93 | INCLUDE GRCTRL.STR ;AN000; | ||
| 94 | ;-------------------------------------------------------------------------------;AN000; | ||
| 95 | ; ;AN000; | ||
| 96 | ; ENTRY POINT TO BIOS HARDWARE INTERRUPT 5 HANDLER ;AN000; | ||
| 97 | ; ;AN000; | ||
| 98 | ;-------------------------------------------------------------------------------;AN000; | ||
| 99 | BIOS_INT_5H DW ? ; Pointer to BIOS int 5h ;AN000; | ||
| 100 | DW ? ;AN000; | ||
| 101 | ;AN000; | ||
| 102 | ;-------------------------------------------------------------------------------;AN000; | ||
| 103 | ; ;AN000; | ||
| 104 | ; PRINT SCREEN ERROR CODE (Used at print screen time, see GRCTRL.STR for ;AN000; | ||
| 105 | ; error codes allowed) ;AN000; | ||
| 106 | ; ;AN000; | ||
| 107 | ;-------------------------------------------------------------------------------;AN000; | ||
| 108 | ERROR_CODE DB 0 ; ERROR CODE 0 = NO ERROR ;AN000; | ||
| 109 | ;AN000; | ||
| 110 | ;-------------------------------------------------------------------------------;AN000; | ||
| 111 | ; ;AN000; | ||
| 112 | ; SCREEN PIXEL: INTERNAL REPRESENTATION ;AN000; | ||
| 113 | ; ;AN000; | ||
| 114 | ;-------------------------------------------------------------------------------;AN000; | ||
| 115 | RGB PIXEL_STR < , , > ; PIXEL := RED, GREEN, BLUE Values ;AN000; | ||
| 116 | ;AN000; | ||
| 117 | ;-------------------------------------------------------------------------------;AN000; | ||
| 118 | ; ;AN000; | ||
| 119 | ; COLOR TRANSLATION TABLE: ;AN000; | ||
| 120 | ; ;AN000; | ||
| 121 | ; This table is used to translate the color numbers returned by ;AN000; | ||
| 122 | ; Interrupt 10H Read Dot and Read Character calls into print ;AN000; | ||
| 123 | ; information. The table consists of 256 entries, one byte each, ;AN000; | ||
| 124 | ; indexed by color number. ;AN000; | ||
| 125 | ; In the case of black and white printing, the table ;AN000; | ||
| 126 | ; entries are grey scale intensities from 0 to 63. In the case ;AN000; | ||
| 127 | ; of color printing each table entry contains a "band mask" indicating ;AN000; | ||
| 128 | ; which color print bands are required to generate the required color. ;AN000; | ||
| 129 | ; The band masks are simply bit masks where each bit corresponds to one ;AN000; | ||
| 130 | ; of the printer bands. ;AN000; | ||
| 131 | ; ;AN000; | ||
| 132 | ; The table is set up at the beginning of the print screen processing, ;AN000; | ||
| 133 | ; before any data is read from the screen. From then on, translating ;AN000; | ||
| 134 | ; from screen information into print information is done quickly by ;AN000; | ||
| 135 | ; accessing this table. Not all 256 entries are initialized for each ;AN000; | ||
| 136 | ; screen print. The number of entries used is equal to the number ;AN000; | ||
| 137 | ; of colors available concurrently with the given display mode. ;AN000; | ||
| 138 | ;-------------------------------------------------------------------------------;AN000; | ||
| 139 | XLT_TAB DB 256 DUP(32) ; COLOR TRANSLATION TABLE ;AN000; | ||
| 140 | ; This table is used to translate the Color Dot ;AN000; | ||
| 141 | ; or Byte Attribute to a Band Mask for color ;AN000; | ||
| 142 | ; printing or to a Grey Intensity for Mono- ;AN000; | ||
| 143 | ; chrome printing. ;AN000; | ||
| 144 | ;AN000; | ||
| 145 | ;-------------------------------------------------------------------------------;AN000; | ||
| 146 | ; ;AN000; | ||
| 147 | ; CURRENT VIDEO MODE ATTRIBUTES ;AN000; | ||
| 148 | ; ;AN000; | ||
| 149 | ;-------------------------------------------------------------------------------;AN000; | ||
| 150 | MODE_TYPE DB ? ; Mode types (bit mask) APA or TXT ;AN000; | ||
| 151 | ;AN000; | ||
| 152 | CUR_MODE_PTR DW ? ; DISPLAYMODE INFO RECORD for the current ;AN000; | ||
| 153 | ; mode (defined in the shared data area). ;AN000; | ||
| 154 | CUR_MODE DB ? ; Current video mode number ;AN000; | ||
| 155 | NB_COLORS DW ? ; Number of colors supported by this mode ;AN000; | ||
| 156 | SCREEN_HEIGHT DW ? ; Number of rows on the screen (chars or pixels);AN000; | ||
| 157 | SCREEN_WIDTH DW ? ; Number of columns on the screen (chars/pixels);AN000; | ||
| 158 | ; (for text modes is equal to NB_CHAR_COLUMNS) ;AN000; | ||
| 159 | NB_CHAR_COLUMNS DB ? ; Number of columns on the screen if in txt mode;AN000; | ||
| 160 | CUR_PAGE DB ? ; Active page number ;AN000; | ||
| 161 | ROTATE_SW DB ? ; Switch: if "ON" then, must print sideways ;AN000; | ||
| 162 | ;AN000; | ||
| 163 | ;-------------------------------------------------------------------------------;AN000; | ||
| 164 | ; ;AN000; | ||
| 165 | ; ACTIVE SCREEN ATTRIBUTES ;AN000; | ||
| 166 | ; ;AN000; | ||
| 167 | ;-------------------------------------------------------------------------------;AN000; | ||
| 168 | CUR_COLUMN DW ? ; Current pixel/char column number ;AN000; | ||
| 169 | CUR_ROW DW ? ; Current pixel/char row number ;AN000; | ||
| 170 | NB_SCAN_LINES DW ? ; Number of screen scan lines ;AN000; | ||
| 171 | SCAN_LINE_MAX_LENGTH DW ? ; Maximum number of dots/chars per scan line ;AN000; | ||
| 172 | CUR_SCAN_LNE_LENGTH DW ? ; Length in pels/chars of the current scan line ;AN000; | ||
| 173 | ;AN000; | ||
| 174 | ;-------------------------------------------------------------------------------;AN000; | ||
| 175 | ; ;AN000; | ||
| 176 | ; PRINTER VARIABLES ;AN000; | ||
| 177 | ; ;AN000; | ||
| 178 | ;-------------------------------------------------------------------------------;AN000; | ||
| 179 | PRT_BUF DB ?,?,?,? ; PRINT BUFFER ;AN000; | ||
| 180 | NB_BOXES_PER_PRT_BUF DB ? ; Number of boxes fitting in the print buffer ;AN000; | ||
| 181 | CUR_BOX DB ?,?,?,? ; BOX = PRINTER REPRESENTATION OF 1 PIXEL ;AN000; | ||
| 182 | BOX_H DB ? ; HEIGHT OF THE BOX ;AN000; | ||
| 183 | BOX_W DB ? ; WIDTH OF THE BOX ;AN000; | ||
| 184 | ;AN000; | ||
| 185 | ;-------------------------------------------------------------------------------;AN000; | ||
| 186 | ; ;AN000; | ||
| 187 | ; CONTROL VARIABLES: ;AN000; | ||
| 188 | ; ;AN000; | ||
| 189 | ; This data is used to communicate between the Installation Modules ;AN000; | ||
| 190 | ; and the Resident Print Screen Modules. ;AN000; | ||
| 191 | ;-------------------------------------------------------------------------------;AN000; | ||
| 192 | PRINT_SCREEN_ALLOWED DB YES; Used to avoid print screens ;AN000; | ||
| 193 | ; while the GRAPHICS installation ;AN000; | ||
| 194 | ; (or re-install) is in progress ;AN000; | ||
| 195 | ; Set by GRAPHICS_INSTALL module. ;AN000; | ||
| 196 | ;AN000; | ||
| 197 | ;AN000; | ||
| 198 | PAGE ;AN000; | ||
| 199 | ;===============================================================================;AN000; | ||
| 200 | ; ;AN000; | ||
| 201 | ; INTERRUPT 5 DRIVER'S CODE: ;AN000; | ||
| 202 | ; ;AN000; | ||
| 203 | ;-------------------------------------------------------------------------------;AN000; | ||
| 204 | ;===============================================================================;AN000; | ||
| 205 | ; ;AN000; | ||
| 206 | ; PRT_SCR : PRINT THE ACTIVE SCREEN ;AN000; | ||
| 207 | ; ;AN000; | ||
| 208 | ;-------------------------------------------------------------------------------;AN000; | ||
| 209 | ; ;AN000; | ||
| 210 | ; INPUT: SHARED_DATA_AREA_PTR = Offset of the data area used for ;AN000; | ||
| 211 | ; passing data between the ;AN000; | ||
| 212 | ; Installation process and the Print ;AN000; | ||
| 213 | ; Screen process. ;AN000; | ||
| 214 | ; PRINT_SCREEN_ALLOWED = Switch. Set to "No" if currently ;AN000; | ||
| 215 | ; installing GRAPHICS.COM ;AN000; | ||
| 216 | ; ;AN000; | ||
| 217 | ; NOTE: These 2 variables are declared within ;AN000; | ||
| 218 | ; PRT_SCR but initialized by the ;AN000; | ||
| 219 | ; Installation process GRAPHICS_INIT ;AN000; | ||
| 220 | ; OUTPUT: PRINTER ;AN000; | ||
| 221 | ; ;AN000; | ||
| 222 | ; CALLED BY: INTERRUPT 5 ;AN000; | ||
| 223 | ; ;AN000; | ||
| 224 | ; ;AN000; | ||
| 225 | ;-------------------------------------------------------------------------------;AN000; | ||
| 226 | ; ;AN000; | ||
| 227 | ; DESCRIPTION: ;AN000; | ||
| 228 | ; ;AN000; | ||
| 229 | ; PRINT THE ACTIVE SCREEN for all TEXT and All Points Addressable (APA) ;AN000; | ||
| 230 | ; display modes available with either a MONO, CGA, EGA, or VGA video ;AN000; | ||
| 231 | ; adapter on a Black and White or Color printer. ;AN000; | ||
| 232 | ; ;AN000; | ||
| 233 | ; INITIALIZATION: ;AN000; | ||
| 234 | ; ;AN000; | ||
| 235 | ; Each pixel or character on the screen has a color attribute. These ;AN000; | ||
| 236 | ; colors must be translated into different internal representations: ;AN000; | ||
| 237 | ; ;AN000; | ||
| 238 | ; For printing in colors, each color is translated to a BAND MASK. ;AN000; | ||
| 239 | ; The Band Mask indicates how to obtain this color on the printer. ;AN000; | ||
| 240 | ; ;AN000; | ||
| 241 | ; For printing in Black and White, each color is translated to a ;AN000; | ||
| 242 | ; GREY INTENSITY number between 0 (black) and 63 (white). ;AN000; | ||
| 243 | ; ;AN000; | ||
| 244 | ; The BAND MASK or the GREY INTENSITIES are found in the COLOR ;AN000; | ||
| 245 | ; TRANSLATION TABLE. This table is initialized before calling any of ;AN000; | ||
| 246 | ; the print screen modules. ;AN000; | ||
| 247 | ; ;AN000; | ||
| 248 | ; PRINT SCREEN TIME: ;AN000; | ||
| 249 | ; ;AN000; | ||
| 250 | ; When a pixel or character is read off the screen by one of the print ;AN000; | ||
| 251 | ; screen modules, its color is used as an index into the translation ;AN000; | ||
| 252 | ; table. ;AN000; | ||
| 253 | ; ;AN000; | ||
| 254 | ; ;AN000; | ||
| 255 | ; LOGIC: ;AN000; | ||
| 256 | ; ;AN000; | ||
| 257 | ; IF SCREEN_PRINTS_ALLOWED=NO ; Block print screens until Installation ;AN000; | ||
| 258 | ; THEN IRET ; Process (or re-install!) is finished. ;AN000; | ||
| 259 | ; ELSE ;AN000; | ||
| 260 | ; ;AN000; | ||
| 261 | ; CALL DET_HW_CONFIG ; Determine hardware configuration ;AN000; | ||
| 262 | ; CALL DET_MODE_STATE ; Determine video mode and active page ;AN000; | ||
| 263 | ; CALL GET_MODE_ATTR ; Get video attributes (TXT or APA, etc) ;AN000; | ||
| 264 | ; ;AN000; | ||
| 265 | ; IF MODE_TYPE = TXT AND Number of colors = 0 ;AN000; | ||
| 266 | ; THEN Invoke BIOS INTERRUPT 5 ;AN000; | ||
| 267 | ; ELSE ;AN000; | ||
| 268 | ; IF PRINTER_TYPE = BLACK_WHITE ;AN000; | ||
| 269 | ; THEN ;AN000; | ||
| 270 | ; IF MODE_TYPE = TXT ;AN000; | ||
| 271 | ; THEN Invoke BIOS INTERRUPT 5 ;AN000; | ||
| 272 | ; ELSE ; Mode is APA ;AN000; | ||
| 273 | ; CALL SET_UP_XLT_TAB ; Set up the color translation table ;AN000; | ||
| 274 | ; CALL PRINT_BW_APA ; Print the active screen on a B&W printer ;AN000; | ||
| 275 | ; ELSE ; Color printer attached ;AN000; | ||
| 276 | ; CALL SET_UP_XLT_TAB ; Set up the color translation table ;AN000; | ||
| 277 | ; CALL PRINT_COLOR ; Print the active screen on a Color prt. ;AN000; | ||
| 278 | ; IRET ;AN000; | ||
| 279 | ; ;AN000; | ||
| 280 | PRT_SCR_BEGIN: ;AN000; | ||
| 281 | PUSH AX ; Save Registers ;AN000; | ||
| 282 | PUSH BX ; ;AN000; | ||
| 283 | PUSH CX ; ;AN000; | ||
| 284 | PUSH DX ; ;AN000; | ||
| 285 | PUSH SI ; ;AN000; | ||
| 286 | PUSH DI ; ;AN000; | ||
| 287 | PUSH BP ; ;AN000; | ||
| 288 | PUSH DS ; ;AN000; | ||
| 289 | PUSH ES ; ;AN000; | ||
| 290 | ; ;AN000; | ||
| 291 | CLD ; Clear direction flag ;AN000; | ||
| 292 | PUSH CS ; DS := CS ;AN000; | ||
| 293 | POP DS ;AN000; | ||
| 294 | ;AN000; | ||
| 295 | ;-------------------------------------------------------------------------------;AN000; | ||
| 296 | ; Verify if we are allowed to print (not allowed if currently installing ;AN000; | ||
| 297 | ; GRAPHICS or printing a screen): ;AN000; | ||
| 298 | ;-------------------------------------------------------------------------------;AN000; | ||
| 299 | CMP PRINT_SCREEN_ALLOWED,NO ; IF not allowed to print ;AN000; | ||
| 300 | JE PRT_SCR_RETURN ; THEN quit ;AN000; | ||
| 301 | ; ELSE print the screen: ;AN000; | ||
| 302 | ;-------------------------------------------------------------------------------;AN000; | ||
| 303 | ; INITIALIZATION: ;AN000; | ||
| 304 | ;-------------------------------------------------------------------------------;AN000; | ||
| 305 | PRT_SCR_INIT: ; Disable print screen while ;AN000; | ||
| 306 | MOV PRINT_SCREEN_ALLOWED,NO ; we are printing the current ;AN000; | ||
| 307 | ; screen. ;AN000; | ||
| 308 | MOV BP,SHARED_DATA_AREA_PTR ; BP := Offset Shared Data Area ;AN000; | ||
| 309 | MOV ERROR_CODE,NO_ERROR ; No error so far. ;AN000; | ||
| 310 | CALL DET_HW_CONFIG ; Determine the type of display adapter ;AN000; | ||
| 311 | CALL DET_MODE_STATE ; Init CUR_PAGE, CUR_MODE ;AN000; | ||
| 312 | CALL GET_MODE_ATTR ; Determine if APA or TXT, nb. of colors, ;AN000; | ||
| 313 | ; and screen dimensions in pels or characters. ;AN000; | ||
| 314 | ; ;AN000; | ||
| 315 | ; Test the error code returned by GET_MODE_ATTR: ;AN000; | ||
| 316 | ; ;AN000; | ||
| 317 | TEST ERROR_CODE,MODE_NOT_SUPPORTED ;If mode not supported then, ;AN000; | ||
| 318 | JNZ EXIT_TO_BIOS ; let BIOS give it a try. ;AN000; | ||
| 319 | ;AN000; | ||
| 320 | ;------------------------------------------------------------------------------;AN000; | ||
| 321 | ; Check the printer type: ;AN000; | ||
| 322 | ;------------------------------------------------------------------------------;AN000; | ||
| 323 | .IF <DS:[BP].PRINTER_TYPE EQ BLACK_WHITE> ; Is a black and white printer ;AN000; | ||
| 324 | .THEN ; attached ? ;AN000; | ||
| 325 | ;------------------------------------------------------------------------------;AN000; | ||
| 326 | ; A Black and White printer is attached ;AN000; | ||
| 327 | ;------------------------------------------------------------------------------;AN000; | ||
| 328 | CMP MODE_TYPE,TXT ; Is the screen in text mode ? ;AN000; | ||
| 329 | JNE INVOKE_PRINT_ROUTINE ; No, call GRAPHICS B&W routine ;AN000; | ||
| 330 | JMP SHORT EXIT_TO_BIOS ; Yes, give control to BIOS INTERRUPT 5 ;AN000; | ||
| 331 | .ELSE ;AN000; | ||
| 332 | ;------------------------------------------------------------------------------;AN000; | ||
| 333 | ; A Color printer is attached ;AN000; | ||
| 334 | ;------------------------------------------------------------------------------;AN000; | ||
| 335 | CMP NB_COLORS,0 ; Is the screen in a Monochrome ;AN000; | ||
| 336 | JNE INVOKE_PRINT_ROUTINE ;AN000; | ||
| 337 | TEST MODE_TYPE,TXT ; text mode ? ;AN000; | ||
| 338 | JNZ INVOKE_PRINT_ROUTINE ;AN000; | ||
| 339 | JMP SHORT EXIT_TO_BIOS ; Yes, let BIOS INTERRUPT 5 handle it ;AN000; | ||
| 340 | ; No, we handle it. ;AN000; | ||
| 341 | .ENDIF ; ENDIF black and white or color printer ;AN000; | ||
| 342 | ;-------------------------------------------------------------------------------;AN000; | ||
| 343 | ; ;AN000; | ||
| 344 | ; Call the print routine (which is either PRINT_COLOR or PRINT_BW_APA) ;AN000; | ||
| 345 | ; ;AN000; | ||
| 346 | ;-------------------------------------------------------------------------------;AN000; | ||
| 347 | INVOKE_PRINT_ROUTINE: ;AN000; | ||
| 348 | CALL SET_UP_XLT_TAB ; Set up the color translation table ;AN000; | ||
| 349 | CALL PRINT_MODULE_START ; Call the print modules that were ;AN000; | ||
| 350 | ; made resident at Install time. ;AN000; | ||
| 351 | MOV PRINT_SCREEN_ALLOWED,YES; Enable PrtScr for next calls ;AN000; | ||
| 352 | ;-----------------------------------------------------------------------------;AN000; | ||
| 353 | ; Test the error code returned by either PRINT_COLOR or PRT_BW_APA ;AN000; | ||
| 354 | ;-----------------------------------------------------------------------------;AN000; | ||
| 355 | TEST ERROR_CODE,UNABLE_TO_PRINT ; If unable to print the screen ;AN000; | ||
| 356 | JNZ SHORT EXIT_TO_BIOS ; then, let BIOS give it a try ;AN000; | ||
| 357 | ;AN000; | ||
| 358 | PRT_SCR_RETURN: ;AN000; | ||
| 359 | ; Restore registers ;AN000; | ||
| 360 | POP ES ; ;AN000; | ||
| 361 | POP DS ; ;AN000; | ||
| 362 | POP BP ; ;AN000; | ||
| 363 | POP DI ; ;AN000; | ||
| 364 | POP SI ; ;AN000; | ||
| 365 | POP DX ; ;AN000; | ||
| 366 | POP CX ; ;AN000; | ||
| 367 | POP BX ; ;AN000; | ||
| 368 | POP AX ; ;AN000; | ||
| 369 | ; ;AN000; | ||
| 370 | IRET ; Return control to interrupted ;AN000; | ||
| 371 | ; process ;AN000; | ||
| 372 | EXIT_TO_BIOS: ;AN000; | ||
| 373 | ; Restore registers ;AN000; | ||
| 374 | POP ES ; ;AN000; | ||
| 375 | POP DS ; ;AN000; | ||
| 376 | POP BP ; ;AN000; | ||
| 377 | POP DI ; ;AN000; | ||
| 378 | POP SI ; ;AN000; | ||
| 379 | POP DX ; ;AN000; | ||
| 380 | POP CX ; ;AN000; | ||
| 381 | POP BX ; ;AN000; | ||
| 382 | POP AX ; ;AN000; | ||
| 383 | CLI ; Disable interrupts ;AN000; | ||
| 384 | MOV CS:PRINT_SCREEN_ALLOWED,YES ; Enable PrtScr for next calls ;AN000; | ||
| 385 | JMP DWORD PTR CS:BIOS_INT_5H ; Exit to BIOS INTERRUPT 5 ;AN000; | ||
| 386 | ;AN000; | ||
| 387 | PRT_SCR ENDP ;AN000; | ||
| 388 | ;AN000; | ||
| 389 | ;AN000; | ||
| 390 | ;===============================================================================;AN000; | ||
| 391 | ; ;AN000; | ||
| 392 | ; PRT_SCR MODULES: ;AN000; | ||
| 393 | ; ;AN000; | ||
| 394 | ;-------------------------------------------------------------------------------;AN000; | ||
| 395 | PAGE ;AN000; | ||
| 396 | ;===============================================================================;AN000; | ||
| 397 | ; ;AN000; | ||
| 398 | ; DET_HW_CONFIG : DETERMINE WHAT TYPE OF VIDEO HARDWARE IS PRESENT ;AN000; | ||
| 399 | ; ;AN000; | ||
| 400 | ;-------------------------------------------------------------------------------;AN000; | ||
| 401 | ; ;AN000; | ||
| 402 | ; INPUT: BP = Offset of the shared data area ;AN000; | ||
| 403 | ; ;AN000; | ||
| 404 | ; OUTPUT: HARDWARE_CONFIG is updated in the shared data area ;AN000; | ||
| 405 | ; ;AN000; | ||
| 406 | ; CALLED BY: PRT_SCR ;AN000; | ||
| 407 | ; ;AN000; | ||
| 408 | ; EXTERNAL CALLS: BIOS INT 10H ;AN000; | ||
| 409 | ; ;AN000; | ||
| 410 | ;-------------------------------------------------------------------------------;AN000; | ||
| 411 | ; ;AN000; | ||
| 412 | ; LOGIC: ;AN000; | ||
| 413 | ; Issue BIOS INT10H Get Display Configuration Code (AX=1A00H) ;AN000; | ||
| 414 | ; IF AL = 1AH THEN /* VGA (PS/2 OR BRECON-B) */ ;AN000; | ||
| 415 | ; /* BL = active DCC */ ;AN000; | ||
| 416 | ; /* BH = alternate DCC */ ;AN000; | ||
| 417 | ; /* Display Code: */ ;AN000; | ||
| 418 | ; /* 1 - Mono Adapter */ ;AN000; | ||
| 419 | ; /* 2 - CGA */ ;AN000; | ||
| 420 | ; /* 4 - EGA with Mono Display */ ;AN000; | ||
| 421 | ; /* 5 - EGA with Color Display */ ;AN000; | ||
| 422 | ; /* 7 - PS/2 Mod 50,60,80 OR BRECON-B with Mono Display */ ;AN000; | ||
| 423 | ; /* 8 - PS/2 Mod 50,60,80 OR BRECON-B with Color Display */ ;AN000; | ||
| 424 | ; /* B - PS/2 Mod 30 with Mono Display */ ;AN000; | ||
| 425 | ; /* C - PS/2 Mod 30 with Color Display */ ;AN000; | ||
| 426 | ; IF AL = 1AH THEN /* Call is supported */ ;AN000; | ||
| 427 | ; Set HARDWARE_CONFIG byte based on DCC returned in DL ;AN000; | ||
| 428 | ; ELSE ;AN000; | ||
| 429 | ; Issue INT 10H EGA Info (AH=12H BL=10H) ;AN000; | ||
| 430 | ; IF BL <> 10H THEN /* EGA */ ;AN000; | ||
| 431 | ; Set EGA bit in HARDWARE_CONFIG ;AN000; | ||
| 432 | ; ELSE /* CGA or */ ;AN000; | ||
| 433 | ; Issue INT 10H PC CONVERTIBLE Physical display description param. ;AN000; | ||
| 434 | ; request. (AH=15H) ;AN000; | ||
| 435 | ; IF ES:[DI] = 5140H ;AN000; | ||
| 436 | ; THEN ;AN000; | ||
| 437 | ; Set PC_CONVERTIBLE bit in HARDWARE_CONFIG ;AN000; | ||
| 438 | ; ELSE ;AN000; | ||
| 439 | ; Set OLD_ADAPTER bit in HARDWARE_CONFIG ;AN000; | ||
| 440 | ; ENDIF ;AN000; | ||
| 441 | ; ENDIF ;AN000; | ||
| 442 | ; ENDIF ;AN000; | ||
| 443 | ; RETURN ;AN000; | ||
| 444 | ; ;AN000; | ||
| 445 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000; | ||
| 446 | DET_HW_CONFIG PROC NEAR ;AN000; | ||
| 447 | ;AN000; | ||
| 448 | ;-------------------------------------------------------------------------------;AN000; | ||
| 449 | ; ;AN000; | ||
| 450 | ; Try to read display combination code (PS/2 call): ;AN000; | ||
| 451 | ; ;AN000; | ||
| 452 | ;-------------------------------------------------------------------------------;AN000; | ||
| 453 | MOV AX,READ_CONFIG_CALL ;AN000; | ||
| 454 | INT 10H ; Call video BIOS ;AN000; | ||
| 455 | ;AN000; | ||
| 456 | .IF <AL EQ 1AH> ; If call is supported ;AN000; | ||
| 457 | .THEN ;AN000; | ||
| 458 | ;-------------------------------------------------------------------------------;AN000; | ||
| 459 | ; ;AN000; | ||
| 460 | ; Call is supported, PS/2 BIOS is present (Model 39,50,60,80 or BRECON-B card), ;AN000; | ||
| 461 | ; Determine what is the primary video adapter: ;AN000; | ||
| 462 | ; ;AN000; | ||
| 463 | ;-------------------------------------------------------------------------------;AN000; | ||
| 464 | .SELECT ;AN000; | ||
| 465 | .WHEN <BL EQ 1> OR ; MONO or ;AN000; | ||
| 466 | .WHEN <BL EQ 2> ; CGA ;AN000; | ||
| 467 | MOV DS:[BP].HARDWARE_CONFIG,OLD_ADAPTER ;AN000; | ||
| 468 | .WHEN <BL EQ 4> OR ; EGA with Mono or ;AN000; | ||
| 469 | .WHEN <BL EQ 5> ; EGA with Color ;AN000; | ||
| 470 | MOV DS:[BP].HARDWARE_CONFIG,EGA ;AN000; | ||
| 471 | .WHEN <BL EQ 7> OR ; BRECON-B with Mono or ;AN000; | ||
| 472 | .WHEN <BL EQ 8> ; BRECON-B with Color ;AN000; | ||
| 473 | MOV DS:[BP].HARDWARE_CONFIG,ROUNDUP ;AN000; | ||
| 474 | .WHEN <BL EQ 0Bh> OR ; PS/2 Model 30 with Mono or ;AN000; | ||
| 475 | .WHEN <BL EQ 0Ch> ; PS/2 Model 30 with Color ;AN000; | ||
| 476 | MOV DS:[BP].HARDWARE_CONFIG,PALACE ;AN000; | ||
| 477 | .ENDSELECT ;AN000; | ||
| 478 | ;-------------------------------------------------------------------------------;AN000; | ||
| 479 | ; ;AN000; | ||
| 480 | ; PS/2 call is not supported, try the EGA info call: ;AN000; | ||
| 481 | ; ;AN000; | ||
| 482 | ;-------------------------------------------------------------------------------;AN000; | ||
| 483 | .ELSE ;AN000; | ||
| 484 | MOV AH,ALT_SELECT_CALL ; Request Alternate select's ;AN000; | ||
| 485 | MOV BL,EGA_INFO_CALL ; "return EGA information call" ;AN000; | ||
| 486 | INT 10H ; Call video BIOS ;AN000; | ||
| 487 | .IF <BL NE EGA_INFO_CALL> ; If a memory value is returned ;AN000; | ||
| 488 | .THEN ; then, there is an EGA ;AN000; | ||
| 489 | MOV DS:[BP].HARDWARE_CONFIG,EGA ;AN000; | ||
| 490 | .ELSE ; else, call is not supported: ;AN000; | ||
| 491 | ;-------------------------------------------------------------------------------;AN000; | ||
| 492 | ; ;AN000; | ||
| 493 | ; EGA call is not supported, try the PC CONVERTIBLE display description call: ;AN000; | ||
| 494 | ; ;AN000; | ||
| 495 | ;-------------------------------------------------------------------------------;AN000; | ||
| 496 | MOV AH,DISP_DESC_CALL ;AN000; | ||
| 497 | INT 10H ; Call BIOS, ES:DI :=Offset of parms;AN000; | ||
| 498 | .IF <ES:[DI] EQ 5140H> ; If LCD display type, ;AN000; | ||
| 499 | .THEN ; set LCD bit in Shared Data area ;AN000; | ||
| 500 | MOV DS:[BP].HARDWARE_CONFIG,PC_CONVERTIBLE ;AN000; | ||
| 501 | .ELSE ; else, we have an old adapter. ;AN000; | ||
| 502 | MOV DS:[BP].HARDWARE_CONFIG,OLD_ADAPTER ; (either MONO or CGA);AN000; | ||
| 503 | .ENDIF ; Display type is LCD ;AN000; | ||
| 504 | .ENDIF ; EGA BIOS is present ;AN000; | ||
| 505 | .ENDIF ; PS/2 BIOS is present ;AN000; | ||
| 506 | RET ;AN000; | ||
| 507 | DET_HW_CONFIG ENDP ;AN000; | ||
| 508 | PAGE ;AN000; | ||
| 509 | ;======================================================================= ;AN000; | ||
| 510 | ; ;AN000; | ||
| 511 | ; DET_MODE_STATE : Determine the current video mode and the active page. ;AN000; | ||
| 512 | ; ;AN000; | ||
| 513 | ;----------------------------------------------------------------------- ;AN000; | ||
| 514 | ; ;AN000; | ||
| 515 | ; INPUT: HARDWARE_CONFIG = Type of video hardware attached ;AN000; | ||
| 516 | ; ;AN000; | ||
| 517 | ; OUTPUT: CUR_MODE = Video mode number (0-13H) ;AN000; | ||
| 518 | ; CUR_PAGE = Video page number (0-8) ;AN000; | ||
| 519 | ; NB_CHAR_COLUMNS = Number of columns if in a text mode. ;AN000; | ||
| 520 | ; ;AN000; | ||
| 521 | ; ;AN000; | ||
| 522 | ; CALLED BY: PRT_SCR ;AN000; | ||
| 523 | ; ;AN000; | ||
| 524 | ; ;AN000; | ||
| 525 | ;-------------------------------------------------------------------------------;AN000; | ||
| 526 | ; ;AN000; | ||
| 527 | ; DESCRIPTION: Use the BIOS interface to ;AN000; | ||
| 528 | ; obtain the current mode and active page. ;AN000; | ||
| 529 | ; ;AN000; | ||
| 530 | ; LOGIC: ;AN000; | ||
| 531 | ; ;AN000; | ||
| 532 | ; Call BIOS INTERRUPT 10H: "Return current video state" (AH = 0fh) ;AN000; | ||
| 533 | ; ;AN000; | ||
| 534 | DET_MODE_STATE PROC NEAR ;AN000; | ||
| 535 | PUSH AX ;AN000; | ||
| 536 | PUSH BX ;AN000; | ||
| 537 | MOV AH,GET_STATE_CALL ;AN000; | ||
| 538 | INT 10H ; CALL BIOS ;AN000; | ||
| 539 | MOV CUR_MODE,AL ;AN000; | ||
| 540 | MOV NB_CHAR_COLUMNS,AH ;AN000; | ||
| 541 | MOV CUR_PAGE,BH ;AN000; | ||
| 542 | ;AN000; | ||
| 543 | POP BX ;AN000; | ||
| 544 | POP AX ;AN000; | ||
| 545 | RET ;AN000; | ||
| 546 | DET_MODE_STATE ENDP ;AN000; | ||
| 547 | ;AN000; | ||
| 548 | PAGE ;AN000; | ||
| 549 | ;======================================================================= ;AN000; | ||
| 550 | ; ;AN000; | ||
| 551 | ; GET_MODE_ATTR: Obtain attributes of current video mode. ;AN000; | ||
| 552 | ; ;AN000; | ||
| 553 | ;----------------------------------------------------------------------- ;AN000; | ||
| 554 | ; ;AN000; | ||
| 555 | ; INPUT: CUR_MODE = Current video mode (1 BYTE) ;AN000; | ||
| 556 | ; ;AN000; | ||
| 557 | ; OUTPUT: MODE_TYPE = Video mode type (TXT or APA) ;AN000; | ||
| 558 | ; NB_COLORS = Maximum number of colors (0-256) (0=B&W) ;AN000; | ||
| 559 | ; ERROR_CODE = Error code if error occurred. ;AN000; | ||
| 560 | ; SCREEN_HEIGHT= Number of rows (in pixels if APA or char if TEXT);AN000; | ||
| 561 | ; SCREEN_WIDTH = Number of columns (in pixels/char) ;AN000; | ||
| 562 | ; ;AN000; | ||
| 563 | ; CALLED BY: PRT_SCR ;AN000; | ||
| 564 | ; ;AN000; | ||
| 565 | ; ;AN000; | ||
| 566 | ;----------------------------------------------------------------------- ;AN000; | ||
| 567 | ; ;AN000; | ||
| 568 | ; DESCRIPTION: Scan the 2 local video mode attribute tables until the ;AN000; | ||
| 569 | ; current mode is located. Return the attributes. ;AN000; | ||
| 570 | ; For APA modes SCREEN_HEIGHT and SCREEN_WIDTH are in pixels, ;AN000; | ||
| 571 | ; for TEXT modes they are in characters. ;AN000; | ||
| 572 | ; ;AN000; | ||
| 573 | ; ;AN000; | ||
| 574 | ; LOGIC: ;AN000; | ||
| 575 | ; ;AN000; | ||
| 576 | ; Scan the APA_ATTR_TABLE ;AN000; | ||
| 577 | ; IF FOUND ;AN000; | ||
| 578 | ; MODE_TYPE := APA ;AN000; | ||
| 579 | ; NB_COLORS := mode.MAX_COLORS ;AN000; | ||
| 580 | ; SCREEN_HEIGHT := mode.NB_L ;AN000; | ||
| 581 | ; SCREEN_WIDTH := mode.NB_C ;AN000; | ||
| 582 | ; ELSE ;AN000; | ||
| 583 | ; Scan the TXT_ATTR_TABLE ;AN000; | ||
| 584 | ; When FOUND ;AN000; | ||
| 585 | ; MODE_TYPE := TXT ;AN000; | ||
| 586 | ; NB_COLORS := mode.NUM_COLORS ;AN000; | ||
| 587 | ; SCREEN_WIDTH := NB_CHAR_COLUMNS ;AN000; | ||
| 588 | ; SCREEN_HEIGHT := Byte in ROM BIOS at 40:84 ;AN000; | ||
| 589 | ; ;AN000; | ||
| 590 | ;----------------------------------------------------------------------- ;AN000; | ||
| 591 | GET_MODE_ATTR PROC NEAR ;AN000; | ||
| 592 | JMP SHORT GET_MODE_ATTR_BEGIN ;AN000; | ||
| 593 | ;----------------------------------------------------------------------- ;AN000; | ||
| 594 | ; ;AN000; | ||
| 595 | ; LOCAL DATA ;AN000; | ||
| 596 | ; ;AN000; | ||
| 597 | ;----------------------------------------------------------------------- ;AN000; | ||
| 598 | ;AN000; | ||
| 599 | APA_ATTR STRUC ; ATTRIBUTES FOR APA MODES: ;AN000; | ||
| 600 | APA_MODE DB ? ; Mode number ;AN000; | ||
| 601 | NB_C DW ? ; Number of columns ;AN000; | ||
| 602 | NB_L DW ? ; Number of lines ;AN000; | ||
| 603 | MAX_COLORS DW ? ; Maximum number of colors available (0=B&W) ;AN000; | ||
| 604 | APA_ATTR ENDS ;AN000; | ||
| 605 | ;AN000; | ||
| 606 | TXT_ATTR STRUC ; ATTRIBUTES FOR TXT MODES: ;AN000; | ||
| 607 | TXT_MODE DB ? ; Mode number ;AN000; | ||
| 608 | NUM_COLORS DB ? ; Number of colors ;AN000; | ||
| 609 | TXT_ATTR ENDS ;AN000; | ||
| 610 | ;AN000; | ||
| 611 | ;----------------------------------------------------------------------- ;AN000; | ||
| 612 | ; ;AN000; | ||
| 613 | ; APA MODE ATTRIBUTES: ;AN000; | ||
| 614 | ; ;AN000; | ||
| 615 | ;----------------------------------------------------------------------- ;AN000; | ||
| 616 | NB_APA_MODES DW 10 ;AN000; | ||
| 617 | APA_ATTR_TABLE LABEL WORD ;AN000; | ||
| 618 | MODE04 APA_ATTR < 4,320,200, 4> ;AN000; | ||
| 619 | MODE05 APA_ATTR < 5,320,200, 4> ;AN000; | ||
| 620 | MODE06 APA_ATTR < 6,640,200, 2> ;AN000; | ||
| 621 | MODE0D APA_ATTR <0DH,320,200, 16> ;AN000; | ||
| 622 | MODE0E APA_ATTR <0EH,640,200, 16> ;AN000; | ||
| 623 | MODE0F APA_ATTR <0FH,640,350, 4> ;AN000; | ||
| 624 | MODE10H APA_ATTR <10H,640,350, 16> ;AN000; | ||
| 625 | MODE11H APA_ATTR <11H,640,480, 2> ;AN000; | ||
| 626 | MODE12H APA_ATTR <12H,640,480, 16> ;AN000; | ||
| 627 | MODE13H APA_ATTR <13H,320,200,256> ;AN000; | ||
| 628 | ;AN000; | ||
| 629 | ;----------------------------------------------------------------------- ;AN000; | ||
| 630 | ; ;AN000; | ||
| 631 | ; TXT MODE ATTRIBUTES: ;AN000; | ||
| 632 | ; ;AN000; | ||
| 633 | ;----------------------------------------------------------------------- ;AN000; | ||
| 634 | NB_TXT_MODES DW 5 ;AN000; | ||
| 635 | TXT_ATTR_TABLE LABEL WORD ;AN000; | ||
| 636 | MODE00 TXT_ATTR < 0, 16> ;AN000; | ||
| 637 | MODE01 TXT_ATTR < 1, 16> ;AN000; | ||
| 638 | MODE02 TXT_ATTR < 2, 16> ;AN000; | ||
| 639 | MODE03 TXT_ATTR < 3, 16> ;AN000; | ||
| 640 | MODE07 TXT_ATTR < 7, 0> ;AN000; | ||
| 641 | ;AN000; | ||
| 642 | ;----------------------------------------------------------------------- ;AN000; | ||
| 643 | ; ;AN000; | ||
| 644 | ; BEGIN OF GET_MODE_ATTR ;AN000; | ||
| 645 | ; ;AN000; | ||
| 646 | ;----------------------------------------------------------------------- ;AN000; | ||
| 647 | GET_MODE_ATTR_BEGIN: ;AN000; | ||
| 648 | PUSH AX ;AN000; | ||
| 649 | PUSH BX ;AN000; | ||
| 650 | PUSH CX ;AN000; | ||
| 651 | PUSH DX ;AN000; | ||
| 652 | MOV DL,CUR_MODE ; DL = CURRENT MODE ;AN000; | ||
| 653 | ; ;AN000; | ||
| 654 | ; Scan the APA_ATTR_TABLE ;AN000; | ||
| 655 | ; ;AN000; | ||
| 656 | MOV CX,NB_APA_MODES ; CS <-- Number of APA modes ;AN000; | ||
| 657 | MOV BX,OFFSET APA_ATTR_TABLE; BX <-- Offset of APA mode table ;AN000; | ||
| 658 | SCAN_APA: ;AN000; | ||
| 659 | CMP DL,[BX].APA_MODE ; IF mode found ;AN000; | ||
| 660 | JE SHORT ITS_APA ; THEN get its attributes ;AN000; | ||
| 661 | ADD BX,SIZE APA_ATTR ;AN000; | ||
| 662 | LOOP SCAN_APA ; ELSE keep scanning ;AN000; | ||
| 663 | JMP SHORT SCAN_TXT_INIT ; NOT in this table: scan txt modes ;AN000; | ||
| 664 | ITS_APA: ;AN000; | ||
| 665 | MOV MODE_TYPE,APA ; MODE = APA ;AN000; | ||
| 666 | MOV AX,[BX].MAX_COLORS ;AN000; | ||
| 667 | MOV NB_COLORS,AX ; Get number of colors ;AN000; | ||
| 668 | MOV AX,[BX].NB_L ;AN000; | ||
| 669 | MOV SCREEN_HEIGHT,AX ; Get number of lines ;AN000; | ||
| 670 | MOV AX,[BX].NB_C ;AN000; | ||
| 671 | MOV SCREEN_WIDTH,AX ; Get number of columns ;AN000; | ||
| 672 | JMP SHORT GET_MODE_ATTR_END ;AN000; | ||
| 673 | ;AN000; | ||
| 674 | ; ;AN000; | ||
| 675 | ; Scan the TXT_ATTR_TABLE ;AN000; | ||
| 676 | ; ;AN000; | ||
| 677 | SCAN_TXT_INIT: ;AN000; | ||
| 678 | MOV CX,NB_TXT_MODES ; CX <-- Number of TXT modes ;AN000; | ||
| 679 | MOV BX,OFFSET TXT_ATTR_TABLE; BX <-- Offset of TXT mode table ;AN000; | ||
| 680 | SCAN_TXT: ;AN000; | ||
| 681 | CMP DL,[BX].TXT_MODE ; IF mode found ;AN000; | ||
| 682 | JE SHORT ITS_TXT ; THEN get its attributes ;AN000; | ||
| 683 | ADD BX,SIZE TXT_ATTR ;AN000; | ||
| 684 | LOOP SCAN_TXT ; ELSE keep scanning ;AN000; | ||
| 685 | ITS_TXT: ;AN000; | ||
| 686 | MOV MODE_TYPE,TXT ; MODE = TXT ;AN000; | ||
| 687 | MOV AL,[BX].NUM_COLORS ;AN000; | ||
| 688 | CBW ;AN000; | ||
| 689 | MOV NB_COLORS,AX ; Get number of colors ;AN000; | ||
| 690 | MOV AL,NB_CHAR_COLUMNS ; Get number of columns ;AN000; | ||
| 691 | CBW ;AN000; | ||
| 692 | MOV SCREEN_WIDTH,AX ;AN000; | ||
| 693 | .IF <DS:[BP].HARDWARE_CONFIG EQ OLD_ADAPTER>; If an old adapter is there;AN000; | ||
| 694 | .THEN ; The number of lines is 25 ;AN000; | ||
| 695 | MOV SCREEN_HEIGHT,25 ;AN000; | ||
| 696 | .ELSE ;AN000; | ||
| 697 | MOV AX,BIOS_SEG ; Get number of rows ;AN000; | ||
| 698 | MOV ES,AX ; from BIOS Data Area ;AN000; | ||
| 699 | MOV BX,NB_ROWS_OFFSET ; at 0040:0084 ;AN000; | ||
| 700 | MOV AL,ES:[BX] ;AN000; | ||
| 701 | CBW ;AN000; | ||
| 702 | INC AX ;AN000; | ||
| 703 | MOV SCREEN_HEIGHT,AX ;AN000; | ||
| 704 | .ENDIF ;AN000; | ||
| 705 | JMP SHORT GET_MODE_ATTR_END ;AN000; | ||
| 706 | ;AN000; | ||
| 707 | ; ;AN000; | ||
| 708 | ; The current mode was not found in any of the tables ;AN000; | ||
| 709 | ; ;AN000; | ||
| 710 | MOV ERROR_CODE,MODE_NOT_SUPPORTED ;AN000; | ||
| 711 | ;AN000; | ||
| 712 | GET_MODE_ATTR_END: ;AN000; | ||
| 713 | POP AX ;AN000; | ||
| 714 | POP BX ;AN000; | ||
| 715 | POP CX ;AN000; | ||
| 716 | POP DX ;AN000; | ||
| 717 | RET ;AN000; | ||
| 718 | GET_MODE_ATTR ENDP ;AN000; | ||
| 719 | PAGE ;AN000; | ||
| 720 | ;======================================================================= ;AN000; | ||
| 721 | ; ;AN000; | ||
| 722 | ; SET_UP_XLT_TABLE : SET UP A COLOR MAPPING FOR EACH COLOR AVAILABLE ;AN000; | ||
| 723 | ; WITH THE CURRENT MODE ;AN000; | ||
| 724 | ; ;AN000; | ||
| 725 | ;----------------------------------------------------------------------- ;AN000; | ||
| 726 | ; ;AN000; | ||
| 727 | ; INPUT: CUR_MODE = Current video mode. ;AN000; | ||
| 728 | ; HARDWARE_CONFIG = Type of display adapter. ;AN000; | ||
| 729 | ; PRINTER_TYPE = Type of printer attached (Color or B&W) ;AN000; | ||
| 730 | ; XLT_TAB = Color translation table. ;AN000; | ||
| 731 | ; CUR_PAGE = Active page number ;AN000; | ||
| 732 | ; BP = Offset of the shared data area ;AN000; | ||
| 733 | ; ;AN000; | ||
| 734 | ; ;AN000; | ||
| 735 | ; OUTPUT: XLT_TAB IS UPDATED ;AN000; | ||
| 736 | ; ;AN000; | ||
| 737 | ; CALLED BY: PRT_SCR ;AN000; | ||
| 738 | ; ;AN000; | ||
| 739 | ;----------------------------------------------------------------------- ;AN000; | ||
| 740 | ; ;AN000; | ||
| 741 | ; DESCRIPTION: The table is updated to hold a mapping for each color ;AN000; | ||
| 742 | ; available in the current video mode either TEXT or APA. ;AN000; | ||
| 743 | ; ;AN000; | ||
| 744 | ; For example, if the current mode supports 16 colors then the first ;AN000; | ||
| 745 | ; sixteen bytes of the table will hold the corresponding Color printer ;AN000; | ||
| 746 | ; or Black and White printer mappings for these colors. ;AN000; | ||
| 747 | ; ;AN000; | ||
| 748 | ; ;AN000; | ||
| 749 | ; LOGIC: ;AN000; | ||
| 750 | ; ;AN000; | ||
| 751 | ; IF HARDWARE_CONFIG = CGA OR HARDWARE_CONFIG = PC_CONVERTIBLE ;AN000; | ||
| 752 | ; THEN ;AN000; | ||
| 753 | ; CALL SET_CGA_XLT_TAB ;AN000; | ||
| 754 | ; ;AN000; | ||
| 755 | ; ELSE IF HARDWARE_CONFIG = EGA ;AN000; | ||
| 756 | ; THEN ;AN000; | ||
| 757 | ; CALL SET_EGA_XLT_TAB ;AN000; | ||
| 758 | ; ;AN000; | ||
| 759 | ; ELSE IF CUR_MODE = 0FH ;AN000; | ||
| 760 | ; THEN ;AN000; | ||
| 761 | ; CALL SET_MODE_F_XLT_TAB ;AN000; | ||
| 762 | ; ;AN000; | ||
| 763 | ; ELSE IF CUR_MODE = 19 ;AN000; | ||
| 764 | ; THEN ;AN000; | ||
| 765 | ; CALL SET_MODE_13H_XLT_TAB ;AN000; | ||
| 766 | ; ;AN000; | ||
| 767 | ; ELSE ;AN000; | ||
| 768 | ; CALL SET_ROUNDUP_XLT_TAB ;AN000; | ||
| 769 | ; ;AN000; | ||
| 770 | ; CALL SET_BACKG_IN_XLT_TAB ; Update the background in the translation table ;AN000; | ||
| 771 | ; ;AN000; | ||
| 772 | SET_UP_XLT_TAB PROC NEAR ;AN000; | ||
| 773 | ;-------------------------------------------------------------------------------;AN000; | ||
| 774 | ; For old display modes: set up translation table as for a Color Graphics Adapt.;AN000; | ||
| 775 | ; Either 4 or 16 colors are set up depending if the mode is an APA or text mode.;AN000; | ||
| 776 | ; ;AN000; | ||
| 777 | ; NOTE: SET_UP_XLT_TAB cannot be invoked if the display adater is a Monochrome ;AN000; | ||
| 778 | ; display adater. (When a Mono. adapter is attached, a jump is made to ;AN000; | ||
| 779 | ; the ROM BIOS for printing the screen, and no translation table is set). ;AN000; | ||
| 780 | ;-------------------------------------------------------------------------------;AN000; | ||
| 781 | .IF <BIT DS:[BP].HARDWARE_CONFIG NZ OLD_ADAPTER> OR ; IF it is a CGA ;AN000; | ||
| 782 | .IF <BIT DS:[BP].HARDWARE_CONFIG NZ PC_CONVERTIBLE> ; or a PC convertible ;AN000; | ||
| 783 | .THEN ; THEN set up CGA colors ;AN000; | ||
| 784 | CALL SET_CGA_XLT_TAB ; ;AN000; | ||
| 785 | .ELSEIF <BIT DS:[BP].HARDWARE_CONFIG NZ EGA> ; ELSEIF it is an EGA ;AN000; | ||
| 786 | CALL SET_EGA_XLT_TAB ; set up EGA colors. ;AN000; | ||
| 787 | .ELSEIF <CUR_MODE EQ 0FH> ; ELSEIF we are in mode 15 ;AN000; | ||
| 788 | CALL SET_MODE_F_XLT_TAB ; set up its 4 shades ;AN000; | ||
| 789 | ;-------------------------------------------------------------------------------;AN000; | ||
| 790 | ; A PS/2 system is attached: (we either have a PALACE [Model 30] or a ROUNDUP) ;AN000; | ||
| 791 | ;-------------------------------------------------------------------------------;AN000; | ||
| 792 | .ELSEIF <CUR_MODE EQ 13H> ; ELSEIF current mode is 13h;AN000; | ||
| 793 | CALL SET_MODE_13H_XLT_TAB ; set up 256 colors ;AN000; | ||
| 794 | .ELSEIF <BIT DS:[BP].HARDWARE_CONFIG NZ PALACE> ; ELSEIF PS/2 Model 30(MCGA);AN000; | ||
| 795 | CALL SET_CGA_XLT_TAB ; handle it like a CGA ;AN000; | ||
| 796 | .ELSE ; ELSE we have a ROUNDUP ;AN000; | ||
| 797 | ;-------------------------------------------------------------------------------;AN000; | ||
| 798 | ; A PS/2 model 50, 60 or 80 or an ADA 'B' card is attached (in 16 color mode): ;AN000; | ||
| 799 | ;-------------------------------------------------------------------------------;AN000; | ||
| 800 | CALL SET_ROUNDUP_XLT_TAB ; set up 16 colors ;AN000; | ||
| 801 | .ENDIF ;AN000; | ||
| 802 | ;-------------------------------------------------------------------------------;AN000; | ||
| 803 | ; Finish setting up the translation table: ;AN000; | ||
| 804 | ;-------------------------------------------------------------------------------;AN000; | ||
| 805 | ;AN000; | ||
| 806 | CALL SET_BACKG_IN_XLT_TAB ; Update the background in the translation table ;AN000; | ||
| 807 | ; according to the command line switch setting ;AN000; | ||
| 808 | ; (i.e.,/R /B) ;AN000; | ||
| 809 | RET ;AN000; | ||
| 810 | SET_UP_XLT_TAB ENDP ;AN000; | ||
| 811 | PAGE ;AN000; | ||
| 812 | ;===============================================================================;AN000; | ||
| 813 | ; ;AN000; | ||
| 814 | ; SET_BACKG_IN_XLT_TAB : ADJUST THE MAPPING FOR THE BACKGROUND COLOR IN THE ;AN000; | ||
| 815 | ; XLT_TAB ACCORDING TO PRINTER TYPE AND /R /B. ;AN000; | ||
| 816 | ; ;AN000; | ||
| 817 | ; ;AN000; | ||
| 818 | ;-------------------------------------------------------------------------------;AN000; | ||
| 819 | ; ;AN000; | ||
| 820 | ; INPUT: BP = Offset of shared data area (SWITCHES) ;AN000; | ||
| 821 | ; XLT_TAB = The color translation table. ;AN000; | ||
| 822 | ; ;AN000; | ||
| 823 | ; OUTPUT: XLT_TAB IS UPDATED ;AN000; | ||
| 824 | ; ;AN000; | ||
| 825 | ;-------------------------------------------------------------------------------;AN000; | ||
| 826 | ; ;AN000; | ||
| 827 | ; DESCRIPTION: If there is a black and white printer and /R is NOT specified ;AN000; | ||
| 828 | ; then the background color should not be printed and it is replaced in the ;AN000; | ||
| 829 | ; translation table by the Intensity for white (will print nothing). ;AN000; | ||
| 830 | ; ;AN000; | ||
| 831 | ; If a color printer is attached and /B is not specified then the background ;AN000; | ||
| 832 | ; color is replaced by the Print Band mask for white. ;AN000; | ||
| 833 | ; ;AN000; | ||
| 834 | ; LOGIC: ;AN000; | ||
| 835 | ; IF (a black and white printer is attached) AND (/R is OFF) ;AN000; | ||
| 836 | ; THEN ;AN000; | ||
| 837 | ; MOV XLT_TAB, WHITE_INT ; Store white in translation table ;AN000; | ||
| 838 | ; ELSE (a color printer is attached) ;AN000; | ||
| 839 | ; IF (/B is ON) ;AN000; | ||
| 840 | ; THEN ;AN000; | ||
| 841 | ; RGB.R := MAX_INT ;AN000; | ||
| 842 | ; RGB.G := MAX_INT ;AN000; | ||
| 843 | ; RGB.B := MAX_INT ;AN000; | ||
| 844 | ; CALL RGB2BAND ; Convert RGB for white to a Band Mask ;AN000; | ||
| 845 | ; MOV XLT_TAB,AL ; Store the band mask in the xlt table ;AN000; | ||
| 846 | ; ;AN000; | ||
| 847 | ; ;AN000; | ||
| 848 | ;-------------------------------------------------------------------------------;AN000; | ||
| 849 | SET_BACKG_IN_XLT_TAB PROC NEAR ;AN000; | ||
| 850 | ;-------------------------------------------------------------------------------;AN000; | ||
| 851 | ; ;AN000; | ||
| 852 | ; Test if a black and white printer is attached. ;AN000; | ||
| 853 | ; ;AN000; | ||
| 854 | ;-------------------------------------------------------------------------------;AN000; | ||
| 855 | .IF <BIT DS:[BP].PRINTER_TYPE NZ BLACK_WHITE> AND ; IF black and white ;AN000; | ||
| 856 | .IF <BIT DS:[BP].SWITCHES Z REVERSE_SW> ; printer and not /R ;AN000; | ||
| 857 | .THEN ; then, map background ;AN000; | ||
| 858 | MOV XLT_TAB,WHITE_INT ; to white. ;AN000; | ||
| 859 | ;-------------------------------------------------------------------------------;AN000; | ||
| 860 | ; ;AN000; | ||
| 861 | ; A Color printer is attached: ;AN000; | ||
| 862 | ; ;AN000; | ||
| 863 | ;-------------------------------------------------------------------------------;AN000; | ||
| 864 | .ELSEIF <BIT DS:[BP].PRINTER_TYPE NZ COLOR> AND ; else, if color printer ;AN000; | ||
| 865 | .IF <BIT DS:[BP].SWITCHES Z BACKGROUND_SW> ; and /B if OFF ;AN000; | ||
| 866 | .THEN ; ;AN000; | ||
| 867 | ; Store a null band mask ;AN000; | ||
| 868 | MOV XLT_TAB,0 ; the translation table. ;AN000; | ||
| 869 | .ENDIF ;AN000; | ||
| 870 | RET ;AN000; | ||
| 871 | SET_BACKG_IN_XLT_TAB ENDP ;AN000; | ||
| 872 | PAGE ;AN000; | ||
| 873 | ;======================================================================= ;AN000; | ||
| 874 | ; ;AN000; | ||
| 875 | ; SET_EGA_XLT_TAB : SET UP COLOR TRANSLATION TABLE FOR ENHANCED GRAPHIC ;AN000; | ||
| 876 | ; ADAPTER ;AN000; | ||
| 877 | ; ;AN000; | ||
| 878 | ;----------------------------------------------------------------------- ;AN000; | ||
| 879 | ; ;AN000; | ||
| 880 | ; INPUT: XLT_TAB = Color translation table. ;AN000; | ||
| 881 | ; PRINTER_TYPE = Type of printer attached (Color or B&W) ;AN000; | ||
| 882 | ; SWITCHES = GRAPHICS command line parameters. ;AN000; | ||
| 883 | ; ;AN000; | ||
| 884 | ; OUTPUT: XLT_TAB IS UPDATED ;AN000; | ||
| 885 | ; ;AN000; | ||
| 886 | ; CALLED BY: SET_UP_XLT_TABLE ;AN000; | ||
| 887 | ; ;AN000; | ||
| 888 | ;----------------------------------------------------------------------- ;AN000; | ||
| 889 | ; ;AN000; | ||
| 890 | ; NOTES: With the EGA, "VIDEO BIOS READ DOT call" returns an index into ;AN000; | ||
| 891 | ; the 16 EGA palette registers. ;AN000; | ||
| 892 | ; ;AN000; | ||
| 893 | ; These registers contain the actual colors stored as rgbRGB components ;AN000; | ||
| 894 | ; (see EGA_COL2RGB for details) for mode hex 10. Under mode hex E these ;AN000; | ||
| 895 | ; registers contain the actual colors as I0RGB components (see CGA_COL2RGB ;AN000; | ||
| 896 | ; for details). ;AN000; | ||
| 897 | ; ;AN000; | ||
| 898 | ; These registers can be Revised by the user but, are 'WRITE ONLY'. ;AN000; | ||
| 899 | ; However, it is possible to define a SAVE AREA where BIOS will maintain ;AN000; | ||
| 900 | ; a copy of the palette registers. ;AN000; | ||
| 901 | ; ;AN000; | ||
| 902 | ; This area is called the "DYNAMIC SAVE AREA" and is defined via the ;AN000; | ||
| 903 | ; BIOS EGA SAVE_PTR AREA. Whenever the palette registers are changed by ;AN000; | ||
| 904 | ; the user, BIOS updates the EGA_SAVE_AREA. ;AN000; | ||
| 905 | ; ;AN000; | ||
| 906 | ; The 16 palette registers are the first 16 bytes of the DYNAMIC SAVE AREA. ;AN000; | ||
| 907 | ; ;AN000; | ||
| 908 | ; This program takes advantage of this feature and consults the EGA DYNAMIC ;AN000; | ||
| 909 | ; SAVE AREA in order to obtain the colors used in the active screen. ;AN000; | ||
| 910 | ; ;AN000; | ||
| 911 | ; ;AN000; | ||
| 912 | ; DESCRIPTION: Obtain each color available with an EGA by reading its ;AN000; | ||
| 913 | ; palette register in the EGA_SAVE_AREA: ;AN000; | ||
| 914 | ; ;AN000; | ||
| 915 | ; Calculate the mapping for this color, either a BAND_MASK or a ;AN000; | ||
| 916 | ; GREY INTENSITY and store it in the color translation table. ;AN000; | ||
| 917 | ; ;AN000; | ||
| 918 | ; ;AN000; | ||
| 919 | ; LOGIC: ;AN000; | ||
| 920 | ; ;AN000; | ||
| 921 | ; Obtain the DYNAMIC EGA SAVE AREA offset from the BIOS SAVE_PTR_AREA. ;AN000; | ||
| 922 | ; ;AN000; | ||
| 923 | ; If current mode is either 4,5 or 6 ;AN000; | ||
| 924 | ; Then, ;AN000; | ||
| 925 | ; CALL SET_CGA_XLT_TAB ;AN000; | ||
| 926 | ; Get the background color by reading palette register number 0 ;AN000; | ||
| 927 | ; Else, ;AN000; | ||
| 928 | ; For each register number (0 to 15): ;AN000; | ||
| 929 | ; Get the register contents (rgbRGB values) from the EGA SAVE AREA ;AN000; | ||
| 930 | ; CALL EGA_COL2RGB ; Obtain the Red, Green, Blue values ;AN000; | ||
| 931 | ; CALL RGB2XLT_TAB ; Obtain a Band Mask or a Grey Intensity ;AN000; | ||
| 932 | ; ; and store the result in the XLT_TAB ;AN000; | ||
| 933 | ; ;AN000; | ||
| 934 | SET_EGA_XLT_TAB PROC NEAR ;AN000; | ||
| 935 | PUSH AX ; Save the registers used ;AN000; | ||
| 936 | PUSH BX ;AN000; | ||
| 937 | PUSH CX ;AN000; | ||
| 938 | PUSH DX ;AN000; | ||
| 939 | PUSH DI ;AN000; | ||
| 940 | ;AN000; | ||
| 941 | ;-------------------------------------------------------------------------------;AN000; | ||
| 942 | ; ;AN000; | ||
| 943 | ; Obtain the pointer to the DYNAMIC SAVE AREA from the SAVE AREA POINTER TABLE: ;AN000; | ||
| 944 | ; ;AN000; | ||
| 945 | ;-------------------------------------------------------------------------------;AN000; | ||
| 946 | EGA_SAVE_PTR EQU 4A8H ; EGA BIOS pointer to table of ;AN000; | ||
| 947 | ; pointer to save areas. ;AN000; | ||
| 948 | XOR AX,AX ; ES segment := paragraph 0 ;AN000; | ||
| 949 | MOV ES,AX ;AN000; | ||
| 950 | ;AN000; | ||
| 951 | LES BX,ES:DWORD PTR EGA_SAVE_PTR ; ES:BX := Pointer to ptr table ;AN000; | ||
| 952 | LES BX,ES:[BX]+4 ; ES:BX := Pointer to dynamic save area;AN000; | ||
| 953 | ; (NOTE: It is the second pointer in ;AN000; | ||
| 954 | ; the table) ;AN000; | ||
| 955 | ;AN000; | ||
| 956 | ;-------------------------------------------------------------------------------;AN000; | ||
| 957 | ; ;AN000; | ||
| 958 | ; Set up one entry in the translation table for each color available. ;AN000; | ||
| 959 | ; ;AN000; | ||
| 960 | ;-------------------------------------------------------------------------------;AN000; | ||
| 961 | .IF <CUR_MODE EQ 4> OR ; If the current mode is an old CGA ;AN000; | ||
| 962 | .IF <CUR_MODE EQ 5> OR ; GRAPHICS mode: ;AN000; | ||
| 963 | .IF <CUR_MODE EQ 6> ;AN000; | ||
| 964 | .THEN ;AN000; | ||
| 965 | ;-------------------------------------------------------------------------------;AN000; | ||
| 966 | ; Current mode is either mode 4, 5 or 6; ;AN000; | ||
| 967 | ; Store each color of the old CGA All Points Addressable mode: ;AN000; | ||
| 968 | ;-------------------------------------------------------------------------------;AN000; | ||
| 969 | CALL SET_CGA_XLT_TAB ; Set up colors in the translation ;AN000; | ||
| 970 | ; table, NOTE: The background color ;AN000; | ||
| 971 | ; will not be set properly since the ;AN000; | ||
| 972 | ; EGA BIOS does not update memory ;AN000; | ||
| 973 | ; location 40:66 with the value ;AN000; | ||
| 974 | ; of the background color as CGA ;AN000; | ||
| 975 | ; does. ;AN000; | ||
| 976 | ;------Adjust the background color in the translation table: ;AN000; | ||
| 977 | ;------The background color is obtained from the EGA DYNAMIC SAVE AREA ;AN000; | ||
| 978 | ;------ES:BX = Address of the EGA DYNAMIC SAVE AREA ;AN000; | ||
| 979 | ;------NOTE : For CGA compatible modes EGA BIOS stores the color in the ;AN000; | ||
| 980 | ;------DYNAMIC SAVE AREA as a I0RGB value. ;AN000; | ||
| 981 | XOR DI,DI ; DI:=register number = index in XLT_TAB;AN000; | ||
| 982 | MOV AL,ES:[BX][DI] ; AL:=Palette register 0 = Back. color ;AN000; | ||
| 983 | MOV AH,AL ; Convert I0RGB to IRGB (CGA color) ;AN001; | ||
| 984 | AND AL,111B ; Isolate RGB bits ;AN001; | ||
| 985 | AND AH,10000B ; Isolate I bit ;AN001; | ||
| 986 | SHR AH,1 ; Move I bit from position 5 to 4 ;AN001; | ||
| 987 | OR AL,AH ; Get IRGB byte. ;AN001; | ||
| 988 | CALL CGA_COL2RGB ; Convert IRGB to R,G,B values ;AN001; | ||
| 989 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 990 | ;AN000; | ||
| 991 | .ELSE ; ELSE, we have an EGA graphics mode: ;AN000; | ||
| 992 | ;-------------------------------------------------------------------------------;AN000; | ||
| 993 | ; The current mode is a either a text mode or one of the EGA enhanced mode; ;AN000; | ||
| 994 | ; Store in the translation table each color available (these modes have 16 col.);AN000; | ||
| 995 | ;-------------------------------------------------------------------------------;AN000; | ||
| 996 | MOV CX,16 ; CX := Number of palette registers ;AN000; | ||
| 997 | ; to read ;AN000; | ||
| 998 | XOR DI,DI ; DI := Palette register number ;AN000; | ||
| 999 | ; and index in the translation table ;AN000; | ||
| 1000 | STORE_1_EGA_COLOR: ;AN000; | ||
| 1001 | MOV AL,ES:[BX][DI] ; AL := Palette register ;AN000; | ||
| 1002 | .IF <CUR_MODE EQ 14> OR ; If mode E (hex) OR mode D (hex) ;AN000; | ||
| 1003 | .IF <CUR_MODE EQ 13> ; the colors are ;AN000; | ||
| 1004 | .THEN ; stored as I0CGA colors ;AN000; | ||
| 1005 | MOV AH,AL ; Convert I0RGB to IRGB (CGA color) ;AN000; | ||
| 1006 | AND AL,111B ; Isolate RGB bits ;AN000; | ||
| 1007 | AND AH,10000B ; Isolate I bit ;AN000; | ||
| 1008 | SHR AH,1 ; Move I bit from position 5 to 4 ;AN000; | ||
| 1009 | OR AL,AH ; Get IRGB byte. ;AN000; | ||
| 1010 | CALL CGA_COL2RGB ; Convert IRGB to R,G,B values ;AN000; | ||
| 1011 | .ELSE ; Else, they are stored as (rgbRGB); ;AN000; | ||
| 1012 | CALL EGA_COL2RGB ; Convert register to R,G,B values ;AN000; | ||
| 1013 | .ENDIF ;AN000; | ||
| 1014 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1015 | INC DI ; Get next palette register number ;AN000; | ||
| 1016 | LOOP STORE_1_EGA_COLOR ;AN000; | ||
| 1017 | .ENDIF ; ENDIF 4 colors or 16 colors ;AN000; | ||
| 1018 | ;AN000; | ||
| 1019 | POP DI ; Restore the registers ;AN000; | ||
| 1020 | POP DX ;AN000; | ||
| 1021 | POP CX ;AN000; | ||
| 1022 | POP BX ;AN000; | ||
| 1023 | POP AX ;AN000; | ||
| 1024 | RET ;AN000; | ||
| 1025 | SET_EGA_XLT_TAB ENDP ;AN000; | ||
| 1026 | PAGE ;AN000; | ||
| 1027 | ;======================================================================= ;AN000; | ||
| 1028 | ; ;AN000; | ||
| 1029 | ; SET_CGA_XLT_TAB : SET UP COLOR TRANSLATION TABLE FOR COLOR GRAPHIC ;AN000; | ||
| 1030 | ; ADAPTER ;AN000; | ||
| 1031 | ; ;AN000; | ||
| 1032 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1033 | ; ;AN000; | ||
| 1034 | ; INPUT: XLT_TAB = Color translation table. ;AN000; | ||
| 1035 | ; PRINTER_TYPE = Type of printer attached (Color or B&W) ;AN000; | ||
| 1036 | ; SWITCHES = GRAPHICS command line parameters. ;AN000; | ||
| 1037 | ; ;AN000; | ||
| 1038 | ; OUTPUT: XLT_TAB IS UPDATED ;AN000; | ||
| 1039 | ; ;AN000; | ||
| 1040 | ; CALLED BY: SET_UP_XLT_TABLE ;AN000; | ||
| 1041 | ; ;AN000; | ||
| 1042 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1043 | ; ;AN000; | ||
| 1044 | ; NOTES: With the CGA, the "VIDEO BIOS READ DOT call" returns a number ;AN000; | ||
| 1045 | ; from 0 to 3. A dot of value 0 is of the background color. ;AN000; | ||
| 1046 | ; ;AN000; | ||
| 1047 | ; The actual value of the background color is stored in BIOS VIDEO ;AN000; | ||
| 1048 | ; DISPLAY DATA AREA as a PIIRGB value (see CGA_COL2RGB for details) and ;AN000; | ||
| 1049 | ; can be any of 16 colors. ;AN000; | ||
| 1050 | ; ;AN000; | ||
| 1051 | ; A dot of value 1,2, or 3 represents any of 2 specific colors depending ;AN000; | ||
| 1052 | ; on the current color palette. ;AN000; | ||
| 1053 | ; ;AN000; | ||
| 1054 | ; The palette number is obtained from the BIOS VIDEO DISPLAY DATA AREA ;AN000; | ||
| 1055 | ; (It is the "P" bit or bit number 5) ;AN000; | ||
| 1056 | ; ;AN000; | ||
| 1057 | ; The dot values 1,2,3 expressed in binary actually represent the RG ;AN000; | ||
| 1058 | ; (Red, Green) components of the color. ;AN000; | ||
| 1059 | ; ;AN000; | ||
| 1060 | ; The palette number represents the B (Blue) component therefore, when ;AN000; | ||
| 1061 | ; the palette number is appended to the color number we obtain the RGB ;AN000; | ||
| 1062 | ; components for that color. ;AN000; | ||
| 1063 | ; ;AN000; | ||
| 1064 | ; (E.G., COLOR = 010 ; COLOR # 2 ;AN000; | ||
| 1065 | ; PALETTE= 0 ; PALETTE # 0 ;AN000; | ||
| 1066 | ; ;AN000; | ||
| 1067 | ; IRGB = 0100 ; Intensity = 0 Ä¿ ;AN000; | ||
| 1068 | ; ; Red = 1 ÃÄÄÄ> color = Red ;AN000; | ||
| 1069 | ; ; Green = 0 ³ ;AN000; | ||
| 1070 | ; ; Blue = 0 ÄÙ ;AN000; | ||
| 1071 | ; ;AN000; | ||
| 1072 | ; ;AN000; | ||
| 1073 | ; DESCRIPTION: ;AN000; | ||
| 1074 | ; ;AN000; | ||
| 1075 | ; For each color available with a CGA: ;AN000; | ||
| 1076 | ; Calculate the color mapping, either a BAND_MASK or a GREY ;AN000; | ||
| 1077 | ; INTENSITY and store it in the color translation table. ;AN000; | ||
| 1078 | ; ;AN000; | ||
| 1079 | ; LOGIC: ;AN000; | ||
| 1080 | ; ;AN000; | ||
| 1081 | ; ; Obtain the background color from VIDEO BIOS DATA AREA ;AN000; | ||
| 1082 | ; ; and the paletter number ;AN000; | ||
| 1083 | ; ;AN000; | ||
| 1084 | ; ; Store the Background color: ;AN000; | ||
| 1085 | ; CALL CGA_COL2RGB ; Convert IRGB components to RGB values ;AN000; | ||
| 1086 | ; CALL RGB2XLT_TAB ; Convert RGB to an entry in the translation ;AN000; | ||
| 1087 | ; ; table ;AN000; | ||
| 1088 | ; ; Store all other colors: ;AN000; | ||
| 1089 | ; FOR IRG := 1 TO 3 ; Obtain the color number ;AN000; | ||
| 1090 | ; Append palette number (B) to IRG ;AN000; | ||
| 1091 | ; CALL CGA_COL2RGB ; Convert color to RGB values ;AN000; | ||
| 1092 | ; CALL RGB2XLT_TAB ; Convert RGB to an entry in the translation ;AN000; | ||
| 1093 | ; ; table ;AN000; | ||
| 1094 | ; ;AN000; | ||
| 1095 | SET_CGA_XLT_TAB PROC NEAR ;AN000; | ||
| 1096 | PUSH AX ;AN000; | ||
| 1097 | PUSH BX ;AN000; | ||
| 1098 | PUSH CX ;AN000; | ||
| 1099 | PUSH DI ;AN000; | ||
| 1100 | PUSH ES ;AN000; | ||
| 1101 | ;AN000; | ||
| 1102 | .IF <CUR_MODE EQ 4> OR ;AN000; | ||
| 1103 | .IF <CUR_MODE EQ 5> ;AN000; | ||
| 1104 | ;===============================================================================;AN000; | ||
| 1105 | ; ;AN000; | ||
| 1106 | ; THE CURRENT MODE IS MODE 4 OR 5 ;AN000; | ||
| 1107 | ; ;AN000; | ||
| 1108 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1109 | .THEN ;AN000; | ||
| 1110 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1111 | ; Read the CRT palette from the BIOS ROM to obtain the background color and ;AN000; | ||
| 1112 | ; the current palette number; store the palette number in BL ;AN000; | ||
| 1113 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1114 | ROM_BIOS_SEG EQU 40H ; CGA BIOS SEGMENT ;AN000; | ||
| 1115 | CRT_PALETTE_OFF EQU 66H ; BIOS Current palette setting ;AN000; | ||
| 1116 | P_BIT_MASK EQU 100000B ; bit 5 = Current palette ;AN000; | ||
| 1117 | I_BIT_MASK EQU 1000B ; bit 4 = Intensity bit ;AN000; | ||
| 1118 | R_BIT_MASK EQU 100B ; bit 2 = Red bit ;AN000; | ||
| 1119 | G_BIT_MASK EQU 10B ; bit 1 = Green bit ;AN000; | ||
| 1120 | B_BIT_MASK EQU 1B ; bit 0 = Blue bit ;AN000; | ||
| 1121 | ;AN000; | ||
| 1122 | MOV AX,ROM_BIOS_SEG ; ES := ROM BIOS SEGMENT ;AN000; | ||
| 1123 | PUSH AX ;AN000; | ||
| 1124 | POP ES ;AN000; | ||
| 1125 | ;AN000; | ||
| 1126 | MOV AL,ES:CRT_PALETTE_OFF; AL := CRT Palette (00PIIRGB) ;AN000; | ||
| 1127 | MOV BL,P_BIT_MASK ; LOW NIBBLE = BACKGROUND COLOR ;AN000; | ||
| 1128 | AND BL,AL ; BL := Palette number ;AN000; | ||
| 1129 | MOV CL,5 ;AN000; | ||
| 1130 | SHR BL,CL ;AN000; | ||
| 1131 | ;AN000; | ||
| 1132 | XOR DI,DI ; DI := Index in the XLT_TAB ;AN000; | ||
| 1133 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1134 | ; Store the background color, (obtained from low 4 bits of the byte at 40:66) ;AN000; | ||
| 1135 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1136 | CALL CGA_COL2RGB ; Convert color (in AL) to R, G, B values ;AN000; | ||
| 1137 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1138 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1139 | ; Store the 3 foreground colors for mode 4 and 5 ;AN000; | ||
| 1140 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1141 | MOV CX,3 ; For each color, but the background: ;AN000; | ||
| 1142 | STORE_1_CGA_MODE4_COLOR: ;AN000; | ||
| 1143 | INC DI ; Increment index in the translation table ;AN000; | ||
| 1144 | MOV AX,DI ; AL := IRG ;AN000; | ||
| 1145 | SHL AL,1 ;AN000; | ||
| 1146 | OR AL,BL ; AL := IRGB ;AN000; | ||
| 1147 | CALL CGA_COL2RGB ; Convert color (in AL) to R, G, B values ;AN000; | ||
| 1148 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1149 | LOOP STORE_1_CGA_MODE4_COLOR ;AN000; | ||
| 1150 | .ELSEIF <CUR_MODE EQ 6> ;AN000; | ||
| 1151 | ;===============================================================================;AN000; | ||
| 1152 | ; ;AN000; | ||
| 1153 | ; THE CURRENT MODE IS MODE 6 ;AN000; | ||
| 1154 | ; ;AN000; | ||
| 1155 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1156 | .THEN ;AN000; | ||
| 1157 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1158 | ; Store background color for mode 6 (mode 6 is a 2 colors, APA mode) ;AN000; | ||
| 1159 | ; Background is stored as BLACK ;AN000; | ||
| 1160 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1161 | XOR DI,DI ; DI := Index of color in translation table ;AN000; | ||
| 1162 | MOV RGB.R,BLACK_INT ; Foreground color is white ;AN000; | ||
| 1163 | MOV RGB.G,BLACK_INT ; RGB := RGB of white ;AN000; | ||
| 1164 | MOV RGB.B,BLACK_INT ; ;AN000; | ||
| 1165 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1166 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1167 | ; Store foreground color for mode 6 (mode 6 is a 2 colors, APA mode) ;AN000; | ||
| 1168 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1169 | INC DI ; DI := Index of color in translation table ;AN000; | ||
| 1170 | MOV RGB.R,WHITE_INT ; Background color is BLACK ;AN000; | ||
| 1171 | MOV RGB.G,WHITE_INT ; RGB := RGB of BLACK ;AN000; | ||
| 1172 | MOV RGB.B,WHITE_INT ; ;AN000; | ||
| 1173 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1174 | .ELSE ;AN000; | ||
| 1175 | ;===============================================================================;AN000; | ||
| 1176 | ; ;AN000; | ||
| 1177 | ; THE CURRENT MODE IS A TEXT MODE: ;AN000; | ||
| 1178 | ; ;AN000; | ||
| 1179 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1180 | XOR DI,DI ; DI := Index in the translation table ;AN000; | ||
| 1181 | MOV CX,16 ; For each of the 16 colors: ;AN000; | ||
| 1182 | STORE_1_CGA_TEXT_COLOR: ;AN000; | ||
| 1183 | MOV AX,DI ; AL := IRGB ;AN000; | ||
| 1184 | CALL CGA_COL2RGB ; Convert color (in AL) to R, G, B values ;AN000; | ||
| 1185 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1186 | INC DI ; Increment index in the translation table ;AN000; | ||
| 1187 | LOOP STORE_1_CGA_TEXT_COLOR ;AN000; | ||
| 1188 | .ENDIF ; ;AN000; | ||
| 1189 | ;AN000; | ||
| 1190 | POP ES ;AN000; | ||
| 1191 | POP DI ;AN000; | ||
| 1192 | POP CX ;AN000; | ||
| 1193 | POP BX ;AN000; | ||
| 1194 | POP AX ;AN000; | ||
| 1195 | ;AN000; | ||
| 1196 | RET ;AN000; | ||
| 1197 | SET_CGA_XLT_TAB ENDP ;AN000; | ||
| 1198 | PAGE ;AN000; | ||
| 1199 | ;===============================================================================;AN000; | ||
| 1200 | ; ;AN000; | ||
| 1201 | ; RGB2XLT_TAB: CONVERT R,G,B VALUES TO EITHER A BAND MASK OR AN INTENSITY ;AN000; | ||
| 1202 | ; STORE THE RESULT IN THE TRANSLATION TABLE ;AN000; | ||
| 1203 | ; ;AN000; | ||
| 1204 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1205 | ; ;AN000; | ||
| 1206 | ; INPUT: DI = Index in the translation table ;AN000; | ||
| 1207 | ; RGB = Red Green Blue values of the color to be stored. ;AN000; | ||
| 1208 | ; ;AN000; | ||
| 1209 | ; OUTPUT: XLT_TAB is updated ;AN000; | ||
| 1210 | ; ;AN000; | ||
| 1211 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1212 | ; DESCRIPTION: Convert the RGB values to either a Band mask or an intensity ;AN000; | ||
| 1213 | ; depending on the printer type; store the result in the translation table. ;AN000; | ||
| 1214 | ; ;AN000; | ||
| 1215 | ; LOGIC: ;AN000; | ||
| 1216 | ; IF PRINTER_TYPE = COLOR ;AN000; | ||
| 1217 | ; THEN ;AN000; | ||
| 1218 | ; CALL RGB2BAND ; Obtain a Band Mask ;AN000; | ||
| 1219 | ; ELSE ; Printer is Monochrome ;AN000; | ||
| 1220 | ; CALL RGB2INT ; Obtain a Grey Intensity ;AN000; | ||
| 1221 | ; Store the result in the XLT_TAB ;AN000; | ||
| 1222 | ; ;AN000; | ||
| 1223 | RGB2XLT_TAB PROC NEAR ;AN000; | ||
| 1224 | .IF <DS:[BP].PRINTER_TYPE EQ COLOR>; Color printer ? ;AN000; | ||
| 1225 | .THEN ;AN000; | ||
| 1226 | ;-------A color printer is attached: ;AN000; | ||
| 1227 | CALL RGB2BAND ; Yes, convert RGB to color band (in AL);AN000; | ||
| 1228 | .ELSE ;AN000; | ||
| 1229 | ;-------A black and white printer is attached: ;AN000; | ||
| 1230 | CALL RGB2INT ; No, RGB to an intensity in AL ;AN000; | ||
| 1231 | .ENDIF ;AN000; | ||
| 1232 | ;-------Store the result ;AN000; | ||
| 1233 | MOV XLT_TAB[DI],AL ;AN000; | ||
| 1234 | RET ;AN000; | ||
| 1235 | RGB2XLT_TAB ENDP ;AN000; | ||
| 1236 | PAGE ;AN000; | ||
| 1237 | ;===============================================================================;AN000; | ||
| 1238 | ; ;AN000; | ||
| 1239 | ; CGA_COL2RGB : CONVERT A COLOR FROM THE CGA TO RED GREEN BLUE VALUES ;AN000; | ||
| 1240 | ; ;AN000; | ||
| 1241 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1242 | ; ;AN000; | ||
| 1243 | ; INPUT: AL = 0000IRGB ONE BYTE WHERE BIT: ;AN000; | ||
| 1244 | ; ;AN000; | ||
| 1245 | ; I = Intensity bit ;AN000; | ||
| 1246 | ; R = Red component ;AN000; | ||
| 1247 | ; G = Green component ;AN000; | ||
| 1248 | ; B = Blue component ;AN000; | ||
| 1249 | ; ;AN000; | ||
| 1250 | ; ;AN000; | ||
| 1251 | ; OUTPUT: RGB.R = RED component (0-63) ;AN000; | ||
| 1252 | ; RGB.G = GREEN component (0-63) ;AN000; | ||
| 1253 | ; RGB.B = BLUE component (0-63) ;AN000; | ||
| 1254 | ; ;AN000; | ||
| 1255 | ; CALLED BY: SET_UP_CGA_XLT_TABLE ;AN000; | ||
| 1256 | ; ;AN000; | ||
| 1257 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1258 | ; ;AN000; | ||
| 1259 | ; DESCRIPTION: If either the RED, GREEN, or BLUE bit is on (in an IRGB ;AN000; | ||
| 1260 | ; byte) then, the corresponding color gun on the display is firing 2/3 ;AN000; | ||
| 1261 | ; of its capacity, giving a color intensity of "2/3". ;AN000; | ||
| 1262 | ; ;AN000; | ||
| 1263 | ; If the INTENSITY bit is on, then 1/3 is added to EACH color. ;AN000; | ||
| 1264 | ; ;AN000; | ||
| 1265 | ; (E.G., IRGB R G B ;AN000; | ||
| 1266 | ; BLACK = 00000000 ( 0, 0, 0) ;AN000; | ||
| 1267 | ; WHITE = 00001111 (3/3, 3/3, 3/3) ;AN000; | ||
| 1268 | ; RED = 00000100 (2/3, 0, 0) ;AN000; | ||
| 1269 | ; HIGH INT. RED = 00001100 (3/3, 1/3, 1/3) ;AN000; | ||
| 1270 | ; ;AN000; | ||
| 1271 | ; Since we want an intensity from 0 to 63, ;AN000; | ||
| 1272 | ; "2/3" of RED means: ;AN000; | ||
| 1273 | ; 2/3 * 63 = 42 ;AN000; | ||
| 1274 | ; ;AN000; | ||
| 1275 | ; ;AN000; | ||
| 1276 | ; LOGIC: ;AN000; | ||
| 1277 | ; Get the intensity. ;AN000; | ||
| 1278 | ; Get the red component ;AN000; | ||
| 1279 | ; Get the green component ;AN000; | ||
| 1280 | ; Get the blue component ;AN000; | ||
| 1281 | ; ;AN000; | ||
| 1282 | CGA_COL2RGB PROC NEAR ;AN000; | ||
| 1283 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1284 | ; ;AN000; | ||
| 1285 | ; Init the R,G,B values: ;AN000; | ||
| 1286 | ; ;AN000; | ||
| 1287 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1288 | MOV RGB.R,0 ;AN000; | ||
| 1289 | MOV RGB.G,0 ;AN000; | ||
| 1290 | MOV RGB.B,0 ;AN000; | ||
| 1291 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1292 | ; ;AN000; | ||
| 1293 | ; Test the Intensity bit: ;AN000; | ||
| 1294 | ; ;AN000; | ||
| 1295 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1296 | .IF <BIT AL AND I_BIT_MASK> ; IF, I is on ;AN000; | ||
| 1297 | .THEN ;AN000; | ||
| 1298 | ADD RGB.R,ONE_THIRD ; Then, add one third to each ;AN000; | ||
| 1299 | ADD RGB.G,ONE_THIRD ; color. ;AN000; | ||
| 1300 | ADD RGB.B,ONE_THIRD ;AN000; | ||
| 1301 | .ENDIF ;AN000; | ||
| 1302 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1303 | ; ;AN000; | ||
| 1304 | ; Test the RGB bits: ;AN000; | ||
| 1305 | ; ;AN000; | ||
| 1306 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1307 | .IF <BIT AL AND R_BIT_MASK> ; If, Red is on ;AN000; | ||
| 1308 | .THEN ;AN000; | ||
| 1309 | ADD RGB.R,TWO_THIRD ; then, add two third RED ;AN000; | ||
| 1310 | .ENDIF ;AN000; | ||
| 1311 | ;AN000; | ||
| 1312 | .IF <BIT AL AND G_BIT_MASK> ; If, Green is on ;AN000; | ||
| 1313 | .THEN ;AN000; | ||
| 1314 | ADD RGB.G,TWO_THIRD ; then, add two third GREEN ;AN000; | ||
| 1315 | .ENDIF ;AN000; | ||
| 1316 | ;AN000; | ||
| 1317 | .IF <BIT AL AND B_BIT_MASK> ; If, Blue is on ;AN000; | ||
| 1318 | .THEN ;AN000; | ||
| 1319 | ADD RGB.B,TWO_THIRD ; then, add two third BLUE ;AN000; | ||
| 1320 | .ENDIF ;AN000; | ||
| 1321 | ;AN000; | ||
| 1322 | RET ;AN000; | ||
| 1323 | CGA_COL2RGB ENDP ;AN000; | ||
| 1324 | PAGE ;AN000; | ||
| 1325 | ;======================================================================= ;AN000; | ||
| 1326 | ; ;AN000; | ||
| 1327 | ; SET_MODE_F_XLT_TAB: SET UP COLOR TRANSLATION TABLE FOR MONOCHROME ;AN000; | ||
| 1328 | ; MODE "F" ;AN000; | ||
| 1329 | ; ;AN000; | ||
| 1330 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1331 | ; ;AN000; | ||
| 1332 | ; INPUT: XLT_TAB = Color translation table. ;AN000; | ||
| 1333 | ; PRINTER_TYPE = Type of printer attached (Color or B&W) ;AN000; | ||
| 1334 | ; SWITCHES = GRAPHICS command line parameters. ;AN000; | ||
| 1335 | ; ;AN000; | ||
| 1336 | ; OUTPUT: XLT_TAB IS UPDATED ;AN000; | ||
| 1337 | ; ;AN000; | ||
| 1338 | ; CALLED BY: SET_UP_XLT_TABLE ;AN000; | ||
| 1339 | ; ;AN000; | ||
| 1340 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1341 | ; ;AN000; | ||
| 1342 | ; NOTES: In mode F the "VIDEO BIOS READ DOT call" returns a byte where ;AN000; | ||
| 1343 | ; bit 1 and 3 represent the value of plane 1 and 3. ;AN000; | ||
| 1344 | ; The following colors are available using this mode: ;AN000; | ||
| 1345 | ; ;AN000; | ||
| 1346 | ; plane 2: plane 0: color: ;AN000; | ||
| 1347 | ; 0 0 black ;AN000; | ||
| 1348 | ; 0 1 white ;AN000; | ||
| 1349 | ; 1 0 blinking white ;AN000; | ||
| 1350 | ; 1 1 high-intensity white ;AN000; | ||
| 1351 | ; ;AN000; | ||
| 1352 | ; ;AN000; | ||
| 1353 | ; DESCRIPTION: A local table holds the Red, Green, Blue values for each of ;AN000; | ||
| 1354 | ; the 4 Mono colors available in Mode Fh. ;AN000; | ||
| 1355 | ; Each color is stored as either a Grey intensity if printing in Monochrome ;AN000; | ||
| 1356 | ; or as a Band Mask if printing in color. ;AN000; | ||
| 1357 | ; Black is stored as black. ;AN000; | ||
| 1358 | ; White is stored as a light gray ;AN000; | ||
| 1359 | ; High-intensity white and blinking white are stored as white. ;AN000; | ||
| 1360 | ; ;AN000; | ||
| 1361 | ; ;AN000; | ||
| 1362 | ; LOGIC: ;AN000; | ||
| 1363 | ; FOR EACH "COLOR" AVAILABLE WITH MODE F ;AN000; | ||
| 1364 | ; GET ITS R,G,B VALUES ;AN000; | ||
| 1365 | ; CALL RGB2XLT_TAB ; Convert RGB to an entry in the translation ;AN000; | ||
| 1366 | ; ; table ;AN000; | ||
| 1367 | ; ;AN000; | ||
| 1368 | SET_MODE_F_XLT_TAB PROC NEAR ;AN000; | ||
| 1369 | PUSH AX ;AN000; | ||
| 1370 | PUSH SI ;AN000; | ||
| 1371 | PUSH DI ;AN000; | ||
| 1372 | JMP SHORT SET_MODE_F_BEGIN ;AN000; | ||
| 1373 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1374 | ; ;AN000; | ||
| 1375 | ; TABLE OF R,G,B VALUES WE ASSIGN TO THE 4 COLORS AVAILABLE IN MODE F: ;AN000; | ||
| 1376 | ; ;AN000; | ||
| 1377 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1378 | MODE_F_RGB LABEL BYTE ;AN000; | ||
| 1379 | DB BLACK_INT,BLACK_INT,BLACK_INT ; Black is mapped to black. ;AN000; | ||
| 1380 | DB TWO_THIRD,TWO_THIRD,TWO_THIRD ; White --> light grey ;AN000; | ||
| 1381 | DB WHITE_INT,WHITE_INT,WHITE_INT ; Blinking --> white ;AN000; | ||
| 1382 | DB WHITE_INT,WHITE_INT,WHITE_INT ; High-int. White --> white ;AN000; | ||
| 1383 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1384 | ; ;AN000; | ||
| 1385 | ; STORE THE COLORS AVAILABLE WITH MODE F ;AN000; | ||
| 1386 | ; ;AN000; | ||
| 1387 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1388 | SET_MODE_F_BEGIN: ;AN000; | ||
| 1389 | MOV SI,OFFSET MODE_F_RGB ; SI <-- Offset of RGB table ;AN000; | ||
| 1390 | XOR DI,DI ; DI <-- Index into translation table ;AN000; | ||
| 1391 | ;AN000; | ||
| 1392 | ;-------For each color available in mode F: ;AN000; | ||
| 1393 | STORE_1_MODE_F_COLOR: ;AN000; | ||
| 1394 | MOV AL,[SI] ; Get the Red component ;AN000; | ||
| 1395 | MOV RGB.R,AL ;AN000; | ||
| 1396 | MOV AL,[SI]+1 ; Get the Green component ;AN000; | ||
| 1397 | MOV RGB.G,AL ;AN000; | ||
| 1398 | MOV AL,[SI]+2 ; Get the Blue component ;AN000; | ||
| 1399 | MOV RGB.B,AL ;AN000; | ||
| 1400 | ;AN000; | ||
| 1401 | ;-------Convert pixel to either a Color band or an Intensity: ;AN000; | ||
| 1402 | CALL RGB2XLT_TAB ; Convert and store in the xlt table ;AN000; | ||
| 1403 | ;AN000; | ||
| 1404 | ADD SI,3 ; Get next R,G,B values ;AN000; | ||
| 1405 | INC DI ; One more color has been stored ;AN000; | ||
| 1406 | CMP DI,NB_COLORS ; All stored ? ;AN000; | ||
| 1407 | JL STORE_1_MODE_F_COLOR ;AN000; | ||
| 1408 | ;AN000; | ||
| 1409 | POP DI ;AN000; | ||
| 1410 | POP SI ;AN000; | ||
| 1411 | POP AX ;AN000; | ||
| 1412 | RET ;AN000; | ||
| 1413 | SET_MODE_F_XLT_TAB ENDP ;AN000; | ||
| 1414 | PAGE ;AN000; | ||
| 1415 | ;======================================================================= ;AN000; | ||
| 1416 | ; ;AN000; | ||
| 1417 | ; SET_MODE_13H_XLT_TAB: SET UP COLOR TRANSLATION TABLE FOR PALACE VIDEO ;AN000; | ||
| 1418 | ; ADAPTER IN MODE 13H ;AN000; | ||
| 1419 | ; ;AN000; | ||
| 1420 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1421 | ; ;AN000; | ||
| 1422 | ; INPUT: XLT_TAB = Color translation table. ;AN000; | ||
| 1423 | ; PRINTER_TYPE = Type of printer attached (Color or B&W) ;AN000; | ||
| 1424 | ; SWITCHES = GRAPHICS command line parameters. ;AN000; | ||
| 1425 | ; ;AN000; | ||
| 1426 | ; OUTPUT: XLT_TAB IS UPDATED ;AN000; | ||
| 1427 | ; ;AN000; | ||
| 1428 | ; CALLED BY: SET_UP_XLT_TABLE ;AN000; | ||
| 1429 | ; ;AN000; | ||
| 1430 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1431 | ; ;AN000; | ||
| 1432 | ; NOTES: With the PALACE the "VIDEO BIOS READ DOT call" returns a direct ;AN000; | ||
| 1433 | ; index to the 256 COLOR REGISTERS. ;AN000; | ||
| 1434 | ; ;AN000; | ||
| 1435 | ; These COLORS REGISTERS hold the R,G,B (Red, Green, Blue) values for ;AN000; | ||
| 1436 | ; each of the 256 colors available at the same time on the screen. ;AN000; | ||
| 1437 | ; Color register number 0 holds the background color. ;AN000; | ||
| 1438 | ; ;AN000; | ||
| 1439 | ; DESCRIPTION: Store a color mapping for each color register. ;AN000; | ||
| 1440 | ; If the REVERSE_SW is off, exchange white and black. ;AN000; | ||
| 1441 | ; ;AN000; | ||
| 1442 | ; LOGIC: ;AN000; | ||
| 1443 | ; ;AN000; | ||
| 1444 | ; For each color (0 to 255) ;AN000; | ||
| 1445 | ; Read the color register ; get the RGB values for this color num. ;AN000; | ||
| 1446 | ; Store the result in the XLT_TAB ;AN000; | ||
| 1447 | ; ;AN000; | ||
| 1448 | SET_MODE_13H_XLT_TAB PROC NEAR ;AN000; | ||
| 1449 | PUSH AX ;AN000; | ||
| 1450 | PUSH BX ;AN000; | ||
| 1451 | PUSH CX ;AN000; | ||
| 1452 | PUSH DX ;AN000; | ||
| 1453 | PUSH DI ;AN000; | ||
| 1454 | ;AN000; | ||
| 1455 | MOV NB_COLORS_TO_READ,256 ; Read 256 color registers ;AN000; | ||
| 1456 | ;AN000; | ||
| 1457 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1458 | ; ;AN000; | ||
| 1459 | ; Store in the translation table each color available for mode 13h: ;AN000; | ||
| 1460 | ; ;AN000; | ||
| 1461 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1462 | XOR DI,DI ; DI := Palette register number ;AN000; | ||
| 1463 | ; and index in the translation table ;AN000; | ||
| 1464 | STORE_1_M13H_COLOR: ;AN000; | ||
| 1465 | MOV BX,DI ; BX := Color register to be read ;AN000; | ||
| 1466 | MOV AX,GET_C_REG_CALL ; AX := BIOS Get color register call ;AN000; | ||
| 1467 | INT 10H ; Call BIOS ;AN000; | ||
| 1468 | MOV RGB.R,DH ; Get Red value ;AN000; | ||
| 1469 | MOV RGB.G,CH ; Get Green value ;AN000; | ||
| 1470 | MOV RGB.B,CL ; Get Blue value ;AN000; | ||
| 1471 | CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1472 | INC DI ; Get next palette register number ;AN000; | ||
| 1473 | CMP DI,NB_COLORS_TO_READ ; All colors stored ? ;AN000; | ||
| 1474 | JL STORE_1_M13H_COLOR ; No, get next one ;AN000; | ||
| 1475 | ;AN000; | ||
| 1476 | ;AN000; | ||
| 1477 | POP DI ;AN000; | ||
| 1478 | POP DX ;AN000; | ||
| 1479 | POP CX ;AN000; | ||
| 1480 | POP BX ;AN000; | ||
| 1481 | POP AX ;AN000; | ||
| 1482 | RET ;AN000; | ||
| 1483 | NB_COLORS_TO_READ DW ? ; Number of colors registers to read with a PS/2;AN000; | ||
| 1484 | SET_MODE_13H_XLT_TAB ENDP ;AN000; | ||
| 1485 | PAGE ;AN000; | ||
| 1486 | ;===============================================================================;AN000; | ||
| 1487 | ; ;AN000; | ||
| 1488 | ; SET_ROUNDUP_XLT_TAB: SET UP COLOR TRANSLATION TABLE FOR ROUNDUP VIDEO ;AN000; | ||
| 1489 | ; ADAPTER ;AN000; | ||
| 1490 | ; ;AN000; | ||
| 1491 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1492 | ; ;AN000; | ||
| 1493 | ; INPUT: XLT_TAB = Color translation table. ;AN000; | ||
| 1494 | ; PRINTER_TYPE = Type of printer attached (Color or B&W) ;AN000; | ||
| 1495 | ; SWITCHES = GRAPHICS command line parameters. ;AN000; | ||
| 1496 | ; ;AN000; | ||
| 1497 | ; OUTPUT: XLT_TAB IS UPDATED ;AN000; | ||
| 1498 | ; ;AN000; | ||
| 1499 | ; CALLED BY: SET_UP_XLT_TABLE ;AN000; | ||
| 1500 | ; ;AN000; | ||
| 1501 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1502 | ; ;AN000; | ||
| 1503 | ; NOTES: With the ROUNDUP the "VIDEO BIOS READ DOT call" returns an ;AN000; | ||
| 1504 | ; index into the 16 PALETTE REGISTERS. ;AN000; | ||
| 1505 | ; ;AN000; | ||
| 1506 | ; Each palette register holds an index into the current "color page" ;AN000; | ||
| 1507 | ; within the 256 COLOR REGISTERS. ;AN000; | ||
| 1508 | ; ;AN000; | ||
| 1509 | ; These "color pages" represent all the colors from WHICH TO CHOOSE the ;AN000; | ||
| 1510 | ; screen colors for an active page; 16 colors can be displayed at the ;AN000; | ||
| 1511 | ; same time on the screen. ;AN000; | ||
| 1512 | ; ;AN000; | ||
| 1513 | ; There are 2 paging modes: either 64 color pages or 16 color pages: ;AN000; | ||
| 1514 | ; ;AN000; | ||
| 1515 | ; In 64 color mode, there are 4 color pages available (the 256 palette ;AN000; | ||
| 1516 | ; registers are partitioned in 4 blocks of 64 colors). ;AN000; | ||
| 1517 | ; ;AN000; | ||
| 1518 | ; The 16 screen colors for the active page are selected from these 64 ;AN000; | ||
| 1519 | ; color registers. ;AN000; | ||
| 1520 | ; ;AN000; | ||
| 1521 | ; This scheme allows for quickly changing the contents of the screen by ;AN000; | ||
| 1522 | ; changing the active page. ;AN000; | ||
| 1523 | ; ;AN000; | ||
| 1524 | ; The COLOR REGISTERS contains the color information stored as RGB (Red, ;AN000; | ||
| 1525 | ; Green, Blue) components. There is one byte for each of these 3 ;AN000; | ||
| 1526 | ; components. The value for each component ranges from 0 to 63 (where ;AN000; | ||
| 1527 | ; 0 = color not present). ;AN000; | ||
| 1528 | ; ;AN000; | ||
| 1529 | ; ;AN000; | ||
| 1530 | ; DESCRIPTION: Determine the paging mode and the active color page. ;AN000; | ||
| 1531 | ; For each color available with the current mode, get the palette ;AN000; | ||
| 1532 | ; register and then, read the corresponding color register in order to ;AN000; | ||
| 1533 | ; obtain its RGB components. ;AN000; | ||
| 1534 | ; ;AN000; | ||
| 1535 | ; For mode 11h, 2 colors only are available. These colors are obtained from ;AN000; | ||
| 1536 | ; palette register 0 (background) and 7 (foreground color). The contents ;AN000; | ||
| 1537 | ; of these 2 palette registers is also used as an index within the color ;AN000; | ||
| 1538 | ; registers. ;AN000; | ||
| 1539 | ; ;AN000; | ||
| 1540 | ; If printing is Monochrome, map the RGB to a Grey Intensity. ;AN000; | ||
| 1541 | ; If printing is in colors, map the RGB to a Band Mask. ;AN000; | ||
| 1542 | ; Store the result in the translation table ;AN000; | ||
| 1543 | ; ;AN000; | ||
| 1544 | ; LOGIC: ;AN000; | ||
| 1545 | ; ;AN000; | ||
| 1546 | ; Read color page state (BIOS INT 10H - AL = 1AH) ;AN000; | ||
| 1547 | ; ;AN000; | ||
| 1548 | ; If mode 4,5 or 6 ;AN000; | ||
| 1549 | ; Then ;AN000; | ||
| 1550 | ; CALL SET_CGA_XLT_TAB ;AN000; | ||
| 1551 | ; Adjust the background color. ;AN000; | ||
| 1552 | ; else ;AN000; | ||
| 1553 | ; If mode 11h ;AN000; | ||
| 1554 | ; then ;AN000; | ||
| 1555 | ; For PALETTE_INDEX := 0 to 15 ;AN000; | ||
| 1556 | ; IF PAGE_MODE = PAGE_64_REGISTERS ;AN000; | ||
| 1557 | ; THEN ;AN000; | ||
| 1558 | ; Read the palette register number "PALETTE_INDEX" ;AN000; | ||
| 1559 | ; COLOR_INDEX := Palette register contents ;AN000; | ||
| 1560 | ; COLOR_INDEX := (CUR_PAGE_NUM * 64) + COLOR_INDEX ;AN000; | ||
| 1561 | ; Read color register number "COLOR_INDEX" ; Obtain R,G,B values. ;AN000; | ||
| 1562 | ; CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1563 | ; ;AN000; | ||
| 1564 | ; ELSE IF PAGE_MODE = PAGE_16_REGISTERS ;AN000; | ||
| 1565 | ; COLOR_INDEX := (CUR_PAGE_NUM * 16) + PALETTE_INDEX ;AN000; | ||
| 1566 | ; Read color register number "COLOR_INDEX" ;AN000; | ||
| 1567 | ; CALL RGB2XLT_TAB ; Convert RGB to an entry in XLT_TAB ;AN000; | ||
| 1568 | ; ;AN000; | ||
| 1569 | ; ;AN000; | ||
| 1570 | SET_ROUNDUP_XLT_TAB PROC NEAR ;AN000; | ||
| 1571 | PAGING_MODE_64 EQU 0 ;AN000; | ||
| 1572 | ;AN000; | ||
| 1573 | PUSH AX ;AN000; | ||
| 1574 | PUSH BX ;AN000; | ||
| 1575 | PUSH CX ;AN000; | ||
| 1576 | PUSH DI ;AN000; | ||
| 1577 | ;AN000; | ||
| 1578 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1579 | ; Obtain the color page state ;AN000; | ||
| 1580 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1581 | MOV AX,PAGE_STATE_CALL ; Call BIOS ;AN000; | ||
| 1582 | INT 10H ; BL := Paging mode ;AN000; | ||
| 1583 | ; BH := Current page ;AN000; | ||
| 1584 | ;AN000; | ||
| 1585 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1586 | ; Check the video mode: ;AN000; | ||
| 1587 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1588 | .SELECT ;AN000; | ||
| 1589 | .WHEN <CUR_MODE EQ 4> OR ; If the current mode is an old CGA ;AN000; | ||
| 1590 | .WHEN <CUR_MODE EQ 5> OR ; mode: ;AN000; | ||
| 1591 | .WHEN <CUR_MODE EQ 6> ; ;AN000; | ||
| 1592 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1593 | ; ;AN000; | ||
| 1594 | ; Old CGA graphics mode (mode 4, 5 or 6) ;AN000; | ||
| 1595 | ; ;AN000; | ||
| 1596 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1597 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1598 | ; Store colors of the old CGA modes: ;AN000; | ||
| 1599 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1600 | CALL SET_CGA_XLT_TAB ; Set up colors in the translation ;AN000; | ||
| 1601 | ; table, NOTE: The background color ;AN000; | ||
| 1602 | ; will not be set properly since the ;AN000; | ||
| 1603 | ; PS/2 BIOS does not update memory ;AN000; | ||
| 1604 | ; location 40:66 with the value ;AN000; | ||
| 1605 | ; of the background color as CGA ;AN000; | ||
| 1606 | ; does for modes 4 and 5. However ;AN000; | ||
| 1607 | ; 40:66 holds the current palette;AN000; | ||
| 1608 | ; selected. ;AN000; | ||
| 1609 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1610 | ; Adjust the background color for modes 4,5 or 6 ;AN000; | ||
| 1611 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1612 | MOV PAL_REGISTER_NB,0 ; Read the palette register number 0 ;AN000; | ||
| 1613 | CALL GET_PALETTE_RGB ; this register points to the color ;AN000; | ||
| 1614 | ; register that contains the RGB ;AN000; | ||
| 1615 | ; values of the BACKGROUND color. ;AN000; | ||
| 1616 | MOV DI,0 ; DI := Index in the translation table ;AN000; | ||
| 1617 | CALL RGB2XLT_TAB ; Store mapping in the translation table;AN000; | ||
| 1618 | ;AN000; | ||
| 1619 | .WHEN <CUR_MODE EQ 11H> ;AN000; | ||
| 1620 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1621 | ; ;AN000; | ||
| 1622 | ; Mode 11h (2 colors out of 256,000 colors) ;AN000; | ||
| 1623 | ; ;AN000; | ||
| 1624 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1625 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1626 | ; Get the background color: ;AN000; | ||
| 1627 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1628 | MOV PAL_REGISTER_NB,0 ; Read the palette register number 0 ;AN000; | ||
| 1629 | CALL GET_PALETTE_RGB ; Get the RGB values for this color ;AN000; | ||
| 1630 | MOV DI,0 ; DI := Index in translation table ;AN000; | ||
| 1631 | CALL RGB2XLT_TAB ; Store mapping in the translation table;AN000; | ||
| 1632 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1633 | ; Get the foreground color: ;AN000; | ||
| 1634 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1635 | MOV PAL_REGISTER_NB,7 ; Read the palette register for the ;AN000; | ||
| 1636 | ; FOREGROUND color (palette register 7);AN000; | ||
| 1637 | CALL GET_PALETTE_RGB ; Get the RGB values for this color ;AN000; | ||
| 1638 | MOV DI,1 ; DI := Index in translation table ;AN000; | ||
| 1639 | CALL RGB2XLT_TAB ; Store mapping in the translation table;AN000; | ||
| 1640 | .OTHERWISE ;AN000; | ||
| 1641 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1642 | ; ;AN000; | ||
| 1643 | ; The current mode is a 16 color mode ;AN000; | ||
| 1644 | ; ;AN000; | ||
| 1645 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1646 | XOR DI,DI ; DI := Index in translation table ;AN000; | ||
| 1647 | MOV CX,16 ; 16 colors to read and store ;AN000; | ||
| 1648 | MOV PAL_REGISTER_NB,0 ; Palette register to read ;AN000; | ||
| 1649 | STORE_1_PS2_COLOR: ;AN000; | ||
| 1650 | CALL GET_PALETTE_RGB ; Get the RGB values for this color ;AN000; | ||
| 1651 | ; ;AN000; | ||
| 1652 | ;-------Convert the RGB values to band mask or intensity and store in XLT_TAB: ;AN000; | ||
| 1653 | ;AN000; | ||
| 1654 | CALL RGB2XLT_TAB ; Store mapping in the translation table;AN000; | ||
| 1655 | INC DI ; Get next palette register number ;AN000; | ||
| 1656 | INC PAL_REGISTER_NB ; ;AN000; | ||
| 1657 | LOOP STORE_1_PS2_COLOR ; Read it. ;AN000; | ||
| 1658 | .ENDSELECT ;AN000; | ||
| 1659 | ;AN000; | ||
| 1660 | POP DI ;AN000; | ||
| 1661 | POP CX ;AN000; | ||
| 1662 | POP BX ;AN000; | ||
| 1663 | POP AX ;AN000; | ||
| 1664 | RET ;AN000; | ||
| 1665 | PAL_REGISTER_NB DB ? ; Number of the palette register to read;AN000; | ||
| 1666 | SET_ROUNDUP_XLT_TAB ENDP ;AN000; | ||
| 1667 | ;AN000; | ||
| 1668 | PAGE ;AN000; | ||
| 1669 | ;===============================================================================;AN000; | ||
| 1670 | ; ;AN000; | ||
| 1671 | ; GET_PALETTE_RGB: ON THE PS/2 MODEL 50, 60 AND 80, GET THE RGB VALUES FOR A ;AN000; | ||
| 1672 | ; PALETTE REGISTER BY READING THE CORRESPONDING COLOR REGISTER;AN000; | ||
| 1673 | ; ;AN000; | ||
| 1674 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1675 | ; ;AN000; | ||
| 1676 | ; INPUT: PAL_REGISTER_NB = Palette register number ;AN000; | ||
| 1677 | ; BH = Current page number ;AN000; | ||
| 1678 | ; BL = Current paging mode ;AN000; | ||
| 1679 | ; ;AN000; | ||
| 1680 | ; OUTPUT: RGB.R = The RGB values obtained from the color register;AN000; | ||
| 1681 | ; RGB.G corresponding to the palette register specified;AN000; | ||
| 1682 | ; RGB.B ;AN000; | ||
| 1683 | ; ;AN000; | ||
| 1684 | ; CALLED BY: SET_ROUNDUP_XLT_TAB ;AN000; | ||
| 1685 | ; ;AN000; | ||
| 1686 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1687 | GET_PALETTE_RGB PROC ;AN000; | ||
| 1688 | PUSH AX ;AN000; | ||
| 1689 | PUSH BX ;AN000; | ||
| 1690 | PUSH CX ;AN000; | ||
| 1691 | PUSH DX ;AN000; | ||
| 1692 | PUSH SI ;AN000; | ||
| 1693 | ;AN000; | ||
| 1694 | MOV AL,BH ; SI := Current page number ;AN000; | ||
| 1695 | CBW ; ;AN000; | ||
| 1696 | MOV SI,AX ; ;AN000; | ||
| 1697 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1698 | ; ;AN000; | ||
| 1699 | ; Calculte the absolute number of the first Color Register for the current page:;AN000; | ||
| 1700 | ; (calculated in SI) ;AN000; | ||
| 1701 | ; ;AN000; | ||
| 1702 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1703 | .IF <BL EQ PAGING_MODE_64> ; If mode is 64 Color page ;AN000; | ||
| 1704 | .THEN ; then ;AN000; | ||
| 1705 | MOV CL,6 ; SI := Current page num * 64 ;AN000; | ||
| 1706 | SHL SI,CL ; ;AN000; | ||
| 1707 | .ELSE ; else, Mode is 16 Color page ;AN000; | ||
| 1708 | MOV CL,4 ; SI := Current page num * 16 ;AN000; | ||
| 1709 | SHL SI,CL ; ;AN000; | ||
| 1710 | .ENDIF ;AN000; | ||
| 1711 | ;AN000; | ||
| 1712 | ; ;AN000; | ||
| 1713 | ;-------Read the PALETTE REGISTER ;AN000; | ||
| 1714 | MOV BL,PAL_REGISTER_NB ; BL := Palette register to be read ;AN000; | ||
| 1715 | MOV AX,GET_P_REG_CALL ; Read palette register call ;AN000; | ||
| 1716 | INT 10H ; Call BIOS, ;AN000; | ||
| 1717 | ; BH := Color register index ;AN000; | ||
| 1718 | ; WITHIN the current page and is;AN000; | ||
| 1719 | ; either (0-15) or (0-63) ;AN000; | ||
| 1720 | ; NOTE: SI = Absolute index (0-255) to ;AN000; | ||
| 1721 | ; the first color register of the ;AN000; | ||
| 1722 | ; current page and is a multiple of ;AN000; | ||
| 1723 | ; either 16 or 64 ;AN000; | ||
| 1724 | MOV BL,BH ; BX := Index within current color page ;AN000; | ||
| 1725 | XOR BH,BH ; ;AN000; | ||
| 1726 | ;AN000; | ||
| 1727 | ; ;AN000; | ||
| 1728 | ;-------Read the Color register: ;AN000; | ||
| 1729 | OR BX,SI ; BX := Index of Color register to read ;AN000; | ||
| 1730 | MOV AX,GET_C_REG_CALL ; Read the color register ;AN000; | ||
| 1731 | INT 10H ; Call BIOS, ;AN000; | ||
| 1732 | MOV RGB.R,DH ; DH := Red value read ;AN000; | ||
| 1733 | MOV RGB.G,CH ; CH := Green value read ;AN000; | ||
| 1734 | MOV RGB.B,CL ; CL := Blue value read ;AN000; | ||
| 1735 | ;AN000; | ||
| 1736 | POP SI ;AN000; | ||
| 1737 | POP DX ;AN000; | ||
| 1738 | POP CX ;AN000; | ||
| 1739 | POP BX ;AN000; | ||
| 1740 | POP AX ;AN000; | ||
| 1741 | RET ;AN000; | ||
| 1742 | GET_PALETTE_RGB ENDP ;AN000; | ||
| 1743 | PAGE ;AN000; | ||
| 1744 | ;======================================================================= ;AN000; | ||
| 1745 | ; ;AN000; | ||
| 1746 | ; EGA_COL2RGB : CONVERT A COLOR FROM THE EGA TO RED GREEN BLUE VALUES ;AN000; | ||
| 1747 | ; ;AN000; | ||
| 1748 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1749 | ; ;AN000; | ||
| 1750 | ; INPUT: AL = 00rgbRGB ONE BYTE WHERE BIT: ;AN000; | ||
| 1751 | ; ;AN000; | ||
| 1752 | ; r = 1/3 of Red component ;AN000; | ||
| 1753 | ; g = 1/3 of Green component ;AN000; | ||
| 1754 | ; b = 1/3 of Blue component ;AN000; | ||
| 1755 | ; R = 2/3 of Red component ;AN000; | ||
| 1756 | ; G = 2/3 of Green component ;AN000; | ||
| 1757 | ; B = 3/3 of Blue component ;AN000; | ||
| 1758 | ; ;AN000; | ||
| 1759 | ; ;AN000; | ||
| 1760 | ; OUTPUT: RGB.R = RED component (0-63) ;AN000; | ||
| 1761 | ; RGB.G = GREEN component (0-63) ;AN000; | ||
| 1762 | ; RGB.B = BLUE component (0-63) ;AN000; | ||
| 1763 | ; ;AN000; | ||
| 1764 | ; CALLED BY: SET_UP_EGA_XLT_TABLE ;AN000; | ||
| 1765 | ; ;AN000; | ||
| 1766 | ;----------------------------------------------------------------------- ;AN000; | ||
| 1767 | ; ;AN000; | ||
| 1768 | ; DESCRIPTION: Sums up the values for each color component. ;AN000; | ||
| 1769 | ; "2/3 of RED" means that the red gun in the display attached to the EGA ;AN000; | ||
| 1770 | ; is firing at 2/3 of full intensity. ;AN000; | ||
| 1771 | ; ;AN000; | ||
| 1772 | ; Since the color intensities range from 0 to 63, "1/3" means an ;AN000; | ||
| 1773 | ; intensity of: ;AN000; | ||
| 1774 | ; 1/3 * 63 = 21 ;AN000; | ||
| 1775 | ; ;AN000; | ||
| 1776 | ; LOGIC: ;AN000; | ||
| 1777 | ; ;AN000; | ||
| 1778 | ; Get the red component ;AN000; | ||
| 1779 | ; Get the green component ;AN000; | ||
| 1780 | ; Get the blue component ;AN000; | ||
| 1781 | ; ;AN000; | ||
| 1782 | EGA_COL2RGB PROC NEAR ;AN000; | ||
| 1783 | ; ;AN000; | ||
| 1784 | ;-------Get the RED component (bit 5 and 2) ;AN000; | ||
| 1785 | ; ;AN000; | ||
| 1786 | ;-------Check bit 2 ;AN000; | ||
| 1787 | MOV RGB.R,0 ;AN000; | ||
| 1788 | TEST AL,100B ; "R" is on ? ;AN000; | ||
| 1789 | JZ CHECK_BIT_5 ; No, check "r" ;AN000; | ||
| 1790 | ADD RGB.R,TWO_THIRD ; Yes, add 2/3 RED ;AN000; | ||
| 1791 | CHECK_BIT_5: ;AN000; | ||
| 1792 | TEST AL,100000B ; "r" is on ? ;AN000; | ||
| 1793 | JZ CHECK_BIT_1 ; No, check Green ;AN000; | ||
| 1794 | ADD RGB.R,ONE_THIRD ; Yes, add 1/3 RED ;AN000; | ||
| 1795 | ; ;AN000; | ||
| 1796 | ;-------Get the GREEN component (bit 4 and 1) ;AN000; | ||
| 1797 | ; ;AN000; | ||
| 1798 | CHECK_BIT_1: ;AN000; | ||
| 1799 | MOV RGB.G,0 ;AN000; | ||
| 1800 | TEST AL,10B ; "G" is on ? ;AN000; | ||
| 1801 | JZ CHECK_BIT_4 ; No, check "g" ;AN000; | ||
| 1802 | ADD RGB.G,TWO_THIRD ; Yes, add 2/3 GREEN ;AN000; | ||
| 1803 | CHECK_BIT_4: ;AN000; | ||
| 1804 | TEST AL,10000B ; "g" is on ? ;AN000; | ||
| 1805 | JZ CHECK_BIT_0 ; No, check for Blue ;AN000; | ||
| 1806 | ADD RGB.G,ONE_THIRD ; Yes, add 1/3 GREEN ;AN000; | ||
| 1807 | ; ;AN000; | ||
| 1808 | ;-------Get the BLUE component (bit 3 and 0) ;AN000; | ||
| 1809 | ; ;AN000; | ||
| 1810 | CHECK_BIT_0: ;AN000; | ||
| 1811 | MOV RGB.B,0 ;AN000; | ||
| 1812 | TEST AL,1B ; "B" is on ? ;AN000; | ||
| 1813 | JZ CHECK_BIT_3 ; No, check "b" ;AN000; | ||
| 1814 | ADD RGB.B,TWO_THIRD ; Yes, add 2/3 BLUE ;AN000; | ||
| 1815 | CHECK_BIT_3: ;AN000; | ||
| 1816 | TEST AL,1000B ; "b" is on ? ;AN000; | ||
| 1817 | JZ EGA_COL2RGB_RETURN ; No, return ;AN000; | ||
| 1818 | ADD RGB.B,ONE_THIRD ; Yes, add 1/3 BLUE ;AN000; | ||
| 1819 | EGA_COL2RGB_RETURN: ;AN000; | ||
| 1820 | RET ;AN000; | ||
| 1821 | EGA_COL2RGB ENDP ;AN000; | ||
| 1822 | ;AN000; | ||
| 1823 | PAGE ;AN000; | ||
| 1824 | ;===============================================================================;AN000; | ||
| 1825 | ; ;AN000; | ||
| 1826 | ; RGB2INT : MAP RED GREEN BLUE VALUES TO AN INTENSITY. ;AN000; | ||
| 1827 | ; ;AN000; | ||
| 1828 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1829 | ; ;AN000; | ||
| 1830 | ; INPUT: RGB.R = A RED value (0-63) ;AN000; | ||
| 1831 | ; RGB.G = A GREEN value (0-63) ;AN000; | ||
| 1832 | ; RGB.B = A BLUE value (0-63) ;AN000; | ||
| 1833 | ; DARKADJUST_VALUE= THE DARKNESS VALUE (In shared data area). ;AN000; | ||
| 1834 | ; SWITCHES = Command line switches ;AN000; | ||
| 1835 | ; ;AN000; | ||
| 1836 | ; OUTPUT: AL = THE INTENSITY (0-63) NOTE: 0 = BLACK ;AN000; | ||
| 1837 | ; 63 = BRIGHT WHITE ;AN000; | ||
| 1838 | ; ;AN000; | ||
| 1839 | ; WARNING: AH IS LOST ;AN000; | ||
| 1840 | ; ;AN000; | ||
| 1841 | ;-------------------------------------------------------------------------------;AN000; | ||
| 1842 | ; ;AN000; | ||
| 1843 | ; DESCRIPTION: When the RGB values for a pixel are at their maximum ;AN000; | ||
| 1844 | ; value, what we obtain is a bright white pixel on the screen; this is ;AN000; | ||
| 1845 | ; the brightest color achievable and therefore, its intensity is 63. ;AN000; | ||
| 1846 | ; ;AN000; | ||
| 1847 | ; When no color gun is firing on the display: RGB values are 0,0,0 this ;AN000; | ||
| 1848 | ; is no color at all and therefore maps to intensity 0. ;AN000; | ||
| 1849 | ; ;AN000; | ||
| 1850 | ; For intermediate colors, experimentation has shown that the eye will ;AN000; | ||
| 1851 | ; see blue as darker than red and red as darker than green. ;AN000; | ||
| 1852 | ; ;AN000; | ||
| 1853 | ; On a grey rainbow from 0 - 10 where 0 is black and 10 is white: ;AN000; | ||
| 1854 | ; ;AN000; | ||
| 1855 | ; Blue corresponds to a grey of intensity 1 ;AN000; | ||
| 1856 | ; Red corresponds to a grey of intensity 3 ;AN000; | ||
| 1857 | ; Green corresponds to a grey of intensity 6 ;AN000; | ||
| 1858 | ; ;AN000; | ||
| 1859 | ; Therefore, if we mix all 3 colors we obtain a grey of ;AN000; | ||
| 1860 | ; intensity 1 + 3 + 6 = 10 (i.e.,white). ;AN000; | ||
| 1861 | ; ;AN000; | ||
| 1862 | ; ;AN000; | ||
| 1863 | ; LOGIC: ;AN000; | ||
| 1864 | ; ;AN000; | ||
| 1865 | ; Calculate the intensity ;AN000; | ||
| 1866 | ; ;AN000; | ||
| 1867 | ; AL = (.6 * G) + (.3 * R) + (.1 * B) ;AN000; | ||
| 1868 | ; ;AN000; | ||
| 1869 | ; Adjust Darkness ;AN000; | ||
| 1870 | ; ;AN000; | ||
| 1871 | ; AL = AL + DARKADJUST_VALUE ;AN000; | ||
| 1872 | ; ;AN000; | ||
| 1873 | RGB2INT PROC NEAR ;AN000; | ||
| 1874 | PUSH BX ;AN000; | ||
| 1875 | PUSH CX ;AN000; | ||
| 1876 | PUSH DX ;AN000; | ||
| 1877 | ;AN000; | ||
| 1878 | XOR AX,AX ; AL := Current component intensity ;AN000; | ||
| 1879 | XOR BX,BX ; BX is used for calculations ;AN000; | ||
| 1880 | XOR DX,DX ; DL := Running sum for grey intensity ;AN000; | ||
| 1881 | ;AN000; | ||
| 1882 | ;-------Process /R (Reverse black and white) ;AN000; | ||
| 1883 | .IF <BIT DS:[BP].SWITCHES Z REVERSE_SW> ; IF reverse is OFF ;AN000; | ||
| 1884 | .THEN ; THEN REVERSE BLACK AND WHITE: ;AN000; | ||
| 1885 | ;-------Test if the color is BLACK ;AN000; | ||
| 1886 | .IF <RGB.R EQ BLACK_INT> AND ; If black ;AN000; | ||
| 1887 | .IF <RGB.G EQ BLACK_INT> AND ; ;AN000; | ||
| 1888 | .IF <RGB.B EQ BLACK_INT> ; ;AN000; | ||
| 1889 | .THEN ; then, replace it with white ;AN000; | ||
| 1890 | MOV AL,WHITE_INT ;AN000; | ||
| 1891 | JMP SHORT RGB2INT_END ;AN000; | ||
| 1892 | .ELSEIF <RGB.R EQ WHITE_INT> AND ; else if, high-intensity white ;AN000; | ||
| 1893 | .IF <RGB.G EQ WHITE_INT> AND ; ;AN000; | ||
| 1894 | .IF <RGB.B EQ WHITE_INT> ; ;AN000; | ||
| 1895 | .THEN ; then, replace it with black ;AN000; | ||
| 1896 | MOV AL,BLACK_INT ;AN000; | ||
| 1897 | JMP SHORT RGB2INT_END ;AN000; | ||
| 1898 | .ELSEIF <RGB.R EQ TWO_THIRD> AND ; else if, white ;AN000; | ||
| 1899 | .IF <RGB.G EQ TWO_THIRD> AND ; ;AN000; | ||
| 1900 | .IF <RGB.B EQ TWO_THIRD> ; ;AN000; | ||
| 1901 | .THEN ; then, replace it with black ;AN000; | ||
| 1902 | MOV AL,BLACK_INT ;AN000; | ||
| 1903 | JMP SHORT RGB2INT_END ;AN000; | ||
| 1904 | .ENDIF ;AN000; | ||
| 1905 | .ENDIF ;AN000; | ||
| 1906 | ;AN000; | ||
| 1907 | ;-------Calculate Green component ;AN000; | ||
| 1908 | MOV AL,RGB.G ; AL := Green component ;AN000; | ||
| 1909 | MOV BH,6 ; ;AN000; | ||
| 1910 | MUL BH ; AX := Green * 6 ;AN000; | ||
| 1911 | MOV BH,10 ; ;AN000; | ||
| 1912 | DIV BH ; AL := (GREEN * 6) / 10 ;AN000; | ||
| 1913 | ADD DL,AL ; DL := Cumulative intensity ;AN000; | ||
| 1914 | MOV CH,AH ; CH := Cumulative remainder ;AN000; | ||
| 1915 | ;AN000; | ||
| 1916 | ;-------Calculate Red component ;AN000; | ||
| 1917 | MOV AL,RGB.R ; AL := Red component ;AN000; | ||
| 1918 | MOV BH,3 ; ;AN000; | ||
| 1919 | MUL BH ; AX := Red * 3 ;AN000; | ||
| 1920 | MOV BH,10 ; ;AN000; | ||
| 1921 | DIV BH ; AL := (RED * 3) / 10 ;AN000; | ||
| 1922 | ADD DL,AL ; DL := Cumulative intensity ;AN000; | ||
| 1923 | ADD CH,AH ; CH := Cumulative remainder ;AN000; | ||
| 1924 | ;AN000; | ||
| 1925 | ;-------Calculate Blue component ;AN000; | ||
| 1926 | MOV AL,RGB.B ; AX := Blue component ;AN000; | ||
| 1927 | XOR AH,AH ; ;AN000; | ||
| 1928 | DIV BH ; AL := BLUE / 10 ;AN000; | ||
| 1929 | ADD DL,AL ; DL := Cumulative intensity ;AN000; | ||
| 1930 | ADD CH,AH ; CH := Cumulative remainder ;AN000; | ||
| 1931 | ;AN000; | ||
| 1932 | ;-------Adjust intensity with cumulative remainder ;AN000; | ||
| 1933 | XOR AX,AX ;AN000; | ||
| 1934 | MOV AL,CH ; AX := Cumulative remainder ;AN000; | ||
| 1935 | MOV BH,10 ; BH := 10 ;AN000; | ||
| 1936 | DIV BH ; AL := Total remainder / 10 ;AN000; | ||
| 1937 | ADD DL,AL ; DL := Cumulative intensity ;AN000; | ||
| 1938 | .IF <AH GT 4> ; If remainder > 4 ;AN000; | ||
| 1939 | .THEN ; Then, add 1 ;AN000; | ||
| 1940 | INC DL ; to the intensity ;AN000; | ||
| 1941 | .ENDIF ;AN000; | ||
| 1942 | ;AN000; | ||
| 1943 | ;-------Adjust darkness ;AN000; | ||
| 1944 | ADD DL,DS:[BP].DARKADJUST_VALUE ;AN000; | ||
| 1945 | ;AN000; | ||
| 1946 | ;-------Return result ;AN000; | ||
| 1947 | MOV AL,DL ; AL := sum of R,G,B intensities ;AN000; | ||
| 1948 | ;AN000; | ||
| 1949 | RGB2INT_END: ;AN000; | ||
| 1950 | POP DX ;AN000; | ||
| 1951 | POP CX ;AN000; | ||
| 1952 | POP BX ;AN000; | ||
| 1953 | RET ;AN000; | ||
| 1954 | RGB2INT ENDP ;AN000; | ||
| 1955 | ;AN000; | ||
| 1956 | PAGE ;AN000; | ||
| 1957 | ;============================================================================== ;AN000; | ||
| 1958 | ; ;AN000; | ||
| 1959 | ; RGB2BAND: MAP RED GREEN BLUE VALUES TO A "SELECT COLOR BAND" MASK FOR ;AN000; | ||
| 1960 | ; THE COLOR PRINTER. ;AN000; | ||
| 1961 | ; ;AN000; | ||
| 1962 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 1963 | ; ;AN000; | ||
| 1964 | ; INPUT: RGB.R = A RED value (0-63) ;AN000; | ||
| 1965 | ; RGB.G = A GREEN value (0-63) ;AN000; | ||
| 1966 | ; RGB.B = A BLUE value (0-63) ;AN000; | ||
| 1967 | ; BP = Offset of the Shared Data Area. ;AN000; | ||
| 1968 | ; ;AN000; | ||
| 1969 | ; OUTPUT: AL = The Band Mask, one byte where: ;AN000; | ||
| 1970 | ; ;AN000; | ||
| 1971 | ; bit 0 = Color Band 1 is needed ;AN000; | ||
| 1972 | ; bit 1 = Color Band 2 is needed ;AN000; | ||
| 1973 | ; bit 2 = Color Band 3 is needed ;AN000; | ||
| 1974 | ; bit 3 = Color Band 4 is needed ;AN000; | ||
| 1975 | ; ;AN000; | ||
| 1976 | ; ;AN000; | ||
| 1977 | ; CALLED BY: SET_CGA_XLT_TAB ;AN000; | ||
| 1978 | ; SET_EGA_XLT_TAB ;AN000; | ||
| 1979 | ; SET_ROUNDUP_XLT_TAB ;AN000; | ||
| 1980 | ; SET_MODE_13H_XLT_TAB ;AN000; | ||
| 1981 | ; SET_MODE_F_XLT_TAB ;AN000; | ||
| 1982 | ; ;AN000; | ||
| 1983 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 1984 | ; ;AN000; | ||
| 1985 | ; NOTES: The RGB values in input describe a color from the screen. ;AN000; | ||
| 1986 | ; Up to 256K different colors can be described with these RGB values. ;AN000; | ||
| 1987 | ; ;AN000; | ||
| 1988 | ; On the color printer, the print ribbon is composed of 4 color bands, ;AN000; | ||
| 1989 | ; each of a different color. By overlapping these 4 bands when ;AN000; | ||
| 1990 | ; printing, more colors can be obtained. However, the number of colors ;AN000; | ||
| 1991 | ; that can be achieved by overlapping print bands is very limited (4 or ;AN000; | ||
| 1992 | ; 8 colors). ;AN000; | ||
| 1993 | ; ;AN000; | ||
| 1994 | ; THIS MODULE SELECT THE PRINTER COLOR THAT IS THE CLOSEST TO THE ;AN000; | ||
| 1995 | ; DESIRED SCREEN COLOR. ;AN000; | ||
| 1996 | ; ;AN000; | ||
| 1997 | ; The Band Mask specifies which color bands have to be overlapped to ;AN000; | ||
| 1998 | ; obtain a color on the printer. ;AN000; | ||
| 1999 | ; ;AN000; | ||
| 2000 | ; ;AN000; | ||
| 2001 | ; DESCRIPTION: Go through the list of printer colors in the SHARED DATA ;AN000; | ||
| 2002 | ; AREA, for each of these colors, compare its RGB values with those in ;AN000; | ||
| 2003 | ; input. ;AN000; | ||
| 2004 | ; Get the BAND_MASK of the closest printer color. ;AN000; | ||
| 2005 | ; ;AN000; | ||
| 2006 | ; LOGIC: ;AN000; | ||
| 2007 | ; ;AN000; | ||
| 2008 | ; Locate the printer colors info structure in the shared data area: ;AN000; | ||
| 2009 | ; COLORPRINT_PTR := BP + COLORPRINT_PTR ;AN000; | ||
| 2010 | ; ;AN000; | ||
| 2011 | ; Get the number of printer colors from the COLORPRINT info in the Shared ;AN000; | ||
| 2012 | ; data area: ;AN000; | ||
| 2013 | ; Number of colors := COLORPRINT_PTR.NUM_PRT_COLOR ;AN000; | ||
| 2014 | ; ;AN000; | ||
| 2015 | ; CURRENT_COLOR_PTR : First record in the COLORPRINT info structure ;AN000; | ||
| 2016 | ; BEST_CHOICE := CURRENT_RECORD_PTR.BAND_MASK ;AN000; | ||
| 2017 | ; MIN_DIFF := Maximum positive value ;AN000; | ||
| 2018 | ; ;AN000; | ||
| 2019 | ; FOR each printer color: ;AN000; | ||
| 2020 | ; CUR_DIFF := 0 ;AN000; | ||
| 2021 | ; (* Calculate the geometric distance between the RGB values from the *) ;AN000; | ||
| 2022 | ; (* input and those of the printer color. *) ;AN000; | ||
| 2023 | ; Red difference := (R - CURRENT_COLOR_PTR.RED) ;AN000; | ||
| 2024 | ; Red difference := Red difference * Red difference ;AN000; | ||
| 2025 | ; CUR_DIFF := CUR_DIFF + Red difference ;AN000; | ||
| 2026 | ; ;AN000; | ||
| 2027 | ; Green difference := (G - CURRENT_COLOR_PTR.GREEN) ;AN000; | ||
| 2028 | ; Green difference := Green difference * Green difference ;AN000; | ||
| 2029 | ; CUR_DIFF := CUR_DIFF + Green difference ;AN000; | ||
| 2030 | ; ;AN000; | ||
| 2031 | ; Blue difference := (B - CURRENT_COLOR_PTR.BLUE) ;AN000; | ||
| 2032 | ; Blue difference := Blue difference * Blue difference ;AN000; | ||
| 2033 | ; CUR_DIFF := CUR_DIFF + Blue difference ;AN000; | ||
| 2034 | ; ;AN000; | ||
| 2035 | ; IF CUR_DIFF < MIN_DIFF ;AN000; | ||
| 2036 | ; THEN BEGIN ;AN000; | ||
| 2037 | ; MIN_DIFF := CUR_DIFF ;AN000; | ||
| 2038 | ; BEST_CHOICE := printer color.BAND_MASK ;AN000; | ||
| 2039 | ; END ;AN000; | ||
| 2040 | ; ;AN000; | ||
| 2041 | ; CURRENT_COLOR_PTR := Offset of next color ;AN000; | ||
| 2042 | ; END (For each printer color) ;AN000; | ||
| 2043 | ; ;AN000; | ||
| 2044 | ; Return BEST_CHOICE ;AN000; | ||
| 2045 | ; ;AN000; | ||
| 2046 | ; ;AN000; | ||
| 2047 | RGB2BAND PROC NEAR ;AN000; | ||
| 2048 | PUSH AX ;AN000; | ||
| 2049 | PUSH BX ;AN000; | ||
| 2050 | PUSH CX ;AN000; | ||
| 2051 | PUSH DX ;AN000; | ||
| 2052 | ;AN000; | ||
| 2053 | ;-------Process /R (Reverse black and white) ;AN000; | ||
| 2054 | .IF <BIT DS:[BP].SWITCHES Z REVERSE_SW> ; IF reverse is OFF ;AN000; | ||
| 2055 | .THEN ; THEN REVERSE BLACK AND WHITE: ;AN000; | ||
| 2056 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2057 | ; ;AN000; | ||
| 2058 | ; REVERSE BLACK AND WHITE: ;AN000; | ||
| 2059 | ; ;AN000; | ||
| 2060 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2061 | ;-------Test if the color is BLACK ;AN000; | ||
| 2062 | .IF <RGB.R EQ BLACK_INT> AND ; If black ;AN000; | ||
| 2063 | .IF <RGB.G EQ BLACK_INT> AND ; ;AN000; | ||
| 2064 | .IF <RGB.B EQ BLACK_INT> ; ;AN000; | ||
| 2065 | .THEN ; then, replace it with the ;AN000; | ||
| 2066 | MOV BEST_CHOICE,0 ; band mask for white ;AN000; | ||
| 2067 | JMP RGB2BAND_END ; return this band mask ;AN000; | ||
| 2068 | .ELSEIF <RGB.R EQ WHITE_INT> AND ; else if, high-intensity white ;AN000; | ||
| 2069 | .IF <RGB.G EQ WHITE_INT> AND ; ;AN000; | ||
| 2070 | .IF <RGB.B EQ WHITE_INT> ; ;AN000; | ||
| 2071 | .THEN ; then, replace it with the ;AN000; | ||
| 2072 | MOV RGB.R,BLACK_INT ; RGB values of black ;AN000; | ||
| 2073 | MOV RGB.G,BLACK_INT ;AN000; | ||
| 2074 | MOV RGB.B,BLACK_INT ;AN000; | ||
| 2075 | .ELSEIF <RGB.R EQ TWO_THIRD> AND ; else if, white ;AN000; | ||
| 2076 | .IF <RGB.G EQ TWO_THIRD> AND ; ;AN000; | ||
| 2077 | .IF <RGB.B EQ TWO_THIRD> ; ;AN000; | ||
| 2078 | .THEN ; then, replace it with the ;AN000; | ||
| 2079 | MOV RGB.R,BLACK_INT ; RGB values of black ;AN000; | ||
| 2080 | MOV RGB.G,BLACK_INT ;AN000; | ||
| 2081 | MOV RGB.B,BLACK_INT ;AN000; | ||
| 2082 | .ENDIF ;AN000; | ||
| 2083 | .ENDIF ;AN000; | ||
| 2084 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2085 | ; ;AN000; | ||
| 2086 | ; CALCULATE THE GEOMETRIC DISTANCE BETWEEN THE COLORS OF THE PIXEL AND THOSE OF ;AN000; | ||
| 2087 | ; THE PRINTER: ;AN000; | ||
| 2088 | ; ;AN000; | ||
| 2089 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2090 | MOV BX,DS:[BP].COLORPRINT_PTR ; BX := OFFSET of COLORPRINT ;AN000; | ||
| 2091 | ADD BX,BP ;AN000; | ||
| 2092 | MOV MIN_DIFF,7FFFh ; No match yet, minimum diff. ;AN000; | ||
| 2093 | ; is maximum POSITIVE value. ;AN000; | ||
| 2094 | XOR CX,CX ;AN000; | ||
| 2095 | MOV CL,DS:[BP].NUM_PRT_COLOR ; CX := Number of print colors ;AN000; | ||
| 2096 | ;AN000; | ||
| 2097 | ;AN000; | ||
| 2098 | INSPECT_1_PRINT_COLOR: ;AN000; | ||
| 2099 | MOV CUR_DIFF,0 ; Current difference := 0 ;AN000; | ||
| 2100 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2101 | ; Calculate the Red difference: ;AN000; | ||
| 2102 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2103 | MOV AL,RGB.R ;AN000; | ||
| 2104 | SUB AL,[BX].RED ;AN000; | ||
| 2105 | ;-------Elevate at the power of two ;AN000; | ||
| 2106 | MOV DL,AL ; DX := Red difference ;AN000; | ||
| 2107 | IMUL DL ; AX := Red diff. square ;AN000; | ||
| 2108 | ADD CUR_DIFF,AX ; CURR_DIF + Red diff. ;AN000; | ||
| 2109 | ;AN000; | ||
| 2110 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2111 | ; Calculate the Green difference: ;AN000; | ||
| 2112 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2113 | MOV AL,RGB.G ;AN000; | ||
| 2114 | SUB AL,[BX].GREEN ;AN000; | ||
| 2115 | ;-------Elevate at the power of two ;AN000; | ||
| 2116 | MOV DL,AL ; DX := Red difference ;AN000; | ||
| 2117 | IMUL DL ; AX := Red diff. square ;AN000; | ||
| 2118 | ADD CUR_DIFF,AX ; CURR_DIF + Green diff. ;AN000; | ||
| 2119 | ;AN000; | ||
| 2120 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2121 | ; Calculate the Blue difference: ;AN000; | ||
| 2122 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2123 | MOV AL,RGB.B ;AN000; | ||
| 2124 | SUB AL,[BX].BLUE ;AN000; | ||
| 2125 | ;-------Elevate at the power of two ;AN000; | ||
| 2126 | MOV DL,AL ; DX := Red difference ;AN000; | ||
| 2127 | IMUL DL ; AX := Red diff. square ;AN000; | ||
| 2128 | ADD CUR_DIFF,AX ; CURR_DIF + Blue diff. ;AN000; | ||
| 2129 | ;AN000; | ||
| 2130 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2131 | ; Check how close is this print color to the screen color: ;AN000; | ||
| 2132 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2133 | MOV AX,CUR_DIFF ; If this color is better than what we ;AN000; | ||
| 2134 | .IF <AX L MIN_DIFF> ; had before. ;AN000; | ||
| 2135 | .THEN ; ;AN000; | ||
| 2136 | MOV MIN_DIFF,AX ; then, new minimum distance; ;AN000; | ||
| 2137 | MOV AL,[BX].SELECT_MASK ; get its band mask. ;AN000; | ||
| 2138 | MOV BEST_CHOICE,AL ; ;AN000; | ||
| 2139 | .ENDIF ; ;AN000; | ||
| 2140 | ;AN000; | ||
| 2141 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2142 | ; Get offset of next COLORPRINT info record: ;AN000; | ||
| 2143 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2144 | ADD BX,SIZE COLORPRINT_STR ;AN000; | ||
| 2145 | LOOP INSPECT_1_PRINT_COLOR ;AN000; | ||
| 2146 | ;AN000; | ||
| 2147 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2148 | ; BEST_CHOICE contains the print color with the closest RGB values ;AN000; | ||
| 2149 | ;------------------------------------------------------------------------------ ;AN000; | ||
| 2150 | RGB2BAND_END: ;AN000; | ||
| 2151 | POP DX ;AN000; | ||
| 2152 | POP CX ;AN000; | ||
| 2153 | POP BX ;AN000; | ||
| 2154 | POP AX ;AN000; | ||
| 2155 | MOV AL,BEST_CHOICE ;AN000; | ||
| 2156 | RET ;AN000; | ||
| 2157 | BEST_CHOICE DB ? ;AN000; | ||
| 2158 | MIN_DIFF DW ? ;AN000; | ||
| 2159 | CUR_DIFF DW ? ;AN000; | ||
| 2160 | RGB2BAND ENDP ;AN000; | ||
| 2161 | CODE ENDS ;AN000; | ||
| 2162 | END ;AN000; | ||