Merge pull request #358 from Kermalis/stuff
Some checks failed
GithubCI / build (push) Has been cancelled

main_loops.c and some pmd-blue stuff
This commit is contained in:
Seth Barberee
2025-03-09 22:25:11 -07:00
committed by GitHub
75 changed files with 2091 additions and 2480 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -101,7 +101,7 @@ _08097E90:
ldr r2, [r1]
mov r1, r8
str r3, [sp, 0x1F4]
bl sub_800B2D4
bl StrsDifferent_IgnoreCase
lsls r0, 24
adds r5, r4, 0
adds r6, r7, 0x1

View File

@@ -1,144 +0,0 @@
.section .rodata
.string "pksdir0\0"
.global gBaseKindTable
gBaseKindTable: @ 80B690C
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x19, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x34, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00
.byte 0x85, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x45, 0x01, 0x00, 0x00
.byte 0x04, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x05, 0x00, 0x00, 0x00
.byte 0x9e, 0x00, 0x00, 0x00
.byte 0x06, 0x00, 0x00, 0x00
.byte 0x1b, 0x01, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x36, 0x00, 0x00, 0x00
.byte 0x08, 0x00, 0x00, 0x00
.byte 0x04, 0x00, 0x00, 0x00
.byte 0x09, 0x00, 0x00, 0x00
.byte 0x18, 0x01, 0x00, 0x00
.byte 0x0a, 0x00, 0x00, 0x00
.byte 0x9b, 0x00, 0x00, 0x00
.byte 0x0b, 0x00, 0x00, 0x00
.byte 0x68, 0x00, 0x00, 0x00
.byte 0x0c, 0x00, 0x00, 0x00
.byte 0x42, 0x00, 0x00, 0x00
.byte 0x0d, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x0e, 0x00, 0x00, 0x00
.byte 0x98, 0x00, 0x00, 0x00
.byte 0x0f, 0x00, 0x00, 0x00
.byte 0x15, 0x01, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gTalkKindTable
gTalkKindTable: @ 80B6994
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x9e, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x18, 0x01, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x98, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gPMDBuildVersion
gPMDBuildVersion: @ 80B69BC
.string "PKDi ver 1.0 [Apr 28 2006] 16:37:54\0"
.align 2,0
.global titlen0_text
titlen0_text:
.string "titlen0\0"
.align 2,0
.global titlen1_text
titlen1_text:
.string "titlen1\0"
.align 2,0
.global titlen2_text
titlen2_text:
.string "titlen2\0"
.align 2,0
.global gLoadScreenBackgroundFileNames
gLoadScreenBackgroundFileNames: @ 80B69F8
.4byte titlen0_text
.4byte titlen1_text
.4byte titlen2_text
.global titlen0p_text
titlen0p_text:
.string "titlen0p\0"
.align 2,0
.global titlen1p_text
titlen1p_text:
.string "titlen1p\0"
.align 2,0
.global titlen2p_text
titlen2p_text:
.string "titlen2p\0"
.align 2,0
.global gLoadScreenBackgroundPaletteFileNames
gLoadScreenBackgroundPaletteFileNames: @ 80B6A28
.4byte titlen0p_text
.4byte titlen1p_text
.4byte titlen2p_text
gSaveTextQuicksaving:: @ 80B6A34
.string "{CENTER_ALIGN}Quicksaving your adventure...\n"
.string "{CENTER_ALIGN}Please don't turn off the power.\0"
.align 2, 0
gSaveTextYourAdventureHasBeenSaved:: @ 80B6A7C
.string "{CENTER_ALIGN}Your adventure has been saved.\0"
.align 2, 0
gSaveTextYourAdventureHasBeenSavedLong:: @ 80B6AA0
.string "{CENTER_ALIGN}Your adventure has been saved.\n"
.string "{CENTER_ALIGN}When you are in a dungeon, quicksave\n"
.string "{CENTER_ALIGN}your progress before ending the game.\0"
.align 2, 0
gSaveTextTheDataCouldNotBeWritten:: @ 80B6B14
.string "{CENTER_ALIGN}The data could not be written.\n"
.string "{CENTER_ALIGN}Please turn off the power and remove\n"
.string "{CENTER_ALIGN}and reinsert the DS Card.\0"
.align 2, 0
gSaveTextFailed:: @ 80B6B78
.string "{CENTER_ALIGN}Save failed.\0"
.align 2, 0
gSaveTextError:: @ 80B6B88
.string "{CENTER_ALIGN}Error reading data.\n"
.string "{CENTER_ALIGN}Please turn off the power and reinsert\n"
.string "{CENTER_ALIGN}the DS Game Card.\0"
.align 2, 0
gSaveTextCantResume:: @ 80B6BDC
.string "{CENTER_ALIGN}Your data was not properly saved,\n"
.string "{CENTER_ALIGN}so your game cannot be resumed\n"
.string "{CENTER_ALIGN}from your last spot.{EXTRA_MSG}{CENTER_ALIGN}Your last outing is considered a defeat.\n"
.string "{CENTER_ALIGN}Before shutting down, save in your\n"
.string "{CENTER_ALIGN}team base, or quicksave in a dungeon.\0"
.align 2, 0
gSaveTextMayNotResume:: @ 80B6CB8
.string "{CENTER_ALIGN}You may not resume your dungeon\n"
.string "{CENTER_ALIGN}adventure using this saved data.\n"
.string "{CENTER_ALIGN}Your last outing is considered a defeat.\0"

View File

@@ -1,9 +0,0 @@
#ifndef GUARD_CODE_2_H
#define GUARD_CODE_2_H
#include "personality_test1.h"
void sub_8001024(struct PersonalityRelated *);
void sub_8001044(struct PersonalityRelated *);
#endif // GUARD_CODE_2_H

6
include/code_800D090_1.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GUARD_CODE_800D090_1_H
#define GUARD_CODE_800D090_1_H
bool8 sub_800DAAC(void);
#endif // GUARD_CODE_800D090_1_H

6
include/code_8042B34.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GUARD_CODE_8042B34_H
#define GUARD_CODE_8042B34_H
void sub_8043D50(s32 *a0, s32 *a1);
#endif // GUARD_CODE_8042B34_H

View File

@@ -48,5 +48,6 @@ s32 GetMailIndex(u8 mailType, u32);
s32 GetFirstIndexofMailType(u8 mailType);
void sub_8095824(DataSerializer *a, unkStruct_203B480 *b);
void sub_8095774(DataSerializer *a, unkStruct_203B480 *b);
void sub_809542C(WonderMailSub *param_1);
#endif // GUARD_CODE_8094F88_H

View File

@@ -36,39 +36,41 @@ typedef struct unkStruct_203B490
extern unkStruct_203B490 *gUnknown_203B490;
void LoadMailInfo(void);
unkStruct_203B490 *GetMailInfo(void);
void InitializeMailJobsNews(void);
bool8 IsValidWonderMail(WonderMail *WonderMailData);
bool8 ValidateWonderMail(WonderMail *data);
s32 CountFilledMailboxSlots(void);
WonderMail *GetMailboxSlotInfo(u8 index);
bool8 IsMailSlotEmpty(u8 index);
void ResetMailboxSlot(u8 index);
void ShiftMailboxSlotsDown(void);
bool8 AcceptJob(WonderMail *mail);
bool8 CheckPKMNNewsSlot(u8 index);
s32 CountFilledMailboxSlots(void);
s32 CountJobsinDungeon(u8 dungeon);
void GeneratePelipperJobs(void);
WonderMail *GetJobSlotInfo(u8 index);
WonderMail *GetMailboxSlotInfo(u8 index);
unkStruct_203B490 *GetMailInfo(void);
s32 GetNumAcceptedJobs(void);
WonderMail *GetPelipperBoardSlotInfo(u8);
void InitializeMailJobsNews(void);
bool8 IsJobSlotEmpty(u8 index);
bool8 IsMailinJobSlot(WonderMail *mail);
bool8 IsMailSlotEmpty(u8 index);
bool8 IsPelipperBoardSlotEmpty(u8);
bool8 IsValidWonderMail(WonderMail *WonderMailData);
void LoadMailInfo(void);
void ReadWonderMailBits(DataSerializer *a, WonderMail *b);
void ReceivePKMNNews(u8 index);
void ResetJobSlot(u8 index);
void ResetMailboxSlot(u8 index);
void ResetPelipperBoardSlot(u8);
void ShiftJobSlotsDown(void);
void ShiftMailboxSlotsDown(void);
void ShiftPelipperJobsDown(void);
void SortJobSlots(void);
void sub_80961B4(void);
bool8 sub_809693C(WonderMail *mail);
void sub_8096AF8(struct unkStruct_8096AF8 *, u8 slotIndex, u8 dungeon);
bool8 sub_8096C08(u8 *jobIndex);
WonderMail *GetPelipperBoardSlotInfo(u8);
bool8 IsPelipperBoardSlotEmpty(u8);
void ResetPelipperBoardSlot(u8);
void ShiftPelipperJobsDown(void);
void ShiftJobSlotsDown(void);
void ReceivePKMNNews(u8 index);
bool8 CheckPKMNNewsSlot(u8 index);
void SortJobSlots(void);
u8 *sub_8096DD8(void);
u8 *sub_8096DE8(void);
u8 sub_8096E2C(void);
void sub_8096EEC(WonderMail *mail);
bool8 ValidateWonderMail(WonderMail *data);
void WriteWonderMailBits(DataSerializer *a, WonderMail *b);
void ReadWonderMailBits(DataSerializer *a, WonderMail *b);
#endif // GUARD_CODE_80958E8_H
#endif // GUARD_CODE_80958E8_H

View File

@@ -82,5 +82,6 @@ s16 GetAdventureFloorsExplored(void);
void UpdateAdventureAchievements(void);
u32 SaveAdventureData(u8 *r0, u32 size);
u32 RestoreAdventureData(u8 *r0, u32 size);
void SetDungeonLocationInfo(DungeonLocation *dl);
#endif // GUARD_CODE_8097670_H
#endif // GUARD_CODE_8097670_H

View File

@@ -1,7 +1,7 @@
#ifndef GUARD_CODE_8099328_H
#define GUARD_CODE_8099328_H
bool8 sub_80992E0(s16 *param_1, s16 *param_2);
bool8 sub_8099328(u8 *);
#endif // GUARD_CODE_8099328_H
#endif // GUARD_CODE_8099328_H

View File

@@ -3,7 +3,7 @@
bool8 sub_8099360(u8 *);
u8 sub_8099394(u8 *);
bool8 sub_8099394(u8 *);
void sub_80993C0(bool8);
void sub_80993D8(void);
void sub_80993E4(void);
@@ -15,6 +15,8 @@ void sub_809965C(void);
extern void sub_8099690(u32);
// code_8099360.s
extern void sub_8099744(void);
extern void sub_8099750(void);
extern void sub_8099A5C(u32, u32, u32);
extern void sub_8099AFC(u32, u32, u32);
extern bool8 sub_8099B94(void);

View File

@@ -4,7 +4,7 @@
void CpuClear(void *, s32);
void CpuCopy(void *dest, const void *src, s32 size);
void nullsub_23(bool8);
void SetWindowTitle(u8 *);
void SetWindowTitle(const u8 *);
void sub_800CDA8(u32);
u32 sub_800CDC8(void);
void VBlank_CB(void);

View File

@@ -3,12 +3,24 @@
#include "file_system.h"
u32 DecompressAT(u8 *result, s32 resultLength, const u8 *compressedData);
u32 DecompressATFile(u8 *result, s32 resultLength, OpenedFile *file);
// size: 0x8
typedef struct SiroArchive
{
/* 0x0 */ u32 magic;
/* 0x4 */ const void *data;
} SiroArchive;
u32 DecompressAT(u8 *dst, s32 dstLen, const u8 *src);
u32 DecompressATFile(void *dst, s32 dstLen, OpenedFile *file);
u32 DecompressATGlobalFile(u32 *result, s32 resultLength, OpenedFile *file);
const u8 *GetSiroPtr(OpenedFile *openedFile);
const void *GetSiroPtr(OpenedFile *openedFile);
void nullsub_16(void);
bool8 sub_800B2D4(char *, char *, s32 length);
// Returns FALSE if the ascii chars in both strings match, ignoring uppercase/lowercase differences.
// "YeS\0" and "yEs\0" => FALSE
// "Yes\0" and "Tes\0" => TRUE
// "Yes\0" and "y\0" => TRUE
// "T\0" and "Tes\0" => TRUE
bool8 StrsDifferent_IgnoreCase(char *strA, char *strB, s32 maxLen);
#endif // GUARD_DECOMPRESS_H

View File

@@ -5,14 +5,14 @@
typedef struct File
{
/* 0x0 */ char *name;
/* 0x4 */ const u8 *data;
/* 0x4 */ const void *data;
} File;
// size: 0x8
typedef struct OpenedFile
{
/* 0x0 */ const File *file;
/* 0x4 */ const u8 *data;
/* 0x4 */ const void *data;
} OpenedFile;
// size: 0x10
@@ -23,13 +23,6 @@ typedef struct FileArchive
/* 0xC */ const File *entries;
} FileArchive;
// size: 0x8
typedef struct SiroArchive
{
/* 0x0 */ u32 magic;
/* 0x4 */ u8 *data;
} SiroArchive;
// size: 0x8
typedef struct UnkFileStruct
{

13
include/main_loops.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef GUARD_MAIN_LOOPS_H
#define GUARD_MAIN_LOOPS_H
#include "personality_test1.h"
void GameLoop(void);
void nullsub_3(s32 yPos, s32 a1);
s32 sub_8000728(void);
void sub_8001024(PersonalityRelated *dst);
void sub_8001044(PersonalityRelated *src);
void sub_8001064(void);
#endif // GUARD_MAIN_LOOPS_H

View File

@@ -14,31 +14,33 @@ typedef struct PersonalityQuestion
/* 0x8 */ const PersonalityEffects *effects;
} PersonalityQuestion;
struct PersonalityRelated
// size: 0x30
typedef struct PersonalityRelated
{
u32 unk4;
s16 StarterID;
s16 PartnerID;
u8 StarterName[0x14];
u8 PartnerNick[0x14];
};
/* 0x0 */ u32 unk0;
/* 0x4 */ s16 StarterID;
/* 0x6 */ s16 PartnerID;
/* 0x8 */ u8 StarterName[20];
/* 0x1C */ u8 PartnerNick[20];
} PersonalityRelated;
struct PersonalityTestTracker
// size: 0xC0
typedef struct PersonalityTestTracker
{
/* 0x0 */ s32 FrameCounter;
struct PersonalityRelated unk4;
/* 0x4 */ PersonalityRelated unk4;
/* 0x34 */ u32 TestState;
/* 0x38 */ s32 QuestionCounter;
/* 0x3C */ u32 currQuestionIndex;
/* 0x40 */ u8 playerNature;
/* 0x44 */ s32 NatureTotals[NUM_PERSONALITIES];
/* 0x78 */ u8 QuestionTracker[NUM_QUIZ_QUESTIONS];
/* 0xB0 */ u32 playerGender; // 1 = Female, 0 = Male
/* 0xB0 */ u32 playerGender; // 0 = Male, 1 = Female
/* 0xB4 */ MenuInputStructSub input;
};
} PersonalityTestTracker;
bool8 CreateTestTracker(void);
void DeleteTestTracker(void);
u32 HandleTestTrackerState(void);
#endif // GUARD_PERSONALITY_TEST1_H
#endif // GUARD_PERSONALITY_TEST1_H

