Skip to content

Commit 61edac5

Browse files
Add files via upload
1 parent beaed64 commit 61edac5

13 files changed

+345
-0
lines changed

soundTest/SKETCH.bat

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@echo off & setlocal enableDelayedExpansion
2+
3+
if "%~1" neq "" goto :%~1
4+
5+
call lib\stdlib 70 55
6+
call lib\gfx
7+
call lib\sound
8+
9+
set "cy=8"
10+
11+
"%~F0" Controller >"%temp%\%~n0_signal.txt" | "%~F0" Main <"%temp%\%~n0_signal.txt"
12+
exit
13+
14+
:Main
15+
for /l %%# in () do (
16+
17+
%@rect% 5 5 60 45
18+
set "scrn=!scrn!!$rect!"
19+
20+
for /l %%i in (1,1,6) do (
21+
set /a "y=3 * %%i + 5"
22+
set "scrn=!scrn!%\e%[!y!;10H%%i. "
23+
)
24+
25+
set "com=" & set /p "com="
26+
if /i "!com!" equ "w" (
27+
%@playSound% "%sfx%\pointer3.wav"
28+
if !cy! geq 11 set /a "cy-=3"
29+
)
30+
if /i "!com!" equ "s" (
31+
%@playSound% "%sfx%\pointer3.wav"
32+
if !cy! leq 20 set /a "cy+=3"
33+
)
34+
if /i "!com!" equ "d" ( %@playSound% "%sfx%\confirm.wav" )
35+
if /i "!com!" equ "a" ( %@playSound% "%sfx%\cancel.wav" )
36+
37+
set "scrn=!scrn!%\e%[!cy!;8H"
38+
39+
title !cy!
40+
echo %\h%!scrn!
41+
set "scrn="
42+
)
43+
exit
44+
45+
46+
47+
:Controller
48+
for /l %%# in () do (
49+
for /f "tokens=*" %%i in ('choice /c:wasd /n') do <nul set /p "=%%~i"
50+
)
51+
exit

soundTest/lib/gfx.bat

