- @echo off
- setlocal enabledelayedexpansion
- set /a _er=0
- set /a _n=0
- set _ln=%~4
- goto init
- :howuse ---------------------------------------------------------------
- echo ------------------
- echo ECOL.BAT - ver 1.0
- echo ------------------
- echo Print colored text in batch script
- echo Written by BrendanLS - http://640kbworld.forum.st
- echo.
- echo Syntax:
- echo ECOL.BAT [COLOR] [X] [Y] "Insert your text"
- echo COLOR value must be a hexadecimal number
- echo.
- echo Example:
- echo ECOL.BAT F0 20 30 "The 640KB World Forum"
- echo.
- echo Enjoy ;^)
- goto quit
- :error ----------------------------------------------------------------
- set /a "_er=_er | (%~1)"
- goto quit
- :geth -----------------------------------------------------------------
- set return=
- set bts=%~1
- :hshift ---------------------------------------------------------------
- set /a "nn = bts & 0xff"
- set return=!h%nn%!%return%
- set /a "bts = bts >> 0x8"
- if %bts% gtr 0 goto hshift
- goto quit
- :init -----------------------------------------------------------------
- if "%~4"=="" call :error 0xff
- (
- set /a _cl=0x%1
- call :error !errorlevel!
- set _cl=%1
- call :error "0x!_cl! ^>^> 8"
- set /a _px=%2
- call :error !errorlevel!
- set /a _py=%3
- call :error !errorlevel!
- ) 2>nul 1>&2
- if !_er! neq 0 (
- echo.
- echo ERROR: value exception "!_er!" occurred.
- echo.
- goto howuse
- )
- set nsys=0123456789abcdef
- set /a _val=-1
- for /l %%a in (0,1,15) do (
- for /l %%b in (0,1,15) do (
- set /a "_val += 1"
- set byte=!nsys:~%%a,1!!nsys:~%%b,1!
- set h!_val!=!byte!
- )
- )
- set /a cnb=0
- set /a cnl=0
- :parse ----------------------------------------------------------------
- set _ch=!_ln:~%_n%,1!
- if "%_ch%"=="" goto perform
- set /a "cnb += 1"
- if %cnb% gtr 7 (
- set /a cnb=0
- set /a "cnl += 1"
- )
- set bln%cnl%=!bln%cnl%! "!_ch!" %_cl%
- set /a "_n += 1"
- goto parse
- :perform --------------------------------------------------------------
- set /a "in = ((_py * 160) + (_px * 2)) & 0xffff"
- call :geth %in%
- set ntr=!return!
- set /a jmp=0xe
- @for /l %%x in (0,1,%cnl%) do (
- set bl8086%%x=eb800:!ntr! !bln%%x!
- set /a "in=!jmp! + 0x!ntr!"
- call :geth !in!
- set ntr=!return!
- set /a jmp=0x10
- )
- (
- echo.%bl80860%&echo.%bl80861%&echo.%bl80862%&echo.%bl80863%&echo.%bl80864%
- echo.q
- )|debug >nul 2>&1
- :quit