Commit Graph

943 Commits

Author SHA1 Message Date
bismurphy
c5d847c4f7
Decompile NP3 EntityBlade (#1338)
Decompiles EntityBlade. I also pulled Blade and his helpers into their
own file, and then made all the helpers `static` like we're trying to
do.
2024-06-18 19:04:13 +01:00
bismurphy
3f1ba2111c
Decompile DRA menu func_800FB23C (#1336)
This one got stalled a long time ago, so I came back to it. It wasn't
easy, and PSP was compiled with -O4, but I got it, so that's nice :)
2024-06-17 20:57:11 -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
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
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
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
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
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
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
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
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
sozud
a5444e13fa
wrp data (#1289) 2024-06-09 00:09:29 +01:00
bismurphy
d8db435934
Decompile NZ0 EntityLifeUpSpawn (#1288)
Boy, this one was a beast!

It created yet another evil awful horrible variant of Primitive, where
it's referencing several s32 values in the struct, so we had to add
another to Primitive.h.

The splat was slightly off, it was missing the nop at the end of this
function.

It appears that this function manages 385 primitives to make the life
max up spawning animation, and puts them all through a bunch of GTE
functions, so I'm wondering if that's why the animation is so laggy.

I'm confused on why this function doesn't show up in duplicates.txt,
since I would have thought it would be universal across all overlays
which contain a boss (which is most of them). Although... now that I
think of it, Slogra and Gaibon are the only bosses in the overlays that
are currently in the decomp, so that's probably why. CEN, DRE, ST0, NP3,
etc don't have bosses so they don't need to have this entity. Hopefully
this ends up duplicating in the other overlays once those get pulled in.

An awful function, but at least it matches!
2024-06-09 00:02:27 +01:00
Luciano Ciccariello
3c5d5a4c91
MAD quick matches (#1287)
small quick wins
2024-06-08 23:02:00 +01:00
sozud
a9f85a4f85
wrp Overlay (#1286) 2024-06-08 22:29:45 +01:00
sozud
54bbad0db7
Wrp data (#1285)
Going to do a few files
2024-06-08 22:19:37 +01:00
Luciano Ciccariello
7a5baed841
Share more code and data between stage overlays (#1281)
Given the fact that sharing compiled C objects is not exactly possible
(code heavily copy&pasted maybe? this initiative is now abandoned 👉
53a566f075)
I decided to keep pressing forward with shared headers. Thanks a lot to
@hohle for making our life much easier by cross-referencing symbols.

The file split on WRP seems to be the closest file split we might have
compared to the original source code (still speculating here). I think
it would be a good idea to start splitting other overlays too with the
same approach.

My idea is to have a file split like the following:

```
st/
   cen/
       e_particles.c
       e_misc.c
       st_common.c
   nz0/
       e_particles.c
       e_misc.c
       st_common.c
   wrp/
       e_particles.c
       e_misc.c
       st_common.c
   e_particles.h
   e_misc.h
   st_common.h
```

each of those C files will just be a one-line `#include
"../the_shared_code.h"` as usual. Right now we create individual headers
for single functions, sometimes for more than one function when we think
grouping makes sense. But I think we can start merging some of those
headers and consolidate the code. This can be done gradually. For
example `src/st/e_particles.h` is still importing function headers under
the hood. That is okay for now, but later on I wish to import those
headers functions into their respective parent headers.

Another important aspect to consider that will validate a correct file
split is to start importing the data inside these new C files. Right now
we have floating data such as `src/st/wrp_psp/wrp_data_EA00.c` or
monstrosities such as `src/st/wrp/6FD0.c`. An example of a (possibly)
correct migrated data is what this PR does with WRP PSP and NZ0 PSX,
with data pointing in `src/st/*/e_particles.c`.
2024-06-08 20:34:58 +01:00
bismurphy
93cadd8077
Decompile NZ0 EntityBossFightManager (#1283)
A few changes here.

First, Slogra needs to be split out to his own file, as mentioned in my
previous PR.

I decompiled EntityCloseBossRoom, but I decided it needed a better name,
since, while it does close the door to the boss room, it actually does a
lot more and in general manages the fight (most importantly, it starts
the fight, spawns Slogra and Gaibon, and when they die, spawns the life
max up). Therefore I named it BossFightManager. Since this function, and
the door blocks it spawns, are the only ones in this file, I decided to
call it bossfight. I think we should try to be liberal with naming
files, once we know all the functions contained in them.

Otherwise I think that should do it! Very cool to have the first boss
fight in the game all figured out.
2024-06-08 16:22:29 +01:00
bismurphy
212962df08
Decompile NZ0 EntityGaibon (#1282)
This was great to get working!

There was a Decompme WIP, but I decided to ignore that and do it from
the beginning, and I think that worked out well. PSP was of course very
helpful.

This ended up being pretty readable with all the steps that were already
documented (I think that was Sonic's doing, so thanks!). Pretty happy to
have this working!

Slogra and Gaibon each have a separate `FntPrint("charal %x\n",
self->animCurFrame);` call in their debug step. Importantly, this string
is in rodata in two places. If Slogra and Gaibon are in the same file,
they share the same string address, and the rodata only gets the string
in one place. Splitting the files restores the duplicated string in
rodata, meaning that these files need to be split.

I have already decompiled EntityCloseBossRoom and found the same issue
there, so my next PR will end up pulling out Slogra into his own file as
well.

Lots of code here, review carefully!
2024-06-08 15:27:11 +01:00
sozud
1d212a3f4d
PSP WRP EntityWarpSmallRocks (#1279) 2024-06-08 12:22:10 +01:00
bismurphy
b9328aa9b3
Decompile DRE Entity3DBackgroundHouse (#1278)
This one was fun! Lots of use of the coordinate transformation
functions, and lots of weirdly packed data.

Had to shift the splat a little bit. This is the last function in the
file (location-wise, not the last to be decompiled) and the end of the C
segment was slightly off.
2024-06-07 14:23:17 -07:00
Mark Street
aff2a634a7
Update mwccgap (basic rodata support) (#1276) 2024-06-07 10:14:08 -07:00
Jonathan Hohle
0561f4d100
"Decompile" CEN Functions (#1274)
Several of the remaining ASM functions in CEN which already have
implementations in other stages.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-07 10:10:59 -07:00
Jonathan Hohle
267d697350
Refactor Entity Explosion (#1273)
Pulls out `EntityExplosion` into a common file.

`cen` and `rwrp` appear to have not imported a declaration for
`AnimateEntity` and call it as an undeclared function with a int-sized
return value. Since `AnimateEntity` is declared in the same compilation
unit a workaround is done to fix how the return value is interpreted.
2024-06-07 01:19:52 +01:00