'Project' Management Batch Scripts

chronosv2

New member
Hey there folks! A question popped up on Facebook about all the code effectively being shared between projects, and I came up with a batch file solution that allows you to set up and select projects via a few command line batch scripts. It saves your code as 7-zip archives in the Projects folder.

It's a bit of a process to get this to work, but this should work at least until things like handling scrolling and the stuff that makes the ROMfile potentially overflow are fixed.

First off we need the 7-zip Command Line tools from https://www.7-zip.org/download.html -- download the "7-Zip Extra: standalone console version, 7z DLL, Plugin for Far Manager" 7z package. (Most modern unarchiver software can read .7z, but if not you may need to download 7-zip itself first)
First we unpack 7za.exe into a temporary folder so we can set up the basic package.
From the NESMaker ZIP file, we need to extract MainASM.asm and the Routines folder from the GameEngineData folder. Package in any fixed scripts we need for the time being (i.e. I've got my fixed ASM for returning to Idle in the movement scripts)
Put those next to 7za in our temporary folder. (This temporary folder should contain 7za.exe, MainASM.asm and the Routines Folder with any changes you want to be default packed into it)
Then we need to run two commands from CMD:
Code:
7za a DefaultASM.7z MainASM.asm
7za a -r DefaultASM.7z Routines\*.*

With that done we can take 7za.exe and DefaultASM.7z and put them into our GameEngineData folder.
Now make 3 .bat or .cmd files, and save them in the GameEngineData folder alongside 7za.exe:

setup-project.bat
Code:
@echo off
echo WARNING! This program overwrites the scripts in your Routines folder with the Default NESMaker ASM Code!
set /P c=Are you sure you want to continue[Y/N]?
if /I "%c%" EQU "Y" goto overwrite
if /I "%C%" EQU "N" goto nooverwrite
echo Invalid choice. Assuming no.
:nooverwrite
pause
goto end

:overwrite
  7za x -y DefaultASM.7z
  pause

:end

save-project.bat
Code:
@echo off
If NOT exist "..\Projects\%1%.7z" goto nofile
7za.exe u -r -mx9 "..\Projects\%1%.7z" Routines\*.*
7za.exe u "..\Projects\%1%.7z" MainASM.asm
goto end

:nofile
  7za.exe a -r -mx9 "..\Projects\%1%.7z" Routines\*.*
  7za.exe a "..\Projects\%1%.7z" MainASM.asm
  pause
  
:end

load-project.bat
Code:
@echo off
echo WARNING! This program overwrites the scripts in your Routines folder with the specified project zip!
set /P c=Are you sure you want to continue[Y/N]?
if /I "%c%" EQU "Y" goto overwrite
if /I "%C%" EQU "N" goto nooverwrite
echo Invalid choice. Assuming no.

:nooverwrite
pause
goto end

:overwrite
  if not exist "..\Projects\%1%.7z" goto nofile
  7za x -y "..\Projects\%1%.7z"
  pause
  goto end
  
:nofile
  echo File does not exist.
  pause

:end

list-projects.bat
Code:
@echo off
echo Listing of Project Code Packages:
echo(
dir /B ..\Projects\*.7z
echo(
echo Remember, the Project Name for the *-project commands is the filename WITHOUT the .7z extension!

Now if you're starting a new project, run
setup-project
and your 'default' ASM will be unzipped, ready for a fresh start.
Run
save-project [projectname]
and an archive of your project code will be stored in the Projects folder using the name you used for [projectname].
Run
load-project [projectname]
and the project archive you created with save-project will be unpacked into the scripts' location.

It's important to remember that setup-project and load-project will overwrite MainASM.asm and the entirety of the Routines folder, so you need to make sure you've saved your work with save-project ahead of time before you run either of these. Judicious backing up of project files is always recommended, and this is no exception, especially because these scripts do things with the entire ASM structure of your project. (That's why I pasted these as code snippets, so anyone wanting to use these makes the files themselves and has a look over the scripts. You can see exactly what I'm doing here, and anything you're not sure of you can run the base command with /? to see what exactly it's meant to do (for instance 'if /?').

Hope this proves useful to some people!
(Also wasn't sure where to save this so if this is in the wrong place, would a mod please move it where it belongs?)

Edit: This is fully intended to be obsoleted by NESMaker's modules and defines. So if you need wildly different projects right now, this could help. Otherwise, it'd be better to wait.
 

chronosv2

New member
Thanks!

I'm fully aware this isn't going to be relevant anymore down the line (as Defines and Modules will allow you to have one large codebase but only use a portion of it) but thought it'd be useful for anyone lamenting the single-codebase system as it stands now.

Got one more script I just thought of a few minutes ago.
I didn't ever really think about listing files, but that could be handy since you're already in a command prompt. So I've edited that into the first post.
 
Top Bottom