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

Function debug_trainer_match

src/debug.cpp:9118–9170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9116}
9117
9118void debug_trainer_match(void)
9119{
9120 uaecptr pc = m68k_getpc();
9121 uae_u16 opcode = x_get_word(pc);
9122 for (int i = 0; i < tpptrcnt; i++) {
9123 struct trainerpatch *tp = tpptr[i];
9124 if (tp->first != opcode)
9125 continue;
9126 if (tp->addr)
9127 continue;
9128 int j;
9129 for (j = 0; j < tp->length; j++) {
9130 uae_u16 d = x_get_word(pc + (j - tp->offset) * 2);
9131 if ((d & tp->maskdata[j]) != tp->data[j])
9132 break;
9133 }
9134 if (j < tp->length)
9135 continue;
9136 tp->first = 0xffff;
9137 tp->addr = pc;
9138 tp->varsize = -1;
9139 tp->varaddr = 0xffffffff;
9140 tp->oldval = 0xffffffff;
9141 if (tp->access >= 0) {
9142 tp->varsize = debug_trainer_get_ea(tp, pc, opcode, &tp->varaddr);
9143 switch (tp->varsize)
9144 {
9145 case 1:
9146 tp->oldval = x_get_byte(tp->varaddr);
9147 break;
9148 case 2:
9149 tp->oldval = x_get_word(tp->varaddr);
9150 break;
9151 case 4:
9152 tp->oldval = x_get_long(tp->varaddr);
9153 break;
9154 }
9155 }
9156 write_log(_T("Patch %d match at %08x. Addr %08x, size %d, val %08x\n"), i, pc, tp->varaddr, tp->varsize, tp->oldval);
9157
9158 if (tp->enabledatstart)
9159 debug_trainer_enable(tp, true);
9160
9161 // all detected?
9162 for (j = 0; j < tpptrcnt; j++) {
9163 struct trainerpatch *tp = tpptr[j];
9164 if (!tp->addr)
9165 break;
9166 }
9167 if (j == tpptrcnt)
9168 debug_opcode_watch = false;
9169 }
9170}
9171
9172static int parsetrainerdata(const TCHAR *data, uae_u16 *outdata, uae_u16 *outmask)
9173{

Callers 1

TRYFunction · 0.85

Calls 4

m68k_getpcFunction · 0.85
debug_trainer_get_eaFunction · 0.85
debug_trainer_enableFunction · 0.85
write_logFunction · 0.70

Tested by

no test coverage detected