News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: A stupid question about calculating length of mio0 data  (Read 1210 times)

SleepyFist

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
A stupid question about calculating length of mio0 data
« on: October 29, 2016, 10:26:51 am »
Im trying to make a rom map for Shindou Mario 64, Ive Identified the location of the mio0 blocks(wasn't hard with a non-byteswapped rom).

The problem is I've got the hex
00 01 5B AE (decompressed length)
00 00 0F 60 (compressed offset)
00 00 64 AC (uncompressed offset)

but I don't know how to calculate the actual len as it is in the rom,
again it might be basic math, probably something I should know already, I'm not sure, but if someone can teach me how to get a proper len out of these values I would appreciate it.

the map I'm working on is based on these
https://www.smwcentral.net/?p=nmap&m=sm64rom
http://origami64.net/showthread.php?tid=113
Sleepy's tune of the week|| 2 Mello - after midnight: unaired broadcasts || https://youtu.be/FKqLCJ4mStI

Zoinkity

  • Hero Member
  • *****
  • Posts: 562
    • View Profile
Re: A stupid question about calculating length of mio0 data
« Reply #1 on: October 29, 2016, 09:18:25 pm »
The only way to determine the length of a MIO, Yaz, or Yay archive is to walk through the compression to find data consumed.

For an example, look at sizeof() in this implementation here:
http://pastebin.com/GUHMwpjT

SleepyFist

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: A stupid question about calculating length of mio0 data
« Reply #2 on: October 30, 2016, 10:27:49 am »
I'm looking at it, but I don't completely understand what I'm looking at,
not versed in programming language, sorry. :huh:
Sleepy's tune of the week|| 2 Mello - after midnight: unaired broadcasts || https://youtu.be/FKqLCJ4mStI

Zoinkity

  • Hero Member
  • *****
  • Posts: 562
    • View Profile
Re: A stupid question about calculating length of mio0 data
« Reply #3 on: October 30, 2016, 10:14:48 pm »
The thing about these is they don't define a filesize.  So, the only way to know its actual size (before padding) is to either log it when decompressing or walk through the file as if you were decompressing it.  You could fudge it though in this case, and the padding really doesn't matter.

This being the game it is, there's these helpful little tables that are used to load resources.  They give the start and endpoint in ROM for the file they load, MIO files included.  You can search for just the ROM address of a file, then copy out its endpoint.  It doesn't help for all of them (the first you can find via ASM reference) but does most of them.

Here's a good chunk of them to get started:
Code: [Select]
0xE42C0 bin
0xE42F0 MIO
0xEF770 MIO
0x1029D0 bin
0x105800 MIO
0x10D870 bin
0x10DC80 MIO
0x10FA90 bin
0x10FD40 MIO
0x1165F0 bin
0x116930 MIO
0x120C30 bin
0x120EB0 MIO
0x12CB90 bin
0x12D1F0 MIO
0x13B300 bin
0x13B690 MIO
0x140700 bin
0x140A70 MIO
0x141BF0 bin
0x141C80 MIO
0x1485E0 bin
0x148890 MIO
0x15B560 bin
0x15BBD0 MIO
0x162FC0 bin
0x163460 MIO
0x194090 bin
0x194CE0 MIO
0x19EDD0 bin
0x19F250 MIO
0x1B2CB0 bin
0x1B3330 MIO
0x1BFC10 bin
0x1C0210 MIO
0x1C2DB0 bin
0x1C2F00 MIO
0x1CCB50 bin
0x1CD220 MIO
0x1DB8F0 bin
0x1DC430 MIO
0x1F3DC0 bin
0x1F4E20 bin
0x1FA4E0 bin
0x244360 bin
0x2448A0 MIO
0x249800 MIO
0x24ACA0 MIO
0x24E3A0 bin

0x280B20 bin
0x280FB0 MIO
0x286AC0 bin
0x2874D0 MIO
0x293D30 MIO
0x2A21F0 MIO
0x2AAE60 MIO
0x2B1310 MIO
0x2C26A0 MIO
0x2CC300 MIO
0x2D5FD0 MIO
0x2DCAF0 MIO
0x2E7CE0 MIO
0x2F8FF0 MIO
0x301C60 MIO
0x307E90 MIO
0x30F950 MIO
0x318530 MIO
0x31BF60 MIO
0x322870 MIO
0x329580 MIO
0x32C780 MIO
0x332170 MIO
0x339B30 MIO
0x3407A0 MIO
0x34A350 MIO
0x34CA60 MIO
0x35D6E0 bin
0x35E770 MIO
0x370AB0 bin
0x371160 MIO
0x3A9EF0 bin
0x3ABBE0 MIO
0x3C1820 bin
0x3C24D0 MIO
0x3D67B0 bin
0x3D70D0 MIO
0x3E0880 bin
0x3E0DD0 MIO
0x3E9660 bin
0x3E9B90 MIO
0x3F4DB0 bin
0x3F5580 MIO
0x3FE940 bin
0x3FF4F0 MIO
0x407500 bin
0x407D40 MIO
0x412220 bin
0x412690 MIO
0x424F60 bin
0x4259E0 MIO
0x42F400 bin
0x42FC20 MIO
0x436D80 bin
0x437420 MIO
0x43C040 bin
0x43C2F0 MIO
0x445660 bin
0x445EB0 MIO
0x446FC0 bin
0x4471C0 MIO
0x452B20 bin
0x4532C0 MIO
0x4677D0 bin
0x468750 MIO
0x470880 bin
0x470EB0 MIO
0x478870 bin
0x479530 MIO
0x4872D0 bin
0x487390 MIO
0x48A490 bin
0x48A750 MIO
0x492D30 bin
0x492EF0 MIO
0x499800 bin
0x499A50 MIO
0x49D520 bin
0x49D740 MIO
0x49EFE0 bin
0x49F140 MIO
0x4A8750 bin
0x4A89F0 MIO
0x4A9810 bin
0x4A9A20 MIO
0x4AC310 bin
0x4AC730 MIO
0x4C6010 bin
0x4C6E20 bin