Skip to content

Commit 86eb473

Browse files
committed
DrawBufferExtension: increase draw buffer 16x
1 parent cc68c8e commit 86eb473

File tree

3 files changed

+84
-14
lines changed

3 files changed

+84
-14
lines changed

OutRun2006Tweaks.lods.ini

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
#
77
# Please post any bad objects you find to https://github.com/emoose/OutRun2006Tweaks/issues/97!
88

9+
# ALPINE
10+
[Stage 3]
11+
# See-through mountains in distance from bunki
12+
0x1 = 0x1, 0xD, 0x22
13+
914
# LAS VEGAS
10-
[Stage 18]
11-
# Wall texture under tunnel
12-
0x1 = 0x1F
15+
#[Stage 18]
16+
# Wall texture under tunnel (TODO: needs more testing, might need to set a dist limit on this map)
17+
# 0x1 = 0x1F
1318

1419
# GRAND CANYON
1520
[Stage 20]
@@ -26,4 +31,4 @@
2631
# PALM BEACH (T)
2732
[Stage 60]
2833
# Bad polygon when entering from bunki
29-
0x1 = 0x6
34+
0x1 = 0x6

src/hooks_drawdistance.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,70 @@ class DrawDistanceIncrease : public Hook
484484
};
485485
DrawDistanceIncrease DrawDistanceIncrease::instance;
486486

487+
// TODO: move this to game.h, should probably remove the resize function
488+
struct TDrawBuffer
489+
{
490+
int NumBuffers_0;
491+
int MaxBuffers_4;
492+
int unk_8[1];
493+
int MaxBuffers_C;
494+
struct TDrawEntry** BufferPtrs_10;
495+
struct TDrawEntry* Buffer_14;
496+
void* UnkBuffer_18;
497+
498+
void resize(int new_size)
499+
{
500+
int bufferPtrsSize_Imm = new_size * 4;
501+
int buffersSize_Imm = new_size * 0x3C;
502+
int unkbuffersSize_Imm = new_size * 0x40;
503+
504+
MaxBuffers_4 = new_size;
505+
MaxBuffers_C = new_size;
506+
507+
BufferPtrs_10 = (TDrawEntry**)malloc(bufferPtrsSize_Imm);
508+
Buffer_14 = (TDrawEntry*)malloc(buffersSize_Imm);
509+
UnkBuffer_18 = malloc(unkbuffersSize_Imm);
510+
}
511+
};
512+
513+
class DrawBufferExtension : public Hook
514+
{
515+
inline static SafetyHookInline drawbufferinit_hook = {};
516+
static void drawbufferinit_dest()
517+
{
518+
drawbufferinit_hook.call();
519+
520+
TDrawBuffer* s_ImmDrawBuffer = Module::exe_ptr<TDrawBuffer>(0x00464EF8);
521+
TDrawBuffer* s_AftDrawBuffer = Module::exe_ptr<TDrawBuffer>(0x004612D8);
522+
523+
constexpr int s_ImmDrawBufferSizeVanilla = 0x100;
524+
constexpr int s_AftDrawBufferSizeVanilla = 0x600;
525+
526+
s_ImmDrawBuffer->resize(s_ImmDrawBufferSizeVanilla * 0x10);
527+
s_AftDrawBuffer->resize(s_AftDrawBufferSizeVanilla * 2);
528+
}
529+
530+
public:
531+
std::string_view description() override
532+
{
533+
return "DrawBufferExtension";
534+
}
535+
536+
bool validate() override
537+
{
538+
return Settings::DrawDistanceIncrease > 0 || Settings::DrawDistanceBehind > 0;
539+
}
540+
541+
bool apply() override
542+
{
543+
drawbufferinit_hook = safetyhook::create_inline(Module::exe_ptr(0x5160), drawbufferinit_dest);
544+
return true;
545+
}
546+
547+
static DrawBufferExtension instance;
548+
};
549+
DrawBufferExtension DrawBufferExtension::instance;
550+
487551
class PauseMenuVisibility : public Hook
488552
{
489553
inline static SafetyHookInline sprani_hook = {};

src/hooks_overlay.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,22 @@ class WndprocHook : public Hook
211211
}
212212
else
213213
{
214-
if (Settings::WindowedHideMouseCursor)
214+
if (!Settings::OverlayEnabled && Settings::WindowedHideMouseCursor)
215215
{
216216
if (msg == WM_SETFOCUS || (msg == WM_ACTIVATE && lParam != WA_INACTIVE))
217217
{
218218
ShowCursor(false);
219219
}
220-
else if (msg == WM_ERASEBKGND) // erase window to white during device reset
221-
{
222-
RECT rect;
223-
GetClientRect(hwnd, &rect);
224-
HBRUSH brush = CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF));
225-
FillRect((HDC)wParam, &rect, brush);
226-
DeleteObject(brush);
227-
return 1;
228-
}
220+
}
221+
222+
if (msg == WM_ERASEBKGND) // erase window to white during device reset
223+
{
224+
RECT rect;
225+
GetClientRect(hwnd, &rect);
226+
HBRUSH brush = CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF));
227+
FillRect((HDC)wParam, &rect, brush);
228+
DeleteObject(brush);
229+
return 1;
229230
}
230231
}
231232
// Other message handling

0 commit comments

Comments
 (0)