|
@@ -107,6 +107,21 @@ std::unique_ptr<Function> FF7::FF7Disassembler::StartFunction(size_t scriptIndex
|
|
|
return func;
|
|
return func;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+std::unique_ptr<Function> FF7::FF7Disassembler::StartLineFunction(size_t script_index){
|
|
|
|
|
+ auto func = std::make_unique<Function>();
|
|
|
|
|
+ func->_retVal = false;
|
|
|
|
|
+ func->_args = 0;
|
|
|
|
|
+ switch (script_index){
|
|
|
|
|
+ case 2: func->_name = "on_enter_line"; break;
|
|
|
|
|
+ case 3: func->_name = "on_move_to_line"; break;
|
|
|
|
|
+ case 4: func->_name = "on_cross_line"; break;
|
|
|
|
|
+ case 5: func->_name = "on_leave_line"; break;
|
|
|
|
|
+ default: func->_name = "script_" + std::to_string(script_index);
|
|
|
|
|
+ }
|
|
|
|
|
+ func->mStartAddr = _address;
|
|
|
|
|
+ return func;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
struct ScriptInfo
|
|
struct ScriptInfo
|
|
|
{
|
|
{
|
|
|
uint16 mEntryPoint;
|
|
uint16 mEntryPoint;
|
|
@@ -188,7 +203,9 @@ void FF7::FF7Disassembler::AddFunc(
|
|
|
|
|
|
|
|
// Read each block of opcodes up to a return.
|
|
// Read each block of opcodes up to a return.
|
|
|
const size_t old_num_instructions = _insts.size();
|
|
const size_t old_num_instructions = _insts.size();
|
|
|
- auto func = StartFunction(script_index);
|
|
|
|
|
|
|
+ std::unique_ptr<Function> func;
|
|
|
|
|
+ if (mEngine->EntityIsLine(entity_index)) func = StartLineFunction(script_index);
|
|
|
|
|
+ else func = StartFunction(script_index);
|
|
|
if (to_return_only){
|
|
if (to_return_only){
|
|
|
// Read opcodes to the end or bail at the first return.
|
|
// Read opcodes to the end or bail at the first return.
|
|
|
is_line = ReadOpCodesToPositionOrReturn(
|
|
is_line = ReadOpCodesToPositionOrReturn(
|
|
@@ -218,7 +235,20 @@ void FF7::FF7Disassembler::AddFunc(
|
|
|
const size_t new_num_instructions = _insts.size();
|
|
const size_t new_num_instructions = _insts.size();
|
|
|
func->mNumInstructions = new_num_instructions - old_num_instructions;
|
|
func->mNumInstructions = new_num_instructions - old_num_instructions;
|
|
|
func->mEndAddr = _insts.back()->_address;
|
|
func->mEndAddr = _insts.back()->_address;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (!func_name.empty()) func->_name = func_name;
|
|
if (!func_name.empty()) func->_name = func_name;
|
|
|
|
|
+
|
|
|
|
|
+ // TODO: Remove and test. Should be applied in StartLineFunction
|
|
|
|
|
+ if (is_line){
|
|
|
|
|
+ switch (script_index){
|
|
|
|
|
+ case 2: func->_name = "on_enter_line"; break;
|
|
|
|
|
+ case 3: func->_name = "on_move_to_line"; break;
|
|
|
|
|
+ case 4: func->_name = "on_cross_line"; break;
|
|
|
|
|
+ case 5: func->_name = "on_leave_line"; break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
int id = FindId(func->mStartAddr, func->mEndAddr, _insts);
|
|
int id = FindId(func->mStartAddr, func->mEndAddr, _insts);
|
|
|
|
|
|
|
|
// If there is no ID check if there was an ID for this entity in any of
|
|
// If there is no ID check if there was an ID for this entity in any of
|