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/arm9.lsf | 2 +- 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 ------------------------------------------------ include/pokemon.h | 3 +- include/sound_chatot.h | 19 +++++ include/unk_02005CFC.h | 19 ----- 10 files changed, 210 insertions(+), 218 deletions(-) create mode 100644 arm9/src/sound_chatot.c delete mode 100644 arm9/src/unk_02005CFC.c create mode 100644 include/sound_chatot.h delete mode 100644 include/unk_02005CFC.h diff --git a/arm9/arm9.lsf b/arm9/arm9.lsf index 25689701..94bf6e35 100644 --- a/arm9/arm9.lsf +++ b/arm9/arm9.lsf @@ -15,7 +15,7 @@ Static arm9 Object sound.o Object unk_020040F4.o Object unk_020051F4.o - Object unk_02005CFC.o + Object sound_chatot.o Object poke_overlay.o Object unk_020061E8.o Object overlay_manager.o 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; - } -} diff --git a/include/pokemon.h b/include/pokemon.h index ec3ac77a..60fa1838 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -10,6 +10,7 @@ #include "constants/pokemon.h" #include "string16.h" #include "player_data.h" +#include "sound_chatot.h" struct BaseStats { /* 0x00 */ u8 hp; @@ -294,7 +295,7 @@ void Party_SpreadPokerus(struct PlayerParty * party); BOOL Pokemon_HasPokerus(struct Pokemon * pokemon); BOOL Pokemon_IsImmuneToPokerus(struct Pokemon * pokemon); void Pokemon_UpdateArceusForme(struct Pokemon * pokemon); -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); void FUN_0206A014(struct Pokemon * pokemon, struct PlayerData * a1, u32 pokeball, u32 a3, u32 encounterType, u32 heap_id); void FUN_0206A094(struct Pokemon * pokemon, u32 a1, u32 a2); BOOL FUN_0206A13C(struct Pokemon * pokemon, u32 a1); diff --git a/include/sound_chatot.h b/include/sound_chatot.h new file mode 100644 index 00000000..fd7184cf --- /dev/null +++ b/include/sound_chatot.h @@ -0,0 +1,19 @@ +#ifndef POKEDIAMOND_SOUND_CHATOT_H +#define POKEDIAMOND_SOUND_CHATOT_H + +#include "global.h" +#include "sav_chatot.h" + +BOOL FUN_02005CFC(); +BOOL FUN_02005D20(struct SaveChatotSoundClip *param0); +u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3); +void FUN_02005DFC(); +u32 FUN_02005E28(); +void FUN_02005E64(); +void FUN_02005E6C(struct SaveChatotSoundClip *param0); +void FUN_02005E80(u8 param0); +void FUN_02005E90(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3); +u32 FUN_02005EE0(struct SaveChatotSoundClip *param0); +u32 FUN_02005F14(s32 param0); + +#endif // POKEDIAMOND_UNK_02005CFC_H diff --git a/include/unk_02005CFC.h b/include/unk_02005CFC.h deleted file mode 100644 index 7b5f73e2..00000000 --- a/include/unk_02005CFC.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef POKEDIAMOND_UNK_02005CFC_H -#define POKEDIAMOND_UNK_02005CFC_H - -#include "global.h" -#include "sav_chatot.h" - -BOOL FUN_02005CFC(); -BOOL FUN_02005D20(struct SaveChatotSoundClip *param0); -u32 FUN_02005D48(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3); -void FUN_02005DFC(); -u32 FUN_02005E28(); -void FUN_02005E64(); -void FUN_02005E6C(struct SaveChatotSoundClip *param0); -void FUN_02005E80(u8 param0); -void FUN_02005E90(struct SaveChatotSoundClip *param0, u32 param1, s32 param2, s32 param3); -u32 FUN_02005EE0(struct SaveChatotSoundClip *param0); -u32 FUN_02005F14(s32 param0); - -#endif // POKEDIAMOND_UNK_02005CFC_H -- cgit v1.2.3