diff options
author | PikalaxALT <PikalaxALT@users.noreply.github.com> | 2021-08-05 15:42:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-05 15:42:00 -0400 |
commit | 7ef47d78e4df35da975471c4fd0499e3ca8a1080 (patch) | |
tree | 74a42c95502bc5ddc15a753aaeb9fbf6b06edf83 /arm9/src | |
parent | f00cb7ad08e2b2770e3c4ba8a749a7a9e113b616 (diff) | |
parent | 1da53f50293e9856ed7c5b8d6ae66d8ecce85ecc (diff) |
Merge pull request #440 from remicalixte/unk_02005CFC
decompile unk_02005CFC.s into sound_chatot.c
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/pokemon.c | 11 | ||||
-rw-r--r-- | arm9/src/scrcmd_sound.c | 17 | ||||
-rw-r--r-- | arm9/src/sound.c | 2 | ||||
-rw-r--r-- | arm9/src/sound_chatot.c | 181 | ||||
-rw-r--r-- | arm9/src/unk_020040F4.c | 31 | ||||
-rw-r--r-- | arm9/src/unk_020051F4.c | 6 |
6 files changed, 212 insertions, 36 deletions
diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c index 29075833..6139a21f 100644 --- a/arm9/src/pokemon.c +++ b/arm9/src/pokemon.c @@ -18,6 +18,9 @@ #include "constants/moves.h" #include "constants/sinnoh_dex.h" #include "constants/trainer_classes.h" +#include "unk_020051F4.h" +#include "sound_chatot.h" + #pragma thumb on @@ -3303,25 +3306,25 @@ 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(struct SaveChatotSoundClip *r7, u32 r5, u16 r4, s32 r6, s32 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 { if (sp1C) FUN_02005E80(1); - FUN_02005E90((int)r7, 0, (int)sp18, (int)r6); + FUN_02005E90(r7, 0, sp18, r6); } } 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/scrcmd_sound.c b/arm9/src/scrcmd_sound.c index ae20b5a4..b0993387 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); @@ -41,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; } @@ -199,7 +196,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; @@ -215,7 +212,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; @@ -230,14 +227,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.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..06b2fc64 --- /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(void) +{ + if (*(u8 *)FUN_02003D38(29) == 1 && FUN_02004ABC(14) == 0) + { + FUN_02005DFC(); + + return TRUE; + } + + return FALSE; +} + +THUMB_FUNC BOOL Chatot_checkCry(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 (!Chatot_checkCry(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(void) +{ + u8 *r5 = FUN_02003D38(15); + u8 *r4 = FUN_02003D38(29); + + if (*r5 == 1) + { + FUN_02004C3C(14); + FUN_02004A04(14); + } + + *r4 = 0; +} + +THUMB_FUNC u32 Chatot_startRecording(void) +{ + 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 Chatot_stopRecording(void) +{ + GF_MIC_StopAutoSampling(); +} + +THUMB_FUNC void Chatot_saveRecording(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 BOOL FUN_02005F14(s32 param0) +{ + switch (param0) + { + case 0: + case 1: + case 5: + case 11: + case 12: + return TRUE; + default: + return FALSE; + } +} diff --git a/arm9/src/unk_020040F4.c b/arm9/src/unk_020040F4.c index 5713ddf0..fa1d968f 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); @@ -59,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); @@ -74,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); @@ -87,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); @@ -471,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)); } @@ -544,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); @@ -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(void) { -#pragma unused(param0) GetSoundDataPointer(); return MIC_StopAutoSampling(); } @@ -914,7 +911,7 @@ THUMB_FUNC void FUN_02004C3C(u32 param0) } } -THUMB_FUNC BOOL GF_SndCaptureIsActive() +THUMB_FUNC BOOL GF_SndCaptureIsActive(void) { return NNS_SndCaptureIsActive(); } @@ -936,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(); @@ -948,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(); } @@ -1000,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); @@ -1013,7 +1010,7 @@ THUMB_FUNC u16 FUN_02004D94() return --(*ptr); } -THUMB_FUNC u8 *FUN_02004DB4() +THUMB_FUNC u8 *FUN_02004DB4(void) { return UNK_021C3DE0; } @@ -1345,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) diff --git a/arm9/src/unk_020051F4.c b/arm9/src/unk_020051F4.c index 6da250d5..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(u32); -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) { |