summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-09-21 22:43:49 -0400
committerGravatar Zach Hilman2019-09-21 22:43:49 -0400
commit2bddc0346815bf5e893ad9611d89dbb0d511e32f (patch)
treea613f239938891b6d89c37df63caf5d842de8070 /src
parentdmnt_cheat_vm: Make Cheat VM compliant to code style (diff)
downloadyuzu-2bddc0346815bf5e893ad9611d89dbb0d511e32f.tar.gz
yuzu-2bddc0346815bf5e893ad9611d89dbb0d511e32f.tar.xz
yuzu-2bddc0346815bf5e893ad9611d89dbb0d511e32f.zip
dmnt_cheat_vm: Default initialize structure values
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/patch_manager.cpp3
-rw-r--r--src/core/memory/dmnt_cheat_types.h30
-rw-r--r--src/core/memory/dmnt_cheat_vm.h144
3 files changed, 88 insertions, 89 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index 90b537834..df0ecb15c 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -278,8 +278,7 @@ std::optional<std::vector<Memory::CheatEntry>> ReadCheatFileFromFolder(
278 278
279std::vector<Memory::CheatEntry> PatchManager::CreateCheatList( 279std::vector<Memory::CheatEntry> PatchManager::CreateCheatList(
280 const Core::System& system, const std::array<u8, 32>& build_id_) const { 280 const Core::System& system, const std::array<u8, 32>& build_id_) const {
281 const auto load_dir = 281 const auto load_dir = system.GetFileSystemController().GetModificationLoadRoot(title_id);
282 Core::System::GetInstance().GetFileSystemController().GetModificationLoadRoot(title_id);
283 if (load_dir == nullptr) { 282 if (load_dir == nullptr) {
284 LOG_ERROR(Loader, "Cannot load mods for invalid title_id={:016X}", title_id); 283 LOG_ERROR(Loader, "Cannot load mods for invalid title_id={:016X}", title_id);
285 return {}; 284 return {};
diff --git a/src/core/memory/dmnt_cheat_types.h b/src/core/memory/dmnt_cheat_types.h
index aa1264c32..bf68fa0fe 100644
--- a/src/core/memory/dmnt_cheat_types.h
+++ b/src/core/memory/dmnt_cheat_types.h
@@ -29,30 +29,30 @@
29namespace Memory { 29namespace Memory {
30 30
31struct MemoryRegionExtents { 31struct MemoryRegionExtents {
32 u64 base; 32 u64 base{};
33 u64 size; 33 u64 size{};
34}; 34};
35 35
36struct CheatProcessMetadata { 36struct CheatProcessMetadata {
37 u64 process_id; 37 u64 process_id{};
38 u64 title_id; 38 u64 title_id{};
39 MemoryRegionExtents main_nso_extents; 39 MemoryRegionExtents main_nso_extents{};
40 MemoryRegionExtents heap_extents; 40 MemoryRegionExtents heap_extents{};
41 MemoryRegionExtents alias_extents; 41 MemoryRegionExtents alias_extents{};
42 MemoryRegionExtents address_space_extents; 42 MemoryRegionExtents address_space_extents{};
43 std::array<u8, 0x20> main_nso_build_id; 43 std::array<u8, 0x20> main_nso_build_id{};
44}; 44};
45 45
46struct CheatDefinition { 46struct CheatDefinition {
47 std::array<char, 0x40> readable_name; 47 std::array<char, 0x40> readable_name{};
48 u32 num_opcodes; 48 u32 num_opcodes{};
49 std::array<u32, 0x100> opcodes; 49 std::array<u32, 0x100> opcodes{};
50}; 50};
51 51
52struct CheatEntry { 52struct CheatEntry {
53 bool enabled; 53 bool enabled{};
54 u32 cheat_id; 54 u32 cheat_id{};
55 CheatDefinition definition; 55 CheatDefinition definition{};
56}; 56};
57 57
58} // namespace Memory 58} // namespace Memory
diff --git a/src/core/memory/dmnt_cheat_vm.h b/src/core/memory/dmnt_cheat_vm.h
index d1580d7f6..c36212cf1 100644
--- a/src/core/memory/dmnt_cheat_vm.h
+++ b/src/core/memory/dmnt_cheat_vm.h
@@ -136,131 +136,131 @@ union VmInt {
136}; 136};
137 137
138struct StoreStaticOpcode { 138struct StoreStaticOpcode {
139 u32 bit_width; 139 u32 bit_width{};
140 MemoryAccessType mem_type; 140 MemoryAccessType mem_type{};
141 u32 offset_register; 141 u32 offset_register{};
142 u64 rel_address; 142 u64 rel_address{};
143 VmInt value; 143 VmInt value{};
144}; 144};
145 145
146struct BeginConditionalOpcode { 146struct BeginConditionalOpcode {
147 u32 bit_width; 147 u32 bit_width{};
148 MemoryAccessType mem_type; 148 MemoryAccessType mem_type{};
149 ConditionalComparisonType cond_type; 149 ConditionalComparisonType cond_type{};
150 u64 rel_address; 150 u64 rel_address{};
151 VmInt value; 151 VmInt value{};
152}; 152};
153 153
154struct EndConditionalOpcode {}; 154struct EndConditionalOpcode {};
155 155
156struct ControlLoopOpcode { 156struct ControlLoopOpcode {
157 bool start_loop; 157 bool start_loop{};
158 u32 reg_index; 158 u32 reg_index{};
159 u32 num_iters; 159 u32 num_iters{};
160}; 160};
161 161
162struct LoadRegisterStaticOpcode { 162struct LoadRegisterStaticOpcode {
163 u32 reg_index; 163 u32 reg_index{};
164 u64 value; 164 u64 value{};
165}; 165};
166 166
167struct LoadRegisterMemoryOpcode { 167struct LoadRegisterMemoryOpcode {
168 u32 bit_width; 168 u32 bit_width{};
169 MemoryAccessType mem_type; 169 MemoryAccessType mem_type{};
170 u32 reg_index; 170 u32 reg_index{};
171 bool load_from_reg; 171 bool load_from_reg{};
172 u64 rel_address; 172 u64 rel_address{};
173}; 173};
174 174
175struct StoreStaticToAddressOpcode { 175struct StoreStaticToAddressOpcode {
176 u32 bit_width; 176 u32 bit_width{};
177 u32 reg_index; 177 u32 reg_index{};
178 bool increment_reg; 178 bool increment_reg{};
179 bool add_offset_reg; 179 bool add_offset_reg{};
180 u32 offset_reg_index; 180 u32 offset_reg_index{};
181 u64 value; 181 u64 value{};
182}; 182};
183 183
184struct PerformArithmeticStaticOpcode { 184struct PerformArithmeticStaticOpcode {
185 u32 bit_width; 185 u32 bit_width{};
186 u32 reg_index; 186 u32 reg_index{};
187 RegisterArithmeticType math_type; 187 RegisterArithmeticType math_type{};
188 u32 value; 188 u32 value{};
189}; 189};
190 190
191struct BeginKeypressConditionalOpcode { 191struct BeginKeypressConditionalOpcode {
192 u32 key_mask; 192 u32 key_mask{};
193}; 193};
194 194
195struct PerformArithmeticRegisterOpcode { 195struct PerformArithmeticRegisterOpcode {
196 u32 bit_width; 196 u32 bit_width{};
197 RegisterArithmeticType math_type; 197 RegisterArithmeticType math_type{};
198 u32 dst_reg_index; 198 u32 dst_reg_index{};
199 u32 src_reg_1_index; 199 u32 src_reg_1_index{};
200 u32 src_reg_2_index; 200 u32 src_reg_2_index{};
201 bool has_immediate; 201 bool has_immediate{};
202 VmInt value; 202 VmInt value{};
203}; 203};
204 204
205struct StoreRegisterToAddressOpcode { 205struct StoreRegisterToAddressOpcode {
206 u32 bit_width; 206 u32 bit_width{};
207 u32 str_reg_index; 207 u32 str_reg_index{};
208 u32 addr_reg_index; 208 u32 addr_reg_index{};
209 bool increment_reg; 209 bool increment_reg{};
210 StoreRegisterOffsetType ofs_type; 210 StoreRegisterOffsetType ofs_type{};
211 MemoryAccessType mem_type; 211 MemoryAccessType mem_type{};
212 u32 ofs_reg_index; 212 u32 ofs_reg_index{};
213 u64 rel_address; 213 u64 rel_address{};
214}; 214};
215 215
216struct BeginRegisterConditionalOpcode { 216struct BeginRegisterConditionalOpcode {
217 u32 bit_width; 217 u32 bit_width{};
218 ConditionalComparisonType cond_type; 218 ConditionalComparisonType cond_type{};
219 u32 val_reg_index; 219 u32 val_reg_index{};
220 CompareRegisterValueType comp_type; 220 CompareRegisterValueType comp_type{};
221 MemoryAccessType mem_type; 221 MemoryAccessType mem_type{};
222 u32 addr_reg_index; 222 u32 addr_reg_index{};
223 u32 other_reg_index; 223 u32 other_reg_index{};
224 u32 ofs_reg_index; 224 u32 ofs_reg_index{};
225 u64 rel_address; 225 u64 rel_address{};
226 VmInt value; 226 VmInt value{};
227}; 227};
228 228
229struct SaveRestoreRegisterOpcode { 229struct SaveRestoreRegisterOpcode {
230 u32 dst_index; 230 u32 dst_index{};
231 u32 src_index; 231 u32 src_index{};
232 SaveRestoreRegisterOpType op_type; 232 SaveRestoreRegisterOpType op_type{};
233}; 233};
234 234
235struct SaveRestoreRegisterMaskOpcode { 235struct SaveRestoreRegisterMaskOpcode {
236 SaveRestoreRegisterOpType op_type; 236 SaveRestoreRegisterOpType op_type{};
237 std::array<bool, 0x10> should_operate; 237 std::array<bool, 0x10> should_operate{};
238}; 238};
239 239
240struct DebugLogOpcode { 240struct DebugLogOpcode {
241 u32 bit_width; 241 u32 bit_width{};
242 u32 log_id; 242 u32 log_id{};
243 DebugLogValueType val_type; 243 DebugLogValueType val_type{};
244 MemoryAccessType mem_type; 244 MemoryAccessType mem_type{};
245 u32 addr_reg_index; 245 u32 addr_reg_index{};
246 u32 val_reg_index; 246 u32 val_reg_index{};
247 u32 ofs_reg_index; 247 u32 ofs_reg_index{};
248 u64 rel_address; 248 u64 rel_address{};
249}; 249};
250 250
251struct UnrecognizedInstruction { 251struct UnrecognizedInstruction {
252 CheatVmOpcodeType opcode; 252 CheatVmOpcodeType opcode{};
253}; 253};
254 254
255struct CheatVmOpcode { 255struct CheatVmOpcode {
256 bool begin_conditional_block; 256 bool begin_conditional_block{};
257 std::variant<StoreStaticOpcode, BeginConditionalOpcode, EndConditionalOpcode, ControlLoopOpcode, 257 std::variant<StoreStaticOpcode, BeginConditionalOpcode, EndConditionalOpcode, ControlLoopOpcode,
258 LoadRegisterStaticOpcode, LoadRegisterMemoryOpcode, StoreStaticToAddressOpcode, 258 LoadRegisterStaticOpcode, LoadRegisterMemoryOpcode, StoreStaticToAddressOpcode,
259 PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode, 259 PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode,
260 PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode, 260 PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode,
261 BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode, 261 BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode,
262 SaveRestoreRegisterMaskOpcode, DebugLogOpcode, UnrecognizedInstruction> 262 SaveRestoreRegisterMaskOpcode, DebugLogOpcode, UnrecognizedInstruction>
263 opcode; 263 opcode{};
264}; 264};
265 265
266class DmntCheatVm { 266class DmntCheatVm {