forked from sashavol/Frozlunky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_recv_patch.h
124 lines (88 loc) · 2.55 KB
/
input_recv_patch.h
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#pragma once
#include "patches.h"
#include "derandom.h"
#include "game_hooks.h"
#include "spelunky.h"
#include "input_frame.h"
#include "input_push_builder.h"
#include <vector>
#include <sstream>
bool state_accepts_input(int state);
/*
Patch to store all real inputs to an infinite-index cyclic buffer spelunky-side.
Abstracts syscalls to game to pull all collected inputs asynchronously.
*/
class InputReceivePatch : public Patch {
private:
std::shared_ptr<GameHooks> gh;
std::shared_ptr<DerandomizePatch> dp;
std::shared_ptr<Spelunky> spel;
std::shared_ptr<InputPushBuilder> ipb[2];
bool is_valid;
//++ input buffer patch
Address exec_space;
Address overwrite_addr;
unsigned local_buffer_pos;
Address input_buffer_position_ptr;
Address input_buffer_ptr;
BYTE* orig_jmpbuild_override;
//==
//++ dwi patch
Address dwi;
Address dwi_insert;
Address dwi_exec_space;
BYTE* orig_main_override;
//==
//++ input cycle block patch
Address allow_input_cycle_ptr;
Address input_cycle_fn;
Address input_cycle_exec_space;
BYTE* orig_input_cycle;
//==
//++ zero inputs patch-out
Address zero_inputs_addr;
BYTE* zero_inputs_orig;
//==
//++ input buffer position reset routine
Address prev_ibufpos_addr;
Address ibufpos_store_routine;
Address ibufpos_reset_routine;
Address main_loop_end;
//==
//++ player attribute tracking
unsigned pid_attr_track;
//==
//++ push buffer position caching
Address bufpos_cache_vars;
Address bufpos_routine;
//==
//++ frame multiplier removal
Address frame_mult_func; //fn
Address frame_mult_addr; //14684D0
Address frame_mult_fl_arb1; //14684C8
Address frame_mult_in_arb2; //14684BC
Address frame_mult_in_arb3; //14684B8
BYTE* orig_frame_mult;
//==
//++ no mouse
Address mouse_addr;
BYTE* orig_mouse;
//==
public:
InputReceivePatch(std::shared_ptr<DerandomizePatch> dp, std::shared_ptr<GameHooks> gh);
~InputReceivePatch();
private:
bool perform_irp_patch();
bool perform_persistent_dwi_patch();
bool perform_input_cycle_patch();
virtual bool _perform() override;
virtual bool _undo() override;
public:
virtual bool valid() override;
//specify which pid's attributes to track (bombs, ropes, health, x pos, y pos)
void set_pid_attributes_track(unsigned track);
//slot = 0 or 1
void set_input_push(int slot, std::shared_ptr<InputPushBuilder> ipb);
//pulls inputs from internal buffer into target vector
void pull_inputs(std::vector<InputFrame>& out);
};