This is an update of the previous PR. Not sure how to get rid of the
get20 function.
https://decomp.me/scratch/cDYU4
This commit is contained in:
sozud 2024-03-14 18:00:40 -07:00 committed by GitHub
parent e6046aa106
commit 41ace307d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 102 additions and 16 deletions

View File

@ -20,13 +20,12 @@ void _SsSeqPlay(s16, s16);
void _SsClose(s16);
extern s32 D_80032EF4;
extern u8 D_80032F00;
extern s8 D_80032F01;
extern u8 D_80032F01;
extern u8 D_80032F02;
void EnterCriticalSection(void);
void VSyncCallback(void (*func)());
void ExitCriticalSection(void);
void InterruptCallback(s32, s32);
void* InterruptCallback(u8, void (*)());
void ResetCallback();
void SpuInit();
void _SsInit();
@ -324,11 +323,13 @@ u32 SpuWritePartly(u8*, u32);
struct SndSeqTickEnv {
s32 unk0;
s32 unk4;
u32 unk8;
u32 unk12;
void (*unk8)();
void (*unk12)();
u8 unk16;
u8 unk17;
u8 unk18;
u8 unk19;
u32 unk20;
};
extern struct SndSeqTickEnv _snd_seq_tick_env;

View File

@ -1,24 +1,109 @@
#include "common.h"
#include "libsnd_i.h"
INCLUDE_ASM("main/nonmatchings/psxsdk/libsnd/ssstart", _SsStart);
void _SsSeqCalledTbyT_1per2();
void _SsTrapIntrVSync();
static void _SsStart(s32 arg0) {
u16 rcnt_target;
s32 wait;
unsigned short var_v0_2;
u32 rcnt_spec;
u8 temp_a0;
void (*callback_func)();
s32 temp;
s32 temp2;
s32 temp3;
wait = 999;
do {
wait -= 1;
} while (wait >= 0);
_snd_seq_tick_env.unk16 = 0;
_snd_seq_tick_env.unk18 = 6;
_snd_seq_tick_env.unk17 = 0;
_snd_seq_tick_env.unk12 = 0;
rcnt_spec = 0xF2000002;
switch (_snd_seq_tick_env.unk0) {
case 0:
_snd_seq_tick_env.unk18 = 0xFF;
return;
case 5:
_snd_seq_tick_env.unk18 = 0;
if (arg0 == 0) {
_snd_seq_tick_env.unk16 = 1;
} else {
rcnt_spec = 0xF2000003;
rcnt_target = 1;
}
break;
case 3:
rcnt_target = 0x89D0U;
break;
case 2:
rcnt_target = 0x44E8;
break;
default:
if (_snd_seq_tick_env.unk4 == 0) {
if (_snd_seq_tick_env.unk0 < 0x46) {
var_v0_2 = 0x204CC0 / _snd_seq_tick_env.unk0;
_snd_seq_tick_env.unk17++;
} else {
var_v0_2 = 0x409980 / _snd_seq_tick_env.unk0;
}
rcnt_target = var_v0_2;
} else {
return;
}
break;
}
temp2 = _snd_seq_tick_env.unk16;
if (temp2 != 0) {
EnterCriticalSection();
VSyncCallback(_snd_seq_tick_env.unk8);
} else {
EnterCriticalSection();
ResetRCnt(rcnt_spec);
SetRCnt(rcnt_spec, rcnt_target & 0xFFFF, 0x1000);
temp_a0 = _snd_seq_tick_env.unk18;
if (temp_a0 == 0) {
temp3 = InterruptCallback(0U, 0);
callback_func = _SsTrapIntrVSync;
temp_a0 = _snd_seq_tick_env.unk18;
_snd_seq_tick_env.unk12 = temp3;
} else {
callback_func = _SsSeqCalledTbyT_1per2;
if (_snd_seq_tick_env.unk17 == 0) {
callback_func = _snd_seq_tick_env.unk8;
}
}
InterruptCallback(temp_a0, callback_func);
}
ExitCriticalSection();
}
void SsStart(void) { _SsStart(1); }
void SsStart2(void) { _SsStart(0); }
void _SsTrapIntrVSync(void) {
if (D_80032EFC != NULL) {
D_80032EFC();
static void _SsTrapIntrVSync(void) {
if (_snd_seq_tick_env.unk12 != NULL) {
_snd_seq_tick_env.unk12();
}
D_80032EF8();
_snd_seq_tick_env.unk8();
}
void _SsSeqCalledTbyT_1per2(void) {
if (D_80032F04 == 0) {
D_80032F04 = 1;
static inline s32 get20() { return _snd_seq_tick_env.unk20; }
static void _SsSeqCalledTbyT_1per2(void) {
if (get20() == 0) {
_snd_seq_tick_env.unk20 = 1;
return;
}
D_80032F04 = 0;
D_80032EF8();
_snd_seq_tick_env.unk20 = 0;
_snd_seq_tick_env.unk8();
}

@ -1 +1 @@
Subproject commit d19cddd9ed40e389e1e7c35e46fd5a768504a66f
Subproject commit 7aad7562e3ae3d8913430048da4211ad5f136441