Skip to content

Commit

Permalink
Merge pull request #4 from Pooquer/test
Browse files Browse the repository at this point in the history
tile culling edits from SGD2FreeRes
  • Loading branch information
Pooquer authored Jul 17, 2023
2 parents d49a270 + 13c759e commit 1ea8cba
Showing 6 changed files with 48 additions and 1 deletion.
2 changes: 2 additions & 0 deletions d2gl/src/d2/common.cpp
Original file line number Diff line number Diff line change
@@ -160,6 +160,8 @@ void initHooks()
game_loop.add(PatchType::Call, getOffset((DLL_D2CLIENT), (0x9B3D, 0xE87A5F0B), (0xA2A2, 0xE8B51B0C), (0x89A2F, 0xE84A37F8), (0x3356F, 0xE85E9CFD), (0x7D1BF, 0xE84801F9), (0x44E2F, 0xE81A85FC), (0x45E7F, 0xE8E473FC), (0x4F256, 0xE8E5550C)), 5, (uintptr_t)gameDrawBeginStub);
// game_loop.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x5333DB3B), (0x865AC, 0x33ED894C), (0x81B7C, 0x33DB894C), (0xA35F6), (0x669F6), (0x90156), (0xC39E6), (0x1D3E6), (0x56EE1, 0x8BEC83EC)), isVerMax(V_110) ? 6 : 5, (uintptr_t)uiDrawBeginStub);
game_loop.add(PatchType::Jump, getOffset((DLL_D2CLIENT), (), (), (), (), (), (0x44374), (), ()), 7, (uintptr_t)uiDrawBeginStub); // mxl // 0x4437B start
game_loop.add(PatchType::Jump, getOffset((DLL_D2CLIENT), (), (), (), (), (), (0x8A4D0), (), ()), 0xB5335 - 0xB5330, (uintptr_t)Sgd2fr_SetTileCullingBoundPatch);

game_loop.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x2BC803CA), (0xB59A5, 0x8B442404), (0xB7B71, 0x8B442404), (0x38FD2), (0x28A82), (0x9F692), (0x16B72), (0x14FF2), (0x68578, 0xD1E82BC8)), 5, (uintptr_t)uiDrawCursorItemStub); // Cursor item
game_loop.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x508D5424), (0xB58CC, 0x6AFF5203), (0xB7A9C, 0x6AFF5203), (0x38461), (0x27F11), (0x9EB21), (0x16001), (0x14481), (0x684A5, 0x518D45B8)), 5, (uintptr_t)uiDrawEndStub); // Cursor changed
game_loop.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x52894424), (0xB5606), (0xB7776), (0x38D46), (0x287F6), (0x9F406), (0x168E6), (0x14D66), (0x68435, 0x57568D55)), 5, (uintptr_t)uiDrawEndStub); // Default cursor
19 changes: 19 additions & 0 deletions d2gl/src/d2/funcs.cpp
Original file line number Diff line number Diff line change
@@ -207,6 +207,25 @@ void uiDrawCursorItem()
App.context->onStageChange();
}

void __cdecl Sgd2fr_D2Client_SetTileCullingBound(CullingSpec* culling_spec, int left, int top, int right, int bottom)
{
if (culling_spec == NULL) {
return;
}

SetRect(&culling_spec->draw_window_rect, left, top, right, bottom);

RECT* tile_culling_rect = &culling_spec->tile_culling_window;
SetRect(tile_culling_rect, -160, -160, 1024 + 160, 768 + 160);
//if (GetIsPerspectiveModeEnabled()) {
// tile_culling_rect->top -= 160;
// tile_culling_rect->left -= 320;
// tile_culling_rect->right += 320;
//}

culling_spec->flags |= 0x1;
}

void uiDrawEnd()
{
App.game.draw_stage = DrawStage::Cursor;
1 change: 1 addition & 0 deletions d2gl/src/d2/funcs.h
Original file line number Diff line number Diff line change
@@ -96,5 +96,6 @@ void levelEntryText();
//mxl
void __fastcall AutomapStartHooked();
void __fastcall AutomapEndHooked();
void __cdecl Sgd2fr_D2Client_SetTileCullingBound(CullingSpec* culling_spec, int left, int top, int right, int bottom);

}
6 changes: 5 additions & 1 deletion d2gl/src/d2/structs.h
Original file line number Diff line number Diff line change
@@ -367,7 +367,11 @@ struct UnitAny {
} v109;
};
};

struct CullingSpec {
uint32_t flags;
RECT draw_window_rect;
RECT tile_culling_window;
};
#pragma pack(push, 1)
struct Room1 {
Room1** pRoomsNear;
20 changes: 20 additions & 0 deletions d2gl/src/d2/stubs.cpp
Original file line number Diff line number Diff line change
@@ -86,6 +86,26 @@ __declspec(naked) void uiDrawBeginStub() // mxl
}
}

__declspec(naked) void Sgd2fr_SetTileCullingBoundPatch()
{
__asm
{
push ebp
mov ebp, esp

push eax
push ecx
push edx
push dword ptr [ebp + 8]
push esi
call Sgd2fr_D2Client_SetTileCullingBound
add esp, 20

leave
ret 4
}
}

__declspec(naked) void uiDrawCursorItemStub()
{
__asm
1 change: 1 addition & 0 deletions d2gl/src/d2/stubs.h
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ void automapDrawEndStub();
void uiDrawBeginStub();
void uiDrawCursorItemStub();
void uiDrawEndStub();
void Sgd2fr_SetTileCullingBoundPatch();

void drawUnitStubStack();
void drawUnitStubESI();

0 comments on commit 1ea8cba

Please sign in to comment.