@echo off
if "%1"=="-getinfo" goto appinfo
if exist log_os\LogOS_is_running goto startscr
goto error
:error
Echo.
Echo This application can only be run inside Log OS.
Echo.
pause
exit
:appinfo
echo %2. ASCII video player (version 1.0)
echo.   Description: Allows you to play black and white videos in ASCVID/ASCAUD format
exit /b
:startscr
title ASCII video player for Log OS
set /a delay=30
setlocal EnableDelayedExpansion EnableExtensions
mode 151,46
set enablesound=enabled
:menu
title ASCII video player
cls
echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                video player
echo.
echo Please choose an option
echo.
echo 1. Load an ASCII video file
set /a yobig=1000/!delay!
echo 2. Set framerate: !yobig! fps
echo 3. Sounds: !enablesound! (if available)
echo 4. List my videos
echo 5. List public videos
echo 6. Exit
echo.
set /p answer=Type a number and then press enter:
if "!answer!"=="1" goto fileload
if "!answer!"=="2" (
cls
set /p yobig=Enter a framerate:
set /a delay=1000/!yobig!
)
if "!answer!"=="3" (
if "!enablesound!"=="enabled" set enablesound=disabled&goto menu
if "!enablesound!"=="disabled" set enablesound=enabled&goto menu
)
if "%answer%"=="4" (
	cls
	echo My videos:
	echo.
	for /f "delims=" %%a in ('dir /b specific_user\%user%\video\*.ASCVID') do (
		set "temp=%%a"
		set "temp=!temp:.ASCVID=!"
		echo !temp!
	)
	echo.
	pause
)
if "%answer%"=="5" (
	cls
	echo Public videos:
	echo.
	for /f "delims=" %%a in ('dir /b specific_os\share\video\*.ASCVID') do (
		set "temp=%%a"
		set "temp=!temp:.ASCVID=!"
		echo !temp!
	)
	echo.
	pause
)
if "!answer!"=="6" exit
goto menu

:fileload
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                video player
echo.
set /p answer=Enter file name:
set "answer=!answer:\=!"
if not "!answer:~0,-7!"==".ascvid" set answer=!answer!.ascvid
if exist "specific_os\share\video\%answer%" set "answer=specific_os\share\video\%answer%"
if exist "specific_user\%user%\video\%answer%" set "answer=specific_user\%user%\video\%answer%"
if not exist !answer! (
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                video player
echo.
echo Specified file does not exist.
pause
goto menu
)

:loop
set frametype=1
bg cursor 0
bg font 1
color 0f
for /f "delims=" %%a in (!answer!) do (
set temp=%%a
if "!temp!"=="." set "temp=                                                                                                                                                      "
if "!temp!"=="-" set "temp=°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"
if "!temp!"=="," set "temp=±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"
if "!temp!"==":" set "temp=²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²"
if "!temp!"==";" set "temp=ŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪŪ"
if "!temp:~0,4!"=="rate" set /a delay=1000/!temp:~5!
if "!enablesound!"=="enabled" (
	if "!temp:~0,5!"=="sound" (
		if not exist bg.exe set "enablesound=disabled"
		if "!temp:~5!"==" on" start /min bg.exe play !answer:~0,-3!aud
	)
)
if not "!temp:~0,5!"=="sound" (
	set /a yobig=1000/delay
	if "!temp:~0,4!"=="rate" set /a delay=1000/!temp:~5!
	if "!enablesound!"=="enabled" (
		if "!temp:~0,5!"=="sound" (
			if not exist bg.exe set "enablesound=disabled"
			if "!temp:~5!"==" on" start /min bg.exe play !answer:~0,-3!aud
		)
	)
	if not "!temp!"=="repeat" (
		if "!temp:~0,3!"=="col" (
			chgcolor !temp:~4!
		) else (
			if "!temp:~0,3!"=="fsc" (
				color !temp:~4!
			) else (
				if "!temp!"=="." echo.                                                                                                                                                      &set temp=sound
				if not "!temp:~0,5!"=="sound" (
					set /a yobig=1000/!delay!
						
					if "!temp:~0,5!"=="frame" bg locate 0 0
					if "!temp:~0,5!"=="frame" (
						if !current_time! GEQ !realtime! (
							bg sleep !delay!
						)
						title Frame !temp:~6! {playing !answer:~0,-7!, !yobig! fps, sound !enablesound!}
						set /a frame=!temp:~6! 2>nul
					)
					if not "!temp:~0,4!"=="rate" (
						if not "!temp:~0,5!"=="frame" echo.!temp!
					)
				)
			)
		)
	)
)
if "!temp:~0,3!"=="end" bg font 6&goto menu
)
goto loop