LastFmLoginWidget::LastFmLoginWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LastFmLoginWidget)
{
    ui->setupUi(this);
    isAuthorized = false;
    API_KEY = "e9b5b66922ea96b054cdd47001ad753b";
    SHARED_SECRET = "56c340c1f8800cc6856875a9aaf96e5c";
    getTokenUrl = QUrl("http://ws.audioscrobbler.com/2.0/?method=auth.gettoken&api_key="+API_KEY);
    connect(ui->webView,SIGNAL(urlChanged(QUrl)),this,SLOT(debugConsole(QUrl)));
}
Пример #2
0
void Debugger::debugConsole(std::uint16_t address) {
  std::cout << "Debugger [" << pc_<< "]> ";
  std::string command;
  std::getline( std::cin, command);

  std::vector<std::string> command_list = split(command, ' ');

  if(command_list.front() == "help") {
    printHelp();
  } else if (command_list.front() == "c") {
    continueExec();
    return;
  } else if (command_list.front() == "pr") {
    printRegisters();
  } else if (command_list.front() == "pm") {
    uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_;
    printMemory(addr);
  } else if (command_list.front() == "ps") {
      std::cout << "--Stack--" << std::endl;
      printStack(stack_);
  } else if (command_list.front() == "disa") {
    uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_;
    printCodeBlockAt(addr);
  } else if(command_list.front() == "br") {
    uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_;
    setBreakPoint(addr);
  } else if(command_list.front() == "cbr") {
    uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_;
    clearBreakPoint(addr);
  } else if(command_list.front() == "setr") {
    setRegester(atoi(command_list[1].c_str()), atoi(command_list[2].c_str()));
  } else if(command_list.front() == "setm") {
    setMemeory(atoi(command_list[1].c_str()), atoi(command_list[2].c_str()));
  } else if(command_list.front() == "push") {
      stack_.push(atoi(command_list[1].c_str()));
  } else if(command_list.front() == "pop") {
      stack_.pop();
  } else if (command_list.front() == "s") {
    return;
  } else {
    std::cout << "Unknowen command type 'help' for list of comamnds" << std::endl;
  }
  debugConsole(pc_);
  return;
}
Пример #3
0
int AgiEngine::testIfCode(int lognum) {
	AgiGame *state = &_game;
	uint8 op;
	uint8 p[16];

	int notMode = false;
	int orMode = false;
	int endTest = false;
	int result = true;

	while (!(shouldQuit() || _restartGame) && !endTest) {
		if (_debug.enabled && (_debug.logic0 || lognum))
			debugConsole(lognum, lTEST_MODE, NULL);

		op = *(code + ip++);
		memmove(p, (code + ip), 16);

		switch (op) {
		case 0xFC:
			if (orMode) {
				// We have reached the end of an OR expression without
				// a single test command evaluating as true. Thus the OR
				// expression evalutes as false which means the whole
				// expression evaluates as false. So skip until the
				// ending 0xFF and return.
				skipInstructionsUntil(0xFF);
				result = false;
				endTest = true;
			} else {
				orMode = true;
			}
			continue;
		case 0xFD:
			notMode = true;
			continue;
		case 0x00:
		case 0xFF:
			endTest = true;
			continue;

		default:
			// Evaluate the command and skip the rest of the instruction
			_agiCondCommands[op](state, this, p);
			skipInstruction(op);

			// NOT mode is enabled only for one instruction
			if (notMode)
				state->testResult = !state->testResult;
			notMode = false;

			if (orMode) {
				if (state->testResult) {
					// We are in OR mode and the last test command evaluated
					// as true, thus the whole OR expression evaluates as
					// true. So skip the rest of the OR expression and
					// continue normally.
					skipInstructionsUntil(0xFC);
					orMode = false;
					continue;
				}
			} else {
				result &= state->testResult;
				if (!result) {
					// Since we are in AND mode and the last test command
					// evaluated as false, the whole expression also evaluates
					// as false. So skip until the ending 0xFF and return.
					skipInstructionsUntil(0xFF);
					endTest = true;
					continue;
				}
			}
			break;
		}
	}

	// Skip the following IF block if the condition evaluates as false
	if (result)
		ip += 2;
	else
		ip += READ_LE_UINT16(code + ip) + 2;

	if (_debug.enabled && (_debug.logic0 || lognum))
		debugConsole(lognum, 0xFF, result ? "=true" : "=false");

	return result;
}
Пример #4
0
int AgiEngine::testIfCode(int lognum) {
    int ec = true;
    int retval = true;
    uint8 op = 0;
    uint8 notTest = false;
    uint8 orTest = false;
    uint16 lastIp = ip;
    uint8 p[16] = { 0 };
    bool end_test = false;

    while (retval && !(shouldQuit() || _restartGame) && !end_test) {
        if (_debug.enabled && (_debug.logic0 || lognum))
            debugConsole(lognum, lTEST_MODE, NULL);

        lastIp = ip;
        op = *(code + ip++);
        memmove(p, (code + ip), 16);

        switch (op) {
        case 0xFF:	// END IF, TEST true
            end_test = true;
            break;
        case 0xFD:
            notTest = !notTest;
            continue;
        case 0xFC:	// OR
            // if or_test is ON and we hit 0xFC, end of OR, then
            // or is STILL false so break.
            if (orTest) {
                ec = false;
                retval = false;
                end_test = true;
            }

            orTest = true;
            continue;

        case 0x00:
            // return true?
            end_test = true;
            break;
        case 0x01:
            ec = testEqual(p[0], p[1]);
            if (p[0] == 11)
                _timerHack++;
            break;
        case 0x02:
            ec = testEqual(p[0], getvar(p[1]));
            if (p[0] == 11 || p[1] == 11)
                _timerHack++;
            break;
        case 0x03:
            ec = testLess(p[0], p[1]);
            if (p[0] == 11)
                _timerHack++;
            break;
        case 0x04:
            ec = testLess(p[0], getvar(p[1]));
            if (p[0] == 11 || p[1] == 11)
                _timerHack++;
            break;
        case 0x05:
            ec = testGreater(p[0], p[1]);
            if (p[0] == 11)
                _timerHack++;
            break;
        case 0x06:
            ec = testGreater(p[0], getvar(p[1]));
            if (p[0] == 11 || p[1] == 11)
                _timerHack++;
            break;
        case 0x07:
            ec = testIsSet(p[0]);
            break;
        case 0x08:
            ec = testIsSet(getvar(p[0]));
            break;
        case 0x09:
            ec = testHas(p[0]);
            break;
        case 0x0A:
            ec = testObjInRoom(p[0], p[1]);
            break;
        case 0x0B:
            ec = testPosn(p[0], p[1], p[2], p[3], p[4]);
            break;
        case 0x0C:
            ec = testController(p[0]);
            break;
        case 0x0D:
            ec = testKeypressed();
            break;
        case 0x0E:
            ec = testSaid(p[0], (uint8 *) code + (ip + 1));
            ip = lastIp;
            ip++;	// skip opcode
            ip += p[0] * 2;	// skip num_words * 2
            ip++;	// skip num_words opcode
            break;
        case 0x0F:
            debugC(7, kDebugLevelScripts, "comparing [%s], [%s]", _game.strings[p[0]], _game.strings[p[1]]);
            ec = testCompareStrings(p[0], p[1]);
            break;
        case 0x10:
            ec = testObjInBox(p[0], p[1], p[2], p[3], p[4]);
            break;
        case 0x11:
            ec = testObjCenter(p[0], p[1], p[2], p[3], p[4]);
            break;
        case 0x12:
            ec = testObjRight(p[0], p[1], p[2], p[3], p[4]);
            break;
        case 0x13: // Unknown test command 19
            // My current theory is that this command checks whether the ego is currently moving
            // and that that movement has been caused using the mouse and not using the keyboard.
            // I base this theory on the game's behavior on an Amiga emulator, not on disassembly.
            // This command is used at least in the Amiga version of Gold Rush! v2.05 1989-03-09
            // (AGI 2.316) in logics 1, 3, 5, 6, 137 and 192 (Logic.192 revealed this command's nature).
            // TODO: Check this command's implementation using disassembly just to be sure.
            ec = _game.viewTable[0].flags & ADJ_EGO_XY;
            debugC(7, kDebugLevelScripts, "op_test: in.motion.using.mouse = %s (Amiga-specific testcase 19)", ec ? "true" : "false");
            break;
        default:
            ec = false;
            end_test = true;
        }

        if (!end_test) {
            if (op <= 0x12)
                ip += logicNamesTest[op].numArgs;

            // exchange ec value
            if (notTest)
                ec = !ec;

            // not is only enabled for 1 test command
            notTest = false;

            if (orTest && ec) {
                // a true inside an OR statement passes
                // ENTIRE statement scan for end of OR

                // CM: test for opcode < 0xfc changed from 'op' to
                //     '*(code+ip)', to avoid problem with the 0xfd (NOT)
                //     opcode byte. Changed a bad ip += ... ip++ construct.
                //     This should fix the crash with Larry's logic.0 code:
                //
                //     if ((isset(4) ||
                //          !isset(2) ||
                //          v30 == 2 ||
                //          v30 == 1)) {
                //       goto Label1;
                //     }
                //
                //     The bytecode is:
                //     ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff

                // find end of OR
                while (*(code + ip) != 0xFC) {
                    if (*(code + ip) == 0x0E) {	// said
                        ip++;

                        // cover count + ^words
                        ip += 1 + ((*(code + ip)) * 2);
                        continue;
                    }

                    if (*(code + ip) < 0xFC)
                        ip += logicNamesTest[*(code + ip)].numArgs;
                    ip++;
                }
                ip++;

                orTest = false;
                retval = true;
            } else {
                retval = orTest ? retval || ec : retval && ec;
            }
        }
    }

    // if false, scan for end of IP?
    if (retval)
        ip += 2;
    else {
        ip = lastIp;
        while (*(code + ip) != 0xff) {
            if (*(code + ip) == 0x0e) {
                ip++;
                ip += (*(code + ip)) * 2 + 1;
            } else if (*(code + ip) < 0xfc) {
                ip += logicNamesTest[*(code + ip)].numArgs;
                ip++;
            } else {
                ip++;
            }
        }
        ip++;		// skip over 0xFF
        ip += READ_LE_UINT16(code + ip) + 2;
    }

    if (_debug.enabled && (_debug.logic0 || lognum))
        debugConsole(lognum, 0xFF, retval ? "=true" : "=false");

    return retval;
}
Пример #5
0
/**
 * Execute a logic script
 * @param n  Number of the logic resource to execute
 */
