Article ID: 51886
This article was previously published under Q51886
Below is an example of printing Hercules graphics SCREEN 3 to an Epson or Epson-compatible printer.
This information applies to Microsoft QuickBasic versions 4.00, 4.00b, and 4.50 for MS-DOS; to Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS; and to Microsoft Basic PDS (Professional Development System) versions 7.00 and 7.10 for MS-DOS. (SCREEN 3 is supported in MS-DOS and MS OS/2 real mode, but not in MS OS/2 protected mode.)
If you have a printer other than Epson, you must change the printer control codes used in the program for setting line spacing and graphics mode. You must find these control codes in your printer manual and make the appropriate modifications to the code below.
Printing Hercules Screen Mode 3Understanding how to print graphics screens generated by Hercules and Hercules-compatible graphics adapters requires familiarity with how Hercules graphics memory is set up.
Hercules memory starts at hex-paragraph B000 (decimal 45056). Graphics memory starts with Page 0 at hex-paragraph B000 (decimal 45056), and Page 1 at hex-paragraph B800 (decimal 47104). (Paragraphs mark segment boundaries, and there are 16 bytes per paragraph.)
However, graphics memory is interleaved, and is not contiguous. Each line of pixels in SCREEN mode 3 consists of 90 bytes. Thus, the top line of pixels (line 0) on Page 0 will start at hex-paragraph B000 at offset 0 and go for 90 bytes.
To draw a line of pixels at the top of the screen (in line 0 of Page 0), POKE 255 into positions 0 through 89 (where 255 means all 8 bits per byte being "on"), as follows:
To perform this procedure on Page 1, change the value of the DEF SEG statement to hex-paragraph &HB800.
Because graphics memory is interleaved and not contiguous, if you continue to POKE at an offset 90 bytes after hex-paragraph B000, the next line will appear on the screen at the fourth line down. To draw a line just one line down (on line 1), add 2000 Hex (8192 decimal) to the offset of the first byte on line 0, then POKE as follows:
This procedure must also be performed for line 2 and line 3. (Note that line numbering starts at 0.) As a result, the first byte of line 2 will be B000:4000 hex, and the first byte of line 3 will be B000:6000 hex. The interleaving cycles every four lines, thus the first byte of line 4 will be B000:005A hex (45056:0090 decimal), and subsequent lines will follow the previous pattern, at offset intervals of 2000 hex (8192 decimal).
The following diagram shows how the scan lines relate to the interleaved video buffer:
This same interleaving is used in video Page 1, which begins at hex- paragraph B800. Please see the figure on Page 89 of the "Programmer's Guide to PC and PS/2 Video Systems" for a more complete diagram of the display memory for Hercules graphics mode.
Video Buffer Display B000:0000 +---------+ +------------- | |<----------Scan Line 0 | ............ 005A |---------| +---Scan Line 1 | ............ | |<---+ | *Scan Line 2 | ............ 00B4 |---------| | | *Scan Line 3 | ............ . . +------Scan Line 4 | ............ . . | | B000:2000 |---------| | | |<------+ 205A |---------| * NOTE: . . Scan line 2 is at B000:4000 hex . . Scan line 3 is at B000:6000 hex
The following subprogram prints SCREEN Page 0 of a Hercules graphics screen to an Epson or Epson-compatible printer. To print SCREEN Page 1, use a DEF SEG = &HB800 statement (instead of &HB000 for Page 0).
This article is part of a collection of articles explaining how to print Basic video screens to Epson printers. Find the entire collection by querying in the Microsoft Knowledge Base using the following words:
Epson and print and screen and QuickBasicIf you want further information, please refer to the following book, which is available in bookstores or by calling Microsoft Press at (800) 888-3303 or (206) 882-8661:
"Programmer's Guide to PC and PS/2 Video Systems," by Richard Wilton (published by Microsoft Press, 1987)
Article ID: 51886 - Last Review: November 21, 2006 - Revision: 1.2