I hope this "Retro awesomness.bat" is what you are looking for:
Code: Select all
@echo off
setlocal enableExtensions disableDelayedExpansion
:: set active, utf-7 and utf8 codepages
set /A "utf7Cp=65000, utf8Cp=65001"
set "cp="
for /f "delims=." %%a in ('2^>nul chcp') do for %%b in (%%a) do set "cp=%%b"
if not defined cp for /f "tokens=2" %%a in ('2^>nul chcp') do set "cp=%%~a"
>nul chcp %utf8Cp%
:: define filenames
set "utf7DataFile=data.utf-7.txt"
set "dataFile=data.dat"
:: create chinese chcp seperator char
set "data="
setlocal enableDelayedExpansion
:: create glyph data using only characters in { '+', '-', '/', '0'-'9', 'A'-'Z', 'a'-'z' }
>nul chcp %utf8Cp%
rem >"%dataFile%" cmd /a /c^<nul set /p "=+/v8-"
rem >nul chcp %utf7Cp%
set "data="
rem <"%dataFile%" set /p "data="
rem >nul chcp %utf8Cp%
set "data=!data!+AF8mOiY7JmUmZiZjJmAgIiXYJcsl2SZCJkAmaiZrJjwluiXEIZUgPAC2AKclrCGoIZEhkyGSIZAiHyGUJbIlvA- +ACEAIgAjAC"
set "data=!data!QAJQAm-'()+ACo-+-,-./0123456789:+ADsAPAA9AD4-?+AEA-ABCDEFGHIJKLMNOPQRSTUVWXYZ+AFsAXABdAF4AXwBg-abcde"
set "data=!data!fghijklmnopqrstuvwxyz+AHsAfAB9AH4jAgDHAPwA6QDiAOQA4ADlAOcA6gDrAOgA7wDuAOwAxADFAMkA5gDGAPQA9gDyAPsA+Q"
set "data=!data!D/ANYA3ACiAKMApSCnAZI-+AOEA7QDzAPoA8QDRAKoAugC/IxAArAC9ALwAoQCrALslkSWSJZMlAiUkJWElYiVWJVUlYyVRJVclX"
set "data=!data!SVcJVslECUUJTQlLCUcJQAlPCVeJV8lWiVUJWklZiVgJVAlbCVnJWglZCVlJVklWCVSJVMlayVqJRglDCWIJYQljCWQJYADsQDfA"
set "data=!data!5MDwAOjA8MAtQPEA6YDmAOpA7QiHgPGA7UiKQ-+ImEAsSJlImQjICMhAPciSACwIhkAtyIaIH8AsiWg-+AKA-"
:: index 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
:: 0 1 2 3 4 5 6 7 8 9
cmd /d /a /e:on /v:on /c">"^!dataFile^!" echo(^!data^!"
set "data="
:: read data from file
>nul chcp %utf7Cp%
set "data="
<"%dataFile%" set /p "data="
>nul chcp %utf8Cp%
::initialize
:: set "Characters=!data:~1,31!!data:~33,222!"
:: removed NUL, BEL, TAB, SUB, ESC, breaking whitespace, non breaking whitespace
set "Characters=!data:~1,6!!data:~8,1!!data:~10,16!!data:~28,4!!data:~33,222!"
set "Colors=123456789abcdef"
call :strlen "Characters" "TotalCharAmount"
call :strlen "Colors" "TotalColorAmount"
for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
mode con cols=80 lines=25
title Retro awesomness.
:loop
set /a "c=!random! %% !TotalCharAmount!, i=!random! %% %TotalColorAmount%, j=!random! %% %TotalColorAmount%, x=(!random! %% 80) + 1, y=(!random! %% 25) + 1"
set /a "color=0x!Colors:~%i%,1!, bgcolor=0x!Colors:~%j%,1!"
<nul set /p "=%ESC%[%y%;%x%f%ESC%[38;5;%color%;48;5;%bgcolor%m!Characters:~%c%,1!%ESC%[0m"
goto :loop
goto :eof
:strlen
:: %~1 environment variable that holds the string to test
:: %~2 environment variable to store the string length to
setlocal enableExtensions enableDelayedExpansion
if not defined %~1 (
set "%~2=-1"
) else (
set "len=0"
for /l %%a in (12,-1,0) do (
set /a "len|=(1<<%%~a)"
for %%b in (!len!) do if "!%~1:~%%~b,1!" == "" set /a "len^=(1<<%%~a)"
)
)
endlocal & set /a "%~2=%len%+1"
goto :eof
Sidenotes:
You need to disable "Legacy console mode" else the vt100 ANSI escape sequences won't work.
When you are using raster fonts then the glyphs used should be system dependent.
So giving CP1252 characters and saying "their CP437 equivalents" is of not much use,
because CP437 isn't used if you are using raster fonts (so i hope the glyphs i used are ok).
I used these characters (as these are the defaults used by my system for raster fonts):
Code: Select all
_☺☻♥♦♣♠•◘○◙♂♀♪♫☼
►◄↕‼¶§▬↨↑↓→←∟↔▲▼
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~⌂
ÇüéâäàåçêëèïîìÄÅ
ÉæÆôöòûùÿÖÜ¢£¥₧ƒ
áíóúñѪº¿⌐¬½¼¡«»
░▒▓│┤╡╢╖╕╣║╗╝╜╛┐
└┴┬├─┼╞╟╚╔╩╦╠═╬╧
╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀
αßΓπΣσµτΦΘΩδ∞φε∩
≡±≥≤⌠⌡÷≈°∙·√ⁿ²■
Just for comparison - the following ones are used by CP 437 if not using raster fonts:
Code: Select all
☺☻♥♦♣♠•◘○◙♂♀♪♫☼
►◄↕‼¶§▬↨↑↓→←∟↔▲▼
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~⌂
ÇüéâäàåçêëèïîìÄÅ
ÉæÆôöòûùÿÖÜø£Ø׃
áíóúñѪº¿®¬½¼¡«»
░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐
└┴┬├─┼ãÃ╚╔╩╦╠═╬¤
ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀
ÓßÔÒõÕµþÞÚÛÙýݯ´
±‗¾¶§÷¸°¨·¹³²■
Edited:
Corrected "!Characters:~%i%,1!" to "!Characters:~%c%,1!" so the actual character index c is used to select the next character, instead of the foreground color index i.
Removed NUL, BEL, TAB, SUB, ESC, breaking whitespace, non breaking whitespace from the environment variable Characters to avoid bad sideeffects; see
viewtopic.php?f=3&t=8582&p=57984#p57984.