summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/main.c7
-rw-r--r--arm9/src/sav_chatot.c98
-rw-r--r--arm9/src/save_arrays.c6
-rw-r--r--arm9/src/scrcmd_sound.c6
-rw-r--r--arm9/src/sound.c74
5 files changed, 142 insertions, 49 deletions
diff --git a/arm9/src/main.c b/arm9/src/main.c
index c05fa1f3..314c4509 100644
--- a/arm9/src/main.c
+++ b/arm9/src/main.c
@@ -26,17 +26,12 @@ s32 UNK_02016FA4;
PMBackLightSwitch gBacklightTop;
struct UnkStruct_02016FA8 UNK_02016FA8;
-extern void InitSystemForTheGame(void);
-extern void InitGraphicMemory(void);
extern void FUN_02022294(void);
extern void GF_InitRTCWork(void);
extern void FUN_02002C14(void);
extern void FUN_02002C50(int, int);
-extern struct SaveBlock2 * SaveBlock2_new(void);
-extern void * FUN_02029EF8(struct SaveBlock2 *);
extern int FUN_020337E8(int);
extern void FUN_02034188(int, int);
-extern int FUN_020227FC(struct SaveBlock2 *);
extern void FUN_02089D90(int);
extern void FUN_0200A2AC(void);
extern void FUN_02015E30(void);
@@ -73,7 +68,7 @@ THUMB_FUNC void NitroMain(void)
FUN_02002C50(3, 3);
UNK_02016FA8.unk10 = -1;
UNK_02016FA8.unk18 = SaveBlock2_new();
- InitSoundData(FUN_02029EF8(UNK_02016FA8.unk18), Sav2_PlayerData_GetOptionsAddr(UNK_02016FA8.unk18));
+ InitSoundData(Sav2_Chatot_get(UNK_02016FA8.unk18), Sav2_PlayerData_GetOptionsAddr(UNK_02016FA8.unk18));
Init_Timer3();
if (FUN_020337E8(3) == 3)
FUN_02034188(3, 0);
diff --git a/arm9/src/sav_chatot.c b/arm9/src/sav_chatot.c
new file mode 100644
index 00000000..7b240a99
--- /dev/null
+++ b/arm9/src/sav_chatot.c
@@ -0,0 +1,98 @@
+#include "global.h"
+#include "MI_memory.h"
+#include "heap.h"
+#include "sav_chatot.h"
+
+THUMB_FUNC u32 Sav2_Chatot_sizeof(void)
+{
+ return sizeof(struct SaveChatotSoundClip);
+}
+
+THUMB_FUNC void Sav2_Chatot_init(struct SaveChatotSoundClip * chatot)
+{
+ MIi_CpuClear32(0, chatot, sizeof(struct SaveChatotSoundClip));
+ chatot->exists = FALSE;
+}
+
+THUMB_FUNC struct SaveChatotSoundClip * Chatot_new(u32 heap_id)
+{
+ struct SaveChatotSoundClip * ret = (struct SaveChatotSoundClip *)AllocFromHeap(heap_id, sizeof(struct SaveChatotSoundClip));
+ Sav2_Chatot_init(ret);
+ return ret;
+}
+
+THUMB_FUNC struct SaveChatotSoundClip * Sav2_Chatot_get(struct SaveBlock2 * sav2)
+{
+ return (struct SaveChatotSoundClip *) SavArray_get(sav2, 22);
+}
+
+THUMB_FUNC BOOL Chatot_exists(struct SaveChatotSoundClip * chatot)
+{
+ return chatot->exists;
+}
+
+THUMB_FUNC void Chatot_invalidate(struct SaveChatotSoundClip * chatot)
+{
+ chatot->exists = FALSE;
+}
+
+THUMB_FUNC s8 * Chatot_GetData(struct SaveChatotSoundClip * chatot)
+{
+ return chatot->data;
+}
+
+static inline s8 transform(u8 value)
+{
+ return (s8)(value - 8);
+}
+
+THUMB_FUNC void Chatot_Decode(s8 * dest, const s8 * data)
+{
+ s32 i;
+ s32 dest_i;
+ u8 val;
+ s8 val2;
+
+ for (dest_i = 0, i = 0; i < 1000; i++, dest_i += 2)
+ {
+ val = (u8)(data[i] & 0xF);
+ val2 = transform(val);
+ dest[dest_i + 0] = (s8)(val2 << 4);
+ val = (u8)(data[i] >> 4);
+ val2 = transform(val);
+ dest[dest_i + 1] = (s8)(val2 << 4);
+ }
+}
+
+static inline u8 untransform(s8 val)
+{
+ val /= 16;
+ return (u8)(val + 8);
+}
+
+THUMB_FUNC void Chatot_Encode(struct SaveChatotSoundClip * chatot, const s8 * data)
+{
+ s32 src_i;
+ s32 i = 0;
+ u8 val2;
+ s8 val;
+ chatot->exists = TRUE;
+
+ for (src_i = 0; src_i < 2000; src_i += 2)
+ {
+ val = data[src_i + 0];
+ val2 = untransform(val);
+ chatot->data[i] = (s8)val2;
+
+ val = data[src_i + 1];
+ val2 = untransform(val);
+ chatot->data[i] |= val2 << 4;
+
+ i++;
+ }
+}
+
+THUMB_FUNC void Chatot_copy(struct SaveChatotSoundClip * dest, const struct SaveChatotSoundClip * src)
+{
+ MIi_CpuCopyFast(src, dest, sizeof(struct SaveChatotSoundClip));
+}
diff --git a/arm9/src/save_arrays.c b/arm9/src/save_arrays.c
index 8520f2c1..f4b18b86 100644
--- a/arm9/src/save_arrays.c
+++ b/arm9/src/save_arrays.c
@@ -15,6 +15,7 @@
#include "seal.h"
#include "unk_020139D8.h"
#include "unk_02024E64.h"
+#include "sav_chatot.h"
extern u32 FUN_0202AC20(void);
extern u32 FUN_02034D7C(void);
@@ -26,7 +27,7 @@ extern u32 FUN_02028054(void);
extern u32 FUN_02028980(void);
extern u32 FUN_02029A84(void);
extern u32 FUN_02029FB0(void);
-extern u32 FUN_02029EC4(void);
+extern u32 Sav2_Chatot_sizeof(void);
extern u32 FUN_0202A89C(void);
extern u32 FUN_0202A8F4(void);
extern u32 FUN_0202A924(void);
@@ -47,7 +48,6 @@ extern void FUN_0202805C(void *);
extern void FUN_02028994(void *);
extern void FUN_02029A8C(void *);
extern void FUN_02029FB8(void *);
-extern void FUN_02029ECC(void *);
extern void FUN_0202A8A4(void *);
extern void FUN_0202A8F8(void *);
extern void FUN_0202A92C(void *);
@@ -87,7 +87,7 @@ const struct SaveChunkHeader UNK_020EE700[] = {
{ 19, 0, (SAVSIZEFN)FUN_02029A84, (SAVINITFN)FUN_02029A8C },
{ 20, 0, (SAVSIZEFN)FUN_02029FB0, (SAVINITFN)FUN_02029FB8 },
{ 21, 0, (SAVSIZEFN)Sav2_SealCase_sizeof, (SAVINITFN)Sav2_SealCase_init },
- { 22, 0, (SAVSIZEFN)FUN_02029EC4, (SAVINITFN)FUN_02029ECC },
+ { 22, 0, (SAVSIZEFN)Sav2_Chatot_sizeof, (SAVINITFN)Sav2_Chatot_init },
{ 23, 0, (SAVSIZEFN)FUN_0202A89C, (SAVINITFN)FUN_0202A8A4 },
{ 24, 0, (SAVSIZEFN)FUN_0202A8F4, (SAVINITFN)FUN_0202A8F8 },
{ 25, 0, (SAVSIZEFN)FUN_0202A924, (SAVINITFN)FUN_0202A92C },
diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c
index 5acaae1e..df611ec7 100644
--- a/arm9/src/scrcmd_sound.c
+++ b/arm9/src/scrcmd_sound.c
@@ -1,6 +1,6 @@
#include "scrcmd.h"
-extern void* FUN_02029EF8(struct SaveBlock2* sav2);
+extern void* Sav2_Chatot_get(struct SaveBlock2* sav2);
extern u32 FUN_02005D20(void *);
extern void FUN_02005E6C(void *);
extern void FUN_0200433C(u32, u32, u32);
@@ -203,7 +203,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0059(struct ScriptContext* ctx)
{
u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
- void* unk = FUN_02029EF8(ctx->unk80->saveBlock2);
+ void* unk = Sav2_Chatot_get(ctx->unk80->saveBlock2);
if (FUN_02005D20(unk) == 1)
{
*ret_ptr = 1;
@@ -241,7 +241,7 @@ THUMB_FUNC BOOL ScrCmd_Unk005B(struct ScriptContext* ctx)
THUMB_FUNC BOOL ScrCmd_Unk005C(struct ScriptContext* ctx)
{
- void* unk = FUN_02029EF8(ctx->unk80->saveBlock2);
+ void* unk = Sav2_Chatot_get(ctx->unk80->saveBlock2);
FUN_02005E6C(unk);
return TRUE;
diff --git a/arm9/src/sound.c b/arm9/src/sound.c
index 95d14c64..a5228dab 100644
--- a/arm9/src/sound.c
+++ b/arm9/src/sound.c
@@ -11,8 +11,8 @@ static u32 UNK_02107074;
void FUN_02003C40(void);
BOOL FUN_02003D04(void);
-void FUN_020040C8(void);
-void FUN_02004064(struct SoundData *);
+void GF_InitMic(void);
+void GF_SoundDataInit(struct SoundData *);
void FUN_02004088(struct SoundData *);
void FUN_020040A4(struct SoundData *);
void FUN_02003CE8(int);
@@ -26,20 +26,20 @@ extern void FUN_0200538C(int, int, int);
extern BOOL FUN_02005404(void);
extern void FUN_02005CFC(void);
-void InitSoundData(void * a0, struct Options * a1)
+void InitSoundData(struct SaveChatotSoundClip * chatot, struct Options * options)
{
struct SoundData * sdat = GetSoundDataPointer();
NNS_SndInit();
- FUN_020040C8();
- FUN_02004064(sdat);
- sdat->heap = NNS_SndHeapCreate(sdat->unk_00094, sizeof(sdat->unk_00094));
+ GF_InitMic();
+ GF_SoundDataInit(sdat);
+ sdat->heap = NNS_SndHeapCreate(sdat->heapBuffer, sizeof(sdat->heapBuffer));
NNS_SndArcInit(&sdat->header, "data/sound/sound_data.sdat", sdat->heap, 0);
NNS_SndArcPlayerSetup(sdat->heap);
FUN_02004088(sdat);
FUN_020040A4(sdat);
UNK_02107074 = 0;
- sdat->unk_BCD4C = a0;
- FUN_02004D60(a1->soundMethod);
+ sdat->chatot = chatot;
+ FUN_02004D60(options->soundMethod);
}
void DoSoundUpdateFrame(void)
@@ -185,7 +185,7 @@ void * FUN_02003D38(u32 a0)
case 34:
return &sdat->unk_BCD48;
case 35:
- return &sdat->unk_BCD4C;
+ return &sdat->chatot;
case 36:
return &sdat->unk_BCD50;
case 37:
@@ -200,61 +200,61 @@ void * FUN_02003D38(u32 a0)
}
}
-int FUN_02003F3C(int * a0)
+int GF_Snd_SaveState(int * level_p)
{
struct SoundData * sdat = GetSoundDataPointer();
- int r4 = NNS_SndHeapSaveState(sdat->heap);
- GF_ASSERT(r4 != -1);
- if (a0 != NULL)
- *a0 = r4;
- return r4;
+ int level = NNS_SndHeapSaveState(sdat->heap);
+ GF_ASSERT(level != -1);
+ if (level_p != NULL)
+ *level_p = level;
+ return level;
}
-void FUN_02003F64(int a0)
+void GF_Snd_RestoreState(int level)
{
struct SoundData * sdat = GetSoundDataPointer();
- NNS_SndHeapLoadState(sdat->heap, a0);
+ NNS_SndHeapLoadState(sdat->heap, level);
}
-BOOL FUN_02003F78(int a0)
+BOOL GF_Snd_LoadGroup(int groupNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return NNS_SndArcLoadGroup(a0, sdat->heap);
+ return NNS_SndArcLoadGroup(groupNo, sdat->heap);
}
-BOOL FUN_02003F90(int a0)
+BOOL GF_Snd_LoadSeq(int seqNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return NNS_SndArcLoadSeq(a0, sdat->heap);
+ return NNS_SndArcLoadSeq(seqNo, sdat->heap);
}
-BOOL FUN_02003FA8(int a0, u32 a1)
+BOOL GF_Snd_LoadSeqEx(int seqNo, u32 loadFlag)
{
struct SoundData * sdat = GetSoundDataPointer();
- return NNS_SndArcLoadSeqEx(a0, a1, sdat->heap);
+ return NNS_SndArcLoadSeqEx(seqNo, loadFlag, sdat->heap);
}
-BOOL FUN_02003FC4(int a0)
+BOOL GF_Snd_LoadWaveArc(int waveArcNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return NNS_SndArcLoadWaveArc(a0, sdat->heap);
+ return NNS_SndArcLoadWaveArc(waveArcNo, sdat->heap);
}
-BOOL FUN_02003FDC(int a0)
+BOOL GF_Snd_LoadBank(int bankNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- return NNS_SndArcLoadBank(a0, sdat->heap);
+ return NNS_SndArcLoadBank(bankNo, sdat->heap);
}
-u32 * FUN_02003FF4(int a0)
+u32 * FUN_02003FF4(int playerNo)
{
struct SoundData * sdat = GetSoundDataPointer();
- if (a0 >= 9)
+ if (playerNo >= (s32)NELEMS(sdat->players))
{
GF_ASSERT(0);
- a0 = 0;
+ playerNo = 0;
}
- return &sdat->unk_BBC94[a0];
+ return &sdat->players[playerNo];
}
u32 FUN_02004018(u32 a0)
@@ -283,7 +283,7 @@ u32 FUN_02004018(u32 a0)
}
}
-void FUN_02004064(struct SoundData * sdat)
+void GF_SoundDataInit(struct SoundData * sdat)
{
int i;
memset(sdat, 0, sizeof(*sdat));
@@ -296,18 +296,18 @@ void FUN_02004088(struct SoundData * sdat)
int i;
for (i = 0; i < 9; i++)
{
- NNS_SndHandleInit(&sdat->unk_BBC94[i]);
+ NNS_SndHandleInit(&sdat->players[i]);
}
}
void FUN_020040A4(struct SoundData * sdat)
{
- FUN_02003F3C(&sdat->unk_BCD1C[0]);
- FUN_02003F78(0);
- FUN_02003F3C(&sdat->unk_BCD1C[1]);
+ GF_Snd_SaveState(&sdat->unk_BCD1C[0]);
+ GF_Snd_LoadGroup(0);
+ GF_Snd_SaveState(&sdat->unk_BCD1C[1]);
}
-void FUN_020040C8(void)
+void GF_InitMic(void)
{
MIC_Init();
PM_SetAmp(1);