This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgm82vpatch.gml
70 lines (55 loc) · 2.38 KB
/
gm82vpatch.gml
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
#define __gm82vpatch_init
globalvar __gm82vpatch_time;__gm82dx8_time=__gm82vpatch_time_now()
//don't initialize more than once!
//this fixes games that use game_restart()
if (__gm82vpatch_checkstart()) exit
//create a daemon to run the vpatch code
object_event_add(__vpatch_object,ev_destroy,0,"instance_copy(0)")
object_event_add(__vpatch_object,ev_other,ev_room_end,"persistent=true")
object_event_add(__vpatch_object,ev_other,ev_animation_end,"__gm82vpatch_dovsync() __gm82vpatch_removelag()")
//switch depending on gm version
if (gamemaker_version==800) {
__gm82vpatch_knowndevice($58d388)
} else {
var __version;__version=__gm82vpatch_test8_1_version()
if (__version==-1) {
show_error(
"This old version of GM 8.1 is not currently supported by VPatch; Please let renex#4506 on discord know about this."
+chr($0d)+chr($0a)+chr($0d)+chr($0a)+"In the meantime, you can patch a fresh copy of the game without VPatch enabled.",
1
)
game_end()
exit
}
if (__version==0) {
//modern 8.1
execute_string("__gm82vpatch_finddevice(get_function_address('d3d_set_culling'))")
}
}
object_set_persistent(__vpatch_object,1)
room_instance_add(room_first,0,0,__vpatch_object)
#define __gm82vpatch_dovsync
//only activate if vsyncable
if (display_get_frequency() mod room_speed == 0) {
set_synchronization(false)
//we do timed wakeups every 1ms to check the time
while (!__gm82vpatch_waitvblank()) {
__gm82vpatch_sleep(1)
if (__gm82vpatch_time_now()-__gm82vpatch_time>1000000/room_speed-2000) {
//Oh my fur and whiskers! I'm late, I'm late, I'm late!
break
}
}
//busywait for vblank
while (!__gm82vpatch_waitvblank()) {/*òwó*/}
__gm82vpatch_time=__gm82vpatch_time_now()
//sync DWM
__gm82vpatch_sleep(2)
//epic win
}
#define __gm82vpatch_removelag
//remove key release input lag from using direct checks
keyboard_check_direct(vk_up)
keyboard_check_direct(vk_down)
keyboard_check_direct(vk_left)
keyboard_check_direct(vk_right)