Difference between revisions of "ScreenMode"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
(Created page with '<center>'''Screen Mode Detection Function'''</center> {{CodeStart}} '' '' {{Cl|DIM}} {{Cl|SHARED}} colors DO {{Cl|PRINT}} {{Cl|PRINT}} {{Cl|PRINT}} " Screen W H …')
 
imported>Clippy
m
 
(15 intermediate revisions by the same user not shown)
Line 3: Line 3:


{{CodeStart}} '' ''
{{CodeStart}} '' ''
{{Cl|DIM}} {{Cl|SHARED}} colors
DO
DO
   {{Cl|PRINT}}
   {{Cl|PRINT}}
   {{Cl|PRINT}}
   {{Cl|PRINT}}
   {{Cl|PRINT}} "  Screen    W      H    "
   {{Cl|PRINT}} "  Screen    W      H    Colors "
   {{Cl|PRINT}} "    0    80/40  (25)   17 "
   {{Cl|PRINT}} "    0    80/40  (25)     16 "
   {{Cl|PRINT}} "    1    (320)  (200)   4 "
   {{Cl|PRINT}} "    1    (320)  (200)     4 "
   {{Cl|PRINT}} "    2    (640)  200     2 "
   {{Cl|PRINT}} "    2    (640)  200       2 "
   {{Cl|PRINT}} "    ....................... "
   {{Cl|PRINT}} "    ......................."
   {{Cl|PRINT}} "    7      320    200   17 "
   {{Cl|PRINT}} "    7      320    200     16 "
   {{Cl|PRINT}} "    8      640    200   17 "
   {{Cl|PRINT}} "    8      640    200     16 "
   {{Cl|PRINT}} "    9    (640)  350   17 "
   {{Cl|PRINT}} "    9    (640)  350     16 "
   {{Cl|PRINT}} "  10    (640)  350     1 "
   {{Cl|PRINT}} "  10    (640)  350       4 "
   {{Cl|PRINT}} "  11    (640)  480     2 "
   {{Cl|PRINT}} "  11    (640)  480       2 "
   {{Cl|PRINT}} "  12    (640)  480   17 "
   {{Cl|PRINT}} "  12    (640)  480     16 "
   {{Cl|PRINT}} "  13      320    200   19 "
   {{Cl|PRINT}} "  13      320    200     256 "
   {{Cl|PRINT}} "     {{Cl|_NEWIMAGE}} screens      "
   {{Cl|PRINT}} " QB64 _NEWIMAGE screens      "
   {{Cl|PRINT}} "  14    (600)  (600)   1  _32"
   {{Cl|PRINT}} "  14    (600, 600, 32)   32 bit"
   {{Cl|PRINT}} "  15    (800)  (600)   19  _256"
   {{Cl|PRINT}} "  15    (800, 600, 256) 256 "
   {{Cl|PRINT}} "  16    (900)  (600)       _ 13"
   {{Cl|PRINT}} "  16    (900, 600, 13256 " 'simulate screen 13
  {{Cl|PRINT}} "  17    (900, 600, 10)   4 " 'simulate screen 10
   {{Cl|PRINT}}
   {{Cl|PRINT}}
   {{Cl|PRINT}} "{{Cl|SCREEN}} ="; scr&; "mode ="; ScreenMode&; "Colors ="; colors
   {{Cl|PRINT}} "{{Cl|SCREEN}} ="; scr&; "mode ="; ScreenMode&; "Colors ="; colors
Line 28: Line 28:


   {{Cl|IF...THEN|IF}} ScreenMode& {{Cl|THEN}} {{Cl|CIRCLE}} (200, 100), 50, 3
   {{Cl|IF...THEN|IF}} ScreenMode& {{Cl|THEN}} {{Cl|CIRCLE}} (200, 100), 50, 3
   {{Cl|INPUT}} "Enter a {{Cl|SCREEN}} mode 0 to 16: ", scrn$
   {{Cl|INPUT}} "Enter a {{Cl|SCREEN}} mode 0 to 17(18 quits): ", scrn$


   scr& = {{Cl|VAL}}(scrn$): mode = -1
   scr& = {{Cl|VAL}}(scrn$)
   {{Cl|IF...THEN|IF}} (scr& < 3 {{Cl|OR (boolean)|OR}} scr& > 6) {{Cl|AND (boolean)|AND}} scr& < 14 {{Cl|THEN}} {{Cl|SCREEN}} scr&
   {{Cl|IF...THEN|IF}} (scr& < 3 {{Cl|OR (boolean)|OR}} scr& > 6) {{Cl|AND (boolean)|AND}} scr& < 14 {{Cl|THEN}} {{Cl|SCREEN}} scr&
   {{Cl|IF...THEN|IF}} scr& = 14 {{Cl|THEN}} handle& = {{Cl|_NEWIMAGE}}(600, 600, 32): {{Cl|SCREEN}} handle&
   {{Cl|IF...THEN|IF}} scr& = 14 {{Cl|THEN}} handle& = {{Cl|_NEWIMAGE}}(600, 600, 32): {{Cl|SCREEN}} handle&
   {{Cl|IF...THEN|IF}} scr& = 15 {{Cl|THEN}} handle& = {{Cl|_NEWIMAGE}}(800, 600, 256): {{Cl|SCREEN}} handle&
   {{Cl|IF...THEN|IF}} scr& = 15 {{Cl|THEN}} handle& = {{Cl|_NEWIMAGE}}(800, 600, 256): {{Cl|SCREEN}} handle&
   {{Cl|IF...THEN|IF}} scr& = 16 {{Cl|THEN}} handle& = {{Cl|_NEWIMAGE}}(900, 600, 13): {{Cl|SCREEN}} handle&
   {{Cl|IF...THEN|IF}} scr& = 16 {{Cl|THEN}} handle& = {{Cl|_NEWIMAGE}}(900, 600, 13): {{Cl|SCREEN}} handle&
  {{Cl|IF...THEN|IF}} scr& = 17 {{Cl|THEN}} handle& = {{Cl|_NEWIMAGE}}(900, 600, 10): {{Cl|SCREEN}} handle&


 
{{Cl|LOOP}} {{Cl|UNTIL}} scr& > 17
{{Cl|LOOP}} {{Cl|UNTIL}} scr& > 16


{{Cl|FUNCTION}} ScreenMode&
{{Cl|FUNCTION}} ScreenMode&
{{Cl|SHARED}} colors 'share number of colors with main program
mode& = -1
mode& = -1
{{Cl|_DEST}} 0 'destination zero always current screen mode
{{Cl|OUT}} {{Cl|&H}}3C7, 1 'set attribute to read
{{Cl|OUT}} {{Cl|&H}}3C7, 1 'set attribute to read
{{Cl|FOR...NEXT|FOR}} colors = 1 {{Cl|TO}} 18 'get RGB color settings
{{Cl|FOR...NEXT|FOR}} colors = 1 {{Cl|TO}} 18 'get RGB color settings
Line 46: Line 48:
   {{Cl|IF...THEN|IF}} red + grn + blu = 0 {{Cl|AND (boolean)|AND}} colors <> 16 {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}}
   {{Cl|IF...THEN|IF}} red + grn + blu = 0 {{Cl|AND (boolean)|AND}} colors <> 16 {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}}
{{Cl|NEXT}}
{{Cl|NEXT}}
wide& = _WIDTH: deep& = {{Cl|_HEIGHT}}
wide& = {{Cl|_WIDTH (function)|_WIDTH}}: deep& = {{Cl|_HEIGHT}} 'get screen dimension
{{Cl|IF...THEN|IF}} colors = 17 {{Cl|AND (boolean)|AND}} wide& = 80 {{Cl|OR (boolean)|OR}} wide& = 40 {{Cl|THEN}} mode& = 0
{{Cl|IF...THEN|IF}} colors = 4 {{Cl|THEN}} mode& = 1
{{Cl|IF...THEN|IF}} colors = 4 {{Cl|THEN}} mode& = 1
{{Cl|IF...THEN|IF}} colors = 2 {{Cl|AND (boolean)|AND}} deep& = 200 {{Cl|THEN}} mode& = 2
{{Cl|IF...THEN|IF}} colors = 2 {{Cl|AND (boolean)|AND}} deep& = 200 {{Cl|THEN}} mode& = 2
Line 57: Line 58:
{{Cl|IF...THEN|IF}} colors = 17 {{Cl|AND (boolean)|AND}} deep& = 480 {{Cl|THEN}} mode& = 12
{{Cl|IF...THEN|IF}} colors = 17 {{Cl|AND (boolean)|AND}} deep& = 480 {{Cl|THEN}} mode& = 12
{{Cl|IF...THEN|IF}} colors > 17 {{Cl|AND (boolean)|AND}} wide& = 320 {{Cl|AND (boolean)|AND}} deep& = 200 {{Cl|THEN}} mode& = 13
{{Cl|IF...THEN|IF}} colors > 17 {{Cl|AND (boolean)|AND}} wide& = 320 {{Cl|AND (boolean)|AND}} deep& = 200 {{Cl|THEN}} mode& = 13
{{Cl|IF...THEN|IF}} colors = 1 {{Cl|AND (boolean)|AND}} (wide& <> 640 {{Cl|OR (boolean)|OR}} deep& <> 350) {{Cl|THEN}} mode& = {{Cl|_DEST}} ' 32 bit
{{Cl|IF...THEN|IF}} {{Cl|_PIXELSIZE}} = 0 {{Cl|THEN}} mode& = 0 'screen 0 any size
{{Cl|IF...THEN|IF}} colors > 17 {{Cl|AND (boolean)|AND}} (wide& <> 320 {{Cl|OR (boolean)|OR}} deep& <> 200) {{Cl|THEN}} mode& = {{Cl|_DEST}} ' 256 colors
{{Cl|IF...THEN|IF}} mode& = -1 {{Cl|THEN}} mode& = {{Cl|_DEST}} 'must be a QB64 screen
{{Cl|IF...THEN|IF}} colors = 1 {{Cl|THEN}} colors = 4
{{Cl|IF...THEN|IF}} colors = 17 {{Cl|THEN}} colors = 16
{{Cl|IF...THEN|IF}} colors > 17 {{Cl|THEN}} colors = 256
{{Cl|IF...THEN|IF}} {{Cl|_PIXELSIZE}} = 4 {{Cl|THEN}} colors = 32
ScreenMode& = mode&
ScreenMode& = mode&
{{Cl|END FUNCTION}}
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
: ''Note:'' Function returns the negative handle value with up to 256 colors or 32 for 32 bit in QB64 [[_NEWIMAGE]] screens.


''See also:''
''See also:''
* [[SCREEN]]
* [[SCREEN]]
* [[SCREEN (function)]]
* [[SCREEN (function)]]
* [[_NEWIMAGE]]
* [[_PIXELSIZE]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 08:53, 21 June 2012

Screen Mode Detection Function


DO PRINT PRINT PRINT " Screen W H Colors " PRINT " 0 80/40 (25) 16 " PRINT " 1 (320) (200) 4 " PRINT " 2 (640) 200 2 " PRINT " ........................ " PRINT " 7 320 200 16 " PRINT " 8 640 200 16 " PRINT " 9 (640) 350 16 " PRINT " 10 (640) 350 4 " PRINT " 11 (640) 480 2 " PRINT " 12 (640) 480 16 " PRINT " 13 320 200 256 " PRINT " QB64 _NEWIMAGE screens " PRINT " 14 (600, 600, 32) 32 bit" PRINT " 15 (800, 600, 256) 256 " PRINT " 16 (900, 600, 13) 256 " 'simulate screen 13 PRINT " 17 (900, 600, 10) 4 " 'simulate screen 10 PRINT PRINT "SCREEN ="; scr&; "mode ="; ScreenMode&; "Colors ="; colors PRINT "_DEST ="; _DEST IF ScreenMode& THEN CIRCLE (200, 100), 50, 3 INPUT "Enter a SCREEN mode 0 to 17(18 quits): ", scrn$ scr& = VAL(scrn$) IF (scr& < 3 OR scr& > 6) AND scr& < 14 THEN SCREEN scr& IF scr& = 14 THEN handle& = _NEWIMAGE(600, 600, 32): SCREEN handle& IF scr& = 15 THEN handle& = _NEWIMAGE(800, 600, 256): SCREEN handle& IF scr& = 16 THEN handle& = _NEWIMAGE(900, 600, 13): SCREEN handle& IF scr& = 17 THEN handle& = _NEWIMAGE(900, 600, 10): SCREEN handle& LOOP UNTIL scr& > 17 FUNCTION ScreenMode& SHARED colors 'share number of colors with main program mode& = -1 _DEST 0 'destination zero always current screen mode OUT &H3C7, 1 'set attribute to read FOR colors = 1 TO 18 'get RGB color settings red = INP(&H3C9): grn = INP(&H3C9): blu = INP(&H3C9) IF red + grn + blu = 0 AND colors <> 16 THEN EXIT FOR NEXT wide& = _WIDTH: deep& = _HEIGHT 'get screen dimension IF colors = 4 THEN mode& = 1 IF colors = 2 AND deep& = 200 THEN mode& = 2 IF colors = 17 AND wide& = 320 AND deep& = 200 THEN mode& = 7 IF colors = 17 AND wide& = 640 AND deep& = 200 THEN mode& = 8 IF colors = 17 AND deep& = 350 THEN mode& = 9 IF colors = 1 AND wide& = 640 AND deep& = 350 THEN mode& = 10 IF colors = 2 AND deep& = 480 THEN mode& = 11 IF colors = 17 AND deep& = 480 THEN mode& = 12 IF colors > 17 AND wide& = 320 AND deep& = 200 THEN mode& = 13 IF _PIXELSIZE = 0 THEN mode& = 0 'screen 0 any size IF mode& = -1 THEN mode& = _DEST 'must be a QB64 screen IF colors = 1 THEN colors = 4 IF colors = 17 THEN colors = 16 IF colors > 17 THEN colors = 256 IF _PIXELSIZE = 4 THEN colors = 32 ScreenMode& = mode& END FUNCTION

Code by Ted Weissgerber
Note: Function returns the negative handle value with up to 256 colors or 32 for 32 bit in QB64 _NEWIMAGE screens.


See also:



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