Making A Backup

From OoT Randomizer Wiki

For using the Randomizer you need to have a backup copy of Ocarina of Time on your computer. This guide will demonstrate how to do this.

Wii Virtual Console

The easiest method of backing up a copy of Ocarina of Time is by creating a WAD of the version installed on your Wii and then extracting that WAD using gzinject and finding the file called rom inside of the extracted contents.

What You Will Need

Getting and Setting Up gzinject

gzinject is an application by Krim/Krimtonz originally for putting the OoT Practice ROM in a WAD, but now has a variety of uses.

Windows: Download then extract the zip file. To run it, open the folder with gzinject in it, then click in the address bar and type cmd and press Enter. In the terminal that shows up you should be able to type gzinject and press Enter and see a bunch of information on how to use gzinject. If you do, move on to the next step.

Linux: Try using the WSL build of gzinject. It doesn't link to many libraries so should work without recompiling. If not, download the source code and then follow the BUILDING file on GitHub.

macOS: Currently you have to build from source. Setting up a build environment is out of scope for this guide, but once you have it set up you should be able to download the source code then follow the BUILDING file on GitHub

Extracting the ROM From the WAD

Once you have a version of gzinject that runs, you'll need to find yourself the Wii common key or figure out a way to generate one. It is the same file you will need to make a WAD on the online generator as well. The file should be placed in the same folder as gzinject and called common-key.bin. Once you have that in place, gzinject should be ready for use.

To extract all of the data from your dumped WAD, open a terminal and type gzinject -a extract -w . Don't forget the space at the end. Next drag your dumped WAD onto the terminal. This should put the path to the WAD at the end. If there is not a space between the "w" and the path, use the arrow keys to go back and add the space. If so, press Enter and gzinject should now extract the WAD to a folder called wadextract.

If it does not make sure that you have the common-key.bin file in the right place, and that you typed the command in the terminal correctly, including the space.

Now if you open the wadextract folder there should be another folder inside called content5 and inside of that folder is a bunch of files, but the one you are looking for is called rom. This is an Ocarina of Time 1.2 ROM that you can run in an emulator. If you want to use it for the Randomizer you will have to downgrade it to 1.0.

Gamecube

Another way to to make a backup of Ocarina of Time is by ripping a Gamecube disc to an ISO using a Wii and then extracting the ROM using Dolphin.

What You Will Need

Extract File From Disc

First, in Dolphin you will need to have the ISO backup of your GameCube disc in the list of games in the main window. If you need to add the path the files are located in, go to OptionsConfigurationPaths and click the Add... button. Next navigate to the folder with your ISO file in it and click Open.

With the backup in the game list, right-click the game and click on Properties then click on the Filesystem tab. You may need to click the arrows on the right of the tabs list to find it.

For a Ocarina of Time / Master Quest ISO, you will want to look for the zlj_f.tgc file for the US copy, if other copies do not have this file, you want the large 500MB+ size file. For Collector's Edition you want to open the tgc folder and select the zelda_ENG_090903.tgc file for the US copy, if other copies do not have this file, you want the large 480MB file. Right-click the file and click Extract File... and extract it to a folder.

Create ROM File From Extracted File

For this part you will want a hex editor for finding where the ROM is in the file we extracted.

For Windows: HxD is recommended. It will also be able to copy the data you find to make a ROM file. For macOS: Hex Fiend looks like a good choice. For Linux: Any graphical hex editor should work, or if you're experienced with hexdump that should also work.

First lets locate the ROM file in the extracted file using a hex editor. Open up the file in a hex editor, then open a find dialog. Hex Fiend has this located at the top of the window. Other software should be able to bring up one by pressing Ctrl+F or on macOS Command ⌘+F. Make sure it is in Hex mode, or you are typing in the Hex side of the window. Type 80 37 12 40 and try to search for that string. This is the "magic" header for a N64 ROM and all N64 ROMs start with these bytes.

