Skip to content

Commit

Permalink
Fixes for switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Fjay69 committed Sep 15, 2018
1 parent 41d557b commit dddaa7e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
Binary file modified WinExtract/.vs/WinExtract/v15/.suo
Binary file not shown.
28 changes: 17 additions & 11 deletions WinExtract/WinExtract/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ static void Main(string[] args)
long sprt = bread.ReadUInt32();
bread.BaseStream.Position = sprt;
string what = getSTRGEntry(bread.ReadUInt32());
bread.BaseStream.Position += 0x34;//Skip 0x34 bytes
//bread.BaseStream.Position += 0x34;//Skip 0x34 bytes
bread.BaseStream.Position += 0x48;//Switch
//TPAG
uint spritec = bread.ReadUInt32();
for (int k = 0; k < spritec; k++)
Expand Down Expand Up @@ -141,7 +142,8 @@ static void Main(string[] args)
for (int i = 0; i < entries.Count - 1; i++)
{
uint offset = entries[i];
bread.BaseStream.Position = offset + 4;
//bread.BaseStream.Position = offset + 4;
bread.BaseStream.Position = offset + 8;//Extra 0000 Switch
offset = bread.ReadUInt32();
entries[i] = offset;
}
Expand Down Expand Up @@ -207,14 +209,14 @@ static void Main(string[] args)
string hashString = sBuilder.ToString();
if (hashString == "ff44e9b4b88209202af1b73d7b187d5f")//Undertale 1.01
{
oldUndertale = true;
//oldUndertale = true;
unpackAUDO = true;
}
}
}
else
{
recordFiles(filesToCreate, chunk_name);
recordFiles(filesToCreate, chunk_name);

if (chunk_name == "TXTR") collectFontImages();
}
Expand Down Expand Up @@ -363,19 +365,23 @@ static uint calculateFontSize(uint font_offset) {
return result;
}

static void collectFontImages() {
static void collectFontImages()
{
long bacup = bread.BaseStream.Position;
bread.BaseStream.Position = FONT_offset;
List<uint> fonts = collect_entries(false);
for (int f=0; f<fonts.Count-1; f++)
for (int f = 0; f < fonts.Count - 1; f++)
{
bread.BaseStream.Position = fonts[f]+28;
bread.BaseStream.Position = fonts[f] + 28;
spriteInfo sprt = getSpriteInfo(bread.ReadUInt32());
Bitmap texture = new Bitmap(Image.FromFile(input_folder+"TXTR\\"+sprt.i+".png"));
Bitmap cropped = texture.Clone(new Rectangle((int)sprt.x, (int)sprt.y, (int)sprt.w, (int)sprt.h), texture.PixelFormat);
cropped.Save(input_folder + "FONT\\" + fontNames[f] + ".png");
Bitmap texture;
using (var tempbmp = new Bitmap(Image.FromFile(input_folder + "TXTR\\" + sprt.i + ".png")))
{
texture = new Bitmap(tempbmp);
Bitmap cropped = texture.Clone(new Rectangle((int)sprt.x, (int)sprt.y, (int)sprt.w, (int)sprt.h), texture.PixelFormat);
cropped.Save(input_folder + "FONT\\" + fontNames[f] + ".png");
}
}

bread.BaseStream.Position = bacup;
}

Expand Down
2 changes: 1 addition & 1 deletion WinExtract/WinExtract/WinExtract.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<StartArguments>"E:\Undertale2\data.win" "E:\Undertale2\Data"</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>"E:\Game Maker Games PS Vita\game [Va-11 Hall-a PS Vita].win" "E:\Game Maker Games PS Vita\VA"</StartArguments>
<StartArguments>"D:\UndertaleSwitch\game.win" "D:\UndertaleSwitch\Data"</StartArguments>
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions WinPack/WinPack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Program
static bool strgWithBr;
static bool correctTXTR;
static bool noAUDO;
static bool UTswitch;
static List<fontInfo> newFonts = new List<fontInfo>();
static string[] chunks = new string[] { "GEN8","OPTN","LANG","EXTN","SOND","AGRP","SPRT","BGND","PATH","SCPT","GLOB","SHDR","FONT",
"TMLN","OBJT","ROOM","DAFL","EMBI","TPAG","CODE","VARI","FUNC","STRG","TXTR","AUDO"};
Expand Down Expand Up @@ -51,6 +52,7 @@ static void Main(string[] args)
if (args[i] == "-tt") translatale = true;
if (args[i] == "-correctTXTR") correctTXTR = true;
if (args[i] == "-noAUDO") noAUDO = true;
if (args[i] == "-switch") UTswitch = true;
}
translatale = true;
strgWithBr = false;
Expand Down Expand Up @@ -181,6 +183,10 @@ static void Main(string[] args)
bwrite.Write(0x00000000);
bwrite.Write(0xFFFFFFFF);
} else bwrite.Write((uint)1);
if (UTswitch) {
bwrite.Write((uint)0);//Switch
chunk_size += 4;//Switch
}
Offsets[f] = (uint)bwrite.BaseStream.Position;
bwrite.Write((uint)0);
chunk_size += 8; if (correctTXTR) chunk_size += 4;
Expand Down

0 comments on commit dddaa7e

Please sign in to comment.