A decompilation of Pikmin 2 (USA) brought to you by fans of the series.
Go to file
2023-01-11 13:54:27 -05:00
.github/workflows Various cleanups & KochappyBaseMgr done 2022-10-19 23:11:49 +01:00
.vscode Ebi screens (#131) 2022-12-29 18:04:33 -05:00
asm WIP ninja build support 2023-01-11 12:14:56 -05:00
docs condense conditional 2023-01-11 13:54:27 -05:00
include Mamuta state progress. 2023-01-11 13:43:39 -05:00
sha1
src condense conditional 2023-01-11 13:54:27 -05:00
tools WIP ninja build support 2023-01-11 12:14:56 -05:00
.clang-format Misc. tweaks 2022-10-26 01:12:41 +01:00
.gitattributes Create .gitattributes 2022-01-27 22:30:48 -05:00
.gitignore WIP ninja build support 2023-01-11 12:14:56 -05:00
aoi.exe Various cleanups & KochappyBaseMgr done 2022-10-19 23:11:49 +01:00
asmdiff.sh Add makefile for elf2dol, Edit asmdiff.sh, Add patch_linker.sh 2021-10-04 10:10:08 -04:00
configure.py WIP ninja build support 2023-01-11 12:14:56 -05:00
dtk_version WIP ninja build support 2023-01-11 12:14:56 -05:00
e_files.mk Match + link more Dolphin files (#94) 2022-10-15 16:53:33 +11:00
genasm.sh Update genasm.sh with --no-strip and some smarts. 2022-07-03 17:28:06 -04:00
genasmNoStrip.sh JPATexture, gameIconTexture, and random progress! 2021-12-05 19:22:31 -05:00
ldscript.lcf Major BSS refactor 2022-06-24 21:08:27 -04:00
LICENSE.MD Rename LICENSE to LICENSE.MD 2022-01-21 21:35:01 -05:00
linker-map.txt
Makefile split dolphin cflags 2023-01-11 12:14:57 -05:00
obj_files.mk split dolphin cflags 2023-01-11 12:14:57 -05:00
README.MD Remove Contributors list. 2022-12-03 16:16:35 +11:00

Pikmin 2

Pikmin 2 decompilation to C++/C

- INFORMATION! -

The ROM this repository builds can be shifted. You are able to add
and remove code as you see fit, for modding or research purposes.

It builds the following DOL: pikmin2.usa.dol: sha1: 90d328bf8f190c90472e8c19e7e53c6ad0fe0d1a

Building

Required Tools

Instructions

  • WINDOWS ONLY STEP:

    • Launch msys2 (provided by devkitPro) and run the following commands:
    pacman -S msys2-keyring
    pacman -S gcc git python
    
  1. Clone the repo using git clone https://github.com/projectPiki/pikmin2/

  2. Download GC_WII_COMPILERS.zip and extract the contents of the GC folder to tools/mwcc_compiler/ - you'll have to make this folder yourself. For example, your directory structure should look like pikmin2/tools/mwcc_compiler/2.6/ (along with the other versions).

  3. Run make -j in a command prompt or terminal.

    • -j Allows make to use multiple threads, speeding up the process.
    • If just -j gives errors on your setup, try specifying a set number of threads, e.g. make -j 4.
  • OPTIONAL STEPS:

    • Obtain a clean DOL of Pikmin 2 USA 1.0 and place it in the base working directory and rename it to baserom.dol.
    • To generate a linker map (takes a considerable amount of time), run make MAPGENFLAG=1 -j.
    • The project uses clang-format for a consistent style. Download the correct version and place in the main repo directory (e.g. pikmin2/clang-format.exe).
  • See this video for a walkthrough of the steps on Windows (thanks Altafen for making this!).

Decompilation workflow

  • The project is compatible with objdiff, which is highly recommended for local decompilation testing. Objdiff can be built from source, or the latest stable build obtained from GitHub actions (recommended).

  • To obtain the latest stable build:

    1. Navigate to the Actions tab of the objdiff repo.
    2. Select the latest main workflow.
    3. Scroll to the bottom of the page and download the stable release for your platform (Mac, Linux, Windows).
    4. Extract contents of .zip to obtain an executable version.
  • To set up objdiff for this project:

    1. Place objdiff.exe in the main directory of the pikmin2 repo, i.e. pikmin2/objdiff.exe.
    2. Set:
      • Build config: None.
      • Select project dir: /path/to/cloned/pikmin2
      • Select target build dir: /path/to/cloned/pikmin2/build/pikmin2.usa/asm
      • Select base build dir: /path/to/cloned/pikmin2/build/pikmin2.usa/src
        • NB: you may have to specify a custom make path if the desired make version is not the default. On Windows, this is likely: /path/to/devkitPro/msys2/usr/bin/make.exe
    3. Select desired object file to diff (likely from pikmin2/build/pikmin2.usa/asm/LIBRARY/OBJECTFILE.o).
    4. Decomp it!

Generating Context for decomp.me Scratches

(NB: The generator requires Python 3 to run)

  • decomp.me is an online decompilation sharing hub, allowing 'scratches' of functions to be generated and collaborated on.
  • Stand-alone decompilation packages and tools such as decomp.me require information on the functions and structures of the project in order to parse extracted blocks correctly. The easiest way to do this is to pass the tool just the necessary 'context' for the file, i.e. a set of all the headers used by the file that's being worked on.
  • A recursive context processing script is included in the repo (tools/decompctx.py), which generates a ctx.c file in the root directory.
    • The contents of this can then be copied and pasted into the 'Context' section of a decomp.me scratch or similar.
  • To use, call the generator via the terminal/command line from the root directory (replacing DIRECTORY and FILE as required): python3 tools/decompctx.py src/DIRECTORY/FILE.cpp
  • Credit to encounter and the Metroid Prime decomp project for the script!