This commit is contained in:
Oliver Bell committed 2022-04-06 09:49:16 +08:00
1 parent 273f85d680
commit 5aecbf282f
3 files changed
+521 -856

No files matched your search

+420 -620
View File
File diff suppressed because it is too large. Load diff
+37 -172
View File
@@ -3,48 +3,18 @@
// Some of these functions have different signatures, so we need to make this
// an array of void pointers or a struct. It's simpler to just make it an array
// for now.
void * const gMPlayJumpTableTemplate[] =
{
ply_fine,
ply_goto,
ply_patt,
ply_pend,
ply_rept,
ply_fine,
ply_fine,
ply_fine,
ply_fine,
ply_prio,
ply_tempo,
ply_keysh,
ply_voice,
ply_vol,
ply_pan,
ply_bend,
ply_bendr,
ply_lfos,
ply_lfodl,
ply_mod,
ply_modt,
ply_fine,
ply_fine,
ply_tune,
ply_fine,
ply_fine,
ply_fine,
ply_port,
ply_fine,
ply_endtie,
SampleFreqSet,
TrackStop,
FadeOutBody,
TrkVolPitSet,
RealClearChain,
void* const gMPlayJumpTableTemplate[] = {
ply_fine, ply_goto, ply_patt, ply_pend, ply_rept,
ply_fine, ply_fine, ply_fine, ply_fine, ply_prio,
ply_tempo, ply_keysh, ply_voice, ply_vol, ply_pan,
ply_bend, ply_bendr, ply_lfos, ply_lfodl, ply_mod,
ply_modt, ply_fine, ply_fine, ply_tune, ply_fine,
ply_fine, ply_fine, ply_port, ply_fine, ply_endtie,
SampleFreqSet, TrackStop, FadeOutBody, TrkVolPitSet, RealClearChain,
SoundMainBTM,
};
const u8 gScaleTable[] =
{
const u8 gScaleTable[] = {
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB,
@@ -62,40 +32,17 @@ const u8 gScaleTable[] =
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
};
const u32 gFreqTable[] =
{
2147483648u,
2275179671u,
2410468894u,
2553802834u,
2705659852u,
2866546760u,
3037000500u,
3217589947u,
3408917802u,
3611622603u,
3826380858u,
4053909305u,
const u32 gFreqTable[] = {
2147483648u, 2275179671u, 2410468894u, 2553802834u,
2705659852u, 2866546760u, 3037000500u, 3217589947u,
3408917802u, 3611622603u, 3826380858u, 4053909305u,
};
const u16 gPcmSamplesPerVBlankTable[] =
{
96,
132,
176,
224,
264,
304,
352,
448,
528,
608,
672,
704,
const u16 gPcmSamplesPerVBlankTable[] = {
96, 132, 176, 224, 264, 304, 352, 448, 528, 608, 672, 704,
};
const u8 gCgbScaleTable[] =
{
const u8 gCgbScaleTable[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
@@ -109,115 +56,33 @@ const u8 gCgbScaleTable[] =
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB,
};
const s16 gCgbFreqTable[] =
{
-2004,
-1891,
-1785,
-1685,
-1591,
-1501,
-1417,
-1337,
-1262,
-1192,
-1125,
-1062,
const s16 gCgbFreqTable[] = {
-2004, -1891, -1785, -1685, -1591, -1501,
-1417, -1337, -1262, -1192, -1125, -1062,
};
const u8 gNoiseTable[] =
{
0xD7, 0xD6, 0xD5, 0xD4,
0xC7, 0xC6, 0xC5, 0xC4,
0xB7, 0xB6, 0xB5, 0xB4,
0xA7, 0xA6, 0xA5, 0xA4,
0x97, 0x96, 0x95, 0x94,
0x87, 0x86, 0x85, 0x84,
0x77, 0x76, 0x75, 0x74,
0x67, 0x66, 0x65, 0x64,
0x57, 0x56, 0x55, 0x54,
0x47, 0x46, 0x45, 0x44,
0x37, 0x36, 0x35, 0x34,
0x27, 0x26, 0x25, 0x24,
0x17, 0x16, 0x15, 0x14,
0x07, 0x06, 0x05, 0x04,
0x03, 0x02, 0x01, 0x00,
const u8 gNoiseTable[] = {
0xD7, 0xD6, 0xD5, 0xD4, 0xC7, 0xC6, 0xC5, 0xC4, 0xB7, 0xB6, 0xB5, 0xB4,
0xA7, 0xA6, 0xA5, 0xA4, 0x97, 0x96, 0x95, 0x94, 0x87, 0x86, 0x85, 0x84,
0x77, 0x76, 0x75, 0x74, 0x67, 0x66, 0x65, 0x64, 0x57, 0x56, 0x55, 0x54,
0x47, 0x46, 0x45, 0x44, 0x37, 0x36, 0x35, 0x34, 0x27, 0x26, 0x25, 0x24,
0x17, 0x16, 0x15, 0x14, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
};
const u8 gCgb3Vol[] =
{
0x00, 0x00,
0x60, 0x60, 0x60, 0x60,
0x40, 0x40, 0x40, 0x40,
0x80, 0x80, 0x80, 0x80,
0x20, 0x20,
const u8 gCgb3Vol[] = {
0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x40, 0x40,
0x40, 0x40, 0x80, 0x80, 0x80, 0x80, 0x20, 0x20,
};
const u8 gClockTable[] =
{
0x00,
0x01,
0x02,
0x03,
0x04,
0x05,
0x06,
0x07,
0x08,
0x09,
0x0A,
0x0B,
0x0C,
0x0D,
0x0E,
0x0F,
0x10,
0x11,
0x12,
0x13,
0x14,
0x15,
0x16,
0x17,
0x18,
0x1C,
0x1E,
0x20,
0x24,
0x28,
0x2A,
0x2C,
0x30,
0x34,
0x36,
0x38,
0x3C,
0x40,
0x42,
0x44,
0x48,
0x4C,
0x4E,
0x50,
0x54,
0x58,
0x5A,
0x5C,
0x60,
const u8 gClockTable[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16, 0x17, 0x18, 0x1C, 0x1E, 0x20, 0x24, 0x28,
0x2A, 0x2C, 0x30, 0x34, 0x36, 0x38, 0x3C, 0x40, 0x42, 0x44,
0x48, 0x4C, 0x4E, 0x50, 0x54, 0x58, 0x5A, 0x5C, 0x60,
};
const XcmdFunc gXcmdTable[] =
{
ply_xxx,
ply_xwave,
ply_xtype,
ply_xxx,
ply_xatta,
ply_xdeca,
ply_xsust,
ply_xrele,
ply_xiecv,
ply_xiecl,
ply_xleng,
ply_xswee,
const XcmdFunc gXcmdTable[] = {
ply_xxx, ply_xwave, ply_xtype, ply_xxx, ply_xatta, ply_xdeca,
ply_xsust, ply_xrele, ply_xiecv, ply_xiecl, ply_xleng, ply_xswee,
};
+64 -64
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "task.h"
#include "global.h"
#include "m4a.h"
static void nullsub_8002A30(void);
@@ -57,15 +58,18 @@ u32 TaskInit(void) {
return 1;
}
struct Task* TaskCreate(TaskMain taskMain, u16 structSize, u16 arg2, u16 flags, TaskDestructor taskDestructor) {
struct Task* TaskCreate(TaskMain taskMain, u16 structSize, u16 arg2, u16 flags,
TaskDestructor taskDestructor) {
struct Task* slow;
struct Task* r4;
u16 fast;
struct EwramNode* r1;
// ???
do ; while (0);
do
;
while (0);
r4 = NULL;
slow = NULL;
@@ -87,7 +91,7 @@ struct Task* TaskCreate(TaskMain taskMain, u16 structSize, u16 arg2, u16 flags,
r4->unk18 = 0;
r4->structOffset = IwramMalloc(structSize);
r4->unk0 = (uintptr_t)gCurTask;
slow = gTaskList[0];
fast = slow->next;
while ((fast + IWRAM_START) != IWRAM_START) {
@@ -125,7 +129,7 @@ void TaskDestroy(struct Task* task) {
((struct Task*)r0)->unk2 = r1;
if (task->structOffset != 0) {
IwramFree(task->structOffset + (void*)IWRAM_START);
IwramFree(task->structOffset + (void*)IWRAM_START);
}
gTaskList[--gLastTaskNum] = task;
@@ -145,7 +149,8 @@ void TaskDestroy(struct Task* task) {
void TaskExecute(void) {
gCurTask = gTaskList[0];
if (!(gUnknown_03001840 & 0x800) && (gTaskList[0] != (struct Task*)IWRAM_START)) {
if (!(gUnknown_03001840 & 0x800) &&
(gTaskList[0] != (struct Task*)IWRAM_START)) {
while (gCurTask != (struct Task*)IWRAM_START) {
gNextTask = (struct Task*)(IWRAM_START + gCurTask->next);
@@ -159,8 +164,7 @@ void TaskExecute(void) {
gUnknown_030053B4 = 0;
}
}
}
else if (gTaskList[0] != (struct Task*)IWRAM_START) {
} else if (gTaskList[0] != (struct Task*)IWRAM_START) {
while (gCurTask != (struct Task*)IWRAM_START) {
gNextTask = (struct Task*)(IWRAM_START + gCurTask->next);
@@ -217,7 +221,7 @@ uintptr_t IwramMalloc(u16 size) {
}
static void IwramFree(struct Unk_03003A20* p) {
struct Unk_03003A20* r2 = p, *r3;
struct Unk_03003A20 *r2 = p, *r3;
#ifndef NONMATCHING
register struct Unk_03003A20* r1 asm("r1");
#else
@@ -226,7 +230,7 @@ static void IwramFree(struct Unk_03003A20* p) {
r2 -= 1;
r1 = gUnknown_03002B00;
r3 = r1;
if (r2 != r1) {
do {
r1 = r3;
@@ -237,7 +241,8 @@ static void IwramFree(struct Unk_03003A20* p) {
r2->unk2 = -r2->unk2;
}
if ((struct Unk_03003A20*)(r1->unk2 + (u8*)r1) == r2) {
u16 r4 = r1->unk2; // not actual code. only for handling side effect of inline asm
u16 r4 = r1->unk2; // not actual code. only for handling side effect of
// inline asm
if (r1->unk2 > 0) {
r1->unk0 = r3->unk0;
r1->unk2 = r4 + r2->unk2;
@@ -263,21 +268,25 @@ static void sub_80028DC(void) {
while ((r2->unk0 + IWRAM_START) != IWRAM_START) {
if (r2->unk2 >= 0) {
r2->unk0 += 0; // load again pls
r2->unk0 += 0; // load again pls
r1 = r2->unk0;
if (((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2 >= 0) {
r2->unk2 += ((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2;
r2->unk0 = ((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk0;
}
else {
r2->unk2 +=
((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2;
r2->unk0 =
((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk0;
} else {
r5 = r2->unk0 + (void*)(IWRAM_START + 4);
r6 = (void*)r2 + 4;
r7 = r2->unk2;
r2->unk2 = ((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2;
++r1; --r1; // why do you insist on loading here?
r2->unk2 =
((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2;
++r1;
--r1; // why do you insist on loading here?
r2->unk0 = ((struct Unk_03003A20*)(r1 + IWRAM_START))->unk0;
for (r3 = 0; r3 <= 0x7f; r3++) {
if (gUnknown_030009F0[r3].structOffset == (u16)(uintptr_t)r5) {
if (gUnknown_030009F0[r3].structOffset ==
(u16)(uintptr_t)r5) {
gUnknown_030009F0[r3].structOffset = (u32)r6;
break;
}
@@ -292,8 +301,7 @@ static void sub_80028DC(void) {
r2->unk0 = (u32)r2;
}
}
}
else {
} else {
r2 = (struct Unk_03003A20*)(r2->unk0 + IWRAM_START);
}
}
@@ -302,54 +310,46 @@ static void sub_80028DC(void) {
static struct Task* TaskGetNextSlot(void) {
if (gLastTaskNum > 0x7f) {
return NULL;
}
else {
} else {
return gTaskList[gLastTaskNum++];
}
}
ASM_FUNC("asm/non_matching/sub_80029D0.inc", void sub_80029D0(u16 arg0, u16 arg1)
// {
// struct Task* r2;
// u32 r0;
// struct Task* next;
// r2 = gTaskList[0];
// r0 = (u16)(uintptr_t)r2;
// while (r0 != 0) {
// if (r2->unk10 >= arg0) {
// while (r2->unk10 < arg1) {
// next = (struct Task*)(r2->next + (IWRAM_START));
// if (r2 != gTaskList[0] && r2 != gTaskList[1]) {
// TaskDestroy(r2);
// }
// if (next != (struct Task*)IWRAM_START) {
// break;
// }
ASM_FUNC("asm/non_matching/sub_80029D0.inc",
void sub_80029D0(u16 arg0, u16 arg1)
// {
// struct Task* r2;
// r2 = next;
// }
// return;
// }
// r0 = r2->next;
// r2 = (struct Task*)(r0 + IWRAM_START);
// }
// }
// u32 r0;
// struct Task* next;
// r2 = gTaskList[0];
// r0 = (u16)(uintptr_t)r2;
// while (r0 != 0) {
// if (r2->unk10 >= arg0) {
// while (r2->unk10 < arg1) {
// next = (struct Task*)(r2->next + (IWRAM_START));
// if (r2 != gTaskList[0] && r2 != gTaskList[1]) {
// TaskDestroy(r2);
// }
// if (next != (struct Task*)IWRAM_START) {
// break;
// }
// r2 = next;
// }
// return;
// }
// r0 = r2->next;
// r2 = (struct Task*)(r0 + IWRAM_START);
// }
// }
)
static void nullsub_8002A30(void) {
static void nullsub_8002A30(void) {}
}
static void nullsub_8002A34(void) {}
static void nullsub_8002A34(void) {
}
static void nullsub_8002A38(void) {
}
static void nullsub_8002A38(void) {}