forked from jewalky/a2mgr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_init.cpp
89 lines (80 loc) · 1.42 KB
/
video_init.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <windows.h>
#include <string>
#include <vector>
#include "utils.h"
#include "config.h"
using namespace std;
int rwid, rhei;
void _stdcall get_res(int *w, int *h)
{
// absolute default
*w = 640;
*h = 480;
if(!z_resolution)
{
// "smart" default, video mode guessed from desktop video mode
DEVMODE mode;
mode.dmSize = sizeof(mode);
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode);
if(mode.dmPelsWidth >= 1024 && mode.dmPelsHeight >= 768)
{
*w = 1024;
*h = 768;
}
else if(mode.dmPelsWidth >= 800 && mode.dmPelsHeight >= 600)
{
*w = 800;
*h = 600;
}
}
else
{
*w = r_width;
*h = r_height;
}
char* commandline_raw = GetCommandLineA();
vector<string> parms = ParseCommandLine(commandline_raw);
for(vector<string>::iterator i = parms.begin(); i != parms.end(); ++i)
{
if((*i) == "-640")
{
*w = 640;
*h = 480;
}
else if((*i) == "-800")
{
*w = 800;
*h = 600;
}
else if((*i) == "-1024")
{
*w = 1024;
*h = 768;
}
else if((*i).find("--res:") == 0)
{
const char* tmpr = (*i).c_str();
int w1, h1;
if(sscanf(tmpr, "--res:%dx%d", &w1, &h1) == 2)
{
*w = w1;
*h = h1;
}
}
}
rwid = *w;
rhei = *h;
}
void _declspec(naked) VIDEO_checkVideoMode(void)
{
__asm {
lea ecx, dword ptr [ebp-0x014] // H
push ecx
lea ecx, dword ptr [ebp-0x010] // W
push ecx
call get_res
test eax, eax
mov edx, 0x00487757
jmp edx
}
}