What's new

N64 Texture Image Extraction

BGNG

New member
Within the past 24 hours, I've hacked the Albanian dialtone out of the track representation binary data of F-Zero X. I'm preparing to create a course editor program, much like the Expansion Kit and the fabled "MetEdit"... The only thing that I'm lacking is the actual texture data that the game maps to the track.

I ask for information of the texture images stored in F-Zero X, preferably a specification of the binary encoding. I not only want to obtain the textures, but I want my program to extract them from the ROM that will have custom tracks patched to it... both to save size in the binary execuatble, and in case the user changed the textures.

Any help would be appreciated. This isn't information you can just pull out of someone's pocket... (Well, I guess that depends on what they have in their pocket at the time)
 

Quvack

Member
Wow sounds like one hell of a project :) I've been hacking various roms a little bit for the n64 but havent looked at F-Zero from that perspective, so I'm not sure if the textures are compressed or not. Have you tried opening the rom in a program like Sprite Viewer? It supports some N64 format, so if you look through that, changing formats and things, if your lucky they'll be uncompressed aswell.

Programming wise I guess you'll either have to load them the way the game does by finding where its pointers to the textures are or link to all of the locations manually?

Regardless best of luck with that project :) If you need any help I can try a little though my rom hacking skills are rather basic currently, well not up to level editing anyways.
 
OP
BGNG

BGNG

New member
Thanks for the tip about Sprite Viewer. I did get the "Bottom of the world" textures, the little character icons, several fonts, and... I found a TON of images used in the Course Edit feature that's apparently built into the game, yet you simply cannot access it without the expansion... Time to do some OTHER hacking...

However, things like the track textures (what I want), character portraits on the "set your engine setting" screen, the title screen images... Those are obviously compressed, but I don't know how...

Can anyone give me some pointers as to how they may be compressed? Perhaps by some form of LZW or RLE?
 

Quvack

Member
Your welcome :)

Theres course edit textures within the normal rom? Interesting! I'll have to have a look thru the rom when I get a bit more time on my hands :)

I really have no idea what sort of compression the textures would be using, sometimes you can tell by going thru the rom and looking for various things that may hint at the formatting used, othertimes you'll have to use a debugger and breakpoint when various things are accessed so you can track down the de-compression routine. It's likely it'd be a variation of one of the common ones though, this is all guessing though, you might have some luck with one called 'Zelda Extractor' its been able to rip a few things out of some games for me, not just zelda. Again i'll look into it when I have a little time :)

The textures might not be compressed still though, its a pain finding the stuff sometimes when they wont show up correctly unless you have the right formatting and width, etc. set up! Just takes time really if its like that.
 

MasterPhW

Master of the Emulation Flame
There is a great prog where you can extract textures of all nintendo consoles (okay... not the NGC... but all others) it's called SNES edit and It's by a german coder...
HP:http://snesedit.romhack.de/
(hope I'm allowed to post this link, if not, delete it!
 
OP
BGNG

BGNG

New member
Okay, I think I found what I'm looking for... And of course: it's probably harder than it should be.

I found another graphics viewer called Tile Molester, which is SnowBro's enhancement to the infamous Tile Layer Pro. Tile Molester provides a number of codecs for displaying images, and I've found that images in the game can go down in the resolution as far as 4-bit Linear images.

Browsing through the file this way, I re-noticed something I'd noticed before: black bars with white bars inside. Not knowing what these were, I counted them: 26. That's the number of tracks in the game. I take a look at the offset, and slap myself in the forhead. This is a graphical representation of the track data I've already hacked in its entirety; the whole focus of this project.
__________

Following this data, however, is a number of odd occurances. It starts out as a relatively white bar, which turns into a bunch of oscillating "tornadoes" similar in appearance to Windows Media Player's "Neon Highway" visualization. These baffled me since I first started looking through the ROM for images.

I think I know what they are. Looking further into the file, I found three relatively large "white bar-tornado" combos, followed by 33 smaller ones, followed by a HUGE number of tiny ones.

Think of those little icons that show up on the left side of the screen during a GP with the top 6 racers' faces in them. Those are uncompressed in the file; I already found them. And I also saw three more in a different spot of the file, which appear to be enhanced versions of Captain Falcon, Samurai Goroh and Jody Summer. The Goroh version is EXACTLY the same as the image seen in IGN's screenshots of the Expansion Kit.

So I added it all up... Three big tornadoes, three full-screen Title Screen images... 33 smaller ones, 33 racer portraits (Accelleration/Max Speed Screen)... Too-many-to-count tiny ones... too-many-to-count course textures. I sure as heck hope I'm right.
__________

If my suspicion is correct, and these are indeed a collection of compressed images, then I need only the standard under which these images are encoded.

Does anybody, instead of having references to programs, have any tips as to the potential encoding scheme of these images? I'll try LZW ans RLE (common in GIF and TGA, respectively), but if they don't work, I'll want to try something else. It can't be too complicated; because if it were, it would bog down the load times.
 
OP
BGNG

BGNG

New member
Looks to me like all the compressed images start with the ANSI word MIO0

Ring any bells to anyone?
__________

I found but one reference on Google about this, and I translated it from Russian. From what I can tell, this is the same encoding Super Mario 64 used (MIO being an abbreviation of Mario), so... Anyone know how that works?
 
Last edited:

Anton

I like beer
"MIO0" - this is what SuperMario uses like a compression type.
And ZeldaExtractor supports "Yaz0" method.

Quvack - could you tell me please what other games works with ZeldaExtractor except Zelda64 ones? I have a compressing utility for Yaz0 and i'm interested what oter games use this type.
 
OP
BGNG

BGNG

New member
Yes, I've already deducted that part... I'm interested in how it works.
 
OP
BGNG

BGNG

New member
Um, yes, that's... putting it rather... bluntly, TheBench. Indeed, I am searching for exactly the same thing. Check your PMs, TheBench. I've made a proposal you may want to consider.

I hereby request that unless any given member has exact information on the binary specifications of MIO0 and/or Yaz0 (NOT links to programs that can read them), that he not post in this thread whatsoever. This is a picky subject, and there's no need to keep it floating around if the solution cannot be provided; because (no offense to Anton, you've been a good sport) posting anything but the requested information is a disservice to the cause.

I've contacted LaC, a contributing member to the N64 emulation scene and co-author of the emulator NEmu, at Dextrose and I'm awaiting a response. I have other plans on how to obtain this information from other people, but all those efforts may fail. If it comes right down to it, I'll royally sink my razor-sharp teeth into F-Zero X until it cries mercy and gives me what I want.

Additionally... If anyone else is interested in joining TheBench and I in our cause, give me a PM. As soon as I get this stuff figured out, there won't be a soul out there who won't hear about it. This is a slight bit of torture I don't think anyone more needs to tollerate.
 

minkster

New member
y are u hacking into fzero anyways? Just wondering if its a hobby or sumthing counting on i dont no anything about hacking or coding :p
 
OP
BGNG

BGNG

New member
Read my first post in this topic. And please, honor my request: no more replies in this thread.
 
OP
BGNG

BGNG

New member
Okay, comments are now welcome in this thread, for I have figured out MIO0 with the help of Quvack. In this post, I have included my documentation on the encoding, which is presented as a binary specification. I have also provided a Visual Basic source code module that I developed for decompressing MIO0.

Both files are included with the MIO0.zip attatched to this post.

EDIT:
Here's an example of how to use the module:

Code:
Dim RetVal As Integer
RetVal = mioDecodeMIO0("F-Zero X.n64", &H2E01E9, "Test")
MsgBox mioGetErrorString(RetVal)

If you just happen to have F-Zero X, non-byte-swapped (aka Z64), then that will successfully extract the Master splash screen (shown below) and store it as raw pixel data. The pixels are 16-bit, RGBA at 320×240. For some reason, the image is offset at the second byte, the image is shifted one pixel left and the first pixel doesn't seem to be there.
 
Last edited:

Quvack

Member
lol once you set to something it doesnt sound like it takes you that long to work it out! congratulations :) I'm gonna be messing around with this a lot!
 
OP
BGNG

BGNG

New member
Well, like I said in my first post... It only took me a matter of hours to completely hack the track representation data in F-Zero X. I've been stuck for a week and a half without textures... But now I have them, so the project can officially be underway.

I'm preparing to write the graphics engine for the editor. It will pull textures straight from the ROM, so any game modders will be able to work with the actual in-game graphics.

Anyhoo... As soon as I feel like it, I'll do this decoding of Yaz0 just the same, if only to help out TheBench in his cause.

EDIT:
Okay, I've updated the modMIO0.bas file. You can still go back and get the old one to find out why. The way I did things, it read all the data from the hard disk, one byte at a time, and did the same for writing. I've modified the procedure to work solely in memory, and it now takes a mere fraction of the time to complete itself.

I've also made it so the decoder can work for the developer and simply render to a buffer in the developer's program for easy access without going to and from the file system. Here're the new examples:

This code, just like before, reads from a file and writes to a file.
Code:
Dim RetVal As Integer
RetVal = mioDecodeMIO0("F-Zero X.n64", &H23EC51, "Big Blue.tex")
MsgBox mioGetErrorString(RetVal)

This code uses the lowerish-level memory version to do the same thing:
Code:
Dim RetVal As Integer, Buffer() As Byte
Open "F-Zero X.n64" For Binary Access Read As #1
    RetVal = mioMemDecode(1, &H23EC51, Buffer())
Close #1: Open "Big Blue.tex" For Output As #2
    Print #2, StrConv(Buffer(), 64);
Close #2
MsgBox mioGetErrorString(RetVal)

Note that the "For Output" and "StrConv" were used solely for the purpose of resetting the length of any existing "Big Blue.tex"... If you wanted to use "For Binary Access Write," you would use the statement: Put #2, 1, Buffer()

Keep in mind, though, that mioMemDecode HAS to have the file opened for Binary and the Read option set. Opening "For Input" will not work. Additionally, the buffer that will recieve the decompressed MIO0 data MUST NOT have predefined dimensions, and must be of the Byte data type. Do like I did, and simply say "Buffer() As Byte"

Attatched is the modified VB code and an MSPaint arrangement of the textures found in the Big Blue section. (Well... The very last image, of the water that shows up below the course, is actually an image that's uncompressed in a different part of the ROM)
 
Last edited:

Quvack

Member
This kind of information is going to help out a hell of a lot when it comes to hacking some n64 games, especially when MIO0 and Yaz0 are ones that are used in a number of roms from what I remember. I'm gonna go through a few of the games I'm interested in and see what I can find in regards to what compression schemes they use.
Compression has been a thing that has plagued rom hacking for a long time so the more information about the formats out there the better, especially with nice lil tools like this!
 

TheBench

New member
Good work! Interesting stuff. You should run through every rom if you get a chance, just see which use MIO0. I'm seeing if I can apply it.
 

Anton

I like beer
this is already exist an uncompressor, for mio0 games, i guess:
http://www.dextrose.com/index.php?s=3&m=8&f=270#f270
readme says that "This tool has been tested on SM64 (English) and Pilot Wings 64 (English)".
I tried to extract data from mario with this tool (and found fonts in one of extracted files). Can edit them (for transtation) but can't compress it back to be able to insert it to rom.

would be very COOL to have a proggy with the reverse process - compressor....
are there any?
 

Top