From 5d11a157dd41a0a738e95636672fca4870029747 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 12 Oct 2023 19:46:34 +0200 Subject: [PATCH] port Matrix_PushUnit --- docs/progress.svg | 16 ++++++++-------- docs/progress.txt | 2 +- src/game/matrix.c | 17 +++++++++++++++++ src/game/matrix.h | 1 + src/global/funcs.h | 1 - src/inject_exec.c | 1 + 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/progress.svg b/docs/progress.svg index 9001897..51219c6 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -17.67% (212) · 79.92% (959) · 0.67% (8) · 1.75% (21) +17.75% (213) · 79.83% (958) · 0.67% (8) · 1.75% (21) - - + + @@ -1266,7 +1266,7 @@ void __cdecl SE_PassMessageToImage(HWND hWnd, UINT uMsg, WPARAM wParam); void __cdecl UT_MemBlt(BYTE *dstBuf, DWORD dstX, DWORD dstY, DWORD width, DWORD height, DWORD dstPitch, BYTE *srcBuf, DWORD srcX, DWORD srcY, DWORD srcPitch); void __cdecl Matrix_Push(void); -void __cdecl Matrix_PushUnit(void); +void __cdecl Matrix_PushUnit(void); void __fastcall flatA(int32_t y0, int32_t y1, BYTE colorIdx); void __fastcall transA(int32_t y0, int32_t y1, BYTE depthQ); void __fastcall gourA(int32_t y0, int32_t y1, BYTE colorIdx); @@ -1281,10 +1281,10 @@ Tomb2.exe progress according to the function sizes: -9.96% · 89.71% · 0.02% · 0.31% +9.97% · 89.70% · 0.02% · 0.31% - - + + @@ -2233,7 +2233,7 @@ void __cdecl draw_shotgun_meshes(int32_t weapon_type); int32_t __cdecl PickupTrigger(int16_t item_num); void __cdecl DDrawRelease(void); -void __cdecl Matrix_PushUnit(void); +void __cdecl Matrix_PushUnit(void); int16_t *__cdecl Output_CalcBackgroundLight(const int16_t *obj_ptr); void __cdecl RingActive(void); void __cdecl Lara_GetCollisionInfo(struct ITEM_INFO *item, struct COLL_INFO *coll); diff --git a/docs/progress.txt b/docs/progress.txt index 3bafb3d..e52b6b7 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -2428,7 +2428,7 @@ typedef enum LARA_MESH { 004571E0 00000026 -R void __cdecl SE_PassMessageToImage(HWND hWnd, UINT uMsg, WPARAM wParam); 00457210 0000006E -R void __cdecl UT_MemBlt(BYTE *dstBuf, DWORD dstX, DWORD dstY, DWORD width, DWORD height, DWORD dstPitch, BYTE *srcBuf, DWORD srcX, DWORD srcY, DWORD srcPitch); 00457280 0000001E + void __cdecl Matrix_Push(void); -0045729E 00000033 * void __cdecl Matrix_PushUnit(void); +0045729E 00000033 + void __cdecl Matrix_PushUnit(void); 004572D4 00000061 -R void __fastcall flatA(int32_t y0, int32_t y1, BYTE colorIdx); 00457335 0000013A -R void __fastcall transA(int32_t y0, int32_t y1, BYTE depthQ); 0045746F 00000160 -R void __fastcall gourA(int32_t y0, int32_t y1, BYTE colorIdx); diff --git a/src/game/matrix.c b/src/game/matrix.c index bc70886..1e9d9b0 100644 --- a/src/game/matrix.c +++ b/src/game/matrix.c @@ -15,6 +15,23 @@ void __cdecl Matrix_Push(void) g_MatrixPtr[0] = g_MatrixPtr[-1]; } +void __cdecl Matrix_PushUnit(void) +{ + struct MATRIX *mptr = ++g_MatrixPtr; + mptr->_00 = (1 << W2V_SHIFT); + mptr->_01 = 0; + mptr->_02 = 0; + mptr->_10 = 0; + mptr->_11 = (1 << W2V_SHIFT); + mptr->_12 = 0; + mptr->_20 = 0; + mptr->_21 = 0; + mptr->_22 = (1 << W2V_SHIFT); + // mptr->_03 = 0; + // mptr->_13 = 0; + // mptr->_23 = 0; +} + void __cdecl Matrix_Pop(void) { g_MatrixPtr--; diff --git a/src/game/matrix.h b/src/game/matrix.h index 9596ff8..5885a97 100644 --- a/src/game/matrix.h +++ b/src/game/matrix.h @@ -8,6 +8,7 @@ struct PHD_3DPOS; void __cdecl Matrix_Push(void); +void __cdecl Matrix_PushUnit(void); void __cdecl Matrix_Pop(void); void __cdecl Matrix_GenerateW2V(struct PHD_3DPOS *viewpos); void __cdecl Matrix_LookAt( diff --git a/src/global/funcs.h b/src/global/funcs.h index bcb53a5..7979ce9 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -958,7 +958,6 @@ #define SE_SetupWindowProc ((LRESULT __stdcall (*)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam))0x00456FA0) #define SE_PassMessageToImage ((void __cdecl (*)(HWND hWnd, UINT uMsg, WPARAM wParam))0x004571E0) #define UT_MemBlt ((void __cdecl (*)(BYTE *dstBuf, DWORD dstX, DWORD dstY, DWORD width, DWORD height, DWORD dstPitch, BYTE *srcBuf, DWORD srcX, DWORD srcY, DWORD srcPitch))0x00457210) -#define Matrix_PushUnit ((void __cdecl (*)(void))0x0045729E) #define flatA ((void __fastcall (*)(int32_t y0, int32_t y1, BYTE colorIdx))0x004572D4) #define transA ((void __fastcall (*)(int32_t y0, int32_t y1, BYTE depthQ))0x00457335) #define gourA ((void __fastcall (*)(int32_t y0, int32_t y1, BYTE colorIdx))0x0045746F) diff --git a/src/inject_exec.c b/src/inject_exec.c index eee6edc..d9c4f61 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -67,6 +67,7 @@ static void Inject_Matrix(void) INJECT(1, 0x0041BA80, Matrix_Interpolate); INJECT(1, 0x0041BC30, Matrix_InterpolateArm); INJECT(1, 0x00457280, Matrix_Push); + INJECT(1, 0x0045729E, Matrix_PushUnit); } static void Inject_Math(void)