FieldModuleInstruction.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #pragma once
  19. #include "decompiler/decompiler_engine.h"
  20. /**
  21. * A module instruction.
  22. */
  23. class FieldModuleInstruction : public KernelCallInstruction{
  24. public:
  25. /**
  26. * Processes the instruction.
  27. *
  28. * @param func[in] Function to process.
  29. * @param stack[out] Function stack.
  30. * @param engine[in] Engine. Unused.
  31. * @param code_gen[in|out] Code generator.
  32. */
  33. virtual void ProcessInst(
  34. Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
  35. ) override;
  36. private:
  37. /**
  38. * Processes a BATTLE opcode.
  39. *
  40. * Opcode: 0x70
  41. * Short name: BATTLE
  42. * Long name: Start battle
  43. *
  44. * Memory layout (4 bytes)
  45. * |0x70|B|N|N|
  46. *
  47. * Arguments
  48. * - const UByte B: Bank (16-bit) to retrieve the address of the
  49. * battle ID, or zero if it is given as a literal value.
  50. * - const UWord N: Battle ID, or address to find ID if B is non-zero.
  51. *
  52. * This launches the battle module with whatever battle number is used
  53. * in the argument, or the value retrieved from memory location N if B
  54. * is non-zero. Battle 1, 2, and 999 (0x03E7) are debug battles.
  55. *
  56. * @param codegen[in|out] Code generator. Output lines are appended.
  57. */
  58. void ProcessBATTLE(CodeGenerator* code_gen);
  59. /**
  60. * Processes a BTLON opcode.
  61. *
  62. * Opcode: 0x71
  63. * Short name: BTLON
  64. * Long name: Battle switch
  65. *
  66. * Memory layout (2 bytes)
  67. * |0x71|S|
  68. *
  69. * Arguments
  70. * - const UByte S: Switch battles on/off (0/1, respectively).
  71. *
  72. * Turns random encounters on or off for this field. Note that if a
  73. * field does not have any Encounter Data set in its field file,
  74. * battles will not occur regardless of the argument passed with this
  75. * opcode.
  76. *
  77. * @param codegen[in|out] Code generator. Output lines are appended.
  78. */
  79. void ProcessBTLON(CodeGenerator* code_gen);
  80. /**
  81. * Processes a MAPJUMP opcode.
  82. *
  83. * Opcode: 0x60
  84. * Short name: BTLON
  85. * Long name: Change Field
  86. *
  87. * Memory layout (10 bytes)
  88. * |0x60|I|I|X|X|Y|Y|Z|Z|D|
  89. *
  90. * Arguments
  91. * - const UShort I: Field ID of the map to jump to.
  92. * - const Short X: X-coordinate of the player on the next field.
  93. * - const Short Y: Y-coordinate of the player on the next field.
  94. * - const Short Z: Z-coordinate of the player on the next field.
  95. * - const UByte D: Direction the character will be facing on the next
  96. * field, in the standard game format.
  97. *
  98. * Switches fields to the one indicated by I, and places the character
  99. * at the coordinates and direction specified. This is an alternative
  100. * to using a gateway, and can complement their usage as it allows for
  101. * more than 12 gateways by simulating their behavior through a LINE
  102. * which, when crossed, executes a MAPJUMP.
  103. *
  104. * @param codegen[in|out] Code generator. Output lines are appended.
  105. * @param func[in] Function. @todo What for?
  106. */
  107. void ProcessMAPJUMP(CodeGenerator* code_gen, Function& func);
  108. };