+241
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
:graphicsFunctions
2+
3+
if not defined wid (
4+
for /f "skip=2 tokens=2" %%a in ('mode') do (if not defined hei (set /a "hei=height=%%a") else if not defined wid (set /a "wid=width=%%a"))
5+
)
6+
7+
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a"
8+
9+
(set \n=^^^
10+
%= This creates an escaped Line Feed - DO NOT ALTER =%
11+
)
12+
13+
set "@32bitlimit=0x7FFFFFFF"
14+
15+
for /l %%i in (0,1,5) do set "barBuffer=!barBuffer!!barBuffer! " & set "boxBuffer=!boxBuffer!!boxBuffer!Ä"
16+
set "sin=(a=((x*31416/180)%%62832)+(((x*31416/180)%%62832)>>31&62832), b=(a-15708^a-47124)>>31,a=(-a&b)+(a&~b)+(31416&b)+(-62832&(47123-a>>31)),a-a*a/1875*a/320000+a*a/1875*a/15625*a/16000*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000) / 10000"
17+
set "cos=(a=((15708-x*31416/180)%%62832)+(((15708-x*31416/180)%%62832)>>31&62832), b=(a-15708^a-47124)>>31,a=(-a&b)+(a&~b)+(31416&b)+(-62832&(47123-a>>31)),a-a*a/1875*a/320000+a*a/1875*a/15625*a/16000*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000) / 10000"
18+
19+
For /l %%i in (1 1 4)Do Set "loop=!Loop!For /l %%# in (1 1 16)Do if not defined Stop "
20+
set "delay=for /l %%# in (1,x,1000000) do rem"
21+
22+
set "pixel=Û"
23+
24+
:_concat
25+
rem %concat% x y "string" outputVar
26+
set @concat=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
27+
set "%%~4=^!%%~4^!%\e%[%%~2;%%~1H%%~3"%\n%
28+
)) else set args=
29+
30+
:_background
31+
REM %@background% color1 color2 lineColor2Starts
32+
set @background=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
33+
set "$background=%\e%[48;5;%%~1m%\e%[0J%\e%[%%~3H%\e%[48;5;%%~2m%\e%[0J"%\n%
34+
)) else set args=
35+
36+
:_fullscreen
37+
rem %@fullscreen%
38+
set "@fullScreen=(title batchfs) ^& Mshta.exe vbscript:Execute("Set Ss=CreateObject(""WScript.Shell""):Ss.AppActivate ""batchfs"":Ss.SendKeys ""{F11}"":close") ^& !@getdim!"
39+
40+
:_plot
41+
rem %plot% y;x 2/5;0-255;0-255;0-255
42+
set @plot=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-2" %%1 in ("^!args^!") do (%\n%
43+
set "$plot=^!$plot^!%\e%[48;%%2m%\e%[%%1H %\e%[0m"%\n%
44+
)) else set args=
45+
46+
:_construct
47+
rem %%~1:NAME %%~2:end/optional %%~3:ID/optional <rtn> %%~1[n].ATTRIBUTES
48+
set @construct=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%1 in ("^!args^!") do (%\n%
49+
if /i "%%~2" neq "purge" (%\n%
50+
if not defined %%~1.length set /a "%%~1.length=-1"%\n%
51+
set /a "%%~1.length+=1"%\n%
52+
set "%%~1.list=^!%%~1.list^!^!%%~1.length^! "%\n%
53+
for %%j in (^^!%%~1.length^^!) do (%\n%
54+
set /a "%%~1[%%j].x=^!random^! %% wid"%\n%
55+
set /a "%%~1[%%j].y=^!random^! %% hei"%\n%
56+
set /a "%%~1[%%j].deg=^!random^! %% 360"%\n%
57+
set /a "%%~1[%%j].mag=^!random^! %% 2 + 1"%\n%
58+
set /a "%%~1[%%j].i=(^!random^! %% 2 * 2 - 1) * %%~1[%%j].mag"%\n%
59+
set /a "%%~1[%%j].j=(^!random^! %% 2 * 2 - 1) * %%~1[%%j].mag"%\n%
60+
)%\n%
61+
) else (%\n%
62+
if "%%~3" equ "" (%\n%
63+
for %%j in (^^!%%~1.length^^!) do (%\n%
64+
for /l %%k in (0,1,%%j) do (%\n%
65+
for %%i in (x y i j deg mag) do set "%%~1[%%k].%%i="%\n%
66+
)%\n%
67+
set "%%~1.length="%\n%
68+
set "%%~1.list="%\n%
69+
)%\n%
70+
) else (%\n%
71+
if "^!%%~1.list^!" neq "^!%%~1.list:%%~3 =^!" (%\n%
72+
set "%%~1.list=^!%%~1.list:%%~3 =^!"%\n%
73+
for %%i in (x y i j deg mag) do set "%%~1[%%~3].%%i="%\n%
74+
set /a "%%~1.length-=1"%\n%
75+
)%\n%
76+
)%\n%
77+
)%\n%
78+
)) else set args=
79+
80+
:_getDistance
81+
rem %getDistance% x2 x1 y2 y1 <rtnVar>
82+
set @getDistance=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
83+
set /a "%%5=( ?=((((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4))))>>31)+1, ?*(2*((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4)))-(((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4))))) + ^^^!?*(((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4)))-(((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4)))*2)) )"%\n%
84+
)) else set args=
85+
86+
:_pow
87+
rem %pow% num pow <rtnVar>
88+
for /l %%a in (1,1,30) do set "pb=!pb!x*"
89+
set @pow=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%1 in ("^!args^!") do (%\n%
90+
set /a "x=%%~1","$p=%%~2*2-1"%\n%
91+
for %%a in (^^!$p^^!) do set /a "%%~3=^!pb:~0,%%a^!"%\n%
92+
)) else set args=
93+
94+
:_circle
95+
rem %circle% x y ch cw <rtn> $circle
96+
set @circle=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
97+
set "$circle=%\e%[48;5;15m"%\n%
98+
for /l %%a in (0,3,360) do (%\n%
99+
set /a "xa=%%~3 * ^!cos:x=%%a^! + %%~1", "ya=%%~4 * ^!sin:x=%%a^! + %%~2"%\n%
100+
set "$circle=^!$circle^!%\e%[^!ya^!;^!xa^!H "%\n%
101+
)%\n%
102+
set "$circle=^!$circle^!%\e%[0m"%\n%
103+
)) else set args=
104+
105+
:_rect
106+
rem %rect% x y w h <rtn> $rect
107+
for /l %%i in (0,1,5) do set "qBuffer=!qBuffer!!qBuffer!q"
108+
set @rect=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
109+
set "$rect=%\e%[%%~2;%%~1H%\e%(0%\e%7l^!qBuffer:~0,%%~3^!k%\e%8%\e%[B"%\n%
110+
for /l %%i in (1,1,%%~4) do set "$rect=^!$rect^!%\e%7x%\e%%\e%[%%~3Cx%\e%8%\e%[B"%\n%
111+
set "$rect=^!$rect^!m^!qBuffer:~0,%%~3^!j%\e%%\e%(B%\e%%\e%[0m"%\n%
112+
)) else set args=
113+
114+
:_line
115+
rem line x0 y0 x1 y1 color
116+
set @line=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
117+
if "%%~5" equ "" ( set "hue=15" ) else ( set "hue=%%~5")%\n%
118+
set "$line=%\e%[48;5;^!hue^!m"%\n%
119+
set /a "xa=%%~1", "ya=%%~2", "xb=%%~3", "yb=%%~4", "dx=%%~3 - %%~1", "dy=%%~4 - %%~2"%\n%
120+
if ^^!dy^^! lss 0 ( set /a "dy=-dy", "stepy=-1" ) else ( set "stepy=1" )%\n%
121+
if ^^!dx^^! lss 0 ( set /a "dx=-dx", "stepx=-1" ) else ( set "stepx=1" )%\n%
122+
set /a "dx<<=1", "dy<<=1"%\n%
123+
if ^^!dx^^! gtr ^^!dy^^! (%\n%
124+
set /a "fraction=dy - (dx >> 1)"%\n%
125+
for /l %%x in (^^!xa^^!,^^!stepx^^!,^^!xb^^!) do (%\n%
126+
if ^^!fraction^^! geq 0 set /a "ya+=stepy", "fraction-=dx"%\n%
127+
set /a "fraction+=dy"%\n%
128+
set "$line=^!$line^!%\e%[^!ya^!;%%xH "%\n%
129+
)%\n%
130+
) else (%\n%
131+
set /a "fraction=dx - (dy >> 1)"%\n%
132+
for /l %%y in (^^!ya^^!,^^!stepy^^!,^^!yb^^!) do (%\n%
133+
if ^^!fraction^^! geq 0 set /a "xa+=stepx", "fraction-=dy"%\n%
134+
set /a "fraction+=dx"%\n%
135+
set "$line=^!$line^!%\e%[%%y;^!xa^!H "%\n%
136+
)%\n%
137+
)%\n%
138+
set "$line=^!$line^!%\e%[0m"%\n%
139+
)) else set args=
140+
141+
:_bezier
142+
rem %bezier% x1 y1 x2 y2 x3 y3 x4 y4
143+
set @bezier=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-8" %%1 in ("^!args^!") do (%\n%
144+
set "$bezier=%\e%[48;5;15m"%\n%
145+
set /a "A=%%~1","B=%%~2","C=%%~3","D=%%~4","E=%%~5","F=%%~6","G=%%~7","H=%%~8","I=C-A","J=E-C","K=G-E","L=D-B","M=F-D"%\n%
146+
for /l %%. in (1,1,50) do (%\n%
147+
set /a "_=%%.<<1,N=((A+_*I*10)/1000+A),O=((C+_*J*10)/1000+C),P=((B+_*L*10)/1000+B),Q=((N+_*(O-N)*10)/1000+N),S=((D+_*M*10)/1000+D),T=((P+_*(S-P)*10)/1000+P),vx=(Q+_*(((O+_*(((E+_*K*10)/1000+E)-O)*10)/1000+O)-Q)*10)/1000+Q,vy=(T+_*(((S+_*(((F+_*(H-F)*10)/1000+F)-S)*10)/1000+S)-T)*10)/1000+T"%\n%
148+
set "$bezier=^!$bezier^!%\e%[^!vy^!;^!vx^!H "%\n%
149+
)%\n%
150+
)) else set args=
151+
152+
:_arc
153+
rem arc x y size DEGREES(0-360) arcRotationDegrees(0-360) lineThinness color
154+
set @arc=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-7" %%1 in ("^!args^!") do (%\n%
155+
set "$arc=%\e%[38;5;15m"%\n%
156+
for /l %%e in (%%~4,%%~6,%%~5) do (%\n%
157+
set /a "_x=%%~3 * ^!cos:x=%%e^! + %%~1", "_y=%%~3 * ^!sin:x=%%e^! + %%~2"%\n%
158+
set "$arc=^!$arc^!%\e%[^!_y^!;^!_x^!H%pixel%"%\n%
159+
)%\n%
160+
set "$arc=^!$arc^!%\e%[0m"%\n%
161+
)) else set args=
162+
163+
:_getBar
164+
rem %getBar% currentValue maxValue MaxlengthOfBar vtColorScheme(2 or 5) colorCode colorCode colorCode
165+
set @Bar=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-7" %%1 in ("^!args^!") do (%\n%
166+
set /a "barVal=%%~3*%%~1/%%~2", "onethird=%%~2 / 3", "twoThird=onethird * 2"%\n%
167+
if %%~1 lss ^^!onethird^^! (%\n%
168+
set "hue=%%~5"%\n%
169+
) else if %%~1 gtr ^^!oneThird^^! if %%~1 lss ^^!twoThird^^! (%\n%
170+
set "hue=%%~6"%\n%
171+
) else if %%~1 gtr ^^!twoThird^^! (%\n%
172+
set "hue=%%~7"%\n%
173+
)%\n%
174+
for /f "tokens=1,2" %%i in ("^!barVal^! ^!hue^!") do (%\n%
175+
set "$bar=%\e%[48;%%~4;%%~jm^!barBuffer:~0,%%~i^!%\e%[0m"%\n%
176+
)%\n%
177+
)) else set args=
178+
179+
:_HSL.RGB
180+
rem %HSL.RGB% 0-3600 0-10000 0-10000 <rtn> r g b
181+
set "HSL(n)=k=(n*100+(%%1 %% 3600)/3) %% 1200, x=k-300, y=900-k, x=y-((y-x)&((x-y)>>31)), x=100-((100-x)&((x-100)>>31)), max=x-((x+100)&((x+100)>>31))"
182+
set @HSL.RGB=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%1 in ("^!args^!") do (%\n%
183+
set /a "%HSL(n):n=0%", "r=(%%3-(%%2*((10000-%%3)-(((10000-%%3)-%%3)&((%%3-(10000-%%3))>>31)))/10000)*max/100)*255/10000","%HSL(n):n=8%", "g=(%%3-(%%2*((10000-%%3)-(((10000-%%3)-%%3)&((%%3-(10000-%%3))>>31)))/10000)*max/100)*255/10000", "%HSL(n):n=4%", "b=(%%3-(%%2*((10000-%%3)-(((10000-%%3)-%%3)&((%%3-(10000-%%3))>>31)))/10000)*max/100)*255/10000"%\n%
184+
)) else set args=
185+
set "hsl(n)="
186+
187+
:_getLen
188+
rem %getlen% "string" <rtn> $length
189+
set @getlen=for %%# in (1 2) do if %%#==2 ( for %%1 in (^^!args^^!) do (%\n%
190+
set "str=X%%~1" ^& set "length=0" ^& for /l %%b in (10,-1,0) do set /a "length|=1<<%%b" ^& for %%c in (^^!length^^!) do if "^!str:~%%c,1^!" equ "" set /a "length&=~1<<%%b"%\n%
191+
)) else set args=
192+
193+
:_tDiff
194+
rem %tDiff% <rtn> deltaTime, FPS, $TT, $min, $sec, frameCount
195+
set @tdiff=(%\n%
196+
for /f "tokens=1-4 delims=:.," %%a in ("^!time: =0^!") do set /a "t1=((((1%%a-1000)*60+(1%%b-1000))*60+(1%%c-1000))*100)+(1%%d-1000)"%\n%
197+
if defined t2 set /a "deltaTime=(t1 - t2)","$TT+=deltaTime","fps=60 * (1000 / (deltaTime + 1)) / 1000","$sec=$TT / 100 %% 60","$min=$TT / 100 / 60 %% 60","frameCount=(frameCount + 1) %% @32bitlimit"%\n%
198+
set /a "t2=t1"%\n%
199+
if "^!$sec:~1^!" equ "" set "$sec=0^!$sec^!"%\n%
200+
title FPS:^^!fps^^! Time: ^^!$min^^!:^^!$sec^^! Frames: ^^!frameCount^^!/^^!$TT^^!%\n%
201+
)
202+
203+
:_sevenSegmentDisplay
204+
rem %sevenSegmentDisplay% x y value color <rtn> $sevenSegmentDisplay
205+
set /a "segbool[0]=0x7E", "segbool[1]=0x30", "segbool[2]=0x6D", "segbool[3]=0x79", "segbool[4]=0x33", "segbool[5]=0x5B", "segbool[6]=0x5F", "segbool[7]=0x70", "segbool[8]=0x7F", "segbool[9]=0x7B"
206+
set @sevenSegmentDisplay=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
207+
set "$sevenSegmentDisplay="%\n%
208+
set /a "qx1=%%~1", "qx2=%%~1 + 1", "qx3=%%~1 + 2", "qx4=%%~1 - 1", "qy1=%%~2", "qy2=%%~2 + 1", "qy3=%%~2 + 2", "qy4=%%~2 + 3", "qy5=%%~2 + 4", "qy6=%%~2 + 5", "qy7=%%~2 + 6"%\n%
209+
for %%j in ( "6 1 1 2 1" "5 3 2 3 3" "4 3 5 3 6" "3 1 7 2 7" "2 4 5 4 6" "1 4 2 4 3" "0 1 4 2 4" ) do (%\n%
210+
for /f "tokens=1-5" %%v in ("%%~j") do (%\n%
211+
set /a "a=%%~4 * ((segbool[%%~3] >> %%~v) & 1)"%\n%
212+
set "$sevenSegmentDisplay=^!$sevenSegmentDisplay^!%\e%[48;5;^!a^!m%\e%[^!qy%%x^!;^!qx%%w^!H %\e%[^!qy%%z^!;^!qx%%y^!H "%\n%
213+
)%\n%
214+
)%\n%
215+
)) else set args=
216+
217+
:_msgBox
218+
rem %msgBox% 'title'text'x;y;textColor;boxColor;boxLength
219+
set @msgBox=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-7 delims=;" %%1 in ("^!args:~1^!") do (%\n%
220+
if "%%~5" neq "" ( set "t.color=%%~5" ) else ( set "t.color=15" )%\n%
221+
if "%%~6" neq "" ( set "box.color=%%~6" ) else ( set "box.color=15" )%\n%
222+
if "%%~7" neq "" ( set "msgBox.length=%%~7" ) else ( set "msgBox.length=60" )%\n%
223+
set "str=X%%~2"%\n%
224+
set "str=^!str:?=^!" ^& set "length=0" ^& for /l %%b in (10,-1,0) do set /a "length|=1<<%%b" ^& for %%c in (^^!length^^!) do if "^!str:~%%c,1^!" equ "" set /a "length&=~1<<%%b"%\n%
225+
set /a "msgBox.height=length / msgBox.length + 4", "msgBox.width=msgBox.length - 2"%\n%
226+
for /f "tokens=1-3" %%a in ("^!msgBox.width^! ^!msgBox.length^! ^!msgBox.height^!") do (%\n%
227+
set "$msgBox=%\e%[38;5;^!box.color^!m%\e%[%%~4;%%~3HÚ^!boxBuffer:~0,%%~a^!¿%\e%[%%~bD%\e%[B³%\e%[%%~aC³%\e%[%%~bD%\e%[BÃ^!boxBuffer:~0,%%~a^!´%\e%[%%~bD%\e%[B"%\n%
228+
for /l %%i in (0,1,%%~c) do set "$msgBox=^!$msgBox^!³%\e%[%%~aC³%\e%[%%~bD%\e%[B"%\n%
229+
set "$msgBox=^!$msgBox^!À^!boxBuffer:~0,%%~a^!Ù%\e%[0m"%\n%
230+
)%\n%
231+
set "str=^!str:=?^!"%\n%
232+
set /a "textx=%%~3 + 2", "texty=%%~4 + 1", "msgBox.width-=2"%\n%
233+
set "$msgBox=^!$msgBox^!%\e%[38;5;^!t.color^!m%\e%[^!texty^!;^!textx^!H%%~1%\e%[^!texty^!;^!textx^!H%\e%[3B"%\n%
234+
for /f "tokens=1,2" %%a in ("^!msgBox.width^! ^!msgBox.length^!") do (%\n%
235+
for /l %%i in (1,%%~a,^^!length^^!) do (%\n%
236+
set "$msgBox=^!$msgBox^!^!str:~%%~i,%%~a^!%\e%[%%~aD%\e%[B"%\n%
237+
)%\n%
238+
)%\n%
239+
set "$msgBox=^!$msgBox^!%\e%[0m%\e%[E"%\n%
240+
for %%i in (textx texty str box.color msgbox.height msgbox.width msgbox.length) do set "%%i="%\n%
241+
)) else set args=

