From a02d40d1410ad0b63f943600028348daccdebbe4 Mon Sep 17 00:00:00 2001 From: tgsm Date: Sun, 25 Jul 2021 22:35:52 -0500 Subject: Decompile scrcmd_17 -> scrcmd_amity_square Command names courtesy of DSPRE. --- arm9/src/scrcmd_amity_square.c | 117 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 arm9/src/scrcmd_amity_square.c (limited to 'arm9/src') diff --git a/arm9/src/scrcmd_amity_square.c b/arm9/src/scrcmd_amity_square.c new file mode 100644 index 00000000..aa38449f --- /dev/null +++ b/arm9/src/scrcmd_amity_square.c @@ -0,0 +1,117 @@ +#include "scrcmd.h" +#include "constants/pokemon.h" +#include "event_data.h" + +extern void FUN_0205F54C(struct ScriptState* state); +extern u16 FUN_0205F55C(struct ScriptState* state); + +static const u16 sAmitySquarePossibleAccessoriesByPokemon[6][10] = { + // TODO: accessory constants + { 0, 5, 21, 11, 26, 13, 25, 31, 16, 33 }, // Clefairy and Skitty + { 2, 19, 20, 24, 17, 0, 23, 29, 28, 15 }, // Torchic and Drifloon + { 8, 9, 3, 11, 22, 30, 17, 6, 14, 32 }, // Psyduck and Pachirisu + { 12, 18, 21, 13, 31, 9, 25, 24, 27, 6 }, // Jigglypuff and Shroomish + { 5, 3, 26, 19, 20, 1, 7, 16, 22, 15 }, // Pikachu + { 12, 30, 2, 20, 29, 4, 8, 27, 14, 10 }, // Buneary and Happiny +}; + +THUMB_FUNC BOOL ScrCmd_ClearAmitySquareSteps(struct ScriptContext* ctx) +{ + struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2); + + FUN_0205F54C(state); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_CheckAmitySquareSteps(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct ScriptState* state = SavArray_Flags_get(ctx->unk80->saveBlock2); + + *ret_ptr = FUN_0205F55C(state); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_GetAmitySquareAccessory(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + u16 species = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 rand = (u16)(LCRandom() % 100); + + u32 j; + if (rand < 15) + { + j = 0; + } + else if (rand < 30) + { + j = 1; + } + else if (rand < 45) + { + j = 2; + } + else if (rand < 60) + { + j = 3; + } + else if (rand < 70) + { + j = 4; + } + else if (rand < 80) + { + j = 5; + } + else if (rand < 88) + { + j = 6; + } + else if (rand < 93) + { + j = 7; + } + else if (rand < 98) + { + j = 8; + } + else + { + j = 9; + } + + u32 i; + switch (species) + { + case SPECIES_CLEFAIRY: + case SPECIES_SKITTY: + i = 0; + break; + case SPECIES_TORCHIC: + case SPECIES_DRIFLOON: + i = 1; + break; + case SPECIES_PSYDUCK: + case SPECIES_PACHIRISU: + i = 2; + break; + case SPECIES_JIGGLYPUFF: + case SPECIES_SHROOMISH: + i = 3; + break; + case SPECIES_PIKACHU: + i = 4; + break; + case SPECIES_BUNEARY: + case SPECIES_HAPPINY: + i = 5; + break; + default: + i = 0; + break; + } + + *ret_ptr = sAmitySquarePossibleAccessoriesByPokemon[i][j]; + return FALSE; +} -- cgit v1.2.3 From 66abfb42155c9643f5709beae069a76054660cc8 Mon Sep 17 00:00:00 2001 From: tgsm Date: Mon, 26 Jul 2021 19:06:44 -0500 Subject: scrcmd_amity_square: Use new accessory constants --- arm9/src/scrcmd_amity_square.c | 97 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 7 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/scrcmd_amity_square.c b/arm9/src/scrcmd_amity_square.c index aa38449f..c957dec1 100644 --- a/arm9/src/scrcmd_amity_square.c +++ b/arm9/src/scrcmd_amity_square.c @@ -1,4 +1,5 @@ #include "scrcmd.h" +#include "constants/accessories.h" #include "constants/pokemon.h" #include "event_data.h" @@ -6,13 +7,95 @@ extern void FUN_0205F54C(struct ScriptState* state); extern u16 FUN_0205F55C(struct ScriptState* state); static const u16 sAmitySquarePossibleAccessoriesByPokemon[6][10] = { - // TODO: accessory constants - { 0, 5, 21, 11, 26, 13, 25, 31, 16, 33 }, // Clefairy and Skitty - { 2, 19, 20, 24, 17, 0, 23, 29, 28, 15 }, // Torchic and Drifloon - { 8, 9, 3, 11, 22, 30, 17, 6, 14, 32 }, // Psyduck and Pachirisu - { 12, 18, 21, 13, 31, 9, 25, 24, 27, 6 }, // Jigglypuff and Shroomish - { 5, 3, 26, 19, 20, 1, 7, 16, 22, 15 }, // Pikachu - { 12, 30, 2, 20, 29, 4, 8, 27, 14, 10 }, // Buneary and Happiny + { // Clefairy and Skitty + ACCESSORY_WHITE_FLUFF, + ACCESSORY_ORANGE_FLUFF, + ACCESSORY_WHITE_FEATHER, + ACCESSORY_MINI_PEBBLE, + ACCESSORY_SMALL_LEAF, + ACCESSORY_BLUE_SCALE, + + ACCESSORY_WHITE_BEARD, + ACCESSORY_THIN_MUSHROOM, + ACCESSORY_BIG_SCALE, + + ACCESSORY_STUMP + }, + + { // Torchic and Drifloon + ACCESSORY_PINK_FLUFF, + ACCESSORY_RED_FEATHER, + ACCESSORY_YELLOW_FEATHER, + ACCESSORY_BLACK_BEARD, + ACCESSORY_NARROW_SCALE, + ACCESSORY_WHITE_FLUFF, + + ACCESSORY_WHITE_MOUSTACHE, + ACCESSORY_SHED_CLAW, + ACCESSORY_NARROW_LEAF, + + ACCESSORY_PURPLE_SCALE + }, + + { // Psyduck and Pachirisu + ACCESSORY_SNAGGY_PEBBLE, + ACCESSORY_JAGGED_BOULDER, + ACCESSORY_BROWN_FLUFF, + ACCESSORY_MINI_PEBBLE, + ACCESSORY_BLACK_MOUSTACHE, + ACCESSORY_SHED_HORN, + + ACCESSORY_NARROW_SCALE, + ACCESSORY_ROUND_PEBBLE, + ACCESSORY_GREEN_SCALE, + + ACCESSORY_THICK_MUSHROOM + }, + + { // Jigglypuff and Shroomish + ACCESSORY_PINK_SCALE, + ACCESSORY_BLUE_FEATHER, + ACCESSORY_WHITE_FEATHER, + ACCESSORY_BLUE_SCALE, + ACCESSORY_THIN_MUSHROOM, + ACCESSORY_JAGGED_BOULDER, + + ACCESSORY_WHITE_BEARD, + ACCESSORY_BLACK_BEARD, + ACCESSORY_BIG_LEAF, + + ACCESSORY_ROUND_PEBBLE + }, + + { // Pikachu + ACCESSORY_ORANGE_FLUFF, + ACCESSORY_BROWN_FLUFF, + ACCESSORY_SMALL_LEAF, + ACCESSORY_RED_FEATHER, + ACCESSORY_YELLOW_FEATHER, + ACCESSORY_YELLOW_FLUFF, + + ACCESSORY_GLITTER_BOULDER, + ACCESSORY_BIG_SCALE, + ACCESSORY_BLACK_MOUSTACHE, + + ACCESSORY_PURPLE_SCALE + }, + + { // Buneary and Happiny + ACCESSORY_PINK_SCALE, + ACCESSORY_SHED_HORN, + ACCESSORY_PINK_FLUFF, + ACCESSORY_YELLOW_FEATHER, + ACCESSORY_SHED_CLAW, + ACCESSORY_BLACK_FLUFF, + + ACCESSORY_SNAGGY_PEBBLE, + ACCESSORY_BIG_LEAF, + ACCESSORY_GREEN_SCALE, + + ACCESSORY_BLACK_PEBBLE + }, }; THUMB_FUNC BOOL ScrCmd_ClearAmitySquareSteps(struct ScriptContext* ctx) -- cgit v1.2.3 From a46463e4c6ca40cfc96dd47a7a28c11275a22ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Tue, 27 Jul 2021 21:30:10 +0200 Subject: decompile unk_02005CFC.s --- arm9/src/pokemon.c | 12 +++- arm9/src/unk_020040F4.c | 9 +-- arm9/src/unk_020051F4.c | 2 +- arm9/src/unk_02005CFC.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 194 insertions(+), 10 deletions(-) create mode 100644 arm9/src/unk_02005CFC.c (limited to 'arm9/src') diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c index 29075833..bd6c702a 100644 --- a/arm9/src/pokemon.c +++ b/arm9/src/pokemon.c @@ -18,6 +18,12 @@ #include "constants/moves.h" #include "constants/sinnoh_dex.h" #include "constants/trainer_classes.h" +#include "unk_020051F4.h" + +extern void FUN_02005E80(u8); +extern void FUN_02005E90(u32 param0, u32 param1, u32 param2, u32 param3); +extern u32 FUN_02005F14(s32 param0); + #pragma thumb on @@ -3303,14 +3309,14 @@ void LoadWotbl_HandleAlternateForme(int species, int forme, u16 * wotbl) ReadWholeNarcMemberByIdPair(wotbl, NARC_POKETOOL_PERSONAL_WOTBL, ResolveMonForme(species, forme)); } -void FUN_02069FB0(u32 r7, u32 r5, u32 r4, u32 r6, u32 sp18, u32 sp1C, u32 sp20) +void FUN_02069FB0(u32 r7, u32 r5, u16 r4, u32 r6, u32 sp18, u32 sp1C, u32 sp20) { if (r4 == SPECIES_CHATOT) { if (!FUN_02005F14((int)r5)) { FUN_02005E80(1); - FUN_020056AC((int)r5, (int)r4, (int)r6, (int)sp18, (int)sp20); + FUN_020056AC(r5, r4, r6, sp18, sp20); } else { @@ -3321,7 +3327,7 @@ void FUN_02069FB0(u32 r7, u32 r5, u32 r4, u32 r6, u32 sp18, u32 sp1C, u32 sp20) } else { - FUN_020056AC((int)r5, (int)r4, (int)r6, (int)sp18, (int)sp20); + FUN_020056AC(r5, r4, r6, sp18, sp20); } } diff --git a/arm9/src/unk_020040F4.c b/arm9/src/unk_020040F4.c index 5713ddf0..3436fe68 100644 --- a/arm9/src/unk_020040F4.c +++ b/arm9/src/unk_020040F4.c @@ -3,6 +3,7 @@ #include "OS_cache.h" #include "sound.h" #include "unk_0202F150.h" +#include "SPI_mic.h" u32 UNK_021C3DD8[2]; @@ -22,9 +23,6 @@ extern void NNS_SndArcPlayerStartSeqEx(u32 *, u32, s32, s32, u32); extern u16 NNS_SndPlayerCountPlayingSeqByPlayerNo(int); extern u32 NNS_SndPlayerGetSeqNo(u32 *); extern u32 NNS_SndArcGetBankInfo(u32); -extern u32 MIC_StartAutoSampling(u32); -extern u32 MIC_StopAutoSampling(); -extern u32 MIC_DoSamplingAsync(u32 param0, u32 param1, u32 param2, u32 param3); extern u32 NNS_SndWaveOutAllocChannel(u32); extern void NNS_SndWaveOutFreeChannel(u32); extern u32 NNS_SndWaveOutStart(u32, u32, void *, u32, u32, u32, u32, s32, u32, s32); @@ -650,14 +648,13 @@ THUMB_FUNC u16 FUN_02004900(u32 param0) return *ptr; } -THUMB_FUNC u32 GF_MIC_StartAutoSampling(u32 param0) +THUMB_FUNC u32 GF_MIC_StartAutoSampling(struct MIC_SamplingData *param0) { return MIC_StartAutoSampling(param0); } -THUMB_FUNC u32 GF_MIC_StopAutoSampling(u32 param0) +THUMB_FUNC u32 GF_MIC_StopAutoSampling() { -#pragma unused(param0) GetSoundDataPointer(); return MIC_StopAutoSampling(); } diff --git a/arm9/src/unk_020051F4.c b/arm9/src/unk_020051F4.c index 6da250d5..64cab171 100644 --- a/arm9/src/unk_020051F4.c +++ b/arm9/src/unk_020051F4.c @@ -14,7 +14,7 @@ extern void NNS_SndPlayerStopSeqAll(u32); extern void NNS_SndPlayerStopSeq(u32 *, u32); extern void NNS_SndPlayerSetTrackPan(u32 *, u32, u32); extern u32 FUN_02005D48(u32, u32, u32, u32); -extern void FUN_02005E80(u32); +extern void FUN_02005E80(u8); extern void FUN_02005DFC(); extern void *FUN_0201B6C8(u32 *); diff --git a/arm9/src/unk_02005CFC.c b/arm9/src/unk_02005CFC.c new file mode 100644 index 00000000..bc34f2a3 --- /dev/null +++ b/arm9/src/unk_02005CFC.c @@ -0,0 +1,181 @@ +#include "global.h" +#include "unk_02005CFC.h" +#include "SPI_mic.h" +#include "math_util.h" +#include "proto.h" +#include "sav_chatot.h" +#include "sound.h" +#include "unk_020040F4.h" +#include "unk_020051F4.h" + +THUMB_FUNC BOOL FUN_02005CFC() +{ + if (*(u8 *)FUN_02003D38(29) == 1 && FUN_02004ABC(14) == 0) + { + FUN_02005DFC(); + + return TRUE; + } + + return FALSE; +} + +THUMB_FUNC BOOL FUN_02005D20(struct SaveChatotSoundClip *param0) +{ + u8 *r4 = FUN_02003D38(30); + + if (!Chatot_exists(param0)) + { + return FALSE; + } + + if (*r4 != 1) + { + return TRUE; + } + + return FALSE; +} + +THUMB_FUNC u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3) +{ +#pragma unused(param1) + + s8 *st0 = FUN_02004DB4(); + u8 *st4 = FUN_02003D38(29); + + if (!FUN_02005D20(param0)) + { + return 0; + } + + FUN_02005614(0); + FUN_02005DFC(); + FUN_02004984(14); + u16 r4 = (u16)(LCRandom() % 8192); + + Chatot_Decode(st0, Chatot_GetData(param0)); + + struct UnkStruct_020040F4_1 st8; + + st8.unk00 = FUN_02004930(14); + st8.unk04 = 0; + st8.unk08 = FUN_02004DB4(); + st8.unk0c = 0; + st8.unk10 = 0; + st8.unk14 = 2000; + st8.unk18 = 2000; + st8.unk20 = (u32)(r4 + 0x8000); + st8.unk24 = param3 / 2 + 64; + st8.unk1c = param2; + + u32 res = FUN_02004A6C(&st8, 14); + FUN_02004AF8(14, param2); + *st4 = 1; + FUN_02005E80(0); + + return res; +} + +THUMB_FUNC void FUN_02005DFC() +{ + u8 *r5 = FUN_02003D38(15); + u8 *r4 = FUN_02003D38(29); + + if (*r5 == 1) + { + FUN_02004C3C(14); + FUN_02004A04(14); + } + + *r4 = 0; +} + +THUMB_FUNC u32 FUN_02005E28() +{ + struct MIC_SamplingData st0; + + st0.unk00 = 2; + st0.unk04 = FUN_02004DB4(); + st0.unk08 = 2000; + if ((st0.unk08 & 0x1f) != 0) + { + st0.unk08 &= ~0x1f; + } + st0.unk0c = 0x4174; + st0.unk10 = 0; + st0.unk14 = 0; + st0.unk18 = 0; + + return GF_MIC_StartAutoSampling(&st0); +} + +THUMB_FUNC void FUN_02005E64() +{ + GF_MIC_StopAutoSampling(); +} + +THUMB_FUNC void FUN_02005E6C(struct SaveChatotSoundClip *param0) +{ + Chatot_Encode(param0, FUN_02004DB4()); +} + +THUMB_FUNC void FUN_02005E80(u8 param0) +{ + *(u8 *)FUN_02003D38(30) = param0; +} + +THUMB_FUNC void FUN_02005E90(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3) +{ + struct SaveChatotSoundClip **r0 = FUN_02003D38(35); + u32 ret; + if (param0 == 0) + { + ret = FUN_02005D48(*r0, param1, param2, param3); + } + else + { + ret = FUN_02005D48(param0, param1, param2, param3); + } + + if (ret == 0) + { + FUN_02005E80(1); + FUN_020056AC(0, SPECIES_CHATOT, param3, param2, 11); + } +} + +THUMB_FUNC u32 FUN_02005EE0(struct SaveChatotSoundClip *param0) +{ + if (!Chatot_exists(param0)) + { + return 0; + } + + s8 r0 = Chatot_GetData(param0)[15]; + if (r0 < -30) + { + return 1; + } + else if (r0 >= 30 && r0 < 128) + { + return 2; + } + + return 0; +} + +THUMB_FUNC u32 FUN_02005F14(s32 param0) +{ + switch (param0) + { + case 0: + case 1: + case 5: + case 11: + case 12: + return 1; + default: + return 0; + } +} -- cgit v1.2.3 From 2caca24385a10df4f0af6000d498350cbb1e92b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Tue, 27 Jul 2021 21:43:18 +0200 Subject: rename to sound_chatot.c --- arm9/src/pokemon.c | 9 +-- arm9/src/scrcmd_sound.c | 6 +- arm9/src/sound.c | 2 +- arm9/src/sound_chatot.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++ arm9/src/unk_020051F4.c | 6 +- arm9/src/unk_02005CFC.c | 181 ------------------------------------------------ 6 files changed, 188 insertions(+), 197 deletions(-) create mode 100644 arm9/src/sound_chatot.c delete mode 100644 arm9/src/unk_02005CFC.c (limited to 'arm9/src') diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c index bd6c702a..6139a21f 100644 --- a/arm9/src/pokemon.c +++ b/arm9/src/pokemon.c @@ -19,10 +19,7 @@ #include "constants/sinnoh_dex.h" #include "constants/trainer_classes.h" #include "unk_020051F4.h" - -extern void FUN_02005E80(u8); -extern void FUN_02005E90(u32 param0, u32 param1, u32 param2, u32 param3); -extern u32 FUN_02005F14(s32 param0); +#include "sound_chatot.h" #pragma thumb on @@ -3309,7 +3306,7 @@ void LoadWotbl_HandleAlternateForme(int species, int forme, u16 * wotbl) ReadWholeNarcMemberByIdPair(wotbl, NARC_POKETOOL_PERSONAL_WOTBL, ResolveMonForme(species, forme)); } -void FUN_02069FB0(u32 r7, u32 r5, u16 r4, u32 r6, u32 sp18, u32 sp1C, u32 sp20) +void FUN_02069FB0(struct SaveChatotSoundClip *r7, u32 r5, u16 r4, s32 r6, s32 sp18, u32 sp1C, u32 sp20) { if (r4 == SPECIES_CHATOT) { @@ -3322,7 +3319,7 @@ void FUN_02069FB0(u32 r7, u32 r5, u16 r4, u32 r6, u32 sp18, u32 sp1C, u32 sp20) { if (sp1C) FUN_02005E80(1); - FUN_02005E90((int)r7, 0, (int)sp18, (int)r6); + FUN_02005E90(r7, 0, sp18, r6); } } else diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c index ae20b5a4..b2bba9a6 100644 --- a/arm9/src/scrcmd_sound.c +++ b/arm9/src/scrcmd_sound.c @@ -1,11 +1,7 @@ #include "scrcmd.h" #include "unk_020040F4.h" +#include "sound_chatot.h" -extern void* Sav2_Chatot_get(struct SaveBlock2* sav2); -extern u32 FUN_02005D20(void *); -extern void FUN_02005E6C(void *); -extern u32 FUN_02005E28(void); -extern void FUN_02005E64(void); extern BOOL FUN_02005CBC(void); extern void PlaySound(u16); extern void FUN_0204AB20(struct UnkSavStruct80 *ctx, u16); diff --git a/arm9/src/sound.c b/arm9/src/sound.c index ec65dd06..210aec2e 100644 --- a/arm9/src/sound.c +++ b/arm9/src/sound.c @@ -3,6 +3,7 @@ #include "SPI_mic.h" #include "SPI_pm.h" #include "unk_020040F4.h" +#include "sound_chatot.h" #pragma thumb on @@ -21,7 +22,6 @@ void FUN_020040DC(void); extern void FUN_0200521C(int); extern void FUN_0200538C(int, int, int); extern BOOL FUN_02005404(void); -extern void FUN_02005CFC(void); void InitSoundData(struct SaveChatotSoundClip * chatot, struct Options * options) { diff --git a/arm9/src/sound_chatot.c b/arm9/src/sound_chatot.c new file mode 100644 index 00000000..c2a4e913 --- /dev/null +++ b/arm9/src/sound_chatot.c @@ -0,0 +1,181 @@ +#include "global.h" +#include "sound_chatot.h" +#include "SPI_mic.h" +#include "math_util.h" +#include "proto.h" +#include "sav_chatot.h" +#include "sound.h" +#include "unk_020040F4.h" +#include "unk_020051F4.h" + +THUMB_FUNC BOOL FUN_02005CFC() +{ + if (*(u8 *)FUN_02003D38(29) == 1 && FUN_02004ABC(14) == 0) + { + FUN_02005DFC(); + + return TRUE; + } + + return FALSE; +} + +THUMB_FUNC BOOL FUN_02005D20(struct SaveChatotSoundClip *param0) +{ + u8 *r4 = FUN_02003D38(30); + + if (!Chatot_exists(param0)) + { + return FALSE; + } + + if (*r4 != 1) + { + return TRUE; + } + + return FALSE; +} + +THUMB_FUNC u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3) +{ +#pragma unused(param1) + + s8 *st0 = FUN_02004DB4(); + u8 *st4 = FUN_02003D38(29); + + if (!FUN_02005D20(param0)) + { + return 0; + } + + FUN_02005614(0); + FUN_02005DFC(); + FUN_02004984(14); + u16 r4 = (u16)(LCRandom() % 8192); + + Chatot_Decode(st0, Chatot_GetData(param0)); + + struct UnkStruct_020040F4_1 st8; + + st8.unk00 = FUN_02004930(14); + st8.unk04 = 0; + st8.unk08 = FUN_02004DB4(); + st8.unk0c = 0; + st8.unk10 = 0; + st8.unk14 = 2000; + st8.unk18 = 2000; + st8.unk20 = (u32)(r4 + 0x8000); + st8.unk24 = param3 / 2 + 64; + st8.unk1c = param2; + + u32 res = FUN_02004A6C(&st8, 14); + FUN_02004AF8(14, param2); + *st4 = 1; + FUN_02005E80(0); + + return res; +} + +THUMB_FUNC void FUN_02005DFC() +{ + u8 *r5 = FUN_02003D38(15); + u8 *r4 = FUN_02003D38(29); + + if (*r5 == 1) + { + FUN_02004C3C(14); + FUN_02004A04(14); + } + + *r4 = 0; +} + +THUMB_FUNC u32 FUN_02005E28() +{ + struct MIC_SamplingData st0; + + st0.unk00 = 2; + st0.unk04 = FUN_02004DB4(); + st0.unk08 = 2000; + if ((st0.unk08 & 0x1f) != 0) + { + st0.unk08 &= ~0x1f; + } + st0.unk0c = 0x4174; + st0.unk10 = 0; + st0.unk14 = 0; + st0.unk18 = 0; + + return GF_MIC_StartAutoSampling(&st0); +} + +THUMB_FUNC void FUN_02005E64() +{ + GF_MIC_StopAutoSampling(); +} + +THUMB_FUNC void FUN_02005E6C(struct SaveChatotSoundClip *param0) +{ + Chatot_Encode(param0, FUN_02004DB4()); +} + +THUMB_FUNC void FUN_02005E80(u8 param0) +{ + *(u8 *)FUN_02003D38(30) = param0; +} + +THUMB_FUNC void FUN_02005E90(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3) +{ + struct SaveChatotSoundClip **r0 = FUN_02003D38(35); + u32 ret; + if (param0 == 0) + { + ret = FUN_02005D48(*r0, param1, param2, param3); + } + else + { + ret = FUN_02005D48(param0, param1, param2, param3); + } + + if (ret == 0) + { + FUN_02005E80(1); + FUN_020056AC(0, SPECIES_CHATOT, param3, param2, 11); + } +} + +THUMB_FUNC u32 FUN_02005EE0(struct SaveChatotSoundClip *param0) +{ + if (!Chatot_exists(param0)) + { + return 0; + } + + s8 r0 = Chatot_GetData(param0)[15]; + if (r0 < -30) + { + return 1; + } + else if (r0 >= 30 && r0 < 128) + { + return 2; + } + + return 0; +} + +THUMB_FUNC u32 FUN_02005F14(s32 param0) +{ + switch (param0) + { + case 0: + case 1: + case 5: + case 11: + case 12: + return 1; + default: + return 0; + } +} diff --git a/arm9/src/unk_020051F4.c b/arm9/src/unk_020051F4.c index 64cab171..53311039 100644 --- a/arm9/src/unk_020051F4.c +++ b/arm9/src/unk_020051F4.c @@ -6,6 +6,7 @@ #include "sound.h" #include "unk_020040F4.h" #include "unk_0200CA44.h" +#include "sound_chatot.h" extern u32 NNS_SndArcPlayerStartSeq(u32 *, u32); extern u32 NNS_SndArcPlayerStartSeqEx(u32 *, s32, s32, s32, u32); @@ -13,9 +14,6 @@ extern void NNS_SndPlayerStopSeqBySeqNo(u32, u32); extern void NNS_SndPlayerStopSeqAll(u32); extern void NNS_SndPlayerStopSeq(u32 *, u32); extern void NNS_SndPlayerSetTrackPan(u32 *, u32, u32); -extern u32 FUN_02005D48(u32, u32, u32, u32); -extern void FUN_02005E80(u8); -extern void FUN_02005DFC(); extern void *FUN_0201B6C8(u32 *); THUMB_FUNC u32 FUN_020051F4(u16 param0) @@ -281,7 +279,7 @@ THUMB_FUNC void FUN_0200554C(u32 param0) THUMB_FUNC u32 FUN_02005578(u16 species) { u8 *r4 = FUN_02003D38(17); - u32 *r0 = FUN_02003D38(35); + struct SaveChatotSoundClip **r0 = FUN_02003D38(35); if (species != SPECIES_CHATOT) { diff --git a/arm9/src/unk_02005CFC.c b/arm9/src/unk_02005CFC.c deleted file mode 100644 index bc34f2a3..00000000 --- a/arm9/src/unk_02005CFC.c +++ /dev/null @@ -1,181 +0,0 @@ -#include "global.h" -#include "unk_02005CFC.h" -#include "SPI_mic.h" -#include "math_util.h" -#include "proto.h" -#include "sav_chatot.h" -#include "sound.h" -#include "unk_020040F4.h" -#include "unk_020051F4.h" - -THUMB_FUNC BOOL FUN_02005CFC() -{ - if (*(u8 *)FUN_02003D38(29) == 1 && FUN_02004ABC(14) == 0) - { - FUN_02005DFC(); - - return TRUE; - } - - return FALSE; -} - -THUMB_FUNC BOOL FUN_02005D20(struct SaveChatotSoundClip *param0) -{ - u8 *r4 = FUN_02003D38(30); - - if (!Chatot_exists(param0)) - { - return FALSE; - } - - if (*r4 != 1) - { - return TRUE; - } - - return FALSE; -} - -THUMB_FUNC u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3) -{ -#pragma unused(param1) - - s8 *st0 = FUN_02004DB4(); - u8 *st4 = FUN_02003D38(29); - - if (!FUN_02005D20(param0)) - { - return 0; - } - - FUN_02005614(0); - FUN_02005DFC(); - FUN_02004984(14); - u16 r4 = (u16)(LCRandom() % 8192); - - Chatot_Decode(st0, Chatot_GetData(param0)); - - struct UnkStruct_020040F4_1 st8; - - st8.unk00 = FUN_02004930(14); - st8.unk04 = 0; - st8.unk08 = FUN_02004DB4(); - st8.unk0c = 0; - st8.unk10 = 0; - st8.unk14 = 2000; - st8.unk18 = 2000; - st8.unk20 = (u32)(r4 + 0x8000); - st8.unk24 = param3 / 2 + 64; - st8.unk1c = param2; - - u32 res = FUN_02004A6C(&st8, 14); - FUN_02004AF8(14, param2); - *st4 = 1; - FUN_02005E80(0); - - return res; -} - -THUMB_FUNC void FUN_02005DFC() -{ - u8 *r5 = FUN_02003D38(15); - u8 *r4 = FUN_02003D38(29); - - if (*r5 == 1) - { - FUN_02004C3C(14); - FUN_02004A04(14); - } - - *r4 = 0; -} - -THUMB_FUNC u32 FUN_02005E28() -{ - struct MIC_SamplingData st0; - - st0.unk00 = 2; - st0.unk04 = FUN_02004DB4(); - st0.unk08 = 2000; - if ((st0.unk08 & 0x1f) != 0) - { - st0.unk08 &= ~0x1f; - } - st0.unk0c = 0x4174; - st0.unk10 = 0; - st0.unk14 = 0; - st0.unk18 = 0; - - return GF_MIC_StartAutoSampling(&st0); -} - -THUMB_FUNC void FUN_02005E64() -{ - GF_MIC_StopAutoSampling(); -} - -THUMB_FUNC void FUN_02005E6C(struct SaveChatotSoundClip *param0) -{ - Chatot_Encode(param0, FUN_02004DB4()); -} - -THUMB_FUNC void FUN_02005E80(u8 param0) -{ - *(u8 *)FUN_02003D38(30) = param0; -} - -THUMB_FUNC void FUN_02005E90(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3) -{ - struct SaveChatotSoundClip **r0 = FUN_02003D38(35); - u32 ret; - if (param0 == 0) - { - ret = FUN_02005D48(*r0, param1, param2, param3); - } - else - { - ret = FUN_02005D48(param0, param1, param2, param3); - } - - if (ret == 0) - { - FUN_02005E80(1); - FUN_020056AC(0, SPECIES_CHATOT, param3, param2, 11); - } -} - -THUMB_FUNC u32 FUN_02005EE0(struct SaveChatotSoundClip *param0) -{ - if (!Chatot_exists(param0)) - { - return 0; - } - - s8 r0 = Chatot_GetData(param0)[15]; - if (r0 < -30) - { - return 1; - } - else if (r0 >= 30 && r0 < 128) - { - return 2; - } - - return 0; -} - -THUMB_FUNC u32 FUN_02005F14(s32 param0) -{ - switch (param0) - { - case 0: - case 1: - case 5: - case 11: - case 12: - return 1; - default: - return 0; - } -} -- cgit v1.2.3 From 610a801e1793ae3242aee3855bceae30aff019f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Tue, 27 Jul 2021 21:49:23 +0200 Subject: document some chatot sound functions --- arm9/src/scrcmd_sound.c | 6 +++--- arm9/src/sound_chatot.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c index b2bba9a6..94e7b69d 100644 --- a/arm9/src/scrcmd_sound.c +++ b/arm9/src/scrcmd_sound.c @@ -211,7 +211,7 @@ THUMB_FUNC BOOL ScrCmd_StartChatotRecord(struct ScriptContext* ctx) { u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); - if (FUN_02005E28() == 0) + if (Chatot_startRecording() == 0) { *ret_ptr = 1; return FALSE; @@ -226,14 +226,14 @@ THUMB_FUNC BOOL ScrCmd_StartChatotRecord(struct ScriptContext* ctx) THUMB_FUNC BOOL ScrCmd_StopChatotRecord(struct ScriptContext* ctx) { #pragma unused(ctx) - FUN_02005E64(); + Chatot_stopRecording(); return TRUE; } THUMB_FUNC BOOL ScrCmd_SaveChatotCry(struct ScriptContext* ctx) { void* unk = Sav2_Chatot_get(ctx->unk80->saveBlock2); - FUN_02005E6C(unk); + Chatot_saveRecording(unk); return TRUE; } diff --git a/arm9/src/sound_chatot.c b/arm9/src/sound_chatot.c index c2a4e913..085b6104 100644 --- a/arm9/src/sound_chatot.c +++ b/arm9/src/sound_chatot.c @@ -91,7 +91,7 @@ THUMB_FUNC void FUN_02005DFC() *r4 = 0; } -THUMB_FUNC u32 FUN_02005E28() +THUMB_FUNC u32 Chatot_startRecording() { struct MIC_SamplingData st0; @@ -110,12 +110,12 @@ THUMB_FUNC u32 FUN_02005E28() return GF_MIC_StartAutoSampling(&st0); } -THUMB_FUNC void FUN_02005E64() +THUMB_FUNC void Chatot_stopRecording() { GF_MIC_StopAutoSampling(); } -THUMB_FUNC void FUN_02005E6C(struct SaveChatotSoundClip *param0) +THUMB_FUNC void Chatot_saveRecording(struct SaveChatotSoundClip *param0) { Chatot_Encode(param0, FUN_02004DB4()); } -- cgit v1.2.3 From 599ff56901be2bdee6e96d202a9210685b051daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Tue, 27 Jul 2021 21:58:07 +0200 Subject: document Chatot_checkCry --- arm9/src/scrcmd_sound.c | 2 +- arm9/src/sound_chatot.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c index 94e7b69d..8e59c182 100644 --- a/arm9/src/scrcmd_sound.c +++ b/arm9/src/scrcmd_sound.c @@ -195,7 +195,7 @@ THUMB_FUNC BOOL ScrCmd_CheckChatotCry(struct ScriptContext* ctx) u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); void* unk = Sav2_Chatot_get(ctx->unk80->saveBlock2); - if (FUN_02005D20(unk) == 1) + if (Chatot_checkCry(unk) == 1) { *ret_ptr = 1; return FALSE; diff --git a/arm9/src/sound_chatot.c b/arm9/src/sound_chatot.c index 085b6104..71cc1abc 100644 --- a/arm9/src/sound_chatot.c +++ b/arm9/src/sound_chatot.c @@ -20,7 +20,7 @@ THUMB_FUNC BOOL FUN_02005CFC() return FALSE; } -THUMB_FUNC BOOL FUN_02005D20(struct SaveChatotSoundClip *param0) +THUMB_FUNC BOOL Chatot_checkCry(struct SaveChatotSoundClip *param0) { u8 *r4 = FUN_02003D38(30); @@ -44,7 +44,7 @@ THUMB_FUNC u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 s8 *st0 = FUN_02004DB4(); u8 *st4 = FUN_02003D38(29); - if (!FUN_02005D20(param0)) + if (!Chatot_checkCry(param0)) { return 0; } -- cgit v1.2.3 From ac24b510d854953ef9d6f4b412a7de77da29757e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 4 Aug 2021 21:09:49 +0200 Subject: add void in parameter list --- arm9/src/scrcmd_sound.c | 3 ++- arm9/src/sound_chatot.c | 8 ++++---- arm9/src/unk_020040F4.c | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c index 8e59c182..b0993387 100644 --- a/arm9/src/scrcmd_sound.c +++ b/arm9/src/scrcmd_sound.c @@ -37,7 +37,8 @@ THUMB_FUNC BOOL ScrCmd_PlayBgm(struct ScriptContext *ctx) THUMB_FUNC BOOL ScrCmd_StopBgm(struct ScriptContext *ctx) { - u32 unk0 = FUN_02004124(ScriptReadHalfword(ctx)); + ScriptReadHalfword(ctx); + u32 unk0 = FUN_02004124(); FUN_02005350(unk0, 0); return FALSE; } diff --git a/arm9/src/sound_chatot.c b/arm9/src/sound_chatot.c index 71cc1abc..2efe4843 100644 --- a/arm9/src/sound_chatot.c +++ b/arm9/src/sound_chatot.c @@ -8,7 +8,7 @@ #include "unk_020040F4.h" #include "unk_020051F4.h" -THUMB_FUNC BOOL FUN_02005CFC() +THUMB_FUNC BOOL FUN_02005CFC(void) { if (*(u8 *)FUN_02003D38(29) == 1 && FUN_02004ABC(14) == 0) { @@ -77,7 +77,7 @@ THUMB_FUNC u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 return res; } -THUMB_FUNC void FUN_02005DFC() +THUMB_FUNC void FUN_02005DFC(void) { u8 *r5 = FUN_02003D38(15); u8 *r4 = FUN_02003D38(29); @@ -91,7 +91,7 @@ THUMB_FUNC void FUN_02005DFC() *r4 = 0; } -THUMB_FUNC u32 Chatot_startRecording() +THUMB_FUNC u32 Chatot_startRecording(void) { struct MIC_SamplingData st0; @@ -110,7 +110,7 @@ THUMB_FUNC u32 Chatot_startRecording() return GF_MIC_StartAutoSampling(&st0); } -THUMB_FUNC void Chatot_stopRecording() +THUMB_FUNC void Chatot_stopRecording(void) { GF_MIC_StopAutoSampling(); } diff --git a/arm9/src/unk_020040F4.c b/arm9/src/unk_020040F4.c index 3436fe68..fa1d968f 100644 --- a/arm9/src/unk_020040F4.c +++ b/arm9/src/unk_020040F4.c @@ -57,7 +57,7 @@ THUMB_FUNC void FUN_020040F4(u8 param0) *ptr = param0; } -THUMB_FUNC u8 FUN_02004104() +THUMB_FUNC u8 FUN_02004104(void) { u8 *ptr = FUN_02003D38(5); @@ -72,7 +72,7 @@ THUMB_FUNC void FUN_02004110(u16 param0) FUN_02004130(0); } -THUMB_FUNC u16 FUN_02004124() +THUMB_FUNC u16 FUN_02004124(void) { u16 *ptr = FUN_02003D38(9); @@ -85,7 +85,7 @@ THUMB_FUNC void FUN_02004130(u16 param0) *ptr = param0; } -THUMB_FUNC u16 FUN_02004140() +THUMB_FUNC u16 FUN_02004140(void) { u16 *ptr = FUN_02003D38(10); @@ -469,7 +469,7 @@ THUMB_FUNC void FUN_02004724(int param0) FUN_0200521C(param0); } -THUMB_FUNC void FUN_02004738() +THUMB_FUNC void FUN_02004738(void) { GF_Snd_RestoreState(FUN_02004748(4)); } @@ -542,7 +542,7 @@ THUMB_FUNC void FUN_020047C8(u8 param0, u8 param1) *ptr = param1; } -THUMB_FUNC void FUN_02004810() +THUMB_FUNC void FUN_02004810(void) { u8 *ptr = FUN_02003D38(11); u8 *ptr2 = FUN_02003D38(12); @@ -653,7 +653,7 @@ THUMB_FUNC u32 GF_MIC_StartAutoSampling(struct MIC_SamplingData *param0) return MIC_StartAutoSampling(param0); } -THUMB_FUNC u32 GF_MIC_StopAutoSampling() +THUMB_FUNC u32 GF_MIC_StopAutoSampling(void) { GetSoundDataPointer(); return MIC_StopAutoSampling(); @@ -911,7 +911,7 @@ THUMB_FUNC void FUN_02004C3C(u32 param0) } } -THUMB_FUNC BOOL GF_SndCaptureIsActive() +THUMB_FUNC BOOL GF_SndCaptureIsActive(void) { return NNS_SndCaptureIsActive(); } @@ -933,7 +933,7 @@ THUMB_FUNC void GF_SndCaptureSetReverbVolume(u32 param0, u32 param1) NNS_SndCaptureSetReverbVolume(param0, param1); } -THUMB_FUNC void FUN_02004CB4() +THUMB_FUNC void FUN_02004CB4(void) { GetSoundDataPointer(); @@ -945,7 +945,7 @@ THUMB_FUNC void FUN_02004CB4() NNS_SndCaptureStartEffect(r4, 0x1000, 0, 0x55F0, 2, FUN_02005068, st8); } -THUMB_FUNC void GF_SndCaptureStopEffect() +THUMB_FUNC void GF_SndCaptureStopEffect(void) { NNS_SndCaptureStopEffect(); } @@ -997,7 +997,7 @@ THUMB_FUNC void FUN_02004D84(u32 param0) *(u32 *)FUN_02003D38(7) = param0; } -THUMB_FUNC u16 FUN_02004D94() +THUMB_FUNC u16 FUN_02004D94(void) { u16 *ptr = FUN_02003D38(7); @@ -1010,7 +1010,7 @@ THUMB_FUNC u16 FUN_02004D94() return --(*ptr); } -THUMB_FUNC u8 *FUN_02004DB4() +THUMB_FUNC u8 *FUN_02004DB4(void) { return UNK_021C3DE0; } @@ -1342,7 +1342,7 @@ THUMB_FUNC void FUN_0200516C(u32 param0) GF_SndCaptureIsActive(); } -THUMB_FUNC void FUN_020051AC() +THUMB_FUNC void FUN_020051AC(void) { if (FUN_02005404() == FALSE && GF_SndPlayerGetSeqNo(GetSoundPlayer(0)) != -1 && FUN_02004124() != 0x47e) -- cgit v1.2.3 From e7a61a19cda2047c8f47ed52cd5253e94f2379ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 4 Aug 2021 21:14:26 +0200 Subject: use BOOL --- arm9/src/sound_chatot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/sound_chatot.c b/arm9/src/sound_chatot.c index 2efe4843..06b2fc64 100644 --- a/arm9/src/sound_chatot.c +++ b/arm9/src/sound_chatot.c @@ -165,7 +165,7 @@ THUMB_FUNC u32 FUN_02005EE0(struct SaveChatotSoundClip *param0) return 0; } -THUMB_FUNC u32 FUN_02005F14(s32 param0) +THUMB_FUNC BOOL FUN_02005F14(s32 param0) { switch (param0) { @@ -174,8 +174,8 @@ THUMB_FUNC u32 FUN_02005F14(s32 param0) case 5: case 11: case 12: - return 1; + return TRUE; default: - return 0; + return FALSE; } } -- cgit v1.2.3 From 7ab3252bf751152c746f1f395105d919ffd35600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sun, 8 Aug 2021 19:40:13 +0200 Subject: decompile unk_02008AA4.s --- arm9/src/unk_02008AA4.c | 257 ++++++++++++++++++++++++++++++++++++++++++++++++ arm9/src/unk_0200BB14.c | 60 ++++------- 2 files changed, 275 insertions(+), 42 deletions(-) create mode 100644 arm9/src/unk_02008AA4.c (limited to 'arm9/src') diff --git a/arm9/src/unk_02008AA4.c b/arm9/src/unk_02008AA4.c new file mode 100644 index 00000000..2d7fb77d --- /dev/null +++ b/arm9/src/unk_02008AA4.c @@ -0,0 +1,257 @@ +#include "global.h" +#include "unk_02008AA4.h" +#include "GX_vramcnt.h" +#include "heap.h" +#include "unk_0200BB14.h" + +extern u32 FUN_020094F0(u32 param0, s32 param1); +extern u32 FUN_02009C80(u32, u32); +extern u32 FUN_02009544(u32); +extern u32 FUN_02009E54(u32 param0, u32 param1); +extern u32 FUN_02009C5C(u32); +extern u32 FUN_02009574(u32); +extern u32 FUN_0200958C(u32); +extern u32 FUN_020095A4(u32); +extern u32 FUN_020095BC(u32); +extern void FUN_0202134C(void *, u32); +extern void FUN_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3); +extern u32 FUN_0201FCB0(u32 *); +extern void FUN_02021390(u32, u32 *); +extern void FUN_0201D194(u32, u32, u32); +extern void FUN_0201E068(u32, u32); + +THUMB_FUNC void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0, + s32 param1, + s32 param2, + s32 param3, + s32 param4, + s32 param5, + s32 param6, + u32 param7, + u32 param8, + u32 param9, + u32 param10, + u32 param11, + u32 param12, + u32 param13, + u32 param14) +{ + u32 r7; + u32 st14; + u32 st10; + + u32 stc = 0; + u32 r4 = 0; + u32 st8 = 0; + + GF_ASSERT(param9); + GF_ASSERT(param10); + GF_ASSERT(param12); + GF_ASSERT(param11); + GF_ASSERT(param0); + + r7 = FUN_020094F0(param9, param1); + GF_ASSERT(r7); + + st14 = FUN_020094F0(param10, param2); + GF_ASSERT(st14); + + st10 = FUN_020094F0(param11, param3); + GF_ASSERT(st10); + + if (param12 != 0 && param4 != -1) + { + stc = FUN_020094F0(param12, param4); + GF_ASSERT(stc); + } + + if (param13 != 0) + { + if (param5 != -1) + { + r4 = FUN_020094F0(param13, param5); + } + + if (param6 != -1) + { + st8 = FUN_020094F0(param14, param6); + } + } + + u32 r6; + if (param7 != 0) + { + r6 = FUN_02009C80(r7, st10); + GF_ASSERT(r6); + + param0->unk04 = FUN_02009544(r7); + } + else + { + r6 = FUN_02009C5C(r7); + GF_ASSERT(r6); + + param0->unk04 = 0; + } + + param0->unk08 = FUN_02009E54(st14, r6); + param0->unk00 = r6; + param0->unk0C = FUN_02009574(st10); + + if (stc != 0) + { + param0->unk10 = FUN_0200958C(stc); + } + else + { + param0->unk10 = 0; + } + + if (r4 != 0) + { + param0->unk14 = FUN_020095A4(r4); + param0->unk18 = FUN_020095BC(st8); + } + else + { + param0->unk14 = 0; + param0->unk18 = 0; + } + + param0->unk1C = param7; + param0->unk20 = (u8)param8; +} + +THUMB_FUNC struct UnkStruct_02008AA4_1 *FUN_02008BE0(struct UnkStruct_02008AA4_2 *param0, + u32 param1, + u32 param2, + u32 param3, + u32 param4, + u32 param5, + u32 param6, + u32 param7) +{ + + s32 r4 = 0; + while (param0[r4].unk00 != -2) + { + r4++; + } + + struct UnkStruct_02008AA4_1 *r6 = AllocFromHeap(param1, sizeof(struct UnkStruct_02008AA4_1)); + r6->unk00 = AllocFromHeap(param1, r4 * sizeof(struct UnkStruct_0200BB14_sub)); + r6->unk04 = r4; + + for (int r7 = 0; r7 < r6->unk04; r7++) + { + FUN_02008AA4(&r6->unk00[r7], + param0[r7].unk00, + param0[r7].unk04, + param0[r7].unk08, + param0[r7].unk0C, + param0[r7].unk10, + param0[r7].unk14, + param0[r7].unk18, + param0[r7].unk1C, + param2, + param3, + param4, + param5, + param6, + param7); + } + + return r6; +} + +THUMB_FUNC void FUN_02008C80(struct UnkStruct_02008AA4_1 *param0) +{ + GF_ASSERT(param0); + + if (param0->unk00 != NULL) + { + FreeToHeap(param0->unk00); + } + FreeToHeap(param0); +} + +THUMB_FUNC u32 FUN_02008C9C(u32 param0, void *param1, u32 param2) +{ + FUN_0202134C(param1, 0xFFFFF000); + + u32 st10[3]; + u32 st0[4]; + + st0[0] = 0; + st0[1] = 0; + st0[2] = 0xFF000; + st0[3] = 0xC0000; + FUN_02009FD8(param1 + 0x98, st0, 1, param1); + + st0[0] = 0; + st0[1] = 0xC0000; + st0[2] = 0xFF000; + st0[3] = 0xC0000; + + FUN_02009FD8(param1 + 0xe0, st0, 2, param1); + + st10[0] = param0; + st10[1] = (u32)param1; + st10[2] = param2; + + return FUN_0201FCB0(st10); +} + +THUMB_FUNC void FUN_02008D04(u32 param0, u32 param1, u32 param2) +{ + u32 st0[4]; + st0[0] = param1; + st0[2] = 0xFF000; + st0[3] = 0xC0000; + st0[1] = param2; + FUN_02021390(param0 + 0x98, st0); +} + +THUMB_FUNC void FUN_02008D24(u32 param0, u32 param1, u32 param2) +{ + u32 st0[4]; + st0[0] = param1; + st0[2] = 0xFF000; + st0[3] = 0xC0000; + st0[1] = param2; + FUN_02021390(param0 + 0xe0, st0); +} + +THUMB_FUNC void FUN_02008D44(u32 param0, u32 param1) +{ + switch (param1) + { + case 0x10: + if (GX_GetBankForOBJ() == 0x40 || GX_GetBankForOBJ() == 0x20) + { + FUN_0201D194(0x3E00, 0x200, param0); + return; + } + + FUN_0201D194(0x7E00, 0x200, param0); + return; + case 0x00100010: + FUN_0201D194(0xfe00, 0x200, param0); + return; + case 0x00200010: + if (GX_GetBankForOBJ() == 0x30 || GX_GetBankForOBJ() == 0x50) + { + FUN_0201D194(0x13E00, 0x200, param0); + return; + } + FUN_0201D194(0x1FE00, 0x200, param0); + return; + } + + GF_AssertFail(); +} + +THUMB_FUNC void FUN_02008DDC(u32 param0) +{ + FUN_0201E068(0xC000, param0); +} diff --git a/arm9/src/unk_0200BB14.c b/arm9/src/unk_0200BB14.c index 4ed957d6..ac8d048e 100644 --- a/arm9/src/unk_0200BB14.c +++ b/arm9/src/unk_0200BB14.c @@ -2,6 +2,7 @@ #include "unk_0200BB14.h" #include "game_init.h" #include "heap.h" +#include "unk_02008AA4.h" extern void FUN_0201D060(u32 *param0, u32 param1, u32 param2); extern void FUN_0201E00C(u32 param0, u32 param1); @@ -18,13 +19,11 @@ extern void FUN_02009EAC(u32 param0, extern u32 FUN_0201C328(u32 param0, u32 param1); extern void FUN_0201D168(); extern void FUN_0201E0BC(); -extern u32 FUN_02008C9C(u32 param0, void *param1, u32 param2); extern void FUN_0201FFC8(u32 param0); extern void FUN_0201FDEC(u32 param0); extern void FUN_02009F80(); extern void FUN_0201C348(); extern void FUN_0201FD58(u32 param0); -extern void FUN_02008C80(u32 param0); extern u32 FUN_02009660(u32 *param0, s32 param1); extern void FUN_020096B4(u32 param0); extern void FUN_02009C30(u32 *param0); @@ -43,14 +42,6 @@ extern u32 *FUN_02009424(u32 param0, u32 param1); extern u32 FUN_020093A8(u32 param0, u32 param1, u32 *param2, u32 param3); extern void FUN_02009A90(u32 *param0); extern void FUN_02009D34(u32 *param0); -extern u32 FUN_02008BE0(void *param0, - u32 param1, - u32 param2, - u32 param3, - u32 param4, - u32 param5, - u32 param6, - u32 param7); extern u32 FUN_0201FE94(struct UnkStruct_0200BB14_4 *param0); extern void FUN_02020130(u32 param0, u32 param1); extern void FUN_02020248(u32 param0, u32 param1); @@ -63,21 +54,6 @@ extern u32 FUN_02008FEC( extern u32 FUN_02009D68(u32 param0); extern u32 FUN_02009E88(u32 param0, u32 param1); extern void FUN_02003108(u32 param0, u32 param1, u16 param2, u32 param3); -extern void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0, - s32 param1, - s32 param2, - s32 param3, - s32 param4, - s32 param5, - s32 param6, - u32 param7, - u32 param8, - u32 param9, - u32 param10, - u32 param11, - u32 param12, - u32 param13, - u32 param14); extern u8 FUN_020202A0(u32 param0); extern u32 FUN_020094F0(u32 param0, u32 param1); extern u32 FUN_02009E54(u32 param0, u32 param1); @@ -344,7 +320,7 @@ THUMB_FUNC BOOL FUN_0200BD20( FUN_02009A90(param1->unk24[0]); FUN_02009D34(param1->unk24[1]); - void *r6 = AllocAndReadFile(param0->unk000, st10[6]); + struct UnkStruct_02008AA4_2 *r6 = AllocAndReadFile(param0->unk000, st10[6]); param1->unk04 = FUN_02008BE0(r6, param0->unk000, param1->unk0c[0], @@ -568,7 +544,7 @@ THUMB_FUNC u8 FUN_0200C0DC(u32 param0, return (u8)r4; } -THUMB_FUNC u32 FUN_0200C124(u32 *param0, +THUMB_FUNC BOOL FUN_0200C124(u32 *param0, struct UnkStruct_0200BB14_2 *param1, u32 param2, u32 param3, @@ -578,7 +554,7 @@ THUMB_FUNC u32 FUN_0200C124(u32 *param0, return FUN_0200C404(param0, param1, param2, param3, param4, 2, param5); } -THUMB_FUNC u32 FUN_0200C13C(u32 *param0, +THUMB_FUNC BOOL FUN_0200C13C(u32 *param0, struct UnkStruct_0200BB14_2 *param1, u32 param2, u32 param3, @@ -732,22 +708,22 @@ THUMB_FUNC u32 FUN_0200C344(u32 *param0, u32 param1, u32 param2) return FUN_02009E88(FUN_020094F0(param0[4], param1), param2); } -THUMB_FUNC u32 FUN_0200C358(struct UnkStruct_0200BB14_2 *param0, u32 param1) +THUMB_FUNC BOOL FUN_0200C358(struct UnkStruct_0200BB14_2 *param0, u32 param1) { return FUN_0200C4F4(param0->unk0c[0], param0->unk24[0], param1); } -THUMB_FUNC u32 FUN_0200C368(struct UnkStruct_0200BB14_2 *param0, u32 param1) +THUMB_FUNC BOOL FUN_0200C368(struct UnkStruct_0200BB14_2 *param0, u32 param1) { return FUN_0200C548(param0->unk0c[1], param0->unk24[1], param1); } -THUMB_FUNC u32 FUN_0200C378(struct UnkStruct_0200BB14_2 *param0, u32 param1) +THUMB_FUNC BOOL FUN_0200C378(struct UnkStruct_0200BB14_2 *param0, u32 param1) { return FUN_0200C4A8(param0->unk0c[2], param0->unk24[2], param1); } -THUMB_FUNC u32 FUN_0200C388(struct UnkStruct_0200BB14_2 *param0, u32 param1) +THUMB_FUNC BOOL FUN_0200C388(struct UnkStruct_0200BB14_2 *param0, u32 param1) { return FUN_0200C4A8(param0->unk0c[3], param0->unk24[3], param1); } @@ -796,8 +772,8 @@ THUMB_FUNC BOOL FUN_0200C404(u32 *param0, u32 r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]); if (r5 != 0) { - u32 r4 = FUN_0200C474(param1->unk24[param5], r5); - GF_ASSERT(r4 == 1); + BOOL r4 = FUN_0200C474(param1->unk24[param5], r5); + GF_ASSERT(r4 == TRUE); return r4; } GF_ASSERT(0); @@ -1085,18 +1061,18 @@ THUMB_FUNC void FUN_0200C75C(u32 param0, u16 *param1, u16 *param2) { s32 *r4 = FUN_0202011C(param0, param1, param2); - param1[0] = r4[0] / 0x1000; + param1[0] = (u16)(r4[0] / 0x1000); if (FUN_02020380(param0) == 2) { s32 r1 = r4[1] - 0xc0000; - param2[0] = r1 / 0x1000; + param2[0] = (u16)(r1 / 0x1000); return; } - param2[0] = r4[1] / 0x1000; + param2[0] = (u16)(r4[1] / 0x1000); } THUMB_FUNC void FUN_0200C7A0(u32 *param0, u16 *param1, u16 *param2) @@ -1104,25 +1080,25 @@ THUMB_FUNC void FUN_0200C7A0(u32 *param0, u16 *param1, u16 *param2) FUN_0200C75C(*param0, param1, param2); } -THUMB_FUNC void FUN_0200C7AC(u32 param0, u16 *param1, u16 *param2, u32 param3) +THUMB_FUNC void FUN_0200C7AC(u32 param0, u16 *param1, u16 *param2, s32 param3) { s32 *r4 = FUN_0202011C(param0, param1, param2); - param1[0] = r4[0] / 0x1000; + param1[0] = (u16)(r4[0] / 0x1000); if (FUN_02020380(param0) == 2) { s32 r1 = r4[1] - param3; - param2[0] = r1 / 0x1000; + param2[0] = (u16)(r1 / 0x1000); return; } - param2[0] = r4[1] / 0x1000; + param2[0] = (u16)(r4[1] / 0x1000); } -THUMB_FUNC void FUN_0200C7F0(u32 *param0, u16 *param1, u16 *param2, u32 param3) +THUMB_FUNC void FUN_0200C7F0(u32 *param0, u16 *param1, u16 *param2, s32 param3) { FUN_0200C7AC(*param0, param1, param2, param3); } -- cgit v1.2.3 From 79dc30189483e739d534bb7539729d0ca9d17961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 11 Aug 2021 22:51:41 +0200 Subject: decompile unk_02008DEC.s --- arm9/src/unk_02008DEC.c | 1141 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1141 insertions(+) create mode 100644 arm9/src/unk_02008DEC.c (limited to 'arm9/src') diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c new file mode 100644 index 00000000..49a2ff0c --- /dev/null +++ b/arm9/src/unk_02008DEC.c @@ -0,0 +1,1141 @@ +#include "global.h" +#include "unk_02008DEC.h" +#include "NNS_g2d.h" +#include "gf_gfx_loader.h" +#include "heap.h" + +extern u32 FUN_02020C44(u32, u32); +extern void FUN_02020C90(u32); +extern u32 FUN_02020CB0(u32 param0, s32 param1); +extern void FUN_02020E1C(u32 param0, u32 param1); +extern void FUN_02020D68(u32 param0, u32 param1); +extern s32 FUN_02020E38(u32); +extern void *FUN_02020E0C(u32); +extern BOOL NNS_G2dGetUnpackedMultiCellBank(void *, void *); +extern BOOL NNS_G2dGetUnpackedMCAnimBank(void *, void *); +extern u32 FUN_02020D10(u32, void *, s32, u32); +extern u32 FUN_02020CD4(u32, void *, u32); +extern u32 FUN_0201D1F8(u32 *param0); +extern u32 FUN_0201D250(u32 *param0); +extern void FUN_0201D2DC(u32, u32); +extern void FUN_0201D324(u32 param0); +extern u32 FUN_0201D3B0(u32); +extern u32 FUN_0201D3D4(u32, u32); +extern u32 FUN_0201D458(u32); +extern void FUN_0201D4F0(u32); +extern u32 FUN_0201E0E4(u32 *param0); +extern u32 FUN_0201E128(u32 *param0); +extern void FUN_0201E168(u32, u32); +extern void FUN_0201E1C8(u32); +extern u32 FUN_0201E258(u32, u32); +extern u32 FUN_0201E230(u32); +extern s32 NNS_G2dGetImagePaletteLocation(u32, u32); + +THUMB_FUNC struct UnkStruct1 *FUN_02008DEC(u32 param0, s32 param1, u32 heap_id) +{ + struct UnkStruct1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct1)); + ptr->unk00 = FUN_02020C44(param0, heap_id); + ptr->unk04 = AllocFromHeap(heap_id, param0 * sizeof(struct UnkStruct1_sub)); + memset(ptr->unk04, 0, param0 * sizeof(struct UnkStruct1_sub)); + ptr->unk08 = (s32)param0; + ptr->unk0C = 0; + ptr->unk10 = param1; + + return ptr; +} + +THUMB_FUNC void FUN_02008E2C(struct UnkStruct1 *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk00); + GF_ASSERT(param0->unk04); + + FUN_020094C4(param0); + + FUN_02020C90(param0->unk00); + param0->unk00 = 0; + + FreeToHeap(param0->unk04); + param0->unk04 = NULL; + + FreeToHeap(param0); +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_02008E6C( + struct UnkStruct1 *param0, struct UnkStruct2 *param1, s32 param2, u32 param3) +{ + GF_ASSERT(param0); + GF_ASSERT(param1); + GF_ASSERT(param1->unk04 > param2); + GF_ASSERT(param0->unk10 == param1->unk08); + + struct UnkStruct1_sub *st1c = FUN_020097D0(param0); + GF_ASSERT(st1c); + + if (param1->unk0C == 0) + { + struct UnkStruct3 *r6 = &((struct UnkStruct3 *)param1->unk00)[param2]; + GF_ASSERT(FUN_0200945C(param0, r6->unk00) == 1); + + FUN_0200994C( + param0, st1c, r6->unk04, r6->unk00, r6->unk44, r6->unk48, param1->unk08, param3); + } + else + { + struct UnkStruct4 *r6 = &((struct UnkStruct4 *)param1->unk00)[param2]; + GF_ASSERT(FUN_0200945C(param0, r6->unk0C) == 1); + + FUN_02009978(param0, + st1c, + r6->unk00, + r6->unk04, + r6->unk08, + r6->unk0C, + r6->unk10, + r6->unk14, + param1->unk08, + param3, + FALSE); + } + + param0->unk0C++; + + return st1c; +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_02008F34(struct UnkStruct1 *param0, + NarcId param1, + s32 param2, + BOOL param3, + s32 param4, + u32 param5, + u32 param6) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 0); + + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_02009978(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, FALSE); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_02008F90(struct UnkStruct1 *param0, + NarcId param1, + s32 param2, + BOOL param3, + s32 param4, + u32 param5, + u32 param6, + BOOL param7) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 0); + + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_02009978(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, param7); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_02008FEC(struct UnkStruct1 *param0, + NarcId param1, + s32 param2, + BOOL param3, + s32 param4, + u32 param5, + u32 param6, + u32 param7) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 1); + + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_02009978(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, FALSE); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_0200904C(struct UnkStruct1 *param0, + NarcId param1, + s32 param2, + BOOL param3, + s32 param4, + u32 param5, + u32 param6, + u32 param7, + BOOL param8) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 1); + + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_02009978(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, param8); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_020090AC(struct UnkStruct1 *param0, + NarcId param1, + s32 param2, + BOOL param3, + s32 param4, + u32 param5, + u32 param6) +{ + GF_ASSERT(param0); + + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_02009978(param0, r6, param1, param2, param3, param4, 0, 0, param5, param6, FALSE); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC void FUN_020090FC(struct UnkStruct1 *param0, + struct UnkStruct1_sub *param1, + NarcId param2, + s32 param3, + BOOL param4, + u32 param5) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 0); + GF_ASSERT(param1); + GF_ASSERT(param1->unk04 == 0); + + s32 r6 = FUN_02009530(param1); + u32 r7 = FUN_020095E4(param1); + FUN_02009490(param0, param1); + + FUN_02009978(param0, param1, param2, param3, param4, r6, r7, 0, 0, param5, FALSE); +} + +THUMB_FUNC void FUN_02009168(struct UnkStruct1 *param0, + struct UnkStruct1_sub *param1, + NarcId param2, + s32 param3, + BOOL param4, + u32 param5) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 1); + GF_ASSERT(param1); + GF_ASSERT(param1->unk04 == 1); + + s32 r6 = FUN_02009530(param1); + u32 r7 = FUN_020095E4(param1); + u32 st24 = FUN_02009610(param1); + FUN_02009490(param0, param1); + + FUN_02009978(param0, param1, param2, param3, param4, r6, r7, st24, 1, param5, 0); +} + +THUMB_FUNC u32 FUN_020091E0(struct UnkStruct1 *param0, + u32 param1, + u32 param2, + u32 param3, + s32 param4, + u32 param5, + u32 param6) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 0); + + u32 r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, 0); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC u32 FUN_0200923C(struct UnkStruct1 *param0, + u32 param1, + u32 param2, + u32 param3, + s32 param4, + u32 param5, + u32 param6, + u32 param7) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 0); + + u32 r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, param7); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC u32 FUN_02009298(struct UnkStruct1 *param0, + u32 param1, + u32 param2, + u32 param3, + s32 param4, + u32 param5, + u32 param6, + u32 param7) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 1); + + u32 r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, 0); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC u32 FUN_020092F8(struct UnkStruct1 *param0, + u32 param1, + u32 param2, + u32 param3, + s32 param4, + u32 param5, + u32 param6, + u32 param7, + u32 param8) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk10 == 1); + + u32 r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, param8); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC u32 FUN_02009358(struct UnkStruct1 *param0, + u32 param1, + u32 param2, + u32 param3, + s32 param4, + u32 param5, + u32 param6) +{ + GF_ASSERT(param0); + + u32 r6 = FUN_020097D0(param0); + GF_ASSERT(r6); + + FUN_020099B0(param0, r6, param1, param2, param3, param4, 0, 0, param5, param6, 0); + param0->unk0C++; + + return r6; +} + +THUMB_FUNC u32 FUN_020093A8( + struct UnkStruct1 *param0, struct UnkStruct2 *param1, u32 *param2, u32 param3) +{ + GF_ASSERT(param0); + GF_ASSERT(param1); + + FUN_020093DC(param0, param1, 0, param1->unk04, param2, param3); + + return param1->unk04; +} + +THUMB_FUNC void FUN_020093DC(struct UnkStruct1 *param0, + struct UnkStruct2 *param1, + s32 param2, + s32 param3, + s32 *param4, + u32 param5) +{ + for (int r5 = param2; r5 < param2 + param3; r5++) + { + u32 r0 = FUN_02008E6C(param0, param1, r5, param5); + + if (param4 != NULL && param4[1] > param4[2]) + { + ((u32 *)param4[0])[param4[2]] = r0; + param4[2]++; + } + } +} + +THUMB_FUNC struct UnkStruct5 *FUN_02009424(u32 param0, u32 param1) +{ + struct UnkStruct5 *r4 = AllocFromHeap(param1, sizeof(struct UnkStruct5)); + r4->unk00 = AllocFromHeap(param1, param0 * sizeof(u32)); + r4->unk04 = param0; + r4->unk08 = 0; + + return r4; +} + +THUMB_FUNC void FUN_02009448(struct UnkStruct5 *param0) +{ + FreeToHeap(param0->unk00); + FreeToHeap(param0); +} + +THUMB_FUNC u32 FUN_0200945C(struct UnkStruct1 *param0, s32 param1) +{ + GF_ASSERT(param0); + return FUN_02020CB0(param0->unk00, param1); +} + +THUMB_FUNC void FUN_02009474(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + + FUN_02009920(param0); + FUN_02020E1C(param0->unk00, 0); +} + +THUMB_FUNC void FUN_02009490(struct UnkStruct1 *param0, struct UnkStruct1_sub *param1) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk04); + + FUN_02009920(param1); + FUN_02020D68(param0->unk00, param1->unk00); + param1->unk00 = 0; + param0->unk0C--; +} + +THUMB_FUNC void FUN_020094C4(struct UnkStruct1 *param0) +{ + for (int i = 0; i < param0->unk08; i++) + { + if (param0->unk04[i].unk00 != 0) + { + FUN_02009490(param0, ¶m0->unk04[i]); + } + } +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_020094F0(struct UnkStruct1 *param0, u32 param1) +{ + GF_ASSERT(param0); + + for (int i = 0; i < param0->unk08; i++) + { + if (param0->unk04[i].unk00 != 0) + { + u32 r0 = FUN_02020E38(param0->unk04[i].unk00); + if (r0 == param1) + { + return ¶m0->unk04[i]; + } + } + } + + return NULL; +} + +THUMB_FUNC s32 FUN_02009530(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + return FUN_02020E38(param0->unk00); +} + +THUMB_FUNC u32 FUN_02009544(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0->unk04 == 0); + return *FUN_02009934(param0); +} + +THUMB_FUNC u32 FUN_0200955C(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0->unk04 == 1); + return *FUN_02009934(param0); +} + +THUMB_FUNC u32 FUN_02009574(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0->unk04 == 2); + return *FUN_02009934(param0); +} + +THUMB_FUNC u32 FUN_0200958C(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0->unk04 == 3); + return *FUN_02009934(param0); +} + +THUMB_FUNC u32 FUN_020095A4(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0->unk04 == 4); + return *FUN_02009934(param0); +} + +THUMB_FUNC u32 FUN_020095BC(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0->unk04 == 5); + return *FUN_02009934(param0); +} + +THUMB_FUNC u32 FUN_020095D4(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + + return param0->unk04; +} + +THUMB_FUNC u32 FUN_020095E4(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + + if (param0->unk04 == 0) + { + return FUN_02009934(param0)[1]; + } + if (param0->unk04 == 1) + { + return FUN_02009934(param0)[1]; + } + + return 0; +} + +THUMB_FUNC u32 FUN_02009610(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + + if (param0->unk04 == 1) + { + return FUN_02009934(param0)[2]; + } + + return 0; +} + +THUMB_FUNC void FUN_02009630(struct UnkStruct1_sub *param0, u32 param1) +{ + GF_ASSERT(param0); + + if (param0->unk04 == 0) + { + FUN_02009934(param0)[1] = param1; + } + if (param0->unk04 == 1) + { + FUN_02009934(param0)[1] = param1; + } +} + +THUMB_FUNC u32 FUN_0200965C(void) +{ + return 16; +} + +THUMB_FUNC u32 *FUN_02009660(u32 *param0, s32 param1) +{ + return ¶m0[param1 * 4]; +} + +THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct2 *param1, u32 param2) +{ + GF_ASSERT(param1); + + param1->unk08 = param0[0]; + param1->unk0C = 1; + + param1->unk04 = FUN_020099E8((struct UnkStruct4 *)(param0 + 1)); + + void *ptr; + if (param1->unk04 > 0) + { + ptr = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct4)); + } + else + { + ptr = NULL; + } + + param1->unk00 = ptr; + // use volatile to force a reload here + void *r0 = *((void *volatile *)param1); + if (r0 != NULL) + { + memcpy(r0, param0 + 1, param1->unk04 * sizeof(struct UnkStruct4)); + } +} + +THUMB_FUNC void FUN_020096B4(struct UnkStruct2 *param0) +{ + if (param0->unk00) + { + FreeToHeap(param0->unk00); + } + param0->unk00 = NULL; + param0->unk04 = 0; +} + +THUMB_FUNC s32 FUN_020096CC(struct UnkStruct2 *param0) +{ + GF_ASSERT(param0); + + return param0->unk04; +} + +THUMB_FUNC u32 FUN_020096DC(struct UnkStruct2 *param0, s32 param1) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk04 > param1); + + if (param0->unk0C == 0) + { + return ((struct UnkStruct3 *)param0->unk00)[param1].unk00; + } + + return ((struct UnkStruct4 *)param0->unk00)[param1].unk0C; +} + +THUMB_FUNC u32 FUN_02009710(struct UnkStruct2 *param0, s32 param1) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk04 > param1); + + u32 r6; + if (param0->unk0C == 1) + { + r6 = ((struct UnkStruct4 *)param0->unk00)[param1].unk04; + } + + // oops, UB here + return r6; +} + +THUMB_FUNC u32 FUN_0200973C(struct UnkStruct2 *param0, s32 param1) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk04 > param1); + + u32 r6; + if (param0->unk0C == 1) + { + r6 = ((struct UnkStruct4 *)param0->unk00)[param1].unk08; + } + + // oops, UB here + return r6; +} + +THUMB_FUNC u32 FUN_02009768(struct UnkStruct2 *param0, s32 param1) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk04 > param1); + + if (param0->unk0C == 0) + { + return ((struct UnkStruct3 *)param0->unk00)[param1].unk44; + } + + return ((struct UnkStruct4 *)param0->unk00)[param1].unk10; +} + +THUMB_FUNC u32 FUN_0200979C(struct UnkStruct2 *param0, s32 param1) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk04 > param1); + + if (param0->unk0C == 0) + { + return ((struct UnkStruct3 *)param0->unk00)[param1].unk48; + } + + return ((struct UnkStruct4 *)param0->unk00)[param1].unk14; +} + +THUMB_FUNC struct UnkStruct1_sub *FUN_020097D0(struct UnkStruct1 *param0) +{ + for (int i = 0; i < param0->unk08; i++) + { + if (param0->unk04[i].unk00 == 0) + { + return ¶m0->unk04[i]; + } + } + + return NULL; +} + +struct CharacterData_02008DEC +{ + NNSG2dCharacterData *chData; + u32 unk04; +}; + +struct PaletteData_02008DEC +{ + NNSG2dPaletteData *plttData; + u32 unk04; + u32 unk08; +}; + +struct CellDataBank_02008DEC +{ + NNSG2dCellDataBank *cellBank; +}; + +struct AnimBank_02008DEC +{ + NNSG2dAnimBankData *bankData; +}; + +THUMB_FUNC void FUN_020097FC( + struct UnkStruct1_sub *param0, u32 param1, u32 param2, u32 param3, u32 param4) +{ + void *r0 = FUN_02020E0C(param0->unk00); + + switch (param1) + { + case 0: + param0->unk08 = FUN_0200986C(r0, param2, param4); + break; + case 1: + param0->unk08 = FUN_0200988C(r0, param2, param3, param4); + break; + case 2: + param0->unk08 = FUN_020098B0(r0, param4); + break; + case 3: + param0->unk08 = FUN_020098CC(r0, param4); + break; + case 4: + param0->unk08 = FUN_020098E8(r0, param4); + break; + case 5: + param0->unk08 = FUN_02009904(r0, param4); + break; + } +} + +THUMB_FUNC struct CharacterData_02008DEC *FUN_0200986C(void *param0, u32 param1, u32 param2) +{ + struct CharacterData_02008DEC *ptr = + AllocFromHeap(param2, sizeof(struct CharacterData_02008DEC)); + + NNS_G2dGetUnpackedCharacterData(param0, &ptr->chData); + ptr->unk04 = param1; + + return ptr; +} + +THUMB_FUNC struct PaletteData_02008DEC *FUN_0200988C( + void *param0, u32 param1, u32 param2, u32 param3) +{ + struct PaletteData_02008DEC *ptr = AllocFromHeap(param3, sizeof(struct PaletteData_02008DEC)); + + NNS_G2dGetUnpackedPaletteData(param0, &ptr->plttData); + ptr->unk04 = param1; + ptr->unk08 = param2; + + return ptr; +} + +THUMB_FUNC struct CellDataBank_02008DEC *FUN_020098B0(void *param0, u32 param1) +{ + struct CellDataBank_02008DEC *ptr = AllocFromHeap(param1, sizeof(struct CellDataBank_02008DEC)); + + NNS_G2dGetUnpackedCellBank(param0, &ptr->cellBank); + + return ptr; +} + +THUMB_FUNC struct AnimBank_02008DEC *FUN_020098CC(void *param0, u32 param1) +{ + struct AnimBank_02008DEC *ptr = AllocFromHeap(param1, sizeof(struct AnimBank_02008DEC)); + + NNS_G2dGetUnpackedAnimBank(param0, &ptr->bankData); + + return ptr; +} + +THUMB_FUNC void *FUN_020098E8(void *param0, u32 param1) +{ + void *ptr = AllocFromHeap(param1, 4); + + NNS_G2dGetUnpackedMultiCellBank(param0, ptr); + + return ptr; +} + +THUMB_FUNC void *FUN_02009904(void *param0, u32 param1) +{ + void *ptr = AllocFromHeap(param1, 4); + + NNS_G2dGetUnpackedMCAnimBank(param0, ptr); + + return ptr; +} + +THUMB_FUNC void FUN_02009920(struct UnkStruct1_sub *param0) +{ + if (param0->unk08 != NULL) + { + FreeToHeap(param0->unk08); + } + + param0->unk08 = NULL; +} + +THUMB_FUNC u32 *FUN_02009934(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(param0->unk08); + + return param0->unk08; +} + +THUMB_FUNC void FUN_0200994C(struct UnkStruct1 *param0, + struct UnkStruct1_sub *param1, + void *param2, + s32 param3, + u32 param4, + u32 param5, + u32 param6, + u32 param7) +{ + param1->unk00 = FUN_02020D10(param0->unk00, param2, param3, param7); + param1->unk04 = param6; + FUN_020097FC(param1, param6, param4, param5, param7); +} + +THUMB_FUNC void FUN_02009978(struct UnkStruct1 *param0, + struct UnkStruct1_sub *param1, + NarcId param2, + s32 param3, + BOOL param4, + s32 param5, + u32 param6, + u32 param7, + u32 param8, + u32 param9, + BOOL param10) +{ + void *r1 = GfGfxLoader_LoadFromNarc(param2, param3, param4, param9, param10); + param1->unk00 = FUN_02020CD4(param0->unk00, r1, param5); + param1->unk04 = param8; + + FUN_020097FC(param1, param8, param6, param7, param9); +} + +THUMB_FUNC void FUN_020099B0(struct UnkStruct1 *param0, + struct UnkStruct1_sub *param1, + u32 param2, + u32 param3, + u32 param4, + u32 param5, + u32 param6, + u32 param7, + u32 param8, + u32 param9, + u32 param10) +{ + param1->unk00 = + FUN_02020CD4(param0->unk00, FUN_02009A04(param2, param3, param4, param9, param10), param5); + param1->unk04 = param8; + + FUN_020097FC(param1, param8, param6, param7, param9); +} + +THUMB_FUNC s32 FUN_020099E8(struct UnkStruct4 *param0) +{ + s32 r3 = 0; + while (param0[r3].unk00 != -2) + { + r3++; + } + + return r3; +} + +THUMB_FUNC void *FUN_02009A04(NARC *param0, u32 param1, u32 param2, u32 param3, u32 param4) +{ + void *r4 = NARC_AllocAndReadWholeMember(param0, param1, param3); + + if (r4 != NULL && param2 != 0) + { + void *ptr; + if (param4 == 0) + { + ptr = AllocFromHeap(param3, (*(u32 *)r4) >> 8); + } + else + { + ptr = AllocFromHeapAtEnd(param3, (*(u32 *)r4) >> 8); + } + + if (ptr != NULL) + { + MI_UncompressLZ8(r4, ptr); + FreeToHeap(r4); + } + + r4 = ptr; + } + + return r4; +} + +THUMB_FUNC u32 FUN_02009A50(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 0); + + u32 st0[4]; + st0[0] = FUN_02009544(param0); + st0[1] = FUN_020095E4(param0); + st0[2] = FUN_02009530(param0); + st0[3] = 0; + + return FUN_0201D1F8(st0); +} + +THUMB_FUNC void FUN_02009A90(struct UnkStruct5 *param0) +{ + GF_ASSERT(param0); + + for (int i = 0; i < param0->unk04; i++) + { + GF_ASSERT(param0->unk00[i] == 0 || FUN_02009A50(param0->unk00[i]) != 0); + } +} + +THUMB_FUNC u32 FUN_02009AC4(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 0); + + u32 st0[4]; + st0[0] = FUN_02009544(param0); + st0[1] = FUN_020095E4(param0); + st0[2] = FUN_02009530(param0); + st0[3] = 0; + + return FUN_0201D250(st0); +} + +THUMB_FUNC u32 FUN_02009B04(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 0); + + u32 st0[4]; + st0[0] = FUN_02009544(param0); + st0[1] = FUN_020095E4(param0); + st0[2] = FUN_02009530(param0); + st0[3] = 1; + + return FUN_0201D1F8(st0); +} + +THUMB_FUNC void FUN_02009B44(struct UnkStruct5 *param0) +{ + GF_ASSERT(param0); + + for (int i = 0; i < param0->unk04; i++) + { + GF_ASSERT(param0->unk00[i] == 0 || FUN_02009B04(param0->unk00[i]) != 0); + } +} + +THUMB_FUNC u32 FUN_02009B78(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 0); + + u32 st0[4]; + st0[0] = FUN_02009544(param0); + st0[1] = FUN_020095E4(param0); + st0[2] = FUN_02009530(param0); + st0[3] = 1; + + return FUN_0201D250(st0); +} + +THUMB_FUNC void FUN_02009BB8(struct UnkStruct1_sub *param0, struct UnkStruct1_sub *param1) +{ + GF_ASSERT(param0); + GF_ASSERT(param1); + + FUN_0201D2DC(FUN_02009530(param0), FUN_02009544(param1)); +} + +THUMB_FUNC void FUN_02009BE8(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + + FUN_0201D2DC(FUN_02009530(param0), FUN_02009544(param0)); +} + +THUMB_FUNC void FUN_02009C0C(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 0); + + FUN_0201D324(FUN_02009530(param0)); +} + +THUMB_FUNC void FUN_02009C30(struct UnkStruct5 *param0) +{ + GF_ASSERT(param0); + for (int i = 0; i < param0->unk04; i++) + { + if (param0->unk00[i] != 0) + { + FUN_02009C0C(param0->unk00[i]); + } + } +} + +THUMB_FUNC u32 FUN_02009C5C(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 0); + + return FUN_0201D3B0(FUN_02009530(param0)); +} + +THUMB_FUNC void FUN_02009C80(struct UnkStruct1_sub *param0, struct UnkStruct1_sub *param1) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 0); + GF_ASSERT(param1); + GF_ASSERT(FUN_020095D4(param1) == 2); + + u32 r4 = FUN_02009530(param0); + if (FUN_0201D3D4(r4, ((u32 **)FUN_02009574(param1))[3][0]) == 0) + { + FUN_0201D458(FUN_0201D3B0(r4)); + } +} + +THUMB_FUNC void FUN_02009CDC(u32 param0) +{ + GF_ASSERT(param0); + + FUN_0201D4F0(param0); +} + +THUMB_FUNC u32 FUN_02009CF0(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 1); + + u32 st0[4]; + st0[0] = FUN_0200955C(param0); + st0[1] = FUN_020095E4(param0); + st0[3] = FUN_02009530(param0); + st0[2] = FUN_02009610(param0); + + return FUN_0201E0E4(st0); +} + +THUMB_FUNC void FUN_02009D34(struct UnkStruct5 *param0) +{ + GF_ASSERT(param0); + for (int i = 0; i < param0->unk04; i++) + { + if (param0->unk00[i] != 0) + { + GF_ASSERT(FUN_02009CF0(param0->unk00[i]) != 0); + } + } +} + +THUMB_FUNC u32 FUN_02009D68(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 1); + + u32 st0[4]; + st0[0] = FUN_0200955C(param0); + st0[1] = FUN_020095E4(param0); + st0[3] = FUN_02009530(param0); + st0[2] = FUN_02009610(param0); + + return FUN_0201E128(st0); +} + +THUMB_FUNC void FUN_02009DAC(struct UnkStruct5 *param0) +{ + GF_ASSERT(param0); + for (int i = 0; i < param0->unk04; i++) + { + if (param0->unk00[i] != 0) + { + GF_ASSERT(FUN_02009D68(param0->unk00[i]) != 0); + } + } +} + +THUMB_FUNC void FUN_02009DE0(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + + FUN_0201E168(FUN_02009530(param0), FUN_0200955C(param0)); +} + +THUMB_FUNC void FUN_02009E04(struct UnkStruct1_sub *param0) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 1); + + FUN_0201E1C8(FUN_02009530(param0)); +} + +THUMB_FUNC void FUN_02009E28(struct UnkStruct5 *param0) +{ + GF_ASSERT(param0); + for (int i = 0; i < param0->unk04; i++) + { + if (param0->unk00[i] != 0) + { + FUN_02009E04(param0->unk00[i]); + } + } +} + +THUMB_FUNC u32 FUN_02009E54(struct UnkStruct1_sub *param0, u32 param1) +{ + GF_ASSERT(param0); + GF_ASSERT(FUN_020095D4(param0) == 1); + + u32 r0 = FUN_02009530(param0); + if (param1 != 0) + { + return FUN_0201E258(r0, param1); + } + + return FUN_0201E230(r0); +} + +THUMB_FUNC s32 FUN_02009E88(struct UnkStruct1_sub *param0, u32 param1) +{ + s32 ret = NNS_G2dGetImagePaletteLocation(FUN_02009E54(param0, 0), param1); + if (ret != -1) + { + return ret / 32; + } + + return ret; +} -- cgit v1.2.3 From 8f43e99f05cc2113398bcd40d29a6dfd952cf4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 11 Aug 2021 23:15:40 +0200 Subject: fix compiler warnings --- arm9/src/unk_02008DEC.c | 102 ++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c index 49a2ff0c..ad4f9700 100644 --- a/arm9/src/unk_02008DEC.c +++ b/arm9/src/unk_02008DEC.c @@ -14,21 +14,21 @@ extern void *FUN_02020E0C(u32); extern BOOL NNS_G2dGetUnpackedMultiCellBank(void *, void *); extern BOOL NNS_G2dGetUnpackedMCAnimBank(void *, void *); extern u32 FUN_02020D10(u32, void *, s32, u32); -extern u32 FUN_02020CD4(u32, void *, u32); +extern u32 FUN_02020CD4(u32, void *, s32); extern u32 FUN_0201D1F8(u32 *param0); extern u32 FUN_0201D250(u32 *param0); -extern void FUN_0201D2DC(u32, u32); -extern void FUN_0201D324(u32 param0); -extern u32 FUN_0201D3B0(u32); -extern u32 FUN_0201D3D4(u32, u32); +extern void FUN_0201D2DC(s32, u32); +extern void FUN_0201D324(s32 param0); +extern u32 FUN_0201D3B0(s32); +extern u32 FUN_0201D3D4(s32, u32); extern u32 FUN_0201D458(u32); extern void FUN_0201D4F0(u32); extern u32 FUN_0201E0E4(u32 *param0); extern u32 FUN_0201E128(u32 *param0); -extern void FUN_0201E168(u32, u32); -extern void FUN_0201E1C8(u32); -extern u32 FUN_0201E258(u32, u32); -extern u32 FUN_0201E230(u32); +extern void FUN_0201E168(s32, u32); +extern void FUN_0201E1C8(s32); +extern u32 FUN_0201E258(s32, u32); +extern u32 FUN_0201E230(s32); extern s32 NNS_G2dGetImagePaletteLocation(u32, u32); THUMB_FUNC struct UnkStruct1 *FUN_02008DEC(u32 param0, s32 param1, u32 heap_id) @@ -245,8 +245,8 @@ THUMB_FUNC void FUN_02009168(struct UnkStruct1 *param0, FUN_02009978(param0, param1, param2, param3, param4, r6, r7, st24, 1, param5, 0); } -THUMB_FUNC u32 FUN_020091E0(struct UnkStruct1 *param0, - u32 param1, +THUMB_FUNC struct UnkStruct1_sub *FUN_020091E0(struct UnkStruct1 *param0, + NARC *param1, u32 param2, u32 param3, s32 param4, @@ -256,7 +256,7 @@ THUMB_FUNC u32 FUN_020091E0(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 0); - u32 r6 = FUN_020097D0(param0); + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, 0); @@ -265,8 +265,8 @@ THUMB_FUNC u32 FUN_020091E0(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC u32 FUN_0200923C(struct UnkStruct1 *param0, - u32 param1, +THUMB_FUNC struct UnkStruct1_sub *FUN_0200923C(struct UnkStruct1 *param0, + NARC *param1, u32 param2, u32 param3, s32 param4, @@ -277,7 +277,7 @@ THUMB_FUNC u32 FUN_0200923C(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 0); - u32 r6 = FUN_020097D0(param0); + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, param7); @@ -286,8 +286,8 @@ THUMB_FUNC u32 FUN_0200923C(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC u32 FUN_02009298(struct UnkStruct1 *param0, - u32 param1, +THUMB_FUNC struct UnkStruct1_sub *FUN_02009298(struct UnkStruct1 *param0, + NARC *param1, u32 param2, u32 param3, s32 param4, @@ -298,7 +298,7 @@ THUMB_FUNC u32 FUN_02009298(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 1); - u32 r6 = FUN_020097D0(param0); + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, 0); @@ -307,8 +307,8 @@ THUMB_FUNC u32 FUN_02009298(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC u32 FUN_020092F8(struct UnkStruct1 *param0, - u32 param1, +THUMB_FUNC struct UnkStruct1_sub *FUN_020092F8(struct UnkStruct1 *param0, + NARC *param1, u32 param2, u32 param3, s32 param4, @@ -320,7 +320,7 @@ THUMB_FUNC u32 FUN_020092F8(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 1); - u32 r6 = FUN_020097D0(param0); + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, param8); @@ -329,8 +329,8 @@ THUMB_FUNC u32 FUN_020092F8(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC u32 FUN_02009358(struct UnkStruct1 *param0, - u32 param1, +THUMB_FUNC struct UnkStruct1_sub *FUN_02009358(struct UnkStruct1 *param0, + NARC *param1, u32 param2, u32 param3, s32 param4, @@ -339,7 +339,7 @@ THUMB_FUNC u32 FUN_02009358(struct UnkStruct1 *param0, { GF_ASSERT(param0); - u32 r6 = FUN_020097D0(param0); + struct UnkStruct1_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, 0, 0, param5, param6, 0); @@ -348,7 +348,7 @@ THUMB_FUNC u32 FUN_02009358(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC u32 FUN_020093A8( +THUMB_FUNC s32 FUN_020093A8( struct UnkStruct1 *param0, struct UnkStruct2 *param1, u32 *param2, u32 param3) { GF_ASSERT(param0); @@ -368,20 +368,20 @@ THUMB_FUNC void FUN_020093DC(struct UnkStruct1 *param0, { for (int r5 = param2; r5 < param2 + param3; r5++) { - u32 r0 = FUN_02008E6C(param0, param1, r5, param5); + struct UnkStruct1_sub *r0 = FUN_02008E6C(param0, param1, r5, param5); if (param4 != NULL && param4[1] > param4[2]) { - ((u32 *)param4[0])[param4[2]] = r0; + ((u32 *)param4[0])[param4[2]] = (u32)r0; param4[2]++; } } } -THUMB_FUNC struct UnkStruct5 *FUN_02009424(u32 param0, u32 param1) +THUMB_FUNC struct UnkStruct5 *FUN_02009424(s32 param0, u32 param1) { struct UnkStruct5 *r4 = AllocFromHeap(param1, sizeof(struct UnkStruct5)); - r4->unk00 = AllocFromHeap(param1, param0 * sizeof(u32)); + r4->unk00 = AllocFromHeap(param1, param0 * sizeof(struct UnkStruct1_sub *)); r4->unk04 = param0; r4->unk08 = 0; @@ -438,7 +438,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020094F0(struct UnkStruct1 *param0, u32 pa { if (param0->unk04[i].unk00 != 0) { - u32 r0 = FUN_02020E38(param0->unk04[i].unk00); + s32 r0 = FUN_02020E38(param0->unk04[i].unk00); if (r0 == param1) { return ¶m0->unk04[i]; @@ -595,7 +595,7 @@ THUMB_FUNC s32 FUN_020096CC(struct UnkStruct2 *param0) return param0->unk04; } -THUMB_FUNC u32 FUN_020096DC(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC s32 FUN_020096DC(struct UnkStruct2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); @@ -608,12 +608,12 @@ THUMB_FUNC u32 FUN_020096DC(struct UnkStruct2 *param0, s32 param1) return ((struct UnkStruct4 *)param0->unk00)[param1].unk0C; } -THUMB_FUNC u32 FUN_02009710(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC s32 FUN_02009710(struct UnkStruct2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); - u32 r6; + s32 r6; if (param0->unk0C == 1) { r6 = ((struct UnkStruct4 *)param0->unk00)[param1].unk04; @@ -623,12 +623,12 @@ THUMB_FUNC u32 FUN_02009710(struct UnkStruct2 *param0, s32 param1) return r6; } -THUMB_FUNC u32 FUN_0200973C(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC BOOL FUN_0200973C(struct UnkStruct2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); - u32 r6; + BOOL r6; if (param0->unk0C == 1) { r6 = ((struct UnkStruct4 *)param0->unk00)[param1].unk08; @@ -840,10 +840,10 @@ THUMB_FUNC void FUN_02009978(struct UnkStruct1 *param0, THUMB_FUNC void FUN_020099B0(struct UnkStruct1 *param0, struct UnkStruct1_sub *param1, - u32 param2, + NARC *param2, u32 param3, u32 param4, - u32 param5, + s32 param5, u32 param6, u32 param7, u32 param8, @@ -904,7 +904,7 @@ THUMB_FUNC u32 FUN_02009A50(struct UnkStruct1_sub *param0) u32 st0[4]; st0[0] = FUN_02009544(param0); st0[1] = FUN_020095E4(param0); - st0[2] = FUN_02009530(param0); + st0[2] = (u32)FUN_02009530(param0); st0[3] = 0; return FUN_0201D1F8(st0); @@ -916,7 +916,7 @@ THUMB_FUNC void FUN_02009A90(struct UnkStruct5 *param0) for (int i = 0; i < param0->unk04; i++) { - GF_ASSERT(param0->unk00[i] == 0 || FUN_02009A50(param0->unk00[i]) != 0); + GF_ASSERT(param0->unk00[i] == NULL || FUN_02009A50(param0->unk00[i]) != 0); } } @@ -928,7 +928,7 @@ THUMB_FUNC u32 FUN_02009AC4(struct UnkStruct1_sub *param0) u32 st0[4]; st0[0] = FUN_02009544(param0); st0[1] = FUN_020095E4(param0); - st0[2] = FUN_02009530(param0); + st0[2] = (u32)FUN_02009530(param0); st0[3] = 0; return FUN_0201D250(st0); @@ -942,7 +942,7 @@ THUMB_FUNC u32 FUN_02009B04(struct UnkStruct1_sub *param0) u32 st0[4]; st0[0] = FUN_02009544(param0); st0[1] = FUN_020095E4(param0); - st0[2] = FUN_02009530(param0); + st0[2] = (u32)FUN_02009530(param0); st0[3] = 1; return FUN_0201D1F8(st0); @@ -954,7 +954,7 @@ THUMB_FUNC void FUN_02009B44(struct UnkStruct5 *param0) for (int i = 0; i < param0->unk04; i++) { - GF_ASSERT(param0->unk00[i] == 0 || FUN_02009B04(param0->unk00[i]) != 0); + GF_ASSERT(param0->unk00[i] == NULL || FUN_02009B04(param0->unk00[i]) != 0); } } @@ -966,7 +966,7 @@ THUMB_FUNC u32 FUN_02009B78(struct UnkStruct1_sub *param0) u32 st0[4]; st0[0] = FUN_02009544(param0); st0[1] = FUN_020095E4(param0); - st0[2] = FUN_02009530(param0); + st0[2] = (u32)FUN_02009530(param0); st0[3] = 1; return FUN_0201D250(st0); @@ -1000,7 +1000,7 @@ THUMB_FUNC void FUN_02009C30(struct UnkStruct5 *param0) GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) { - if (param0->unk00[i] != 0) + if (param0->unk00[i] != NULL) { FUN_02009C0C(param0->unk00[i]); } @@ -1022,7 +1022,7 @@ THUMB_FUNC void FUN_02009C80(struct UnkStruct1_sub *param0, struct UnkStruct1_su GF_ASSERT(param1); GF_ASSERT(FUN_020095D4(param1) == 2); - u32 r4 = FUN_02009530(param0); + s32 r4 = FUN_02009530(param0); if (FUN_0201D3D4(r4, ((u32 **)FUN_02009574(param1))[3][0]) == 0) { FUN_0201D458(FUN_0201D3B0(r4)); @@ -1044,7 +1044,7 @@ THUMB_FUNC u32 FUN_02009CF0(struct UnkStruct1_sub *param0) u32 st0[4]; st0[0] = FUN_0200955C(param0); st0[1] = FUN_020095E4(param0); - st0[3] = FUN_02009530(param0); + st0[3] = (u32)FUN_02009530(param0); st0[2] = FUN_02009610(param0); return FUN_0201E0E4(st0); @@ -1055,7 +1055,7 @@ THUMB_FUNC void FUN_02009D34(struct UnkStruct5 *param0) GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) { - if (param0->unk00[i] != 0) + if (param0->unk00[i] != NULL) { GF_ASSERT(FUN_02009CF0(param0->unk00[i]) != 0); } @@ -1070,7 +1070,7 @@ THUMB_FUNC u32 FUN_02009D68(struct UnkStruct1_sub *param0) u32 st0[4]; st0[0] = FUN_0200955C(param0); st0[1] = FUN_020095E4(param0); - st0[3] = FUN_02009530(param0); + st0[3] = (u32)FUN_02009530(param0); st0[2] = FUN_02009610(param0); return FUN_0201E128(st0); @@ -1081,7 +1081,7 @@ THUMB_FUNC void FUN_02009DAC(struct UnkStruct5 *param0) GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) { - if (param0->unk00[i] != 0) + if (param0->unk00[i] != NULL) { GF_ASSERT(FUN_02009D68(param0->unk00[i]) != 0); } @@ -1108,7 +1108,7 @@ THUMB_FUNC void FUN_02009E28(struct UnkStruct5 *param0) GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) { - if (param0->unk00[i] != 0) + if (param0->unk00[i] != NULL) { FUN_02009E04(param0->unk00[i]); } @@ -1120,7 +1120,7 @@ THUMB_FUNC u32 FUN_02009E54(struct UnkStruct1_sub *param0, u32 param1) GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 1); - u32 r0 = FUN_02009530(param0); + s32 r0 = FUN_02009530(param0); if (param1 != 0) { return FUN_0201E258(r0, param1); -- cgit v1.2.3 From e3766102b2132d09de4368f0be4f3898c263c9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Thu, 12 Aug 2021 00:32:06 +0200 Subject: remove externs and cleanup some dependent code --- arm9/src/unk_02008AA4.c | 46 +++++------- arm9/src/unk_02008DEC.c | 43 +++-------- arm9/src/unk_0200BB14.c | 196 ++++++++++++++++++++---------------------------- 3 files changed, 110 insertions(+), 175 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02008AA4.c b/arm9/src/unk_02008AA4.c index 2d7fb77d..4ddb6995 100644 --- a/arm9/src/unk_02008AA4.c +++ b/arm9/src/unk_02008AA4.c @@ -3,16 +3,8 @@ #include "GX_vramcnt.h" #include "heap.h" #include "unk_0200BB14.h" +#include "unk_02008DEC.h" -extern u32 FUN_020094F0(u32 param0, s32 param1); -extern u32 FUN_02009C80(u32, u32); -extern u32 FUN_02009544(u32); -extern u32 FUN_02009E54(u32 param0, u32 param1); -extern u32 FUN_02009C5C(u32); -extern u32 FUN_02009574(u32); -extern u32 FUN_0200958C(u32); -extern u32 FUN_020095A4(u32); -extern u32 FUN_020095BC(u32); extern void FUN_0202134C(void *, u32); extern void FUN_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3); extern u32 FUN_0201FCB0(u32 *); @@ -29,20 +21,20 @@ THUMB_FUNC void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0, s32 param6, u32 param7, u32 param8, - u32 param9, - u32 param10, - u32 param11, - u32 param12, - u32 param13, - u32 param14) + struct UnkStruct1 *param9, + struct UnkStruct1 *param10, + struct UnkStruct1 *param11, + struct UnkStruct1 *param12, + struct UnkStruct1 *param13, + struct UnkStruct1 *param14) { - u32 r7; - u32 st14; - u32 st10; + struct UnkStruct1_sub *r7; + struct UnkStruct1_sub *st14; + struct UnkStruct1_sub *st10; - u32 stc = 0; - u32 r4 = 0; - u32 st8 = 0; + struct UnkStruct1_sub *stc = NULL; + struct UnkStruct1_sub *r4 = NULL; + struct UnkStruct1_sub *st8 = NULL; GF_ASSERT(param9); GF_ASSERT(param10); @@ -124,12 +116,12 @@ THUMB_FUNC void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0, THUMB_FUNC struct UnkStruct_02008AA4_1 *FUN_02008BE0(struct UnkStruct_02008AA4_2 *param0, u32 param1, - u32 param2, - u32 param3, - u32 param4, - u32 param5, - u32 param6, - u32 param7) + struct UnkStruct1 *param2, + struct UnkStruct1 *param3, + struct UnkStruct1 *param4, + struct UnkStruct1 *param5, + struct UnkStruct1 *param6, + struct UnkStruct1 *param7) { s32 r4 = 0; diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c index ad4f9700..76e32b63 100644 --- a/arm9/src/unk_02008DEC.c +++ b/arm9/src/unk_02008DEC.c @@ -349,7 +349,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02009358(struct UnkStruct1 *param0, } THUMB_FUNC s32 FUN_020093A8( - struct UnkStruct1 *param0, struct UnkStruct2 *param1, u32 *param2, u32 param3) + struct UnkStruct1 *param0, struct UnkStruct2 *param1, struct UnkStruct5 *param2, u32 param3) { GF_ASSERT(param0); GF_ASSERT(param1); @@ -363,17 +363,17 @@ THUMB_FUNC void FUN_020093DC(struct UnkStruct1 *param0, struct UnkStruct2 *param1, s32 param2, s32 param3, - s32 *param4, + struct UnkStruct5 *param4, u32 param5) { for (int r5 = param2; r5 < param2 + param3; r5++) { struct UnkStruct1_sub *r0 = FUN_02008E6C(param0, param1, r5, param5); - if (param4 != NULL && param4[1] > param4[2]) + if (param4 != NULL && param4->unk04 > param4->unk08) { - ((u32 *)param4[0])[param4[2]] = (u32)r0; - param4[2]++; + param4->unk00[param4->unk08] = r0; + param4->unk08++; } } } @@ -430,7 +430,7 @@ THUMB_FUNC void FUN_020094C4(struct UnkStruct1 *param0) } } -THUMB_FUNC struct UnkStruct1_sub *FUN_020094F0(struct UnkStruct1 *param0, u32 param1) +THUMB_FUNC struct UnkStruct1_sub *FUN_020094F0(struct UnkStruct1 *param0, s32 param1) { GF_ASSERT(param0); @@ -545,9 +545,9 @@ THUMB_FUNC u32 FUN_0200965C(void) return 16; } -THUMB_FUNC u32 *FUN_02009660(u32 *param0, s32 param1) +THUMB_FUNC struct UnkStruct2 *FUN_02009660(struct UnkStruct2 *param0, s32 param1) { - return ¶m0[param1 * 4]; + return ¶m0[param1]; } THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct2 *param1, u32 param2) @@ -677,29 +677,6 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020097D0(struct UnkStruct1 *param0) return NULL; } -struct CharacterData_02008DEC -{ - NNSG2dCharacterData *chData; - u32 unk04; -}; - -struct PaletteData_02008DEC -{ - NNSG2dPaletteData *plttData; - u32 unk04; - u32 unk08; -}; - -struct CellDataBank_02008DEC -{ - NNSG2dCellDataBank *cellBank; -}; - -struct AnimBank_02008DEC -{ - NNSG2dAnimBankData *bankData; -}; - THUMB_FUNC void FUN_020097FC( struct UnkStruct1_sub *param0, u32 param1, u32 param2, u32 param3, u32 param4) { @@ -1015,7 +992,7 @@ THUMB_FUNC u32 FUN_02009C5C(struct UnkStruct1_sub *param0) return FUN_0201D3B0(FUN_02009530(param0)); } -THUMB_FUNC void FUN_02009C80(struct UnkStruct1_sub *param0, struct UnkStruct1_sub *param1) +THUMB_FUNC u32 FUN_02009C80(struct UnkStruct1_sub *param0, struct UnkStruct1_sub *param1) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -1025,7 +1002,7 @@ THUMB_FUNC void FUN_02009C80(struct UnkStruct1_sub *param0, struct UnkStruct1_su s32 r4 = FUN_02009530(param0); if (FUN_0201D3D4(r4, ((u32 **)FUN_02009574(param1))[3][0]) == 0) { - FUN_0201D458(FUN_0201D3B0(r4)); + return FUN_0201D458(FUN_0201D3B0(r4)); } } diff --git a/arm9/src/unk_0200BB14.c b/arm9/src/unk_0200BB14.c index ac8d048e..e84b759b 100644 --- a/arm9/src/unk_0200BB14.c +++ b/arm9/src/unk_0200BB14.c @@ -3,6 +3,7 @@ #include "game_init.h" #include "heap.h" #include "unk_02008AA4.h" +#include "unk_02008DEC.h" extern void FUN_0201D060(u32 *param0, u32 param1, u32 param2); extern void FUN_0201E00C(u32 param0, u32 param1); @@ -24,44 +25,15 @@ extern void FUN_0201FDEC(u32 param0); extern void FUN_02009F80(); extern void FUN_0201C348(); extern void FUN_0201FD58(u32 param0); -extern u32 FUN_02009660(u32 *param0, s32 param1); -extern void FUN_020096B4(u32 param0); -extern void FUN_02009C30(u32 *param0); -extern void FUN_02009E28(u32 *param0); -extern void FUN_02009448(u32 *param0); -extern void FUN_02008E2C(u32 param0); extern void FUN_0201C350(u32 param0); extern void FUN_0201D12C(); extern void FUN_0201E08C(); extern void FUN_02009FA0(); -extern u32 FUN_0200965C(s32 param0); -extern void FUN_02009668(void *param0, u32 param1, u32 param2); -extern u32 FUN_020096CC(u32 param0); -extern u32 FUN_02008DEC(u32 param0, s32 param1, u32 param2); -extern u32 *FUN_02009424(u32 param0, u32 param1); -extern u32 FUN_020093A8(u32 param0, u32 param1, u32 *param2, u32 param3); -extern void FUN_02009A90(u32 *param0); -extern void FUN_02009D34(u32 *param0); extern u32 FUN_0201FE94(struct UnkStruct_0200BB14_4 *param0); extern void FUN_02020130(u32 param0, u32 param1); extern void FUN_02020248(u32 param0, u32 param1); -extern u32 FUN_0200945C(u32 param0, s32 param1); -extern u32 FUN_02008F34( - u32 param0, u32 param1, u32 param2, u32 param3, s32 param4, u32 param5, u32 param6); -extern void FUN_02009B04(u32 param0); -extern u32 FUN_02008FEC( - u32 param0, u32 param1, u32 param2, u32 param3, s32 param4, u32 param5, u32 param6, u32 param7); -extern u32 FUN_02009D68(u32 param0); -extern u32 FUN_02009E88(u32 param0, u32 param1); extern void FUN_02003108(u32 param0, u32 param1, u16 param2, u32 param3); extern u8 FUN_020202A0(u32 param0); -extern u32 FUN_020094F0(u32 param0, u32 param1); -extern u32 FUN_02009E54(u32 param0, u32 param1); -extern void FUN_02009CDC(u32 param0); -extern u32 FUN_020090AC( - u32 param0, u32 param1, u32 param2, u32 param3, s32 param4, u32 param5, u32 param6); -extern u32 FUN_02009530(u32 param0); -extern void FUN_02009490(u32 param0, u32 param1); extern void FUN_0201D324(u32 param0); extern void FUN_0201E1C8(u32 param0); extern void FUN_020201E4(u32 param0, u32 param1); @@ -91,12 +63,6 @@ extern void FUN_02020100(u32 param0, u32 param1); extern void FUN_02020054(u32 param0, u32 *param1); extern void FUN_02020358(u32 param0, u32 param1); extern void FUN_02020398(u32 param0, u32 param1); -extern void FUN_02009AC4(u32 param0); -extern void FUN_02009B78(u32 param0); -extern void FUN_020090FC(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5); -extern void FUN_02009BE8(u32 param0); -extern void FUN_02009168(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5); -extern void FUN_02009DE0(u32 param0); THUMB_FUNC struct UnkStruct_0200BB14_1 *FUN_0200BB14(u32 heap_id) { @@ -293,12 +259,12 @@ THUMB_FUNC BOOL FUN_0200BD20( } param1->unk54 = st14; - u32 r2 = FUN_0200965C(st14); + u32 r2 = FUN_0200965C(); param1->unk08 = AllocFromHeap(param0->unk000, r2 * st14); for (s32 i = 0; i < st14; i++) { - u32 st18 = FUN_02009660(param1->unk08, i); + struct UnkStruct2 *st18 = FUN_02009660(param1->unk08, i); void *st1c = AllocAndReadFile(param0->unk000, st10[i]); FUN_02009668(st1c, st18, param0->unk000); @@ -313,7 +279,7 @@ THUMB_FUNC BOOL FUN_0200BD20( for (s32 i = 0; i < st14; i++) { - u32 st20 = FUN_02009660(param1->unk08, i); + struct UnkStruct2 *st20 = FUN_02009660(param1->unk08, i); param1->unk24[i] = FUN_02009424(FUN_020096CC(st20), param0->unk000); param1->unk3c[i] = FUN_020093A8(param1->unk0c[i], st20, param1->unk24[i], param0->unk000); } @@ -432,7 +398,7 @@ THUMB_FUNC u32 FUN_0200BE74(u32 *param0, } THUMB_FUNC BOOL FUN_0200BF60( - struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, u32 *param2) + struct UnkStruct_0200BB14_1 *param0, struct UnkStruct_0200BB14_2 *param1, s32 *param2) { struct UnkStruct_0200BB14_1 *st0 = param0; s32 i; @@ -462,9 +428,9 @@ THUMB_FUNC BOOL FUN_0200BF60( param1->unk24[i] = FUN_02009424(param2[i], st0->unk000); param1->unk3c[i] = 0; - for (s32 j = 0; j < (s32)param1->unk24[i][1]; j++) + for (s32 j = 0; j < param1->unk24[i]->unk04; j++) { - ((u32 *)param1->unk24[i][0])[j] = 0; + param1->unk24[i]->unk00[j] = NULL; } } } @@ -474,9 +440,9 @@ THUMB_FUNC BOOL FUN_0200BF60( THUMB_FUNC BOOL FUN_0200C00C(u32 *param0, struct UnkStruct_0200BB14_2 *param1, - u32 param2, - u32 param3, - u32 param4, + NarcId param2, + s32 param3, + BOOL param4, u32 param5, s32 param6) { @@ -485,8 +451,8 @@ THUMB_FUNC BOOL FUN_0200C00C(u32 *param0, return FALSE; } - u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); - if (r5 != 0) + struct UnkStruct1_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); + if (r5 != NULL) { FUN_02009B04(r5); FUN_0200C474(param1->unk24[0], r5); @@ -494,14 +460,14 @@ THUMB_FUNC BOOL FUN_0200C00C(u32 *param0, } GF_ASSERT(0); - return r5 != 0 ? TRUE : FALSE; + return r5 != NULL ? TRUE : FALSE; } THUMB_FUNC s32 FUN_0200C06C(u32 *param0, struct UnkStruct_0200BB14_2 *param1, - u32 param2, - u32 param3, - u32 param4, + NarcId param2, + s32 param3, + BOOL param4, u32 param5, u32 param6, s32 param7) @@ -511,16 +477,16 @@ THUMB_FUNC s32 FUN_0200C06C(u32 *param0, return -1; } - u32 r5 = + struct UnkStruct1_sub * r5 = FUN_02008FEC(param1->unk0c[1], param2, param3, param4, param7, param6, param5, param0[0]); - if (r5 != 0) + if (r5 != NULL) { GF_ASSERT(FUN_02009D68(r5) == 1); FUN_0200C474(param1->unk24[1], r5); return (s8)FUN_02009E88(r5, param6); } - GF_ASSERT(0); + GF_ASSERT(FALSE); return -1; } @@ -528,9 +494,9 @@ THUMB_FUNC u8 FUN_0200C0DC(u32 param0, u32 param1, u32 *param2, struct UnkStruct_0200BB14_2 *param3, - u32 param4, - u32 param5, - u32 param6, + NarcId param4, + s32 param5, + BOOL param6, u32 param7, u32 param8, s32 param9) @@ -546,9 +512,9 @@ THUMB_FUNC u8 FUN_0200C0DC(u32 param0, THUMB_FUNC BOOL FUN_0200C124(u32 *param0, struct UnkStruct_0200BB14_2 *param1, - u32 param2, - u32 param3, - u32 param4, + NarcId param2, + s32 param3, + BOOL param4, s32 param5) { return FUN_0200C404(param0, param1, param2, param3, param4, 2, param5); @@ -556,9 +522,9 @@ THUMB_FUNC BOOL FUN_0200C124(u32 *param0, THUMB_FUNC BOOL FUN_0200C13C(u32 *param0, struct UnkStruct_0200BB14_2 *param1, - u32 param2, - u32 param3, - u32 param4, + NarcId param2, + s32 param3, + BOOL param4, s32 param5) { return FUN_0200C404(param0, param1, param2, param3, param4, 3, param5); @@ -698,12 +664,12 @@ THUMB_FUNC struct UnkStruct_0200BB14_5 *FUN_0200C154( return ptr; } -THUMB_FUNC u32 FUN_0200C334(u32 *param0, u32 param1) +THUMB_FUNC u32 FUN_0200C334(struct UnkStruct1 **param0, s32 param1) { return FUN_02009E54(FUN_020094F0(param0[4], param1), 0); } -THUMB_FUNC u32 FUN_0200C344(u32 *param0, u32 param1, u32 param2) +THUMB_FUNC s32 FUN_0200C344(struct UnkStruct1 **param0, s32 param1, u32 param2) { return FUN_02009E88(FUN_020094F0(param0[4], param1), param2); } @@ -752,15 +718,15 @@ THUMB_FUNC void FUN_0200C3DC(u32 *param0) } FUN_0201FFC8(param0[0]); - FUN_02008C80(param0[2]); + FUN_02008C80((struct UnkStruct_02008AA4_1 *)param0[2]); FreeToHeap(param0); } THUMB_FUNC BOOL FUN_0200C404(u32 *param0, struct UnkStruct_0200BB14_2 *param1, - u32 param2, - u32 param3, - u32 param4, + NarcId param2, + s32 param3, + BOOL param4, u32 param5, s32 param6) { @@ -769,25 +735,25 @@ THUMB_FUNC BOOL FUN_0200C404(u32 *param0, return FALSE; } - u32 r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]); - if (r5 != 0) + struct UnkStruct1_sub *r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]); + if (r5 != NULL) { BOOL r4 = FUN_0200C474(param1->unk24[param5], r5); GF_ASSERT(r4 == TRUE); return r4; } GF_ASSERT(0); - return r5 != 0 ? TRUE : FALSE; + return r5 != NULL ? TRUE : FALSE; } -THUMB_FUNC BOOL FUN_0200C474(u32 *param0, u32 param1) +THUMB_FUNC BOOL FUN_0200C474(struct UnkStruct5 *param0, struct UnkStruct1_sub *param1) { - for (s32 i = 0; i < (s32)param0[1]; i++) + for (s32 i = 0; i < param0->unk04; i++) { - if (((u32 *)param0[0])[i] == 0) + if (param0->unk00[i] == NULL) { - ((u32 *)param0[0])[i] = param1; - param0[2]++; + param0->unk00[i] = param1; + param0->unk08++; return TRUE; } } @@ -795,19 +761,19 @@ THUMB_FUNC BOOL FUN_0200C474(u32 *param0, u32 param1) return FALSE; } -THUMB_FUNC BOOL FUN_0200C4A8(u32 param0, u32 *param1, u32 param2) +THUMB_FUNC BOOL FUN_0200C4A8(struct UnkStruct1 *param0, struct UnkStruct5 *param1, u32 param2) { - for (s32 i = 0; i < (s32)param1[1]; i++) + for (s32 i = 0; i < param1->unk04; i++) { - if (((u32 *)param1[0])[i] != 0) + if (param1->unk00[i] != 0) { - u32 r0 = FUN_02009530(((u32 *)param1[0])[i]); + s32 r0 = FUN_02009530(param1->unk00[i]); if (r0 == param2) { - FUN_02009490(param0, ((u32 *)param1[0])[i]); - ((u32 *)param1[0])[i] = 0; - param1[2]--; + FUN_02009490(param0, param1->unk00[i]); + param1->unk00[i] = NULL; + param1->unk08--; return TRUE; } @@ -817,20 +783,20 @@ THUMB_FUNC BOOL FUN_0200C4A8(u32 param0, u32 *param1, u32 param2) return FALSE; } -THUMB_FUNC BOOL FUN_0200C4F4(u32 param0, u32 *param1, u32 param2) +THUMB_FUNC BOOL FUN_0200C4F4(struct UnkStruct1 *param0, struct UnkStruct5 *param1, u32 param2) { - for (s32 i = 0; i < (s32)param1[1]; i++) + for (s32 i = 0; i < param1->unk04; i++) { - if (((u32 *)param1[0])[i] != 0) + if (param1->unk00[i] != NULL) { - u32 r0 = FUN_02009530(((u32 *)param1[0])[i]); + s32 r0 = FUN_02009530(param1->unk00[i]); if (r0 == param2) { FUN_0201D324(param2); - FUN_02009490(param0, ((u32 *)param1[0])[i]); - ((u32 *)param1[0])[i] = 0; - param1[2]--; + FUN_02009490(param0, param1->unk00[i]); + param1->unk00[i] = NULL; + param1->unk08--; return TRUE; } @@ -840,20 +806,20 @@ THUMB_FUNC BOOL FUN_0200C4F4(u32 param0, u32 *param1, u32 param2) return FALSE; } -THUMB_FUNC BOOL FUN_0200C548(u32 param0, u32 *param1, u32 param2) +THUMB_FUNC BOOL FUN_0200C548(struct UnkStruct1 *param0, struct UnkStruct5 *param1, u32 param2) { - for (s32 i = 0; i < (s32)param1[1]; i++) + for (s32 i = 0; i < param1->unk04; i++) { - if (((u32 *)param1[0])[i] != 0) + if (param1->unk00[i] != 0) { - u32 r0 = FUN_02009530(((u32 *)param1[0])[i]); + s32 r0 = FUN_02009530(param1->unk00[i]); if (r0 == param2) { FUN_0201E1C8(param2); - FUN_02009490(param0, ((u32 *)param1[0])[i]); - ((u32 *)param1[0])[i] = 0; - param1[2]--; + FUN_02009490(param0, param1->unk00[i]); + param1->unk00[i] = NULL; + param1->unk08--; return TRUE; } @@ -1205,9 +1171,9 @@ THUMB_FUNC void FUN_0200C90C(u32 *param0, u32 param1) THUMB_FUNC BOOL FUN_0200C918(u32 *param0, struct UnkStruct_0200BB14_2 *param1, - u32 param2, - u32 param3, - u32 param4, + NarcId param2, + s32 param3, + BOOL param4, u32 param5, s32 param6) { @@ -1216,8 +1182,8 @@ THUMB_FUNC BOOL FUN_0200C918(u32 *param0, return FALSE; } - u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); - if (r5 != 0) + struct UnkStruct1_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); + if (r5 != NULL) { FUN_02009AC4(r5); FUN_0200C474(param1->unk24[0], r5); @@ -1225,15 +1191,15 @@ THUMB_FUNC BOOL FUN_0200C918(u32 *param0, return TRUE; } - GF_ASSERT(0); - return r5 != 0 ? TRUE : FALSE; + GF_ASSERT(FALSE); + return r5 != NULL ? TRUE : FALSE; } THUMB_FUNC BOOL FUN_0200C978(u32 *param0, struct UnkStruct_0200BB14_2 *param1, - u32 param2, - u32 param3, - u32 param4, + NarcId param2, + s32 param3, + BOOL param4, u32 param5, s32 param6) { @@ -1242,8 +1208,8 @@ THUMB_FUNC BOOL FUN_0200C978(u32 *param0, return FALSE; } - u32 r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); - if (r5 != 0) + struct UnkStruct1_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); + if (r5 != NULL) { FUN_02009B78(r5); FUN_0200C474(param1->unk24[0], r5); @@ -1251,23 +1217,23 @@ THUMB_FUNC BOOL FUN_0200C978(u32 *param0, return TRUE; } - GF_ASSERT(0); - return r5 != 0 ? TRUE : FALSE; + GF_ASSERT(FALSE); + return r5 != NULL ? TRUE : FALSE; } THUMB_FUNC void FUN_0200C9D8( - u32 *param0, u32 *param1, u32 param2, u32 param3, u32 param4, u32 param5) + u32 *param0, struct UnkStruct1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5) { - u32 r6 = FUN_020094F0(param1[3], param5); + struct UnkStruct1_sub *r6 = FUN_020094F0(param1[3], param5); FUN_020090FC(param1[3], r6, param2, param3, param4, param0[0]); FUN_02009BE8(r6); } THUMB_FUNC void FUN_0200CA0C( - u32 *param0, u32 *param1, u32 param2, u32 param3, u32 param4, u32 param5) + u32 *param0, struct UnkStruct1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5) { - u32 r6 = FUN_020094F0(param1[4], param5); + struct UnkStruct1_sub *r6 = FUN_020094F0(param1[4], param5); FUN_02009168(param1[4], r6, param2, param3, param4, param0[0]); FUN_02009DE0(r6); -- cgit v1.2.3 From 5ded23bcd3e68fa316c46b37266047ab28d08a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Thu, 12 Aug 2021 00:34:18 +0200 Subject: global struct names --- arm9/src/unk_02008AA4.c | 36 ++++---- arm9/src/unk_02008DEC.c | 222 ++++++++++++++++++++++++------------------------ arm9/src/unk_0200BB14.c | 34 ++++---- 3 files changed, 146 insertions(+), 146 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02008AA4.c b/arm9/src/unk_02008AA4.c index 4ddb6995..1cabb887 100644 --- a/arm9/src/unk_02008AA4.c +++ b/arm9/src/unk_02008AA4.c @@ -21,20 +21,20 @@ THUMB_FUNC void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0, s32 param6, u32 param7, u32 param8, - struct UnkStruct1 *param9, - struct UnkStruct1 *param10, - struct UnkStruct1 *param11, - struct UnkStruct1 *param12, - struct UnkStruct1 *param13, - struct UnkStruct1 *param14) + struct UnkStruct_02008DEC_1 *param9, + struct UnkStruct_02008DEC_1 *param10, + struct UnkStruct_02008DEC_1 *param11, + struct UnkStruct_02008DEC_1 *param12, + struct UnkStruct_02008DEC_1 *param13, + struct UnkStruct_02008DEC_1 *param14) { - struct UnkStruct1_sub *r7; - struct UnkStruct1_sub *st14; - struct UnkStruct1_sub *st10; + struct UnkStruct_02008DEC_sub *r7; + struct UnkStruct_02008DEC_sub *st14; + struct UnkStruct_02008DEC_sub *st10; - struct UnkStruct1_sub *stc = NULL; - struct UnkStruct1_sub *r4 = NULL; - struct UnkStruct1_sub *st8 = NULL; + struct UnkStruct_02008DEC_sub *stc = NULL; + struct UnkStruct_02008DEC_sub *r4 = NULL; + struct UnkStruct_02008DEC_sub *st8 = NULL; GF_ASSERT(param9); GF_ASSERT(param10); @@ -116,12 +116,12 @@ THUMB_FUNC void FUN_02008AA4(struct UnkStruct_0200BB14_sub *param0, THUMB_FUNC struct UnkStruct_02008AA4_1 *FUN_02008BE0(struct UnkStruct_02008AA4_2 *param0, u32 param1, - struct UnkStruct1 *param2, - struct UnkStruct1 *param3, - struct UnkStruct1 *param4, - struct UnkStruct1 *param5, - struct UnkStruct1 *param6, - struct UnkStruct1 *param7) + struct UnkStruct_02008DEC_1 *param2, + struct UnkStruct_02008DEC_1 *param3, + struct UnkStruct_02008DEC_1 *param4, + struct UnkStruct_02008DEC_1 *param5, + struct UnkStruct_02008DEC_1 *param6, + struct UnkStruct_02008DEC_1 *param7) { s32 r4 = 0; diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c index 76e32b63..4467a03d 100644 --- a/arm9/src/unk_02008DEC.c +++ b/arm9/src/unk_02008DEC.c @@ -31,12 +31,12 @@ extern u32 FUN_0201E258(s32, u32); extern u32 FUN_0201E230(s32); extern s32 NNS_G2dGetImagePaletteLocation(u32, u32); -THUMB_FUNC struct UnkStruct1 *FUN_02008DEC(u32 param0, s32 param1, u32 heap_id) +THUMB_FUNC struct UnkStruct_02008DEC_1 *FUN_02008DEC(u32 param0, s32 param1, u32 heap_id) { - struct UnkStruct1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct1)); + struct UnkStruct_02008DEC_1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_02008DEC_1)); ptr->unk00 = FUN_02020C44(param0, heap_id); - ptr->unk04 = AllocFromHeap(heap_id, param0 * sizeof(struct UnkStruct1_sub)); - memset(ptr->unk04, 0, param0 * sizeof(struct UnkStruct1_sub)); + ptr->unk04 = AllocFromHeap(heap_id, param0 * sizeof(struct UnkStruct_02008DEC_sub)); + memset(ptr->unk04, 0, param0 * sizeof(struct UnkStruct_02008DEC_sub)); ptr->unk08 = (s32)param0; ptr->unk0C = 0; ptr->unk10 = param1; @@ -44,7 +44,7 @@ THUMB_FUNC struct UnkStruct1 *FUN_02008DEC(u32 param0, s32 param1, u32 heap_id) return ptr; } -THUMB_FUNC void FUN_02008E2C(struct UnkStruct1 *param0) +THUMB_FUNC void FUN_02008E2C(struct UnkStruct_02008DEC_1 *param0) { GF_ASSERT(param0); GF_ASSERT(param0->unk00); @@ -61,20 +61,20 @@ THUMB_FUNC void FUN_02008E2C(struct UnkStruct1 *param0) FreeToHeap(param0); } -THUMB_FUNC struct UnkStruct1_sub *FUN_02008E6C( - struct UnkStruct1 *param0, struct UnkStruct2 *param1, s32 param2, u32 param3) +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008E6C( + struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_2 *param1, s32 param2, u32 param3) { GF_ASSERT(param0); GF_ASSERT(param1); GF_ASSERT(param1->unk04 > param2); GF_ASSERT(param0->unk10 == param1->unk08); - struct UnkStruct1_sub *st1c = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *st1c = FUN_020097D0(param0); GF_ASSERT(st1c); if (param1->unk0C == 0) { - struct UnkStruct3 *r6 = &((struct UnkStruct3 *)param1->unk00)[param2]; + struct UnkStruct_02008DEC_3 *r6 = &((struct UnkStruct_02008DEC_3 *)param1->unk00)[param2]; GF_ASSERT(FUN_0200945C(param0, r6->unk00) == 1); FUN_0200994C( @@ -82,7 +82,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008E6C( } else { - struct UnkStruct4 *r6 = &((struct UnkStruct4 *)param1->unk00)[param2]; + struct UnkStruct_02008DEC_4 *r6 = &((struct UnkStruct_02008DEC_4 *)param1->unk00)[param2]; GF_ASSERT(FUN_0200945C(param0, r6->unk0C) == 1); FUN_02009978(param0, @@ -103,7 +103,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008E6C( return st1c; } -THUMB_FUNC struct UnkStruct1_sub *FUN_02008F34(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008F34(struct UnkStruct_02008DEC_1 *param0, NarcId param1, s32 param2, BOOL param3, @@ -114,7 +114,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008F34(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 0); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_02009978(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, FALSE); @@ -123,7 +123,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008F34(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_02008F90(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008F90(struct UnkStruct_02008DEC_1 *param0, NarcId param1, s32 param2, BOOL param3, @@ -135,7 +135,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008F90(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 0); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_02009978(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, param7); @@ -144,7 +144,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008F90(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_02008FEC(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008FEC(struct UnkStruct_02008DEC_1 *param0, NarcId param1, s32 param2, BOOL param3, @@ -156,7 +156,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008FEC(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 1); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_02009978(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, FALSE); @@ -165,7 +165,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02008FEC(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_0200904C(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_0200904C(struct UnkStruct_02008DEC_1 *param0, NarcId param1, s32 param2, BOOL param3, @@ -178,7 +178,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_0200904C(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 1); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_02009978(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, param8); @@ -187,7 +187,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_0200904C(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_020090AC(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020090AC(struct UnkStruct_02008DEC_1 *param0, NarcId param1, s32 param2, BOOL param3, @@ -197,7 +197,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020090AC(struct UnkStruct1 *param0, { GF_ASSERT(param0); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_02009978(param0, r6, param1, param2, param3, param4, 0, 0, param5, param6, FALSE); @@ -206,8 +206,8 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020090AC(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC void FUN_020090FC(struct UnkStruct1 *param0, - struct UnkStruct1_sub *param1, +THUMB_FUNC void FUN_020090FC(struct UnkStruct_02008DEC_1 *param0, + struct UnkStruct_02008DEC_sub *param1, NarcId param2, s32 param3, BOOL param4, @@ -225,8 +225,8 @@ THUMB_FUNC void FUN_020090FC(struct UnkStruct1 *param0, FUN_02009978(param0, param1, param2, param3, param4, r6, r7, 0, 0, param5, FALSE); } -THUMB_FUNC void FUN_02009168(struct UnkStruct1 *param0, - struct UnkStruct1_sub *param1, +THUMB_FUNC void FUN_02009168(struct UnkStruct_02008DEC_1 *param0, + struct UnkStruct_02008DEC_sub *param1, NarcId param2, s32 param3, BOOL param4, @@ -245,7 +245,7 @@ THUMB_FUNC void FUN_02009168(struct UnkStruct1 *param0, FUN_02009978(param0, param1, param2, param3, param4, r6, r7, st24, 1, param5, 0); } -THUMB_FUNC struct UnkStruct1_sub *FUN_020091E0(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020091E0(struct UnkStruct_02008DEC_1 *param0, NARC *param1, u32 param2, u32 param3, @@ -256,7 +256,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020091E0(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 0); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, 0); @@ -265,7 +265,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020091E0(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_0200923C(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_0200923C(struct UnkStruct_02008DEC_1 *param0, NARC *param1, u32 param2, u32 param3, @@ -277,7 +277,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_0200923C(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 0); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, 0, 0, param6, param7); @@ -286,7 +286,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_0200923C(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_02009298(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02009298(struct UnkStruct_02008DEC_1 *param0, NARC *param1, u32 param2, u32 param3, @@ -298,7 +298,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02009298(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 1); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, 0); @@ -307,7 +307,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02009298(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_020092F8(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020092F8(struct UnkStruct_02008DEC_1 *param0, NARC *param1, u32 param2, u32 param3, @@ -320,7 +320,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020092F8(struct UnkStruct1 *param0, GF_ASSERT(param0); GF_ASSERT(param0->unk10 == 1); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, param5, param6, 1, param7, param8); @@ -329,7 +329,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020092F8(struct UnkStruct1 *param0, return r6; } -THUMB_FUNC struct UnkStruct1_sub *FUN_02009358(struct UnkStruct1 *param0, +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02009358(struct UnkStruct_02008DEC_1 *param0, NARC *param1, u32 param2, u32 param3, @@ -339,7 +339,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02009358(struct UnkStruct1 *param0, { GF_ASSERT(param0); - struct UnkStruct1_sub *r6 = FUN_020097D0(param0); + struct UnkStruct_02008DEC_sub *r6 = FUN_020097D0(param0); GF_ASSERT(r6); FUN_020099B0(param0, r6, param1, param2, param3, param4, 0, 0, param5, param6, 0); @@ -349,7 +349,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_02009358(struct UnkStruct1 *param0, } THUMB_FUNC s32 FUN_020093A8( - struct UnkStruct1 *param0, struct UnkStruct2 *param1, struct UnkStruct5 *param2, u32 param3) + struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_2 *param1, struct UnkStruct_02008DEC_5 *param2, u32 param3) { GF_ASSERT(param0); GF_ASSERT(param1); @@ -359,16 +359,16 @@ THUMB_FUNC s32 FUN_020093A8( return param1->unk04; } -THUMB_FUNC void FUN_020093DC(struct UnkStruct1 *param0, - struct UnkStruct2 *param1, +THUMB_FUNC void FUN_020093DC(struct UnkStruct_02008DEC_1 *param0, + struct UnkStruct_02008DEC_2 *param1, s32 param2, s32 param3, - struct UnkStruct5 *param4, + struct UnkStruct_02008DEC_5 *param4, u32 param5) { for (int r5 = param2; r5 < param2 + param3; r5++) { - struct UnkStruct1_sub *r0 = FUN_02008E6C(param0, param1, r5, param5); + struct UnkStruct_02008DEC_sub *r0 = FUN_02008E6C(param0, param1, r5, param5); if (param4 != NULL && param4->unk04 > param4->unk08) { @@ -378,29 +378,29 @@ THUMB_FUNC void FUN_020093DC(struct UnkStruct1 *param0, } } -THUMB_FUNC struct UnkStruct5 *FUN_02009424(s32 param0, u32 param1) +THUMB_FUNC struct UnkStruct_02008DEC_5 *FUN_02009424(s32 param0, u32 param1) { - struct UnkStruct5 *r4 = AllocFromHeap(param1, sizeof(struct UnkStruct5)); - r4->unk00 = AllocFromHeap(param1, param0 * sizeof(struct UnkStruct1_sub *)); + struct UnkStruct_02008DEC_5 *r4 = AllocFromHeap(param1, sizeof(struct UnkStruct_02008DEC_5)); + r4->unk00 = AllocFromHeap(param1, param0 * sizeof(struct UnkStruct_02008DEC_sub *)); r4->unk04 = param0; r4->unk08 = 0; return r4; } -THUMB_FUNC void FUN_02009448(struct UnkStruct5 *param0) +THUMB_FUNC void FUN_02009448(struct UnkStruct_02008DEC_5 *param0) { FreeToHeap(param0->unk00); FreeToHeap(param0); } -THUMB_FUNC u32 FUN_0200945C(struct UnkStruct1 *param0, s32 param1) +THUMB_FUNC u32 FUN_0200945C(struct UnkStruct_02008DEC_1 *param0, s32 param1) { GF_ASSERT(param0); return FUN_02020CB0(param0->unk00, param1); } -THUMB_FUNC void FUN_02009474(struct UnkStruct1_sub *param0) +THUMB_FUNC void FUN_02009474(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); @@ -408,7 +408,7 @@ THUMB_FUNC void FUN_02009474(struct UnkStruct1_sub *param0) FUN_02020E1C(param0->unk00, 0); } -THUMB_FUNC void FUN_02009490(struct UnkStruct1 *param0, struct UnkStruct1_sub *param1) +THUMB_FUNC void FUN_02009490(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_sub *param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04); @@ -419,7 +419,7 @@ THUMB_FUNC void FUN_02009490(struct UnkStruct1 *param0, struct UnkStruct1_sub *p param0->unk0C--; } -THUMB_FUNC void FUN_020094C4(struct UnkStruct1 *param0) +THUMB_FUNC void FUN_020094C4(struct UnkStruct_02008DEC_1 *param0) { for (int i = 0; i < param0->unk08; i++) { @@ -430,7 +430,7 @@ THUMB_FUNC void FUN_020094C4(struct UnkStruct1 *param0) } } -THUMB_FUNC struct UnkStruct1_sub *FUN_020094F0(struct UnkStruct1 *param0, s32 param1) +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020094F0(struct UnkStruct_02008DEC_1 *param0, s32 param1) { GF_ASSERT(param0); @@ -449,56 +449,56 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020094F0(struct UnkStruct1 *param0, s32 pa return NULL; } -THUMB_FUNC s32 FUN_02009530(struct UnkStruct1_sub *param0) +THUMB_FUNC s32 FUN_02009530(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); return FUN_02020E38(param0->unk00); } -THUMB_FUNC u32 FUN_02009544(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009544(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0->unk04 == 0); return *FUN_02009934(param0); } -THUMB_FUNC u32 FUN_0200955C(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_0200955C(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0->unk04 == 1); return *FUN_02009934(param0); } -THUMB_FUNC u32 FUN_02009574(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009574(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0->unk04 == 2); return *FUN_02009934(param0); } -THUMB_FUNC u32 FUN_0200958C(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_0200958C(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0->unk04 == 3); return *FUN_02009934(param0); } -THUMB_FUNC u32 FUN_020095A4(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_020095A4(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0->unk04 == 4); return *FUN_02009934(param0); } -THUMB_FUNC u32 FUN_020095BC(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_020095BC(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0->unk04 == 5); return *FUN_02009934(param0); } -THUMB_FUNC u32 FUN_020095D4(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_020095D4(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); return param0->unk04; } -THUMB_FUNC u32 FUN_020095E4(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_020095E4(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); @@ -514,7 +514,7 @@ THUMB_FUNC u32 FUN_020095E4(struct UnkStruct1_sub *param0) return 0; } -THUMB_FUNC u32 FUN_02009610(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009610(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); @@ -526,7 +526,7 @@ THUMB_FUNC u32 FUN_02009610(struct UnkStruct1_sub *param0) return 0; } -THUMB_FUNC void FUN_02009630(struct UnkStruct1_sub *param0, u32 param1) +THUMB_FUNC void FUN_02009630(struct UnkStruct_02008DEC_sub *param0, u32 param1) { GF_ASSERT(param0); @@ -545,24 +545,24 @@ THUMB_FUNC u32 FUN_0200965C(void) return 16; } -THUMB_FUNC struct UnkStruct2 *FUN_02009660(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC struct UnkStruct_02008DEC_2 *FUN_02009660(struct UnkStruct_02008DEC_2 *param0, s32 param1) { return ¶m0[param1]; } -THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct2 *param1, u32 param2) +THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct_02008DEC_2 *param1, u32 param2) { GF_ASSERT(param1); param1->unk08 = param0[0]; param1->unk0C = 1; - param1->unk04 = FUN_020099E8((struct UnkStruct4 *)(param0 + 1)); + param1->unk04 = FUN_020099E8((struct UnkStruct_02008DEC_4 *)(param0 + 1)); void *ptr; if (param1->unk04 > 0) { - ptr = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct4)); + ptr = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); } else { @@ -574,11 +574,11 @@ THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct2 *param1, u32 param2) void *r0 = *((void *volatile *)param1); if (r0 != NULL) { - memcpy(r0, param0 + 1, param1->unk04 * sizeof(struct UnkStruct4)); + memcpy(r0, param0 + 1, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); } } -THUMB_FUNC void FUN_020096B4(struct UnkStruct2 *param0) +THUMB_FUNC void FUN_020096B4(struct UnkStruct_02008DEC_2 *param0) { if (param0->unk00) { @@ -588,27 +588,27 @@ THUMB_FUNC void FUN_020096B4(struct UnkStruct2 *param0) param0->unk04 = 0; } -THUMB_FUNC s32 FUN_020096CC(struct UnkStruct2 *param0) +THUMB_FUNC s32 FUN_020096CC(struct UnkStruct_02008DEC_2 *param0) { GF_ASSERT(param0); return param0->unk04; } -THUMB_FUNC s32 FUN_020096DC(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC s32 FUN_020096DC(struct UnkStruct_02008DEC_2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); if (param0->unk0C == 0) { - return ((struct UnkStruct3 *)param0->unk00)[param1].unk00; + return ((struct UnkStruct_02008DEC_3 *)param0->unk00)[param1].unk00; } - return ((struct UnkStruct4 *)param0->unk00)[param1].unk0C; + return ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk0C; } -THUMB_FUNC s32 FUN_02009710(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC s32 FUN_02009710(struct UnkStruct_02008DEC_2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); @@ -616,14 +616,14 @@ THUMB_FUNC s32 FUN_02009710(struct UnkStruct2 *param0, s32 param1) s32 r6; if (param0->unk0C == 1) { - r6 = ((struct UnkStruct4 *)param0->unk00)[param1].unk04; + r6 = ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk04; } // oops, UB here return r6; } -THUMB_FUNC BOOL FUN_0200973C(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC BOOL FUN_0200973C(struct UnkStruct_02008DEC_2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); @@ -631,40 +631,40 @@ THUMB_FUNC BOOL FUN_0200973C(struct UnkStruct2 *param0, s32 param1) BOOL r6; if (param0->unk0C == 1) { - r6 = ((struct UnkStruct4 *)param0->unk00)[param1].unk08; + r6 = ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk08; } // oops, UB here return r6; } -THUMB_FUNC u32 FUN_02009768(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC u32 FUN_02009768(struct UnkStruct_02008DEC_2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); if (param0->unk0C == 0) { - return ((struct UnkStruct3 *)param0->unk00)[param1].unk44; + return ((struct UnkStruct_02008DEC_3 *)param0->unk00)[param1].unk44; } - return ((struct UnkStruct4 *)param0->unk00)[param1].unk10; + return ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk10; } -THUMB_FUNC u32 FUN_0200979C(struct UnkStruct2 *param0, s32 param1) +THUMB_FUNC u32 FUN_0200979C(struct UnkStruct_02008DEC_2 *param0, s32 param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk04 > param1); if (param0->unk0C == 0) { - return ((struct UnkStruct3 *)param0->unk00)[param1].unk48; + return ((struct UnkStruct_02008DEC_3 *)param0->unk00)[param1].unk48; } - return ((struct UnkStruct4 *)param0->unk00)[param1].unk14; + return ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk14; } -THUMB_FUNC struct UnkStruct1_sub *FUN_020097D0(struct UnkStruct1 *param0) +THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020097D0(struct UnkStruct_02008DEC_1 *param0) { for (int i = 0; i < param0->unk08; i++) { @@ -678,7 +678,7 @@ THUMB_FUNC struct UnkStruct1_sub *FUN_020097D0(struct UnkStruct1 *param0) } THUMB_FUNC void FUN_020097FC( - struct UnkStruct1_sub *param0, u32 param1, u32 param2, u32 param3, u32 param4) + struct UnkStruct_02008DEC_sub *param0, u32 param1, u32 param2, u32 param3, u32 param4) { void *r0 = FUN_02020E0C(param0->unk00); @@ -764,7 +764,7 @@ THUMB_FUNC void *FUN_02009904(void *param0, u32 param1) return ptr; } -THUMB_FUNC void FUN_02009920(struct UnkStruct1_sub *param0) +THUMB_FUNC void FUN_02009920(struct UnkStruct_02008DEC_sub *param0) { if (param0->unk08 != NULL) { @@ -774,7 +774,7 @@ THUMB_FUNC void FUN_02009920(struct UnkStruct1_sub *param0) param0->unk08 = NULL; } -THUMB_FUNC u32 *FUN_02009934(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 *FUN_02009934(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(param0->unk08); @@ -782,8 +782,8 @@ THUMB_FUNC u32 *FUN_02009934(struct UnkStruct1_sub *param0) return param0->unk08; } -THUMB_FUNC void FUN_0200994C(struct UnkStruct1 *param0, - struct UnkStruct1_sub *param1, +THUMB_FUNC void FUN_0200994C(struct UnkStruct_02008DEC_1 *param0, + struct UnkStruct_02008DEC_sub *param1, void *param2, s32 param3, u32 param4, @@ -796,8 +796,8 @@ THUMB_FUNC void FUN_0200994C(struct UnkStruct1 *param0, FUN_020097FC(param1, param6, param4, param5, param7); } -THUMB_FUNC void FUN_02009978(struct UnkStruct1 *param0, - struct UnkStruct1_sub *param1, +THUMB_FUNC void FUN_02009978(struct UnkStruct_02008DEC_1 *param0, + struct UnkStruct_02008DEC_sub *param1, NarcId param2, s32 param3, BOOL param4, @@ -815,8 +815,8 @@ THUMB_FUNC void FUN_02009978(struct UnkStruct1 *param0, FUN_020097FC(param1, param8, param6, param7, param9); } -THUMB_FUNC void FUN_020099B0(struct UnkStruct1 *param0, - struct UnkStruct1_sub *param1, +THUMB_FUNC void FUN_020099B0(struct UnkStruct_02008DEC_1 *param0, + struct UnkStruct_02008DEC_sub *param1, NARC *param2, u32 param3, u32 param4, @@ -834,7 +834,7 @@ THUMB_FUNC void FUN_020099B0(struct UnkStruct1 *param0, FUN_020097FC(param1, param8, param6, param7, param9); } -THUMB_FUNC s32 FUN_020099E8(struct UnkStruct4 *param0) +THUMB_FUNC s32 FUN_020099E8(struct UnkStruct_02008DEC_4 *param0) { s32 r3 = 0; while (param0[r3].unk00 != -2) @@ -873,7 +873,7 @@ THUMB_FUNC void *FUN_02009A04(NARC *param0, u32 param1, u32 param2, u32 param3, return r4; } -THUMB_FUNC u32 FUN_02009A50(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009A50(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -887,7 +887,7 @@ THUMB_FUNC u32 FUN_02009A50(struct UnkStruct1_sub *param0) return FUN_0201D1F8(st0); } -THUMB_FUNC void FUN_02009A90(struct UnkStruct5 *param0) +THUMB_FUNC void FUN_02009A90(struct UnkStruct_02008DEC_5 *param0) { GF_ASSERT(param0); @@ -897,7 +897,7 @@ THUMB_FUNC void FUN_02009A90(struct UnkStruct5 *param0) } } -THUMB_FUNC u32 FUN_02009AC4(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009AC4(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -911,7 +911,7 @@ THUMB_FUNC u32 FUN_02009AC4(struct UnkStruct1_sub *param0) return FUN_0201D250(st0); } -THUMB_FUNC u32 FUN_02009B04(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009B04(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -925,7 +925,7 @@ THUMB_FUNC u32 FUN_02009B04(struct UnkStruct1_sub *param0) return FUN_0201D1F8(st0); } -THUMB_FUNC void FUN_02009B44(struct UnkStruct5 *param0) +THUMB_FUNC void FUN_02009B44(struct UnkStruct_02008DEC_5 *param0) { GF_ASSERT(param0); @@ -935,7 +935,7 @@ THUMB_FUNC void FUN_02009B44(struct UnkStruct5 *param0) } } -THUMB_FUNC u32 FUN_02009B78(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009B78(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -949,7 +949,7 @@ THUMB_FUNC u32 FUN_02009B78(struct UnkStruct1_sub *param0) return FUN_0201D250(st0); } -THUMB_FUNC void FUN_02009BB8(struct UnkStruct1_sub *param0, struct UnkStruct1_sub *param1) +THUMB_FUNC void FUN_02009BB8(struct UnkStruct_02008DEC_sub *param0, struct UnkStruct_02008DEC_sub *param1) { GF_ASSERT(param0); GF_ASSERT(param1); @@ -957,14 +957,14 @@ THUMB_FUNC void FUN_02009BB8(struct UnkStruct1_sub *param0, struct UnkStruct1_su FUN_0201D2DC(FUN_02009530(param0), FUN_02009544(param1)); } -THUMB_FUNC void FUN_02009BE8(struct UnkStruct1_sub *param0) +THUMB_FUNC void FUN_02009BE8(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); FUN_0201D2DC(FUN_02009530(param0), FUN_02009544(param0)); } -THUMB_FUNC void FUN_02009C0C(struct UnkStruct1_sub *param0) +THUMB_FUNC void FUN_02009C0C(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -972,7 +972,7 @@ THUMB_FUNC void FUN_02009C0C(struct UnkStruct1_sub *param0) FUN_0201D324(FUN_02009530(param0)); } -THUMB_FUNC void FUN_02009C30(struct UnkStruct5 *param0) +THUMB_FUNC void FUN_02009C30(struct UnkStruct_02008DEC_5 *param0) { GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) @@ -984,7 +984,7 @@ THUMB_FUNC void FUN_02009C30(struct UnkStruct5 *param0) } } -THUMB_FUNC u32 FUN_02009C5C(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009C5C(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -992,7 +992,7 @@ THUMB_FUNC u32 FUN_02009C5C(struct UnkStruct1_sub *param0) return FUN_0201D3B0(FUN_02009530(param0)); } -THUMB_FUNC u32 FUN_02009C80(struct UnkStruct1_sub *param0, struct UnkStruct1_sub *param1) +THUMB_FUNC u32 FUN_02009C80(struct UnkStruct_02008DEC_sub *param0, struct UnkStruct_02008DEC_sub *param1) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 0); @@ -1013,7 +1013,7 @@ THUMB_FUNC void FUN_02009CDC(u32 param0) FUN_0201D4F0(param0); } -THUMB_FUNC u32 FUN_02009CF0(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009CF0(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 1); @@ -1027,7 +1027,7 @@ THUMB_FUNC u32 FUN_02009CF0(struct UnkStruct1_sub *param0) return FUN_0201E0E4(st0); } -THUMB_FUNC void FUN_02009D34(struct UnkStruct5 *param0) +THUMB_FUNC void FUN_02009D34(struct UnkStruct_02008DEC_5 *param0) { GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) @@ -1039,7 +1039,7 @@ THUMB_FUNC void FUN_02009D34(struct UnkStruct5 *param0) } } -THUMB_FUNC u32 FUN_02009D68(struct UnkStruct1_sub *param0) +THUMB_FUNC u32 FUN_02009D68(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 1); @@ -1053,7 +1053,7 @@ THUMB_FUNC u32 FUN_02009D68(struct UnkStruct1_sub *param0) return FUN_0201E128(st0); } -THUMB_FUNC void FUN_02009DAC(struct UnkStruct5 *param0) +THUMB_FUNC void FUN_02009DAC(struct UnkStruct_02008DEC_5 *param0) { GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) @@ -1065,14 +1065,14 @@ THUMB_FUNC void FUN_02009DAC(struct UnkStruct5 *param0) } } -THUMB_FUNC void FUN_02009DE0(struct UnkStruct1_sub *param0) +THUMB_FUNC void FUN_02009DE0(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); FUN_0201E168(FUN_02009530(param0), FUN_0200955C(param0)); } -THUMB_FUNC void FUN_02009E04(struct UnkStruct1_sub *param0) +THUMB_FUNC void FUN_02009E04(struct UnkStruct_02008DEC_sub *param0) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 1); @@ -1080,7 +1080,7 @@ THUMB_FUNC void FUN_02009E04(struct UnkStruct1_sub *param0) FUN_0201E1C8(FUN_02009530(param0)); } -THUMB_FUNC void FUN_02009E28(struct UnkStruct5 *param0) +THUMB_FUNC void FUN_02009E28(struct UnkStruct_02008DEC_5 *param0) { GF_ASSERT(param0); for (int i = 0; i < param0->unk04; i++) @@ -1092,7 +1092,7 @@ THUMB_FUNC void FUN_02009E28(struct UnkStruct5 *param0) } } -THUMB_FUNC u32 FUN_02009E54(struct UnkStruct1_sub *param0, u32 param1) +THUMB_FUNC u32 FUN_02009E54(struct UnkStruct_02008DEC_sub *param0, u32 param1) { GF_ASSERT(param0); GF_ASSERT(FUN_020095D4(param0) == 1); @@ -1106,7 +1106,7 @@ THUMB_FUNC u32 FUN_02009E54(struct UnkStruct1_sub *param0, u32 param1) return FUN_0201E230(r0); } -THUMB_FUNC s32 FUN_02009E88(struct UnkStruct1_sub *param0, u32 param1) +THUMB_FUNC s32 FUN_02009E88(struct UnkStruct_02008DEC_sub *param0, u32 param1) { s32 ret = NNS_G2dGetImagePaletteLocation(FUN_02009E54(param0, 0), param1); if (ret != -1) diff --git a/arm9/src/unk_0200BB14.c b/arm9/src/unk_0200BB14.c index e84b759b..95a854d7 100644 --- a/arm9/src/unk_0200BB14.c +++ b/arm9/src/unk_0200BB14.c @@ -264,7 +264,7 @@ THUMB_FUNC BOOL FUN_0200BD20( for (s32 i = 0; i < st14; i++) { - struct UnkStruct2 *st18 = FUN_02009660(param1->unk08, i); + struct UnkStruct_02008DEC_2 *st18 = FUN_02009660(param1->unk08, i); void *st1c = AllocAndReadFile(param0->unk000, st10[i]); FUN_02009668(st1c, st18, param0->unk000); @@ -279,7 +279,7 @@ THUMB_FUNC BOOL FUN_0200BD20( for (s32 i = 0; i < st14; i++) { - struct UnkStruct2 *st20 = FUN_02009660(param1->unk08, i); + struct UnkStruct_02008DEC_2 *st20 = FUN_02009660(param1->unk08, i); param1->unk24[i] = FUN_02009424(FUN_020096CC(st20), param0->unk000); param1->unk3c[i] = FUN_020093A8(param1->unk0c[i], st20, param1->unk24[i], param0->unk000); } @@ -451,7 +451,7 @@ THUMB_FUNC BOOL FUN_0200C00C(u32 *param0, return FALSE; } - struct UnkStruct1_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); + struct UnkStruct_02008DEC_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); if (r5 != NULL) { FUN_02009B04(r5); @@ -477,7 +477,7 @@ THUMB_FUNC s32 FUN_0200C06C(u32 *param0, return -1; } - struct UnkStruct1_sub * r5 = + struct UnkStruct_02008DEC_sub * r5 = FUN_02008FEC(param1->unk0c[1], param2, param3, param4, param7, param6, param5, param0[0]); if (r5 != NULL) { @@ -664,12 +664,12 @@ THUMB_FUNC struct UnkStruct_0200BB14_5 *FUN_0200C154( return ptr; } -THUMB_FUNC u32 FUN_0200C334(struct UnkStruct1 **param0, s32 param1) +THUMB_FUNC u32 FUN_0200C334(struct UnkStruct_02008DEC_1 **param0, s32 param1) { return FUN_02009E54(FUN_020094F0(param0[4], param1), 0); } -THUMB_FUNC s32 FUN_0200C344(struct UnkStruct1 **param0, s32 param1, u32 param2) +THUMB_FUNC s32 FUN_0200C344(struct UnkStruct_02008DEC_1 **param0, s32 param1, u32 param2) { return FUN_02009E88(FUN_020094F0(param0[4], param1), param2); } @@ -735,7 +735,7 @@ THUMB_FUNC BOOL FUN_0200C404(u32 *param0, return FALSE; } - struct UnkStruct1_sub *r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]); + struct UnkStruct_02008DEC_sub *r5 = FUN_020090AC(param1->unk0c[param5], param2, param3, param4, param6, param5, param0[0]); if (r5 != NULL) { BOOL r4 = FUN_0200C474(param1->unk24[param5], r5); @@ -746,7 +746,7 @@ THUMB_FUNC BOOL FUN_0200C404(u32 *param0, return r5 != NULL ? TRUE : FALSE; } -THUMB_FUNC BOOL FUN_0200C474(struct UnkStruct5 *param0, struct UnkStruct1_sub *param1) +THUMB_FUNC BOOL FUN_0200C474(struct UnkStruct_02008DEC_5 *param0, struct UnkStruct_02008DEC_sub *param1) { for (s32 i = 0; i < param0->unk04; i++) { @@ -761,7 +761,7 @@ THUMB_FUNC BOOL FUN_0200C474(struct UnkStruct5 *param0, struct UnkStruct1_sub *p return FALSE; } -THUMB_FUNC BOOL FUN_0200C4A8(struct UnkStruct1 *param0, struct UnkStruct5 *param1, u32 param2) +THUMB_FUNC BOOL FUN_0200C4A8(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_5 *param1, u32 param2) { for (s32 i = 0; i < param1->unk04; i++) { @@ -783,7 +783,7 @@ THUMB_FUNC BOOL FUN_0200C4A8(struct UnkStruct1 *param0, struct UnkStruct5 *param return FALSE; } -THUMB_FUNC BOOL FUN_0200C4F4(struct UnkStruct1 *param0, struct UnkStruct5 *param1, u32 param2) +THUMB_FUNC BOOL FUN_0200C4F4(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_5 *param1, u32 param2) { for (s32 i = 0; i < param1->unk04; i++) { @@ -806,7 +806,7 @@ THUMB_FUNC BOOL FUN_0200C4F4(struct UnkStruct1 *param0, struct UnkStruct5 *param return FALSE; } -THUMB_FUNC BOOL FUN_0200C548(struct UnkStruct1 *param0, struct UnkStruct5 *param1, u32 param2) +THUMB_FUNC BOOL FUN_0200C548(struct UnkStruct_02008DEC_1 *param0, struct UnkStruct_02008DEC_5 *param1, u32 param2) { for (s32 i = 0; i < param1->unk04; i++) { @@ -1182,7 +1182,7 @@ THUMB_FUNC BOOL FUN_0200C918(u32 *param0, return FALSE; } - struct UnkStruct1_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); + struct UnkStruct_02008DEC_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); if (r5 != NULL) { FUN_02009AC4(r5); @@ -1208,7 +1208,7 @@ THUMB_FUNC BOOL FUN_0200C978(u32 *param0, return FALSE; } - struct UnkStruct1_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); + struct UnkStruct_02008DEC_sub *r5 = FUN_02008F34(param1->unk0c[0], param2, param3, param4, param6, param5, param0[0]); if (r5 != NULL) { FUN_02009B78(r5); @@ -1222,18 +1222,18 @@ THUMB_FUNC BOOL FUN_0200C978(u32 *param0, } THUMB_FUNC void FUN_0200C9D8( - u32 *param0, struct UnkStruct1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5) + u32 *param0, struct UnkStruct_02008DEC_1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5) { - struct UnkStruct1_sub *r6 = FUN_020094F0(param1[3], param5); + struct UnkStruct_02008DEC_sub *r6 = FUN_020094F0(param1[3], param5); FUN_020090FC(param1[3], r6, param2, param3, param4, param0[0]); FUN_02009BE8(r6); } THUMB_FUNC void FUN_0200CA0C( - u32 *param0, struct UnkStruct1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5) + u32 *param0, struct UnkStruct_02008DEC_1 **param1, NarcId param2, s32 param3, BOOL param4, s32 param5) { - struct UnkStruct1_sub *r6 = FUN_020094F0(param1[4], param5); + struct UnkStruct_02008DEC_sub *r6 = FUN_020094F0(param1[4], param5); FUN_02009168(param1[4], r6, param2, param3, param4, param0[0]); FUN_02009DE0(r6); -- cgit v1.2.3 From f2c5ab8f4b9a50829f0e9e18f564fb215f749085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Thu, 12 Aug 2021 00:40:37 +0200 Subject: fix missing return --- arm9/src/unk_02008DEC.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c index 4467a03d..183a9c81 100644 --- a/arm9/src/unk_02008DEC.c +++ b/arm9/src/unk_02008DEC.c @@ -1000,10 +1000,14 @@ THUMB_FUNC u32 FUN_02009C80(struct UnkStruct_02008DEC_sub *param0, struct UnkStr GF_ASSERT(FUN_020095D4(param1) == 2); s32 r4 = FUN_02009530(param0); - if (FUN_0201D3D4(r4, ((u32 **)FUN_02009574(param1))[3][0]) == 0) + + u32 r0 = FUN_0201D3D4(r4, ((u32 **)FUN_02009574(param1))[3][0]); + if (r0 == 0) { return FUN_0201D458(FUN_0201D3B0(r4)); } + + return r0; } THUMB_FUNC void FUN_02009CDC(u32 param0) -- cgit v1.2.3 From 5d38c1e34cf8969153ee50b81a4609fb9507d16e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 13 Aug 2021 19:07:36 -0400 Subject: Use NAIX enums in script_buffers.c --- arm9/src/script_buffers.c | 95 ++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 47 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c index 1242d550..d7620db5 100644 --- a/arm9/src/script_buffers.c +++ b/arm9/src/script_buffers.c @@ -13,6 +13,7 @@ #include "script_buffers.h" #include "unk_02024E64.h" #include "text.h" +#include "msgdata/msg.naix" #pragma thumb on @@ -34,9 +35,9 @@ const u16 UNK_020ECE6C[][2] = { }; const u16 UNK_020ECE64[] = { - 382, - 384, - 383, + NARC_msg_narc_0382_bin, + NARC_msg_narc_0384_bin, + NARC_msg_narc_0383_bin, 0 }; @@ -137,7 +138,7 @@ void BufferRivalsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2 void BufferFriendsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2) { struct PlayerData * data = Sav2_PlayerData_GetProfileAddr(sav2); - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 497, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0497_bin, mgr->heap_id); if (PlayerProfile_GetTrainerGender(data) == 0) { ReadMsgDataIntoString(msgData, 1, mgr->tmpbuf); @@ -152,7 +153,7 @@ void BufferFriendsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav void BufferBoxMonSpeciesName(struct ScrStrBufs * mgr, u32 idx, struct BoxPokemon * mon) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 362, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, mgr->heap_id); ReadMsgDataIntoString(msgData, GetBoxMonData(mon, MON_DATA_SPECIES, NULL), mgr->tmpbuf); SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL); DestroyMsgData(msgData); @@ -165,7 +166,7 @@ void BufferBoxMonSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, struct void BufferSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 species) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 363, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0363_bin, mgr->heap_id); ReadMsgDataIntoString(msgData, species, mgr->tmpbuf); SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL); DestroyMsgData(msgData); @@ -191,7 +192,7 @@ void BufferIntegerAsString(struct ScrStrBufs * mgr, u32 idx, int num, u32 ndigit void BufferMoveName(struct ScrStrBufs * mgr, u32 idx, u32 move) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 588, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, move, mgr->tmpbuf); @@ -202,7 +203,7 @@ void BufferMoveName(struct ScrStrBufs * mgr, u32 idx, u32 move) void BufferRibbonNameOrDesc(struct ScrStrBufs * mgr, u32 idx, u32 ribbon) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 484, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0484_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, ribbon, mgr->tmpbuf); @@ -213,7 +214,7 @@ void BufferRibbonNameOrDesc(struct ScrStrBufs * mgr, u32 idx, u32 ribbon) void BufferAbilityName(struct ScrStrBufs * mgr, u32 idx, u32 ability) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 552, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0552_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, ability, mgr->tmpbuf); @@ -224,7 +225,7 @@ void BufferAbilityName(struct ScrStrBufs * mgr, u32 idx, u32 ability) void BufferNatureName(struct ScrStrBufs * mgr, u32 idx, u32 nature) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 190, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0190_bin, mgr->heap_id); ReadMsgDataIntoString(msgData, nature, mgr->tmpbuf); SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL); DestroyMsgData(msgData); @@ -232,7 +233,7 @@ void BufferNatureName(struct ScrStrBufs * mgr, u32 idx, u32 nature) void BufferItemName(struct ScrStrBufs * mgr, u32 idx, u32 item) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 344, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0344_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, item, mgr->tmpbuf); @@ -243,7 +244,7 @@ void BufferItemName(struct ScrStrBufs * mgr, u32 idx, u32 item) void BufferItemNameWithIndefArticle(struct ScrStrBufs * mgr, u32 idx, u32 item) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 346, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0346_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, item, mgr->tmpbuf); @@ -254,7 +255,7 @@ void BufferItemNameWithIndefArticle(struct ScrStrBufs * mgr, u32 idx, u32 item) void BufferItemNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 item) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 347, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0347_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, item, mgr->tmpbuf); @@ -265,7 +266,7 @@ void BufferItemNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 item) void BufferPocketName(struct ScrStrBufs * mgr, u32 idx, u32 pocket) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 349, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0349_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, pocket, mgr->tmpbuf); @@ -276,7 +277,7 @@ void BufferPocketName(struct ScrStrBufs * mgr, u32 idx, u32 pocket) void BufferTypeName(struct ScrStrBufs * mgr, u32 idx, u32 type) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 565, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0565_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, type, mgr->tmpbuf); @@ -287,7 +288,7 @@ void BufferTypeName(struct ScrStrBufs * mgr, u32 idx, u32 type) void BufferStatName(struct ScrStrBufs * mgr, u32 idx, u32 stat) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 495, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0495_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, stat, mgr->tmpbuf); @@ -298,7 +299,7 @@ void BufferStatName(struct ScrStrBufs * mgr, u32 idx, u32 stat) void BufferStatusName(struct ScrStrBufs * mgr, u32 idx, u32 status) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 205, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0205_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, status, mgr->tmpbuf); @@ -309,7 +310,7 @@ void BufferStatusName(struct ScrStrBufs * mgr, u32 idx, u32 status) void BufferFlavorDislikeText(struct ScrStrBufs * mgr, u32 idx, u32 flavor) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 548, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0548_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, flavor, mgr->tmpbuf); @@ -320,7 +321,7 @@ void BufferFlavorDislikeText(struct ScrStrBufs * mgr, u32 idx, u32 flavor) void BufferLandmarkName(struct ScrStrBufs * mgr, u32 idx, u32 landmark) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 382, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, landmark, mgr->tmpbuf); @@ -331,7 +332,7 @@ void BufferLandmarkName(struct ScrStrBufs * mgr, u32 idx, u32 landmark) void BufferPoketchAppName(struct ScrStrBufs * mgr, u32 idx, u32 app) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 406, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0406_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, app, mgr->tmpbuf); @@ -342,7 +343,7 @@ void BufferPoketchAppName(struct ScrStrBufs * mgr, u32 idx, u32 app) void BufferTrainerClassName(struct ScrStrBufs * mgr, u32 idx, u32 trclass) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 560, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf); @@ -353,7 +354,7 @@ void BufferTrainerClassName(struct ScrStrBufs * mgr, u32 idx, u32 trclass) void BufferTrainerClassNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trclass) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 561, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0561_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf); @@ -364,7 +365,7 @@ void BufferTrainerClassNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trc void BufferTrainerClassNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct TrainerDataLoaded * tr) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 560, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, tr->data.trainerClass, mgr->tmpbuf); @@ -375,7 +376,7 @@ void BufferTrainerClassNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, stru void BufferTrainerName(struct ScrStrBufs * mgr, u32 idx, u32 msgno) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 559, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0559_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, msgno, mgr->tmpbuf); @@ -392,7 +393,7 @@ void BufferTrainerNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct Tr void BufferUndergroundItemName(struct ScrStrBufs * mgr, u32 idx, u32 item) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 569, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0569_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, item, mgr->tmpbuf); @@ -403,7 +404,7 @@ void BufferUndergroundItemName(struct ScrStrBufs * mgr, u32 idx, u32 item) void BufferUndergroundItemNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 item) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 570, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0570_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, item, mgr->tmpbuf); @@ -414,7 +415,7 @@ void BufferUndergroundItemNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 void BufferUndergroundTrapName(struct ScrStrBufs * mgr, u32 idx, u32 trap) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 571, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0571_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf); @@ -425,7 +426,7 @@ void BufferUndergroundTrapName(struct ScrStrBufs * mgr, u32 idx, u32 trap) void BufferUndergroundTrapNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trap) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 572, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0572_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf); @@ -436,7 +437,7 @@ void BufferUndergroundTrapNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 void BufferContestJudgeName(struct ScrStrBufs * mgr, u32 idx, u32 judge) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 194, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0194_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, judge, mgr->tmpbuf); @@ -447,7 +448,7 @@ void BufferContestJudgeName(struct ScrStrBufs * mgr, u32 idx, u32 judge) void BufferContestMessage(struct ScrStrBufs * mgr, u32 idx, u32 msg) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 191, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf); @@ -458,7 +459,7 @@ void BufferContestMessage(struct ScrStrBufs * mgr, u32 idx, u32 msg) void BufferContestMessage2(struct ScrStrBufs * mgr, u32 idx, u32 msg) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 191, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf); @@ -469,7 +470,7 @@ void BufferContestMessage2(struct ScrStrBufs * mgr, u32 idx, u32 msg) void BufferInterviewQuestion(struct ScrStrBufs * mgr, u32 idx, u32 question) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 574, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0574_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, question, mgr->tmpbuf); @@ -480,7 +481,7 @@ void BufferInterviewQuestion(struct ScrStrBufs * mgr, u32 idx, u32 question) void BufferInterviewAnswer(struct ScrStrBufs * mgr, u32 idx, u32 answer) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 573, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0573_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, answer, mgr->tmpbuf); @@ -491,7 +492,7 @@ void BufferInterviewAnswer(struct ScrStrBufs * mgr, u32 idx, u32 answer) void BufferDecorationName(struct ScrStrBufs * mgr, u32 idx, u32 decor) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 567, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0567_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf); @@ -502,7 +503,7 @@ void BufferDecorationName(struct ScrStrBufs * mgr, u32 idx, u32 decor) void BufferDecorationNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 decor) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 568, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0568_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf); @@ -513,7 +514,7 @@ void BufferDecorationNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 decor void BufferGenderSymbol(struct ScrStrBufs * mgr, u32 idx, u32 gender) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 199, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, mgr->heap_id); switch (gender) { case 0: @@ -538,7 +539,7 @@ void BufferBoxName(struct ScrStrBufs * mgr, u32 idx, struct PCStorage * pc, int void BufferGymName(struct ScrStrBufs * mgr, u32 idx, u32 gym) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 331, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0331_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, gym, mgr->tmpbuf); @@ -549,7 +550,7 @@ void BufferGymName(struct ScrStrBufs * mgr, u32 idx, u32 gym) void BufferTimeOfDayName(struct ScrStrBufs * mgr, u32 idx, u32 time) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 550, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0550_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, time, mgr->tmpbuf); @@ -560,7 +561,7 @@ void BufferTimeOfDayName(struct ScrStrBufs * mgr, u32 idx, u32 time) void BufferCountryName(struct ScrStrBufs * mgr, u32 idx, u32 country) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 612, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0612_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, country, mgr->tmpbuf); @@ -592,7 +593,7 @@ void FUN_0200B518(struct ScrStrBufs * mgr, u32 idx, u32 a2) void BufferSealName(struct ScrStrBufs * mgr, u32 idx, u32 seal) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 10, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0010_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf); @@ -603,7 +604,7 @@ void BufferSealName(struct ScrStrBufs * mgr, u32 idx, u32 seal) void BufferSealNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 seal) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 11, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0011_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf); @@ -629,7 +630,7 @@ void BufferLocationName(struct ScrStrBufs * mgr, u32 idx, u16 a2) // Location is invalid. // Fallback: Mystery Zone DestroyMsgData(msgData); - msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 382, mgr->heap_id); + msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, 0, mgr->tmpbuf); @@ -641,7 +642,7 @@ void BufferLocationName(struct ScrStrBufs * mgr, u32 idx, u16 a2) void BufferPoffinName(struct ScrStrBufs * mgr, u32 idx, u32 poffin) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 414, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0414_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, poffin, mgr->tmpbuf); @@ -652,7 +653,7 @@ void BufferPoffinName(struct ScrStrBufs * mgr, u32 idx, u32 poffin) void BufferFashionName(struct ScrStrBufs * mgr, u32 idx, u32 fashion) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 338, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0338_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf); @@ -663,7 +664,7 @@ void BufferFashionName(struct ScrStrBufs * mgr, u32 idx, u32 fashion) void BufferFashionNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 fashion) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 339, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0339_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf); @@ -674,7 +675,7 @@ void BufferFashionNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 fashion) void BufferContestBackgroundName(struct ScrStrBufs * mgr, u32 idx, u32 bg) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 340, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0340_bin, mgr->heap_id); if (msgData != NULL) { ReadMsgDataIntoString(msgData, bg, mgr->tmpbuf); @@ -696,7 +697,7 @@ void BufferEasyChatWord(struct ScrStrBufs * mgr, struct SaveBlock2 * sav2, u32 r void BufferMonthNameAbbr(struct ScrStrBufs * mgr, u32 idx, u32 month) { - struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 364, mgr->heap_id); + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0364_bin, mgr->heap_id); if (msgData != NULL) { if (month < 1 || month > 12) -- cgit v1.2.3 From 57351f30edb58f09bba1cab85280e014a5d2e834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sat, 14 Aug 2021 13:16:36 +0200 Subject: fix fakematch --- arm9/src/unk_02008DEC.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c index 183a9c81..3050110b 100644 --- a/arm9/src/unk_02008DEC.c +++ b/arm9/src/unk_02008DEC.c @@ -559,22 +559,18 @@ THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct_02008DEC_2 *param1, u param1->unk04 = FUN_020099E8((struct UnkStruct_02008DEC_4 *)(param0 + 1)); - void *ptr; if (param1->unk04 > 0) { - ptr = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); + param1->unk00 = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); } else { - ptr = NULL; + param1->unk00 = NULL; } - param1->unk00 = ptr; - // use volatile to force a reload here - void *r0 = *((void *volatile *)param1); - if (r0 != NULL) + if (param1->unk00 != NULL) { - memcpy(r0, param0 + 1, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); + memcpy(param1->unk00, param0 + 1, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); } } -- cgit v1.2.3 From ee3f5159550b154ea8b5c01b518756638eb5c4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sat, 14 Aug 2021 13:34:58 +0200 Subject: replace ugly casts with clean union --- arm9/src/unk_02008DEC.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02008DEC.c b/arm9/src/unk_02008DEC.c index 3050110b..2238b920 100644 --- a/arm9/src/unk_02008DEC.c +++ b/arm9/src/unk_02008DEC.c @@ -74,7 +74,7 @@ THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008E6C( if (param1->unk0C == 0) { - struct UnkStruct_02008DEC_3 *r6 = &((struct UnkStruct_02008DEC_3 *)param1->unk00)[param2]; + struct UnkStruct_02008DEC_3 *r6 = ¶m1->unk00_3[param2]; GF_ASSERT(FUN_0200945C(param0, r6->unk00) == 1); FUN_0200994C( @@ -82,7 +82,7 @@ THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_02008E6C( } else { - struct UnkStruct_02008DEC_4 *r6 = &((struct UnkStruct_02008DEC_4 *)param1->unk00)[param2]; + struct UnkStruct_02008DEC_4 *r6 = ¶m1->unk00_4[param2]; GF_ASSERT(FUN_0200945C(param0, r6->unk0C) == 1); FUN_02009978(param0, @@ -561,26 +561,26 @@ THUMB_FUNC void FUN_02009668(u32 *param0, struct UnkStruct_02008DEC_2 *param1, u if (param1->unk04 > 0) { - param1->unk00 = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); + param1->unk00_4 = AllocFromHeap(param2, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); } else { - param1->unk00 = NULL; + param1->unk00_4 = NULL; } - if (param1->unk00 != NULL) + if (param1->unk00_4 != NULL) { - memcpy(param1->unk00, param0 + 1, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); + memcpy(param1->unk00_4, param0 + 1, param1->unk04 * sizeof(struct UnkStruct_02008DEC_4)); } } THUMB_FUNC void FUN_020096B4(struct UnkStruct_02008DEC_2 *param0) { - if (param0->unk00) + if (param0->unk00_4) { - FreeToHeap(param0->unk00); + FreeToHeap(param0->unk00_4); } - param0->unk00 = NULL; + param0->unk00_4 = NULL; param0->unk04 = 0; } @@ -598,10 +598,10 @@ THUMB_FUNC s32 FUN_020096DC(struct UnkStruct_02008DEC_2 *param0, s32 param1) if (param0->unk0C == 0) { - return ((struct UnkStruct_02008DEC_3 *)param0->unk00)[param1].unk00; + return param0->unk00_3[param1].unk00; } - return ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk0C; + return param0->unk00_4[param1].unk0C; } THUMB_FUNC s32 FUN_02009710(struct UnkStruct_02008DEC_2 *param0, s32 param1) @@ -612,7 +612,7 @@ THUMB_FUNC s32 FUN_02009710(struct UnkStruct_02008DEC_2 *param0, s32 param1) s32 r6; if (param0->unk0C == 1) { - r6 = ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk04; + r6 = param0->unk00_4[param1].unk04; } // oops, UB here @@ -627,7 +627,7 @@ THUMB_FUNC BOOL FUN_0200973C(struct UnkStruct_02008DEC_2 *param0, s32 param1) BOOL r6; if (param0->unk0C == 1) { - r6 = ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk08; + r6 = param0->unk00_4[param1].unk08; } // oops, UB here @@ -641,10 +641,10 @@ THUMB_FUNC u32 FUN_02009768(struct UnkStruct_02008DEC_2 *param0, s32 param1) if (param0->unk0C == 0) { - return ((struct UnkStruct_02008DEC_3 *)param0->unk00)[param1].unk44; + return param0->unk00_3[param1].unk44; } - return ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk10; + return param0->unk00_4[param1].unk10; } THUMB_FUNC u32 FUN_0200979C(struct UnkStruct_02008DEC_2 *param0, s32 param1) @@ -654,10 +654,10 @@ THUMB_FUNC u32 FUN_0200979C(struct UnkStruct_02008DEC_2 *param0, s32 param1) if (param0->unk0C == 0) { - return ((struct UnkStruct_02008DEC_3 *)param0->unk00)[param1].unk48; + return param0->unk00_3[param1].unk48; } - return ((struct UnkStruct_02008DEC_4 *)param0->unk00)[param1].unk14; + return param0->unk00_4[param1].unk14; } THUMB_FUNC struct UnkStruct_02008DEC_sub *FUN_020097D0(struct UnkStruct_02008DEC_1 *param0) -- cgit v1.2.3 From 2a568ac2b0bd8b1a8ca6441e8e3af914bffe38ba Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Aug 2021 16:17:18 -0400 Subject: Decompile unk_02021590 --- arm9/src/communication_error.c | 1 - arm9/src/font.c | 38 +++---- arm9/src/render_text.c | 2 +- arm9/src/script_buffers.c | 27 ++--- arm9/src/text.c | 39 +++---- arm9/src/unk_02021590.c | 225 +++++++++++++++++++++++++++++++++++++++++ arm9/src/unk_02021934.c | 9 +- 7 files changed, 284 insertions(+), 57 deletions(-) create mode 100644 arm9/src/unk_02021590.c (limited to 'arm9/src') diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 0ea26458..73345af1 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -7,7 +7,6 @@ #include "msgdata/msg.naix" #include "text.h" -extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); extern void FUN_0200A274(fx32 brightness, fx32, u32); extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); diff --git a/arm9/src/font.c b/arm9/src/font.c index 6c838892..5e46b237 100644 --- a/arm9/src/font.c +++ b/arm9/src/font.c @@ -4,6 +4,7 @@ #include "graphic/font.naix" #include "render_text.h" #include "string16.h" +#include "unk_02021590.h" #include "text.h" #include "unk_0201B8B8.h" @@ -11,7 +12,12 @@ struct UnkStruct_02002C14 *UNK_02106FC8; struct UnkStruct_02002C14 UNK_02106FCC; -const u16 UNK_020ECB54[4][2] = { { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 } }; +const u16 UNK_020ECB54[4][2] = { + { NARC_font_narc_0000_bin, FALSE }, + { NARC_font_narc_0001_bin, FALSE }, + { NARC_font_narc_0002_bin, FALSE }, + { NARC_font_narc_0003_bin, FALSE } +}; const struct FontInfo gFontInfos[5] = { { 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 }, @@ -21,12 +27,6 @@ const struct FontInfo gFontInfos[5] = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, }; -extern struct UnkStruct_0202199C *FUN_02021590(u32, u16, u32, u16, u32); -extern void FUN_020215E0(struct UnkStruct_0202199C *, u32, u32); -extern void FUN_020215C8(struct UnkStruct_0202199C *param0); -extern void FUN_02021750(struct UnkStruct_0202199C *, u32); -extern u32 FUN_020218D8(struct UnkStruct_0202199C *, u16 *str, u32); - THUMB_FUNC void FUN_02002C14() { UNK_02106FC8 = &UNK_02106FCC; @@ -40,10 +40,10 @@ THUMB_FUNC void FUN_02002C14() SetFontsPointer(&gFontInfos[0]); } -THUMB_FUNC void FUN_02002C50(u32 param0, u32 param1) +THUMB_FUNC void FUN_02002C50(u32 font_id, u32 heap_id) { - UNK_02106FC8->unk94[param0] = - FUN_02021590(14, UNK_020ECB54[param0][0], 1, UNK_020ECB54[param0][1], param1); + UNK_02106FC8->unk94[font_id] = + FontData_new(NARC_GRAPHIC_FONT, UNK_020ECB54[font_id][0], 1, UNK_020ECB54[font_id][1], heap_id); } THUMB_FUNC void FUN_02002C84(s32 param0, u32 param1) @@ -51,7 +51,7 @@ THUMB_FUNC void FUN_02002C84(s32 param0, u32 param1) GF_ASSERT(param0 < 4); GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL); - FUN_020215E0(UNK_02106FC8->unk94[param0], 0, param1); + FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 0, param1); } THUMB_FUNC void FUN_02002CC0(s32 param0) @@ -59,7 +59,7 @@ THUMB_FUNC void FUN_02002CC0(s32 param0) GF_ASSERT(param0 < 4); GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL); - FUN_020215E0(UNK_02106FC8->unk94[param0], 1, 0); + FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 1, 0); } THUMB_FUNC void FUN_02002CF8(int param0) @@ -89,16 +89,16 @@ THUMB_FUNC void FUN_02002CF8(int param0) if (UNK_02106FC8->unk94[param0] != NULL) { - FUN_020215C8(UNK_02106FC8->unk94[param0]); + FontData_delete(UNK_02106FC8->unk94[param0]); UNK_02106FC8->unk94[param0] = NULL; } } -THUMB_FUNC struct UnkStruct_02002C14 *FUN_02002D94(u32 param0, u32 param1) +THUMB_FUNC struct UnkStruct_02002C14_sub *FUN_02002D94(u32 param0, u32 param1) { - FUN_02021750(UNK_02106FC8->unk94[param0], param1); + TryLoadGlyph(UNK_02106FC8->unk94[param0], param1, &UNK_02106FC8->unk00); - return UNK_02106FC8; + return &UNK_02106FC8->unk00; } THUMB_FUNC u32 FontFunc(u32 fontId, struct TextPrinter *printer) @@ -119,14 +119,14 @@ THUMB_FUNC u32 FUN_02002DE0(u32 param0, u16 *str, u32 param2) { GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL); - FUN_020218D8(UNK_02106FC8->unk94[param0], str, param2); + return GetStringWidth(UNK_02106FC8->unk94[param0], str, param2); } THUMB_FUNC u32 FUN_02002E14(u32 param0, struct String *str, u32 param2) { GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL); - FUN_020218D8(UNK_02106FC8->unk94[param0], String_c_str(str), param2); + return GetStringWidth(UNK_02106FC8->unk94[param0], String_c_str(str), param2); } THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr) @@ -163,7 +163,7 @@ THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr) return ret; } -THUMB_FUNC void FUN_02002ED0(u32 layer, u32 baseAddr, u32 heap_id) +THUMB_FUNC void FUN_02002ED0(enum GFBgLayer layer, u32 baseAddr, u32 heap_id) { GfGfxLoader_GXLoadPal( NARC_GRAPHIC_FONT, NARC_font_narc_0006_NCLR, layer, baseAddr, 0x20, heap_id); diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c index 34777739..aa29e82d 100644 --- a/arm9/src/render_text.c +++ b/arm9/src/render_text.c @@ -207,7 +207,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) return 3; } - struct UnkStruct_02002C14 *r5 = FUN_02002D94(subStruct->glyphId, currentChar); + struct UnkStruct_02002C14_sub *r5 = FUN_02002D94(subStruct->glyphId, currentChar); CopyGlyphToWindow(printer->printerTemplate.window, r5->buf, r5->width, diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c index d7620db5..550dcab5 100644 --- a/arm9/src/script_buffers.c +++ b/arm9/src/script_buffers.c @@ -14,6 +14,7 @@ #include "unk_02024E64.h" #include "text.h" #include "msgdata/msg.naix" +#include "graphic/font.naix" #pragma thumb on @@ -747,12 +748,12 @@ void ScrStrBufs_ResetBuffers(struct ScrStrBufs * mgr) StringSetEmpty(mgr->array[i].msg); } -struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4) +struct UnkStruct_0200B870 * MessagePrinter_new(u32 color1, u32 color2, u32 color3, u32 heap_id) { - struct UnkStruct_0200B870 * sp8 = AllocFromHeap(r4, sizeof(struct UnkStruct_0200B870)); + struct UnkStruct_0200B870 * sp8 = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200B870)); if (sp8 != NULL) { - sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 4, 1, &sp8->unk_4, r4); + sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0004_NCGR_lz, 1, &sp8->unk_4, heap_id); int i; u8 * ptr = sp8->unk_4->unk_14; for (i = 0; i < sp8->unk_4->unk_10; i++) @@ -760,35 +761,35 @@ struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4) switch (ptr[i]) { case 0x00: - ptr[i] = (u8)((sp4 << 4) | sp4); + ptr[i] = (u8)((color3 << 4) | color3); break; case 0x01: - ptr[i] = (u8)((sp4 << 4) | r5); + ptr[i] = (u8)((color3 << 4) | color1); break; case 0x02: - ptr[i] = (u8)((sp4 << 4) | r6); + ptr[i] = (u8)((color3 << 4) | color2); break; case 0x10: - ptr[i] = (u8)((r5 << 4) | sp4); + ptr[i] = (u8)((color1 << 4) | color3); break; case 0x11: - ptr[i] = (u8)((r5 << 4) | r5); + ptr[i] = (u8)((color1 << 4) | color1); break; case 0x12: - ptr[i] = (u8)((r5 << 4) | r6); + ptr[i] = (u8)((color1 << 4) | color2); break; case 0x20: - ptr[i] = (u8)((r6 << 4) | sp4); + ptr[i] = (u8)((color2 << 4) | color3); break; case 0x21: - ptr[i] = (u8)((r6 << 4) | r5); + ptr[i] = (u8)((color2 << 4) | color1); break; case 0x22: - ptr[i] = (u8)((r6 << 4) | r6); + ptr[i] = (u8)((color2 << 4) | color2); break; } } - sp8->unk_28 = sp4; + sp8->unk_28 = color3; } return sp8; } diff --git a/arm9/src/text.c b/arm9/src/text.c index e8c76722..64b3587e 100644 --- a/arm9/src/text.c +++ b/arm9/src/text.c @@ -6,10 +6,11 @@ #include "script_buffers.h" #include "unk_0200CA44.h" #include "font.h" +#include "graphic/font.naix" const struct FontInfo *gFonts = NULL; -u16 UNK_021C5734[0x100]; +u16 sFontHalfRowLookupTable[0x100]; BOOL UNK_021C5714[8]; u16 UNK_021C570E; u16 UNK_021C5710; @@ -294,7 +295,7 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow { for (l = 0; l < 4; l++) { - UNK_021C5734[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0)); + sFontHalfRowLookupTable[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0)); } } } @@ -303,22 +304,22 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow THUMB_FUNC void DecompressGlyphTile(const u16 *src, u16 *dst) { - dst[0] = UNK_021C5734[(u32)src[0] >> 8]; - dst[1] = UNK_021C5734[(u8)src[0]]; - dst[2] = UNK_021C5734[(u32)src[1] >> 8]; - dst[3] = UNK_021C5734[(u8)src[1]]; - dst[4] = UNK_021C5734[(u32)src[2] >> 8]; - dst[5] = UNK_021C5734[(u8)src[2]]; - dst[6] = UNK_021C5734[(u32)src[3] >> 8]; - dst[7] = UNK_021C5734[(u8)src[3]]; - dst[8] = UNK_021C5734[(u32)src[4] >> 8]; - dst[9] = UNK_021C5734[(u8)src[4]]; - dst[10] = UNK_021C5734[(u32)src[5] >> 8]; - dst[11] = UNK_021C5734[(u8)src[5]]; - dst[12] = UNK_021C5734[(u32)src[6] >> 8]; - dst[13] = UNK_021C5734[(u8)src[6]]; - dst[14] = UNK_021C5734[(u32)src[7] >> 8]; - dst[15] = UNK_021C5734[(u8)src[7]]; + dst[0] = sFontHalfRowLookupTable[(u32)src[0] >> 8]; + dst[1] = sFontHalfRowLookupTable[(u8)src[0]]; + dst[2] = sFontHalfRowLookupTable[(u32)src[1] >> 8]; + dst[3] = sFontHalfRowLookupTable[(u8)src[1]]; + dst[4] = sFontHalfRowLookupTable[(u32)src[2] >> 8]; + dst[5] = sFontHalfRowLookupTable[(u8)src[2]]; + dst[6] = sFontHalfRowLookupTable[(u32)src[3] >> 8]; + dst[7] = sFontHalfRowLookupTable[(u8)src[3]]; + dst[8] = sFontHalfRowLookupTable[(u32)src[4] >> 8]; + dst[9] = sFontHalfRowLookupTable[(u8)src[4]]; + dst[10] = sFontHalfRowLookupTable[(u32)src[5] >> 8]; + dst[11] = sFontHalfRowLookupTable[(u8)src[5]]; + dst[12] = sFontHalfRowLookupTable[(u32)src[6] >> 8]; + dst[13] = sFontHalfRowLookupTable[(u8)src[6]]; + dst[14] = sFontHalfRowLookupTable[(u32)src[7] >> 8]; + dst[15] = sFontHalfRowLookupTable[(u8)src[7]]; } THUMB_FUNC void FUN_0201C1A8(struct TextPrinter *printer) @@ -330,7 +331,7 @@ THUMB_FUNC u16 *FUN_0201C1B0(void) { void *res = AllocFromHeap(0, 32 * 24 * sizeof(u16)); struct UnkStruct_0200B870_sub * var; - void *tmp = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 5, 0, &var, 0); + void *tmp = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0005_NCGR, 0, &var, 0); MI_CpuCopy32(var->unk_14, res, 32 * 24 * sizeof(u16)); FreeToHeap(tmp); return res; diff --git a/arm9/src/unk_02021590.c b/arm9/src/unk_02021590.c new file mode 100644 index 00000000..3ab1a38e --- /dev/null +++ b/arm9/src/unk_02021590.c @@ -0,0 +1,225 @@ +#include "global.h" +#include "heap.h" +#include "filesystem.h" +#include "unk_02021590.h" +#include "unk_0201B8B8.h" +#include "string_util.h" + +void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id); +void InitFontResources(struct FontData *ptr, u32 a1, u32 heap_id); +void FontData_FreeWidthsAndNarc(struct FontData * ptr); +void InitFontResources_FromPreloaded(struct FontData * ptr, u32 heap_id); +void InitFontResources_LazyFromNarc(struct FontData * ptr, u32 heap_id); +void FreeLoadedFontResources(struct FontData * ptr); +void FreeLoadedFontResources_FromPreloaded(struct FontData * ptr); +void FreeLoadedFontResources_LazyFromNarc(struct FontData * ptr); +void DecompressGlyphTiles_FromPreloaded(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2); +void DecompressGlyphTiles_LazyFromNarc(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2); +int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1); +int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1); + +static const u8 sGlyphShapes[][2] = { + { 0, 1 }, + { 2, 3 }, +}; + +static void (*const sAllocators[])(struct FontData *, u32) = { + InitFontResources_FromPreloaded, + InitFontResources_LazyFromNarc, +}; + +static void (*const sDestructors[])(struct FontData *) = { + FreeLoadedFontResources_FromPreloaded, + FreeLoadedFontResources_LazyFromNarc, +}; + +THUMB_FUNC struct FontData *FontData_new(NarcId narcId, s32 fileId, u32 unk2, BOOL unk3, u32 heap_id) +{ + struct FontData * ret = (struct FontData *)AllocFromHeap(heap_id, sizeof(struct FontData)); + if (ret != NULL) + { + FontData_Init(ret, narcId, fileId, unk3, heap_id); + InitFontResources(ret, unk2, heap_id); + } + return ret; +} + +THUMB_FUNC void FontData_delete(struct FontData * ptr) +{ + FreeLoadedFontResources(ptr); + FontData_FreeWidthsAndNarc(ptr); + FreeToHeap(ptr); +} + +THUMB_FUNC void FontData_ModeSwitch(struct FontData * ptr, u32 a1, u32 heap_id) +{ + if (ptr->glyphAccessMode != a1) + { + FreeLoadedFontResources(ptr); + InitFontResources(ptr, a1, heap_id); + } +} + +THUMB_FUNC void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id) +{ + ptr->narc = NARC_ctor(narcId, heap_id); + if (ptr->narc != NULL) + { + NARC_ReadFromMember(ptr->narc, (u32)fileId, 0, 16, &ptr->gfxHeader); + ptr->isFixedWidthFont = unk; + if (unk) + { + ptr->glyphWidths = NULL; + ptr->glyphWidthFunc = GetGlyphWidth_FixedWidth; + } + else + { + GF_ASSERT(ptr->gfxHeader.widthDataStart != 0); + ptr->glyphWidths = AllocFromHeap(heap_id, ptr->gfxHeader.numGlyphs); + ptr->glyphWidthFunc = GetGlyphWidth_VariableWidth; + NARC_ReadFromMember(ptr->narc, (u32)fileId, ptr->gfxHeader.widthDataStart, ptr->gfxHeader.numGlyphs, ptr->glyphWidths); + } + GF_ASSERT(ptr->gfxHeader.glyphWidth <= 2 && ptr->gfxHeader.glyphHeight <= 2); + ptr->glyphShape = sGlyphShapes[ptr->gfxHeader.glyphWidth - 1][ptr->gfxHeader.glyphHeight - 1]; + ptr->glyphSize = (u32)(16 * ptr->gfxHeader.glyphWidth * ptr->gfxHeader.glyphHeight); + ptr->fileId = (u32)fileId; + } +} + +THUMB_FUNC void FontData_FreeWidthsAndNarc(struct FontData * ptr) +{ + if (ptr->glyphWidths != NULL) + FreeToHeap(ptr->glyphWidths); + if (ptr->narc != NULL) + NARC_dtor(ptr->narc); +} + +THUMB_FUNC void InitFontResources(struct FontData * ptr, u32 a1, u32 heap_id) +{ + ptr->glyphAccessMode = a1; + sAllocators[a1](ptr, heap_id); +} + +THUMB_FUNC void InitFontResources_FromPreloaded(struct FontData * ptr, u32 heap_id) +{ + u32 r4 = ptr->glyphSize * ptr->gfxHeader.numGlyphs; + ptr->narcReadBuf = AllocFromHeap(heap_id, r4); + ptr->uncompGlyphFunc = DecompressGlyphTiles_FromPreloaded; + NARC_ReadFromMember(ptr->narc, ptr->fileId, ptr->gfxHeader.headerSize, r4, ptr->narcReadBuf); +} + +THUMB_FUNC void InitFontResources_LazyFromNarc(struct FontData * ptr, u32 heap_id) +{ +#pragma unused(heap_id) + ptr->uncompGlyphFunc = DecompressGlyphTiles_LazyFromNarc; +} + +THUMB_FUNC void FreeLoadedFontResources(struct FontData * ptr) +{ + sDestructors[ptr->glyphAccessMode](ptr); +} + +THUMB_FUNC void FreeLoadedFontResources_FromPreloaded(struct FontData * ptr) +{ + FreeToHeap(ptr->narcReadBuf); + ptr->narcReadBuf = NULL; +} + +THUMB_FUNC void FreeLoadedFontResources_LazyFromNarc(struct FontData * ptr) +{ +#pragma unused(ptr) +} + +THUMB_FUNC void TryLoadGlyph(struct FontData * ptr, u32 param1, struct UnkStruct_02002C14_sub * ptr2) +{ + if (param1 <= ptr->gfxHeader.numGlyphs) + ptr->uncompGlyphFunc(ptr, (u16)(param1 - 1), ptr2); + else + { + ptr2->width = 0; + ptr2->height = 0; + } +} + +THUMB_FUNC void DecompressGlyphTiles_FromPreloaded(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2) +{ + u8 *r4 = &((u8 *)ptr->narcReadBuf)[param1 * ptr->glyphSize]; + switch (ptr->glyphShape) + { + case 0: + DecompressGlyphTile((void *)(r4), (void *)param2->buf); + break; + case 1: + DecompressGlyphTile((void *)(r4), (void *)param2->buf); + DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x40)); + break; + case 2: + DecompressGlyphTile((void *)(r4), (void *)param2->buf); + DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x20)); + break; + case 3: + DecompressGlyphTile((void *)(r4), (void *)param2->buf); + DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x20)); + DecompressGlyphTile((void *)(r4 + 0x20), (void *)(param2->buf + 0x40)); + DecompressGlyphTile((void *)(r4 + 0x30), (void *)(param2->buf + 0x60)); + break; + } + param2->width = (u8)ptr->glyphWidthFunc(ptr, param1); + param2->height = ptr->gfxHeader.fixedHeight; +} + +THUMB_FUNC void DecompressGlyphTiles_LazyFromNarc(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2) +{ + NARC_ReadFromMember(ptr->narc, ptr->fileId, ptr->gfxHeader.headerSize + param1 * ptr->glyphSize, ptr->glyphSize, ptr->glyphReadBuf); + switch (ptr->glyphShape) + { + case 0: + DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf); + break; + case 1: + DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf); + DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x40)); + break; + case 2: + DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf); + DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x20)); + break; + case 3: + DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf); + DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x20)); + DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x20), (void *)(param2->buf + 0x40)); + DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x30), (void *)(param2->buf + 0x60)); + break; + } + param2->width = (u8)ptr->glyphWidthFunc(ptr, param1); + param2->height = ptr->gfxHeader.fixedHeight; +} + +THUMB_FUNC u32 GetStringWidth(struct FontData * ptr, const u16 * str, u32 letterSpacing) +{ + u32 width = 0; + + while (*str != EOS) + { + if (*str == 0xFFFE) + { + str = MsgArray_SkipControlCode(str); + if (*str == EOS) + break; + } + width += ptr->glyphWidthFunc(ptr, (*str) - 1) + letterSpacing; + str++; + } + return width - letterSpacing; +} + +THUMB_FUNC int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1) +{ + return ptr->glyphWidths[a1]; +} + +THUMB_FUNC int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1) +{ +#pragma unused(a1) + return ptr->gfxHeader.fixedWidth; +} diff --git a/arm9/src/unk_02021934.c b/arm9/src/unk_02021934.c index b12e2d8f..07ddde87 100644 --- a/arm9/src/unk_02021934.c +++ b/arm9/src/unk_02021934.c @@ -3,6 +3,7 @@ #include "heap.h" #include "string_util.h" #include "unk_0201B8B8.h" +#include "unk_02021590.h" #pragma thumb on @@ -10,7 +11,7 @@ void StrAddChar(struct String * str, u16 val); -s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6) +s32 StringGetWidth(struct FontData * r7, const u16 * arr, u32 r6) { s32 ret = 0; u32 r4 = 0; @@ -29,7 +30,7 @@ s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6) } else { - r4 += (r6 + r7->unk_70(r7, *arr - 1)); + r4 += (r6 + r7->glyphWidthFunc(r7, *arr - 1)); arr++; } } @@ -38,7 +39,7 @@ s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6) return ret; } -s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C * r6, const u16 * arr) +s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct FontData * r6, const u16 * arr) { s32 ret = 0; while (*arr != 0xFFFF) @@ -53,7 +54,7 @@ s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C } else { - ret += r6->unk_70(r6, *arr - 1); + ret += r6->glyphWidthFunc(r6, *arr - 1); arr++; } } -- cgit v1.2.3 From dc1072ecfc7fb55d7cb256ad1d9e9c6b39bc0b8d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Aug 2021 18:01:25 -0400 Subject: Remove duplicate function declarations --- arm9/src/unk_02021590.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02021590.c b/arm9/src/unk_02021590.c index 3ab1a38e..e6a3d690 100644 --- a/arm9/src/unk_02021590.c +++ b/arm9/src/unk_02021590.c @@ -5,19 +5,6 @@ #include "unk_0201B8B8.h" #include "string_util.h" -void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id); -void InitFontResources(struct FontData *ptr, u32 a1, u32 heap_id); -void FontData_FreeWidthsAndNarc(struct FontData * ptr); -void InitFontResources_FromPreloaded(struct FontData * ptr, u32 heap_id); -void InitFontResources_LazyFromNarc(struct FontData * ptr, u32 heap_id); -void FreeLoadedFontResources(struct FontData * ptr); -void FreeLoadedFontResources_FromPreloaded(struct FontData * ptr); -void FreeLoadedFontResources_LazyFromNarc(struct FontData * ptr); -void DecompressGlyphTiles_FromPreloaded(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2); -void DecompressGlyphTiles_LazyFromNarc(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2); -int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1); -int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1); - static const u8 sGlyphShapes[][2] = { { 0, 1 }, { 2, 3 }, -- cgit v1.2.3 From 496ab2d25dd76329ef5bb95090291e237a56f474 Mon Sep 17 00:00:00 2001 From: red031000 Date: Mon, 16 Aug 2021 14:51:17 +0100 Subject: literally one single random scrcmd func in a mod04 PR --- arm9/src/scrcmd.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index c79684a0..ceb1a1cf 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -1,4 +1,5 @@ #include "scrcmd.h" +#include "unk_0200CA44.h" #include "unk_0204639C.h" #include "main.h" #include "options.h" @@ -54,11 +55,11 @@ extern void MOD05_021E26CC(u32 param0, u8 param1); extern void MOD05_021E2B80(u32 param0, u8 param1); extern void MOD05_021E2B9C(u32 param0, u8 param1); extern u32 FUN_0205AEA4(u32 param0, const void *ptr); -extern void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, void *param2); extern u32 FUN_02058B2C(u32 param0); extern u32 FUN_02058B4C(u32 param0); extern u32 FUN_020580B4(u32 param0, u32 param1); extern u32 FUN_02058060(u32 param0, u32 param1); +extern void FUN_0203B1A8(u32 param0, void *param1); extern u8 *UNK_020F34E0; @@ -79,6 +80,7 @@ static BOOL FUN_0203AD2C(struct ScriptContext *ctx); static BOOL FUN_0203AD78(struct ScriptContext *ctx); static u32 FUN_0203B120(struct UnkSavStruct80 *arg, u16 param1); static BOOL FUN_0203B158(struct ScriptContext *ctx); +static void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, void *param2); extern u8 sScriptConditionTable[6][3]; @@ -1355,13 +1357,13 @@ THUMB_FUNC BOOL ScrCmd_Unk02A1(struct ScriptContext *ctx) if (unk6 < unk2) { unk4[pos * 2] = 12; - unk4[pos * 2 + 1] = unk2 - unk6; + unk4[pos * 2 + 1] = (u16)(unk2 - unk6); pos++; } else if (unk6 > unk2) { unk4[pos * 2] = 13; - unk4[pos * 2 + 1] = unk6 - unk2; + unk4[pos * 2 + 1] = (u16)(unk6 - unk2); pos++; } @@ -1405,3 +1407,17 @@ THUMB_FUNC static BOOL FUN_0203B158(struct ScriptContext *ctx) u8 *unk = FUN_02039438(ctx->unk80, 4); return *unk == 0 ? TRUE : FALSE; } + +THUMB_FUNC static void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, void *param2) +{ + UnkStruct_0203B174 *unkStruct = (UnkStruct_0203B174 *)AllocFromHeap(4, sizeof(UnkStruct_0203B174)); + if (unkStruct == NULL) + { + GF_AssertFail(); + return; + } + unkStruct->Unk0C = arg; + unkStruct->Unk04 = param1; + unkStruct->Unk08 = param2; + unkStruct->Unk00 = FUN_0200CA44(FUN_0203B1A8, unkStruct, 0); +} -- cgit v1.2.3 From 20b8fa77bcd1875640cb2bb61375bcf0a0bdd45f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 18 Aug 2021 08:18:54 -0400 Subject: unk_02015D14 --- arm9/src/text.c | 2 +- arm9/src/unk_02015D14.c | 325 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 arm9/src/unk_02015D14.c (limited to 'arm9/src') diff --git a/arm9/src/text.c b/arm9/src/text.c index 64b3587e..f178fa9d 100644 --- a/arm9/src/text.c +++ b/arm9/src/text.c @@ -282,7 +282,7 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow sp20[2] = shadowColor; sp20[3] = bgColor; - // FIXME: Need these to be accessed by a pointer to UNK_021C570C + // These are accessed by a pointer to UNK_021C570C due to -ipa file UNK_021C5712 = bgColor; UNK_021C570E = fgColor; UNK_021C5710 = shadowColor; diff --git a/arm9/src/unk_02015D14.c b/arm9/src/unk_02015D14.c new file mode 100644 index 00000000..7a6598a2 --- /dev/null +++ b/arm9/src/unk_02015D14.c @@ -0,0 +1,325 @@ +#include "global.h" +#include "unk_02015D14.h" + +static const u16 UNK_020ED734[][2] = { + {0x0001, 0x01DE}, + {0x0003, 0x0003}, + {0x0005, 0x0005}, + {0x0007, 0x0007}, + {0x0009, 0x0009}, + {0x000B, 0x000B}, + {0x000C, 0x000C}, + {0x000E, 0x000E}, + {0x0010, 0x0010}, + {0x0012, 0x0012}, + {0x0014, 0x0014}, + {0x0016, 0x0016}, + {0x0018, 0x0018}, + {0x001A, 0x001A}, + {0x001C, 0x001C}, + {0x001E, 0x001E}, + {0x0020, 0x0020}, + {0x0022, 0x0022}, + {0x0025, 0x0025}, + {0x0027, 0x0027}, + {0x0029, 0x0029}, + {0x002B, 0x002B}, + {0x002C, 0x002C}, + {0x002D, 0x002D}, + {0x002E, 0x002E}, + {0x002F, 0x002F}, + {0x0030, 0x0030}, + {0x0033, 0x0033}, + {0x0036, 0x0036}, + {0x0039, 0x0039}, + {0x003C, 0x003C}, + {0x003F, 0x003F}, + {0x0040, 0x0040}, + {0x0041, 0x0041}, + {0x0042, 0x0042}, + {0x0043, 0x0043}, + {0x0045, 0x0045}, + {0x0047, 0x0047}, + {0x0049, 0x0049}, + {0x004A, 0x004A}, + {0x004B, 0x004B}, + {0x004C, 0x004C}, + {0x004D, 0x004D}, + {0x004E, 0x004E}, + {0x004F, 0x004F}, + {0x0050, 0x0050}, + {0x0051, 0x0051}, + {0x0002, 0x0002}, + {0x0004, 0x0004}, + {0x0006, 0x0006}, + {0x0008, 0x0008}, + {0x000A, 0x000A}, + {0x0044, 0x0044}, + {0x0046, 0x0046}, + {0x0048, 0x0048}, + {0x000D, 0x000D}, + {0x000F, 0x000F}, + {0x0011, 0x0011}, + {0x0013, 0x0013}, + {0x0015, 0x0015}, + {0x0017, 0x0017}, + {0x0019, 0x0019}, + {0x001B, 0x001B}, + {0x001D, 0x001D}, + {0x001F, 0x001F}, + {0x0021, 0x0021}, + {0x0023, 0x0023}, + {0x0026, 0x0026}, + {0x0028, 0x0028}, + {0x002A, 0x002A}, + {0x0031, 0x0031}, + {0x0034, 0x0034}, + {0x0037, 0x0037}, + {0x003A, 0x003A}, + {0x003D, 0x003D}, + {0x0032, 0x0032}, + {0x0035, 0x0035}, + {0x0038, 0x0038}, + {0x003B, 0x003B}, + {0x003E, 0x003E}, + {0x0024, 0x0024}, + {0x0053, 0x0053}, + {0x0055, 0x0055}, + {0x0057, 0x0057}, + {0x0059, 0x0059}, + {0x005B, 0x005B}, + {0x005C, 0x005C}, + {0x005E, 0x005E}, + {0x0060, 0x0060}, + {0x0062, 0x0062}, + {0x0064, 0x0064}, + {0x0066, 0x0066}, + {0x0068, 0x0068}, + {0x006A, 0x006A}, + {0x006C, 0x006C}, + {0x006E, 0x006E}, + {0x0070, 0x0070}, + {0x0072, 0x0072}, + {0x0075, 0x0075}, + {0x0077, 0x0077}, + {0x0079, 0x0079}, + {0x007B, 0x007B}, + {0x007C, 0x007C}, + {0x007D, 0x007D}, + {0x007E, 0x007E}, + {0x007F, 0x007F}, + {0x0080, 0x0080}, + {0x0083, 0x0083}, + {0x0086, 0x0086}, + {0x0089, 0x0089}, + {0x008C, 0x008C}, + {0x008F, 0x008F}, + {0x0090, 0x0090}, + {0x0091, 0x0091}, + {0x0092, 0x0092}, + {0x0093, 0x0093}, + {0x0095, 0x0095}, + {0x0097, 0x0097}, + {0x0099, 0x0099}, + {0x009A, 0x009A}, + {0x009B, 0x009B}, + {0x009C, 0x009C}, + {0x009D, 0x009D}, + {0x009E, 0x009E}, + {0x009F, 0x009F}, + {0x00A0, 0x00A0}, + {0x00A1, 0x00A1}, + {0x0052, 0x0052}, + {0x0054, 0x0054}, + {0x0056, 0x0056}, + {0x0058, 0x0058}, + {0x005A, 0x005A}, + {0x0094, 0x0094}, + {0x0096, 0x0096}, + {0x0098, 0x0098}, + {0x005D, 0x005D}, + {0x005F, 0x005F}, + {0x0061, 0x0061}, + {0x0063, 0x0063}, + {0x0065, 0x0065}, + {0x0067, 0x0067}, + {0x0069, 0x0069}, + {0x006B, 0x006B}, + {0x006D, 0x006D}, + {0x006F, 0x006F}, + {0x0071, 0x0071}, + {0x0073, 0x0073}, + {0x0076, 0x0076}, + {0x0078, 0x0078}, + {0x007A, 0x007A}, + {0x0081, 0x0081}, + {0x0084, 0x0084}, + {0x0087, 0x0087}, + {0x008A, 0x008A}, + {0x008D, 0x008D}, + {0x0082, 0x0082}, + {0x0085, 0x0085}, + {0x0088, 0x0088}, + {0x008B, 0x008B}, + {0x008E, 0x008E}, + {0x0074, 0x0074}, + {0x00A2, 0x0121}, + {0x00A3, 0x0122}, + {0x00A4, 0x0123}, + {0x00A5, 0x0124}, + {0x00A6, 0x0125}, + {0x00A7, 0x0126}, + {0x00A8, 0x0127}, + {0x00A9, 0x0128}, + {0x00AA, 0x0129}, + {0x00AB, 0x012A}, + {0x00E1, 0x01AB}, + {0x00E2, 0x01AC}, + {0x00E4, 0x01AE}, + {0x00F1, 0x01BE}, + {0x00E6, 0x01B0}, + {0x00E5, 0x01AF}, + {0x00EA, 0x00EA}, + {0x00EB, 0x00EB}, + {0x00E8, 0x01B2}, + {0x00E9, 0x01B3}, + {0x00EE, 0x01BB}, + {0x00EF, 0x01BC}, + {0x0112, 0x0112}, + {0x00E3, 0x01AD}, + {0x00F2, 0x0176}, + {0x00E7, 0x01B1}, + {0x00AC, 0x012B}, + {0x00AD, 0x012C}, + {0x00AE, 0x012D}, + {0x00AF, 0x012E}, + {0x00B0, 0x012F}, + {0x00B1, 0x0130}, + {0x00B2, 0x0131}, + {0x00B3, 0x0132}, + {0x00B4, 0x0133}, + {0x00B5, 0x0134}, + {0x00B6, 0x0135}, + {0x00B7, 0x0136}, + {0x00B8, 0x0137}, + {0x00B9, 0x0138}, + {0x00BA, 0x0139}, + {0x00BB, 0x013A}, + {0x00BC, 0x013B}, + {0x00BD, 0x013C}, + {0x00BE, 0x013D}, + {0x00BF, 0x013E}, + {0x00C0, 0x013F}, + {0x00C1, 0x0140}, + {0x00C2, 0x0141}, + {0x00C3, 0x0142}, + {0x00C4, 0x0143}, + {0x00C5, 0x0144}, + {0x00C6, 0x0145}, + {0x00C7, 0x0146}, + {0x00C8, 0x0147}, + {0x00C9, 0x0148}, + {0x00CA, 0x0149}, + {0x00CB, 0x014A}, + {0x00CC, 0x014B}, + {0x00CD, 0x014C}, + {0x00CE, 0x014D}, + {0x00CF, 0x014E}, + {0x00D0, 0x014F}, + {0x00D1, 0x0150}, + {0x00D2, 0x0151}, + {0x00D3, 0x0152}, + {0x00D4, 0x0153}, + {0x00D5, 0x0154}, + {0x00D6, 0x0155}, + {0x00D7, 0x0156}, + {0x00D8, 0x0157}, + {0x00D9, 0x0158}, + {0x00DA, 0x0159}, + {0x00DB, 0x015A}, + {0x00DC, 0x015B}, + {0x00DD, 0x015C}, + {0x00DE, 0x015D}, + {0x00DF, 0x015E}, + {0x011F, 0x011F}, + {0x00F6, 0x01C4}, + {0x0163, 0x0163}, + {0x0175, 0x0175}, + {0x017B, 0x017B}, + {0x0183, 0x0183}, + {0x0195, 0x0195}, + {0x019B, 0x019B}, +}; + +static THUMB_FUNC u16 FUN_02015D14(u32 a0) +{ + switch (a0) + { + default: + return 0xEA; + case 2: + case 4: + case 7: + return 0x1B4; + case 3: + return 0x1B7; + case 5: + return 0x1B6; + } +} + +static THUMB_FUNC u16 FUN_02015D50(u32 a0) +{ + switch (a0) + { + default: + return 0xEB; + case 2: + case 4: + case 7: + return 0x1B5; + case 3: + return 0x1B8; + case 5: + return 0x1B4; + } +} + +THUMB_FUNC BOOL FUN_02015D88(const u8 * a, u16 * b, u32 c, u32 d) +{ + s32 r2; + u32 r4; + s32 r3; + s32 r1; + + r2 = (d != 1) ? 1 : 0; + for (r4 = 0; r4 < c - 1; r4++) + { + if (a[r4] == 0xFF) + break; + if (a[r4] >= 0xF7) + { + r3 = (s32)((c - 1) < 10 ? (c - 1) : 10); + for (r1 = 0; r1 < r3; r1++) + { + b[r1] = 0x1AC; + } + b[r1] = 0xFFFF; + return FALSE; + } + switch (UNK_020ED734[a[r4]][r2]) + { + case 0xEA: + b[r4] = FUN_02015D14(d); + break; + case 0xEB: + b[r4] = FUN_02015D50(d); + break; + default: + b[r4] = UNK_020ED734[a[r4]][r2]; + break; + } + } + b[r4] = 0xFFFF; + return TRUE; +} -- cgit v1.2.3 From ed84d6a9a3bfc2c092e22b8e941cac775dc14127 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 18 Aug 2021 08:44:22 -0400 Subject: Rename unk_0201D514 --> rs_migrate_string; document --- arm9/src/rs_migrate_string.c | 327 +++++++++++++++++++++++++++++++++++++++++++ arm9/src/unk_02015D14.c | 325 ------------------------------------------ 2 files changed, 327 insertions(+), 325 deletions(-) create mode 100644 arm9/src/rs_migrate_string.c delete mode 100644 arm9/src/unk_02015D14.c (limited to 'arm9/src') diff --git a/arm9/src/rs_migrate_string.c b/arm9/src/rs_migrate_string.c new file mode 100644 index 00000000..46752374 --- /dev/null +++ b/arm9/src/rs_migrate_string.c @@ -0,0 +1,327 @@ +#include "global.h" +#include "string_util.h" +#include "rs_migrate_string.h" + +static const u16 conversion_table[][2] = { + {0x0001, 0x01DE}, // + {0x0003, 0x0003}, // あ + {0x0005, 0x0005}, // い + {0x0007, 0x0007}, // う + {0x0009, 0x0009}, // え + {0x000B, 0x000B}, // お + {0x000C, 0x000C}, // か + {0x000E, 0x000E}, // き + {0x0010, 0x0010}, // く + {0x0012, 0x0012}, // け + {0x0014, 0x0014}, // こ + {0x0016, 0x0016}, // さ + {0x0018, 0x0018}, // し + {0x001A, 0x001A}, // す + {0x001C, 0x001C}, // せ + {0x001E, 0x001E}, // そ + {0x0020, 0x0020}, // た + {0x0022, 0x0022}, // ち + {0x0025, 0x0025}, // つ + {0x0027, 0x0027}, // て + {0x0029, 0x0029}, // と + {0x002B, 0x002B}, // な + {0x002C, 0x002C}, // に + {0x002D, 0x002D}, // ぬ + {0x002E, 0x002E}, // ね + {0x002F, 0x002F}, // の + {0x0030, 0x0030}, // は + {0x0033, 0x0033}, // ひ + {0x0036, 0x0036}, // ふ + {0x0039, 0x0039}, // へ + {0x003C, 0x003C}, // ほ + {0x003F, 0x003F}, // ま + {0x0040, 0x0040}, // み + {0x0041, 0x0041}, // む + {0x0042, 0x0042}, // め + {0x0043, 0x0043}, // も + {0x0045, 0x0045}, // や + {0x0047, 0x0047}, // ゆ + {0x0049, 0x0049}, // よ + {0x004A, 0x004A}, // ら + {0x004B, 0x004B}, // り + {0x004C, 0x004C}, // る + {0x004D, 0x004D}, // れ + {0x004E, 0x004E}, // ろ + {0x004F, 0x004F}, // わ + {0x0050, 0x0050}, // を + {0x0051, 0x0051}, // ん + {0x0002, 0x0002}, // ぁ + {0x0004, 0x0004}, // ぃ + {0x0006, 0x0006}, // ぅ + {0x0008, 0x0008}, // ぇ + {0x000A, 0x000A}, // ぉ + {0x0044, 0x0044}, // ゃ + {0x0046, 0x0046}, // ゅ + {0x0048, 0x0048}, // ょ + {0x000D, 0x000D}, // が + {0x000F, 0x000F}, // ぎ + {0x0011, 0x0011}, // ぐ + {0x0013, 0x0013}, // げ + {0x0015, 0x0015}, // ご + {0x0017, 0x0017}, // ざ + {0x0019, 0x0019}, // じ + {0x001B, 0x001B}, // ず + {0x001D, 0x001D}, // ぜ + {0x001F, 0x001F}, // ぞ + {0x0021, 0x0021}, // だ + {0x0023, 0x0023}, // ぢ + {0x0026, 0x0026}, // づ + {0x0028, 0x0028}, // で + {0x002A, 0x002A}, // ど + {0x0031, 0x0031}, // ば + {0x0034, 0x0034}, // び + {0x0037, 0x0037}, // ぶ + {0x003A, 0x003A}, // べ + {0x003D, 0x003D}, // ぼ + {0x0032, 0x0032}, // ぱ + {0x0035, 0x0035}, // ぴ + {0x0038, 0x0038}, // ぷ + {0x003B, 0x003B}, // ぺ + {0x003E, 0x003E}, // ぽ + {0x0024, 0x0024}, // っ + {0x0053, 0x0053}, // ア + {0x0055, 0x0055}, // イ + {0x0057, 0x0057}, // ウ + {0x0059, 0x0059}, // エ + {0x005B, 0x005B}, // オ + {0x005C, 0x005C}, // カ + {0x005E, 0x005E}, // キ + {0x0060, 0x0060}, // ク + {0x0062, 0x0062}, // ケ + {0x0064, 0x0064}, // コ + {0x0066, 0x0066}, // サ + {0x0068, 0x0068}, // シ + {0x006A, 0x006A}, // ス + {0x006C, 0x006C}, // セ + {0x006E, 0x006E}, // ソ + {0x0070, 0x0070}, // タ + {0x0072, 0x0072}, // チ + {0x0075, 0x0075}, // ツ + {0x0077, 0x0077}, // テ + {0x0079, 0x0079}, // ト + {0x007B, 0x007B}, // ナ + {0x007C, 0x007C}, // ニ + {0x007D, 0x007D}, // ヌ + {0x007E, 0x007E}, // ネ + {0x007F, 0x007F}, // ノ + {0x0080, 0x0080}, // ハ + {0x0083, 0x0083}, // ヒ + {0x0086, 0x0086}, // フ + {0x0089, 0x0089}, // ヘ + {0x008C, 0x008C}, // ホ + {0x008F, 0x008F}, // マ + {0x0090, 0x0090}, // ミ + {0x0091, 0x0091}, // ム + {0x0092, 0x0092}, // メ + {0x0093, 0x0093}, // モ + {0x0095, 0x0095}, // ヤ + {0x0097, 0x0097}, // ユ + {0x0099, 0x0099}, // ヨ + {0x009A, 0x009A}, // ラ + {0x009B, 0x009B}, // リ + {0x009C, 0x009C}, // ル + {0x009D, 0x009D}, // レ + {0x009E, 0x009E}, // ロ + {0x009F, 0x009F}, // ワ + {0x00A0, 0x00A0}, // ヲ + {0x00A1, 0x00A1}, // ン + {0x0052, 0x0052}, // ァ + {0x0054, 0x0054}, // ィ + {0x0056, 0x0056}, // ゥ + {0x0058, 0x0058}, // ェ + {0x005A, 0x005A}, // ォ + {0x0094, 0x0094}, // ャ + {0x0096, 0x0096}, // ュ + {0x0098, 0x0098}, // ョ + {0x005D, 0x005D}, // ガ + {0x005F, 0x005F}, // ギ + {0x0061, 0x0061}, // グ + {0x0063, 0x0063}, // ゲ + {0x0065, 0x0065}, // ゴ + {0x0067, 0x0067}, // ザ + {0x0069, 0x0069}, // ジ + {0x006B, 0x006B}, // ズ + {0x006D, 0x006D}, // ゼ + {0x006F, 0x006F}, // ゾ + {0x0071, 0x0071}, // ダ + {0x0073, 0x0073}, // ヂ + {0x0076, 0x0076}, // ヅ + {0x0078, 0x0078}, // デ + {0x007A, 0x007A}, // ド + {0x0081, 0x0081}, // バ + {0x0084, 0x0084}, // ビ + {0x0087, 0x0087}, // ブ + {0x008A, 0x008A}, // ベ + {0x008D, 0x008D}, // ボ + {0x0082, 0x0082}, // パ + {0x0085, 0x0085}, // ピ + {0x0088, 0x0088}, // プ + {0x008B, 0x008B}, // ペ + {0x008E, 0x008E}, // ポ + {0x0074, 0x0074}, // ッ + {0x00A2, 0x0121}, // 0 + {0x00A3, 0x0122}, // 1 + {0x00A4, 0x0123}, // 2 + {0x00A5, 0x0124}, // 3 + {0x00A6, 0x0125}, // 4 + {0x00A7, 0x0126}, // 5 + {0x00A8, 0x0127}, // 6 + {0x00A9, 0x0128}, // 7 + {0x00AA, 0x0129}, // 8 + {0x00AB, 0x012A}, // 9 + {0x00E1, 0x01AB}, // ! + {0x00E2, 0x01AC}, // ? + {0x00E4, 0x01AE}, // . + {0x00F1, 0x01BE}, // - + {0x00E6, 0x01B0}, // · + {0x00E5, 0x01AF}, // … + {0x00EA, 0x00EA}, // “ + {0x00EB, 0x00EB}, // ” + {0x00E8, 0x01B2}, // ‘ + {0x00E9, 0x01B3}, // ' + {0x00EE, 0x01BB}, // ♂ + {0x00EF, 0x01BC}, // ♀ + {0x0112, 0x0112}, // ¥ + {0x00E3, 0x01AD}, // , + {0x00F2, 0x0176}, // × + {0x00E7, 0x01B1}, // / + {0x00AC, 0x012B}, // A + {0x00AD, 0x012C}, // B + {0x00AE, 0x012D}, // C + {0x00AF, 0x012E}, // D + {0x00B0, 0x012F}, // E + {0x00B1, 0x0130}, // F + {0x00B2, 0x0131}, // G + {0x00B3, 0x0132}, // H + {0x00B4, 0x0133}, // I + {0x00B5, 0x0134}, // J + {0x00B6, 0x0135}, // K + {0x00B7, 0x0136}, // L + {0x00B8, 0x0137}, // M + {0x00B9, 0x0138}, // N + {0x00BA, 0x0139}, // O + {0x00BB, 0x013A}, // P + {0x00BC, 0x013B}, // Q + {0x00BD, 0x013C}, // R + {0x00BE, 0x013D}, // S + {0x00BF, 0x013E}, // T + {0x00C0, 0x013F}, // U + {0x00C1, 0x0140}, // V + {0x00C2, 0x0141}, // W + {0x00C3, 0x0142}, // X + {0x00C4, 0x0143}, // Y + {0x00C5, 0x0144}, // Z + {0x00C6, 0x0145}, // a + {0x00C7, 0x0146}, // b + {0x00C8, 0x0147}, // c + {0x00C9, 0x0148}, // d + {0x00CA, 0x0149}, // e + {0x00CB, 0x014A}, // f + {0x00CC, 0x014B}, // g + {0x00CD, 0x014C}, // h + {0x00CE, 0x014D}, // i + {0x00CF, 0x014E}, // j + {0x00D0, 0x014F}, // k + {0x00D1, 0x0150}, // l + {0x00D2, 0x0151}, // m + {0x00D3, 0x0152}, // n + {0x00D4, 0x0153}, // o + {0x00D5, 0x0154}, // p + {0x00D6, 0x0155}, // q + {0x00D7, 0x0156}, // r + {0x00D8, 0x0157}, // s + {0x00D9, 0x0158}, // t + {0x00DA, 0x0159}, // u + {0x00DB, 0x015A}, // v + {0x00DC, 0x015B}, // w + {0x00DD, 0x015C}, // x + {0x00DE, 0x015D}, // y + {0x00DF, 0x015E}, // z + {0x011F, 0x011F}, // ▶ + {0x00F6, 0x01C4}, // : + {0x0163, 0x0163}, // Ä + {0x0175, 0x0175}, // Ö + {0x017B, 0x017B}, // Ü + {0x0183, 0x0183}, // ä + {0x0195, 0x0195}, // ö + {0x019B, 0x019B}, // ü +}; + +static THUMB_FUNC u16 GetOpeningQuote(u32 language) +{ + switch (language) + { + default: + return 0xEA; + case LANGUAGE_ENGLISH: + case LANGUAGE_ITALIAN: + case LANGUAGE_SPANISH: + return 0x1B4; + case LANGUAGE_FRENCH: + return 0x1B7; + case LANGUAGE_GERMAN: + return 0x1B6; + } +} + +static THUMB_FUNC u16 GetClosingQuote(u32 language) +{ + switch (language) + { + default: + return 0xEB; + case LANGUAGE_ENGLISH: + case LANGUAGE_ITALIAN: + case LANGUAGE_SPANISH: + return 0x1B5; + case LANGUAGE_FRENCH: + return 0x1B8; + case LANGUAGE_GERMAN: + return 0x1B4; + } +} + +THUMB_FUNC BOOL ConvertRSStringToDPStringInternational(const u8 * rs_str, u16 * dp_str, u32 length, u32 language) +{ + BOOL notFullWidth; + u32 i; + + notFullWidth = (language != LANGUAGE_JAPANESE); + for (i = 0; i < length - 1; i++) + { + if (rs_str[i] == 0xFF) // RS: EOS + break; + if (rs_str[i] >= 0xF7) // RS: DYNAMIC + { + // If we're here, the provided name is corrupt. + // Fill it with question marks. + s32 r3 = (s32)((length - 1) < 10 ? (length - 1) : 10); + s32 r1; + for (r1 = 0; r1 < r3; r1++) + { + dp_str[r1] = 0x1AC; // DP: ? + } + dp_str[r1] = EOS; + return FALSE; + } + switch (conversion_table[rs_str[i]][notFullWidth]) + { + case 0xEA: // RS: Opening double quote + dp_str[i] = GetOpeningQuote(language); + break; + case 0xEB: // RS: Closing double quote + dp_str[i] = GetClosingQuote(language); + break; + default: + dp_str[i] = conversion_table[rs_str[i]][notFullWidth]; + break; + } + } + dp_str[i] = EOS; + return TRUE; +} diff --git a/arm9/src/unk_02015D14.c b/arm9/src/unk_02015D14.c deleted file mode 100644 index 7a6598a2..00000000 --- a/arm9/src/unk_02015D14.c +++ /dev/null @@ -1,325 +0,0 @@ -#include "global.h" -#include "unk_02015D14.h" - -static const u16 UNK_020ED734[][2] = { - {0x0001, 0x01DE}, - {0x0003, 0x0003}, - {0x0005, 0x0005}, - {0x0007, 0x0007}, - {0x0009, 0x0009}, - {0x000B, 0x000B}, - {0x000C, 0x000C}, - {0x000E, 0x000E}, - {0x0010, 0x0010}, - {0x0012, 0x0012}, - {0x0014, 0x0014}, - {0x0016, 0x0016}, - {0x0018, 0x0018}, - {0x001A, 0x001A}, - {0x001C, 0x001C}, - {0x001E, 0x001E}, - {0x0020, 0x0020}, - {0x0022, 0x0022}, - {0x0025, 0x0025}, - {0x0027, 0x0027}, - {0x0029, 0x0029}, - {0x002B, 0x002B}, - {0x002C, 0x002C}, - {0x002D, 0x002D}, - {0x002E, 0x002E}, - {0x002F, 0x002F}, - {0x0030, 0x0030}, - {0x0033, 0x0033}, - {0x0036, 0x0036}, - {0x0039, 0x0039}, - {0x003C, 0x003C}, - {0x003F, 0x003F}, - {0x0040, 0x0040}, - {0x0041, 0x0041}, - {0x0042, 0x0042}, - {0x0043, 0x0043}, - {0x0045, 0x0045}, - {0x0047, 0x0047}, - {0x0049, 0x0049}, - {0x004A, 0x004A}, - {0x004B, 0x004B}, - {0x004C, 0x004C}, - {0x004D, 0x004D}, - {0x004E, 0x004E}, - {0x004F, 0x004F}, - {0x0050, 0x0050}, - {0x0051, 0x0051}, - {0x0002, 0x0002}, - {0x0004, 0x0004}, - {0x0006, 0x0006}, - {0x0008, 0x0008}, - {0x000A, 0x000A}, - {0x0044, 0x0044}, - {0x0046, 0x0046}, - {0x0048, 0x0048}, - {0x000D, 0x000D}, - {0x000F, 0x000F}, - {0x0011, 0x0011}, - {0x0013, 0x0013}, - {0x0015, 0x0015}, - {0x0017, 0x0017}, - {0x0019, 0x0019}, - {0x001B, 0x001B}, - {0x001D, 0x001D}, - {0x001F, 0x001F}, - {0x0021, 0x0021}, - {0x0023, 0x0023}, - {0x0026, 0x0026}, - {0x0028, 0x0028}, - {0x002A, 0x002A}, - {0x0031, 0x0031}, - {0x0034, 0x0034}, - {0x0037, 0x0037}, - {0x003A, 0x003A}, - {0x003D, 0x003D}, - {0x0032, 0x0032}, - {0x0035, 0x0035}, - {0x0038, 0x0038}, - {0x003B, 0x003B}, - {0x003E, 0x003E}, - {0x0024, 0x0024}, - {0x0053, 0x0053}, - {0x0055, 0x0055}, - {0x0057, 0x0057}, - {0x0059, 0x0059}, - {0x005B, 0x005B}, - {0x005C, 0x005C}, - {0x005E, 0x005E}, - {0x0060, 0x0060}, - {0x0062, 0x0062}, - {0x0064, 0x0064}, - {0x0066, 0x0066}, - {0x0068, 0x0068}, - {0x006A, 0x006A}, - {0x006C, 0x006C}, - {0x006E, 0x006E}, - {0x0070, 0x0070}, - {0x0072, 0x0072}, - {0x0075, 0x0075}, - {0x0077, 0x0077}, - {0x0079, 0x0079}, - {0x007B, 0x007B}, - {0x007C, 0x007C}, - {0x007D, 0x007D}, - {0x007E, 0x007E}, - {0x007F, 0x007F}, - {0x0080, 0x0080}, - {0x0083, 0x0083}, - {0x0086, 0x0086}, - {0x0089, 0x0089}, - {0x008C, 0x008C}, - {0x008F, 0x008F}, - {0x0090, 0x0090}, - {0x0091, 0x0091}, - {0x0092, 0x0092}, - {0x0093, 0x0093}, - {0x0095, 0x0095}, - {0x0097, 0x0097}, - {0x0099, 0x0099}, - {0x009A, 0x009A}, - {0x009B, 0x009B}, - {0x009C, 0x009C}, - {0x009D, 0x009D}, - {0x009E, 0x009E}, - {0x009F, 0x009F}, - {0x00A0, 0x00A0}, - {0x00A1, 0x00A1}, - {0x0052, 0x0052}, - {0x0054, 0x0054}, - {0x0056, 0x0056}, - {0x0058, 0x0058}, - {0x005A, 0x005A}, - {0x0094, 0x0094}, - {0x0096, 0x0096}, - {0x0098, 0x0098}, - {0x005D, 0x005D}, - {0x005F, 0x005F}, - {0x0061, 0x0061}, - {0x0063, 0x0063}, - {0x0065, 0x0065}, - {0x0067, 0x0067}, - {0x0069, 0x0069}, - {0x006B, 0x006B}, - {0x006D, 0x006D}, - {0x006F, 0x006F}, - {0x0071, 0x0071}, - {0x0073, 0x0073}, - {0x0076, 0x0076}, - {0x0078, 0x0078}, - {0x007A, 0x007A}, - {0x0081, 0x0081}, - {0x0084, 0x0084}, - {0x0087, 0x0087}, - {0x008A, 0x008A}, - {0x008D, 0x008D}, - {0x0082, 0x0082}, - {0x0085, 0x0085}, - {0x0088, 0x0088}, - {0x008B, 0x008B}, - {0x008E, 0x008E}, - {0x0074, 0x0074}, - {0x00A2, 0x0121}, - {0x00A3, 0x0122}, - {0x00A4, 0x0123}, - {0x00A5, 0x0124}, - {0x00A6, 0x0125}, - {0x00A7, 0x0126}, - {0x00A8, 0x0127}, - {0x00A9, 0x0128}, - {0x00AA, 0x0129}, - {0x00AB, 0x012A}, - {0x00E1, 0x01AB}, - {0x00E2, 0x01AC}, - {0x00E4, 0x01AE}, - {0x00F1, 0x01BE}, - {0x00E6, 0x01B0}, - {0x00E5, 0x01AF}, - {0x00EA, 0x00EA}, - {0x00EB, 0x00EB}, - {0x00E8, 0x01B2}, - {0x00E9, 0x01B3}, - {0x00EE, 0x01BB}, - {0x00EF, 0x01BC}, - {0x0112, 0x0112}, - {0x00E3, 0x01AD}, - {0x00F2, 0x0176}, - {0x00E7, 0x01B1}, - {0x00AC, 0x012B}, - {0x00AD, 0x012C}, - {0x00AE, 0x012D}, - {0x00AF, 0x012E}, - {0x00B0, 0x012F}, - {0x00B1, 0x0130}, - {0x00B2, 0x0131}, - {0x00B3, 0x0132}, - {0x00B4, 0x0133}, - {0x00B5, 0x0134}, - {0x00B6, 0x0135}, - {0x00B7, 0x0136}, - {0x00B8, 0x0137}, - {0x00B9, 0x0138}, - {0x00BA, 0x0139}, - {0x00BB, 0x013A}, - {0x00BC, 0x013B}, - {0x00BD, 0x013C}, - {0x00BE, 0x013D}, - {0x00BF, 0x013E}, - {0x00C0, 0x013F}, - {0x00C1, 0x0140}, - {0x00C2, 0x0141}, - {0x00C3, 0x0142}, - {0x00C4, 0x0143}, - {0x00C5, 0x0144}, - {0x00C6, 0x0145}, - {0x00C7, 0x0146}, - {0x00C8, 0x0147}, - {0x00C9, 0x0148}, - {0x00CA, 0x0149}, - {0x00CB, 0x014A}, - {0x00CC, 0x014B}, - {0x00CD, 0x014C}, - {0x00CE, 0x014D}, - {0x00CF, 0x014E}, - {0x00D0, 0x014F}, - {0x00D1, 0x0150}, - {0x00D2, 0x0151}, - {0x00D3, 0x0152}, - {0x00D4, 0x0153}, - {0x00D5, 0x0154}, - {0x00D6, 0x0155}, - {0x00D7, 0x0156}, - {0x00D8, 0x0157}, - {0x00D9, 0x0158}, - {0x00DA, 0x0159}, - {0x00DB, 0x015A}, - {0x00DC, 0x015B}, - {0x00DD, 0x015C}, - {0x00DE, 0x015D}, - {0x00DF, 0x015E}, - {0x011F, 0x011F}, - {0x00F6, 0x01C4}, - {0x0163, 0x0163}, - {0x0175, 0x0175}, - {0x017B, 0x017B}, - {0x0183, 0x0183}, - {0x0195, 0x0195}, - {0x019B, 0x019B}, -}; - -static THUMB_FUNC u16 FUN_02015D14(u32 a0) -{ - switch (a0) - { - default: - return 0xEA; - case 2: - case 4: - case 7: - return 0x1B4; - case 3: - return 0x1B7; - case 5: - return 0x1B6; - } -} - -static THUMB_FUNC u16 FUN_02015D50(u32 a0) -{ - switch (a0) - { - default: - return 0xEB; - case 2: - case 4: - case 7: - return 0x1B5; - case 3: - return 0x1B8; - case 5: - return 0x1B4; - } -} - -THUMB_FUNC BOOL FUN_02015D88(const u8 * a, u16 * b, u32 c, u32 d) -{ - s32 r2; - u32 r4; - s32 r3; - s32 r1; - - r2 = (d != 1) ? 1 : 0; - for (r4 = 0; r4 < c - 1; r4++) - { - if (a[r4] == 0xFF) - break; - if (a[r4] >= 0xF7) - { - r3 = (s32)((c - 1) < 10 ? (c - 1) : 10); - for (r1 = 0; r1 < r3; r1++) - { - b[r1] = 0x1AC; - } - b[r1] = 0xFFFF; - return FALSE; - } - switch (UNK_020ED734[a[r4]][r2]) - { - case 0xEA: - b[r4] = FUN_02015D14(d); - break; - case 0xEB: - b[r4] = FUN_02015D50(d); - break; - default: - b[r4] = UNK_020ED734[a[r4]][r2]; - break; - } - } - b[r4] = 0xFFFF; - return TRUE; -} -- cgit v1.2.3 From 06b3faa2ef3e9a0ad297f4dfa48573bbed7249d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 18 Aug 2021 17:50:40 +0200 Subject: decompile and split unk_02009EAC.s --- arm9/src/unk_02009EAC.c | 170 +++++++++++++++++++++++++++++++++++++++++++++ arm9/src/unk_0200A104.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 348 insertions(+) create mode 100644 arm9/src/unk_02009EAC.c create mode 100644 arm9/src/unk_0200A104.c (limited to 'arm9/src') diff --git a/arm9/src/unk_02009EAC.c b/arm9/src/unk_02009EAC.c new file mode 100644 index 00000000..df21ed80 --- /dev/null +++ b/arm9/src/unk_02009EAC.c @@ -0,0 +1,170 @@ +#include "global.h" +#include "unk_02009EAC.h" +#include "GX_g2.h" +#include "MI_memory.h" +#include "heap.h" + + +extern void FUN_020213A0(void); +extern void FUN_0202135C(void *param0, + u32 *param1, + u32 (*param2)(u32, u32), + u32 (*param3)(u32), + void (*param4)(void), + u32 param5, + u32 param6); +extern void FUN_020203CC(u32 heap_id); +extern void FUN_02020404(u32 heap_id); + +struct UnkStruct_02009EAC *UNK_021C4670; + +THUMB_FUNC void FUN_02009EAC(s32 param0, + s32 param1, + s32 param2, + s32 param3, + u32 param4, + u32 param5, + u32 param6, + u32 param7, + u32 param8) +{ + s32 r0; + if (param0 < 4) + { + r0 = 4; + if (param1 > 0x7c) + { + param1 = param1 - (4 - param0); + } + } + else + { + r0 = param0; + } + + s32 r2; + if (param2 < 1) + { + r2 = 1; + if (param3 > 0x1e) + { + param3 = param3 - (1 - param2); + } + } + else + { + r2 = param2; + } + + FUN_02009EF0(r0, param1, r2, param3, param4, param5, param6, param7, param8); +} + +THUMB_FUNC void FUN_02009EF0(u32 param0, + u32 param1, + u32 param2, + u32 param3, + u32 param4, + u32 param5, + u32 param6, + u32 param7, + u32 param8) +{ + GF_ASSERT(UNK_021C4670 == NULL); + UNK_021C4670 = AllocFromHeap(param8, sizeof(struct UnkStruct_02009EAC)); + GF_ASSERT(UNK_021C4670); + + UNK_021C4670->heap_id = param8; + + GF_ASSERT(NNS_G2dGetNewOamManagerInstance( + &UNK_021C4670->oamManagers[0], param0, param1, param2, param3, 0)); + GF_ASSERT(NNS_G2dGetNewOamManagerInstance( + &UNK_021C4670->oamManagers[1], param4, param5, param6, param7, 1)); +} + +THUMB_FUNC void FUN_02009F80(void) +{ + if (UNK_021C4670 != NULL) + { + NNS_G2dApplyAndResetOamManagerBuffer(&UNK_021C4670->oamManagers[0]); + NNS_G2dApplyAndResetOamManagerBuffer(&UNK_021C4670->oamManagers[1]); + } +} + +THUMB_FUNC void FUN_02009FA0(void) +{ + GF_ASSERT(UNK_021C4670); + + FUN_0200A064(UNK_021C4670->heap_id); + FUN_0200A06C(UNK_021C4670->heap_id); + + FreeToHeap(UNK_021C4670); + UNK_021C4670 = NULL; +} + +THUMB_FUNC void FUN_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3) +{ + GF_ASSERT(UNK_021C4670); + + if (param2 == 1) + { + FUN_0202135C(param0, param1, FUN_0200A074, FUN_0200A0B8, FUN_020213A0, param2, param3); + return; + } + + FUN_0202135C(param0, param1, FUN_0200A094, FUN_0200A0DC, FUN_020213A0, param2, param3); +} + +THUMB_FUNC NNSG2dOamManager *FUN_0200A03C(u32 param0) +{ + GF_ASSERT(UNK_021C4670); + if (param0 == 0) + { + return &UNK_021C4670->oamManagers[0]; + } + else + { + return &UNK_021C4670->oamManagers[1]; + } +} + +THUMB_FUNC void FUN_0200A064(u32 heap_id) +{ + FUN_020203CC(heap_id); +} + +THUMB_FUNC void FUN_0200A06C(u32 heap_id) +{ + FUN_02020404(heap_id); +} + +THUMB_FUNC u32 FUN_0200A074(u32 param0, u32 param1) +{ + u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&UNK_021C4670->oamManagers[0], param0, param1); + GF_ASSERT(res); + + return res; +} + +THUMB_FUNC u32 FUN_0200A094(u32 param0, u32 param1) +{ + u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&UNK_021C4670->oamManagers[1], param0, param1); + GF_ASSERT(res); + + return res; +} + +THUMB_FUNC u32 FUN_0200A0B8(u32 param0) +{ + u32 res = NNS_G2dEntryOamManagerAffine(&UNK_021C4670->oamManagers[0], param0); + GF_ASSERT(res != 0xFFFE); + + return res; +} + +THUMB_FUNC u32 FUN_0200A0DC(u32 param0) +{ + u32 res = NNS_G2dEntryOamManagerAffine(&UNK_021C4670->oamManagers[1], param0); + GF_ASSERT(res != 0xFFFE); + + return res; +} diff --git a/arm9/src/unk_0200A104.c b/arm9/src/unk_0200A104.c new file mode 100644 index 00000000..a0190301 --- /dev/null +++ b/arm9/src/unk_0200A104.c @@ -0,0 +1,178 @@ +#include "global.h" +#include "unk_0200A104.h" +#include "GX_g2.h" +#include "MI_memory.h" + +struct UnkStruct_0200A104 UNK_021C4694; + +struct UnkStruct_0200A104 UNK_021C4674; + +THUMB_FUNC void FUN_0200A104(struct UnkStruct_0200A104 *param0) +{ + u32 r4 = 0; + + if (param0->unk0a != param0->unk1a + param0->unk10 * param0->unk14 && + param0->unk1a != param0->unk0a) + { + param0->unk1a += param0->unk10 * param0->unk14; + param0->unk18 += param0->unk16; + + if (param0->unk18 >= param0->unk08) + { + param0->unk1a += param0->unk10; + if (param0->unk1a != param0->unk0a) + { + param0->unk18 -= param0->unk08; + } + else + { + r4 = 1; + } + } + } + else + { + param0->unk1a = param0->unk0a; + r4 = 1; + } + + if ((param0->unk04 & 1) != 0) + { + G2x_SetBlendBrightness_(0x04000050, param0->unk00, param0->unk1a); + } + else if ((param0->unk04 & 2) != 0) + { + G2x_SetBlendBrightness_(0x04001050, param0->unk00, param0->unk1a); + } + + if (r4 == 1) + { + param0->unk1c = 0; + } +} + +THUMB_FUNC void FUN_0200A1A0( + struct UnkStruct_0200A104 *param0, u16 param1, s16 param2, s16 param3, u32 param4, u32 param5) +{ + GF_ASSERT(param0->unk1c == 0); + + param0->unk1c = 1; + param0->unk00 = (u8)param4; + param0->unk04 = (u8)param5; + param0->unk08 = param1; + param0->unk0a = param2; + param0->unk1a = param3; + param0->unk12 = param3 - param2; + + if (param0->unk12 > 0) + { + param0->unk10 = -1; + } + else + { + param0->unk10 = 1; + param0->unk12 *= -1; + } + + param0->unk14 = param0->unk12 / param1; + param0->unk16 = param0->unk12 % param1; + param0->unk18 = 0; +} + +THUMB_FUNC void FUN_0200A208(u16 param0, s16 param1, s16 param2, u32 param3, u32 param4) +{ + if (param0 != 0) + { + if ((param4 & 1) != 0) + { + G2x_SetBlendBrightness_(0x04000050, param3, param2); + FUN_0200A1A0(&UNK_021C4694, param0, param1, param2, param3, 1); + } + + if ((param4 & 2) != 0) + { + G2x_SetBlendBrightness_(0x04001050, param3, param2); + FUN_0200A1A0(&UNK_021C4674, param0, param1, param2, param3, 2); + } + } +} + +THUMB_FUNC void FUN_0200A274(fx32 brightness, fx32 param1, u32 param2) +{ + + if ((param2 & 1) != 0) + { + G2x_SetBlendBrightness_(0x04000050, param1, brightness); + } + + if ((param2 & 2) != 0) + { + G2x_SetBlendBrightness_(0x04001050, param1, brightness); + } + + FUN_0200A2D8(param2); +} + +THUMB_FUNC void FUN_0200A2AC(void) +{ + MI_CpuFill8(&UNK_021C4694, 0, sizeof(struct UnkStruct_0200A104)); + MI_CpuFill8(&UNK_021C4674, 0, sizeof(struct UnkStruct_0200A104)); + + UNK_021C4694.unk1c = 0; + UNK_021C4674.unk1c = 0; +} + +THUMB_FUNC void FUN_0200A2D8(u32 param0) +{ + if (param0 & 1) + { + MI_CpuFill8(&UNK_021C4694, 0, sizeof(struct UnkStruct_0200A104)); + UNK_021C4694.unk1c = 0; + } + + if (param0 & 2) + { + MI_CpuFill8(&UNK_021C4674, 0, sizeof(struct UnkStruct_0200A104)); + UNK_021C4674.unk1c = 0; + } +} + +THUMB_FUNC void FUN_0200A318(void) +{ + if (UNK_021C4694.unk1c) + { + FUN_0200A104(&UNK_021C4694); + } + + if (UNK_021C4674.unk1c) + { + FUN_0200A104(&UNK_021C4674); + } +} + +THUMB_FUNC u32 FUN_0200A344(u32 param0) +{ + if (param0 == 3) + { + if (UNK_021C4694.unk1c == 0 && UNK_021C4674.unk1c == 0) + { + return 1; + } + } + else if (param0 == 1) + { + if (UNK_021C4694.unk1c == 0) + { + return 1; + } + } + else if (param0 == 2) + { + if (UNK_021C4674.unk1c == 0) + { + return 1; + } + } + + return 0; +} -- cgit v1.2.3 From 4c6555ebcf6ad432ded5d9699d1d3b404907ce6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 18 Aug 2021 18:15:18 +0200 Subject: fix warnings --- arm9/src/communication_error.c | 2 +- arm9/src/error_message_reset.c | 2 +- arm9/src/main.c | 3 +-- arm9/src/unk_02008AA4.c | 2 +- arm9/src/unk_02009EAC.c | 19 +++++++++---------- arm9/src/unk_0200A104.c | 22 +++++++++++----------- arm9/src/unk_0200BB14.c | 12 +----------- arm9/src/wfc_user_info_warning.c | 2 +- 8 files changed, 26 insertions(+), 38 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 73345af1..9a34fc75 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -6,8 +6,8 @@ #include "msgdata.h" #include "msgdata/msg.naix" #include "text.h" +#include "unk_0200A104.h" -extern void FUN_0200A274(fx32 brightness, fx32, u32); extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index d49e8e51..bf8ad0f1 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -6,6 +6,7 @@ #include "bg_window.h" #include "PAD_pad.h" #include "font.h" +#include "unk_0200A104.h" const struct WindowTemplate UNK_020FF49C = { @@ -46,7 +47,6 @@ extern void FUN_0200E3A0(PMLCDTarget, int); extern void FUN_0200CB00(struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); extern void FUN_0200CCA4(struct Window *param0, u32 param1, u32 param2, u32 param3); extern void FUN_0200E394(u32 param0); -extern void FUN_0200A274(u32 param0, u32 param1, u32 param2); THUMB_FUNC void VBlankHandler() { diff --git a/arm9/src/main.c b/arm9/src/main.c index fb4f8707..aa4da4bb 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -18,6 +18,7 @@ #include "wfc_user_info_warning.h" #include "module_52.h" #include "font.h" +#include "unk_0200A104.h" FS_EXTERN_OVERLAY(MODULE_52); FS_EXTERN_OVERLAY(MODULE_63); @@ -32,13 +33,11 @@ extern void FUN_02022294(void); extern void GF_InitRTCWork(void); extern int FUN_020337E8(int); extern void FUN_02089D90(int); -extern void FUN_0200A2AC(void); extern void FUN_02015E30(void); extern void FUN_0201B5CC(void *); extern void GF_RTC_UpdateOnFrame(void); extern void FUN_02015E60(void); extern void FUN_020222C4(void); -extern void FUN_0200A318(void); extern void FUN_0200E2D8(void); extern struct Unk21DBE18 MOD63_021DBE18; diff --git a/arm9/src/unk_02008AA4.c b/arm9/src/unk_02008AA4.c index 1cabb887..9a7dfc75 100644 --- a/arm9/src/unk_02008AA4.c +++ b/arm9/src/unk_02008AA4.c @@ -4,9 +4,9 @@ #include "heap.h" #include "unk_0200BB14.h" #include "unk_02008DEC.h" +#include "unk_02009EAC.h" extern void FUN_0202134C(void *, u32); -extern void FUN_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3); extern u32 FUN_0201FCB0(u32 *); extern void FUN_02021390(u32, u32 *); extern void FUN_0201D194(u32, u32, u32); diff --git a/arm9/src/unk_02009EAC.c b/arm9/src/unk_02009EAC.c index df21ed80..b673eb1b 100644 --- a/arm9/src/unk_02009EAC.c +++ b/arm9/src/unk_02009EAC.c @@ -4,7 +4,6 @@ #include "MI_memory.h" #include "heap.h" - extern void FUN_020213A0(void); extern void FUN_0202135C(void *param0, u32 *param1, @@ -59,26 +58,26 @@ THUMB_FUNC void FUN_02009EAC(s32 param0, FUN_02009EF0(r0, param1, r2, param3, param4, param5, param6, param7, param8); } -THUMB_FUNC void FUN_02009EF0(u32 param0, - u32 param1, - u32 param2, - u32 param3, +THUMB_FUNC void FUN_02009EF0(s32 param0, + s32 param1, + s32 param2, + s32 param3, u32 param4, u32 param5, u32 param6, u32 param7, - u32 param8) + u32 heap_id) { GF_ASSERT(UNK_021C4670 == NULL); - UNK_021C4670 = AllocFromHeap(param8, sizeof(struct UnkStruct_02009EAC)); + UNK_021C4670 = AllocFromHeap(heap_id, sizeof(struct UnkStruct_02009EAC)); GF_ASSERT(UNK_021C4670); - UNK_021C4670->heap_id = param8; + UNK_021C4670->heap_id = heap_id; GF_ASSERT(NNS_G2dGetNewOamManagerInstance( - &UNK_021C4670->oamManagers[0], param0, param1, param2, param3, 0)); + &UNK_021C4670->oamManagers[0], (u16)param0, (u16)param1, (u16)param2, (u16)param3, 0)); GF_ASSERT(NNS_G2dGetNewOamManagerInstance( - &UNK_021C4670->oamManagers[1], param4, param5, param6, param7, 1)); + &UNK_021C4670->oamManagers[1], (u16)param4, (u16)param5, (u16)param6, (u16)param7, 1)); } THUMB_FUNC void FUN_02009F80(void) diff --git a/arm9/src/unk_0200A104.c b/arm9/src/unk_0200A104.c index a0190301..407ac34d 100644 --- a/arm9/src/unk_0200A104.c +++ b/arm9/src/unk_0200A104.c @@ -38,11 +38,11 @@ THUMB_FUNC void FUN_0200A104(struct UnkStruct_0200A104 *param0) if ((param0->unk04 & 1) != 0) { - G2x_SetBlendBrightness_(0x04000050, param0->unk00, param0->unk1a); + G2x_SetBlendBrightness_(reg_addr_G2_BLDCNT, param0->unk00, param0->unk1a); } else if ((param0->unk04 & 2) != 0) { - G2x_SetBlendBrightness_(0x04001050, param0->unk00, param0->unk1a); + G2x_SetBlendBrightness_(reg_addr_G2S_DB_BLDCNT, param0->unk00, param0->unk1a); } if (r4 == 1) @@ -52,7 +52,7 @@ THUMB_FUNC void FUN_0200A104(struct UnkStruct_0200A104 *param0) } THUMB_FUNC void FUN_0200A1A0( - struct UnkStruct_0200A104 *param0, u16 param1, s16 param2, s16 param3, u32 param4, u32 param5) + struct UnkStruct_0200A104 *param0, u16 param1, s16 param2, s16 param3, fx32 param4, u32 param5) { GF_ASSERT(param0->unk1c == 0); @@ -62,7 +62,7 @@ THUMB_FUNC void FUN_0200A1A0( param0->unk08 = param1; param0->unk0a = param2; param0->unk1a = param3; - param0->unk12 = param3 - param2; + param0->unk12 = (s16)(param3 - param2); if (param0->unk12 > 0) { @@ -74,24 +74,24 @@ THUMB_FUNC void FUN_0200A1A0( param0->unk12 *= -1; } - param0->unk14 = param0->unk12 / param1; - param0->unk16 = param0->unk12 % param1; + param0->unk14 = (s16)(param0->unk12 / param1); + param0->unk16 = (u16)(param0->unk12 % param1); param0->unk18 = 0; } -THUMB_FUNC void FUN_0200A208(u16 param0, s16 param1, s16 param2, u32 param3, u32 param4) +THUMB_FUNC void FUN_0200A208(u16 param0, s16 param1, s16 param2, fx32 param3, u32 param4) { if (param0 != 0) { if ((param4 & 1) != 0) { - G2x_SetBlendBrightness_(0x04000050, param3, param2); + G2x_SetBlendBrightness_(reg_addr_G2_BLDCNT, param3, param2); FUN_0200A1A0(&UNK_021C4694, param0, param1, param2, param3, 1); } if ((param4 & 2) != 0) { - G2x_SetBlendBrightness_(0x04001050, param3, param2); + G2x_SetBlendBrightness_(reg_addr_G2S_DB_BLDCNT, param3, param2); FUN_0200A1A0(&UNK_021C4674, param0, param1, param2, param3, 2); } } @@ -102,12 +102,12 @@ THUMB_FUNC void FUN_0200A274(fx32 brightness, fx32 param1, u32 param2) if ((param2 & 1) != 0) { - G2x_SetBlendBrightness_(0x04000050, param1, brightness); + G2x_SetBlendBrightness_(reg_addr_G2_BLDCNT, param1, brightness); } if ((param2 & 2) != 0) { - G2x_SetBlendBrightness_(0x04001050, param1, brightness); + G2x_SetBlendBrightness_(reg_addr_G2S_DB_BLDCNT, param1, brightness); } FUN_0200A2D8(param2); diff --git a/arm9/src/unk_0200BB14.c b/arm9/src/unk_0200BB14.c index 95a854d7..d862ad2d 100644 --- a/arm9/src/unk_0200BB14.c +++ b/arm9/src/unk_0200BB14.c @@ -4,31 +4,21 @@ #include "heap.h" #include "unk_02008AA4.h" #include "unk_02008DEC.h" +#include "unk_02009EAC.h" extern void FUN_0201D060(u32 *param0, u32 param1, u32 param2); extern void FUN_0201E00C(u32 param0, u32 param1); extern void NNS_G2dInitOamManagerModule(); -extern void FUN_02009EAC(u32 param0, - u32 param1, - u32 param2, - u32 param3, - u32 param4, - u32 param5, - u32 param6, - u32 param7, - u32 param8); extern u32 FUN_0201C328(u32 param0, u32 param1); extern void FUN_0201D168(); extern void FUN_0201E0BC(); extern void FUN_0201FFC8(u32 param0); extern void FUN_0201FDEC(u32 param0); -extern void FUN_02009F80(); extern void FUN_0201C348(); extern void FUN_0201FD58(u32 param0); extern void FUN_0201C350(u32 param0); extern void FUN_0201D12C(); extern void FUN_0201E08C(); -extern void FUN_02009FA0(); extern u32 FUN_0201FE94(struct UnkStruct_0200BB14_4 *param0); extern void FUN_02020130(u32 param0, u32 param1); extern void FUN_02020248(u32 param0, u32 param1); diff --git a/arm9/src/wfc_user_info_warning.c b/arm9/src/wfc_user_info_warning.c index d9edd94c..4ba4166c 100644 --- a/arm9/src/wfc_user_info_warning.c +++ b/arm9/src/wfc_user_info_warning.c @@ -10,9 +10,9 @@ #include "string16.h" #include "text.h" #include "wfc_user_info_warning.h" +#include "unk_0200A104.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); -extern void FUN_0200A274(fx32 brightness, fx32, u32); extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); -- cgit v1.2.3 From bb8d0b174dfafd4d268a874ef55f2d09f510b82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 18 Aug 2021 19:57:28 +0200 Subject: partially document oam.c and brightness.c --- arm9/src/brightness.c | 198 +++++++++++++++++++++++++++++++++++++++ arm9/src/communication_error.c | 4 +- arm9/src/error_message_reset.c | 4 +- arm9/src/main.c | 6 +- arm9/src/oam.c | 169 +++++++++++++++++++++++++++++++++ arm9/src/unk_02008AA4.c | 2 +- arm9/src/unk_02009EAC.c | 169 --------------------------------- arm9/src/unk_0200A104.c | 178 ----------------------------------- arm9/src/unk_0200BB14.c | 6 +- arm9/src/wfc_user_info_warning.c | 4 +- 10 files changed, 380 insertions(+), 360 deletions(-) create mode 100644 arm9/src/brightness.c create mode 100644 arm9/src/oam.c delete mode 100644 arm9/src/unk_02009EAC.c delete mode 100644 arm9/src/unk_0200A104.c (limited to 'arm9/src') diff --git a/arm9/src/brightness.c b/arm9/src/brightness.c new file mode 100644 index 00000000..59e96fd3 --- /dev/null +++ b/arm9/src/brightness.c @@ -0,0 +1,198 @@ +#include "global.h" +#include "brightness.h" +#include "GX_g2.h" +#include "MI_memory.h" + +struct BrightnessData mainScreenBrightnessData; + +struct BrightnessData subScreenBrightnessData; + +THUMB_FUNC void DoBrightnessTransitionStep(struct BrightnessData *brightness) +{ + BOOL transitionFinished = FALSE; + + if (brightness->target_brightness != + brightness->current_brightness + + brightness->transition_direction * brightness->step_size_integer && + brightness->current_brightness != brightness->target_brightness) + { + brightness->current_brightness += + brightness->transition_direction * brightness->step_size_integer; + brightness->fractional_count += brightness->step_size_fractional; + + if (brightness->fractional_count >= brightness->step_count) + { + brightness->current_brightness += brightness->transition_direction; + if (brightness->current_brightness != brightness->target_brightness) + { + brightness->fractional_count -= brightness->step_count; + } + else + { + transitionFinished = TRUE; + } + } + } + else + { + brightness->current_brightness = brightness->target_brightness; + transitionFinished = TRUE; + } + + if ((brightness->screenMask & 1) != 0) + { + G2x_SetBlendBrightness_( + ®_G2_BLDCNT, brightness->surfaceMask, brightness->current_brightness); + } + else if ((brightness->screenMask & 2) != 0) + { + G2x_SetBlendBrightness_( + ®_G2S_DB_BLDCNT, brightness->surfaceMask, brightness->current_brightness); + } + + if (transitionFinished == TRUE) + { + brightness->transitionActive = FALSE; + } +} + +THUMB_FUNC void InitBrightnessTransition(struct BrightnessData *brightnessData, + u16 step_count, + s16 target_brightness, + s16 start_brightness, + fx32 surfaceMask, + u32 screenMask) +{ + GF_ASSERT(!brightnessData->transitionActive); + + brightnessData->transitionActive = TRUE; + brightnessData->surfaceMask = (u8)surfaceMask; + brightnessData->screenMask = (u8)screenMask; + brightnessData->step_count = step_count; + brightnessData->target_brightness = target_brightness; + brightnessData->current_brightness = start_brightness; + brightnessData->brightness_diff = (s16)(start_brightness - target_brightness); + + if (brightnessData->brightness_diff > 0) + { + brightnessData->transition_direction = -1; + } + else + { + brightnessData->transition_direction = 1; + brightnessData->brightness_diff *= -1; + } + + brightnessData->step_size_integer = (s16)(brightnessData->brightness_diff / step_count); + brightnessData->step_size_fractional = (u16)(brightnessData->brightness_diff % step_count); + brightnessData->fractional_count = 0; +} + +THUMB_FUNC void StartBrightnessTransition( + u16 step_count, s16 target_brightness, s16 start_brightness, fx32 surfaceMask, u32 screenMask) +{ + if (step_count != 0) + { + if ((screenMask & 1) != 0) + { + G2x_SetBlendBrightness_(®_G2_BLDCNT, surfaceMask, start_brightness); + InitBrightnessTransition(&mainScreenBrightnessData, + step_count, + target_brightness, + start_brightness, + surfaceMask, + 1); + } + + if ((screenMask & 2) != 0) + { + G2x_SetBlendBrightness_(®_G2S_DB_BLDCNT, surfaceMask, start_brightness); + InitBrightnessTransition(&subScreenBrightnessData, + step_count, + target_brightness, + start_brightness, + surfaceMask, + 2); + } + } +} + +THUMB_FUNC void SetBrightness(fx32 brightness, fx32 surfaceMask, u32 screenMask) +{ + + if ((screenMask & 1) != 0) + { + G2x_SetBlendBrightness_(®_G2_BLDCNT, surfaceMask, brightness); + } + + if ((screenMask & 2) != 0) + { + G2x_SetBlendBrightness_(®_G2S_DB_BLDCNT, surfaceMask, brightness); + } + + InitScreenBrightnessData(screenMask); +} + +THUMB_FUNC void InitAllScreenBrightnessData(void) +{ + MI_CpuFill8(&mainScreenBrightnessData, 0, sizeof(struct BrightnessData)); + MI_CpuFill8(&subScreenBrightnessData, 0, sizeof(struct BrightnessData)); + + mainScreenBrightnessData.transitionActive = FALSE; + subScreenBrightnessData.transitionActive = FALSE; +} + +THUMB_FUNC void InitScreenBrightnessData(u32 screenMask) +{ + if (screenMask & 1) + { + MI_CpuFill8(&mainScreenBrightnessData, 0, sizeof(struct BrightnessData)); + mainScreenBrightnessData.transitionActive = FALSE; + } + + if (screenMask & 2) + { + MI_CpuFill8(&subScreenBrightnessData, 0, sizeof(struct BrightnessData)); + subScreenBrightnessData.transitionActive = FALSE; + } +} + +THUMB_FUNC void DoAllScreenBrightnessTransitionStep(void) +{ + if (mainScreenBrightnessData.transitionActive) + { + DoBrightnessTransitionStep(&mainScreenBrightnessData); + } + + if (subScreenBrightnessData.transitionActive) + { + DoBrightnessTransitionStep(&subScreenBrightnessData); + } +} + +THUMB_FUNC BOOL IsBrightnessTransitionActive(u32 screenMask) +{ + if (screenMask == 3) + { + if (!mainScreenBrightnessData.transitionActive && !subScreenBrightnessData.transitionActive) + { + return TRUE; + } + } + else if (screenMask == 1) + { + if (!mainScreenBrightnessData.transitionActive) + { + return TRUE; + } + } + else if (screenMask == 2) + { + if (!subScreenBrightnessData.transitionActive) + { + return TRUE; + } + } + + return FALSE; +} diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 9a34fc75..4401d9b8 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -6,7 +6,7 @@ #include "msgdata.h" #include "msgdata/msg.naix" #include "text.h" -#include "unk_0200A104.h" +#include "brightness.h" extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); @@ -149,7 +149,7 @@ THUMB_FUNC void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code) GX_BothDispOn(); FUN_0200E394(PM_LCD_TOP); FUN_0200E394(PM_LCD_BOTTOM); - FUN_0200A274(0, 0x3F, 3); + SetBrightness(0, 0x3F, 3); RemoveWindow(&window); DestroyMsgData(error_message_data); diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index bf8ad0f1..93bc898d 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -6,7 +6,7 @@ #include "bg_window.h" #include "PAD_pad.h" #include "font.h" -#include "unk_0200A104.h" +#include "brightness.h" const struct WindowTemplate UNK_020FF49C = { @@ -124,7 +124,7 @@ THUMB_FUNC void PrintErrorMessageAndReset() GX_BothDispOn(); FUN_0200E394(0); FUN_0200E394(1); - FUN_0200A274(0, 0x3f, 3); + SetBrightness(0, 0x3f, 3); FUN_02032DAC(); while (1) diff --git a/arm9/src/main.c b/arm9/src/main.c index aa4da4bb..312d222c 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -18,7 +18,7 @@ #include "wfc_user_info_warning.h" #include "module_52.h" #include "font.h" -#include "unk_0200A104.h" +#include "brightness.h" FS_EXTERN_OVERLAY(MODULE_52); FS_EXTERN_OVERLAY(MODULE_63); @@ -96,7 +96,7 @@ THUMB_FUNC void NitroMain(void) gMain.unk6C = 1; gMain.unk30 = 0; InitializeMainRNG(); - FUN_0200A2AC(); + InitAllScreenBrightnessData(); FUN_02015E30(); UNK_02016FA4 = 0; for (;;) @@ -126,7 +126,7 @@ THUMB_FUNC void NitroMain(void) OS_WaitIrq(1, 1); gMain.unk2C++; gMain.unk30 = 0; - FUN_0200A318(); + DoAllScreenBrightnessTransitionStep(); FUN_0200E2D8(); if (gMain.vBlankIntr) gMain.vBlankIntr(gMain.vBlankIntrArg); diff --git a/arm9/src/oam.c b/arm9/src/oam.c new file mode 100644 index 00000000..ff3405d4 --- /dev/null +++ b/arm9/src/oam.c @@ -0,0 +1,169 @@ +#include "global.h" +#include "oam.h" +#include "GX_g2.h" +#include "MI_memory.h" +#include "heap.h" + +extern void FUN_020213A0(void); +extern void FUN_0202135C(void *param0, + u32 *param1, + u32 (*param2)(u32, u32), + u32 (*param3)(u32), + void (*param4)(void), + u32 param5, + u32 param6); +extern void FUN_020203CC(u32 heap_id); +extern void FUN_02020404(u32 heap_id); + +struct OamData *oamData; + +THUMB_FUNC void FUN_02009EAC(s32 param0, + s32 param1, + s32 param2, + s32 param3, + u32 param4, + u32 param5, + u32 param6, + u32 param7, + u32 param8) +{ + s32 r0; + if (param0 < 4) + { + r0 = 4; + if (param1 > 0x7c) + { + param1 = param1 - (4 - param0); + } + } + else + { + r0 = param0; + } + + s32 r2; + if (param2 < 1) + { + r2 = 1; + if (param3 > 0x1e) + { + param3 = param3 - (1 - param2); + } + } + else + { + r2 = param2; + } + + InitOamData(r0, param1, r2, param3, param4, param5, param6, param7, param8); +} + +THUMB_FUNC void InitOamData(s32 param0, + s32 param1, + s32 param2, + s32 param3, + u32 param4, + u32 param5, + u32 param6, + u32 param7, + u32 heap_id) +{ + GF_ASSERT(oamData == NULL); + oamData = AllocFromHeap(heap_id, sizeof(struct OamData)); + GF_ASSERT(oamData); + + oamData->heap_id = heap_id; + + GF_ASSERT(NNS_G2dGetNewOamManagerInstance( + &oamData->oamManagers[0], (u16)param0, (u16)param1, (u16)param2, (u16)param3, 0)); + GF_ASSERT(NNS_G2dGetNewOamManagerInstance( + &oamData->oamManagers[1], (u16)param4, (u16)param5, (u16)param6, (u16)param7, 1)); +} + +THUMB_FUNC void ApplyAndResetOamManagerBuffer(void) +{ + if (oamData != NULL) + { + NNS_G2dApplyAndResetOamManagerBuffer(&oamData->oamManagers[0]); + NNS_G2dApplyAndResetOamManagerBuffer(&oamData->oamManagers[1]); + } +} + +THUMB_FUNC void DeinitOamData(void) +{ + GF_ASSERT(oamData); + + FUN_0200A064(oamData->heap_id); + FUN_0200A06C(oamData->heap_id); + + FreeToHeap(oamData); + oamData = NULL; +} + +THUMB_FUNC void FUN_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3) +{ + GF_ASSERT(oamData); + + if (param2 == 1) + { + FUN_0202135C(param0, param1, EntryOamManagerOamWithAffineIdxMainScreen, EntryOamManagerAffineMainScreen, FUN_020213A0, param2, param3); + return; + } + + FUN_0202135C(param0, param1, EntryOamManagerOamWithAffineIdxSubScreen, EntryOamManagerAffineSubScreen, FUN_020213A0, param2, param3); +} + +THUMB_FUNC NNSG2dOamManager *GetOamManager(u32 screen) +{ + GF_ASSERT(oamData); + if (screen == 0) + { + return &oamData->oamManagers[0]; + } + else + { + return &oamData->oamManagers[1]; + } +} + +THUMB_FUNC void FUN_0200A064(u32 heap_id) +{ + FUN_020203CC(heap_id); +} + +THUMB_FUNC void FUN_0200A06C(u32 heap_id) +{ + FUN_02020404(heap_id); +} + +THUMB_FUNC u32 EntryOamManagerOamWithAffineIdxMainScreen(u32 param0, u32 param1) +{ + u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&oamData->oamManagers[0], param0, param1); + GF_ASSERT(res); + + return res; +} + +THUMB_FUNC u32 EntryOamManagerOamWithAffineIdxSubScreen(u32 param0, u32 param1) +{ + u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&oamData->oamManagers[1], param0, param1); + GF_ASSERT(res); + + return res; +} + +THUMB_FUNC u32 EntryOamManagerAffineMainScreen(u32 param0) +{ + u32 res = NNS_G2dEntryOamManagerAffine(&oamData->oamManagers[0], param0); + GF_ASSERT(res != 0xFFFE); + + return res; +} + +THUMB_FUNC u32 EntryOamManagerAffineSubScreen(u32 param0) +{ + u32 res = NNS_G2dEntryOamManagerAffine(&oamData->oamManagers[1], param0); + GF_ASSERT(res != 0xFFFE); + + return res; +} diff --git a/arm9/src/unk_02008AA4.c b/arm9/src/unk_02008AA4.c index 9a7dfc75..300967fc 100644 --- a/arm9/src/unk_02008AA4.c +++ b/arm9/src/unk_02008AA4.c @@ -4,7 +4,7 @@ #include "heap.h" #include "unk_0200BB14.h" #include "unk_02008DEC.h" -#include "unk_02009EAC.h" +#include "oam.h" extern void FUN_0202134C(void *, u32); extern u32 FUN_0201FCB0(u32 *); diff --git a/arm9/src/unk_02009EAC.c b/arm9/src/unk_02009EAC.c deleted file mode 100644 index b673eb1b..00000000 --- a/arm9/src/unk_02009EAC.c +++ /dev/null @@ -1,169 +0,0 @@ -#include "global.h" -#include "unk_02009EAC.h" -#include "GX_g2.h" -#include "MI_memory.h" -#include "heap.h" - -extern void FUN_020213A0(void); -extern void FUN_0202135C(void *param0, - u32 *param1, - u32 (*param2)(u32, u32), - u32 (*param3)(u32), - void (*param4)(void), - u32 param5, - u32 param6); -extern void FUN_020203CC(u32 heap_id); -extern void FUN_02020404(u32 heap_id); - -struct UnkStruct_02009EAC *UNK_021C4670; - -THUMB_FUNC void FUN_02009EAC(s32 param0, - s32 param1, - s32 param2, - s32 param3, - u32 param4, - u32 param5, - u32 param6, - u32 param7, - u32 param8) -{ - s32 r0; - if (param0 < 4) - { - r0 = 4; - if (param1 > 0x7c) - { - param1 = param1 - (4 - param0); - } - } - else - { - r0 = param0; - } - - s32 r2; - if (param2 < 1) - { - r2 = 1; - if (param3 > 0x1e) - { - param3 = param3 - (1 - param2); - } - } - else - { - r2 = param2; - } - - FUN_02009EF0(r0, param1, r2, param3, param4, param5, param6, param7, param8); -} - -THUMB_FUNC void FUN_02009EF0(s32 param0, - s32 param1, - s32 param2, - s32 param3, - u32 param4, - u32 param5, - u32 param6, - u32 param7, - u32 heap_id) -{ - GF_ASSERT(UNK_021C4670 == NULL); - UNK_021C4670 = AllocFromHeap(heap_id, sizeof(struct UnkStruct_02009EAC)); - GF_ASSERT(UNK_021C4670); - - UNK_021C4670->heap_id = heap_id; - - GF_ASSERT(NNS_G2dGetNewOamManagerInstance( - &UNK_021C4670->oamManagers[0], (u16)param0, (u16)param1, (u16)param2, (u16)param3, 0)); - GF_ASSERT(NNS_G2dGetNewOamManagerInstance( - &UNK_021C4670->oamManagers[1], (u16)param4, (u16)param5, (u16)param6, (u16)param7, 1)); -} - -THUMB_FUNC void FUN_02009F80(void) -{ - if (UNK_021C4670 != NULL) - { - NNS_G2dApplyAndResetOamManagerBuffer(&UNK_021C4670->oamManagers[0]); - NNS_G2dApplyAndResetOamManagerBuffer(&UNK_021C4670->oamManagers[1]); - } -} - -THUMB_FUNC void FUN_02009FA0(void) -{ - GF_ASSERT(UNK_021C4670); - - FUN_0200A064(UNK_021C4670->heap_id); - FUN_0200A06C(UNK_021C4670->heap_id); - - FreeToHeap(UNK_021C4670); - UNK_021C4670 = NULL; -} - -THUMB_FUNC void FUN_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3) -{ - GF_ASSERT(UNK_021C4670); - - if (param2 == 1) - { - FUN_0202135C(param0, param1, FUN_0200A074, FUN_0200A0B8, FUN_020213A0, param2, param3); - return; - } - - FUN_0202135C(param0, param1, FUN_0200A094, FUN_0200A0DC, FUN_020213A0, param2, param3); -} - -THUMB_FUNC NNSG2dOamManager *FUN_0200A03C(u32 param0) -{ - GF_ASSERT(UNK_021C4670); - if (param0 == 0) - { - return &UNK_021C4670->oamManagers[0]; - } - else - { - return &UNK_021C4670->oamManagers[1]; - } -} - -THUMB_FUNC void FUN_0200A064(u32 heap_id) -{ - FUN_020203CC(heap_id); -} - -THUMB_FUNC void FUN_0200A06C(u32 heap_id) -{ - FUN_02020404(heap_id); -} - -THUMB_FUNC u32 FUN_0200A074(u32 param0, u32 param1) -{ - u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&UNK_021C4670->oamManagers[0], param0, param1); - GF_ASSERT(res); - - return res; -} - -THUMB_FUNC u32 FUN_0200A094(u32 param0, u32 param1) -{ - u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&UNK_021C4670->oamManagers[1], param0, param1); - GF_ASSERT(res); - - return res; -} - -THUMB_FUNC u32 FUN_0200A0B8(u32 param0) -{ - u32 res = NNS_G2dEntryOamManagerAffine(&UNK_021C4670->oamManagers[0], param0); - GF_ASSERT(res != 0xFFFE); - - return res; -} - -THUMB_FUNC u32 FUN_0200A0DC(u32 param0) -{ - u32 res = NNS_G2dEntryOamManagerAffine(&UNK_021C4670->oamManagers[1], param0); - GF_ASSERT(res != 0xFFFE); - - return res; -} diff --git a/arm9/src/unk_0200A104.c b/arm9/src/unk_0200A104.c deleted file mode 100644 index 407ac34d..00000000 --- a/arm9/src/unk_0200A104.c +++ /dev/null @@ -1,178 +0,0 @@ -#include "global.h" -#include "unk_0200A104.h" -#include "GX_g2.h" -#include "MI_memory.h" - -struct UnkStruct_0200A104 UNK_021C4694; - -struct UnkStruct_0200A104 UNK_021C4674; - -THUMB_FUNC void FUN_0200A104(struct UnkStruct_0200A104 *param0) -{ - u32 r4 = 0; - - if (param0->unk0a != param0->unk1a + param0->unk10 * param0->unk14 && - param0->unk1a != param0->unk0a) - { - param0->unk1a += param0->unk10 * param0->unk14; - param0->unk18 += param0->unk16; - - if (param0->unk18 >= param0->unk08) - { - param0->unk1a += param0->unk10; - if (param0->unk1a != param0->unk0a) - { - param0->unk18 -= param0->unk08; - } - else - { - r4 = 1; - } - } - } - else - { - param0->unk1a = param0->unk0a; - r4 = 1; - } - - if ((param0->unk04 & 1) != 0) - { - G2x_SetBlendBrightness_(reg_addr_G2_BLDCNT, param0->unk00, param0->unk1a); - } - else if ((param0->unk04 & 2) != 0) - { - G2x_SetBlendBrightness_(reg_addr_G2S_DB_BLDCNT, param0->unk00, param0->unk1a); - } - - if (r4 == 1) - { - param0->unk1c = 0; - } -} - -THUMB_FUNC void FUN_0200A1A0( - struct UnkStruct_0200A104 *param0, u16 param1, s16 param2, s16 param3, fx32 param4, u32 param5) -{ - GF_ASSERT(param0->unk1c == 0); - - param0->unk1c = 1; - param0->unk00 = (u8)param4; - param0->unk04 = (u8)param5; - param0->unk08 = param1; - param0->unk0a = param2; - param0->unk1a = param3; - param0->unk12 = (s16)(param3 - param2); - - if (param0->unk12 > 0) - { - param0->unk10 = -1; - } - else - { - param0->unk10 = 1; - param0->unk12 *= -1; - } - - param0->unk14 = (s16)(param0->unk12 / param1); - param0->unk16 = (u16)(param0->unk12 % param1); - param0->unk18 = 0; -} - -THUMB_FUNC void FUN_0200A208(u16 param0, s16 param1, s16 param2, fx32 param3, u32 param4) -{ - if (param0 != 0) - { - if ((param4 & 1) != 0) - { - G2x_SetBlendBrightness_(reg_addr_G2_BLDCNT, param3, param2); - FUN_0200A1A0(&UNK_021C4694, param0, param1, param2, param3, 1); - } - - if ((param4 & 2) != 0) - { - G2x_SetBlendBrightness_(reg_addr_G2S_DB_BLDCNT, param3, param2); - FUN_0200A1A0(&UNK_021C4674, param0, param1, param2, param3, 2); - } - } -} - -THUMB_FUNC void FUN_0200A274(fx32 brightness, fx32 param1, u32 param2) -{ - - if ((param2 & 1) != 0) - { - G2x_SetBlendBrightness_(reg_addr_G2_BLDCNT, param1, brightness); - } - - if ((param2 & 2) != 0) - { - G2x_SetBlendBrightness_(reg_addr_G2S_DB_BLDCNT, param1, brightness); - } - - FUN_0200A2D8(param2); -} - -THUMB_FUNC void FUN_0200A2AC(void) -{ - MI_CpuFill8(&UNK_021C4694, 0, sizeof(struct UnkStruct_0200A104)); - MI_CpuFill8(&UNK_021C4674, 0, sizeof(struct UnkStruct_0200A104)); - - UNK_021C4694.unk1c = 0; - UNK_021C4674.unk1c = 0; -} - -THUMB_FUNC void FUN_0200A2D8(u32 param0) -{ - if (param0 & 1) - { - MI_CpuFill8(&UNK_021C4694, 0, sizeof(struct UnkStruct_0200A104)); - UNK_021C4694.unk1c = 0; - } - - if (param0 & 2) - { - MI_CpuFill8(&UNK_021C4674, 0, sizeof(struct UnkStruct_0200A104)); - UNK_021C4674.unk1c = 0; - } -} - -THUMB_FUNC void FUN_0200A318(void) -{ - if (UNK_021C4694.unk1c) - { - FUN_0200A104(&UNK_021C4694); - } - - if (UNK_021C4674.unk1c) - { - FUN_0200A104(&UNK_021C4674); - } -} - -THUMB_FUNC u32 FUN_0200A344(u32 param0) -{ - if (param0 == 3) - { - if (UNK_021C4694.unk1c == 0 && UNK_021C4674.unk1c == 0) - { - return 1; - } - } - else if (param0 == 1) - { - if (UNK_021C4694.unk1c == 0) - { - return 1; - } - } - else if (param0 == 2) - { - if (UNK_021C4674.unk1c == 0) - { - return 1; - } - } - - return 0; -} diff --git a/arm9/src/unk_0200BB14.c b/arm9/src/unk_0200BB14.c index d862ad2d..093d35c1 100644 --- a/arm9/src/unk_0200BB14.c +++ b/arm9/src/unk_0200BB14.c @@ -4,7 +4,7 @@ #include "heap.h" #include "unk_02008AA4.h" #include "unk_02008DEC.h" -#include "unk_02009EAC.h" +#include "oam.h" extern void FUN_0201D060(u32 *param0, u32 param1, u32 param2); extern void FUN_0201E00C(u32 param0, u32 param1); @@ -158,7 +158,7 @@ THUMB_FUNC void FUN_0200BC1C(u32 *param0) THUMB_FUNC void FUN_0200BC30() { - FUN_02009F80(); + ApplyAndResetOamManagerBuffer(); } THUMB_FUNC void FUN_0200BC38() @@ -205,7 +205,7 @@ THUMB_FUNC void FUN_0200BCB0(u32 *param0) if (param0[2] == 1) { - FUN_02009FA0(); + DeinitOamData(); } } diff --git a/arm9/src/wfc_user_info_warning.c b/arm9/src/wfc_user_info_warning.c index 4ba4166c..370cf314 100644 --- a/arm9/src/wfc_user_info_warning.c +++ b/arm9/src/wfc_user_info_warning.c @@ -10,7 +10,7 @@ #include "string16.h" #include "text.h" #include "wfc_user_info_warning.h" -#include "unk_0200A104.h" +#include "brightness.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); @@ -118,7 +118,7 @@ THUMB_FUNC void ShowWFCUserInfoWarning(u32 heap_id, u32 a1) GX_BothDispOn(); FUN_0200E394(0); FUN_0200E394(1); - FUN_0200A274(0, 0x3F, 3); + SetBrightness(0, 0x3F, 3); while (TRUE) { -- cgit v1.2.3 From f31aa875f127653e7e1fc81a3093b2d8f09aea8f Mon Sep 17 00:00:00 2001 From: tgsm Date: Fri, 20 Aug 2021 16:49:35 -0400 Subject: Decompile unk_02089D90 -> save_data_read_error --- arm9/src/main.c | 4 +- arm9/src/save.c | 6 +- arm9/src/save_data_read_error.c | 123 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 arm9/src/save_data_read_error.c (limited to 'arm9/src') diff --git a/arm9/src/main.c b/arm9/src/main.c index 312d222c..3b3b0dd6 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -11,6 +11,7 @@ #include "game_init.h" #include "poke_overlay.h" #include "player_data.h" +#include "save_data_read_error.h" #include "sound.h" #include "timer3.h" #include "unk_02031734.h" @@ -32,7 +33,6 @@ struct UnkStruct_02016FA8 UNK_02016FA8; extern void FUN_02022294(void); extern void GF_InitRTCWork(void); extern int FUN_020337E8(int); -extern void FUN_02089D90(int); extern void FUN_02015E30(void); extern void FUN_0201B5CC(void *); extern void GF_RTC_UpdateOnFrame(void); @@ -72,7 +72,7 @@ THUMB_FUNC void NitroMain(void) ShowWFCUserInfoWarning(3, 0); if (FUN_020227FC(UNK_02016FA8.unk18) == 0) { - FUN_02089D90(0); + ShowSaveDataReadError(0); } else { diff --git a/arm9/src/save.c b/arm9/src/save.c index 7eb523f6..9ddb7336 100644 --- a/arm9/src/save.c +++ b/arm9/src/save.c @@ -4,6 +4,7 @@ #include "heap.h" #include "CARD_backup.h" #include "OS_spinLock.h" +#include "save_data_read_error.h" #pragma thumb on @@ -13,9 +14,6 @@ extern void FUN_02016444(u8 mask); extern void FUN_02016454(u8 mask); -// unk_02089D90.s -extern void FUN_02089D90(int); - // unk_02089F24.s extern void FUN_0208A0B8(int, int); @@ -861,7 +859,7 @@ BOOL FlashLoadChunk(u32 src, void * dest, u32 size) if (!r5) { FreeToHeap(UNK_021C59C8.ptr); - FUN_02089D90(1); + ShowSaveDataReadError(1); } return r5; } diff --git a/arm9/src/save_data_read_error.c b/arm9/src/save_data_read_error.c new file mode 100644 index 00000000..708b3a3c --- /dev/null +++ b/arm9/src/save_data_read_error.c @@ -0,0 +1,123 @@ +#include "global.h" +#include "bg_window.h" +#include "brightness.h" +#include "game_init.h" +#include "msgdata.h" +#include "msgdata/msg.naix" +#include "save_data_read_error.h" +#include "text.h" + +extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); +extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); +extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); +extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); +extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); + +const struct WindowTemplate gSaveDataReadErrorWindowTemplate = { + .bgId = GF_BG_LYR_MAIN_0, + .tilemapLeft = 3, + .tilemapTop = 3, + .width = 26, + .height = 18, + .paletteNum = 0x01, + .baseTile = 0x23, +}; + +const struct GraphicsModes gSaveDataReadErrorGraphicsModes = { + .dispMode = GX_DISPMODE_GRAPHICS, + .bgMode = GX_BGMODE_0, + .subMode = GX_BGMODE_0, + ._2d3dMode = GX_BG0_AS_2D, +}; + +const struct BgTemplate gSaveDataReadErrorBgTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .size = GF_BG_SCR_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_16, + .screenBase = GX_BG_SCRBASE_0x0000, + .charBase = GX_BG_CHARBASE_0x18000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 1, + .areaOver = GX_BG_AREAOVER_XLU, + .unk17 = 0, + .mosaic = FALSE, +}; + +const struct GraphicsBanks gSaveDataReadErrorGraphicsBanks = { + .bg = 3, + .bgextpltt = 0, + .subbg = 0, + .subbgextpltt = 0, + .obj = 0, + .objextpltt = 0, + .subobj = 0, + .subobjextpltt = 0, + .tex = 0, + .texpltt = 0, +}; + +THUMB_FUNC void ShowSaveDataReadError(u32 heap_id) +{ + struct Window window; + + FUN_0200E3A0(PM_LCD_TOP, 0); + FUN_0200E3A0(PM_LCD_BOTTOM, 0); + + Main_SetVBlankIntrCB(NULL, NULL); + FUN_02015F34(NULL, NULL); + + GX_DisableEngineALayers(); + GX_DisableEngineBLayers(); + reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + + SetKeyRepeatTimers(4, 8); + + gMain.unk65 = 0; + + GX_SwapDisplay(); + reg_G2_BLDCNT = 0; + reg_G2S_DB_BLDCNT = 0; + reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK); + reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK); + GX_SetBanks(&gSaveDataReadErrorGraphicsBanks); + + struct BgConfig* bg_config = BgConfig_Alloc(heap_id); + + SetBothScreensModesAndDisable(&gSaveDataReadErrorGraphicsModes); + + InitBgFromTemplate(bg_config, 0, &gSaveDataReadErrorBgTemplate, 0); + BgClearTilemapBufferAndCommit(bg_config, 0); + FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id); + FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id); + BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id); + BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21); + BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21); + + struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0005_bin, heap_id); + struct String* str = String_ctor(384, heap_id); + + FUN_0201BD5C(); + + AddWindow(bg_config, &window, &gSaveDataReadErrorWindowTemplate); + FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); + FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + + ReadMsgDataIntoString(msg_data, 0, str); + AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); + String_dtor(str); + + GX_BothDispOn(); + FUN_0200E394(PM_LCD_TOP); + FUN_0200E394(PM_LCD_BOTTOM); + SetBrightness(0, 0x3F, 3); + + while (TRUE) + { + HandleDSLidAction(); + OS_WaitIrq(TRUE, OS_IE_V_BLANK); + } +} -- cgit v1.2.3 From 614fcf2c7cc60e71d0c4707df67a822c19cdc1b4 Mon Sep 17 00:00:00 2001 From: tgsm Date: Fri, 20 Aug 2021 17:27:56 -0400 Subject: Document gMain.unk65 -> gMain.screensFlipped --- arm9/src/GX_layers.c | 2 +- arm9/src/communication_error.c | 2 +- arm9/src/error_message_reset.c | 2 +- arm9/src/game_init.c | 2 +- arm9/src/save_data_read_error.c | 2 +- arm9/src/wfc_user_info_warning.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/GX_layers.c b/arm9/src/GX_layers.c index 28147dbd..348a398a 100644 --- a/arm9/src/GX_layers.c +++ b/arm9/src/GX_layers.c @@ -96,7 +96,7 @@ THUMB_FUNC void GX_BothDispOn() THUMB_FUNC void GX_SwapDisplay() { - if (gMain.unk65 == 0) + if (gMain.screensFlipped == 0) { GX_SetDispSelect(GX_DISP_SELECT_MAIN_SUB); } diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 4401d9b8..04058b83 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -107,7 +107,7 @@ THUMB_FUNC void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code) SetKeyRepeatTimers(4, 8); - gMain.unk65 = 0; + gMain.screensFlipped = 0; GX_SwapDisplay(); reg_G2_BLDCNT = 0; diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index 93bc898d..97bc7c70 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -85,7 +85,7 @@ THUMB_FUNC void PrintErrorMessageAndReset() SetKeyRepeatTimers(4, 8); - gMain.unk65 = 0; + gMain.screensFlipped = 0; GX_SwapDisplay(); G2_BlendNone(); diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c index 44dcc111..705ffbc9 100644 --- a/arm9/src/game_init.c +++ b/arm9/src/game_init.c @@ -163,7 +163,7 @@ void InitSystemForTheGame(void) gMain.unk10 = 0; gMain.unk14 = 0; gMain.unk2C = 0; - gMain.unk65 = 0; + gMain.screensFlipped = 0; } void InitGraphicMemory(void) diff --git a/arm9/src/save_data_read_error.c b/arm9/src/save_data_read_error.c index 708b3a3c..f3778435 100644 --- a/arm9/src/save_data_read_error.c +++ b/arm9/src/save_data_read_error.c @@ -76,7 +76,7 @@ THUMB_FUNC void ShowSaveDataReadError(u32 heap_id) SetKeyRepeatTimers(4, 8); - gMain.unk65 = 0; + gMain.screensFlipped = 0; GX_SwapDisplay(); reg_G2_BLDCNT = 0; diff --git a/arm9/src/wfc_user_info_warning.c b/arm9/src/wfc_user_info_warning.c index 370cf314..da547f3d 100644 --- a/arm9/src/wfc_user_info_warning.c +++ b/arm9/src/wfc_user_info_warning.c @@ -83,7 +83,7 @@ THUMB_FUNC void ShowWFCUserInfoWarning(u32 heap_id, u32 a1) SetKeyRepeatTimers(4, 8); - gMain.unk65 = 0; + gMain.screensFlipped = 0; GX_SwapDisplay(); reg_G2_BLDCNT = 0; -- cgit v1.2.3 From a09a13e2b35e6ca07ab623464189b8bf602a66a8 Mon Sep 17 00:00:00 2001 From: tgsm Date: Fri, 20 Aug 2021 21:31:50 -0400 Subject: Decompile unk_02089F24 -> save_data_write_error --- arm9/src/save.c | 8 +- arm9/src/save_data_write_error.c | 199 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+), 5 deletions(-) create mode 100644 arm9/src/save_data_write_error.c (limited to 'arm9/src') diff --git a/arm9/src/save.c b/arm9/src/save.c index 9ddb7336..524edfb7 100644 --- a/arm9/src/save.c +++ b/arm9/src/save.c @@ -5,6 +5,7 @@ #include "CARD_backup.h" #include "OS_spinLock.h" #include "save_data_read_error.h" +#include "save_data_write_error.h" #pragma thumb on @@ -14,9 +15,6 @@ extern void FUN_02016444(u8 mask); extern void FUN_02016454(u8 mask); -// unk_02089F24.s -extern void FUN_0208A0B8(int, int); - struct { struct SaveBlock2 * ptr; BOOL iswritten; @@ -908,10 +906,10 @@ BOOL WaitFlashWrite(int lock, BOOL * res) return FALSE; } -void SaveErrorHandling(int lock, int errno) +void SaveErrorHandling(int lock, u32 errno) { CARD_UnlockBackup((u16)lock); OS_ReleaseLockID((u16)lock); FreeToHeap(UNK_021C59C8.ptr); - FUN_0208A0B8(1, errno); + ShowSaveDataWriteError(1, errno); } diff --git a/arm9/src/save_data_write_error.c b/arm9/src/save_data_write_error.c new file mode 100644 index 00000000..f2270b52 --- /dev/null +++ b/arm9/src/save_data_write_error.c @@ -0,0 +1,199 @@ +#include "global.h" +#include "bg_window.h" +#include "brightness.h" +#include "game_init.h" +#include "msgdata.h" +#include "msgdata/msg.naix" +#include "save_data_write_error.h" +#include "text.h" + +extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); +extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); +extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); +extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); +extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); + +extern const struct WindowTemplate gSaveDataReadErrorWindowTemplate; +extern const struct GraphicsModes gSaveDataReadErrorGraphicsModes; +extern const struct BgTemplate gSaveDataReadErrorBgTemplate; +extern const struct GraphicsBanks gSaveDataReadErrorGraphicsBanks; + +static const struct WindowTemplate sSaveDataWriteErrorWindowTemplate = { + .bgId = GF_BG_LYR_MAIN_0, + .tilemapLeft = 3, + .tilemapTop = 3, + .width = 26, + .height = 18, + .paletteNum = 0x01, + .baseTile = 0x23, +}; + +static const struct GraphicsModes sSaveDataWriteErrorGraphicsModes = { + .dispMode = GX_DISPMODE_GRAPHICS, + .bgMode = GX_BGMODE_0, + .subMode = GX_BGMODE_0, + ._2d3dMode = GX_BG0_AS_2D, +}; + +static const struct BgTemplate sSaveDataWriteErrorBgTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .size = GF_BG_SCR_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_16, + .screenBase = GX_BG_SCRBASE_0x0000, + .charBase = GX_BG_CHARBASE_0x18000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 1, + .areaOver = GX_BG_AREAOVER_XLU, + .unk17 = 0, + .mosaic = FALSE, +}; + +static const struct GraphicsBanks sSaveDataWriteErrorGraphicsBanks = { + .bg = 3, + .bgextpltt = 0, + .subbg = 0, + .subbgextpltt = 0, + .obj = 0, + .objextpltt = 0, + .subobj = 0, + .subobjextpltt = 0, + .tex = 0, + .texpltt = 0, +}; + +THUMB_FUNC void ShowGBACartRemovedError(u32 heap_id) +{ + struct Window window; + + FUN_0200E3A0(PM_LCD_TOP, 0); + FUN_0200E3A0(PM_LCD_BOTTOM, 0); + + Main_SetVBlankIntrCB(NULL, NULL); + FUN_02015F34(NULL, NULL); + + GX_DisableEngineALayers(); + GX_DisableEngineBLayers(); + reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + + SetKeyRepeatTimers(4, 8); + + gMain.screensFlipped = 0; + + GX_SwapDisplay(); + reg_G2_BLDCNT = 0; + reg_G2S_DB_BLDCNT = 0; + reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK); + reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK); + GX_SetBanks(&gSaveDataReadErrorGraphicsBanks); + + struct BgConfig* bg_config = BgConfig_Alloc(heap_id); + + SetBothScreensModesAndDisable(&gSaveDataReadErrorGraphicsModes); + + InitBgFromTemplate(bg_config, 0, &gSaveDataReadErrorBgTemplate, 0); + BgClearTilemapBufferAndCommit(bg_config, 0); + FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id); + FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id); + BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id); + BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21); + BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21); + + struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0005_bin, heap_id); + struct String* str = String_ctor(384, heap_id); + + FUN_0201BD5C(); + + AddWindow(bg_config, &window, &gSaveDataReadErrorWindowTemplate); + FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); + FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + + ReadMsgDataIntoString(msg_data, 1, str); + AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); + String_dtor(str); + + GX_BothDispOn(); + FUN_0200E394(PM_LCD_TOP); + FUN_0200E394(PM_LCD_BOTTOM); + SetBrightness(0, 0x3F, 3); + + while (TRUE) + { + HandleDSLidAction(); + OS_WaitIrq(TRUE, OS_IE_V_BLANK); + } +} + +THUMB_FUNC void ShowSaveDataWriteError(u32 heap_id, u32 err_no) +{ + struct Window window; + + u32 msg_no; + if (err_no == 0) { + msg_no = 1; + } else { + msg_no = 0; + } + + FUN_0200E3A0(PM_LCD_TOP, 0); + FUN_0200E3A0(PM_LCD_BOTTOM, 0); + + FUN_02015EF4(); + Main_SetVBlankIntrCB(NULL, NULL); + FUN_02015F34(NULL, NULL); + + GX_DisableEngineALayers(); + GX_DisableEngineBLayers(); + reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + + SetKeyRepeatTimers(4, 8); + + gMain.screensFlipped = 0; + + GX_SwapDisplay(); + reg_G2_BLDCNT = 0; + reg_G2S_DB_BLDCNT = 0; + reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK); + reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK); + GX_SetBanks(&sSaveDataWriteErrorGraphicsBanks); + + struct BgConfig* bg_config = BgConfig_Alloc(heap_id); + + SetBothScreensModesAndDisable(&sSaveDataWriteErrorGraphicsModes); + + InitBgFromTemplate(bg_config, 0, &sSaveDataWriteErrorBgTemplate, 0); + BgClearTilemapBufferAndCommit(bg_config, 0); + FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id); + FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id); + BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id); + BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21); + BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21); + + struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0006_bin, heap_id); + struct String* str = String_ctor(384, heap_id); + + FUN_0201BD5C(); + + AddWindow(bg_config, &window, &sSaveDataWriteErrorWindowTemplate); + FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); + FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + + ReadMsgDataIntoString(msg_data, msg_no, str); + AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); + String_dtor(str); + + GX_BothDispOn(); + FUN_0200E394(PM_LCD_TOP); + FUN_0200E394(PM_LCD_BOTTOM); + SetBrightness(0, 0x3F, 3); + + while (TRUE) + { + HandleDSLidAction(); + OS_WaitIrq(TRUE, OS_IE_V_BLANK); + } +} -- cgit v1.2.3 From 0d600f46805de96895678bb76d7c3e87466f459f Mon Sep 17 00:00:00 2001 From: tgsm Date: Fri, 20 Aug 2021 21:41:10 -0400 Subject: Move ShowGBACartRemovedError to save_data_read_error --- arm9/src/save_data_read_error.c | 79 ++++++++++++++++++++++++++++++++++++---- arm9/src/save_data_write_error.c | 68 ---------------------------------- 2 files changed, 71 insertions(+), 76 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/save_data_read_error.c b/arm9/src/save_data_read_error.c index f3778435..9524475c 100644 --- a/arm9/src/save_data_read_error.c +++ b/arm9/src/save_data_read_error.c @@ -13,7 +13,7 @@ extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_valu extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); -const struct WindowTemplate gSaveDataReadErrorWindowTemplate = { +static const struct WindowTemplate sSaveDataReadErrorWindowTemplate = { .bgId = GF_BG_LYR_MAIN_0, .tilemapLeft = 3, .tilemapTop = 3, @@ -23,14 +23,14 @@ const struct WindowTemplate gSaveDataReadErrorWindowTemplate = { .baseTile = 0x23, }; -const struct GraphicsModes gSaveDataReadErrorGraphicsModes = { +static const struct GraphicsModes sSaveDataReadErrorGraphicsModes = { .dispMode = GX_DISPMODE_GRAPHICS, .bgMode = GX_BGMODE_0, .subMode = GX_BGMODE_0, ._2d3dMode = GX_BG0_AS_2D, }; -const struct BgTemplate gSaveDataReadErrorBgTemplate = { +static const struct BgTemplate sSaveDataReadErrorBgTemplate = { .x = 0, .y = 0, .bufferSize = 0x800, @@ -46,7 +46,7 @@ const struct BgTemplate gSaveDataReadErrorBgTemplate = { .mosaic = FALSE, }; -const struct GraphicsBanks gSaveDataReadErrorGraphicsBanks = { +static const struct GraphicsBanks sSaveDataReadErrorGraphicsBanks = { .bg = 3, .bgextpltt = 0, .subbg = 0, @@ -83,13 +83,13 @@ THUMB_FUNC void ShowSaveDataReadError(u32 heap_id) reg_G2S_DB_BLDCNT = 0; reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK); reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK); - GX_SetBanks(&gSaveDataReadErrorGraphicsBanks); + GX_SetBanks(&sSaveDataReadErrorGraphicsBanks); struct BgConfig* bg_config = BgConfig_Alloc(heap_id); - SetBothScreensModesAndDisable(&gSaveDataReadErrorGraphicsModes); + SetBothScreensModesAndDisable(&sSaveDataReadErrorGraphicsModes); - InitBgFromTemplate(bg_config, 0, &gSaveDataReadErrorBgTemplate, 0); + InitBgFromTemplate(bg_config, 0, &sSaveDataReadErrorBgTemplate, 0); BgClearTilemapBufferAndCommit(bg_config, 0); FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id); FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id); @@ -102,7 +102,7 @@ THUMB_FUNC void ShowSaveDataReadError(u32 heap_id) FUN_0201BD5C(); - AddWindow(bg_config, &window, &gSaveDataReadErrorWindowTemplate); + AddWindow(bg_config, &window, &sSaveDataReadErrorWindowTemplate); FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); FUN_0200CCA4(&window, FALSE, 0x01F7, 2); @@ -121,3 +121,66 @@ THUMB_FUNC void ShowSaveDataReadError(u32 heap_id) OS_WaitIrq(TRUE, OS_IE_V_BLANK); } } + +THUMB_FUNC void ShowGBACartRemovedError(u32 heap_id) +{ + struct Window window; + + FUN_0200E3A0(PM_LCD_TOP, 0); + FUN_0200E3A0(PM_LCD_BOTTOM, 0); + + Main_SetVBlankIntrCB(NULL, NULL); + FUN_02015F34(NULL, NULL); + + GX_DisableEngineALayers(); + GX_DisableEngineBLayers(); + reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + + SetKeyRepeatTimers(4, 8); + + gMain.screensFlipped = 0; + + GX_SwapDisplay(); + reg_G2_BLDCNT = 0; + reg_G2S_DB_BLDCNT = 0; + reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK); + reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK); + GX_SetBanks(&sSaveDataReadErrorGraphicsBanks); + + struct BgConfig* bg_config = BgConfig_Alloc(heap_id); + + SetBothScreensModesAndDisable(&sSaveDataReadErrorGraphicsModes); + + InitBgFromTemplate(bg_config, 0, &sSaveDataReadErrorBgTemplate, 0); + BgClearTilemapBufferAndCommit(bg_config, 0); + FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id); + FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id); + BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id); + BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21); + BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21); + + struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0005_bin, heap_id); + struct String* str = String_ctor(384, heap_id); + + FUN_0201BD5C(); + + AddWindow(bg_config, &window, &sSaveDataReadErrorWindowTemplate); + FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); + FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + + ReadMsgDataIntoString(msg_data, 1, str); + AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); + String_dtor(str); + + GX_BothDispOn(); + FUN_0200E394(PM_LCD_TOP); + FUN_0200E394(PM_LCD_BOTTOM); + SetBrightness(0, 0x3F, 3); + + while (TRUE) + { + HandleDSLidAction(); + OS_WaitIrq(TRUE, OS_IE_V_BLANK); + } +} diff --git a/arm9/src/save_data_write_error.c b/arm9/src/save_data_write_error.c index f2270b52..71edb91d 100644 --- a/arm9/src/save_data_write_error.c +++ b/arm9/src/save_data_write_error.c @@ -13,11 +13,6 @@ extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_valu extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); -extern const struct WindowTemplate gSaveDataReadErrorWindowTemplate; -extern const struct GraphicsModes gSaveDataReadErrorGraphicsModes; -extern const struct BgTemplate gSaveDataReadErrorBgTemplate; -extern const struct GraphicsBanks gSaveDataReadErrorGraphicsBanks; - static const struct WindowTemplate sSaveDataWriteErrorWindowTemplate = { .bgId = GF_BG_LYR_MAIN_0, .tilemapLeft = 3, @@ -64,69 +59,6 @@ static const struct GraphicsBanks sSaveDataWriteErrorGraphicsBanks = { .texpltt = 0, }; -THUMB_FUNC void ShowGBACartRemovedError(u32 heap_id) -{ - struct Window window; - - FUN_0200E3A0(PM_LCD_TOP, 0); - FUN_0200E3A0(PM_LCD_BOTTOM, 0); - - Main_SetVBlankIntrCB(NULL, NULL); - FUN_02015F34(NULL, NULL); - - GX_DisableEngineALayers(); - GX_DisableEngineBLayers(); - reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; - reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; - - SetKeyRepeatTimers(4, 8); - - gMain.screensFlipped = 0; - - GX_SwapDisplay(); - reg_G2_BLDCNT = 0; - reg_G2S_DB_BLDCNT = 0; - reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK); - reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK); - GX_SetBanks(&gSaveDataReadErrorGraphicsBanks); - - struct BgConfig* bg_config = BgConfig_Alloc(heap_id); - - SetBothScreensModesAndDisable(&gSaveDataReadErrorGraphicsModes); - - InitBgFromTemplate(bg_config, 0, &gSaveDataReadErrorBgTemplate, 0); - BgClearTilemapBufferAndCommit(bg_config, 0); - FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id); - FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id); - BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id); - BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21); - BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21); - - struct MsgData* msg_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0005_bin, heap_id); - struct String* str = String_ctor(384, heap_id); - - FUN_0201BD5C(); - - AddWindow(bg_config, &window, &gSaveDataReadErrorWindowTemplate); - FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); - FUN_0200CCA4(&window, FALSE, 0x01F7, 2); - - ReadMsgDataIntoString(msg_data, 1, str); - AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); - String_dtor(str); - - GX_BothDispOn(); - FUN_0200E394(PM_LCD_TOP); - FUN_0200E394(PM_LCD_BOTTOM); - SetBrightness(0, 0x3F, 3); - - while (TRUE) - { - HandleDSLidAction(); - OS_WaitIrq(TRUE, OS_IE_V_BLANK); - } -} - THUMB_FUNC void ShowSaveDataWriteError(u32 heap_id, u32 err_no) { struct Window window; -- cgit v1.2.3 From d7426e1f1c75846151eea1828bc2ab069c5a072e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sun, 22 Aug 2021 01:21:52 +0200 Subject: decompile unk_0200CABC.s --- arm9/src/bg_window.c | 2 +- arm9/src/unk_0200CABC.c | 1082 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1083 insertions(+), 1 deletion(-) create mode 100644 arm9/src/unk_0200CABC.c (limited to 'arm9/src') diff --git a/arm9/src/bg_window.c b/arm9/src/bg_window.c index 2986645f..f1a5e525 100644 --- a/arm9/src/bg_window.c +++ b/arm9/src/bg_window.c @@ -1366,7 +1366,7 @@ THUMB_FUNC void CopyBgTilemapRectAffine(struct Bg *bg, } THUMB_FUNC void FillBgTilemapRect(struct BgConfig *bgConfig, - u32 bgId, + u8 bgId, u16 fillValue, u8 x, u8 y, diff --git a/arm9/src/unk_0200CABC.c b/arm9/src/unk_0200CABC.c new file mode 100644 index 00000000..17f646f9 --- /dev/null +++ b/arm9/src/unk_0200CABC.c @@ -0,0 +1,1082 @@ +#include "global.h" +#include "unk_0200CABC.h" +#include "filesystem.h" +#include "gf_gfx_loader.h" +#include "graphic/field_board.naix" +#include "graphic/winframe.naix" +#include "pokemon.h" +#include "render_text.h" +#include "unk_020061E8.h" +#include "unk_0200BB14.h" +#include "unk_0200CA44.h" + +const struct UnkStruct_0200CABC_3 UNK_020ECE88 = { + 10, + 0, + 10, + 10, +}; + +const struct UnkStruct_0200CABC_3 UNK_020ECE98 = { + 0, + 0, + 10, + 10, +}; + +extern void FUN_02020130(u32 param0, u32 param1); +extern u32 FUN_0202022C(u32 param0); +extern void FUN_020201E4(u32 param0, u32 param1); +extern void FUN_0201FDEC(u32 param0); +extern void MOD05_021D99F8(struct UnkStruct_0200CABC_2 *param0); +extern void FUN_0200E188(struct UnkStruct_0200CABC_2 *param0); +extern void *FUN_0201B6C8(BOOL); +extern void MOD05_021D959C( + struct UnkStruct_0200CABC_2 *param0, void *param1, u32 param2, u32 param3); +extern void MOD05_021D967C(struct UnkStruct_0200CABC_2 *param0, + NarcId narcId, + s32 memberId, + u32 param3, + u32 param4, + u32 param5, + u32 param6); +extern void MOD05_021D96F4( + struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4); +extern void MOD05_021D9708( + struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4); +extern void MOD05_021D971C(struct UnkStruct_0200CABC_2 *param0, + NarcId narcId, + s32 memberId, + u32 param3, + u32 param4, + u32 param5); +extern u32 *MOD05_021D9820(struct UnkStruct_0200CABC_2 *param0, void *); +extern struct UnkStruct63_021DB450 *FUN_02006D98(u32); +extern void FUN_020072E8(struct UnkStruct63_021DB450 *param0); +extern void FUN_02012400(u16, u16, u16, void *, void *); +extern u32 NNS_G2dGetImageLocation(u32, u32); +extern void *FUN_02012470(u16, u16, u16); +extern u32 NNS_G2dGetImagePaletteLocation(u32, u32); + +THUMB_FUNC u32 FUN_0200CABC( + struct BgConfig *bgConfig, u32 layer, u32 numTiles, u32 param3, u32 heap_id) +{ + if (param3 == 0) + { + return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME, + NARC_winframe_narc_0000_NCGR, + bgConfig, + layer, + numTiles, + 0, + FALSE, + heap_id); + } + + return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME, + NARC_winframe_narc_0001_NCGR, + bgConfig, + layer, + numTiles, + 0, + FALSE, + heap_id); +} + +THUMB_FUNC u32 FUN_0200CAFC(void) +{ + return 24; +} + +THUMB_FUNC void FUN_0200CB00( + struct BgConfig *bg_config, u32 layer, u32 num_tiles, u32 param3, u8 param4, u32 heap_id) +{ + s32 r1; + if (param4 != 0) + { + r1 = NARC_winframe_narc_0001_NCGR; + } + else + { + r1 = NARC_winframe_narc_0000_NCGR; + } + + GfGfxLoader_LoadCharData( + NARC_GRAPHIC_WINFRAME, r1, bg_config, layer, num_tiles, 0, FALSE, heap_id); + + if (param4 == 2) + { + r1 = NARC_winframe_narc_0045_NCLR; + } + else + { + r1 = NARC_winframe_narc_0024_NCLR; + } + + if (layer < 4) + { + GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 0, param3 << 5, 32, heap_id); + return; + } + + GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 4, param3 << 5, 32, heap_id); +} + +THUMB_FUNC void FUN_0200CB6C(struct BgConfig *bgConfig, + u8 bgId, + u8 param2, + u8 param3, + u8 param4, + u8 param5, + u8 param6, + u16 param7) +{ + FillBgTilemapRect(bgConfig, bgId, param7, (u8)(param2 - 1), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 1), param2, (u8)(param3 - 1), param4, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 2), (u8)(param2 + param4), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 3), (u8)(param2 - 1), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 5), (u8)(param2 + param4), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 6), (u8)(param2 - 1), (u8)(param3 + param5), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 7), param2, (u8)(param3 + param5), param4, 1, param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 8), + (u8)(param2 + param4), + (u8)(param3 + param5), + 1, + 1, + param6); +} + +THUMB_FUNC void FUN_0200CCA4( + struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) +{ + FUN_0200CB6C(window->bgConfig, + GetWindowBgId(window), + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + palette_num, + fill_value); + + if (!copy_to_vram) + { + CopyWindowToVram(window); + } +} + +THUMB_FUNC void FUN_0200CCF8(struct Window *window, BOOL copy_to_vram) +{ + + FillBgTilemapRect(window->bgConfig, + GetWindowBgId(window), + 0, + (u8)(GetWindowX(window) - 1), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 2), + (u8)(GetWindowHeight(window) + 2), + 0); + + if (!copy_to_vram) + { + ClearWindowTilemapAndCopyToVram(window); + } +} + +THUMB_FUNC s32 FUN_0200CD60(s32 param0) +{ + return param0 + 2; +} + +THUMB_FUNC s32 FUN_0200CD64(s32 param0) +{ + return param0 + 25; +} + +THUMB_FUNC void FUN_0200CD68( + struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5) +{ + + GfGfxLoader_LoadCharData( + NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), param0, param1, param2, 0, FALSE, param5); + + if (param1 < 4) + { + GfGfxLoader_GXLoadPal( + NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 0, param3 << 5, 32, param5); + return; + } + + GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 4, param3 << 5, 32, param5); +} + +THUMB_FUNC void FUN_0200CDD8(struct BgConfig *bgConfig, + u8 bgId, + u8 param2, + u8 param3, + u8 param4, + u8 param5, + u8 param6, + u16 param7) +{ + FillBgTilemapRect(bgConfig, bgId, param7, (u8)(param2 - 2), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 1), (u8)(param2 - 1), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 2), param2, (u8)(param3 - 1), param4, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 3), (u8)(param2 + param4), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 4), + (u8)(param2 + param4 + 1), + (u8)(param3 - 1), + 1, + 1, + param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 5), + (u8)(param2 + param4 + 2), + (u8)(param3 - 1), + 1, + 1, + param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 6), (u8)(param2 - 2), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 7), (u8)(param2 - 1), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 9), (u8)(param2 + param4), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 10), (u8)(param2 + param4 + 1), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 11), (u8)(param2 + param4 + 2), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 12), (u8)(param2 - 2), (u8)(param3 + param5), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 13), (u8)(param2 - 1), (u8)(param3 + param5), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 14), param2, (u8)(param3 + param5), param4, 1, param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 15), + (u8)(param2 + param4), + (u8)(param3 + param5), + 1, + 1, + param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 16), + (u8)(param2 + param4 + 1), + (u8)(param3 + param5), + 1, + 1, + param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 17), + (u8)(param2 + param4 + 2), + (u8)(param3 + param5), + 1, + 1, + param6); +} + +THUMB_FUNC void FUN_0200D06C(struct Window *window, u32 fill_value, u32 palette_num) +{ + FUN_0200CDD8(window->bgConfig, + GetWindowBgId(window), + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + (u8)palette_num, + (u16)fill_value); +} + +THUMB_FUNC void FUN_0200D0BC( + struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) +{ + FUN_0200D06C(window, fill_value, palette_num); + if (!copy_to_vram) + { + CopyWindowToVram(window); + } + + FUN_0200D18C(window, fill_value); +} + +THUMB_FUNC void FUN_0200D0E0(struct Window *window, BOOL param1) +{ + FillBgTilemapRect(window->bgConfig, + GetWindowBgId(window), + 0, + (u8)(GetWindowX(window) - 2), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 5), + (u8)(GetWindowHeight(window) + 2), + 0); + + if (!param1) + { + ClearWindowTilemapAndCopyToVram(window); + } +} + +THUMB_FUNC void FUN_0200D148(u8 *param0, + u16 param1, + u16 param2, + u16 param3, + u16 param4, + u8 *param5, + u16 param6, + u16 param7, + u16 param8, + u16 param9, + u16 param10, + u16 param11) +{ + struct Bitmap src; + src.pixels = param0; + src.width = param3; + src.height = param4; + + struct Bitmap dst; + dst.pixels = param5; + dst.width = param6; + dst.height = param7; + + BlitBitmapRect4Bit(&src, &dst, param1, param2, param8, param9, param10, param11, 0); +} + +THUMB_FUNC void FUN_0200D18C(struct Window *window, u16 fill_value) +{ + u32 heap_id = BgConfig_GetHeapId(window->bgConfig); + u8 bg_id = GetWindowBgId(window); + + void *ptr = AllocFromHeap(heap_id, 0x180); + void *charptr = BgGetCharPtr(bg_id); + + NNSG2dCharacterData *pCharData; + void *st30; + void *st2c; + st2c = GfGfxLoader_GetCharData( + NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0022_NCGR, FALSE, &pCharData, heap_id); + st30 = pCharData->pRawData; + + for (u8 i = 0; i < 3; i++) + { + memcpy(ptr + (i << 7), charptr + ((fill_value + 10) << 5), 0x20); + memcpy(ptr + ((i << 7) + 0x20), charptr + ((fill_value + 11) << 5), 0x20); + memcpy(ptr + ((i << 7) + 0x40), charptr + ((fill_value + 10) << 5), 0x20); + memcpy(ptr + ((i << 7) + 0x60), charptr + ((fill_value + 11) << 5), 0x20); + } + + FUN_0200D148(st30, 4, 0, 12, 0x30, ptr, 12, 0x30, 1, 0, 12, 0x30); + BG_LoadCharTilesData(window->bgConfig, bg_id, ptr, 0x180, (u32)(fill_value + 18)); + FUN_02002840(fill_value); + FreeToHeap(st2c); + FreeToHeap(ptr); +} + +THUMB_FUNC void FUN_0200D274( + struct BgConfig *bg_config, u8 bg_id, u16 param2, u8 param3, u8 param4, u32 heap_id) +{ + + NNSG2dCharacterData *pCharData; + void *stc = GfGfxLoader_GetCharData( + NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), FALSE, &pCharData, heap_id); + u8 *ptr = AllocFromHeap(heap_id, 0x240); + memcpy(ptr, pCharData->pRawData, 0x240); + + for (u32 r3 = 0; r3 < 0x240; r3++) + { + u8 r6 = (u8)(ptr[r3] >> 4); + u8 r2 = (u8)(ptr[r3] & 0xf); + if (r6 == 0) + { + r6 = param3; + } + if (r2 == 0) + { + r2 = param3; + } + + ptr[r3] = (u8)(r2 | (r6 << 4)); + } + + BG_LoadCharTilesData(bg_config, bg_id, (u32 *)ptr, 0x240, param2); + FreeToHeap(stc); + FreeToHeap(ptr); +} + +THUMB_FUNC void FUN_0200D300(struct BgConfig *bg_config, + u8 bg_id, + u16 numtiles, + u8 param3, + u8 param4, + u16 param5, + u32 heap_id) +{ + GfGfxLoader_LoadCharData(NARC_GRAPHIC_FIELD_BOARD, + NARC_field_board_narc_0000_NCGR, + bg_config, + bg_id, + numtiles, + 0x3C0, + FALSE, + heap_id); + + NNSG2dPaletteData *pPltData; + void *st14; + st14 = AllocAndReadWholeNarcMemberByIdPair( + NARC_GRAPHIC_FIELD_BOARD, NARC_field_board_narc_0001_NCLR, heap_id); + NNS_G2dGetUnpackedPaletteData(st14, &pPltData); + BG_LoadPlttData(bg_id, pPltData->pRawData + param4 * 0x20, 0x20, (u16)(param3 << 5)); + FreeToHeapExplicit(heap_id, st14); + + if (param4 <= 1) + { + FUN_0200D378(bg_config, bg_id, (u16)(numtiles + 30), param4, param5, heap_id); + } +} + +THUMB_FUNC void FUN_0200D378( + struct BgConfig *bg_config, u8 bg_id, u16 numtiles, u8 param3, u16 param4, u32 heap_id) +{ + if (param3 == 0) + { + param4 += 33; + } + else + { + param4 += 2; + } + + GfGfxLoader_LoadCharData( + NARC_GRAPHIC_FIELD_BOARD, param4, bg_config, bg_id, numtiles, 0x300, FALSE, heap_id); +} + +THUMB_FUNC void FUN_0200D3B0(struct BgConfig *bgConfig, + u8 bgId, + u8 param2, + u8 param3, + u8 param4, + u8 param5, + u8 param6, + u16 param7) +{ + FillBgTilemapRect(bgConfig, bgId, param7, (u8)(param2 - 9), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 1), (u8)(param2 - 8), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 2), + (u8)(param2 - 7), + (u8)(param3 - 1), + (u8)(param4 + 7), + 1, + param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 3), (u8)(param2 + param4), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 4), + (u8)(param2 + param4 + 1), + (u8)(param3 - 1), + 1, + 1, + param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 5), + (u8)(param2 + param4 + 2), + (u8)(param3 - 1), + 1, + 1, + param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 6), (u8)(param2 - 9), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 7), (u8)(param2 - 8), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 8), (u8)(param2 - 1), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 9), (u8)(param2 + param4), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 10), (u8)(param2 + param4 + 1), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 11), (u8)(param2 + param4 + 2), param3, 1, param5, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 12), (u8)(param2 - 9), (u8)(param3 + param5), 1, 1, param6); + FillBgTilemapRect( + bgConfig, bgId, (u16)(param7 + 13), (u8)(param2 - 8), (u8)(param3 + param5), 1, 1, param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 14), + (u8)(param2 - 7), + (u8)(param3 + param5), + (u8)(param4 + 7), + 1, + param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 15), + (u8)(param2 + param4), + (u8)(param3 + param5), + 1, + 1, + param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 16), + (u8)(param2 + param4 + 1), + (u8)(param3 + param5), + 1, + 1, + param6); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(param7 + 17), + (u8)(param2 + param4 + 2), + (u8)(param3 + param5), + 1, + 1, + param6); +} + +THUMB_FUNC void FUN_0200D678(struct Window *window, u16 param1, u8 param2) +{ + u16 i, j; + u16 x, y; + u8 bg_id; + + bg_id = GetWindowBgId(window); + x = (u16)(GetWindowX(window) - 7); + y = GetWindowY(window); + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 6; j++) + { + FillBgTilemapRect(window->bgConfig, + bg_id, + (u16)(param1 + 6 * i + j), + (u8)(x + j), + (u8)(y + i), + 1, + 1, + param2); + } + } +} + +THUMB_FUNC void FUN_0200D6F8(struct Window *window, BOOL param1, u16 param2, u8 param3, u8 param4) +{ + u8 bg_id = GetWindowBgId(window); + if (param4 <= 1) + { + FUN_0200D3B0(window->bgConfig, + bg_id, + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + param3, + param2); + FUN_0200D678(window, (u16)(param2 + 30), param3); + } + else + { + FUN_0200CDD8(window->bgConfig, + bg_id, + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + param3, + param2); + } + + if (!param1) + { + CopyWindowToVram(window); + } + + FUN_0200D18C(window, param2); +} + +THUMB_FUNC void FUN_0200D7A0(struct Window *window, u32 param1, BOOL param2) +{ + u8 bg_id = GetWindowBgId(window); + if (param1 <= 1) + { + FillBgTilemapRect(window->bgConfig, + bg_id, + 0, + (u8)(GetWindowX(window) - 9), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 11), + (u8)(GetWindowHeight(window) + 2), + 0); + } + else + { + FillBgTilemapRect(window->bgConfig, + bg_id, + 0, + (u8)(GetWindowX(window) - 2), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 4), + (u8)(GetWindowHeight(window) + 2), + 0); + } + + if (!param2) + { + ClearWindowTilemapAndCopyToVram(window); + } +} + +THUMB_FUNC struct UnkStruct_0200CABC_1 *FUN_0200D858(struct Window *window, u32 param1) +{ + u32 heap_id = BgConfig_GetHeapId(window->bgConfig); + void *charptr = BgGetCharPtr(GetWindowBgId(window)); + + struct UnkStruct_0200CABC_1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200CABC_1)); + memcpy(ptr->unk004[8], charptr + (param1 + 18) * 32, 0x80); + void *ptr2 = AllocFromHeap(heap_id, 0x80); + memcpy(ptr2, charptr + (param1 + 10) * 32, 0x20); + memcpy(ptr2 + 0x20, charptr + (param1 + 11) * 32, 0x20); + memcpy(ptr2 + 0x40, charptr + (param1 + 10) * 32, 0x20); + memcpy(ptr2 + 0x60, charptr + (param1 + 11) * 32, 0x20); + + for (u8 i = 0; i < 8; i++) + { + memcpy(ptr->unk004[i], ptr2, 0x80); + } + FreeToHeap(ptr2); + + NNSG2dCharacterData *pCharData; + void *r5 = GfGfxLoader_GetCharData( + NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0023_NCGR, FALSE, &pCharData, heap_id); + FUN_0200D148( + pCharData->pRawData, 0, 0, 0x10, 0x80, ptr->unk004[0], 0x10, 0x80, 0, 0, 0x10, 0x80); + FreeToHeap(r5); + + ptr->unk000 = window; + ptr->unk484 = (u16)param1; + ptr->unk486 = 0; + ptr->unk487 = 0; + ptr->unk488 = 0; + + FUN_0200CA60(FUN_0200DB7C, ptr, 0); + FUN_0200D980(ptr, 1); + + return ptr; +} + +THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) +{ + u8 bg_id = GetWindowBgId(param0->unk000); + u8 x = GetWindowX(param0->unk000); + u8 y = GetWindowY(param0->unk000); + u8 width = GetWindowWidth(param0->unk000); + + if (param1 == 2) + { + BG_LoadCharTilesData(param0->unk000->bgConfig, + bg_id, + (u32 *)param0->unk004[8], + 0x80, + (u32)(param0->unk484 + 18)); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 10), + (u8)(x + width + 1), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 11), + (u8)(x + width + 2), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 10), + (u8)(x + width + 1), + (u8)(y + 3), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 11), + (u8)(x + width + 2), + (u8)(y + 3), + 1, + 1, + 0x10); + BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id); + return; + } + + BG_LoadCharTilesData(param0->unk000->bgConfig, + bg_id, + (u32 *)param0->unk004[param0->unk487], + 0x80, + (u32)(param0->unk484 + 18)); + if (param1 != 0) + { + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 18), + (u8)(x + width + 1), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 19), + (u8)(x + width + 2), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 20), + (u8)(x + width + 1), + (u8)(y + 3), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->unk484 + 21), + (u8)(x + width + 2), + (u8)(y + 3), + 1, + 1, + 0x10); + BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id); + } +} + +THUMB_FUNC void FUN_0200DB7C(u32 param0, void *param1) +{ + struct UnkStruct_0200CABC_1 *r1 = (struct UnkStruct_0200CABC_1 *)param1; + + if (r1->unk488 != 0) + { + if (r1->unk488 == 1) + { + FUN_0200D980(r1, 2); + } + FUN_0200CAB4((s32)param0); + return; + } + + r1->unk486++; + if (r1->unk486 == 16) + { + r1->unk486 = 0; + r1->unk487 = (r1->unk487 + 1) & 7; + FUN_0200D980(r1, 0); + } +} + +THUMB_FUNC void FUN_0200DBE8(u32 param0, void *param1) +{ + FreeToHeap(param1); + FUN_0200CAB4((s32)param0); +} + +THUMB_FUNC void FUN_0200DBFC(struct UnkStruct_0200CABC_1 *param0) +{ + FUN_0200CA98(FUN_0200DBE8, param0, 0); + param0->unk488 = 1; +} + +THUMB_FUNC void FUN_0200DC24(struct UnkStruct_0200CABC_1 *param0) +{ + FUN_0200CA98(FUN_0200DBE8, param0, 0); + param0->unk488 = 2; +} + +THUMB_FUNC u8 *FUN_0200DC4C(struct BgConfig *bg_config, + u8 bg_id, + u8 param2, + u8 param3, + u8 param4, + u16 param5, + u16 param6, + u8 param7, + s32 param8) +{ + struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param8); + FUN_0200DDAC(r4, (u32)param8); + FUN_0200DDD8(r4); + FUN_0200DE30(r4, param2, param3); + FUN_0200DE80(r4, param6, param7); + FUN_0200DFD8(r4, param4, param5); + BgCommitTilemapBufferToVram(bg_config, bg_id); + + return &r4->unk16f; +} + +THUMB_FUNC u8 *FUN_0200DCA4(struct BgConfig *bg_config, + u8 bg_id, + u8 param2, + u8 param3, + u8 param4, + u16 param5, + struct Pokemon *param6, + s32 param7) +{ + struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param7); + FUN_0200DDAC(r4, (u32)param7); + FUN_0200DDD8(r4); + FUN_0200DE30(r4, param2, param3); + FUN_0200DEC0(r4, param6); + FUN_0200DFD8(r4, param4, param5); + BgCommitTilemapBufferToVram(bg_config, bg_id); + + return &r4->unk16f; +} + +THUMB_FUNC void FUN_0200DCF8(u32 param0, void *param1) +{ + struct UnkStruct_0200CABC_2 *unk = (struct UnkStruct_0200CABC_2 *)param1; + switch (unk->unk16f) + { + case 1: + FUN_0200E188(unk); + FUN_0200C3DC(unk->unk164); + MOD05_021D99F8(unk); + FUN_0200621C((s32)param0); + return; + case 2: + unk->unk16f = 3; + FUN_02020130(*unk->unk164, 1); + break; + case 3: + if (FUN_0202022C(*unk->unk164) == 6) + { + unk->unk16f = 0; + } + } + + FUN_020201E4(*unk->unk164, 0x1000); + FUN_0201FDEC(unk->unk000); +} + +THUMB_FUNC struct UnkStruct_0200CABC_2 *FUN_0200DD70( + struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u32 param4) +{ + struct UnkStruct_0200CABC_2 *res = FUN_0201B6C8(FUN_020061E8(FUN_0200DCF8, 0x170, 0, param4)); + + res->unk16f = 0; + res->unk168 = bg_config; + res->unk16c = bg_id; + res->unk16d = param2; + res->unk16e = param3; + + return res; +} + +THUMB_FUNC void FUN_0200DDAC(struct UnkStruct_0200CABC_2 *param0, u32 param1) +{ + + const u32 UNK_020ECEA8[] = { + 0x01, + 0x01, + 0x01, + 0x01, + 0x00, + 0x00, + }; + MOD05_021D959C(param0, UNK_020ECEA8, 1, param1); +} + +THUMB_FUNC void FUN_0200DDD8(struct UnkStruct_0200CABC_2 *param0) +{ + MOD05_021D967C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0049_NCLR, 0, 1, 1, 0x15CD5); + MOD05_021D96F4(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0047_NCER, 0, 0x15CD5); + MOD05_021D9708(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0046_NANR, 0, 0x15CD5); + MOD05_021D971C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0048_NCGR, 0, 1, 0x15CD5); +} + +THUMB_FUNC void FUN_0200DE30(struct UnkStruct_0200CABC_2 *param0, u8 param1, u8 param2) +{ + u32 UNK_020ECEC0[] = { + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x015CD5, + 0x015CD5, + 0x015CD5, + 0x015CD5, + 0x00, + 0x00, + 0x00, + 0x00, + }; + ((u16 *)UNK_020ECEC0)[0] = (u16)((param1 + 5) * 8); + ((u16 *)UNK_020ECEC0)[1] = (u16)((param2 + 5) * 8); + param0->unk164 = MOD05_021D9820(param0, UNK_020ECEC0); + FUN_0201FDEC(param0->unk000); + GX_EngineBToggleLayers(0x10, GX_LAYER_TOGGLE_ON); +} + +THUMB_FUNC void FUN_0200DE80(struct UnkStruct_0200CABC_2 *param0, u16 param1, u8 param2) +{ + struct UnkStruct63_021DB450 *r7 = FUN_02006D98(param0->unk162); + struct SomeDrawPokemonStruct stc; + FUN_02068C00(&stc, param1, param2, 2, 0, 0, 0); + FUN_0200DEF4(param0, &stc); + FUN_020072E8(r7); +} + +THUMB_FUNC void FUN_0200DEC0(struct UnkStruct_0200CABC_2 *param0, struct Pokemon *param1) +{ + struct UnkStruct63_021DB450 *r6 = FUN_02006D98(param0->unk162); + struct SomeDrawPokemonStruct st0; + FUN_02068B68(&st0, param1, 2); + FUN_0200DEF4(param0, &st0); + FUN_020072E8(r6); +} + +THUMB_FUNC void FUN_0200DEF4( + struct UnkStruct_0200CABC_2 *param0, struct SomeDrawPokemonStruct *param1) +{ + void *r4 = AllocFromHeap(param0->unk162, 0x1900); + + struct UnkStruct_0200CABC_3 st18 = UNK_020ECE98; + FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st18, r4); + + struct UnkStruct_0200CABC_3 st8 = UNK_020ECE88; + FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st8, r4 + 0xc80); + + u32 st4 = FUN_02009C5C(FUN_020094F0(param0->unk130, 0x15CD5)); + + u32 r7 = NNS_G2dGetImageLocation(st4, 1); + DC_FlushRange(r4, 0x1900); + GX_LoadOBJ(r4, r7, 0x1900); + FreeToHeap(r4); + void *res = FUN_02012470(param1->unk0, param1->unk4, param0->unk162); + + u32 r5 = + NNS_G2dGetImagePaletteLocation(FUN_02009E54(FUN_020094F0(param0->unk134, 0x15CD5), st4), 1); + DC_FlushRange(res, 0x20); + GX_LoadOBJPltt(res, r5, 0x20); + FreeToHeap(res); +} + +THUMB_FUNC void FUN_0200DFD8(struct UnkStruct_0200CABC_2 *param0, u8 param1, u16 param2) +{ + FillBgTilemapRect(param0->unk168, + param0->unk16c, + param2, + (u8)(param0->unk16d - 1), + (u8)(param0->unk16e - 1), + 1, + 1, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 1), + param0->unk16d, + (u8)(param0->unk16e - 1), + 10, + 1, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 2), + (u8)(param0->unk16d + 10), + (u8)(param0->unk16e - 1), + 1, + 1, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 4), + param0->unk16d, + param0->unk16e, + 10, + 10, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 3), + (u8)(param0->unk16d - 1), + param0->unk16e, + 1, + 10, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 5), + (u8)(param0->unk16d + 10), + param0->unk16e, + 1, + 10, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 6), + (u8)(param0->unk16d - 1), + (u8)(param0->unk16e + 10), + 1, + 1, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 7), + param0->unk16d, + (u8)(param0->unk16e + 10), + 10, + 1, + param1); + FillBgTilemapRect(param0->unk168, + param0->unk16c, + (u16)(param2 + 8), + (u8)(param0->unk16d + 10), + (u8)(param0->unk16e + 10), + 1, + 1, + param1); + + ScheduleBgTilemapBufferTransfer(param0->unk168, param0->unk16c); +} + +THUMB_FUNC void FUN_0200E188(struct UnkStruct_0200CABC_2 *param0) +{ + FillBgTilemapRect(param0->unk168, + param0->unk16c, + 0, + (u8)(param0->unk16d - 1), + (u8)(param0->unk16e - 1), + 12, + 12, + 0); + ScheduleBgTilemapBufferTransfer(param0->unk168, param0->unk16c); +} -- cgit v1.2.3 From 59f143d03b359f07c08da66c294fb048a33993ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sun, 22 Aug 2021 10:02:23 +0200 Subject: remove old externs --- arm9/src/communication_error.c | 3 +-- arm9/src/error_message_reset.c | 3 +-- arm9/src/save_data_read_error.c | 3 +-- arm9/src/save_data_write_error.c | 3 +-- arm9/src/scrcmd.c | 30 +++++++++++++----------------- arm9/src/text_02054590.c | 16 ++-------------- arm9/src/unk_0200CABC.c | 1 - arm9/src/wfc_user_info_warning.c | 3 +-- 8 files changed, 20 insertions(+), 42 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 04058b83..2c6752a5 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -7,9 +7,8 @@ #include "msgdata/msg.naix" #include "text.h" #include "brightness.h" +#include "unk_0200CABC.h" -extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); -extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index 97bc7c70..66a71a75 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -7,6 +7,7 @@ #include "PAD_pad.h" #include "font.h" #include "brightness.h" +#include "unk_0200CABC.h" const struct WindowTemplate UNK_020FF49C = { @@ -44,8 +45,6 @@ const struct GraphicsBanks UNK_020FF4D8 = { .bg = 3 }; u32 sErrorMessagePrinterLock; extern void FUN_0200E3A0(PMLCDTarget, int); -extern void FUN_0200CB00(struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); -extern void FUN_0200CCA4(struct Window *param0, u32 param1, u32 param2, u32 param3); extern void FUN_0200E394(u32 param0); THUMB_FUNC void VBlankHandler() diff --git a/arm9/src/save_data_read_error.c b/arm9/src/save_data_read_error.c index 9524475c..7e378304 100644 --- a/arm9/src/save_data_read_error.c +++ b/arm9/src/save_data_read_error.c @@ -6,10 +6,9 @@ #include "msgdata/msg.naix" #include "save_data_read_error.h" #include "text.h" +#include "unk_0200CABC.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); -extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); -extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); diff --git a/arm9/src/save_data_write_error.c b/arm9/src/save_data_write_error.c index 71edb91d..04f2d686 100644 --- a/arm9/src/save_data_write_error.c +++ b/arm9/src/save_data_write_error.c @@ -6,10 +6,9 @@ #include "msgdata/msg.naix" #include "save_data_write_error.h" #include "text.h" +#include "unk_0200CABC.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); -extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); -extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index ceb1a1cf..007b1bcf 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -6,6 +6,9 @@ #include "player_data.h" #include "text.h" #include "bg_window.h" +#include "unk_0200CABC.h" +#include "text_02054590.h" + extern void *FUN_02039438(struct UnkSavStruct80* arg, u32 id); extern void *CreateScriptContext(struct UnkSavStruct80* arg, u16 id); @@ -22,27 +25,19 @@ extern void MOD05_021E2C58(struct ScriptContext *ctx, u16 typ, u16 id, u16 word1 extern struct ScrStrBufs *MOD06_02244210(struct SaveBlock2 *sav, u16 poke, u16 sex, u8 flag, u8 *unk); extern void MOD05_021E2CBC(struct ScriptContext *ctx, struct ScrStrBufs *str, u8 param2, u32 param3); extern void MOD05_021E2BB8(void *param0, struct ScriptContext *ctx); -extern BOOL FUN_020546C8(u8 param0); extern u32 FUN_02058488(u32 param0); extern BOOL FUN_02030F40(void); extern void FUN_02055304(u32 param0, u32 param1); extern void FUN_02039460(struct UnkSavStruct80 *arg); -extern void FUN_020545B8(u32 param0, u8 *param1, u32 param2); -extern void FUN_02054608(u8 *param0, struct Options *options); -extern void FUN_0200D0E0(struct Window *param0, u32 param1); extern u32 FUN_02058510(u32 param0, u32 param1); extern void MOD05_021E8128(u32 param0, u8 type, u16 map); extern void MOD05_021E8130(u32 param0, u32 param1); extern void MOD05_021E8158(struct UnkSavStruct80 *unk80); extern struct Window * MOD05_021E8140(u32 param0); extern BOOL MOD05_021E8148(u32 param0); -extern u8 FUN_02054658(struct Window * param0, struct String *str, struct Options *opt, u32 param3); extern void MOD05_021E8144(u32 param0); -extern void FUN_0200CB00(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5); -extern u32 Std_CreateYesNoMenu(u32 param0, u8 **param1, u32 param2, u32 param3, u32 param4); +extern u32 Std_CreateYesNoMenu(struct BgConfig *param0, u8 **param1, u32 param2, u32 param3, u32 param4); extern u32 FUN_020021AC(u32 param0, u32 param1); -extern u32 FUN_0200D858(u32 *param0, u32 param1); -extern void FUN_0200DBFC(u32 param0); extern u32 MOD05_021E1BF8(struct UnkSavStruct80 *arg, u8 param1, u8 param2, u8 param3, u8 param4, u16 *param5, u32 param6, u32 *param7, struct MsgData *msgData); extern void MOD05_021E1C4C(u32 param0, u32 param1, u32 param2); extern void MOD05_021E1C54(u32 param0); @@ -773,8 +768,8 @@ THUMB_FUNC BOOL ScrCmd_Unk0033(struct ScriptContext *ctx) { struct UnkSavStruct80 *unk80 = ctx->unk80; u8 *unk = (u8 *)FUN_02039438(unk80, 6); - FUN_020545B8(unk80->unk08, FUN_02039438(unk80, 1), 3); - FUN_02054608(FUN_02039438(unk80, 1), Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2)); + FUN_020545B8(unk80->unk08, (struct Window *)FUN_02039438(unk80, 1), 3); + FUN_02054608((struct Window *)FUN_02039438(unk80, 1), Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2)); *unk = 1; return FALSE; } @@ -958,7 +953,7 @@ THUMB_FUNC BOOL ScrCmd_Unk003A(struct ScriptContext *ctx) ReadMsgDataIntoString(ctx->msgData, msg, *unk2); StringExpandPlaceholders(*unk4, *unk3, *unk2); - *unk1 = FUN_02054658(MOD05_021E8140(unk80->unk60), *unk3, Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2), 1); + *unk1 = (u8)FUN_02054658(MOD05_021E8140(unk80->unk60), *unk3, Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2), 1); ctx->data[0] = wk; SetupNativeScript(ctx, FUN_0203A94C); return TRUE; @@ -1112,15 +1107,16 @@ THUMB_FUNC static BOOL FUN_0203AB00(struct ScriptContext *ctx) THUMB_FUNC BOOL ScrCmd_ShowSaveClock(struct ScriptContext *ctx) { - u32 *unk = FUN_02039438(ctx->unk80, 1); - u32 *unk2 = FUN_02039438(ctx->unk80, 18); + struct Window *unk = (struct Window *)FUN_02039438(ctx->unk80, 1); + struct UnkStruct_0200CABC_1 **unk2 = (struct UnkStruct_0200CABC_1 **)FUN_02039438(ctx->unk80, 18); *unk2 = FUN_0200D858(unk, 994); return FALSE; } + THUMB_FUNC BOOL ScrCmd_HideSaveClock(struct ScriptContext *ctx) { - u32 *unk = FUN_02039438(ctx->unk80, 18); + struct UnkStruct_0200CABC_1 **unk = (struct UnkStruct_0200CABC_1 **)FUN_02039438(ctx->unk80, 18); FUN_0200DBFC(*unk); return FALSE; } @@ -1345,13 +1341,13 @@ THUMB_FUNC BOOL ScrCmd_Unk02A1(struct ScriptContext *ctx) { unk4[0] = 15; pos++; - unk4[1] = unk1 - unk5; + unk4[1] = (u16)(unk1 - unk5); } else if (unk5 > unk1) { unk4[0] = 14; pos++; - unk4[1] = unk5 - unk1; + unk4[1] = (u16)(unk5 - unk1); } if (unk6 < unk2) diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c index 3c3d0fed..7b6ddeb7 100644 --- a/arm9/src/text_02054590.c +++ b/arm9/src/text_02054590.c @@ -3,22 +3,10 @@ #include "bg_window.h" #include "font.h" #include "render_text.h" +#include "unk_0200CABC.h" extern void FUN_0201BD5C(void); -extern void FUN_0200CD68( - struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); -extern void FUN_0200D0BC(struct Window *param0, u32 param1, u32 param2, u32 param3); - -extern void FUN_0200D300(struct BgConfig *param0, - u32 param1, - u32 param2, - u32 param3, - u8 param4, - u32 param5, - u32 param6); -extern void FUN_0200D6F8(struct Window *param0, u32 param1, u32 param2, u32 param3, u8 param4); - THUMB_FUNC void FUN_02054590(u32 param0, u32 param1) { if (param1 == 1) @@ -99,7 +87,7 @@ THUMB_FUNC void FUN_020546E0( } } -THUMB_FUNC void FUN_02054744(struct Window *param0, u32 param1, u32 param2) +THUMB_FUNC void FUN_02054744(struct Window *param0, u32 param1, u16 param2) { FUN_0200D300(param0->bgConfig, GetWindowBgId(param0), 0x399, 9, (u8)param1, param2, 4); FillWindowPixelBuffer(param0, 15); diff --git a/arm9/src/unk_0200CABC.c b/arm9/src/unk_0200CABC.c index 17f646f9..2004ff29 100644 --- a/arm9/src/unk_0200CABC.c +++ b/arm9/src/unk_0200CABC.c @@ -29,7 +29,6 @@ extern u32 FUN_0202022C(u32 param0); extern void FUN_020201E4(u32 param0, u32 param1); extern void FUN_0201FDEC(u32 param0); extern void MOD05_021D99F8(struct UnkStruct_0200CABC_2 *param0); -extern void FUN_0200E188(struct UnkStruct_0200CABC_2 *param0); extern void *FUN_0201B6C8(BOOL); extern void MOD05_021D959C( struct UnkStruct_0200CABC_2 *param0, void *param1, u32 param2, u32 param3); diff --git a/arm9/src/wfc_user_info_warning.c b/arm9/src/wfc_user_info_warning.c index da547f3d..ced5d707 100644 --- a/arm9/src/wfc_user_info_warning.c +++ b/arm9/src/wfc_user_info_warning.c @@ -11,10 +11,9 @@ #include "text.h" #include "wfc_user_info_warning.h" #include "brightness.h" +#include "unk_0200CABC.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); -extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); -extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); -- cgit v1.2.3 From 99d4cb2b2addcd12e7775c7817c5ed7783cbe971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sun, 22 Aug 2021 10:58:33 +0200 Subject: partially document unk_0200CABC --- arm9/src/communication_error.c | 2 +- arm9/src/error_message_reset.c | 2 +- arm9/src/save_data_read_error.c | 4 +- arm9/src/save_data_write_error.c | 2 +- arm9/src/scrcmd.c | 2 +- arm9/src/text_02054590.c | 4 +- arm9/src/unk_0200CABC.c | 462 +++++++++++++++++++-------------------- arm9/src/wfc_user_info_warning.c | 2 +- 8 files changed, 240 insertions(+), 240 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 2c6752a5..3c1f5a06 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -135,7 +135,7 @@ THUMB_FUNC void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code) AddWindow(bg_config, &window, &sCommunicationErrorWindowTemplate); FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); - FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2); BufferIntegerAsString(mgr, 0, (s32)error_code, 5, 2, 1); ReadMsgDataIntoString(error_message_data, error_message_no, tmp_str); diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index 66a71a75..55a816e8 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -113,7 +113,7 @@ THUMB_FUNC void PrintErrorMessageAndReset() FUN_0201BD5C(); AddWindow(ptr, &buf, &UNK_020FF49C); FillWindowPixelRect(&buf, 15, 0, 0, 0xd0, 0x90); - FUN_0200CCA4(&buf, 0, 0x1f7, 2); + DrawFrameAndWindow1(&buf, 0, 0x1f7, 2); ReadMsgDataIntoString(msg_data, 3, str); diff --git a/arm9/src/save_data_read_error.c b/arm9/src/save_data_read_error.c index 7e378304..616578f4 100644 --- a/arm9/src/save_data_read_error.c +++ b/arm9/src/save_data_read_error.c @@ -103,7 +103,7 @@ THUMB_FUNC void ShowSaveDataReadError(u32 heap_id) AddWindow(bg_config, &window, &sSaveDataReadErrorWindowTemplate); FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); - FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2); ReadMsgDataIntoString(msg_data, 0, str); AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); @@ -166,7 +166,7 @@ THUMB_FUNC void ShowGBACartRemovedError(u32 heap_id) AddWindow(bg_config, &window, &sSaveDataReadErrorWindowTemplate); FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); - FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2); ReadMsgDataIntoString(msg_data, 1, str); AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); diff --git a/arm9/src/save_data_write_error.c b/arm9/src/save_data_write_error.c index 04f2d686..2a8848c6 100644 --- a/arm9/src/save_data_write_error.c +++ b/arm9/src/save_data_write_error.c @@ -111,7 +111,7 @@ THUMB_FUNC void ShowSaveDataWriteError(u32 heap_id, u32 err_no) AddWindow(bg_config, &window, &sSaveDataWriteErrorWindowTemplate); FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); - FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2); ReadMsgDataIntoString(msg_data, msg_no, str); AddTextPrinterParameterized(&window, 0, str, 0, 0, 0, NULL); diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index 007b1bcf..68769c88 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -779,7 +779,7 @@ THUMB_FUNC BOOL ScrCmd_CloseMessageBox(struct ScriptContext* ctx) struct UnkSavStruct80 *unk80 = ctx->unk80; struct Window *unk = FUN_02039438(unk80, 0x1); u8 *unk2 = FUN_02039438(unk80, 0x6); - FUN_0200D0E0(unk, 0); //clear window? + ClearFrameAndWindow2(unk, 0); //clear window? RemoveWindow(unk); *unk2 = 0; return FALSE; diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c index 7b6ddeb7..e3276f25 100644 --- a/arm9/src/text_02054590.c +++ b/arm9/src/text_02054590.c @@ -33,7 +33,7 @@ THUMB_FUNC void FUN_02054608(struct Window *param0, struct Options *options) { FUN_0200CD68(param0->bgConfig, GetWindowBgId(param0), 994, 10, (u8)Options_GetFrame(options), 4); FUN_0205464C(param0); - FUN_0200D0BC(param0, 0, 994, 10); + DrawFrameAndWindow2(param0, 0, 994, 10); } THUMB_FUNC void FUN_0205464C(struct Window *param0) @@ -91,5 +91,5 @@ THUMB_FUNC void FUN_02054744(struct Window *param0, u32 param1, u16 param2) { FUN_0200D300(param0->bgConfig, GetWindowBgId(param0), 0x399, 9, (u8)param1, param2, 4); FillWindowPixelBuffer(param0, 15); - FUN_0200D6F8(param0, 0, 0x399, 9, (u8)param1); + DrawFrameAndWindow3(param0, 0, 0x399, 9, (u8)param1); } diff --git a/arm9/src/unk_0200CABC.c b/arm9/src/unk_0200CABC.c index 2004ff29..f57469e1 100644 --- a/arm9/src/unk_0200CABC.c +++ b/arm9/src/unk_0200CABC.c @@ -82,9 +82,9 @@ THUMB_FUNC u32 FUN_0200CABC( heap_id); } -THUMB_FUNC u32 FUN_0200CAFC(void) +THUMB_FUNC s32 FUN_0200CAFC(void) { - return 24; + return NARC_winframe_narc_0024_NCLR; } THUMB_FUNC void FUN_0200CB00( @@ -121,42 +121,42 @@ THUMB_FUNC void FUN_0200CB00( GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 4, param3 << 5, 32, heap_id); } -THUMB_FUNC void FUN_0200CB6C(struct BgConfig *bgConfig, +THUMB_FUNC void DrawFrame1(struct BgConfig *bgConfig, u8 bgId, - u8 param2, - u8 param3, - u8 param4, - u8 param5, - u8 param6, - u16 param7) + u8 x, + u8 y, + u8 width, + u8 height, + u8 paletteNum, + u16 fillValue) { - FillBgTilemapRect(bgConfig, bgId, param7, (u8)(param2 - 1), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 1), param2, (u8)(param3 - 1), param4, 1, param6); + bgConfig, bgId, (u16)(fillValue + 1), x, (u8)(y - 1), width, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 2), (u8)(param2 + param4), (u8)(param3 - 1), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 2), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 3), (u8)(param2 - 1), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 3), (u8)(x - 1), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 5), (u8)(param2 + param4), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 6), (u8)(param2 - 1), (u8)(param3 + param5), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 7), param2, (u8)(param3 + param5), param4, 1, param6); + bgConfig, bgId, (u16)(fillValue + 7), x, (u8)(y + height), width, 1, paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 8), - (u8)(param2 + param4), - (u8)(param3 + param5), + (u16)(fillValue + 8), + (u8)(x + width), + (u8)(y + height), 1, 1, - param6); + paletteNum); } -THUMB_FUNC void FUN_0200CCA4( +THUMB_FUNC void DrawFrameAndWindow1( struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) { - FUN_0200CB6C(window->bgConfig, + DrawFrame1(window->bgConfig, GetWindowBgId(window), GetWindowX(window), GetWindowY(window), @@ -171,7 +171,7 @@ THUMB_FUNC void FUN_0200CCA4( } } -THUMB_FUNC void FUN_0200CCF8(struct Window *window, BOOL copy_to_vram) +THUMB_FUNC void ClearFrameAndWindow1(struct Window *window, BOOL copy_to_vram) { FillBgTilemapRect(window->bgConfig, @@ -216,83 +216,83 @@ THUMB_FUNC void FUN_0200CD68( GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 4, param3 << 5, 32, param5); } -THUMB_FUNC void FUN_0200CDD8(struct BgConfig *bgConfig, +THUMB_FUNC void DrawFrame2(struct BgConfig *bgConfig, u8 bgId, - u8 param2, - u8 param3, - u8 param4, - u8 param5, - u8 param6, - u16 param7) + u8 x, + u8 y, + u8 width, + u8 height, + u8 paletteNum, + u16 fillValue) { - FillBgTilemapRect(bgConfig, bgId, param7, (u8)(param2 - 2), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 2), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 1), (u8)(param2 - 1), (u8)(param3 - 1), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 2), param2, (u8)(param3 - 1), param4, 1, param6); + bgConfig, bgId, (u16)(fillValue + 2), x, (u8)(y - 1), width, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 3), (u8)(param2 + param4), (u8)(param3 - 1), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 4), - (u8)(param2 + param4 + 1), - (u8)(param3 - 1), + (u16)(fillValue + 4), + (u8)(x + width + 1), + (u8)(y - 1), 1, 1, - param6); + paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 5), - (u8)(param2 + param4 + 2), - (u8)(param3 - 1), + (u16)(fillValue + 5), + (u8)(x + width + 2), + (u8)(y - 1), 1, 1, - param6); + paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 6), (u8)(param2 - 2), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 2), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 7), (u8)(param2 - 1), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 1), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 9), (u8)(param2 + param4), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 10), (u8)(param2 + param4 + 1), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 11), (u8)(param2 + param4 + 2), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 12), (u8)(param2 - 2), (u8)(param3 + param5), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 2), (u8)(y + height), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 13), (u8)(param2 - 1), (u8)(param3 + param5), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 14), param2, (u8)(param3 + param5), param4, 1, param6); + bgConfig, bgId, (u16)(fillValue + 14), x, (u8)(y + height), width, 1, paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 15), - (u8)(param2 + param4), - (u8)(param3 + param5), + (u16)(fillValue + 15), + (u8)(x + width), + (u8)(y + height), 1, 1, - param6); + paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 16), - (u8)(param2 + param4 + 1), - (u8)(param3 + param5), + (u16)(fillValue + 16), + (u8)(x + width + 1), + (u8)(y + height), 1, 1, - param6); + paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 17), - (u8)(param2 + param4 + 2), - (u8)(param3 + param5), + (u16)(fillValue + 17), + (u8)(x + width + 2), + (u8)(y + height), 1, 1, - param6); + paletteNum); } -THUMB_FUNC void FUN_0200D06C(struct Window *window, u32 fill_value, u32 palette_num) +THUMB_FUNC void DrawWindowFrame2(struct Window *window, u32 fill_value, u32 palette_num) { - FUN_0200CDD8(window->bgConfig, + DrawFrame2(window->bgConfig, GetWindowBgId(window), GetWindowX(window), GetWindowY(window), @@ -302,10 +302,10 @@ THUMB_FUNC void FUN_0200D06C(struct Window *window, u32 fill_value, u32 palette_ (u16)fill_value); } -THUMB_FUNC void FUN_0200D0BC( +THUMB_FUNC void DrawFrameAndWindow2( struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) { - FUN_0200D06C(window, fill_value, palette_num); + DrawWindowFrame2(window, fill_value, palette_num); if (!copy_to_vram) { CopyWindowToVram(window); @@ -314,7 +314,7 @@ THUMB_FUNC void FUN_0200D0BC( FUN_0200D18C(window, fill_value); } -THUMB_FUNC void FUN_0200D0E0(struct Window *window, BOOL param1) +THUMB_FUNC void ClearFrameAndWindow2(struct Window *window, BOOL param1) { FillBgTilemapRect(window->bgConfig, GetWindowBgId(window), @@ -331,30 +331,30 @@ THUMB_FUNC void FUN_0200D0E0(struct Window *window, BOOL param1) } } -THUMB_FUNC void FUN_0200D148(u8 *param0, - u16 param1, - u16 param2, - u16 param3, - u16 param4, - u8 *param5, - u16 param6, - u16 param7, - u16 param8, - u16 param9, - u16 param10, - u16 param11) +THUMB_FUNC void BlitRect4Bit(u8 *srcPixels, + u16 srcX, + u16 srcY, + u16 srcWidth, + u16 srcHeight, + u8 *dstPixels, + u16 dstWidth, + u16 dstHeight, + u16 dstX, + u16 dstY, + u16 width, + u16 height) { struct Bitmap src; - src.pixels = param0; - src.width = param3; - src.height = param4; + src.pixels = srcPixels; + src.width = srcWidth; + src.height = srcHeight; struct Bitmap dst; - dst.pixels = param5; - dst.width = param6; - dst.height = param7; + dst.pixels = dstPixels; + dst.width = dstWidth; + dst.height = dstHeight; - BlitBitmapRect4Bit(&src, &dst, param1, param2, param8, param9, param10, param11, 0); + BlitBitmapRect4Bit(&src, &dst, srcX, srcY, dstX, dstY, width, height, 0); } THUMB_FUNC void FUN_0200D18C(struct Window *window, u16 fill_value) @@ -380,7 +380,7 @@ THUMB_FUNC void FUN_0200D18C(struct Window *window, u16 fill_value) memcpy(ptr + ((i << 7) + 0x60), charptr + ((fill_value + 11) << 5), 0x20); } - FUN_0200D148(st30, 4, 0, 12, 0x30, ptr, 12, 0x30, 1, 0, 12, 0x30); + BlitRect4Bit(st30, 4, 0, 12, 0x30, ptr, 12, 0x30, 1, 0, 12, 0x30); BG_LoadCharTilesData(window->bgConfig, bg_id, ptr, 0x180, (u32)(fill_value + 18)); FUN_02002840(fill_value); FreeToHeap(st2c); @@ -465,95 +465,95 @@ THUMB_FUNC void FUN_0200D378( NARC_GRAPHIC_FIELD_BOARD, param4, bg_config, bg_id, numtiles, 0x300, FALSE, heap_id); } -THUMB_FUNC void FUN_0200D3B0(struct BgConfig *bgConfig, +THUMB_FUNC void DrawFrame3(struct BgConfig *bgConfig, u8 bgId, - u8 param2, - u8 param3, - u8 param4, - u8 param5, - u8 param6, - u16 param7) + u8 x, + u8 y, + u8 width, + u8 height, + u8 paletteNum, + u16 fillValue) { - FillBgTilemapRect(bgConfig, bgId, param7, (u8)(param2 - 9), (u8)(param3 - 1), 1, 1, param6); + FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 9), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 1), (u8)(param2 - 8), (u8)(param3 - 1), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 8), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 2), - (u8)(param2 - 7), - (u8)(param3 - 1), - (u8)(param4 + 7), + (u16)(fillValue + 2), + (u8)(x - 7), + (u8)(y - 1), + (u8)(width + 7), 1, - param6); + paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 3), (u8)(param2 + param4), (u8)(param3 - 1), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 4), - (u8)(param2 + param4 + 1), - (u8)(param3 - 1), + (u16)(fillValue + 4), + (u8)(x + width + 1), + (u8)(y - 1), 1, 1, - param6); + paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 5), - (u8)(param2 + param4 + 2), - (u8)(param3 - 1), + (u16)(fillValue + 5), + (u8)(x + width + 2), + (u8)(y - 1), 1, 1, - param6); + paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 6), (u8)(param2 - 9), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 9), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 7), (u8)(param2 - 8), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 8), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 8), (u8)(param2 - 1), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 8), (u8)(x - 1), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 9), (u8)(param2 + param4), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 10), (u8)(param2 + param4 + 1), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 11), (u8)(param2 + param4 + 2), param3, 1, param5, param6); + bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 12), (u8)(param2 - 9), (u8)(param3 + param5), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 9), (u8)(y + height), 1, 1, paletteNum); FillBgTilemapRect( - bgConfig, bgId, (u16)(param7 + 13), (u8)(param2 - 8), (u8)(param3 + param5), 1, 1, param6); + bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 8), (u8)(y + height), 1, 1, paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 14), - (u8)(param2 - 7), - (u8)(param3 + param5), - (u8)(param4 + 7), + (u16)(fillValue + 14), + (u8)(x - 7), + (u8)(y + height), + (u8)(width + 7), 1, - param6); + paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 15), - (u8)(param2 + param4), - (u8)(param3 + param5), + (u16)(fillValue + 15), + (u8)(x + width), + (u8)(y + height), 1, 1, - param6); + paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 16), - (u8)(param2 + param4 + 1), - (u8)(param3 + param5), + (u16)(fillValue + 16), + (u8)(x + width + 1), + (u8)(y + height), 1, 1, - param6); + paletteNum); FillBgTilemapRect(bgConfig, bgId, - (u16)(param7 + 17), - (u8)(param2 + param4 + 2), - (u8)(param3 + param5), + (u16)(fillValue + 17), + (u8)(x + width + 2), + (u8)(y + height), 1, 1, - param6); + paletteNum); } -THUMB_FUNC void FUN_0200D678(struct Window *window, u16 param1, u8 param2) +THUMB_FUNC void DrawWindowCorner(struct Window *window, u16 fillValue, u8 paletteNum) { u16 i, j; u16 x, y; @@ -569,52 +569,52 @@ THUMB_FUNC void FUN_0200D678(struct Window *window, u16 param1, u8 param2) { FillBgTilemapRect(window->bgConfig, bg_id, - (u16)(param1 + 6 * i + j), + (u16)(fillValue + 6 * i + j), (u8)(x + j), (u8)(y + i), 1, 1, - param2); + paletteNum); } } } -THUMB_FUNC void FUN_0200D6F8(struct Window *window, BOOL param1, u16 param2, u8 param3, u8 param4) +THUMB_FUNC void DrawFrameAndWindow3(struct Window *window, BOOL copy_to_vram, u16 fillValue, u8 paletteNum, u8 param4) { u8 bg_id = GetWindowBgId(window); if (param4 <= 1) { - FUN_0200D3B0(window->bgConfig, + DrawFrame3(window->bgConfig, bg_id, GetWindowX(window), GetWindowY(window), GetWindowWidth(window), GetWindowHeight(window), - param3, - param2); - FUN_0200D678(window, (u16)(param2 + 30), param3); + paletteNum, + fillValue); + DrawWindowCorner(window, (u16)(fillValue + 30), paletteNum); } else { - FUN_0200CDD8(window->bgConfig, + DrawFrame2(window->bgConfig, bg_id, GetWindowX(window), GetWindowY(window), GetWindowWidth(window), GetWindowHeight(window), - param3, - param2); + paletteNum, + fillValue); } - if (!param1) + if (!copy_to_vram) { CopyWindowToVram(window); } - FUN_0200D18C(window, param2); + FUN_0200D18C(window, fillValue); } -THUMB_FUNC void FUN_0200D7A0(struct Window *window, u32 param1, BOOL param2) +THUMB_FUNC void ClearFrameAndWindow3(struct Window *window, u8 param1, BOOL copy_to_vram) { u8 bg_id = GetWindowBgId(window); if (param1 <= 1) @@ -640,7 +640,7 @@ THUMB_FUNC void FUN_0200D7A0(struct Window *window, u32 param1, BOOL param2) 0); } - if (!param2) + if (!copy_to_vram) { ClearWindowTilemapAndCopyToVram(window); } @@ -668,12 +668,12 @@ THUMB_FUNC struct UnkStruct_0200CABC_1 *FUN_0200D858(struct Window *window, u32 NNSG2dCharacterData *pCharData; void *r5 = GfGfxLoader_GetCharData( NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0023_NCGR, FALSE, &pCharData, heap_id); - FUN_0200D148( + BlitRect4Bit( pCharData->pRawData, 0, 0, 0x10, 0x80, ptr->unk004[0], 0x10, 0x80, 0, 0, 0x10, 0x80); FreeToHeap(r5); ptr->unk000 = window; - ptr->unk484 = (u16)param1; + ptr->fillValue = (u16)param1; ptr->unk486 = 0; ptr->unk487 = 0; ptr->unk488 = 0; @@ -697,10 +697,10 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) bg_id, (u32 *)param0->unk004[8], 0x80, - (u32)(param0->unk484 + 18)); + (u32)(param0->fillValue + 18)); FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 10), + (u16)(param0->fillValue + 10), (u8)(x + width + 1), (u8)(y + 2), 1, @@ -708,7 +708,7 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) 0x10); FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 11), + (u16)(param0->fillValue + 11), (u8)(x + width + 2), (u8)(y + 2), 1, @@ -716,7 +716,7 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) 0x10); FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 10), + (u16)(param0->fillValue + 10), (u8)(x + width + 1), (u8)(y + 3), 1, @@ -724,7 +724,7 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) 0x10); FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 11), + (u16)(param0->fillValue + 11), (u8)(x + width + 2), (u8)(y + 3), 1, @@ -738,12 +738,12 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) bg_id, (u32 *)param0->unk004[param0->unk487], 0x80, - (u32)(param0->unk484 + 18)); + (u32)(param0->fillValue + 18)); if (param1 != 0) { FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 18), + (u16)(param0->fillValue + 18), (u8)(x + width + 1), (u8)(y + 2), 1, @@ -751,7 +751,7 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) 0x10); FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 19), + (u16)(param0->fillValue + 19), (u8)(x + width + 2), (u8)(y + 2), 1, @@ -759,7 +759,7 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) 0x10); FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 20), + (u16)(param0->fillValue + 20), (u8)(x + width + 1), (u8)(y + 3), 1, @@ -767,7 +767,7 @@ THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) 0x10); FillBgTilemapRect(param0->unk000->bgConfig, bg_id, - (u16)(param0->unk484 + 21), + (u16)(param0->fillValue + 21), (u8)(x + width + 2), (u8)(y + 3), 1, @@ -833,7 +833,7 @@ THUMB_FUNC u8 *FUN_0200DC4C(struct BgConfig *bg_config, FUN_0200DDD8(r4); FUN_0200DE30(r4, param2, param3); FUN_0200DE80(r4, param6, param7); - FUN_0200DFD8(r4, param4, param5); + DrawFramed10x10Square(r4, param4, param5); BgCommitTilemapBufferToVram(bg_config, bg_id); return &r4->unk16f; @@ -853,7 +853,7 @@ THUMB_FUNC u8 *FUN_0200DCA4(struct BgConfig *bg_config, FUN_0200DDD8(r4); FUN_0200DE30(r4, param2, param3); FUN_0200DEC0(r4, param6); - FUN_0200DFD8(r4, param4, param5); + DrawFramed10x10Square(r4, param4, param5); BgCommitTilemapBufferToVram(bg_config, bg_id); return &r4->unk16f; @@ -865,7 +865,7 @@ THUMB_FUNC void FUN_0200DCF8(u32 param0, void *param1) switch (unk->unk16f) { case 1: - FUN_0200E188(unk); + ClearFramed10x10Square(unk); FUN_0200C3DC(unk->unk164); MOD05_021D99F8(unk); FUN_0200621C((s32)param0); @@ -891,10 +891,10 @@ THUMB_FUNC struct UnkStruct_0200CABC_2 *FUN_0200DD70( struct UnkStruct_0200CABC_2 *res = FUN_0201B6C8(FUN_020061E8(FUN_0200DCF8, 0x170, 0, param4)); res->unk16f = 0; - res->unk168 = bg_config; - res->unk16c = bg_id; - res->unk16d = param2; - res->unk16e = param3; + res->bgConfig = bg_config; + res->bgId = bg_id; + res->x = param2; + res->y = param3; return res; } @@ -989,93 +989,93 @@ THUMB_FUNC void FUN_0200DEF4( FreeToHeap(res); } -THUMB_FUNC void FUN_0200DFD8(struct UnkStruct_0200CABC_2 *param0, u8 param1, u16 param2) +THUMB_FUNC void DrawFramed10x10Square(struct UnkStruct_0200CABC_2 *param0, u8 paletteNum, u16 fillValue) { - FillBgTilemapRect(param0->unk168, - param0->unk16c, - param2, - (u8)(param0->unk16d - 1), - (u8)(param0->unk16e - 1), + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + fillValue, + (u8)(param0->x - 1), + (u8)(param0->y - 1), 1, 1, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 1), - param0->unk16d, - (u8)(param0->unk16e - 1), + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 1), + param0->x, + (u8)(param0->y - 1), 10, 1, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 2), - (u8)(param0->unk16d + 10), - (u8)(param0->unk16e - 1), + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 2), + (u8)(param0->x + 10), + (u8)(param0->y - 1), 1, 1, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 4), - param0->unk16d, - param0->unk16e, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 4), + param0->x, + param0->y, 10, 10, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 3), - (u8)(param0->unk16d - 1), - param0->unk16e, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 3), + (u8)(param0->x - 1), + param0->y, 1, 10, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 5), - (u8)(param0->unk16d + 10), - param0->unk16e, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 5), + (u8)(param0->x + 10), + param0->y, 1, 10, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 6), - (u8)(param0->unk16d - 1), - (u8)(param0->unk16e + 10), + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 6), + (u8)(param0->x - 1), + (u8)(param0->y + 10), 1, 1, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 7), - param0->unk16d, - (u8)(param0->unk16e + 10), + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 7), + param0->x, + (u8)(param0->y + 10), 10, 1, - param1); - FillBgTilemapRect(param0->unk168, - param0->unk16c, - (u16)(param2 + 8), - (u8)(param0->unk16d + 10), - (u8)(param0->unk16e + 10), + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 8), + (u8)(param0->x + 10), + (u8)(param0->y + 10), 1, 1, - param1); + paletteNum); - ScheduleBgTilemapBufferTransfer(param0->unk168, param0->unk16c); + ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId); } -THUMB_FUNC void FUN_0200E188(struct UnkStruct_0200CABC_2 *param0) +THUMB_FUNC void ClearFramed10x10Square(struct UnkStruct_0200CABC_2 *param0) { - FillBgTilemapRect(param0->unk168, - param0->unk16c, + FillBgTilemapRect(param0->bgConfig, + param0->bgId, 0, - (u8)(param0->unk16d - 1), - (u8)(param0->unk16e - 1), + (u8)(param0->x - 1), + (u8)(param0->y - 1), 12, 12, 0); - ScheduleBgTilemapBufferTransfer(param0->unk168, param0->unk16c); + ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId); } diff --git a/arm9/src/wfc_user_info_warning.c b/arm9/src/wfc_user_info_warning.c index ced5d707..f16b4faa 100644 --- a/arm9/src/wfc_user_info_warning.c +++ b/arm9/src/wfc_user_info_warning.c @@ -108,7 +108,7 @@ THUMB_FUNC void ShowWFCUserInfoWarning(u32 heap_id, u32 a1) FUN_0201BD5C(); AddWindow(bg_config, &window, &sWFCWarningMsgWindowTemplate); FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); - FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + DrawFrameAndWindow1(&window, FALSE, 0x01F7, 2); ReadMsgDataIntoString(warning_messages_data, 15, warning_message); AddTextPrinterParameterized(&window, 0, warning_message, 0, 0, 0, 0); -- cgit v1.2.3 From 08c88720e7d4a5520262468f70e62b99429c10cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sun, 22 Aug 2021 11:02:04 +0200 Subject: rename unk_0200CABC to render_window --- arm9/src/communication_error.c | 2 +- arm9/src/error_message_reset.c | 2 +- arm9/src/render_window.c | 1027 ++++++++++++++++++++++++++++++++++++ arm9/src/save_data_read_error.c | 2 +- arm9/src/save_data_write_error.c | 2 +- arm9/src/scrcmd.c | 2 +- arm9/src/text_02054590.c | 2 +- arm9/src/unk_0200CABC.c | 1081 -------------------------------------- arm9/src/wfc_user_info_warning.c | 2 +- 9 files changed, 1034 insertions(+), 1088 deletions(-) create mode 100644 arm9/src/render_window.c delete mode 100644 arm9/src/unk_0200CABC.c (limited to 'arm9/src') diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c index 3c1f5a06..848e3d0a 100644 --- a/arm9/src/communication_error.c +++ b/arm9/src/communication_error.c @@ -7,7 +7,7 @@ #include "msgdata/msg.naix" #include "text.h" #include "brightness.h" -#include "unk_0200CABC.h" +#include "render_window.h" extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index 55a816e8..12af3c6f 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -7,7 +7,7 @@ #include "PAD_pad.h" #include "font.h" #include "brightness.h" -#include "unk_0200CABC.h" +#include "render_window.h" const struct WindowTemplate UNK_020FF49C = { diff --git a/arm9/src/render_window.c b/arm9/src/render_window.c new file mode 100644 index 00000000..7a682eb6 --- /dev/null +++ b/arm9/src/render_window.c @@ -0,0 +1,1027 @@ +#include "global.h" +#include "render_window.h" +#include "filesystem.h" +#include "gf_gfx_loader.h" +#include "graphic/field_board.naix" +#include "graphic/winframe.naix" +#include "pokemon.h" +#include "render_text.h" +#include "unk_020061E8.h" +#include "unk_0200BB14.h" +#include "unk_0200CA44.h" + +const struct UnkStruct_0200CABC_3 UNK_020ECE88 = { + 10, + 0, + 10, + 10, +}; + +const struct UnkStruct_0200CABC_3 UNK_020ECE98 = { + 0, + 0, + 10, + 10, +}; + +extern void FUN_02020130(u32 param0, u32 param1); +extern u32 FUN_0202022C(u32 param0); +extern void FUN_020201E4(u32 param0, u32 param1); +extern void FUN_0201FDEC(u32 param0); +extern void MOD05_021D99F8(struct UnkStruct_0200CABC_2 *param0); +extern void *FUN_0201B6C8(BOOL); +extern void MOD05_021D959C( + struct UnkStruct_0200CABC_2 *param0, void *param1, u32 param2, u32 param3); +extern void MOD05_021D967C(struct UnkStruct_0200CABC_2 *param0, + NarcId narcId, + s32 memberId, + u32 param3, + u32 param4, + u32 param5, + u32 param6); +extern void MOD05_021D96F4( + struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4); +extern void MOD05_021D9708( + struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4); +extern void MOD05_021D971C(struct UnkStruct_0200CABC_2 *param0, + NarcId narcId, + s32 memberId, + u32 param3, + u32 param4, + u32 param5); +extern u32 *MOD05_021D9820(struct UnkStruct_0200CABC_2 *param0, void *); +extern struct UnkStruct63_021DB450 *FUN_02006D98(u32); +extern void FUN_020072E8(struct UnkStruct63_021DB450 *param0); +extern void FUN_02012400(u16, u16, u16, void *, void *); +extern u32 NNS_G2dGetImageLocation(u32, u32); +extern void *FUN_02012470(u16, u16, u16); +extern u32 NNS_G2dGetImagePaletteLocation(u32, u32); + +THUMB_FUNC u32 FUN_0200CABC( + struct BgConfig *bgConfig, u32 layer, u32 numTiles, u32 param3, u32 heap_id) +{ + if (param3 == 0) + { + return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME, + NARC_winframe_narc_0000_NCGR, + bgConfig, + layer, + numTiles, + 0, + FALSE, + heap_id); + } + + return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME, + NARC_winframe_narc_0001_NCGR, + bgConfig, + layer, + numTiles, + 0, + FALSE, + heap_id); +} + +THUMB_FUNC s32 FUN_0200CAFC(void) +{ + return NARC_winframe_narc_0024_NCLR; +} + +THUMB_FUNC void FUN_0200CB00( + struct BgConfig *bg_config, u32 layer, u32 num_tiles, u32 param3, u8 param4, u32 heap_id) +{ + s32 r1; + if (param4 != 0) + { + r1 = NARC_winframe_narc_0001_NCGR; + } + else + { + r1 = NARC_winframe_narc_0000_NCGR; + } + + GfGfxLoader_LoadCharData( + NARC_GRAPHIC_WINFRAME, r1, bg_config, layer, num_tiles, 0, FALSE, heap_id); + + if (param4 == 2) + { + r1 = NARC_winframe_narc_0045_NCLR; + } + else + { + r1 = NARC_winframe_narc_0024_NCLR; + } + + if (layer < 4) + { + GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 0, param3 << 5, 32, heap_id); + return; + } + + GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 4, param3 << 5, 32, heap_id); +} + +THUMB_FUNC void DrawFrame1(struct BgConfig *bgConfig, + u8 bgId, + u8 x, + u8 y, + u8 width, + u8 height, + u8 paletteNum, + u16 fillValue) +{ + FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 1), x, (u8)(y - 1), width, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 2), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 3), (u8)(x - 1), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 7), x, (u8)(y + height), width, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 8), (u8)(x + width), (u8)(y + height), 1, 1, paletteNum); +} + +THUMB_FUNC void DrawFrameAndWindow1( + struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) +{ + DrawFrame1(window->bgConfig, + GetWindowBgId(window), + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + palette_num, + fill_value); + + if (!copy_to_vram) + { + CopyWindowToVram(window); + } +} + +THUMB_FUNC void ClearFrameAndWindow1(struct Window *window, BOOL copy_to_vram) +{ + + FillBgTilemapRect(window->bgConfig, + GetWindowBgId(window), + 0, + (u8)(GetWindowX(window) - 1), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 2), + (u8)(GetWindowHeight(window) + 2), + 0); + + if (!copy_to_vram) + { + ClearWindowTilemapAndCopyToVram(window); + } +} + +THUMB_FUNC s32 FUN_0200CD60(s32 param0) +{ + return param0 + 2; +} + +THUMB_FUNC s32 FUN_0200CD64(s32 param0) +{ + return param0 + 25; +} + +THUMB_FUNC void FUN_0200CD68( + struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5) +{ + + GfGfxLoader_LoadCharData( + NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), param0, param1, param2, 0, FALSE, param5); + + if (param1 < 4) + { + GfGfxLoader_GXLoadPal( + NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 0, param3 << 5, 32, param5); + return; + } + + GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 4, param3 << 5, 32, param5); +} + +THUMB_FUNC void DrawFrame2(struct BgConfig *bgConfig, + u8 bgId, + u8 x, + u8 y, + u8 width, + u8 height, + u8 paletteNum, + u16 fillValue) +{ + FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 2), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 2), x, (u8)(y - 1), width, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 4), (u8)(x + width + 1), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width + 2), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 2), y, 1, height, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 1), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 2), (u8)(y + height), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 14), x, (u8)(y + height), width, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 15), (u8)(x + width), (u8)(y + height), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(fillValue + 16), + (u8)(x + width + 1), + (u8)(y + height), + 1, + 1, + paletteNum); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(fillValue + 17), + (u8)(x + width + 2), + (u8)(y + height), + 1, + 1, + paletteNum); +} + +THUMB_FUNC void DrawWindowFrame2(struct Window *window, u32 fill_value, u32 palette_num) +{ + DrawFrame2(window->bgConfig, + GetWindowBgId(window), + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + (u8)palette_num, + (u16)fill_value); +} + +THUMB_FUNC void DrawFrameAndWindow2( + struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) +{ + DrawWindowFrame2(window, fill_value, palette_num); + if (!copy_to_vram) + { + CopyWindowToVram(window); + } + + FUN_0200D18C(window, fill_value); +} + +THUMB_FUNC void ClearFrameAndWindow2(struct Window *window, BOOL param1) +{ + FillBgTilemapRect(window->bgConfig, + GetWindowBgId(window), + 0, + (u8)(GetWindowX(window) - 2), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 5), + (u8)(GetWindowHeight(window) + 2), + 0); + + if (!param1) + { + ClearWindowTilemapAndCopyToVram(window); + } +} + +THUMB_FUNC void BlitRect4Bit(u8 *srcPixels, + u16 srcX, + u16 srcY, + u16 srcWidth, + u16 srcHeight, + u8 *dstPixels, + u16 dstWidth, + u16 dstHeight, + u16 dstX, + u16 dstY, + u16 width, + u16 height) +{ + struct Bitmap src; + src.pixels = srcPixels; + src.width = srcWidth; + src.height = srcHeight; + + struct Bitmap dst; + dst.pixels = dstPixels; + dst.width = dstWidth; + dst.height = dstHeight; + + BlitBitmapRect4Bit(&src, &dst, srcX, srcY, dstX, dstY, width, height, 0); +} + +THUMB_FUNC void FUN_0200D18C(struct Window *window, u16 fill_value) +{ + u32 heap_id = BgConfig_GetHeapId(window->bgConfig); + u8 bg_id = GetWindowBgId(window); + + void *ptr = AllocFromHeap(heap_id, 0x180); + void *charptr = BgGetCharPtr(bg_id); + + NNSG2dCharacterData *pCharData; + void *st30; + void *st2c; + st2c = GfGfxLoader_GetCharData( + NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0022_NCGR, FALSE, &pCharData, heap_id); + st30 = pCharData->pRawData; + + for (u8 i = 0; i < 3; i++) + { + memcpy(ptr + (i << 7), charptr + ((fill_value + 10) << 5), 0x20); + memcpy(ptr + ((i << 7) + 0x20), charptr + ((fill_value + 11) << 5), 0x20); + memcpy(ptr + ((i << 7) + 0x40), charptr + ((fill_value + 10) << 5), 0x20); + memcpy(ptr + ((i << 7) + 0x60), charptr + ((fill_value + 11) << 5), 0x20); + } + + BlitRect4Bit(st30, 4, 0, 12, 0x30, ptr, 12, 0x30, 1, 0, 12, 0x30); + BG_LoadCharTilesData(window->bgConfig, bg_id, ptr, 0x180, (u32)(fill_value + 18)); + FUN_02002840(fill_value); + FreeToHeap(st2c); + FreeToHeap(ptr); +} + +THUMB_FUNC void FUN_0200D274( + struct BgConfig *bg_config, u8 bg_id, u16 param2, u8 param3, u8 param4, u32 heap_id) +{ + + NNSG2dCharacterData *pCharData; + void *stc = GfGfxLoader_GetCharData( + NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), FALSE, &pCharData, heap_id); + u8 *ptr = AllocFromHeap(heap_id, 0x240); + memcpy(ptr, pCharData->pRawData, 0x240); + + for (u32 r3 = 0; r3 < 0x240; r3++) + { + u8 r6 = (u8)(ptr[r3] >> 4); + u8 r2 = (u8)(ptr[r3] & 0xf); + if (r6 == 0) + { + r6 = param3; + } + if (r2 == 0) + { + r2 = param3; + } + + ptr[r3] = (u8)(r2 | (r6 << 4)); + } + + BG_LoadCharTilesData(bg_config, bg_id, (u32 *)ptr, 0x240, param2); + FreeToHeap(stc); + FreeToHeap(ptr); +} + +THUMB_FUNC void FUN_0200D300(struct BgConfig *bg_config, + u8 bg_id, + u16 numtiles, + u8 param3, + u8 param4, + u16 param5, + u32 heap_id) +{ + GfGfxLoader_LoadCharData(NARC_GRAPHIC_FIELD_BOARD, + NARC_field_board_narc_0000_NCGR, + bg_config, + bg_id, + numtiles, + 0x3C0, + FALSE, + heap_id); + + NNSG2dPaletteData *pPltData; + void *st14; + st14 = AllocAndReadWholeNarcMemberByIdPair( + NARC_GRAPHIC_FIELD_BOARD, NARC_field_board_narc_0001_NCLR, heap_id); + NNS_G2dGetUnpackedPaletteData(st14, &pPltData); + BG_LoadPlttData(bg_id, pPltData->pRawData + param4 * 0x20, 0x20, (u16)(param3 << 5)); + FreeToHeapExplicit(heap_id, st14); + + if (param4 <= 1) + { + FUN_0200D378(bg_config, bg_id, (u16)(numtiles + 30), param4, param5, heap_id); + } +} + +THUMB_FUNC void FUN_0200D378( + struct BgConfig *bg_config, u8 bg_id, u16 numtiles, u8 param3, u16 param4, u32 heap_id) +{ + if (param3 == 0) + { + param4 += 33; + } + else + { + param4 += 2; + } + + GfGfxLoader_LoadCharData( + NARC_GRAPHIC_FIELD_BOARD, param4, bg_config, bg_id, numtiles, 0x300, FALSE, heap_id); +} + +THUMB_FUNC void DrawFrame3(struct BgConfig *bgConfig, + u8 bgId, + u8 x, + u8 y, + u8 width, + u8 height, + u8 paletteNum, + u16 fillValue) +{ + FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 9), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 8), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(fillValue + 2), + (u8)(x - 7), + (u8)(y - 1), + (u8)(width + 7), + 1, + paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 4), (u8)(x + width + 1), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width + 2), (u8)(y - 1), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 9), y, 1, height, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 8), y, 1, height, paletteNum); + FillBgTilemapRect(bgConfig, bgId, (u16)(fillValue + 8), (u8)(x - 1), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 9), (u8)(y + height), 1, 1, paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 8), (u8)(y + height), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(fillValue + 14), + (u8)(x - 7), + (u8)(y + height), + (u8)(width + 7), + 1, + paletteNum); + FillBgTilemapRect( + bgConfig, bgId, (u16)(fillValue + 15), (u8)(x + width), (u8)(y + height), 1, 1, paletteNum); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(fillValue + 16), + (u8)(x + width + 1), + (u8)(y + height), + 1, + 1, + paletteNum); + FillBgTilemapRect(bgConfig, + bgId, + (u16)(fillValue + 17), + (u8)(x + width + 2), + (u8)(y + height), + 1, + 1, + paletteNum); +} + +THUMB_FUNC void DrawWindowCorner(struct Window *window, u16 fillValue, u8 paletteNum) +{ + u16 i, j; + u16 x, y; + u8 bg_id; + + bg_id = GetWindowBgId(window); + x = (u16)(GetWindowX(window) - 7); + y = GetWindowY(window); + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 6; j++) + { + FillBgTilemapRect(window->bgConfig, + bg_id, + (u16)(fillValue + 6 * i + j), + (u8)(x + j), + (u8)(y + i), + 1, + 1, + paletteNum); + } + } +} + +THUMB_FUNC void DrawFrameAndWindow3( + struct Window *window, BOOL copy_to_vram, u16 fillValue, u8 paletteNum, u8 param4) +{ + u8 bg_id = GetWindowBgId(window); + if (param4 <= 1) + { + DrawFrame3(window->bgConfig, + bg_id, + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + paletteNum, + fillValue); + DrawWindowCorner(window, (u16)(fillValue + 30), paletteNum); + } + else + { + DrawFrame2(window->bgConfig, + bg_id, + GetWindowX(window), + GetWindowY(window), + GetWindowWidth(window), + GetWindowHeight(window), + paletteNum, + fillValue); + } + + if (!copy_to_vram) + { + CopyWindowToVram(window); + } + + FUN_0200D18C(window, fillValue); +} + +THUMB_FUNC void ClearFrameAndWindow3(struct Window *window, u8 param1, BOOL copy_to_vram) +{ + u8 bg_id = GetWindowBgId(window); + if (param1 <= 1) + { + FillBgTilemapRect(window->bgConfig, + bg_id, + 0, + (u8)(GetWindowX(window) - 9), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 11), + (u8)(GetWindowHeight(window) + 2), + 0); + } + else + { + FillBgTilemapRect(window->bgConfig, + bg_id, + 0, + (u8)(GetWindowX(window) - 2), + (u8)(GetWindowY(window) - 1), + (u8)(GetWindowWidth(window) + 4), + (u8)(GetWindowHeight(window) + 2), + 0); + } + + if (!copy_to_vram) + { + ClearWindowTilemapAndCopyToVram(window); + } +} + +THUMB_FUNC struct UnkStruct_0200CABC_1 *FUN_0200D858(struct Window *window, u32 param1) +{ + u32 heap_id = BgConfig_GetHeapId(window->bgConfig); + void *charptr = BgGetCharPtr(GetWindowBgId(window)); + + struct UnkStruct_0200CABC_1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200CABC_1)); + memcpy(ptr->unk004[8], charptr + (param1 + 18) * 32, 0x80); + void *ptr2 = AllocFromHeap(heap_id, 0x80); + memcpy(ptr2, charptr + (param1 + 10) * 32, 0x20); + memcpy(ptr2 + 0x20, charptr + (param1 + 11) * 32, 0x20); + memcpy(ptr2 + 0x40, charptr + (param1 + 10) * 32, 0x20); + memcpy(ptr2 + 0x60, charptr + (param1 + 11) * 32, 0x20); + + for (u8 i = 0; i < 8; i++) + { + memcpy(ptr->unk004[i], ptr2, 0x80); + } + FreeToHeap(ptr2); + + NNSG2dCharacterData *pCharData; + void *r5 = GfGfxLoader_GetCharData( + NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0023_NCGR, FALSE, &pCharData, heap_id); + BlitRect4Bit( + pCharData->pRawData, 0, 0, 0x10, 0x80, ptr->unk004[0], 0x10, 0x80, 0, 0, 0x10, 0x80); + FreeToHeap(r5); + + ptr->unk000 = window; + ptr->fillValue = (u16)param1; + ptr->unk486 = 0; + ptr->unk487 = 0; + ptr->unk488 = 0; + + FUN_0200CA60(FUN_0200DB7C, ptr, 0); + FUN_0200D980(ptr, 1); + + return ptr; +} + +THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) +{ + u8 bg_id = GetWindowBgId(param0->unk000); + u8 x = GetWindowX(param0->unk000); + u8 y = GetWindowY(param0->unk000); + u8 width = GetWindowWidth(param0->unk000); + + if (param1 == 2) + { + BG_LoadCharTilesData(param0->unk000->bgConfig, + bg_id, + (u32 *)param0->unk004[8], + 0x80, + (u32)(param0->fillValue + 18)); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 10), + (u8)(x + width + 1), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 11), + (u8)(x + width + 2), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 10), + (u8)(x + width + 1), + (u8)(y + 3), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 11), + (u8)(x + width + 2), + (u8)(y + 3), + 1, + 1, + 0x10); + BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id); + return; + } + + BG_LoadCharTilesData(param0->unk000->bgConfig, + bg_id, + (u32 *)param0->unk004[param0->unk487], + 0x80, + (u32)(param0->fillValue + 18)); + if (param1 != 0) + { + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 18), + (u8)(x + width + 1), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 19), + (u8)(x + width + 2), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 20), + (u8)(x + width + 1), + (u8)(y + 3), + 1, + 1, + 0x10); + FillBgTilemapRect(param0->unk000->bgConfig, + bg_id, + (u16)(param0->fillValue + 21), + (u8)(x + width + 2), + (u8)(y + 3), + 1, + 1, + 0x10); + BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id); + } +} + +THUMB_FUNC void FUN_0200DB7C(u32 param0, void *param1) +{ + struct UnkStruct_0200CABC_1 *r1 = (struct UnkStruct_0200CABC_1 *)param1; + + if (r1->unk488 != 0) + { + if (r1->unk488 == 1) + { + FUN_0200D980(r1, 2); + } + FUN_0200CAB4((s32)param0); + return; + } + + r1->unk486++; + if (r1->unk486 == 16) + { + r1->unk486 = 0; + r1->unk487 = (r1->unk487 + 1) & 7; + FUN_0200D980(r1, 0); + } +} + +THUMB_FUNC void FUN_0200DBE8(u32 param0, void *param1) +{ + FreeToHeap(param1); + FUN_0200CAB4((s32)param0); +} + +THUMB_FUNC void FUN_0200DBFC(struct UnkStruct_0200CABC_1 *param0) +{ + FUN_0200CA98(FUN_0200DBE8, param0, 0); + param0->unk488 = 1; +} + +THUMB_FUNC void FUN_0200DC24(struct UnkStruct_0200CABC_1 *param0) +{ + FUN_0200CA98(FUN_0200DBE8, param0, 0); + param0->unk488 = 2; +} + +THUMB_FUNC u8 *FUN_0200DC4C(struct BgConfig *bg_config, + u8 bg_id, + u8 param2, + u8 param3, + u8 param4, + u16 param5, + u16 param6, + u8 param7, + s32 param8) +{ + struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param8); + FUN_0200DDAC(r4, (u32)param8); + FUN_0200DDD8(r4); + FUN_0200DE30(r4, param2, param3); + FUN_0200DE80(r4, param6, param7); + DrawFramed10x10Square(r4, param4, param5); + BgCommitTilemapBufferToVram(bg_config, bg_id); + + return &r4->unk16f; +} + +THUMB_FUNC u8 *FUN_0200DCA4(struct BgConfig *bg_config, + u8 bg_id, + u8 param2, + u8 param3, + u8 param4, + u16 param5, + struct Pokemon *param6, + s32 param7) +{ + struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param7); + FUN_0200DDAC(r4, (u32)param7); + FUN_0200DDD8(r4); + FUN_0200DE30(r4, param2, param3); + FUN_0200DEC0(r4, param6); + DrawFramed10x10Square(r4, param4, param5); + BgCommitTilemapBufferToVram(bg_config, bg_id); + + return &r4->unk16f; +} + +THUMB_FUNC void FUN_0200DCF8(u32 param0, void *param1) +{ + struct UnkStruct_0200CABC_2 *unk = (struct UnkStruct_0200CABC_2 *)param1; + switch (unk->unk16f) + { + case 1: + ClearFramed10x10Square(unk); + FUN_0200C3DC(unk->unk164); + MOD05_021D99F8(unk); + FUN_0200621C((s32)param0); + return; + case 2: + unk->unk16f = 3; + FUN_02020130(*unk->unk164, 1); + break; + case 3: + if (FUN_0202022C(*unk->unk164) == 6) + { + unk->unk16f = 0; + } + } + + FUN_020201E4(*unk->unk164, 0x1000); + FUN_0201FDEC(unk->unk000); +} + +THUMB_FUNC struct UnkStruct_0200CABC_2 *FUN_0200DD70( + struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u32 param4) +{ + struct UnkStruct_0200CABC_2 *res = FUN_0201B6C8(FUN_020061E8(FUN_0200DCF8, 0x170, 0, param4)); + + res->unk16f = 0; + res->bgConfig = bg_config; + res->bgId = bg_id; + res->x = param2; + res->y = param3; + + return res; +} + +THUMB_FUNC void FUN_0200DDAC(struct UnkStruct_0200CABC_2 *param0, u32 param1) +{ + + const u32 UNK_020ECEA8[] = { + 0x01, + 0x01, + 0x01, + 0x01, + 0x00, + 0x00, + }; + MOD05_021D959C(param0, UNK_020ECEA8, 1, param1); +} + +THUMB_FUNC void FUN_0200DDD8(struct UnkStruct_0200CABC_2 *param0) +{ + MOD05_021D967C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0049_NCLR, 0, 1, 1, 0x15CD5); + MOD05_021D96F4(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0047_NCER, 0, 0x15CD5); + MOD05_021D9708(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0046_NANR, 0, 0x15CD5); + MOD05_021D971C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0048_NCGR, 0, 1, 0x15CD5); +} + +THUMB_FUNC void FUN_0200DE30(struct UnkStruct_0200CABC_2 *param0, u8 param1, u8 param2) +{ + u32 UNK_020ECEC0[] = { + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x015CD5, + 0x015CD5, + 0x015CD5, + 0x015CD5, + 0x00, + 0x00, + 0x00, + 0x00, + }; + ((u16 *)UNK_020ECEC0)[0] = (u16)((param1 + 5) * 8); + ((u16 *)UNK_020ECEC0)[1] = (u16)((param2 + 5) * 8); + param0->unk164 = MOD05_021D9820(param0, UNK_020ECEC0); + FUN_0201FDEC(param0->unk000); + GX_EngineBToggleLayers(0x10, GX_LAYER_TOGGLE_ON); +} + +THUMB_FUNC void FUN_0200DE80(struct UnkStruct_0200CABC_2 *param0, u16 param1, u8 param2) +{ + struct UnkStruct63_021DB450 *r7 = FUN_02006D98(param0->unk162); + struct SomeDrawPokemonStruct stc; + FUN_02068C00(&stc, param1, param2, 2, 0, 0, 0); + FUN_0200DEF4(param0, &stc); + FUN_020072E8(r7); +} + +THUMB_FUNC void FUN_0200DEC0(struct UnkStruct_0200CABC_2 *param0, struct Pokemon *param1) +{ + struct UnkStruct63_021DB450 *r6 = FUN_02006D98(param0->unk162); + struct SomeDrawPokemonStruct st0; + FUN_02068B68(&st0, param1, 2); + FUN_0200DEF4(param0, &st0); + FUN_020072E8(r6); +} + +THUMB_FUNC void FUN_0200DEF4( + struct UnkStruct_0200CABC_2 *param0, struct SomeDrawPokemonStruct *param1) +{ + void *r4 = AllocFromHeap(param0->unk162, 0x1900); + + struct UnkStruct_0200CABC_3 st18 = UNK_020ECE98; + FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st18, r4); + + struct UnkStruct_0200CABC_3 st8 = UNK_020ECE88; + FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st8, r4 + 0xc80); + + u32 st4 = FUN_02009C5C(FUN_020094F0(param0->unk130, 0x15CD5)); + + u32 r7 = NNS_G2dGetImageLocation(st4, 1); + DC_FlushRange(r4, 0x1900); + GX_LoadOBJ(r4, r7, 0x1900); + FreeToHeap(r4); + void *res = FUN_02012470(param1->unk0, param1->unk4, param0->unk162); + + u32 r5 = + NNS_G2dGetImagePaletteLocation(FUN_02009E54(FUN_020094F0(param0->unk134, 0x15CD5), st4), 1); + DC_FlushRange(res, 0x20); + GX_LoadOBJPltt(res, r5, 0x20); + FreeToHeap(res); +} + +THUMB_FUNC void DrawFramed10x10Square( + struct UnkStruct_0200CABC_2 *param0, u8 paletteNum, u16 fillValue) +{ + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + fillValue, + (u8)(param0->x - 1), + (u8)(param0->y - 1), + 1, + 1, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 1), + param0->x, + (u8)(param0->y - 1), + 10, + 1, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 2), + (u8)(param0->x + 10), + (u8)(param0->y - 1), + 1, + 1, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 4), + param0->x, + param0->y, + 10, + 10, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 3), + (u8)(param0->x - 1), + param0->y, + 1, + 10, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 5), + (u8)(param0->x + 10), + param0->y, + 1, + 10, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 6), + (u8)(param0->x - 1), + (u8)(param0->y + 10), + 1, + 1, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 7), + param0->x, + (u8)(param0->y + 10), + 10, + 1, + paletteNum); + FillBgTilemapRect(param0->bgConfig, + param0->bgId, + (u16)(fillValue + 8), + (u8)(param0->x + 10), + (u8)(param0->y + 10), + 1, + 1, + paletteNum); + + ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId); +} + +THUMB_FUNC void ClearFramed10x10Square(struct UnkStruct_0200CABC_2 *param0) +{ + FillBgTilemapRect( + param0->bgConfig, param0->bgId, 0, (u8)(param0->x - 1), (u8)(param0->y - 1), 12, 12, 0); + ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId); +} diff --git a/arm9/src/save_data_read_error.c b/arm9/src/save_data_read_error.c index 616578f4..45a0c7bd 100644 --- a/arm9/src/save_data_read_error.c +++ b/arm9/src/save_data_read_error.c @@ -6,7 +6,7 @@ #include "msgdata/msg.naix" #include "save_data_read_error.h" #include "text.h" -#include "unk_0200CABC.h" +#include "render_window.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); diff --git a/arm9/src/save_data_write_error.c b/arm9/src/save_data_write_error.c index 2a8848c6..3f03fb4b 100644 --- a/arm9/src/save_data_write_error.c +++ b/arm9/src/save_data_write_error.c @@ -6,7 +6,7 @@ #include "msgdata/msg.naix" #include "save_data_write_error.h" #include "text.h" -#include "unk_0200CABC.h" +#include "render_window.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index 68769c88..2d57f0b1 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -6,7 +6,7 @@ #include "player_data.h" #include "text.h" #include "bg_window.h" -#include "unk_0200CABC.h" +#include "render_window.h" #include "text_02054590.h" diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c index e3276f25..03d01ae6 100644 --- a/arm9/src/text_02054590.c +++ b/arm9/src/text_02054590.c @@ -3,7 +3,7 @@ #include "bg_window.h" #include "font.h" #include "render_text.h" -#include "unk_0200CABC.h" +#include "render_window.h" extern void FUN_0201BD5C(void); diff --git a/arm9/src/unk_0200CABC.c b/arm9/src/unk_0200CABC.c deleted file mode 100644 index f57469e1..00000000 --- a/arm9/src/unk_0200CABC.c +++ /dev/null @@ -1,1081 +0,0 @@ -#include "global.h" -#include "unk_0200CABC.h" -#include "filesystem.h" -#include "gf_gfx_loader.h" -#include "graphic/field_board.naix" -#include "graphic/winframe.naix" -#include "pokemon.h" -#include "render_text.h" -#include "unk_020061E8.h" -#include "unk_0200BB14.h" -#include "unk_0200CA44.h" - -const struct UnkStruct_0200CABC_3 UNK_020ECE88 = { - 10, - 0, - 10, - 10, -}; - -const struct UnkStruct_0200CABC_3 UNK_020ECE98 = { - 0, - 0, - 10, - 10, -}; - -extern void FUN_02020130(u32 param0, u32 param1); -extern u32 FUN_0202022C(u32 param0); -extern void FUN_020201E4(u32 param0, u32 param1); -extern void FUN_0201FDEC(u32 param0); -extern void MOD05_021D99F8(struct UnkStruct_0200CABC_2 *param0); -extern void *FUN_0201B6C8(BOOL); -extern void MOD05_021D959C( - struct UnkStruct_0200CABC_2 *param0, void *param1, u32 param2, u32 param3); -extern void MOD05_021D967C(struct UnkStruct_0200CABC_2 *param0, - NarcId narcId, - s32 memberId, - u32 param3, - u32 param4, - u32 param5, - u32 param6); -extern void MOD05_021D96F4( - struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4); -extern void MOD05_021D9708( - struct UnkStruct_0200CABC_2 *param0, NarcId narcId, s32 memberId, u32 param3, u32 param4); -extern void MOD05_021D971C(struct UnkStruct_0200CABC_2 *param0, - NarcId narcId, - s32 memberId, - u32 param3, - u32 param4, - u32 param5); -extern u32 *MOD05_021D9820(struct UnkStruct_0200CABC_2 *param0, void *); -extern struct UnkStruct63_021DB450 *FUN_02006D98(u32); -extern void FUN_020072E8(struct UnkStruct63_021DB450 *param0); -extern void FUN_02012400(u16, u16, u16, void *, void *); -extern u32 NNS_G2dGetImageLocation(u32, u32); -extern void *FUN_02012470(u16, u16, u16); -extern u32 NNS_G2dGetImagePaletteLocation(u32, u32); - -THUMB_FUNC u32 FUN_0200CABC( - struct BgConfig *bgConfig, u32 layer, u32 numTiles, u32 param3, u32 heap_id) -{ - if (param3 == 0) - { - return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME, - NARC_winframe_narc_0000_NCGR, - bgConfig, - layer, - numTiles, - 0, - FALSE, - heap_id); - } - - return GfGfxLoader_LoadCharData(NARC_GRAPHIC_WINFRAME, - NARC_winframe_narc_0001_NCGR, - bgConfig, - layer, - numTiles, - 0, - FALSE, - heap_id); -} - -THUMB_FUNC s32 FUN_0200CAFC(void) -{ - return NARC_winframe_narc_0024_NCLR; -} - -THUMB_FUNC void FUN_0200CB00( - struct BgConfig *bg_config, u32 layer, u32 num_tiles, u32 param3, u8 param4, u32 heap_id) -{ - s32 r1; - if (param4 != 0) - { - r1 = NARC_winframe_narc_0001_NCGR; - } - else - { - r1 = NARC_winframe_narc_0000_NCGR; - } - - GfGfxLoader_LoadCharData( - NARC_GRAPHIC_WINFRAME, r1, bg_config, layer, num_tiles, 0, FALSE, heap_id); - - if (param4 == 2) - { - r1 = NARC_winframe_narc_0045_NCLR; - } - else - { - r1 = NARC_winframe_narc_0024_NCLR; - } - - if (layer < 4) - { - GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 0, param3 << 5, 32, heap_id); - return; - } - - GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, r1, 4, param3 << 5, 32, heap_id); -} - -THUMB_FUNC void DrawFrame1(struct BgConfig *bgConfig, - u8 bgId, - u8 x, - u8 y, - u8 width, - u8 height, - u8 paletteNum, - u16 fillValue) -{ - FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 1), x, (u8)(y - 1), width, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 2), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 3), (u8)(x - 1), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 5), (u8)(x + width), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 7), x, (u8)(y + height), width, 1, paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 8), - (u8)(x + width), - (u8)(y + height), - 1, - 1, - paletteNum); -} - -THUMB_FUNC void DrawFrameAndWindow1( - struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) -{ - DrawFrame1(window->bgConfig, - GetWindowBgId(window), - GetWindowX(window), - GetWindowY(window), - GetWindowWidth(window), - GetWindowHeight(window), - palette_num, - fill_value); - - if (!copy_to_vram) - { - CopyWindowToVram(window); - } -} - -THUMB_FUNC void ClearFrameAndWindow1(struct Window *window, BOOL copy_to_vram) -{ - - FillBgTilemapRect(window->bgConfig, - GetWindowBgId(window), - 0, - (u8)(GetWindowX(window) - 1), - (u8)(GetWindowY(window) - 1), - (u8)(GetWindowWidth(window) + 2), - (u8)(GetWindowHeight(window) + 2), - 0); - - if (!copy_to_vram) - { - ClearWindowTilemapAndCopyToVram(window); - } -} - -THUMB_FUNC s32 FUN_0200CD60(s32 param0) -{ - return param0 + 2; -} - -THUMB_FUNC s32 FUN_0200CD64(s32 param0) -{ - return param0 + 25; -} - -THUMB_FUNC void FUN_0200CD68( - struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5) -{ - - GfGfxLoader_LoadCharData( - NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), param0, param1, param2, 0, FALSE, param5); - - if (param1 < 4) - { - GfGfxLoader_GXLoadPal( - NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 0, param3 << 5, 32, param5); - return; - } - - GfGfxLoader_GXLoadPal(NARC_GRAPHIC_WINFRAME, FUN_0200CD64(param4), 4, param3 << 5, 32, param5); -} - -THUMB_FUNC void DrawFrame2(struct BgConfig *bgConfig, - u8 bgId, - u8 x, - u8 y, - u8 width, - u8 height, - u8 paletteNum, - u16 fillValue) -{ - FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 2), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 1), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 2), x, (u8)(y - 1), width, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 4), - (u8)(x + width + 1), - (u8)(y - 1), - 1, - 1, - paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 5), - (u8)(x + width + 2), - (u8)(y - 1), - 1, - 1, - paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 2), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 1), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 2), (u8)(y + height), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 1), (u8)(y + height), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 14), x, (u8)(y + height), width, 1, paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 15), - (u8)(x + width), - (u8)(y + height), - 1, - 1, - paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 16), - (u8)(x + width + 1), - (u8)(y + height), - 1, - 1, - paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 17), - (u8)(x + width + 2), - (u8)(y + height), - 1, - 1, - paletteNum); -} - -THUMB_FUNC void DrawWindowFrame2(struct Window *window, u32 fill_value, u32 palette_num) -{ - DrawFrame2(window->bgConfig, - GetWindowBgId(window), - GetWindowX(window), - GetWindowY(window), - GetWindowWidth(window), - GetWindowHeight(window), - (u8)palette_num, - (u16)fill_value); -} - -THUMB_FUNC void DrawFrameAndWindow2( - struct Window *window, BOOL copy_to_vram, u16 fill_value, u8 palette_num) -{ - DrawWindowFrame2(window, fill_value, palette_num); - if (!copy_to_vram) - { - CopyWindowToVram(window); - } - - FUN_0200D18C(window, fill_value); -} - -THUMB_FUNC void ClearFrameAndWindow2(struct Window *window, BOOL param1) -{ - FillBgTilemapRect(window->bgConfig, - GetWindowBgId(window), - 0, - (u8)(GetWindowX(window) - 2), - (u8)(GetWindowY(window) - 1), - (u8)(GetWindowWidth(window) + 5), - (u8)(GetWindowHeight(window) + 2), - 0); - - if (!param1) - { - ClearWindowTilemapAndCopyToVram(window); - } -} - -THUMB_FUNC void BlitRect4Bit(u8 *srcPixels, - u16 srcX, - u16 srcY, - u16 srcWidth, - u16 srcHeight, - u8 *dstPixels, - u16 dstWidth, - u16 dstHeight, - u16 dstX, - u16 dstY, - u16 width, - u16 height) -{ - struct Bitmap src; - src.pixels = srcPixels; - src.width = srcWidth; - src.height = srcHeight; - - struct Bitmap dst; - dst.pixels = dstPixels; - dst.width = dstWidth; - dst.height = dstHeight; - - BlitBitmapRect4Bit(&src, &dst, srcX, srcY, dstX, dstY, width, height, 0); -} - -THUMB_FUNC void FUN_0200D18C(struct Window *window, u16 fill_value) -{ - u32 heap_id = BgConfig_GetHeapId(window->bgConfig); - u8 bg_id = GetWindowBgId(window); - - void *ptr = AllocFromHeap(heap_id, 0x180); - void *charptr = BgGetCharPtr(bg_id); - - NNSG2dCharacterData *pCharData; - void *st30; - void *st2c; - st2c = GfGfxLoader_GetCharData( - NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0022_NCGR, FALSE, &pCharData, heap_id); - st30 = pCharData->pRawData; - - for (u8 i = 0; i < 3; i++) - { - memcpy(ptr + (i << 7), charptr + ((fill_value + 10) << 5), 0x20); - memcpy(ptr + ((i << 7) + 0x20), charptr + ((fill_value + 11) << 5), 0x20); - memcpy(ptr + ((i << 7) + 0x40), charptr + ((fill_value + 10) << 5), 0x20); - memcpy(ptr + ((i << 7) + 0x60), charptr + ((fill_value + 11) << 5), 0x20); - } - - BlitRect4Bit(st30, 4, 0, 12, 0x30, ptr, 12, 0x30, 1, 0, 12, 0x30); - BG_LoadCharTilesData(window->bgConfig, bg_id, ptr, 0x180, (u32)(fill_value + 18)); - FUN_02002840(fill_value); - FreeToHeap(st2c); - FreeToHeap(ptr); -} - -THUMB_FUNC void FUN_0200D274( - struct BgConfig *bg_config, u8 bg_id, u16 param2, u8 param3, u8 param4, u32 heap_id) -{ - - NNSG2dCharacterData *pCharData; - void *stc = GfGfxLoader_GetCharData( - NARC_GRAPHIC_WINFRAME, FUN_0200CD60(param4), FALSE, &pCharData, heap_id); - u8 *ptr = AllocFromHeap(heap_id, 0x240); - memcpy(ptr, pCharData->pRawData, 0x240); - - for (u32 r3 = 0; r3 < 0x240; r3++) - { - u8 r6 = (u8)(ptr[r3] >> 4); - u8 r2 = (u8)(ptr[r3] & 0xf); - if (r6 == 0) - { - r6 = param3; - } - if (r2 == 0) - { - r2 = param3; - } - - ptr[r3] = (u8)(r2 | (r6 << 4)); - } - - BG_LoadCharTilesData(bg_config, bg_id, (u32 *)ptr, 0x240, param2); - FreeToHeap(stc); - FreeToHeap(ptr); -} - -THUMB_FUNC void FUN_0200D300(struct BgConfig *bg_config, - u8 bg_id, - u16 numtiles, - u8 param3, - u8 param4, - u16 param5, - u32 heap_id) -{ - GfGfxLoader_LoadCharData(NARC_GRAPHIC_FIELD_BOARD, - NARC_field_board_narc_0000_NCGR, - bg_config, - bg_id, - numtiles, - 0x3C0, - FALSE, - heap_id); - - NNSG2dPaletteData *pPltData; - void *st14; - st14 = AllocAndReadWholeNarcMemberByIdPair( - NARC_GRAPHIC_FIELD_BOARD, NARC_field_board_narc_0001_NCLR, heap_id); - NNS_G2dGetUnpackedPaletteData(st14, &pPltData); - BG_LoadPlttData(bg_id, pPltData->pRawData + param4 * 0x20, 0x20, (u16)(param3 << 5)); - FreeToHeapExplicit(heap_id, st14); - - if (param4 <= 1) - { - FUN_0200D378(bg_config, bg_id, (u16)(numtiles + 30), param4, param5, heap_id); - } -} - -THUMB_FUNC void FUN_0200D378( - struct BgConfig *bg_config, u8 bg_id, u16 numtiles, u8 param3, u16 param4, u32 heap_id) -{ - if (param3 == 0) - { - param4 += 33; - } - else - { - param4 += 2; - } - - GfGfxLoader_LoadCharData( - NARC_GRAPHIC_FIELD_BOARD, param4, bg_config, bg_id, numtiles, 0x300, FALSE, heap_id); -} - -THUMB_FUNC void DrawFrame3(struct BgConfig *bgConfig, - u8 bgId, - u8 x, - u8 y, - u8 width, - u8 height, - u8 paletteNum, - u16 fillValue) -{ - FillBgTilemapRect(bgConfig, bgId, fillValue, (u8)(x - 9), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 1), (u8)(x - 8), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 2), - (u8)(x - 7), - (u8)(y - 1), - (u8)(width + 7), - 1, - paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 3), (u8)(x + width), (u8)(y - 1), 1, 1, paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 4), - (u8)(x + width + 1), - (u8)(y - 1), - 1, - 1, - paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 5), - (u8)(x + width + 2), - (u8)(y - 1), - 1, - 1, - paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 6), (u8)(x - 9), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 7), (u8)(x - 8), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 8), (u8)(x - 1), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 9), (u8)(x + width), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 10), (u8)(x + width + 1), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 11), (u8)(x + width + 2), y, 1, height, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 12), (u8)(x - 9), (u8)(y + height), 1, 1, paletteNum); - FillBgTilemapRect( - bgConfig, bgId, (u16)(fillValue + 13), (u8)(x - 8), (u8)(y + height), 1, 1, paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 14), - (u8)(x - 7), - (u8)(y + height), - (u8)(width + 7), - 1, - paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 15), - (u8)(x + width), - (u8)(y + height), - 1, - 1, - paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 16), - (u8)(x + width + 1), - (u8)(y + height), - 1, - 1, - paletteNum); - FillBgTilemapRect(bgConfig, - bgId, - (u16)(fillValue + 17), - (u8)(x + width + 2), - (u8)(y + height), - 1, - 1, - paletteNum); -} - -THUMB_FUNC void DrawWindowCorner(struct Window *window, u16 fillValue, u8 paletteNum) -{ - u16 i, j; - u16 x, y; - u8 bg_id; - - bg_id = GetWindowBgId(window); - x = (u16)(GetWindowX(window) - 7); - y = GetWindowY(window); - - for (i = 0; i < 4; i++) - { - for (j = 0; j < 6; j++) - { - FillBgTilemapRect(window->bgConfig, - bg_id, - (u16)(fillValue + 6 * i + j), - (u8)(x + j), - (u8)(y + i), - 1, - 1, - paletteNum); - } - } -} - -THUMB_FUNC void DrawFrameAndWindow3(struct Window *window, BOOL copy_to_vram, u16 fillValue, u8 paletteNum, u8 param4) -{ - u8 bg_id = GetWindowBgId(window); - if (param4 <= 1) - { - DrawFrame3(window->bgConfig, - bg_id, - GetWindowX(window), - GetWindowY(window), - GetWindowWidth(window), - GetWindowHeight(window), - paletteNum, - fillValue); - DrawWindowCorner(window, (u16)(fillValue + 30), paletteNum); - } - else - { - DrawFrame2(window->bgConfig, - bg_id, - GetWindowX(window), - GetWindowY(window), - GetWindowWidth(window), - GetWindowHeight(window), - paletteNum, - fillValue); - } - - if (!copy_to_vram) - { - CopyWindowToVram(window); - } - - FUN_0200D18C(window, fillValue); -} - -THUMB_FUNC void ClearFrameAndWindow3(struct Window *window, u8 param1, BOOL copy_to_vram) -{ - u8 bg_id = GetWindowBgId(window); - if (param1 <= 1) - { - FillBgTilemapRect(window->bgConfig, - bg_id, - 0, - (u8)(GetWindowX(window) - 9), - (u8)(GetWindowY(window) - 1), - (u8)(GetWindowWidth(window) + 11), - (u8)(GetWindowHeight(window) + 2), - 0); - } - else - { - FillBgTilemapRect(window->bgConfig, - bg_id, - 0, - (u8)(GetWindowX(window) - 2), - (u8)(GetWindowY(window) - 1), - (u8)(GetWindowWidth(window) + 4), - (u8)(GetWindowHeight(window) + 2), - 0); - } - - if (!copy_to_vram) - { - ClearWindowTilemapAndCopyToVram(window); - } -} - -THUMB_FUNC struct UnkStruct_0200CABC_1 *FUN_0200D858(struct Window *window, u32 param1) -{ - u32 heap_id = BgConfig_GetHeapId(window->bgConfig); - void *charptr = BgGetCharPtr(GetWindowBgId(window)); - - struct UnkStruct_0200CABC_1 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200CABC_1)); - memcpy(ptr->unk004[8], charptr + (param1 + 18) * 32, 0x80); - void *ptr2 = AllocFromHeap(heap_id, 0x80); - memcpy(ptr2, charptr + (param1 + 10) * 32, 0x20); - memcpy(ptr2 + 0x20, charptr + (param1 + 11) * 32, 0x20); - memcpy(ptr2 + 0x40, charptr + (param1 + 10) * 32, 0x20); - memcpy(ptr2 + 0x60, charptr + (param1 + 11) * 32, 0x20); - - for (u8 i = 0; i < 8; i++) - { - memcpy(ptr->unk004[i], ptr2, 0x80); - } - FreeToHeap(ptr2); - - NNSG2dCharacterData *pCharData; - void *r5 = GfGfxLoader_GetCharData( - NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0023_NCGR, FALSE, &pCharData, heap_id); - BlitRect4Bit( - pCharData->pRawData, 0, 0, 0x10, 0x80, ptr->unk004[0], 0x10, 0x80, 0, 0, 0x10, 0x80); - FreeToHeap(r5); - - ptr->unk000 = window; - ptr->fillValue = (u16)param1; - ptr->unk486 = 0; - ptr->unk487 = 0; - ptr->unk488 = 0; - - FUN_0200CA60(FUN_0200DB7C, ptr, 0); - FUN_0200D980(ptr, 1); - - return ptr; -} - -THUMB_FUNC void FUN_0200D980(struct UnkStruct_0200CABC_1 *param0, u32 param1) -{ - u8 bg_id = GetWindowBgId(param0->unk000); - u8 x = GetWindowX(param0->unk000); - u8 y = GetWindowY(param0->unk000); - u8 width = GetWindowWidth(param0->unk000); - - if (param1 == 2) - { - BG_LoadCharTilesData(param0->unk000->bgConfig, - bg_id, - (u32 *)param0->unk004[8], - 0x80, - (u32)(param0->fillValue + 18)); - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 10), - (u8)(x + width + 1), - (u8)(y + 2), - 1, - 1, - 0x10); - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 11), - (u8)(x + width + 2), - (u8)(y + 2), - 1, - 1, - 0x10); - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 10), - (u8)(x + width + 1), - (u8)(y + 3), - 1, - 1, - 0x10); - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 11), - (u8)(x + width + 2), - (u8)(y + 3), - 1, - 1, - 0x10); - BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id); - return; - } - - BG_LoadCharTilesData(param0->unk000->bgConfig, - bg_id, - (u32 *)param0->unk004[param0->unk487], - 0x80, - (u32)(param0->fillValue + 18)); - if (param1 != 0) - { - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 18), - (u8)(x + width + 1), - (u8)(y + 2), - 1, - 1, - 0x10); - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 19), - (u8)(x + width + 2), - (u8)(y + 2), - 1, - 1, - 0x10); - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 20), - (u8)(x + width + 1), - (u8)(y + 3), - 1, - 1, - 0x10); - FillBgTilemapRect(param0->unk000->bgConfig, - bg_id, - (u16)(param0->fillValue + 21), - (u8)(x + width + 2), - (u8)(y + 3), - 1, - 1, - 0x10); - BgCommitTilemapBufferToVram(param0->unk000->bgConfig, bg_id); - } -} - -THUMB_FUNC void FUN_0200DB7C(u32 param0, void *param1) -{ - struct UnkStruct_0200CABC_1 *r1 = (struct UnkStruct_0200CABC_1 *)param1; - - if (r1->unk488 != 0) - { - if (r1->unk488 == 1) - { - FUN_0200D980(r1, 2); - } - FUN_0200CAB4((s32)param0); - return; - } - - r1->unk486++; - if (r1->unk486 == 16) - { - r1->unk486 = 0; - r1->unk487 = (r1->unk487 + 1) & 7; - FUN_0200D980(r1, 0); - } -} - -THUMB_FUNC void FUN_0200DBE8(u32 param0, void *param1) -{ - FreeToHeap(param1); - FUN_0200CAB4((s32)param0); -} - -THUMB_FUNC void FUN_0200DBFC(struct UnkStruct_0200CABC_1 *param0) -{ - FUN_0200CA98(FUN_0200DBE8, param0, 0); - param0->unk488 = 1; -} - -THUMB_FUNC void FUN_0200DC24(struct UnkStruct_0200CABC_1 *param0) -{ - FUN_0200CA98(FUN_0200DBE8, param0, 0); - param0->unk488 = 2; -} - -THUMB_FUNC u8 *FUN_0200DC4C(struct BgConfig *bg_config, - u8 bg_id, - u8 param2, - u8 param3, - u8 param4, - u16 param5, - u16 param6, - u8 param7, - s32 param8) -{ - struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param8); - FUN_0200DDAC(r4, (u32)param8); - FUN_0200DDD8(r4); - FUN_0200DE30(r4, param2, param3); - FUN_0200DE80(r4, param6, param7); - DrawFramed10x10Square(r4, param4, param5); - BgCommitTilemapBufferToVram(bg_config, bg_id); - - return &r4->unk16f; -} - -THUMB_FUNC u8 *FUN_0200DCA4(struct BgConfig *bg_config, - u8 bg_id, - u8 param2, - u8 param3, - u8 param4, - u16 param5, - struct Pokemon *param6, - s32 param7) -{ - struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param7); - FUN_0200DDAC(r4, (u32)param7); - FUN_0200DDD8(r4); - FUN_0200DE30(r4, param2, param3); - FUN_0200DEC0(r4, param6); - DrawFramed10x10Square(r4, param4, param5); - BgCommitTilemapBufferToVram(bg_config, bg_id); - - return &r4->unk16f; -} - -THUMB_FUNC void FUN_0200DCF8(u32 param0, void *param1) -{ - struct UnkStruct_0200CABC_2 *unk = (struct UnkStruct_0200CABC_2 *)param1; - switch (unk->unk16f) - { - case 1: - ClearFramed10x10Square(unk); - FUN_0200C3DC(unk->unk164); - MOD05_021D99F8(unk); - FUN_0200621C((s32)param0); - return; - case 2: - unk->unk16f = 3; - FUN_02020130(*unk->unk164, 1); - break; - case 3: - if (FUN_0202022C(*unk->unk164) == 6) - { - unk->unk16f = 0; - } - } - - FUN_020201E4(*unk->unk164, 0x1000); - FUN_0201FDEC(unk->unk000); -} - -THUMB_FUNC struct UnkStruct_0200CABC_2 *FUN_0200DD70( - struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u32 param4) -{ - struct UnkStruct_0200CABC_2 *res = FUN_0201B6C8(FUN_020061E8(FUN_0200DCF8, 0x170, 0, param4)); - - res->unk16f = 0; - res->bgConfig = bg_config; - res->bgId = bg_id; - res->x = param2; - res->y = param3; - - return res; -} - -THUMB_FUNC void FUN_0200DDAC(struct UnkStruct_0200CABC_2 *param0, u32 param1) -{ - - const u32 UNK_020ECEA8[] = { - 0x01, - 0x01, - 0x01, - 0x01, - 0x00, - 0x00, - }; - MOD05_021D959C(param0, UNK_020ECEA8, 1, param1); -} - -THUMB_FUNC void FUN_0200DDD8(struct UnkStruct_0200CABC_2 *param0) -{ - MOD05_021D967C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0049_NCLR, 0, 1, 1, 0x15CD5); - MOD05_021D96F4(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0047_NCER, 0, 0x15CD5); - MOD05_021D9708(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0046_NANR, 0, 0x15CD5); - MOD05_021D971C(param0, NARC_GRAPHIC_WINFRAME, NARC_winframe_narc_0048_NCGR, 0, 1, 0x15CD5); -} - -THUMB_FUNC void FUN_0200DE30(struct UnkStruct_0200CABC_2 *param0, u8 param1, u8 param2) -{ - u32 UNK_020ECEC0[] = { - 0x00, - 0x00, - 0x00, - 0x00, - 0x01, - 0x015CD5, - 0x015CD5, - 0x015CD5, - 0x015CD5, - 0x00, - 0x00, - 0x00, - 0x00, - }; - ((u16 *)UNK_020ECEC0)[0] = (u16)((param1 + 5) * 8); - ((u16 *)UNK_020ECEC0)[1] = (u16)((param2 + 5) * 8); - param0->unk164 = MOD05_021D9820(param0, UNK_020ECEC0); - FUN_0201FDEC(param0->unk000); - GX_EngineBToggleLayers(0x10, GX_LAYER_TOGGLE_ON); -} - -THUMB_FUNC void FUN_0200DE80(struct UnkStruct_0200CABC_2 *param0, u16 param1, u8 param2) -{ - struct UnkStruct63_021DB450 *r7 = FUN_02006D98(param0->unk162); - struct SomeDrawPokemonStruct stc; - FUN_02068C00(&stc, param1, param2, 2, 0, 0, 0); - FUN_0200DEF4(param0, &stc); - FUN_020072E8(r7); -} - -THUMB_FUNC void FUN_0200DEC0(struct UnkStruct_0200CABC_2 *param0, struct Pokemon *param1) -{ - struct UnkStruct63_021DB450 *r6 = FUN_02006D98(param0->unk162); - struct SomeDrawPokemonStruct st0; - FUN_02068B68(&st0, param1, 2); - FUN_0200DEF4(param0, &st0); - FUN_020072E8(r6); -} - -THUMB_FUNC void FUN_0200DEF4( - struct UnkStruct_0200CABC_2 *param0, struct SomeDrawPokemonStruct *param1) -{ - void *r4 = AllocFromHeap(param0->unk162, 0x1900); - - struct UnkStruct_0200CABC_3 st18 = UNK_020ECE98; - FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st18, r4); - - struct UnkStruct_0200CABC_3 st8 = UNK_020ECE88; - FUN_02012400(param1->unk0, param1->unk2, param0->unk162, &st8, r4 + 0xc80); - - u32 st4 = FUN_02009C5C(FUN_020094F0(param0->unk130, 0x15CD5)); - - u32 r7 = NNS_G2dGetImageLocation(st4, 1); - DC_FlushRange(r4, 0x1900); - GX_LoadOBJ(r4, r7, 0x1900); - FreeToHeap(r4); - void *res = FUN_02012470(param1->unk0, param1->unk4, param0->unk162); - - u32 r5 = - NNS_G2dGetImagePaletteLocation(FUN_02009E54(FUN_020094F0(param0->unk134, 0x15CD5), st4), 1); - DC_FlushRange(res, 0x20); - GX_LoadOBJPltt(res, r5, 0x20); - FreeToHeap(res); -} - -THUMB_FUNC void DrawFramed10x10Square(struct UnkStruct_0200CABC_2 *param0, u8 paletteNum, u16 fillValue) -{ - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - fillValue, - (u8)(param0->x - 1), - (u8)(param0->y - 1), - 1, - 1, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 1), - param0->x, - (u8)(param0->y - 1), - 10, - 1, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 2), - (u8)(param0->x + 10), - (u8)(param0->y - 1), - 1, - 1, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 4), - param0->x, - param0->y, - 10, - 10, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 3), - (u8)(param0->x - 1), - param0->y, - 1, - 10, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 5), - (u8)(param0->x + 10), - param0->y, - 1, - 10, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 6), - (u8)(param0->x - 1), - (u8)(param0->y + 10), - 1, - 1, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 7), - param0->x, - (u8)(param0->y + 10), - 10, - 1, - paletteNum); - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - (u16)(fillValue + 8), - (u8)(param0->x + 10), - (u8)(param0->y + 10), - 1, - 1, - paletteNum); - - ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId); -} - -THUMB_FUNC void ClearFramed10x10Square(struct UnkStruct_0200CABC_2 *param0) -{ - FillBgTilemapRect(param0->bgConfig, - param0->bgId, - 0, - (u8)(param0->x - 1), - (u8)(param0->y - 1), - 12, - 12, - 0); - ScheduleBgTilemapBufferTransfer(param0->bgConfig, param0->bgId); -} diff --git a/arm9/src/wfc_user_info_warning.c b/arm9/src/wfc_user_info_warning.c index f16b4faa..e48262b0 100644 --- a/arm9/src/wfc_user_info_warning.c +++ b/arm9/src/wfc_user_info_warning.c @@ -11,7 +11,7 @@ #include "text.h" #include "wfc_user_info_warning.h" #include "brightness.h" -#include "unk_0200CABC.h" +#include "render_window.h" extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); -- cgit v1.2.3