SHARE
TWEET

CMD.EXE - To print colored text using the debug.exe (Win32)

bl8086 Aug 2nd, 2012 (edited) 2,021 Never
  1. @echo off
  2. rem Script written by BrendanSilva [bl8086]
  3. rem You need DEBUG.EXE executable in your system.
  4. setlocal enabledelayedexpansion
  5. set /a _er=0
  6. set /a _n=0
  7. set _ln=%~4
  8. goto init
  9. :howuse ------------------------------------------------------------------------
  10.     echo.
  11.     echo ECOL.BAT - v2.0
  12.     echo Print colored text as batch script without temporary files.
  13.     echo Written by bl8086
  14.     echo.
  15.     echo Syntax:
  16.     echo ECOL.BAT [COLOR] [X] [Y] "Insert your text here"
  17.     echo COLOR value must be a hexadecimal number like "color /?" information
  18.     echo.
  19.     echo Example:
  20.     echo ECOL.BAT F0 20 30 "640K ought to be enough for anybody."
  21.     echo.
  22.     goto :eof
  23. :error ------------------------------------------------------------------------
  24.     set /a "_er=_er | (%~1)"
  25.     goto :eof
  26. :gcnvhx ------------------------------------------------------------------------
  27.     set _cvhx=
  28.     set /a _cvint=%~1
  29. :cnvhx
  30.     set /a "_gch = _cvint & 0xF"
  31.     set _cvhx=!nsys:~%_gch%,1!%_cvhx%
  32.     set /a "_cvint = _cvint >> 4"
  33.     if !_cvint! neq 0 goto cnvhx
  34.     goto :eof
  35. :init --------------------------------------------------------------------------
  36.     if "%~4"=="" call :error 0xff
  37.     (
  38.         set /a _cl=0x%1
  39.         call :error !errorlevel!
  40.         set _cl=%1
  41.         call :error "0x!_cl! ^>^> 8"
  42.         set /a _px=%2
  43.         call :error !errorlevel!
  44.         set /a _py=%3
  45.         call :error !errorlevel!
  46.     ) 2>nul 1>&2
  47.     if !_er! neq 0 (
  48.         echo.
  49.         echo ERROR: value exception "!_er!" occurred. Check memory out.
  50.         echo.
  51.         goto howuse
  52.     )
  53.     set nsys=0123456789ABCDEF
  54.     set /a cnb=0
  55.     set /a cnl=0
  56.     set _cvhx=0
  57.     set _cvint=0
  58.     set _cvmhx=0
  59. :parse -------------------------------------------------------------------------
  60.     set _ch=!_ln:~%_n%,1!
  61.     if "%_ch%"=="" goto perform
  62.     set /a "cnb += 1"
  63.     if %cnb% gtr 7 (
  64.         set /a cnb=0
  65.         set /a "cnl += 1"
  66.     )
  67.     set bln%cnl%=!bln%cnl%! "!_ch!" %_cl%
  68.     set /a "_n += 1"
  69.     goto parse
  70. :perform -----------------------------------------------------------------------
  71.     set /a "in = ((_py * 0xA0) + (_px << 1)) & 0xFFFF"
  72.     call :gcnvhx %in%
  73.     set ntr=!_cvhx!
  74.     set /a jmp=0xe
  75.     set bl8086str=echo.h 0 0
  76.     @for /l %%x in (0,1,%cnl%) do (
  77.         set bl8086str=!bl8086str!^&echo.eb800:!ntr! !bln%%x!
  78.         set /a "in=!jmp! + 0x!ntr!"
  79.         call :gcnvhx !in!
  80.         set ntr=!_cvhx!
  81.         set /a jmp=0x10
  82.     )
  83.     (
  84.     echo %bl8086str%
  85.     echo.q
  86.     ) |debug >nul 2>&1
RAW Paste Data
Top