Skip to content

Commit

Permalink
Merge pull request #5 from Mixone-FinallyHere/master
Browse files Browse the repository at this point in the history
Repaired a dumb mistake
  • Loading branch information
XLuma authored Dec 24, 2020
2 parents d74023f + 96671f6 commit 92796a5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
11 changes: 10 additions & 1 deletion DSShinyEditor/DSShinyEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
Expand All @@ -19,4 +19,13 @@
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="Tools\blz.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Tools\ndstool.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
22 changes: 21 additions & 1 deletion DSShinyEditor/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Editor(string path, byte rate)
unpack.StartInfo.CreateNoWindow = true;
unpack.Start();
unpack.WaitForExit();

DecompressArm9(workingFolder);
// Modify the arm9
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(workingFolder + "arm9.bin")))
{
Expand All @@ -68,6 +68,7 @@ public Editor(string path, byte rate)
} else
{
// Copy ROM and modify it

File.Copy(path, workingFolder+"shinyModified.nds");
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(workingFolder + "shinyModified.nds")))
{
Expand All @@ -94,5 +95,24 @@ public uint TryGetAddress(string gameVers)
throw new Exception("Game not supported. Exiting.\n" + e.StackTrace);
}
}

private void DecompressArm9(string workingFolder)
{
if (new FileInfo(workingFolder + @"arm9.bin").Length < 0xC0000)
{
BinaryWriter arm9Truncate = new BinaryWriter(File.OpenWrite(workingFolder + @"arm9.bin"));
long arm9Length = new FileInfo(workingFolder + @"arm9.bin").Length;
arm9Truncate.BaseStream.SetLength(arm9Length - 0xc);
arm9Truncate.Close();
}

Process decompress = new Process();
decompress.StartInfo.FileName = @"Tools\blz.exe";
decompress.StartInfo.Arguments = @" -d " + '"' + workingFolder + "arm9.bin" + '"';
decompress.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
decompress.StartInfo.CreateNoWindow = true;
decompress.Start();
decompress.WaitForExit();
}
}
}
Binary file added DSShinyEditor/Tools/blz.exe
Binary file not shown.

0 comments on commit 92796a5

Please sign in to comment.