diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/main.c | 2 | ||||
-rw-r--r-- | arm9/src/math_util.c | 30 | ||||
-rw-r--r-- | arm9/src/pokedex.c | 46 | ||||
-rw-r--r-- | arm9/src/text.c | 13 | ||||
-rw-r--r-- | arm9/src/unk_02015E30.c | 30 | ||||
-rw-r--r-- | arm9/src/unk_02021934.c | 46 | ||||
-rw-r--r-- | arm9/src/unk_0202F150.c | 2 | ||||
-rw-r--r-- | arm9/src/unk_02031734.c | 4 |
8 files changed, 85 insertions, 88 deletions
diff --git a/arm9/src/main.c b/arm9/src/main.c index f7bcf7f0..05b7f67f 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -54,8 +54,8 @@ extern struct Unk21DBE18 MOD52_021D76C8; extern u8 SDK_STATIC_BSS_START[]; -const int gGameVersion = GAME_VERSION; const int gGameLanguage = GAME_LANGUAGE; +const int gGameVersion = GAME_VERSION; THUMB_FUNC void NitroMain(void) { diff --git a/arm9/src/math_util.c b/arm9/src/math_util.c index 84dfdcfb..4ecee59c 100644 --- a/arm9/src/math_util.c +++ b/arm9/src/math_util.c @@ -6,7 +6,7 @@ extern const s16 UNK_020FFA38[]; // temporary until further notice /* * Constant tables */ -const s32 gSineTable[] = +const fx32 gSineTable[] = { FX32_CONST(0.0), // sin(0) FX32_CONST(0.017333984375), // sin(1) @@ -460,7 +460,7 @@ const s32 gSineTable[] = FX32_CONST(0.999755859375), // sin(449) }; -const u16 UNK_020EDC7E[] = // rotations? +static const u16 UNK_020EDC7E[] = // rotations? { 0x0000, 0x00B7, 0x016D, 0x0223, 0x02D9, 0x038F, 0x0445, 0x04FB, 0x05B1, 0x0667, 0x071D, 0x07D3, 0x0889, 0x093F, 0x09F5, 0x0AAB, 0x0B61, 0x0C17, 0x0CCD, 0x0D83, @@ -592,31 +592,41 @@ THUMB_FUNC s32 Sin32(s32 degrees) * Random number generators */ static u32 sMTRNG_State[624]; // Mersenne Twister seed storage/buffer +#ifdef NONMATCHING +// Using -ipa file makes the following hack unnecessary, +// but for some reason forces UNK_020EDC7E to align to +// word rather than short... +static u32 sLCRNG_State; +#define sMTRNG_State_2 sMTRNG_State +#else static union { u32 LC_State; // Linear-congruential seed storage/buffer u32 MTRNG_State[]; // Don't bother asking why Game Freak did this. Just don't. } sRNGHack; +#define sLCRNG_State sRNGHack.LC_State +#define sMTRNG_State_2 (sRNGHack.MTRNG_State + 1) +#endif // Returns the Linear-congruential buffer in full. THUMB_FUNC u32 GetLCRNGSeed() { - return sRNGHack.LC_State; + return sLCRNG_State; } // Initializes the Linear-congruential buffer with a 32-bit seed. THUMB_FUNC void SetLCRNGSeed(u32 seed) { - sRNGHack.LC_State = seed; + sLCRNG_State = seed; } // Calculates an unsigned 16-bit random integer using the Linear-congruential algorithm. THUMB_FUNC u16 LCRandom(void) { // cycle the RNG - sRNGHack.LC_State *= 0x41C64E6D; - sRNGHack.LC_State += 0x6073; - return (u16)(sRNGHack.LC_State / 65536); // shut up the compiler + sLCRNG_State *= 0x41C64E6D; + sLCRNG_State += 0x6073; + return (u16)(sLCRNG_State / 65536); // shut up the compiler } // Returns a cheap, psuedo-random unsigned 32-bit random integer from a seed. @@ -631,7 +641,7 @@ static u32 sMTRNG_XOR[2] = {0, 0x9908b0df}; // Mersenne Twister XOR mask table // Initializes the Mersenne Twister buffer with a 32-bit seed. THUMB_FUNC void SetMTRNGSeed(u32 seed) { - sRNGHack.MTRNG_State[0+1] = seed; + sMTRNG_State_2[0] = seed; for (sMTRNG_Cycles = 1; sMTRNG_Cycles < 624; sMTRNG_Cycles++) sMTRNG_State[sMTRNG_Cycles] = 1812433253 * (sMTRNG_State[sMTRNG_Cycles - 1] ^ (sMTRNG_State[sMTRNG_Cycles - 1] >> 30)) + sMTRNG_Cycles; @@ -659,8 +669,8 @@ THUMB_FUNC u32 MTRandom(void) sMTRNG_State[i] = sMTRNG_State[i + -227] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1]; } - val = (sRNGHack.MTRNG_State[623+1] & 0x80000000) | (sRNGHack.MTRNG_State[0+1] & 0x7fffffff); - sRNGHack.MTRNG_State[623+1] = sRNGHack.MTRNG_State[396+1] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1]; + val = (sMTRNG_State_2[623] & 0x80000000) | (sMTRNG_State_2[0] & 0x7fffffff); + sMTRNG_State_2[623] = sMTRNG_State_2[396] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1]; sMTRNG_Cycles = 0; } diff --git a/arm9/src/pokedex.c b/arm9/src/pokedex.c index bd1ea254..d86afa6a 100644 --- a/arm9/src/pokedex.c +++ b/arm9/src/pokedex.c @@ -226,12 +226,11 @@ void Pokedex_InitSeenDeoxysFormesArray(struct Pokedex * pokedex) static inline BOOL HasUnownLetterBeenSeen(struct Pokedex * pokedex, u8 letter) { - u8 * arr; s32 i; + u8 * arr; for (i = 0, arr = (u8 *)pokedex; i < 28; i++, arr++) { - u8 val = arr[0x010C]; - if (letter == val) + if (letter == *(arr + 0x10C)) return TRUE; } return FALSE; @@ -239,12 +238,11 @@ static inline BOOL HasUnownLetterBeenSeen(struct Pokedex * pokedex, u8 letter) static inline s32 FindFirstAvailableUnownLetterSlot(struct Pokedex * pokedex) { - u8 * arr; s32 i; + u8 * arr; for (i = 0, arr = (u8 *)pokedex; i < 28; i++, arr++) { - u8 val = arr[0x010C]; - if (val == 0xFF) + if (*(arr + 0x10C) == 0xFF) break; } return i; @@ -320,26 +318,26 @@ s32 FUN_020242C8(struct Pokedex * pokedex, u16 species, s32 r4) return r1; } -const u16 sSinnohDexMythicalMons[] = { - SPECIES_MANAPHY -}; - -const u16 sNationalDexMythicalMons[] = { - SPECIES_MEW, - SPECIES_LUGIA, - SPECIES_HO_OH, - SPECIES_CELEBI, - SPECIES_JIRACHI, - SPECIES_DEOXYS, - SPECIES_PHIONE, - SPECIES_MANAPHY, - SPECIES_DARKRAI, - SPECIES_SHAYMIN, - SPECIES_ARCEUS -}; - BOOL Pokedex_SpeciesIsNotMythical(u16 species) { + static const u16 sSinnohDexMythicalMons[] = { + SPECIES_MANAPHY + }; + + static const u16 sNationalDexMythicalMons[] = { + SPECIES_MEW, + SPECIES_LUGIA, + SPECIES_HO_OH, + SPECIES_CELEBI, + SPECIES_JIRACHI, + SPECIES_DEOXYS, + SPECIES_PHIONE, + SPECIES_MANAPHY, + SPECIES_DARKRAI, + SPECIES_SHAYMIN, + SPECIES_ARCEUS + }; + s32 i; BOOL ret = TRUE; for (i = 0; i < (s32)NELEMS(sNationalDexMythicalMons); i++) diff --git a/arm9/src/text.c b/arm9/src/text.c index efaa6f4e..3034baab 100644 --- a/arm9/src/text.c +++ b/arm9/src/text.c @@ -7,16 +7,9 @@ const struct FontInfo *gFonts = NULL; u16 UNK_021C5734[0x100]; u32 UNK_021C5714[8]; - -// These three variables are written and never read. -// GenerateFontHalfRowLookupTable sets these variables -// in a manner consistent with them being defined static -// in the scope of that function, but doing so breaks the -// allocation of other variables in this file. -u16 UNK_021C5712; u16 UNK_021C570E; u16 UNK_021C5710; - +u16 UNK_021C5712; u8 UNK_021C570C; extern u32 FUN_0200CA7C(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2); @@ -278,7 +271,6 @@ THUMB_FUNC u32 RenderFont(struct TextPrinter *printer) } } -#ifdef NONMATCHING THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) { s32 r5 = 0; @@ -312,9 +304,6 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow } } } -#else -GLOBAL_ASM("asm/nonmatchings/GenerateFontHalfRowLookupTable.s") -#endif THUMB_FUNC void DecompressGlyphTile(const u16 *src, u16 *dst) { diff --git a/arm9/src/unk_02015E30.c b/arm9/src/unk_02015E30.c index 8be466fb..2f7b5bb5 100644 --- a/arm9/src/unk_02015E30.c +++ b/arm9/src/unk_02015E30.c @@ -1,35 +1,37 @@ #include "unk_02015E30.h" -struct UnkStruct_02015E30 UNK_021C4898; +u64 UNK_021C48B0; +u64 UNK_021C48A8; +u64 UNK_021C48A0; +struct IGT * UNK_021C489C; +u32 UNK_021C4898; THUMB_FUNC void FUN_02015E30() { - UNK_021C4898.unk00 = 0; + UNK_021C4898 = 0; } THUMB_FUNC void FUN_02015E3C(struct IGT *igt) { - struct UnkStruct_02015E30 *unk1 = &UNK_021C4898; - UNK_021C4898.unk00 = 1; - UNK_021C4898.unk10 = 0; - UNK_021C4898.unk14 = 0; - UNK_021C4898.unk08 = 0; - UNK_021C4898.unk04 = igt; + UNK_021C4898 = 1; + UNK_021C48A8 = 0; + UNK_021C48A0 = 0; + UNK_021C489C = igt; - UNK_021C4898.unk18 = GetTimer3Count(); + UNK_021C48B0 = GetTimer3Count(); } THUMB_FUNC void FUN_02015E60() { - if (UNK_021C4898.unk00 != 0) + if (UNK_021C4898 != 0) { - u64 res = Timer3CountToSeconds(GetTimer3Count() - UNK_021C4898.unk18); + u64 res = Timer3CountToSeconds(GetTimer3Count() - UNK_021C48B0); - if (UNK_021C4898.unk08 < res) + if (UNK_021C48A0 < res) { - AddIGTSeconds(UNK_021C4898.unk04, (u32)(res - UNK_021C4898.unk08)); - UNK_021C4898.unk08 = res; + AddIGTSeconds(UNK_021C489C, (u32)(res - UNK_021C48A0)); + UNK_021C48A0 = res; } } } diff --git a/arm9/src/unk_02021934.c b/arm9/src/unk_02021934.c index cd66a136..ebc600fa 100644 --- a/arm9/src/unk_02021934.c +++ b/arm9/src/unk_02021934.c @@ -109,31 +109,31 @@ struct String * StringDup(struct String * src, u32 heap_id) return dest; } -static const u16 sCharset_JP[10] = { - 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, - 0xA7, 0xA8, 0xA9, 0xAA, 0xAB -}; - -static const u16 sCharset_EN[10] = { - 0x121, 0x122, 0x123, 0x124, 0x125, - 0x126, 0x127, 0x128, 0x129, 0x12A -}; - -static const u32 sPowersOfTen[10] = { - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000 -}; - void String16_FormatInteger(struct String * str, int num, u32 ndigits, int strConvMode, BOOL whichCharset) { + static const u16 sCharset_EN[10] = { + 0x121, 0x122, 0x123, 0x124, 0x125, + 0x126, 0x127, 0x128, 0x129, 0x12A + }; + + static const u16 sCharset_JP[10] = { + 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + 0xA7, 0xA8, 0xA9, 0xAA, 0xAB + }; + + static const u32 sPowersOfTen[10] = { + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000 + }; + ASSERT_STR16(str); const u16 * charbase; diff --git a/arm9/src/unk_0202F150.c b/arm9/src/unk_0202F150.c index d52857c1..ae7d2ed2 100644 --- a/arm9/src/unk_0202F150.c +++ b/arm9/src/unk_0202F150.c @@ -10,8 +10,8 @@ struct struct UnkStruct0202F150 *unk04; } UNK_021C59F4; -vu8 UNK_02105D58 = 4; vu8 UNK_02105D59 = 4; +vu8 UNK_02105D58 = 4; extern void FUN_0202D7D8(u8 *param0, u32 param1, struct UnkStruct0202F150_sub1 *param2); extern u32 FUN_0200CA60(void (*param0)(), u32 param1, u32 param2); diff --git a/arm9/src/unk_02031734.c b/arm9/src/unk_02031734.c index 65ed3bc4..57764b82 100644 --- a/arm9/src/unk_02031734.c +++ b/arm9/src/unk_02031734.c @@ -18,12 +18,10 @@ const struct UnkStruct_02031734_const1 UNK_020EEC5C = { { (u32)FUN_02032234, (u32)FUN_0203234C, 0 } }; +char UNK_02105D64[] = " FULL"; char UNK_02105D5C[] = "FREAK"; - char UNK_02105D6C[] = " GAME"; -char UNK_02105D64[] = " FULL"; - struct UnkStruct_02031734 *UNK_021C5A00; extern void FUN_0202D8D0(u32 param0, u32 param1, u32 param2); |