home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / SCRNPAGE.ZIP / SCRNPAGE.DOC < prev    next >
Encoding:
Text File  |  1986-06-28  |  11.8 KB  |  247 lines

  1.  
  2.                FINDING FORGOTTEN TREASURE WITH TURBO PASCAL
  3.                             By D. L. Raney
  4.  
  5.      If you have read the IBM Reference manual or the many other fine
  6.   technical books for the IBM-PC and its many compatibles, you have more
  7.   then likely read about its ablity to use video paging. Video paging is a
  8.   means of using the entire 16k of video memory available on a color video
  9.   card. ( There is no video paging available on the monochrome card, due to
  10.   its limited memory. )
  11.      In the standard 80 column by 25 row video configuration, you are using
  12.   only 4k of the available memory. That leaves 12k of memory to just set
  13.   there idly, but what can we do with this idle memory? For starters, why
  14.   use a tiny window for a help screen when you could have an entire screen
  15.   to display at the blink of an eye (saving stack memory for better things)
  16.   without ever touching your main work screen, or you could draw several
  17.   input screens to use by simply setting a register. You may not have an
  18.   immediate use for this feature, or you have tried to use it and found that
  19.   none of the programming software directly supports this feature. It has been
  20.   my experience with Turbo Pascal that there is no support, and to top that
  21.   off MS-Dos does not even support this feature! In using a program to select
  22.   the active video page, and using MS-Dos function call #2 & #9 ( output
  23.   character & string ), MS-Dos outputs the character(s) to video page #0
  24.   ( 80x25 color or mono pages 0-3, 40x25 color or mono pages 0-7 ), Never
  25.   checking the active video page ( location 0462h contains the byte that
  26.   holds the current display page, 044Ah contains the screen width, 044Eh
  27.   contains screen offset location ) always writing to screen zero.
  28.   We could manipulate these memory locations, but we would be asking for
  29.   trouble down the line, as these memory locations could change in future
  30.   versions. We could also just store the information directly to the screen
  31.   memory, but the screen memory location could also change, which could
  32.   possibly create havoc with the machine.
  33.      There is a better way, a more compatible way, using the video bios rom.
  34.   Using this method will insure are program is compatible with future
  35.   versions of IBM computers, after all the rom may change, but the functions
  36.   remain the same. Now investigating the video bios function ( Intrrupt 10h )
  37.   we find all the primative functions we will need. What we need now is an
  38.   easy method of using these functions, using them as is would be tedious at
  39.   best. The ideal solution would be to have the same functions and procedures
  40.   that are incorporated into Turbo Pascal's video support. So we could design
  41.   our own functions and procedures to handle these for us, much the same as
  42.   the standard ones, with some added parameters of course.
  43.      The following is a list of the standard routines we will need and their
  44.   translation to the routines we will need.
  45.  
  46.   Write(Text: String); ------------> WritePg(Page: Byte; Text: String);
  47.   WriteLn(Text: String); ----------> WriteLnPg(Page: Byte; Text: String);
  48.   ClrEol; -------------------------> ClrEolPg(Page: Byte);
  49.   ClrScr; -------------------------> ClrScrPg(Page: Byte);
  50.   DelLine; ------------------------> DelLinePg(Page: Byte);
  51.   GotoXy(X,Y: Byte);---------------> GotoXyPg(X,Y,Page: Byte);
  52.   InsLine; ------------------------> InsLinePg(Page: Byte);
  53.   WhereX: Integer; ----------------> WhereXPg(Page: Byte): Byte;
  54.   WhereY: Integer; ----------------> WhereYPg(Page: Byte): Byte;
  55.   TextColor(Color: Integer); ------> TextColorPg(Page,Color: Byte);
  56.   TextBackground(Color: Integer); -> TextBackgroundPg(Page,Color: Byte);
  57.   Read(Text: String); -------------> ReadString(Page,Len,Type: Byte);
  58.   N/A -----------------------------> SetVideoPage(Page: Byte);
  59.   N/A -----------------------------> VideoMod; byte           (A Function)
  60.   N/A -----------------------------> SetVedeoMod(Mode: byte);
  61.  
  62.      As you will note, the extended functions and procedures all have "Pg"
  63.   appended to them. This is done to distinguish them from the standard ones.
  64.   This will also aid in remembering the syntax of them. You do not need to
  65.   understand how each of these procedures and functions work, only how to
  66.   use them. If you are interested in how they work, read the section on
  67.   the video bios routines in your IBM technical reference manual, or any good
  68.   book on the IBM such as "The Peter Norton Programmers Guide to the IBM PC",
  69.   then study the procedures and functions I have written.
  70.  
  71.  
  72.            EXTENDED VIDEO SCREEN PAGING SYNTAX'S AND DISCRIPTIONS
  73.            ------------------------------------------------------
  74.  
  75.   TEXTCOLORPG
  76.  
  77.      Syntax: TextColorPg(Page,Color);
  78.  
  79.      PAGE is the video screen page on which you wish to set the text color.
  80.      COLOR is the color of text you wish to use. Each Video screen page has
  81.      its own color table, and may be set to their own separate colors.
  82.      COLOR must be in the range of 0 to 15.
  83.  
  84.   TEXTBACKGROUNDPG
  85.  
  86.      Syntax: TextBackgroundPg(Page,Color);
  87.  
  88.      PAGE is the video screen page on which you wish to set the background
  89.      color. COLOR is the color of the background you wish to select. COLOR
  90.      must be in the range of 0 to 7. PAGE if in 80 column mode must be in
  91.      the range of 0 to 3, if in 40 column mode it must be in the range of
  92.      0 to 7.
  93.  
  94.   WHEREXPG
  95.  
  96.      Syntax: WhereXPg(Page);
  97.  
  98.      This function returns the cursor X position (Row) on the selected video
  99.      screen page. PAGE must be in the correct range, 0 to 3 for 80 column,
  100.      0 to 7 for 40 column modes.
  101.  
  102.   WHEREYPG
  103.  
  104.      Syntax: WhereYPg(Page);
  105.  
  106.      This function returns the cursor Y position (Column) of the selected
  107.      video screen page. PAGE must be in the range of, 0 to 3 for 80 column,
  108.      0 to 7 for 40 column mode.
  109.  
  110.   INSLINEPG
  111.  
  112.      Syntax: InsLinePg(Page);
  113.  
  114.      This procedure will insert a blank line at the current cursor line
  115.      position. The attribute will be the current video screen page color
  116.      settings.
  117.  
  118.   DELLINEPG
  119.  
  120.      Syntax: DelLinePg(Page);
  121.  
  122.      This procedure will delete a line on the selected screen page at which
  123.      the cursor is located. A new line will be scrolled onto the bottom of
  124.      the screen. The attribute will be the current video screen page color
  125.      settings.
  126.  
  127.   GOTOXYPG
  128.  
  129.      Syntax: GotoXyPg(X,Y,Page);
  130.  
  131.      This procedure will locate the cursor, on the selected screen page, to
  132.      the desired X,Y position. X and Y must be in proper range, 1 to 25 for
  133.      Y, 1 to (80 or 40) depending on screen width.
  134.  
  135.   CLRSCRPG
  136.  
  137.      Syntax: ClrScrPg(Page);
  138.  
  139.      This will clear the selected video screen page, and set the attribute
  140.      to the current settings for that page, and home the cursor to the upper
  141.      left hand corner.
  142.  
  143.   CLREOLPG
  144.  
  145.      Syntax: ClrEolPg(Page);
  146.  
  147.      This clears from the current cursor location to the end of the line.
  148.      The attribute will be the same as the current color settings.
  149.  
  150.   SETVIDEOPAGE
  151.  
  152.      Syntax: SetVideoPage(Page);
  153.  
  154.      This will set the active displayed video screen page. PAGE must be in
  155.      the correct range for current mode or procedure will return with no
  156.      change to the current active page.
  157.  
  158.   WRITEPG
  159.  
  160.      Syntax: WritePg(Page,String);
  161.  
  162.      PAGE contains the video screen page you wish to write the string of
  163.      characters to. STRING must be of the type string. If you wish to write
  164.      a value to the screen using this procedure it must be converted to a
  165.      string. The same is true for variables of the type char. This procedure
  166.      will write the string starting at the current cursor location, and the
  167.      cursor location will remain at the space following the last character
  168.      printed.
  169.  
  170.   WRITELNPG
  171.  
  172.      Syntax: WriteLnPg(Page,String);
  173.  
  174.      Page equals the video screen page to write to. Sorry, no numeric or
  175.      character types, these must be converted to a string type. This
  176.      procedure will write the string to the current cursor location, and will
  177.      perform a carriage return and line feed following the last character.
  178.  
  179.   READSTRING
  180.  
  181.      Syntax: AString:=ReadString(Page,Length,NumOrStr);
  182.  
  183.      This is an example of how to perform a read from any video screen page.
  184.      Since the standard READ and READLN routines only echo characters input
  185.      to video screen page #0, we need to do our own character echoing, using
  186.      our new routines. Although some what awkward, it does work. You may
  187.      write a better one, or use this one as is, or modify it to suit your own
  188.      needs. READSTRING is declared as a function and will only return a string
  189.      of characters. Any numeric input must be converted using the standard
  190.      routine VAL of Turbo Pascal.
  191.      ASTRING is of the type AnyString which must be defined in the program
  192.      block as AnyString = String[255]. PAGE is of the selected video screen
  193.      page. LENGTH is of a value of 1 to 255, please note though that lengths
  194.      of much more than 20 or 30 characters the input can be quite slow, and
  195.      the length should be contained to one line. NUMORSTR is the type of input
  196.      requested. A value of 0 will accept input of any ASCII character of the
  197.      range Chr(32) to Chr(126). A value of 1 will accept inputs of the type
  198.      "0"-"9","+","-", and ".".
  199.  
  200.  
  201.                 COLOR CARD VIDEO SCREEN PAGE'S MEMORY MAP
  202.                 -----------------------------------------
  203.  
  204.  
  205.      OFFSET ADDRESS           COLOR VIDEO MEMORY MAP
  206.  
  207.                 B800 ->:--------------------------------------:
  208.                        :       PAGE 0 (40 COLUMN MODE)        :
  209.                        :                2k                    :
  210.                 B880 ->: - - - - - - - - - - - - - - - - - - -:
  211.                        :       PAGE 1 (40 COLUMN)             :
  212.                        :       PAGE 0 (80 COLUMN MODE)        :
  213.                 B900 ->:--------------------------------------:
  214.                        :       PAGE 2 (40 COLUMN)             :
  215.                        :       PAGE 1 (80 COLUMN)             :
  216.                 B980 ->:- - - - - - - - - - - - - - - - - - - :
  217.                        :       PAGE 3 (40 COLUMN)             :
  218.                        :                                      :
  219.                 BA00 ->:--------------------------------------:
  220.                        :       PAGE 4 (40 COLUMN)             :
  221.                        :       PAGE 2 (80 COLUMN)             :
  222.                 BA80 ->: - - - - - - - - - - - - - - - - - - -:
  223.                        :       PAGE 5 (40 COLUMN)             :
  224.                        :                                      :
  225.                 BB00 ->:--------------------------------------:
  226.                        :       PAGE 6 (40 COLUMN)             :
  227.                        :       PAGE 3 (80 COLUMN)             :
  228.                 BB80 ->:- - - - - - - - - - - - - - - - - - - :
  229.                        :       PAGE 7 (40 COLUMN)             :
  230.                        :                                      :
  231.                        :--------------------------------------:
  232.  
  233.  
  234.      In conclusion I must state that all of the routines listed could be
  235.   further enhanced, but for most purposes they should fit the bill. There are
  236.   many other features of the IBM-PC that I feel are not being used to their
  237.   full advantage, and I invite anyone to explore their machines to find those
  238.   little known and used features, and let others share in your discoveries.
  239.  
  240.   Comments and questions should be directed to:
  241.                                                 Dennis L. Raney
  242.                                                 2612 Castle Dr.
  243.                                                 Blue Springs, Mo. 64015
  244.                                                      (or)
  245.                                                 Genie mail address D.L.RANEY
  246.  
  247.