Merge pull request #471 from Kermalis/stuff
Some checks are pending
GithubCI / build (push) Waiting to run

Random doc/clean
This commit is contained in:
AnonymousRandomPerson 2026-02-05 21:08:52 -05:00 committed by GitHub
commit a83ec31928
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
59 changed files with 1142 additions and 1120 deletions

View File

@ -1,9 +1,8 @@
#ifndef GUARD_CODE_8004AA0_H
#define GUARD_CODE_8004AA0_H
#include "file_system.h"
#include "structs/rgb.h"
#include "structs/str_202EE8C.h"
#include "structs/str_file_system.h"
extern unkStruct_202EE8C gUnknown_202EE8C[32];
@ -18,6 +17,7 @@ typedef struct unkDataFor8004AA4
void nullsub_6(void);
void sub_8004AA4(unkStruct_202EE8C *, OpenedFile *, s32);
bool8 sub_8004AF0(bool8, unkStruct_202EE8C *, s32, s32, s32, const RGB_Struct *);
bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const RGB_Struct *ramp, RGB_Struct16 *a5);
bool8 sub_8004D14(unkStruct_202EE8C *, s32);
bool8 sub_8004D40(unkStruct_202EE8C *, s32);

View File

@ -3,4 +3,8 @@
void sprintfStatic(char *buffer, const char *text, ...);
bool8 sub_800D588(void);
void sub_800D6AC(void);
void sub_800D7D0(void);
#endif // GUARD_CODE_800D090_H

View File

@ -1,24 +0,0 @@
#ifndef GUARD_CODE_802DB28_H
#define GUARD_CODE_802DB28_H
#include "structs/str_mon_portrait.h"
#include "structs/str_text.h"
#include "structs/str_wonder_mail.h"
// size: 0xA8
struct unkStruct_203B2FC
{
/* 0x0 */ u32 state;
/* 0x4 */ u32 fallbackState;
unkStruct_802F204 unk8;
/* 0x30 */ u8 jobSlotIndex;
/* 0x34 */ WonderMail *jobInfo;
/* 0x38 */ MonPortraitMsg monPortrait;
WindowTemplates unk48;
};
bool8 sub_802DB28(u8 jobSlotIndex, u8 dungeon);
u32 sub_802DBD4(void);
void sub_802DC00(void);
#endif // GUARD_CODE_802DB28_H

View File

@ -1,10 +0,0 @@
#ifndef GUARD_CODE_802F204_H
#define GUARD_CODE_802F204_H
#include "structs/str_wonder_mail.h"
u32 sub_802F204(unkStruct_802F204 *, bool8 displayClientSprite);
u32 sub_802F298(void);
void sub_802F2C0(void);
#endif // GUARD_CODE_802F204_H

View File

@ -1,10 +1,11 @@
#ifndef GUARD_CODE_803C1D0_H
#define GUARD_CODE_803C1D0_H
#include "structs/str_mission_rewards.h"
#include "structs/str_wonder_mail.h"
u8 sub_803C1D0(DungeonLocation *, u8);
const u8 *GetMissionRankText(u8 index);
void sub_803C21C(WonderMail *, unkStruct_802F204 *);
void sub_803C21C(WonderMail *, MissionRewards *);
#endif // GUARD_CODE_803C1D0_H

View File

@ -1,20 +1,5 @@
#ifndef GUARD_CONSTANTS_WONDER_MAIL_H
#define GUARD_CONSTANTS_WONDER_MAIL_H
enum RewardType
{
MONEY,
MONEY_EXTRA,
ITEM,
ITEM_EXTRA,
BLANK_4,
MONEY1,
MONEY1_EXTRA,
ITEM1,
ITEM1_EXTRA,
FRIEND_AREA,
END_REWARDS
};
#define GUARD_CONSTANTS_WONDER_MAIL_H
enum WonderMailMode
{
@ -77,10 +62,8 @@ enum WonderMailMissionTypes
#define MAIL_STATUS_SUSPENDED 0
#define NUM_POKEMON_NEWS 56 // 50 normal + 6 special issues
#define PASSWORD_BUFFER_SIZE 54
#define MAX_ITEM_REWARDS 3
#endif //GUARD_CONSTANTS_WONDER_MAIL_H
#endif // GUARD_CONSTANTS_WONDER_MAIL_H

View File

@ -78,9 +78,11 @@ void sub_8088618(void);
void sub_808862C(void);
void sub_80886C4(void);
void sub_808875C(void);
void sub_8088848(void);
void HandleGroudonBossFaint(u8, u8);
void sub_8088DC0(void);
void sub_8088E5C(void);
void sub_8088EE8(void);
void sub_8089168(void);
void sub_80892C8(void);
void sub_8089328(void);
@ -107,6 +109,7 @@ void sub_808A308(void);
void HandleSuicuneBossFaint(u8, u8);
void sub_808A608(void);
void sub_808A668(void);
void sub_808A718(void);
void HandleHoOhBossFaint(u8, u8);
void sub_808A9E4(void);
void sub_808AA3C(void);

View File

@ -30,4 +30,6 @@ u32 SetFileSystemUnk(u32 value);
#define TRY_CLOSE_FILE_AND_SET_NULL(filePtr) if (filePtr != NULL) CLOSE_FILE_AND_SET_NULL(filePtr)
#define TRY_CLOSE_FILE(filePtr) if (filePtr != NULL) CloseFile(filePtr)
#endif // GUARD_FILE_SYSTEM_H

View File

@ -5,6 +5,7 @@
#include "items.h"
#include "pokemon.h"
#include "structs/menu.h"
#include "structs/str_mission_rewards.h"
#include "structs/str_wonder_mail.h"
// size: 0x568
@ -36,7 +37,7 @@ typedef struct WonderMailStruct_203B33C
u32 unk530;
u32 unk534;
/* 0x538 */ s16 speciesNum; // A7 << 3
unkStruct_802F204 unk53C;
/* 0x53C */ MissionRewards rewards;
s32 unk564;
} WonderMailStruct_203B33C;

View File

@ -14,6 +14,7 @@ struct unkStruct_8009A1C_ptr
void ResetVramPalOAM(void);
void sub_8009A1C(const EfoFileData *r0, u32 palId, u32 vramDstOffset, u32 r3);
void InitFontPalette(void);
void InitGraphics(void);
void ResetScheduledMemCopies(void);
void ScheduleMemCopy(u32 *, const u32 *, u32);
void ScheduleBgTilemapCopy(u32);

10
include/mission_reward.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef GUARD_MISSION_REWARD_H
#define GUARD_MISSION_REWARD_H
#include "structs/str_mission_rewards.h"
bool8 MR_Create(MissionRewards *rewards, bool8 displayClientSprite);
u32 MR_Update(void);
void MR_Destroy(void);
#endif // GUARD_MISSION_REWARD_H

View File

@ -13,28 +13,27 @@ enum TeamRanks
MAX_TEAM_RANKS
};
struct RescueTeamData
typedef struct RescueTeamData
{
u8 teamName[TEAM_NAME_LENGTH];
s32 teamRankPts;
bool8 isTeamRenamed;
};
} RescueTeamData;
extern struct RescueTeamData *gRescueTeamInfoRef;
extern RescueTeamData *gRescueTeamInfoRef;
void LoadRescueTeamInfo(void);
struct RescueTeamData *GetRescueTeamInfo(void);
RescueTeamData *GetRescueTeamInfo(void);
void InitializeRescueTeamInfo(void);
void sub_80920B8(u8 *buffer);
void sub_80920D8(u8 *buffer);
void CopyTeamNameToBuffer(u8 *buffer);
void StrncpyTeamName(u8 *buffer);
void SetRescueTeamName(u8 *buffer);
s32 GetTeamRankPts(void);
s32 GetPtsToNextRank(void);
void AddToTeamRankPts(s32 newPts);
u8 GetRescueTeamRank(void);
const u8 *GetTeamRankString(u32 index);
u8 GetIsTeamRenamed(void);
u32 SaveRescueTeamInfo(u8 *param_1,u32 param_2);
u32 ReadRescueTeamInfo(u8 *param_1, u32 param_2);
u32 SaveRescueTeamInfo(u8 *buffer, u32 bufLen);
u32 ReadRescueTeamInfo(u8 *buffer, u32 bufLen);
#endif // GUARD_RESCUE_TEAM_INFO_H

View File

@ -59,7 +59,7 @@ typedef struct UnkStruct_203B184
/* 0x10 */ u32 *unk10;
/* 0x14 */ unkStruct_203B48C *unk14;
/* 0x18 */ unkStruct_203B490 *mailInfo;
/* 0x1C */ struct RescueTeamData *RescueTeamInfo;
/* 0x1C */ RescueTeamData *RescueTeamInfo;
/* 0x20 */ struct unkStruct_203B494 *unk20;
/* 0x24 */ ExclusivePokemonData *exclusivePokemon;
/* 0x28 */ bool8 *BoughtFriendAreas;

View File

@ -10,6 +10,14 @@ typedef struct RGB_Struct
u8 unk4; // Never read, always 0x80. Unused transparency/alpha flag?
} RGB_Struct;
// Size: R=0x8 | B=0x6
typedef struct RGB_Struct16
{
s16 r;
s16 g;
s16 b;
} RGB_Struct16;
#define RGB_R 0
#define RGB_G 1
#define RGB_B 2

View File

@ -1,6 +1,7 @@
#ifndef GUARD_STR_802C39C_H
#define GUARD_STR_802C39C_H
#include "structs/str_mission_rewards.h"
#include "structs/str_wonder_mail.h"
// size: 0x58
@ -12,7 +13,7 @@ typedef struct unkStruct_802C39C
/* 0x10 */ s16 clientSpecies;
/* 0x12 */ s16 targetSpecies;
/* 0x14 */ u8 targetItem;
/* 0x18 */ unkStruct_802F204 unk18;
/* 0x18 */ MissionRewards rewards;
/* 0x40 */ u8 mailTitleType;
/* 0x41 */ u8 mailDescriptionType;
/* 0x42 */ u8 mailMissionType;

View File

@ -0,0 +1,35 @@
#ifndef GUARD_STR_MISSION_REWARDS_H
#define GUARD_STR_MISSION_REWARDS_H
#define MAX_ITEM_REWARDS 3
enum RewardType
{
MONEY,
MONEY_EXTRA,
ITEM,
ITEM_EXTRA,
BLANK_4,
MONEY1,
MONEY1_EXTRA,
ITEM1,
ITEM1_EXTRA,
FRIEND_AREA,
END_REWARDS
};
// Size: 0x28
typedef struct MissionRewards
{
/* 0x0 */ u8 clientName[POKEMON_NAME_LENGTH];
/* 0xA */ u8 name2[POKEMON_NAME_LENGTH]; // target name?
/* 0x14 */ s16 clientSpecies;
/* 0x16 */ u8 rewardType; // See enum "RewardType"
/* 0x18 */ s32 moneyReward;
/* 0x1C */ u8 itemRewards[MAX_ITEM_REWARDS];
/* 0x1F */ u8 quantity;
/* 0x20 */ u8 friendAreaReward;
/* 0x24 */ u32 teamRankPtsReward;
} MissionRewards;
#endif // GUARD_STR_MISSION_REWARDS_H

View File

@ -2,9 +2,8 @@
#define GUARD_STR_WONDER_MAIL_H
#include "constants/wonder_mail.h"
#include "structs/str_dungeon.h"
#include "structs/str_pokemon.h"
#include "structs/str_dungeon_mail_seed.h"
#include "structs/str_pokemon.h"
// size: 0x14
typedef struct WonderMail
@ -21,20 +20,6 @@ typedef struct WonderMail
/* 0x13 */ u8 friendAreaReward;
} WonderMail;
// size: 0x28
typedef struct unkStruct_802F204
{
/* 0x0 */ u8 clientName[POKEMON_NAME_LENGTH];
/* 0xA */ u8 name2[POKEMON_NAME_LENGTH]; // target name?
/* 0x14 */ s16 clientSpecies;
u8 rewardType;
/* 0x18 */ s32 moneyReward;
/* 0x1C */ u8 itemRewards[MAX_ITEM_REWARDS];
/* 0x1F */ u8 quantity;
/* 0x20 */ u8 friendAreaReward;
/* 0x24 */ u32 teamRankPtsReward;
} unkStruct_802F204;
// size: 0xB4
typedef struct unkStruct_803B344
{

View File

@ -0,0 +1,8 @@
#ifndef GUARD_THANK_YOU_MESSAGES_H
#define GUARD_THANK_YOU_MESSAGES_H
bool8 TYM_Create(u8 jobSlotIndex, u8 dungeon);
u32 TYM_Update(void);
void TYM_Destroy(void);
#endif // GUARD_THANK_YOU_MESSAGES_H

View File

@ -4,9 +4,9 @@
#include "constants/wonder_mail.h"
#include "structs/menu.h"
#include "structs/str_items.h"
#include "structs/str_mission_rewards.h"
#include "structs/str_mon_portrait.h"
#include "structs/str_text.h"
#include "structs/str_wonder_mail.h"
// size: 0x564
typedef struct WonderMailStruct_203B2C4
@ -30,7 +30,7 @@ typedef struct WonderMailStruct_203B2C4
/* 0x434 */ u8 formattedString[0x100];
/* 0x534 */ s32 wonderMailMethod;
/* 0x538 */ u32 wonderMailMode;
unkStruct_802F204 unk53C;
/* 0x53C */ MissionRewards rewards;
} WonderMailStruct_203B2C4;
void CleanThankYouMailPelipper(void);

View File

@ -1,8 +1,8 @@
#ifndef GUARD_WONDER_MAIL_2_H
#define GUARD_WONDER_MAIL_2_H
u8 sub_802B2D4(void);
u32 sub_802B358(void);
void sub_802B3B8(void);
bool8 WM2_Create(void);
void WM2_Destroy(void);
u32 WM2_Update(void);
#endif // GUARD_WONDER_MAIL_2_H

View File

@ -0,0 +1,6 @@
#ifndef GUARD_WONDER_MAIL_3_MID_H
#define GUARD_WONDER_MAIL_3_MID_H
u32 sub_802EF48(void);
#endif // GUARD_WONDER_MAIL_3_MID_H

View File

@ -152,7 +152,7 @@ SECTIONS {
src/wonder_mail_802C860.o(.text);
src/wonder_mail_802CDD4.o(.text);
src/wonder_mail_802D098.o(.text);
src/code_802DB28.o(.text);
src/thank_you_messages.o(.text);
src/code_802DE84.o(.text);
src/mailbox.o(.text);
src/pelipper_board.o(.text);
@ -523,7 +523,7 @@ SECTIONS {
src/wonder_mail_802C860.o(.rodata);
src/wonder_mail_802CDD4.o(.rodata);
src/wonder_mail_802D098.o(.rodata);
src/code_802DB28.o(.rodata);
src/thank_you_messages.o(.rodata);
src/code_802DE84.o(.rodata);
src/mailbox.o(.rodata);
src/pelipper_board.o(.rodata);

View File

@ -97,7 +97,7 @@ UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3,
return ret;
}
bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const RGB_Struct *ramp, s16 *a5)
bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const RGB_Struct *ramp, RGB_Struct16 *a5)
{
bool8 ret;
s32 i;
@ -123,9 +123,9 @@ bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const R
ret = TRUE;
}
r = a5[0] + a0->unk14.r;
g = a5[1] + a0->unk14.g;
b = a5[2] + a0->unk14.b;
r = a5->r + a0->unk14.r;
g = a5->g + a0->unk14.g;
b = a5->b + a0->unk14.b;
if (r > 0xFF)
r = 0xFF;

View File

@ -1,7 +1,8 @@
#include "global.h"
#include "music.h"
#include "memory.h"
#include "code_800D090.h"
#include "cpu.h"
#include "memory.h"
#include "music.h"
void Hang(void)
{
@ -162,8 +163,6 @@ EWRAM_DATA struct UnkStruct_202DCF8 gUnknown_202DCF8 = {0};
extern u32 sub_80001E8(void);
extern void sub_8000228(void);
void sub_800D6AC(void);
void sub_800D7D0(void);
static u32 sub_800D820(u16 *a0, u16 a1[2][8]);
static void sub_800D7B8(void);
static void sub_800D944(u16 *a0);
@ -336,7 +335,7 @@ UNUSED static u8 sub_800D57C(void)
return gUnknown_202DB70;
}
u8 sub_800D588(void)
bool8 sub_800D588(void)
{
return (gUnknown_202DB68 & 0x80);
}

