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

This article was previously published under Q69986
This article has been archived. It is offered "as is" and will no longer be updated.
SUMMARY
This article explains how to BLOAD and BSAVE images to multiple videopages (above page 0) for EGA screen modes 7, 8, 9, and 10. Thisarticle applies only to SCREEN modes that support multiple pages:screen modes 7 through 10. (Because Basic does not allow multiplescreen pages for screen modes 11, 12, or 13, this article does NOTapply to screen modes 11 through 13. This article also does NOT applyto programs compiled to run under MS OS/2 because these EGA screenmodes are not supported by Basic under OS/2.)

NOTE: The following Microsoft Knowledge Base article explains only how toBLOAD and BSAVE page 0 in each EGA screen mode. This article supplementsthat 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 and6.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 isthe 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 thedesired screen page; you may also need to add the appropriate active pageand visual page arguments to the SCREEN statement.

Basic's DEF SEG statement sets the segment used by the BSAVE and BLOADstatements. The following chart gives the starting segment (DEF SEG)values for video pages 0 and above for each EGA SCREEN mode thatsupports 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 inhexadecimal (base 16) notation. When you set the segment with the DEFSEG statement, add Basic's &H prefix in front of each hexadecimalnumber. For example, set the segment for page 2 of SCREEN 7 asfollows:
   DEF SEG = &HA400      ' Note that &H denotes hexadecimal notation.				
The above chart represents the maximum number of video pages providedby QuickBasic, not necessarily the maximum number of pages supportedby your video hardware. Below is a chart of the number of video pagesavailable based on the amount of memory installed on yourEGA-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 requiresthat you specify a visual page in the SCREEN statement. The visualpage argument is the fourth argument of the SCREEN statement.Attempting to select a video page that is not supported for aparticular screen mode results in an "Illegal function call" error.Below is an example of how to set the visual page in the context of aprogram 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 argumentof the SCREEN statement) in the SCREEN statement to BLOAD an image toa video page. The active page argument affects only the video page onwhich 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 specifythe active page in the SCREEN statement. You must also execute a DEFSEG statement to specify the segment in video memory that correspondswith the active page. For example, the following code executes BSAVEon 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 animage to page 1 of SCREEN 9. The image is a solid box drawn usingBasic'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.CLSCALL DisplayImageCALL BSAVEImageCLSPRINT "Press any key to see the image "WHILE INKEY$ = "": WENDCALL BLOADImageENDSUB 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 SEGEND SUBSUB 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 SEGEND SUBSUB 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 MicrosoftKnowledge Base:
45699 Complete Instructions to BLOAD and BSAVE EGA and VGA Screens
QuickBas BasicCom
Properties

Article ID: 69986 - Last Review: 08/23/2013 18:25:17 - Revision: 1.2

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1
  • kbnosurvey kbarchive KB69986
Feedback