core1/code_5650.c, func_802432F8() match

This commit is contained in:
Banjo Kazooie
2023-02-03 00:24:06 -06:00
parent 6ae297e31f
commit 7a40f9161f
6 changed files with 283 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
# banjo (97.8580%) # banjo (98.0621%)
<img src="./progress/progress_total.svg"> <img src="./progress/progress_total.svg">

View File

@@ -148,7 +148,7 @@ typedef struct {
} N_ALGenericEvent; } N_ALGenericEvent;
typedef struct { typedef struct {
s16 type; u16 type;
union { union {
ALMIDIEvent midi; ALMIDIEvent midi;
ALTempoEvent tempo; ALTempoEvent tempo;

View File

@@ -9,7 +9,7 @@
</mask> </mask>
<g mask="url(#anybadge_1)"> <g mask="url(#anybadge_1)">
<path fill="#555" d="M0 0h44v20H0z"/> <path fill="#555" d="M0 0h44v20H0z"/>
<path fill="#0de000" d="M44 0h67v20H44z"/> <path fill="#07e000" d="M44 0h67v20H44z"/>
<path fill="url(#b)" d="M0 0h111v20H0z"/> <path fill="url(#b)" d="M0 0h111v20H0z"/>
</g> </g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
@@ -17,7 +17,7 @@
<text x="22.0" y="14">core1</text> <text x="22.0" y="14">core1</text>
</g> </g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="78.5" y="15" fill="#010101" fill-opacity=".3">97.0254%</text> <text x="78.5" y="15" fill="#010101" fill-opacity=".3">98.4321%</text>
<text x="77.5" y="14">97.0254%</text> <text x="77.5" y="14">98.4321%</text>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -9,7 +9,7 @@
</mask> </mask>
<g mask="url(#anybadge_1)"> <g mask="url(#anybadge_1)">
<path fill="#555" d="M0 0h150v20H0z"/> <path fill="#555" d="M0 0h150v20H0z"/>
<path fill="#0ae000" d="M150 0h67v20H150z"/> <path fill="#09e000" d="M150 0h67v20H150z"/>
<path fill="url(#b)" d="M0 0h217v20H0z"/> <path fill="url(#b)" d="M0 0h217v20H0z"/>
</g> </g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
@@ -17,7 +17,7 @@
<text x="75.0" y="14">Banjo-Kazooie (us.v10)</text> <text x="75.0" y="14">Banjo-Kazooie (us.v10)</text>
</g> </g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="184.5" y="15" fill="#010101" fill-opacity=".3">97.8580%</text> <text x="184.5" y="15" fill="#010101" fill-opacity=".3">98.0621%</text>
<text x="183.5" y="14">97.8580%</text> <text x="183.5" y="14">98.0621%</text>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -4,18 +4,23 @@
#include "n_libaudio.h" #include "n_libaudio.h"
#include "n_synth.h" #include "n_synth.h"
void func_802444C0(N_AL_Struct81s *arg0); void func_802444C0(N_AL_Struct81s *arg0);
void func_80244050(ALEventQueue *arg0, N_AL_Struct81s *arg1, u16 arg2); void func_80244050(ALEventQueue *arg0, N_AL_Struct81s *arg1, u16 arg2);
void func_8024324C(N_ALSndPlayer *arg0);
void func_80244190(N_AL_Struct81s *arg0);
void func_8024324C(N_ALSndPlayer *arg0);
void func_802432F8(N_ALSndPlayer *sndp, N_ALEvent *event);
void func_80243F84(N_AL_Struct81s *arg0);
void func_80243FE4(N_AL_Struct81s *arg0);
s32 func_80244110(u16 *arg0, u16 *arg1);
void func_80244190(N_AL_Struct81s *arg0);
void *func_80244608(ALBank *bank, s16 arg1, struct46s *arg2);
void func_80244978(s32 arg0, s16 type, s32 arg2);
// extern ALEventUnknown; // extern ALEventUnknown;
/* .bss */ /* .bss */
#define CODE_5650_ABS(s) (((s) >= 0)? (s): -(s))
N_ALSndPlayer D_8027EEC0; N_ALSndPlayer D_8027EEC0;
u16 *D_8027EF14; s16 *D_8027EF14;
extern struct { extern struct {
s32 volume[4]; s32 volume[4];
}D_8027EF18; }D_8027EF18;
@@ -68,7 +73,7 @@ void func_8024324C(N_ALSndPlayer *arg0)
do do
{ {
if ((new_var->nextEvent.type & 0xFFFFFFFF) == 0x20) if ((s16)(new_var->nextEvent.type) == 0x20)
{ {
sp3C.type = 0x20; sp3C.type = 0x20;
alEvtqPostEvent(&new_var->evtq, (ALEvent *) (&sp3C), new_var->frameTime); alEvtqPostEvent(&new_var->evtq, (ALEvent *) (&sp3C), new_var->frameTime);
@@ -84,7 +89,263 @@ void func_8024324C(N_ALSndPlayer *arg0)
new_var->curTime += new_var->nextDelta; new_var->curTime += new_var->nextDelta;
} }
#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_5650/func_802432F8.s") void func_802432F8(N_ALSndPlayer *sndp, N_ALEvent *event) {
N_AL_Struct81s *temp_s0;
ALVoiceConfig spDC;
N_ALSndPlayer *temp_fp;
N_ALEvent *var_s5;
ALSound *temp_s1;
N_ALEvent spC0;
N_ALEvent spB0;
s32 spAC;
N_AL_Struct81s *temp_s6;
s32 spA4;
s32 temp_t6;
s32 var_v0;
bool var_s2;
s32 sp94;
s32 sp90;
N_ALVoice *voice;
ALKeyMap *keymap;
u16 sp86;
u16 sp84;
N_AL_Struct81s *sp80;
N_ALEvent sp70;
s32 var_v1_4;
s32 sp68;
u8 clamped_pan;
temp_fp = n_syn->n_sndp;
var_s5 = event;
sp94 = 1;
sp90 = 0;
temp_s0 = NULL;
temp_s6 = NULL;
do{
if (temp_s6 != NULL) {
spB0.msg.generic.data[0].i = temp_s0;
spB0.type = var_s5->type;
spB0.msg.generic.data[1].i = var_s5->msg.vol.delta;
var_s5 = (N_ALEvent *) &spB0;
}
temp_s0 = (N_AL_Struct81s*)var_s5->msg.generic.data[0].i;
temp_s1 = temp_s0->unk8;
if (temp_s1 == NULL) {
func_80244110(&sp86, &sp84);
return;
}
keymap = temp_s1->keyMap;
temp_s6 = temp_s0->node.next;
switch (var_s5->type) { /* irregular */
case 0x1:
if((temp_s0->unk40 != 5) && (temp_s0->unk40 != 4))
return;
spDC.fxBus = 0;
spDC.priority = (u8)temp_s0->unk36;
spDC.unityPitch = 0;
var_s2 = (D_802758D4 >= temp_fp->maxSounds); //SHOULD BE ^1
if (!(var_s2) || (temp_s0->unk3F & 0x10)) {
sp90 = n_alSynAllocVoice(&temp_s0->voice, &spDC);
}
if (sp90 == 0) {
if ((temp_s0->unk3F & 0x12) || (temp_s0->unk38 > 0)) {
temp_s0->unk40 = 4U;
temp_s0->unk38 = (s32) (temp_s0->unk38 - 1);
alEvtqPostEvent(&temp_fp->evtq, (ALEvent *) var_s5, 0x8235);
return;
}
if(var_s2){
sp80 = D_802758C0.unk4;
do{
if (!(sp80->unk3F & 0x12) && (sp80->unk3F & 0x4) && (sp80->unk40 != 3)) {
sp70.type = 0x80;
sp70.msg.generic.data[0].i = sp80;
sp80->unk40 = 3U;
var_s2 = 0;
alEvtqPostEvent(&temp_fp->evtq, (ALEvent *) &sp70, 0x3E8);
n_alSynSetVol(&sp80->voice, 0, 0x3E8);
}
sp80 = sp80->node.prev;
}while(var_s2 && sp80 != NULL);
if (!var_s2) {
temp_s0->unk38 = 2;
alEvtqPostEvent(&temp_fp->evtq, (ALEvent *) var_s5, 0x3E9);
}
else{
func_80243F84(temp_s0);
}
}
else{
func_80243F84(temp_s0);
}
return;
}
temp_s0->unk3F |= 4;
n_alSynStartVoice(&temp_s0->voice, temp_s1->wavetable);
temp_s0->unk40 = 1;
D_802758D4 += 1;
spAC = (s32) (((f32) temp_s1->envelope->attackTime / temp_s0->unk2C) / temp_s0->unk28);
spA4 = MAX(0, ((D_8027EF14[keymap->keyMin & 0x3F] * ((temp_s1->envelope->attackVolume * temp_s0->unk34 * temp_s1->sampleVolume) / 16129)) / 32767) - 1);
n_alSynSetVol(&temp_s0->voice, 0, 0);
n_alSynSetVol(&temp_s0->voice, (s16) spA4, spAC);
var_v1_4 = (temp_s0->unk3D + temp_s1->samplePan) - 0x40;
clamped_pan = MIN(MAX(var_v1_4, 0), 0x7F);
n_alSynSetPan(&temp_s0->voice, clamped_pan);
n_alSynSetPitch(&temp_s0->voice, temp_s0->unk2C * temp_s0->unk28);
if ((keymap->keyMax & 0xF) >= 0xE) {
var_v0= (keymap->keyMax & 0xF) * 8;
} else {
var_v0 = temp_s0->unk3E;
if (D_802758D0) {
var_v0 += (keymap->keyMax & 0xF) * 8;
}
}
var_v0 = MIN(0x7F, MAX(0, var_v0));
n_alSynSetFXMix(&temp_s0->voice, var_v0);
spC0.type = 0x40;
spC0.msg.generic.data[0].i = temp_s0;
spAC = (s32) (((f32) temp_s1->envelope->attackTime / temp_s0->unk2C) / temp_s0->unk28);
alEvtqPostEvent(&temp_fp->evtq, (ALEvent *) &spC0, spAC);
break;
case 0x2:
case 0x400:
case 0x1000:
if ((var_s5->type != 0x1000) || (temp_s0->unk3F & 2)) {
switch (temp_s0->unk40) { /* switch 1; irregular */
case 1: /* switch 1 */
func_80244050(&temp_fp->evtq, temp_s0, 0x40);
spAC = (s32) (((f32) temp_s1->envelope->releaseTime / temp_s0->unk28) / temp_s0->unk2C);
temp_s0->envPhase = 2;
temp_s0->unk48 = 0;
n_alSynSetVol(&temp_s0->voice, 0, spAC);
if (spAC != 0) {
spC0.type = 0x80;
spC0.msg.generic.data[0].i = temp_s0;
if (spAC <= 0x7D00) {
spAC = 0x7D00;
}
alEvtqPostEvent(&temp_fp->evtq, (ALEvent *) &spC0, spAC);
temp_s0->unk40 = 2U;
} else {
func_80243F84(temp_s0);
}
break;
case 4: /* switch 1 */
case 5: /* switch 1 */
func_80243F84(temp_s0);
break;
}
if (var_s5->type == 2) {
var_s5->type = 0x1000;
}
}
break;
case 0x4:
temp_s0->unk3D = var_s5->msg.generic.data[1].i;
if (temp_s0->unk40 == 1) {
clamped_pan = MIN(MAX((temp_s0->unk3D + temp_s1->samplePan) - 0x40, 0), 0x7F);
n_alSynSetPan(&temp_s0->voice, clamped_pan);
}
break;
case 0x10:
temp_s0->unk2C = var_s5->msg.generic.data[1].f;
if (temp_s0->unk40 == 1) {
n_alSynSetPitch(&temp_s0->voice, temp_s0->unk2C * temp_s0->unk28);
if (temp_s0->unk3F & 0x20) {
func_80243FE4(temp_s0);
}
}
break;
case 0x100:
temp_s0->unk3E = (u8) var_s5->msg.vol.delta;
if (temp_s0->unk40 == 1) {
if ((keymap->keyMax & 0xF) >= 0xE) {
var_v0 = (keymap->keyMax & 0xF) * 8;
} else {
var_v0 = temp_s0->unk3E;
if (D_802758D0 != 0) {
var_v0 += (keymap->keyMax & 0xF) * 8;
}
}
var_v0 = MIN(0x7F, MAX(0, var_v0));
n_alSynSetFXMix(&temp_s0->voice, var_v0);
}
break;
case 0x8:
temp_t6 = MAX(0, (((f32) D_8027EF14[keymap->keyMin & 0x3F] * ((temp_s0->unk44 * (f32) temp_s0->unk34 * (f32)temp_s1->sampleVolume) / 16129)) / 32767) - 1);
temp_s0->unk34 = (s16) var_s5->msg.vol.delta;
if (temp_s0->unk40 == 1) {
spA4 = MAX(0, (((f32) D_8027EF14[keymap->keyMin & 0x3F] * ((temp_s0->unk44 * (f32) temp_s0->unk34 * (f32)temp_s1->sampleVolume) / 16129)) / 32767) - 1);
var_v0 = spA4 - temp_t6;
n_alSynSetVol(&temp_s0->voice, (s16)spA4, MAX(0x3E8, CODE_5650_ABS(var_v0) >> 2));
}
break;
case 0x800:
if (temp_s0->unk40 == 1) {
spAC = ((temp_s1->envelope->releaseTime / temp_s0->unk28) / temp_s0->unk2C);
spA4 = MAX(0, ((f32) (s16) D_8027EF14[keymap->keyMin & 0x3F] * ((temp_s0->unk44 * (f32) temp_s0->unk34 * (f32)temp_s1->sampleVolume) / 16129)) / 32767 - 1);
n_alSynSetVol(&temp_s0->voice, (s16)spA4, spAC);
}
break;
case 0x40:
if (!(temp_s0->unk3F & 2)) {
spA4 = MAX(0, ((s32) ((s16) D_8027EF14[keymap->keyMin & 0x3F] * ( (temp_s1->envelope->decayVolume * temp_s0->unk34 * temp_s1->sampleVolume) / 16129)) / 32767) - 1);
spAC = (s32) (((f32) temp_s1->envelope->decayTime / temp_s0->unk28) / temp_s0->unk2C);
n_alSynSetVol(&temp_s0->voice, spA4, spAC);
spC0.type = 2;
spC0.msg.generic.data[0].i = temp_s0;
alEvtqPostEvent(&temp_fp->evtq, (ALEvent *) &spC0, spAC);
if (temp_s0->unk3F & 0x20) {
func_80243FE4(temp_s0);
}
}
break;
case 0x80:
func_80243F84(temp_s0);
break;
case 0x200:
if (temp_s0->unk3F & 0x10) {
sp68 = func_80244608(var_s5->msg.midi.duration, (s16)var_s5->msg.generic.data[1].i, temp_s0->unk30);
func_80244978(sp68, 8, temp_s0->unk34);
func_80244978(sp68, 4, temp_s0->unk3D);
func_80244978(sp68, 0x100, temp_s0->unk3E);
func_80244978(sp68, 0x10, reinterpret_cast(s32, temp_s0->unk2C));
}
break;
default:
break;
}
var_v0 = var_s5->type & 0x2D1;
temp_s0 = temp_s6;
if ((temp_s0 != NULL) && !var_v0) {
sp94 = temp_s0->unk3F & 1;
}
}while((sp94 == 0) && (temp_s0 != NULL) && !var_v0);
}
void func_80243F84(N_AL_Struct81s *arg0) { void func_80243F84(N_AL_Struct81s *arg0) {
if (arg0->unk3F & 4) { if (arg0->unk3F & 4) {
@@ -421,7 +682,7 @@ void func_80244978(s32 arg0, s16 type, s32 arg2){
} }
s32 func_802449C4(u8 arg0){ s32 func_802449C4(u8 arg0){
return D_8027EF14[arg0]; return (u16)D_8027EF14[arg0];
} }
void func_802449E4(u8 arg0, u16 arg1) { void func_802449E4(u8 arg0, u16 arg1) {

View File

@@ -217,8 +217,6 @@ s32 D_80380B18;
s32 D_80380B1C; s32 D_80380B1C;
s8 D_80380B20[0x400]; s8 D_80380B20[0x400];
s8 D_80380F20[0x80]; s8 D_80380F20[0x80];
f32 D_80380FA0;
f32 D_80380FA8[0x20];
void func_802F7A2C(s32 arg0); void func_802F7A2C(s32 arg0);
@@ -516,6 +514,7 @@ void *func_802F55A8(u8 arg0){
} }
#ifndef NONMATCHING #ifndef NONMATCHING
f32 D_80380FA0;
void _printbuffer_draw_letter(s32 letter, f32* xPtr, f32* yPtr, f32 arg3, Gfx **gtx, Mtx **mtx, Vtx **vtx); void _printbuffer_draw_letter(s32 letter, f32* xPtr, f32* yPtr, f32 arg3, Gfx **gtx, Mtx **mtx, Vtx **vtx);
#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_6DA30/_printbuffer_draw_letter.s") #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_6DA30/_printbuffer_draw_letter.s")
#else #else
@@ -821,6 +820,8 @@ f32 func_802F6C90(u8 letter, f32* xPtr, f32 *yPtr, f32 arg3){
} }
void printbuffer_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { void printbuffer_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) {
static f32 D_80380FA8[0x20];
s32 j; s32 j;
f32 _x; f32 _x;
f32 _y; f32 _y;