View File

@ -34,12 +34,12 @@ static void sub_801BE30(void);
static void sub_801BEAC(void);
static void sub_801BEC8(void);
bool8 sub_801B60C(u32 r0, u8 id, u8 quantity)
bool8 sub_801B60C(u32 r0, u8 itemID, u8 quantity)
{
sUnknown_203B234 = MemoryAlloc(sizeof(unkStruct_203B234), MEMALLOC_GROUP_8);
sUnknown_203B234->menuAction = 0;
sUnknown_203B234->unk0 = r0;
sUnknown_203B234->unk10.id = id;
sUnknown_203B234->unk10.id = itemID;
if (IsThrownItem(sUnknown_203B234->unk10.id)) {
sUnknown_203B234->unk10.quantity = quantity;

View File

@ -1,194 +0,0 @@
#include "global.h"
#include "globaldata.h"
#include "code_802DB28.h"
#include "code_802F204.h"
#include "code_803C1D0.h"
#include "code_80958E8.h"
#include "exclusive_pokemon.h"
#include "input.h"
#include "items.h"
#include "memory.h"
#include "pokemon.h"
#include "string_format.h"
#include "text_1.h"
EWRAM_INIT static struct unkStruct_203B2FC *sUnknown_203B2FC = {NULL};
#include "data/code_802DB28.h"
static void sub_802DC28(u32 newState);
static void sub_802DC40(void);
static void sub_802DC9C(void);
static void sub_802DE44(void);
static void sub_802DE60(void);
bool8 sub_802DB28(u8 jobSlotIndex, u8 dungeon)
{
struct unkStruct_8096AF8 local_18;
sub_8096AF8(&local_18, jobSlotIndex, dungeon);
if (!local_18.unk0)
return FALSE;
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sUnknown_203B2FC = MemoryAlloc(sizeof(struct unkStruct_203B2FC), MEMALLOC_GROUP_8);
sUnknown_203B2FC->jobSlotIndex = jobSlotIndex;
sUnknown_203B2FC->jobInfo = GetJobSlotInfo(jobSlotIndex);
sub_8096EEC(sUnknown_203B2FC->jobInfo);
sub_803C21C(sUnknown_203B2FC->jobInfo, &sUnknown_203B2FC->unk8);
sUnknown_203B2FC->monPortrait.faceFile = GetDialogueSpriteDataPtr(sUnknown_203B2FC->jobInfo->clientSpecies);
sUnknown_203B2FC->monPortrait.faceData = NULL;
sUnknown_203B2FC->monPortrait.spriteId = 0;
sUnknown_203B2FC->monPortrait.flip = FALSE;
sUnknown_203B2FC->monPortrait.unkE = 0;
sUnknown_203B2FC->monPortrait.pos.x = 2;
sUnknown_203B2FC->monPortrait.pos.y = 8;
if (sUnknown_203B2FC->monPortrait.faceFile != NULL)
sUnknown_203B2FC->monPortrait.faceData = (PortraitGfx *) sUnknown_203B2FC->monPortrait.faceFile->data;
sub_802DC28(0);
return TRUE;
}
u32 sub_802DBD4(void)
{
switch (sUnknown_203B2FC->state) {
case 7:
sUnknown_203B2FC->jobInfo->mailType = WONDER_MAIL_TYPE_OKD;
return 3;
case 6:
sub_802DE44();
return 0;
default:
sub_802DE60();
return 0;
}
}
void sub_802DC00(void)
{
if (sUnknown_203B2FC != NULL) {
if (sUnknown_203B2FC->monPortrait.faceFile != NULL)
CloseFile(sUnknown_203B2FC->monPortrait.faceFile);
FREE_AND_SET_NULL(sUnknown_203B2FC);
}
}
static void sub_802DC28(u32 newState)
{
sUnknown_203B2FC->state = newState;
sub_802DC40();
sub_802DC9C();
}
static void sub_802DC40(void)
{
s32 i;
RestoreSavedWindows(&sUnknown_203B2FC->unk48);
switch (sUnknown_203B2FC->state) {
case 0:
case 7:
for (i = 0; i < 4; i++)
sUnknown_203B2FC->unk48.id[i] = sUnknown_80E016C;
break;
}
ResetUnusedInputStruct();
ShowWindows(&sUnknown_203B2FC->unk48, TRUE, TRUE);
}
static void sub_802DC9C(void)
{
u8 *speciesText;
s32 index;
switch (sUnknown_203B2FC->state) {
case 0:
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, sUnknown_203B2FC->jobInfo->clientSpecies);
CopyYellowMonsterNametoBuffer(gFormatBuffer_Monsters[7], sUnknown_203B2FC->jobInfo->clientSpecies);
speciesText = GetMonSpecies(sUnknown_203B2FC->jobInfo->clientSpecies);
strcpy(gFormatBuffer_Monsters[0], speciesText);
speciesText = GetMonSpecies(sUnknown_203B2FC->jobInfo->targetSpecies);
strcpy(gFormatBuffer_Monsters[1], speciesText);
UnlockExclusivePokemon(sUnknown_203B2FC->jobInfo->clientSpecies);
BufferItemName(gFormatBuffer_Items[0], sUnknown_203B2FC->jobInfo->targetItem, NULL);
sUnknown_203B2FC->fallbackState = 6;
switch (sUnknown_203B2FC->jobInfo->missionType) {
case WONDER_MAIL_MISSION_TYPE_DELIVER_ITEM:
sub_802DC28(5);
break;
case WONDER_MAIL_MISSION_TYPE_FIND_ITEM:
sub_802DC28(4);
break;
case WONDER_MAIL_MISSION_TYPE_RESCUE_TARGET:
sub_802DC28(2);
UnlockExclusivePokemon(sUnknown_203B2FC->jobInfo->targetSpecies);
break;
case WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT:
sub_802DC28(3);
UnlockExclusivePokemon(sUnknown_203B2FC->jobInfo->targetSpecies);
break;
default:
case WONDER_MAIL_MISSION_TYPE_RESCUE_CLIENT:
sub_802DC28(1);
break;
}
break;
case 1:
CreateDialogueBoxAndPortrait(sThanksForRescuingMe, 0, &sUnknown_203B2FC->monPortrait, 0x10D);
break;
case 2:
CreateDialogueBoxAndPortrait(sThanksForRescuingThem, 0, &sUnknown_203B2FC->monPortrait, 0x10D);
break;
case 3:
CreateDialogueBoxAndPortrait(sThanksForEscortingMe, 0, &sUnknown_203B2FC->monPortrait, 0x10D);
break;
case 5:
CreateDialogueBoxAndPortrait(sThanksForDelivering, 0, &sUnknown_203B2FC->monPortrait, 0x10D);
break;
case 4:
index = FindItemInInventory(sUnknown_203B2FC->jobInfo->targetItem);
if (index != -1) {
ShiftItemsDownFrom(index);
FillInventoryGaps();
}
CreateDialogueBoxAndPortrait(sThanksForGetting, 0, &sUnknown_203B2FC->monPortrait, 0x10D);
break;
case 6:
sub_802F204(&sUnknown_203B2FC->unk8, 1);
break;
case 7:
default:
break;
}
}
static void sub_802DE44(void)
{
switch (sub_802F298()) {
case 2:
case 3:
sub_802F2C0();
sub_802DC28(7);
break;
case 0:
case 1:
break;
}
}
static void sub_802DE60(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0)
sub_802DC28(sUnknown_203B2FC->fallbackState);
}

View File

@ -70,34 +70,34 @@ void sub_803B35C(WonderMail *mail, unkStruct_802C39C *param_2)
{
u8 uVar2;
sub_803C21C(mail, &param_2->unk18);
sub_803C21C(mail, &param_2->rewards);
switch(mail->unk2) {
case '\x01':
case 1:
param_2->mailTitleType = 0;
param_2->mailDescriptionType = 0;
param_2->mailMissionType = MISSION_TYPE_SPECIAL_MISSION;
param_2->unk18.rewardType = 5;
param_2->rewards.rewardType = 5;
break;
case '\x02':
case 2:
param_2->mailTitleType = 1;
param_2->mailDescriptionType = 1;
param_2->mailMissionType = MISSION_TYPE_SPECIAL_MISSION;
param_2->unk18.rewardType = 5;
param_2->rewards.rewardType = 5;
break;
case '\x03':
case 3:
param_2->mailTitleType = 2;
param_2->mailDescriptionType = 2;
param_2->mailMissionType = MISSION_TYPE_SPECIAL_MISSION;
param_2->unk18.rewardType = 5;
param_2->rewards.rewardType = 5;
break;
case '\x04':
case 4:
param_2->mailTitleType = 3;
param_2->mailDescriptionType = 3;
param_2->mailMissionType = MISSION_TYPE_SPECIAL_MISSION;
param_2->unk4C = sub_8096DD8();
param_2->unk50 = sub_8096DE8();
break;
case '\x05':
case 5:
if (mail->missionType == MISSION_TYPE_RESCUE_CLIENT) {
param_2->mailTitleType = '\v';
param_2->mailMissionType = MISSION_TYPE_FIND_ITEM;
@ -109,7 +109,7 @@ void sub_803B35C(WonderMail *mail, unkStruct_802C39C *param_2)
param_2->mailDescriptionType = 4;
break;
case '\x06':
case 6:
if (mail->missionType == 3) {
param_2->mailTitleType = '\v';
param_2->mailMissionType = MISSION_TYPE_FIND_ITEM;
@ -121,7 +121,7 @@ void sub_803B35C(WonderMail *mail, unkStruct_802C39C *param_2)
param_2->mailDescriptionType = 5;
break;
case '\a':
case 7:
param_2->unk0[1] = sub_803B600(mail);
if (param_2->unk0[1] == -1) {
param_2->mailTitleType = 9;
@ -133,7 +133,7 @@ void sub_803B35C(WonderMail *mail, unkStruct_802C39C *param_2)
param_2->mailDescriptionType = 6;
param_2->mailMissionType = MISSION_TYPE_RESCUE_TARGET;
break;
case '\b':
case 8:
param_2->unk0[1] = sub_803B628(mail);
if (param_2->unk0[1] == -1) {
param_2->mailTitleType = 9;
@ -144,7 +144,7 @@ void sub_803B35C(WonderMail *mail, unkStruct_802C39C *param_2)
param_2->mailDescriptionType = 7;
param_2->mailMissionType = MISSION_TYPE_RESCUE_TARGET;
break;
case '\t':
case 9:
param_2->unk0[1] = sub_803B66C(mail);
if (param_2->unk0[1] == -1) {
param_2->mailTitleType = 0xA;

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "code_803C1B4.h"
#include "structs/str_mission_rewards.h"
#include "structs/str_wonder_mail.h"
#include "dungeon_info.h"
#include "event_flag.h"
@ -43,77 +44,77 @@ u32 GetDungeonTeamRankPts(DungeonLocation *dungeon, u8 r1)
return gUnknown_80E80A0[index];
}
void sub_803C21C(WonderMail *param_1, unkStruct_802F204 *param_2)
void sub_803C21C(WonderMail *param_1, MissionRewards *rewards)
{
s32 index;
u32 uVar2;
uVar2 = sub_803C1D0(&param_1->dungeonSeed.location,param_1->missionType);
param_2->moneyReward = 0;
rewards->moneyReward = 0;
for(index = 0; index < MAX_ITEM_REWARDS; index++)
{
param_2->itemRewards[index] = ITEM_NOTHING;
for (index = 0; index < MAX_ITEM_REWARDS; index++) {
rewards->itemRewards[index] = ITEM_NOTHING;
}
param_2->friendAreaReward = 0;
param_2->quantity = 10;
rewards->friendAreaReward = 0;
rewards->quantity = 10;
switch(param_1->rewardType) {
case MONEY:
param_2->rewardType = 0;
param_2->moneyReward = (uVar2 + 1) * 100;
rewards->rewardType = 0;
rewards->moneyReward = (uVar2 + 1) * 100;
break;
case MONEY_EXTRA:
param_2->rewardType = 1;
param_2->moneyReward = (uVar2 + 1) * 100;
param_2->itemRewards[0] = param_1->itemReward;
rewards->rewardType = 1;
rewards->moneyReward = (uVar2 + 1) * 100;
rewards->itemRewards[0] = param_1->itemReward;
break;
case ITEM:
param_2->rewardType = 2;
param_2->itemRewards[0] = param_1->itemReward;
rewards->rewardType = 2;
rewards->itemRewards[0] = param_1->itemReward;
break;
case ITEM_EXTRA:
param_2->rewardType = 3;
param_2->itemRewards[0] = param_1->itemReward;
rewards->rewardType = 3;
rewards->itemRewards[0] = param_1->itemReward;
do {
sub_803C37C(&param_1->dungeonSeed.location,param_1->missionType,&param_2->itemRewards[1]);
} while (param_2->itemRewards[0] == param_2->itemRewards[1]);
sub_803C37C(&param_1->dungeonSeed.location, param_1->missionType, &rewards->itemRewards[1]);
} while (rewards->itemRewards[0] == rewards->itemRewards[1]);
break;
case MONEY1:
param_2->rewardType = 0;
param_2->moneyReward = (uVar2 + 1) * 200;
rewards->rewardType = 0;
rewards->moneyReward = (uVar2 + 1) * 200;
break;
case MONEY1_EXTRA:
param_2->rewardType = 1;
param_2->moneyReward = (uVar2 + 1) * 200;
param_2->itemRewards[0] = param_1->itemReward;
rewards->rewardType = 1;
rewards->moneyReward = (uVar2 + 1) * 200;
rewards->itemRewards[0] = param_1->itemReward;
break;
case ITEM1: // ITEM1
param_2->rewardType = 2;
param_2->itemRewards[0] = param_1->itemReward;
rewards->rewardType = 2;
rewards->itemRewards[0] = param_1->itemReward;
break;
case ITEM1_EXTRA:
param_2->rewardType = 3;
param_2->itemRewards[0] = param_1->itemReward;
rewards->rewardType = 3;
rewards->itemRewards[0] = param_1->itemReward;
do {
sub_803C37C(&param_1->dungeonSeed.location,param_1->missionType,&param_2->itemRewards[1]);
} while (param_2->itemRewards[0] == param_2->itemRewards[1]);
sub_803C37C(&param_1->dungeonSeed.location, param_1->missionType, &rewards->itemRewards[1]);
} while (rewards->itemRewards[0] == rewards->itemRewards[1]);
do {
do {
sub_803C37C(&param_1->dungeonSeed.location,param_1->missionType,&param_2->itemRewards[2]);
} while (param_2->itemRewards[0] == param_2->itemRewards[2]);
} while (param_2->itemRewards[1] == param_2->itemRewards[2]);
sub_803C37C(&param_1->dungeonSeed.location, param_1->missionType, &rewards->itemRewards[2]);
} while (rewards->itemRewards[0] == rewards->itemRewards[2]);
} while (rewards->itemRewards[1] == rewards->itemRewards[2]);
break;
case FRIEND_AREA:
param_2->rewardType = 4;
param_2->friendAreaReward = param_1->friendAreaReward;
rewards->rewardType = 4;
rewards->friendAreaReward = param_1->friendAreaReward;
break;
default:
param_2->rewardType = 5;
rewards->rewardType = 5;
break;
}
CopyYellowMonsterNametoBuffer(param_2->clientName, param_1->clientSpecies);
param_2->clientSpecies = param_1->clientSpecies;
param_2->teamRankPtsReward = GetDungeonTeamRankPts(&param_1->dungeonSeed.location,param_1->missionType);
CopyYellowMonsterNametoBuffer(rewards->clientName, param_1->clientSpecies);
rewards->clientSpecies = param_1->clientSpecies;
rewards->teamRankPtsReward = GetDungeonTeamRankPts(&param_1->dungeonSeed.location,param_1->missionType);
}
void sub_803C37C(DungeonLocation *location, u8 r1, u8 *itemReward)

View File

@ -1,11 +1,4 @@
static const WindowTemplate sUnknown_80E016C = {
0,
3,
0, 0,
0, 0,
0, 0,
NULL
};
static const WindowTemplate sDummyWinTemplate = WIN_TEMPLATE_DUMMY;
ALIGNED(4) static const u8 sThanksForRescuingMe[] = _(" Thank you for rescuing me!");

View File

@ -9,52 +9,40 @@
#include "constants/weather.h"
#include "structs/str_dungeon.h"
#include "structs/sprite_oam.h"
#include "dungeon_cutscenes.h"
#include "dungeon_music.h"
#include "dungeon_logic.h"
#include "exclusive_pokemon.h"
#include "weather.h"
#include "pokemon.h"
#include "dungeon_util.h"
#include "dungeon_map_access.h"
#include "dungeon_misc.h"
#include "dungeon_vram.h"
#include "dungeon_mon_sprite_render.h"
#include "dungeon_range.h"
#include "random.h"
#include "math.h"
#include "code_8004AA0.h"
#include "bg_palette_buffer.h"
#include "items.h"
#include "code_8004AA0.h"
#include "direction_util.h"
#include "dungeon_boss_dialogue.h"
#include "dungeon_cutscenes.h"
#include "dungeon_engine.h"
#include "dungeon_logic.h"
#include "dungeon_map.h"
#include "dungeon_map_access.h"
#include "dungeon_message.h"
#include "dungeon_misc.h"
#include "dungeon_mon_spawn.h"
#include "dungeon_mon_sprite_render.h"
#include "dungeon_pos_data.h"
#include "dungeon_range.h"
#include "dungeon_music.h"
#include "dungeon_tilemap.h"
#include "dungeon_util.h"
#include "dungeon_vram.h"
#include "effect_data.h"
#include "effect_main.h"
#include "effect_sub_1.h"
#include "sprite.h"
#include "effect_data.h"
#include "exclusive_pokemon.h"
#include "items.h"
#include "math.h"
#include "pokemon.h"
#include "pokemon_3.h"
#include "dungeon_boss_dialogue.h"
#include "dungeon_pos_data.h"
#include "dungeon_engine.h"
#include "dungeon_tilemap.h"
#include "dungeon_map.h"
#include "dungeon_mon_spawn.h"
#include "dungeon_message.h"
#include "direction_util.h"
struct RgbS16
{
s16 r;
s16 g;
s16 b;
};
#include "random.h"
#include "sprite.h"
#include "weather.h"
extern OpenedFile *gDungeonPaletteFile;
extern RGB_Struct gUnknown_202ECA4[33];
extern bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const RGB_Struct *ramp, struct RgbS16 *a5);
extern void sub_8088EE8(void);
extern void sub_8088848(void);
extern void sub_808A718(void);
// Size: R=0x8 | B=0x6
typedef struct FixedRoomCutsceneData
{
@ -1219,7 +1207,7 @@ void SetDungeonBGColorRGB(s32 r, s32 g, s32 b, bool8 a3, bool8 a4)
s32 i, palIndex, n;
const RGB_Struct *colorPtr;
RGB_Struct color;
struct RgbS16 colorS16;
RGB_Struct16 colorS16;
n = 160;
sub_8085E98();

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "globaldata.h"
#include "dungeon_cutscene.h"
#include "dungeon_cutscenes.h"
#include "effect_main.h"
#include "dungeon_vram.h"
#include "dungeon_8041AD0.h"

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "globaldata.h"
#include "dungeon_cutscene.h"
#include "dungeon_cutscenes.h"
#include "effect_main.h"
#include "dungeon_vram.h"
#include "dungeon_8041AD0.h"

View File

@ -125,9 +125,7 @@ void InitDungeonMap(bool8 a0)
void CloseDungeonMapFile(void)
{
if (sDungeonMapGfxFile != NULL) {
CloseFile(sDungeonMapGfxFile);
}
TRY_CLOSE_FILE(sDungeonMapGfxFile);
SetDungeonMapToNotShown();
}

View File

@ -344,9 +344,7 @@ void DisplayDungeonMessage_Async(struct MonDialogueSpriteInfo *monSpriteInfo, co
PRINT_STRING_WAIT_PRESS_ASYNC(&chosenMenuIndex);
gDungeon->unk1BDD4.unk1C05F = 0;
if (monPortrait.faceFile != NULL) {
CloseFile(monPortrait.faceFile);
}
TRY_CLOSE_FILE(monPortrait.faceFile);
if (a2) {
sub_805E804();
@ -517,9 +515,7 @@ bool32 DisplayDungeonYesNoMessage_Async(struct MonDialogueSpriteInfo *monSpriteI
PRINT_STRING_WAIT_PRESS_ASYNC(&chosenMenuIndex);
if (monPortrait.faceFile != NULL) {
CloseFile(monPortrait.faceFile);
}
TRY_CLOSE_FILE(monPortrait.faceFile);
LoadDungeonMapPalette();
sub_803EAF0(0, NULL);
@ -560,9 +556,7 @@ s32 DisplayDungeonMenuMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const
CreateMenuDialogueBoxAndPortrait(str, 0, -1, menuItems, NULL, 3, 0, monPortraitPtr, unkArg);
PRINT_STRING_WAIT_PRESS_ASYNC(&chosenMenuIndex);
if (monPortrait.faceFile != NULL) {
CloseFile(monPortrait.faceFile);
}
TRY_CLOSE_FILE(monPortrait.faceFile);
LoadDungeonMapPalette();
sub_803EAF0(0, NULL);

View File

@ -241,7 +241,7 @@ void FriendList_ShowWindow(void)
sub_80073B8(sFriendList->unk358.m.menuWinId);
switch (sFriendList->unk0) {
case 2:
sub_80920D8(winTxtBuff);
StrncpyTeamName(winTxtBuff);
PrintStringOnWindow(10, 0, winTxtBuff, sFriendList->unk358.m.menuWinId, '\0');
break;
case 4:

View File

@ -6,7 +6,6 @@
#include "code_800D090.h"
#include "code_801B3C0.h"
#include "code_801C8C4.h"
#include "code_802F204.h"
#include "code_8094F88.h"
#include "cpu.h"
#include "friend_list.h"
@ -16,6 +15,7 @@
#include "main_menu1.h"
#include "memory.h"
#include "menu_input.h"
#include "mission_reward.h"
#include "music_util.h"
#include "other_menus2.h"
#include "pokemon.h"
@ -578,8 +578,6 @@ void sub_80353BC(void);
void sub_8035424(void);
void sub_8035430(void);
extern u8 sub_800D588(void);
static void SetFriendRescueMenuState(u32 newState);
u32 CreateFriendRescueMenu(void)
@ -963,7 +961,7 @@ void CleanFriendRescueMenu(void)
FriendList_Free();
NamingScreen_Free();
sub_801CBB8();
sub_802F2C0();
MR_Destroy();
sub_8030DE4();
RecruitedMonSummaryMenu_Destroy();
FreeItemDescriptionWindow();
@ -974,7 +972,7 @@ void nullsub_40(void)
{
}
void sub_8032828(void)
static void sub_8032828(void)
{
unkStruct_203B480 *mail;
u8 buffer[80];
@ -1266,7 +1264,7 @@ void sub_8032828(void)
case 2:
case 3:
gUnknown_203B33C->status = sub_80381F4(gUnknown_203B33C->unk40, &gUnknown_203B33C->unk48, &gUnknown_203B33C->unk78);
if (sub_800D588() != 0)
if (sub_800D588())
gUnknown_203B33C->unk420 = gUnknown_203B33C->unk78.unk10.unk10;
else
gUnknown_203B33C->unk420 = gUnknown_203B33C->unk48.unk10.unk10;
@ -1274,7 +1272,7 @@ void sub_8032828(void)
case 4:
case 5:
gUnknown_203B33C->status = sub_80381F4(gUnknown_203B33C->unk40, &gUnknown_203B33C->unkA8, &gUnknown_203B33C->unk130);
if (sub_800D588() != 0)
if (sub_800D588())
gUnknown_203B33C->unk420 = gUnknown_203B33C->unk130.mail.unk10.unk10;
else
gUnknown_203B33C->unk420 = gUnknown_203B33C->unkA8.mail.unk10.unk10;
@ -1390,7 +1388,7 @@ void sub_8032828(void)
case 0x6:
case 0x7:
gUnknown_203B33C->status = sub_80381F4(gUnknown_203B33C->unk40, &gUnknown_203B33C->unk1B8, &gUnknown_203B33C->unk1E8);
if (sub_800D588() != 0)
if (sub_800D588())
gUnknown_203B33C->unk420 = gUnknown_203B33C->unk1E8.unk10.unk10;
else
gUnknown_203B33C->unk420 = gUnknown_203B33C->unk1B8.unk10.unk10;
@ -1445,22 +1443,22 @@ void sub_8032828(void)
break;
case 0x6E:
monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(gUnknown_203B33C->unk53C.clientName, monName);
gUnknown_203B33C->unk53C.clientSpecies = 0;
gUnknown_203B33C->unk53C.rewardType = 2;
gUnknown_203B33C->unk53C.moneyReward = 0;
strcpy(gUnknown_203B33C->rewards.clientName, monName);
gUnknown_203B33C->rewards.clientSpecies = 0;
gUnknown_203B33C->rewards.rewardType = 2;
gUnknown_203B33C->rewards.moneyReward = 0;
mail = GetMailatIndex(GetMailIndex(6, gUnknown_203B33C->unk420));
// ABSOLUTELY GENIUS
// ABSOLUTELY GENIUS (probably is an inline/macro since this happens in other funcs too)
if (mail->item.id != ITEM_NOTHING)
gUnknown_203B33C->unk53C.itemRewards[0] = mail->item.id;
gUnknown_203B33C->rewards.itemRewards[0] = mail->item.id;
else
gUnknown_203B33C->unk53C.itemRewards[0] = ITEM_NOTHING;
gUnknown_203B33C->unk53C.quantity = 1;
gUnknown_203B33C->unk53C.teamRankPtsReward = GetDungeonTeamRankPts(&mail->dungeonSeed.location, 0);
gUnknown_203B33C->unk53C.itemRewards[1] = 0;
gUnknown_203B33C->unk53C.itemRewards[2] = 0;
gUnknown_203B33C->unk53C.friendAreaReward = 0;
sub_802F204(&gUnknown_203B33C->unk53C, 0);
gUnknown_203B33C->rewards.itemRewards[0] = ITEM_NOTHING;
gUnknown_203B33C->rewards.quantity = 1;
gUnknown_203B33C->rewards.teamRankPtsReward = GetDungeonTeamRankPts(&mail->dungeonSeed.location, 0);
gUnknown_203B33C->rewards.itemRewards[1] = 0;
gUnknown_203B33C->rewards.itemRewards[2] = 0;
gUnknown_203B33C->rewards.friendAreaReward = 0;
MR_Create(&gUnknown_203B33C->rewards, FALSE);
break;
case 0x62:
nullsub_23(FALSE);
@ -1853,7 +1851,7 @@ void sub_8033CAC(void)
SetFriendRescueMenuState(0x37);
break;
case 0x12:
if(sub_800D588() != 0)
if(sub_800D588())
speciesNum = gUnknown_203B33C->unk130.pokemon.speciesNum;
else
speciesNum = gUnknown_203B33C->unkA8.pokemon.speciesNum;
@ -3192,8 +3190,8 @@ void sub_80352A4(void)
u8 mailIndex;
char *monName;
if ( sub_802F298() == 3) {
sub_802F2C0();
if ( MR_Update() == 3) {
MR_Destroy();
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER);
monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(gFormatBuffer_Monsters[0], monName);

View File

@ -1,11 +1,10 @@
#include "global.h"
#include "globaldata.h"
#include "graphics_memory.h"
#include "bg_palette_buffer.h"
#include "structs/axdata.h"
#include "cpu.h"
#include "def_filearchives.h"
#include "file_system.h"
#include "graphics_memory.h"
#include "text_1.h"
struct FontData

View File

@ -1,16 +1,14 @@
#include "global.h"
#include "globaldata.h"
#include "ground_lives_helper.h"
#include "constants/direction.h"
#include "input.h"
#include "ground_lives_helper.h"
#include "game_options.h"
#include "ground_main.h"
#include "ground_script.h"
#include "ground_map.h"
#include "ground_script.h"
#include "input.h"
#include "textbox.h"
extern void nullsub_104(void);
extern void sub_809C6CC(u16 param_1);
#include "unk_ds_only_feature.h"
void nullsub_117(void)
{

View File

@ -2159,7 +2159,7 @@ static s32 ExecuteScriptCommand(Action *action)
}
}
case CMD_BYTE_3E: {
sub_80920B8(sPokeNameBuffer);
CopyTeamNameToBuffer(sPokeNameBuffer);
sPokeNameBuffer[10] = '\0';
ScriptSpecialTextHandler2(SPECIAL_TEXT_TEAM_NAME_INPUT, 0, STR_TO_MONORSTRPTR(sPokeNameBuffer));
sub_80A87AC(0, 11);

View File

@ -192,8 +192,7 @@ UNUSED static void sub_80A64A4(void)
sub_809971C(r9, (RGB_Array*)r2, 16);
sub_80997F4(sl, r4);
if (file != NULL)
CloseFile(file);
TRY_CLOSE_FILE(file);
}
}
}
@ -358,10 +357,7 @@ void sub_80A68A0(struct UnkGroundSpriteStruct *ptr)
if ((ptr->flags_0x50 & 0x200) && ptr->unk58 != 0 && ptr->unk5C != -1) {
sub_800DC14(ptr->unk5C);
}
if (ptr->unk54 != NULL) {
CloseFile(ptr->unk54);
ptr->unk54 = NULL;
}
TRY_CLOSE_FILE_AND_SET_NULL(ptr->unk54);
sub_80A69FC(ptr);
}
@ -550,9 +546,7 @@ void GroundSprite_ExtendPaletteAdd(struct UnkGroundSpriteStruct *ptr, u16 a1)
ptr->unk68 = r2;
}
Log(0, "extend palette %3d[%3d] %04x set %04x %04x", r8, var_28, r2, a1, r6);
if (file != NULL) {
CloseFile(file);
}
TRY_CLOSE_FILE(file);
}
else {
if (ptr != NULL) {

View File

@ -316,7 +316,7 @@ static void DrawLoadScreenText(void)
// Draw Team Name
if (CheckQuest(QUEST_SET_TEAM_NAME))
sub_80920D8(teamNameBuffer);
StrncpyTeamName(teamNameBuffer);
else
InlineStrcpy(teamNameBuffer, _(""));

View File

@ -32,9 +32,6 @@ extern const u8 IWRAM_INIT_ROM_START[];
UNUSED static const char sStringRomUserData[] = "PKD ROM USER DATA 000000";
// code_2.c
extern void InitGraphics(void);
extern void Hang(void);
// arm9.bin::02000B88

View File

@ -1,73 +1,66 @@
#include "global.h"
#include "globaldata.h"
#include "music_util.h"
#include "code_801B60C.h"
#include "code_802F204.h"
#include "friend_area.h"
#include "input.h"
#include "items.h"
#include "memory.h"
#include "mission_reward.h"
#include "music_util.h"
#include "pokemon.h"
#include "rescue_team_info.h"
#include "string_format.h"
#include "text_1.h"
struct unkStruct_203B310
enum MR_State
{
// size: 0x84
/* 0x0 */ u32 state;
/* 0x4 */ u32 nextState;
/* 0x8 */ bool8 displayClientDialogueSprite; // true to display the dialogue sprite for the client
/* 0x9 */ u8 currTeamRank; // team rank
MR_STATE_PREP_MONEY_REWARD,
MR_STATE_MONEY_REWARD,
MR_STATE_PREP_FRIEND_AREA_REWARD,
MR_STATE_UNLOCK_FRIEND_AREA,
MR_STATE_PREP_ITEM_REWARD,
MR_STATE_GIVE_ITEM_REWARD,
MR_STATE_NEXT_ITEM,
MR_STATE_TEAM_PNTS_REWARD,
MR_STATE_NEW_TEAM_RANK,
MR_STATE_REWARD_EXIT,
};
// Size: 0x84
typedef struct MR_Work
{
/* 0x0 */ u32 state; // See enum "MR_State"
/* 0x4 */ u32 nextState; // See enum "MR_State"
/* 0x8 */ bool8 displayClientDialogueSprite;
/* 0x9 */ u8 currTeamRank;
/* 0xC */ s32 itemRewardIndex;
unkStruct_802F204 *unk10;
/* 0x10 */ MissionRewards *rewards;
/* 0x14 */ MonPortraitMsg monPortrait;
WindowTemplates unk24;
};
/* 0x24 */ WindowTemplates windows;
} MR_Work;
EWRAM_INIT struct unkStruct_203B310 *gUnknown_203B310 = {NULL};
EWRAM_INIT MR_Work *sMRWork = { NULL };
enum FriendRewardStates
{
PREP_MONEY_REWARD,
MONEY_REWARD,
PREP_FRIEND_AREA_REWARD,
UNLOCK_FRIEND_AREA,
PREP_ITEM_REWARD,
GIVE_ITEM_REWARD,
NEXT_ITEM,
TEAM_PNTS_REWARD,
NEW_TEAM_RANK,
REWARD_EXIT,
};
static const WindowTemplate sWinTemplateDummy = WIN_TEMPLATE_DUMMY;
const WindowTemplate gUnknown_80E041C = {
0,
0x03,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
NULL
};
ALIGNED(4) const u8 gUnknown_80E0434[] = _(
ALIGNED(4) static const u8 gUnknown_80E0434[] = _(
" Here's your reward!\n"
"{COLOR CYAN}{VALUE_0}{RESET} {POKE}!");
ALIGNED(4) const u8 gUnknown_80E045C[] = _(
ALIGNED(4) static const u8 gUnknown_80E045C[] = _(
"{CENTER_ALIGN}{COLOR YELLOW_N}{POKEMON_0}{RESET} received\n"
"{CENTER_ALIGN}{COLOR CYAN}{VALUE_0}{RESET} {POKE}.");
ALIGNED(4) const u8 gUnknown_80E0484[] = _(
ALIGNED(4) static const u8 gUnknown_80E0484[] = _(
"{CENTER_ALIGN}{COLOR YELLOW_N}{POKEMON_0}{RESET}'s team received\n"
"{CENTER_ALIGN}{COLOR CYAN}{VALUE_0}{RESET} {POKE}.");
ALIGNED(4) const u8 gUnknown_80E04B4[]= _(
ALIGNED(4) static const u8 gUnknown_80E04B4[]= _(
" As your reward, you can\n"
"now go to the Friend Area\n"
"{COLOR GREEN}{FRIEND_AREA}{RESET}!");
ALIGNED(4) const u8 gUnknown_80E04F4[] = _(
ALIGNED(4) static const u8 gUnknown_80E04F4[] = _(
"{CENTER_ALIGN}...Oh, wait, sorry.{EXTRA_MSG}"
"{CENTER_ALIGN}You already have the \n"
"{CENTER_ALIGN}{COLOR GREEN}{FRIEND_AREA} Friend Area{RESET}.{EXTRA_MSG}"
@ -76,300 +69,315 @@ ALIGNED(4) const u8 gUnknown_80E04F4[] = _(
"{CENTER_ALIGN}In its place, {COLOR YELLOW_N}{POKEMON_0}{RESET},\n"
"{CENTER_ALIGN}you can have {COLOR CYAN_G}1,000{RESET} {POKE}.");
ALIGNED(4) const u8 gUnknown_80E05C0[] = _(
ALIGNED(4) static const u8 gUnknown_80E05C0[] = _(
"{CENTER_ALIGN}{COLOR YELLOW_N}{POKEMON_0}{RESET} gained access\n"
"{CENTER_ALIGN}to the Friend Area\n"
"{CENTER_ALIGN}{COLOR GREEN}{FRIEND_AREA}{RESET}.");
ALIGNED(4) const u8 gUnknown_80E05FC[] = _(
ALIGNED(4) static const u8 gUnknown_80E05FC[] = _(
"{CENTER_ALIGN}{COLOR YELLOW_N}{POKEMON_0}{RESET}'s team gained access\n"
"{CENTER_ALIGN}to the Friend Area\n"
"{CENTER_ALIGN}{COLOR GREEN}{FRIEND_AREA}{RESET}.");
ALIGNED(4) const u8 gUnknown_80E0640[] = _(
ALIGNED(4) static const u8 gUnknown_80E0640[] = _(
" Here's your reward!\n"
"The promised {COLOR GREEN}{MOVE_ITEM_1}{RESET}!");
ALIGNED(4) const u8 gUnknown_80E0670[] = _(
ALIGNED(4) static const u8 gUnknown_80E0670[] = _(
"{CENTER_ALIGN}Rescue Team {COLOR CYAN_G}$t{RESET}\n"
"{CENTER_ALIGN}gained {COLOR CYAN}{VALUE_0}{RESET} rescue points.");
ALIGNED(4) const u8 gUnknown_80E06A8[] = _(
ALIGNED(4) static const u8 gUnknown_80E06A8[] = _(
"{CENTER_ALIGN}Congratulations!{EXTRA_MSG}"
"{CENTER_ALIGN}{COLOR CYAN_G}$t{RESET} went up in rank\n"
"{CENTER_ALIGN}from the {POKEMON_2}\n"
"{CENTER_ALIGN}to the {POKEMON_3}!");
static void MR_InitStateDialogue(void);
static void MR_InitStateWindows(void);
static void MR_SetState(u32 state);
static void MR_ProceedToNextState(void);
static void sub_802F6FC(void);
void SetRewardSceneState(u32);
void sub_802F6FC(void);
void ProceedToNextRewardSceneState(void);
void sub_802F300(void);
void HandleMissionReward(void);
u32 sub_802F204(unkStruct_802F204 *r0, bool8 displayClientSprite)
bool8 MR_Create(MissionRewards *rewards, bool8 displayClientSprite)
{
struct unkStruct_203B310 *preload;
MR_Work *preload;
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
gUnknown_203B310 = MemoryAlloc(sizeof(struct unkStruct_203B310), MEMALLOC_GROUP_8);
gUnknown_203B310->unk10 = r0;
gUnknown_203B310->itemRewardIndex = 0;
gUnknown_203B310->displayClientDialogueSprite = displayClientSprite;
sMRWork = MemoryAlloc(sizeof(MR_Work), MEMALLOC_GROUP_8);
sMRWork->rewards = rewards;
sMRWork->itemRewardIndex = 0;
sMRWork->displayClientDialogueSprite = displayClientSprite;
// NOTE: dumb var to get correct ordering
preload = gUnknown_203B310;
strcpy(gSpeakerNameBuffer, preload->unk10->clientName);
preload = sMRWork;
strcpy(gSpeakerNameBuffer, preload->rewards->clientName);
PrintPokeNameToBuffer(gFormatBuffer_Monsters[0], GetLeaderMon1());
gUnknown_203B310->monPortrait.faceFile = GetDialogueSpriteDataPtr(gUnknown_203B310->unk10->clientSpecies);
gUnknown_203B310->monPortrait.faceData = NULL;
sMRWork->monPortrait.faceFile = GetDialogueSpriteDataPtr(sMRWork->rewards->clientSpecies);
sMRWork->monPortrait.faceData = NULL;
gUnknown_203B310->monPortrait.spriteId = 0;
gUnknown_203B310->monPortrait.flip = FALSE;
gUnknown_203B310->monPortrait.unkE = 0;
gUnknown_203B310->monPortrait.pos.x = 2;
gUnknown_203B310->monPortrait.pos.y = 8;
sMRWork->monPortrait.spriteId = 0;
sMRWork->monPortrait.flip = FALSE;
sMRWork->monPortrait.unkE = 0;
sMRWork->monPortrait.pos.x = 2;
sMRWork->monPortrait.pos.y = 8;
if(gUnknown_203B310->monPortrait.faceFile != NULL)
{
gUnknown_203B310->monPortrait.faceData = (PortraitGfx *) gUnknown_203B310->monPortrait.faceFile->data;
}
if (sMRWork->monPortrait.faceFile != NULL)
sMRWork->monPortrait.faceData = (PortraitGfx *)sMRWork->monPortrait.faceFile->data;
SetRewardSceneState(PREP_MONEY_REWARD);
return 1;
MR_SetState(MR_STATE_PREP_MONEY_REWARD);
return TRUE;
}
u32 sub_802F298(void)
u32 MR_Update(void)
{
switch(gUnknown_203B310->state)
{
case REWARD_EXIT:
switch (sMRWork->state) {
case MR_STATE_REWARD_EXIT: {
return 3;
case GIVE_ITEM_REWARD:
}
case MR_STATE_GIVE_ITEM_REWARD: {
sub_802F6FC();
return 0;
default:
ProceedToNextRewardSceneState();
}
default: {
MR_ProceedToNextState();
return 0;
}
}
}
void sub_802F2C0(void)
void MR_Destroy(void)
{
if (gUnknown_203B310 != NULL) {
if(gUnknown_203B310->monPortrait.faceFile != 0)
CloseFile(gUnknown_203B310->monPortrait.faceFile);
FREE_AND_SET_NULL(gUnknown_203B310);
if (sMRWork != NULL) {
TRY_CLOSE_FILE(sMRWork->monPortrait.faceFile);
FREE_AND_SET_NULL(sMRWork);
}
}
void SetRewardSceneState(u32 newState)
static void MR_SetState(u32 state)
{
gUnknown_203B310->state = newState;
sub_802F300();
HandleMissionReward();
sMRWork->state = state;
MR_InitStateWindows();
MR_InitStateDialogue();
}
void sub_802F300(void)
static void MR_InitStateWindows(void)
{
s32 index;
switch(gUnknown_203B310->state)
{
case PREP_MONEY_REWARD:
RestoreSavedWindows(&gUnknown_203B310->unk24);
for(index = 0; index < 4; index++)
{
gUnknown_203B310->unk24.id[index] = gUnknown_80E041C;
switch (sMRWork->state) {
case MR_STATE_PREP_MONEY_REWARD: {
s32 i;
RestoreSavedWindows(&sMRWork->windows);
for (i = 0; i < MAX_WINDOWS; i++) {
sMRWork->windows.id[i] = sWinTemplateDummy;
}
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B310->unk24, TRUE, TRUE);
default:
ShowWindows(&sMRWork->windows, TRUE, TRUE);
break;
}
default: {
break;
}
}
}
void HandleMissionReward(void)
static void MR_InitStateDialogue(void)
{
s32 moneyReward;
const u8 *rankString;
u8 itemID;
struct unkStruct_8090F58 local_20;
Item item;
switch (sMRWork->state) {
case MR_STATE_PREP_MONEY_REWARD: {
s32 moneyReward = sMRWork->rewards->moneyReward;
switch(gUnknown_203B310->state) {
case PREP_MONEY_REWARD:
moneyReward = gUnknown_203B310->unk10->moneyReward;
if (moneyReward == 0) {
SetRewardSceneState(PREP_FRIEND_AREA_REWARD);
}
else {
gFormatArgs[0] = moneyReward;
if (gUnknown_203B310->displayClientDialogueSprite) {
CreateDialogueBoxAndPortrait(gUnknown_80E0434,0,&gUnknown_203B310->monPortrait,0x10d);
gUnknown_203B310->nextState = MONEY_REWARD;
if (moneyReward == 0) {
MR_SetState(MR_STATE_PREP_FRIEND_AREA_REWARD);
}
else {
SetRewardSceneState(MONEY_REWARD);
gFormatArgs[0] = moneyReward;
if (sMRWork->displayClientDialogueSprite) {
CreateDialogueBoxAndPortrait(gUnknown_80E0434, 0, &sMRWork->monPortrait, 0x10d);
sMRWork->nextState = MR_STATE_MONEY_REWARD;
}
else {
MR_SetState(MR_STATE_MONEY_REWARD);
}
}
break;
}
break;
case MONEY_REWARD:
PlaySound(0xcb);
AddToTeamMoney(gUnknown_203B310->unk10->moneyReward);
if (GetUnitSum_808D544(0) < 2) {
CreateDialogueBoxAndPortrait(gUnknown_80E045C,0,0,0x101);
case MR_STATE_MONEY_REWARD: {
PlaySound(203);
AddToTeamMoney(sMRWork->rewards->moneyReward);
if (GetUnitSum_808D544(0) < 2)
CreateDialogueBoxAndPortrait(gUnknown_80E045C, 0, 0, 0x101);
else
CreateDialogueBoxAndPortrait(gUnknown_80E0484, 0, 0, 0x101);
sMRWork->nextState = MR_STATE_PREP_FRIEND_AREA_REWARD;
break;
}
else {
CreateDialogueBoxAndPortrait(gUnknown_80E0484,0,0,0x101);
}
gUnknown_203B310->nextState = PREP_FRIEND_AREA_REWARD;
break;
case PREP_FRIEND_AREA_REWARD:
if (gUnknown_203B310->unk10->friendAreaReward == 0) {
SetRewardSceneState(PREP_ITEM_REWARD);
}
else {
WriteFriendAreaName(gFormatBuffer_FriendArea,gUnknown_203B310->unk10->friendAreaReward,FALSE);
if (gUnknown_203B310->displayClientDialogueSprite) {
CreateDialogueBoxAndPortrait(gUnknown_80E04B4,0,&gUnknown_203B310->monPortrait,0x10d);
gUnknown_203B310->nextState = UNLOCK_FRIEND_AREA;
case MR_STATE_PREP_FRIEND_AREA_REWARD: {
if (sMRWork->rewards->friendAreaReward == 0) {
MR_SetState(MR_STATE_PREP_ITEM_REWARD);
}
else {
SetRewardSceneState(UNLOCK_FRIEND_AREA);
WriteFriendAreaName(gFormatBuffer_FriendArea, sMRWork->rewards->friendAreaReward, FALSE);
if (sMRWork->displayClientDialogueSprite) {
CreateDialogueBoxAndPortrait(gUnknown_80E04B4, 0, &sMRWork->monPortrait, 0x10d);
sMRWork->nextState = MR_STATE_UNLOCK_FRIEND_AREA;
}
else {
MR_SetState(MR_STATE_UNLOCK_FRIEND_AREA);
}
}
break;
}
break;
case UNLOCK_FRIEND_AREA:
if (GetFriendAreaStatus(gUnknown_203B310->unk10->friendAreaReward)) {
// We already have the friend area
AddToTeamMoney(1000);
CreateDialogueBoxAndPortrait(gUnknown_80E04F4,0,0,0x101);
}
else
{
if (GetUnitSum_808D544(0) < 2) {
UnlockFriendArea(gUnknown_203B310->unk10->friendAreaReward);
PlaySound(0xce);
CreateDialogueBoxAndPortrait(gUnknown_80E05C0,0,0,0x101);
case MR_STATE_UNLOCK_FRIEND_AREA: {
if (GetFriendAreaStatus(sMRWork->rewards->friendAreaReward)) {
// We already have the friend area
AddToTeamMoney(1000);
CreateDialogueBoxAndPortrait(gUnknown_80E04F4, 0, 0, 0x101);
}
else
{
UnlockFriendArea(gUnknown_203B310->unk10->friendAreaReward);
PlaySound(0xce);
CreateDialogueBoxAndPortrait(gUnknown_80E05FC,0,0,0x101);
}
}
gUnknown_203B310->nextState = PREP_ITEM_REWARD;
break;
case PREP_ITEM_REWARD:
itemID = gUnknown_203B310->unk10->itemRewards[0];
if (itemID != ITEM_NOTHING)
{
if (gUnknown_203B310->unk10->moneyReward == 0) {
item.id = itemID;
if (IsThrownItem(item.id)) {
item.quantity = gUnknown_203B310->unk10->quantity;
}
else {
item.quantity = 0;
}
item.flags = ITEM_FLAG_EXISTS;
local_20.unk0 = 0;
local_20.unk4 = 0;
local_20.unk8 = 1;
sub_8090E14(gFormatBuffer_Items[1],&item,&local_20);
if (gUnknown_203B310->displayClientDialogueSprite) {
CreateDialogueBoxAndPortrait(gUnknown_80E0640,0,&gUnknown_203B310->monPortrait,0x10d);
gUnknown_203B310->nextState = GIVE_ITEM_REWARD;
if (GetUnitSum_808D544(0) < 2) {
UnlockFriendArea(sMRWork->rewards->friendAreaReward);
PlaySound(0xce);
CreateDialogueBoxAndPortrait(gUnknown_80E05C0, 0, 0, 0x101);
}
else
{
SetRewardSceneState(GIVE_ITEM_REWARD);
UnlockFriendArea(sMRWork->rewards->friendAreaReward);
PlaySound(0xce);
CreateDialogueBoxAndPortrait(gUnknown_80E05FC, 0, 0, 0x101);
}
}
else
{
SetRewardSceneState(GIVE_ITEM_REWARD);
}
sMRWork->nextState = MR_STATE_PREP_ITEM_REWARD;
break;
}
else
SetRewardSceneState(TEAM_PNTS_REWARD);
break;
case GIVE_ITEM_REWARD:
if ((gUnknown_203B310->unk10->itemRewards[gUnknown_203B310->itemRewardIndex]) == 0) {
SetRewardSceneState(NEXT_ITEM);
}
else {
if ((gUnknown_203B310->itemRewardIndex == 0) && (gUnknown_203B310->unk10->moneyReward == 0)) {
sub_801B60C(0,gUnknown_203B310->unk10->itemRewards[0],gUnknown_203B310->unk10->quantity);
}
else {
sub_801B60C(1,gUnknown_203B310->unk10->itemRewards[gUnknown_203B310->itemRewardIndex],gUnknown_203B310->unk10->quantity);
}
}
break;
case NEXT_ITEM:
gUnknown_203B310->itemRewardIndex++;
if(gUnknown_203B310->itemRewardIndex < MAX_ITEM_REWARDS)
SetRewardSceneState(GIVE_ITEM_REWARD);
else
SetRewardSceneState(TEAM_PNTS_REWARD);
break;
case TEAM_PNTS_REWARD:
if (gUnknown_203B310->unk10->teamRankPtsReward == 0) {
SetRewardSceneState(REWARD_EXIT);
}
else {
gUnknown_203B310->currTeamRank = GetRescueTeamRank();
AddToTeamRankPts(gUnknown_203B310->unk10->teamRankPtsReward);
PlaySound(0xcb);
if (gUnknown_203B310->currTeamRank != GetRescueTeamRank()) {
gUnknown_203B310->nextState = NEW_TEAM_RANK;
}
else {
gUnknown_203B310->nextState = REWARD_EXIT;
}
gFormatArgs[0] = gUnknown_203B310->unk10->teamRankPtsReward;
CreateDialogueBoxAndPortrait(gUnknown_80E0670,0,0,0x101);
}
break;
case NEW_TEAM_RANK:
PlaySound(0xc9);
gUnknown_203B310->nextState = REWARD_EXIT;
rankString = GetTeamRankString(gUnknown_203B310->currTeamRank);
strcpy(gFormatBuffer_Monsters[2],rankString);
rankString = GetTeamRankString(GetRescueTeamRank());
strcpy(gFormatBuffer_Monsters[3],rankString);
CreateDialogueBoxAndPortrait(gUnknown_80E06A8,0,0,0x101);
break;
case REWARD_EXIT:
break;
}
}
case MR_STATE_PREP_ITEM_REWARD: {
u8 itemID = sMRWork->rewards->itemRewards[0];
void sub_802F6FC(void)
{
switch(sub_801B6AC())
{
case 2:
case 3:
sub_801B72C();
SetRewardSceneState(NEXT_ITEM);
if (itemID != ITEM_NOTHING) {
if (sMRWork->rewards->moneyReward == 0) {
struct unkStruct_8090F58 local_20;
Item item;
item.id = itemID;
if (IsThrownItem(item.id))
item.quantity = sMRWork->rewards->quantity;
else
item.quantity = 0;
item.flags = ITEM_FLAG_EXISTS;
local_20.unk0 = 0;
local_20.unk4 = 0;
local_20.unk8 = 1;
sub_8090E14(gFormatBuffer_Items[1], &item, &local_20);
if (sMRWork->displayClientDialogueSprite) {
CreateDialogueBoxAndPortrait(gUnknown_80E0640, 0, &sMRWork->monPortrait, 0x10d);
sMRWork->nextState = MR_STATE_GIVE_ITEM_REWARD;
}
else {
MR_SetState(MR_STATE_GIVE_ITEM_REWARD);
}
}
else {
MR_SetState(MR_STATE_GIVE_ITEM_REWARD);
}
}
else {
MR_SetState(MR_STATE_TEAM_PNTS_REWARD);
}
break;
case 0:
case 1:
}
case MR_STATE_GIVE_ITEM_REWARD: {
if (sMRWork->rewards->itemRewards[sMRWork->itemRewardIndex] == ITEM_NOTHING) {
MR_SetState(MR_STATE_NEXT_ITEM);
}
else if (sMRWork->itemRewardIndex == 0 && sMRWork->rewards->moneyReward == 0) {
sub_801B60C(0, sMRWork->rewards->itemRewards[0], sMRWork->rewards->quantity);
}
else {
sub_801B60C(1, sMRWork->rewards->itemRewards[sMRWork->itemRewardIndex], sMRWork->rewards->quantity);
}
break;
}
case MR_STATE_NEXT_ITEM: {
sMRWork->itemRewardIndex++;
if (sMRWork->itemRewardIndex < MAX_ITEM_REWARDS)
MR_SetState(MR_STATE_GIVE_ITEM_REWARD);
else
MR_SetState(MR_STATE_TEAM_PNTS_REWARD);
break;
}
case MR_STATE_TEAM_PNTS_REWARD: {
if (sMRWork->rewards->teamRankPtsReward == 0) {
MR_SetState(MR_STATE_REWARD_EXIT);
}
else {
sMRWork->currTeamRank = GetRescueTeamRank();
AddToTeamRankPts(sMRWork->rewards->teamRankPtsReward);
PlaySound(203);
if (sMRWork->currTeamRank != GetRescueTeamRank())
sMRWork->nextState = MR_STATE_NEW_TEAM_RANK;
else
sMRWork->nextState = MR_STATE_REWARD_EXIT;
gFormatArgs[0] = sMRWork->rewards->teamRankPtsReward;
CreateDialogueBoxAndPortrait(gUnknown_80E0670, 0, 0, 0x101);
}
break;
}
case MR_STATE_NEW_TEAM_RANK: {
const u8 *rankString;
PlaySound(201);
sMRWork->nextState = MR_STATE_REWARD_EXIT;
rankString = GetTeamRankString(sMRWork->currTeamRank);
strcpy(gFormatBuffer_Monsters[2], rankString);
rankString = GetTeamRankString(GetRescueTeamRank());
strcpy(gFormatBuffer_Monsters[3], rankString);
CreateDialogueBoxAndPortrait(gUnknown_80E06A8, 0, 0, 0x101);
break;
}
case MR_STATE_REWARD_EXIT: {
break;
}
}
}
void ProceedToNextRewardSceneState(void)
static void sub_802F6FC(void)
{
switch (sub_801B6AC()) {
case 2:
case 3: {
sub_801B72C();
MR_SetState(MR_STATE_NEXT_ITEM);
break;
}
case 0:
case 1: {
break;
}
}
}
static void MR_ProceedToNextState(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
SetRewardSceneState(gUnknown_203B310->nextState);
}
if (sub_80144A4(&temp) == 0)
MR_SetState(sMRWork->nextState);
}

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "globaldata.h"
#include "code_800D090.h"
#include "code_8094F88.h"
#include "constants/communication_error_codes.h"
#include "constants/dungeon.h"
@ -36,7 +37,6 @@ extern void sub_800D494(void);
extern void sub_800D510(void);
extern void sub_800D520(void);
extern void sub_800D570(void);
extern u8 sub_800D588(void);
extern void sub_800D59C(void *, u32);
extern u8 sub_800D600(void);
extern void sub_800D670(s32 idx, void *dst, s32 size);
@ -312,7 +312,7 @@ static s32 sub_8037DF0(void)
sub_800D670(0, &iStack_10, 4);
sub_800D670(1, &iStack_c, 4);
if ((iStack_10 != 0) || (iStack_c != 0)) {
linkStatus = (!sub_800D588()) ? iStack_c : iStack_10;
linkStatus = !sub_800D588() ? iStack_c : iStack_10;
if (linkStatus == COMMS_GOOD) {
linkStatus = 0xe;
}
@ -326,8 +326,8 @@ static void sub_8037E38(unkStruct_8035D94 *param_1,unkStruct_8035D94 *param_2)
unkStruct_8035D94 *r4;
u32 load;
r4 = sub_800D588() == 0 ? param_2 : param_1;
r3 = sub_800D588() == 0 ? param_1 : param_2;
r4 = !sub_800D588() ? param_2 : param_1;
r3 = !sub_800D588() ? param_1 : param_2;
if (r4->itemIndex == r3->itemIndex) {
load = gTeamInventoryRef->teamStorage[r4->itemIndex];
@ -343,10 +343,9 @@ static void sub_8037E38(unkStruct_8035D94 *param_1,unkStruct_8035D94 *param_2)
static void sub_8037E90(unkStruct_203B480 *param_1, unkStruct_203B480 *param_2)
{
if(sub_800D588() == 0)
{
if (!sub_800D588())
param_2 = param_1;
}
param_2->mailType = 2;
sub_80951BC(param_2);
sub_8095274(param_2->unk10.unk10);
@ -361,14 +360,11 @@ static void sub_8037EBC(WonderMailStruct_203B2C0_sub *param_1, WonderMailStruct
unkStruct_203B480 *mail;
WonderMailStruct_203B2C0_sub *puVar2;
if(sub_800D588() == 0)
{
if (!sub_800D588())
puVar2 = param_1;
}
else
{
puVar2 = param_2;
}
mail = GetMailatIndex(GetMailIndex(1, (puVar2->mail).unk10.unk10));
*mail = (*puVar2).mail;
mail->mailType = 5;
@ -394,10 +390,9 @@ static void sub_8037F4C(unkStruct_203B480 *param_1, unkStruct_203B480 *param_2)
unkStruct_203B480 *mail;
MainMenu1Work *mainMenu;
if(sub_800D588() == 0)
{
if (!sub_800D588())
param_2 = param_1;
}
mail = GetMailatIndex(GetMailIndex(4, param_2->unk10.unk10));
*mail = *param_2;
mail->mailType = 6;
@ -438,8 +433,8 @@ static s32 sub_8038014(unkStruct_8035D94 *param_1,unkStruct_8035D94 *param_2)
unkStruct_8035D94 *r3;
unkStruct_8035D94 *r4;
r4 = sub_800D588() == 0 ? param_2 : param_1;
r3 = sub_800D588() == 0 ? param_1 : param_2;
r4 = !sub_800D588() ? param_2 : param_1;
r3 = !sub_800D588() ? param_1 : param_2;
if (r4->itemIndex == r3->itemIndex) {
r2 = gTeamInventoryRef->teamStorage[r4->itemIndex];
@ -468,10 +463,10 @@ static s32 sub_8038078(unkStruct_203B480 *param_1,unkStruct_203B480 *param_2)
u32 uVar2;
u32 uVar3;
if (sub_800D588() == 0) {
if (!sub_800D588())
param_2 = param_1;
}
uVar3 = (param_2->unk10).unk10;
uVar3 = param_2->unk10.unk10;
if (gUnknown_203B184 != NULL) {
uVar2 = gUnknown_203B184->unk050;
}
@ -491,9 +486,8 @@ static s32 sub_80380C4(unkStruct_203B480 *param_1,unkStruct_203B480 *param_2)
u32 uVar2;
unkStruct_203B480 *mail;
if (sub_800D588() == 0) {
if (!sub_800D588())
mail = param_1;
}
else
mail = param_2;
@ -518,9 +512,9 @@ static s32 sub_80380C4(unkStruct_203B480 *param_1,unkStruct_203B480 *param_2)
static s32 sub_803812C(unkStruct_203B480 *param_1, unkStruct_203B480 *param_2)
{
if (sub_800D588() == 0) {
if (!sub_800D588())
param_2 = param_1;
}
if (HasMail(1, (param_2->unk10).unk10)) {
return COMMS_GOOD;
}

View File

@ -334,26 +334,26 @@ void CreateRescueDescription(unkStruct_802C39C *param_1)
y += 12;
PrintStringOnWindow(10, y, gRewardText, param_1->unk0[0], 0);
switch (param_1->unk18.rewardType) {
switch (param_1->rewards.rewardType) {
case MONEY:
sprintfStatic(buf_1, gMissionRewardText[param_1->unk18.rewardType], param_1->unk18.moneyReward);
sprintfStatic(buf_1, gMissionRewardText[param_1->rewards.rewardType], param_1->rewards.moneyReward);
PrintStringOnWindow(68, y, buf_1, param_1->unk0[0], 0);
break;
case MONEY_EXTRA:
sprintfStatic(buf_1, gMissionRewardText[param_1->unk18.rewardType], param_1->unk18.moneyReward);
sprintfStatic(buf_1, gMissionRewardText[param_1->rewards.rewardType], param_1->rewards.moneyReward);
PrintStringOnWindow(68, y, buf_1, param_1->unk0[0], 0);
break;
case ITEM: // Item
case ITEM_EXTRA: // Item + ?
BufferItemName(gFormatBuffer_Items[0], param_1->unk18.itemRewards[0], NULL);
sprintfStatic(buf_1, gMissionRewardText[param_1->unk18.rewardType], gFormatBuffer_Items[0]);
BufferItemName(gFormatBuffer_Items[0], param_1->rewards.itemRewards[0], NULL);
sprintfStatic(buf_1, gMissionRewardText[param_1->rewards.rewardType], gFormatBuffer_Items[0]);
PrintStringOnWindow(68, y, buf_1, param_1->unk0[0], 0);
break;
case 4: // Friend Area
PrintStringOnWindow(68, y, gMissionRewardText[param_1->unk18.rewardType], param_1->unk0[0], 0);
PrintStringOnWindow(68, y, gMissionRewardText[param_1->rewards.rewardType], param_1->unk0[0], 0);
break;
default:
PrintStringOnWindow(68, y, gMissionRewardText[param_1->unk18.rewardType], param_1->unk0[0], 0);
PrintStringOnWindow(68, y, gMissionRewardText[param_1->rewards.rewardType], param_1->unk0[0], 0);
break;
}

View File

@ -110,8 +110,7 @@ u32 HelperPelipperCallback(void)
void CleanHelperPelipper(void)
{
if (sPostOfficeHelper != NULL) {
if (sPostOfficeHelper->monPortrait.faceFile != NULL)
CloseFile(sPostOfficeHelper->monPortrait.faceFile);
TRY_CLOSE_FILE(sPostOfficeHelper->monPortrait.faceFile);
FREE_AND_SET_NULL(sPostOfficeHelper);
}
}

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "globaldata.h"
#include "bg_control.h"
#include "code_800D090.h"
#include "crt0.h"
#include "debug.h"
#include "input.h"
@ -30,10 +31,6 @@ EWRAM_INIT s16 gUnknown_203B0AE = {-1};
EWRAM_INIT s16 gUnknown_203B0B0 = {-1}; // Written to but never read
EWRAM_INIT s16 gUnknown_203B0B2 = {-1}; // Written to but never read
// code_800D090.s
extern void sub_800D6AC(void);
extern void sub_800D7D0(void);
static void UpdateBGControlRegisters(void);
static void VBlankIntr(void);
static void VCountIntr(void);

View File

@ -6,8 +6,8 @@
#include "event_flag.h"
#include "strings.h"
EWRAM_INIT struct RescueTeamData *gRescueTeamInfoRef = {NULL};
EWRAM_DATA struct RescueTeamData gRescueTeamInfo = {0};
EWRAM_INIT RescueTeamData *gRescueTeamInfoRef = { NULL };
EWRAM_DATA RescueTeamData gRescueTeamInfo = { 0 };
static const s32 sRescueRankMaxPoints[MAX_TEAM_RANKS] = {
[NORMAL_RANK] = 50,
@ -24,7 +24,7 @@ void LoadRescueTeamInfo(void)
gRescueTeamInfoRef = &gRescueTeamInfo;
}
struct RescueTeamData *GetRescueTeamInfo(void)
RescueTeamData *GetRescueTeamInfo(void)
{
return &gRescueTeamInfo;
}
@ -36,70 +36,68 @@ void InitializeRescueTeamInfo(void)
gRescueTeamInfoRef->isTeamRenamed = FALSE;
}
void sub_80920B8(u8 *buffer)
void CopyTeamNameToBuffer(u8 *buffer)
{
s32 counter;
for (counter = 0; counter < TEAM_NAME_LENGTH; counter++) {
*buffer++ = gRescueTeamInfoRef->teamName[counter];
s32 i;
for (i = 0; i < TEAM_NAME_LENGTH; i++) {
*buffer++ = gRescueTeamInfoRef->teamName[i];
}
}
void sub_80920D8(u8 *buffer)
void StrncpyTeamName(u8 *buffer)
{
StrncpyCustom(buffer, gRescueTeamInfoRef->teamName, TEAM_NAME_LENGTH);
}
void SetRescueTeamName(u8 *buffer)
{
s32 counter;
for (counter = 0; counter < TEAM_NAME_LENGTH; counter++) {
gRescueTeamInfoRef->teamName[counter] = *buffer++;
s32 i;
for (i = 0; i < TEAM_NAME_LENGTH; i++) {
gRescueTeamInfoRef->teamName[i] = *buffer++;
}
}
s32 GetTeamRankPts(void)
{
return gRescueTeamInfoRef->teamRankPts;
return gRescueTeamInfoRef->teamRankPts;
}
s32 GetPtsToNextRank(void)
{
u8 teamRank;
u8 teamRank;
teamRank = GetRescueTeamRank();
if (teamRank == LUCARIO_RANK) {
return 0;
}
else
{
return (sRescueRankMaxPoints[teamRank] - gRescueTeamInfoRef->teamRankPts);
}
teamRank = GetRescueTeamRank();
if (teamRank == LUCARIO_RANK)
return 0;
return (sRescueRankMaxPoints[teamRank] - gRescueTeamInfoRef->teamRankPts);
}
// Unused
void SetTeamRankPoints(s32 newPts)
UNUSED static void SetTeamRankPoints(s32 newPts)
{
gRescueTeamInfoRef->teamRankPts = newPts;
}
void AddToTeamRankPts(s32 newPts)
{
gRescueTeamInfoRef->teamRankPts += newPts;
if (gRescueTeamInfoRef->teamRankPts > 99999999) {
gRescueTeamInfoRef->teamRankPts = 99999999;
}
gRescueTeamInfoRef->teamRankPts += newPts;
if (gRescueTeamInfoRef->teamRankPts > 99999999)
gRescueTeamInfoRef->teamRankPts = 99999999;
}
u8 GetRescueTeamRank(void)
{
s32 rank;
s32 rank;
for(rank = NORMAL_RANK; rank < MAX_TEAM_RANKS; rank++){
if (gRescueTeamInfoRef->teamRankPts < sRescueRankMaxPoints[rank]) {
return rank;
for (rank = NORMAL_RANK; rank < MAX_TEAM_RANKS; rank++){
if (gRescueTeamInfoRef->teamRankPts < sRescueRankMaxPoints[rank])
return rank;
}
}
return LUCARIO_RANK;
return LUCARIO_RANK;
}
const u8 *GetTeamRankString(u32 index)
@ -108,50 +106,50 @@ const u8 *GetTeamRankString(u32 index)
return gRescueTeamRanks[index_u8];
}
// Unused
bool8 GetIsTeamRenamed(void)
UNUSED static bool8 GetIsTeamRenamed(void)
{
return gRescueTeamInfoRef->isTeamRenamed;
}
u32 SaveRescueTeamInfo(u8 *param_1, u32 size)
u32 SaveRescueTeamInfo(u8 *buffer, u32 bufLen)
{
DataSerializer auStack36;
DataSerializer w;
u8 neg1;
u8 zero;
u8 *puVar2;
u8 *ptr;
neg1 = -1;
zero = 0;
InitBitWriter(&auStack36, param_1, size);
WriteBits(&auStack36, gRescueTeamInfoRef->teamName, 0x58);
WriteBits(&auStack36, (u8 *)&gRescueTeamInfoRef->teamRankPts, 0x20);
InitBitWriter(&w, buffer, bufLen);
WriteBits(&w, gRescueTeamInfoRef->teamName, (TEAM_NAME_LENGTH + 1) * 8);
WriteBits(&w, &gRescueTeamInfoRef->teamRankPts, sizeof(s32) * 8);
gRescueTeamInfoRef->isTeamRenamed = CheckQuest(QUEST_SET_TEAM_NAME);
if (gRescueTeamInfoRef->isTeamRenamed)
{
puVar2 = &neg1;
}
ptr = &neg1;
else
{
puVar2 = &zero;
}
WriteBits(&auStack36,puVar2,1);
FinishBitSerializer(&auStack36);
return auStack36.count;
ptr = &zero;
WriteBits(&w, ptr, 1);
FinishBitSerializer(&w);
return w.count;
}
u32 ReadRescueTeamInfo(u8 *param_1, u32 size)
u32 ReadRescueTeamInfo(u8 *buffer, u32 bufLen)
{
DataSerializer auStack32;
u8 byteArray[4];
DataSerializer r;
u8 tempBuf[4];
InitBitReader(&auStack32, param_1, size);
ReadBits(&auStack32, gRescueTeamInfoRef->teamName, 0x58);
ReadBits(&auStack32, &gRescueTeamInfoRef->teamRankPts, 0x20);
ReadBits(&auStack32, byteArray, 1);
gRescueTeamInfoRef->isTeamRenamed = byteArray[0] & 1;
FinishBitSerializer(&auStack32);
return auStack32.count;
InitBitReader(&r, buffer, bufLen);
ReadBits(&r, gRescueTeamInfoRef->teamName, (TEAM_NAME_LENGTH + 1) * 8);
ReadBits(&r, &gRescueTeamInfoRef->teamRankPts, sizeof(s32) * 8);
ReadBits(&r, tempBuf, 1);
gRescueTeamInfoRef->isTeamRenamed = tempBuf[0] & 1;
FinishBitSerializer(&r);
return r.count;
}

View File

@ -131,8 +131,7 @@ u32 GetSavePakStatus(void)
void FinishWriteSavePak(void)
{
if (sSavePakWrite != NULL) {
if (sSavePakWrite->monPortrait.faceFile != NULL)
CloseFile(sSavePakWrite->monPortrait.faceFile);
TRY_CLOSE_FILE(sSavePakWrite->monPortrait.faceFile);
FREE_AND_SET_NULL(sSavePakWrite);
}
sub_80993E4();

View File

@ -713,7 +713,7 @@ const u8 *FormatString(const u8 *str, u8 *dst, u8 *dstMax, u16 flags)
case 't':
str++;
if (CheckQuest(QUEST_SET_TEAM_NAME)) {
sub_80920D8(sFormatBuffer_TeamName);
StrncpyTeamName(sFormatBuffer_TeamName);
}
else {
InlineStrcpy(sFormatBuffer_TeamName, "????");

View File

@ -10,7 +10,6 @@
#include "code_8015080.h"
#include "code_801B60C.h"
#include "code_801D014.h"
#include "code_802DB28.h"
#include "code_803B050.h"
#include "code_80958E8.h"
#include "code_8099360.h"
@ -56,6 +55,7 @@
#include "text_2.h"
#include "text_3.h"
#include "textbox.h"
#include "thank_you_messages.h"
#include "thank_you_wonder_mail.h"
#include "wigglytuff_shop1.h"
#include "wigglytuff_shop3.h"
@ -1139,9 +1139,9 @@ static const unkStruct_3001B64_unk418 gUnknown_8116228 =
static const unkStruct_3001B64_unk418 gUnknown_8116238 =
{
.unk0 = 1,
.unk4 = sub_802B2D4,
.unk8 = sub_802B3B8,
.unkC = sub_802B358,
.unk4 = WM2_Create,
.unk8 = WM2_Destroy,
.unkC = WM2_Update,
};
static const unkStruct_3001B64_unk418 gUnknown_8116248 =
@ -1180,8 +1180,8 @@ static const unkStruct_3001B64_unk418 gUnknown_8116288 =
{
.unk0 = 1,
.unk4 = NULL,
.unk8 = sub_802DC00,
.unkC = sub_802DBD4,
.unk8 = TYM_Destroy,
.unkC = TYM_Update,
};
// These 3 are identical
@ -1683,7 +1683,7 @@ static bool8 sub_809B648(void)
if (!local_18.unk0) {
return 0;
}
else if (!sub_802DB28(local_1c,local_33)) {
else if (!TYM_Create(local_1c,local_33)) {
return 0;
}
else {

243
src/thank_you_messages.c Normal file
View File

@ -0,0 +1,243 @@
#include "global.h"
#include "globaldata.h"
#include "structs/str_mission_rewards.h"
#include "structs/str_mon_portrait.h"
#include "structs/str_text.h"
#include "structs/str_wonder_mail.h"
#include "code_803C1D0.h"
#include "code_80958E8.h"
#include "exclusive_pokemon.h"
#include "input.h"
#include "items.h"
#include "memory.h"
#include "mission_reward.h"
#include "pokemon.h"
#include "string_format.h"
#include "text_1.h"
#include "thank_you_messages.h"
enum TYM_State
{
TYM_STATE_0,
TYM_STATE_1,
TYM_STATE_2,
TYM_STATE_3,
TYM_STATE_4,
TYM_STATE_5,
TYM_STATE_6,
TYM_STATE_7,
};
// Size: 0xA8
typedef struct TYM_Work
{
/* 0x0 */ u32 state; // See enum "TYM_State"
/* 0x4 */ u32 fallbackState; // See enum "TYM_State"
/* 0x8 */ MissionRewards rewards;
/* 0x30 */ u8 jobSlotIndex;
/* 0x34 */ WonderMail *jobInfo;
/* 0x38 */ MonPortraitMsg monPortrait;
/* 0x48 */ WindowTemplates windows;
} TYM_Work;
EWRAM_INIT static TYM_Work *sTYMWork = { NULL };
#include "data/thank_you_messages.h"
static void TYM_InitStateDialogue(void);
static void TYM_InitStateWindows(void);
static void TYM_ProceedToNextState(void);
static void TYM_SetState(u32 newState);
static void sub_802DE44(void);
bool8 TYM_Create(u8 jobSlotIndex, u8 dungeon)
{
struct unkStruct_8096AF8 local_18;
sub_8096AF8(&local_18, jobSlotIndex, dungeon);
if (!local_18.unk0)
return FALSE;
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sTYMWork = MemoryAlloc(sizeof(TYM_Work), MEMALLOC_GROUP_8);
sTYMWork->jobSlotIndex = jobSlotIndex;
sTYMWork->jobInfo = GetJobSlotInfo(jobSlotIndex);
sub_8096EEC(sTYMWork->jobInfo);
sub_803C21C(sTYMWork->jobInfo, &sTYMWork->rewards);
sTYMWork->monPortrait.faceFile = GetDialogueSpriteDataPtr(sTYMWork->jobInfo->clientSpecies);
sTYMWork->monPortrait.faceData = NULL;
sTYMWork->monPortrait.spriteId = 0;
sTYMWork->monPortrait.flip = FALSE;
sTYMWork->monPortrait.unkE = 0;
sTYMWork->monPortrait.pos.x = 2;
sTYMWork->monPortrait.pos.y = 8;
if (sTYMWork->monPortrait.faceFile != NULL)
sTYMWork->monPortrait.faceData = (PortraitGfx *)sTYMWork->monPortrait.faceFile->data;
TYM_SetState(TYM_STATE_0);
return TRUE;
}
u32 TYM_Update(void)
{
switch (sTYMWork->state) {
case TYM_STATE_7: {
sTYMWork->jobInfo->mailType = WONDER_MAIL_TYPE_OKD;
return 3;
}
case TYM_STATE_6: {
sub_802DE44();
return 0;
}
default: {
TYM_ProceedToNextState();
return 0;
}
}
}
void TYM_Destroy(void)
{
if (sTYMWork != NULL) {
TRY_CLOSE_FILE(sTYMWork->monPortrait.faceFile);
FREE_AND_SET_NULL(sTYMWork);
}
}
static void TYM_SetState(u32 newState)
{
sTYMWork->state = newState;
TYM_InitStateWindows();
TYM_InitStateDialogue();
}
static void TYM_InitStateWindows(void)
{
s32 i;
RestoreSavedWindows(&sTYMWork->windows);
switch (sTYMWork->state) {
case TYM_STATE_0:
case TYM_STATE_7: {
for (i = 0; i < MAX_WINDOWS; i++)
sTYMWork->windows.id[i] = sDummyWinTemplate;
break;
}
}
ResetUnusedInputStruct();
ShowWindows(&sTYMWork->windows, TRUE, TRUE);
}
static void TYM_InitStateDialogue(void)
{
switch (sTYMWork->state) {
case TYM_STATE_0: {
u8 *speciesText;
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, sTYMWork->jobInfo->clientSpecies);
CopyYellowMonsterNametoBuffer(gFormatBuffer_Monsters[7], sTYMWork->jobInfo->clientSpecies);
speciesText = GetMonSpecies(sTYMWork->jobInfo->clientSpecies);
strcpy(gFormatBuffer_Monsters[0], speciesText);
speciesText = GetMonSpecies(sTYMWork->jobInfo->targetSpecies);
strcpy(gFormatBuffer_Monsters[1], speciesText);
UnlockExclusivePokemon(sTYMWork->jobInfo->clientSpecies);
BufferItemName(gFormatBuffer_Items[0], sTYMWork->jobInfo->targetItem, NULL);
sTYMWork->fallbackState = TYM_STATE_6;
switch (sTYMWork->jobInfo->missionType) {
case WONDER_MAIL_MISSION_TYPE_DELIVER_ITEM: {
TYM_SetState(TYM_STATE_5);
break;
}
case WONDER_MAIL_MISSION_TYPE_FIND_ITEM: {
TYM_SetState(TYM_STATE_4);
break;
}
case WONDER_MAIL_MISSION_TYPE_RESCUE_TARGET: {
TYM_SetState(TYM_STATE_2);
UnlockExclusivePokemon(sTYMWork->jobInfo->targetSpecies);
break;
}
case WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT: {
TYM_SetState(TYM_STATE_3);
UnlockExclusivePokemon(sTYMWork->jobInfo->targetSpecies);
break;
}
default:
case WONDER_MAIL_MISSION_TYPE_RESCUE_CLIENT: {
TYM_SetState(TYM_STATE_1);
break;
}
}
break;
}
case TYM_STATE_1: {
CreateDialogueBoxAndPortrait(sThanksForRescuingMe, 0, &sTYMWork->monPortrait, 0x10D);
break;
}
case TYM_STATE_2: {
CreateDialogueBoxAndPortrait(sThanksForRescuingThem, 0, &sTYMWork->monPortrait, 0x10D);
break;
}
case TYM_STATE_3: {
CreateDialogueBoxAndPortrait(sThanksForEscortingMe, 0, &sTYMWork->monPortrait, 0x10D);
break;
}
case TYM_STATE_5: {
CreateDialogueBoxAndPortrait(sThanksForDelivering, 0, &sTYMWork->monPortrait, 0x10D);
break;
}
case TYM_STATE_4: {
s32 index = FindItemInInventory(sTYMWork->jobInfo->targetItem);
if (index != -1) {
ShiftItemsDownFrom(index);
FillInventoryGaps();
}
CreateDialogueBoxAndPortrait(sThanksForGetting, 0, &sTYMWork->monPortrait, 0x10D);
break;
}
case TYM_STATE_6: {
MR_Create(&sTYMWork->rewards, TRUE);
break;
}
case TYM_STATE_7:
default: {
break;
}
}
}
static void sub_802DE44(void)
{
switch (MR_Update()) {
case 2:
case 3: {
MR_Destroy();
TYM_SetState(TYM_STATE_7);
break;
}
case 0:
case 1: {
break;
}
}
}
static void TYM_ProceedToNextState(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0)
TYM_SetState(sTYMWork->fallbackState);
}

View File

@ -5,7 +5,6 @@
#include "music_util.h"
#include "code_801B3C0.h"
#include "code_801C8C4.h"
#include "code_802F204.h"
#include "code_8031D70.h"
#include "code_803C1B4.h"
#include "code_8094F88.h"
@ -15,6 +14,7 @@
#include "main_menu1.h"
#include "memory.h"
#include "menu_input.h"
#include "mission_reward.h"
#include "other_menus2.h"
#include "pokemon.h"
#include "rescue_password_menu.h"
@ -214,7 +214,6 @@ extern void sub_802A9FC();
extern void sub_802A828();
extern void sub_802A850();
extern void SetThankYouMailMenuState(u32);
extern u8 sub_800D588(void);
extern void sub_8011C28(u32);
@ -411,7 +410,7 @@ void CleanThankYouMailPelipper(void)
sub_801CBB8();
NamingScreen_Free();
sub_8031E10();
sub_802F2C0();
MR_Destroy();
}
}
@ -1208,10 +1207,10 @@ void sub_802AB7C(void)
void sub_802AB98(void)
{
const char *monName;
switch(sub_802F298())
switch(MR_Update())
{
case 3:
sub_802F2C0();
MR_Destroy();
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER);
monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(gFormatBuffer_Monsters[0], monName);
@ -1308,7 +1307,7 @@ void UpdateThankYouMailText(void)
case 6:
case 7:
sUnknown_203B2C4->linkError = sub_80381F4(sUnknown_203B2C4->unk40,&sUnknown_203B2C4->unk1B8,&sUnknown_203B2C4->unk1E8);
if ( sub_800D588() != '\0') {
if (sub_800D588()) {
sUnknown_203B2C4->unk430 = sUnknown_203B2C4->unk1E8.unk10.unk10;
}
else {
@ -1365,26 +1364,27 @@ void UpdateThankYouMailText(void)
break;
}
break;
case 0x22:
case 0x22: {
monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(sUnknown_203B2C4->unk53C.clientName,monName); // 0x53C
sUnknown_203B2C4->unk53C.clientSpecies = MONSTER_PELIPPER; // 0x550
sUnknown_203B2C4->unk53C.rewardType = 2; // 0x552
sUnknown_203B2C4->unk53C.moneyReward = 0; // 0x554
mailIndex = GetMailIndex(6,sUnknown_203B2C4->unk430);
strcpy(sUnknown_203B2C4->rewards.clientName, monName);
sUnknown_203B2C4->rewards.clientSpecies = MONSTER_PELIPPER;
sUnknown_203B2C4->rewards.rewardType = 2;
sUnknown_203B2C4->rewards.moneyReward = 0;
mailIndex = GetMailIndex(6, sUnknown_203B2C4->unk430);
mail = GetMailatIndex(mailIndex);
itemIndex = mail->item.id;
if (itemIndex != ITEM_NOTHING)
sUnknown_203B2C4->unk53C.itemRewards[0] = itemIndex; // unk558
sUnknown_203B2C4->rewards.itemRewards[0] = itemIndex;
else
sUnknown_203B2C4->unk53C.itemRewards[0] = ITEM_NOTHING; // unk558
sUnknown_203B2C4->unk53C.quantity = 1; // unk55B
sUnknown_203B2C4->unk53C.teamRankPtsReward = GetDungeonTeamRankPts(&mail->dungeonSeed.location, 0); // unk560
sUnknown_203B2C4->unk53C.itemRewards[1] = 0; // unk559
sUnknown_203B2C4->unk53C.itemRewards[2] = 0; // unk55A
sUnknown_203B2C4->unk53C.friendAreaReward = 0; // unk55C
sub_802F204(&sUnknown_203B2C4->unk53C,0); // unk53C
sUnknown_203B2C4->rewards.itemRewards[0] = ITEM_NOTHING;
sUnknown_203B2C4->rewards.quantity = 1;
sUnknown_203B2C4->rewards.teamRankPtsReward = GetDungeonTeamRankPts(&mail->dungeonSeed.location, 0);
sUnknown_203B2C4->rewards.itemRewards[1] = 0;
sUnknown_203B2C4->rewards.itemRewards[2] = 0;
sUnknown_203B2C4->rewards.friendAreaReward = 0;
MR_Create(&sUnknown_203B2C4->rewards, FALSE);
break;
}
case COMMUNICATING_THANK_YOU_MAIL:
// Communicating..
nullsub_23(FALSE);

View File

@ -4,7 +4,6 @@
#include "constants/wonder_mail.h"
#include "adventure_info.h"
#include "code_800D090.h"
#include "code_802F204.h"
#include "code_803C1B4.h"
#include "code_8094F88.h"
#include "code_8099360.h"
@ -14,6 +13,7 @@
#include "input.h"
#include "memory.h"
#include "menu_input.h"
#include "mission_reward.h"
#include "pokemon.h"
#include "pokemon_mail.h"
#include "rescue_team_info.h"
@ -23,36 +23,34 @@
#include "text_1.h"
#include "wonder_mail_2.h"
struct unkStruct_203B2C8
// This file appears to be for the rescue mission success reward
enum WM2State
{
// size: 0x140
/* 0x0 */ u8 currState;
WM2STATE_WELCOMEBACK,
WM2STATE_REWARD,
WM2STATE_MUSTSAVE,
WM2STATE_SAVING,
WM2STATE_SEEYA,
WM2STATE_DONE,
};
// Size: R=0x140 | B=?
typedef struct WonderMail2Work
{
/* 0x0 */ u8 state; // See enum "WM2State"
/* 0x1 */ u8 unk1;
/* 0x4 */ MonPortraitMsg monPortrait;
/* 0x14 */ u8 teamName[4]; // Figure out size of this buffer
u8 fill18[0x114 - 0x18];
unkStruct_802F204 unk114;
u32 fill13C;
};
/* 0x14 */ u8 teamName[0x100];
/* 0x114 */ MissionRewards rewards;
/* 0x13C */ u32 unused13C;
} WonderMail2Work;
enum States {
INIT_STATE,
EXIT_STATE = 5
};
static EWRAM_INIT WonderMail2Work *sWM2Work = { NULL };
static EWRAM_INIT struct unkStruct_203B2C8 *sUnknown_203B2C8 = {NULL};
static ALIGNED(4) const u8 sTeamNamePlaceholder[] = _("????");
extern void sub_802B548(u32);
extern void sub_802B560(void);
extern void sub_802B57C(void);
extern void sub_802B5B8(void);
extern void sub_802B5FC(void);
extern void sub_802B624(void);
ALIGNED(4) const char gRescueTeamNamePlaceholder[] = "????";
ALIGNED(4) const char gUnknown_80DF9F8[] = _(
static ALIGNED(4) const u8 sWelcomeBackText[] = _(
" Oh, hello!\n"
"Your rescue mission went well, didn't it?\n"
"I wouldn't expect any less, {COLOR CYAN_G}%s{RESET}!{EXTRA_MSG}"
@ -60,200 +58,212 @@ ALIGNED(4) const char gUnknown_80DF9F8[] = _(
"Here is your reward from the Pokémon\n"
"Rescue Organization!");
ALIGNED(4) const char gUnknown_80DFAA8[] = _(
static ALIGNED(4) const u8 sMustSaveText[] = _(
" I hope you will keep on\n"
"rescuing your friends in\n"
"dire straits.{EXTRA_MSG}"
" And now, I must save\n"
"your adventure.");
ALIGNED(4) const char gUnknown_80DFB14[] = _(
static ALIGNED(4) const u8 sSeeyaText[] = _(
" Oh, yes, that's right.\n"
"Please don't forget to send an {COLOR CYAN_G}A-OK Mail{RESET}\n"
"to the friend you just rescued.{EXTRA_MSG}"
" Please give me a shout if\n"
"you would like to send {COLOR CYAN_G}A-OK Mail{RESET}.");
u8 sub_802B2D4(void)
{
OpenedFile *faceFile;
static void WM2_SetState(u32 state);
static void WM2_Update_WelcomeBack(void);
static void WM2_Update_Reward(void);
static void WM2_Update_MustSave(void);
static void WM2_Update_Saving(void);
static void WM2_Update_Seeya(void);
bool8 WM2_Create(void)
{
OpenedFile *faceFile;
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sWM2Work = MemoryAlloc(sizeof(WonderMail2Work), MEMALLOC_GROUP_8);
MemoryFill8(sWM2Work, 0, sizeof(WonderMail2Work));
sWM2Work->unk1 = -1;
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER);
faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER);
sWM2Work->monPortrait.faceFile = faceFile;
sWM2Work->monPortrait.faceData = (PortraitGfx *)faceFile->data;
sWM2Work->monPortrait.spriteId = 0;
sWM2Work->monPortrait.flip = FALSE;
sWM2Work->monPortrait.unkE = 0;
sWM2Work->monPortrait.pos.x = 2;
sWM2Work->monPortrait.pos.y = 8;
if (sub_8099394(&sWM2Work->unk1) != TRUE)
return FALSE;
WM2_SetState(WM2STATE_WELCOMEBACK);
return TRUE;
}
u32 WM2_Update(void)
{
switch (sWM2Work->state) {
case WM2STATE_WELCOMEBACK: {
WM2_Update_WelcomeBack();
break;
}
case WM2STATE_REWARD: {
WM2_Update_Reward();
break;
}
case WM2STATE_MUSTSAVE: {
WM2_Update_MustSave();
break;
}
case WM2STATE_SAVING: {
WM2_Update_Saving();
break;
}
case WM2STATE_SEEYA: {
WM2_Update_Seeya();
break;
}
case WM2STATE_DONE: {
return 3;
}
}
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sUnknown_203B2C8 = MemoryAlloc(sizeof(struct unkStruct_203B2C8), MEMALLOC_GROUP_8);
MemoryFill8(sUnknown_203B2C8,0,sizeof(struct unkStruct_203B2C8));
sUnknown_203B2C8->unk1 = -1;
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER);
faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER);
sUnknown_203B2C8->monPortrait.faceFile = faceFile;
sUnknown_203B2C8->monPortrait.faceData = (PortraitGfx *) faceFile->data;
sUnknown_203B2C8->monPortrait.spriteId = 0;
sUnknown_203B2C8->monPortrait.flip = FALSE;
sUnknown_203B2C8->monPortrait.unkE = 0;
sUnknown_203B2C8->monPortrait.pos.x = 2;
sUnknown_203B2C8->monPortrait.pos.y = 8;
if (sub_8099394(&sUnknown_203B2C8->unk1) != 1) {
return 0;
}
else
{
sub_802B548(INIT_STATE);
return 1;
}
}
u32 sub_802B358(void)
void WM2_Destroy(void)
{
switch(sUnknown_203B2C8->currState) {
case INIT_STATE:
sub_802B560();
break;
case 1:
sub_802B57C();
break;
case 2:
sub_802B5B8();
break;
case 3:
sub_802B5FC();
break;
case 4:
sub_802B624();
break;
case EXIT_STATE:
return 3;
}
return 0;
}
void sub_802B3B8(void)
{
if (sUnknown_203B2C8 != NULL) {
CloseFile(sUnknown_203B2C8->monPortrait.faceFile);
FREE_AND_SET_NULL(sUnknown_203B2C8);
if (sWM2Work != NULL) {
CloseFile(sWM2Work->monPortrait.faceFile);
FREE_AND_SET_NULL(sWM2Work);
}
}
void nullsub_132(void)
static void WM2_InitStateWindows(void)
{
}
void sub_802B3E0(void)
static void WM2_InitStateDialogue(void)
{
unkStruct_203B480 *mail;
char *monName;
char teamNameBuffer[40];
switch (sWM2Work->state) {
case WM2STATE_WELCOMEBACK: {
u8 teamNameBuffer[40];
switch(sUnknown_203B2C8->currState) {
case INIT_STATE:
if (CheckQuest(QUEST_SET_TEAM_NAME)) {
// Copy Team Name to buffer
sub_80920D8(teamNameBuffer);
if (CheckQuest(QUEST_SET_TEAM_NAME))
StrncpyTeamName(teamNameBuffer);
else
strcpy(teamNameBuffer, sTeamNamePlaceholder);
sprintfStatic(sWM2Work->teamName, sWelcomeBackText, teamNameBuffer);
CreateDialogueBoxAndPortrait(sWM2Work->teamName, 0, &sWM2Work->monPortrait, 0x10D);
break;
}
else {
// Copy "????" to buffer
strcpy(teamNameBuffer,gRescueTeamNamePlaceholder);
case WM2STATE_REWARD: {
unkStruct_203B480 *mail;
u8 *monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(sWM2Work->rewards.clientName, monName);
sWM2Work->rewards.clientSpecies = MONSTER_PELIPPER;
sWM2Work->rewards.rewardType = 2;
sWM2Work->rewards.moneyReward = 0;
IncrementFriendRescueSuccesses();
mail = GetMailatIndex(sWM2Work->unk1);
sub_803C37C(&mail->dungeonSeed.location, 0, sWM2Work->rewards.itemRewards);
sWM2Work->rewards.teamRankPtsReward = GetDungeonTeamRankPts(&mail->dungeonSeed.location, 0);
sWM2Work->rewards.itemRewards[1] = ITEM_NOTHING;
sWM2Work->rewards.itemRewards[2] = ITEM_NOTHING;
sWM2Work->rewards.quantity = 10;
sWM2Work->rewards.friendAreaReward = 0;
MR_Create(&sWM2Work->rewards, FALSE);
break;
}
// Print and expand placeholders?
sprintfStatic(sUnknown_203B2C8->teamName,gUnknown_80DF9F8,teamNameBuffer);
// Display to screen with Pelipper face
CreateDialogueBoxAndPortrait(sUnknown_203B2C8->teamName, 0, &sUnknown_203B2C8->monPortrait, 0x10d);
break;
case 1:
monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(sUnknown_203B2C8->unk114.clientName, monName);
sUnknown_203B2C8->unk114.clientSpecies = MONSTER_PELIPPER;
sUnknown_203B2C8->unk114.rewardType = 2;
sUnknown_203B2C8->unk114.moneyReward = 0;
IncrementFriendRescueSuccesses();
mail = GetMailatIndex(sUnknown_203B2C8->unk1);
sub_803C37C(&mail->dungeonSeed.location, 0, sUnknown_203B2C8->unk114.itemRewards);
sUnknown_203B2C8->unk114.teamRankPtsReward = GetDungeonTeamRankPts(&mail->dungeonSeed.location, 0);
sUnknown_203B2C8->unk114.itemRewards[1] = ITEM_NOTHING;
sUnknown_203B2C8->unk114.itemRewards[2] = ITEM_NOTHING;
sUnknown_203B2C8->unk114.quantity = 10;
sUnknown_203B2C8->unk114.friendAreaReward = 0;
sub_802F204(&sUnknown_203B2C8->unk114, FALSE);
break;
case 2:
// I hope you will keep on rescuing your friends
// I must save your adventure
CreateDialogueBoxAndPortrait(gUnknown_80DFAA8, 0, &sUnknown_203B2C8->monPortrait, 0x10d);
break;
case 4:
// Oh yes, that's right. Please don't forget to send an A-OK Mail
// to the friend you just rescued
CreateDialogueBoxAndPortrait(gUnknown_80DFB14, 0, &sUnknown_203B2C8->monPortrait, 0x10d);
case 3:
case 5:
break;
}
case WM2STATE_MUSTSAVE: {
CreateDialogueBoxAndPortrait(sMustSaveText, 0, &sWM2Work->monPortrait, 0x10D);
break;
}
case WM2STATE_SEEYA: {
CreateDialogueBoxAndPortrait(sSeeyaText, 0, &sWM2Work->monPortrait, 0x10D);
break;
}
case WM2STATE_SAVING:
case WM2STATE_DONE: {
break;
}
}
}
void sub_802B548(u32 newState)
// state: See enum "WM2State"
static void WM2_SetState(u32 state)
{
sUnknown_203B2C8->currState = newState;
nullsub_132();
sub_802B3E0();
sWM2Work->state = state;
WM2_InitStateWindows();
WM2_InitStateDialogue();
}
void sub_802B560(void)
static void WM2_Update_WelcomeBack(void)
{
s32 temp;
if(sub_80144A4(&temp) == 0)
{
sub_802B548(1);
if (sub_80144A4(&temp) == 0)
WM2_SetState(WM2STATE_REWARD);
}
static void WM2_Update_Reward(void)
{
if (MR_Update() == 3) {
u8 *monName;
MR_Destroy();
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER);
monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(gFormatBuffer_Monsters[0], monName);
WM2_SetState(WM2STATE_MUSTSAVE);
}
}
void sub_802B57C(void)
static void WM2_Update_MustSave(void)
{
char *monName;
s32 temp;
if (sub_802F298() == 3) {
sub_802F2C0();
CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER);
monName = GetMonSpecies(MONSTER_PELIPPER);
strcpy(gFormatBuffer_Monsters[0], monName);
sub_802B548(2);
}
}
if (sub_80144A4(&temp) == 0) {
s32 u = sub_8011C34();
unkStruct_203B480 *mail = GetMailatIndex(sWM2Work->unk1);
void sub_802B5B8(void)
{
u32 uVar2;
unkStruct_203B480 *mail;
s32 temp;
mail->mailType = WONDER_MAIL_TYPE_AOK;
mail->unk28 = u;
if (sub_80144A4(&temp) == 0) {
uVar2 = sub_8011C34();
mail = GetMailatIndex(sUnknown_203B2C8->unk1);
mail->mailType = WONDER_MAIL_TYPE_AOK;
mail->unk28 = uVar2;
sub_802B548(3);
sub_8011C28(1);
PrepareSavePakWrite(MONSTER_NONE);
}
}
void sub_802B5FC(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
if (!WriteSavePak()) {
FinishWriteSavePak();
sub_802B548(4);
WM2_SetState(WM2STATE_SAVING);
sub_8011C28(1);
PrepareSavePakWrite(MONSTER_NONE);
}
}
}
void sub_802B624(void)
static void WM2_Update_Saving(void)
{
s32 temp;
s32 temp;
if (sub_80144A4(&temp) == 0) {
sub_802B548(EXIT_STATE);
}
if (sub_80144A4(&temp) == 0) {
if (!WriteSavePak()) {
FinishWriteSavePak();
WM2_SetState(WM2STATE_SEEYA);
}
}
}
static void WM2_Update_Seeya(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0)
WM2_SetState(WM2STATE_DONE);
}

View File

@ -1,7 +1,6 @@
#include "global.h"
#include "globaldata.h"
#include "structs/str_802C39C.h"
#include "text_3.h"
#include "code_802DE84.h"
#include "code_803B050.h"
#include "common_strings.h"
@ -9,11 +8,20 @@
#include "memory.h"
#include "menu_input.h"
#include "text_1.h"
#include "text_3.h"
#include "wonder_mail_3_mid.h"
#include "wonder_mail_802CDD4.h"
enum MenuActions
{
CANCEL_ACTION = 1,
SEND_ACTION,
INFO_ACTION
};
// Size: 0x150
struct unkStruct_203B30C
{
// size: 0x150
s32 state;
u8 unk4;
unkStruct_802C39C unk8;
@ -21,24 +29,10 @@ struct unkStruct_203B30C
MenuItem unkB0[8];
WindowTemplates unkF0;
};
static EWRAM_INIT struct unkStruct_203B30C *gUnknown_203B30C = {NULL};
extern void sub_802EFEC(u32);
extern void sub_802F148(void);
extern void sub_802F184(void);
extern void sub_802F1E8(void);
extern void sub_802F004();
extern void sub_802F088();
extern void sub_802F108(void);
static EWRAM_INIT struct unkStruct_203B30C *gUnknown_203B30C = { NULL };
const WindowTemplate gUnknown_80E03C4 = {
0,
0x03,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
NULL
};
const WindowTemplate gUnknown_80E03C4 = WIN_TEMPLATE_DUMMY;
const WindowTemplate gUnknown_80E03DC = {
0,
0x03,
@ -58,11 +52,13 @@ const WindowTemplate gUnknown_80E03F4 = {
const u8 gUnknown_80E040C[] = "Send";
enum MenuActions {
CANCEL_ACTION = 1,
SEND_ACTION,
INFO_ACTION
};
static void sub_802EFEC(u32);
static void sub_802F148(void);
static void sub_802F184(void);
static void sub_802F1E8(void);
static void sub_802F004();
static void sub_802F088();
static void sub_802F108(void);
u32 sub_802EF48(void)
{
@ -71,7 +67,7 @@ u32 sub_802EF48(void)
return 1;
}
u32 sub_802EF6C(void)
UNUSED static u32 sub_802EF6C(void)
{
switch(gUnknown_203B30C->state)
{
@ -94,28 +90,27 @@ u32 sub_802EF6C(void)
return 0;
}
u8 sub_802EFC4(void)
UNUSED static u8 sub_802EFC4(void)
{
return gUnknown_203B30C->unk4;
}
void sub_802EFD0(void)
UNUSED static void sub_802EFD0(void)
{
if(gUnknown_203B30C != NULL)
{
if (gUnknown_203B30C != NULL) {
MemoryFree(gUnknown_203B30C);
gUnknown_203B30C = NULL;
}
}
void sub_802EFEC(u32 newState)
static void sub_802EFEC(u32 newState)
{
gUnknown_203B30C->state = newState;
sub_802F004();
sub_802F088();
}
void sub_802F004(void)
static void sub_802F004(void)
{
s32 index;
@ -137,7 +132,7 @@ void sub_802F004(void)
ShowWindows(&gUnknown_203B30C->unkF0, TRUE, TRUE);
}
void sub_802F088(void)
static void sub_802F088(void)
{
unkStruct_803B344 *temp;
@ -163,7 +158,7 @@ void sub_802F088(void)
}
}
void sub_802F108(void)
static void sub_802F108(void)
{
s32 loopMax = 0;
@ -177,7 +172,7 @@ void sub_802F108(void)
gUnknown_203B30C->unkB0[loopMax].menuAction = CANCEL_ACTION;
}
void sub_802F148(void)
static void sub_802F148(void)
{
switch(sub_802CE5C(TRUE))
{
@ -195,7 +190,7 @@ void sub_802F148(void)
}
}
void sub_802F184(void)
static void sub_802F184(void)
{
s32 menuAction;
@ -221,7 +216,7 @@ void sub_802F184(void)
}
}
void sub_802F1E8(void)
static void sub_802F1E8(void)
{
switch(sub_802DEE0())
{

View File

@ -212,7 +212,7 @@ void sub_803092C(void)
local.clientSpecies = mail->clientSpecies;
local.targetSpecies = mail->clientSpecies;
local.targetItem = ITEM_NOTHING;
local.unk18.rewardType = MONEY1;
local.rewards.rewardType = MONEY1;
switch(mail->mailType)
{

View File

@ -59,30 +59,29 @@ static void sub_8030E48(void);
bool8 sub_8030D40(u8 mailIndex, s32 windowID)
{
gUnknown_203B324 = MemoryAlloc(sizeof(struct unkStruct_203B324), MEMALLOC_GROUP_8);
gUnknown_203B324->mailIndex = mailIndex;
ResetTouchScreenMenuInput(&gUnknown_203B324->unk0);
gUnknown_203B324->windowID = windowID;
gUnknown_203B324->unk14 = &gUnknown_203B324->unk18.id[windowID];
RestoreSavedWindows(&gUnknown_203B324->unk18);
gUnknown_203B324->unk18.id[gUnknown_203B324->windowID] = gUnknown_80E091C;
sub_8030DD4();
return TRUE;
gUnknown_203B324 = MemoryAlloc(sizeof(struct unkStruct_203B324), MEMALLOC_GROUP_8);
gUnknown_203B324->mailIndex = mailIndex;
ResetTouchScreenMenuInput(&gUnknown_203B324->unk0);
gUnknown_203B324->windowID = windowID;
gUnknown_203B324->unk14 = &gUnknown_203B324->unk18.id[windowID];
RestoreSavedWindows(&gUnknown_203B324->unk18);
gUnknown_203B324->unk18.id[gUnknown_203B324->windowID] = gUnknown_80E091C;
sub_8030DD4();
return TRUE;
}
u32 sub_8030DA0(void)
{
switch(sub_8012A64(&gUnknown_203B324->unk0, gUnknown_203B324->windowID))
{
case INPUT_B_BUTTON:
PlayMenuSoundEffect(MENU_SFX_BACK);
return 2;
case INPUT_A_BUTTON:
PlayMenuSoundEffect(MENU_SFX_ACCEPT);
return 3;
default:
return 0;
}
switch (sub_8012A64(&gUnknown_203B324->unk0, gUnknown_203B324->windowID)) {
case INPUT_B_BUTTON:
PlayMenuSoundEffect(MENU_SFX_BACK);
return 2;
case INPUT_A_BUTTON:
PlayMenuSoundEffect(MENU_SFX_ACCEPT);
return 3;
default:
return 0;
}
}
static void sub_8030DD4(void)
@ -93,14 +92,13 @@ static void sub_8030DD4(void)
void sub_8030DE4(void)
{
if(gUnknown_203B324 != NULL)
{
gUnknown_203B324->unk18.id[gUnknown_203B324->windowID] = gUnknown_80E0900;
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B324->unk18, TRUE, TRUE);
MemoryFree(gUnknown_203B324);
gUnknown_203B324 = NULL;
}
if (gUnknown_203B324 != NULL) {
gUnknown_203B324->unk18.id[gUnknown_203B324->windowID] = gUnknown_80E0900;
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B324->unk18, TRUE, TRUE);
MemoryFree(gUnknown_203B324);
gUnknown_203B324 = NULL;
}
}
static void sub_8030E2C(void)
@ -111,47 +109,49 @@ static void sub_8030E2C(void)
static void sub_8030E48(void)
{
u16 uVar2;
unkStruct_203B480 *mail;
unkStruct_802C39C stack;
u8 buffer [256];
u16 uVar2;
unkStruct_203B480 *mail;
unkStruct_802C39C stack;
u8 buffer[0x100];
mail = &gUnknown_203B480[gUnknown_203B324->mailIndex];
sub_80073B8(gUnknown_203B324->windowID);
stack.unk0[0] = gUnknown_203B324->windowID;
stack.mailTitleType = 7;
stack.mailMissionType = MISSION_TYPE_FRIEND_RESCUE;
stack.mailStatus = MAIL_STATUS_SUSPENDED;
stack.dungeonSeed = &mail->dungeonSeed;
stack.playerName = mail->playerName;
stack.clientSpecies = mail->clientSpecies;
stack.targetSpecies = mail->clientSpecies;
stack.targetItem = ITEM_NOTHING;
if (mail->item.id == ITEM_NOTHING) {
stack.unk18.rewardType = MONEY1;
}
else {
stack.unk18.rewardType = ITEM;
stack.unk18.itemRewards[0] = mail->item.id;
}
switch(mail->mailType)
{
case WONDER_MAIL_TYPE_SOS_1:
case WONDER_MAIL_TYPE_AOK:
stack.mailDescriptionType = 10;
break;
case WONDER_MAIL_TYPE_THANK_YOU:
stack.mailDescriptionType = 11;
break;
case WONDER_MAIL_TYPE_NONE:
default:
stack.mailDescriptionType = 9;
break;
}
CreateRescueDescription(&stack);
uVar2 = mail->unk10.unk10_u16 % 10000;
PrintStringOnWindow(10,0x68,gUnknown_80E0934,gUnknown_203B324->windowID,0); // ID:
sprintfStatic(buffer,gUnknown_80E0938,uVar2); // %-4d
PrintStringOnWindow(0x44,0x68,buffer,gUnknown_203B324->windowID,0);
sub_80073E0(gUnknown_203B324->windowID);
mail = &gUnknown_203B480[gUnknown_203B324->mailIndex];
sub_80073B8(gUnknown_203B324->windowID);
stack.unk0[0] = gUnknown_203B324->windowID;
stack.mailTitleType = 7;
stack.mailMissionType = MISSION_TYPE_FRIEND_RESCUE;
stack.mailStatus = MAIL_STATUS_SUSPENDED;
stack.dungeonSeed = &mail->dungeonSeed;
stack.playerName = mail->playerName;
stack.clientSpecies = mail->clientSpecies;
stack.targetSpecies = mail->clientSpecies;
stack.targetItem = ITEM_NOTHING;
if (mail->item.id == ITEM_NOTHING) {
stack.rewards.rewardType = MONEY1;
}
else {
stack.rewards.rewardType = ITEM;
stack.rewards.itemRewards[0] = mail->item.id;
}
switch (mail->mailType) {
case WONDER_MAIL_TYPE_SOS_1:
case WONDER_MAIL_TYPE_AOK:
stack.mailDescriptionType = 10;
break;
case WONDER_MAIL_TYPE_THANK_YOU:
stack.mailDescriptionType = 11;
break;
case WONDER_MAIL_TYPE_NONE:
default:
stack.mailDescriptionType = 9;
break;
}
CreateRescueDescription(&stack);
uVar2 = mail->unk10.unk10_u16 % 10000;
PrintStringOnWindow(10, 104, gUnknown_80E0934, gUnknown_203B324->windowID, 0); // ID:
sprintfStatic(buffer, gUnknown_80E0938, uVar2); // %-4d
PrintStringOnWindow(68, 104, buffer, gUnknown_203B324->windowID, 0);
sub_80073E0(gUnknown_203B324->windowID);
}

View File

@ -2,6 +2,7 @@
#include "globaldata.h"
#include "constants/communication_error_codes.h"
#include "constants/wonder_mail.h"
#include "code_800D090.h"
#include "code_801B3C0.h"
#include "code_801C8C4.h"
#include "code_8031D70.h"
@ -18,6 +19,7 @@
#include "save_write.h"
#include "string_format.h"
#include "text_1.h"
#include "wonder_mail_3_mid.h"
#include "wonder_mail_4.h"
#include "wonder_mail_5.h"
#include "wonder_mail_802D098.h"
@ -40,7 +42,7 @@
#define PASSWORD_INVALID 19
#define PASSWORD_ENTRY_SCREEN 18
// size: 0x49C
// Size: 0x49C
struct unkStruct_203B3E8
{
/* 0x0 */ u8 state;
@ -71,10 +73,7 @@ EWRAM_INIT struct unkStruct_203B3E8 *gUnknown_203B3E8 = {NULL};
#include "data/wonder_mail_main_menu.h"
extern void SetWonderMailMainMenuState(u8);
extern u8 sub_800D588(void);
extern void sub_802EF48(void);
static void SetWonderMailMainMenuState(u8);
void PrintWonderMailMainMenuError(u32);
void HandleWonderMailMainScreen(void);
void HandleGameLinkCableMenu(void);
@ -543,7 +542,7 @@ void WonderMailMainMenuCallback(void)
case 9:
case 10:
gUnknown_203B3E8->wonderMailStatus = sub_80381F4(gUnknown_203B3E8->unk24C,&gUnknown_203B3E8->unk254,&gUnknown_203B3E8->unk308);
if (sub_800D588() != 0) {
if (sub_800D588()) {
gUnknown_203B3E8->unk3C0 = gUnknown_203B3E8->unk308;
}
else {
@ -570,7 +569,7 @@ void WonderMailMainMenuCallback(void)
}
}
void SetWonderMailMainMenuState(u8 newState)
static void SetWonderMailMainMenuState(u8 newState)
{
gUnknown_203B3E8->state = newState;
nullsub_54();

View File

@ -76,7 +76,7 @@
.include "src/wonder_mail_802C860.o"
.include "src/wonder_mail_802CDD4.o"
.include "src/wonder_mail_802D098.o"
.include "src/code_802DB28.o"
.include "src/thank_you_messages.o"
.include "src/code_802DE84.o"
.include "src/mailbox.o"
.include "src/pelipper_board.o"