XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Mon Aug 21, 2017 9:31 am

All times are UTC + 1 hour


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblarc)
PostPosted: Sat Mar 18, 2017 5:00 pm 
Offline
ultra-n00b

Joined: Thu Jun 18, 2015 7:04 pm
Posts: 5
Has thanked: 6 times
Have thanks: 0 time














You can make the ads go away by registering

I'm having trouble repacking a Yaz0 file with existing tools (Uwizard seems to be the most up to date, which uses yaz0enc). It's supposed to go Yaz0/SZS > SARC, and while SARC repacking works, Yaz0 unpacking and/or repacking go wrong and make the game crash even if content is left untouched. Can anyone take a look? Here's the header for reference:

Image

A link to the file I'm trying to repack, Common.sblarc, is on the attachment. I can provide the whole file, Bootup.pack (SARC), if needed. Path goes: content/Pack/Bootup.pack/Layout/Common.sblarc
And here are specs of the format from 2005 if they're of any help: http://www.amnoid.de/gc/yaz0.txt

Thanks.


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.



Top
 Profile  
 
 Post subject: Re: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblar
PostPosted: Tue Mar 21, 2017 5:26 pm 
Offline
veteran

Joined: Sat Feb 27, 2010 6:57 pm
Posts: 86
Has thanked: 37 times
Have thanks: 67 times
Here ya go

Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Syroot.NintenTools.Yaz0;

namespace Yaz0
{
    class Program
    {
        public static byte[] ArrayReverse(byte[] array)
        {
            Array.Reverse(array);
            return array;
        }

        public static Int32 SwapEndianness(Int32 value)
        {
            return BitConverter.ToInt32(ArrayReverse(BitConverter.GetBytes(value)), 0);
        }

        static void Main(string[] args)
        {
            if (args.Count() == 3)
            {
                switch(args[0])
                {
                    case "decode":
                        if (File.Exists(args[1]))
                        {
                            FileInfo fi = new FileInfo(args[1]);
                            Yaz0Compression.Decompress(fi.FullName, args[2]);
                        }
                        else
                        {
                            Console.WriteLine("The specified input file does not exist");
                        }
                        break;
                    case "encode":
                        if (File.Exists(args[1]))
                        {
                            FileInfo fi = new FileInfo(args[1]);
                            byte[] decodedBuffer = File.ReadAllBytes(fi.FullName);
                            Int32 bulkChunksCount = decodedBuffer.Length / 0x08;
                            Int32 extraChunkSize = decodedBuffer.Length % 0x08;
                            byte[] chunkBuffer = new byte[0x08];
                            using (FileStream fs = new FileStream(args[2], FileMode.Create, FileAccess.Write))
                            {
                                fs.Write(Encoding.UTF8.GetBytes("Yaz0"), 0, 4);
                                fs.Write(BitConverter.GetBytes(SwapEndianness((Int32)fi.Length)), 0, 4);
                                fs.Write(BitConverter.GetBytes(SwapEndianness(0x00000000)), 0, 4); //Can be 0x00002000 sometimes, check the original Yaz0 file at offset 0x08
                                fs.Write(BitConverter.GetBytes(SwapEndianness(0x00000000)), 0, 4);

                                for (int i = 0; i < bulkChunksCount; i++)
                                {
                                    fs.Write(BitConverter.GetBytes(0xFF), 0, 1);
                                    Array.Copy(decodedBuffer, (i * 8), chunkBuffer, 0, 8);
                                    fs.Write(chunkBuffer, 0, 8);
                                }

                                if (extraChunkSize != 0)
                                {
                                    Array.Resize(ref chunkBuffer, extraChunkSize);
                                    Array.Copy(decodedBuffer, (0x08 * bulkChunksCount), chunkBuffer, 0, chunkBuffer.Length);

                                    Byte codeByte = 0x00;
                                    switch (extraChunkSize)
                                    {
                                        case 1:
                                            codeByte = 0x80;
                                            break;
                                        case 2:
                                            codeByte = 0xC0;
                                            break;
                                        case 3:
                                            codeByte = 0xE0;
                                            break;
                                        case 4:
                                            codeByte = 0xF0;
                                            break;
                                        case 5:
                                            codeByte = 0xF8;
                                            break;
                                        case 6:
                                            codeByte = 0xFC;
                                            break;
                                        case 7:
                                            codeByte = 0xFE;
                                            break;
                                        default:
                                            break;
                                    }

                                    fs.Write(BitConverter.GetBytes(codeByte), 0, 1);
                                    fs.Write(chunkBuffer, 0, chunkBuffer.Length);
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("The specified input file does not exist");
                        }
                        break;
                    default:
                        break;
                }
                Console.WriteLine("Finished!");
                Console.WriteLine("Press any key to exit ...");
                Console.ReadKey();
            }
            else
            {
                //Show help
                Console.WriteLine("Yaz0.exe decode <input_file> <output_file>");
                Console.WriteLine("Yaz0.exe encode <input_file> <output_file>");
                Console.WriteLine("Press any key to exit ...");
                Console.ReadKey();
            }
        }
    }
}



Last edited by EcheloCross on Wed Mar 22, 2017 5:32 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblar
PostPosted: Tue Mar 21, 2017 8:15 pm 
Offline
ultra-n00b

Joined: Thu Jun 18, 2015 7:04 pm
Posts: 5
Has thanked: 6 times
Have thanks: 0 time
EcheloCross wrote:
Here ya go

Forgive my ignorance but that's C#, right? I see it mentions Syroot.NintenTools.Yaz0, do I need to get it before compiling?


Top
 Profile  
 
