Difference between revisions of "ScreenMode"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 7: Line 7:
   {{Cl|PRINT}}
   {{Cl|PRINT}}
   {{Cl|PRINT}} "  Screen    W      H    C  "
   {{Cl|PRINT}} "  Screen    W      H    C  "
   {{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}} "    _NEWIMAGE screens      "
   {{Cl|PRINT}} "  14    (600)  (600)   1  _32"
   {{Cl|PRINT}} "  14    (600)  (600)   32 bit"
   {{Cl|PRINT}} "  15    (800)  (600)   19 _256"
   {{Cl|PRINT}} "  15    (800)  (600)  256 "
   {{Cl|PRINT}} "  16    (900)  (600)       _ 13"
   {{Cl|PRINT}} "  16    (900)  (600) 256 "
   {{Cl|PRINT}}
   {{Cl|PRINT}}
   {{Cl|PRINT}} "{{Cl|SCREEN}} ="; scr&; "mode ="; ScreenMode&; "Colors ="; colors
   {{Cl|PRINT}} "{{Cl|SCREEN}} ="; scr&; "mode ="; ScreenMode&; "Colors ="; colors
Line 29: Line 29:
   {{Cl|INPUT}} "Enter a {{Cl|SCREEN}} mode 0 to 16: ", scrn$
   {{Cl|INPUT}} "Enter a {{Cl|SCREEN}} mode 0 to 16: ", 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&
Line 40: Line 40:
{{Cl|FUNCTION}} ScreenMode&
{{Cl|FUNCTION}} ScreenMode&
SHARED colors
SHARED colors
mode& = -1
{{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 59: Line 58:
{{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}} 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}} 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}} colors > 17 {{Cl|AND (boolean)|AND}} (wide& <> 320 {{Cl|OR (boolean)|OR}} deep& <> 200) {{Cl|THEN}} mode& = {{Cl|_DEST}} ' 256 colors
IF colors = 17 THEN colors = 16
{{Cl|IF...THEN|IF}} colors = 1 {{Cl|AND (boolean)|AND}} mode& < -1 {{Cl|THEN}} colors = 32 '32 bit colors
IF colors = 19 THEN colors = 256
{{Cl|IF...THEN|IF}} colors = 1 {{Cl|AND (boolean)|AND}} mode& = 10 {{Cl|THEN}} colors = 4
{{Cl|IF...THEN|IF}} colors = 17 {{Cl|THEN}} colors = 16  
{{Cl|IF...THEN|IF}} colors = 19 {{Cl|THEN}} colors = 25
ScreenMode& = mode&
ScreenMode& = mode&
{{Cl|END FUNCTION}}
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{CodeEnd}}
: ''Note:'' Function returns 256 colors or 32 for 32 bit QB64 [[_NEWIMAGE]] screens.





Revision as of 22:58, 20 June 2012

Screen Mode Detection Function


DO PRINT PRINT PRINT " Screen W H C " 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 " _NEWIMAGE screens " PRINT " 14 (600) (600) 32 bit" PRINT " 15 (800) (600) 256 " PRINT " 16 (900) (600) 256 " 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 16: ", 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& LOOP UNTIL scr& > 16 FUNCTION ScreenMode& SHARED colors 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 IF colors = 17 AND wide& = 80 OR wide& = 40 THEN mode& = 0 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 colors = 1 AND (wide& <> 640 OR deep& <> 350) THEN mode& = _DEST ' 32 bit IF colors > 17 AND (wide& <> 320 OR deep& <> 200) THEN mode& = _DEST ' 256 colors IF colors = 1 AND mode& < -1 THEN colors = 32 '32 bit colors IF colors = 1 AND mode& = 10 THEN colors = 4 IF colors = 17 THEN colors = 16 IF colors = 19 THEN colors = 25 ScreenMode& = mode& END FUNCTION

Note: Function returns 256 colors or 32 for 32 bit QB64 _NEWIMAGE screens.


See also:



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