soundTest/lib/sfx/African4.wav

223 KB
Binary file not shown.

soundTest/lib/sfx/Retro8.wav

223 KB
Binary file not shown.

soundTest/lib/sfx/cancel.wav

77.8 KB
Binary file not shown.

soundTest/lib/sfx/cmdwiz.exe

83.2 KB
Binary file not shown.

soundTest/lib/sfx/confirm.wav

116 KB
Binary file not shown.

soundTest/lib/sfx/pointer1.wav

77.8 KB
Binary file not shown.

soundTest/lib/sfx/pointer2.wav

77.8 KB
Binary file not shown.

soundTest/lib/sfx/pointer3.wav

145 KB
Binary file not shown.

soundTest/lib/sfx/popup.wav

39.3 KB
Binary file not shown.

soundTest/lib/sound.bat

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set "sfx=lib\sfx"
2+
3+
:_playSound
4+
REM %@playSound% "path"
5+
set "@playSound=start "" /B lib\sfx\cmdwiz playsound"

soundTest/lib/stdlib.bat

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
for /f "tokens=1 delims==" %%a in ('set') do (
2+
set "unload=true"
3+
for %%b in (cd Path ComSpec SystemRoot temp windir) do if /i "%%a"=="%%b" set "unload=false"
4+
if "!unload!"=="true" set "%%a="
5+
)
6+
set "unload="
7+
8+
(set \n=^^^
9+
%= This creates an escaped Line Feed - DO NOT ALTER \n =%
10+
)
11+
for /f %%a in ('echo prompt $E^| cmd') do set "\e=%%a" %= \e =%
12+
set "\c=%\e%[2J" %= \c =%
13+
set "\h=%\e%[2J%\e%[H" %= \h =%
14+
<nul set /p "=%\e%[?25l" & rem hide cursor
15+
16+
set "@32bitlimit=0x7FFFFFFF" & rem 2147483647 or (1 << 31) - 1 or 0x7FFFFFFF
17+
18+
set @getDim=(%\n%
19+
set "wid=" ^& set "hei=" ^& set "width=" ^& set "height="%\n%
20+
for /f "skip=2 tokens=2" %%a in ('mode') do if not defined hei (set /a "hei=height=%%a") else if not defined wid set /a "wid=width=%%a"%\n%
21+
)
22+
23+
%@getDim%
24+
if "%~2" neq "" (
25+
set /a "wid=width=%~1", "hei=height=%~2"
26+
mode %~1,%~2
27+
) 2>nul
28+
exit /b
29+
30+
Features:
31+
%~1 = width
32+
%~2 = height
33+
34+
Clears environment of unnecessary variables
35+
Hides cursor
36+
Sets size of window and provides definitions in variables, see below
37+
38+
Macros:
39+
@getDim
40+
41+
Values:
42+
@32bitlimit
43+
wid/width
44+
hei/height
45+
\e = esc
46+
\c = clear screen
47+
\h = clear\goto 0,0
48+
\n = newLine

0 commit comments

Comments
 (0)