This is some code I wrote a while ago and I think it might make sense to
add it to `decompile.py`.
This function takes in an assembly file, and will scan through it for
any jump tables. It will then find them in the asm folder, and move the
jumptable information into the assembly file for the function. This
means that users do not have to seek out rodata and paste it into the
asm file manually.
As an example, the user can now run `dec EntityAlucard` and it will
successfully decompile the function and insert it to the .c file,
because now when it passes the assembly to m2c, the rodata is there at
the bottom of the assembly function. Overall this has been a big
convenience for me and I hope it will be helpful for others.
As part of an upcoming PR, I would like to call decompile.py from an
external Python script. Therefore, to make this easy, I have moved the
main behaviors of decompile.py to a dedicated `main()` function, which
gets called with the arguments from `argparse`. The parsing, rather than
being out in the open in the file, is handled in the `if __name__==
__main__` block, since we shouldn't need to do parsing when calling
externally.
This change had one small breaking result, that `check_injected_code`
wasn't working since it was relying on `func` being an accessible global
variable. Now `func` is passed as a function argument, so it will not
error out. Otherwise, this PR should hopefully be completely "invisible"
when using decompile.py as it was used previously, but should open the
door to better external calling.
I poked inside the exported functions and detected all the signatures
used. This will be helpful to keep decompiling DRA. I took the chance to
decompile `func_ptr_80170004` from `w_015` and all the `GetWeaponId`.
Interestingly, `w_057` and `w_058` has the wrong implementation of
`GetWeaponId`, suggesting developers copy&pasted stuff around after all.
This depends from #476 . Let's not merge before that.
![f_000](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/abcc5bd5-ed0c-4fc7-88fa-aa6e796aac1b)
Matches w_000, effectively opening the doors to understand how hand
equippables work. That includes weapons, shields, consumable; all of
them internally named as Weapons). This overlay is used by:
* Tyrfing
* Namakura
* Gladius
* Scimitar
* Cutlass
* Saber
* Falchion
* Broadsword
* Bekatowa
* Damascus sword
* Hunter sword
* Bastard sword
* Talwar
* Sword of Hador
* Luminus
* Harper
* Gram
* Mormegil
* Terminus Est
* Dark Blade
* Mourneblade
* Badelaire
Due to the nature of splat, renaming the symbols is hella hard but
possible once we start importing the `.data` section in it. As far I
know this overlay does not contain any `.rodata`.
Checklist to convert it from Draft to Ready:
- [x] Decompile [func_4000_8017B1D8](https://decomp.me/scratch/HLPI0)
- [x] Confirm name of the functions
- [X] ~~Put shareable code in the appropriate folder (either as `.h` or
`.c`~~ not all overlays have identical functions (see w_029). Needs more
research
- [X] ~~Import `.data` in the C file~~ needs substancial re-work in the
spriteparts asset extractor
- [x] Move `AnimSoundEvent` to the appropriate header
- [X] ~~Rename `Entity::unk58` and `Entity::`unk6A`~~ more appropriate
as a separate PR