Your hex editor should have a place on the window where it displays an "Offset" value somewhere in the window. Make sure you have the 8 or 0 in 80 selected and then write down this value. It is usually a hex value which means that it uses the numbers 0-9 and the letters A-F. Use this Hex to Decimal converter to convert the hex number to a normal decimal number. We will use this in the next section, but the next part is OS specific.

Windows

Now that you have the decimal value of where the ROM is located, press Control+E to open the Select block dialog. Make sure that the radio button next to the dec option is selected. In the Start-offset text box paste or type the decimal value of where the ROM is. Next click the radio button next to Length and type in that text box 33554432. Next click OK and the ROM file will now be selected.

Copy the ROM file's bytes with Ctrl+C, open a new file by pressing Ctrl+N. Next press Ctrl+S to save the file. Save it with a name you will remember such as Ocarina of Time.z64 or similar.

Linux and macOS

Now that you have the decimal value of where the ROM is located, open a terminal. Type cd and press space, then drag the folder you want to save the ROM in into the terminal such as your Downloads folder then press Enter.

We will be using dd to extract the relevant bytes from the file we extracted. Type dd skip= and paste the decimal value of where the ROM is located, then press space and continue the command with count=33554432 if= then drag the file you extracted using Dolphin into the terminal to put it's path here. Press space again then continue the command with of=OcarinaOfTime.z64 bs=1 and press Enter. This will create a file called OcarinaOfTime.z64 in the folder you chose earlier.

Nintendo 64

You can also dump directly from your own N64 carts too. There are many different methods to do so, but not all of them have been tested so it's not realistic to support all of them.

JoeyN64 Cart Flasher

Supports: Windows Known working with but unsupported: Linux (Issues with updating firmware and writing files back to cart)

Store Page

The JoeyN64 Cart Flasher by BennVenn focuses more on rewriting bootleg carts, but can also be used for dumping real carts as well. Generally it is pretty easy to use, however it may try to overdump Ocarina of Time ROMs if it uses a different ROM chip than expected internally. In that case you'll need to play with a hex editor to get a working ROM for randomizer. You'll also need a USB wire to plug into your computer on one end, and a USB-C plug on the other that does data transfer to plug into the device.

Usage

Using the JoeyN64 itself is easy. You just place the game cart into the cartridge connector, ensure that the label is facing away from the N64 controller port. Then plug the USB cable into your computer, then into the JoeyN64. It should show up like a USB drive would in This PC. Open it up and you should see a DEBUG or DEBUG.TXT file. Opening that file should open it in notepad or an equivalent text editor. Ensure that the line near the end of the file says Checksums OK! and not Checksums Bad!. If it says the checksums are bad, unplug the JoeyN64 and try reseating the cartridge. If it continues to happen, try cleaning the contacts on the cartridge with some isopropyl alcohol and a cotton swab, wait for it to dry, and try the JoeyN64 again. Once the checksums are good there should be a THE_LEGE.Z64 file next to the debug text file. You can copy that to your computer. You can also backup your save file THE_LEGE.SRA here too.

You may notice that the file you copied is 64MB. This is due to hardware in the cartridge behaving differently than expected by the firmware. You'll need to cut out the excess data using a hex editor or disk dumper like for the Gamecube method. Just in this case you will be starting at location 0 for Windows, or skipping 0 bytes for macOS and Linux.

Once you have a 32MB file, you can use the downgrader site to verify or downgrade your ROM to be used for the randomizer. If it is a 1.0 ROM already, you can get started using the randomizer. If it detects as a downgradable/convertable ROM you can do so to get a 1.0 ROM to use. If the site cannot detect your ROM, try again with a fresh dump copied from your cart to your PC.

Updating Firmware

Go to Firmware updates and download the newest firmware version. It should be near the top of the list. Open the downloaded zip file and copy the MODE.TXT file from the zip to the JoeyN64, then wait for it to disconnect then reconnect. Next copy the FIRMWARE.JR file and paste it in the JoeyN64. It should disconnect and then reconnect and the DEBUG.TXT file should display the new version in the top line.