@echo off
color F0
title Asm Maker v4.0
if not exist "Source" MD Source
if not exist "Hex" MD Hex
if not exist "Exec" MD Exec
If not exist "Data" ren "All" "Data
cd Data
If not exist "Required" MD Required
If not exist "Headers" MD Headers
If exist "Tasm.exe" move "Tasm.exe" "Required\Tasm.exe"
If exist "ObjHex.exe" move "ObjHex.exe" "Required\ObjHex.exe"
If exist "Tasm80.tab" move "Tasm80.tab" "Required\Tasm80.tab"
If exist "Devpac83.com" move "Devpac83.com" "Required\Devpac83.com"
If exist "Devpac8x.com" move "Devpac8x.com" "Required\Devpac8x.com"
If exist "Convert.exe" move "Convert.exe" "Required\Convert.exe"
If exist "Bintointelhex.exe" move "Bintointelhex.exe" "Required\BintoIntelHex.exe"
If exist "rabsig.exe" move "rabsig.exe" "Required\Rabsig.exe"
If exist "glheader.exe" move "glheader.exe" "Required\GLHeader.exe"
If exist "addhex.exe" move "addhex.exe" "Required\AddHex.exe"
If exist "fillapp.exe" move "fillapp.exe" "Required\FillApp.exe"
If exist "sighead.bin" move "sighead.bin" "Required\Sighead.bin"
If exist "0104.key" move "0104.key" "Required\0104.key"
If exist "Ion.hdr" move "Ion.hdr" "Headers\Ion.hdr"
If exist "App.hdr" move "App.hdr" "Headers\App.hdr"
If exist "App2.hdr" move "App2.hdr" "Headers\App2.hdr"
If exist "TI83.hdr" move "TI83.hdr" "Headers\TI83.hdr"
If exist "Mirage.hdr" move "Mirage.hdr" "Headers\Mirage.hdr"
If exist "DoorsCS.hdr" move "DoorsCS.hdr" "Headers\DoorsCS.hdr"
If exist "DoorsCS2.hdr" move "DoorsCS2.hdr" "Headers\DoorsCS2.hdr"
If exist "DoorsCS3.hdr" move "DoorsCS3.hdr" "Headers\DoorsCS3.hdr"
cd..
set asmdir=%cd%
:Menu
cd %asmdir%
cls
echo Asm Maker v4.0 ////////////////////
echo ------------------------------------------------------------
echo (1)New Asm		(2)Compile Prgm
echo (3)Compile App		(4)Options
echo (0)Quit
set /p choose=Do:
If "%choose%" == "1" goto :New
If "%choose%" == "2" goto :CompPrgm
If "%choose%" == "3" goto :CompApp
If "%choose%" == "4" goto :Options
If "%choose%" == "0" exit
goto :Menu
:New
cls
cd Data\Headers
set /p name=Name:
if exist "..\..\Source\%name%.z80" notepad "..\..\Source\%name%.z80"
if exist "..\..\Source\%name%.asm" notepad "..\..\Source\%name%.asm"
if exist "..\..\Source\%name%.z80" goto :Menu
if exist "..\..\Source\%name%.z80" goto :Menu
:Head
cls
dir /b
echo (0)No Header
set /p head=Header:
if "%head%" == "0" echo. >..\..\Source\%name%.z80
if "%head%" == "0" notepad ..\..\Source\%name%.z80
if "%head%" == "0" goto :Menu
If not exist "%head%.hdr" goto :Head
type %head%.hdr >>..\..\Source\%name%.z80
notepad ..\..\Source\%name%.z80
cd..\..
goto :Menu
:Options
CLS
echo [Options]
echo (1)Reset        (2)Search All
echo (3)New Header   (4)Search Specific
echo (0)Back
set /p choose=Do:
If "%choose%" == "1" goto :Reset
If "%choose%" == "2" goto :Find
If "%choose%" == "4" goto :FindA
If "%choose%" == "3" goto :NewHead
If "%choose%" == "0" goto :Menu
goto :Options
:Reset
del /Q Exec
del /Q Source
del /Q Hex
MD Exec
MD Source
MD Hex
cls
echo Data Reset & Pause
goto  :Options
:NewHead
cls
set /p name=Name:
echo. >>Data\Headers\%name%.hdr
notepad Data\Headers\%name%.hdr
goto :Options
:Find
CLS
cd Source
for /R C:\ %%i in (*.asm) do if "%%~xi" == ".asm" if exist %%i copy /Y "%%i" & cls
for /R C:\ %%i in (*.z80) do if exist %%i copy /Y "%%i" & cls
for /R C:\ %%i in (*.inc) do if exist %%i copy /Y "%%i" "%asmdir%\Data" & cls
for /R C:\ %%i in (*.hex) do if exist %%i copy /Y "%%i" "%asmdir%\Hex" & cls
for /R C:\ %%i in (*.83p) do if exist %%i copy /Y "%%i" "%asmdir%\Exec" & cls
for /R C:\ %%i in (*.8xp) do if exist %%i copy /Y "%%i" "%asmdir%\Exec" & cls
for /R C:\ %%i in (*.8xk) do if exist %%i copy /Y "%%i" "%asmdir%\Exec" & cls
echo All matches have been put their corresponding folders.
Pause
cd..
goto :Options
:FindA
CLS
set /P find=Find:
cd Source
for /R C:\ %%i in (%find%.asm) do if "%%~xi" == ".asm" if exist %%i copy /Y "%%i" & cls
for /R C:\ %%i in (%find%.z80) do if exist %%i copy /Y "%%i" & cls
for /R C:\ %%i in (%find%.inc) do if exist %%i copy /Y "%%i" "%asmdir%\Data" & cls
for /R C:\ %%i in (%find%.hex) do if exist %%i copy /Y "%%i" "%asmdir%\Hex" & cls
for /R C:\ %%i in (%find%.83p) do if exist %%i copy /Y "%%i" "%asmdir%\Exec" & cls
for /R C:\ %%i in (%find%.8xp) do if exist %%i copy /Y "%%i" "%asmdir%\Exec" & cls
for /R C:\ %%i in (%find%.8xk) do if exist %%i copy /Y "%%i" "%asmdir%\Exec" & cls
echo All matches have been put their corresponding folders.
Pause
cd..
goto :Options

