sotn-decomp/tools
Luciano Ciccariello 3464bb705a
TT_000 func_801733D4 (#789)
This has been one of the most weird functions I ever decompiled. I will
share a few tricks I learnt. In short, I tried inlining as much as
possible by removing all the temps.

---

```c
switch (self->step) {
...
case 2:
        isEntityAlive = 0;
        if (self->step != 2) {
            return;
        }
```
This was the output from M2C. As there is no way that `self->step` is
different than `2`, deleting had no effect on the matching.

---

```c
var_v0 = self->step;
switch (var_v0) {
    case 1:
        ...
        if (statement) {
            self->step++;
        }
        ...
        D_SOME_VARIABLE = var_v0;
}
```

This was another very weird one. I couldn't understand why
`D_SOME_VARIABLE` was assigned that way much further down the `case 1`.
The way I fixed it is that `var_v0` was always `1` due to `case 1:`. By
doing `D_SOME_VARIABLE = 1` I got a match.

---

```c
temp_a0_2 = D_80174C2C + 1;
...
D_80174C2C = temp_a0_2 & -(temp_a0_2 < 0x10);
```

To understand this madness I used a random C compiler I found online and
tested in a `for` loop what's the output for all the given `temp_a0_2`.
It seemed the value never changed but over `16` the value was always 0.
I logically re-written that statement into something that made logically
more sense for me and it matched, even if it looks very different from
the original:

```c
D_80174C2C++;
D_80174C2C = D_80174C2C >= 16 ? 0 : D_80174C2C;
```
2023-11-18 18:40:14 -08:00
..
asm-differ@6d3e4c44d1 Revert "Update external tools" (#776) 2023-11-16 09:02:15 +00:00
dups Add duplicates report to dups tool (#467) 2023-08-14 09:22:35 -07:00
function_finder Fix function finder (#784) 2023-11-17 20:24:42 -08:00
gfxsotn Add tool to export stage graphics into a PNG 2022-11-20 14:04:21 +00:00
lints/sotn-lint Rewrite lints, lint more FIX (#439) 2023-08-05 11:36:00 -07:00
m2c@0813874880 Revert "Update external tools" (#776) 2023-11-16 09:02:15 +00:00
maspsx@ae43f009e3 Revert "Update external tools" (#776) 2023-11-16 09:02:15 +00:00
n64splat@8acd2fad74 Revert "Update external tools" (#776) 2023-11-16 09:02:15 +00:00
saturn-splitter@8d549a8042 Split saturn libs, add function (#385) 2023-07-21 22:39:37 +01:00
sotn-debugmodule Replace RoomDimensions with Tilemap (#730) 2023-11-04 16:43:45 +00:00
sotn-disk Patch DRA stages when rebuilding the disk image 2023-02-21 11:20:04 +00:00
splat_ext Extract subweapon definitions (#790) 2023-11-19 00:32:27 +00:00
split_jpt_yaml Format code 2023-07-25 17:38:30 +00:00
vab-ex Sound effect extraction WIP (#398) 2023-07-31 12:12:07 -07:00
analyze_calls.py Fix directory .md file output in analyze_calls CI (#754) 2023-11-08 09:28:39 +00:00
bin2c.py Format code 2023-07-25 17:38:30 +00:00
decompile.py Fix an edge case in jump table resolver (#677) 2023-10-10 22:20:56 +01:00
gfxstage.py Split BIN/WEAPON0.BIN (#154) 2023-08-10 23:56:40 +01:00
m2ctx.py Format code 2023-09-19 22:25:08 +00:00
permuter_settings.toml mostly renamings, one func (#33) 2023-01-02 08:57:53 +00:00
png2bin.py Split BIN/WEAPON0.BIN (#154) 2023-08-10 23:56:40 +01:00
progress.py Update mapfile-parser and re-add weapon support (#476) 2023-08-16 01:12:30 +01:00
requirements-debian.txt Dockerless Saturn build (#266) 2023-06-19 20:10:09 +01:00
requirements-python.txt Revert "Update external tools" (#776) 2023-11-16 09:02:15 +00:00
richter_symbols.py Format code 2023-07-25 17:38:30 +00:00
sotn-str.py Fix source code line numbers (#708) 2023-10-28 09:08:12 -07:00
spritesheet.py Add spritesheet tool (#441) 2023-08-06 07:14:14 +01:00
symbols_test.py Extract and document all functions from main.exe (#736) 2023-11-06 14:53:27 -08:00
symbols.py TT_000 func_801733D4 (#789) 2023-11-18 18:40:14 -08:00
tools.mk Add tool to automatically perform symbols cross referencing (#413) 2023-07-31 12:14:57 -07:00
update.h Rename two global timers (#624) 2023-09-22 23:42:06 +01:00