 Post subject: Re: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblar
PostPosted: Wed Mar 22, 2017 5:18 am 
Offline
veteran

Joined: Sat Feb 27, 2010 6:57 pm
Posts: 86
Has thanked: 37 times
Have thanks: 67 times
Yes, its c#, and yes you need to get that Syroot.NintenTools.Yaz0 part for decoding only.
https://github.com/Syroot/NintenTools.Yaz0

You can comment out the decoding part and the need for Syroot.Nintentools.Yaz0 if you are already using a different tool to decode them.

The encode method I wrote using the info from the doc you provided. It uses fake compression (compression level 0), so the file gets larger when encoding. Even though the files are larger, they are still valid Yaz0.


Top
 Profile  
 
 Post subject: Re: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblar
PostPosted: Wed Mar 22, 2017 10:49 pm 
Offline
ultra-n00b

Joined: Thu Jun 18, 2015 7:04 pm
Posts: 5
Has thanked: 6 times
Have thanks: 0 time
EcheloCross wrote:
Yes, its c#, and yes you need to get that Syroot.NintenTools.Yaz0 part for decoding only.
https://github.com/Syroot/NintenTools.Yaz0

You can comment out the decoding part and the need for Syroot.Nintentools.Yaz0 if you are already using a different tool to decode them.

The encode method I wrote using the info from the doc you provided. It uses fake compression (compression level 0), so the file gets larger when encoding. Even though the files are larger, they are still valid Yaz0.

Sorry, I must be doing something wrong. Bear with me as I've never done this before. I downloaded VS2015, made it a Visual C# Console Application, got NuGet, ran the command to get Syroot.Nintentools.Yaz0 and built it, but decode just returns "Finished!" without doing anything while encode refuses to work. Could you please compile it?


Top
 Profile  
 
 Post subject: Re: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblar
PostPosted: Thu Mar 23, 2017 9:16 am 
Offline
veteran

Joined: Sat Feb 27, 2010 6:57 pm
Posts: 86
Has thanked: 37 times
Have thanks: 67 times
Here ya go

Give it a try like this, and you'll see the files match if you compare the "decoded" and "encoded_decoded" files md5 sums
Code:
Yaz0.exe decode Common.sblarc Common_decoded.sblarc

Yaz0.exe encode Common_decoded.sblarc Common_encoded.sblarc

Yaz0.exe decode Common_encoded.sblarc Common_encoded_decoded.sblarc


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.



Top
 Profile  
 
 Post subject: Re: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblar
PostPosted: Thu Mar 23, 2017 9:53 pm 
Offline
ultra-n00b

Joined: Thu Jun 18, 2015 7:04 pm
Posts: 5
Has thanked: 6 times
Have thanks: 0 time
EcheloCross wrote:
Here ya go

Give it a try like this, and you'll see the files match if you compare the "decoded" and "encoded_decoded" files md5 sums
Code:
Yaz0.exe decode Common.sblarc Common_decoded.sblarc

Yaz0.exe encode Common_decoded.sblarc Common_encoded.sblarc

Yaz0.exe decode Common_encoded.sblarc Common_encoded_decoded.sblarc

Thanks. It works, but the game seems to require maximum compression, it still crashes. Might be something new for the format. None of the tools I've tried even got close to the original's 3.770KB.


Top
 Profile  
 
 Post subject: Re: [Wii U]Legend of Zelda: Breath of the Wild - Yaz0 (sblar
PostPosted: Wed Jun 21, 2017 5:35 pm 
Offline
mega-veteran
mega-veteran

Joined: Thu Sep 30, 2010 9:52 am
Posts: 177
Has thanked: 19 times
Have thanks: 0 time
Hi friend, anyone got anything? Ask, how can you see these files in wiiu? When down the game I only see 00000.app files or other things .app.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group