home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-12-20 | 41.2 KB | 1,109 lines |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- QWIK SCREEN UTILITIES
- USER'S GUIDE
-
- Version 5.x
- December 20, 1988
-
-
- Copyright (C) 1988 Eagle Performance Software
- All Rights Reserved.
-
-
-
- _______
- ____| _ | (tm)
- --| | |-------------------
- | ____|__ | Association of
- | | |_| Shareware
- |__| o | Professionals
- -----| | |---------------------
- |___|___| MEMBER
-
-
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
-
- T A B L E O F C O N T E N T S
-
- 1. INTRODUCTION . . . . . . . . . . . . . . . . . . . . . 3
- Features . . . . . . . . . . . . . . . . . . . . . . 3
- Using the Manuals . . . . . . . . . . . . . . . . . . 3
- Licensing . . . . . . . . . . . . . . . . . . . . . . 4
- Customer Service . . . . . . . . . . . . . . . . . . 4
- ASP . . . . . . . . . . . . . . . . . . . . . . . . . 5
-
- 2. GETTING STARTED . . . . . . . . . . . . . . . . . . . . 6
- Distribution Files . . . . . . . . . . . . . . . . . 6
- Demonstration . . . . . . . . . . . . . . . . . . . . 6
- Simple Programming . . . . . . . . . . . . . . . . . 6
- Procedures and Functions . . . . . . . . . . . . . . 8
-
- 3. BASIC TECHNIQUES . . . . . . . . . . . . . . . . . . . 11
- Number to String Conversion . . . . . . . . . . . . . 11
- Cursor Mode Routines . . . . . . . . . . . . . . . . 11
- Cursor Location Routines . . . . . . . . . . . . . . 13
- EOS Marker . . . . . . . . . . . . . . . . . . . . . 13
- Scrolling . . . . . . . . . . . . . . . . . . . . . . 14
- Pop-Up Windows . . . . . . . . . . . . . . . . . . . 15
-
- 4. ADVANCED TECHNIQUES . . . . . . . . . . . . . . . . . . 17
- Virtual Screens . . . . . . . . . . . . . . . . . . . 17
- Video Pages . . . . . . . . . . . . . . . . . . . . . 18
- Video Modes . . . . . . . . . . . . . . . . . . . . . 19
- Multi-tasking Environments . . . . . . . . . . . . . 20
- Interrupts . . . . . . . . . . . . . . . . . . . . . 20
-
- 5. HARDWARE DETECTION . . . . . . . . . . . . . . . . . . 21
- Display Combination Code . . . . . . . . . . . . . . 21
- Snow Checking . . . . . . . . . . . . . . . . . . . . 22
- System Hardware . . . . . . . . . . . . . . . . . . . 23
- Tips . . . . . . . . . . . . . . . . . . . . . . . . 23
-
- APPENDIX A: Video Mode Table . . . . . . . . . . . . . . . 24
-
- APPENDIX B: Cursor Mode Data . . . . . . . . . . . . . . . 26
- Cursor Mode Tables . . . . . . . . . . . . . . . . . 26
- Cursor Emulation . . . . . . . . . . . . . . . . . . 26
-
- APPENDIX C: Performance . . . . . . . . . . . . . . . . . 29
- Code Size . . . . . . . . . . . . . . . . . . . . . . 29
- Speed . . . . . . . . . . . . . . . . . . . . . . . . 29
- TP4 Usage . . . . . . . . . . . . . . . . . . . . . . 30
-
- APPENDIX D: Application Products . . . . . . . . . . . . . 31
-
- APPENDIX E: Revision History . . . . . . . . . . . . . . . 34
-
- APPENDIX F: References and Credits . . . . . . . . . . . . 37
-
-
-
-
- 2
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- 1. I N T R O D U C T I O N
-
-
- FEATURES
-
- Welcome to QWIK Screen Utilities!
-
- You have just obtained a copy of the highest performance screen writing
- tools available today for Turbo Pascal 5.0 (TP5). Both novice and
- professional programmers will appreciate these simple and very powerful
- utilities that gives you absolute control over your CRT displays in all
- text modes.
-
- Here are some of the features you will discover:
-
- . Writes on all IBM compatible computers, displays and
- adapters including the new PS/2 systems and Hercules.
- . Superior video detection routine.
- . Eliminates snow and flicker.
- . Writes directly to the screen in absolute coordinates.
- . Writes in all text modes and column modes.
- . Writes on all video pages.
- . Writes on virtual screens in RAM.
- . Writes text and attribute, text only, or attribute only.
- . Reads strings, characters and attributes.
- . Uses End-Of-String (EOS) marker for quick string chaining.
- . Provides standardized cursor control for all adapters.
- . Enhanced cursor movement.
- . 650% faster than TP5 direct screen writing.
- . Only 2.7k bytes of code if all 43 utilities are used.
- . Optimized by the compiler and drops unused code.
- . Used in all other Eagle products.
-
- QWIK is an enhancement unit providing capabilities not offered in the CRT
- unit that came with TP5. In contrast to the CRT unit which does window
- relative writing, QWIK knows how to write directly to the screen in
- absolute screen coordinates for any video configuration.
-
- | Version 5X - This version is simply a TP5 compiled version of QWIK42B.
- | QWIK50 will be out at a later date with other features specific to TP5.
-
-
- USING THE MANUALS
-
- Disk Based Guides - The manuals for QWIK are on disk so that you can
- conveniently scan for the topic you are seeking. You can do this with any
- list or search utility with a search function. You can also make a printed
- copy. If you have not already printed this manual, refer to the READ.ME
- file for instructions. At the present time, no bound manuals are being
- offered with registration.
-
- User's Guide - This manual, the one your are reading now, assumes that as a
- programmer you are already familiar with Turbo Pascal 4.0. And that you
- have a working knowledge of your disk operating system (DOS). It will
- provide you the basic principles of direct screen writing and powerful tips
-
-
- Chapter 1, Introduction Page 3
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- on some previously unavailable techniques.
-
- Reference Guide - This manual describes in detail all procedures, functions
- and variables used in QWIK. It is a alphabetically arranged for easy
- access in a format similar to the TP5 manual. Use this manual when you
- have become familiar with the basic principles in the User's guide.
-
-
- LICENSING
-
- Registration - These utilities and the documentation have been released for
- distribution as Shareware. You have been given the chance to sample the
- full capability of QWIK without risk! If you find that QWIK is a valuable
- tool, then you are expected to register. You will find a reasonable
- licensing schedule found in LICENSE.ARC to meet private or commercial
- needs. When registering, be sure to specify the version for Turbo Pascal
- (such as TP4 or TP5) you wish to receive.
-
- Source Code - All registered users will receive source code when the signed
- license agreement is returned with the registration.
-
-
- CUSTOMER SERVICE
-
- If you have questions, comments, or suggestions, the Eagle can be contacted
- by three means - (1) CompuServe, (2) telephone, (3) The Eagle BBS, or
- (4) mail.
-
- CompuServe - The most dependable way to contact the Eagle is through
- CompuServe. James (Jim) H. LeMay has written the TP5 version of QWIK. He
- can be contacted on the Borland Forum by typing GO BPROGA from the
- CompuServe main menu. You will enter the Forum for Turbo Pascal. You can
- contact Jim with his PPN number of 76011,217. Messages can also be left
- through EasyPlex.
-
- Telephone - Jim can also be reached by phone at (817) 735-4833 on weekdays
- and Saturday from 9:00 a.m. to 8:00 p.m CST.
-
- The Eagle BBS - After 01-10-89, you can also contact us on our 24-hour BBS
- at (214) 539-9878, 1200 N81.
-
- Mail - For registration or problems, please write:
-
- Eagle Performance Software
- TP products
- P.O. Box 122237
- Ft. Worth, TX 76121-2237
-
- In your written request for resolving problems, be sure to include:
-
- . A 5 1/4 inch diskette of compilable source code of the problem.
- . The Eagle product and version number.
- . The computer make and model.
- . The type of video card, video monitor and keyboard.
-
-
-
- Chapter 1, Introduction Page 4
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- For identical Turbo C products, write:
-
- Eagle Performance Software
- TC products
- P.O. Box 292786
- Lewisville, TX 75029-2786
-
- Or, contact Jim Gallagher at (214)-539-7855
-
- ASP
-
- QWIK is a Shareware program conforming to the standards of the Association
- of Shareware Professionals (ASP). You can get more information about ASP
- by writing to:
-
- Association of Shareware Professionals
- 325 118th Ave. S.E., Suite 200
- Bellevue, WA 98005.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Chapter 1, Introduction Page 5
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- 2. G E T T I N G S T A R T E D
-
- This section will acquaint you with the files on disk and show you a
- brief demonstration. You will also run your first program with QWIK and
- then become familiar with all of the utilities.
-
-
- DISTRIBUTION FILES
-
- In this version, QWIK5X.ARC contains:
-
- Qwik5x .tpu: Compiled unit of 2000 lines of assembly for TP5.
- Qwik5x .pas: Source code for QWIK5X.TPU. (MASM source code
- and object files are not included.)
- Qwik5x .doc: This document - a user's guide to QWIK.
- QwikDemo.pas: A demonstration program showing the features and
- speed of all procedures and is written primarily
- for color cards, but also works on mono cards.
- QwikRef .doc: QWIK Reference Guide document covering each
- procedure and variable in detail.
- Qinitest.pas: A program that verifies the equipment detected by
- the Qinit procedure.
- Qbench .pas: A timing program that shows "screens/second" for
- typical QWIK procedures.
- Strs .pas: Supplementary unit for number to string
- conversions.
- TimerD12.inc: Include file to measure elapsed time.
- License .arc: ARC file containing license agreements.
-
-
- DEMONSTRATION
-
- To get an overview of the speed and features of QWIK, let's run a
- demonstration program that came with the utilities. Do the following
- steps.
-
- 1. Copy QWIK5X.TPU to QWIK.TPU for TP5.
- 2. Make, compile and run QWIKDEMO.PAS to get a feel for
- features and speed.
- 3. Press return when the screen prompts you to continue with
- "... press any key".
- 4. Before running QINITEST.PAS, read the source code header
- to see if you want to test for a computer submodel ID.
-
-
- SIMPLE PROGRAMMING
-
- First Program - Let's write a short program to see how simple it is to
- write with QWIK. While in the TP editor, enter the following code:
-
- uses Crt,Qwik;
- begin
- TextAttr := Yellow+BlackBG;
- ClrScr;
- Qwrite (5, 1,Yellow+BlueBG,'QWIK writing');
-
-
- Chapter 2, Getting Started Page 6
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- Qwrite (5,13,Yellow+BlueBG,' is easy!');
- end.
-
- Assuming you have already copied QWIK5X.TPU to QWIK.TPU, compile and run
- the code. You can then see the text "QWIK writing is easy!" starting on
- row 5, column 1. On color monitors, the text is a yellow foreground with a
- blue background while monochrome monitors show high intensity on black.
-
- Row/Col vs. X/Y - You probably noticed that the row parameter is first and
- the column parameter is second. Since QWIK is entirely for text modes, it
- is more intuitive to specify the row first and the column second just like
- any word processor. The X/Y scheme is better suited for graphics.
-
- Attributes - Notice that our example uses the constant "BlueBG". QWIK
- provides eight convenient background color constants to use along with
- Turbo's 16 foreground colors. The same names are used, but the "BG" suffix
- is added:
-
- BlackBG RedBG
- BlueBG MagentaBG
- GreenBG BrownBG
- CyanBG LightGrayBG
-
- These allow QWIK to make the most of Turbo's constant folding. By simply
- adding the foreground and background constants together, the compiler saves
- the result as a single word. And, by simply reading the Qwrite statement,
- what you see is what you get (WYSIWYG).
-
- Readable Code - As an added benefit, QWIK was designed with human factors
- in mind and was made so that it is very easy to read the code you create.
- With the row, column, and attribute parameters first and the string last,
- you can see that the two Qwrite statements were easily aligned. WYSIWYG to
- the rescue again!
-
- Chaining - Notice that we had to calculate the string length of "QWIK
- writing" before we could locate the string " is easy". Let's modify the
- last statement to indeed make it easier to locate the last string:
-
- uses Crt,Qwik;
- begin
- TextAttr := Yellow+BlackBG;
- ClrScr;
- Qwrite (5, 1,Yellow+BlueBG,'QWIK writing');
- QwriteEos (Yellow+BlueBG,' is easy!');
- end.
-
- Now that was really easy! How did QwriteEos know where to write? QWIK
- internally keeps track of an End-Of-String (EOS) marker so that any
- subsequent "Eos" procedure like QwriteEos will chain the next string right
- there - no rows or columns to calculate! And you can chain as many as you
- want on to any other QWIK procedure.
-
- Same Attribute - But suppose we did not want to change the attribute that
- was already on the screen and don't even know what it is. How is that
- done? Just modify the attributes to the following:
-
-
- Chapter 2, Getting Started Page 7
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
-
- uses Crt,Qwik;
- begin
- TextAttr := LightGray+BlackBG;
- ClrScr;
- Qwrite (5, 1,SameAttr,'QWIK writing');
- QwriteEos (SameAttr,' is easy!');
- end.
-
- The special constant SameAttr (which is negative) tells QWIK to simply
- enter the text on the screen without changing the attribute. The result of
- the program would show the text with LightGray on Black attributes. This
- special constant works on all QWIK utilities. When assigned to a variable,
- the attribute can even be switched at run time.
-
- Centering - Rather than having the text left justified, let's center the
- text on the screen by modifying a portion of the code:
-
- ...
- ClrScr;
- QwriteC (5, 1,80,SameAttr,'QWIK writing is easy!');
- end.
-
- This will place the text on row 5 centered between columns 1 and 80 which
- is perfect for an 80 column text mode. But what if other text or column
- modes are used? How can we ensure that it is always centered? Only one
- simple change is needed:
-
- ...
- ClrScr;
- QwriteC (5, 1,CRTcols,SameAttr,'QWIK writing is easy!');
- end.
-
- The variable CRTcols always has the value of the column width that is
- currently being used. How does it know? QWIK is initialized at startup by
- executing a procedure called Qinit. It detects a host of information about
- your video configuration, everything from the type of video card you are
- using to the shape of the cursor being used. You can see a list of all
- these variables available for your use in QWIKREF.DOC.
-
-
- PROCEDURES AND FUNCTIONS
-
- Now that you have a basic idea of what QWIK can do, let's make a brief
- survey of all the utilities in QWIK.TPU to just know what is available:
-
- One initializing procedure:
-
- Qinit - Initializing procedure executed by QWIK5X.TPU which
- sets the global variables for the QWIK procedures.
- It should be executed again after a change from one
- text mode to another.
-
- Three quick direct screen writing procedures, all work with or
- without attribute change:
-
-
- Chapter 2, Getting Started Page 8
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
-
- Qwrite - For any type string or character (char).
- QwriteC - For any type string or char; self-centering.
- QwriteA - For any type variable, arrays or substrings.
-
- Four quick direct screen filling procedures in Rows-by-Cols block
- parameters:
-
- Qfill - Repetitive filling with the same character; with or
- without attribute change.
- QfillC - Same as Qfill, but self-centering.
- Qattr - Repetitive filling with an attribute only.
- QattrC - Same as Qattr, but self-centering.
-
- Two quick screen storing procedures:
-
- QstoreToMem - Saves a Rows-by-Cols block to memory.
- QstoreToScr - Restores a Rows-by-Cols block to any screen page.
-
- Two quick screen storing procedures for copying blocks between a
- screen (Scr) and a virtual screen (Vscr - a screen in memory):
-
- QScrToVscr - Copies a Rows-by-Cols block from QWIK screen to
- virtual screen.
- QVscrToScr - Restores a Rows-by-Cols block from a virtual screen
- to the QWIK screen.
-
- Three quick screen reading functions for reading data from any
- screen:
-
- QreadStr - Reads a string of text.
- QreadChar - Reads a single character.
- QreadAttr - Reads an attribute.
-
- Two quick scrolling procedures work on any video page and also
- virtual screens without flicker or snow:
-
- QscrollUp - Scroll affected rows-by-cols block up.
- QscrollDown - Scroll affected rows-by-cols block down.
-
- Two quick video page changing procedures:
-
- QviewPage - Changes the page to be displayed - up to 8!
- QwritePage - Sets the page on which the QWIK procedures are
- writing. You don't have to write just on the
- displayed page!
-
- Three quick cursor procedures and functions which work on any video
- page. They now work on the page being written rather than viewed:
-
- GotoRC - Move cursor to absolute row and column coordinates
- rather than relative to a window.
- WhereR - Returns absolute cursor row.
- WhereC - Returns absolute cursor column.
-
-
-
- Chapter 2, Getting Started Page 9
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- Eight quick EOS (End-Of-String) marker procedures and functions that
- alter its position and/or the cursor. The marker can be moved on the
- CRT and virtual screens, while the cursor movement is only on the
- page being written:
-
- GotoEos - Moves cursor to EOS marker (like TP write).
- EosR - Returns absolute row of EOS marker.
- EosC - Returns absolute col of EOS marker.
- EosToRC - Sets EOS to a given row and column.
- EosToRCrel - Relatively shifts EOS by a number of rows and
- columns, and can be negative or positive.
- EosToCursor - Matches EOS to the cursor position.
- EosLn - Moves EOS to column 1 of the next row.
- QEosLn - Like EosLn, but scrolls up if past last row.
-
- Three cursor routines alter the cursor mode:
-
- GetCursor - Get current cursor mode from low memory.
- SetCursor - Sets new cursor mode.
- ModCursor - Modifies cursor mode to on, off or erratic
- blink saving current scan lines.
-
- Four quick EOS writing procedures that chain write at the EOS marker:
-
- QwriteEos - like Qwrite.
- QwriteEosA - like QwriteA.
- QfillEos - like Qfill.
- QattrEos - like Qattr.
-
- A Submodel identification routine:
-
- GetSubModelID - Optional procedure to find IBM submodel ID.
-
- Five string functions that convert integers and reals to strings by
- using the supplementary STRS unit:
-
- StrL - converts LongInt to string
- StrLF - converts LongInt to string in a fixed Field
- StrR - converts Real to string
- StrRF - converts Real to string in a fixed Field
- StrRFD - converts Real to string in a fixed Field with a
- specified number of Decimals
-
- For a full description of each utility with its parameters, please refer to
- QWIKREF.DOC for a summary of details and examples.
-
-
-
-
-
-
-
-
-
-
-
-
- Chapter 2, Getting Started Page 10
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- 3. B A S I C T E C H N I Q U E S
-
-
- NUMBER TO STRING CONVERSION
-
- Str Procedure - TP5 handily converts numbers into strings with the Str
- procedure. For example:
-
- var MyNumber: integer;
- MyString: string;
- begin
- Str (MyNumber:7,MyString);
- Qwrite ( 1, 1,SameAttr,MyString);
- end.
-
- But this means that a data area must be reserved and the code isn't as
- readable as it could be.
-
- Str Functions - Instead, QWIK and the supplementary STRS unit let you use a
- function form of Str:
-
- uses Qwik, Strs;
- var MyNumber: integer;
- begin
- Qwrite ( 1, 1,SameAttr,StrLF(MyNumber,7));
- end.
-
- Just like WriteLn, this lets the number remain in the Qwrite statement.
- There are five functions in the STRS unit and they can be used just like
- any other function:
-
- StrL - converts LongInt to string
- StrLF - converts LongInt to string in a fixed Field
- StrR - converts Real to string
- StrRF - converts Real to string in a fixed Field
- StrRFD - converts Real to string in a fixed Field with a specified
- number of Decimals
-
- The suffixes mean:
-
- L - LongInt, but any scalar will work
- R - Real
- F - Field width that is right justified format
- D - Number of decimals in the format
-
- The Str* functions actually use the Str procedure from TP5 to do the
- conversion. But with an InLine code trick, functions were created that
- don't recopy the string for the greatest speed. The code useage is
- also reduced.
-
-
- CURSOR MODE ROUTINES
-
- Three Routines - If you have ever struggled with controlling the shape of
- the cursor, your life is about to be made easier. With just three
-
-
- Chapter 3, Basic Techniques Page 11
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- routines, SetCursor, GetCursor, and ModCursor, you can consistently and
- reliably control the cursor mode (shape and visibility) on any video card!
-
- Four Standard Modes - To make it even easier, four standard cursor mode
- variables are initialized at startup to fit the exact requirements of the
- detected video card. They are:
-
- CursorUnderline - The standard underline cursor.
- CursorHalfBlock - The half block shape usually used for insert
- editing.
- CursorBlock - An easy to find full cell cursor.
- CursorInitial - The mode detected at start up.
-
- So, if we wanted a full block cursor, only one line of code is needed:
-
- SetCursor (CursorBlock);
-
- And that's it! There's nothing else to figure out - even if you are using
- something like 43-row mode on an EGA card. When ending your programs, you
- can get back to the original cursor mode by using:
-
- SetCursor (CursorInitial);
-
- Hidden Cursor - Many programs need to hide the cursor altogether. This can
- be done with ModCursor:
-
- ModCursor (CursorOff);
-
- Why use ModCursor instead of SetCursor? ModCursor leaves the shape of the
- cursor alone, and only alters bits 13 and 14 of the cursor mode to turn it
- on or off. In fact there are three constants that are useful with
- ModCursor:
-
- CursorOff ($2000) - To turn the cursor off.
- CursorOn ($0000) - To turn the cursor back on with the same shape.
- CursorBlink ($6000) - To create erratic blinking on MDA/CGA. (On
- EGA/VGA, it turns the cursor off.)
-
- Using your imagination, you can also mix and match the constants and
- variables by logically summing them. Let's say we want to change the shape
- of the cursor to a block while it is still turned off:
-
- SetCursor (CursorBlock or CursorOff);
-
- So, the next time ModCursor(CursorOn) is used, the cursor will be a full
- block. As a suggestion for terminating your program, be sure to restore
- the cursor in your exit procedure with:
-
- SetCursor (CursorInitial);
-
- GetCursor - This function simply returns the current cursor mode value
- stored in low memory allowing you to save it for later use.
-
-
-
-
-
- Chapter 3, Basic Techniques Page 12
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- CURSOR LOCATION ROUTINES
-
- QWIK has three routines that complement the CRT unit - GotoRC, WhereR, and
- WhereC. They correspond with the familiar GotoXY, WhereX, and WhereY.
- However, there are some important differences:
-
- . The QWIK routines are absolute to the screen and are not restricted
- by the Turbo window.
- . The suffixes "R" and "C" mean row and column, so the parameters of
- GotoRC are reversed from GotoXY.
- . The QWIK routines will also work on any video page. This is
- explained in the Advanced Techniques section later.
-
- This is not the only way to move the cursor. The EOS marker is also a very
- powerful aid as you will see in the next topic.
-
-
- EOS MARKER
-
- Invisible Alternate Cursor - From the examples in the Simple Programming
- topic, we found that we could easily chain two strings together using the
- EOS marker. In fact, this marker is so versatile, the EOS marker utilities
- can be made interchangeable with the cursor, but much faster. You could
- think of it as an alternate cursor that is invisible.
-
- Keeping Track - Any time a QWIK writing procedure is used, the EOS marker
- is updated. It is actually saved as the global variable QEosOfs.
- Technically, the value is the offset from the screen base and is a 0-based
- byte count. For example, if the following procedure was executed:
-
- Qwrite (6,5,Yellow,'Important Data');
-
- the EOS would be at row 6, column 19, right after the word "Data". The
- value of QEosOfs on an 80 column screen would be:
-
- QEosOfs = ((Row-1)*CRTcols + (Col-1)) * 2 = 836
-
- QWIK does not need to calculate this value, but simply saves it after
- writing, so it is very efficient. From the overview, you are already aware
- of the four routines that will start writing at this marker - QwriteEos,
- QwriteEosA, QfillEos, and QattrEos. But what about changing the location
- of the marker itself? Keep reading.
-
- Moving the Marker - QWIK has four routines that will manually move the EOS
- marker:
-
- EosToRC - Sets EOS to a given row and column.
- EosToRCrel - Relatively shifts EOS by a number of rows and
- columns, and can be negative or positive.
- EosLn - Moves EOS to column 1 of the next row.
- QEosLn - Like EosLn, but scrolls up if past last row.
-
- The basic procedure EosToRC moves the EOS marker exactly like GotoRC does
- for the cursor. But there are also several ways to move the marker
- relatively. Let's test a short program:
-
-
- Chapter 3, Basic Techniques Page 13
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
-
- uses Crt,Qwik;
- begin
- TextAttr := Yellow;
- ClrScr;
- Qwrite ( 1, 1,Yellow+BlueBG,'First Row ');
- EosLn; { Jump to (2,1) }
- QwriteEos (Yellow+BlueBG,'Second Row ');
- EosToRC ( 3, 1); { Jump to (3,1) }
- QwriteEos (Yellow+BlueBG,'Third Row ');
- EosToRCrel ( 1,-4); { Jump to (4,8) }
- QwriteEos (Yellow+BlueBG, 'etc.');
- EosToRC (succ(EosR),8); { Jump to (5,8) }
- QwriteEos (Yellow+BlueBG, 'etc.');
- end.
-
- Compile and run the program. You should see "Row" and "etc." all aligned
- in one column. So, you can see that there are several simple ways to move
- the marker!
-
- EOS and the Cursor - You can also interface the EOS marker and the cursor
- with two procedures:
-
- GotoEos - Moves cursor to match the EOS marker.
- EosToCursor - Sets the EOS marker to match the cursor position.
-
- It can't get any simpler than that! Now you can see that:
-
- Qwrite (1,1,Yellow,'Test Line');
- GotoEos;
-
- and,
-
- TextAttr := Yellow;
- GotoXY (1,1);
- Write ('Test Line');
-
- produce identical results. But QWIK is much faster!
-
-
- SCROLLING
-
- Improved Control - With the CRT unit, you can only control the full screen
- size with WriteLn. But with the two QWIK routines, QscrollUp and
- QscrollDown, you can define any area to be scrolled:
-
- QscrollUp ( 2, 2,CRTrows-2,CRTcols-2,MyAttr);
-
- This example scrolls a portion of the screen starting at (2,2) leaving a
- one character border. In a 25x80 text mode, it clears row 24 from column 2
- to 79. In addition, the cleared row attribute is MyAttr.
-
- Improved Performance - With QscrollDown and QscrollUp (called Qscroll* for
- brevity), your programs can overcome the BIOS problems on many machines.
- Transparent to you, these procedures work on all cards and machines without
-
-
- Chapter 3, Basic Techniques Page 14
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- flicker or snow and operate at three speeds:
-
- Maximum - for video cards without snow
- Fast CGA - for CGA cards on 80286 machines or better
- Slow CGA - for CGA cards on 8086/8088 machines
-
- Qinit detects the CPU ID and video card to select the fastest algorithm.
- All speeds use 16-bit transfers rather than 8-bit. So, you can be assured
- of the highest performance.
-
- Cursor Location - These routines do not move the cursor. However, EOS is
- pointing to the first column of the blank line and GotoEos will move the
- cursor there if needed.
-
- QEosLn - This procedure is another alternative to full screen scrolling.
- It has the same function as EosLn, but will additionally scroll the screen
- up if the EOS marker is past the last row. Then it simply calls QscrollUp.
- The attribute of the cleared row is the global variable ScrollAttr. You
- must set this prior to using QEosLn.
-
-
- POP-UP WINDOWS
-
- QWIK has the basic tools to create and remove pop-up windows. Let's try to
- create one. While in the TP editor, enter the following code:
-
- uses Crt,Qwik;
- var
- MyWindow,MyUnderlay: array[1..250] of word;
- begin
- { -- Fill the screen with a hatch character. -- }
- Qfill ( 1, 1,CRTrows,CRTcols,LightGray+BlackBG,#176);
- { -- Create a pop-up window.-- }
- QstoreToMem ( 5,12,10,25,MyUnderlay); { Save area to be covered }
- Qfill ( 5,12,10,25,Black+LightGray,' '); { Clear the area }
- QwriteC (9,12,36,SameAttr,'Pop-Up Window'); { Label window }
- delay (1000); { Wait a sec }
- QstoreToMem ( 5,12,10,25,MyWindow); { Save a copy }
- QstoreToScr ( 5,12,10,25,MyUnderlay); { Restore screen }
- { -- Move window some where else. -- }
- QstoreToMem ( 8,25,10,25,MyUnderlay); { Save area to be covered }
- QstoreToScr ( 8,25,10,25,MyWindow); { Move window }
- delay (1000); { Wait a sec }
- { -- Remove window. -- }
- QstoreToScr ( 8,25,10,25,MyUnderlay); { Restore screen }
- end.
-
- Compile and run the code. You will see a 10 row by 25 column window
- located at (5,12) which is row 5, column 12 . After one second, it will be
- moved to (8,25). Then after another second, it is removed from the screen.
- We did a lot of work with very little code!
-
- Rows-by-Cols - QstoreToScr and QstoreToMem are screen saving and restoring
- procedures that conveniently work in row-by-column blocks. They
- accommodate any column mode, so there is no need to be concerned about
-
-
- Chapter 3, Basic Techniques Page 15
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- screen width.
-
- Memory Requirements - Notice that QstoreToMem wrote the data direct to
- memory in MyWindow. It is important that the memory allocated to that
- variable is correct to prevent it from overwriting any other variables.
- The array size chosen was a 250 word array which is a perfect fit since one
- word is needed for each character and attribute on the screen. If you
- prefer, the heap can also be used such as:
-
- var MyUnderlay: pointer;
- begin
- GetMem (MyUnderlay,500);
- QstoreToMem ( 5,12,10,25,MyUnderlay^);
- { ... }
- FreeMem (MyUnderlay,500);
- end.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Chapter 3, Basic Techniques Page 16
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- 4. A D V A N C E D T E C H N I Q U E S
-
- This section will acquaint you with the powerful virtual screen writing
- features already built into QWIK. You will also find out easy it is to
- work on multiple video pages and how to accommodate video mode changes.
-
-
- VIRTUAL SCREENS
-
- This topic will show you how to create and use powerful virtual screens.
-
- Virtual Screen - Just what is a virtual screen? It is a screen maintained
- in RAM of any dimensions that can be reproduced on the CRT in full or in
- part. The advantages are:
-
- . Variable row-by-column screen
- . Large video buffer up to 64k
- . High speed in RAM
- . Unlimited number of screens
-
- Screen Record - QWIK uses seven variables to define any screen. At start
- up, QWIK initializes them to the video system detected:
-
- CRTrows - Number of rows
- CRTcols - Number of columns
- CRTsize - Byte allocation for screen
- Qsnow - True if snow checking needed
- QEosOfs - EOS offset
- QScrOfs - Screen offset
- QScrSeg - Screen segment
-
- To make data access even easier, all these variables are contained in the
- record QScrRec of VScrRecType. In addition, QScrPtr is absolute to QScrOfs
- and QScrSeg. This gives QWIK a true far pointer, so screens can be
- anywhere in memory and not just paragraph aligned!
-
- Creating Virtual Screens - In three easy steps, you can easily create a
- virtual screen:
-
- 1. Allocate memory for the screen.
- 2. Save the current screen record.
- 3. Modify the screen record for the virtual screen.
-
- Let's write some code that does just that:
-
- uses Qwik;
- var CRTrec,VScrRec: VScrRecType;
- begin
- with VScrRec do { create specs for virtual screen }
- begin
- Vrows := 80; { Let's choose 80 rows }
- Vcols := 100; { Let's choose 100 columns }
- Vsize := Vrows * Vcols shl 1;
- Vsnow := false; { Can always be false }
- VEosOfs := 0; { Be safe and start at the base }
-
-
- Chapter 4, Advanced Techniques Page 17
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- GetMem (VScrPtr,Vsize); { Allocate heap space }
- end;
- CRTrec := QScrRec; { Save CRT specs }
- QScrRec := VScrRec; { Set virtual specs }
- { ... } { Write to the virtual screen }
- QScrRec := CRTrec; { Restore CRT specs when done! }
- end.
-
- Now, when you use any QWIK routine, they can be directed to the virtual
- screen - writing, reading, scrolling, wrapping, and everything you would
- expect. Qsnow can always be false when writing to virtual screens since
- RAM is used and not video card memory.
-
- Cursor Control - One thing not available to virtual screens is cursor
- movement, because the cursor location is reserved by DOS for just video
- pages. That means there is no cursor available for virtual screens. So,
- how can we get around this? The EOS marker comes to the rescue as an
- indispensable cursor! All EOS routines can still be used as before.
-
- Taking a Peek - At some time, we will need to take a look at all or a
- portion of the virtual screen by copying it to the CRT. Two inter-screen
- procedures do this by blocks at high speed - QScrToVscr and QVscrToScr.
- Here are the parameters of QVscrToScr:
-
- QVscrToScr (Row,Col,Rows,Cols,Vrow,Vcol,Vwidth,VScrPtr);
-
- Just like QstoreToScr, Row, Col, Rows, and Cols describe the position and
- size on the screen (Scr). This screen is specified by QScrRec which is
- usually the CRT. VScrPtr points to the virtual screen (Vscr). Now, where
- is the same size block on Vscr? It's at Vrow and Vcol. But the Vscr may
- have a different column width than CRTcols. So you specify that with
- Vwidth. Only the Scr side checks for possible snow. These procedures are
- extremely fast making virtual screens very practical. See QScrToVscr and
- QVscrToScr in QWIKREF.DOC for more examples.
-
- Multiple Virtual Screens - By changing QScrRec, you can even copy blocks
- from one virtual screen to another! These routines do not affect QEosOfs.
-
-
- VIDEO PAGES
-
- Multi-page Cards - TP5 procedures such as Write, Window, and GotoXY are
- dedicated to just page 0, but many video cards have more than one page. If
- you have a CGA or better, you already have memory on your card for 4 to 8
- pages. Since the BIOS recognizes them as well, QWIK gives you access to
- these extra pages.
-
- Page Control - QwritePage and QviewPage give you the power to use QWIK on
- all video pages and display which ever you choose. On a multiple-video
- page card like CGA, you can simply code:
-
- QwritePage (MyPage);
-
- to make all QWIK routines be directed to your selected video page even
- though you could be viewing another page. To view a page, you can in turn
-
-
- Chapter 4, Advanced Techniques Page 18
- QWIK Screen Utilities User's Guide, Version 5.x
-
-
- simply code:
-
- QviewPage (MyPage);
-
- Tips About Pages - Here are some tips to keep in mind when using several
- video pages:
-
- . The highest valid video page is detected by Qinit and saved in the
- variable MaxPage.
- . Invalid page parameters are just ignored.
- . The BIOS reserves a separate cursor location for each of up to 8
- video pages.
- . There is only one possible cursor mode which is always displayed on
- the CRT.
- . The cursor location routines operate on the page being written
- rather than viewed.
- . The current video page viewed is found with VideoPage.
- . The current video page set by QwritePage is saved in QvideoPage.
- . Be sure to end your programs with "QviewPage (0);".
-
-
- VIDEO MODES
-
- CRT Unit - If you intend to use the CRT unit with QWIK, it is best to place
- the CRT unit first in the "USES" list. When the CRT runs its
- initialization code, it checks for the video mode to see if it is a valid
- text mode (0..3,7). If so, it remains in that mode. If not, it is in a
- graphics or extended column mode and is forced back into the