-
Notifications
You must be signed in to change notification settings - Fork 1
/
cheat.c
167 lines (148 loc) · 3.75 KB
/
cheat.c
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#include "cheat.h"
int cheat_clear_flags(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
cheat_clearflag_constant(prCheat);
cheat_clearflag_fresh(prCheat);
cheat_clearflag_selected(prCheat);
return CHEAT_SUCCESS;
}
int cheat_clearflag_constant(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->flags &= ~CHEAT_FLAG_CONSTANT;
return CHEAT_SUCCESS;
}
int cheat_clearflag_fresh(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->flags &= ~CHEAT_FLAG_FRESH;
return CHEAT_SUCCESS;
}
int cheat_clearflag_selected(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->flags &= ~CHEAT_FLAG_SELECTED;
return CHEAT_SUCCESS;
}
unsigned int cheat_get_block(Cheat* prCheat) {
unsigned int block = 0;
if (prCheat != NULL) {
block = (unsigned int)prCheat->block;
}
return block;
}
unsigned int cheat_get_length(Cheat *prCheat) {
unsigned int clen = 0;
if (prCheat != NULL) {
clen = (unsigned int)prCheat->len;
}
return clen;
}
int cheat_init(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_NULLPTR;
}
prCheat->block = (unsigned short) 0;
prCheat->flags = (unsigned char) 0;
prCheat->len = (unsigned short) 0;
prCheat->name[0] = (char) 0;
return CHEAT_SUCCESS;
}
int cheat_is_constant(Cheat* prCheat) {
int is = 0;
if (prCheat != NULL) {
is = (prCheat->flags & CHEAT_FLAG_CONSTANT) ? 1 : 0;
}
return is;
}
int cheat_is_fresh(Cheat* prCheat) {
int is = 0;
if (prCheat != NULL) {
is = (prCheat->flags & CHEAT_FLAG_FRESH) ? 1 : 0;
}
return is;
}
int cheat_is_inactive(Cheat* prCheat) {
int is = 0;
if (prCheat != NULL) {
if (cheat_is_constant(prCheat) == 0 &&
cheat_is_selected(prCheat) == 0) {
is = 1;
}
}
return is;
}
int cheat_is_selected(Cheat* prCheat) {
int is = 0;
if (prCheat != NULL) {
is = (prCheat->flags & CHEAT_FLAG_SELECTED) ? 1 : 0;
}
return is;
}
int cheat_set_block(Cheat* prCheat, unsigned int block) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->block = (unsigned short)(block & 0xFFFF);
return CHEAT_SUCCESS;
}
int cheat_set_length(Cheat* prCheat, unsigned int length) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->len = (unsigned short)(length & 0xFFFF);
return CHEAT_SUCCESS;
}
int cheat_setflag_constant(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->flags |= CHEAT_FLAG_CONSTANT;
return CHEAT_SUCCESS;
}
int cheat_setflag_fresh(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->flags |= CHEAT_FLAG_FRESH;
return CHEAT_SUCCESS;
}
int cheat_setflag_selected(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
prCheat->flags |= CHEAT_FLAG_SELECTED;
return CHEAT_SUCCESS;
}
int cheat_set_constant(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
cheat_clearflag_selected(prCheat);
cheat_setflag_constant(prCheat);
cheat_clearflag_fresh(prCheat);
return CHEAT_SUCCESS;
}
int cheat_set_inactive(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
cheat_clearflag_constant(prCheat);
cheat_clearflag_selected(prCheat);
cheat_clearflag_fresh(prCheat);
return CHEAT_SUCCESS;
}
int cheat_set_selected(Cheat* prCheat) {
if (prCheat == NULL) {
return CHEAT_MEMORY;
}
cheat_clearflag_constant(prCheat);
cheat_setflag_selected(prCheat);
cheat_clearflag_fresh(prCheat);
return CHEAT_SUCCESS;
}