| 1 | /* Mednafen - Multi-system Emulator |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 16 | */ |
| 17 | |
| 18 | #include <stdio.h> |
| 19 | #include <stdlib.h> |
| 20 | #include <string.h> |
| 21 | #include <ctype.h> |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "mempatcher.h"cxx . . $ `<file>/mednafen/mempatcher.h`/ |
| 25 | #include "settings.h"cxx . . $ `<file>/mednafen/settings.h`/ |
| 26 | |
| 27 | #ifdef _WIN32 |
| 28 | #include "msvc_compat.h" |
| 29 | #endif |
| 30 | |
| 31 | static uint8cxx . . $ uint8# **RAMPtrscxx . . $ RAMPtrs. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 32 | static uint32cxx . . $ uint32# PageSizecxx . . $ PageSize.; |
| 33 | static uint32cxx . . $ uint32# NumPagescxx . . $ NumPages.; |
| 34 | |
| 35 | typedef struct __CHEATFcxx . . $ __CHEATF# |
| 36 | { |
| 37 | char *namecxx . . $ __CHEATF#name.; |
| 38 | char *conditionscxx . . $ __CHEATF#conditions.; |
| 39 | |
| 40 | uint32cxx . . $ uint32# addrcxx . . $ __CHEATF#addr.; |
| 41 | uint64cxx . . $ uint64# valcxx . . $ __CHEATF#val.; |
| 42 | uint64cxx . . $ uint64# comparecxx . . $ __CHEATF#compare.; |
| 43 | |
| 44 | unsigned int lengthcxx . . $ __CHEATF#length.; |
| 45 | bool bigendiancxx . . $ __CHEATF#bigendian.; |
| 46 | unsigned int icountcxx . . $ __CHEATF#icount.; /* Instance count */ |
| 47 | char typecxx . . $ __CHEATF#type.; /* 'R' for replace, 'S' for substitute(GG), 'C' for substitute with compare */ |
| 48 | int statuscxx . . $ __CHEATF#status.; |
| 49 | } CHEATFcxx . . $ CHEATF#; |
| 50 | |
| 51 | static stdcxx . . $ std/::vectorcxx . . $ std/vector#<CHEATFcxx . . $ CHEATF#> cheatscxx . . $ cheats.; |
| 52 | static bool CheatsActivecxx . . $ CheatsActive. = true; |
| 53 | |
| 54 | static stdcxx . . $ std/::vectorcxx . . $ std/vector#<SUBCHEATcxx . . $ SUBCHEAT#> SubCheatscxx . . $ SubCheats.[8]; |
| 55 | |
| 56 | static void RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(void) |
| 57 | { |
| 58 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<CHEATF>::iteratorcxx . . $ std/vector#iterator# chitcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 59 | |
| 60 | for(int x = 0; x < 8; x++) |
| 61 | SubCheatscxx . . $ SubCheats.[x].clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); |
| 62 | |
| 63 | if(!CheatsActivecxx . . $ CheatsActive.) return; |
| 64 | |
| 65 | for(chit =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(328b848e4bb5434c). cheatscxx . . $ cheats..begincxx . . $ std/vector#begin(55a6de06420d4903).(); chit !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). cheatscxx . . $ cheats..endcxx . . $ std/vector#end(55a6de06420d4903).(); chit++cxx . . $ __gnu_cxx/__normal_iterator#operator++(6cefca3db4774be2).) |
| 66 | { |
| 67 | if(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).statuscxx . . $ __CHEATF#status. && chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).typecxx . . $ __CHEATF#type. != 'R') |
| 68 | { |
| 69 | for(unsigned int x = 0; x < chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).lengthcxx . . $ __CHEATF#length.; x++) |
| 70 | { |
| 71 | SUBCHEATcxx . . $ SUBCHEAT# tmpsub; |
| 72 | unsigned int shiftie; |
| 73 | |
| 74 | if(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).bigendiancxx . . $ __CHEATF#bigendian.) |
| 75 | shiftie = (chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).lengthcxx . . $ __CHEATF#length. - 1 - x) * 8; |
| 76 | else |
| 77 | shiftie = x * 8; |
| 78 | |
| 79 | tmpsub.addrcxx . . $ __SUBCHEAT#addr. = chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).addrcxx . . $ __CHEATF#addr. + x; |
| 80 | tmpsub.valuecxx . . $ __SUBCHEAT#value. = (chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).valcxx . . $ __CHEATF#val. >> shiftie) & 0xFF; |
| 81 | if(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).typecxx . . $ __CHEATF#type. == 'C') |
| 82 | tmpsub.comparecxx . . $ __SUBCHEAT#compare. = (chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).comparecxx . . $ __CHEATF#compare. >> shiftie) & 0xFF; |
| 83 | else |
| 84 | tmpsub.comparecxx . . $ __SUBCHEAT#compare. = -1; |
| 85 | SubCheatscxx . . $ SubCheats.[(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).addrcxx . . $ __CHEATF#addr. + x) & 0x7].push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(tmpsub); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | extern "C" bool MDFNMP_Init(uint32cxx . . $ uint32# ps, uint32cxx . . $ uint32# numpages) |
| 92 | { |
| 93 | PageSizecxx . . $ PageSize. = ps; |
| 94 | NumPagescxx . . $ NumPages. = numpages; |
| 95 | |
| 96 | RAMPtrscxx . . $ RAMPtrs. = (uint8cxx . . $ uint8# **)calloccxx . . $ calloc(95acc9b79bb49189).(numpages, sizeof(uint8cxx . . $ uint8# *)); |
| 97 | |
| 98 | CheatsActivecxx . . $ CheatsActive. = MDFN_GetSettingB("cheats"); |
| 99 | return(1); |
| 100 | } |
| 101 | |
| 102 | extern "C" void MDFNMP_Kill(void) |
| 103 | { |
| 104 | if(RAMPtrscxx . . $ RAMPtrs.) |
| 105 | { |
| 106 | freecxx . . $ free(bd21765a0afc8e3c).(RAMPtrscxx . . $ RAMPtrs.); |
| 107 | RAMPtrscxx . . $ RAMPtrs. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | extern "C" void MDFNMP_AddRAM(uint32cxx . . $ uint32# size, uint32cxx . . $ uint32# A, uint8cxx . . $ uint8# *RAM) |
| 112 | { |
| 113 | uint32cxx . . $ uint32# AB = A / PageSizecxx . . $ PageSize.; |
| 114 | |
| 115 | size /= PageSizecxx . . $ PageSize.; |
| 116 | |
| 117 | for(unsigned int x = 0; x < size; x++) |
| 118 | { |
| 119 | RAMPtrscxx . . $ RAMPtrs.[AB + x] = RAM; |
| 120 | if(RAM) /* Don't increment the RAM pointer if we're passed a NULL pointer */ |
| 121 | RAM += PageSizecxx . . $ PageSize.; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | extern "C" void MDFNMP_InstallReadPatches(void) { } |
| 126 | void MDFNMP_RemoveReadPatchescxx . . $ MDFNMP_RemoveReadPatches(49f6e7a06ebc5aa8).(void) { } |
| 127 | |
| 128 | /* This function doesn't allocate any memory for "name" */ |
| 129 | static int AddCheatEntrycxx . . $ AddCheatEntry(4d74b56d7f62d11b).(char *name, char *conditions, uint32cxx . . $ uint32# addr, uint64cxx . . $ uint64# val, uint64cxx . . $ uint64# compare, int status, char type, unsigned int length, bool bigendian) |
| 130 | { |
| 131 | CHEATFcxx . . $ CHEATF# temp; |
| 132 | |
| 133 | memset(&temp, 0, sizeof(CHEATFcxx . . $ CHEATF#)); |
| 134 | |
| 135 | temp.namecxx . . $ __CHEATF#name.=name; |
| 136 | temp.conditionscxx . . $ __CHEATF#conditions. = conditions; |
| 137 | temp.addrcxx . . $ __CHEATF#addr.=addr; |
| 138 | temp.valcxx . . $ __CHEATF#val.=val; |
| 139 | temp.statuscxx . . $ __CHEATF#status.=status; |
| 140 | temp.comparecxx . . $ __CHEATF#compare.=compare; |
| 141 | temp.lengthcxx . . $ __CHEATF#length. = length; |
| 142 | temp.bigendiancxx . . $ __CHEATF#bigendian. = bigendian; |
| 143 | temp.typecxx . . $ __CHEATF#type.=type; |
| 144 | |
| 145 | cheatscxx . . $ cheats..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(temp); |
| 146 | return(1); |
| 147 | } |
| 148 | |
| 149 | extern "C" void MDFN_LoadGameCheats(void *override_ptr) |
| 150 | { |
| 151 | RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(); |
| 152 | } |
| 153 | |
| 154 | extern "C" void MDFN_FlushGameCheats(int nosave) |
| 155 | { |
| 156 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<CHEATF>::iteratorcxx . . $ std/vector#iterator# chitcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 157 | |
| 158 | for(chit =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(328b848e4bb5434c). cheatscxx . . $ cheats..begincxx . . $ std/vector#begin(55a6de06420d4903).(); chit !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). cheatscxx . . $ cheats..endcxx . . $ std/vector#end(55a6de06420d4903).(); chit++cxx . . $ __gnu_cxx/__normal_iterator#operator++(6cefca3db4774be2).) |
| 159 | { |
| 160 | freecxx . . $ free(bd21765a0afc8e3c).(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).namecxx . . $ __CHEATF#name.); |
| 161 | if(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).conditionscxx . . $ __CHEATF#conditions.) |
| 162 | freecxx . . $ free(bd21765a0afc8e3c).(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).conditionscxx . . $ __CHEATF#conditions.); |
| 163 | } |
| 164 | cheatscxx . . $ cheats..clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); |
| 165 | |
| 166 | RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(); |
| 167 | } |
| 168 | |
| 169 | int MDFNI_AddCheatcxx . . $ MDFNI_AddCheat(41c94168d8be1ca1).(const char *name, uint32cxx . . $ uint32# addr, uint64cxx . . $ uint64# val, uint64cxx . . $ uint64# compare, char type, unsigned int length, bool bigendian) |
| 170 | { |
| 171 | char *t; |
| 172 | |
| 173 | if(!(t = strdup(name))) |
| 174 | return(0); |
| 175 | |
| 176 | if(!AddCheatEntrycxx . . $ AddCheatEntry(4d74b56d7f62d11b).(t, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, addr,val,compare,1,type, length, bigendian)) |
| 177 | { |
| 178 | freecxx . . $ free(bd21765a0afc8e3c).(t); |
| 179 | return(0); |
| 180 | } |
| 181 | |
| 182 | MDFNMP_RemoveReadPatchescxx . . $ MDFNMP_RemoveReadPatches(49f6e7a06ebc5aa8).(); |
| 183 | RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(); |
| 184 | MDFNMP_InstallReadPatches(); |
| 185 | |
| 186 | return(1); |
| 187 | } |
| 188 | |
| 189 | int MDFNI_DelCheatcxx . . $ MDFNI_DelCheat(4c679297bf94b9eb).(uint32cxx . . $ uint32# which) |
| 190 | { |
| 191 | freecxx . . $ free(bd21765a0afc8e3c).(cheatscxx . . $ cheats.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).which].namecxx . . $ __CHEATF#name.); |
| 192 | cheatscxx . . $ cheats..erasecxx . . $ std/vector#erase(351407f384f345bc).(cheatscxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640)..begincxx . . $ std/vector#begin(55a6de06420d4903).() +cxx . . $ __gnu_cxx/__normal_iterator#operator+(192bf940fa7bb3b2). which); |
| 193 | |
| 194 | MDFNMP_RemoveReadPatchescxx . . $ MDFNMP_RemoveReadPatches(49f6e7a06ebc5aa8).(); |
| 195 | RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(); |
| 196 | MDFNMP_InstallReadPatches(); |
| 197 | |
| 198 | return(1); |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | Condition format(ws = white space): |
| 203 | |
| 204 | <variable size><ws><endian><ws><address><ws><operation><ws><value> |
| 205 | [,second condition...etc.] |
| 206 | |
| 207 | Value should be unsigned integer, hex(with a 0x prefix) or |
| 208 | base-10. |
| 209 | |
| 210 | Operations: |
| 211 | >= |
| 212 | <= |
| 213 | > |
| 214 | < |
| 215 | == |
| 216 | != |
| 217 | & Result of AND between two values is nonzero |
| 218 | !& Result of AND between two values is zero |
| 219 | ^ same, XOR |
| 220 | !^ |
| 221 | | same, OR |
| 222 | !| |
| 223 | |
| 224 | Full example: |
| 225 | |
| 226 | 2 L 0xADDE == 0xDEAD, 1 L 0xC000 == 0xA0 |
| 227 | |
| 228 | */ |
| 229 | |
| 230 | static bool TestConditionscxx . . $ TestConditions(c5f7da30cbc0f4e9).(const char *string) |
| 231 | { |
| 232 | char address[64]; |
| 233 | char operation[64]; |
| 234 | char value[64]; |
| 235 | char endian; |
| 236 | unsigned int bytelen; |
| 237 | bool passed = 1; |
| 238 | |
| 239 | while(sscanf(string, "%u %c %63s %63s %63s", &bytelen, &endian, address, operation, value) == 5 && passed) |
| 240 | { |
| 241 | uint64cxx . . $ uint64# v_value; |
| 242 | uint64cxx . . $ uint64# value_at_address; |
| 243 | |
| 244 | if(value[0] == '0' && value[1] == 'x') |
| 245 | v_value = strtoull(value + 2, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 16); |
| 246 | else |
| 247 | v_value = strtoull(value, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0); |
| 248 | |
| 249 | value_at_address = 0; |
| 250 | |
| 251 | if(!strcmp(operation, ">=")) |
| 252 | { |
| 253 | if(!(value_at_address >= v_value)) |
| 254 | passed = 0; |
| 255 | } |
| 256 | else if(!strcmp(operation, "<=")) |
| 257 | { |
| 258 | if(!(value_at_address <= v_value)) |
| 259 | passed = 0; |
| 260 | } |
| 261 | else if(!strcmp(operation, ">")) |
| 262 | { |
| 263 | if(!(value_at_address > v_value)) |
| 264 | passed = 0; |
| 265 | } |
| 266 | else if(!strcmp(operation, "<")) |
| 267 | { |
| 268 | if(!(value_at_address < v_value)) |
| 269 | passed = 0; |
| 270 | } |
| 271 | else if(!strcmp(operation, "==")) |
| 272 | { |
| 273 | if(!(value_at_address == v_value)) |
| 274 | passed = 0; |
| 275 | } |
| 276 | else if(!strcmp(operation, "!=")) |
| 277 | { |
| 278 | if(!(value_at_address != v_value)) |
| 279 | passed = 0; |
| 280 | } |
| 281 | else if(!strcmp(operation, "&")) |
| 282 | { |
| 283 | if(!(value_at_address & v_value)) |
| 284 | passed = 0; |
| 285 | } |
| 286 | else if(!strcmp(operation, "!&")) |
| 287 | { |
| 288 | if(value_at_address & v_value) |
| 289 | passed = 0; |
| 290 | } |
| 291 | else if(!strcmp(operation, "^")) |
| 292 | { |
| 293 | if(!(value_at_address ^ v_value)) |
| 294 | passed = 0; |
| 295 | } |
| 296 | else if(!strcmp(operation, "!^")) |
| 297 | { |
| 298 | if(value_at_address ^ v_value) |
| 299 | passed = 0; |
| 300 | } |
| 301 | else if(!strcmp(operation, "|")) |
| 302 | { |
| 303 | if(!(value_at_address | v_value)) |
| 304 | passed = 0; |
| 305 | } |
| 306 | else if(!strcmp(operation, "!|")) |
| 307 | { |
| 308 | if(value_at_address | v_value) |
| 309 | passed = 0; |
| 310 | } |
| 311 | string = strchr(string, ','); |
| 312 | if(!string) |
| 313 | break; |
| 314 | string++; |
| 315 | } |
| 316 | |
| 317 | return(passed); |
| 318 | } |
| 319 | |
| 320 | extern "C" void MDFNMP_ApplyPeriodicCheats(void) |
| 321 | { |
| 322 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<CHEATF>::iteratorcxx . . $ std/vector#iterator# chitcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 323 | |
| 324 | if(!CheatsActivecxx . . $ CheatsActive.) |
| 325 | return; |
| 326 | |
| 327 | for(chit =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(328b848e4bb5434c). cheatscxx . . $ cheats..begincxx . . $ std/vector#begin(55a6de06420d4903).(); chit !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). cheatscxx . . $ cheats..endcxx . . $ std/vector#end(55a6de06420d4903).(); chit++cxx . . $ __gnu_cxx/__normal_iterator#operator++(6cefca3db4774be2).) |
| 328 | { |
| 329 | if(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).statuscxx . . $ __CHEATF#status. && chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).typecxx . . $ __CHEATF#type. == 'R') |
| 330 | { |
| 331 | if(!chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).conditionscxx . . $ __CHEATF#conditions. || TestConditionscxx . . $ TestConditions(c5f7da30cbc0f4e9).(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).conditionscxx . . $ __CHEATF#conditions.)) |
| 332 | for(unsigned int x = 0; x < chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).lengthcxx . . $ __CHEATF#length.; x++) |
| 333 | { |
| 334 | uint32cxx . . $ uint32# page = ((chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).addrcxx . . $ __CHEATF#addr. + x) / PageSizecxx . . $ PageSize.) % NumPagescxx . . $ NumPages.; |
| 335 | if(RAMPtrscxx . . $ RAMPtrs.[page]) |
| 336 | { |
| 337 | uint64cxx . . $ uint64# tmpval = chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).valcxx . . $ __CHEATF#val.; |
| 338 | |
| 339 | if(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).bigendiancxx . . $ __CHEATF#bigendian.) |
| 340 | tmpval >>= (chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).lengthcxx . . $ __CHEATF#length. - 1 - x) * 8; |
| 341 | else |
| 342 | tmpval >>= x * 8; |
| 343 | |
| 344 | RAMPtrscxx . . $ RAMPtrs.[page][(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).addrcxx . . $ __CHEATF#addr. + x) % PageSizecxx . . $ PageSize.] = tmpval; |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | void MDFNI_ListCheatscxx . . $ MDFNI_ListCheats(bee3a6b2bc6780fb).(int (*callb)(char *name, uint32cxx . . $ uint32# a, uint64cxx . . $ uint64# v, uint64cxx . . $ uint64# compare, int s, char type, unsigned int length, bool bigendian, void *data), void *data) |
| 352 | { |
| 353 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<CHEATF>::iteratorcxx . . $ std/vector#iterator# chitcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 354 | |
| 355 | for(chit =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(328b848e4bb5434c). cheatscxx . . $ cheats..begincxx . . $ std/vector#begin(55a6de06420d4903).(); chit !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). cheatscxx . . $ cheats..endcxx . . $ std/vector#end(55a6de06420d4903).(); chit++cxx . . $ __gnu_cxx/__normal_iterator#operator++(6cefca3db4774be2).) |
| 356 | { |
| 357 | if(!callb(chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).namecxx . . $ __CHEATF#name., chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).addrcxx . . $ __CHEATF#addr., chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).valcxx . . $ __CHEATF#val., chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).comparecxx . . $ __CHEATF#compare., chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).statuscxx . . $ __CHEATF#status., chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).typecxx . . $ __CHEATF#type., chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).lengthcxx . . $ __CHEATF#length., chit->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).bigendiancxx . . $ __CHEATF#bigendian., data)) break; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | int MDFNI_GetCheatcxx . . $ MDFNI_GetCheat(6d1ec47ccc947b34).(uint32cxx . . $ uint32# which, char **name, uint32cxx . . $ uint32# *a, uint64cxx . . $ uint64# *v, uint64cxx . . $ uint64# *compare, int *s, char *type, unsigned int *length, bool *bigendian) |
| 362 | { |
| 363 | CHEATFcxx . . $ CHEATF# *next = &cheatscxx . . $ cheats.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).which]; |
| 364 | |
| 365 | if(name) |
| 366 | *name=next->namecxx . . $ __CHEATF#name.; |
| 367 | if(a) |
| 368 | *a=next->addrcxx . . $ __CHEATF#addr.; |
| 369 | if(v) |
| 370 | *v=next->valcxx . . $ __CHEATF#val.; |
| 371 | if(s) |
| 372 | *s=next->statuscxx . . $ __CHEATF#status.; |
| 373 | if(compare) |
| 374 | *compare=next->comparecxx . . $ __CHEATF#compare.; |
| 375 | if(type) |
| 376 | *type=next->typecxx . . $ __CHEATF#type.; |
| 377 | if(length) |
| 378 | *length = next->lengthcxx . . $ __CHEATF#length.; |
| 379 | if(bigendian) |
| 380 | *bigendian = next->bigendiancxx . . $ __CHEATF#bigendian.; |
| 381 | return(1); |
| 382 | } |
| 383 | |
| 384 | int MDFNI_DecodePARcxx . . $ MDFNI_DecodePAR(3a4289f9daa6abb1).(const char *str, uint32cxx . . $ uint32# *a, uint8cxx . . $ uint8# *v, uint8cxx . . $ uint8# *c, char *type) |
| 385 | { |
| 386 | int boo[4]; |
| 387 | if(strlen(str)!=8) return(0); |
| 388 | |
| 389 | sscanf(str,"%02x%02x%02x%02x",boo,boo+1,boo+2,boo+3); |
| 390 | |
| 391 | *c = 0; |
| 392 | |
| 393 | if(1) |
| 394 | { |
| 395 | *a=(boo[3]<<8)|(boo[2]+0x7F); |
| 396 | *v=0; |
| 397 | } |
| 398 | else |
| 399 | { |
| 400 | *v=boo[3]; |
| 401 | *a=boo[2]|(boo[1]<<8); |
| 402 | } |
| 403 | |
| 404 | *type = 'S'; |
| 405 | return(1); |
| 406 | } |
| 407 | |
| 408 | /* name can be NULL if the name isn't going to be changed. */ |
| 409 | int MDFNI_SetCheatcxx . . $ MDFNI_SetCheat(34d2a457eb803bb6).(uint32cxx . . $ uint32# which, const char *name, uint32cxx . . $ uint32# a, uint64cxx . . $ uint64# v, uint64cxx . . $ uint64# compare, int s, char type, unsigned int length, bool bigendian) |
| 410 | { |
| 411 | CHEATFcxx . . $ CHEATF# *next = &cheatscxx . . $ cheats.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).which]; |
| 412 | |
| 413 | if(name) |
| 414 | { |
| 415 | char *t; |
| 416 | |
| 417 | if(!(t=(char *)realloccxx . . $ realloc(42b2a9dd8f084bf2).(next->namecxx . . $ __CHEATF#name.,strlen(name)+1))) |
| 418 | return(0); |
| 419 | next->namecxx . . $ __CHEATF#name.=t; |
| 420 | strcpy(next->namecxx . . $ __CHEATF#name.,name); |
| 421 | } |
| 422 | next->addrcxx . . $ __CHEATF#addr.=a; |
| 423 | next->valcxx . . $ __CHEATF#val.=v; |
| 424 | next->statuscxx . . $ __CHEATF#status.=s; |
| 425 | next->comparecxx . . $ __CHEATF#compare.=compare; |
| 426 | next->typecxx . . $ __CHEATF#type.=type; |
| 427 | next->lengthcxx . . $ __CHEATF#length. = length; |
| 428 | next->bigendiancxx . . $ __CHEATF#bigendian. = bigendian; |
| 429 | |
| 430 | RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(); |
| 431 | |
| 432 | return(1); |
| 433 | } |
| 434 | |
| 435 | /* Convenience function. */ |
| 436 | int MDFNI_ToggleCheatcxx . . $ MDFNI_ToggleCheat(4c679297bf94b9eb).(uint32cxx . . $ uint32# which) |
| 437 | { |
| 438 | cheatscxx . . $ cheats.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).which].statuscxx . . $ __CHEATF#status. = !cheatscxx . . $ cheats.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).which].statuscxx . . $ __CHEATF#status.; |
| 439 | RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(); |
| 440 | |
| 441 | return(cheatscxx . . $ cheats.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).which].statuscxx . . $ __CHEATF#status.); |
| 442 | } |
| 443 | |
| 444 | static void SettingChangedcxx . . $ SettingChanged(85c52e162fed56f9).(const char *name) |
| 445 | { |
| 446 | MDFNMP_RemoveReadPatchescxx . . $ MDFNMP_RemoveReadPatches(49f6e7a06ebc5aa8).(); |
| 447 | |
| 448 | CheatsActivecxx . . $ CheatsActive. = MDFN_GetSettingB("cheats"); |
| 449 | |
| 450 | RebuildSubCheatscxx . . $ RebuildSubCheats(49f6e7a06ebc5aa8).(); |
| 451 | |
| 452 | MDFNMP_InstallReadPatches(); |
| 453 | } |