Match GenerateFontHalfRowLookupTable using '-ipa file'

This commit is contained in:
PikalaxALT
2021-05-16 10:19:38 -04:00
parent 3cc7de8e0d
commit 6a91d89d2c
10 changed files with 91 additions and 182 deletions

View File

@@ -110,7 +110,7 @@ ASM_PROCESSOR := $(ASM_PROCESSOR_DIR)/compile.sh
# ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o
ASFLAGS = -proc arm5te -i ../include -i .. -D$(GAME_VERSION) -D$(GAME_LANGUAGE)
CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE)
CFLAGS = -O4,p -gccext,on -proc arm946e -ipa file -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE)
CXXFLAGS = -O4,p -proc arm946e -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE)
LDFLAGS = -nodead -w off -proc v5te -interworking -map closure,unused -symtab sort -m _start
LIBS := -Llib -lsyscall
@@ -192,6 +192,10 @@ ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(LIB
# TODO: Move out to lib/Makefile
$(BUILD_DIR)/lib/%.o: MWCCVERSION = 1.2/sp2p3
$(BUILD_DIR)/lib/%.o: CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off -interworking -DFS_IMPLEMENT -enum int -W all -i ../include -ir ../include-mw -ir lib/include
# FIXME: Using -ipa file breaks .rodata alignment
$(BUILD_DIR)/src/math_util.o: CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE)
####################### Everything Else ######################

View File

@@ -1,92 +0,0 @@
.section .text
glabel GenerateFontHalfRowLookupTable
.extern UNK_021C570C
.extern UNK_021C5734
push {r3-r7, lr}
sub sp, #0x30
ldr r3, _0201C0F8 ; =UNK_021C570C
mov r5, #0x0
str r5, [sp, #0x20]
str r0, [sp, #0x24]
str r2, [sp, #0x28]
str r1, [sp, #0x2c]
strh r1, [r3, #0x6]
strh r0, [r3, #0x2]
add r0, sp, #0x20
strh r2, [r3, #0x4]
str r5, [sp, #0x14]
str r0, [sp, #0x8]
mov r12, r0
mov lr, r0
str r0, [sp, #0x18]
_0201C07E:
mov r0, #0x0
str r0, [sp, #0x10]
ldr r0, [sp, #0x18]
str r0, [sp, #0x4]
ldr r0, [sp, #0x8]
ldr r0, [r0, #0x0]
str r0, [sp, #0x1c]
_0201C08C:
mov r0, #0x0
str r0, [sp, #0xc]
mov r0, lr
str r0, [sp, #0x0]
ldr r0, [sp, #0x4]
ldr r0, [r0, #0x0]
lsl r7, r0, #0x4
_0201C09A:
ldr r0, [sp, #0x0]
mov r3, #0x0
ldr r0, [r0, #0x0]
mov r4, r12
lsl r6, r0, #0x8
_0201C0A4:
ldr r0, [r4, #0x0]
add r1, r7, #0x0
lsl r0, r0, #0xc
orr r0, r6
orr r1, r0
ldr r0, [sp, #0x1c]
add r3, r3, #0x1
add r2, r0, #0x0
orr r2, r1
lsl r1, r5, #0x1
ldr r0, _0201C0FC ; =UNK_021C5734
add r5, r5, #0x1
add r4, r4, #0x4
strh r2, [r0, r1]
cmp r3, #0x4
blt _0201C0A4
ldr r0, [sp, #0x0]
add r0, r0, #0x4
str r0, [sp, #0x0]
ldr r0, [sp, #0xc]
add r0, r0, #0x1
str r0, [sp, #0xc]
cmp r0, #0x4
blt _0201C09A
ldr r0, [sp, #0x4]
add r0, r0, #0x4
str r0, [sp, #0x4]
ldr r0, [sp, #0x10]
add r0, r0, #0x1
str r0, [sp, #0x10]
cmp r0, #0x4
blt _0201C08C
ldr r0, [sp, #0x8]
add r0, r0, #0x4
str r0, [sp, #0x8]
ldr r0, [sp, #0x14]
add r0, r0, #0x1
str r0, [sp, #0x14]
cmp r0, #0x4
blt _0201C07E
add sp, #0x30
pop {r3-r7, pc}
.balign 4
_0201C0F8: .word UNK_021C570C
_0201C0FC: .word UNK_021C5734

View File

@@ -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)
{

View File

@@ -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;
}

View File

@@ -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++)

View File

@@ -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)
{

View File

@@ -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;
}
}
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -18,11 +18,9 @@ const struct UnkStruct_02031734_const1 UNK_020EEC5C = {
{ (u32)FUN_02032234, (u32)FUN_0203234C, 0 }
};
char UNK_02105D5C[] = "FREAK";
char UNK_02105D6C[] = " GAME";
char UNK_02105D64[] = " FULL";
char UNK_02105D5C[] = "FREAK";
char UNK_02105D6C[] = " GAME";
struct UnkStruct_02031734 *UNK_021C5A00;