View File

@@ -106,6 +106,7 @@ void GetPokemonLevelData(LevelData* a1, s32 _id, s32 level);
const u8* DecompressMoveID(const u8* a1, u16* moveID);
bool8 sub_808DA44(s32, u32);
void sub_808D144(PokemonStruct1 *pokemon, struct unkStruct_808D144 *r1);
void sub_808CE74(s16 _species, bool32 _isLeader, u8* name);
static inline bool8 PokemonFlag1(PokemonStruct1 *mon)
{

View File

@@ -79,4 +79,6 @@ PokemonStruct1 *sub_808F798(PokemonStruct1 *pokemon, short _species);
void CreatePokemonInfoTabScreen(s32 param_1, s32 param_2, struct unkStruct_808FF20 *mon, struct UnkInfoTabStruct *param_4, u32 windowId);
void sub_808FF20(struct unkStruct_808FF20 *param_1, struct PokemonStruct1 *pokemon, bool8 param_3);
void sub_808ED00(void);
#endif // GUARD_POKEMON_3_H

View File

@@ -1,11 +1,13 @@
#ifndef GUARD_RANDOM_H
#define GUARD_RANDOM_H
void SeedRng(u8 *seed);
void SeedRng(u8 seed[6]);
s32 Rand32Bit(void);
s32 RandInt(s32 cap);
s32 RandRange(s32 a, s32 b);
s32 GetRNGSeed(void);
// Returns a random number [0, maxExclusive)
s32 RandInt(s32 maxExclusive);
// Returns a random number [minInclusive, maxExclusive)
s32 RandRange(s32 minInclusive, s32 maxExclusive);
s32 GetRNGState(void);
void SetRNGSeed(s32 state);
#endif // GUARD_RANDOM_H
#endif // GUARD_RANDOM_H

View File

@@ -12,9 +12,11 @@
enum
{
SAVE_NO_STATUS = -1,
SAVE_COMPLETED,
SAVE_NOT_WRTTEN,
SAVE_FAILED
SAVE_FAILED,
SAVE_UNK3
};
enum
@@ -47,6 +49,7 @@ struct UnkStruct_sub_8011DAC
};
// size: 0x5C
// This is most likely a debug savestate
struct UnkStruct_203B184
{
/* 0x0 */ TeamInventory *MoneyItems;
@@ -74,11 +77,11 @@ struct UnkStruct_203B184
u32 RngState;
};
void nullsub_33(void);
u32 sub_8011C1C(void);
void sub_8011C28(u32 in);
s32 sub_8011C34(void);
void sub_8011C40(s32 in);
const char *GetGameInternalName(void);
void sub_8011CA8(u32 *out, s32 size);
u32 ReadSaveFromPak(u32 *a);
u32 WriteSavetoPak(s32 *param_1, u32 param_2);

View File

@@ -4,6 +4,7 @@
#include "structs/menu.h"
// size: 0x1B4
// for some reason, this is 0x1A4 in NDS, but I (Kermalis) can't find out why yet. It seems like MenuStruct or Windows is smaller in NDS
typedef struct SaveMenuWork
{
/* 0x0 */ u32 currMenu;

View File

@@ -45,7 +45,7 @@ typedef struct MenuInputStruct
typedef struct MenuItem
{
const u8 *text;
s32 menuAction; // action??
s32 menuAction;
} MenuItem;
// size: 0x50

View File

@@ -1,293 +0,0 @@
#ifndef GUARD_SPRITE_OAM_TEMP_H
#define GUARD_SPRITE_OAM_TEMP_H
#include "sprite_oam.h"
// This file is here for temporary decomp notes about SpriteOAM. It can be deleted later when we figure it out.
// SpriteOAM initialization is handled by inlines. Potentially has inlines for other scenarios [for example: AddSprite() and AddAxSprite()]
// There is lots of testing done and evidence that it most likely is not handled by macros.
// Some funcs (such as sub_8039174) can be fakematched with "{} while(0);" contexts and a temp var. Note that it's not a "do {} while(0)" but just a "{} while(0)".
// However, that does not work for most funcs, and does not produce some of the register preloading we get with inlines.
// Also, the inlines I (kermalis) have tested with DO produce the behavior we see in all of the funcs. It just doesn't match 100% yet.
// Most of the special work seems to be done on the first two u16 of SpriteOAM.
// They are usually loaded/stored separately from the second half of the struct.
// There doesn't seem to be a logical reason for SpriteOAM to be split into two substructs, but the evidence points to it.
// AddSprite() and AddAxSprite() still haven't been matched (I'm writing this Dec 4 2024), because they suggest SpriteOAM is actually two separate substructs.
// "volatile u32/u16" was the first thing we tried, but it produces horrible asm and doesn't make sense for Chunsoft to have used it in this context.
// The main breakthrough came from producing 99% similar asm through attrib1/attrib2 being a substruct.
// Proposed struct definition:
typedef struct SpriteOAM2_Sub1
{
u16 attrib1;
u16 attrib2;
} SpriteOAM2_Sub1;
typedef struct SpriteOAM2_Sub2
{
u16 attrib3;
u16 unk6;
} SpriteOAM2_Sub2;
typedef struct SpriteOAM2
{
SpriteOAM2_Sub1 unk0;
SpriteOAM2_Sub2 unk2;
} SpriteOAM2;
// (It's called SpriteOAM2 temporarily to avoid conflicts with the current one)
// There seem to be 3 ways of handling SpriteOAM that I have found so far.
// #1 - When a SpriteOAM is initialized on the stack, certain inlines set its fields. This produces heavily inefficient asm but that's what they did.
// #2 - When a SpriteOAM is initialized from ram, it uses different inlines that produce way better asm. They're still known to be inlines because of the register preloading.
// #3 - Sometimes neither of the above 2's inlines are used for attrib1. It appears to be a third set of inlines (didn't attempt yet, feel free to).
// For type #3, way more testing needs to be done.
// The thing is, in all 3 scenarios, an identical order of operations is usually applied.
// The asm being nearly identical each time also makes it unlikely to be done manually without some macros or inlines.
// And this is why we haven't "real" matched many (any?) SpriteOAM funcs in the years this decomp has existed.
// Here are some helpful decomp.me links with examples.
// Type #1 - Main func (sub_8013F84) - Initializes a SpriteOAM on the stack [https://decomp.me/scratch/KYLmA]
// Type #2 - Complex fast init func (sub_8052FB8) - Loop func that initializes many SpriteOAM from ram [https://decomp.me/scratch/RX3cp]
// Type #3 - Fast init func (sub_8039174) - Initializes a SpriteOAM from ram [https://decomp.me/scratch/4qs37]
// Type #1 attrib1 inlines:
static inline void SetAttrib1(SpriteOAM2_Sub1 *sub, u32 attrib1)
{
SpriteOAM2_Sub1 nSub = *sub;
nSub.attrib1 = attrib1;
*sub = nSub;
// The only issue with this is the fact that the "ldr" happens before the "0xFFFF0000" mask is loaded.
// The only way we have gotten the mask to load before the "ldr" is with something like this:
// *sub = (SpriteOAM2_Sub){ value, sub->attrib2 };
// However, that produces bad asm. So the solution is to somehow make it a one liner like the above, while still loading from the entire "*sub" somehow.
// This func can also be changed to simply return a SpriteOAM2_Sub1 instead of replacing the value.
// BTW, making a "{} while(0)" macro for this actually folds the constants together unlike this... which is more efficient asm. Not what we want for matching lol.
// Matching this will be a huge deal!
}
static inline void SetAffineMode1(SpriteOAM2 *s, u32 mode1)
{
u32 valueM = mode1 & SPRITEOAM_MAX_AFFINEMODE1;
u32 value = valueM << SPRITEOAM_SHIFT_AFFINEMODE1;
SetAttrib1(&s->unk0, s->unk0.attrib1 & (u16)~SPRITEOAM_MASK_AFFINEMODE1);
SetAttrib1(&s->unk0, s->unk0.attrib1 | value);
}
static inline void SetAffineMode2(SpriteOAM2 *s, u32 mode2)
{
u32 valueM = mode2 & SPRITEOAM_MAX_AFFINEMODE2;
u32 value = valueM << SPRITEOAM_SHIFT_AFFINEMODE2;
SetAttrib1(&s->unk0, s->unk0.attrib1 & (u16)~SPRITEOAM_MASK_AFFINEMODE2);
SetAttrib1(&s->unk0, s->unk0.attrib1 | value);
}
static inline void SetObjMode(SpriteOAM2 *s, u32 mode)
{
u32 valueM = mode & SPRITEOAM_MAX_OBJMODE;
u32 value = valueM << SPRITEOAM_SHIFT_OBJMODE;
SetAttrib1(&s->unk0, s->unk0.attrib1 & (u16)~SPRITEOAM_MASK_OBJMODE);
SetAttrib1(&s->unk0, s->unk0.attrib1 | value);
}
static inline void SetMosaic(SpriteOAM2 *s, u32 mosaic)
{
u32 valueM = mosaic & SPRITEOAM_MAX_MOSAIC;
u32 value = valueM << SPRITEOAM_SHIFT_MOSAIC;
SetAttrib1(&s->unk0, s->unk0.attrib1 & (u16)~SPRITEOAM_MASK_MOSAIC);
SetAttrib1(&s->unk0, s->unk0.attrib1 | value);
}
static inline void SetBPP(SpriteOAM2 *s, u32 bpp)
{
u32 valueM = bpp & SPRITEOAM_MAX_BPP;
u32 value = valueM << SPRITEOAM_SHIFT_BPP;
SetAttrib1(&s->unk0, s->unk0.attrib1 & (u16)~SPRITEOAM_MASK_BPP);
SetAttrib1(&s->unk0, s->unk0.attrib1 | value);
}
static inline void SetShape(SpriteOAM2 *s, u32 shape)
{
u32 valueM = shape & SPRITEOAM_MAX_SHAPE;
u32 value = valueM << SPRITEOAM_SHIFT_SHAPE;
SetAttrib1(&s->unk0, s->unk0.attrib1 & (u16)~SPRITEOAM_MASK_SHAPE);
SetAttrib1(&s->unk0, s->unk0.attrib1 | value);
}
// Type #2 attrib1 inlines:
static inline void FastSetAffineMode1(SpriteOAM2 *s, u32 mode1)
{
u32 value;
value = mode1 & SPRITEOAM_MAX_AFFINEMODE1;
s->unk0.attrib1 &= ~SPRITEOAM_MASK_AFFINEMODE1;
s->unk0.attrib1 |= value << SPRITEOAM_SHIFT_AFFINEMODE1;
}
static inline void FastSetAffineMode2(SpriteOAM2 *s, u32 mode2)
{
u32 value;
value = mode2 & SPRITEOAM_MAX_AFFINEMODE2;
s->unk0.attrib1 &= ~SPRITEOAM_MASK_AFFINEMODE2;
s->unk0.attrib1 |= value << SPRITEOAM_SHIFT_AFFINEMODE2;
}
static inline void FastSetObjMode(SpriteOAM2 *s, u32 mode)
{
u32 value;
value = mode & SPRITEOAM_MAX_OBJMODE;
s->unk0.attrib1 &= ~SPRITEOAM_MASK_OBJMODE;
s->unk0.attrib1 |= value << SPRITEOAM_SHIFT_OBJMODE;
}
static inline void FastSetMosaic(SpriteOAM2 *s, u32 mosaic)
{
u32 value;
value = mosaic & SPRITEOAM_MAX_MOSAIC;
s->unk0.attrib1 &= ~SPRITEOAM_MASK_MOSAIC;
s->unk0.attrib1 |= value << SPRITEOAM_SHIFT_MOSAIC;
}
static inline void FastSetBPP(SpriteOAM2 *s, u32 bpp)
{
u32 value;
value = bpp & SPRITEOAM_MAX_BPP;
s->unk0.attrib1 &= ~SPRITEOAM_MASK_BPP;
s->unk0.attrib1 |= value << SPRITEOAM_SHIFT_BPP;
}
static inline void FastSetShape(SpriteOAM2 *s, u32 shape)
{
u32 value;
value = shape & SPRITEOAM_MAX_SHAPE;
s->unk0.attrib1 &= ~SPRITEOAM_MASK_SHAPE;
s->unk0.attrib1 |= value << SPRITEOAM_SHIFT_SHAPE;
}
// attrib2 inlines:
// These pretty much match in every scenario.
// Trying to macro-ify or make a sub-inline will remove some register preloading we rely on.
static inline void SetX(SpriteOAM2 *s, u32 x)
{
u32 value;
u32 valueS;
value = x & SPRITEOAM_MAX_X;
valueS = value << SPRITEOAM_SHIFT_X;
s->unk0.attrib2 &= ~SPRITEOAM_MASK_X;
s->unk0.attrib2 |= valueS;
}
static inline void SetMatrixNum(SpriteOAM2 *s, u32 matNum)
{
u32 value;
u32 valueS;
value = matNum & SPRITEOAM_MAX_MATRIXNUM;
valueS = value << SPRITEOAM_SHIFT_MATRIXNUM;
s->unk0.attrib2 &= ~SPRITEOAM_MASK_MATRIXNUM;
s->unk0.attrib2 |= valueS;
}
static inline void SetSize(SpriteOAM2 *s, u32 size)
{
u32 value;
u32 valueS;
value = size & SPRITEOAM_MAX_SIZE;
valueS = value << SPRITEOAM_SHIFT_SIZE;
s->unk0.attrib2 &= ~SPRITEOAM_MASK_SIZE;
s->unk0.attrib2 |= valueS;
}
// attrib3 inline:
// For some reason this one is all combined. Also matches pretty much every time.
// It's possible the attrib1 ones are also combined like this, but not the attrib2 ones since they're called out of order or omitted.
// And just like the attrib2 inlines, attempting to macro or inline further results in removed preloading.
static inline void SetAttrib3(SpriteOAM2 *s, u32 tileNum, u32 prio, u32 palNum)
{
u32 value;
u32 valueS;
value = tileNum & SPRITEOAM_MAX_TILENUM;
valueS = value << SPRITEOAM_SHIFT_TILENUM;
s->unk2.attrib3 &= ~SPRITEOAM_MASK_TILENUM;
s->unk2.attrib3 |= valueS;
value = prio & SPRITEOAM_MAX_PRIORITY;
valueS = value << SPRITEOAM_SHIFT_PRIORITY;
s->unk2.attrib3 &= ~SPRITEOAM_MASK_PRIORITY;
s->unk2.attrib3 |= valueS;
value = palNum & SPRITEOAM_MAX_PALETTENUM;
valueS = value << SPRITEOAM_SHIFT_PALETTENUM;
s->unk2.attrib3 &= ~SPRITEOAM_MASK_PALETTENUM;
s->unk2.attrib3 |= valueS;
}
// unk6 inlines:
// Basically same situation as attrib2 inlines. Can't be altered past this or combined, and matches like this.
static inline void SetUnk6_0(SpriteOAM2 *s, u32 part0)
{
u32 value;
u32 valueS;
value = part0 & SPRITEOAM_MAX_UNK6_0;
valueS = value << SPRITEOAM_SHIFT_UNK6_0;
s->unk2.unk6 &= ~SPRITEOAM_MASK_UNK6_0;
s->unk2.unk6 |= valueS;
}
static inline void SetUnk6_1(SpriteOAM2 *s, u32 part1)
{
u32 value;
u32 valueS;
value = part1 & SPRITEOAM_MAX_UNK6_1;
valueS = value << SPRITEOAM_SHIFT_UNK6_1;
s->unk2.unk6 &= ~SPRITEOAM_MASK_UNK6_1;
s->unk2.unk6 |= valueS;
}
static inline void SetUnk6_2(SpriteOAM2 *s, u32 part2)
{
u32 value;
u32 valueS;
value = part2 & SPRITEOAM_MAX_UNK6_2;
valueS = value << SPRITEOAM_SHIFT_UNK6_2;
s->unk2.unk6 &= ~SPRITEOAM_MASK_UNK6_2;
s->unk2.unk6 |= valueS;
}
// Not seen yet
/*static inline void SetUnk6_3(SpriteOAM2 *s, u32 part3)
{
u32 value;
u32 valueS;
value = part3 & SPRITEOAM_MAX_UNK6_3;
valueS = value << SPRITEOAM_SHIFT_UNK6_3;
s->unk2.unk6 &= ~SPRITEOAM_MASK_UNK6_3;
s->unk2.unk6 |= valueS;
}*/
static inline void SetUnk6_4(SpriteOAM2 *s, u32 part4)
{
u32 value;
u32 valueS;
value = part4 & SPRITEOAM_MAX_UNK6_4;
valueS = value << SPRITEOAM_SHIFT_UNK6_4;
s->unk2.unk6 &= ~SPRITEOAM_MASK_UNK6_4;
s->unk2.unk6 |= valueS;
}
#endif // GUARD_SPRITE_OAM_TEMP_H

View File

@@ -6,7 +6,7 @@
#include "structs/str_pokemon.h"
#include "structs/str_wonder_mail.h"
struct UnkStruct_RunDungeon
typedef struct UnkStruct_RunDungeon
{
u8 unk0;
DungeonLocation unk4;
@@ -28,9 +28,9 @@ struct UnkStruct_RunDungeon
u8 unk7E;
DungeonLocation unk80;
WonderMailSub unk84;
};
} UnkStruct_RunDungeon;
void RunDungeon(struct UnkStruct_RunDungeon *r8);
#endif // GUARD_STR_DUNGEON_8042F6C_H
// TODO: This func should not be in a structs include file
void RunDungeon(UnkStruct_RunDungeon *r8);
#endif // GUARD_STR_DUNGEON_8042F6C_H

