MCPcopy Create free account
hub / github.com/dborth/fceugx / LoadCheats

Function LoadCheats

source/cheatmgr.cpp:32–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 ***************************************************************************/
31
32static int LoadCheats (int length)
33{
34 unsigned int addr;
35 unsigned int val;
36 unsigned int status;
37 unsigned int type;
38 unsigned int compare;
39 int x;
40
41 char *namebuf;
42 int tc=0;
43
44 char * linebreak = strtok((char *)savebuffer, "\n");
45 int line_num = 0;
46
47 while(linebreak != NULL && line_num < 500)
48 {
49 line_num++;
50 char *tbuf=linebreak;
51 int doc=0;
52
53 addr=val=compare=status=type=0;
54
55 if(tbuf[0]=='S')
56 {
57 tbuf++;
58 type=1;
59 }
60 else type=0;
61
62 if(tbuf[0]=='C')
63 {
64 tbuf++;
65 doc=1;
66 }
67
68 if(tbuf[0]==':')
69 {
70 tbuf++;
71 status=0;
72 }
73 else status=1;
74
75 if(doc)
76 {
77 char *neo = &tbuf[4+2+2+1+1+1];
78 if(sscanf(tbuf, "%04x%*[:]%02x%*[:]%02x", &addr, &val, &compare) != 3)
79 continue;
80 namebuf=(char *)malloc(strlen(neo)+1);
81 strcpy(namebuf, neo);
82 }
83 else
84 {
85 char *neo = &tbuf[4+2+1+1];
86 if(sscanf(tbuf, "%04x%*[:]%02x", &addr, &val) != 2)
87 continue;
88 namebuf=(char *)malloc(strlen(neo)+1);
89 strcpy(namebuf, neo);

Callers 1

SetupCheatsFunction · 0.85

Calls 3

AddCheatEntryFunction · 0.85
FCEUI_ToggleCheatFunction · 0.85
RebuildSubCheatsFunction · 0.85

Tested by

no test coverage detected