Disassembly instructions

From Pikmin Technical Knowledge Base
(Redirected from Ghidra)
Jump to navigation Jump to search

The following guide will teach you how to get a disassembler environment with Pikmin or Pikmin 2's code, complete with the symbol map. Some things to keep in mind:

  • The disassembly is still written in PowerPC assembly language, and we only have access to the names of functions, classes, and so on; even then, some of them might be missing. We don't have access to the names of variables or anything like that.
  • The symbol map (i.e. the thing that gives functions, classes, etc. a name) for Pikmin 2 can be found in the first USA demo version of the game. (The one on the retail disc was overwritten with junk data.) For most purposes, it's good enough, since the code should be very similar to the final game.

Getting the necessary files[edit]

Pikmin[edit]

  1. Obtain any copy of Pikmin, as long as it's on the GameCube.
  2. Add it to Dolphin's game list.
  3. Right-click it, Properties, Filesystem:
    1. Right-click Disc at the top of the tree, Extract DOL..., and extract it somewhere.
    2. Right-click /dataDir/build.map, Extract File..., and extract it somewhere.

Pikmin 2[edit]

  1. Obtain the Multi Game Demo Disc Version 17 (US).
  2. Add it to Dolphin's game list.
  3. Right-click it, Properties, Filesystem, go down to zz_Pikmin2_game.tgc, right-click it, Extract File..., and extract it somewhere.
  4. Add the Pikmin 2 demo you've extracted to Dolphin's game list.
    • If your version of Dolphin can't read .tgc files, download tgctogcm and run the .tgc file through it, in order to get a plain old .gcm file.
  5. Right-click the Pikmin 2 demo in Dolphin's game list, Properties, Filesystem:
    1. Right-click Disc at the top of the tree, Extract DOL..., and extract it somewhere.
    2. Right-click pikmin2UP.MAP, Extract File..., and extract it somewhere.

If the Wii versions of either game are what you are looking to disassemble, get ported symbol maps from Hocotate Hacker (USA versions for both); alternatively, you can build the decompilations and obtain a symbol map from those.

Setting up a disassembly environment[edit]

Basics[edit]

  1. Install Ghidra (and maybe familiarize yourself with how it works).
  2. Go to the Ghidra GameCube loader project, and follow the instructions to install it on Ghidra.
  3. In Ghidra, create a project for the game you want, and add that respective game's .dol file you extracted to the project. The type should be detected automatically, but if not, you should select Nintendo GameCube Binary for the format, and PowerPC:BE:32:Gekko_Brodway:default for the language.
  4. When asked if you want to include a symbol map, choose yes, and pick the .map file you extracted.
  5. Drag the .dol file to the CodeBrowser tool. When prompted to analyze the project, press Yes, and go with the defaults.
Credits: Espyo, Yoshi2