Old 05-08-2008, 05:27 PM   #1
MusicallyInspired

MusicallyInspired's Avatar
DOS, Turbo C, and Text Colors
I know it's possible to change the background and text colours on the entire screen, but I want to have my DOS program (not a Windows command line program, written in Turbo C) make certain strings of text one colour and other strings another colour without changing the entire screen. How is that done?
__________________
Roland SC-55 Music Packs Website
- MediaFire mirror for Duke3D expansions
More SC-55 music packs coming soon...
MusicallyInspired is offline  
Old 05-08-2008, 05:31 PM   #2
Superczar

Superczar's Avatar
Re: DOS, Turbo C, and Text Colors
The 'textcolor' function IIRC
__________________
'F*** Fresch!!!'.
Superczar is offline  
Old 05-08-2008, 05:35 PM   #3
MusicallyInspired

MusicallyInspired's Avatar
Re: DOS, Turbo C, and Text Colors
Ok, I know that changes the colours of the whole screen but how would I use that for specific text strings only?
__________________
Roland SC-55 Music Packs Website
- MediaFire mirror for Duke3D expansions
More SC-55 music packs coming soon...
MusicallyInspired is offline  
Old 05-08-2008, 05:41 PM   #4
Superczar

Superczar's Avatar
Re: DOS, Turbo C, and Text Colors
Use it when you are going to print the mesage to screen and then right after change it back or to the next color you are going to use, it's not supposed to affect any text already on screen.
__________________
'F*** Fresch!!!'.
Superczar is offline  
Old 05-08-2008, 05:43 PM   #5
MusicallyInspired

MusicallyInspired's Avatar
Re: DOS, Turbo C, and Text Colors
Ahhh I see. That would explain why textcolor() would only work for me when I used clrscr(). Thanks I'll try that. Is there another one that affects the whole screen?
__________________
Roland SC-55 Music Packs Website
- MediaFire mirror for Duke3D expansions
More SC-55 music packs coming soon...
MusicallyInspired is offline  
Old 05-08-2008, 05:48 PM   #6
Superczar

Superczar's Avatar
Re: DOS, Turbo C, and Text Colors
You mean change the text color of anything that is already on screen? I don't know, the only other one I see is to change the background color, try textbackground, it may set the whole screen...
__________________
'F*** Fresch!!!'.
Superczar is offline  
Old 05-08-2008, 06:20 PM   #7
MusicallyInspired

MusicallyInspired's Avatar
Re: DOS, Turbo C, and Text Colors
Your way works. And if I want to do it to the whole screen I can just do clrscr(). Thanks.
__________________
Roland SC-55 Music Packs Website
- MediaFire mirror for Duke3D expansions
More SC-55 music packs coming soon...
MusicallyInspired is offline  
Old 05-08-2008, 06:24 PM   #8
Superczar

Superczar's Avatar
Re: DOS, Turbo C, and Text Colors
Out of curiosity, whatcha makin?
__________________
'F*** Fresch!!!'.
Superczar is offline  
Old 05-08-2008, 06:52 PM   #9
MusicallyInspired

MusicallyInspired's Avatar
Re: DOS, Turbo C, and Text Colors
Nothing special. Just little programs to gain some experience. I'm just getting into it so I don't know a lot yet. I wrote the Duke Nukem Text Adventure in a thread in the Duke Nukem section, a BMI weight calculator, and a baby gender predictor based on old wives' tales.
__________________
Roland SC-55 Music Packs Website
- MediaFire mirror for Duke3D expansions
More SC-55 music packs coming soon...
MusicallyInspired is offline  
Old 05-08-2008, 08:10 PM   #10
Black Yeti
Post Re: DOS, Turbo C, and Text Colors
In a DOS Program you can directly access the screen buffer. The memory location is B800H:0000H. The bytes represent the screen from top left to bottom right. One byte for the character and one byte for the color (four bits are for the foreground color and four for the background color) then the next character follows.

You could write a setCharacter() function like this for a 80x25 Screen:

Code:
/* row and col start at zero */
void setCharacter(char col, char row, char character, char color) {
    char far *scrn = ( char far * ) 0xB8000000;
    unsigned int offset = row*80*2 + col*2;
    scrn[offset] = character;
    scrn[offset + 1] = color;
}
I haven't tested the code, it's been a while since the last time I wrote a DOS porgram. But I hope you understand the concept.
Black Yeti is offline  
Old 05-08-2008, 08:49 PM   #11
Cipher

Cipher's Avatar
Re: DOS, Turbo C, and Text Colors
Wow, its been a long time since I seen "far pointers."

I still don't know what they do.
__________________
I never got to know half of you half as much as I'd have liked, and I never liked half of you half as much as you deserved.

Christian Death Metal FTW!
Cipher is offline  
Old 05-08-2008, 08:55 PM   #12
Black Yeti
Re: DOS, Turbo C, and Text Colors
A pointer is basically just an address into the memory. A far pointer includes a segment selector while an ordinary pointer only contains the address within a certain sector. This article explains it a bit: http://wiki.answers.com/Q/What_is_th...r_pointer_in_C
Black Yeti is offline  
Old 05-09-2008, 09:40 AM   #13
MusicallyInspired

MusicallyInspired's Avatar
Re: DOS, Turbo C, and Text Colors
How does one hide the text cursour on-screen (not a mouse cursour) in C?
__________________
Roland SC-55 Music Packs Website
- MediaFire mirror for Duke3D expansions
More SC-55 music packs coming soon...
MusicallyInspired is offline  
Old 05-09-2008, 11:07 AM   #14
Black Yeti
Re: DOS, Turbo C, and Text Colors
This is done via an interrupt call: http://www.ctyme.com/intr/rb-0086.htm

But to be true I don't actually know how to do one in Turbo C.
Black Yeti is offline  
Old 05-09-2008, 01:02 PM   #15
MusicallyInspired

MusicallyInspired's Avatar
Re: DOS, Turbo C, and Text Colors
EDIT: Never mind..
__________________
Roland SC-55 Music Packs Website
- MediaFire mirror for Duke3D expansions
More SC-55 music packs coming soon...
MusicallyInspired is offline  
Old 05-09-2008, 04:19 PM   #16
8IronBob

8IronBob's Avatar
Re: DOS, Turbo C, and Text Colors
I remember this, it was cool to do all sorts of graphics with text and color. Borland was one of the only brands of C IDE/Compiler combos that actually used their own graphics generation engines, that was one thing I liked about Turbo C/C++.
__________________
PC Specs: Antec 900 ATX Case, Gigabyte 790GX Mobo, AMD Phenom II x4 955, EVGA 2GB GTX 680, Corsair Vengeance 16GB DDR3-1600, 160GB X25-M SSD, 500GB+640GB WD Caviar Blacks, 8x LG Blu-ray burner, 3D Vision 2 Kit/3DTV Play, Toshiba TL32515U, Logitech Z-2300 Speakers, DAS Pro K/B, Logitech MX518 Mouse, Win 7 Pro x64, Wacom Bamboo Fun Tablet.
8IronBob is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:46 PM.

Page generated in 0.12719011 seconds (100.00% PHP - 0% MySQL) with 15 queries

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Website is 1987-2014 Apogee Software, Ltd.
Ideas and messages posted here become property of Apogee Software Ltd.