mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-04 23:14:37 +00:00
Decompile 2 small files (code_8006BA00.c and code_8006C3A0.c) (#101)
* Decompile code_8006C3A0.c (handling "env" flags) * Decompile code_8006BA00.c (handling sound sources)
This commit is contained in:
parent
d0ba37b148
commit
4932e93ba2
31 changed files with 143 additions and 296 deletions
65
src/code/code_8006BA00.c
Normal file
65
src/code/code_8006BA00.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
void func_8006BA00(GlobalContext* globalCtx) {
|
||||
SoundSource* sources = &globalCtx->soundSources[0];
|
||||
s32 i;
|
||||
|
||||
// clang-format off
|
||||
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { sources[i].countdown = 0; }
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void func_8006BA30(GlobalContext* globalCtx) {
|
||||
SoundSource* source;
|
||||
s32 i;
|
||||
|
||||
source = &globalCtx->soundSources[0];
|
||||
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
|
||||
if (source->countdown != 0) {
|
||||
if (DECR(source->countdown) == 0) {
|
||||
func_800F89E8(&source->relativePos);
|
||||
} else {
|
||||
func_800A6EF4(&globalCtx->mf_11D60, &source->originPos, &source->relativePos);
|
||||
}
|
||||
}
|
||||
|
||||
source++;
|
||||
}
|
||||
}
|
||||
|
||||
void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId) {
|
||||
s32 countdown;
|
||||
SoundSource* source;
|
||||
s32 smallestCountdown;
|
||||
SoundSource* backupSource;
|
||||
s32 i;
|
||||
|
||||
smallestCountdown = 0xFFFF;
|
||||
|
||||
source = &globalCtx->soundSources[0];
|
||||
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
|
||||
if (source->countdown == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
countdown = source->countdown;
|
||||
if (countdown < smallestCountdown) {
|
||||
smallestCountdown = countdown;
|
||||
backupSource = source;
|
||||
}
|
||||
|
||||
source++;
|
||||
}
|
||||
|
||||
if (i >= ARRAY_COUNT(globalCtx->soundSources)) {
|
||||
source = backupSource;
|
||||
func_800F89E8(&source->relativePos);
|
||||
}
|
||||
|
||||
source->originPos = *pos;
|
||||
source->countdown = duration;
|
||||
|
||||
func_800A6EF4(&globalCtx->mf_11D60, &source->originPos, &source->relativePos);
|
||||
Audio_PlaySoundGeneral(sfxId, &source->relativePos, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
}
|
|
@ -1,10 +1,34 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C3A0.s")
|
||||
void Flags_UnsetAllEnv(GlobalContext* globalCtx) {
|
||||
u8 i;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C3D0.s")
|
||||
for (i = 0; i < 20; i++) {
|
||||
globalCtx->envFlags[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C438.s")
|
||||
void Flags_SetEnv(GlobalContext* globalCtx, s16 flag) {
|
||||
s16 index = flag / 16;
|
||||
s16 bit = flag % 16;
|
||||
s16 mask = 1 << bit;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C4A4.s")
|
||||
globalCtx->envFlags[index] |= mask;
|
||||
}
|
||||
|
||||
void Flags_UnsetEnv(GlobalContext* globalCtx, s16 flag) {
|
||||
s16 index = flag / 16;
|
||||
s16 bit = flag % 16;
|
||||
s16 mask = (1 << bit) ^ 0xFFFF;
|
||||
|
||||
globalCtx->envFlags[index] &= mask;
|
||||
}
|
||||
|
||||
s32 Flags_GetEnv(GlobalContext* globalCtx, s16 flag) {
|
||||
s16 index = flag / 16;
|
||||
s16 bit = flag % 16;
|
||||
s16 mask = 1 << bit;
|
||||
|
||||
return globalCtx->envFlags[index] & mask;
|
||||
}
|
||||
|
|
|
@ -3054,7 +3054,7 @@ Actor* Actor_Find(ActorContext* actorCtx, s32 actorId, s32 actorType) {
|
|||
|
||||
void func_80032C7C(GlobalContext* globalCtx, Actor* actor) {
|
||||
globalCtx->actorCtx.unk_00 = 5;
|
||||
Audio_PlaySoundAtPosition(globalCtx, &actor->posRot.pos, 0x14, NA_SE_EN_LAST_DAMAGE);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &actor->posRot.pos, 20, NA_SE_EN_LAST_DAMAGE);
|
||||
}
|
||||
|
||||
s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
|
||||
|
|
|
@ -193,9 +193,9 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
|
|||
break;
|
||||
case 3:
|
||||
if (sp3F != 0) {
|
||||
func_8006C3D0(globalCtx, 0);
|
||||
Flags_SetEnv(globalCtx, 0);
|
||||
if (gSaveContext.entranceIndex == 0x0053) {
|
||||
func_8006C3D0(globalCtx, 2);
|
||||
Flags_SetEnv(globalCtx, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -225,7 +225,7 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
|
|||
globalCtx->envCtx.unk_EE[3] = 0x10;
|
||||
break;
|
||||
case 10:
|
||||
func_8006C3D0(globalCtx, 1);
|
||||
Flags_SetEnv(globalCtx, 1);
|
||||
break;
|
||||
case 11:
|
||||
if (globalCtx->unk_11D30[0] < 0x672) {
|
||||
|
@ -350,10 +350,10 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
|
|||
globalCtx->unk_11DE9 = 0;
|
||||
break;
|
||||
case 30:
|
||||
func_8006C3D0(globalCtx, 3);
|
||||
Flags_SetEnv(globalCtx, 3);
|
||||
break;
|
||||
case 31:
|
||||
func_8006C3D0(globalCtx, 4);
|
||||
Flags_SetEnv(globalCtx, 4);
|
||||
break;
|
||||
case 32:
|
||||
if (sp3F != 0) {
|
||||
|
@ -1935,7 +1935,7 @@ void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx) {
|
|||
}
|
||||
|
||||
if ((gSaveContext.cutsceneIndex >= 0xFFF0) && (csCtx->state == CS_STATE_IDLE)) {
|
||||
func_8006C438(globalCtx, 0);
|
||||
Flags_UnsetEnv(globalCtx, 0);
|
||||
|
||||
D_8011E1C0 = 0;
|
||||
D_8011E1C4 = 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ void Effect_SS_Clear(GlobalContext* globalCtx) {
|
|||
|
||||
void Effect_SS_Delete(LoadedParticleEntry* particle) {
|
||||
if (particle->flags & 2) {
|
||||
func_800F89E8(particle);
|
||||
func_800F89E8(&particle->position);
|
||||
}
|
||||
|
||||
if (particle->flags & 4) {
|
||||
|
|
|
@ -2,16 +2,11 @@
|
|||
#include <global.h>
|
||||
|
||||
void Lib_MemSet(u8* dest, size_t size, u8 val) {
|
||||
u32 i = 0;
|
||||
u32 i;
|
||||
|
||||
// TODO: Convert this to while/for if possible
|
||||
if (i == size) {
|
||||
return;
|
||||
}
|
||||
do {
|
||||
*dest++ = val;
|
||||
i++;
|
||||
} while (i != size);
|
||||
// clang-format off
|
||||
for (i = 0; i < size; i++) { *dest++ = val; }
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
f32 Math_Coss(s16 angle) {
|
||||
|
|
|
@ -367,7 +367,7 @@ void Gameplay_Init(GlobalContext* globalCtx) {
|
|||
TransitionFade_Start(&globalCtx->transitionFade);
|
||||
func_800AD000(&D_80161498);
|
||||
D_801614B0.a = 0x00;
|
||||
func_8006C3A0(globalCtx);
|
||||
Flags_UnsetAllEnv(globalCtx);
|
||||
|
||||
osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetSize(&globalCtx->state.tha));
|
||||
zAllocSize = THA_GetSize(&globalCtx->state.tha);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue