2189 Commits

Author SHA1 Message Date
sozud
b2595df83d
Integrate psp function finder (#1293)
Current output looks like this
```
| Ovl    | Function                 |   Length |   Branches | Jtbl   | WIP                             | %     |
|--------|--------------------------|----------|------------|--------|---------------------------------|-------|
| wrp    | DestroyCurrentEntity     |       16 |          2 |        | https://decomp.me/scratch/aKfDL | 0.99  |
| wrp    | CreateEntitiesToTheRight |       90 |         11 |        | https://decomp.me/scratch/nKKQN | 0.989 |
| wrp    | CreateEntitiesAbove      |       92 |         11 |        | https://decomp.me/scratch/ezNeo | 0.99  |
| wrp    | CreateEntitiesToTheLeft  |       97 |         12 |        |                                 |       |
| wrp    | CreateEntitiesBelow      |       99 |         12 |        |                                 |       |
| wrp    | InitRoomEntities         |      151 |         10 |        | https://decomp.me/scratch/thtl9 | 0.981 |
| wrp    | EntityEquipItemDrop      |      584 |         67 | Yes    | https://decomp.me/scratch/R4CBY | 0.993 |
| wrp    | EntityNumericDamage      |      683 |         51 |        | https://decomp.me/scratch/IyaVH | 0.989 |
| tt_000 | func_80172C30            |      731 |         65 |        |                                 |       |
| wrp    | EntityPrizeDrop          |      973 |        120 | Yes    |                                 |       |
| wrp    | EntityStageNamePopup     |      990 |         83 |        | https://decomp.me/scratch/hTUwZ | 0.972 |
| wrp    | EntityWarpRoom           |     1034 |         83 | Yes    | https://decomp.me/scratch/4MUb6 | 0.953 |
| wrp    | EntityRelicOrb           |     1186 |         87 | Yes    |                                 |       |
| tt_000 | func_80172120            |     1199 |        126 | Yes    |                                 |       |
| wrp    | EntityRedDoor            |     1248 |        112 | Yes    |                                 |       |
| wrp    | HitDetection             |     1628 |        196 |        |                                 |       |
```

I haven't tested the CI script, will just do some commits on master if
it's broken
2024-06-17 15:52:17 -07:00
bismurphy
7c6d759f12
Decompile NP3 EntityOwlKnight (#1333)
This is a huge one! Lots of file shuffling needed to happen, but now
that things are in place I feel relatively confident that we have our
file splits in the right places, which is great. It's really cool when
we can make file splits that are motivated by game structure, and not by
rodata limitations.

Anyway, here it is, let me know which flags and stuff I forgot about :)
2024-06-17 09:36:09 -07:00
Jonathan Hohle
32f42645d5
Decompile main (#1326)
Decompiles `main`.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-16 20:11:42 -07:00
bismurphy
b01fe2b36b
Decompile w45 func_ptr_80170010 (#1332)
Another one of these weapon functions that needs to return s32, so they
all got changed over.
2024-06-16 16:08:37 -07:00
bismurphy
b5678baf97
Decompile NP3 func_801CBF18 (#1331)
Helper function for the Owl Knight, does a bunch of stuff with prims.
Might be related to his death animation.
2024-06-16 11:13:52 -07:00
bismurphy
d3bcca25ff
Decompile NP3 EntityOwl (#1330)
Another big one! This required mangling the files a little bit; once the
other functions are decompiled the files should come back together
nicely. The function itself is in 4B018.c, and the function is currently
alone in that file.
2024-06-15 23:32:20 -07:00
bismurphy
c4e2edfe6e
Decompile NP3 EntityGurkha (#1329)
The last one I have ready for this set. Should be a nice chunk of NP3 to
knock out!
2024-06-16 02:09:01 +01:00
bismurphy
483791eb8f
Decompile NP3 EntityGurkhaBodyParts (#1328)
Next one in the sequence, nothing much additional to share.
2024-06-15 19:55:58 -04:00
bismurphy
60d78fd36b
Decompile NP3 EntityHammer (#1327)
Kind of a complicated process to get this one working, beyond the normal
function decompilation.

Files are split for now, because there are weird things with rodata. I
have already done the two remaining Gurkha functions, so my next PRs
will pull those in and will end up bringing the files back together.

Messy things here, tried to make it looks nice but as always, feedback
is appreciated.
2024-06-16 00:01:46 +01:00
bismurphy
92eeed4775
Decompile the last WRP function (#1325)
What is a SOTN? A nasty, miserable little pile of pointer manipulations!

Well here we are, the last one! Solving the previous function helped me
figure out the patterns here, but wow, this is really a miracle.

Let me know how you want to handle the de-duplication. We can either do
that here, or merge this and do all the others in a second PR.
2024-06-15 17:36:49 +01:00
sozud
866942689c
nz0 data (#1324) 2024-06-15 17:17:44 +01:00
bismurphy
782fdfd32e
De-duplicate the first of the recursive prim functions (#1323)
Fairly straightforward de-duplication. If anyone has better names for
either the function or the array it uses, feel free to suggest them, but
with this thing being so weird and its purpose being unknown, I had to
keep the names pretty generic.
2024-06-14 19:15:15 -07:00
bismurphy
704ca622ba
Decompile WRP func_801907EC (!) (#1322)
One of the last two functions!

Since this is duplicated in every overlay (but never used in any of
them), it will make sense to de-duplicate this. I will use my automatic
de-duplication script to put it into the appropriate .h file. That can
either be in this PR (after getting the seal of approval), or can be a
separate PR (after merging this initial WRP version). I'm good with any
option.

Very cool though, glad I figured this one out finally! Hopefully the
last one will come along soon...
2024-06-14 15:30:45 -07:00
bismurphy
5053101b2f
Decompile NP3 func_801CDAC8 (#1321)
A relatively simple function. The call to func_801CD78C necessitated the
prior PR, so now that that one is in, this one can go in smoothly.
2024-06-14 22:02:22 +01:00
bismurphy
e26f0118a3
Defake NP3 func_801CD78C (#1319)
This function is part of a small network of functions that pass around
Entities and Point32s, so it ends up being a little weird. I guess the
first two elements of an Entity are equivalent to a Point32, but still
weird.

Within this function though, there is nothing to indicate that the args
are Entity, and a PSP function seems to allocate the right stack size to
call this with Point32, so I think we should do that, and have the
callers cast their entities to Point32 if needed.
2024-06-14 19:24:27 +01:00
bismurphy
a4a556239e
Decompile NZ0 801B0AA4 (#1318)
3 NZ0 functions remaining? I think you mean 2 NZ0 functions remaining :)

I don't really understand this one, it's a bit of a mess. Lots of
tilemap stuff, so maybe this does something with the weird shifting
backgrounds in the Alchemy lab? Who knows.
2024-06-13 15:04:08 -07:00
bismurphy
2a199f0975
Decompile NZ0 EntityMagicallySealedDoor (#1317)
I was able to start with the red door code and rely on that a fair bit.
I modified the code to recreate the parts that are needed for the blue
door.

Their entity extensions matched up (with the blue door needing a couple
extra members) so I changed ET_RedDoor to just be ET_Door, and both
doors use it. I'll be curious to see if the weird golden door to the
Olrox fight is similar to these ones.

NZ0 is really getting empty now!
2024-06-13 22:08:08 +01:00
bismurphy
f349c2fdea
Decompile NZ0 func_801C4198 (#1315)
This is a weird function, we don't really know what it does. But
matching is always the first step. Just glad it works.

The behavior on the `dataPtr` makes me sad. Pointers are treated in such
evil ways in this game.
2024-06-13 20:52:28 +01:00
Luciano Ciccariello
9861f51336
Extract stage map into individual files (#1316)
This took me a lot of manual work. But I think I confirmed a pattern
that will help me to automate all of this for all the next stage
overlays that will be imported in the repo.

I noticed some stages with only one room having more than two layers or
more than two tile definitions, it might be either debugging or unused
content? I did not have time to explore any of that.

I modified the `tiledef` splat extension to greatly minimise the set-up
and noise.
2024-06-13 20:01:10 +01:00
bismurphy
5769a39a04
Decompile NZ0 EntityMaria (#1314)
Relatively simple function.

I'm trying to get better at things like using good variable names,
organizing files, etc, and I think it pays off. This function is more
readable than it would have been in the initial scratch. Excited to
really get the game into a state where all the code is directly
readable.
2024-06-13 17:52:43 +01:00
Josh Lory
9f09aa81ee
Decompile DRA func_8012C600 (#1313)
PSX: https://decomp.me/scratch/74j2Y
PSP: https://decomp.me/scratch/ons5L

Let me know if you'd like to inline `CLAMP_MIN` and `CLAMP_MAX`, or move
them to `macros.h` or `common.h`. I see a reference to `CLAMP` in
STYLE.md but couldn't find it in the repo.
2024-06-13 09:31:49 -07:00
bismurphy
731bf1fab1
Decompile ST0 EntityDraculaCutscene (#1312)
The duplicate finder missed this one, but I found it indirectly by
looking for the preceding functions, which are all duplicates. This
should actually be the last of the cutscenes (at least, until we get new
overlays).

All these cutscenes have little tweaks to their logic, but nothing very
interesting, so not much more to share here. But cool to have them all
done!
2024-06-13 09:22:35 -07:00
Josh Lory
f8a29fdd9b
Decompile DRA func_80121F58 (#1299)
PSX: https://decomp.me/scratch/w2wDx
PSP: https://decomp.me/scratch/s95Fn
2024-06-12 21:16:55 -07:00
Luciano Ciccariello
b2c1fb3151
Link WRP (#1305)
I think this is pretty much ready to be merged it. I do not see much of
a point of having the branch floating around.

I am using a `#ifndef HARD_LINK` to avoid compiling duplicate functions
with the same symbol name.

For data with the same symbol name but different content I am doing a
`#define OVL_EXPORT(x) WRP_##x`. So for example
`OVL_EXPORT(g_EntityGfx)` will be expanded as `WRP_g_EntityGfx`. It is
an unfortunate hack. On the other hand all the data migration allowed me
to mark most of the data and functions as `static`. If we use the same
approach on other overlays we could easily statically link them as well.

SEL is enabled by default. It will take you straight to the real WRP,
not the dummy one.

Most of the changes are loading assets from their respective JSON files.
Linking the stage was pretty straight forward.
2024-06-12 22:03:56 +01:00
Xeeynamo
5f4c609d3a Format code 2024-06-12 20:07:47 +00:00
Luciano Ciccariello
f96e0aa9fc Re-organise shared symbols 2024-06-12 21:06:51 +01:00
Luciano Ciccariello
2402c8aa64 Always allow duplicate symbols when generating reports 2024-06-12 20:32:54 +01:00
Luciano Ciccariello
adbcdc894e Avoid duplicate symbols while generating reports 2024-06-12 20:02:16 +01:00
Luciano Ciccariello
8abb09e3ff
Update splat to 0.24.4 (#1112)
Still work in progress. I removed splat as a submodule and started using
it as a pip package instead. Everything is matching but the memory card
icons part in both DRA and SEL. I still have no idea what the issue is.
Once this PR is good to be merged, we can get rid of the splat fork too.
2024-06-12 18:50:32 +01:00
bismurphy
4ae980706e
Decompile NO3 EntityDeathCutscene (#1309)
As far as the duplicate-finder can tell, this is the last of the
cutscenes, but who knows - we may find more. Luckily, the pattern is
pretty recognizable.

Named it due to what we see at the very end in `case 7`, with the
TimeAttackController getting triggered.
2024-06-12 10:09:19 -07:00
Mark Street
350559c0b8
Update mwccgap (static functions) (#1311) 2024-06-12 09:35:35 -07:00
Jonathan Hohle
77edb0c33e
Decompile Several Similar EntityWeaponAttack (#1300)
Decompiles several `EntityWeasponAttack` functions that were grouped by
the deduper. Many of the variations are subtle - change to how the
subtype is calculated, draw mode, setting sprite bank or not, setting
vars or not.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-11 21:36:26 -07:00
Luciano Ciccariello
b5966cdd58
Batch draws (#1306)
Instead of sending one single draw call, this batches as much calls as
possible. I am supporting the vertex buffer with an index buffer to
minimse how much data is sent to the driver.

The `StoreImage` got some minor boost too.
2024-06-11 21:11:11 -07:00
sozud
fa3ba301c2
EntityRedDoor (#1294)
Done by @Xeeynamo, just integrating https://decomp.me/scratch/z1VlU
2024-06-11 20:38:33 -07:00
sozud
3570cebd2c
EntityNumericDamage (#1295) 2024-06-11 19:26:18 -07:00
bismurphy
8d60f29a10
Decompile NO3 func_801BEDAC (#1308)
A tiny helper function for the cutscenes in the game.

This is a duplicate function. It exists right before every cutscene
function that I've been decompiling, and this one is no different. I
directly copied and pasted it (wow, I'm just like the original SOTN
programmers :D).

Nothing special at all here, I literally just pasted it, never even
looked at assembly, but it matches.
2024-06-11 18:33:41 -07:00
bismurphy
55dad83ad1
Decompile DRE EntityCSMoveAlucard (#1307)
I was asked to help with #556 , but that is an old PR and I'm not sure I
want to be doing a PR into a PR, so here's this one.

I did not touch the code at all, just shifted around the files and such
in order to get rodata to match.
2024-06-11 17:59:39 -07:00
Luciano Ciccariello
aa105d653a
PSP WRP merge warp.c and import bss section (#1303)
Merging `wrp_psp/warp.c` into `wrp/warp.c`.

I imported all the BSS data into `wrp_psp/bss.c`. I do not feel it is
yet the right time to split the bss section into the individual files as
I feel it might have a ripple effect to every other overlay.

I confirm empty arrays on PSX are in data, but on PSP they are in bss.
This is currently forcing me to do some `#ifdef` here and there. It
should get solved once the bss is split into their respective original
files.

I feel very positive about the file split in WRP. So far it seems to be
accurate. I really hope to spread this new pattern to other overlays
too. It should make importing new stage overlays in the future much
easier.
2024-06-11 15:14:50 -07:00
bismurphy
f24865dd96
Decompile DRE EntitySuccubusCutscene (#1304)
Continuing to run the cycle on all these cutscenes.

This one is interesting because it switches on self->params to do
different things - this might signify when the Succubus shows up as
"Lisa", versus after the reveal when it shows up as Succubus. Unsure,
that can be a project for the future.
2024-06-11 14:53:22 -07:00
bismurphy
0dfc016f69
Decompile CEN EntityHolyGlassesCutscene (#1302)
This is very similar to the Maria Cutscene that I recently finished in
NZ0, so I'm doing this one too while the knowledge is still fresh.
2024-06-11 11:41:28 -07:00
Jonathan Hohle
312c8441f5
More Descriptive func_801B9744 (#1137)
This adds some additional context for func_801B9744 and renames globals
to fit their assumed purpose.

Migrated various stream metadata to C definitions.

The makefile changes add a dependency on `sel.h` to all the objects that
get built from the `st/sel` directory.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-11 10:47:59 -07:00
bismurphy
00d07f6a10
Improve NZ0 func_801C3F9C (#1301)
This is an old function which is decompiled, but is messy. It had an
Unkstruct, which I determined to be a variant of the Primitive.
Therefore, we add a new Primitive version to Primitive.h, and delete the
Unkstruct, rewriting this function.

Hopefully decompiling the caller will help to determine what this
function does, as well as what the unknown primitive members are.
2024-06-11 10:27:17 -07:00
bismurphy
6b4fcfff9f
Decompile NZ0 EntityMariaCutscene (#1298)
Wow. This is perhaps one of the hardest functions I've ever done. It
does disgusting things with pointers that I've never seen anything like
before - some of them are the fault of the programmers, some are the
compiler.

Once I was like 98% done, I found func_801B69F8 which is very similar
(and decompiled), but wasn't picked up by the duplicate finder, so that
was a little sad. Once I found that though, the last of my mysteries
were quickly solved.

This is a huge function and it's nice to get it cracked.
2024-06-11 09:38:10 -07:00
Josh Lory
75d5c6a1ba
Decompile DRA EntityPlayerPinkEffect (#1255)
PSX: https://decomp.me/scratch/2YXLH
PSP: https://decomp.me/scratch/yJ6yP

<img width="869" alt="image"
src="https://github.com/Xeeynamo/sotn-decomp/assets/413693/f63e0a63-d48e-495b-9a7f-ec9b3f331720">

After correcting the `PLAYER` and `g_Player` references I have a small
remaining diff, do I need to create symbols for these so they resolve
without dot notation? Also the location of the last `.rodata+0xd8` is
off.

---------

Co-authored-by: Sozud <sozud@users.noreply.github.com>
2024-06-11 07:43:30 +01:00
sozud
9d9661b10f
PSP WRP EntityWarpRoom (#1296) 2024-06-11 05:19:56 +01:00
Josh Lory
b9e9423e9f
Two small ST0 functions (#1297)
One duplicate and one near-duplicate.

`func_801B101C` ([decomp](https://decomp.me/scratch/K87Ql)) is listed as
a 96% match of `func_801B76F0` but it seems to be using a slightly
different Dialogue struct.
2024-06-10 17:04:14 -07:00
Luciano Ciccariello
e685273893
Move WRP data to match C file structure (#1292)
More data imported into the C files. I reached this stopgap due to
`st_debug.c`, where I am failing to import the data from PSP. Strangely
enough, PSP suggests `st_debug`, `e_breakable` and even `warp` being in
the same file?!

The INIT section seems to follow the `PfnEntityUpdates` on both PSP and
PSX. But on PSX this is very close to the top while on PSP is right in
the middle.

Overall the PSX C and DATA order seem to align perfectly. PSP is far
more unpredictable, but the DATA order seem to also follow the C files.
The advantage of PSP is that almost everything is out of order compared
to PSX, which easily suggests file splits.

Another key difference between PSP and PSX is that arrays filled with
`0x00` are found in DATA on PSX and in BSS on PSP.
2024-06-09 21:14:03 -07:00
sozud
f06831aa68
func_psp_09244020 (#1291)
This uses a bunch of functions from PS.ELF so not sure about any of the
structs or stack variables
2024-06-09 12:13:47 -07:00
Jonathan Hohle
2466df633d
Decompile CEN EntityPrizeDrop, EntityEquipItemDrop (#1284)
These are the common implementation. They needed to be split for the
jump tables to be positioned correctly.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-09 17:29:22 +01:00
Luciano Ciccariello
a757bc4288
MAD func_8018E674 (#1290) 2024-06-08 20:29:50 -07:00