WorldSubStackInstruction.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * V-Gears
  3. * Copyright (C) 2022 V-Gears Team
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <iostream>
  19. #include <sstream>
  20. #include <boost/format.hpp>
  21. #include "decompiler/world/instruction/WorldSubStackInstruction.h"
  22. #include "decompiler/world/WorldEngine.h"
  23. #include "decompiler/world/WorldCodeGenerator.h"
  24. #include "decompiler/world/WorldDisassembler.h"
  25. void FF7::WorldSubStackInstruction::ProcessInst(
  26. Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
  27. ){
  28. std::string op;
  29. switch (opcode_){
  30. case 0x41: op = "-"; break;
  31. case 0x40: op = "+"; break;
  32. case 0x80: op = "&&"; break;
  33. case 0xa0: op = "||"; break;
  34. case 0xc0: op = "|"; break;
  35. case 0x15: // neg
  36. case 0x17: // not
  37. stack.Push(stack.Pop()->negate());
  38. return;
  39. break;
  40. case 0x30: op = "*";break;
  41. case 0x60: op = "<"; break;
  42. case 0x61: op = ">"; break;
  43. case 0x62: op = "<="; break;
  44. case 0x63: op = ">="; break;
  45. case 0x0b0: op = "&"; break; // TODO: Review op
  46. case 0x51: op = "<<"; break;
  47. default:op = "unknown_operation";
  48. }
  49. std::string value = stack.Pop()->getString() + " " + op + " " + stack.Pop()->getString();
  50. stack.Push(new VarValue(value));
  51. }