Documented flag.c and fixed a typo in basic_space.c (#598)

* Added docs to flag.c

* Updated documentation

* Fixed typo
This commit is contained in:
Thomas Ryan 2025-06-01 22:37:05 -04:00 committed by GitHub
parent 9e230f7a3a
commit ab82b87684
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 1 deletions

View File

@ -198,7 +198,7 @@ void BoardLandRedExec(s32 player, s32 space) {
HuPrcVSleep();
}
// Set player's colour to blue and finish the sequence
// Set player's colour to red and finish the sequence
GWPlayer[player].color = 2;
BoardPlayerMotionEndWait(player);
BoardPlayerIdleSet(player);

View File

@ -1,8 +1,27 @@
#include "dolphin.h"
#include "game/gamework_data.h"
// Used to store system flags. There are 128 bits available for system flags.
// Though Mario Party 4 seems to only use the first bit to toggle read/write
// access to the memory card.
static u8 _Sys_Flag[16];
/**
* @brief Gets the pointer to the flag array.
*
* @details The available flag options are system flags (0x30000-0x3FFFF) and
* game flags (0x00000-0xFFFFF).
*
* Game flags are stored in the GWSystem.flag array.
* The GWSystem variable is a global variable that is defined in gamework.c.
* GWSystem flags are a 2D array of 3 groups of 16 flags each for a total of 48
* flags.
*
* TODOC: A comprehensive list of all the flags and their meanings
*
* @param flag Address of the flag to get.
* @return u8* Pointer to the flag array.
*/
static u8 *GetFlagPtr(u32 flag)
{
u8 *ret;
@ -15,6 +34,12 @@ static u8 *GetFlagPtr(u32 flag)
return ret;
}
/**
* @brief Checks the value of a flag.
*
* @param flag Address of the flag to check.
* @return s32 Value of the flag.
*/
s32 _CheckFlag(u32 flag)
{
u8 *flag_ptr = GetFlagPtr(flag);
@ -22,6 +47,11 @@ s32 _CheckFlag(u32 flag)
return flag_ptr[index/8] & (1 << (index % 8));
}
/**
* @brief Sets the value of a flag. Setting the bit to 1.
*
* @param flag Address of the flag to set.
*/
void _SetFlag(u32 flag)
{
u8 *flag_ptr = GetFlagPtr(flag);
@ -29,6 +59,11 @@ void _SetFlag(u32 flag)
flag_ptr[index/8] |= (1 << (index % 8));
}
/**
* @brief Clears the value of a flag. Setting the bit to 0.
*
* @param flag Address of the flag to clear.
*/
void _ClearFlag(u32 flag)
{
u8 *flag_ptr = GetFlagPtr(flag);
@ -36,6 +71,12 @@ void _ClearFlag(u32 flag)
flag_ptr[index/8] &= ~(1 << (index % 8));
}
/**
* @brief Initializes the system flag array.
*
* @details This flag array is used to store various system flags that are
* used when interacting with the console. Also known as temporary flags.
*/
void _InitFlag(void)
{
memset(_Sys_Flag, 0, sizeof(_Sys_Flag));