********************DISCLAIMER************************
Please respect the rights of all texture pack designers by not uploading the modified pack in any way or form.
By modifying the texture caches you are agreeing that you intend to use them for personal use only and have no intention of sharing the texture caches.
Please show the texture pack creators the respect they deserve for providing you with their hard work.
********************DISCLAIMER************************
This process will be used at the users risk and is not supported by Emulation64, it's staff members, administrators, moderators, or texture artists.
Prerequisits:
LANdroid provided an excellent tutorial on how to set up cygwin and install glide64-cache-extract. This information will be required in this tutorial. So please read his tutorial first.
Introduction:
Djipi gave us his very nice texture packs for Zelda. Many people like them but there is one bummer: They are not valid texture packs but only the texture cache of Glide64. This makes everything a little bit problematic because now everyone needs the same GlideHQ settings as he had.
Besides this minor inconvenience, there is also one big known problem: The Lens of Truth doesn't work in Majora's Mask with this texture cache. And Djipi doesn't want us to
- send the exported textures around
- mix the textures with other texture packs
- modify his texture
But hey, this is a texture cache and caches are known to drop data when it is broken or outdated. So lets just do that. And LANdroid already gave us all we need to know about the broken texture:
The texture(s) causing the lens of truth not to work are:
ZELDA MAJORA'S MASK#0E654C89#4#0_all.png
OR
ZELDA MAJORA'S MASK#0E654C89#4#0_rgb.png
I have dumped these from the original ROM and believe that it is probably the first one.
I believe I know how to fix this but I was hoping Djipi might update his pack with a fix by removing that texture.
For your information if this is fixed you still need to enable the following setting in Project64:
Options > Configure Graphics Plugin > Glide64 Settings - Basic Settings > Frame buffer emulation - [x] Use frame buffer objects
So lets just drop these broken textures from the cache and continue without them.
Required tools:
- Cygwin
- gzip
- xdelta
- glide64-cache-extract
- Hexeditor which is capable of removing bytes (I've use okteta from the KDE project)
- A texteditor (like Notepad+)
The Glide64 texture cache format
First we need to understand the basics of the Glide64 cache format. It a gzip compressed container. Inside this container is a header saving what the cache creators settings were when he dumped the .dat cache files. This is then followed by blocks of textures (each one having a 47 byte header followed by the texture data).
Code:
+----------------------+
| GZIP container |
| +----------------+ |
| | Cache header | |
| +----------------+ |
| | Texture 1 | |
| +----------------+ |
| | Texture 2 | |
| +----------------+ |
| | ..... | |
| +----------------+ |
| | Texture n | |
| +----------------+ |
| |
+----------------------+
So it is extreme easy to just drop a specific texture after the gzip compression is removed from the cache file.
Preparations
Please start the cygwin terminal (you will be automatically in your users HOME directory)
And then download the Majora's Mask texture cache pack from Djipi and place following files in the folder C:\cygwin\home\[USER]\
- ZELDA MAJORA'S MASK_HIRESTEXTURES.dat
- ZELDA MAJORA'S MASK_MEMORYCACHE.dat
Identifying the position of the texture
The position of the textures can be found using glide64-cache-extract. But first the outer gzip layer has to be removed from the cache. And then we save the positions using glide64-cache-extract's debug capabilities
Code:
zcat "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" > unpacked.cache
glide64_cache_extract -vv -i unpacked.cache -o /dev/null 2> debug.txt
Please note that the textures were not really extracted. All converted output was directly dumped into the void using /dev/null
The C:\cygwin\home\[USER]\debug.txt can now be opened with your texteditor/notepad. You will see the config header (the settings Djipi set when creating his texture cache) and a lot of file headers. We need to find the file header with the checksum that LANdroid identified: 0E654C89. You should find following section
Code:
Offset: 0x646cd2
File header:
checksum: 0x000000000E654C89
width: 256
height: 256
format: 0x8002
smallLodLog2: 8
largeLodLog2: 8
aspectRatioLog2: 0
tiles: 0
untiled_width: 0
untiled_height: 0
is_hires_tex: 1
size: 13406
Offset: 0x64a15f
File header:
....
Nice work, we now know that the problematic texture starts at 0x646cd2 and the next texture starts at 0x64a15f.
Dropping the texture from the cache
We now know that the problematic bytes in the cache are starting at 0x646cd2 and are ending at 0x64a15e (0x64a15f - 1). So we open up unpacked.cache in our hexeditor and select the mentioned 13453 bytes, cut them out and save the file as modified.cache.
Recompressing the texture cache
We've uncompressed the cache to be able to drop the texture. Now we need to compress it to be able to load it with Glide64 again. But first save the original for later.
Code:
mv "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig"
gzip -n -c modified.cache > "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat"
And now a little bit of cleanup work:
Code:
rm debug.txt unpacked.cache modified.cache
Tata, you have just removed the problematic texture. I personally don't know if this helps because I neither have the game nor a savestate to test it.
Just copy the files "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" and "ZELDA MAJORA'S MASK_MEMORYCACHE.dat" to your cache folder and try it out.
Advanced: Creating a patch
It would be nice when we can save the modification instructions somewhere instead of doing it by hand all the time. Here comes xdelta into play. Maybe you've remember that we saved the original "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" as "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig". These two files can now be used to create a delta file as follows:
Code:
xdelta delta "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" "ZELDA MAJORA'S MASK_HIRESTEXTURES.delta"
This should create 273 bytes file called "ZELDA MAJORA'S MASK_HIRESTEXTURES.delta" which contains all necessary instructions from this tutorial.
Advanced: Applying the patch
Ok, now assume that you have only the original texture cache files, the delta file and xdelta. Here it is how you can apply it again:
- move the texture cache files to the same folder as the delta file
- rename the "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" to "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig"
- apply the delta file with xdelta
- copy "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" and "ZELDA MAJORA'S MASK_MEMORYCACHE.dat" to the glide64 texture cache folder
Here are step 2+3 as cygwin terminal (bash) commands:
Code:
mv "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig"
xdelta patch "ZELDA MAJORA'S MASK_HIRESTEXTURES.delta" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat"
or as Windows cmd commands:
Code:
move "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig"
xdelta patch "ZELDA MAJORA'S MASK_HIRESTEXTURES.delta" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat.orig" "ZELDA MAJORA'S MASK_HIRESTEXTURES.dat"
An zip file which contains an example as batch file and the required tools can be downloaded here. It doesn't contain the .dat cache files but only the tools and the delta file. The pristine .dat files have to be copied to the extracted folder manually. Running the .bat file will then create the new .dat files which can be used together with Glide64.
Do not distributed the modified texture cache files
Acknowledgements
- Djipi for creating the Zelda MM and OoT texture cache (but I still say that the Glide64 cache file format was never for distribution and never a DRM)
- LANdroid for debugging the Lens of truth problem
- Every tool and library author for their awesome tools/libraries
Last edited:
Moshroum,
Great work and tutorial.
I can confirm that the lens of truth is now working using this method.
For people wanting to use this fix you still need to enable certain settings:
Specifically: [X] Use frame buffer objects
Credit for this information to 5h0rty at Project64 forums:
http://forum.pj64-emu.com/showpost.php?p=49992&postcount=7
Great work and tutorial.
I can confirm that the lens of truth is now working using this method.
For people wanting to use this fix you still need to enable certain settings:
Specifically: [X] Use frame buffer objects
Credit for this information to 5h0rty at Project64 forums:
http://forum.pj64-emu.com/showpost.php?p=49992&postcount=7
Last edited: