VOGONS

Common searches


First post, by massasauga

User metadata
Rank Newbie
Rank
Newbie

I've gotten DOSBox to work and I have been able to tweak the parameters. But I have also noticed that on the Welcome Screen when DOSBox starts up, there are fields with blue background, colored titles, etc. I am sure there is an escape sequence that can be used to change colors in forground and background in the command line, but I can't find any documentation covering this. I have tried emulating Hercules Graphics and can switch between green, brown, or white, but control is limited with what you can do. I am familiar with ANSI escape sequences to tweak colors in prompts, but none of these work with DOSBox.

Is there any documentation explaining how to control command line font colors?

Attachments

Reply 1 of 4, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

You need to have 4dos or so to make use of the ansi codes. Dosbox on its own doesn't add them (except for the hardcoded stuff)

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for OS X (10.4-10.14 ppc/intel 32/64bit) codesigned for gatekeeper
DOSBox SVN with SDL2 snapshot for OS X (10.7-10.14 intel 64bit) codesigned for gatekeeper

Reply 2 of 4, by dreamer_

User metadata
Rank Member
Rank
Member
massasauga wrote on 2020-01-06, 01:22:

I've gotten DOSBox to work and I have been able to tweak the parameters. But I have also noticed that on the Welcome Screen when DOSBox starts up, there are fields with blue background, colored titles, etc. I am sure there is an escape sequence that can be used to change colors in forground and background in the command line, but I can't find any documentation covering this. I have tried emulating Hercules Graphics and can switch between green, brown, or white, but control is limited with what you can do. I am familiar with ANSI escape sequences to tweak colors in prompts, but none of these work with DOSBox.

Is there any documentation explaining how to control command line font colors?

AFAIK no, there's no documentation - but ANSI codes work fine… except you can't type them in DOSBox terminal. But if you'll type literal escape code in the file and display it (e.g. using C:\>type msg_file or echo inside autoexec section of .conf file) then the text will be coloured.

Example:

Create a new file using vi/vim (e.g. called msg) To type in escape code you need to: change to insert mode, press Ctrl-V, type in escape sequence, e.g.: i<Ctrl-V>27 will show up as ^[ (literally a byte containing 27 - ESC character in ASCII encoding). Knowing this, type in following text:

^[[32;1mCOLOUR^[[0m NOCOLOUR

Then:

$ dosbox .
C:\>type msg

(and word COLOUR will be coloured 😉)

| ← Ceci n'est pas une pipe
dosbox-staging

Reply 3 of 4, by massasauga

User metadata
Rank Newbie
Rank
Newbie

Thanks, dreamer.
I still need to play with this a little more, but I have been able to make a few quick test files. I am now able to switch the prompt colors by using the type command. This is pretty much what I was looking for. After I refine my process, I will get back and pass along what I have found out.

Thanks also to Dominus.

Reply 4 of 4, by massasauga

User metadata
Rank Newbie
Rank
Newbie

Here is some more information that I found out by experimenting.
The numbers corresponding to colors of type displayed are:

Foreground Background
30 black 40
31 red 41
32 green 42
33 yellow 43
34 blue 44
35 magenta 45
36 cyan 46
37 white 47

Colors in foreground can be brightened by preceding the color code with a 1 followed by a semicolon (;)
e.g. dark red with a yellow background would be coded as <esc>27[0;31;43mThis text is red with yellow background.<esc>27[0m
When you enter this in vi, it will appear as ^[[0;31;43mThis test is red with yellow background.^[[0m
The number "27" (which is the escape code for color) will not appear in vi when you type it.
The "m" at the end of each escape sequence is a terminator of the sequence. When you type the "[" character two of them will appear.
The "0;" preceding a foreground character is for the dark color of the character, and it can be left out, as far as I can tell.
If you replace the "0" with a "1" this will brighten the color. Background colors do not brighten.

I believe I have gotten this all down correctly. If anyone reading this has any changes or additions to this, please feel free
to comment or rewrite as needed.