sf64/mips_to_c.sh
Ryan Myers 8e808803e2
fox_effects decompiled (#77)
* Match 5 funcs

* Match func_8007E93C

* Match func_8007EBB8

* Match func_8007ED54

* Match func_8007EE68

* 0.017453292f to M_DTOR

* format

* 3 more matches

* Match 2 more

* 2 more matches

* Match func_8007F958

* Match func_8007FBE0

* Match func_8007FD84

* Match func_8007FE88

* 5 new matches

* Match func_80080D04

* Match func_800815DC and func_8008165C

* Match func_80081BEC

* MAtch func_80081B24

* Match 2 more

* 3 more matches

* Small tweaks

* Give names to function params

* Match func_80080ACC

* MAtch func_80083D2C

* Match func_800837EC

* WIP func_80081C5C

* Add view of rodata that needs to be migrated somewhere

* Match func_80081C5C!

* Fix bss reordering, and formatting.

* Add a submodule of m2c, and a new script for generating the context for a file, and a m2c output to an ignored folder.

* Migrate rodata

* Start importing data for sf_77E40.c

* Successful data migration for sf_77E40.c

* make format

* Reorganzie data for sf_77E40.c

* Try stubbing a PRINTF, to help with RODATA strings.

* Rename sf_77E40 to fox_effect

* Rename Object_8C to Effect

* make format...

* Rename gObjects8C to gEffects
2024-01-13 10:43:04 -03:00

30 lines
729 B
Bash
Executable File

#!/bin/sh
if [ $# -lt 2 ]; then
echo 1>&2 "$0: not enough arguments"
echo 1>&2 "Usage: $0 path/to/sourcefile.c func_name"
exit 2
elif [ $# -gt 2 ]; then
echo 1>&2 "$0: too many arguments"
exit 2
fi
PYTHON=python3
SOURCEFILE=$1
FUNCNAME=$2
M2CFILE=m2cfiles/$FUNCNAME.c
ASMFILE=$(find . -type f -name "*$FUNCNAME.s")
# Support python venv's if one is installed.
PYTHON_VENV=.venv/bin/python3
if test -f $PYTHON_VENV; then
PYTHON=$PYTHON_VENV
fi
echo "Generating ctx.c from $SOURCEFILE..."
$PYTHON ./tools/m2ctx.py $SOURCEFILE
echo "Generating $M2CFILE..."
echo '#include "../ctx.c"\n' > $M2CFILE
$PYTHON ./tools/m2c/m2c.py --target mips-ido-c --pointer-style left --context ctx.c -f $FUNCNAME $ASMFILE >> $M2CFILE