home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TJOCKREF.ZIP / FASTTTT.TXT < prev    next >
Encoding:
Text File  |  1988-08-26  |  19.7 KB  |  657 lines

  1. !SHORT:Attr              Combine frgrnd and bkgrnd colors as single attribute byte
  2. Attr                                                           FastTTT
  3.      
  4.  
  5.  
  6. Purpose   To combine foreground and background colors as a single
  7.           attribute byte.
  8.  
  9. Result type    byte;
  10.  
  11. Declaration    Attr(F,B:byte):byte;
  12.                     
  13.           F is the foreground color (0..15)
  14.           B is the background color (0..15)
  15.  
  16. Uses FastTTT.
  17.  
  18. Remarks   The video memory for an 80 by 25 character screen is
  19.           composed of 2000 bytes of data. There is an attribute byte
  20.           and a character byte for each of the 1000 character
  21.           positions on the screen. This simple function will combine a
  22.           foreground color (F) with a background color (B) to form a
  23.           single attribute byte.
  24.                
  25. The valid color ranges are 0 to 15. (Refer to Appendix B for
  26. a color table.)
  27.                
  28. If a background color is set greater than 7 then "flashing"
  29. characters will result.
  30.  
  31.  
  32. Example
  33.  
  34.  
  35.                USES FASTTTT;
  36.                VAR MSG_COL : BYTE;
  37.                BEGIN
  38.                  MSG_COL := ATTR(15,4);
  39.                END.
  40.      
  41.  
  42. The color attribute MSG_COL would be set to white on a red background.
  43. !SEEALSO:FastWrite PlainWrite
  44.  
  45.  
  46. !SHORT:Box               Draw a rectangle or box on screen
  47. Box                                                            FastTTT
  48.           
  49.  
  50.  
  51. Purpose   To draw a rectangle or box on the screen.
  52.  
  53. Declaration    Box(X1,Y1,X2,Y2,F,B,Boxtype: byte);
  54.                     
  55.           X1 is the top left X coordinate (1..79)
  56.           Y1 is the top left Y coordinate (1..24)
  57.           X2 is lower right X coordinate (2..80)
  58.           Y2 is lower right Y coordinate (2..25)
  59.           F is the foreground color (0..15)
  60.           B is the background color (0..15)
  61.           Boxtype is the box line type (see remarks)
  62.  
  63. Uses FastTTT.
  64.  
  65. Remarks   The area inside the box is not cleared.
  66.                     
  67.           The normal values for the Boxtype are:
  68.                1    Single line
  69.                2    Double line
  70.                3    Single top/bottom, double sides
  71.                4    Double top/bottom, single sides
  72.                     
  73.           If a BoxType of 0 is passed the the procedure will use a
  74.           space (' ') as the box character. If any other number (i.e.
  75.           5..256) is used, the box is drawn using the ascii character
  76.           represented by the number. Refer to the Turbo Pascal Owner's
  77.           Handbook page 568 to see the ascii table.
  78.  
  79.  
  80.  
  81. Example
  82.  
  83.  
  84.                USES CRT, FASTTTT;
  85.                BEGIN
  86.                  CLRSCR;
  87.                  BOX(1,1,80,12,WHITE,RED,1);
  88.                  BOX(1,13,80,25,BLUE,LIGHTGRAY,2);
  89.                END.
  90.           
  91.  
  92. The screen would be cleared, a single lined box would be drawn on the
  93. top half of the screen, and a double lined box in the lower half. Note
  94. that the CRT unit was also USED - this allowed the use of ClrScr, and
  95. the colors could be referred to by name rather than their numeric
  96. code.
  97.  
  98. !SEEALSO:FBox GrowFBox
  99.       
  100. !SHORT:Clearline         Clear all text on a specific line of screen
  101. ClearLine                                                      FastTTT
  102.      
  103.  
  104.  
  105. Purpose   To clear all text on a specific line of the screen.
  106.  
  107. Declaration    ClearLine(Y,F,B:integer);
  108.                
  109.           Y is the line number on the screen to be cleared (1..25)
  110.           F is the foreground color of the blank line (0..15)
  111.           B is the background color of the blank line (0..15)
  112. Uses FastTTT.
  113.  
  114. Remarks   The actual display color of the line will be set to B. The
  115.           only reason for setting the foreground color is to change
  116.           the attribute byte, for subsequent writes.
  117.  
  118.  
  119.  
  120. Example
  121.  
  122.  
  123.                USES FASTTTT;
  124.                BEGIN
  125.                  CLEARLINE(25,15,0);
  126.                END.
  127.      
  128.  
  129. The 25th line of the screen is cleared with a black background.
  130.       
  131. !SEEALSO:ClearText
  132.  
  133.  
  134. !SHORT:ClearText         Clear all text on a rectangular section of screen
  135. ClearText                                                      FastTTT
  136.           
  137.  
  138.  
  139. Purpose   To clear all text on a rectangular section of the screen.
  140.  
  141. Declaration    ClearText(X1,Y1,X2,Y2,F,B:integer);
  142.                     
  143.           X1 is the top left X coordinate (1..79)
  144.           Y1 is the top left Y coordinate (1..24)
  145.           X2 is lower right X coordinate (2..80)
  146.           Y2 is lower right Y coordinate (2..25)
  147.           F is the foreground color of the blank line (0..15)
  148.           B is the background color of the blank line (0..15)
  149.  
  150. Uses FastTTT.
  151.  
  152. Remarks   The actual display color of the area will be set to B. The
  153.           only reason for setting the foreground color is to change
  154.           the attribute byte, for subsequent writes.
  155.  
  156.  
  157.  
  158. Example
  159.  
  160.  
  161.                USES FASTTTT;
  162.                BEGIN
  163.                  CLEARTEXT(1,1,40,25,15,0);
  164.                END.
  165.           
  166.  
  167. The lefthand side of the screen is cleared with a black background.
  168.  
  169. !SEEALSO:ClearLine PlainWrite
  170.  
  171.       
  172. !SHORT:CurrentDisplay    Used internally to determine the current type of videocard
  173. CurrentDisplay                                                 FastTTT
  174.      
  175.  
  176.  
  177. Purpose   Used internally to determine the current type of videocard.
  178.  
  179. Result    DisplayType;
  180.  
  181. Declaration    CurrentDisplay: DisplayType;
  182.                
  183.           The DisplayType is Monochrome, CGA, EGA, MCGA,  or VGA
  184.  
  185. Uses FastTTT.
  186.  
  187. Remarks   This function is used internally.
  188.  
  189. !SEEALSO:ReinitFastwrite
  190.  
  191.  
  192. !SHORT:Fastwrite         Core procedure of the unit for fast screen writes
  193. Fastwrite                                                      FastTTT
  194.           
  195.  
  196.  
  197. Purpose   The core procedure of the unit for fast screen writes.
  198.  
  199. Declaration    Fastwrit(Col, Row, Attr:byte; St: string);external
  200.  
  201.           Col is the X coord of first char. in string (1..80)
  202.           Row is the Y coord of string (1..25)
  203.           Attr is the color attribute
  204.           St is the string or text to be displayed
  205.  
  206. Uses FastTTT.
  207.  
  208. Remarks   This procedure is external and the source code is actually
  209.           in assembly language. (See the file FastTTT.asm on the
  210.           distribution disk, if you're interested.) I recommend you
  211.           use the WriteAT procedure in preference to Fastwrit, because
  212.           it can pass foreground and background colors rather then the
  213.           combined color attribute. If the text is too long to fit on
  214.           the screen, it will be wrapped onto the next line.
  215.  
  216.  
  217.  
  218. Example
  219.  
  220.  
  221.                USES FASTTTT
  222.                BEGIN
  223.                  FASTWRITE(1,1,14,'TOP LEFT OF SCREEN');
  224.                  FASTWRITE(59,25,ATTR(14,4),'BOTTOM RIGHT OF SCREEN;);
  225.                END;
  226.  
  227. !SEEALSO:Attr WriteAT PlainWrite WriteVert
  228.  
  229.  
  230.  
  231. !SHORT:Fbox              Draw a box and clear screen inside the box
  232. FBox                                                           FastTTT
  233.      
  234.  
  235.  
  236. Purpose   To draw a box and clear the screen inside the box.
  237.  
  238. Declaration    FBox(X1,Y1,X2,Y2,F,B,Boxtype:integer);
  239.                
  240.           X1 is the top left X coordinate (1..79)
  241.           Y1 is the top left Y coordinate (1..24)
  242.           X2 is lower right X coordinate (2..80)
  243.           Y2 is lower right Y coordinate (2..25)
  244.           F is the foreground color (0..15)
  245.           B is the background color (0..15)
  246.           Boxtype is the box line type (see remarks)
  247.  
  248. Uses FastTTT.
  249.  
  250. Remarks   The normal values for the Boxtype are:
  251.                1    Single line
  252.                2    Double line
  253.                3    Single top/bottom, double sides
  254.                4    Double top/bottom, single sides
  255.  
  256.           If a BoxType of 0 is passed, the procedure will use a space
  257.           (' ') as the box character. If any other number (i.e.
  258.           5..256) is used, the box is drawn using the ascii character
  259.           represented by the number. Refer to page 568 of the Turbo
  260.           Pascal Owner's Handbook to see the ascii table.
  261.  
  262.  
  263.  
  264. Example
  265.  
  266.  
  267.                USES CRT, FASTTTT;
  268.                BEGIN
  269.                  FBOX(1,1,80,12,WHITE,RED,1);
  270.                  FBOX(1,13,80,25,BLUE,LIGHTGRAY,2);
  271.                END.
  272.      
  273.  
  274. A single lined box would be drawn on the top half of the screen and
  275. the area inside the box would be cleared to a red background. A double
  276. lined box would be drawn in the lower half, and the area inside the
  277. box would be cleared to lightgray. Note that the CRT unit was also
  278. USED, so the colors could be refered to by name rather than their
  279. numeric code.
  280.  
  281. !SEEALSO:Box GrowFBox
  282.  
  283. !SHORT:GrowFBox          Draw box and clear screen inside box; box grows on screen
  284. GrowFBox                                                       FastTTT
  285.           
  286.  
  287.  
  288. Purpose   To draw a box and clear the screen inside the box. This
  289.           procedure is the functional equivalent to FBox, but the box
  290.           grows (or explodes!) on the screen for a fancy visual
  291.           effect.
  292.  
  293. Declaration    GrowFBox(X1,Y1,X2,Y2,F,B,Boxtype:integer);
  294.                     
  295.           X1 is the top left X coordinate (1..79)
  296.           Y1 is the top left Y coordinate (1..24)
  297.           X2 is lower right X coordinate (2..80)
  298.           Y2 is lower right Y coordinate (2..25)
  299.           F is the foreground color (0..15)
  300.           B is the background color (0..15)
  301.           Boxtype is the box line type (see remarks)
  302.  
  303. Uses FastTTT.
  304.  
  305. Remarks   The normal values for the Boxtype are:
  306.                1    Single line
  307.                2    Double line
  308.                3    Single top/bottom, double sides
  309.                4    Double top/bottom, single sides
  310.  
  311.            If a BoxType of 0 is passed the the procedure will use a
  312.            space (' ') as the box character. If any other number (i.e.
  313.            5..256) is used the box is drawn using the ascii character
  314.            represented by the number. Refer to page 568 of the Turbo
  315.            Pascal Owner's Handbook to see the ascii table.
  316.                     
  317.            If the box grows too quickly or too slowly, alter the global
  318.            variable Speed. The default value is 200; increase the value
  319.            to slow the speed down (ugh!) or decrease it to speed the
  320.            box up.
  321.  
  322.           
  323.  
  324.  
  325.  
  326. Example
  327.  
  328.  
  329.                USES CRT, FASTTTT;
  330.                BEGIN
  331.                  SPEED := 400;
  332.                  GROWFBOX(1,1,80,12,WHITE,RED,1);
  333.                  GROWFBOX(1,13,80,25,BLUE,LIGHTGRAY,2);
  334.                END.
  335.  
  336. !SEEALSO:Box FBox
  337.  
  338.       
  339. !SHORT:HorizLine         Draw a horixontal lin on screen
  340. HorizLine                                                      FastTTT
  341.      
  342.  
  343.  
  344. Purpose   To draw a horizontal line on the screen.
  345.  
  346. Declaration    HorizLine(X1,X2,Y,F,B,LineType: integer);
  347.                
  348.           X1 is the left X coordinate (1..79)
  349.           X2 is the right X coordinate (2..80)
  350.           Y is the Y coordinate (1..25)
  351.           F is the foreground color (0..15)
  352.           B is the background color (0..15)
  353.           Linetype is the line type (see remarks)
  354.  
  355. Uses FastTTT.
  356.  
  357. Remarks   The normal values for the Linetype are:
  358.                1    Single line
  359.                2    Double line
  360.                     
  361.                X2 may be larger than X1.
  362.  
  363.  
  364.  
  365. Example
  366.  
  367.  
  368.                USES CRT,FASTTTT;
  369.                BEGIN
  370.                  HORIZTLINE(10,17,13,LIGHTCYAN,BLUE,1);
  371.                END.
  372.      
  373.  
  374. Draws a single horizontal line across the center of the screen.
  375.  
  376. !SEEALSO:VertLine
  377.  
  378.       
  379. !SHORT:PlainWrite        Write text to screen very quickly in default color attribute
  380. PlainWrite                                                     FastTTT
  381.           
  382.  
  383.  
  384. Purpose   To write text to the screen very quickly in the default
  385.                     color attribute.
  386.  
  387. Declaration    PlainWrite(Col, Row: byte; St: string); external;
  388.                     
  389.           Col is the X coord of first char. in string (1..80)
  390.           Row is the Y coord of string (1..25)
  391.           St is the string or text to be displayed
  392.  
  393. Uses FastTTT.
  394.  
  395. Remarks   This procedure is external and the source code is actually
  396.           in assembly language (see the file FastTTT.asm on the
  397.           distribution disk, if you're interested). This procedure is
  398.           very similar to Fastwrite but it uses the current color
  399.           attribute for each character. It is even faster than
  400.           Fastwrite!
  401.  
  402.  
  403.  
  404. Example
  405.  
  406.  
  407.                USES CRT, FASTTTT
  408.                BEGIN
  409.                  CLEARTEXT(1,1,80,25,WHITE,BLACK);
  410.                  PLAINWRITE(1,1,'TOP LEFT OF SCREEN');
  411.                  PLAINWRITE(59,25,'BOTTOM RIGHT OF SCREEN;);
  412.                  END;
  413.           
  414.  
  415. The screen is cleared to a black background with a white foreground,
  416. and the two phrases are written to the screen in white letters.
  417.  
  418. !SEEALSO:WriteAT FastWrite WriteVert
  419.  
  420. !SHORT:ReInitFastWrite   Initialize variables referenced internally by FastWrite
  421. ReInitFastWrite                                                FastTTT
  422.      
  423.  
  424.  
  425. Purpose   To initialize variables referenced internally by Fastwrite.
  426.  
  427. Declaration    ReinitFastWrite;external;
  428.  
  429. Uses FastTTT.
  430.  
  431. Remarks   This procedure is automatically called at the commencement
  432.           of any program that uses the FastTTT unit. (Refer to page 64
  433.           of the Turbo Pascal Owner's Handbook for a further
  434.           explanation of initialized procedures.) It would not
  435.           normally be necessary to call this procedure.
  436.                
  437.           This procedure is external and the source code is actually
  438.           in assembly language. (See the file FastTTT.asm on the
  439.           distribution disk, if you're interested.)
  440.  
  441.       
  442. !SHORT:Replicate         Consrtuct a string of repeated characters
  443. Replicate                                                      FastTTT
  444.           
  445.  
  446.  
  447. Purpose   To construct a string of repeated characters
  448.  
  449. Declaration    (N:byte; C:Char): string;
  450.  
  451. Uses FastTTT.
  452.  
  453. Result type    String
  454.  
  455. Remarks   This function uses memory moves and is much faster than a
  456.           "for" loop.
  457.  
  458. Example
  459.  
  460.  
  461.                USES FASTTTT;
  462.                VAR TXT:STRING;
  463.                BEGIN
  464.                  TXT := REPLICATE(80,'+');
  465.                  FASTWRITE(1,1,14,TXT);
  466.                END.
  467.           
  468.  
  469. The variable Txt is set to an 80 character string composed of +'s i.e.
  470. '++++++++++....+++++++++'. The string is then written to the first
  471. line of the screen in yellow. Note that these two procedures could be
  472. combined to form a single statement:
  473.      FastWrite(1,1,14,Replicate(80,'+'));
  474.  
  475.       
  476. !SHORT:VertLine          Draw a vertical line on screen
  477. VertLine                                                       FastTTT
  478.      
  479.  
  480.  
  481. Purpose   To draw a vertical line on the screen.
  482.  
  483. Declaration    VertLine(X,Y1,Y2,F,B,LineType: integer);
  484.                
  485.           X is the X coordinate (1..80)
  486.           Y1 is the upper Y coordinate (1..24)
  487.           Y2 is the lower Y coordinate (2..25)
  488.           F is the foreground color (0..15)
  489.           B is the background color (0..15)
  490.           Linetype is the line type (see remarks)
  491.  
  492. Uses FastTTT.
  493.  
  494. Remarks   The normal values for the Linetype are:
  495.                1    Single line
  496.                2    Double line
  497.                     
  498.            Y2 may be larger than Y1.
  499.  
  500.  
  501.  
  502. Example
  503.  
  504.  
  505.                USES CRT,FASTTTT;
  506.                BEGIN
  507.                  VERTLINE(40,1,25,LIGHTCYAN,BLUE,2);
  508.                END.
  509.      
  510.  
  511. Draws a double vertical line down the center of the screen.
  512.  
  513. !SEEALSO:HorizLine
  514.  
  515. !SHORT:WriteAT           Writes directly to screen quickly in specified colors
  516. WriteAT                                                        FastTTT
  517.           
  518.  
  519.  
  520. Purpose   To writes directly to the screen el quicko in specified
  521.           colors.
  522.  
  523. Declaration    WriteAT(X,Y,F,B: integer; St: string);
  524.                     
  525.           X is the X coord of first character in the string (1..80)
  526.           Y is Y coord of string
  527.           F is the foreground color (0..15)
  528.           B is the background color (0..15)
  529.           St is the text string
  530.  
  531. Uses FastTTT.
  532.  
  533. Remarks   This is the most frequently used procedure in the Toolkit.
  534.           It is preferrable to Fastwrite (for most of us), because you
  535.           can specify the foreground and background colors separately.
  536.                     
  537.           This procedure cannot be used to write integers or reals -
  538.           first convert the number to a string using the Int_to_Str
  539.           function in the StrngTTT unit.
  540.  
  541.  
  542.  
  543. Example
  544.  
  545.  
  546.                USES CRT,FASTTTT;
  547.                CONST
  548.                  HEADING = 'TOOLKIT';
  549.                VAR
  550.                  NAME: STRING;
  551.                BEGIN
  552.                  NAME := 'BOB ''TECHNOJOCK'' AINSBURY';
  553.                  WRITEAT(1,25,YELLOW,RED,'PRESS F1 FOR HELP');
  554.                  WRITEAT(36,1,LIGHTGREEN,BLACK,HEADING);
  555.                  WRITEAT(1,5,LIGHTCYAN,BLACK,NAME);
  556.                  WRITEAT(60,20,WHITE,BLACK,'HELLO '+'THERE!');
  557.                END.
  558.           
  559.  
  560. The example writes various strings to the screen, and illustrates that
  561. string constants/variables and concatenated strings are valid.
  562.  
  563. !SEEALSO:Fastwrite PlainWrite WriteVert
  564.  
  565. !SHORT:WriteBetween      Write text centered between two points
  566. WriteBetween                                                   FastTTT
  567.      
  568.  
  569.  
  570. Purpose   To write text centered between two points.
  571.  
  572. Declaration    WriteBetween(X1,X2,Y,F,B: integer; ST: string);
  573.                
  574.           X1 is the left most X coord (1..79)
  575.           X2 is the right most X Coord (2..80)
  576.           Y is the Y coord or line number (1..25)
  577.           F is the foreground (0..15)
  578.           B is the background (0..15)
  579.           ST is the string or text to be displayed
  580.  
  581. Uses FastTTT.
  582.  
  583. Remarks   If the length of the string is greater than the distance
  584.           between the X coordinates, the string will simply be written
  585.           commencing at X1.
  586.  
  587.  
  588.  
  589. Example
  590.  
  591.  
  592.                USES FASTTTT;
  593.                BEGIN
  594.                  WRITEBETWEEN(1,40,15,0,'LEFT SIDE');
  595.                  WRITEBETWEEN(41,80,14,0,'RIGHT SIDE');
  596.                END.
  597.  
  598. !SEEALSO:WriteCenter WriteAT
  599.  
  600. !SHORT:WriteCenter       Write text on the center of a line
  601. WriteCenter                                                    FastTTT
  602.           
  603.  
  604.  
  605. Purpose   To write text on the center of a line
  606.  
  607. Declaration    WriteCenter(Y,F,B: integer; ST: string);
  608.                     
  609.           Y is the Y coord or line number (1..25)
  610.           F is the foreground color (0..15)
  611.           B is the background color (0..15)
  612.           ST is the string or text to be displayed
  613.  
  614. Uses FastTTT.
  615.  
  616. Remarks   The same rules apply as for WriteAT e.g. no reals/integers,
  617.           strings may be concatenated etc.
  618.  
  619.  
  620.  
  621. Example
  622.  
  623.  
  624.                USES FASTTTT;
  625.                BEGIN
  626.                  WRITECENTER(1,13,0,'MAJOR HEADING');
  627.                END.
  628.  
  629. !SEEALSO:WriteAT WriteBetween
  630.       
  631. !SHORT:WriteVert         Write a string vertically
  632. WriteVert                                                      FastTTT
  633.      
  634.  
  635.  
  636. Purpose   To write a string vertically.
  637.  
  638. Declaration    WriteVert(X,Y,F,B: integer; ST: string);
  639.                
  640.           X is X coord of first character in string (1..25)
  641.           Y is Y coord of first character in string (1..80)
  642.           F is the foreground color
  643.           B is the background color
  644.           ST is the string or text to be displayed
  645. Uses FastTTT.
  646.  
  647. Remarks   This odd little procedure will write a string down the
  648.           screen rather than across the screen. If the string is too
  649.           long to fit on the screen, it will be truncated.
  650. Example
  651.  
  652.  
  653.                Uses FastTTT;
  654.                BEGIN
  655.                  WRITEVERT(10,5,15,0,'Y        AXIS');
  656.                END.
  657.