Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Disc Support #3

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ A program to build Syati Modules. (Command line tool)


```bat
SyatiModuleBuildTool.exe <REGION> <Path_To_Syati> <Path_To_Modules_Folder> <Path_To_Code_Output_Folder> <Path_To_Disc_Output_Folder>
SyatiModuleBuildTool.exe <REGION> <Path_To_Syati> <Path_To_Modules_Folder> <Path_To_Code_Output_Folder>
```

**Mandatory Arguments:**
- Replace `<REGION>` with one of the following: `USA`, `PAL`, `JPN`, `KOR`, `TWN`. Choose the one that matches your game disc.
- Replace `<Path_To_Syati>` with the complete path to your Syati folder. If your path has spaces in it, surround it with Quotation Marks "
- Replace `<Path_To_Modules>` with the complete path to the folder that you put the modules into. If your path has spaces in it, surround it with Quotation Marks "
- Replace `<Path_To_Code_Output_Folder>` with the complete path of the folder that you would like the resulting CustomCode.bin to be saved to. If your path has spaces in it, surround it with Quotation Marks "
- Replace `<Path_To_Disc_Output_Folder>` with the complete path of the folder that you would like the disc files of the modules to be copied to. If your path has spaces in it, surround it with Quotation Marks "
- Replace `<Path_To_Disc_Output_Folder>` with the complete path of the folder that you would like the disc files of the modules to be copied to. If your path has spaces in it, surround it with Quotation Marks ".

**Optional Arguments:**
- If you would like to copy disc files, add `-d <Path>` to the end of the command, and replace `<Path>` with the folder you would like to copy the disc files to. If your path has spaces in it, surround it with Quotation Marks ". (Ensure there is a space between the last path and this argument)
- If you would like to use **UniBuild**, add `-u` to the end of the command. (Ensure there is a space between the last path and the `-u`)
> *Note: UniBuild is an alternative method of compiling modules which may result in smaller output binaries. If you have less than 10 modules, you do not need UniBuild.*

After running the command, you will be given a **CustomCode.bin** and a **CustomCode.map**.
After running the command, you will be given a **CustomCode.bin**, a **CustomCode.map**, and if specified, the disc files of all your modules.
33 changes: 27 additions & 6 deletions SyatiModuleBuildTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void TryLoadModule(string ModulePath)
$"-D{args[0]}"
];
Console.WriteLine();
if (args.Last().Equals("-u"))
if (args.Any(s => s.Equals("-u")))
ModuleUtility.CompileAllUnibuild(Modules, Flags, IncludePaths, SyatiFolderPath, args[3], ref AllObjectOutputs);
else
ModuleUtility.CompileAllModules(Modules, Flags, IncludePaths, SyatiFolderPath, ref AllObjectOutputs);
Expand Down Expand Up @@ -185,25 +185,46 @@ void TryLoadModule(string ModulePath)
throw new InvalidOperationException("Linker Failure");
}

if (args.Length > 4 && args[4] != "-u") { // Make sure the argument in the position of Path_To_Disc_Output_Folder isn't the unibuild flag
Console.WriteLine();
Console.WriteLine("Copying disc...");
// if (args.Length > 4 && args[4] != "-u") { // Make sure the argument in the position of Path_To_Disc_Output_Folder isn't the unibuild flag
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, left that in accidentally, I'll fix it rn

if (GetOptionalArgument(ref args, "-d", out var path)) {
if (path is not null) {
Console.WriteLine();
Console.WriteLine("Copying disc...");

DiscUtility.CopyAllFiles(Modules, args[4]);
DiscUtility.CopyAllFiles(Modules, path);
}
else {
Console.WriteLine("A path to copy disc files to was not provided, skipped copying.");
}
}

Console.WriteLine();
Console.WriteLine("Complete!");
}
static bool GetOptionalArgument(ref string[] args, string flag, out string? str) {
for (int i = 0; i < args.Length; i++) {
if (args[i] == flag) {
if (i + 1 < args.Length)
str = args[i + 1];
else
str = null;

return true;
}
}

str = null;
return false;
}
static void Help()
{
Console.WriteLine(
"""
SyatiModuleBuildTool.exe <REGION> <Path_To_Syati_Repo> <Path_To_Modules_Folder> <Path_To_Code_Output_Folder> <Path_To_Disc_Output_Folder>

Extra options:
-u Enable UniBuild. UniBuild can shrink the final .bin file size at the potential cost of debuggability. Should only be used when you have a lot of modules. (10+)
-d <Path> Copy module disc files. To use this option, replace <Path> with the path you want to copy the disc files to.
-u Enable UniBuild. UniBuild can shrink the final .bin file size at the potential cost of debuggability. Should only be used when you have a lot of modules. (10+)
""");
}
static void Error(Exception ex)
Expand Down