Code: Select all
:::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal Enabledelayedexpansion
mode 69,58
set "preserve= TMP COMSPEC NUMBER_OF_PROCESSORS preserve "
for /f "delims==" %%v in ('set') do if "!preserve: %%v =!" equ "!preserve!" set "%%v="
set "preserve="
set MAP[1]=1212121212...2121212121..........
set MAP[2]=2........1...1........2..121.....
set MAP[3]=1........21212....121.1.2...2....
set MAP[4]=1........21212....121.1.2...2....
set MAP[5]=1.............................2..
set MAP[6]=2....1...12121................2..
set MAP[7]=1....2...2...2.....1..11.....1...
set MAP[8]=1....1...1...1....12..2.2...2....
set MAP[9]=2....2...2...2........1..121.....
set MAP[10]=1212212121...1212121212..........
set /A Playerx=4*10000, PlayerY=5*10000, Angle=0
For /L %%N in (1,1,50) do set S=_!S!
For /L %%N in (1,1,50) do set S0=Û!S0!
For /L %%N in (1,1,50) do set S0s=°!S0s!
For /L %%N in (1,1,50) do set S1=²!S1!
For /L %%N in (1,1,50) do set S1s= !S1s!
setlocal
For /L %%N in (-32,1,32) do (
set /A I=%%N+32
call :sin_cos "%%N * PI / 180" sin cos
set "_C=!_C! !cos!"
set "TL=!TL!^!N!I!:~%%n,1^!"
)
echo !_C!>corr.txt
echo !TL!>TL.txt
endlocal
set/A from=%angle%-32, to=%angle%+32
For /L %%Z in (%from%,1,%to%) do (
call :sin_cos "%%Z * PI / 180" aStepY aStepX
set "SC=!SC!"!aStepY! !aStepX!" "
)
rem for average FPS
set "t1=!time: =0!"
for /l %%. in (1,1,360) do (
rem for instant FPS
rem set "t1=!time: =0!"
call :raycast
rem for average FPS
for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000, FPS=100000/(a*10/%%.), a=a*10/%%."
Title Raycast Dos Batch - Time Elapsed:!a!ms - FPS: !FPS:~0,-2!.!FPS:~-2! [%%.]
rem for instant FPS
rem for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000, FPS=10000/a"
rem Title Raycast Dos Batch - Time Elapsed:!a!0ms - FPS: !FPS:~0,-2!.!FPS:~-2! [%%.]
set a=&set FPS=
rem set /A Playerx=4*10000, PlayerY=5*10000+%%.*500
set /A Angle+=1, to+=1
call :sin_cos "!to! * PI / 180" aStepY aStepX
set "SC=!SC!"!aStepY! !aStepX!" "
set SC=!SC:*"=!
set SC=!SC:*"=!
rem pause>nul
)
pause
exit /B
rem 3.10 - 4.38 - 4.46 - 4.48 - 4.65 - 4.76 - 4.87 - 4.80 - 4.78/4.83 - 4.90
rem set /A aStepY=%%u, aStepX=%%v
rem for %%C in (!Z!) do set corr=!_C:~%%C,5!
:::::::::::::::::::::::::::::::::::::::::::::::::
:raycast
setlocal
for /f usebackq^ delims^=^ eol^= %%A in (corr.txt) do set "_C=%%A"
( %= Empty Environment =%
for %%v in (Angle Number_of_Processors prompt comspec PlayerX
PlayerY from to SC aStepY aStepX) do set "%%v="
set Z=0
For %%Z in (%SC%) do for /f "tokens=1,2" %%u in (%%Z) do (
if %%v gtr 0 (
set /A "$X=%PlayerX%/10000, $tx=(($X+1)*10000-%PlayerX%)*10000/%%v, Dtx=10000*10000/%%v, $SX=1"
) else if %%v lss 0 (
set /A "$X=%PlayerX%/10000, $tx=($X*10000-%PlayerX%)*10000/%%v, Dtx=-10000*10000/%%v, $SX=-1"
) else set /A $X=%PlayerX%/10000, $tx=Dtx=100000000, $SX=0
if %%u gtr 0 (
set /A "$Y=%PlayerY%/10000, $ty=(($Y+1)*10000-%PlayerY%)*10000/%%u, Dty=10000*10000/%%u, $SY=1, Distance=21*10000"
) else if %%u lss 0 (
set /A "$Y=%PlayerY%/10000, $ty=($Y*10000-%PlayerY%)*10000/%%u, Dty=-10000*10000/%%u, $SY=-1, Distance=21*10000"
) else set /A $Y=%PlayerY%/10000, $ty=Dty=100000000, $SY=0, Distance=21*10000
set "$B="
for /L %%£ in (1,1,3) do if not defined $B for /L %%? in (1,1,7) do if not defined $B (
if !$tx! lss !$ty! (
set /A $tx+=Dtx, $X+=$SX
for /f "tokens=1,2" %%X in ("!$X! !$Y!") do if "!Map[%%Y]:~%%X,1!" geq "1" (
set /A Distance=$tx-Dtx, Side=0, $B=!Map[%%Y]:~%%X,1!
)
) else (
set /A $ty+=Dty, $Y+=$SY
for /f "tokens=1,2" %%X in ("!$X! !$Y!") do if "!Map[%%Y]:~%%X,1!" geq "1" (
set /A Distance=$ty-Dty, Side=1, $B=!Map[%%Y]:~%%X,1!
)
)
)
for %%C in (!Z!) do set /A "Len=(25*10000/( (Distance/2*!_C:~%%C,5!/10000) + 1234 ))*2, st=(50-len)/2+1, I=Z/5, Z+=5"
%= 2D-clipping =%
if !st! lss 1 (set st=1) else if !st! gtr 50 set st=50
for /f "tokens=1,2" %%X in ("!st! !len!") do if !$B! equ 1 (
if !side! equ 0 (
set "N!I!=-!S:~0,%%X!+!S0:~0,%%Y!+!S:~0,%%X!-"
) else set "N!I!=-!S:~0,%%X!+!S0s:~0,%%Y!+!S:~0,%%X!-"
) else (
if !side! equ 0 (
set "N!I!=-!S:~0,%%X!+!S1:~0,%%Y!+!S:~0,%%X!-"
) else set "N!I!=-!S:~0,%%X!+!S1s:~0,%%Y!+!S:~0,%%X!-"
)
)
)
set /P "TL="<TL.txt
cls & for /L %%n in (0, 1, 55) do echo( ^|%TL%^|
endlocal
exit /b
:Sin_Cos rad*10000 return_var*10000 rem RADIANT
setlocal
set /a "PI=(35500000/113+5)/10, PI_div_2=(35500000/113/2+5)/10, PIx2=2*PI, PI32=PI+PI_div_2"
set "SIN=(a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000)"
set /a "a=(%~1) %% %PIx2%, b=(a>>31|1)*a"
if !b! gtr %PI32% (set /a "a=a-(a>>31|1)*%PIx2%, c=%SIN%") else (
if !b! gtr %PI_div_2% (set /a "a=(a>>31|1)*%PI%-a, c=%SIN%") else set /a "c=%SIN%")
set /a "a=(%PI_div_2%-%~1) %% %PIx2%, b=(a>>31|1)*a"
if !b! gtr %PI32% (set /a "a=a-(a>>31|1)*%PIx2%, a=%SIN%") else (
if !b! gtr %PI_div_2% (set /a "a=(a>>31|1)*%PI%-a, a=%SIN%") else set /a "a=%SIN%")
(endlocal & set "%2=%c%" & set "%3=%a%")
goto :eof