Skip to content

Commit

Permalink
port patches from SP repo - use clean game.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh authored and dkeetonx committed Jul 22, 2016
1 parent df78a3e commit 253eb34
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 16 deletions.
Binary file modified Game.exe
Binary file not shown.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ NFLAGS = -f elf -Iinc/
CFLAGS = -std=c99 -Iinc/

OBJS = \
src/disable_max_windowed_mode.o \
src/disable_dpi_scaling.o \
src/loading.o \
src/loading-func.o \
src/remove_16bit_windowed_check.o \
Expand All @@ -29,7 +31,7 @@ OBJS = \
src/trigger_actions_extended.o \
src/briefing_screen_mission_start.o \
src/briefing_restate_map_file.o \
src/no-cd.o \
src/no-cd_iran.o \
src/display_messages_typed_by_yourself.o \
src/graphics_patch.o \
src/multiplayer_units_placing.o \
Expand Down
2 changes: 2 additions & 0 deletions inc/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// ### Functions ###

void SetSingleProcAffinity();
void DisableHighDpiScaling();
void DisableMaxWindowedMode();

// ### Variables ###

Expand Down
15 changes: 15 additions & 0 deletions src/disable_dpi_scaling.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <windows.h>
#include "TiberianSun.h"

typedef bool (__stdcall *SetProcessDPIAware_)();

void DisableHighDpiScaling()
{
HMODULE hModule = LoadLibraryA("User32.dll");
if (hModule)
{
SetProcessDPIAware_ setProcessDPIAware = (SetProcessDPIAware_)GetProcAddress(hModule, "SetProcessDPIAware");
if (setProcessDPIAware)
setProcessDPIAware();
}
}
15 changes: 15 additions & 0 deletions src/disable_max_windowed_mode.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <windows.h>
#include "TiberianSun.h"

typedef int (__stdcall *SetAppCompatData_)(int index, int data);

void DisableMaxWindowedMode()
{
HMODULE hModule = LoadLibraryA("ddraw.dll");
if (hModule)
{
SetAppCompatData_ setAppCompatData = (SetAppCompatData_)GetProcAddress(hModule, "SetAppCompatData");
if (setAppCompatData)
setAppCompatData(12, 0);
}
}
4 changes: 4 additions & 0 deletions src/loading-func.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ void LoadSunIni()
NoWindowFrame = SunIni_GetBool("Video", "NoWindowFrame", false);
UseGraphicsPatch = SunIni_GetBool("Video", "UseGraphicsPatch", true);
VideoWindowed = SunIni_GetBool("Video", "Video.Windowed", false);
if (SunIni_GetBool("Video", "DisableHighDpiScaling", false))
DisableHighDpiScaling();
if (SunIni_GetBool("Video", "DisableMaxWindowedMode", false))
DisableMaxWindowedMode();
}
23 changes: 8 additions & 15 deletions src/no-cd.asm → src/no-cd_iran.asm
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
%include "macros/patch.inc"
%include "macros/datatypes.inc"

@LJMP 0x004754A0, _CD_AlwaysFindTS
@LJMP 0x0044E7A0, _CD_AlwaysAvailable
@LJMP 0x0044E7C0, _CD_NeverAsk
@LJMP 0x004E0469, _Init_Game_NoCD_Check
gbool IsNoCD, true

cglobal IsNoCD

section .bss
IsNoCD: resb 1

section .text

_Init_Game_NoCD_Check:
hack 0x004E0469 ; _Init_Game_NoCD_Check
cmp byte [IsNoCD], 1
jz 0x004E06F5
cmp eax, ebp
jnz 0x004E06F5
jmp 0x004E0471

_CD_NeverAsk:
hack 0x0044E7C0 ; _CD_NeverAsk
cmp byte [IsNoCD], 0
jz .Normal_Code

Expand All @@ -32,7 +23,8 @@ _CD_NeverAsk:
sub esp, 184h
jmp 0x0044E7C6

