Help with program that emulate VT100 terminal

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with program that emulate VT100 terminal

#16 Post by Aacini » 20 Jul 2014 10:05

einstein1969 wrote:Nice work Antonio! :D

If you need to debug you can use [url]

I have probed but there are some problem on some lines and the color should be adjusted

[image]

I have tried some years ago on ubuntu this is a snapshot of an user that developed a color adjust.

[image]

OT
For the vt100 emulator (in real time, not file input) have you some suggestion?
/OT :D

einstein1969


The link to the US-SLURG.ANS file fail because timeout. I tried to browse the sixteencolors.net site, but it is too slow and there are not indications of the type of file shown. Could you post here the US-SLURG.ANS file? I think it is not very large.

There is a complete Ansi driver for Windows; it is called ANSICON and you may download it from this site: "ANSICON provides ANSI escape sequences for Windows console programs. It provides much the same functionality as ANSI.SYS does for MS-DOS."

EDIT: This is the direct link to the site to download ANSICON: http://adoxa.altervista.org/ansicon/

Antonio

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Help with program that emulate VT100 terminal

#17 Post by einstein1969 » 20 Jul 2014 12:48

Yes, the site is slow and rotten .

This ?way back machine

einstein1969

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with program that emulate VT100 terminal

#18 Post by Aacini » 20 Jul 2014 14:14

Ok. Ansi files downloaded, thanks!

Several of the .ANS files use an attribute code that confuses me. As I understood it, each "ESC [ ... m" sequence set the attribute from the point it appears on cancelling the previous attribute, NOT combining the new attribute with the previous one. If this is true, then the 0 attribute: "all attributes off" is meaningless, because any way the new attribute will cancel the previous one, and the zero may be just ignored.

However, is possible that I misunderstood the way to use the "ESC [ ... m" sequence and it must combine the new attribute with the previous one, in which case the 0 attribute is useful. I need this information in order to modify my AnsiSys.exe program, because an initial zero in the attribute, like in "ESC[0;36m", cause the problem.

Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with program that emulate VT100 terminal

#19 Post by foxidrive » 20 Jul 2014 19:57

The MSDOS V6.22 help.com and help.hlp contains useful reference material.

I have a copy if you can't locate it.

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Help with program that emulate VT100 terminal

#20 Post by dbenham » 21 Jul 2014 08:19

einstein1969 wrote:For the vt100 emulator (in real time, not file input) have you some suggestion?

Simply pipe the output of your program that generates ANSI escape sequences to ansisys.exe

Code: Select all

yourProgram | ansisys.bat

It works great with the brainf*** hanoi program.


Dave Benham

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with program that emulate VT100 terminal

#21 Post by foxidrive » 07 Nov 2014 21:22

Antonio,
There is an AnsiSys.exe bug that I seem to have found:

When ESC[40;37m is used then it uses the default screen colour - which is green in my case - where is should be using white.



I modified the display portion of your example batch file - people may find it easier to see how AnsiSys.exe can be used.

A modified version of "Ansi Color Table.bat"

Code: Select all

@echo off
setlocal EnableDelayedExpansion

if not exist AnsiSys.exe (
   echo Extracting AnsiSys.exe
   call :ExtractBinaryFile AnsiSys.exe
   echo AnsiSys.exe file created
   echo/
)


rem The next variable must have an Ascii ESC (27) after the equals sign
set "ESC="

cls
set b=1
(
echo Using attribute %b%
echo/
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo/
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo/
)| AnsiSys.exe

set b=5
(
echo Using attribute %b%
echo/
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo/
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo/
)| AnsiSys.exe

set b=5;1
(
echo Using attribute %b%
echo/
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo/
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo/
)| AnsiSys.exe



pause
cls


rem Create an Ansi table of the 256 foreground/background color combinations

echo/
echo                     Ansi color table of console text colors
echo/

set line=
for /L %%x in (40,1,47) do (
   for /L %%y in (30,1,37) do set "line=!line! %ESC%[%%x;%%ym   %%x;%%y"
echo !line!| AnsiSys.exe
set line=
)

echo/                                       
echo %ESC%[1;33m  use 1 for highlite| AnsiSys.exe
echo/                                       


echo/
set line=
for /L %%x in (40,1,47) do (
   for /L %%y in (30,1,37) do set "line=!line! %ESC%[1;%%x;%%ym 1;%%x;%%y"
echo !line!| AnsiSys.exe
set line=
)


pause
cls

echo/                                       
echo %ESC%[1;33m  add 5 for bright| AnsiSys.exe
echo/

set line=
for /L %%x in (40,1,47) do (
   for /L %%y in (30,1,37) do set "line=!line! %ESC%[5;%%x;%%ym 5;%%x;%%y"
echo !line!| AnsiSys.exe
set line=
)

echo/
set line=
for /L %%x in (40,1,47) do (
   for /L %%y in (30,1,37) do set "line=!line! %ESC%[5;1;%%x;%%ym 5;1;%%x;%%y"
echo !line!| AnsiSys.exe
set line=
)


pause
goto :EOF


rem Extract Binary File from hexadecimal digits placed in a "resource" in this .bat file

:ExtractBinaryFile filename.ext[.cab]
setlocal EnableDelayedExpansion
set "start="
set "end="
for /F "tokens=1,3 delims=:=>" %%a in ('findstr /N /B "</*resource" "%~F0"') do (
   if not defined start (
      if "%%~b" equ "%~1" set start=%%a
   ) else if not defined end set end=%%a
)
(for /F "skip=%start% tokens=1* delims=:" %%a in ('findstr /N "^" "%~F0"') do (
   if "%%a" == "%end%" goto decodeHexFile
   echo %%b
)) > "%~1.hex"
:decodeHexFile

rem Modified code based on :genchr subroutine
type nul > t.tmp
(for /F "usebackq" %%a in ("%~1.hex") do (
   set input=%%a
   set i=0
   for /L %%I in (0,2,120) do for %%i in (!i!) do if "!input:~%%i,1!" neq "" (
      set hex=!input:~%%i,2!
      set /A i+=2
      if "!hex:~0,1!" neq "[" (
         set /A chr=0x!hex!
         if not exist !chr!.chr call :genchr !chr!
         type !chr!.chr
      ) else (
         for /L %%J in (1,1,5) do for %%i in (!i!) do if "!input:~%%i,1!" neq "]" (
            set "hex=!hex!!input:~%%i,1!"
            set /A i+=1
         )
         if not exist 0.chr call :genchr 0
         for /L %%J in (1,1,!hex:~1!) do type 0.chr
         set /A i+=1
      )
   )
)) > "%~1"
del *.chr
del t.tmp temp.tmp
del "%~1.hex"

rem Expand created file if extension is .cab
set "filename=%~1"
if /I "%filename:~-4%" equ ".cab" (
   expand "%filename%" "%filename:~0,-4%" > NUL
   del "%filename%"
)

exit /B


:genchr
REM This code creates one single byte. Parameter: int
REM Teamwork of carlos, penpen, aGerman, dbenham
REM Tested under Win2000, XP, Win7, Win8
set "options=/d compress=off /d reserveperdatablocksize=26"
if %~1 neq 26 (
   makecab %options% /d reserveperfoldersize=%~1 t.tmp %~1.chr > nul
   type %~1.chr | ( (for /l %%N in (1,1,38) do pause)>nul & findstr "^" > temp.tmp )
   >nul copy /y temp.tmp /a %~1.chr /b
) else (
   copy /y nul + nul /a 26.chr /a >nul
)
exit /B


<resource id="AnsiSys.exe">
4d5a900003[3]04[3]ffff[2]b8[7]40[35]c0[3]0e1fba0e00b409cd21b8014ccd21546869732070726f6772616d2063616e6e6f74206265207275
6e20696e20444f53206d6f64652e0d0d0a24[7]5159150315387b5015387b5015387b509b2768501b387b50e918695017387b505269636815387b50
[24]5045[2]4c0103001294ca53[8]e0000f010b01050c0006[3]04[7]10[3]10[3]20[4]40[2]10[3]02[2]04[7]04[8]40[3]04[6]03[5]10[2]10
[4]10[2]10[6]10[11]2c20[2]3c[84]20[2]2c[27]2e74657874[3]2404[3]10[3]06[3]04[14]20[2]602e7264617461[2]5201[3]20[3]02[3]0a
[14]40[2]402e64617461[3]3001[3]30[3]02[3]0c[14]40[2]c0[464]558bec83c4e86af5e8ed03[2]a3133040008d45ea50ff3513304000e8d303
[2]668b45f266a31b304000fce88f03[2]e8ae03[2]803e007429668b06662d30303c0976082c073c0f76022c1f86c43c0976082c073c0f76022c1f
d51066a31b3040006a01682a3140006a00ff152420400083c40c660bc00f842e01[2]803d2a3140001b75526a01682a3140006a00ff152420400083
c40c803d2a3140005b75c133c0a3253140008d3d25314000e8ff[3]aa80fc3b74f58ac48d3d00304000b903[3]8bd9f2ae75962bd94bff149d033040
00eb8a803d2a3140000a743d833d17304000ff75178d45ea50ff3513304000e8f902[2]8b45eea3173040006a01682a3140006a01ff151c20400083
c40cff051d304000e944ffffff833d1d3040[2]744066833d1b3040000774368d3d2130400066a11b3040008b0d1d304000f366ab682b314000ff35
17304000ff351d3040006821304000ff3513304000e89d02[2]33c0a31d30400048a317304000c6052a3140000d6a01682a3140006a01ff151c2040
0083c40cc6052a3140000a6a01682a3140006a01ff151c20400083c40ce9b7feffff6a00e83a02[2]32ff6a01682a3140006a00ff152420400083c4
0ca02a3140003c30726d3c3977692c308af86a01682a3140006a00ff152420400083c40ca02a3140003c30724a3c3977462c308ae7d50a8af86a0168
2a3140006a00ff152420400083c40ca02a3140003c3072233c39771f2c308ae7d50a8af86a01682a3140006a00ff152420400083c40ca02a3140008a
e786c4c3680f304000ff152020400083c40433c0a31d30400048a317304000c3833d1d3040[2]744066833d1b3040000774368d3d2130400066a11b
3040008b0d1d304000f366ab682b314000ff3517304000ff351d3040006821304000ff3513304000e85e01[2]33c0a31d30400048a317304000a025
314000fec80fb6d8c1e310a026314000fec8660fb6d853ff3513304000e82701[2]c3833d1d3040[2]744066833d1b3040000774368d3d2130400066
a11b3040008b0d1d304000f366ab682b314000ff3517304000ff351d3040006821304000ff3513304000e8e3[3]33c0a31d30400048a31730400066
bb0700803d253140[2]747b6633db8d3525314000ac0ac0746d3c01750580cb08ebf23c05750580cb80ebe93c1e72e53c2577242c1e3c017504b004
eb163c037504b006eb0e3c047504b001eb063c067502b0030ad8ebbd3c2872b93c2f77b52c283c017504b004eb163c037504b006eb0e3c047504b001
eb063c067502b003c0e0040ad8eb8e66891d1b304000c3e847[3]8bf08a06463c2275098a06463c2275f9eb0c8a06463c20740484c075f54ec38a06
463c2074f94ec3ccff2500204000ff2504204000ff2508204000ff250c204000ff2510204000ff2514204000ff2524204000ff251c204000ff252020
40[477]9420[2]a220[2]c020[2]d020[2]ec20[2]0a21[6]3221[2]3c21[2]2a21[6]6820[10]1c21[3]20[2]8420[10]4621[2]1c20[22]9420[2]
a220[2]c020[2]d020[2]ec20[2]0a21[6]3221[2]3c21[2]2a21[6]9b004578697450726f6365737300f500476574436f6e736f6c6553637265656e
427566666572496e666f[2]6a0147657453746448616e646c65[2]6d02536574436f6e736f6c65437572736f72506f736974696f6e[2]f202577269
7465436f6e736f6c654f757470757441747472696275746500e600476574436f6d6d616e644c696e6541006b65726e656c33322e646c6c[2]73015f
7265616400f8015f7772697465[2]b00273797374656d[2]6d73766372742e646c6c[176]484a6d5f12400043124000da124000434c53[5][4xff]07
[484]
</resource>

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with program that emulate VT100 terminal

#22 Post by Aacini » 09 Nov 2014 09:28

foxidrive wrote:Antonio,
There is an AnsiSys.exe bug that I seem to have found:

When ESC[40;37m is used then it uses the default screen colour - which is green in my case - where is should be using white.


You are right, foxi! I fixed this problem and posted the new version of "Ansi Color Table.bat" in the same place of the original, so just delete AnsiSys.exe program, download the Batch file again and run it.

This "bug" was caused by a misinterpretation of how each one of the Ansi attributes should be processed. In the first version, each time a new attribute appear I "initialized" the attribute with zero, that means "black on black", and then insert the new attribute; this produces a black color on the unassigned attributes (foreground or background), but an unassigned attribute should mean "default color" if COLOR command was used. In the new version I keep the "previous" attribute and combine it with the new given one. However, I can't still duplicate the same colors of some images, and I think this is caused by how the "light colors" 1 and 5 attributes are combined. I can't find an exact description of how Ansi attributes must be processed and I don't like to do multiple tests.

Perhaps someone could help me to fix this problem posting some cases of attributes not correctly processed and the way they must appear. In this case, don't forget to first download the new version!

Antonio

PS - I like your modification! :D

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with program that emulate VT100 terminal

#23 Post by foxidrive » 09 Nov 2014 13:55

Aacini wrote:I fixed this problem and posted the new version of "Ansi Color Table.bat"

It's fixed the bug I mentioned, but something broke in the highlite implementations.

The left is how my modified script appears with the new binary - and the right is how it appears with the old binary.
Note that two lines are now identical, the top line in attribute 5 and the top line in attribute 5;1

Image Image

Sorry for the large images.

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with program that emulate VT100 terminal

#24 Post by Aacini » 11 Nov 2014 14:34

foxidrive wrote:
Aacini wrote:I fixed this problem and posted the new version of "Ansi Color Table.bat"

It's fixed the bug I mentioned, but something broke in the highlite implementations.

The left is how my modified script appears with the new binary - and the right is how it appears with the old binary.
Note that two lines are now identical, the top line in attribute 5 and the top line in attribute 5;1


Yes, the way to fix this "bug" was to keep previous attribute and combine it with the new one; this means that if the new attribute does not include a certain part (where the 4 possible parts are: foreground color, background color, foreground light 1 and background light 5), then such part is preserved from previous attribute. However, the COLOR command modify the value we take as "previous attribute". If COLOR command set Light Green on Black, for example, then the "previous attribute" includes the Foreground Light part, so any text will be displayed with this attribute set even if the new attribute does not include the 1 part. Exist the 0 attribute that is defined as "Reset / Normal text", that is, when 0 attribute appear it clear any previous attribute and set the current one as 7 (White on Black).

Note that previous description REFERS TO THE WAY I WRITEN MY ANSISYS.EXE PROGRAM, because I couldn't find a precise description on the way these details must be managed! I think that the only way to clear this point is running a test program in any computer that have a reliable Ansi driver (like an old MS-DOS machine) and take the output as base. The Batch file below, that is your modified version with just one section more, may serve for this purpose. If anyone have a computer with an Ansi driver, I'll appreciate it if you may run this program and post an image of the output screen.

Code: Select all

@echo off
setlocal

rem The next variable must have an Ascii ESC (27) after the equals sign
set "ESC="

cls
echo Set (default) screen colors to Light Green on Black (COLOR 0A)
color 0A
echo/

(
echo With no attributes = Both colors normal
echo/
echo        31    32     33     34      35     36     37
echo      %ESC%[31m Red %ESC%[32m Green %ESC%[33m Yellow %ESC%[34m Blue %ESC%[35m Magenta %ESC%[36m Cyan %ESC%[37m White %ESC%[m
echo/
echo        41    42     43     44      45     46     47
echo      %ESC%[37;41m Red %ESC%[37;42m Green %ESC%[37;43m Yellow %ESC%[37;44m Blue %ESC%[37;45m Magenta %ESC%[37;46m Cyan %ESC%[37;47m White %ESC%[m
echo/
)| AnsiSys.exe

set b=1
(
echo Using attribute %b% = Foreground color light
echo/
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo/
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo/
)| AnsiSys.exe

set b=5
(
echo Using attribute %b% = Background color light
echo/
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo/
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo/
)| AnsiSys.exe

set b=5;1
(
echo Using attribute %b% = Both colors light
echo/
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo/
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo/
)| AnsiSys.exe

pause
color
cls

Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with program that emulate VT100 terminal

#25 Post by foxidrive » 12 Nov 2014 05:32

Image

I think I got this right: Left is the original AnsiSys.exe Right is the new AnsiSys.exe


I had to modify the batch file to run in Win 98SE

Code: Select all

@echo off

rem The next variable must have an Ascii ESC (27) after the equals sign
set ESC=

 >%temp%\file.tmp echo Set (default) screen colors to Light Green on Black (COLOR 0A)
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo With no attributes = Both colors normal
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        31    32     33     34      35     36     37
>>%temp%\file.tmp echo      %ESC%[31m Red %ESC%[32m Green %ESC%[33m Yellow %ESC%[34m Blue %ESC%[35m Magenta %ESC%[36m Cyan %ESC%[37m White %ESC%[m
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        41    42     43     44      45     46     47
>>%temp%\file.tmp echo      %ESC%[37;41m Red %ESC%[37;42m Green %ESC%[37;43m Yellow %ESC%[37;44m Blue %ESC%[37;45m Magenta %ESC%[37;46m Cyan %ESC%[37;47m White %ESC%[m
>>%temp%\file.tmp echo.
set b=1
>>%temp%\file.tmp echo Using attribute %b% = Foreground color light
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        31    32     33     34      35     36     37
>>%temp%\file.tmp echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        41    42     43     44      45     46     47
>>%temp%\file.tmp echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
>>%temp%\file.tmp echo.
set b=5
>>%temp%\file.tmp echo Using attribute %b% = Background color light
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        31    32     33     34      35     36     37
>>%temp%\file.tmp echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        41    42     43     44      45     46     47
>>%temp%\file.tmp echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
>>%temp%\file.tmp echo.
set b=5;1
>>%temp%\file.tmp echo Using attribute %b% = Both colors light
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        31    32     33     34      35     36     37
>>%temp%\file.tmp echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
>>%temp%\file.tmp echo.
>>%temp%\file.tmp echo        41    42     43     44      45     46     47
>>%temp%\file.tmp echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
>>%temp%\file.tmp echo.
type %temp%\file.tmp|AnsiSy1.exe
pause
type %temp%\file.tmp|AnsiSys.exe
pause

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with program that emulate VT100 terminal

#26 Post by foxidrive » 12 Nov 2014 05:38

It occurs to me that you might want to see what a plain ANSI.SYS driver does with the code - here is the plain batch version:

Image

Code: Select all

@echo off

rem The next variable must have an Ascii ESC (27) after the equals sign
set ESC=

echo Set (default) screen colors to Light Green on Black (COLOR 0A)
echo.
echo With no attributes = Both colors normal
echo.
echo        31    32     33     34      35     36     37
echo      %ESC%[31m Red %ESC%[32m Green %ESC%[33m Yellow %ESC%[34m Blue %ESC%[35m Magenta %ESC%[36m Cyan %ESC%[37m White %ESC%[m
echo.
echo        41    42     43     44      45     46     47
echo      %ESC%[37;41m Red %ESC%[37;42m Green %ESC%[37;43m Yellow %ESC%[37;44m Blue %ESC%[37;45m Magenta %ESC%[37;46m Cyan %ESC%[37;47m White %ESC%[m
echo.
set b=1
echo Using attribute %b% = Foreground color light
echo.
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo.
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo.
set b=5
echo Using attribute %b% = Background color light
echo.
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo.
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo.
set b=5;1
echo Using attribute %b% = Both colors light
echo.
echo        31    32     33     34      35     36     37
echo      %ESC%[%b%;31m Red %ESC%[%b%;32m Green %ESC%[%b%;33m Yellow %ESC%[%b%;34m Blue %ESC%[%b%;35m Magenta %ESC%[%b%;36m Cyan %ESC%[%b%;37m White %ESC%[m
echo.
echo        41    42     43     44      45     46     47
echo      %ESC%[%b%;37;41m Red %ESC%[%b%;37;42m Green %ESC%[%b%;37;43m Yellow %ESC%[%b%;37;44m Blue %ESC%[%b%;37;45m Magenta %ESC%[%b%;37;46m Cyan %ESC%[%b%;37;47m White %ESC%[m
echo.
pause

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with program that emulate VT100 terminal

#27 Post by Aacini » 12 Nov 2014 07:31

Aacini wrote:If anyone have a computer with an Ansi driver, I'll appreciate it if you may run this program and post an image of the output screen.

foxidrive wrote:It occurs to me that you might want to see what a plain ANSI.SYS driver does with the code - here is the plain batch version:

This is exactly the information I need, excepting for one detail: How the plain ANSI.SYS driver show previous image WHEN COLOR COMMAND HAD SET A LIGHT FOREGROUND COLOR?

Code: Select all

echo Set (default) screen colors to Light Green on Black (COLOR 0A)
color 0A
echo/

Please, include previous lines in the plain batch version (below CLS command) and run it again with the plain ANSI.SYS driver...

Antonio

PS - Please, post an image a little bit larger...

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with program that emulate VT100 terminal

#28 Post by foxidrive » 12 Nov 2014 08:03

I would but Win98 and Dos don't have the color command.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with program that emulate VT100 terminal

#29 Post by foxidrive » 12 Nov 2014 09:02

The nearest I can do is to use another ansi sequence to set the green-on-black colour at the start - is that ok?

Image

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with program that emulate VT100 terminal

#30 Post by Aacini » 12 Nov 2014 09:10

foxidrive wrote:I would but Win98 and Dos don't have the color command.

This means that my AnsiSys.exe driver may show attributes when COLOR command changed the default colors IN ANY WAY I WISH because none can tell my that my colors are wrong! :shock: "Wrong when compared vs. what?" :roll:

Perhaps we could set a standard right now. What do you think that should be the right way? Preserve on not preserve the previous Foregroung Light color (1) and Background Light color (5) attributes when a new attribute is set and it does not include 1 or 5?

Knows anybody how AnsiCon.sys program manage this point?

Antonio

Post Reply