From 12406d3dfc9cde3c0c2420e64a1f4e20197e7c78 Mon Sep 17 00:00:00 2001 From: krystalgamer Date: Thu, 9 May 2024 18:46:44 +0200 Subject: [PATCH] M3dInit_FlagZeroWibbles --- m3dinit.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ m3dinit.h | 35 +++++++++++++++++++++++++ main.cpp | 30 ++-------------------- 3 files changed, 111 insertions(+), 28 deletions(-) diff --git a/m3dinit.cpp b/m3dinit.cpp index 7aedd63..f1c3680 100644 --- a/m3dinit.cpp +++ b/m3dinit.cpp @@ -1,3 +1,77 @@ #include "m3dinit.h" #include "validate.h" + +// @Ok +// Hated this piece of shit, memoery accesses are fucked up on the original for some reason +// there might be a hidden struct or smth, it's not the first time I see something like this +// where pointers to the middle of the struct are used +void M3dInit_FlagZeroWibbles(STexWibItemInfo *pTexWibItemInfo) +{ + print_if_false(pTexWibItemInfo != NULL, "NULL pTexWibItemInfo"); + + STexWibItemInfo *v1 = pTexWibItemInfo; + STexWibItemInfo *v3; + unsigned int v2; + + while (v1->ItemOffset.Full) + { + v2 = 0; + + v1->ZeroUAmplitudes = 1; + v2 = v1->field_C.Full; + v1->ZeroVAmplitudes = 1; + + v3 = v1 + 1; + + +#define AmplitudeCheck(x, arg) {\ + int tmp = 0;\ + tmp = (x);\ + if ( ((int)((tmp) & 0xFFFFFFF0)) > ((int)0x00000050) ) {\ + v1->arg = 0; }\ +} + +#define UAmplitudeCheck(x) AmplitudeCheck(x, ZeroUAmplitudes) +#define VAmplitudeCheck(x) AmplitudeCheck(x, ZeroVAmplitudes) + + while (v2) + { + UAmplitudeCheck(v3->ItemOffset.Byte[2]); + VAmplitudeCheck(v3->ItemOffset.Byte[3]); + + UAmplitudeCheck(v3->field_6); + VAmplitudeCheck(v3->field_7); + + UAmplitudeCheck(v3->field_8); + VAmplitudeCheck(v3->field_9); + + + UAmplitudeCheck(v3->ZeroUAmplitudes); + VAmplitudeCheck(v3->ZeroVAmplitudes); + + v3++; + v2--; + } + + v1 = v3; + + } +} + +void validate_STexWibItemInfo() +{ + VALIDATE_SIZE(STexWibItemInfo, 0x10); + + VALIDATE(STexWibItemInfo, ItemOffset, 0x0); + + VALIDATE(STexWibItemInfo, field_6, 0x6); + VALIDATE(STexWibItemInfo, field_7, 0x7); + VALIDATE(STexWibItemInfo, field_8, 0x8); + VALIDATE(STexWibItemInfo, field_9, 0x9); + + VALIDATE(STexWibItemInfo, field_C, 0xC); + + VALIDATE(STexWibItemInfo, ZeroUAmplitudes, 0xE); + VALIDATE(STexWibItemInfo, ZeroVAmplitudes, 0xF); +} diff --git a/m3dinit.h b/m3dinit.h index f725dc8..4caf724 100644 --- a/m3dinit.h +++ b/m3dinit.h @@ -5,4 +5,39 @@ #include "export.h" +union ItemOffsetUnion +{ + unsigned Full; + unsigned char Byte[4]; +}; + +union UnionItemInfo +{ + unsigned __int16 Full; + unsigned char Byte[2]; +}; + +struct STexWibItemInfo +{ + ItemOffsetUnion ItemOffset; + unsigned char padAfterOffset[2]; + + unsigned char field_6; + unsigned char field_7; + unsigned char field_8; + unsigned char field_9; + + unsigned char padAfter9[2]; + + UnionItemInfo field_C; + + unsigned char ZeroUAmplitudes; + unsigned char ZeroVAmplitudes; +}; + + +EXPORT void M3dInit_FlagZeroWibbles(STexWibItemInfo *pTexWibItemInfo); + +void validate_STexWibItemInfo(); + #endif diff --git a/main.cpp b/main.cpp index 341da94..5e48110 100644 --- a/main.cpp +++ b/main.cpp @@ -6,68 +6,41 @@ #include "vector.h" #include "friction.h" #include "bit.h" - #include "front.h" - #include "pshell.h" - #include "baddy.h" - #include "mj.h" - #include "submarin.h" - #include "venom.h" - #include "ps2funcs.h" - #include "blackcat.h" - #include "torch.h" - #include "hostage.h" #include "cop.h" - #include "carnage.h" - #include "chopper.h" - #include "docock.h" - #include "jonah.h" - #include "lizard.h" - #include "lizman.h" - #include "mysterio.h" - #include "platform.h" - #include "rhino.h" - #include "scorpion.h" - #include "simby.h" - #include "spclone.h" - #include "superock.h" - #include "thug.h" - #include "turret.h" - #include "shell.h" - #include "web.h" #include "bit2.h" #include "camera.h" #include "quat.h" - #include "mem.h" #include "exp.h" #include "m3dcolij.h" +#include "m3dinit.h" template @@ -232,6 +205,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, validate_SHandle(); validate_CItemFrag(); validate_SLineInfo(); + validate_STexWibItemInfo();