Announcement

Collapse
No announcement yet.

Changing from color to mono

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing from color to mono

    Is there a few a lines of code that I can write at the start of my program to
    determine if the computer monitor is set up for monochrome?
    If not, what statement can I write at the beginning of the program
    that when the operator makes a choice the program will automatically
    go to mono mode even though it has color code?
    Thanks,
    Keith

  • #2
    Code:
    SUB ScrnInit                                                                  
            LOCAL VidMode%                                                        
            REG 1, &H0F00                     'AH = 15                            
            CALL INTERRUPT &H10               'video services                     
            VidMode% = REG(1) AND &H00FF      'AL                                 
            IF VidMode% <> 7 THEN 
                    'COLOR
            ELSE
                    'MONO 
            END IF
    END SUB
    It's also a good idea to have a method (like a config file or a commandline option) that can be used to "force" the use of monochrome, because some video cards do not report their mode accurately. For example, if a system is using a "mono vga" monitor, the video card thinks that the display is in color when it's really not. Lots of old laptops also have this problem. Also, visually-impared users will appreciate the ability to use a high-contrast mono mode.

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited April 14, 2000).]
    "Not my circus, not my monkeys."

    Comment


    • #3
      Check the online help on internal variables on pbvScrnCard, which can
      help you identify color display adapters. However, there's no way to tell
      if someone's using, say, a grayscale monitor with a VGA card, so it's wise
      to allow setting monochrome mode explicitly. Many programs use /B
      as a command-line switch to select "black & white" (mono) mode.

      There is no one statement you can use to change the color settings
      for your entire program. Instead, you need to set up a list of variables
      to use when setting the color. At the start of your program, when you
      detect whether the display is color or mono, you can set the color
      variables accordingly.

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Tom's right, of course. I forgot that pbvScrnCard was added at PB/DOS version 3.2 (I think). The code I posted will work with all versions of PB/DOS, including FirstBASIC, but if you've got a recent version of PB examining the first bit of pbvScrnCard is certainly easier.

        Code:
        IF (pbvScrnCard AND 1) THEN
           PRINT "M0NO"
        ELSE
           PRINT "COLOR"
        END IF
        As far as a "global switch" goes, some of my PB/DOS programs use a function I call SetColors instead of the COLOR statement. That way, I "centralize" all COLOR operations and it's easy to add a global switch that uses black and white instead of colors.

        This has worked pretty well for me...

        Code:
        	%Black           = 0
        	%LowBlue         = 1
        	%LowGreen        = 2
        	%LowCyan         = 3
        	%LowRed          = 4
        	%LowMagenta      = 5
        	%Brown           = 6
        	%LowWhite        = 7
         
        	%Gray            = 8
        	%HighBlue        = 9
        	%HighGreen       = 10
        	%HighCyan        = 11
        	%HighRed         = 12
        	%HighMagenta     = 13
        	%Yellow          = 14
        	%HighWhite       = 15
        
        	%BlackBlink      = 16
        	%LowBlueBlink    = 17
        	%LowGreenBlink   = 18
        	%LowCyanBlink    = 19
        	%LowRedBlink     = 20
        	%LowMagentaBlink = 21
        	%BrownBlink      = 22
        	%LowWhiteBlink   = 23
         
        	%GrayBlink       = 24
        	%HighBlueBlink   = 25
        	%HighGreenBlink  = 26
        	%HighCyanBlink   = 27
        	%HighRedBlink    = 28
        	%HighMagentaBlink= 29
        	%YellowBlink     = 30
        	%HighWhiteBlink  = 31
         
        SUB SetColors(BYVAL ForeColor%,BYVAL BackColor%)
        	SHARED MonoDisplay%  'set to nonzero value for mono display
        	IF MonoDisplay% THEN
        		IF BackColor% <> %Black THEN
        			'we have to do an inverse of some types for Mono VGA
        			BackColor% = %LowWhite            
        			IF ForeColor% > %HighWhite THEN 
                                        ForeColor% = %BlackBlink
                                ELSE 
                                        ForeColor% = %Black
                                END IF
        		ELSE
        			IF ForeColor% MOD 16 <> 0 THEN 
                                        ForeColor% = ((ForeColor%\8)*8)+7
                                END IF
        		END IF
        	END IF
        	COLOR ForeColor%,BackColor%
        END SUB
        Then you use SetColors instead of COLOR everywhere in your program.

        --Eric

        ------------------
        Perfect Sync: Perfect Sync Development Tools
        Email: mailto:[email protected][email protected]</A>



        [This message has been edited by Eric Pearson (edited April 14, 2000).]
        "Not my circus, not my monkeys."

        Comment


        • #5
          FYI, pbvScrnCard was introduced in PowerBASIC 3.00a.

          ------------------
          Alan C. Earnshaw
          Information Management Systems, Inc.
          Alan C. Earnshaw
          Information Management Systems, Inc.
          http://www.infoms.com

          Comment

          Working...
          X