Advertisement
Dimitri_UA

Untitled

Aug 9th, 2014
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. eOpcodeResult ProcessOneCommand()
  2. {
  3.     unsigned short id = *(unsigned short *)&CScripts::space[m_pc] & 0x7FFF;
  4.     if(*(unsigned short *)&CScripts::space[m_pc] & 0x8000)
  5.         m_bNegFlag = true;
  6.     else
  7.         m_bNegFlag = false;
  8.     m_pc += 2;
  9.     // check for user (default replacement) opcodes here
  10.     for(auto i = CScripts::defaultOpcodeReplacement.begin(); i < CScripts::defaultOpcodeReplacement.end; i++)
  11.     {
  12.         if((*i).opcodeId == id)
  13.             return (*i).opcodeFunc(this, id);
  14.     }
  15.     //
  16.     switch(id)
  17.     {
  18.     case 0x004C: // GOTO_IF_TRUE
  19.         Collect(1);
  20.         if(m_bCompareFlag)
  21.             JumpTo(CScripts::params.intParam[0]);
  22.         return RET_CONTINUE;
  23.     case 0x004D: // GOTO_IF_FALSE
  24.         Collect(1);
  25.         if(!m_bCompareFlag)
  26.             JumpTo(CScripts::params.intParam[0]);
  27.         return RET_CONTINUE;
  28.     case 0x0002: // GOTO
  29.         Collect(1);
  30.         JumpTo(CScripts::params.intParam[0]);
  31.         return RET_CONTINUE;
  32.     case 0x0050: // GOSUB
  33.         Collect(1);
  34.         m_aRetAddr[m_nCountRet++] = m_pc;
  35.         JumpTo(CScripts::params.intParam[0]);
  36.         return RET_CONTINUE;
  37.     default:
  38.         if(id >= CUSTOM_OPCODES_START_ID)
  39.             return CScripts::customOpcodes[id - CUSTOM_OPCODES_START_ID](this, id);
  40.         return CScripts::defaultOpcodeHandlers[id / 100](this, id);
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement