7.0 KiB
7.0 KiB
Thank you for your interest on helping out!
Unfortunately, we do not allow AI to be used for decompiling.
- AI often produces code in questionable quality and a human would unlikely write.
- They may use source code leaks as references as it could be in their training data.
Resources
- An introduction to decompilation, if this is your first time learning.
- A tool for decompiling. This include, but not limited to:
- Ghidra
- Requires Cuyler36's GameCube Loader.
- for Ghidra users, you can access the shared repository.
- Hex Rays (in IDA Pro)
- M2C
- decomp.me
- Ghidra
- Code IDE (recommended: Visual Studio Code)
- A diffing tool. (such as objdiff)
Ghidra
Accessing the repository
Note
At least version 12.0 is required!
- Head to ghidra.decomp.dev then create an account and/or login from there.
- On the "Repository Access" window, select:
- Repository:
Wii_IPL_Ghidra - Role: If you would like to make changes, select
Write. Otherwise selectRead.
- Repository:
- Click Request then wait for your request to be accepted.
Opening the repository
- Goto File > New Project
- Select "Shared Project"
- You would need to input the following:
- Server Name:
ghidra.decomp.dev - Port Number:
13100
- Server Name:
- The list of existing servers should show
Wii_IPL_Ghidra. Select that one. - Input where you want the shared project to be saved.
- You are now ready to open a program! (for now, its just
ipl_v4_3_usa.dol)- If you have write access and want to make changes to the program, right click on the program that you want to open, and click "Check out".
- Do not check the "Request exclusive checkout" option!
- Changes will be made to the repository, so make sure that you are checking out to the latest version!
- If you would want to upload of your changes, right click on the program that is currently opened, and click "Check In".
- If you have write access and want to make changes to the program, right click on the program that you want to open, and click "Check out".
Code Guidelines
Note: In some scenarios, some of these rules (mostly related to naming) can be ignored if they either affect matching or relate to original symbols or DWARF from ELF files.
General
- Style formatting is all done by
clang-format.- It should automatically apply when using Visual Studio Code on saving a source file.
- Hexadecimal values should be upper case. (
0xDEADBABEinstead of0xdeadbabe) - For checking on pointers, please use the
NULLmacro, unless if it affects code matching.
// Do this!
if (myPointer == NULL) {
// ...
}
// Don't do this!
if (myPointer == 0) {
// ...
}
- You should always include curly braces (
{,}) for statements and conditions, even if it's only one line. This is to help readability.
switch (myVariable) {
case 0: {
// ...
}
}
if (myVariable == 0) {
// ...
}
while (myVariable != 0) {
// ...
}
for (myVariable = 0; myVariable < 0; myVariable++) {
// ...
}
- Look out for bugs, typos and any other errors in the code, and try to add comments on them using the Doxygen command
@bug.
// @bug Should use the full path
nand::wrapper::Delete("cdb.vff");
File types
- For C code, use the
.cextension. - For C++ code, use the
.cppextension. - For C and C++ headers, use the
.hextension.
Header guards
Despite the compiler that this project uses (CodeWarrior) has support for #pragma once, please use the standard way for header guards. This is to help readability.
#ifndef {LIBRARY}_{NAME}_H
#define {LIBRARY}_{NAME}_H
// ...
#endif // {LIBRARY}_{NAME}_H
-
Guard names for libraries:
- System Menu -
IPL - RVL_SDK and RevoEX - in "revolution" directory,
REVOLUTION. And in "private" directory,PRIVATE - NW4R -
NW4R - RVLMiddleware/eZiText - in "zi8clib" directory,
ZI8_CLIB. Otherwise,EZI_TEXT - RVLMiddleware/ATOKDict -
ATOK - OperaWWW -
REVOLUTION_WWW - EGG -
EGG
- System Menu -
-
Examples:
src/system/iplChannelManager.cpp->IPL_SYSTEM_CHANNEL_MANAGER_Hsrc/scene/iplHealth.cpp->IPL_SCENE_HEALTH_Hlibs/RVL_SDK/src/os/OSAlarm.c->REVOLUTION_OS_ALARM_H
Make sure the guard names are uppercase SNAKE_CASE.
Header includes
- Try and not include any unnecesary includes.
- For headers in the
libsdirectory, please use<> - For headers in the
includedirectory, please use""- An exception is the directory
include/decomp, where you have to use<>
- An exception is the directory
// Do this!
#include <revolution/os/OSAlarm.h> // Header in the libs directory
#include "system/iplSystem.h" // Header in the include directory
#include <decomp.h> // Header in the include/decomp directory
// Don't do this!
#include "revolution/os/OSAlarm.h" // Header in the libs directory
#include <system/iplSystem.h> // Header in the include directory
#include "decomp.h" // Header in the include/decomp directory
Naming
- Names with known symbols should exactly match,
- Even if the symbol has typos or does not follow the guidelines!
- Function names with no known symbols should be written in camelCase.
- This mostly applies to static local and inline functions.
- Labels must be snake_case.
- Struct members must be camelCase (and should not include the
mprefix). - Class members must start with the
mprefix and be in PascalCase.- Some types have different prefixes:
- Static:
sm - Pointers (including typedef pointers):
mpOSMessageis an exception however. Although it is a typedefvoid*, it's not normally treated as a pointer, and is so it can be casted as anything.
- Booleans:
mb - Strings (including wide strings):
ms(pointer:msp)
- Static:
- Some types have different prefixes:
class MyClass {
int mMyValue1;
int* mpMyValue2;
char msString[4];
char* mspStringPtr;
static int smMyStaticValue = 1;
};
Classes and structures
- Offsets for fields and virtual functions must be commented.
- For unknown structure/class fields, they must be referred to by their offset (in uppercase hex), prefixed by
unk_.
int mKnownValue; // 0x00
int unk_0x04;
int mKnownValue1; // 0x08
virtual ~VirtualDtor(); // 0x08
virtual void VirtualFunc0(); // 0x0C
virtual void VirtualFunc1(); // 0x10
Literals
- For floating-point values, please be explicit with them. (they can also affect matching)
// Do this!
float value0 = 1.0f;
float value1 = 2f;
float value2 = 3.f;
// Don't do this! (they are implicitly double values!!)
float value0 = 1.0;
float value1 = 2;
float value2 = 3.;
Conclusion
If you have any questions or are interested in contributing to this project, you can join the Discord Server and ask in the #wii-menu channel.