예제 #1
0
void xMemFinder::doFind() {
	ui.labResult->setText("");
	QStringList strl = ui.leBytes->text().split(":",QString::SkipEmptyParts);
	QStringList strm = ui.leMask->text().split(":",QString::SkipEmptyParts);
	int psiz = strl.size();
	if (psiz == 0) return;
	unsigned char pat[8];
	unsigned char msk[8];
	int idx = 0;
	for (idx = 0; idx < 8; idx++) {	// fill arrays
		if (idx < psiz) {
			pat[idx] = strl[idx].toInt(NULL, 16);
		} else {
			pat[idx] = 0x00;
		}
		if (idx < strm.size()) {
			msk[idx] = strm[idx].toInt(NULL, 16);
		} else {
			msk[idx] = 0xff;
		}
	}
	int shift = 0;
	idx = 0;
	int found = 0;
	unsigned char bt;
	while (!found && (shift < 0x10000)) {
		bt = memRd(mem, (adr + shift) & 0xffff);
		if ((bt & msk[idx]) == (pat[idx] & msk[idx])) {
			idx++;
			if (idx >= psiz)
				found = 1;
		} else {
			idx = 0;
		}
        shift++;
	}
	if (found) {
		adr = adr + shift - psiz;
		ui.labResult->setText(QString("Found @ %0").arg(gethexword(adr)));
		emit patFound(adr);
	} else {
		ui.labResult->setText("Not found");
	}
}
예제 #2
0
int loadSNA_f(Computer* comp, FILE* file, size_t fileSize) {

	unsigned char tmp, tmp2;
	unsigned short adr;
	char* pageBuf = malloc(0x4000);
	char* tmpgBuf = malloc(0x4000);

	compReset(comp, (fileSize < 49180) ? RES_48 : RES_128);

	snaHead hd;
	fread((char*)&hd, sizeof(snaHead), 1, file);
	comp->cpu->hl_ = (hd._h << 8) | hd._l;
	comp->cpu->de_ = (hd._d << 8) | hd._e;
	comp->cpu->bc_ = (hd._b << 8) | hd._c;
	comp->cpu->af_ = (hd._a << 8) | hd._f;
	comp->cpu->hl = (hd.h << 8) | hd.l;
	comp->cpu->de = (hd.d << 8) | hd.e;
	comp->cpu->bc = (hd.b << 8) | hd.c;
	comp->cpu->af = (hd.a << 8) | hd.f;
	comp->cpu->ix = (hd.hx << 8) | hd.lx;
	comp->cpu->iy = (hd.hy << 8) | hd.ly;
	comp->cpu->sp = (hd.hsp << 8) | hd.lsp;
	comp->cpu->i = hd.i;
	comp->cpu->r = hd.r;
	comp->cpu->r7 = hd.r & 0x80;
	comp->cpu->imode = hd.imod & 3;
	comp->cpu->iff1 = (hd.flag19 & 4) ? 1 : 0;
	comp->vid->brdcol = hd.border & 7;
	comp->vid->nextbrd = hd.border & 7;

	fread(pageBuf, 0x4000, 1, file);
	memSetPageData(comp->mem,MEM_RAM,5,pageBuf);
	fread(pageBuf, 0x4000, 1, file);
	memSetPageData(comp->mem,MEM_RAM,2,pageBuf);
	fread(tmpgBuf, 0x4000, 1, file);

	if (fileSize < 49180) {
		comp->p7FFD = 0x10;
		comp->pEFF7 = 0x00;
		comp->dos = 0;
		comp->hw->mapMem(comp);
		memSetBank(comp->mem, MEM_BANK3, MEM_RAM,0);
		memSetPageData(comp->mem, MEM_RAM, 0, tmpgBuf);
		comp->vid->curscr = 5;
		adr = (hd.hsp << 8) | hd.lsp;
		tmp = memRd(comp->mem, adr++);
		tmp2 = memRd(comp->mem, adr++);
		comp->cpu->sp = adr;
		comp->cpu->pc = tmp | (tmp2 << 8);
	} else {
		adr = fgetc(file);
		adr |= fgetc(file) << 8;
		comp->cpu->pc = adr;
		tmp = fgetc(file);
		comp->hw->out(comp,0x7ffd,tmp,0);
		tmp2 = fgetc(file);
		comp->dos = (tmp2 & 1) ? 1 : 0;
		for (tmp2 = 0; tmp2 < 8; tmp2++) {
			if ((tmp2 == 2) || (tmp2 == 5)) tmp2++;
			if ((tmp & 7) != tmp2) {
				fread(pageBuf, 0x4000, 1, file);
				memSetPageData(comp->mem, MEM_RAM, tmp2, pageBuf);
			}
		}
		memSetPageData(comp->mem, MEM_RAM, tmp & 7, tmpgBuf);
	}
	tsReset(comp->ts);
	free(pageBuf);
	free(tmpgBuf);
	return ERR_OK;
}