_CD_AlwaysAvailable:
hack 0x0044E7A0 ; _CD_AlwaysAvailable
cmp byte [IsNoCD], 0
jz .Normal_Code

Expand All @@ -45,7 +37,8 @@ _CD_AlwaysAvailable:
cmp eax, 0FFFFFFFEh
jmp 0x0044E7A7

_CD_AlwaysFindTS:
hack 0x004754A0 ; _CD_AlwaysFindTS
cmp byte [IsNoCD], 0
jz .Normal_Code

Expand Down
59 changes: 59 additions & 0 deletions src/no-cd_nyer.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
%include "macros/patch.inc"
%include "macros/datatypes.inc"

gbool IsNoCD, true

hack 0x004754A0, 0x004754A6
cmp byte[IsNoCD], 1
jnz .out
xor eax, eax
cmp edi, 1
jnz .ret
inc eax
.ret:
retn

.out:
sub esp, 0x148
jmp hackend

hack 0x004756E4
cmp byte[IsNoCD], 1
jnz .out
cmp eax, dword[0x711A00]
jnz 0x0047578F
jmp 0x004756F2

.out:
cmp eax, -1
jle 0x004756FE
jmp hackend

hack 0x0047578F, 0x00475795
cmp byte[IsNoCD], 1
jnz .out
cmp eax, edi
jnz 0x004756F2
mov dword[0x711A00], eax
jmp 0x004757AC

.out:
mov ecx, dword[esp+0x10]
test ecx, ecx
jmp hackend

hack 0x004AB8FB
cmp byte[IsNoCD], 1
jnz .out
cmp eax, 3
jnz 0x004AB91E
jmp hackend

.out:
cmp eax, 5
jnz 0x004AB91E
jmp hackend
89 changes: 89 additions & 0 deletions src/no-cd_tfd.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
%include "macros/patch.inc"
%include "macros/datatypes.inc"

gbool IsNoCD, true

hack 0x004754A0, 0x004754A6
cmp byte[IsNoCD], 1
jnz .out
cmp edi, 1
je .is1
xor edi, edi
.is1:
mov eax, edi
retn
.out:
sub esp, 0x148
jmp hackend

hack 0x004756E4
cmp byte[IsNoCD], 1
jnz .out
cmp eax, dword[0x711A00]
jne 0x0047578F
jmp 0x004756F2

.out:
cmp eax, -1
jle 0x004756FE
jmp hackend

hack 0x0047578F, 0x00475795
cmp byte[IsNoCD], 1
jnz .out
mov dword[0x711A00], eax
cmp eax, edi
jne 0x004756F2
jmp 0x004757AC
.out:
mov ecx, dword[esp+0x10]
test ecx, ecx
jmp hackend

hack 0x004AB8FB
cmp byte[IsNoCD], 1
jnz .out
cmp eax, 3
jne 0x004AB91E
jmp hackend

.out:
cmp eax, 5
jne 0x004AB91E
jmp hackend

hack 0x005DB2D4, 0x005DB2DC
cmp byte[IsNoCD], 1
jnz .out
cmp al, 1
mov dword[0x7E3EC0], ecx
jne 0x005DB327
cmp ebx, -1
je 0x005DB327
mov eax, dword[0x7E2438]
cmp dword[eax+0x7F8], 1
jne 0x005DB327
mov eax, dword[eax+0x1DA4]
mov ecx, dword[0x7E2234]
mov edx, dword[eax*4+ecx]
mov ecx, 0x006FE164
push 1
push 1
push 1
add ebx, 0x30
mov byte[ecx+4], bl
or edx, 0xFFFFFFFF
sub ebx, 0x30
call 0x00563670
jmp 0x005DB327

.out:
cmp al, 1
mov dword[0x7E3EC0], ecx
jmp hackend

0 comments on commit 253eb34

Please sign in to comment.