home *** CD-ROM | disk | FTP | other *** search
-
- The two files PageDisp.Pas and Speedchk.pas were written as demo
- programs to demonstrate the use of User provided I/O routines from Turbo
- Pascal. This capability basically provides you with the ability to make
- Tubo use the procedure you have written instead of its own internal
- routine in the Write and Writeln statements.
- What the programmer has to do is to write a procedure/Function to
- do the I/O ensuring that the parameters are compatible.(Check the T.P
- reference manual for the parameters expected of the I/O procedures and
- functions). Turbo has pre-declared integer variables called ConOutPtr,
- ConInPtr,LstOutPtr etc which are supposed to point to the offset of the
- corresponding I/O routines. So assigning these pointers to the offsets
- of your I/O routines will essentially cause T.P to use them for the
- corresponding function. If an output pointer has been reassigned, then
- all the Write and Writeln statements will call the new procedures and
- If it is an input pointer, the Read/Readln statements will use the new
- procedure/function.
- The programs PageDisp and SpeedChk reassign the ConOutPtr to a
- routine "WriteChar". What the procedure WriteChar does is to write a
- character to screen writing the character and its attribute directly to
- the display memory instead of using the BIOS interrupt 10H. The additional
- capability of this routine is that it can write to any page of the display
- of a Color Graphics adapter. The Color Graphics adapter in an IBM PC has
- 16K of memory and hence can hold 4 pages of 80 X 25 characters in the text
- mode. Any one of these pages can be selected on the screen by using the
- BIOS interrupt 5. However, most high level languages do not use this
- capability and do not provide access to pages other than page 0.( May be to
- maintain compatibility with the monochrome adapter also.) Using the multipage
- capability enables you to change displays almost instantaneously by writing
- to a non-displayed page and switching to that page after finishing writing.
- The procedure Writechar enables one to write to any page specified by the
- variable Out_Page irrespective of what is displayed on the screen.The
- procedure Disp_Page is used to bring onto display any of thes pages.
- These programs bring out another feature in Turbo Pascal which is
- the capability to replace any standad internal procedure by a user-provided
- procedure. If a procedure/function provided by the user has the same name as
- an internal Turbo procedure/function, then the internal function gets
- disabled and the user-provided function is used in all calls to that
- procedure. The procedures TextColor and TextBackground have been redefined
- this way in the two programs to make those functions work when using the
- WiteChar procedure for output. There is a disadvantage in this though..
- If at all you want to go back to the internal display driver routine at some
- other place in the same program (Which you can do by restoring the original
- value of ConOutPtr) the procedures TextColor and TextBackground will not work.
- So if that capability is needed, you'd have to rename them to something else
- and use those nonstandard names to change background and foreground text
- colors when using WriteChar as the Display diver.
- The writechar procedure as given here does not support the Window
- function of Turbo. However it is possible to do that also by incorporating
- some more code.The Assembler source for that procedure is provided as a
- separate file for anyone who would like to make changes.
- While writing and testing the program DispPage, I wanted to test the
- improvement in speed achieved by using writing directly to screen and hence
- the program SpeedChk. This measures the speed of 4 cases of writing to screen
- 20 lines of 79 characters each. The first 2 use the Turbo internal procedure
- while the next two use WriteChar for screen output. The second and fourth
- runs write these lines on the 25th line of the display, forcing the screen
- to scroll which slows down the output quite a lot. On my AT&T 6300, I
- observed speed increases of the order of 5 to 6 : 1 for unscrolled output
- and about 3.5 : 1 for scrolled outputs. This was using Tubo Pascal 2.0 which
- I am using presently. Turbo 3.0 apparently uses direct screen memory writes
- in its standard output routine, so the speed increases may be much less. Also
- an IBM PC may give different ratio than my AT&T machine, due to differences
- in hardware (8 bit vs 16 bit bus mainly) and the BIOS software.
- I hope these routines are of some value to other Turbo Pascal
- enthusiasts. Any comments and suggestions would be appreciated.
- Babu Kalakrishnan
- Voice # (415)-965-8859
- Or leave message on LogOn BBS (408)-735-7390
- or P.D.S.E (408)-735-7190