Difference between revisions of "SCREEN (statement)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 3: Line 3:
  
  
:''Qbasic & QB64 Syntax: {{KW|SCREEN (statement)|SCREEN}} mode% [, , active_page, visual_page]  
+
:::::::''Qbasic Syntax: {{KW|SCREEN (statement)|SCREEN}} mode% [, , active_page, visual_page]  
  
  
Line 12: Line 12:
 
* Some screen mode text sizes are adjustable with [[WIDTH]] and some support [[PCOPY]] and page flipping.  
 
* Some screen mode text sizes are adjustable with [[WIDTH]] and some support [[PCOPY]] and page flipping.  
  
{{WhiteStart}}                   '''LEGACY SCREEN MODES AT A GLANCE'''
+
{{WhiteStart}}                       '''LEGACY SCREEN MODES AT A GLANCE'''
                          TEXT          GRAPHICS  
+
                      TEXT          GRAPHICS  
              Screen  Rows  Columns  Width  Height  Colors  
+
          Screen  Rows  Columns  Width  Height  Att/Colors Video Pages
                0  25/43/50 80/40      --------      16/16 DAC  
+
            0  25/43/50 80/40      --------      16/16 DAC     0 - 7
                1      25      40      320    200       4   BG  
+
            1      25      40      320    200       4/16 BG     one
                2      25      80      640    200       2  
+
            2      25      80      640    200       2/mono      one
              ...............................................  
+
          ..............................................................  
                7      25      40      320    200       16   DAC
+
            7      25      40      320    200     16/16 DAC     0 - 7
                8      25      80      640    200       16  
+
            8      25      80      640    200     16/16         0 - 3
                9      25      80      640    350      16/64 DAC  
+
            9      25      80      640    350      16/64 DAC     0 - 1
                10      25      80      640    350       4  
+
            10      25      80      640    350       4/2          one
                11    30/60    80      640    480       2  
+
            11    30/60    80      640    480       2/mono      one
                12    30/60    80      640    480      16
+
            12    30/60    80      640    480     16/262K       one
                13      25      40      320    200      256 '' ''
+
            13      25      40      320    200      256/65K      one
 +
 
 +
          Note: QB64 allows video paging and [[PCOPY]] in ALL screen modes! '' ''
 
{{WhiteEnd}}
 
{{WhiteEnd}}
  

Revision as of 19:38, 6 February 2011

The SCREEN statement sets the screen mode of a program. No statement defaults the program to SCREEN 0 text ONLY mode.


Qbasic Syntax: SCREEN mode% [, , active_page, visual_page]


  • The SCREEN mode values available today are 0 to 2 and 7 to 13 listed below.
  • The empty comma disables color when any value is used. DO NOT USE! Include the comma ONLY when using page flipping.
  • If the SCREEN mode supports pages, the Active page is the page to be worked on while visualpage is the one displayed.
  • A SCREEN statement that changes screen modes also clears the screen like CLS. Nothing on the screen is retained.
  • Some screen mode text sizes are adjustable with WIDTH and some support PCOPY and page flipping.

LEGACY SCREEN MODES AT A GLANCE TEXT GRAPHICS Screen Rows Columns Width Height Att/Colors Video Pages 0 25/43/50 80/40 -------- 16/16 DAC 0 - 7 1 25 40 320 200 4/16 BG one 2 25 80 640 200 2/mono one .............................................................. 7 25 40 320 200 16/16 DAC 0 - 7 8 25 80 640 200 16/16 0 - 3 9 25 80 640 350 16/64 DAC 0 - 1 10 25 80 640 350 4/2 one 11 30/60 80 640 480 2/mono one 12 30/60 80 640 480 16/262K one 13 25 40 320 200 256/65K one Note: QB64 allows video paging and PCOPY in ALL screen modes!

QB64 Custom Screen Modes
QB64 only 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]


  • Custom screen modes can be created using a _NEWIMAGE or _LOADIMAGE function imagehandle return value.
  • _NEWIMAGE screens can be any set size. A screen mode can be imitated or 256 or 32 bit colors can be designated.
  • The _LOADIMAGE screen size will be the size of the image loaded. Can designate a mode or 256 or 32 bit colors.
  • QB64 allows page flipping or a PCOPY in ANY SCREEN mode.
  • All SCREEN modes are Windows in QB64. Use _FULLSCREEN to set the window area to full screen.
  • _SCREENMOVE can position a window or the _MIDDLE option can center it on the desktop.


