Add OOB texture fix entry for Arrow heads (#5207)

This commit is contained in:
Archez 2025-03-25 04:21:44 -04:00 committed by GitHub
parent 890f3ccee6
commit 0f1fb1e5de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 73 additions and 0 deletions

View file

@ -21,6 +21,9 @@ static const ALIGN_ASSET(2) char gHilite1Tex[] = dgHilite1Tex;
#define dgHilite2Tex "__OTR__objects/gameplay_keep/gHilite2Tex"
static const ALIGN_ASSET(2) char gHilite2Tex[] = dgHilite2Tex;
#define dgHilite2Tex_Overflow "__OTR__objects/gameplay_keep/gHilite2Tex_Overflow"
static const ALIGN_ASSET(2) char gHilite2Tex_Overflow[] = dgHilite2Tex_Overflow;
#define dgHylianShieldDesignTex "__OTR__objects/gameplay_keep/gHylianShieldDesignTex"
static const ALIGN_ASSET(2) char gHylianShieldDesignTex[] = dgHylianShieldDesignTex;

View file

@ -7,6 +7,8 @@
<Texture Name="gameplay_keepTex_04CF40" OutName="gameplay_keepTex_04CF40" Format="i8" Width="64" Height="17" Offset="0x4CF40" AddedByScript="true"/>
<Texture Name="gHilite1Tex" OutName="hilite_1" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gHilite2Tex" OutName="hilite_2" Format="rgba16" Width="16" Height="16" Offset="0x200"/>
<!-- SOH [Port] Additional entry for authentic overflowed texture usage. This entry has its offset off by "one pixel" due to ZAPD not allowing duplicates -->
<Texture Name="gHilite2Tex_Overflow" OutName="hilite_2_overflow" Format="rgba16" Width="32" Height="32" Offset="0x1FE" />
<Texture Name="gHylianShieldDesignTex" OutName="hylian_shield_design" Format="rgba16" Width="32" Height="64" Offset="0x400"/>
<Texture Name="gOcarinaofTimeDesignTex" OutName="ocarina_of_time_design" Format="rgba16" Width="32" Height="16" Offset="0x1400"/>
<Texture Name="gBottleGlassTex" OutName="bottle_glass" Format="rgba16" Width="16" Height="16" Offset="0x1800"/>

View file

@ -7,6 +7,8 @@
<Texture Name="gameplay_keepTex_04CF40" OutName="gameplay_keepTex_04CF40" Format="i8" Width="64" Height="17" Offset="0x4CF40" AddedByScript="true"/>
<Texture Name="gHilite1Tex" OutName="hilite_1" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gHilite2Tex" OutName="hilite_2" Format="rgba16" Width="16" Height="16" Offset="0x200"/>
<!-- SOH [Port] Additional entry for authentic overflowed texture usage. This entry has its offset off by "one pixel" due to ZAPD not allowing duplicates -->
<Texture Name="gHilite2Tex_Overflow" OutName="hilite_2_overflow" Format="rgba16" Width="32" Height="32" Offset="0x1FE" />
<Texture Name="gHylianShieldDesignTex" OutName="hylian_shield_design" Format="rgba16" Width="32" Height="64" Offset="0x400"/>
<Texture Name="gOcarinaofTimeDesignTex" OutName="ocarina_of_time_design" Format="rgba16" Width="32" Height="16" Offset="0x1400"/>
<Texture Name="gBottleGlassTex" OutName="bottle_glass" Format="rgba16" Width="16" Height="16" Offset="0x1800"/>

View file

@ -7,6 +7,8 @@
<Texture Name="gameplay_keepTex_04CF40" OutName="gameplay_keepTex_04CF40" Format="i8" Width="64" Height="17" Offset="0x4CF40" AddedByScript="true"/>
<Texture Name="gHilite1Tex" OutName="hilite_1" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gHilite2Tex" OutName="hilite_2" Format="rgba16" Width="16" Height="16" Offset="0x200"/>
<!-- SOH [Port] Additional entry for authentic overflowed texture usage. This entry has its offset off by "one pixel" due to ZAPD not allowing duplicates -->
<Texture Name="gHilite2Tex_Overflow" OutName="hilite_2_overflow" Format="rgba16" Width="32" Height="32" Offset="0x1FE" />
<Texture Name="gHylianShieldDesignTex" OutName="hylian_shield_design" Format="rgba16" Width="32" Height="64" Offset="0x400"/>
<Texture Name="gOcarinaofTimeDesignTex" OutName="ocarina_of_time_design" Format="rgba16" Width="32" Height="16" Offset="0x1400"/>
<Texture Name="gBottleGlassTex" OutName="bottle_glass" Format="rgba16" Width="16" Height="16" Offset="0x1800"/>

View file

@ -7,6 +7,8 @@
<Texture Name="gameplay_keepTex_04CF40" OutName="gameplay_keepTex_04CF40" Format="i8" Width="64" Height="17" Offset="0x4CF40" AddedByScript="true"/>
<Texture Name="gHilite1Tex" OutName="hilite_1" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gHilite2Tex" OutName="hilite_2" Format="rgba16" Width="16" Height="16" Offset="0x200"/>
<!-- SOH [Port] Additional entry for authentic overflowed texture usage. This entry has its offset off by "one pixel" due to ZAPD not allowing duplicates -->
<Texture Name="gHilite2Tex_Overflow" OutName="hilite_2_overflow" Format="rgba16" Width="32" Height="32" Offset="0x1FE" />
<Texture Name="gHylianShieldDesignTex" OutName="hylian_shield_design" Format="rgba16" Width="32" Height="64" Offset="0x400"/>
<Texture Name="gOcarinaofTimeDesignTex" OutName="ocarina_of_time_design" Format="rgba16" Width="32" Height="16" Offset="0x1400"/>
<Texture Name="gBottleGlassTex" OutName="bottle_glass" Format="rgba16" Width="16" Height="16" Offset="0x1800"/>

View file

@ -7,6 +7,8 @@
<Texture Name="gameplay_keepTex_04CF40" OutName="gameplay_keepTex_04CF40" Format="i8" Width="64" Height="17" Offset="0x4CF40" AddedByScript="true"/>
<Texture Name="gHilite1Tex" OutName="hilite_1" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gHilite2Tex" OutName="hilite_2" Format="rgba16" Width="16" Height="16" Offset="0x200"/>
<!-- SOH [Port] Additional entry for authentic overflowed texture usage. This entry has its offset off by "one pixel" due to ZAPD not allowing duplicates -->
<Texture Name="gHilite2Tex_Overflow" OutName="hilite_2_overflow" Format="rgba16" Width="32" Height="32" Offset="0x1FE" />
<Texture Name="gHylianShieldDesignTex" OutName="hylian_shield_design" Format="rgba16" Width="32" Height="64" Offset="0x400"/>
<Texture Name="gOcarinaofTimeDesignTex" OutName="ocarina_of_time_design" Format="rgba16" Width="32" Height="16" Offset="0x1400"/>
<Texture Name="gBottleGlassTex" OutName="bottle_glass" Format="rgba16" Width="16" Height="16" Offset="0x1800"/>

View file

@ -7,6 +7,8 @@
<Texture Name="gameplay_keepTex_04CF40" OutName="gameplay_keepTex_04CF40" Format="i8" Width="64" Height="17" Offset="0x4CF40" AddedByScript="true"/>
<Texture Name="gHilite1Tex" OutName="hilite_1" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gHilite2Tex" OutName="hilite_2" Format="rgba16" Width="16" Height="16" Offset="0x200"/>
<!-- SOH [Port] Additional entry for authentic overflowed texture usage. This entry has its offset off by "one pixel" due to ZAPD not allowing duplicates -->
<Texture Name="gHilite2Tex_Overflow" OutName="hilite_2_overflow" Format="rgba16" Width="32" Height="32" Offset="0x1FE" />
<Texture Name="gHylianShieldDesignTex" OutName="hylian_shield_design" Format="rgba16" Width="32" Height="64" Offset="0x400"/>
<Texture Name="gOcarinaofTimeDesignTex" OutName="ocarina_of_time_design" Format="rgba16" Width="32" Height="16" Offset="0x1400"/>
<Texture Name="gBottleGlassTex" OutName="bottle_glass" Format="rgba16" Width="16" Height="16" Offset="0x1800"/>

View file

@ -65,6 +65,63 @@ static DListPatchInfo ironKnuckleDListPatchInfos[] = {
{ object_ik_DL_01D638, 110 },
};
static DListPatchInfo arrowTipDListPatchInfos[] = {
{ gArrowNearDL, 46 },
{ gArrowFarDL, 5 },
};
void PatchArrowTipTexture() {
// Custom texture for Arrow tips that accounts for overflow texture reading
Gfx arrowTipTextureWithOverflowFixGfx =
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b_LOAD_BLOCK, 1, gHilite2Tex_Overflow);
// Gfx instructions to fix authentic vanilla bug where the Arrow tips texture is read as the wrong size
Gfx arrowTipTextureWithSizeFixGfx[] = {
gsDPLoadTextureBlock(gHilite2Tex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP,
G_TX_MIRROR | G_TX_WRAP, 5, 5, 1, 1),
};
bool fixTexturesOOB = CVarGetInteger(CVAR_ENHANCEMENT("FixTexturesOOB"), 0);
for (const auto& patchInfo : arrowTipDListPatchInfos) {
const char* dlist = patchInfo.dlist;
int start = patchInfo.startInstruction;
// Patch using custom overflowed texture
if (!fixTexturesOOB) {
// Unpatch the other texture fix
for (size_t i = 4; i < 8; i++) {
int instruction = start + i;
std::string unpatchName = "arrowTipTextureWithSizeFix_" + std::to_string(instruction);
ResourceMgr_UnpatchGfxByName(dlist, unpatchName.c_str());
}
std::string patchName = "arrowTipTextureWithOverflowFix_" + std::to_string(start);
std::string patchName2 = "arrowTipTextureWithOverflowFix_" + std::to_string(start + 1);
ResourceMgr_PatchGfxByName(dlist, patchName.c_str(), start, arrowTipTextureWithOverflowFixGfx);
ResourceMgr_PatchGfxByName(dlist, patchName2.c_str(), start + 1, gsSPNoOp());
} else { // Patch texture to use correct image size/fmt
// Unpatch the other texture fix
std::string unpatchName = "arrowTipTextureWithOverflowFix_" + std::to_string(start);
std::string unpatchName2 = "arrowTipTextureWithOverflowFix_" + std::to_string(start + 1);
ResourceMgr_UnpatchGfxByName(dlist, unpatchName.c_str());
ResourceMgr_UnpatchGfxByName(dlist, unpatchName2.c_str());
for (size_t i = 4; i < 8; i++) {
int instruction = start + i;
std::string patchName = "arrowTipTextureWithSizeFix_" + std::to_string(instruction);
if (i == 0) {
ResourceMgr_PatchGfxByName(dlist, patchName.c_str(), instruction, gsSPNoOp());
} else {
ResourceMgr_PatchGfxByName(dlist, patchName.c_str(), instruction,
arrowTipTextureWithSizeFixGfx[i - 1]);
}
}
}
}
}
void PatchDekuStickTextureOverflow() {
// Custom texture for holding Deku Stick that accounts for overflow texture reading
Gfx dekuSticTexkWithOverflowFixGfx = gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_8b, 1, gDekuStickOverflowTex);
@ -216,6 +273,7 @@ void PatchIronKnuckleTextureOverflow() {
}
void ApplyAuthenticGfxPatches() {
PatchArrowTipTexture();
PatchDekuStickTextureOverflow();
PatchFreezardTextureOverflow();
PatchIronKnuckleTextureOverflow();