View File

@@ -28,12 +28,13 @@ typedef struct Window
u8 unk46;
} Window;
// size: 0x4
typedef struct WindowHeader
{
u8 count; // How many headers there are, it's used for windows which can be scrolled left/right
u8 currId; // Id of the current header
u8 width;
u8 f3;
/* 0x0 */ u8 count; // How many headers there are, it's used for windows which can be scrolled left/right
/* 0x1 */ u8 currId; // Id of the current header
/* 0x2 */ u8 width;
/* 0x3 */ u8 f3;
} WindowHeader;
#include "structs/str_position.h"
@@ -42,18 +43,15 @@ typedef struct WindowHeader
typedef struct WindowTemplate
{
u8 unk0;
s32 type;
DungeonPos pos;
s16 width;
s16 height;
/* 0x4 */ s32 type;
/* 0x8 */ DungeonPos pos;
/* 0xC */ s16 width;
/* 0xE */ s16 height;
s16 unk10; // In most cases it's the same as height. If it's smaller than height, the window may look glitchy. Maybe something with tile allocation/how the window is filled?
s16 unk12;
const WindowHeader *header;
} WindowTemplate;
// All fields are zeroed out except for type which is set to WINDOW_TYPE_NORMAL.
#define WINDOW_DUMMY (WindowTemplate) {.unk0 = 0, .type = WINDOW_TYPE_NORMAL, .width = 0, .pos = {0, 0}, .height = 0, .unk10 = 0, .unk12 = 0, .header = NULL}
#define WINDOW_TYPE_0 0
#define WINDOW_TYPE_WITHOUT_BORDER 1
#define WINDOW_TYPE_2 2
@@ -65,8 +63,13 @@ typedef struct WindowTemplate
#define MAX_WINDOWS 4
typedef struct WindowTemplates {
WindowTemplate id[MAX_WINDOWS];
// All fields are zeroed out except for type which is set to WINDOW_TYPE_NORMAL.
#define WIN_TEMPLATE_DUMMY (WindowTemplate) { .unk0 = 0, .type = WINDOW_TYPE_NORMAL, .pos = { .x = 0, .y = 0 }, .width = 0, .height = 0, .unk10 = 0, .unk12 = 0, .header = NULL }
// size: 0x60
typedef struct WindowTemplates
{
/* 0x0 */ WindowTemplate id[MAX_WINDOWS];
} WindowTemplates;
#endif // GUARD_STR_TEXT_H
#endif // GUARD_STR_TEXT_H

View File

@@ -49,9 +49,7 @@ SECTIONS {
asm/crt0.o(.text);
src/code_80001DC.o(.text);
asm/arm_func.o(.text);
src/code_2.o(.text);
asm/code_2.o(.text);
src/code.o(.text);
src/main_loops.o(.text);
src/event_flag.o(.text);
asm/code_8002774.o(.text);
src/code_8002774.o(.text);
@@ -408,7 +406,7 @@ SECTIONS {
.rodata :
ALIGN(4)
{
data/data_code_2.o(.rodata);
src/main_loops.o(.rodata);
data/data.o(.rodata);
src/memory.o(.rodata);
data/data1.o(.rodata);

View File

@@ -1,369 +0,0 @@
#include "global.h"
#include "structs/str_dungeon_8042F6C.h"
#include "structs/str_wonder_mail.h"
#include "code_80118A4.h"
#include "code_80A26CC.h"
#include "code_8099360.h"
#include "event_flag.h"
#include "items.h"
#include "memory.h"
#include "personality_test1.h"
#include "pokemon.h"
#include "quick_save_read.h"
#include "quick_save_write.h"
#include "random.h"
#include "save.h"
#include "string_format.h"
#include "text_util.h"
#include "constants/monster.h"
extern void NDS_LoadOverlay_GroundMain();
extern u32 xxx_script_related_8098468(u32);
extern u8 sub_80992E0(s16 *, s16 *);
extern bool8 sub_8099328(u8 *dungeonId);
extern bool8 sub_8099360(u8 *);
extern u8 sub_8099394(u8 *);
extern void GeneratePelipperJobs();
extern void sub_8043D50(s32 *a0, s32 *a1);
extern void xxx_update_stuff(u32);
extern void sub_80961B4();
extern void sub_808ED00();
extern void SetDungeonLocationInfo(DungeonLocation *dl);
extern void sub_808CE74(s16, bool32, u8*);
void xxx_dungeon_8001340(struct UnkStruct_RunDungeon *r0);
void sub_80011E8(u8 *param_1);
void sub_809542C(WonderMailSub *param_1);
struct unkTalkTable
{
u32 unk0;
s16 species;
};
extern struct unkTalkTable gTalkKindTable[];
extern struct unkTalkTable gBaseKindTable[];
EWRAM_INIT u32 gUnknown_203B03C = 0;
EWRAM_INIT struct PersonalityRelated gPersonalityRelated_203B040 = {
.unk4 = 0,
.StarterID = MONSTER_CHARMANDER,
.PartnerID = MONSTER_SQUIRTLE,
.StarterName = {""},
.PartnerNick = {""},
};
void SaveLoadRelated_8000EDC(struct UnkStruct_RunDungeon *param_1)
{
u8 quickSaveValid;
s32 quickSaveStatus;
s32 local_1c; // 0x4800
s32 local_18; // sizeof(Dungeon)
quickSaveValid = TRUE;
gUnknown_203B03C = 1;
sub_800A8F8(3);
sub_8014144();
sub_8043D50(&local_1c,&local_18);
param_1->unk74 = MemoryAlloc(local_1c,7); // size: 0x4800
param_1->unk78 = MemoryAlloc(local_18,7); // size: sizeof(Dungeon)
if (param_1->unk8) {
PrepareQuickSaveRead(param_1->unk74,local_1c);
while( TRUE ) {
if (!ReadQuickSave()) break;
xxx_update_stuff(0);
}
quickSaveValid = IsQuickSaveValid();
FinishQuickSaveRead();
sub_8011830();
if (quickSaveValid) {
sub_80121E0(0xf1208);
}
else {
sub_80121E0(0xf1209);
}
xxx_call_start_bg_music();
}
else {
GeneratePelipperJobs();
sub_80961B4();
sub_808ED00();
}
if (quickSaveValid) {
xxx_dungeon_8001340(param_1);
sub_8099648();
SetWindowBGColor();
sub_8099690(0);
}
else {
param_1->unk7C = 5;
}
if (param_1->unk7C == -2) {
sub_809542C(&param_1->unk84);
}
if ((param_1->unk7C == 3) || (param_1->unk7C == -2)) {
SetDungeonLocationInfo(&param_1->unk80);
xxx_call_stop_bgm();
if (param_1->unk7C == -2) {
PrepareQuickSaveWrite(param_1->unk74,local_1c,1);
}
else {
PrepareQuickSaveWrite(param_1->unk74,local_1c,0);
}
while ((quickSaveStatus = WriteQuickSave(), (quickSaveStatus != 2))) {
if (quickSaveStatus == 3) break;
if (quickSaveStatus == 1) {
MemoryFree(param_1->unk78);
MemoryFree(param_1->unk74);
}
xxx_update_stuff(0);
}
FinishQuickSaveWrite();
}
else {
sub_808ED00();
MemoryFree(param_1->unk78);
MemoryFree(param_1->unk74);
}
}
void sub_8001024(struct PersonalityRelated *r0)
{
*r0 = gPersonalityRelated_203B040;
}
void sub_8001044(struct PersonalityRelated *r0)
{
gPersonalityRelated_203B040 = *r0;
}
void sub_8001064(void)
{
struct unkTalkTable *psVar2;
u8 buffer2 [20];
u8 buffer1 [20];
if (GetPlayerPokemonStruct() == NULL) {
if (gPersonalityRelated_203B040.StarterName[0] == '\0') {
CopyMonsterNameToBuffer(buffer1,gPersonalityRelated_203B040.StarterID);
CopyStringtoBuffer(buffer2,buffer1);
sub_808CE74(gPersonalityRelated_203B040.StarterID,TRUE,buffer2);
}
else {
sub_808CE74(gPersonalityRelated_203B040.StarterID,TRUE,gPersonalityRelated_203B040.StarterName);
}
}
if (sub_808D378() == NULL) {
if (gPersonalityRelated_203B040.PartnerNick[0] == '\0') {
CopyMonsterNameToBuffer(buffer1,gPersonalityRelated_203B040.PartnerID);
CopyStringtoBuffer(buffer2,buffer1);
sub_808CE74(gPersonalityRelated_203B040.PartnerID,FALSE,buffer2);
}
else {
sub_808CE74(gPersonalityRelated_203B040.PartnerID,FALSE,gPersonalityRelated_203B040.PartnerNick);
}
}
if (gPersonalityRelated_203B040.StarterID != MONSTER_NONE) {
psVar2 = &gBaseKindTable[0];
while ((psVar2->species != MONSTER_NONE && (gPersonalityRelated_203B040.StarterID != psVar2->species))) {
psVar2++;
}
SetScriptVarValue(NULL,BASE_KIND,psVar2->unk0);
}
if (gPersonalityRelated_203B040.PartnerID != MONSTER_NONE) {
psVar2 = &gTalkKindTable[0];
while ((psVar2->species != MONSTER_NONE && (gPersonalityRelated_203B040.PartnerID != psVar2->species))) {
psVar2++;
}
SetScriptVarValue(NULL,PARTNER_TALK_KIND,psVar2->unk0);
}
}
u8 sub_8001170(void)
{
s16 local_10;
s16 auStack_e;
u8 dungeonID;
u8 auStack_b;
dungeonID = 0x63;
if (sub_80992E0(&local_10,&auStack_e) != 0) {
dungeonID = sub_80A2740(local_10);
}
else {
if (!sub_8099328(&dungeonID) && (!sub_8099360(&dungeonID) && sub_8099394(&auStack_b) != 0)) {
dungeonID = 0x3F;
}
}
return dungeonID;
}
void sub_80011CC(u8 *param_1,u8 param_2)
{
u32 zero = 0;
param_1[0] = param_2;
param_1[1] = zero;
sub_80011E8(param_1);
param_1[0xb] = 0;
param_1[4] = 0;
param_1[0xc] = 0;
param_1[0xd] = 0;
}
void sub_80011E8(u8 *param_1)
{
param_1[5] = sub_80023E4(8);
param_1[6] = sub_80023E4(3);
param_1[8] = sub_80023E4(7);
param_1[9] = sub_80023E4(0);
param_1[10] = sub_80023E4(5);
if (sub_80023E4(0x18) && sub_80023E4(0x19) && sub_80023E4(0x1a)) {
param_1[7] = 1;
}
else {
param_1[7] = 0;
}
}
void sub_8001248(void)
{
s32 index;
for(index = 0; index < INVENTORY_SIZE; index++)
{
if(RandInt(100) < 50)
ZeroOutItem(&gTeamInventoryRef->teamItems[index]);
}
FillInventoryGaps();
for(index = 0; index < NUM_MONSTERS; index++)
{
PokemonStruct1 *mon = &gRecruitedPokemonRef->pokemon[index];
if(PokemonFlag1(mon) && PokemonFlag2(mon))
mon->heldItem.id = ITEM_NOTHING;
}
gTeamInventoryRef->teamMoney = 0;
}
void sub_80012C0(void)
{
s32 index;
for(index = 0; index < INVENTORY_SIZE; index++)
{
ZeroOutItem(&gTeamInventoryRef->teamItems[index]);
}
FillInventoryGaps();
for(index = 0; index < NUM_MONSTERS; index++)
{
PokemonStruct1 *mon = &gRecruitedPokemonRef->pokemon[index];
if(PokemonFlag1(mon) && PokemonFlag2(mon))
mon->heldItem.id = ITEM_NOTHING;
}
gTeamInventoryRef->teamMoney = 0;
}
void NDS_LoadOverlay_GroundMain()
{
}
void nullsub_2(struct UnkStruct_RunDungeon *r0)
{
}
u32 xxx_script_related_8001334(u32 r0)
{
return xxx_script_related_8098468(r0);
}
void xxx_dungeon_8001340(struct UnkStruct_RunDungeon *r0)
{
nullsub_2(r0);
RunDungeon(r0);
NDS_LoadOverlay_GroundMain();
}
void nullsub_3(s32 a0, s32 a1)
{
}
/////////////////////////////////
/// TODO merge with event_flag
/////////////////////////////////
extern void sub_80972F4(void);
extern void nullsub_128(void);
void ThoroughlyResetScriptVars(void)
{
s32 iVar1;
s32 iVar3;
u16 uVar2;
struct ScriptVarInfo *puVar1;
for(iVar3 = 0; iVar3 < 0x400; iVar3++)
{
gScriptVarBuffer[iVar3] = 0;
}
for(iVar1 = 0; iVar1 < 0x51; iVar1 = (iVar1 + 1) * 0x10000 >> 0x10)
{
puVar1 = &gScriptVarInfo[iVar1];
if (((puVar1->type != 0) && ((puVar1->type != 8)))) {
for (uVar2 = 0; uVar2 < puVar1->arrayLen; uVar2++) {
SetScriptVarArrayValue(NULL, iVar1, uVar2, puVar1->defaultValue);
}
}
}
ClearScriptVarArray(NULL, CONDITION);
ScenarioCalc(SCENARIO_SELECT,0,0);
ScenarioCalc(SCENARIO_MAIN,0,0);
ScenarioCalc(SCENARIO_SUB1,0,0);
ScenarioCalc(SCENARIO_SUB2,0,0);
ScenarioCalc(SCENARIO_SUB3,0,0);
ScenarioCalc(SCENARIO_SUB4,0,0);
ScenarioCalc(SCENARIO_SUB5,0,0);
ScenarioCalc(SCENARIO_SUB6,0,0);
ScenarioCalc(SCENARIO_SUB7,0,0);
ScenarioCalc(SCENARIO_SUB8,0,0);
ScenarioCalc(SCENARIO_SUB9,0,0);
SetScriptVarValue(NULL,GROUND_ENTER,0xa2);
SetScriptVarValue(NULL,GROUND_ENTER_LINK,0);
SetScriptVarValue(NULL,GROUND_GETOUT,0xa2);
SetScriptVarValue(NULL,GROUND_MAP,-1);
SetScriptVarValue(NULL,GROUND_PLACE,0x24);
SetScriptVarValue(NULL,DUNGEON_SELECT,-1);
SetScriptVarValue(NULL,DUNGEON_ENTER,0);
SetScriptVarValue(NULL,DUNGEON_ENTER_INDEX,-1);
SetScriptVarValue(NULL,DUNGEON_RESULT,0);
SetScriptVarValue(NULL,START_MODE,0);
SetScriptVarValue(NULL,CLEAR_COUNT,0);
SetScriptVarValue(NULL,WEATHER_KIND,-1);
SetScriptVarValue(NULL,PLAYER_KIND,0);
SetScriptVarValue(NULL,PARTNER1_KIND,0);
SetScriptVarValue(NULL,PARTNER2_KIND,0);
SetScriptVarValue(NULL,NEW_FRIEND_KIND,0);
ClearScriptVarArray(NULL,WARP_LIST);
SetScriptVarValue(NULL,WARP_LOCK,0);
SetScriptVarValue(NULL,PARTNER_TALK_KIND,0);
SetScriptVarValue(NULL,BASE_KIND,0);
SetScriptVarValue(NULL,BASE_LEVEL,0);
SetScriptVarValue(NULL,FLAG_KIND,0);
SetScriptVarValue(NULL,FLAG_KIND_CHANGE_REQUEST,0);
ClearScriptVarArray(NULL,RESCUE_SCENARIO_ORDER_LIST);
ClearScriptVarArray(NULL,RESCUE_SCENARIO_JOB_LIST);
ClearScriptVarArray(NULL,RESCUE_SCENARIO_CONQUEST_LIST);
ClearScriptVarArray(NULL,TRAINING_CONQUEST_LIST);
ClearScriptVarArray(NULL,TRAINING_PRESENT_LIST);
ClearScriptVarArray(NULL,DUNGEON_ENTER_LIST);
ClearScriptVarArray(NULL,DUNGEON_CLEAR_LIST);
ClearScriptVarArray(NULL,EVENT_S08E01);
sub_80972F4();
}
void sub_8001564(void)
{
nullsub_128();
}

View File

@@ -1,200 +0,0 @@
#include "global.h"
#include "bg_control.h"
#include "bg_palette_buffer.h"
#include "code_800558C.h"
#include "code_8009804.h"
#include "code_800C9CC.h"
#include "code_80118A4.h"
#include "string_format.h"
#include "code_8094F88.h"
#include "code_8097670.h"
#include "constants/bg_music.h"
#include "constants/main_menu.h"
#include "cpu.h"
#include "debug.h"
#include "event_flag.h"
#include "exclusive_pokemon.h"
#include "file_system.h"
#include "friend_area.h"
#include "game_options.h"
#include "main_menu1.h"
#include "main_menu2.h"
#include "memory.h"
#include "moves.h"
#include "music.h"
#include "play_time.h"
#include "pokemon.h"
#include "rescue_team_info.h"
#include "save_read.h"
#include "save.h"
#include "sprite.h"
#include "text.h"
extern void NDS_LoadOverlay_GroundMain(void);
extern void sub_8014144(void);
extern void sub_800DAAC(void);
extern void xxx_script_related_8001334(u32);
extern void LoadTitleScreen(void);
extern void nullsub_33(void);
extern u32 sub_80009D0(u32);
extern u16 gUnknown_2026E4E;
EWRAM_DATA s32 sTitleBrightness = 0;
// TODO: figure out the struct
struct UnkStruct203B040
{
u8 unk0[48];
};
EWRAM_INIT OpenedFile *gTitlePaletteFile = NULL;
extern u32 gUnknown_203B03C;
extern char gPMDBuildVersion[];
void xxx_update_stuff(u32);
void GameLoop(void)
{
u32 tmp;
u8 tmp3 = 1;
u32 nextMenu;
u32 flag;
InitHeap();
NDS_DebugInit();
sub_801180C();
NDS_LoadOverlay_GroundMain();
sub_8014144();
LoadMonsterParameters();
sub_8097670();
InitializePlayTime();
LoadGameOptions();
SetWindowBGColor();
LoadExclusivePokemon();
LoadFriendAreas();
LoadItemParameters();
LoadRescueTeamInfo();
LoadWazaParameters();
sub_80950BC();
LoadMailInfo();
sub_800CD64(0x8000, FALSE);
sub_8012284();
InitializeGameOptions(TRUE);
SetWindowTitle(gPMDBuildVersion);
sub_800DAAC();
SetSavingIconCoords(NULL);
tmp = 0;
if (ReadSaveFromPak(&tmp))
ThoroughlyResetScriptVars();
xxx_script_related_8001334(14);
xxx_script_related_8001334(15);
ClearScriptVarArray(NULL, EVENT_LOCAL);
xxx_script_related_8001334(16);
if (GetScriptVarValue(NULL, EVENT_LOCAL) == 0)
xxx_script_related_8001334(17);
while (1) {
gUnknown_203B03C = 0; // ???
sub_800A8F8(2);
ResetSprites(TRUE);
UpdateFadeInTile(0);
InitFontPalette();
sub_800CDA8(2);
ShowWindows(NULL, TRUE, TRUE);
gUnknown_2026E4E = 0x1000;
LoadTitleScreen();
SetBG2RegOffsets(0, 0);
SetBG3RegOffsets(0, 0);
sTitleBrightness = 0;
while (sTitleBrightness < 32) {
s32 i;
sTitleBrightness++;
for (i = 0; i < 240; i++)
SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], sTitleBrightness, NULL);
xxx_update_stuff(0);
}
if (tmp3) {
PrepareSavePakRead();
while ((tmp3 = ReadSavePak()))
xxx_update_stuff(0);
FinishReadSavePak();
}
tmp3 = 1;
StartNewBGM(MUS_FILE_SELECT);
flag = TRUE;
sub_80095CC(0, 20);
InitMainMenu();
while (1) {
if (sub_80363E0()) {
if (gRealInputs.pressed & L_BUTTON) {
flag = FALSE;
SetBGOBJEnableFlags(19);
} else if (!flag && (gRealInputs.held & L_BUTTON) == 0) {
flag = TRUE;
SetBGOBJEnableFlags(0);
}
if (!flag) {
xxx_update_stuff(0);
continue;
}
}
SetUpMenu();
xxx_update_stuff(0);
nextMenu = UpdateMenu();
CleanUpMenu();
if (nextMenu == 2) break;
if (nextMenu == 4) break;
if (nextMenu == MENU_NEW_GAME) break;
}
DeleteMainMenu();
while (sTitleBrightness > 0) {
s32 i;
sTitleBrightness--;
for (i = 0; i < 240; i++)
SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], sTitleBrightness, NULL);
xxx_update_stuff(0);
}
CloseFile(gTitlePaletteFile);
switch (nextMenu) {
case 2: {
s32 mailIndex = GetFirstIndexofMailType(7);
if (mailIndex != -1) {
DeleteMailAtIndex(mailIndex);
tmp3 = sub_80009D0(2);
} else {
tmp3 = sub_80009D0(1);
}
break;
}
case 4:
tmp3 = sub_80009D0(3);
break;
case MENU_NEW_GAME:
sub_80122A8();
nullsub_33();
tmp3 = sub_80009D0(0);
break;
}
}
}
void xxx_update_stuff(u32 r0)
{
DrawDialogueBoxString();
sub_8005838(NULL, 0);
nullsub_8(gGameOptionsRef->unkA);
sub_8005180();
sub_80060EC();
sub_8011860();
sub_800CB20();
LoadBufferedInputs();
CopySpritesToOam();
sub_8005304();
TransferBGPaletteBuffer();
xxx_call_update_bg_vram();
sub_8009908();
xxx_call_update_bg_sound_input();
ResetSprites(FALSE);
}

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "code_800D090_1.h"
void nullsub_189(void)
{}
@@ -42,8 +43,9 @@ void nullsub_197(void)
void nullsub_198(void)
{}
u32 sub_800DAAC(void) {
return 0;
bool8 sub_800DAAC(void)
{
return FALSE;
}
u32 sub_800DAB0(void) {

View File

@@ -5,6 +5,7 @@
#include "code_80118A4.h"
#include "code_800E9A8.h"
#include "file_system.h"
#include "main_loops.h"
#include "memory.h"
#include "dungeon_map.h"
@@ -17,7 +18,6 @@ struct unkStruct_800F18C
};
extern s32 sub_800E2C0(u32);
extern s32 sub_8000728(void);
extern u32 sub_800E900(void);
extern void sub_8009BE4(void);
extern void sub_800F204(void);

View File

@@ -1,8 +1,9 @@
#include "global.h"
#include "file_system.h"
#include "memory.h"
#include "code_800E9E4.h"
#include "dungeon_pokemon_sprites.h"
#include "file_system.h"
#include "main_loops.h"
#include "memory.h"
#include "sprite.h"
struct unkStruct_203B0D0_sub
@@ -30,7 +31,6 @@ EWRAM_INIT void *gUnknown_203B0D4 = NULL; // TODO: figure out the actual struct
EWRAM_INIT DungeonPokemonSprites *gDungeonPokemonSprites = NULL; // Todo: move to a different file, or merge files in this rom region
EWRAM_INIT SpriteOAM gUnknown_203B0DC = {0};
extern s32 sub_8000728();
OpenedFile *sub_800F1C0(s32, s32);
s32 sub_800F0F4(s32, s32);
void sub_800F204(OpenedFile *file);

View File

@@ -185,9 +185,9 @@ static const struct WindowTemplates gUnknown_80F62B0 =
.unk12 = 0,
.header = NULL,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -203,9 +203,9 @@ static const struct WindowTemplates gUnknown_80F6310 =
.unk12 = 0,
.header = NULL,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -239,7 +239,7 @@ static const struct WindowTemplates gUnknown_80F6370 =
.unk12 = 0,
.header = NULL,
},
[3] = WINDOW_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -255,9 +255,9 @@ static const struct WindowTemplates gUnknown_80F63D0 =
.unk12 = 2,
.header = NULL,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -502,7 +502,7 @@ s32 sub_803EF90(s32 a0, u8 a1)
bitsNo = 0;
for (id = 0; id < 4; id++) {
u32 *dst = mainDst;
const u32 *src = (u32 *)((&gUnknown_202EC9C->data[4] + r12[id] * 32));
const u32 *src = (u32 *)((&((u8 *)gUnknown_202EC9C->data)[4] + r12[id] * 32));
for (i = 0; i < 8; i++) {
u32 toOr1, toOr2;
@@ -534,13 +534,13 @@ s32 sub_803EF90(s32 a0, u8 a1)
if (a0 > 999) a0 = 999;
if (a0 < -999) a0 = -999;
r2 = (u32 *)(gUnknown_202EC9C->data + 0x184);
r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x184);
if (a1) {
if (a0 > 0) {
r2 = (u32 *)(gUnknown_202EC9C->data + 0x144);
r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x144);
}
else if (a0 < 0) {
r2 = (u32 *)(gUnknown_202EC9C->data + 0x164);
r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x164);
a0 = -a0;
}
}
@@ -596,7 +596,7 @@ s32 sub_803EF90(s32 a0, u8 a1)
}
if (arrId == 9 && unkBool) {
const u32 *src = (u32 *)(&gUnknown_202EC9C->data[4]);
const u32 *src = (u32 *)(&((u8 *)gUnknown_202EC9C->data)[4]);
u32 *dst = mainDst;
for (i = 0; i < 8; i++) {
u32 toOr1, toOr2;
@@ -626,7 +626,7 @@ s32 sub_803EF90(s32 a0, u8 a1)
}
{
const u32 *src = (u32 *)(&gUnknown_202EC9C->data[4] + (a0 * 32));
const u32 *src = (u32 *)(&((u8 *)gUnknown_202EC9C->data)[4] + (a0 * 32));
u32 *dst = mainDst;
for (i = 0; i < 8; i++) {
u32 toOr1, toOr2;

View File

@@ -360,7 +360,8 @@ extern const s16 gUnknown_80F6850[4];
extern OpenedFile *gDungeonNameBannerPalette;
// This functions is the main 'loop' when the player is in a Dungeon. It runs from the moment the player enters a dungeon, until they leave(by completing or by fainting).
void RunDungeon(struct UnkStruct_RunDungeon *r8)
// arm9.bin::0206A848
void RunDungeon(UnkStruct_RunDungeon *r8)
{
bool8 check;
Entity *leader;

View File

@@ -949,8 +949,8 @@ static const WindowTemplates gUnknown_8106DC8 = {
.unk12 = 0,
.header = NULL
},
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -3,16 +3,15 @@
#include "dungeon.h"
#include "event_flag.h"
#include "exclusive_pokemon.h"
#include "code_80A26CC.h"
#include "code_80958E8.h"
#include "code_80972F4.h"
#include "code_80A26CC.h"
#include "data/story_missions.h"
ALIGNED(4) const u8 gDummyScenarioText[] = _("{COLOR YELLOW_C}Scenario try dummy{RESET}");
ALIGNED(4) const u8 gBlankMission[] = _("{COLOR RED_W}???{RESET}");
extern void GeneratePelipperJobs(void);
void sub_80972F4(void)
{
ClearScriptVarArray(NULL, RESCUE_SCENARIO_ORDER_LIST);

View File

@@ -8,7 +8,7 @@
static EWRAM_DATA struct unkStruct_203B494 sUnknown_2039778 = {0};
EWRAM_INIT struct unkStruct_203B494 *gUnknown_203B494 = {0};
EWRAM_INIT struct unkStruct_203B494 *gUnknown_203B494 = { NULL }; // NDS=20EB98C
// data_810AE24.s
extern const u8 *gAdventureLogText[];
@@ -30,6 +30,7 @@ struct unkStruct_203B494 *sub_8097680(void)
return &sUnknown_2039778;
}
// arm9.bin::0206968C
void SetDungeonLocationInfo(DungeonLocation *dl)
{
gUnknown_203B494->dungeonLocation.id = dl->id;

View File

@@ -1,8 +1,9 @@
#include "global.h"
#include "code_8099328.h"
#include "code_80A26CC.h"
#include "event_flag.h"
u8 sub_80992E0(s16 *param_1, s16 *param_2)
bool8 sub_80992E0(s16 *param_1, s16 *param_2)
{
s32 sVar2;

View File

@@ -30,7 +30,7 @@ bool8 sub_8099360(u8 *dungeonId) {
return FALSE;
}
u8 sub_8099394(u8 *param) {
bool8 sub_8099394(u8 *param) {
s16 script_disc;
script_disc = GetScriptVarValue(NULL, DUNGEON_ENTER);
@@ -62,7 +62,8 @@ void sub_80993E4(void) {
*/
void sub_8099648(void);
UNUSED static NAKED void sub_80993F0(void)
NAKED
UNUSED static void sub_80993F0(void)
{
asm_unified(" .text\n"
" push {r4-r7,lr}\n"

View File

@@ -28,6 +28,8 @@
#include "friend_list_menu.h"
#include "personality_test1.h"
#include "credits2.h"
#include "main_loops.h"
#include "string_format.h"
IWRAM_INIT struct unkStruct_3001B64 *gUnknown_3001B64 = {NULL};
@@ -39,7 +41,6 @@ u8 ScriptPrintText_809B2B8(struct unkStruct_3001B64_unkC *, s32, s32, const char
bool8 IsTextboxOpen_809B40C(struct unkStruct_3001B64_unkC *);
extern void sub_801416C(s32, s32);
extern void ResetTextbox_809B294(void);
extern void sub_8014144(void);
extern s32 sub_803B168(void);
extern void sub_803B1BC(void);
@@ -771,7 +772,6 @@ void sub_802E918();
u32 sub_80282DC(u8 *r0);
void sub_809927C(u8);
void sub_80282FC(void);
void sub_8001064(void);
extern u8 CreateThankYouMailPelipper(void);
extern u8 sub_802E864(void);
extern u8 sub_802DFB0(void);

View File

@@ -30,7 +30,7 @@ u32 sub_800CDC8(void)
return gUnknown_202D800;
}
void SetWindowTitle(u8 *title)
void SetWindowTitle(const u8 *title)
{
}

77
src/data/main_loops.h Normal file
View File

@@ -0,0 +1,77 @@
static const unkTalkTable sBaseKindTable[17] = {
[0] = { .unk0 = 0, .species = MONSTER_PIKACHU },
[1] = { .unk0 = 1, .species = MONSTER_MEOWTH },
[2] = { .unk0 = 2, .species = MONSTER_EEVEE },
[3] = { .unk0 = 3, .species = MONSTER_SKITTY },
[4] = { .unk0 = 4, .species = MONSTER_SQUIRTLE },
[5] = { .unk0 = 5, .species = MONSTER_TOTODILE },
[6] = { .unk0 = 6, .species = MONSTER_MUDKIP },
[7] = { .unk0 = 7, .species = MONSTER_PSYDUCK },
[8] = { .unk0 = 8, .species = MONSTER_CHARMANDER },
[9] = { .unk0 = 9, .species = MONSTER_TORCHIC },
[10] = { .unk0 = 10, .species = MONSTER_CYNDAQUIL },
[11] = { .unk0 = 11, .species = MONSTER_CUBONE },
[12] = { .unk0 = 12, .species = MONSTER_MACHOP },
[13] = { .unk0 = 13, .species = MONSTER_BULBASAUR },
[14] = { .unk0 = 14, .species = MONSTER_CHIKORITA },
[15] = { .unk0 = 15, .species = MONSTER_TREECKO },
[16] = { .unk0 = 0, .species = MONSTER_NONE },
};
static const unkTalkTable sTalkKindTable[5] = {
[0] = { .unk0 = 1, .species = MONSTER_SQUIRTLE },
[1] = { .unk0 = 1, .species = MONSTER_TOTODILE },
[2] = { .unk0 = 3, .species = MONSTER_TORCHIC },
[3] = { .unk0 = 3, .species = MONSTER_CHIKORITA },
[4] = { .unk0 = 2, .species = MONSTER_NONE },
};
ALIGNED(4) static const u8 sPMDBuildVersion[] = _("PKDi ver 1.0 [Apr 28 2006] 16:37:54");
ALIGNED(4) static const u8 sTitlen0[] = _("titlen0");
ALIGNED(4) static const u8 sTitlen1[] = _("titlen1");
ALIGNED(4) static const u8 sTitlen2[] = _("titlen2");
/* static */ // TODO: Uncomment
ALIGNED(4) const u8* const sLoadScreenBackgroundFileNames[3] = { sTitlen0, sTitlen1, sTitlen2 };
ALIGNED(4) static const u8 sTitlen0p[] = _("titlen0p");
ALIGNED(4) static const u8 sTitlen1p[] = _("titlen1p");
ALIGNED(4) static const u8 sTitlen2p[] = _("titlen2p");
/* static */ // TODO: Uncomment
ALIGNED(4) const u8* const sLoadScreenBackgroundPaletteFileNames[3] = { sTitlen0p, sTitlen1p, sTitlen2p };
ALIGNED(4) static const u8 sSaveTextQuicksaving[] = _(
"{CENTER_ALIGN}Quicksaving your adventure...\n"
"{CENTER_ALIGN}Please don't turn off the power.");
ALIGNED(4) static const u8 sSaveTextYourAdventureHasBeenSaved[] = _("{CENTER_ALIGN}Your adventure has been saved.");
ALIGNED(4) static const u8 sSaveTextYourAdventureHasBeenSavedLong[] = _(
"{CENTER_ALIGN}Your adventure has been saved.\n"
"{CENTER_ALIGN}When you are in a dungeon, quicksave\n"
"{CENTER_ALIGN}your progress before ending the game.");
ALIGNED(4) static const u8 sSaveTextTheDataCouldNotBeWritten[] = _(
"{CENTER_ALIGN}The data could not be written.\n"
"{CENTER_ALIGN}Please turn off the power and remove\n"
"{CENTER_ALIGN}and reinsert the DS Card.");
ALIGNED(4) static const u8 sSaveTextFailed[] = _("{CENTER_ALIGN}Save failed.");
ALIGNED(4) static const u8 sSaveTextError[] = _(
"{CENTER_ALIGN}Error reading data.\n"
"{CENTER_ALIGN}Please turn off the power and reinsert\n"
"{CENTER_ALIGN}the DS Game Card.");
ALIGNED(4) static const u8 sSaveTextCantResume[] = _(
"{CENTER_ALIGN}Your data was not properly saved,\n"
"{CENTER_ALIGN}so your game cannot be resumed\n"
"{CENTER_ALIGN}from your last spot.{EXTRA_MSG}"
"{CENTER_ALIGN}Your last outing is considered a defeat.\n"
"{CENTER_ALIGN}Before shutting down, save in your\n"
"{CENTER_ALIGN}team base, or quicksave in a dungeon.");
ALIGNED(4) static const u8 sSaveTextMayNotResume[] = _(
"{CENTER_ALIGN}You may not resume your dungeon\n"
"{CENTER_ALIGN}adventure using this saved data.\n"
"{CENTER_ALIGN}Your last outing is considered a defeat.");

View File

@@ -17,11 +17,12 @@ static void DecompressAT_Finish(void);
static char DecompressAT_GetByte(s32);
static void DecompressAT_Init(u32 *);
static u32 DecompressATGlobal(u32 *, s32, const char *);
static void NDS_DecompressRLE(const void *);
static void NDS_DecompressRLE(const SiroArchive *);
const u8 *GetSiroPtr(OpenedFile *openedFile)
// arm9.bin::020093F4
const void *GetSiroPtr(OpenedFile *openedFile)
{
struct SiroArchive *siro = (struct SiroArchive *)openedFile->data;
const SiroArchive *siro = (const SiroArchive *)openedFile->data;
if (siro->magic == MAGIC_SIR0)
NDS_DecompressRLE(openedFile->data);
@@ -33,7 +34,8 @@ const u8 *GetSiroPtr(OpenedFile *openedFile)
return openedFile->data;
}
UNUSED static void *UnusedGetSir0Ptr(struct SiroArchive *siro)
// arm9.bin::020093A0
UNUSED static const void *UnusedGetSir0Ptr(const SiroArchive *siro)
{
if (siro->magic != MAGIC_SIR0)
return siro;
@@ -42,7 +44,8 @@ UNUSED static void *UnusedGetSir0Ptr(struct SiroArchive *siro)
return siro->data;
}
static void NDS_DecompressRLE(const void *unused)
// arm9.bin::02009324
static void NDS_DecompressRLE(const SiroArchive *siro)
{
}
@@ -54,14 +57,14 @@ UNUSED static void nullsub_175(void)
{
}
u32 DecompressATFile(u8 *result, s32 resultLength, OpenedFile *file)
u32 DecompressATFile(void *dst, s32 dstLen, OpenedFile *file)
{
return DecompressAT(result, resultLength, file->data);
return DecompressAT(dst, dstLen, file->data);
}
u32 DecompressAT(u8 *result, s32 resultLength, const u8 *compressedData)
u32 DecompressAT(u8 *dst, s32 dstLen, const u8 *src)
{
s32 compressedLength = compressedData[5] + (compressedData[6] << 8);
s32 compressedLength = src[5] + (src[6] << 8);
s32 bytesWritten = 0;
s32 currentByte = 0;
s32 cmdBit = 8;
@@ -69,57 +72,57 @@ u32 DecompressAT(u8 *result, s32 resultLength, const u8 *compressedData)
s32 flags[9];
s32 idxStart;
if (compressedData[0] == 'A'
&& compressedData[1] == 'T'
&& compressedData[2] == '4'
&& compressedData[3] == 'P') {
u32 tmp2 = compressedData[0x10] + (compressedData[0x11] << 8);
if (resultLength != 0 && resultLength != tmp2)
if (src[0] == 'A'
&& src[1] == 'T'
&& src[2] == '4'
&& src[3] == 'P') {
u32 tmp2 = src[0x10] + (src[0x11] << 8);
if (dstLen != 0 && dstLen != tmp2)
return 0;
idxStart = 0x12;
}
else if (compressedData[0] == 'A'
&& compressedData[1] == 'T'
&& compressedData[2] == '3'
&& compressedData[3] == 'P') {
else if (src[0] == 'A'
&& src[1] == 'T'
&& src[2] == '3'
&& src[3] == 'P') {
idxStart = 0x10;
}
else
return 0;
if (compressedData[4] == 'N') {
if (src[4] == 'N') {
// uncompressed mode, unused
for (curIndex = 0; curIndex < compressedLength; curIndex++) {
result[curIndex] = compressedData[curIndex + 7];
dst[curIndex] = src[curIndex + 7];
}
return curIndex;
}
flags[0] = compressedData[0x7] + 3;
flags[1] = compressedData[0x8] + 3;
flags[2] = compressedData[0x9] + 3;
flags[3] = compressedData[0xa] + 3;
flags[4] = compressedData[0xb] + 3;
flags[5] = compressedData[0xc] + 3;
flags[6] = compressedData[0xd] + 3;
flags[7] = compressedData[0xe] + 3;
flags[8] = compressedData[0xf] + 3;
flags[0] = src[0x7] + 3;
flags[1] = src[0x8] + 3;
flags[2] = src[0x9] + 3;
flags[3] = src[0xa] + 3;
flags[4] = src[0xb] + 3;
flags[5] = src[0xc] + 3;
flags[6] = src[0xd] + 3;
flags[7] = src[0xe] + 3;
flags[8] = src[0xf] + 3;
curIndex = idxStart;
if (curIndex < compressedLength) {
do {
if (resultLength != 0 && bytesWritten >= resultLength)
if (dstLen != 0 && bytesWritten >= dstLen)
return 0;
if (cmdBit == 8) {
currentByte = compressedData[curIndex++];
currentByte = src[curIndex++];
cmdBit = 0;
}
if ((currentByte & 0x80) == 0) {
// if bit is unset, process command
u32 command = (compressedData[curIndex] >> 4) + 3;
u32 tmp = (compressedData[curIndex] & 0xf) << 8;
u32 command = (src[curIndex] >> 4) + 3;
u32 tmp = (src[curIndex] & 0xf) << 8;
u32 c;
if (command == flags[0]) command = 0x1f;
@@ -134,78 +137,78 @@ u32 DecompressAT(u8 *result, s32 resultLength, const u8 *compressedData)
switch (command) {
case 0x1f: { // aaaa
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
c = src[curIndex++] & 0xf;
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x1e: { // abbb
u8 byte = compressedData[curIndex];
u8 byte = src[curIndex];
c = 0xF;
c = byte & c;
curIndex++;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
result[bytesWritten++] = ((((c + 1) & 0xf) << 4) | ((c + 1) & 0xf));
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
dst[bytesWritten++] = ((((c + 1) & 0xf) << 4) | ((c + 1) & 0xf));
break;
}
case 0x1d: { // babb
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
c = src[curIndex++] & 0xf;
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x1c: { // bbab
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c - 1) & 0xf) << 4) | ((c + 0) & 0xf));
c = src[curIndex++] & 0xf;
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
dst[bytesWritten++] = ((((c - 1) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x1b: { // bbba
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
c = src[curIndex++] & 0xf;
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
break;
}
case 0x1a: { // baaa -- the horrible, hard-to-match case
u8 byte = compressedData[curIndex];
u8 byte = src[curIndex];
c = 0xF;
c = byte & c;
curIndex++;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
result[bytesWritten++] = ((((c - 1) & 0xf) << 4) | ((c - 1) & 0xf));
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
dst[bytesWritten++] = ((((c - 1) & 0xf) << 4) | ((c - 1) & 0xf));
break;
}
case 0x19: { // abaa
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
c = src[curIndex++] & 0xf;
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x18: { // aaba
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 1) & 0xf) << 4) | ((c + 0) & 0xf));
c = src[curIndex++] & 0xf;
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
dst[bytesWritten++] = ((((c + 1) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x17: { // aaab
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
c = src[curIndex++] & 0xf;
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
dst[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
break;
}
default: {
tmp += (compressedData[curIndex++, curIndex++]);
tmp += (src[curIndex++, curIndex++]);
tmp += bytesWritten - 0x1000;
for(;command;command--)
{
result[bytesWritten++] = result[tmp];
dst[bytesWritten++] = dst[tmp];
tmp++;
}
}
}
} else {
// if bit is set, just copy next byte
result[bytesWritten++] = (compressedData[curIndex]);
dst[bytesWritten++] = (src[curIndex]);
curIndex++;
}
cmdBit++;
@@ -433,20 +436,26 @@ UNUSED static bool32 IsATxPCompressed_unused(char *data)
return FALSE;
}
bool8 sub_800B2D4(char *arg0, char *arg1, s32 length)
// Is this for sure part of this file?
bool8 StrsDifferent_IgnoreCase(char *strA, char *strB, s32 maxLen)
{
s32 i;
char a, b;
for (i = 0; i < length; i++) {
a = arg0[i];
b = arg1[i];
// convert to lowercase
if ('A' <= a && a <= 'Z') a += 0x20;
if ('A' <= b && b <= 'Z') b += 0x20;
for (i = 0; i < maxLen; i++) {
char a = strA[i];
char b = strB[i];
// Uppercase -> lowercase
if ('A' <= a && a <= 'Z')
a += 0x20;
if ('A' <= b && b <= 'Z')
b += 0x20;
if (a != b)
return TRUE;
if (a == '\0')
// `a` and `b` are equal here, but we check them for null terminators since `maxLen` is just a suggestion
if (a == '\0' /*&& b == '\0'*/)
break;
}
return FALSE;

View File

@@ -4823,7 +4823,8 @@ static void GenerateSecondaryTerrainFormations(u32 flag, FloorProperties *floorP
}
#else
NAKED static void GenerateSecondaryTerrainFormations(u32 flag, FloorProperties *floorProps)
NAKED
static void GenerateSecondaryTerrainFormations(u32 flag, FloorProperties *floorProps)
{
asm_unified("\n"
" push {r4-r7,lr}\n"

View File

@@ -93,7 +93,7 @@ void LoadDungeonTilesetAssets(void)
sprintf(fileName,gUnknown_80F6A1C,gUnknown_8108EC0[gDungeon->tileset]); // b%02dcel
file_1 = OpenFileAndGetFileDataPtr(fileName,&gDungeonFileArchive);
DecompressATFile((void*)gDungeon->unk11884,0x1194,file_1);
DecompressATFile(gDungeon->unk11884,0x1194,file_1);
CloseFile(file_1);
if (gDungeon->tileset < 0x40) {

View File

@@ -133,7 +133,9 @@ bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1)
.unk10 = 0x10,
.header = &header,
},
WINDOW_DUMMY, WINDOW_DUMMY, WINDOW_DUMMY
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY
},
};

View File

@@ -208,9 +208,9 @@ bool8 ShowDungeonMovesMenu(Entity * entity, bool8 addLinkOptions, bool8 addUseMo
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
u8 unk[4];
@@ -946,9 +946,9 @@ bool8 sub_8063E70(Entity *entity, Move *moves, bool8 showYesNoBox, bool8 allowBP
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
Move movesLocal[8];

View File

@@ -493,9 +493,9 @@ static void PrintOthersMenuOptions(void)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -566,9 +566,9 @@ static void PrintQuickSaveMenuOptions(void)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -619,9 +619,9 @@ static void PrintGameOptions(void)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -674,9 +674,9 @@ static void PrintDungeonOptions(void)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
s32 mapOptionUnderscoreWidths[] = {16, 25, 27};
@@ -765,9 +765,9 @@ static void PrintOthersOptions(void)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
s32 underscoreWidths[] = {19, 17, 25};
@@ -953,9 +953,9 @@ static void PrintHintsMenu(void)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -1008,9 +1008,9 @@ static void ShowChosenHintWindow(s32 hintId)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -72,9 +72,9 @@ static const WindowTemplates sRecruitmentSearchWindows = {
.unk12 = 2,
.header = &sRecruitmentWindowHeader,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -58,9 +58,9 @@ void ShowDungeonStairsMenu(Entity *mon)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -178,9 +178,9 @@ static void ShowStairsDescription(DungeonPos *pos)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
s32 i, statusesCount;

View File

@@ -188,9 +188,9 @@ bool8 ShowDungeonTeamMenu(Entity *a0)
.unk12 = 0,
.header = &sTeamWindowHeader,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -520,9 +520,9 @@ void ShowDungeonTacticsMenu(ActionContainer *a0)
.unk12 = 2,
.header = &sTeamWindowHeader,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
EntityInfo *monInfo;
@@ -755,9 +755,9 @@ void ShowDungeonSummaryOrIQMenu(ActionContainer *a0, bool8 showIq)
.unk12 = 2,
.header = &sTeamWindowHeader,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
s32 r8;
@@ -1410,9 +1410,9 @@ static void ShowStatusInfoWindow(s32 statusId)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -1488,8 +1488,8 @@ Entity *ShowDungeonToWhichMonMenu(s32 *teamId, s32 caseId)
.unk12 = 0,
.header = NULL,
},
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
bool8 bPress = FALSE;

View File

@@ -53,9 +53,9 @@ void ShowDungeonTileMenu(Entity *mon)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -168,9 +168,9 @@ static void ShowTileDescription(DungeonPos *pos)
.unk12 = 0,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
u8 trapName[0x60];

View File

@@ -19,7 +19,7 @@ void CreateDungeonMenuSubWindow(WindowTemplate *mainWindow, s32 subWindowX)
s32 i;
WindowTemplates windows = {
.id = {
[0] = WINDOW_DUMMY,
[0] = WIN_TEMPLATE_DUMMY,
[1] = {
.type = WINDOW_TYPE_NORMAL,
.pos = {22, 4},
@@ -27,8 +27,8 @@ void CreateDungeonMenuSubWindow(WindowTemplate *mainWindow, s32 subWindowX)
.height = 4,
.unk10 = 4,
},
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -48,10 +48,85 @@ extern bool8 HasCompletedAllMazes(void);
extern u8 sub_8002658(s16);
extern void sub_809733C(u32, u32);
extern void sub_80973A8(u32, u32);
extern void sub_80972F4(void);
extern void nullsub_128(void);
// A fakematch? Debugging leftover? A bug? No clue.
#define GET_PTR_x400VAR(varId)(((void*) (&gScriptVarInfo[varId - 0x466])) - 4)
void ThoroughlyResetScriptVars(void)
{
s32 iVar1;
s32 iVar3;
u16 uVar2;
struct ScriptVarInfo *puVar1;
for(iVar3 = 0; iVar3 < 0x400; iVar3++)
{
gScriptVarBuffer[iVar3] = 0;
}
for(iVar1 = 0; iVar1 < 0x51; iVar1 = (iVar1 + 1) * 0x10000 >> 0x10)
{
puVar1 = &gScriptVarInfo[iVar1];
if (((puVar1->type != 0) && ((puVar1->type != 8)))) {
for (uVar2 = 0; uVar2 < puVar1->arrayLen; uVar2++) {
SetScriptVarArrayValue(NULL, iVar1, uVar2, puVar1->defaultValue);
}
}
}
ClearScriptVarArray(NULL, CONDITION);
ScenarioCalc(SCENARIO_SELECT,0,0);
ScenarioCalc(SCENARIO_MAIN,0,0);
ScenarioCalc(SCENARIO_SUB1,0,0);
ScenarioCalc(SCENARIO_SUB2,0,0);
ScenarioCalc(SCENARIO_SUB3,0,0);
ScenarioCalc(SCENARIO_SUB4,0,0);
ScenarioCalc(SCENARIO_SUB5,0,0);
ScenarioCalc(SCENARIO_SUB6,0,0);
ScenarioCalc(SCENARIO_SUB7,0,0);
ScenarioCalc(SCENARIO_SUB8,0,0);
ScenarioCalc(SCENARIO_SUB9,0,0);
SetScriptVarValue(NULL,GROUND_ENTER,0xa2);
SetScriptVarValue(NULL,GROUND_ENTER_LINK,0);
SetScriptVarValue(NULL,GROUND_GETOUT,0xa2);
SetScriptVarValue(NULL,GROUND_MAP,-1);
SetScriptVarValue(NULL,GROUND_PLACE,0x24);
SetScriptVarValue(NULL,DUNGEON_SELECT,-1);
SetScriptVarValue(NULL,DUNGEON_ENTER,0);
SetScriptVarValue(NULL,DUNGEON_ENTER_INDEX,-1);
SetScriptVarValue(NULL,DUNGEON_RESULT,0);
SetScriptVarValue(NULL,START_MODE,0);
SetScriptVarValue(NULL,CLEAR_COUNT,0);
SetScriptVarValue(NULL,WEATHER_KIND,-1);
SetScriptVarValue(NULL,PLAYER_KIND,0);
SetScriptVarValue(NULL,PARTNER1_KIND,0);
SetScriptVarValue(NULL,PARTNER2_KIND,0);
SetScriptVarValue(NULL,NEW_FRIEND_KIND,0);
ClearScriptVarArray(NULL,WARP_LIST);
SetScriptVarValue(NULL,WARP_LOCK,0);
SetScriptVarValue(NULL,PARTNER_TALK_KIND,0);
SetScriptVarValue(NULL,BASE_KIND,0);
SetScriptVarValue(NULL,BASE_LEVEL,0);
SetScriptVarValue(NULL,FLAG_KIND,0);
SetScriptVarValue(NULL,FLAG_KIND_CHANGE_REQUEST,0);
ClearScriptVarArray(NULL,RESCUE_SCENARIO_ORDER_LIST);
ClearScriptVarArray(NULL,RESCUE_SCENARIO_JOB_LIST);
ClearScriptVarArray(NULL,RESCUE_SCENARIO_CONQUEST_LIST);
ClearScriptVarArray(NULL,TRAINING_CONQUEST_LIST);
ClearScriptVarArray(NULL,TRAINING_PRESENT_LIST);
ClearScriptVarArray(NULL,DUNGEON_ENTER_LIST);
ClearScriptVarArray(NULL,DUNGEON_CLEAR_LIST);
ClearScriptVarArray(NULL,EVENT_S08E01);
sub_80972F4();
}
void sub_8001564(void)
{
nullsub_128();
}
void ResetScriptVarArray(u8 *localVarBuf, s16 varId_)
{
struct ScriptVarInfo *infoPtr;

View File

@@ -20,6 +20,7 @@
#include "menu_input.h"
#include "moves.h"
#include "pokemon.h"
#include "pokemon_3.h"
#include "sprite.h"
#include "text.h"
@@ -46,13 +47,10 @@ extern void CreateFriendActionMenu();
extern void sub_80276A8();
bool8 sub_8027D9C(PokemonStruct1 *pokeStruct);
extern u8 sub_8027DCC(PokemonStruct1 *);
extern void SetFriendAreaActionMenuState(u32);
extern void PlaySound(u32);
extern void sub_808D31C(PokemonStruct1 *);
extern bool8 sub_808D750(s16 index_);
extern void sub_808ED00(void);
u32 sub_8027E18(PokemonStruct1 *);
u8 sub_8027E4C(PokemonStruct1 *r0);

View File

@@ -78,7 +78,7 @@ void FriendAreasMap_InitGfx(void)
DecompressATGlobalFile((u32 *)(VRAM + 0x8000), 0x0, file);
sub_8004AA4(gFriendAreasMapPtr->unk4C4C, gFriendAreasMapPtr->unk0[4], 0x10);
size = 0x4000;
DecompressATFile((u8 *) &gFriendAreasMapPtr->unk14, size, file2);
DecompressATFile(&gFriendAreasMapPtr->unk14, size, file2);
gFriendAreasMapPtr->brightness = 0;
gFriendAreasMapPtr->bgPos.x = 0;
@@ -305,9 +305,9 @@ void FriendAreasMap_PrintAvailableSubAreas(void)
.unk10 = 2,
.header = &header,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -23,6 +23,7 @@
#include "menu_input.h"
#include "moves.h"
#include "pokemon.h"
#include "pokemon_3.h"
#include "text.h"
EWRAM_INIT unkStruct_203B2B4 *gUnknown_203B2B4 = {NULL};
@@ -30,8 +31,6 @@ EWRAM_INIT unkStruct_203B2B4 *gUnknown_203B2B4 = {NULL};
#include "data/friend_list_menu.h"
extern u8 sub_8002658(s16);
extern void sub_808ED00(void);
extern s32 sub_80144A4(s32 *);
void SetFriendListMenuState(s32);

View File

@@ -5,6 +5,8 @@
#include "code_8009804.h"
#include "code_800C9CC.h"
#include "code_80118A4.h"
#include "code_80958E8.h"
#include "code_8099360.h"
#include "code_80A26CC.h"
#include "debug.h"
#include "event_flag.h"
@@ -60,12 +62,10 @@ extern void sub_809B614();
extern void sub_809CA20();
extern void sub_80A6E80();
extern void sub_8099BE4();
extern void sub_8099744();
extern void nullsub_120();
extern void sub_809B638();
extern void nullsub_106();
extern void sub_80A73EC();
extern void sub_8099750();
extern void sub_80A6E68();
extern void GroundMap_Action();
extern void nullsub_124();
@@ -75,8 +75,6 @@ extern void GroundEffect_Action();
extern void sub_809CB8C();
extern void sub_8098CC8();
extern void GeneratePelipperJobs();
extern void sub_80961B4();
extern void ClearAllItems_8091FB4();
extern u8 sub_809C730();
extern void sub_8095494(WonderMailSub *param_1, u8 index);

View File

@@ -2,7 +2,7 @@
#include "code_800C9CC.h"
#include "input.h"
EWRAM_DATA Inputs gRealInputs = {0}; // 20255F0
EWRAM_DATA Inputs gRealInputs = {0}; // GBA=20255F0 | NDS=20F5CC0
static EWRAM_DATA UnusedInputStruct sUnusedInputsRelated = {0}; // 2025600
static EWRAM_DATA u32 sUnusedScrambledInputJunk[3] = {0}; // 202562C
static EWRAM_DATA Inputs sBufferedInputs = {0}; // 2025638

View File

@@ -11,6 +11,7 @@
#include "flash.h"
#include "input.h"
#include "main.h"
#include "main_loops.h"
#include "music.h"
#include "random.h"
#include "reg_control.h"
@@ -32,11 +33,11 @@ extern const u8 IWRAM_INIT_ROM_START[];
UNUSED static const char sStringRomUserData[] = "PKD ROM USER DATA 000000";
// code_2.c
extern void GameLoop(void);
extern void InitGraphics(void);
extern void Hang(void);
// arm9.bin::02000B88
void AgbMain(void)
{
ALIGNED(4) u8 value[4];

1462
src/main_loops.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -10,9 +10,9 @@
#include "text_util.h"
#include "text.h"
static EWRAM_DATA OpenedFile *sWazaParametersFile = {0};
static EWRAM_DATA MoveDataEntry *sMovesData = {0};
static EWRAM_DATA MoveLearnset *sMoveLearnsets = {0}; // 420 entries, aka (MONSTER_DEOXYS_SPEED + 1), aka (MONSTER_MUNCHLAX)
static EWRAM_DATA OpenedFile *sWazaParametersFile = { NULL }; // NDS=213C188
static EWRAM_DATA MoveDataEntry *sMovesData = { NULL }; // NDS=213C18C
static EWRAM_DATA MoveLearnset *sMoveLearnsets = { NULL }; // NDS=0213C184 | 420 entries, aka (MONSTER_DEOXYS_SPEED + 1), aka (MONSTER_MUNCHLAX)
// data_8107010.s
extern const unkStruct_80928C0 gUnknown_81098C4;
@@ -49,6 +49,7 @@ static void unk_LinkedSequencesToMoves8(Move *, Move [8][8]);
static void unk_LinkedSequencesToMoves8_v2(Move *, Move [8][8]);
static void unk_MovePrintData(Move *, s32);
// arm9.bin::020640A0
void LoadWazaParameters(void)
{
sWazaParametersFile = OpenFileAndGetFileDataPtr(gUnknown_81098D0, &gSystemFileArchive);
@@ -160,6 +161,7 @@ s16 GetMoveTargetAndRange(Move *move, bool32 isAI)
return sMovesData[move->id].targetingFlags[isAI];
}
// arm9.bin::02063CE4
u8 GetMoveType(Move *move)
{
return sMovesData[move->id].type;

View File

@@ -22,6 +22,7 @@
#include "moves.h"
#include "party_list_menu.h"
#include "pokemon.h"
#include "pokemon_3.h"
#include "text_util.h"
#include "text.h"
@@ -32,7 +33,6 @@ static EWRAM_INIT unkStruct_203B2B8 *sUnknown_203B2B8 = {NULL};
extern u32 sub_8026F04(PokemonStruct1 *);
bool8 CanTakePokemonHeldItem(PokemonStruct1 *r0);
extern bool8 sub_808D750(s16 index_);
extern void sub_808ED00(void);
bool8 sub_8026E88(PokemonStruct1 *r0);
bool8 sub_8026EB8(PokemonStruct1 *r0);
void sub_8026E08(u32 r0);

View File

@@ -1,7 +1,6 @@
#include "global.h"
#include "globaldata.h"
#include "bg_palette_buffer.h"
#include "code_2.h"
#include "string_format.h"
#include "code_801602C.h"
#include "code_8094D28.h"
@@ -9,6 +8,7 @@
#include "constants/emotions.h"
#include "game_options.h"
#include "input.h"
#include "main_loops.h"
#include "memory.h"
#include "menu_input.h"
#include "personality_test1.h"
@@ -39,7 +39,7 @@ enum
PERSONALITY_TEST_END,
};
static EWRAM_INIT struct PersonalityTestTracker *sPersonalityTestTracker = {NULL};
static EWRAM_INIT PersonalityTestTracker *sPersonalityTestTracker = {NULL};
#include "data/personality_test1.h"
@@ -65,7 +65,7 @@ static void UpdateNatureTotals(void);
bool8 CreateTestTracker(void)
{
sPersonalityTestTracker = MemoryAlloc(sizeof(struct PersonalityTestTracker), 8);
sPersonalityTestTracker = MemoryAlloc(sizeof(PersonalityTestTracker), 8);
sub_801317C(&sPersonalityTestTracker->input);
InitializeTestStats();
sub_8099690(1);

View File

@@ -1051,7 +1051,7 @@ void GetPokemonLevelData(LevelData* a1, s32 _id, s32 level)
gLevelCurrentPokeId = id;
sprintf(buffer, "lvmp%03d", id);
file = OpenFileAndGetFileDataPtr(buffer, &gSystemFileArchive);
DecompressATFile((char*)gLevelCurrentData, 0, file);
DecompressATFile(gLevelCurrentData, 0, file);
CloseFile(file);
}
level -= 1;

View File

@@ -520,7 +520,8 @@ u32 sub_808ECFC(void)
return 0;
}
void sub_808ED00() {
void sub_808ED00()
{
s32 team[4];
s32 i;
s32 length = sub_808D580(team);

View File

@@ -5,6 +5,7 @@
#include "code_8094F88.h"
#include "code_80958E8.h"
#include "code_80972F4.h"
#include "code_8099328.h"
#include "code_8099360.h"
#include "code_80A26CC.h"
#include "constants/mailbox.h"
@@ -22,9 +23,6 @@ static EWRAM_INIT unkStruct_203B330 *sUnknown_203B330 = {NULL};
#include "data/post_office_guide2.h"
// code_8098BDC.s
extern u8 sub_80992E0(s16 *, s16 *);
static void DisplayMissionObjectives(void);
static void sub_8031A2C(void);
@@ -171,7 +169,7 @@ static void DisplayMissionObjectives(void)
case 3:
case 0:
default:
if (sub_80992E0(&auStack44, &missionIndex) != 0)
if (sub_80992E0(&auStack44, &missionIndex))
PrintStringOnWindow(10, 16, GetCurrentMissionText(missionIndex), sUnknown_203B330->unk10, 0);
else if (sub_8099360(&local_test) != 0)
PrintStringOnWindow(10, 16, sub_80975DC(sub_80A2688(local_test)), sUnknown_203B330->unk10, 0);

View File

@@ -2,51 +2,48 @@
#include "globaldata.h"
#include "random.h"
EWRAM_INIT s32 gPRNGSequenceNum = {1};
static EWRAM_INIT s32 sPRNGState = {1};
void SeedRng(u8 *seed)
void SeedRng(u8 seed[6])
{
gPRNGSequenceNum = 54021 + (seed[0] * seed[1]) + (seed[2] * seed[3]) + (seed[4] * seed[5]);
sPRNGState = 54021 + (seed[0] * seed[1]) + (seed[2] * seed[3]) + (seed[4] * seed[5]);
}
static s16 Rand16Bit(void)
{
gPRNGSequenceNum = 1566083941 * gPRNGSequenceNum + 1;
return gPRNGSequenceNum >> 16;
sPRNGState = (1566083941 * sPRNGState) + 1;
return sPRNGState >> 16;
}
s32 Rand32Bit(void)
{
s32 r1 = Rand16Bit();
s32 r2 = Rand16Bit();
return (r1 << 16) | r2;
s32 a = Rand16Bit();
s32 b = Rand16Bit();
return (a << 16) | b;
}
// Returns a random number in the range [0, cap).
s32 RandInt(s32 cap)
s32 RandInt(s32 maxExclusive)
{
return (((Rand32Bit() & 0xFFFF) * cap) >> 16) & 0xFFFF;
return (((Rand32Bit() & 0xFFFF) * maxExclusive) >> 16) & 0xFFFF;
}
// Returns a random number between a and b.
s32 RandRange(s32 a, s32 b)
s32 RandRange(s32 minInclusive, s32 maxExclusive)
{
if (a == b)
return a;
if (a < b)
return RandInt(b - a) + a;
return RandInt(a - b) + b;
if (minInclusive == maxExclusive)
return minInclusive;
else if (minInclusive < maxExclusive)
return RandInt(maxExclusive - minInclusive) + minInclusive;
else // minclusive > maxExclusive
return RandInt(minInclusive - maxExclusive) + maxExclusive;
}
s32 GetRNGSeed(void)
s32 GetRNGState(void)
{
return gPRNGSequenceNum;
return sPRNGState;
}
void SetRNGSeed(s32 state)
{
gPRNGSequenceNum = state;
gPRNGSequenceNum = Rand32Bit();
}
sPRNGState = state;
sPRNGState = Rand32Bit();
}

View File

@@ -29,7 +29,7 @@ EWRAM_DATA s32 gUnknown_202DE28 = {0};
EWRAM_INIT u32 gUnknown_203B17C = {0};
EWRAM_INIT const char *gUnknown_203B180 = {"POKE_DUNGEON__05"};
EWRAM_INIT struct UnkStruct_203B184 *gUnknown_203B184 = {0};
EWRAM_INIT struct UnkStruct_203B184 *gUnknown_203B184 = {NULL};
ALIGNED(4) static const char fill_save0[] = _("pksdir0");
ALIGNED(4) static const char fill_save1[] = _("pksdir0");
@@ -70,7 +70,7 @@ void sub_8011C40(s32 x)
gUnknown_202DE28 = x;
}
const char *GetGameInternalName(void)
static const char *GetGameInternalName(void)
{
return gUnknown_203B180; // returns POKE_DUNGEON__05
}
@@ -329,7 +329,7 @@ u32 WriteSavetoPak(s32 *param_1, u32 param_2)
if (gUnknown_203B184 == NULL) {
playerSave->unk41C = param_2;
playerSave->unk418 = sub_8011C34();
playerSave->RngState = GetRNGSeed();
playerSave->RngState = GetRNGState();
}
else {
playerSave->unk41C = gUnknown_203B184->unk054;

View File

@@ -10,7 +10,7 @@
#include "sprite.h"
#include "text.h"
static EWRAM_INIT SaveMenuWork *sUnknown_203B364 = {NULL};
static EWRAM_INIT SaveMenuWork *sSaveMenuWork = {NULL};
const WindowTemplate gUnknown_80E6F20 =
{
@@ -125,29 +125,29 @@ void CreateSaveMenu(s32 currMenu)
{
s32 index;
if (sUnknown_203B364 == NULL) {
sUnknown_203B364 = MemoryAlloc(sizeof(SaveMenuWork),8);
MemoryFill8(sUnknown_203B364,0,sizeof(SaveMenuWork));
if (sSaveMenuWork == NULL) {
sSaveMenuWork = MemoryAlloc(sizeof(SaveMenuWork),8);
MemoryFill8(sSaveMenuWork,0,sizeof(SaveMenuWork));
}
for(index = 0; index < 4; index++){
sUnknown_203B364->unk148.id[index] = gUnknown_80E6F20;
sSaveMenuWork->unk148.id[index] = gUnknown_80E6F20;
}
ResetUnusedInputStruct();
ShowWindows(&sUnknown_203B364->unk148, TRUE, TRUE);
ShowWindows(&sSaveMenuWork->unk148, TRUE, TRUE);
if (currMenu == MENU_DELETE_SAVE) {
// Beware, Deleting your Adventure
SetMenuItems(sUnknown_203B364->unk8,&sUnknown_203B364->unk148,0,&gUnknown_80E6F38,gDeletingYourAdventureMenuItems,
SetMenuItems(sSaveMenuWork->unk8,&sSaveMenuWork->unk148,0,&gUnknown_80E6F38,gDeletingYourAdventureMenuItems,
FALSE,6,FALSE);
}
else {
// Saving your Adventure
SetMenuItems(sUnknown_203B364->unk8,&sUnknown_203B364->unk148,0,&gUnknown_80E6F38,gSavingAdventureMenuItems,
SetMenuItems(sSaveMenuWork->unk8,&sSaveMenuWork->unk148,0,&gUnknown_80E6F38,gSavingAdventureMenuItems,
FALSE,6,FALSE);
}
sub_8035CF4(sUnknown_203B364->unk8,0,TRUE);
sUnknown_203B364->unk4 = 0;
sUnknown_203B364->currMenu = currMenu;
sub_8035CF4(sSaveMenuWork->unk8,0,TRUE);
sSaveMenuWork->unk4 = 0;
sSaveMenuWork->currMenu = currMenu;
sub_8038830();
}
@@ -155,12 +155,13 @@ void CleanSaveMenu(void)
{
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
if (sUnknown_203B364 != NULL) {
MemoryFree(sUnknown_203B364);
sUnknown_203B364 = NULL;
if (sSaveMenuWork != NULL) {
MemoryFree(sSaveMenuWork);
sSaveMenuWork = NULL;
}
}
// arm9.bin::02052F98
s32 UpdateSaveMenu(void)
{
s32 saveStatus;
@@ -172,14 +173,14 @@ s32 UpdateSaveMenu(void)
menu = MENU_NO_SCREEN_CHANGE;
action = 3;
switch(sUnknown_203B364->unk4)
switch(sSaveMenuWork->unk4)
{
default:
case 2:
menu = MENU_NO_SCREEN_CHANGE;
break;
case 0:
sub_8012FD8(&sUnknown_203B364->unk8[0]);
sub_8012FD8(&sSaveMenuWork->unk8[0]);
uStack_18 = 0;
sub_80140F8();
saveStatus = WriteSavetoPak(&uStack_18,sub_8011C1C());
@@ -187,76 +188,76 @@ s32 UpdateSaveMenu(void)
switch(saveStatus)
{
case SAVE_COMPLETED:
sub_8035CC0(&sUnknown_203B364->unk148,0);
if (sUnknown_203B364->currMenu == MENU_DELETE_SAVE) {
SetMenuItems(sUnknown_203B364->unk8,&sUnknown_203B364->unk148,0,&gUnknown_80E6F38,
sub_8035CC0(&sSaveMenuWork->unk148,0);
if (sSaveMenuWork->currMenu == MENU_DELETE_SAVE) {
SetMenuItems(sSaveMenuWork->unk8,&sSaveMenuWork->unk148,0,&gUnknown_80E6F38,
gDeletedSaveMenuItems,FALSE,6,FALSE);
}
else {
SetMenuItems(sUnknown_203B364->unk8,&sUnknown_203B364->unk148,0,&gUnknown_80E6F38,
SetMenuItems(sSaveMenuWork->unk8,&sSaveMenuWork->unk148,0,&gUnknown_80E6F38,
gAdventureSavedMenuItems,FALSE,6,FALSE);
}
if (sUnknown_203B364->currMenu == 0x2d) {
sUnknown_203B364->unk4 = 1;
if (sSaveMenuWork->currMenu == 0x2d) {
sSaveMenuWork->unk4 = 1;
return MENU_COMMUNICATION_1;
}
sub_8035CF4(sUnknown_203B364->unk8,0,TRUE);
sUnknown_203B364->unk4 = 1;
sub_8035CF4(sSaveMenuWork->unk8,0,TRUE);
sSaveMenuWork->unk4 = 1;
break;
case SAVE_NOT_WRTTEN:
CreateDialogueBoxAndPortrait(gUnknown_80E7178,0,0,0);
sUnknown_203B364->unk4 = 5;
sSaveMenuWork->unk4 = 5;
break;
default:
sub_8035CC0(&sUnknown_203B364->unk148,0);
if (sUnknown_203B364->currMenu == MENU_DELETE_SAVE) {
SetMenuItems(sUnknown_203B364->unk8,&sUnknown_203B364->unk148,0,&gUnknown_80E6F38,
sub_8035CC0(&sSaveMenuWork->unk148,0);
if (sSaveMenuWork->currMenu == MENU_DELETE_SAVE) {
SetMenuItems(sSaveMenuWork->unk8,&sSaveMenuWork->unk148,0,&gUnknown_80E6F38,
gAdventureCouldNotBeDeletedMenuItems,FALSE,6,FALSE);
}
else {
SetMenuItems(sUnknown_203B364->unk8,&sUnknown_203B364->unk148,0,&gUnknown_80E6F38,
SetMenuItems(sSaveMenuWork->unk8,&sSaveMenuWork->unk148,0,&gUnknown_80E6F38,
gAdventureCouldNotBeSavedMenuItems,FALSE,6,FALSE);
}
sub_8035CF4(sUnknown_203B364->unk8,0,TRUE);
sUnknown_203B364->unk4 = 1;
sub_8035CF4(sSaveMenuWork->unk8,0,TRUE);
sSaveMenuWork->unk4 = 1;
break;
}
menu = MENU_NO_SCREEN_CHANGE;
break;
case 1:
if (sub_80130A8(&sUnknown_203B364->unk8[0]) == '\0') {
sub_8013114(&sUnknown_203B364->unk8[0],&action);
if (sub_80130A8(&sSaveMenuWork->unk8[0]) == '\0') {
sub_8013114(&sSaveMenuWork->unk8[0],&action);
}
switch(action)
{
case 2:
case 4:
if ((sUnknown_203B364->currMenu == 0x29) || (sUnknown_203B364->currMenu == MENU_DELETE_SAVE)) {
sUnknown_203B364->unk4 = 1;
if ((sSaveMenuWork->currMenu == 0x29) || (sSaveMenuWork->currMenu == MENU_DELETE_SAVE)) {
sSaveMenuWork->unk4 = 1;
menu = MENU_MAIN_SCREEN;
}
else if (sUnknown_203B364->currMenu == 0x2d) {
sUnknown_203B364->unk4 = 1;
else if (sSaveMenuWork->currMenu == 0x2d) {
sSaveMenuWork->unk4 = 1;
menu = MENU_COMMUNICATION_1;
}
else if (sUnknown_203B364->currMenu == 0x2c) {
sUnknown_203B364->unk4 = 1;
else if (sSaveMenuWork->currMenu == 0x2c) {
sSaveMenuWork->unk4 = 1;
menu = 0x1f;
}
else {
mainMenu = GetMainMenu();
if (mainMenu->unk3A != 0) {
sUnknown_203B364->unk4 = 1;
sSaveMenuWork->unk4 = 1;
menu = 0x35;
}
else {
sUnknown_203B364->unk4 = 1;
menu = sUnknown_203B364->currMenu == 0x2b ? MENU_WONDER_MAIL : MENU_FRIEND_RESCUE;
sSaveMenuWork->unk4 = 1;
menu = sSaveMenuWork->currMenu == 0x2b ? MENU_WONDER_MAIL : MENU_FRIEND_RESCUE;
}
}
break;
case 3:
sUnknown_203B364->unk4 = 1;
sSaveMenuWork->unk4 = 1;
break;
}
sub_80388C4();
@@ -266,31 +267,31 @@ s32 UpdateSaveMenu(void)
void sub_8038830(void)
{
SpriteSetAffine1(&sUnknown_203B364->unk1A8, 0);
SpriteSetAffine2(&sUnknown_203B364->unk1A8, 0);
SpriteSetObjMode(&sUnknown_203B364->unk1A8, 0);
SpriteSetMosaic(&sUnknown_203B364->unk1A8, 0);
SpriteSetBpp(&sUnknown_203B364->unk1A8, 0);
SpriteSetShape(&sUnknown_203B364->unk1A8, 1);
SpriteSetAffine1(&sSaveMenuWork->unk1A8, 0);
SpriteSetAffine2(&sSaveMenuWork->unk1A8, 0);
SpriteSetObjMode(&sSaveMenuWork->unk1A8, 0);
SpriteSetMosaic(&sSaveMenuWork->unk1A8, 0);
SpriteSetBpp(&sSaveMenuWork->unk1A8, 0);
SpriteSetShape(&sSaveMenuWork->unk1A8, 1);
SpriteSetTileNum(&sUnknown_203B364->unk1A8, 0x3F0);
SpriteSetPriority(&sUnknown_203B364->unk1A8, 0);
SpriteSetPalNum(&sUnknown_203B364->unk1A8, 15);
SpriteSetTileNum(&sSaveMenuWork->unk1A8, 0x3F0);
SpriteSetPriority(&sSaveMenuWork->unk1A8, 0);
SpriteSetPalNum(&sSaveMenuWork->unk1A8, 15);
SpriteSetMatrixNum(&sUnknown_203B364->unk1A8, 0);
SpriteSetSize(&sUnknown_203B364->unk1A8, 0);
SpriteSetMatrixNum(&sSaveMenuWork->unk1A8, 0);
SpriteSetSize(&sSaveMenuWork->unk1A8, 0);
SpriteSetX(&sUnknown_203B364->unk1A8, 112);
SpriteSetY(&sUnknown_203B364->unk1A8, 104);
SpriteSetX(&sSaveMenuWork->unk1A8, 112);
SpriteSetY(&sSaveMenuWork->unk1A8, 104);
sUnknown_203B364->unk1B0 = 0;
sSaveMenuWork->unk1B0 = 0;
ResetSprites(FALSE);
}
void sub_80388C4(void)
{
if (sUnknown_203B364->unk1B0 & 8)
AddSprite(&sUnknown_203B364->unk1A8, 0x100, NULL, NULL);
if (sSaveMenuWork->unk1B0 & 8)
AddSprite(&sSaveMenuWork->unk1A8, 0x100, NULL, NULL);
sUnknown_203B364->unk1B0++;
sSaveMenuWork->unk1B0++;
}

View File

@@ -1,40 +1,40 @@
#include "global.h"
#include "cpu.h"
#include "main_loops.h"
#include "random.h"
#include "sprite.h"
static EWRAM_DATA u16 sOAMSpriteCount = {0}; // 2025670 Written to but never read
static EWRAM_DATA u16 sOAMSpriteCount = {0}; // GBA=2025670 | NDS=20EC504 | Written to but never read
static EWRAM_DATA s16 sUnknown_2025672[8] = {0};
static EWRAM_DATA s16 sUnknown_2025682[9] = {0};
static EWRAM_DATA DungeonPos sUnknown_2025694 = {0};
static EWRAM_DATA u32 sUnknown_2025698 = {0};
UNUSED static EWRAM_DATA u32 sUnused1 = {0}; // 202569C
static EWRAM_DATA SpriteList sUnknown_20256A0 = {0};
UNUSED static EWRAM_DATA u32 sUnused1 = {0}; // GBA=202569C
static EWRAM_DATA SpriteList sSpriteList = {0}; // NDS=20ED4C0
static EWRAM_DATA UnkSpriteLink sUnknown_2025EA8[128] = {0};
static EWRAM_DATA SpriteOAM sUnknown_20262A8[128] = {0};
static EWRAM_DATA s32 sSpriteCount = {0}; // 20266A8
UNUSED static EWRAM_DATA u32 sUnused2 = {0}; // 20266AC
static EWRAM_DATA s32 sSpriteCount = {0}; // GBA=20266A8
UNUSED static EWRAM_DATA u32 sUnused2 = {0}; // GBA=20266AC
#define UNK_20266B0_ARR_COUNT 160
static EWRAM_DATA unkStruct_20266B0 sUnknown_20266B0[UNK_20266B0_ARR_COUNT] = {0};
static EWRAM_DATA void *sCharMemCursor = {0}; // 2026E30
UNUSED static EWRAM_DATA u32 sUnused3 = {0}; // 2026E34
static EWRAM_DATA void *sCharMemCursor = {0}; // GBA=2026E30
UNUSED static EWRAM_DATA u32 sUnused3 = {0}; // GBA=2026E34
static EWRAM_INIT unkStruct_20266B0 *sUnknown_203B074 = {0};
// code.c
extern void nullsub_3(s32, s32);
static void RegisterSpriteParts_80052BC(UnkSpriteMem *);
static void AxResInitUnoriented(axdata *, axmain *, u32, u32, u32, bool8);
// arm9.bin::0200265C
void InitSprites(void)
{
ResetSprites(TRUE);
SetSavingIconCoords(NULL);
}
// arm9.bin::020024f4
void ResetSprites(bool8 a0)
{
s32 i;
@@ -48,7 +48,7 @@ void ResetSprites(bool8 a0)
sCharMemCursor = OBJ_VRAM0;
sUnknown_203B074 = &sUnknown_20266B0[0];
a = &sUnknown_20256A0.sprites[0];
a = &sSpriteList.sprites[0];
b = a + 1;
// 16 loops, very smart
@@ -132,10 +132,11 @@ void ResetSprites(bool8 a0)
}
}
sUnknown_20256A0.unk800 = 0;
sUnknown_20256A0.unk804 = 0;
sSpriteList.unk800 = 0;
sSpriteList.unk804 = 0;
}
// arm9.bin::020024CC
void sub_8004E8C(unkStruct_2039DB0 *a0)
{
a0->unk0 = 0xFFFF;
@@ -169,6 +170,7 @@ void sub_8004E8C(unkStruct_2039DB0 *a0)
*(_dstVar++) = *(_srcVar++); \
}
// arm9.bin::020021C4
void AddAxSprite(ax_pose *a0, axdata1 *a1, UnkSpriteMem *a2, unkStruct_2039DB0 *spriteMasks)
{
// size: 0xC
@@ -249,12 +251,13 @@ void AddAxSprite(ax_pose *a0, axdata1 *a1, UnkSpriteMem *a2, unkStruct_2039DB0 *
SpriteSetPalNum(sprite, sUnknown_2025682[sp.unk2.unk0]);
}
sUnknown_2025EA8[sSpriteCount].unk0 = sUnknown_20256A0.sprites[spriteId].unk0;
sUnknown_20256A0.sprites[spriteId].unk0 = sUnknown_2025EA8 + sSpriteCount;
sUnknown_2025EA8[sSpriteCount].unk0 = sSpriteList.sprites[spriteId].unk0;
sSpriteList.sprites[spriteId].unk0 = sUnknown_2025EA8 + sSpriteCount;
sSpriteCount++;
}
// a2 and spriteMasks are always called with NULL lol
// arm9.bin::02002088
void AddSprite(struct SpriteOAM *a0, s32 a1, struct UnkSpriteMem *a2, struct unkStruct_2039DB0 *spriteMasks)
{
s32 yPos;
@@ -286,18 +289,19 @@ void AddSprite(struct SpriteOAM *a0, s32 a1, struct UnkSpriteMem *a2, struct unk
if (a2 != NULL)
RegisterSpriteParts_80052BC(a2);
sUnknown_2025EA8[sSpriteCount].unk0 = sUnknown_20256A0.sprites[a1].unk0;
sUnknown_20256A0.sprites[a1].unk0 = &sUnknown_2025EA8[sSpriteCount];
sUnknown_2025EA8[sSpriteCount].unk0 = sSpriteList.sprites[a1].unk0;
sSpriteList.sprites[a1].unk0 = &sUnknown_2025EA8[sSpriteCount];
sSpriteCount++;
}
// arm9.bin::02002048
void sub_8005180(void)
{
UnkSpriteLink *r1;
UnkSpriteLink *r2;
r2 = &sUnknown_20256A0.sprites[0];
r2 = &sSpriteList.sprites[0];
r1 = r2;
if (r2 != NULL) {
@@ -314,6 +318,7 @@ void sub_8005180(void)
r2->unk0 = NULL;
}
// arm9.bin::02001FB0
void CopySpritesToOam(void)
{
UnkSpriteLink *sLink;
@@ -321,7 +326,7 @@ void CopySpritesToOam(void)
vu16 *oam;
s32 count;
sLink = &sUnknown_20256A0.sprites[0];
sLink = &sSpriteList.sprites[0];
oam = (vu16 *)(OAM + OAM_SIZE); // End of OAM. Work backwards
count = 0;

View File

@@ -159,17 +159,27 @@ static EWRAM_DATA MenuInputStructSub gUnknown_202EC28 = {0};
static EWRAM_INIT WindowTemplates sUnknown_203B198 = {
.id = {
[0] = {
.pos = {2, 15},
.unk0 = 0,
.type = WINDOW_TYPE_0,
.pos = { .x = 2, .y = 15 },
.width = 26,
.height = 5,
.unk10 = 7,
.unk12 = 0,
.header = NULL,
},
[1] = {
.unk0 = 0x40,
.type = WINDOW_TYPE_7,
.pos = { .x = 0, .y = 0 },
.width = 0,
.height = 0,
.unk10 = 0,
.unk12 = 0,
.header = NULL,
},
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -113,10 +113,10 @@ static const u32 gUnknown_80B853C[16] =
static const WindowTemplates sDummyWindows =
{
.id = {
[0] = WINDOW_DUMMY,
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[0] = WIN_TEMPLATE_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -54,8 +54,8 @@ static EWRAM_INIT WindowTemplates sWorldMapWindows = {
.height = 3,
.unk10 = 3,
},
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};
@@ -298,7 +298,7 @@ static void sub_801059C(void)
DecompressATGlobalFile((u32 *)(VRAM + 0x8000), 0x0, file);
sub_8004AA4(sWorldMapPtr->unk5150, sWorldMapPtr->unk1100[4], 0x10);
size = 0x4000;
DecompressATFile((u8 *) &sWorldMapPtr->unk1114, size, file2);
DecompressATFile(&sWorldMapPtr->unk1114, size, file2);
sWorldMapPtr->brightness = 0;
sWorldMapPtr->bgPos.x = 0;
@@ -492,9 +492,9 @@ static void PrintDungeonName(DungeonLocation *dungLocation)
.height = 2,
.unk10 = 2,
},
[1] = WINDOW_DUMMY,
[2] = WINDOW_DUMMY,
[3] = WINDOW_DUMMY,
[1] = WIN_TEMPLATE_DUMMY,
[2] = WIN_TEMPLATE_DUMMY,
[3] = WIN_TEMPLATE_DUMMY,
}
};

View File

@@ -1,6 +1,6 @@
.include "src/m4a.o"
.include "src/code_2.o"
.include "src/main_loops.o"
.space 0x4
.include "src/event_flag.o"

View File

@@ -1,7 +1,6 @@
.align 2
.include "src/code_2.o"
.include "src/code.o"
.include "src/main_loops.o"
.include "src/other_random.o"
.include "src/sprite.o"
.include "src/code_800558C.o"