You are currently offline, waiting for your internet to reconnect

How to Print Hercules Graphics SCREEN 3 to an Epson Printer

This article was previously published under Q51886
This article has been archived. It is offered "as is" and will no longer be updated.
Below is an example of printing Hercules graphics SCREEN 3 to an Epsonor 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 and6.00b for MS-DOS; and to Microsoft Basic PDS (Professional DevelopmentSystem) versions 7.00 and 7.10 for MS-DOS. (SCREEN 3 is supported inMS-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 printercontrol codes used in the program for setting line spacing andgraphics mode. You must find these control codes in your printermanual and make the appropriate modifications to the code below.

Printing Hercules Screen Mode 3

Understanding how to print graphics screens generated by Hercules andHercules-compatible graphics adapters requires familiarity with howHercules graphics memory is set up.

Hercules memory starts at hex-paragraph B000 (decimal 45056). Graphicsmemory starts with Page 0 at hex-paragraph B000 (decimal 45056), andPage 1 at hex-paragraph B800 (decimal 47104). (Paragraphs mark segmentboundaries, and there are 16 bytes per paragraph.)

However, graphics memory is interleaved, and is not contiguous. Eachline of pixels in SCREEN mode 3 consists of 90 bytes. Thus, the topline of pixels (line 0) on Page 0 will start at hex-paragraph B000 atoffset 0 and go for 90 bytes.

To draw a line of pixels at the top of the screen (in line 0 of Page0), POKE 255 into positions 0 through 89 (where 255 means all 8 bitsper byte being "on"), as follows:
   SCREEN 3   DEF SEG = &HB000   FOR x = 0 TO 89    ' B000:0000 hex to B000:0059 hex (in      POKE x, 255     ' segment:offset notation)   NEXT x				
To perform this procedure on Page 1, change the value of the DEF SEGstatement to hex-paragraph &HB800.

Because graphics memory is interleaved and not contiguous, if youcontinue to POKE at an offset 90 bytes after hex-paragraph B000, thenext line will appear on the screen at the fourth line down. To draw aline just one line down (on line 1), add 2000 Hex (8192 decimal) tothe offset of the first byte on line 0, then POKE as follows:
   DEF SEG = &HB000   FOR x = 8192 TO 8281     ' or B000:2000 hex to B000:2059 hex (in      POKE x, 255           ' segment:offset notation)   NEXT x				
This procedure must also be performed for line 2 and line 3. (Notethat line numbering starts at 0.) As a result, the first byte of line2 will be B000:4000 hex, and the first byte of line 3 will beB000:6000 hex. The interleaving cycles every four lines, thus thefirst byte of line 4 will be B000:005A hex (45056:0090 decimal), andsubsequent lines will follow the previous pattern, at offset intervalsof 2000 hex (8192 decimal).

The following diagram shows how the scan lines relate to theinterleaved video buffer:
               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				
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'sGuide to PC and PS/2 Video Systems" for a more complete diagram of thedisplay memory for Hercules graphics mode.

The following subprogram prints SCREEN Page 0 of a Hercules graphicsscreen to an Epson or Epson-compatible printer. To print SCREEN Page1, use a DEF SEG = &HB800 statement (instead of &HB000 for Page 0).
   DECLARE SUB HerculesPrintScreen ()   ' Before using Hercules SCREEN 3, you must run QBHERC.COM (included   ' with QuickBasic 4.00 or 4.00b, and Basic compiler 6.00 or 6.00b)   ' or MSHERC.COM (included with QuickBasic 4.50).   SCREEN 3   ' Put your screen graphics commands here - and take out commands   ' between these markers:   ' --------------------------------------------------------------     FOR i% = 1 TO 719 STEP 10       LINE (1, 1)-(i%, 348)       LINE (1, 348)-(i%, 1)     NEXT i%   ' --------------------------------------------------------------   CALL HerculesPrintScreen   SUB HerculesPrintScreen STATIC      DEF SEG = &HB000  'Set segment to SCREEN 3, video Page 0      OPEN "LPT1" FOR BINARY AS #1  'Open printer port in binary mode      WIDTH #1, 255                 'Set print width to 256 bytes wide      adv872$ = CHR$(27) + "A" + CHR$(8)      dots408$ = CHR$(27) + "K" + CHR$(92) + CHR$(1)      linefeed$ = CHR$(10)      PUT #1, , adv872$        'Set printer linefeed to 8/72"      FOR x = 0 TO 89         PUT #1, , dots408$    'Set printer for bit image graphic mode         FOR y = 7740 + x TO x STEP -90            FOR z = 24576 + y TO y STEP -8192               image$ = CHR$(PEEK(z))               PUT #1, , image$  'Send bit-image graphics to printer            NEXT z         NEXT y         PUT #1, , linefeed$   'Send a linefeed to the printer      NEXT x      ResetPrn$ = CHR$(27) + "@"      PUT #1, , ResetPrn$      'Reset the printer to default settings      CLOSE #1   END SUB				
This article is part of a collection of articles explaining how to printBasic video screens to Epson printers. Find the entire collection byquerying in the Microsoft Knowledge Base using the following words:
Epson and print and screen and QuickBasic
If you want further information, please refer to the following book, whichis available in bookstores or by calling Microsoft Press at (800) 888-3303or (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: 02/27/2014 21:00:06 - Revision: 1.2

  • kbnosurvey kbarchive KB51886