Skip to content

Commit

Permalink
Implement draw functions for TR8
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIndra55 committed Mar 9, 2024
1 parent 6593fb6 commit 97d84b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ void Hook::PostInitialize()
// Register the message hook
MessageHook::OnMessage(std::bind(&Hook::OnMessage, this, _1, _2, _3, _4));

#ifndef TR8
Font::OnFlush(std::bind(&Hook::OnFrame, this));
#endif

GameLoop::OnLoop(std::bind(&Hook::OnLoop, this));

// Post initialize all modules
Expand Down
2 changes: 2 additions & 0 deletions src/modules/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void MainMenu::SwitchPlayerCharacter(char* name) noexcept

void MainMenu::OnFrame()
{
#ifndef TR8
// Shows the watermark in th main menu
auto mainState = *(int*)GET_ADDRESS(0x10E5868, 0x838838, 0x000000);

Expand All @@ -182,6 +183,7 @@ void MainMenu::OnFrame()
font->SetCursor(5.f, 430.f);
font->Print("TRLAU-Menu-Hook");
}
#endif
}

void MainMenu::OnLoop()
Expand Down
13 changes: 10 additions & 3 deletions src/render/Draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void TRANS_TransToDrawVertexV4f(DRAWVERTEX* v, cdc::Vector3* vec)
{
auto addr = GET_ADDRESS(0x402EF0, 0x402F20, 0x000000);
auto addr = GET_ADDRESS(0x402EF0, 0x402F20, 0x49F990);

Hooking::Call(addr, v, vec);
}
Expand All @@ -17,14 +17,21 @@ void TRANS_RotTransPersVectorf(cdc::Vector3* srcvector, cdc::Vector3* dstvector)

void DRAW_DrawQuads(int flags, int tpage, DRAWVERTEX* verts, int numquads)
{
auto addr = GET_ADDRESS(0x406720, 0x406D70, 0x000000);
auto addr = GET_ADDRESS(0x406720, 0x406D70, 0x5BFB20);

Hooking::Call(addr, flags, tpage, verts, numquads);
}

void DRAW_DrawLines(LINEVERTEX* verts, int numlines)
{
auto addr = GET_ADDRESS(0x000000, 0x000000, 0x5BFCD0);

Hooking::Call(addr, verts, numlines);
}

void DRAW_DrawTriangles(int flags, int tpage, DRAWVERTEX* verts, int numtris)
{
auto addr = GET_ADDRESS(0x406A40, 0x407570, 0x000000);
auto addr = GET_ADDRESS(0x406A40, 0x407570, 0x5BFA40);

Hooking::Call(addr, flags, tpage, verts, numtris);
}
Expand Down
10 changes: 10 additions & 0 deletions src/render/Draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ struct DRAWVERTEX
unsigned int anPad[2];
};

struct LINEVERTEX
{
float x;
float y;
float z;

unsigned int color;
};

#undef RGB

#define RGBA(r, g, b, a) r | (g << 8) | (b << 16) | (a << 24)
Expand All @@ -26,6 +35,7 @@ void TRANS_RotTransPersVectorf(cdc::Vector3* srcvector, cdc::Vector3* dstvector)

void DRAW_DrawQuads(int flags, int tpage, DRAWVERTEX* verts, int numquads);
void DRAW_DrawTriangles(int flags, int tpage, DRAWVERTEX* verts, int numtris);
void DRAW_DrawLines(LINEVERTEX* verts, int numlines);

void DrawTriangle(cdc::Vector3* v0, cdc::Vector3* v1, cdc::Vector3* v2, int color);
void DrawPlane(cdc::Vector3* v0, cdc::Vector3* v1, int color);
Expand Down

0 comments on commit 97d84b6

Please sign in to comment.