summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arm9/asm/unk_02005CFC.s303
-rw-r--r--arm9/lib/NitroSDK/include/SPI_mic.h17
-rw-r--r--arm9/src/pokemon.c12
-rw-r--r--arm9/src/unk_020040F4.c9
-rw-r--r--arm9/src/unk_020051F4.c2
-rw-r--r--arm9/src/unk_02005CFC.c181
-rw-r--r--include/pokemon.h2
-rw-r--r--include/proto.h4
-rw-r--r--include/unk_020040F4.h5
-rw-r--r--include/unk_02005CFC.h19
10 files changed, 234 insertions, 320 deletions
diff --git a/arm9/asm/unk_02005CFC.s b/arm9/asm/unk_02005CFC.s
deleted file mode 100644
index e56b613f..00000000
--- a/arm9/asm/unk_02005CFC.s
+++ /dev/null
@@ -1,303 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .text
-
- thumb_func_start FUN_02005CFC
-FUN_02005CFC: ; 0x02005CFC
- push {r3, lr}
- mov r0, #0x1d
- bl FUN_02003D38
- ldrb r0, [r0, #0x0]
- cmp r0, #0x1
- bne _02005D1C
- mov r0, #0xe
- bl FUN_02004ABC
- cmp r0, #0x0
- bne _02005D1C
- bl FUN_02005DFC
- mov r0, #0x1
- pop {r3, pc}
-_02005D1C:
- mov r0, #0x0
- pop {r3, pc}
-
- thumb_func_start FUN_02005D20
-FUN_02005D20: ; 0x02005D20
- push {r3-r5, lr}
- add r5, r0, #0x0
- mov r0, #0x1e
- bl FUN_02003D38
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl Chatot_exists
- cmp r0, #0x0
- bne _02005D3A
- mov r0, #0x0
- pop {r3-r5, pc}
-_02005D3A:
- ldrb r0, [r4, #0x0]
- cmp r0, #0x1
- beq _02005D44
- mov r0, #0x1
- pop {r3-r5, pc}
-_02005D44:
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start FUN_02005D48
-FUN_02005D48: ; 0x02005D48
- push {r3-r7, lr}
- sub sp, #0x30
- add r6, r0, #0x0
- add r5, r2, #0x0
- add r7, r3, #0x0
- bl FUN_02004DB4
- str r0, [sp, #0x0]
- mov r0, #0x1d
- bl FUN_02003D38
- str r0, [sp, #0x4]
- add r0, r6, #0x0
- bl FUN_02005D20
- cmp r0, #0x0
- bne _02005D70
- add sp, #0x30
- mov r0, #0x0
- pop {r3-r7, pc}
-_02005D70:
- mov r0, #0x0
- bl FUN_02005614
- bl FUN_02005DFC
- mov r0, #0xe
- bl FUN_02004984
- bl LCRandom
- lsr r2, r0, #0x1f
- lsl r1, r0, #0x13
- sub r1, r1, r2
- mov r0, #0x13
- ror r1, r0
- add r0, r2, r1
- lsl r0, r0, #0x10
- lsr r4, r0, #0x10
- add r0, r6, #0x0
- bl Chatot_GetData
- add r1, r0, #0x0
- ldr r0, [sp, #0x0]
- bl Chatot_Decode
- mov r0, #0xe
- bl FUN_02004930
- str r0, [sp, #0x8]
- mov r0, #0x0
- str r0, [sp, #0xc]
- bl FUN_02004DB4
- str r0, [sp, #0x10]
- mov r0, #0x0
- str r0, [sp, #0x14]
- str r0, [sp, #0x18]
- mov r0, #0x7d
- lsl r0, r0, #0x4
- str r0, [sp, #0x1c]
- str r0, [sp, #0x20]
- mov r0, #0x2
- lsl r0, r0, #0xe
- add r0, r4, r0
- str r0, [sp, #0x28]
- lsr r0, r7, #0x1f
- add r0, r7, r0
- asr r0, r0, #0x1
- add r0, #0x40
- str r0, [sp, #0x2c]
- add r0, sp, #0x8
- mov r1, #0xe
- str r5, [sp, #0x24]
- bl FUN_02004A6C
- add r4, r0, #0x0
- mov r0, #0xe
- add r1, r5, #0x0
- bl FUN_02004AF8
- ldr r0, [sp, #0x4]
- mov r1, #0x1
- strb r1, [r0, #0x0]
- mov r0, #0x0
- bl FUN_02005E80
- add r0, r4, #0x0
- add sp, #0x30
- pop {r3-r7, pc}
- .balign 4
-
- thumb_func_start FUN_02005DFC
-FUN_02005DFC: ; 0x02005DFC
- push {r3-r5, lr}
- mov r0, #0xf
- bl FUN_02003D38
- add r5, r0, #0x0
- mov r0, #0x1d
- bl FUN_02003D38
- add r4, r0, #0x0
- ldrb r0, [r5, #0x0]
- cmp r0, #0x1
- bne _02005E20
- mov r0, #0xe
- bl FUN_02004C3C
- mov r0, #0xe
- bl FUN_02004A04
-_02005E20:
- mov r0, #0x0
- strb r0, [r4, #0x0]
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start FUN_02005E28
-FUN_02005E28: ; 0x02005E28
- push {lr}
- sub sp, #0x1c
- mov r0, #0x2
- str r0, [sp, #0x0]
- bl FUN_02004DB4
- mov r1, #0x7d
- str r0, [sp, #0x4]
- lsl r1, r1, #0x4
- mov r0, #0x1f
- str r1, [sp, #0x8]
- tst r0, r1
- beq _02005E48
- mov r0, #0x1f
- bic r1, r0
- str r1, [sp, #0x8]
-_02005E48:
- ldr r0, _02005E60 ; =0x00004174
- str r0, [sp, #0xc]
- mov r0, #0x0
- str r0, [sp, #0x10]
- str r0, [sp, #0x14]
- str r0, [sp, #0x18]
- add r0, sp, #0x0
- bl GF_MIC_StartAutoSampling
- add sp, #0x1c
- pop {pc}
- nop
-_02005E60: .word 0x00004174
-
- thumb_func_start FUN_02005E64
-FUN_02005E64: ; 0x02005E64
- ldr r3, _02005E68 ; =GF_MIC_StopAutoSampling
- bx r3
- .balign 4
-_02005E68: .word GF_MIC_StopAutoSampling
-
- thumb_func_start FUN_02005E6C
-FUN_02005E6C: ; 0x02005E6C
- push {r4, lr}
- add r4, r0, #0x0
- bl FUN_02004DB4
- add r1, r0, #0x0
- add r0, r4, #0x0
- bl Chatot_Encode
- pop {r4, pc}
- .balign 4
-
- thumb_func_start FUN_02005E80
-FUN_02005E80: ; 0x02005E80
- push {r4, lr}
- add r4, r0, #0x0
- mov r0, #0x1e
- bl FUN_02003D38
- strb r4, [r0, #0x0]
- pop {r4, pc}
- .balign 4
-
- thumb_func_start FUN_02005E90
-FUN_02005E90: ; 0x02005E90
- push {r3-r7, lr}
- add r5, r0, #0x0
- mov r0, #0x23
- add r7, r1, #0x0
- add r4, r2, #0x0
- add r6, r3, #0x0
- bl FUN_02003D38
- cmp r5, #0x0
- bne _02005EB2
- ldr r0, [r0, #0x0]
- add r1, r7, #0x0
- add r2, r4, #0x0
- add r3, r6, #0x0
- bl FUN_02005D48
- b _02005EBE
-_02005EB2:
- add r0, r5, #0x0
- add r1, r7, #0x0
- add r2, r4, #0x0
- add r3, r6, #0x0
- bl FUN_02005D48
-_02005EBE:
- cmp r0, #0x0
- bne _02005ED8
- mov r0, #0x1
- bl FUN_02005E80
- mov r0, #0xb
- str r0, [sp, #0x0]
- ldr r1, _02005EDC ; =0x000001B9
- mov r0, #0x0
- add r2, r6, #0x0
- add r3, r4, #0x0
- bl FUN_020056AC
-_02005ED8:
- pop {r3-r7, pc}
- nop
-_02005EDC: .word 0x000001B9
-
- thumb_func_start FUN_02005EE0
-FUN_02005EE0: ; 0x02005EE0
- push {r4, lr}
- add r4, r0, #0x0
- bl Chatot_exists
- cmp r0, #0x0
- bne _02005EF0
- mov r0, #0x0
- pop {r4, pc}
-_02005EF0:
- add r0, r4, #0x0
- bl Chatot_GetData
- mov r1, #0xf
- ldrsb r0, [r0, r1]
- sub r1, #0x2d
- cmp r0, r1
- bge _02005F04
- mov r0, #0x1
- pop {r4, pc}
-_02005F04:
- cmp r0, #0x1e
- blt _02005F10
- cmp r0, #0x80
- bge _02005F10
- mov r0, #0x2
- pop {r4, pc}
-_02005F10:
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start FUN_02005F14
-FUN_02005F14: ; 0x02005F14
- cmp r0, #0xb
- bgt _02005F2E
- bge _02005F32
- cmp r0, #0x5
- bgt _02005F36
- cmp r0, #0x0
- blt _02005F36
- beq _02005F32
- cmp r0, #0x1
- beq _02005F32
- cmp r0, #0x5
- beq _02005F32
- b _02005F36
-_02005F2E:
- cmp r0, #0xc
- bne _02005F36
-_02005F32:
- mov r0, #0x1
- bx lr
-_02005F36:
- mov r0, #0x0
- bx lr
- .balign 4
diff --git a/arm9/lib/NitroSDK/include/SPI_mic.h b/arm9/lib/NitroSDK/include/SPI_mic.h
index 79588fe9..999aeba3 100644
--- a/arm9/lib/NitroSDK/include/SPI_mic.h
+++ b/arm9/lib/NitroSDK/include/SPI_mic.h
@@ -1,6 +1,23 @@
#ifndef NITRO_SPI_MIC_H_
#define NITRO_SPI_MIC_H_
+#include "global.h"
+
+
+struct MIC_SamplingData
+{
+ u32 unk00;
+ u8 *unk04;
+ u32 unk08;
+ u32 unk0c;
+ u32 unk10;
+ u32 unk14;
+ u32 unk18;
+};
+
void MIC_Init(void);
+u32 MIC_StartAutoSampling(struct MIC_SamplingData *data);
+u32 MIC_StopAutoSampling();
+u32 MIC_DoSamplingAsync(u32 param0, u32 param1, u32 param2, u32 param3);
#endif //NITRO_SPI_MIC_H_
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;
+ }
+}
diff --git a/include/pokemon.h b/include/pokemon.h
index d107bf85..ec3ac77a 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -294,7 +294,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, 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);
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/proto.h b/include/proto.h
index 7af3f19d..43ed28ac 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -11,10 +11,6 @@ int TrainerClass_GetGenderOrTrainerCount(int x);
int FUN_02014C3C(u8);
void FUN_02014C54(int, int, struct UnkStruct_02069038 *, u8);
u32 IsNighttime(void); // is day or night
-int FUN_02005F14(int);
-void FUN_02005E80(int);
-void FUN_02005E90(int, int, int, int);
-void FUN_020056AC(int, int, int, int, int);
void FUN_020808AC(struct BoxPokemon *, struct PlayerData *, int, u32, u32);
#endif //POKEDIAMOND_PROTO_H
diff --git a/include/unk_020040F4.h b/include/unk_020040F4.h
index 413e853f..f82ec034 100644
--- a/include/unk_020040F4.h
+++ b/include/unk_020040F4.h
@@ -2,6 +2,7 @@
#define POKEDIAMOND_UNK_020040F4_H
#include "global.h"
+#include "SPI_mic.h"
struct WaveArcInfo
{
@@ -65,8 +66,8 @@ u8 FUN_020048D0(u16 param0);
u32 GF_SndPlayerGetSeqNo(u32 *param0);
u32 FUN_020048F4(u16 param0);
u16 FUN_02004900(u32 param0);
-u32 GF_MIC_StartAutoSampling(u32 param0);
-u32 GF_MIC_StopAutoSampling(u32 param0);
+u32 GF_MIC_StartAutoSampling(struct MIC_SamplingData *param0);
+u32 GF_MIC_StopAutoSampling();
u32 GF_MIC_DoSamplingAsync(u32 param0, u32 param1, u32 param2, u32 param3);
void *FUN_02004930(u32 param0);
BOOL FUN_02004984(u32 param0);
diff --git a/include/unk_02005CFC.h b/include/unk_02005CFC.h
new file mode 100644
index 00000000..7b5f73e2
--- /dev/null
+++ b/include/unk_02005CFC.h
@@ -0,0 +1,19 @@
+#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