[Functions] Safer debug drawing

This commit is contained in:
momo5502 2017-03-28 08:57:14 +02:00
parent b57aa4b262
commit 845d776507
2 changed files with 44 additions and 21 deletions

View File

@ -755,40 +755,63 @@ namespace Game
*specular2 = saveSpecular2; *specular2 = saveSpecular2;
} }
void R_AddDebugLine(float* color, float* v1, float* v2) __declspec(naked) void R_AddDebugLine(float* /*color*/, float* /*v1*/, float* /*v2*/)
{ {
void* debugglobals = reinterpret_cast<void*> (Utils::Hook::Get<int>(0x66DAD78) + 268772);
void* func = reinterpret_cast<void*> (0x51CEB0);
__asm __asm
{ {
mov eax, v2 pushad
mov eax, [esp + 2Ch] // v2
push eax push eax
mov eax, v1
mov eax, [esp + 2Ch] // v1
push eax push eax
mov esi, debugglobals
mov edi, color // debugglobals
call func mov edi, ds:66DAD78h
add esp, 8 add edi, 268772
mov edi, [esp + 2Ch] // color
mov eax, 51CEB0h
call eax
add esp, 8h
popad
retn
} }
} }
void R_AddDebugString(float *color, float *pos, float scale, char *string) __declspec(naked) void R_AddDebugString(float* /*color*/, float* /*pos*/, float /*scale*/, const char* /*string*/)
{ {
void* debugglobals = reinterpret_cast<void*> (Utils::Hook::Get<int>(0x66DAD78) + 268772);
void* func = reinterpret_cast<void*> (0x51D0A0);
__asm __asm
{ {
mov eax, string pushad
mov eax, [esp + 30h] // string
push eax push eax
mov eax, scale
mov eax, [esp + 30h] // scale
push eax push eax
mov eax, color
mov eax, [esp + 2Ch] // color
push eax push eax
mov eax, pos
mov eax, [esp + 34h] // pos
push eax push eax
mov edi, debugglobals
call func // debugglobals
add esp, 16 mov edi, ds:66DAD78h
add edi, 268772
mov eax, 51D0A0h
call eax
add esp, 10h
popad
retn
} }
} }
} }

View File

@ -773,5 +773,5 @@ namespace Game
void SortWorldSurfaces(GfxWorld* world); void SortWorldSurfaces(GfxWorld* world);
void R_AddDebugLine(float* color, float* v1, float* v2); void R_AddDebugLine(float* color, float* v1, float* v2);
void R_AddDebugString(float *color, float *pos, float scale, char *str); void R_AddDebugString(float *color, float *pos, float scale, const char *str);
} }