Skip to content

Commit

Permalink
add PTLG Strikers Texture Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Venomalia committed Jul 15, 2022
1 parent 839d2fa commit 6e6eb2b
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 6 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ output to the same place only with a "~" in front of the folder.
- Super Smash Bros. Brawl
- Takt of Magic[¹](#notes)
- Odama
- Mario Soccer

### Games( 20-50% )
- Go Vacation
- Night's Journey of Dreams
- Mario Strikers Charged Football
- Pikmin 1

### Not supported games ( 0-20% )
- Kirby Air Ride
- Mario Strikers Charged Football
- MarioGolf Toadstool Tour
- F-ZERO GX
- SOULCALIBUR2
Expand All @@ -93,7 +94,7 @@ output to the same place only with a "~" in front of the folder.
## Supported formats
- RARC, NARC, U8, CPK, bres, AFS Archives
- YAZ, YAY, CLZ, LZ11, LZSS Compressing
- BTI, TPL, NUTC, REFT, TXE, TEX1, TEX0, TXTR Textures
- BTI, TPL, NUTC, REFT, TXE, TEX1, TEX0, TXTR, PTLG Textures
- BMD3, BDL4 J3D Models

## Credits
Expand All @@ -117,4 +118,7 @@ output to the same place only with a "~" in front of the folder.
- to read LZ11 Compressing

- [CLZ-Compression](https://github.com/sukharah/CLZ-Compression)
- to read CLZ Compressing
- to read CLZ Compressing

- [Switch-Toolbox](https://github.com/KillzXGaming/Switch-Toolbox/blob/12dfbaadafb1ebcd2e07d239361039a8d05df3f7/File_Format_Library/FileFormats/NLG/MarioStrikers/StrikersRLT.cs)
- PTLG format base on
4 changes: 4 additions & 0 deletions TextureExtraction tool/Data/TextureExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ private void Scan(Stream stream, string subdirectory, in string Extension = "")
using (JUTTexture Texture = new NUTC(stream)) Save(Texture, subdirectory);
result.ExtractedSize += stream.Length;
break;
case "PTLG":
using (JUTTexture Texture = new PTLG(stream)) Save(Texture, subdirectory);
result.ExtractedSize += stream.Length;
break;
case "TEX1":
foreach (var item in new BMD.TEX1(stream).Textures)
{
Expand Down
2 changes: 1 addition & 1 deletion TextureExtraction tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,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: RARC, NARC, U8, CPK, BDL4, BMD3, TPL, BTI, NUTC, TXE, bres, REFT, AFS, TXTR,\n\t\t {string.Join(", ", Compression.GetAvailablDecompress().Select(x => x.Name))}.");
Console.WriteLine($"Supported formats: RARC, NARC, U8, CPK, BDL4, BMD3, TPL, BTI, NUTC, TXE, bres, REFT, AFS, TXTR, PTLG, \n\t\t {string.Join(", ", Compression.GetAvailablDecompress().Select(x => x.Name))}.");
ConsoleEx.WriteLineColoured("".PadLeft(108, '-'), 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.6.7.0")]
[assembly: AssemblyFileVersion("0.6.7.0")]
[assembly: AssemblyVersion("0.6.8.0")]
[assembly: AssemblyFileVersion("0.6.8.0")]
1 change: 1 addition & 0 deletions lib/AuroraLip/AuroraLip.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<Compile Include="Compression\Interfaces\ICompression.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Texture\Formats\BTI.cs" />
<Compile Include="Texture\Formats\PTLG.cs" />
<Compile Include="Texture\Formats\TXTR.cs" />
<Compile Include="Texture\Formats\NUTC.cs" />
<Compile Include="Texture\Formats\REFT.cs" />
Expand Down
122 changes: 122 additions & 0 deletions lib/AuroraLip/Texture/Formats/PTLG.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
using AuroraLip.Common;
using System;
using System.Collections.Generic;
using System.IO;
using static AuroraLip.Texture.J3D.JUtility;

namespace AuroraLip.Texture.Formats
{
// base on https://github.com/KillzXGaming/Switch-Toolbox/blob/12dfbaadafb1ebcd2e07d239361039a8d05df3f7/File_Format_Library/FileFormats/NLG/MarioStrikers/StrikersRLT.cs
public class PTLG : JUTTexture, IMagicIdentify
{
public string Magic => magic;

private const string magic = "PTLG";

public PTLG() { }

public PTLG(Stream stream) : base(stream) { }

public PTLG(string filepath) : base(filepath) { }

protected override void Read(Stream stream)
{
if (!stream.MatchString(magic))
throw new Exception($"Invalid Identifier. Expected \"{Magic}\"");

uint numTextures = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
uint unk = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
uint padding = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);

uint Off = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
if (Off == 0)
stream.Seek(12, SeekOrigin.Current);
else
stream.Seek(-4, SeekOrigin.Current);

List<PTLGEntry> Entries = new List<PTLGEntry>();
for (int i = 0; i < numTextures; i++)
{
Entries.Add(new PTLGEntry(stream));
}

long startPos = stream.Position; //1008

for (int i = 0; i < numTextures; i++)
{
stream.Seek(startPos + Entries[i].ImageOffset, SeekOrigin.Begin);

long pos = stream.Position;

uint Images = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
uint unknown2 = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0); //1 3 2 8 ||Unknown ==12 2439336753|1267784150|3988437873
byte unknown4 = (byte)stream.ReadByte(); //5 0 8
PTLGImageFormat PTLGFormat = (PTLGImageFormat)stream.ReadByte();
GXImageFormat Format = (GXImageFormat)Enum.Parse(typeof(GXImageFormat), PTLGFormat.ToString());
byte unknown5 = (byte)stream.ReadByte(); //5 0 8
byte unknown6 = (byte)stream.ReadByte(); //3 4 0 2 6 8
ushort ImageWidth = BitConverter.ToUInt16(stream.ReadBigEndian(2), 0);

if (ImageWidth == 0)
ImageWidth = BitConverter.ToUInt16(stream.ReadBigEndian(2), 0);
ushort ImageHeight = BitConverter.ToUInt16(stream.ReadBigEndian(2), 0);

ushort unknown7 = BitConverter.ToUInt16(stream.ReadBigEndian(2), 0);//0
uint unknown8 = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0); //256
uint unknown9 = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);//is 65535 Unknown ==12
uint unknown10 = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);//0

if (Entries[i].Unknown != 0) continue;

TexEntry current = new TexEntry(stream, null, Format, GXPaletteFormat.IA8, 0, ImageWidth, ImageHeight, (int)Images - 1)
{
LODBias = 0,
MagnificationFilter = GXFilterMode.Nearest,
MinificationFilter = GXFilterMode.Nearest,
WrapS = GXWrapMode.CLAMP,
WrapT = GXWrapMode.CLAMP,
EnableEdgeLOD = false,
MinLOD = 0,
MaxLOD = 0
};
Add(current);

stream.Seek(pos + Entries[i].SectionSize, SeekOrigin.Begin);


}
}

protected override void Write(Stream stream)
{
throw new NotImplementedException();
}

public enum PTLGImageFormat : byte
{
I4 = 0x02,
I8 = 0x03,
IA4 = 0x04,
RGB5A3 = 0x05,
CMPR = 0x06,
RGB565 = 0x07,
RGBA32 = 0x08
}

public class PTLGEntry
{
public uint Hash;
public uint ImageOffset;
public uint SectionSize;
public uint Unknown; //0 or 12

public PTLGEntry(Stream stream)
{
Hash = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
ImageOffset = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
SectionSize = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
Unknown = BitConverter.ToUInt32(stream.ReadBigEndian(4), 0);
}
}
}
}

0 comments on commit 6e6eb2b

Please sign in to comment.