MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / debug_init_trainer

Function debug_init_trainer

src/debug.cpp:9220–9378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9218}
9219
9220void debug_init_trainer(const TCHAR *file)
9221{
9222 TCHAR section[256];
9223 int cnt = 1;
9224
9225 struct ini_data *ini = ini_load(file, false);
9226 if (!ini)
9227 return;
9228
9229 write_log(_T("Loaded '%s'\n"), file);
9230
9231 _tcscpy(section, _T("patch"));
9232
9233 for (;;) {
9234 struct ini_context ictx;
9235 ini_initcontext(ini, &ictx);
9236
9237 for (;;) {
9238 TCHAR *name = NULL;
9239 TCHAR *data;
9240
9241 ini_getstring_multi(ini, section, _T("name"), &name, &ictx);
9242
9243 if (!ini_getstring_multi(ini, section, _T("data"), &data, &ictx))
9244 break;
9245 ini_setcurrentasstart(ini, &ictx);
9246 ini_setlast(ini, section, _T("data"), &ictx);
9247
9248 TCHAR *p = _tcschr(data, ';');
9249 if (p)
9250 *p = 0;
9251 my_trim(data);
9252
9253 struct trainerpatch *tp = xcalloc(struct trainerpatch, 1);
9254
9255 int datalen = (uaetcslen(data) + 3) / 4;
9256 tp->data = xcalloc(uae_u16, datalen);
9257 tp->maskdata = xcalloc(uae_u16, datalen);
9258 tp->length = parsetrainerdata(data, tp->data, tp->maskdata);
9259 xfree(data);
9260
9261 ini_getval_multi(ini, section, _T("offset"), &tp->offset, &ictx);
9262 if (tp->offset < 0 || tp->offset >= tp->length)
9263 tp->offset = 0;
9264
9265 if (ini_getstring_multi(ini, section, _T("replacedata"), &data, &ictx)) {
9266 int replacedatalen = (uaetcslen(data) + 3) / 4;
9267 tp->replacedata = xcalloc(uae_u16, replacedatalen);
9268 tp->replacemaskdata = xcalloc(uae_u16, replacedatalen);
9269 tp->replacelength = parsetrainerdata(data, tp->replacedata, tp->replacemaskdata);
9270 ini_getval_multi(ini, section, _T("replaceoffset"), &tp->offset, &ictx);
9271 if (tp->replaceoffset < 0 || tp->replaceoffset >= tp->length)
9272 tp->replaceoffset = 0;
9273 tp->access = -1;
9274 xfree(data);
9275 }
9276
9277 tp->access = 2;

Callers 1

m68k_goFunction · 0.85

Calls 14

ini_loadFunction · 0.85
ini_initcontextFunction · 0.85
ini_getstring_multiFunction · 0.85
ini_setcurrentasstartFunction · 0.85
ini_setlastFunction · 0.85
parsetrainerdataFunction · 0.85
ini_getval_multiFunction · 0.85
ini_getstringFunction · 0.85
inputdevice_geteventidFunction · 0.85
ini_setlastasstartFunction · 0.85
ini_nextsectionFunction · 0.85
ini_freeFunction · 0.85

Tested by

no test coverage detected