Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mm/2s2h/BenPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ CrowdControl* CrowdControl::Instance;
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/Enhancements/Enhancements.h"
#include "2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.h"
#include "2s2h/Enhancements/GfxPatcher/PlayerCustomFlipbooks.h"
#include "2s2h/DeveloperTools/DebugConsole.h"
#include "2s2h/Rando/Rando.h"
#include "2s2h/Rando/Spoiler/Spoiler.h"
Expand Down Expand Up @@ -719,6 +720,7 @@ extern "C" void InitOTR() {
OTRMessage_Init();
OTRAudio_Init();
OTRExtScanner();
PlayerCustomFlipbooks_Patch();

// Just came up with arbitrary numbers that seemed to work, this is
// usually set once(?) in currently stubbed out areas of code.
Expand Down
133 changes: 133 additions & 0 deletions mm/2s2h/Enhancements/GfxPatcher/PlayerCustomFlipbooks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#include "PlayerCustomFlipbooks.h"
#include "2s2h/BenPort.h"

extern "C" {
#include "z64player.h"
extern TexturePtr sPlayerEyesTextures[PLAYER_FORM_MAX][PLAYER_EYES_MAX];
extern TexturePtr sPlayerMouthTextures[PLAYER_FORM_MAX][PLAYER_MOUTH_MAX];
uint8_t ResourceMgr_FileExists(const char* resName);
}

static const char* sFDEyesTextures[PLAYER_EYES_MAX] = {
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesOpenTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesHalfTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesClosedTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesRightTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesLeftTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesUpTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesDownTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityEyesWincingTex",
};

static const char* sFDMouthTextures[PLAYER_MOUTH_MAX] = {
"__OTR__objects/object_link_boy/gLinkFierceDeityMouthClosedTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityMouthHalfTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityMouthOpenTex",
"__OTR__objects/object_link_boy/gLinkFierceDeityMouthSmileTex",
};

static const char* sDekuEyesTextures[PLAYER_EYES_MAX] = {
"__OTR__objects/object_link_nuts/gLinkDekuEyesOpenTex", "__OTR__objects/object_link_nuts/gLinkDekuEyesHalfTex",
"__OTR__objects/object_link_nuts/gLinkDekuEyesClosedTex", "__OTR__objects/object_link_nuts/gLinkDekuEyesRightTex",
"__OTR__objects/object_link_nuts/gLinkDekuEyesLeftTex", "__OTR__objects/object_link_nuts/gLinkDekuEyesUpTex",
"__OTR__objects/object_link_nuts/gLinkDekuEyesDownTex", "__OTR__objects/object_link_nuts/gLinkDekuEyesWincingTex",
};

static const char* sDekuMouthTextures[PLAYER_MOUTH_MAX] = {
"__OTR__objects/object_link_nuts/gLinkDekuMouthClosedTex",
"__OTR__objects/object_link_nuts/gLinkDekuMouthHalfTex",
"__OTR__objects/object_link_nuts/gLinkDekuMouthOpenTex",
"__OTR__objects/object_link_nuts/gLinkDekuMouthSmileTex",
};

static const char* sGoronMouthTextures[PLAYER_MOUTH_MAX] = {
"__OTR__objects/object_link_goron/gLinkGoronMouthClosedTex",
"__OTR__objects/object_link_goron/gLinkGoronMouthHalfTex",
"__OTR__objects/object_link_goron/gLinkGoronMouthOpenTex",
"__OTR__objects/object_link_goron/gLinkGoronMouthSmileTex",
};

static s32 sFacePatchState = 0;

static void PlayerCustomFlipbooks_PatchOnce(void) {
if (sFacePatchState != 0) {
return;
}

bool EyesPatch = true;
bool MouthPatch = true;
bool DekuEyesPatch = true;
bool DekuMouthPatch = true;
bool GoronMouthPatch = true;

for (s32 i = 0; i < PLAYER_EYES_MAX; i++) {
if (!ResourceMgr_FileExists(sFDEyesTextures[i])) {
EyesPatch = false;
break;
}
}

for (s32 i = 0; i < PLAYER_MOUTH_MAX; i++) {
if (!ResourceMgr_FileExists(sFDMouthTextures[i])) {
MouthPatch = false;
break;
}
}

for (s32 i = 0; i < PLAYER_EYES_MAX; i++) {
if (!ResourceMgr_FileExists(sDekuEyesTextures[i])) {
DekuEyesPatch = false;
break;
}
}

for (s32 i = 0; i < PLAYER_MOUTH_MAX; i++) {
if (!ResourceMgr_FileExists(sDekuMouthTextures[i])) {
DekuMouthPatch = false;
break;
}
}

for (s32 i = 0; i < PLAYER_MOUTH_MAX; i++) {
if (!ResourceMgr_FileExists(sGoronMouthTextures[i])) {
GoronMouthPatch = false;
break;
}
}

if (EyesPatch) {
for (s32 i = 0; i < PLAYER_EYES_MAX; i++) {
sPlayerEyesTextures[PLAYER_FORM_FIERCE_DEITY][i] = (TexturePtr)sFDEyesTextures[i];
}
}

if (MouthPatch) {
for (s32 i = 0; i < PLAYER_MOUTH_MAX; i++) {
sPlayerMouthTextures[PLAYER_FORM_FIERCE_DEITY][i] = (TexturePtr)sFDMouthTextures[i];
}
}

if (DekuEyesPatch) {
for (s32 i = 0; i < PLAYER_EYES_MAX; i++) {
sPlayerEyesTextures[PLAYER_FORM_DEKU][i] = (TexturePtr)sDekuEyesTextures[i];
}
}

if (DekuMouthPatch) {
for (s32 i = 0; i < PLAYER_MOUTH_MAX; i++) {
sPlayerMouthTextures[PLAYER_FORM_DEKU][i] = (TexturePtr)sDekuMouthTextures[i];
}
}

if (GoronMouthPatch) {
for (s32 i = 0; i < PLAYER_MOUTH_MAX; i++) {
sPlayerMouthTextures[PLAYER_FORM_GORON][i] = (TexturePtr)sGoronMouthTextures[i];
}
}

sFacePatchState = 1;
}

void PlayerCustomFlipbooks_Patch(void) {
PlayerCustomFlipbooks_PatchOnce();
}
3 changes: 3 additions & 0 deletions mm/2s2h/Enhancements/GfxPatcher/PlayerCustomFlipbooks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void PlayerCustomFlipbooks_Patch(void);
Loading