Skip to content

Commit

Permalink
fixes problems with NUTC
Browse files Browse the repository at this point in the history
fixes problems with NUTs that do not contain image files
  • Loading branch information
Venomalia committed Jul 9, 2022
1 parent 0238c2a commit 6aa07e7
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 24 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ output to the same place only with a "~" in front of the folder.
- Doshin the Giant
- DONKEY KONG JUNGLE BEAT
- Pikmin 2
- Star Fox Assault
- Donkey Konga

### Games( 50-80% )
- LUIGI'S MANSION
Expand All @@ -59,11 +61,12 @@ output to the same place only with a "~" in front of the folder.
- Pandora s Tower
- Punch Out
- Xenoblade Chronicles
- Donkey Konga

## Supported formats
- RARC, U8, CPK Archives
- YAZ, YAY, CLZ, LZ11 Compressing
- BTI, TPL, TEX1 Textures
- BTI, TPL, NUTC, TXE, TEX1 Textures
- BMD, BDL J3D Models

## Credits
Expand Down
9 changes: 7 additions & 2 deletions TextureExtraction tool/Data/Dictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ static Dictionary()

//Not supported
//Archives
new FileTypInfo(".LZ",new Header("LzS"), FileTyp.Archive, "compressed"),
new FileTypInfo("ZLB",new Header("ZLB"), FileTyp.Archive, "compressed"),
new FileTypInfo("bdl",new Header("J3D2bdl3"), FileTyp.Archive, "display lists"),
new FileTypInfo("bdl",new Header("J3D2bmd2"), FileTyp.Archive, "model"),
new FileTypInfo("dir", FileTyp.Else, "Archive Info"),
Expand All @@ -71,9 +73,7 @@ static Dictionary()
new FileTypInfo("RSC", FileTyp.Archive, "Wario World"),
new FileTypInfo("",new Header("FCMP"), FileTyp.Archive, "MURAMASA"),// compressed MURAMASA: THE DEMON BLADE |.ftx|FCMP FTEX||.mbs|FCMP FMBS||.nms|FCMP NMSB||.nsb|FCMP NSBD|Skript Data||.esb|FCMP EMBP||.abf|FCMP MLIB|
new FileTypInfo("afs",new Header("AFS"), FileTyp.Archive, "Ganbarion"),
new FileTypInfo("",new Header(new byte[]{90,76,66}), FileTyp.Archive, "Starfox"),
new FileTypInfo("dict",new Header(new byte[]{169,243,36,88,6,1}), FileTyp.Archive),
new FileTypInfo("",new Header(new byte[]{78,80,65,67}), FileTyp.Archive),
new FileTypInfo("",new Header(new byte[]{65,75,76,90,126,63,81,100,61,204,204,205}), FileTyp.Archive,"Skies of Arcadia Legends"),