:CompPrgm
cls
cd Source
echo Asm Maker v4.0 ////////////////////
echo ------------------------------------------------------------
echo [Source Files]//////////////////////////////////////////////
dir /b
echo/////////////////////////////////////////////////////////////
set /p run=Assemble:
If not exist "%run%.z80" If not exist "%run%.asm" goto :NF
cls
echo -----Creating Hex for %run%...
echo #define TI83 >..\Data\%run%.asm
if exist %run%.asm type %run%.asm >>..\Data\%run%.asm
if exist %run%.z80 type %run%.z80 >>..\Data\%run%.asm
cd..\Data
copy "Required\Tasm80.tab" "Tasm80.tab"
Required\Tasm -80 -i -b %run%.asm %run%.bin
Required\ObjHex %run%.bin >"..\Hex\%run%.hex"
if errorlevel 1 goto :Errors
echo -----Assembling %run% for the TI-83...
Required\Devpac83 %run%
if errorlevel 1 goto :Errors
echo -----Assembling %run% for the TI-83/84 Plus...
Required\Devpac8X %run%
if errorlevel 1 goto :Errors
cls
move "%run%.8xp" "..\Exec\%run%.8xp"
move "%run%.83p" "..\Exec\%run%.83p"
del %run%.bin
del %run%.lst
del %run%.asm
del Tasm80.tab
echo TI-83 is %run%.83p
echo TI-83 Plus is %run%.8xp
echo Hex is %run%.hex
pause
goto :Menu
:CompApp
cls
Set /p pages=Pages:
if %pages% == "1" goto :App1
if %pages% == "2" goto :App2
if %pages% == "3" goto :App3
if %pages% == "4" goto :App4
if %pages% == "5" goto :App5
goto :CompApp
:App1
cls
cd Source
echo Asm Maker v4.0 ////////////////////
echo ------------------------------------------------------------
echo [Source Files]//////////////////////////////////////////////
dir /b
echo/////////////////////////////////////////////////////////////
set /p run=Assemble:
if exist %run%.z80 copy %run%.z80 "..\Data\%run%.z80"
if exist %run%.asm copy %run%.asm "..\Data\%run%.z80"
cd..\Data
copy "Required\Tasm80.tab"
echo ----- Assembling %run% for TI-83 Plus App...
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %run%.bin
if errorlevel 1 goto :Apperror
"Required\bintointelhex" -o %run%.hex -p0 %run%.bin -e
if errorlevel 1 goto :Apperror
copy %run%.hex copyoapp.hex
type %run%.hex | find /v ":00000003FD" > delete03.hex
copy delete03.hex %run%.hex
"Required\fillapp" %run%.hex
if errorlevel 1 goto :Apperror
"Required\rabsig" "Required\0104.key" %run%.hex tempsig.bin
if errorlevel 1 goto :Apperror
copy "Required\sighead.bin"+tempsig.bin /B sig.bin /B
"Required\convert" sig.bin tmpsig.hex
if errorlevel 1 goto :Apperror
"Required\addhex" tmpsig.hex %run%.hex
if errorlevel 1 goto :Apperror
copy %run%.hex *.app
"Required\glheader" %run%.hex
if errorlevel 1 goto :Apperror
copy copyoapp.hex %run%.hex
del copyoapp.hex
rem del delete03.hex
del tempsig.bin
del sig.bin
del tmpsig.hex
del %run%.app
del delete03.hex
del testing.txt
del temp.z80
del temp.lst
del %run%.z80
del Tasm80.tab
del %run%.hex
del %run%.bin
copy %run%.8xk "..\Exec\%run%.8xk"
del %run%.8xk
cls
echo ----- %run% has been successfully converted!
echo App is %run%.8xk
pause
goto :Menu
:App2
cls
cd Source
echo Asm Maker v4.0 ////////////////////
echo ------------------------------------------------------------
echo [Source Files]//////////////////////////////////////////////
dir /b
echo/////////////////////////////////////////////////////////////
set /p run=Assemble:
if exist %run%.z80 copy %run%.z80 "..\Data\%run%.z80"
if exist %run%.asm copy %run%.asm "..\Data\%run%.z80"
set /p runb=Page2:
if exist %runb%.z80 copy %runb%.z80 "..\Data\%runb%.z80"
if exist %runb%.asm copy %runb%.asm "..\Data\%runb%.z80"
cd..\Data
copy "Required\Tasm80.tab"
echo ----- Assembling %run% for TI-83 Plus App...
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %run%.bin
if errorlevel 1 goto :Apperror
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %runb%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %runb%.bin
"Required\bintointelhex" -o %run%.hex -p0 %run%.bin -p1 %runb%.bin -e
if errorlevel 1 goto :Apperror
copy %run%.hex copyoapp.hex
type %run%.hex | find /v ":00000003FD" > delete03.hex
copy delete03.hex %run%.hex
"Required\fillapp" %run%.hex
if errorlevel 1 goto :Apperror
"Required\rabsig" "Required\0104.key" %run%.hex tempsig.bin
if errorlevel 1 goto :Apperror
copy "Required\sighead.bin"+tempsig.bin /B sig.bin /B
"Required\convert" sig.bin tmpsig.hex
if errorlevel 1 goto :Apperror
"Required\addhex" tmpsig.hex %run%.hex
if errorlevel 1 goto :Apperror
copy %run%.hex *.app
"Required\glheader" %run%.hex
if errorlevel 1 goto :Apperror
copy copyoapp.hex %run%.hex
del copyoapp.hex
rem del delete03.hex
del tempsig.bin
del sig.bin
del tmpsig.hex
del %run%.app
del delete03.hex
del testing.txt
del temp.z80
del temp.lst
del %run%.z80
del Tasm80.tab
del %run%.hex
del %run%.bin
copy %run%.8xk "..\Exec\%run%.8xk"
del %run%.8xk
cls
echo ----- %run% has been successfully converted!
echo App is %run%.8xk
pause
goto :Menu
:App3
cls
cd Source
echo Asm Maker v4.0 ////////////////////
echo ------------------------------------------------------------
echo [Source Files]//////////////////////////////////////////////
dir /b
echo/////////////////////////////////////////////////////////////
set /p run=Assemble:
if exist %run%.z80 copy %run%.z80 "..\Data\%run%.z80"
if exist %run%.asm copy %run%.asm "..\Data\%run%.z80"
set /p runb=Page2:
if exist %runb%.z80 copy %runb%.z80 "..\Data\%runb%.z80"
if exist %runb%.asm copy %runb%.asm "..\Data\%runb%.z80"
set /p runc=Page3:
if exist %runc%.z80 copy %runc%.z80 "..\Data\%runc%.z80"
if exist %runc%.asm copy %runc%.asm "..\Data\%runc%.z80"
cd..\Data
copy "Required\Tasm80.tab"
echo ----- Assembling %run% for TI-83 Plus App...
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %run%.bin
if errorlevel 1 goto :Apperror
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %runb%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %runb%.bin
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %runc%.bin
"Required\bintointelhex" -o %run%.hex -p0 %run%.bin -p1 %runb%.bin -p2 %runc%.bin -e
if errorlevel 1 goto :Apperror
copy %run%.hex copyoapp.hex
type %run%.hex | find /v ":00000003FD" > delete03.hex
copy delete03.hex %run%.hex
"Required\fillapp" %run%.hex
if errorlevel 1 goto :Apperror
"Required\rabsig" "Required\0104.key" %run%.hex tempsig.bin
if errorlevel 1 goto :Apperror
copy "Required\sighead.bin"+tempsig.bin /B sig.bin /B
"Required\convert" sig.bin tmpsig.hex
if errorlevel 1 goto :Apperror
"Required\addhex" tmpsig.hex %run%.hex
if errorlevel 1 goto :Apperror
copy %run%.hex *.app
"Required\glheader" %run%.hex
if errorlevel 1 goto :Apperror
copy copyoapp.hex %run%.hex
del copyoapp.hex
rem del delete03.hex
del tempsig.bin
del sig.bin
del tmpsig.hex
del %run%.app
del delete03.hex
del testing.txt
del temp.z80
del temp.lst
del %run%.z80
del Tasm80.tab
del %run%.hex
del %run%.bin
copy %run%.8xk "..\Exec\%run%.8xk"
del %run%.8xk
cls
echo ----- %run% has been successfully converted!
echo App is %run%.8xk
pause
goto :Menu
:App4
cls
cd Source
echo Asm Maker v4.0 ////////////////////
echo ------------------------------------------------------------
echo [Source Files]//////////////////////////////////////////////
dir /b
echo/////////////////////////////////////////////////////////////
set /p run=Assemble:
if exist %run%.z80 copy %run%.z80 "..\Data\%run%.z80"
if exist %run%.asm copy %run%.asm "..\Data\%run%.z80"
set /p runb=Page2:
if exist %runb%.z80 copy %runb%.z80 "..\Data\%runb%.z80"
if exist %runb%.asm copy %runb%.asm "..\Data\%runb%.z80"
set /p runc=Page3:
if exist %runc%.z80 copy %runc%.z80 "..\Data\%runc%.z80"
if exist %runc%.asm copy %runc%.asm "..\Data\%runc%.z80"
set /p rund=Page4:
if exist %rund%.z80 copy %rund%.z80 "..\Data\%rund%.z80"
if exist %rund%.asm copy %rund%.asm "..\Data\%rund%.z80"
cd..\Data
copy "Required\Tasm80.tab"
echo ----- Assembling %run% for TI-83 Plus App...
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %run%.bin
if errorlevel 1 goto :Apperror
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %runb%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %runb%.bin
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %runc%.bin
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %rund%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %rund%.bin
"Required\bintointelhex" -o %run%.hex -p0 %run%.bin -p1 %runb%.bin -p2 %runc%.bin -p3 %rund%.bin-e
if errorlevel 1 goto :Apperror
copy %run%.hex copyoapp.hex
type %run%.hex | find /v ":00000003FD" > delete03.hex
copy delete03.hex %run%.hex
"Required\fillapp" %run%.hex
if errorlevel 1 goto :Apperror
"Required\rabsig" "Required\0104.key" %run%.hex tempsig.bin
if errorlevel 1 goto :Apperror
copy "Required\sighead.bin"+tempsig.bin /B sig.bin /B
"Required\convert" sig.bin tmpsig.hex
if errorlevel 1 goto :Apperror
"Required\addhex" tmpsig.hex %run%.hex
if errorlevel 1 goto :Apperror
copy %run%.hex *.app
"Required\glheader" %run%.hex
if errorlevel 1 goto :Apperror
copy copyoapp.hex %run%.hex
del copyoapp.hex
rem del delete03.hex
del tempsig.bin
del sig.bin
del tmpsig.hex
del %run%.app
del delete03.hex
del testing.txt
del temp.z80
del temp.lst
del %run%.z80
del Tasm80.tab
del %run%.hex
del %run%.bin
copy %run%.8xk "..\Exec\%run%.8xk"
del %run%.8xk
cls
echo ----- %run% has been successfully converted!
echo App is %run%.8xk
pause
goto :Menu
:App5
cls
cd Source
echo Asm Maker v4.0 ////////////////////
echo ------------------------------------------------------------
echo [Source Files]//////////////////////////////////////////////
dir /b
echo/////////////////////////////////////////////////////////////
set /p run=Assemble:
if exist %run%.z80 copy %run%.z80 "..\Data\%run%.z80"
if exist %run%.asm copy %run%.asm "..\Data\%run%.z80"
set /p runb=Page2:
if exist %runb%.z80 copy %runb%.z80 "..\Data\%runb%.z80"
if exist %runb%.asm copy %runb%.asm "..\Data\%runb%.z80"
set /p runc=Page3:
if exist %runc%.z80 copy %runc%.z80 "..\Data\%runc%.z80"
if exist %runc%.asm copy %runc%.asm "..\Data\%runc%.z80"
set /p rund=Page4:
if exist %rund%.z80 copy %rund%.z80 "..\Data\%rund%.z80"
if exist %rund%.asm copy %rund%.asm "..\Data\%rund%.z80"
set /p rune=Page5:
if exist %rune%.z80 copy %rune%.z80 "..\Data\%rune%.z80"
if exist %rune%.asm copy %rune%.asm "..\Data\%rune%.z80"
cd..\Data
copy "Required\Tasm80.tab"
echo ----- Assembling %run% for TI-83 Plus App...
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %run%.bin
if errorlevel 1 goto :Apperror
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %runb%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %runb%.bin
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %run%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %runc%.bin
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %rund%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %rund%.bin
echo #define TI83P >temp.z80
echo #define APP >>temp.z80
echo #include %rune%.z80 >>temp.z80
"Required\tasm" -80 -i -b -l temp.z80 %rune%.bin
"Required\bintointelhex" -o %run%.hex -p0 %run%.bin -p1 %runb%.bin -p2 %runc%.bin -p3 %rund%.bin -p4 %rune%.bin -e
if errorlevel 1 goto :Apperror
copy %run%.hex copyoapp.hex
type %run%.hex | find /v ":00000003FD" > delete03.hex
copy delete03.hex %run%.hex
"Required\fillapp" %run%.hex
if errorlevel 1 goto :Apperror
"Required\rabsig" "Required\0104.key" %run%.hex tempsig.bin
if errorlevel 1 goto :Apperror
copy "Required\sighead.bin"+tempsig.bin /B sig.bin /B
"Required\convert" sig.bin tmpsig.hex
if errorlevel 1 goto :Apperror
"Required\addhex" tmpsig.hex %run%.hex
if errorlevel 1 goto :Apperror
copy %run%.hex *.app
"Required\glheader" %run%.hex
if errorlevel 1 goto :Apperror
copy copyoapp.hex %run%.hex
del copyoapp.hex
rem del delete03.hex
del tempsig.bin
del sig.bin
del tmpsig.hex
del %run%.app
del delete03.hex
del testing.txt
del temp.z80
del temp.lst
del %run%.z80
del Tasm80.tab
del %run%.hex
del %run%.bin
copy %run%.8xk "..\Exec\%run%.8xk"
del %run%.8xk
cls
echo ----- %run% has been successfully converted!
echo App is %run%.8xk
pause
goto :Menu
:Errors
cls
echo There were Errors! & pause
:Err
cls
set /P do=Check Errors?(1)Yes (2)No:
if "%do%" == "1" notepad %run%.lst
if "%do%" == "1" goto :Menu
if "%do%" == "2" goto :Menu
goto :Err
:nf
cls
echo File not found! & pause
goto :Menu
:Apperror
cls
echo There were errors making %run%.8xk
pause
goto :Menu