Final Fantasy Hacktics

Modding => Help! => Topic started by: nitwit on November 22, 2014, 09:22:36 pm

Title: Source code for the event compiler and decompiler?
Post by: nitwit on November 22, 2014, 09:22:36 pm
I want to study it.
Title: Re: Source code for the event compiler and decompiler?
Post by: Xifanie on November 22, 2014, 09:30:31 pm
I lost it.
Title: Re: Source code for the event compiler and decompiler?
Post by: nitwit on November 22, 2014, 10:43:52 pm
Do you remember the structure of it?  What language did you use?

It doesn't seem very complicated.
Title: Re: Source code for the event compiler and decompiler?
Post by: Xifanie on November 22, 2014, 10:56:09 pm
Gosh, it was years ago.
I used Delphi Pascal 7 I think, and the structure huh... was really bad.

It's not a very complicated program as a base, it's just reading and reformatting text to and from arrays of bytes.
Without asking me anything specific, I might as well rewrite the damn thing just to answer you.
Title: Re: Source code for the event compiler and decompiler?
Post by: nitwit on November 23, 2014, 11:40:43 am
That isn't necessary, a pseudocode approximation works, abstracted from FFT opcodes.
Title: Re: Source code for the event compiler and decompiler?
Post by: Xifanie on November 23, 2014, 02:25:45 pm
(http://i.imgur.com/pdpXsUq.gif)
Title: Re: Source code for the event compiler and decompiler?
Post by: Raijinili on November 23, 2014, 04:09:59 pm
Quote from: nitwit on November 22, 2014, 10:43:52 pm
It doesn't seem very complicated.
What's your experience in reverse engineering?
Title: Re: Source code for the event compiler and decompiler?
Post by: nitwit on November 23, 2014, 04:49:01 pm
LOCATE EVENTS
Load event file.
Create text file.
Go to event scripts in event file (assuming the event scripts are located only in a specific location in the file).




DECODE AND WRITE
If byte at current address equals opcode n, then:
{
     Decode opcode n and parameter bytes (if any) to english language equivalents.
     Write English language equivalents to text file.
     Append newline character.
     Move current address to byte after the last parameter byte.
}




LOOPING MECHANISM
Not sure how to do this, or if it's necessary.  Should I loop through the IF THEN ELSE block (which will be huge) for every byte until I read the end of the file?  If the event script is only located at a certain point in the file then I need to detect the start and the length of the event scripting, then I can set up a WHILE loop for currentAddress != scriptStart + scriptLength.  Actually I think that's right, a FOR loop wouldn't work because there is no set length of event scripts in a given block.  The variable length of parameter bytes means that in a space of 100 bytes I could have 100 opcodes or fewer.




I answered my own question.