pokecilver
pokecilver copied to clipboard
Converting Functions
Need to put together a better tool for converting the functions. Currently, the proccess that seems to work fine is: -convert the asm to C with convASM.py -check that the script is working when ran in game -check for contained functions (functions that do not make calls, jumps, or RST (or any macros using these) -if a function is contained, all calls to it can be changed to CCALL(absoluteAddress) (ex: CALL(mInitSound) to CCALL(aInitSound)) -similarly, all jumps can be changed to returns of the function (ex: JP(mInitSound) to return InitSound()) or (ex: JR_NZ(mInitSound) to IF_NZ return InitSound) -if testing this proves fine, the contained function can be "converted" or finalized -to finalize, change all RET/conditional RET to returns (ex: RET_C to IF_C return) -any jumps this function makes will also need to be converted/finalized, and so forth -all finalized functions should go in C/ConvertedFunctions.txt, and be removed from C/functions.h -any CCALLS to this function should now be changed to a direct call of it (ex: CCALL(aInitSound) to InitSound()) -test, as always
Will look into automating this some more...
With the addition of C/functionHelper.py, C files can be ran through in analysis mode (-a flag), and should be ran through again until no results are returned (all contained functions are located at that point). Afterwards, re-run with the -u flag to make the updates.
An example to handle a folder at once would be to use xargs: find home/*.c | xargs -I {} ./functionHelper.py {} -a Until no results show, then the same command, but with the -u flag instead of -a
Still need to add in additional handling for converting/finalizing functions