home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / info / dostips1.arc / DOSCOLOR.TXT < prev    next >
Encoding:
Text File  |  1985-11-25  |  23.1 KB  |  626 lines

  1.                           DOS 2.0 COLOR
  2.          (Star-Dot-Star PC World Vol 2 No 4 April 1984)
  3.  
  4.      BASIC provides a COLOR statement; but DOS 2.0 does not.
  5. However, the DOS 2.0 command PROMPT is used to implement ANSI.SYS 
  6. escape sequences.  This is possible because the PROMPT command 
  7. uses $e to represent the ESCape code 27, which cannot be entered 
  8. from the keyboard.
  9.      Copy and save the batch file in the listing COLOR.BAT.  In 
  10. addition to the batch file, create a CONFIG.SYS file named
  11. containing the line DEVICE=ANSI.SYS.  (You will also need the
  12. file ANSI.SYS, from your DOS 2.0 disk, on this disk.)  Now reboot
  13. your PC to install the ANSI.SYS driver.
  14.      COLOR.BAT can now be used to set screen colors.  The command 
  15. COLOR GREEN, for example, sets the display's characters to green, 
  16. and the command COLOR BBLUE turns the background blue, keeping 
  17. the current foreground (character) color.  Notice that the letter 
  18. B, indicating background, is prefixed to the name of the color.
  19.      You can use more than one parameter in the same command, for 
  20. example, COLOR GREEN BBLUE; however, if the foreground and
  21. background colors are the same, the characters will be invisible.  
  22. Because all the background colors provided by COLOR.BAT are low 
  23. intensity, you can restore visible characters by entering the 
  24. command COLOR BRIGHT.  (Work carefully, because what you type is 
  25. invisible at this point.)  This command sets the current
  26. foreground color to high intensity.  
  27.      To change characters from low intensity blue to high
  28. intensity green, use the command COLOR BRIGHT GREEN.  When
  29. changing characters from high to low intensity, you must include
  30. the name of the color after the parameter NORMAL (for example,
  31. COLOR NORMAL CYAN) since the command COLOR NORMAL (without
  32. specifying a color), merely returns the display to its usual
  33. appearance.
  34.      COLOR.BAT also works with the monochrome monitor to provide 
  35. normal, bright (high intensity), and inverse video characters.  
  36. COLOR.BAT can easily be modified to include blinking or
  37. underlining on the monochrome monitor.  A table of the SGR (Set
  38. Graphics Rendition) escape code sequences are in the DOS manual.
  39.      You can also combine PROMPT and other escape codes in batch 
  40. files to define strings for key combinations such as <Alt>-<F1> 
  41. or <Ctrl>-<F10> -- a poor man's version of ProKey.  The following 
  42. can be placed in a batch file, which then assigns the string DIR 
  43. B: (with no carriage return) to <Alt>-B.
  44.           prompt $e[0;48;"DIR B:"p
  45.           prompt
  46.      Note that there is no semicolon after the second set of 
  47. quotation marks, despite the SGR syntax shown in the
  48. documentation.  If the semicolon is included before the final p,
  49. unexpected results occur.  ASCII and extended ASCII codes can be
  50. found in the Technical Reference manual.  If you don't have a
  51. manual, they are also in Appendix G of the BASIC manual.
  52.      Unfortunately, many programs have their own keyboard and 
  53. screen display routines, and the ANSI.SYS driver is locked out 
  54. while these programs are active.  Hopefully, they restore the 
  55. previous state upon termination.  BASICA and Peachtext are two 
  56. programs that behave this way.
  57. COLOR.BAT:
  58.  
  59. goto %1
  60. :normal
  61.  prompt $e[0m
  62.  goto exit
  63. :bright
  64.  prompt $e[1m
  65.  goto exit
  66. :reverse
  67.  prompt $e[7m
  68.  goto exit
  69. :black
  70.  prompt $e[30m
  71.  goto exit
  72. :red
  73.  prompt $e[31m
  74.  goto exit
  75. :green
  76.  prompt $e[32m
  77.  goto exit
  78. :yellow
  79.  prompt $e[33m
  80.  goto exit
  81. :blue
  82.  prompt $e[34m
  83.  goto exit
  84. :magenta
  85.  prompt $e[35m
  86.  goto exit
  87. :cyan
  88.  prompt $e[36m
  89.  goto exit
  90. :white
  91.  prompt $e[37m
  92.  goto exit
  93. :bblack
  94.  prompt $e[40m
  95.  goto exit
  96. :bred
  97.  prompt $e[41m
  98.  goto exit
  99. :bgreen
  100.  prompt $e[42m
  101.  goto exit
  102. :byellow 
  103.  prompt $e[43m
  104.  goto exit
  105. :bblue
  106.  prompt $e[44m
  107.  goto exit
  108. :bmagenta
  109.  prompt $e[45m
  110.  goto exit
  111. :bcyan
  112.  prompt $e[46m
  113.  goto exit
  114. :bwhite
  115.  prompt $e[47m
  116.  goto exit
  117. :exit
  118.  shift
  119.  if not .==.%1 goto %1
  120.  prompt
  121.  echo off
  122.  cls
  123.  goto done
  124. :help
  125.  .ANSI.SYS and CONFIG.SYS (containing 
  126.  . the line DEVICE=ANSI.SYS) must be 
  127.  . accessible when the PC is booted.
  128.  .Type COLOR and then your choice of
  129.  . character, intensity, and/or back-
  130.  . ground color(s) selected from the
  131.  . following list of parameters:
  132.  .For color displays:
  133.  .      black           bblack
  134.  .      red             bred
  135.  .      green           bgreen
  136.  .      yellow          byellow
  137.  .      blue            bblue
  138.  .      magenta         bmagenta
  139.  .      cyan            bcyan
  140.  .      white           bwhite
  141.  .For color and monochrome displays:
  142.  .      normal
  143.  .      bright
  144.  .      reverse
  145. :done
  146.  
  147. ------------------------------------------------------------------
  148.                           Hi-Res Magic
  149.         (PC Magazine Vol 3 No 8 May 1, 1984 User-to-User)
  150.  
  151.      The program below displays unusual color effects on RGB 
  152. monitors.  If you want to be extremely weird, you can use OUT 
  153. &H3D8,8 in line 130, but the characters as well as the line 
  154. graphics will appear as "flags".  For an even better display, 
  155. include these additional three lines and tap any key a few times.  
  156. Then hit any key several times and watch the effect.
  157.  
  158. 250 I$=INKEY$:IF I$="" THEN 250 ELSE K=(K-1) MOD 128
  159. 260 OUT 985,K
  160. 270 GOTO 250
  161. - - - - - - - -
  162.  
  163. 100 'Hi-Res Color Demo
  164. 110 SCREEN 2:WIDTH 80:KEY OFF:CLS
  165. 120 OUT 985,0
  166. 130 OUT &H3D8,10
  167. 140 LOCATE 20,2
  168. 150 PRINT "0000 0001 0010 0011 0100 0101 0110 0111 ";
  169. 160 PRINT "1000 1001 1010 1011 1100 1101 1110 1111"
  170. 170 FOR COLR=0 TO 15
  171. 180 FOR N=0 TO 9
  172. 190 X=(40*COLR)+(4*N)
  173. 200 IF COLR    >7 THEN LINE (X,0)  -(X,150)
  174. 210 IF COLR AND 4 THEN LINE (X+1,0)-(X+1,150)
  175. 220 IF COLR AND 2 THEN LINE (X+2,0)-(X+2,150)
  176. 230 IF COLR AND 1 THEN LINE (X+3,0)-(X+3,150)
  177. 240 NEXT:NEXT
  178.  
  179. -----------------------------------------------------------------
  180.                      Changing Border Colors
  181.        (PC Magazine Vol 3 No 24 Dec 11, 1984 User-to-User)
  182.  
  183.      Many programs allow you to adjust the foreground and
  184. background colors, but few offer the option to set border colors.
  185. So even if you can change the main colors, you end up running the 
  186. program against a black border.  A short BORDER.COM can be created 
  187. using DEBUG to do this nicely.  To see the results of this file, 
  188. get into DOS, type BORDER, and hit Enter.
  189.  
  190. A>DEBUG
  191. -n BORDER.COM
  192. -e100
  193. xxxx:0100  5A.B0  8A.03  C7.BA  0A.D9  C0.03  74.EE  01.CD  C3.20
  194. -rcx
  195. CX 0000
  196. :8
  197. -w
  198. Writing 0008 bytes
  199. -q
  200.  
  201.      The border color in this case is light blue, but you can 
  202. create different borders by substituting numbers other than 03 
  203. after the 8A. If you do this, give you different colored files 
  204. different names; do this by substituting other names in the -n 
  205. line.
  206.  
  207. -----------------------------------------------------------------
  208.                       Adding a Bit of Color
  209.         (PC Magazine Vol 4 No 9 April 30, 1985 PC Tutor)
  210.  
  211.      ....add color output to software packages that weren't
  212. originally written to support it.  According to the IBM Technical 
  213. Reference manual, write an I/O command to port address 3D9.  This 
  214. port is the Color Select Register of the IBM color card.  It
  215. allows setting a border color in alphanumeric modes, and that's 
  216. about it.  The functions of the bits addressed by this port are:
  217.           Bits 0-2: B/G/R select the border color
  218.           Bit 3: Intensify border color 
  219. These 4 bits select the border color in alphanumeric modes.  (In 
  220. graphics mode these bits set the background color.)
  221.           Bit 4: Select alternate background color set
  222. This selects an intensified set of background colors in
  223. alphanumeric and graphics modes.
  224.           Bit 5: Color palette select (graphics only)
  225. This selects the set of screen colors (cyan/magenta/white) or 
  226. (green/red/yellow).
  227.      The 3D9 port is not going to be much use in character modes, 
  228. except to set up a border color.  The following program, created 
  229. with DEBUG.COM, will set a dark-blue border when used with the 
  230. normal IBM color monitor and color board.
  231.           A>DEBUG BORDER.COM
  232.           -file not found
  233.           -A100
  234.           xxxx:0100   MOV   AL,1
  235.           xxxx:0102   MOV   DX,3D9
  236.           xxxx:0105   OUT   DX,AL
  237.           xxxx:0106   MOV   AX,4C00
  238.           xxxx:0109   INT   21
  239.           xxxx:010B <Enter>
  240.           -R CX
  241.           CX 0000
  242.           :0012
  243.           -W
  244.           -Q
  245.      More satisfactory methods for color output can range from 
  246. simple to complex.  The simplest answer is to just clear the 
  247. screen to the desired color and then proceed, hoping that your 
  248. program does not alter the screen coloring.  A tougher approach
  249. is to use the ANSI.SYS method of sending escape sequences to set 
  250. screen color.  The final approach requires actually modifying the 
  251. program in question to achieve color.
  252.      To see whether the simple approach will work, try entering 
  253. this program:
  254.           A>DEBUG SCR.COM
  255.           file not found
  256.           -A100
  257.           1E9F:0100   MOV   AX,600
  258.           1E9F:0103   MOV   CX,0
  259.           1E9F:0106   MOV   DX,183F
  260.           1E9F:0109   MOV   BH,03
  261.           1E9F:010B   INT   10
  262.           1E9B:010D   MOV   AX,4C00
  263.           1E9F:0110   INT   21
  264.           -R CX
  265.           CX 0000
  266.           :0020
  267.           -W
  268.           -Q
  269. Once you have created this program, you can just run it by name: 
  270. at the A> simply type SCR. On a color display, it will change the 
  271. screen color.  The value 03 here for the screen color (light blue 
  272. on black background) can be changed to other combinations of 
  273. color settings.
  274.  
  275. -----------------------------------------------------------------
  276.                        Color-Conscious CLS
  277.        (PC Magazine Vol 4 No 14 July 9, 1985 User-to-User)
  278.  
  279.      Users of RGB monitors often use utilities such as Peter
  280. Norton's SCRATR to set screen colors while in DOS.  Unfortunately, 
  281. the DOS CLS command not only clears the screen, it also resets 
  282. the color adaptor back to the default white on black.  Even
  283. Norton's CLEAR.COM program has the same effect.  The short CL.COM 
  284. program provides a solution to this problem.  It will clear the 
  285. screen but will not change the current screen attributes.
  286. - - - - -
  287. A>debug cl.com
  288. File not found
  289. -a 100
  290. xxxx:0100  mov ah,08
  291. xxxx:0102  mov,bh,00
  292. xxxx:0104  int 10
  293. xxxx:0106  mov bh,ah
  294. xxxx:0108  mov ax,0600
  295. xxxx:010B  mov cx,0000
  296. xxxx:010E  mov dx,184f
  297. xxxx:0111  int 10
  298. xxxx:0113  mov ah,02
  299. xxxx:0115  mov bh,00
  300. xxxx:0117  mov dx,0000
  301. xxxx:011A  int 10
  302. xxxx:011C  int 20
  303. xxxx:011E
  304. -rcx
  305. CX 0000
  306. :le
  307. -w
  308. Writing 001E bytes
  309. -q
  310. - - - - -
  311.      Editor's Note: CL.COM is an improvement over the CLS command 
  312. for users with color systems.  Most of us rely on a User-to-User 
  313. oldie called COLOR.COM, which sets the colors and clears the 
  314. screen.  The COLOR.COM program sets screen colors in DOS.  Don't 
  315. actually enter ## and ** -- instead pick the colors you want by 
  316. substituting the proper hex value of the background/foreground 
  317. colors.  For blue letters on white, replace the ## with 71; for 
  318. white on blue replace it with 17; for brown on red, replace it 
  319. with 46.  Then replace the ** with the hex value of the border 
  320. color.  For a light-blue border, replace the ** with 03; for light 
  321. green, replace it with 02; for bright red, replace it with 0C.
  322.  
  323. A>debug
  324. -n color.com
  325. -e 100 2b c0 1e 50 b8 03 00 cd 10 b8 00 06 b9 00 00 ba
  326. -e 110 50 20 b7 ## cd 10 b4 02 ba 00 00 b7 00 cd 10 b0
  327. -e 120 ** ba d9 03 ee cd 20
  328. -rcx
  329. CX 0000
  330. :27
  331. -w
  332. Writing 0027 bytes
  333. -q
  334.  
  335. Note:  For another method and programs to use, see the ANSICOL.BAS and
  336. and ANSIMAKR.BAS programs along with the ANSIMAKR.DOC file.
  337.  
  338. -----------------------------------------------------------------
  339.                         Color Me Anything
  340.          (PC Magazine Vol 4 No 20 Oct 1, 1985 PC Tutor)
  341.  
  342.      To change background and foreground display colors at the DOS
  343. command level, use the PROMPT command to write the ANSI control
  344. sequences that color the display.  Be certain ANSI.SYS and a CONFIG.SYS
  345. file with the line: DEVICE=ANSI.SYS are in the root directory.  Then,
  346. to create yellow on blue with a distinctive magenta DOS prompt, for
  347. example, use the prompt: PROMPT $e[35;44;1m$p$g$e[33;44;1m.  The
  348. initial $e is PROMPT's lingo for the Escape code needed by ANSI.SYS,
  349. and the table below shows the numbers for ANSI.SYS screen attribute
  350. control sequences for the PROMPT command.
  351.  
  352. $e[#;...;#m where # is shown below:
  353.   Normal white on black:          0
  354.   High intensity:                 1
  355.   Monochrome display underline:   4
  356.   Blink:                          5
  357.   Reverse video:                  7
  358.   Invisible:                      8
  359.  
  360.           Foreground  Background
  361.   Black:       30         40
  362.   Red:         31         41
  363.   Green:       32         42
  364.   Yellow:      33         43
  365.   Blue:        34         44
  366.   Magenta:     35         45
  367.   Cyan:        36         46
  368.   White:       37         47
  369.  
  370. -----------------------------------------------------------------
  371.                         Better DOS Colors
  372.        (PC Magazine Vol 4 No 23 Nov 12, 1985 User-to-User)
  373.  
  374.      The CSET.COM program, created with DEBUG, allows foreground,
  375. background and border colors on an RGB monitor to be set.  The DOS CLS
  376. command wipes out the colors set by CSET, so instead of using CLS, use
  377. CSET to clear the screen.  To enter your own border color, replace the
  378. * with a hex number from 0 to F (where 1=blue, 2=green, ...F=high-
  379. intensity white).  To enter the foreground (text) and background
  380. colors, replace the ## with a two-digit hex number from 00 to FF.  To
  381. calculate this number, multiply the background color by 16 and add it
  382. to the foreground, and convert the total to hex -- or simply use the
  383. individual hex values of the background as the first digit and the
  384. foreground as the second digit.
  385.  
  386. A>DEBUG CSET.COM
  387. File not found
  388. -A 100
  389. xxxx:0100  SUB   AX,AX
  390. xxxx:xxxx  PUSH  DS
  391. xxxx:xxxx  PUSH  AX
  392. xxxx:xxxx  MOV   AX,0003
  393. xxxx:xxxx  INT   10
  394. xxxx:xxxx  MOV   AX,0B00
  395. xxxx:xxxx  MOV   BX,000*
  396. xxxx:xxxx  INT   10
  397. xxxx:xxxx  MOV   AX,0600
  398. xxxx:xxxx  MOV   CX,0000
  399. xxxx:xxxx  MOV   DX,2050
  400. xxxx:xxxx  MOV   BH,##
  401. xxxx:xxxx  INT   10
  402. xxxx:xxxx  MOV   AH,02
  403. xxxx:xxxx  MOV   DX,0000
  404. xxxx:xxxx  MOV   BH,00
  405. xxxx:xxxx  INT   10
  406. xxxx:xxxx  RETF
  407. xxxx:xxxx
  408. -R CX
  409. CX 0000
  410. :00xx
  411. -W
  412. Writing xxxx bytes
  413. -Q
  414.  
  415. -----------------------------------------------------------------
  416.                             Color CLS
  417.        (PC Magazine Vol 4 No 25 Dec 10, 1985 User-to-User)
  418.  
  419.      The instructions below allow DOS users to patch COMMAND.COM so
  420. that CLS will set the screen to any color.  This will work on both the
  421. standard and enhanced color graphics cards, and on the PC and AT.
  422.      If you don't mind a black border, just use DEBUG to edit the
  423. appropriate screen attribute byte.  Figure 1 below is instructions to
  424. patch just the foreground and background DOS 2.1 COMMAND.COM CLS
  425. command.  With this patch the screen reverts to bright yellow text on
  426. a blue background whenever you type in CLS.  You will no longer need
  427. a small .COM file or ANSI.SYS to run DOS in color.  If you do use
  428. ANSI.SYS, the patch will be overridden.
  429.      Figure 2 includes patches to change the border colors of all
  430. versions of DOS 2.0 and higher.  Complications arise in each version
  431. because the original CLS command selects black as the border color by
  432. XORing the BX register.  Inserting extra code to MOVe the desired
  433. number into the register would lengthen COMMAND.COM by one byte.  This
  434. was avoided by rearranging the code of the CLS portion of COMMAND.COM
  435. and taking advantage of a zero that is left in the BH register.
  436. Figures 3 and 4 show the before and after CLS addresses.
  437.      The border patch won't work on an EGA configured for the high-
  438. resolution 640 by 370 mode; BIOS prevents a border color from being
  439. set in this mode.  It can be set, however, if the standard RGB monitor
  440. is attached.
  441.      If you want to make additional color changes, edit the bytes
  442. shown in the table in Figure 4.  If you are using a patched version
  443. of COMMAND.COM and are prompted to insert a disk containing COMMAND.COM
  444. in drive A:, you must insert a disk containing the patched version.
  445.      Editor's Note: It's fairly easy to use colors other than the ones
  446. in the example (as shown here, an attribute byte of 1E and a border of
  447. 01 yields borth a border and background of dark blue with intense
  448. yellow text).  The two-character hex attribute byte stores the
  449. foreground as the rightmost character and the background as the
  450. leftmost character.  Pick a hex numbe from 0 to F for each, where
  451. 0 = black, 1 = blue, 2 = green, 3 = light blue (cyan), 4 = red,
  452. 5 = purple (magenta), 6 = either brown or yellow depending on your
  453. monitor (IBM's monitor produces a true brown; others may not),
  454. 7 = grayish white, 8 = dark gray, 9 = bright blue; A = bright green,
  455. B = bright light blue, C = bright red, D = bright purple, E = bright
  456. yellow, and F = overintense white.  So green text on a purple
  457. background would be 52, and bright red text on a light blue background
  458. would be 3C.  The border color is obviously just a single character
  459. from the above list.
  460.  
  461. Figure 1:  DOS 2.1 screen color change; black border
  462.  
  463. A>debug command.com
  464. -e 2539 1e
  465. -w
  466. Writing 4580 bytes
  467. -q
  468.  
  469. Figure 2: Change border and screen attributes
  470.  
  471. DOS 2.0:                          DOS 2.1:
  472.  
  473. A>debug command.com               A>debug command.com
  474. -E 2346 1E                        -E 2359 1E
  475. -M CS:2337 2352 CS:2331           -M CS:234A 2365 CS:2344
  476. -A 234d                           -A 2360
  477. xxxx:234D MOV BL,01               xxxx:2360 MOV BL,01
  478. xxxx:234F MOV AH,0B               xxxx:2362 MOV AH,0B
  479. xxxx:2351                         xxxx:2364
  480. -W                                -W
  481. Writing 4500 bytes                Writing 4580 bytes
  482. -Q                                -Q
  483.  
  484. DOS 3.0:                          DOS 3.1
  485.  
  486. A>debug command.com               A>debug command.com
  487. -E 2428 1E                        -E 2642 1E
  488. -M CS:2418 2434 CS:2412           -M CS:2632 264E CS:262C
  489. -A 242F                           -A 2649
  490. xxxx:242F MOV BL,01               xxxx:2649 MOV BL,01
  491. xxxx:2431 MOV AH,0B               xxxx:264B MOV AH,0B
  492. xxxx:2433                         xxxx:264D
  493. -W                                -W
  494. Writing 561A bytes                Writing 5AAA bytes
  495. -Q                                -Q
  496.  
  497. Figure 3: Standard patches before the border patch is made to
  498.           COMMAND.COM
  499.  
  500.   DOS        Location of        Address of Screen
  501. Version      CLS Command         Attribute Byte
  502.  
  503.   2.0         2331-2353              2346
  504.   2.1         2344-2366              2359
  505.   3.0         2412-2345              2428
  506.   3.1         262C-264F              2642
  507.  
  508. Figure 4: New addresses after border patch
  509.  
  510.   DOS      Address of Screen    Address of Border
  511. Version     Attribute Byte       Attribute Byte
  512.  
  513.   2.0           2340                 234E
  514.   2.1           2353                 2361
  515.   3.0           2422                 2430
  516.   3.1           263C                 264A
  517.  
  518. -----------------------------------------------------------------
  519.                       Bordering on Madness
  520.          (PC Magazine Vol 4 No 26 Dec 24, 1985 PC Tutor)
  521.  
  522.      Preference for color control at the DOS command level is to
  523. install ANSI.SYS and use the PROMPT command (see PC Mag Vol 4 No 20
  524. PC Tutor "Color Me Anything" above).  But you need not run COLOR.COM
  525. (see PC Mag Vol 4 No 14 PC Tutor "Color-Conscious CLS" above) if you
  526. have ANSI.SYS installed.  ANSI.SYS maintains its own default video
  527. color attribute, which starts out as white on black.  Until that
  528. attribute is changed (as with the PROMPT command), it will display
  529. white on black no matter what COLOR.COM tries to do.
  530.      A read advantage of using ANSI.SYS is that it will not wipe out
  531. the border when you clear the screen with CLS.  However, many programs
  532. reset the video mode (wiping out the border) when they load.
  533. KBORDER.COM changes the border color with a couple of keystrokes.
  534.      Create KBORDER.COM using DEBUG 2.0 or later.  Don't run the
  535. program while in DEBUG.  Quit DEBUG first and then run it.  The
  536. program will remain resident in memory until you reboot.
  537.      After KBORDER.COM is loaded, you can hold down the Ctrl key and
  538. press the < key to step through all 16 border colors.  Ctrl > steps
  539. backward through these border colors.  It will work within most
  540. programs but not those (like XyWrite) that hog the keyboard interrupt.
  541.      If a PC display is in medium-resolution graphics mode, KBORDER
  542. changes the background color.  In high-resolution mode on a PC (which
  543. is normally white on black), KBORDER changes the foreground color.
  544. This provides a little variety when working with Microsoft Word or
  545. other programs that use high-resolution graphics.
  546.      It's easy to return the border to the color you like best after
  547. it's been clobbered.  Just type Ctrl < and Ctrl > quickly in
  548. succession.
  549.      The CLS command works differently depending on whether ANSI.SYS
  550. has been loaded or not.  Although seemingly a simple command, CLS has
  551. the unique distinction of being the only internal DOS command that
  552. calls the BIOS directly.  All other internal commands use only DOS
  553. calls.  Since the use of a BIOS call from within COMMAND.COM clearly
  554. violates the hierarchical structure of DOS, COMMAND.COM tries to avoid
  555. having to do so.  If ANSI.SYS is loaded, COMMAND.COM executes CLS by
  556. simply sending the ANSI.SYS ED (Erase in Display) sequence to the
  557. display through DOS.  ANSI.SYS intercepts this sequence and colors the
  558. whole screen with the last screen attribute.  It does nothing to the
  559. border.
  560.      If standard output has been redirected from the screen to another
  561. device (as with the CTTY command) or to a file, COMMAND.COM also avoids
  562. using BIOS calls for CLS.  For instance, try running the command:
  563. CLS > CLRSCRN.  Whether ANSI.SYS is loaded or not, COMMAND.COM will
  564. create a file called CLRSCRN, which contains the 4-byte ANSI ED
  565. sequence for clearing your screen.  If you then enter:  TYPE CLRSCRN
  566. your screen will be cleared if you have ANSI.SYS loaded.  If not,
  567. you'll just see the ANSI sequence displayed on your screen.
  568.      Only if COMMAND.COM actually has to clear your display -- without
  569. the benefit of ANSI.SYS to do the work -- will it make the BIOS calls
  570. to set the background to black and wipe out the border.  This is a
  571. more literal interpretation of "Clear Screen" than most of us would
  572. prefer.
  573.  
  574. A>DEBUG
  575. -A
  576. :0100 JMP   013E
  577. :0102 DB    0
  578. :0103 DW    0,0
  579. :0107 STI
  580. :0108 PUSH  AX
  581. :0109 PUSH  BX
  582. :010A PUSH  DS
  583. :010B CS:
  584. :010C MOV   BL,[0102]
  585. :0110 IN    AL,60
  586. :0112 CMP   AL,33
  587. :0114 JZ    011E
  588. :0116 CMP   AL,34
  589. :0118 JNZ   0136
  590. :011A DEC   BL
  591. :011C JMP   0120
  592. :011E INC   BL
  593. :0120 AND   BL,0F
  594. :0123 MOV   AH,2
  595. :0125 INT   16
  596. :0127 TEST  AL,4
  597. :0129 JZ    0136
  598. :012B CS:
  599. :012C MOV   [0102],BL
  600. :0130 SUB   BH,BH
  601. :0132 MOV   AH,0B
  602. :0134 INT   10
  603. :0136 POP   DS
  604. :0137 POP   BX
  605. :0138 POP   AX
  606. :0139 CS:
  607. :013A JMP   FAR [0103]
  608. :013E MOV   AX,3509
  609. :0141 INT   21
  610. :0143 MOV   [0103],BX
  611. :0147 MOV   [0105],ES
  612. :014B MOV   DX,0107
  613. :014E MOV   AX,2509
  614. :0151 INT   21
  615. :0153 MOV   DX,013E
  616. :0156 INT   27
  617. :0158
  618. -N KBORDER.COM
  619. -R CX
  620. CX 0000
  621. :0058
  622. -W
  623. Writing 0058 bytes
  624. -Q
  625.  
  626.