-
Notifications
You must be signed in to change notification settings - Fork 23
Getting To Know The Codebase
The main function is in "src/sysBootup.cpp".
A lot of classes in Pikmin 1 inherit from a family of intrusive linked list classes called "Nodes". There is ANode (lowest base class, short for "Age Node"), CoreNode (most common, extends ANode), Node (second most common, extents CoreNode), and a few other ones that only really serve one purpose.
Modding Pikmin 1 with the Decomp Toolkit (DTK) build system is incredibly easy. In the root of the repository, run the command python configure.py --non-matching to enable modding. Some development features only present in the Win32 build of Pikmin 1 have been decompiled and can be enabled by alternatively running the command python configure.py --develop (the --develop option implies --non-matching). The code can then be compiled by running the command ninja in the root of the repository. Bugfixes for known issues in the original codebase are automatically enabled for non-matching builds. The mechanisms for these features can be seen in the "types.h" header, see: the BUGFIX, TERNARY_BUGFIX, DEVELOP, and TERNARY_DEVELOP macros.
The code for Pikmin 1 was written in a time where standards-compliance was not well guaranteed by the MetroWerks 1.2.5 compiler. Because of this, the codebase was written in a cripplingly const-incorrect way that is non-portable to even MetroWerks 1.3 (and beyond). This has been addressed by the quasi-cv-qualifier macro immut seen in the "types.h" header. In all places that require const-correctness to be legal C++ (at least, as far as we are aware), immut has been inserted (expands to const for non-matching builds). A similar, though less common, issue exists in some code written by Nakata. He had a habit of binding temporary rvalues to non-const lvalue references. This is also fixed by a macro called NRef (expands to & for matching builds). With these two fixes, the Pikmin 1 codebase has been confirmed to work fine up to MetroWerks 2.6 (although currently the machine-generated linker script must manually be edited to add an .sbss2 section group). MetroWerks 2.7 has matrix math(?) issues we haven't diagnosed yet, and MetroWerks 3.0a3 and beyond unfortunately forbid multi-character character literals (these are commonly used in Pikmin 1) despite them being legal (but underspecified) in C++.
Contains a lot of central system programming, particularly game "sections". Game sections are the broad-stroke flow of how the game moves from one type of thing to another, such as from title screen to file select, file select to the map, map to gameplay, etc, and the logic of how it transitions and queues things up. These include:
-
game.cpp - Central control of single-player game flow (broad-stroke stuff, not the file details), such as:
- gameSetup.cpp - Section for loading in from the title screen
- cardSelect.cpp - Section for file select
- mapSelect.cpp - Section for world map and challenge mode map select
- newPikiGame.cpp - Section for day-to-day gameplay for both story and challenge modes
- introGame.cpp - Section for the asteroid/crash landing cutscene
- gameExit.cpp - Section for exiting back to title or file select
- titles.cpp - Section for broad title screen logic.
- ninLogo.cpp - Section for the Nintendo logo on boot-up
- movSample.cpp - Section for any pre-rendered movies, such as the tutorial movies and credits
- gameflow.cpp - Controlling structure for all the sections, along with a bunch of other things related to, well, game flow
This library also contains the code for other central operation features, such as:
- moviePlayer.cpp and cinePlayer.cpp - everything for handling cutscenes
- cardutil.cpp and memoryCard.cpp - Pikmin-specific handling of the GameCube's memory card access and writing system
- gamePrefs.cpp - handling options that are saved between play sessions, such as volume levels and language
- mapMgr.cpp and dayMgr.cpp - controls for handling the course/map while gameplay is happening, and coordinating time of day, lighting, enemy spawns, etc.
- animMgr.cpp - animation controls
Contains the code for Navi and Piki, including how they work, how they make decisions, and how they interact with other things. Handling of carry-able items are also included in here (Pellets, including corpses and ship parts). Several Items also live in this directory, including:
- bombItem.cpp - Bomb Rocks
- fishItem.cpp - Unused
- goalItem.cpp - Onion
- keyItem.cpp - Key (Unused), Door (Unused), Big Door (Unused)
- kusaItem.cpp - Climbing Stick
- mizuItem.cpp - Nectar Drop
- ropeItem.cpp - TODO
- seedItem.cpp - Pikmin Sprout
- ufoItem.cpp - S.S. Dolphin
- weedsItem.cpp - Nectar Grass, Nectar Rocks, Weeds (Unused)
Contains several home-spun libraries named for Nakata (nlib), as well as the Teki AI code for:
- taichappy.cpp - Dwarf Bulborb, Dwarf Bulbear, Water Dumple
- taicollec.cpp - Breadbug
- taiiwagen.cpp - Rock Shooter (Unused), Rolling Rock
- taikinoko.cpp - Puffstool
- taimizinko.cpp - Honeywisp, Honeywisp Generator
- tainapkid.cpp - Swooping Snitchbug
- taiotimoti.cpp - Yellow Wollywog, Wollywog
- taipalm.cpp - Pellet Posy
- taishell.cpp - Pearly Clamclamp, Pearl, Rocket Pearl
- taiswallow.cpp - Spotty Bulborb, Spotty Bulbear
Contains all of the code for Bosses, including:
- CoreNucleus.cpp, CoreNucleusAi.cpp, Nucleus.cpp, NucleusAi.cpp, Slime.cpp, SlimeAi.cpp, SlimeBody.cpp, SlimeCreature.cpp - Goolix (I'm being deadass)
- King.cpp, KingAi.cpp, KingBody.cpp - Emperor Bulblax
- KingBack.cpp, KingBackAi.cpp - Fake Emperor Bulblax (Unused)
- Kogane.cpp, KoganeAi.cpp - Iridescent Flint Beetle
- Mizu.cpp, MizuAi.cpp - Water Geyser
- Pom.cpp, PomAi.cpp - Candypop Bud
- Snake.cpp, SnakeAi.cpp, SnakeBody.cpp - Burrowing Snagret
- Spider.cpp, SpiderAi.cpp, SpiderLeg.cpp - Beady Long Legs
Contains code for a lot of the 2D menus seen in-game, and related code - these are split between this and Yamashita's library. Ogawa uses Yamashita's zen namespace for his code, which makes sense considering the overlap. These include:
- ogMessage.cpp - handles the actual managing and printing of a variety of text screens
- ogTutorial.cpp - specifically manages pop-up text screens during gameplay and cutscenes - the files they draw from are laid out in ogTutorialData.cpp
- ogDiary.cpp - end-of-day diary entry text screen containing Olimar's musings
- ogTitle.cpp - the main title screen menu and its immediate options sub-menu.
- file select-related screens, such as ogFileSelect.cpp, ogFileChkSel.cpp, ogFileCopy.cpp, ogFileDelete.cpp and ogMemChk.cpp
- ogPause.cpp - the pause menu, accessed with START
- ogMenu.cpp - the map/controls menu, accessed with Y, alongside ogRader.cpp for the radar map-specific code
- ogResult.cpp - overall manager for end-of-day results screen, including Pikmin totals
- ogSave.cpp - save game text boxes
[TODO: ogTest, ogSub, ogMap, ogMakeDefault, ogTotalScore, ogNikatu, ogGraph, ogStart, ogCallBack]
Contains home-spun library code in the zen namespace, the P2D library which can be seen as a predecessor to the J2D library, particle effect code, and the Teki AI code for:
- TAIbeatle.cpp - Armored Cannon Beetle
- TAIdororo.cpp - Smoky Progg
- TAIhibaA.cpp - Fire Geyser
- TAIkabekuiA.cpp - Female Sheargrub
- TAIkabekuiB.cpp - Male Sheargrub
- TAIkabekuiC.cpp - Shearwig
- TAImar.cpp - Puffy Blowhog
- TAImiurin.cpp - Mamuta
- TAIotama.cpp - Wogpole
- TAItamago.cpp - Giant Egg
- TAItank.cpp - Fiery Blowhog
- TAIusuba.cpp - Antlion (Unused)
TODO: Explain gsys, playerState, seSystem, gameflow, etc.