QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The SCREEN statement sets the video display mode and size of the program window’s workspace.

Syntax

SCREEN {mode% imagehandle&} [, , active_page, visual_page]

Parameter(s)

Usage


                       **LEGACY SCREEN MODES AT A GLANCE**

 **Screen      Text           Graphics          Colors      Video    Text      Default** 
  **Mode   Rows   Columns   Width   Height  Attrib.   BPP   Pages    Block    QB64 Font**

   0   25/43/50  80/40    No graphics     16/16 DAC  4     0-7     -----    _FONT 16
   1      25      40      320     200     16/4 BG    4     none    8 X 8    _FONT 8 
   2      25      80      640     200      2/mono    1     none    8 X 8    _FONT 8 
   ................................................................................. 
   7      25      40      320     200     16/16 DAC  4     0-7     8 X 8    _FONT 8 
   8      25      80      640     200     16/16      4     0-3     8 X 8    _FONT 8 
   9      25      80      640     350     16/64 DAC  4     0-1     8 X 14   _FONT 14
  10      25      80      640     350     4/2 GScale 2     none    8 X 14   _FONT 14
  11     30/60    80      640     480      2/mono    1     none    8 X 16   _FONT 16
  12     30/60    80      640     480     16/262K    4     none    8 X 16   _FONT 16
  13      25      40      320     200     256/65K    8     none    8 X 8    _FONT 8 

              **QB64 allows video paging and [PCOPY](PCOPY) in ALL screen modes!** 

QB64 Custom Screen Modes

QB64 Syntax

SCREEN imagehandle& [, , active_page, visual_page]

SCREEN _NEWIMAGE(wide&, high&[, {mode 256 32}]) [, , active_page, visual_page]
SCREEN _LOADIMAGE(file$[, {mode 256 32}]) [, , active_page, visual_page]

Legacy Screen Modes

Note: Use OUT or _PALETTECOLOR to create higher intensity color backgrounds than COLOR , 7.

All other available SCREEN modes can use text and graphics and are fullscreen in QBasic ONLY.

Modern Syntax

QB64 can use page flipping with any number of pages in any screen mode!

Text and Graphics

Text Coordinates:

Graphic Coordinates:

QB64 Screen Statements and Functions:

Example(s)

Shows an example of each legacy screen mode available to QBasic and QB64.


SCREEN 0
PRINT "This is SCREEN 0 - only text is allowed!"
FOR S = 1 TO 13
   IF S < 3 OR S > 6 THEN 
     DO: SLEEP: LOOP UNTIL INKEY$ <> ""
     SCREEN S
     PRINT "This is SCREEN"; S; " - can use text and graphics!"
       IF S = 2 OR S = 11 THEN PRINT "Monochrome - no COLOR statements!"
       IF S = 10 THEN 
         COLOR 2: PRINT "This SCREEN has only 4 colors. Black and 3 white: 2 blinks.
         CIRCLE (100,100), 50, 2
       ELSE : CIRCLE (100,100), 100, S
       END IF
   END IF
NEXT 
SLEEP
SYSTEM 


This is SCREEN 0 - only text is allowed!

Displays each SCREEN (statement) mode one at a time with a CIRCLE (except for SCREEN (statement) 0)

Making ANY QB64 legacy screen mode larger using a SUB that easily converts PRINT to _PRINTSTRING.


Scr13& = _NEWIMAGE(320, 200, 13)  'this is the old SCREEN 13 image page to set the image
Big13& = _NEWIMAGE(640, 480, 256) 'use 4 X 3 aspect ratio that Qbasic used when full screen

SCREEN Big13&
_DEST Scr13&
image1& = _LOADIMAGE("Howie.BMP", 256)  'see the download link below for 2 image files
image2& = _LOADIMAGE("Howie2.BMP", 256)
_PUTIMAGE (10, 20), image1&, Scr13&
_PUTIMAGE (160, 20), image2&, Scr13&
_COPYPALETTE image1&, Scr13&
COLOR 151: LOCATE 2, 4: PRINTS "Screen 13 Height Reduction to 83%" 
LOCATE 22, 22: PRINTS CHR$(24) + " 4 X 3 Proportion"  'use concatenation
LOCATE 24, 21: PRINTS CHR$(27) + " Stretched at 100%" 'instead of a semicolon!
_COPYPALETTE Scr13&, Big13&  'required when imported image colors are used
_PUTIMAGE , Scr13&, Big13&   'stretches the screen to double the size
K$ = INPUT$(1)
END

SUB PRINTS (Text$)
row% = (CSRLIN - 1) * _FONTHEIGHT      'finds current screen page text or font row height
col% = (POS(0) - 1) * _PRINTWIDTH("W") 'finds current page text or font column width
_PRINTSTRING (col%, row%), Text$
END SUB 

Code by Ted Weissgerber

Explanation: The procedure above creates a larger version of a SCREEN 13 window by stretching it with _PUTIMAGE. It cannot stretch PRINTed text so _PRINTSTRING must be used instead. LOCATE sets the PRINT cursor position for CSRLIN and POS(0) to read. The SUB then converts the coordinates to graphical ones. Then change PRINT to PRINTS using the Search Menu.

Download of Example 2 Bitmap images

You can easily change PRINT to the PRINTS sub-procedure name in your code using the IDE Search Menu Change option.

See Example(s)

See Also