Skip to content

Commit

Permalink
Merge branch 'master' into misc-tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards authored Oct 7, 2023
2 parents 56ff4ce + 0e84c7d commit f01a6af
Show file tree
Hide file tree
Showing 167 changed files with 1,347 additions and 1,312 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ Other disassembly and/or decompilation projects:
* [**Pokémon Pinball: Ruby & Sapphire**](https://github.com/pret/pokepinballrs)
* [**Pokémon FireRed and LeafGreen**](https://github.com/pret/pokefirered)
* [**Pokémon Mystery Dungeon: Red Rescue Team**](https://github.com/pret/pmd-red)

* [**Pokémon Diamond and Pearl**](https://github.com/pret/pokediamond)
* [**Pokémon Platinum**](https://github.com/pret/pokeplatinum)
* [**Pokémon HeartGold and SoulSilver**](https://github.com/pret/pokeheartgold)
* [**Pokémon Mystery Dungeon: Explorers of Sky**](https://github.com/pret/pmd-sky)

## Contacts

You can find us on [Discord](https://discord.gg/d5dubZ3) and [IRC](https://web.libera.chat/?#pret).
You can find us on:

* [Discord (PRET, #pokeemerald)](https://discord.gg/d5dubZ3)
* [IRC](https://web.libera.chat/?#pret)
5 changes: 5 additions & 0 deletions constants/gba_constants.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef GUARD_CONSTANTS_GBA_CONSTANTS_INC
#define GUARD_CONSTANTS_GBA_CONSTANTS_INC

.set PSR_USR_MODE, 0x00000010
.set PSR_FIQ_MODE, 0x00000011
.set PSR_IRQ_MODE, 0x00000012
Expand Down Expand Up @@ -511,3 +514,5 @@
.set BLDCNT_TGT2_OBJ, 1 << 12
.set BLDCNT_TGT2_BD, 1 << 13
.set BLDCNT_TGT2_ALL, BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD

#endif @ GUARD_CONSTANTS_GBA_CONSTANTS_INC
5 changes: 5 additions & 0 deletions constants/global.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef GUARD_CONSTANTS_GLOBAL_INC
#define GUARD_CONSTANTS_GLOBAL_INC

.set TRUE, 1
.set FALSE, 0

Expand All @@ -20,3 +23,5 @@

.set OBJ_IMAGE_ANIM_H_FLIP, 1 << 6
.set OBJ_IMAGE_ANIM_V_FLIP, 1 << 7

#endif @ GUARD_CONSTANTS_GLOBAL_INC
5 changes: 5 additions & 0 deletions constants/m4a_constants.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef GUARD_CONSTANTS_M4A_CONSTANTS_INC
#define GUARD_CONSTANTS_M4A_CONSTANTS_INC

.equiv ID_NUMBER, 0x68736d53

.equiv PCM_DMA_BUF_SIZE, 1584
Expand Down Expand Up @@ -250,3 +253,5 @@
struct_field o_CgbChannel_nextChannelPointer, 4
struct_field o_CgbChannel_dummy4, 8
struct_field CgbChannel_size, 0

#endif @ GUARD_CONSTANTS_M4A_CONSTANTS_INC
5 changes: 5 additions & 0 deletions constants/tms_hms.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef GUARD_CONSTANTS_TMS_HMS_INC
#define GUARD_CONSTANTS_TMS_HMS_INC

#include "constants/tms_hms.h"

/* Expands to:
Expand All @@ -15,3 +18,5 @@ FOREACH_TM(EQUIV_TM)
FOREACH_HM(EQUIV_HM)
#undef EQUIV_TM
#undef EQUIV_HM

#endif @ GUARD_CONSTANTS_TMS_HMS_INC
4 changes: 2 additions & 2 deletions gflib/string_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8

if (state == WRITING_DIGITS)
{
char *out = dest++;
u8 *out = dest++;

if (digit <= 0xF)
c = sDigits[digit];
Expand All @@ -309,7 +309,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8
}
else if (digit != 0 || powerOfSixteen == 1)
{
char *out;
u8 *out;
state = WRITING_DIGITS;
out = dest++;

Expand Down
6 changes: 2 additions & 4 deletions gflib/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,7 @@ void DecompressGlyphTile(const void *src_, void *dest_)
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
}

// Unused
static u8 GetLastTextColor(u8 colorType)
static u8 UNUSED GetLastTextColor(u8 colorType)
{
switch (colorType)
{
Expand Down Expand Up @@ -1224,8 +1223,7 @@ static u16 RenderText(struct TextPrinter *textPrinter)
return RENDER_FINISH;
}

// Unused
static u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing)
static u32 UNUSED GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing)
{
int i;
u8 width;
Expand Down
2 changes: 1 addition & 1 deletion gflib/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u
BlitBitmapRect4Bit(&sourceRect, &destRect, srcX, srcY, destX, destY, rectWidth, rectHeight, 0);
}

static void BlitBitmapRectToWindowWithColorKey(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 colorKey)
static void UNUSED BlitBitmapRectToWindowWithColorKey(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 colorKey)
{
struct Bitmap sourceRect;
struct Bitmap destRect;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
7 changes: 6 additions & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ struct BattleStruct
u8 expGetterBattlerId;
u8 unused_5;
u8 absentBattlerFlags;
u8 palaceFlags; // First 4 bits are "is < 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI
u8 palaceFlags; // First 4 bits are "is <= 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI
u8 field_93; // related to choosing pokemon?
u8 wallyBattleState;
u8 wallyMovesState;
Expand Down Expand Up @@ -440,6 +440,11 @@ struct BattleStruct
u8 alreadyStatusedMoveAttempt; // As bits for battlers; For example when using Thunder Wave on an already paralyzed pokemon.
};

// The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider,
// and 1 flag per battler to indicate whether the battler is awake and at <= 50% HP (which affects move choice).
// The assert below is to ensure palaceFlags is large enough to store these flags without overlap.
STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLERS_COUNT + MAX_MON_MOVES, PalaceFlagsTooSmall)

#define F_DYNAMIC_TYPE_1 (1 << 6)
#define F_DYNAMIC_TYPE_2 (1 << 7)
#define DYNAMIC_TYPE_MASK (F_DYNAMIC_TYPE_1 - 1)
Expand Down
20 changes: 16 additions & 4 deletions include/battle_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,26 @@ u8 GetBattlerSpriteDefault_Y(u8 battlerId);
u8 GetSubstituteSpriteDefault_Y(u8 battlerId);

// battle_anim_status_effects.c
#define STAT_ANIM_PLUS1 15
#define STAT_ANIM_PLUS2 39
#define STAT_ANIM_MINUS1 22
#define STAT_ANIM_MINUS2 46
#define STAT_ANIM_PLUS1 14
#define STAT_ANIM_PLUS2 38
#define STAT_ANIM_MINUS1 21
#define STAT_ANIM_MINUS2 45
#define STAT_ANIM_MULTIPLE_PLUS1 55
#define STAT_ANIM_MULTIPLE_PLUS2 56
#define STAT_ANIM_MULTIPLE_MINUS1 57
#define STAT_ANIM_MULTIPLE_MINUS2 58

enum {
STAT_ANIM_PAL_ATK,
STAT_ANIM_PAL_DEF,
STAT_ANIM_PAL_ACC,
STAT_ANIM_PAL_SPEED,
STAT_ANIM_PAL_EVASION,
STAT_ANIM_PAL_SPATK,
STAT_ANIM_PAL_SPDEF,
STAT_ANIM_PAL_MULTIPLE = 0xFF
};

void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId);

// battle_anim_ground.c
Expand Down
1 change: 1 addition & 0 deletions include/constants/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

#define TRAINER_ID_LENGTH 4
#define MAX_MON_MOVES 4
#define ALL_MOVES_MASK ((1 << MAX_MON_MOVES) - 1)

#define CONTESTANT_COUNT 4
#define CONTEST_CATEGORY_COOL 0
Expand Down
2 changes: 1 addition & 1 deletion include/gba/io_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@
#define R_BUTTON 0x0100
#define L_BUTTON 0x0200
#define KEYS_MASK 0x03FF
#define KEY_INTR_ENABLE 0x0400
#define KEY_INTR_ENABLE 0x4000
#define KEY_OR_INTR 0x0000
#define KEY_AND_INTR 0x8000
#define DPAD_ANY ((DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN))
Expand Down
6 changes: 6 additions & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
#define SAFE_DIV(a, b) ((a) / (b))
#endif

// The below macro does a%n, but (to match) will switch to a&(n-1) if n is a power of 2.
// There are cases where GF does a&(n-1) where we would really like to have a%n, because
// if n is changed to a value that isn't a power of 2 then a&(n-1) is unlikely to work as
// intended, and a%n for powers of 2 isn't always optimized to use &.
#define MOD(a, n)(((n) & ((n)-1)) ? ((a) % (n)) : ((a) & ((n)-1)))

// Extracts the upper 16 bits of a 32-bit number
#define HIHALF(n) (((n) & 0xFFFF0000) >> 16)

Expand Down
37 changes: 19 additions & 18 deletions include/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -881,13 +881,13 @@ extern const u32 gMonShinyPalette_Starmie[];
extern const u32 gMonStillFrontPic_Starmie[];
extern const u8 gMonIcon_Starmie[];
extern const u8 gMonFootprint_Starmie[];
extern const u32 gMonFrontPic_Mrmime[];
extern const u32 gMonPalette_Mrmime[];
extern const u32 gMonBackPic_Mrmime[];
extern const u32 gMonShinyPalette_Mrmime[];
extern const u32 gMonStillFrontPic_Mrmime[];
extern const u8 gMonIcon_Mrmime[];
extern const u8 gMonFootprint_Mrmime[];
extern const u32 gMonFrontPic_MrMime[];
extern const u32 gMonPalette_MrMime[];
extern const u32 gMonBackPic_MrMime[];
extern const u32 gMonShinyPalette_MrMime[];
extern const u32 gMonStillFrontPic_MrMime[];
extern const u8 gMonIcon_MrMime[];
extern const u8 gMonFootprint_MrMime[];
extern const u32 gMonFrontPic_Scyther[];
extern const u32 gMonPalette_Scyther[];
extern const u32 gMonBackPic_Scyther[];
Expand Down Expand Up @@ -4769,17 +4769,18 @@ extern const u32 gMetalShineTilemap[];

extern const u32 gBattleAnimMaskImage_Curse[];
extern const u32 gBattleAnimMaskTilemap_Curse[];
extern const u32 gBattleStatMask_Gfx[];
extern const u32 gBattleStatMask1_Tilemap[];
extern const u32 gBattleStatMask2_Tilemap[];
extern const u32 gBattleStatMask1_Pal[];
extern const u32 gBattleStatMask2_Pal[];
extern const u32 gBattleStatMask3_Pal[];
extern const u32 gBattleStatMask4_Pal[];
extern const u32 gBattleStatMask5_Pal[];
extern const u32 gBattleStatMask6_Pal[];
extern const u32 gBattleStatMask7_Pal[];
extern const u32 gBattleStatMask8_Pal[];

extern const u32 gStatAnim_Gfx[];
extern const u32 gStatAnim_Increase_Tilemap[];
extern const u32 gStatAnim_Decrease_Tilemap[];
extern const u32 gStatAnim_Defense_Pal[];
extern const u32 gStatAnim_Attack_Pal[];
extern const u32 gStatAnim_Accuracy_Pal[];
extern const u32 gStatAnim_Speed_Pal[];
extern const u32 gStatAnim_Multiple_Pal[];
extern const u32 gStatAnim_Evasion_Pal[];
extern const u32 gStatAnim_SpAttack_Pal[];
extern const u32 gStatAnim_SpDefense_Pal[];

extern const u32 gContestInterfaceGfx[];
extern const u32 gContestAudienceGfx[];
Expand Down
3 changes: 2 additions & 1 deletion include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ struct BoxPokemon
u8 isBadEgg:1;
u8 hasSpecies:1;
u8 isEgg:1;
u8 unused:5;
u8 blockBoxRS:1; // Unused, but Pokémon Box Ruby & Sapphire will refuse to deposit a Pokémon with this flag set
u8 unused:4;
u8 otName[PLAYER_NAME_LENGTH];
u8 markings;
u16 checksum;
Expand Down
7 changes: 6 additions & 1 deletion include/siirtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#define SIIRTCINFO_24HOUR 0x40 // 0: 12-hour mode, 1: 24-hour mode
#define SIIRTCINFO_POWER 0x80 // power on or power failure occurred

#define HOURS_PER_DAY 24
#define MINUTES_PER_HOUR 60
#define SECONDS_PER_MINUTE 60

enum
{
MONTH_JAN = 1,
Expand All @@ -22,7 +26,8 @@ enum
MONTH_SEP,
MONTH_OCT,
MONTH_NOV,
MONTH_DEC
MONTH_DEC,
MONTH_COUNT = MONTH_DEC
};

struct SiiRtcInfo
Expand Down
8 changes: 4 additions & 4 deletions src/AgbRfu_LinkManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 connect_period)
return 0;
}

static void rfu_LMAN_PARENT_stopWaitLinkRecoveryAndDisconnect(u8 bm_targetSlot)
static void UNUSED rfu_LMAN_PARENT_stopWaitLinkRecoveryAndDisconnect(u8 bm_targetSlot)
{
u8 i;

Expand Down Expand Up @@ -1295,7 +1295,7 @@ void rfu_LMAN_setMSCCallback(void (*MSC_callback_p)(u16))
rfu_setMSCCallback(rfu_LMAN_MSC_callback);
}

static void rfu_LMAN_setLMANCallback(void (*func)(u8, u8))
static void UNUSED rfu_LMAN_setLMANCallback(void (*func)(u8, u8))
{
lman.LMAN_callback = func;
}
Expand All @@ -1315,7 +1315,7 @@ u8 rfu_LMAN_setLinkRecovery(u8 enable_flag, u16 recovery_period)
return 0;
}

static u8 rfu_LMAN_setNIFailCounterLimit(u16 NI_failCounter_limit)
static u8 UNUSED rfu_LMAN_setNIFailCounterLimit(u16 NI_failCounter_limit)
{
if (gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag)
{
Expand All @@ -1327,7 +1327,7 @@ static u8 rfu_LMAN_setNIFailCounterLimit(u16 NI_failCounter_limit)
return 0;
}

static u8 rfu_LMAN_setFastSearchParent(u8 enable_flag)
static u8 UNUSED rfu_LMAN_setFastSearchParent(u8 enable_flag)
{
if (lman.state == LMAN_STATE_START_SEARCH_PARENT || lman.state == LMAN_STATE_POLL_SEARCH_PARENT || lman.state == LMAN_STATE_END_SEARCH_PARENT)
{
Expand Down
2 changes: 1 addition & 1 deletion src/anim_mon_front_pics.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const u32 gMonFrontPic_Goldeen[] = INCBIN_U32("graphics/pokemon/goldeen/anim_fro
const u32 gMonFrontPic_Seaking[] = INCBIN_U32("graphics/pokemon/seaking/anim_front.4bpp.lz");
const u32 gMonFrontPic_Staryu[] = INCBIN_U32("graphics/pokemon/staryu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Starmie[] = INCBIN_U32("graphics/pokemon/starmie/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mrmime[] = INCBIN_U32("graphics/pokemon/mr_mime/anim_front.4bpp.lz");
const u32 gMonFrontPic_MrMime[] = INCBIN_U32("graphics/pokemon/mr_mime/anim_front.4bpp.lz");
const u32 gMonFrontPic_Scyther[] = INCBIN_U32("graphics/pokemon/scyther/anim_front.4bpp.lz");
const u32 gMonFrontPic_Jynx[] = INCBIN_U32("graphics/pokemon/jynx/anim_front.4bpp.lz");
const u32 gMonFrontPic_Electabuzz[] = INCBIN_U32("graphics/pokemon/electabuzz/anim_front.4bpp.lz");
Expand Down
9 changes: 5 additions & 4 deletions src/apprentice.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ static void CreateApprenticeMenu(u8 menu)
default:
left = 0;
top = 0;
#ifdef UBFIX
return;
#endif
break;
}

Expand Down Expand Up @@ -1278,8 +1281,7 @@ const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language)
}
}

// Functionally unused
static void Task_SwitchToFollowupFuncAfterButtonPress(u8 taskId)
static void UNUSED Task_SwitchToFollowupFuncAfterButtonPress(u8 taskId)
{
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
SwitchTaskToFollowupFunc(taskId);
Expand All @@ -1302,8 +1304,7 @@ static void ExecuteFuncAfterButtonPress(void (*func)(void))
gTasks[taskId].data[1] = (u32)(func) >> 16;
}

// Unused
static void ExecuteFollowupFuncAfterButtonPress(TaskFunc task)
static void UNUSED ExecuteFollowupFuncAfterButtonPress(TaskFunc task)
{
u8 taskId = CreateTask(Task_SwitchToFollowupFuncAfterButtonPress, 1);
SetTaskFuncWithFollowupFunc(taskId, Task_SwitchToFollowupFuncAfterButtonPress, task);
Expand Down
6 changes: 3 additions & 3 deletions src/battle_ai_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ static u8 ChooseMoveOrAction_Doubles(void)
else
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4);
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> MAX_BATTLERS_COUNT);
else
BattleAI_SetupAIData((1 << MAX_MON_MOVES) - 1);
BattleAI_SetupAIData(ALL_MOVES_MASK);

gBattlerTarget = i;

Expand Down Expand Up @@ -2252,7 +2252,7 @@ static void AIStackPushVar(const u8 *var)
gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = var;
}

static void AIStackPushVar_cursor(void)
static void UNUSED AIStackPushVar_cursor(void)
{
gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = gAIScriptPtr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/battle_anim_bug.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ static void AnimMissileArc_Step(struct Sprite *sprite)
else
{
s16 tempData[8];
u16 *data = sprite->data;
s16 *data = sprite->data;
u16 x1 = sprite->x;
s16 x2 = sprite->x2;
u16 y1 = sprite->y;
Expand Down
Loading

0 comments on commit f01a6af

Please sign in to comment.