How to BLOAD/BSAVE Multiple Screen Pages for EGA Screens 7-10

Article translations Article translations
Article ID: 69986 - View products that this article applies to.
This article was previously published under Q69986
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

SUMMARY

This article explains how to BLOAD and BSAVE images to multiple video pages (above page 0) for EGA screen modes 7, 8, 9, and 10. This article applies only to SCREEN modes that support multiple pages: screen modes 7 through 10. (Because Basic does not allow multiple screen pages for screen modes 11, 12, or 13, this article does NOT apply to screen modes 11 through 13. This article also does NOT apply to programs compiled to run under MS OS/2 because these EGA screen modes are not supported by Basic under OS/2.)

NOTE: The following Microsoft Knowledge Base article explains only how to BLOAD and BSAVE page 0 in each EGA screen mode. This article supplements that article.
45699 Complete Instructions to BLOAD and BSAVE EGA and VGA Screens
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 Basic PDS (Professional Development System) versions 7.00 and 7.10 for MS-DOS.

MORE INFORMATION

The process to BSAVE and BLOAD images for video pages above page 0 is the same as outlined in the following Microsoft Knowledge Base article:
45699 Complete Instructions to BLOAD and BSAVE EGA and VGA Screens
Just increase the segment value in the DEF SEG statement to point to the desired screen page; you may also need to add the appropriate active page and visual page arguments to the SCREEN statement.

Basic's DEF SEG statement sets the segment used by the BSAVE and BLOAD statements. The following chart gives the starting segment (DEF SEG) values for video pages 0 and above for each EGA SCREEN mode that supports multiple video pages:
   SCREEN  DEF SEG Value to BSAVE/BLOAD a Given Video Page:
   Mode    Page 0  Page 1  Page 2  Page 3  Page 4  Page 5  Page 6  Page 7
   ----    ------  ------  ------  ------  ------  ------  ------  ------

   7       A000    A200    A400    A600    A800    AA00    AC00    AE00
   8       A000    A400    A800    AC00
   9       A000    A800
  10       A000    A800
				
The values for the segment in the above chart are represented in hexadecimal (base 16) notation. When you set the segment with the DEF SEG statement, add Basic's &H prefix in front of each hexadecimal number. For example, set the segment for page 2 of SCREEN 7 as follows:
   DEF SEG = &HA400      ' Note that &H denotes hexadecimal notation.
				
The above chart represents the maximum number of video pages provided by QuickBasic, not necessarily the maximum number of pages supported by your video hardware. Below is a chart of the number of video pages available based on the amount of memory installed on your EGA-compatible hardware:
   Screen Mode   64K EGA memory  128K EGA  256K EGA
   -----------   --------------  --------  --------

        7        2 pages         4 pages   8 pages
        8        1 page          2 pages   4 pages
        9        1 page          1 page    2 pages
       10        1 page          1 page    2 pages
				
To view the video screen where the image is loaded or saved requires that you specify a visual page in the SCREEN statement. The visual page argument is the fourth argument of the SCREEN statement. Attempting to select a video page that is not supported for a particular screen mode results in an "Illegal function call" error. Below is an example of how to set the visual page in the context of a program that BLOADs an image into page 1 of SCREEN 7.
    SCREEN 7, , , 1          'Set the visual page to 1.
   DEF SEG = &HA200         'Define the segment beginning at page 1
                            'for SCREEN 9.
   CLS
   FOR i% = 0 TO 3          'BLOAD each of the four bit planes.
      OUT &H3C4, 2          'Indicates index to Map Register.
      OUT &H3C5, 2 ^ i%     'Select the bit plane to load into.
      BLOAD "IMAGE" + CHR$(48 + i%) + ".GRA", 0
   NEXT i%
   DEF SEG
				
Note: You are not required to specify an active page (third argument of the SCREEN statement) in the SCREEN statement to BLOAD an image to a video page. The active page argument affects only the video page on which the output from Basic graphic statements, such as LINE, CIRCLE, and DRAW, will go.

Before you BSAVE video pages greater than 0, you must first specify the active page in the SCREEN statement. You must also execute a DEF SEG statement to specify the segment in video memory that corresponds with the active page. For example, the following code executes BSAVE on an image created on page 1 of SCREEN 7:
   SCREEN 7, , 1              ' Set the active page to 1.
   DEF SEG = &HA200           ' Define the segment where page 1
                              ' starts, as given in the chart above.
   CLS
   LINE (50, 50)-(150, 150), 2, BF   ' Draw a solid rectangle on the
                                     ' screen.
   FOR i% = 0 TO 3
      OUT &H3CE, 4                   'Select Read Map Select Register.
      OUT &H3CF, i%                  'Select the bit plane to save.
      BSAVE "image" + CHR$(48 + i%) + ".GRA", 0, 8000
   NEXT i%
   DEF SEG
				
The following sample program demonstrates how to BLOAD and BSAVE an image to page 1 of SCREEN 9. The image is a solid box drawn using Basic's LINE statement.

Sample Code

DECLARE SUB DisplayImage ()
DECLARE SUB BSAVEImage ()
DECLARE SUB BLOADImage ()
CONST BitPlaneSize = 28000  ' Amount of disk space needed to save one
                            ' bit plane (in bytes) for SCREEN 9.
CONST VideoPageSegment = &HA800       ' Beginning of page 1 for
                                      ' SCREEN 9 in video memory.
CONST FileName = "IMAGE"
SCREEN 9, , 1, 1            ' Set the visual and active pages to 1.
CLS
CALL DisplayImage
CALL BSAVEImage
CLS
PRINT "Press any key to see the image "
WHILE INKEY$ = "": WEND
CALL BLOADImage
END

SUB BLOADImage
   DEF SEG = VideoPageSegment
   FOR i% = 0 TO 3
      OUT &H3C4, 2             'Indicates index to Map Register.
      OUT &H3C5, 2 ^ i%        'Select the bit plane to load into.
      f$ = FileName + CHR$(i% + 48) + ".GRA"
      BLOAD f$, 0
   NEXT i%
   DEF SEG
END SUB

SUB BSAVEImage
   DEF SEG = VideoPageSegment
   FOR i% = 0 TO 3
      OUT &H3CE, 4             'Select Read Map Select Register.
      OUT &H3CF, i%            'Select the bit plane to save.
      f$ = FileName + CHR$(i% + 48) + ".GRA"
      BSAVE f$, 0, BitPlaneSize
   NEXT i%
   DEF SEG
END SUB

SUB DisplayImage
   LINE (50, 50)-(150, 150), 2, BF    'Draw a solid box on the screen.
END SUB
				

REFERENCES

For more information, please see the following article in the Microsoft Knowledge Base:
45699 Complete Instructions to BLOAD and BSAVE EGA and VGA Screens

Properties

Article ID: 69986 - Last Review: August 23, 2013 - Revision: 1.2
APPLIES TO
  • Microsoft QuickBasic 4.0, when used with:
    • Microsoft MS-DOS 6.22 Standard Edition
  • Microsoft QuickBASIC 4.0b, when used with:
    • Microsoft MS-DOS 6.22 Standard Edition
  • Microsoft QuickBasic 4.5 for MS-DOS, when used with:
    • Microsoft MS-DOS 6.22 Standard Edition
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1
Keywords: 
kbnosurvey kbarchive KB69986

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com