Another amazing porting...
Posted: 25 Oct 2023 02:30
Hi to all,
It's been a long time since I left the dos alone due to my bad health. A year ago I was working on this port and I didn't have the strength to publish it. I have to thank aGerman and others because they allowed me to set the fonts. If you have any suggestions let me know. I also have a version in development which uses convolution to make everything more pleasant.
PS:There is a little bug in setting the fonts and I hope that aGerman or someone else will help me solve it
PS2: I forgot to mention that it uses fractal compression.
It's been a long time since I left the dos alone due to my bad health. A year ago I was working on this port and I didn't have the strength to publish it. I have to thank aGerman and others because they allowed me to set the fonts. If you have any suggestions let me know. I also have a version in development which uses convolution to make everything more pleasant.
Code: Select all
echo off & setlocal enableDelayedExpansion
mode CON: COLS=128 LINES=96 & chcp 65001 >nul
call :init_setfont
rem %rem setfont% 3 Lucida Console
%setfont% 3 Consolas
for /F "Tokens=1 delims==" %%v in ('set') do if not %%v==ComSpec if not %%v==Path if not %%v==TMP set "%%v="
call :macros
:: Hide the cursor
<nul set /p "=!ESC![?25l"
set /a "imageSize.Width=128, imageSize.Height=96, H=imageSize.Height-1, L=imageSize.Width-1"
set "c0=255;226;137" & set "c1=233;158;069" & set "c2=165;090;000" & set "c3=000;000;000"
set /A seed = 0x7EC80000, dir=i=0
set max=56475
set tot=0
set "t0=!time: =0!"
(
echo Awo3vi+bBysOPPWbipEbCw69k3i4PrBacLUCgNCxnNIgkyCcPREm1t8Zl/WQo6NH
echo ivcIWSmtoyx9/A191XowUdQxVCuyQrEUipYpFLDxUywEEwoJPrvpFhh3uOKscoDH
echo UkCNPD6vrWMeFLI9I4/Ae6+dMS6WziWnnjcsRCu5ITk=
) >"%tmp%\s-mon.txt"
certutil -decode "%tmp%\s-mon.txt" "%tmp%\s-mon.bin" >nul
for %%F in ("%tmp%\s-mon.bin") do <nul >"%tmp%\s-mon.tmp" set /p ".=@" & set ds=%%~zF
for /l %%n in (1,1,32) do if !ds! gtr 1 set /a "ds/=2" & type "%tmp%\s-mon.tmp" >>"%tmp%\s-mon.tmp"
set /a expectedNum=0, d=0
for /F "eol=F usebackq tokens=1,2 skip=1 delims=:[] " %%A in (`fc /b "%tmp%\s-mon.bin" "%tmp%\s-mon.tmp"`) DO (
set /a num=0x%%A && (
set /a numDec=num-1
for /L %%n in (!expectedNum!,1,!numDec!) DO (
set /a "d=(d+1) %% 2"
set "s=!s!40"
if !d! equ 0 set "s=!s! "
)
set /a "expectedNum=num+1, d=(d+1) %% 2"
set "s=!s!%%B"
if !d! equ 0 set "s=!s! "
)
)
for %%L in (%s%
) do (
set /A "seed = (seed & -65536) | 0x%%L, x = 0x%%L & 255, y = (0x%%L >> 8) & 255, len=(64 - i) * 32, i+=1, ic=(i-1) & 3"
set /a p=tot*100/max
title Decompressing !p!%%
For %%C in (!ic!) do For /L %%M in (1,1,!len!) do (
set /A "carry = seed & 0x80000000, seed = (seed << 1) & -1"
if !carry! gtr 0x80000000 (set /A "seed = seed ^ 0x04C11DB7, dir = seed & 255, dir=dir & 130") else set /A "dir=dir & 130"
if !dir! equ 0 (set /A "y+=1, y&=127"
) else (
if !dir! equ 2 (set /A "x+=1, x&=127"
) else (
if !dir! equ 128 (set /A "y-=1, y&=127"
) else if !dir! equ 130 set /A "x-=1, x&=127"
)
)
if !y! leq 95 if !x! leq 127 (
set /A "bx=x+1, by=y+1, tot+=1"
set "color=!c%%C!"
%Plot% !bx! !by! !color:~0,3! !color:~4,3! !color:~8,3!
)
)
)
:next
%difftime%
title Decompressing 100%% elapsed: !td! sec max=!tot!
pause>nul:
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
rem implemento macro
:macros
set "Char=█"
rem set "Char=*"
for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
:: define LF as a Line Feed (newline) character
set ^"LF=^
^" Above empty line is required - do not remove
:: define CR as a Carriage Return character
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
:: define BS as a BackSpace character
for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "BS=%%A"
:: define a newline with line continuation
set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: macro Plot=Screen.Setpixel X Y R G B
set Plot=for %%# in (1 2) do if %%#==2 (%\n%
for /f "tokens=1-5 delims=, " %%1 in ("^!args^!") do (%\n%
^<nul set /p "=!ESC![%%2;%%1H!ESC![38;2;%%3;%%4;%%5m!Char!!ESC![0m"%\n%
)) else set args=
rem %rem Plot% 10 10 150 0 0
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Difftime
set gettime=set "t0=^!time: =0^!"
set difftime=for /F "tokens=1-8 delims=:.," %%a in ("^!t0: =0^!:^!time: =0^!") do set /a "td=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, td+=(a>>31) & 8640000, td=td/100"
goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::.
:init_setfont
:: - BRIEF -
:: Get or set the console font size and font name.
:: - SYNTAX -
:: %setfont% [fontSize [fontName]]
:: fontSize Size of the font. (Can be 0 to preserve the size.)
:: fontName Name of the font. (Can be omitted to preserve the name.)
:: - EXAMPLES -
:: Output the current console font size and font name:
:: %setfont%
:: Set the console font size to 14 and the font name to Lucida Console:
:: %setfont% 14 Lucida Console
setlocal DisableDelayedExpansion
set setfont=for /l %%# in (1 1 2) do if %%#==2 (^
%=% for /f "tokens=1,2*" %%- in ("? ^^!arg^^!") do endlocal^&powershell.exe -nop -ep Bypass -c ^"Add-Type '^
%===% using System;^
%===% using System.Runtime.InteropServices;^
%===% [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)] public struct FontInfo{^
%=====% public int objSize;^
%=====% public int nFont;^
%=====% public short fontSizeX;^
%=====% public short fontSizeY;^
%=====% public int fontFamily;^
%=====% public int fontWeight;^
%=====% [MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)] public string faceName;}^
%===% public class WApi{^
%=====% [DllImport(\"kernel32.dll\")] public static extern IntPtr CreateFile(string name,int acc,int share,IntPtr sec,int how,int flags,IntPtr tmplt);^
%=====% [DllImport(\"kernel32.dll\")] public static extern void GetCurrentConsoleFontEx(IntPtr hOut,int maxWnd,ref FontInfo info);^
%=====% [DllImport(\"kernel32.dll\")] public static extern void SetCurrentConsoleFontEx(IntPtr hOut,int maxWnd,ref FontInfo info);^
%=====% [DllImport(\"kernel32.dll\")] public static extern void CloseHandle(IntPtr handle);}';^
%=% $hOut=[WApi]::CreateFile('CONOUT$',-1073741824,2,[IntPtr]::Zero,3,0,[IntPtr]::Zero);^
%=% $fInf=New-Object FontInfo;^
%=% $fInf.objSize=84;^
%=% [WApi]::GetCurrentConsoleFontEx($hOut,0,[ref]$fInf);^
%=% If('%%~.'){^
%===% $fInf.nFont=0; $fInf.fontSizeX=0; $fInf.fontFamily=0; $fInf.fontWeight=0;^
%===% If([Int16]'%%~.' -gt 0){$fInf.fontSizeX=[Int16]'%%~.';$fInf.fontSizeY=[Int16]'%%~.'}^
%===% If('%%~/'){$fInf.faceName='%%~/'}^
%===% [WApi]::SetCurrentConsoleFontEx($hOut,0,[ref]$fInf);}^
%=% Else{(''+$fInf.fontSizeY+' '+$fInf.faceName)}^
%=% [WApi]::CloseHandle($hOut);^") else setlocal EnableDelayedExpansion^&set arg=
endlocal &set "setfont=%setfont%"
if !!# neq # set "setfont=%setfont:^^!=!%"
exit /b
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%===% If([Int16]'%%~.' -gt 0){$fInf.fontSizeY=[Int16]'%%~.'}^
%===% If([Int16]'%%~.' -gt 0){$fInf.fontSizeX=[Int16]'%%~.';$fInf.fontSizeY=[Int16]'%%~.'}^
###############################################################################
PS2: I forgot to mention that it uses fractal compression.