| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi group 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 |
|
#2
| |||
| |||
| On Aug 22, 6:51 am, "Schjaer" <j...@nospambyg.dtu.dk> wrote: > Hi group > > 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? 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. |
|
#3
| |||
| |||
| On 8/22/08 7:51 AM, in article g8m988$h8h$1@news.net.uni-c.dk, "Schjaer" <jsj@nospambyg.dtu.dk> wrote: > Hi group > > 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 > > 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. |
|
#4
| |||
| |||
| Op Fri, 22 Aug 2008 13:51:35 +0200 schreef "Schjaer" <jsj@nospambyg.dtu.dk>: >Hi group > >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 > 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.juda_ANTISPAM_@tiscali.nl (ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk) |
|
#5
| |||
| |||
| "Jim Leonard" <MobyGamer@gmail.com> wrote in message news:a186b1b0-ec00-4eab-8b0f-22d2c39ce821@56g2000hsm.googlegroups.com... > On Aug 22, 6:51 am, "Schjaer" <j...@nospambyg.dtu.dk> wrote: >> Hi group >> >> 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? > > Incorrect colors are the result of MS-DOS painting just the characters > while leaving the color attributes alone. 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. |
|
#6
| |||
| |||
| "winston19842005" <bjjlyates@NOSPAMbellsouth.net> wrote in message news:C4D471FD.81D8%bjjlyates@NOSPAMbellsouth.net.. . > On 8/22/08 7:51 AM, in article g8m988$h8h$1@news.net.uni-c.dk, "Schjaer" > <jsj@nospambyg.dtu.dk> wrote: > >> Hi group >> >> 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 >> >> > It might help to know the OS. 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. |
|
#7
| |||
| |||
| "Bart" <broersma.juda_ANTISPAM_@tiscali.nl> wrote in message news:0192b45eiuafcrihmvs3aarrh956ebchg6@4ax.com... > Op Fri, 22 Aug 2008 13:51:35 +0200 schreef "Schjaer" > <jsj@nospambyg.dtu.dk>: > >>Hi group >> >>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 >> > 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); 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? |
|
#8
| |||
| |||
| On 2008-08-28, Schjaer <jsj@nospambyg.dtu.dk> wrote: >>> screen colors are restored or not at exit. Any suggestions? >> >> Incorrect colors are the result of MS-DOS painting just the characters >> while leaving the color attributes alone. > > But what colors does MS-DOS use to paint the characters? 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. |
|
#9
| |||
| |||
| On Aug 28, 6:23*am, "Schjaer" <j...@nospambyg.dtu.dk> wrote: > "Jim Leonard" <MobyGa...@gmail.com> wrote in message > > news:a186b1b0-ec00-4eab-8b0f-22d2c39ce821@56g2000hsm.googlegroups.com... > > > > > On Aug 22, 6:51 am, "Schjaer" <j...@nospambyg.dtu.dk> wrote: > >> Hi group > > >> 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? > > > Incorrect colors are the result of MS-DOS painting just the characters > > while leaving the color attributes alone. > > But what colors does MS-DOS use to paint the characters? 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). |
|
#10
| |||
| |||
| "Jim Leonard" <MobyGamer@gmail.com> wrote in message news:73c1404a-b9eb-4690-8e14-7d2c50b4705b@k37g2000hsf.googlegroups.com... On Aug 28, 6:23 am, "Schjaer" <j...@nospambyg.dtu.dk> wrote: > "Jim Leonard" <MobyGa...@gmail.com> wrote in message > > news:a186b1b0-ec00-4eab-8b0f-22d2c39ce821@56g2000hsm.googlegroups.com... > > > > > On Aug 22, 6:51 am, "Schjaer" <j...@nospambyg.dtu.dk> wrote: > >> Hi group > > >> 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? > > > Incorrect colors are the result of MS-DOS painting just the characters > > while leaving the color attributes alone. > > But what colors does MS-DOS use to paint the characters? 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 |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.