int AgiEngine::runLogic(int n) {
	AgiGame *state = &_game;
	uint8 op = 0;
	uint8 p[CMD_BSIZE] = { 0 };
	int num = 0;
	ScriptPos sp;
	//int logic_index = 0;

	state->logic_list[0] = 0;
	state->max_logics = 0;

	debugC(2, kDebugLevelScripts, "=================");
	debugC(2, kDebugLevelScripts, "runLogic(%d)", n);

	sp.script = n;
	sp.curIP = 0;
	_game.execStack.push_back(sp);

	// If logic not loaded, load it
	if (~_game.dirLogic[n].flags & RES_LOADED) {
		debugC(4, kDebugLevelScripts, "logic %d not loaded!", n);
		agiLoadResource(rLOGIC, n);
	}

	_game.lognum = n;
	_game._curLogic = &_game.logics[_game.lognum];

	_game._curLogic->cIP = _game._curLogic->sIP;

	_timerHack = 0;
	while (ip < _game.logics[n].size && !(shouldQuit() || _restartGame)) {
		if (_debug.enabled) {
			if (_debug.steps > 0) {
				if (_debug.logic0 || n) {
					debugConsole(n, lCOMMAND_MODE, NULL);
					_debug.steps--;
				}
			} else {
				_sprites->blitBoth();
				_sprites->commitBoth();
				do {
					mainCycle();
				} while (!_debug.steps && _debug.enabled);
				_sprites->eraseBoth();
			}
		}

		_game.execStack.back().curIP = ip;

		char st[101];
		int sz = MIN(_game.execStack.size(), 100u);
		memset(st, '.', sz);
		st[sz] = 0;

		switch (op = *(code + ip++)) {
		case 0xff:	// if (open/close)
			testIfCode(n);
			break;
		case 0xfe:	// goto
			// +2 covers goto size
			ip += 2 + ((int16)READ_LE_UINT16(code + ip));

			// timer must keep running even in goto loops,
			// but AGI engine can't do that :(
			if (_timerHack > 20) {
				pollTimer();
				updateTimer();
				_timerHack = 0;
			}
			break;
		case 0x00:	// return
			debugC(2, kDebugLevelScripts, "%sreturn() // Logic %d", st, n);
			debugC(2, kDebugLevelScripts, "=================");

//			if (getVersion() < 0x2000) {
//				if (logic_index < state->max_logics) {
//					n = state->logic_list[++logic_index];
//					state->_curLogic = &state->logics[n];
//					state->lognum = n;
//					ip = 2;
//					warning("running logic %d\n", n);
//					break;
//				}
//				_v[13]=0;
//			}

			_game.execStack.pop_back();
			return 1;
		default:
			num = logicNamesCmd[op].argumentsLength();
			memmove(p, code + ip, num);
			memset(p + num, 0, CMD_BSIZE - num);

			debugC(2, kDebugLevelScripts, "%s%s(%d %d %d)", st, logicNamesCmd[op].name, p[0], p[1], p[2]);

			_agiCommands[op](&_game, p);
			ip += num;
		}

//		if ((op == 0x0B || op == 0x3F || op == 0x40) && logic_index < state->max_logics) {
//			n = state->logic_list[++logic_index];
//			state->_curLogic = &state->logics[n];
//			state->lognum = n;
//			ip = 2;
//			warning("running logic %d\n", n);
//		}

		if (_game.exitAllLogics)
			break;
	}

	_game.execStack.pop_back();

	return 0;		// after executing new.room()
}