summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorDerek Hensley <hensley.derek58@gmail.com>2022-02-19 15:49:36 -0800
committerGitHub <noreply@github.com>2022-02-19 23:49:36 +0000
commit71c0120fbd7191a6c543b547946573a347bad749 (patch)
treeaa0955cccb4198c1999575200c1fed6d4b62f890 /src/code
parentf67ecbc3c222197cfdd9e63e8cc78506db06f0d4 (diff)
SubS Cutscenes, Flags, Objects, and Angles (#665)
* Bring cutscene code over * Document cutscene functions * Bring over flags code * Document flags * Bring Object code over * Document object functions * Better infinite loop comment * Remove Effect_add correction * Bring func_8013D5E8 code over * Document angle helper * ActorFixer * Rename angle helper * Missed gs * Should probably test before commiting * Better angle helper name as well as typo fix * English is hard * Len to num * Fix merge * Fix merge * Format Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com>
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_en_hy_code.c8
-rw-r--r--src/code/z_sub_s.c69
2 files changed, 65 insertions, 12 deletions
diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c
index 7b17f78f2..b803b291c 100644
--- a/src/code/z_en_hy_code.c
+++ b/src/code/z_en_hy_code.c
@@ -112,10 +112,10 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) {
s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) {
s32 isInitialized = false;
- if ((func_8013D8DC(enHy->animObjIndex, globalCtx) == true) &&
- (func_8013D8DC(enHy->headObjIndex, globalCtx) == true) &&
- (func_8013D8DC(enHy->skelUpperObjIndex, globalCtx) == true) &&
- (func_8013D8DC(enHy->skelLowerObjIndex, globalCtx) == true)) {
+ if ((SubS_IsObjectLoaded(enHy->animObjIndex, globalCtx) == true) &&
+ (SubS_IsObjectLoaded(enHy->headObjIndex, globalCtx) == true) &&
+ (SubS_IsObjectLoaded(enHy->skelUpperObjIndex, globalCtx) == true) &&
+ (SubS_IsObjectLoaded(enHy->skelLowerObjIndex, globalCtx) == true)) {
enHy->actor.objBankIndex = enHy->skelLowerObjIndex;
isInitialized = true;
ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f);
diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c
index 2ce355d47..eda973125 100644
--- a/src/code/z_sub_s.c
+++ b/src/code/z_sub_s.c
@@ -154,7 +154,9 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AED4.s")
+void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) {
+ *flags = (*flags & ~unsetBits) | setBits;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s")
@@ -248,7 +250,9 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D5E8.s")
+s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) {
+ return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s")
@@ -260,9 +264,13 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D8DC.s")
+s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) {
+ return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true;
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s")
+s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx) {
+ return Object_GetIndex(&globalCtx->objectCtx, id);
+}
/**
* Finds the first actor instance of a specified Id and category.
@@ -281,11 +289,11 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC
return actor;
}
-s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 limbRotTableLen) {
+s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) {
s32 i;
u32 frames = globalCtx->gameplayFrames;
- for (i = 0; i < limbRotTableLen; i++) {
+ for (i = 0; i < numLimbs; i++) {
limbRotTableY[i] = (i * 50 + 0x814) * frames;
limbRotTableZ[i] = (i * 50 + 0x940) * frames;
}
@@ -340,9 +348,54 @@ void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* a
*curIndex = nextIndex;
}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E2D4.s")
+s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type) {
+ s32 isStarted = false;
+
+ if ((curCutscene != -1) && (ActorCutscene_GetCurrentIndex() == curCutscene)) {
+ ActorCutscene_Stop(curCutscene);
+ ActorCutscene_SetIntentToPlay(nextCutscene);
+ } else if (ActorCutscene_GetCanPlayNext(nextCutscene)) {
+ switch (type) {
+ case SUBS_CUTSCENE_SET_UNK_LINK_FIELDS:
+ ActorCutscene_StartAndSetUnkLinkFields(nextCutscene, actor);
+ break;
+ case SUBS_CUTSCENE_NORMAL:
+ ActorCutscene_Start(nextCutscene, actor);
+ break;
+ case SUBS_CUTSCENE_SET_FLAG:
+ ActorCutscene_StartAndSetFlag(nextCutscene, actor);
+ break;
+ }
+ isStarted = true;
+ } else {
+ ActorCutscene_SetIntentToPlay(nextCutscene);
+ }
+
+ return isStarted;
+}
+
+s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) {
+ s16 cs;
+ s32 i;
+
+ for (i = 0; i < numCutscenes; i++) {
+ cutscenes[i] = -1;
+ }
+
+ cs = actor->cutscene;
+ i = 0;
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E3B8.s")
+ while (cs != -1) {
+ // Note: Infinite loop if numCutscenes is less than possible additional cutscenes
+ if (i < numCutscenes) {
+ cutscenes[i] = cs;
+ cs = ActorCutscene_GetAdditionalCutscene(cs);
+ i++;
+ }
+ }
+
+ return i;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s")