blob: 86786e6618043a44ea0837bcf4b1eab57d364b8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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)
{
MI_CpuClear32(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)
{
MI_CpuCopyFast(src, dest, sizeof(struct SaveChatotSoundClip));
}
|