After exiting a DOS program that manipulates the screen colors I sometimes
(but not always) don't get the same colors back that existed before invoking
the program. I have tried to save then restore TextAttr within the program
but that seems to have no effect. I have observed this in both Turbo Pascal
7.0 and FreePascal. It seems to be a question of sheer luck if the original
screen colors are restored or not at exit. Any suggestions?
Jorgen
Incorrect colors are the result of MS-DOS painting just the characters
while leaving the color attributes alone. Your DOS program probably
recolors the entire screen, then dumps you at the prompt without
cleaning up.
It might help to know the OS.
I've noticed programs that did not exhibit this behavior under Windows
versions prior to XP did not exhibit this behavior, whereas the same program
(same configuration) run under "DOS" under XP or Vista sometimes have
strange color changes.
Do you save and restore the current videomode?
In plain DOS...
var CurrentMode: Byte Absolute $0000:$0449;
SavedMode: Byte;
Somewhere at startup
...
SavedMode := CurrentMode;
...
Somewhre at cleanup in the end
...
if CurrentMode <> VMode then TextMode(SavedMode);
...
This has worked for me in the past.
Bart
--
Bart Broersma
broersma.ju...@tiscali.nl
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)
But what colors does MS-DOS use to paint the characters?
>Your DOS program probably
> recolors the entire screen, then dumps you at the prompt without
> cleaning up.
No, I save TextAttr upon entry then restore it just before exit.
It seems to be a problem only under genuine DOS (6.22), not under Windows
DOS-prompt.
> I've noticed programs that did not exhibit this behavior under Windows
> versions prior to XP did not exhibit this behavior, whereas the same
> program
> (same configuration) run under "DOS" under XP or Vista sometimes have
> strange color changes.
So far I have noticed it only under real DOS.
I can't use the TextMode procedure because it clears the screen. Besides,
according to the TP 7 manual it hasn't got anything to do with colors, only
with the number of screen lines, etc. Do you think it affects the colors
after exiting a Pascal program?
As far as I can remember, it uses some attribute to fill new lines when the
screen scrolls up, and just prints characters without changing the attribute
otherwise.
One of the reasons that in BBS times people often had ansi.sys loaded, and
an ansi escape sequence setting the attribute in their (4dos) prompt.
>>Your DOS program probably
>> recolors the entire screen, then dumps you at the prompt without
>> cleaning up.
>
> No, I save TextAttr upon entry then restore it just before exit.
And what "textattr" is this? The Crt one is just a variable for internal
use. Afaik it doesn't correspond with some systemwide value.
It doesn't use color, it only prints characters. That's why, if the
screen was recolored, the characters will show up using the previous
coloring.
> >Your DOS program probably
> > recolors the entire screen, then dumps you at the prompt without
> > cleaning up.
>
> No, I save TextAttr upon entry then restore it just before exit.
That's internal to CRT only.
What you should be doing is saving the screen contents when starting,
then restoring them on exit (along with the correct screen mode and
cursor location).
That sounds like the solution. How does one do that?
Jorgen
IIRC it does partially. In general you are right, but (either dos or bios)
has some color to fill newly inserted lines with.
<URL:http://www.merlyn.demon.co.uk/programs/shower.pas> does that.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.
See www.trsek.com/pas/trsek procedure put_window, get_window. It's
solve your problem.
TrSek