Background Colors in Text Mode

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
DDastardly71
Coder
Posts: 22
Joined: Fri Oct 17, 2008 6:56 pm
Location: U.S.A.

Background Colors in Text Mode

Post by DDastardly71 »

I have seen some programs that used colors beyond &H8 for its background like the old Norton Utilities that used &HF. How can I do this programmatically?

Can I do this strictly QB or with the aid of ASSEMBLY? Can you provide a code?
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

You can use extra colors by setting blinking mode off which turns intensity on. which allows colors 9 through 15 to be used as background color.

Here's a link to a microsoft article on the subject with sample QB code (which works with pds, vb-dos and qb 4.5

http://support.microsoft.com/kb/50945
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
User avatar
DDastardly71
Coder
Posts: 22
Joined: Fri Oct 17, 2008 6:56 pm
Location: U.S.A.

Post by DDastardly71 »

Thanks for that quick reply but I forgot to mention that I needed it for SCREEN 0.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

SCREEN 0 is the only mode with high intensity blinking colors above 15 that does not need Interrupt code.

By default when running full-screen, this makes the foreground blink rather than making the background brighter.
(But this also happens if you use CALL INTERRUPTX.) You can also:

T% = INP(&H3DA) 'read first (discarded)
OUT &H3C0, &H10
T% = INP(&H3C1) 'use in final setting
OUT &H3C0, &H10
OUT &H3C1, T% AND NOT 8

to switch from flashing to background-intensity mode.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
DDastardly71
Coder
Posts: 22
Joined: Fri Oct 17, 2008 6:56 pm
Location: U.S.A.

Post by DDastardly71 »

I don't mean to sound like a noob but how do you insert this into your program.

This is what I want to accomplish...

COLOR 0, 15

without it blinking. Please include a sample code.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

That should work, but you have to use CLS to spread the background over the screen. That is one problem with screen 0. The background will only show up under PRINTs otherwise.

COLOR 0, 15: CLS

PRINT "Hello"

It should NOT blink as only the forecolors above 15 blink! Just add 16 to a normal color. If you want to stop the blinking, add my code above at the beginning of the program. The background CANNOT BLINK!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Harry Potter
Veteran
Posts: 111
Joined: Sat Feb 21, 2009 8:19 am
Location: New York, U.S.

Post by Harry Potter »

COLOR 0, 15: CLS
The COLOR command takes the blinking option in the foreground color parameter as Foreground Color + 16. To have a high-intensity background, add 16 to the foreground color and use Color AND 7 as the background color.
Joseph Rose, a.k.a. Harry Potter
Creating magic in the computer community...or at least striving to! :(
Post Reply