@echo --------------------------------
@echo  COMPILE:
@echo --------------------------------

@cd /d "%~dp0"
@cd /d "compile"
@del /Q "effect.bin" 2>NUL
@del /Q "effect.bin.mlz" 2>NUL
@del /Q "effect.bin.pl5d" 2>NUL
@del /Q "pg0.bin" 2>NUL
@del /Q "pg0.bin.mlz" 2>NUL
@del /Q "pg0.bin.pl5d" 2>NUL
@del /Q "pg1.bin" 2>NUL
@del /Q "pg1.bin.mlz" 2>NUL
@del /Q "pg1.bin.pl5d" 2>NUL
@del /Q "pg7.bin" 2>NUL
@del /Q "pg7.bin.mlz" 2>NUL
@del /Q "pg7.bin.pl5d" 2>NUL
@cd /d "%~dp0"
@
@
@sjasmplus.exe kernal.asm
@
@
@for /f %%i in ("compile/effect.bin") do @set SizeBin=%%~zi
@for /f %%i in ("compile/pg0.bin") do @set SizeBin0=%%~zi
@for /f %%i in ("compile/pg1.bin") do @set SizeBin1=%%~zi
@for /f %%i in ("compile/pg7.bin") do @set SizeBin7=%%~zi



@echo --------------------------------
@echo  PACKING:
@echo --------------------------------


@"system/MegaLZ.exe" compile/effect.bin compile/effect.bin.mlz > nul
@for /f %%i in ("compile/effect.bin.mlz") do @set SizeBinCompress=%%~zi
@set /a Percent= 100-100*SizeBinCompress/SizeBin
@
@"system/pletter5d.exe" compile/effect.bin compile/effect.bin.pl5d > nul
@for /f %%i in ("compile/effect.bin.pl5d") do @set pl5dSizeBinCompress=%%~zi
@set /a pl5dPercent= 100-100*pl5dSizeBinCompress/SizeBin
@



@if not exist "compile\pg0.bin" goto NOPACK0
@
@"system/MegaLZ.exe" compile/pg0.bin compile/pg0.bin.mlz > nul
@for /f %%i in ("compile/pg0.bin.mlz") do @set SizeBinCompress0=%%~zi
@set /a Percent0= 100-100*SizeBinCompress0/(SizeBin0 + 1)
@
@"system/pletter5d.exe" compile/pg0.bin compile/pg0.bin.pl5d > nul
@for /f %%i in ("compile/pg0.bin.pl5d") do @set pl5dSizeBinCompress0=%%~zi
@set /a pl5dPercent0= 100-100*pl5dSizeBinCompress0/(SizeBin0 + 1)
@
:NOPACK0


@if not exist "compile\pg1.bin" goto NOPACK1
@
@"system/MegaLZ.exe" compile/pg1.bin compile/pg1.bin.mlz > nul
@for /f %%i in ("compile/pg1.bin.mlz") do @set SizeBinCompress1=%%~zi
@set /a Percent1= 100-100*SizeBinCompress1/(SizeBin1 + 1)
@
@"system/pletter5d.exe" compile/pg1.bin compile/pg1.bin.pl5d > nul
@for /f %%i in ("compile/pg1.bin.pl5d") do @set pl5dSizeBinCompress1=%%~zi
@set /a pl5dPercent1= 100-100*pl5dSizeBinCompress1/(SizeBin1 + 1)
@
:NOPACK1


@if not exist "compile\pg7.bin" goto NOPACK7
@
@"system/MegaLZ.exe" compile/pg7.bin compile/pg7.bin.mlz > nul
@for /f %%i in ("compile/pg7.bin.mlz") do @set SizeBinCompress7=%%~zi
@set /a Percent7= 100-100*SizeBinCompress7/(SizeBin7 + 1)
@
@"system/pletter5d.exe" compile/pg7.bin compile/pg7.bin.pl5d > nul
@for /f %%i in ("compile/pg7.bin.pl5d") do @set pl5dSizeBinCompress7=%%~zi
@set /a pl5dPercent7= 100-100*pl5dSizeBinCompress7/(SizeBin7 + 1)
@
:NOPACK7


@echo megaLZ FX PACKED SIZE: from %SizeBin% to %SizeBinCompress%, SAVED: %Percent% percent
@echo plet5d FX PACKED SIZE: from %SizeBin% to %pl5dSizeBinCompress%, SAVED: %pl5dPercent% percent
@if not exist "compile\pg0.bin" goto NOPACKSHOW0
@echo --------------------------------
@echo megaLZ PG0 PACKED SIZE: from %SizeBin0% to %SizeBinCompress0%, SAVED: %Percent0% percent
@echo plet5d PG0 PACKED SIZE: from %SizeBin0% to %pl5dSizeBinCompress0%, SAVED: %pl5dPercent0% percent
:NOPACKSHOW0
@if not exist "compile\pg1.bin" goto NOPACKSHOW1
@echo --------------------------------
@echo megaLZ PG1 PACKED SIZE: from %SizeBin1% to %SizeBinCompress1%, SAVED: %Percent1% percent
@echo plet5d PG1 PACKED SIZE: from %SizeBin1% to %pl5dSizeBinCompress1%, SAVED: %pl5dPercent1% percent
:NOPACKSHOW1
@if not exist "compile\pg7.bin" goto NOPACKSHOW7
@echo --------------------------------
@echo megaLZ PG7 PACKED SIZE: from %SizeBin7% to %SizeBinCompress7%, SAVED: %Percent7% percent
@echo plet5d PG7 PACKED SIZE: from %SizeBin7% to %pl5dSizeBinCompress7%, SAVED: %pl5dPercent7% percent
:NOPACKSHOW7
@echo --------------------------------



@set /p input="1 to execute"
@if %input% == 1 start demo.trd
exit