Commit Graph

7 Commits

Author SHA1 Message Date
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
Xeeynamo
b93bbddd39 Format code 2023-09-16 09:41:49 +00:00
Luciano Ciccariello
ee4a372906
Remove orphan symbols (#595)
Allows to not hard code the location in-memory of decompiled functions
and imported data if not required. This allows to relocate the
referenced symbols when editing the original code or game data. If you
were getting the offset of those symbols from the symbol list in
`config/` I suggest to use the built `build/us/*.map` file instead.
2023-09-16 10:40:40 +01:00
Xeeynamo
043f65c529 Format code 2023-07-07 21:49:56 +00:00
Luciano Ciccariello
009e63100e TT_000 UpdateAnim refactor 2023-07-07 22:49:29 +01:00
Formatting bot
b049941376 Format code 2023-05-06 01:16:56 +00:00
Luciano Ciccariello
651deb2f82 Rename config folder to use game version 2023-02-21 01:42:33 +00:00