mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-23 05:59:40 +00:00
fix zora magic shield alpha (#768)
This commit is contained in:
parent
a5059beaeb
commit
137ca0de12
@ -1 +1 @@
|
|||||||
Subproject commit 375489d5f1f5fa4b9144ac9669c411e3b149f32a
|
Subproject commit 854685155a6addaf72ec2415ac481a08ace9f9ce
|
@ -1 +1 @@
|
|||||||
Subproject commit 3d2b4da8e327a6a096993996c5280c069a92c03f
|
Subproject commit 7a88bfc08cbe44fd682b8f6f66b9d32d44b699bc
|
@ -1080,6 +1080,25 @@ extern "C" size_t ResourceMgr_GetArraySizeByName(const char* path) {
|
|||||||
|
|
||||||
return res->Scalars.size();
|
return res->Scalars.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loads U8 data from an Array resource into an externally managed buffer, or mallocs a new buffer
|
||||||
|
// if the passed in a nullptr. This malloced buffer must be freed by the caller.
|
||||||
|
extern "C" u8* ResourceMgr_LoadArrayByNameAsU8(const char* path, u8* buffer) {
|
||||||
|
auto res = std::static_pointer_cast<SOH::Array>(GetResourceByName(path));
|
||||||
|
|
||||||
|
if (buffer == nullptr) {
|
||||||
|
buffer = (u8*)malloc(sizeof(u8) * res->Scalars.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < res->Scalars.size(); i++) {
|
||||||
|
buffer[i] = res->Scalars[i].u8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loads Vec3s data from an Array resource.
|
||||||
|
// mallocs a new buffer that must be freed by the caller.
|
||||||
extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
|
extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
|
||||||
auto res = std::static_pointer_cast<SOH::Array>(GetResourceByName(path));
|
auto res = std::static_pointer_cast<SOH::Array>(GetResourceByName(path));
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc);
|
|||||||
Gfx* ResourceMgr_LoadGfxByName(const char* path);
|
Gfx* ResourceMgr_LoadGfxByName(const char* path);
|
||||||
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
|
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
|
||||||
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
|
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
|
||||||
|
u8* ResourceMgr_LoadArrayByNameAsU8(const char* path, u8* buffer);
|
||||||
char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path);
|
char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path);
|
||||||
char* ResourceMgr_LoadArrayByName(const char* path);
|
char* ResourceMgr_LoadArrayByName(const char* path);
|
||||||
size_t ResourceMgr_GetArraySizeByName(const char* path);
|
size_t ResourceMgr_GetArraySizeByName(const char* path);
|
||||||
|
@ -43,12 +43,34 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryArrayV0::ReadResource(std:
|
|||||||
ScalarData data;
|
ScalarData data;
|
||||||
|
|
||||||
switch (array->ArrayScalarType) {
|
switch (array->ArrayScalarType) {
|
||||||
|
case ScalarType::ZSCALAR_S8:
|
||||||
|
data.s8 = reader->ReadInt8();
|
||||||
|
break;
|
||||||
|
case ScalarType::ZSCALAR_U8:
|
||||||
|
case ScalarType::ZSCALAR_X8:
|
||||||
|
data.u8 = reader->ReadUByte();
|
||||||
|
break;
|
||||||
case ScalarType::ZSCALAR_S16:
|
case ScalarType::ZSCALAR_S16:
|
||||||
data.s16 = reader->ReadInt16();
|
data.s16 = reader->ReadInt16();
|
||||||
break;
|
break;
|
||||||
case ScalarType::ZSCALAR_U16:
|
case ScalarType::ZSCALAR_U16:
|
||||||
|
case ScalarType::ZSCALAR_X16:
|
||||||
data.u16 = reader->ReadUInt16();
|
data.u16 = reader->ReadUInt16();
|
||||||
break;
|
break;
|
||||||
|
case ScalarType::ZSCALAR_S32:
|
||||||
|
data.s32 = reader->ReadInt32();
|
||||||
|
break;
|
||||||
|
case ScalarType::ZSCALAR_U32:
|
||||||
|
case ScalarType::ZSCALAR_X32:
|
||||||
|
data.u32 = reader->ReadUInt32();
|
||||||
|
break;
|
||||||
|
case ScalarType::ZSCALAR_S64:
|
||||||
|
data.s64 = reader->ReadInt64();
|
||||||
|
break;
|
||||||
|
case ScalarType::ZSCALAR_U64:
|
||||||
|
case ScalarType::ZSCALAR_X64:
|
||||||
|
data.u64 = reader->ReadUInt64();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// OTRTODO: IMPLEMENT OTHER TYPES!
|
// OTRTODO: IMPLEMENT OTHER TYPES!
|
||||||
break;
|
break;
|
||||||
@ -61,4 +83,4 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryArrayV0::ReadResource(std:
|
|||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
} // namespace SOH
|
} // namespace SOH
|
||||||
|
@ -2124,13 +2124,17 @@ void Player_DrawZoraShield(PlayState* play, Player* player) {
|
|||||||
f32 scale = player->unk_B62 * (10.0f / 51.0f);
|
f32 scale = player->unk_B62 * (10.0f / 51.0f);
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
|
// 2S2H [Port] Graph allocated buffer to be used with ResourceMgr_LoadArrayByNameAsU8 to avoid
|
||||||
|
// needing to use malloc/free with Scalar based Array resources
|
||||||
|
u8* alphaU8Buffer = GRAPH_ALLOC(play->state.gfxCtx, 80 * sizeof(u8));
|
||||||
|
|
||||||
OPEN_DISPS(play->state.gfxCtx);
|
OPEN_DISPS(play->state.gfxCtx);
|
||||||
|
|
||||||
AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_zora_Matanimheader_012A80));
|
AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_zora_Matanimheader_012A80));
|
||||||
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
|
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
vtx = ResourceMgr_LoadVtxByName(Lib_SegmentedToVirtual(&object_link_zora_Vtx_011210)); phi_a0 = (u8*)ResourceMgr_LoadArrayByName(Lib_SegmentedToVirtual(&object_link_zora_U8_011710));
|
vtx = ResourceMgr_LoadVtxByName(Lib_SegmentedToVirtual(&object_link_zora_Vtx_011210)); phi_a0 = ResourceMgr_LoadArrayByNameAsU8(Lib_SegmentedToVirtual(&object_link_zora_U8_011710), alphaU8Buffer);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// ARRAY_COUNT(object_link_zora_Vtx_011210)
|
// ARRAY_COUNT(object_link_zora_Vtx_011210)
|
||||||
|
Loading…
Reference in New Issue
Block a user