Skip to content

Commit e6447ae

Browse files
committed
DrawDist: update lods, move DrawBuffer to game.h
1 parent dbcc883 commit e6447ae

File tree

4 files changed

+59
-37
lines changed

4 files changed

+59
-37
lines changed

OutRun2006Tweaks.lods.ini

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@
1111
# See-through mountains in distance from bunki
1212
0x1 = 0x1, 0xD, 0x22
1313

14-
# LAS VEGAS
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
14+
# SNOW MOUNTAIN
15+
[Stage 4]
16+
# Piece of floating mountain geometry when entering the stage
17+
0x1 = 0x8
18+
# Random piece of floating geometry above the lift cables, didn't get a close look
19+
0x6 = 0x1E
20+
21+
# LAS VEGAS
22+
[Stage 18]
23+
# Building geo above winding section
24+
0x1 = 0x1F
25+
0x3 = 0x1, 0x3, 0x10, 0x11, 0x1F, 0x21, 0x4E, 0x50
1826

1927
# GRAND CANYON
2028
[Stage 20]
@@ -23,6 +31,10 @@
2331
0x1 = 0x2, 0x1A, 0x20, 0x22
2432
0x2 = 0x9
2533

34+
# MAYA
35+
[Stage 25]
36+
0x1 = 0x34
37+
2638
# NEW YORK
2739
[Stage 26]
2840
# Bushes when entering from bunki

src/game.hpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ typedef struct tagSPRARGS2
591591
} SPRARGS2;
592592
static_assert(sizeof(SPRARGS2) == 0xB8);
593593

594-
struct tagEvWorkRobot
594+
typedef struct tagEvWorkRobot
595595
{
596596
uint32_t workId_0;
597597
uint32_t dword4;
@@ -611,8 +611,26 @@ struct tagEvWorkRobot
611611
char byte85;
612612
uint8_t unk_86[2];
613613
uint8_t unk_88[8];
614-
};
615-
static_assert(sizeof(tagEvWorkRobot) == 0x90);
614+
} EvWorkRobot;
615+
static_assert(sizeof(EvWorkRobot) == 0x90);
616+
617+
typedef struct TDrawEntry
618+
{
619+
uint8_t todo[0x3C];
620+
} DrawEntry;
621+
static_assert(sizeof(DrawEntry) == 0x3C);
622+
623+
typedef struct TDrawBuffer
624+
{
625+
int NumBuffers_0;
626+
int MaxBuffers_4;
627+
int unk_8[1];
628+
int MaxBuffers_C;
629+
DrawEntry** BufferPtrs_10;
630+
DrawEntry* Buffer_14;
631+
void* UnkBuffer_18;
632+
} DrawBuffer;
633+
static_assert(sizeof(DrawBuffer) == 0x1C);
616634

617635
inline void WaitForDebugger()
618636
{

src/game_addrs.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "plugin.hpp"
44
#include <d3d9.h>
55
#include <dinput.h>
6+
#include "game.hpp"
67

78
typedef void(__stdcall* D3DXVec4Transform_fn)(D3DXVECTOR4*, D3DXVECTOR4*, D3DMATRIX*);
89

@@ -54,6 +55,9 @@ namespace Game
5455

5556
inline D3DXVECTOR2* screen_scale = nullptr;
5657

58+
inline DrawBuffer* s_ImmDrawBuffer = nullptr;
59+
inline DrawBuffer* s_AftDrawBuffer = nullptr;
60+
5761
// ini cfg
5862
inline D3DXVECTOR2* screen_resolution = nullptr;
5963
inline int* D3DFogEnabled = nullptr;
@@ -160,6 +164,9 @@ namespace Game
160164

161165
screen_scale = Module::exe_ptr<D3DXVECTOR2>(0x340C94);
162166

167+
s_ImmDrawBuffer = Module::exe_ptr<DrawBuffer>(0x00464EF8);
168+
s_AftDrawBuffer = Module::exe_ptr<DrawBuffer>(0x004612D8);
169+
163170
screen_resolution = Module::exe_ptr<D3DXVECTOR2>(0x340C8C);
164171

165172
D3DFogEnabled = Module::exe_ptr<int>(0x340C88);

src/hooks_drawdistance.cpp

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -484,47 +484,32 @@ 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-
513487
class DrawBufferExtension : public Hook
514488
{
515489
inline static SafetyHookInline drawbufferinit_hook = {};
516490
static void drawbufferinit_dest()
517491
{
518492
drawbufferinit_hook.call();
519493

520-
TDrawBuffer* s_ImmDrawBuffer = Module::exe_ptr<TDrawBuffer>(0x00464EF8);
521-
TDrawBuffer* s_AftDrawBuffer = Module::exe_ptr<TDrawBuffer>(0x004612D8);
494+
auto resize_buffer = [](DrawBuffer* buffer, int max_size)
495+
{
496+
int bufferPtrsSize_Imm = max_size * sizeof(DrawEntry*);
497+
int buffersSize_Imm = max_size * sizeof(DrawEntry);
498+
int unkbuffersSize_Imm = max_size * 0x40; // todo: what 0x40 byte struct is this?
499+
500+
buffer->MaxBuffers_4 = max_size;
501+
buffer->MaxBuffers_C = max_size;
502+
503+
buffer->BufferPtrs_10 = (DrawEntry**)malloc(bufferPtrsSize_Imm);
504+
buffer->Buffer_14 = (DrawEntry*)malloc(buffersSize_Imm);
505+
buffer->UnkBuffer_18 = malloc(unkbuffersSize_Imm);
506+
};
522507

523508
constexpr int s_ImmDrawBufferSizeVanilla = 0x100;
524509
constexpr int s_AftDrawBufferSizeVanilla = 0x600;
525510

526-
s_ImmDrawBuffer->resize(s_ImmDrawBufferSizeVanilla * 0x10);
527-
s_AftDrawBuffer->resize(s_AftDrawBufferSizeVanilla * 2);
511+
resize_buffer(Game::s_ImmDrawBuffer, s_ImmDrawBufferSizeVanilla * 0x10);
512+
resize_buffer(Game::s_AftDrawBuffer, s_AftDrawBufferSizeVanilla * 2);
528513
}
529514

530515
public:

0 commit comments

Comments
 (0)