Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does the rsizetable (RESTBL) work? #15

Closed
alerion921 opened this issue May 18, 2023 · 11 comments
Closed

How does the rsizetable (RESTBL) work? #15

alerion921 opened this issue May 18, 2023 · 11 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@alerion921
Copy link

When i open a table file and i have one that i have edited, how do i set the size correctly?

Like it isnt bytes is it? Is it a CRC32 value?

Sry that i have to ask

@ArchLeaders
Copy link
Member

The values is the RESTBL are the smallest working heap allocation sizes for a file. For us, it is usually an estimation based off the file size, but with a bit extra room to be safe until we better know how to estimate/calculate them.

I usually take the ratio of the original (decompressed) file size and the original RESTBL value, and use that to scale the new file size. If the game still does not load, I'll increment it until it does load.

@ArchLeaders ArchLeaders added documentation Improvements or additions to documentation good first issue Good for newcomers labels May 18, 2023
@ArchLeaders ArchLeaders pinned this issue May 18, 2023
@ArchLeaders ArchLeaders changed the title When opening a rsizeresource table file How does the rsizetable (RESTBL) work? May 18, 2023
@alerion921
Copy link
Author

So i can do bytes of decompressed and + with compressed file? And then the total bytes ? Sorry i dont understand completly :-/

@ArchLeaders
Copy link
Member

No, you'd take the original decompressed file size (from the game ROM) and compare it with the RESTBL entry. Then apply that ratio to the modified file size (also decompressed) to get the new RESTBL estimated entry size.

If the game still crashes, increment the RESTBL entry value by an arbitrary amount.

@alerion921
Copy link
Author

Thank you!

@alerion921
Copy link
Author

alerion921 commented May 19, 2023

I am confused to why this still does not work, my brain might be too tired for me to understand this..

here is what i tried:

Try 1 (size):
43697792 - Original Size inside Resource File
43697532 - Decompressed Original Size (from explorer properties)
size diffrence: 260

43445080 - Modified Decompressed Size
43444820 - Modified with diffrence - (260) FAILED (Tried to add this to resourcesizetable)
43445340 - Modified with the diffrence + (260) FAILED (Tried to add this to resourcesizetable)

Try 2 (size on disk instead):
43697532 - Original Size inside Resource File
43700224 - Decompressed Original Size on Disk (from explorer properties)
size diffrence: 2692

43446272 - Modified Decompressed Size on disk
43448964 - Modified Decompressed Size on disk + diffrence (2692) FAILED (Tried to add this to resourcesizetable)
43443580 - Modified Decompressed Size on disk - diffrence (2692) FAILED (Tried to add this to resourcesizetable)

Try 3:

Modified size on disk - Original Size in resource file: 251260
= 43446272 + 251260 = 43697532 FAILED (Tried to add this to resourcesizetable)

Im lost :(

@ArchLeaders
Copy link
Member

First off, your ratio calculation is wrong. You get the ratio from the difference, we don't care to much about the difference itself.

We need to find "by what was the original file size multiplied to get the resource size?"

Or, written in an expression:

file_size * x = resource_size
resource_size / files_size = x

If we plug in your numbers we get:

43697532 * x = 43697792
43697792 / 43697532 = x
x = 1.00000595

So the ratio you want is actually 1.00000595.


So then we take the modified file size and multiply it by the ratio to get an approximate answer based on the original difference.

(Notice this is the same as the original equation, just with our new variables)

modified_file_size * ratio = resource_size
// always round up from zero to be safe
43445080 * 1.00000595 = 43445339

And finally comes the most important part:

If the game still crashes, increment the RESTBL entry value by an arbitrary amount.

Because this is still just a rough estimation without any real structure, we need to add a bit of extra room to account for stuff we don't understand.

For this I usually start by just moving a digit somewhere in the middle of the number up one (e.g. 456 > 466).

After that it's just testing and changing until it works.


Also note: Never use the file size on disk, it's just the file size with windows meta data included.

@alerion921
Copy link
Author

Thanks this made alot more sense to me and i got it working. Now i just got to figure out how to remove the textboxes without the game crashing upon load.. My goal is to remove the text boxes that contain the nintendo buttons in the background of the current active UI button :)

@tomxhachijuroku
Copy link

First off, your ratio calculation is wrong. You get the ratio from the difference, we don't care to much about the difference itself.

We need to find "by what was the original file size multiplied to get the resource size?"

Or, written in an expression:

file_size * x = resource_size
resource_size / files_size = x

If we plug in your numbers we get:

43697532 * x = 43697792
43697792 / 43697532 = x
x = 1.00000595

So the ratio you want is actually 1.00000595.

So then we take the modified file size and multiply it by the ratio to get an approximate answer based on the original difference.

(Notice this is the same as the original equation, just with our new variables)

modified_file_size * ratio = resource_size
// always round up from zero to be safe
43445080 * 1.00000595 = 43445339

And finally comes the most important part:

If the game still crashes, increment the RESTBL entry value by an arbitrary amount.

Because this is still just a rough estimation without any real structure, we need to add a bit of extra room to account for stuff we don't understand.

For this I usually start by just moving a digit somewhere in the middle of the number up one (e.g. 456 > 466).

After that it's just testing and changing until it works.

Also note: Never use the file size on disk, it's just the file size with windows meta data included.

Hello I have a question.
I did the math in my case I'm translating totk to Polish, so I'm modding EUen.Product.110.sarc.zs:

11428804 * 1.0000357 = 11429212

But I'm confused about the arbitrary amount since the middle of my number is empty:
1142 9212
Can you tell me witch number in 11429212 i need to be changing until I find the right value for RESTBL?
Thank you in advance.

@ArchLeaders
Copy link
Member

There is no real method to it, you just pick a digit somewhere and change it's value, then test in-game if it works.

@tomxhachijuroku
Copy link

tomxhachijuroku commented Jun 14, 2023

There is no real method to it, you just pick a digit somewhere and change it's value, then test in-game if it works.

Do I have to test every number from the beginning to the end, or from the end to the beginning, always just by one up or just increase the value of the middle number in the 3 at the end, can you make a couple examples, in the reply please, and why it doesn't work if I just max out to 99999999 like it did work in botw RESTBL?

@ArchLeaders
Copy link
Member

It doesn't really work like that, you are just trying to get the smallest number that doesn't cause the game to crash.

The reason using 999... "works" is because it's enough memory for the file to fit into, however you'll overload the memory heap very quickly because the file doesn't need that much, so you waste a bunch of space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants