Exemplo n.º 1
0
int base_handler_switch(char *d)
{
        S32 new_switches;
        int i;
        bool old_sw;
        bool new_sw;

        new_switches = gethexword(d);
        if(new_switches < 0)
                return -1;
        // Have the new switch state. Compare with the old state.
        for(i = 0; i < 14;) {
                old_sw = (base_switches & (1 << i)) != 0;
                new_sw = (new_switches & (1 << i)) != 0;
                if(old_sw != new_sw) {
                        // Switch has changed so call handler
                        ActionSwitchChange ((1 << i), new_sw ? SWITCH_UP :
                                SWITCH_DOWN);
                }

                i++;
                if( i == 4)     // Skip to bumper switches
                        i = 8;

        }
	
	base_switches = (U16)new_switches;

        return 0;
}
Exemplo n.º 2
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");
	}
}