Qbasic and QB64 Legacy SCREEN Modes
  • SCREEN 0 (default mode) is a text only screen mode. 64 (VGA) colors with hi-intensity(blinking) colors 16 to 31. (DAC attrib 6, 8 to 15). 16 Background colors. No graphics are possible! Normally runs in a window. ALT-Enter switches from a window to fullscreen. To automatically run in fullscreen, use another Screen mode before using SCREEN 0. Can use PCOPY with video pages 0 to 7. Text is 25, 43 or 50 rows by 40 or 80 columns. Default is 25 by 80. See WIDTH.
All other available SCREEN modes can use text and graphics and are fullscreen in Qbasic ONLY.
  • SCREEN 1 has 4 background color attributes. 0 = black, 1 = blue, 2 = green, 3 = grey. White foreground only. Text is 25 by 40. White graphics is 320 by 200.
  • SCREEN 2 is monochrome with black background and white foreground. Text is 25 by 80. White graphics 640 by 200.
  • SCREENs 3 to 6 are no longer supported on most computers! Using them will cause an error!
  • SCREEN 7 has 16 color attributes (DAC attrib. 8 to 15) with background colors. Text 25 rows by 40 columns. Graphics 320 columns by 200 rows. Video pages 0 to 7 for flipping or PCOPY.
  • SCREEN 8 has 16 color attributes with background. Text is 25 by 80. Graphics is 640 by 200. Video pages 0 to 3.
  • SCREEN 9 has 64 DAC color hues for (DAC attrib. 6, 8 to 15) with background colors. Text is 25 by 80. Graphics is 640 by 350. Video pages 0 and 1 for flipping or PCOPY.
  • SCREEN 10 has 4 color attributes with black background. 1 = normal white, 2 = blinking white and 3 = bright white. Text is 25 by 80. Graphics is 640 by 350.
  • SCREEN 11 is monochrome with black background and white foreground. Text is 30 or 60 by 80 columns(see WIDTH). White graphics is 640 by 480.
  • SCREEN 12 has 16 color attributes, black background. 256K possible color hues. Text is 30 or 60 by 80 columns(see WIDTH). Graphics 640 by 480.
  • SCREEN 13 has 256 color attributes, black background. 256K possible color hues. Text is 25 by 40. Graphics is 320 by 200.


Text Coordinates:
  • Are a minimum of 1 and the values given above are the maximums.
  • Text characters occupy a certain sized pixel box adjusted by WIDTH in some screen modes.
  • Text PRINT cursor positions can be read by CSRLIN and POS(0) to LOCATE text PRINTS.
  • The SCREEN (function) can be used to read the ASCII character code or color of text in SCREEN 0 only.
  • VIEW PRINT can be used to designate a text view port area.


Graphic Coordinates:
  • The minimum on screen graphics pixel coordinates are 0 for columns and rows in the top left corner.
  • Maximum pixel coordinates are one less than the maximum dimensions above because the pixel count starts at 0.
  • Graphic objects such as PSET, PRESET, LINE, CIRCLE and DRAW can be placed partially off of the screen.
  • GET and PUT screen image operations MUST be located completely on the screen in Qbasic!
  • VIEW can be used to designate a graphic view port area of the screen.
  • WINDOW can be used to set the graphics SCREEN coordinates to almost any size needed. Use the SCREEN option for normal row coordinate values. Row coordinates are Cartesian(decrease in value going down the screen) otherwise.


QB64 Screen Statements and Functions:
  • For file image screens that adopt the image dimensions and image color settings use: _LOADIMAGE
  • To create custom sized screen modes or pages and 256 or 32 bit colors use: _NEWIMAGE
  • _PUTIMAGE can stretch or reduce the size of images to fit the SCREEN size.
  • PUT can use _CLIP to set objects partially or fully off screen. GET can read objects off screen in QB64 ONLY.
  • A _DISPLAY statement can be used to only display an image after changes instead of using page flipping or PCOPY.


Example 1: Shows an example of each legacy screenmode.

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 mode one at a time with a CIRCLE (except for SCREEN 0)


Example 2: Making ANY QB64 program window 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& COLOR 14: LOCATE 2, 4: PRINTS "Screen 13 Height Reduction to 83%" COLOR 12: LOCATE 22, 22: PRINTS CHR$(24) + " 4 X 3 Proportion" 'use concatenation COLOR 10: 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.


See Examples:

  • SAVEIMAGE (QB64 Image to Bitmap SUB by Galleon)


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page