//Textures
Expand Down Expand Up @@ -125,6 +125,9 @@ static Dictionary()
new FileTypInfo("bct", FileTyp.Audio, "Wii Remote sound info"),
new FileTypInfo("csw", FileTyp.Audio, "Wii Remote sound effect"),
new FileTypInfo("cit", FileTyp.Else, "Chord information table"),
new FileTypInfo("cbd", FileTyp.Audio, "data"),
new FileTypInfo("chd",new Header("CHD"), FileTyp.Else),
new FileTypInfo("c3d", FileTyp.Else, "3D Audio Position"),
//Video
new FileTypInfo("thp", new Header("THP"), FileTyp.Video),
new FileTypInfo("dat", new Header("MOC5"), FileTyp.Video),
Expand Down Expand Up @@ -161,6 +164,7 @@ static Dictionary()
new FileTypInfo("brlyt", new Header("RLYT"), FileTyp.Layout, "NW4R structure"),
//Model
new FileTypInfo("brmdl", FileTyp.Model),
new FileTypInfo("fpc", FileTyp.Model, "pac file container"),
//Animation
new FileTypInfo("bck",new Header("J3D1bck1"), FileTyp.Animation, "skeletal transformation"),
new FileTypInfo("bck",new Header("J3D1bck3"), FileTyp.Animation, "skeletal transformation"),
Expand Down Expand Up @@ -199,6 +203,7 @@ static Dictionary()
new FileTypInfo("breft",new Header("REFT"), FileTyp.Else, "Effect"),
new FileTypInfo("cmd",new Header("CAM "), FileTyp.Else, "Camera data"),
new FileTypInfo("bin",new Header("BTGN"), FileTyp.Else, "Materials"),
new FileTypInfo(".pac",new Header("NPAC"), FileTyp.Else, "Star Fox Assault"),
new FileTypInfo("tbl", FileTyp.Else, "JMap data"),
new FileTypInfo("bcam", FileTyp.Else, "JMap camera data"),
new FileTypInfo("brplt", FileTyp.Else, "Palette"),
Expand Down
21 changes: 21 additions & 0 deletions TextureExtraction tool/Data/TextureExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,27 @@ private void Scan(Stream stream, in string subdirectory, in string Extension = "
case "CLZ":
Scan(Compression<CLZ>.Decompress(stream), GetDirectoryWithoutExtension(subdirectory));
break;
case "ZLB":
case "LzS":
byte[] bytes = stream.ToArray();
if (Compression.TryToDecompress(bytes, out byte[] test, out ICompression algorithm))
{
Scan(new MemoryStream(test), subdirectory);
break;
}

if (Compression.TryToFindMatch(in bytes, out algorithm))
{
Log.Write(FileAction.Unsupported, subdirectory + Extension + $" ~{Math.Round((double)stream.Length / 1048576, 2)}mb", $"Description: {filetype.GetFullDescription()} Algorithm:{algorithm.GetType().Name}?");
if (!result.UnsupportedFileTyp.Contains(filetype)) result.UnsupportedFileTyp.Add(filetype);
result.Unsupported++;
result.SkippedSize += stream.Length;
}
else
{
goto default;
}
break;
case "NUTC":
using (JUTTexture Texture = new NUTC(stream)) Save(Texture, subdirectory);
result.ExtractedSize += stream.Length;
Expand Down
2 changes: 1 addition & 1 deletion TextureExtraction tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static void PrintHeader()
#else
Console.WriteLine($"{System.Diagnostics.Process.GetCurrentProcess().ProcessName} v{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}\t\t{DateTime.Now.ToString()}");
#endif
Console.WriteLine($"Supported formats: arc, szs, szp, cpk, bdl, bmd, tpl, bti, {string.Join(", ", Compression.GetAvailablDecompress().Select(x => x.Name))}.");
Console.WriteLine($"Supported formats: RARC, U8, CPK, BDL4, BMD3, TPL, BTI, NUTC, TXE, {string.Join(", ", Compression.GetAvailablDecompress().Select(x => x.Name))}.");
ConsoleEx.WriteLineColoured("".PadLeft(96, '-'), ConsoleColor.Blue);
ConsoleEx.WriteColoured("INFO:", ConsoleColor.Red);
Console.WriteLine(" currently no ROM images are supported, Please unpack them with dolphin into a folder.");
Expand Down
4 changes: 2 additions & 2 deletions TextureExtraction tool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.5.0")]
[assembly: AssemblyFileVersion("0.5.5.0")]
[assembly: AssemblyVersion("0.6.0.0")]
[assembly: AssemblyFileVersion("0.6.0.0")]
4 changes: 2 additions & 2 deletions lib/AuroraLip/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
36 changes: 20 additions & 16 deletions lib/AuroraLip/Texture/Formats/NUTC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,28 @@ protected override void Read(Stream stream)
byte[] palettedata = stream.Read((int)paletteSize);
stream.Position = ImageDataAddress;

GXPaletteFormat GXPaletteFormat = GXPaletteFormat.IA8;
if (PaletteFormat != NUTCPaletteFormat.None)
//When the data size is zero these images hold additional data like Palettedata
if (imageSize != 0)
{
if ((int)PaletteFormat > 3) PaletteFormat = NUTCPaletteFormat.IA8;
GXPaletteFormat = (GXPaletteFormat)Enum.Parse(typeof(GXPaletteFormat), PaletteFormat.ToString());
GXPaletteFormat GXPaletteFormat = GXPaletteFormat.IA8;
if (PaletteFormat != NUTCPaletteFormat.None)
{
if ((int)PaletteFormat > 3) PaletteFormat = NUTCPaletteFormat.IA8;
GXPaletteFormat = (GXPaletteFormat)Enum.Parse(typeof(GXPaletteFormat), PaletteFormat.ToString());
}
TexEntry current = new TexEntry(stream, palettedata, (GXImageFormat)Enum.Parse(typeof(GXImageFormat), Format.ToString()), GXPaletteFormat, ColorsCount, ImageWidth, ImageHeight, TotalImageCount - 1)
{
LODBias = 0,
MagnificationFilter = GXFilterMode.Nearest,
MinificationFilter = GXFilterMode.Nearest,
WrapS = GXWrapMode.CLAMP,
WrapT = GXWrapMode.CLAMP,
EnableEdgeLOD = false,
MinLOD = 0,
MaxLOD = 0
};
Add(current);
}
TexEntry current = new TexEntry(stream, palettedata, (GXImageFormat)Enum.Parse(typeof(GXImageFormat), Format.ToString()), GXPaletteFormat, ColorsCount, ImageWidth, ImageHeight, TotalImageCount - 1)
{
LODBias = 0,
MagnificationFilter = GXFilterMode.Nearest,
MinificationFilter = GXFilterMode.Nearest,
WrapS = GXWrapMode.CLAMP,
WrapT = GXWrapMode.CLAMP,
EnableEdgeLOD = false,
MinLOD = 0,
MaxLOD = 0
};
Add(current);
stream.Position = ImageAddress + totalSize;
}
}
Expand Down

0 comments on commit 6aa07e7

Please sign in to comment.