Spring Cleaning

This commit is contained in:
intns 2024-01-24 16:38:25 +00:00
parent a24601e719
commit 0ae485ec13
12 changed files with 570 additions and 185 deletions

View File

@ -3,9 +3,24 @@
#include "JSystem/JKernel/JKRThread.h"
/**
* @brief Represents an application thread.
*
* This class is derived from JKRThread, with a specific use for application threads.
*/
struct AppThread : public JKRThread {
/**
* @brief Constructs an AppThread object.
*
* @param stackSize The size of the thread's stack.
* @param msgCount The number of messages the thread can hold.
* @param threadPriority The priority of the thread.
*/
AppThread(u32 stackSize, int msgCount, int threadPriority);
/**
* @brief Destructor for the AppThread object.
*/
virtual ~AppThread() { } // _08 (weak)
// _00 = VTBL

View File

@ -5,20 +5,68 @@
#include "id32.h"
#include "Parameters.h"
/**
* @brief The BaseParm struct represents a base parameter.
*
* This struct serves as the base class for all parameter types.
* It contains common members and virtual functions that can be overridden by derived classes.
*/
struct BaseParm {
BaseParm(Parameters*, u32, char*);
inline virtual int size() = 0;
inline virtual void write(Stream&) { }
inline virtual void read(Stream&) { }
/**
* @brief Constructs a BaseParm object.
*
* @param parameters Pointer to the Parameters object.
* @param id The ID of the parameter.
* @param name The name of the parameter.
*/
BaseParm(Parameters* parameters, u32 id, char* name);
/**
* @brief Gets the size of the parameter.
*
* @return The size of the parameter in bytes.
*/
virtual int size() = 0;
/**
* @brief Writes the parameter to a stream.
*
* @param stream The stream to write the parameter to.
*/
virtual void write(Stream& stream) { }
/**
* @brief Reads the parameter from a stream.
*
* @param stream The stream to read the parameter from.
*/
virtual void read(Stream& stream) { }
// _00 VTBL
ID32 mId; // _04
BaseParm* mNext; // _10
char* mName; // _14
};
/**
* @brief The Parm struct represents a parameter of a specific type.
*
* This struct is derived from the BaseParm struct and adds members specific to the parameter type.
* It also overrides the virtual functions of the base class.
*
* @tparam T The type of the parameter value.
*/
template <typename T>
struct Parm : public BaseParm {
/**
* @brief Constructs a Parm object.
*
* @param parameters Pointer to the Parameters object.
* @param id The ID of the parameter.
* @param comment A comment for the parameter.
* @param value The initial value of the parameter.
* @param min The minimum value of the parameter.
* @param max The maximum value of the parameter.
*/
inline Parm(Parameters* parameters, u32 id, char* comment, T value, T min, T max)
: BaseParm(parameters, id, comment)
, mValue(value)
@ -27,37 +75,138 @@ struct Parm : public BaseParm {
{
}
/**
* @brief Converts the Parm object to its underlying value type.
*
* @return The underlying value of the parameter.
*/
inline operator T() { return mValue; }
inline void operator=(const T& rhs) { mValue = rhs; }
inline T& operator()() { return mValue; }
/**
* @brief Assigns a new value to the Parm object.
*
* @param rhs The new value to assign.
*/
void operator=(const T& rhs) { mValue = rhs; }
/**
* @brief Returns a reference to the underlying value of the Parm object.
*
* @return A reference to the underlying value of the parameter.
*/
T& operator()() { return mValue; }
/**
* @brief Gets the size of the parameter.
*
* @return The size of the parameter in bytes.
*/
virtual int size() { return sizeof(T); }
virtual void write(Stream&);
virtual void read(Stream&);
/**
* @brief Writes the parameter to a stream.
*
* @param stream The stream to write the parameter to.
*/
virtual void write(Stream& stream);
/**
* @brief Reads the parameter from a stream.
*
* @param stream The stream to read the parameter from.
*/
virtual void read(Stream& stream);
T mValue; // _18
T _1C; // _1C
T _1C; // _1C, unused in the entire game!
T mMin; // _20
T mMax; // _24
};
/**
* @brief The ParmString struct represents a string parameter.
*
* This struct is derived from the BaseParm struct and adds members specific to string parameters.
* It also overrides the virtual functions of the base class.
*/
struct ParmString : public BaseParm {
ParmString(Parameters*, char*, int, u32, char*);
inline virtual int size() { return -1; }
virtual void write(Stream&);
virtual void read(Stream&);
/**
* @brief Constructs a ParmString object.
*
* @param parameters Pointer to the Parameters object.
* @param name The name of the parameter.
* @param length The length of the string.
* @param id The ID of the parameter.
* @param comment A comment for the parameter.
*/
ParmString(Parameters* parameters, char* name, int length, u32 id, char* comment);
/**
* @brief Gets the size of the parameter.
*
* @return -1, indicating that the size is variable.
*/
virtual int size() { return -1; }
/**
* @brief Writes the parameter to a stream.
*
* @param stream The stream to write the parameter to.
*/
virtual void write(Stream& stream);
/**
* @brief Reads the parameter from a stream.
*
* @param stream The stream to read the parameter from.
*/
virtual void read(Stream& stream);
char* mValue; // _18
int mLength; // _1C
};
/**
* @brief The ParmEnum struct represents an enumerated parameter.
*
* This struct is derived from the BaseParm struct and adds members specific to enumerated parameters.
* It also overrides the virtual functions of the base class.
*/
struct ParmEnum : public BaseParm {
ParmEnum(Parameters*, char**, u32, int, s32, char*);
inline virtual int size() { return 4; }
virtual void write(Stream&);
virtual void read(Stream&);
/**
* @brief Constructs a ParmEnum object.
*
* @param parameters Pointer to the Parameters object.
* @param enumValues An array of strings representing the enumeration values.
* @param id The ID of the parameter.
* @param enumElemSize The size of each enumeration element.
* @param value The initial value of the parameter.
* @param comment A comment for the parameter.
*/
ParmEnum(Parameters* parameters, char** enumValues, u32 id, int enumElemSize, s32 value, char* comment);
operator u32() { return mValue; }
/**
* @brief Gets the size of the parameter.
*
* @return 4, indicating that the size is fixed.
*/
virtual int size() { return 4; }
/**
* @brief Writes the parameter to a stream.
*
* @param stream The stream to write the parameter to.
*/
virtual void write(Stream& stream);
/**
* @brief Reads the parameter from a stream.
*
* @param stream The stream to read the parameter from.
*/
virtual void read(Stream& stream);
inline operator u32() { return mValue; }
u32 mValue; // _18
int mEnumElemSize; // _1C

View File

@ -4,8 +4,21 @@
#include "types.h"
#include "stream.h"
/**
* @brief A template struct representing a bit flag.
*
* This struct provides functionality for manipulating and working with bit flags.
* It allows setting, unsetting, clearing, reading, and writing bit flags.
*
* @tparam T The type of the bit flag.
*/
template <typename T>
struct BitFlag {
/**
* @brief Default constructor.
*
* Initializes the byte view of the bit flag to all zeros.
*/
BitFlag()
{
for (int i = 0; i < sizeof(T); i++) {
@ -13,6 +26,11 @@ struct BitFlag {
}
}
/**
* @brief Clears the bit flag.
*
* Sets all bytes of the byte view to zero.
*/
inline void clear()
{
for (int i = 0; i < sizeof(T); i++) {
@ -20,6 +38,13 @@ struct BitFlag {
}
}
/**
* @brief Reads the bit flag from a stream.
*
* Reads each byte of the byte view from the given stream.
*
* @param stream The stream to read from.
*/
inline void readBytes(Stream& stream)
{
for (int i = 0; i < sizeof(T); i++) {
@ -27,6 +52,13 @@ struct BitFlag {
}
}
/**
* @brief Writes the bit flag to a stream.
*
* Writes each byte of the byte view to the given stream.
*
* @param stream The stream to write to.
*/
inline void writeBytes(Stream& stream)
{
for (int i = 0; i < sizeof(T); i++) {
@ -34,24 +66,48 @@ struct BitFlag {
}
}
/** @fabricated */
/**
* @brief Checks if a specific bit is set in the bit flag.
*
* @param value The value of the bit to check.
* @return true if the bit is set, false otherwise.
*/
inline bool isSet(T value) { return (typeView & value) != 0; }
/** @fabricated */
// inline bool isUnset(T value) { return (typeView & value) == 0; }
/** @fabricated */
/**
* @brief Sets a specific bit in the bit flag.
*
* @param value The value of the bit to set.
*/
inline void set(T value) { typeView |= value; }
/** @fabricated */
/**
* @brief Unsets a specific bit in the bit flag.
*
* @param value The value of the bit to unset.
*/
inline void unset(T value) { typeView &= ~value; }
union {
u8 byteView[sizeof(T)];
T typeView;
u8 byteView[sizeof(T)]; /**< The byte view of the bit flag. */
T typeView; /**< The type view of the bit flag. */
};
};
/**
* @brief A template struct representing an array of bit flags.
*
* This struct provides a convenient way to manage an array of bit flags, where each flag is represented by a single bit.
* The template parameters are the type of the flag (T) and the number of flags in the array (I).
*
* The BitFlagArray struct provides functions to initialize the flags to zero and to clear all the flags.
*
* Example usage:
* ```
* BitFlagArray<int, 8> flags; // Create an array of 8 integer flags
* flags.clear(); // Clear all the flags
* ```
*/
template <typename T, int I>
struct BitFlagArray {
inline BitFlagArray()

View File

@ -4,32 +4,88 @@
#include "stream.h"
#include "types.h"
// TODO
/**
* @brief Represents a collection of bit flags.
*/
struct BitFlags {
u8* mFlagArr; // _00 flag array
u16 _04; // _04
u16 mFlagCnt; // _06 flag count
u8* mFlagList; // _00
u16 mTotalValueAmount; // _04
u16 mFlagListSize; // _06
/**
* @brief Default constructor for BitFlags.
*/
BitFlags();
void dump();
void read(Stream&);
void write(Stream&);
void create(u16, u8* flags);
/**
* @brief Dumps the bit flags to the console.
* @note Stripped in the main game.
*/
void dump();
/**
* @brief Reads the bit flags from a stream.
* @param stream The stream to read from.
*/
void read(Stream& stream);
/**
* @brief Writes the bit flags to a stream.
* @param stream The stream to write to.
*/
void write(Stream& stream);
/**
* @brief Creates the bit flags with the specified size and initial values.
* @param size The size of the bit flags.
* @param flags The initial values of the bit flags.
*/
void create(u16 totalSize, u8* flags);
/**
* @brief Resets all the bit flags to zero.
*/
void reset();
/**
* @brief Sets all the bit flags to zero.
*/
void all_zero();
/**
* @brief Sets all the bit flags to one.
*/
void all_one();
/**
* @brief Sets the specified bit flag.
* @param flag The index of the bit flag to set.
*/
void setFlag(u16 flag);
/**
* @brief Resets the specified bit flag.
* @param flag The index of the bit flag to reset.
*/
void resetFlag(u16 flag);
/**
* @brief Checks if the specified bit flag is set.
* @param flag The index of the bit flag to check.
* @return True if the bit flag is set, false otherwise.
*/
bool isFlag(u16 flag);
/**
* @brief Sets all the bit flags to the specified value.
* @param value The value to set all the bit flags to.
*/
inline void set_all(u8 value)
{
for (s32 i = 0; i < mFlagCnt; i++) {
mFlagArr[i] = value;
for (s32 i = 0; i < mFlagListSize; i++) {
mFlagList[i] = value;
}
}
void setFlag(u16);
void resetFlag(u16);
bool isFlag(u16);
};
#endif

View File

@ -10,8 +10,8 @@
#define NINTENDOLOGO_HEIGHT 104.0f
// Nintendo logo is blue in japanese, red elsewhere
#define NINTENDOLOGO_COLOR_JP 0, 70, 255, 255
#define NINTENDOLOGO_COLOR_US 220, 0, 0, 255
#define NINTENDOLOGO_COLOR_JP (0, 70, 255, 255)
#define NINTENDOLOGO_COLOR_US (220, 0, 0, 255)
#define DOLBYLOGO_XPOS 189.0f
#define DOLBYLOGO_YPOS 150.0f
@ -30,21 +30,34 @@ namespace ebi {
struct TScreenProgre;
}
/**
* @brief The BootSection is responsible for booting and initializing the game.
*
* It inherits from the BaseHIOSection class and provides functionality for loading resources, displaying logos,
* setting display modes, and handling user input during the boot process.
*/
struct BootSection : public Game::BaseHIOSection {
/**
* @brief Pointer to a member function of the BootSection class that returns a bool and takes no arguments.
* This type is used as a callback for running and waiting operations.
*/
typedef bool (BootSection::*RunWaitCallback)();
/**
* @brief Enumeration of state IDs for the boot section.
*/
enum StateID {
SID_LOAD_RESOURCE_FIRST = 0,
SID_LOAD_MEMORY_CARD,
SID_INIT_NINTENDO_LOGO,
SID_UNUSED_3,
SID_NINTENDO_LOGO,
SID_WAIT_PROGRESSIVE,
SID_SET_INTERLACE,
SID_SET_PROGRESSIVE,
SID_DOLBY_LOGO_1,
SID_DOLBY_LOGO_2,
SID_NULL = -1
SID_LOAD_RESOURCE_FIRST = 0, /**< Load resource first state ID */
SID_LOAD_MEMORY_CARD, /**< Load memory card state ID */
SID_INIT_NINTENDO_LOGO, /**< Initialize Nintendo logo state ID */
SID_UNUSED_3, /**< Unused state ID */
SID_NINTENDO_LOGO, /**< Nintendo logo state ID */
SID_WAIT_PROGRESSIVE, /**< Wait progressive state ID */
SID_SET_INTERLACE, /**< Set interlace state ID */
SID_SET_PROGRESSIVE, /**< Set progressive state ID */
SID_DOLBY_LOGO_1, /**< Dolby logo 1 state ID */
SID_DOLBY_LOGO_2, /**< Dolby logo 2 state ID */
SID_NULL = -1 /**< Null state ID */
};
BootSection(JKRHeap*);

View File

@ -19,58 +19,65 @@ struct SectionInfo {
};
struct GameFlow : public ISectionMgr {
/**
* @brief Enumeration of section names in the game flow.
*/
enum SectionNames {
RootMenu,
ObjectEditor,
SingleGame,
ChallengeGame,
TestChallenge,
TekiTest,
AnimEditor,
MapPartsEditor,
TexViewer,
Ogawa,
Hikino,
Yamashita,
Nishimura,
Nishimura2,
Morimura,
Ebisawa,
CaveEditor,
JStudioCameraEditor,
MovieTest,
JStudioKandoTest,
PelletTest,
Boot,
MainTitle,
Demo,
MessagePreviewer,
_2DDebug,
Fujino,
EbiMainTitle,
OgawaScreenTest,
E3ThanksSection,
VSGame,
EbimunEffect,
_2DDebug2,
EXP_C,
EXP_S,
SECTION_COUNT // 35
SN_RootMenu, /** Root menu section */
SN_ObjectEditor, /** Object editor section */
SN_SingleGame, /** Single game section */
SN_ChallengeGame, /** Challenge game section */
SN_TestChallenge, /** Test challenge section */
SN_TekiTest, /** Teki test section */
SN_AnimEditor, /** Animation editor section */
SN_MapPartsEditor, /** Map parts editor section */
SN_TexViewer, /** Texture viewer section */
SN_Ogawa, /** Ogawa's section */
SN_Hikino, /** Hikino's section */
SN_Yamashita, /** Yamashita's section */
SN_Nishimura, /** Nishimura's section */
SN_Nishimura2, /** Nishimura's other section */
SN_Morimura, /** Morimura's section */
SN_Ebisawa, /** Ebisawa's section */
SN_CaveEditor, /** Cave editor section */
SN_JStudioCameraEditor, /** JStudio camera editor section */
SN_MovieTest, /** Movie test section */
SN_JStudioKandoTest, /** Kando's JStudio test section */
SN_PelletTest, /** Pellet test section */
SN_Boot, /** Boot section */
SN_MainTitle, /** Main title section */
SN_Demo, /** Demo section */
SN_MessagePreviewer, /** Message previewer section */
SN_Debug2D, /** Debug 2D section */
SN_Fujino, /** Fujino's section */
SN_EbiMainTitle, /** Ebisawa's main title section */
SN_OgawaScreenTest, /** Ogawa's screen testing section */
SN_E3ThanksSection, /** E3 thanks section */
SN_VSGame, /** VS game section */
SN_EbimunEffect, /** Ebimun's effect testing section */
SN_Debug2D_2, /** The second 2D debugging section */
SN_ExpC, /** ExpC section */
SN_ExpS, /** ExpS section */
SN_SECTION_COUNT, /** Total size of the enum */
};
GameFlow();
~GameFlow(); // unused and not virtual
inline void runGame() // might be a (non-static) member function of GameFlow?
~GameFlow();
inline void runGame()
{
JKRExpHeap* expHeap;
JKRHeap* parentHeap;
JKRHeap::TState state(parentHeap = JKRHeap::sCurrentHeap);
parentHeap->state_register(&state, -1);
expHeap = makeExpHeap(parentHeap->getFreeSize(), parentHeap, true);
setSection();
mSection->init();
mSection->run();
mSection->exit();
expHeap->destroy();
parentHeap->becomeCurrentHeap();
}

View File

@ -5,14 +5,25 @@
#include "JSystem/JSupport/JSUList.h"
#include "IDelegate.h"
struct JUTGamePad;
struct JUTFont;
struct Menu {
/**
* @struct Menu::KeyEvent
* @brief Represents a key event in the menu.
*/
struct KeyEvent {
/**
* @enum cTypeFlag
* @brief Flags for the key event type.
*/
enum cTypeFlag { UNK0 = 16, UNK1 = 32 };
KeyEvent(cTypeFlag, u32, IDelegate1<Menu&>*);
/**
* @brief Constructs a KeyEvent object.
* @param type The type of the key event.
* @param param The parameter of the key event.
* @param action The action to be performed when the key event occurs.
*/
KeyEvent(cTypeFlag type, u32 param, IDelegate1<Menu&>* action);
int mType; // _00
int _04;
@ -20,29 +31,89 @@ struct Menu {
JSUPtrLink mLink;
};
/**
* @struct Menu::MenuItem
* @brief Represents a menu item.
*/
struct MenuItem {
/**
* @enum cTypeFlag
* @brief Flags for the menu item type.
*/
enum cTypeFlag { UNK0 = 0, UNK1 = 1 };
MenuItem(cTypeFlag, int, char*);
/**
* @brief Constructs a MenuItem object.
* @param type The type of the menu item.
* @param sectionFlags The section flags of the menu item.
* @param name The name of the menu item.
*/
MenuItem(cTypeFlag type, int sectionFlags, char* name);
/**
* @brief Gets the next menu item.
* @return A pointer to the next menu item.
*/
MenuItem* getNext();
/**
* @brief Gets the previous menu item.
* @return A pointer to the previous menu item.
*/
MenuItem* getPrev();
void checkEvents(Menu*, int);
/**
* @brief Checks the events of the menu item.
* @param menu A pointer to the Menu object.
* @param param The parameter of the menu item.
*/
void checkEvents(Menu* menu, int param);
int _00; // _00
bool _04; // _04
bool mIsActive; // _04
char* mName; // _08
int mSectionFlags; // _0C
int mType;
JSUPtrList mList; // _14
JSUPtrLink mLink; // _20
int mType; // _10
JSUPtrList mList; // _14
JSUPtrLink mLink; // _20
};
Menu(JUTGamePad*, JUTFont*, bool);
void addKeyEvent(KeyEvent::cTypeFlag, u32, IDelegate1<Menu&>*);
void addOption(int i, char* name, IDelegate1<Menu&>*, bool);
void doUpdate(bool);
/**
* @brief Constructs a Menu object.
* @param control A pointer to the JUTGamePad object.
* @param font A pointer to the JUTFont object.
* @param flag A boolean indicating the flag of the menu.
*/
Menu(JUTGamePad* control, JUTFont* font, bool flag);
/**
* @brief Adds a key event to the menu.
* @param type The type of the key event.
* @param param The parameter of the key event.
* @param action The action to be performed when the key event occurs.
*/
void addKeyEvent(KeyEvent::cTypeFlag type, u32 param, IDelegate1<Menu&>* action);
/**
* @brief Adds an option to the menu.
* @param i The index of the option.
* @param name The name of the option.
* @param action The action to be performed when the option is selected.
* @param isActive A boolean indicating whether the option is active or not.
*/
void addOption(int i, char* name, IDelegate1<Menu&>* action, bool isActive);
/**
* @brief Updates the menu.
* @param flag A boolean indicating whether the menu should be updated or not.
*/
void doUpdate(bool flag);
/**
* @brief Sets the position of the menu.
* @param x The x-coordinate of the menu position.
* @param y The y-coordinate of the menu position.
*/
inline void setPosition(int x, int y)
{
mPositionX = x;
@ -69,8 +140,8 @@ struct Menu {
int _4C; // _4C
int _50; // _50
int _54; // _54
bool _58; // _58
bool _59; // _59
bool mIsInitialised; // _58
bool mIsUpdated; // _59
int _5C;
};

View File

@ -7,8 +7,8 @@
* @note Size: 0x10
*/
BitFlags::BitFlags()
: mFlagArr(0)
, mFlagCnt(0)
: mFlagList(0)
, mFlagListSize(0)
{
}
@ -18,7 +18,7 @@ BitFlags::BitFlags()
*/
void BitFlags::dump()
{
for (s32 i = 0; i < mFlagCnt; i++) { }
for (s32 i = 0; i < mFlagListSize; i++) { }
}
/**
@ -27,8 +27,8 @@ void BitFlags::dump()
*/
void BitFlags::read(Stream& stream)
{
for (s32 i = 0; i < mFlagCnt; i++) {
mFlagArr[i] = stream.readByte();
for (s32 i = 0; i < mFlagListSize; i++) {
mFlagList[i] = stream.readByte();
}
}
@ -38,8 +38,8 @@ void BitFlags::read(Stream& stream)
*/
void BitFlags::write(Stream& stream)
{
for (s32 i = 0; i < mFlagCnt; i++) {
stream.writeByte(mFlagArr[i]);
for (s32 i = 0; i < mFlagListSize; i++) {
stream.writeByte(mFlagList[i]);
}
}
@ -47,15 +47,17 @@ void BitFlags::write(Stream& stream)
* @note Address: 0x8041C2D0
* @note Size: 0x54
*/
void BitFlags::create(u16 arg1, u8* flags)
void BitFlags::create(u16 totalSize, u8* flags)
{
_04 = arg1;
mFlagCnt = (arg1 >> 3) + 1;
mTotalValueAmount = totalSize;
// Divides by 8 and rounds up (to accomodate anything non-divisible by 8), as each u8 contains 8 bits
mFlagListSize = (totalSize >> 3) + 1;
if (flags) {
mFlagArr = flags;
mFlagList = flags;
} else {
mFlagArr = new u8[mFlagCnt];
mFlagList = new u8[mFlagListSize];
}
}
@ -65,8 +67,8 @@ void BitFlags::create(u16 arg1, u8* flags)
*/
void BitFlags::reset()
{
for (s32 i = 0; i < mFlagCnt; i++) {
mFlagArr[i] = 0;
for (s32 i = 0; i < mFlagListSize; i++) {
mFlagList[i] = 0;
}
}
@ -90,7 +92,7 @@ void BitFlags::setFlag(u16 input)
{
u16 index = input >> 3;
input = (input - (input & ~7));
mFlagArr[index] |= 1 << input;
mFlagList[index] |= 1 << input;
}
/**
@ -101,7 +103,7 @@ void BitFlags::resetFlag(u16 input)
{
u16 index = input >> 3;
input = (input - (input & ~7));
mFlagArr[index] &= ~(1 << input);
mFlagList[index] &= ~(1 << input);
}
/**
@ -112,5 +114,5 @@ bool BitFlags::isFlag(u16 input)
{
u16 index = input >> 3;
input = (input - (input & ~7));
return (mFlagArr[index] & (1 << input)) != 0;
return (mFlagList[index] & (1 << input)) != 0;
}

View File

@ -268,12 +268,14 @@ TinyPikminMgr::TinyPikminMgr()
{
P2ASSERTLINE(731, !sTinyPikminMgr);
sTinyPikminMgr = this;
int pikis;
if (randFloat() < TINYPIKMINMGR_HIGHCOUNT_CHANCE) {
pikis = TINYPIKMINMGR_LOWERCOUNT;
} else {
pikis = TINYPIKMINMGR_HIGHERCOUNT;
}
sTinyPikminNum = pikis;
mPikis = new TinyPikmin[sTinyPikminNum];
if (randFloat() > 0.5f) {
@ -421,24 +423,30 @@ BootSection::BootSection(JKRHeap* heap)
, mDoOpenProgressive(false)
, mLogoShakeStrength(0.0f)
{
sBootSection = this;
sBootSection = this;
Game::HIORootNode* node = new Game::HIORootNode(this);
node->mName = "ブートセクション";
node->setName("ブートセクション");
initHIO(node);
setDisplay(JFWDisplay::createManager(nullptr, mDisplayHeap, JUTXfb::DoubleBuffer, false), 1);
sys->setFrameRate(1);
mButtonCallback = new Delegate<BootSection>(this, &BootSection::loadResident);
JUTProcBar::sManager->setVisible(false);
JUTProcBar::sManager->setVisibleHeapBar(false);
mController = new Controller(JUTGamePad::PORT_0);
new Controller(JUTGamePad::PORT_1);
/*mController2 =*/new Controller(JUTGamePad::PORT_1);
sys->createRomFont(JKRGetCurrentHeap());
gPikmin2AramMgr->setLoadPermission(true);
particle2dMgr = nullptr;
mPikiMgr = new TinyPikminMgr;
mPikiMgr->init();
mTimeStep = 0.5f;
}

View File

@ -50,7 +50,7 @@ static SectionInfo sSectionInfo[] = {
{ "EXP_S", 0x22000000 },
};
} // namespace
u32 GameFlow::mActiveSectionFlag = Boot;
u32 GameFlow::mActiveSectionFlag = SN_Boot;
/**
* @note Address: 0x804241A4
@ -58,7 +58,7 @@ u32 GameFlow::mActiveSectionFlag = Boot;
*/
GameFlow::GameFlow()
{
mActiveSectionFlag = Boot;
mActiveSectionFlag = SN_Boot;
mSection = nullptr;
}
@ -89,13 +89,13 @@ void GameFlow::setSection()
JKRHeap::sCurrentHeap->getFreeSize();
switch (mActiveSectionFlag) {
case Boot:
case SN_Boot:
mSection = new BootSection(JKRHeap::sCurrentHeap);
mActiveSectionFlag = RootMenu;
mActiveSectionFlag = SN_RootMenu;
break;
case RootMenu:
case SN_RootMenu:
mSection = new RootMenuSection(JKRHeap::sCurrentHeap);
mActiveSectionFlag = MainTitle;
mActiveSectionFlag = SN_MainTitle;
break;
default:
JUT_PANICLINE(188, "Unknown SectionFlag. %d \n", mActiveSectionFlag);
@ -111,9 +111,9 @@ SectionInfo* GameFlow::getSectionInfo(int id)
{
SectionInfo* sectionInfo = nullptr;
P2ASSERTBOUNDSLINE(201, 0, id, SECTION_COUNT);
P2ASSERTBOUNDSLINE(201, 0, id, SN_SECTION_COUNT);
for (u32 i = 0; i < SECTION_COUNT; i++) {
for (u32 i = 0; i < SN_SECTION_COUNT; i++) {
if (id == sSectionInfo[i].mId.mSectionId) {
sectionInfo = &sSectionInfo[i];
break;
@ -131,19 +131,19 @@ ISection* GameFlow::createSection(JKRHeap* heap)
{
ISection* section;
switch (mActiveSectionFlag) {
case Demo:
case SN_Demo:
section = new Demo::Section(heap);
break;
case MainTitle:
case SN_MainTitle:
section = new Title::Section(heap);
break;
case SingleGame:
case SN_SingleGame:
section = new Game::SingleGameSection(heap);
break;
case ChallengeGame:
case SN_ChallengeGame:
section = new Game::VsGameSection(heap, false);
break;
case VSGame:
case SN_VSGame:
section = new Game::VsGameSection(heap, true);
break;
default:
@ -151,6 +151,6 @@ ISection* GameFlow::createSection(JKRHeap* heap)
break;
}
mActiveSectionFlag = MainTitle;
mActiveSectionFlag = SN_MainTitle;
return section;
}

View File

@ -127,16 +127,17 @@ void Section::init()
mMenu->addKeyEvent(Menu::KeyEvent::UNK1, 512, new Delegate1<Section, Menu&>(this, &menuCancel));
mMenu->addKeyEvent(Menu::KeyEvent::UNK0, 256, new Delegate1<Section, Menu&>(this, &menuSelect));
int sects = 0;
for (int i = 0; i < GameFlow::SECTION_COUNT; i++) {
for (int i = 0; i < GameFlow::SN_SECTION_COUNT; i++) {
SectionInfo* data = GameFlow::getSectionInfo(i);
if (data) {
if ((!Game::gGameConfig.mParms.mMarioClubDevelop.mData || data->mId.c) && data->mId.b) {
if ((!Game::gGameConfig.mParms.mMarioClubDevelop() || data->mId.c) && data->mId.b) {
mMenu->addOption(i, data->mName, nullptr, true);
sects++;
}
} else {
char* test = "NO NAME"; // another 4 bytes of 0 is supposed to generate with this, but with it still being in sdata2?
mMenu->addOption(i, test, nullptr, true);
char* name = "NO NAME";
mMenu->addOption(i, name, nullptr, true);
sects++;
}
}
@ -304,13 +305,13 @@ void Section::doUpdateMainTitle()
mIsMainActive = false;
switch (id) {
case ebi::TMainTitleMgr::Select_Story:
GameFlow::mActiveSectionFlag = GameFlow::SingleGame;
GameFlow::mActiveSectionFlag = GameFlow::SN_SingleGame;
break;
case ebi::TMainTitleMgr::Select_Challenge:
GameFlow::mActiveSectionFlag = GameFlow::ChallengeGame;
GameFlow::mActiveSectionFlag = GameFlow::SN_ChallengeGame;
break;
case ebi::TMainTitleMgr::Select_Vs:
GameFlow::mActiveSectionFlag = GameFlow::VSGame;
GameFlow::mActiveSectionFlag = GameFlow::SN_VSGame;
break;
case ebi::TMainTitleMgr::Select_Options:
mState = State_Options;
@ -351,7 +352,7 @@ void Section::doUpdateMainTitle()
mIsMainActive = true;
break;
default:
GameFlow::mActiveSectionFlag = GameFlow::MainTitle;
GameFlow::mActiveSectionFlag = GameFlow::SN_MainTitle;
break;
}
} else {
@ -359,7 +360,7 @@ void Section::doUpdateMainTitle()
if (!Game::gGameConfig.mParms.mKFesVersion.mData && !Game::gGameConfig.mParms.mNintendoVersion.mData) {
mMainTitleMgr.forceQuit();
mIsMainActive = false;
GameFlow::mActiveSectionFlag = GameFlow::Demo;
GameFlow::mActiveSectionFlag = GameFlow::SN_Demo;
} else {
mGoToDemoTimer = 0.0f;
}

View File

@ -16,27 +16,27 @@ Menu::Menu(JUTGamePad* control, JUTFont* font, bool flag)
mFlag = flag;
_0C = 0;
MenuItem* rootItem = new MenuItem(MenuItem::UNK0, 0, "root");
rootItem->_04 = false;
MenuItem* rootItem = new MenuItem(MenuItem::UNK0, 0, "root");
rootItem->mIsActive = false;
mItemList.append(&rootItem->mLink);
_2C = 0;
mItemCount = 0;
mLastItem = nullptr;
mCurrentItem = nullptr;
mSelf2 = nullptr;
mSelf = nullptr;
_4C = 0;
_50 = 0;
_54 = 0;
mPositionX = 190;
mPositionY = 220;
_48 = 260;
_58 = true;
_59 = true;
mState = 0;
mTimer = 0.0f;
mTimer2 = 0.0f;
_2C = 0;
mItemCount = 0;
mLastItem = nullptr;
mCurrentItem = nullptr;
mSelf2 = nullptr;
mSelf = nullptr;
_4C = 0;
_50 = 0;
_54 = 0;
mPositionX = 190;
mPositionY = 220;
_48 = 260;
mIsInitialised = true;
mIsUpdated = true;
mState = 0;
mTimer = 0.0f;
mTimer2 = 0.0f;
volatile int idk1, idk2, idk3, idk4;
idk4 = 190;
@ -51,16 +51,16 @@ Menu::Menu(JUTGamePad* control, JUTFont* font, bool flag)
* @note Address: 0x804562B0
* @note Size: 0xC0
*/
void Menu::addOption(int index, char* name, IDelegate1<Menu&>* delegate, bool flag)
void Menu::addOption(int optionIdx, char* optionName, IDelegate1<Menu&>* pressAction, bool isActive)
{
mLastItem = new MenuItem(MenuItem::UNK1, index, name);
mLastItem->_04 = flag;
mLastItem = new MenuItem(MenuItem::UNK1, optionIdx, optionName);
mLastItem->mIsActive = isActive;
mItemList.append(&mLastItem->mLink);
if (delegate) {
addKeyEvent(KeyEvent::UNK0, _5C, delegate);
if (pressAction) {
addKeyEvent(KeyEvent::UNK0, _5C, pressAction);
}
if (!mCurrentItem && mLastItem->_04) {
if (!mCurrentItem && mLastItem->mIsActive) {
mCurrentItem = mLastItem;
}
@ -112,45 +112,52 @@ void Menu::doUpdate(bool flag)
break;
case 2:
if (flag) {
_59 = true;
mIsUpdated = true;
}
u32 input = mControl->getButtonDown();
if (input & Controller::PRESS_DOWN) {
mCurrentItem->checkEvents(this, 2);
mCurrentItem = mCurrentItem->getNext();
if (!mCurrentItem) {
mCurrentItem = (MenuItem*)mItemList.mHead->mValue;
}
MenuItem* item;
while (item = mCurrentItem, !item->mName || !item->_04) {
while (item = mCurrentItem, !item->mName || !item->mIsActive) {
item = mCurrentItem->getNext();
mCurrentItem = item;
if (!mCurrentItem) {
mCurrentItem = (MenuItem*)mItemList.mHead->mValue;
}
}
_59 = true;
mIsUpdated = true;
PSSystem::spSysIF->playSystemSe(PSSE_SY_MENU_CURSOR, 0);
} else if (input & Controller::PRESS_UP) {
mCurrentItem->checkEvents(this, 2);
mCurrentItem = mCurrentItem->getPrev();
if (!mCurrentItem) {
mCurrentItem = (MenuItem*)mItemList.mHead->mValue;
}
MenuItem* item;
while (item = mCurrentItem, !item->mName || !item->_04) {
while (item = mCurrentItem, !item->mName || !item->mIsActive) {
item = mCurrentItem->getPrev();
mCurrentItem = item;
if (!mCurrentItem) {
mCurrentItem = (MenuItem*)mItemList.mHead->mValue;
}
}
_59 = true;
mIsUpdated = true;
PSSystem::spSysIF->playSystemSe(PSSE_SY_MENU_CURSOR, 0);
}
if (_58) {
_58 = false;
_59 = true;
if (mIsInitialised) {
mIsInitialised = false;
mIsUpdated = true;
}
break;
}
@ -454,7 +461,7 @@ Menu::KeyEvent::KeyEvent(cTypeFlag type, u32 a1, IDelegate1<Menu&>* delegate)
Menu::MenuItem::MenuItem(cTypeFlag type, int a1, char* name)
: mLink(this)
{
_04 = 1;
mIsActive = 1;
mName = name;
mSectionFlags = a1;
mType = type;