Commit Graph

2576 Commits

Author SHA1 Message Date
Josh Lory
342bdfcdd4
Decompile DRA EntitySubwpnThrownDagger (#1369)
Shout out to @bismurphy for doing most of the initial work on this
match.

PSX:  https://decomp.me/scratch/2GysU
PSP: https://decomp.me/scratch/cjmbN
2024-07-01 19:33:45 -07:00
Josh Lory
472c455b37
Decompile DRA EntityLevelUpAnimation (#1354)
PSX: https://decomp.me/scratch/tedz6
PSP: https://decomp.me/scratch/TWe0Y

Not an exact match on PSP yet. Happy to take another pass if you want
that to also match!
2024-07-01 17:15:18 -07:00
Josh Lory
fd2bc9382e
Decompile DRA func_80129864 (#1364)
PSX: https://decomp.me/scratch/0camu
PSP: https://decomp.me/scratch/g2m4c

The previous version of the PSX decomp.me has some clues to better
variable names but I was having trouble solving the final register
mismatches.
2024-07-01 17:06:55 -07:00
bismurphy
0312a85553
Decompile heaven sword func_ptr_80170008 (#1367)
This one is kind of ugly in places.

It uses offset 0x84 as an s32, while Weapon uses it to hold an entity,
so this forced the creation of a new ext for the heaven sword.

There is only one more function left in this file (EntityWeaponAttack),
so once that one is done, I will move the whole file over to use the
Heaven Sword extension.
2024-07-01 15:37:11 -07:00
bismurphy
8e78845e8b
Decompile heaven sword func_ptr_8017000C (#1366)
Someone in the Long Library discord was asking about Heaven Sword
(especially its special attack) so I'll go ahead and decompile that
next.

This initial function appears to reveal that Heaven Sword doesn't follow
the main Weapon struct. I'm going to keep using it until the weapon is
done, so we can get a better picture of what the mismatching fields are.
All the struct members are the same size, they're just different names.
2024-07-01 19:40:03 +01:00
sozud
e517944ab0
SsVabOpenHeadWithMode Attempt (#1362)
This PR is trying to get SsVabOpenHeadWithMode running, but I'm getting
the wrong result vs. my test app. I'm putting this up to see if others
have ideas.
c7484b6800/test.c (L154)

I check a bunch of preconditions on the test app and the implementation
so I think they are starting from the same state. The test app is able
to play the library song so I think it's OK.

The problem is that SpuMalloc returns the wrong value. See
```
_svm_vab_start[vabId] = spuAllocMem;
```

_svm_vab_start[0] is supposed to be 0x00001010 but instead we get
0x11010.


c7484b6800/test.c (L201)

```
69648 != 4112 in check_ss_vab_open_head_with_mode /home/d/sotn-decomp-2/src/pc/psxsdk/emu.cpp:306
```

The scratch for SpuMalloc is https://decomp.me/scratch/UjIPd

The version here is based off this one since I think that scratch isn't
usable yet.
4ff48d4660/psx_seq_player/lib_spu.cpp (L2462)

The scratch for func_800286E0 is https://decomp.me/scratch/msP8t
2024-07-01 11:23:21 -07:00
sozud
574c61381f
SpuVmFlush, SpuVmKeyOnNow, SpuVmDoAllocate (#1365)
Some of these functions and variables can't be linked against so this
takes an indirect approach to testing by calling SsUtKeyOnV and
SpuVmFlush.
2024-07-01 10:47:58 -07:00
Jonathan Hohle
75752b8878
Speed Up make format (#1359)
After building for all supported architectures `make format` was taking
around 30s. This commit includes various changes which get that down to
around 3½s on the same machine.

This changes the `format` target in a few ways:

  * filters out files generated by CMake
  * runs `clang-format` in parallel
  * breaks `format` into 3 separate targets which can be run in parallel

When building the PC version cmake creates a file to test compiler
features. This file is picked up by the pattern which matches files for
`clang-format`. This file took around 20s, filtering it out brought
total format time to around 10s.

Instead of passing a list created by a `find` command directly as the
args to `clang-format` the list is now passed to `xargs` which runs
several processes in parallel, each looking at 10 files (determined by
experimentation). This has the added advantage of ensuring as the source
list grows `ARG_MAX` won't be a concern. This brought total format time
to around 6s.

`format` was broken up into three targets `-src`, `-tools`, and
`-symbols`. These targets can be run in parallel, bringing the total
time down to 3½s.

---------

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-30 09:26:53 +01:00
sozud
b6eca8f34f
SpuSetKey (#1363)
Doing this one since we will hit it later once SsVabOpenHeadWithMode is
functioning
2024-06-30 01:26:38 -07:00
sozud
7561fc3e67
Implement SpuSetCommonAttr (#1361) 2024-06-29 00:13:42 -07:00
sozud
15d98d5fe1
Libsnd malloc and reverb funcs (#1355)
This makes changes to get SpuSetReverb, SpuMallocWithStartAddr and
SpuClearReverbWorkArea running. We don't have matches for
SpuMallocWithStartAddr and _SpuMallocSeparateTo3 so the current WIPs are
used. A unit test is added to check that these are creating the correct
_spu_memList. Spu write tests are added for the other functions. To
avoid pulling in the DMA controller _spu_t just does the writes itself.
2024-06-28 10:02:58 -07:00
Luciano Ciccariello
26070612b1
Minor fake symbols fix (#1360)
Just minor follow-ups
2024-06-28 17:53:19 +01:00
Luciano Ciccariello
1006c9f044 Fix ST0 header by declaring PrologueScroll 2024-06-28 16:11:55 +01:00
Jonathan Hohle
9f11c4157a
CEN, DRE, MAD, NO3, NP3, RWRP, & ST0 Stage Headers (#1356)
Decompiles stage header data for all in progress stages.

Of note is that NO3 and NP3 (and likely other future stages) use an
`AbbreviatedHeader` because their `SpriteBanks` start immediately after
`UpdateStageEntities`. There are several areas which use
`sizeof(Overlay)` to copy this data over, in those cases sprite bank
data is copied into the tail fields of the overlay but are never used.
2024-06-28 15:11:14 +01:00
Jonathan Hohle
9354d7e5ac
Fix Directory Creation Dependencies in Makefile (#1353)
This updates the Makefile so that targets which depend on phony targets
(like `*_dirs`) have direct dependencies on those targets rather than
relying on transient dependencies from dependent targets. Other targets
explicitly create parent directories for their files.

This resolves #739, making it possible to using make-4.4 to build in
parallel.
2024-06-28 14:23:41 +01:00
Jonathan Hohle
9bf34f1ac2
Decompile PrologueScroll (#1358)
`PrologueScroll` is responsible for scrolling the prologue text
following Richter's fight with Dracula.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-27 19:52:31 -07:00
Josh Lory
6462f2f4eb
Duplicate DRA EntitySubwpnAxeCrash (#1352)
Near-duplicate of `EntitySubwpnCrashAgunea` in RIC.
2024-06-24 11:49:21 -07:00
Josh Lory
16c0b3f174
Extract more DRA data (#1351)
Continuing the work in
https://github.com/Xeeynamo/sotn-decomp/pull/1350.
2024-06-23 22:50:56 -07:00
Josh Lory
077527d0ea
Duplicate DRA EntityHolyWaterBreakGlass (#1350)
I'm not sure if I did the data extraction correctly. There is more to
pull out of the remaining `0x106C8` section but the sizes aren't quite
lining up.
2024-06-23 20:29:17 -07:00
Jonathan Hohle
078ed30c06
Enhance sotn_str & Encode Menu Strings (#1320)
`sotn_str` can now handle escaped quotes, right parenthesis, and more in
in `_S` strings. This allows all of the strings in `dra/menu.c` to be
encoded as static C-strings.

This also converts the spell button sequences to UTF-8.

---------

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-20 13:49:16 -07:00
bismurphy
d45701638f
Rewrite DRA and ST0 gpubuffer function to remove NON_MATCHING (#1348)
Found this function which had a NON_MATCHING.

I'm getting pretty good at finding PSP functions now, so finding the PSP
told me that this was an if-block, not a ternary operator.

PSP also indicated that some of the other lines were using
multiple-assignment, rather than a sequence of individual assignments,
so I made those changes too.

As usual, I don't really know what these do, but it's nice to have pure
matches now.

Now the only functions left with NON_MATCHING are RenderEntities and
RenderPrimitives.
2024-06-19 22:27:46 +01:00
bismurphy
404d5da5bb
Decompile NP3 EntityGaibon (#1347)
This finishes NP3.

Gaibon's logic is extremely similar here as it is in NZ0. There are a
few differences, especially in the initialization code (which runs
before the primary switch), but as a whole, it's a copy-paste.

Slogra and Gaibon are in separate files. The only way we know this is
because they both have debugging `charal` strings which exist separately
in rodata (if they were the same file, it would reuse the same rodata
location for both strings).
2024-06-19 21:51:37 +01:00
Jonathan Hohle
ec593bc0b6
Decompile func_80123B40 (#1334)
Finishes off work originally started by @joshlory.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-19 11:26:59 -07:00
bismurphy
e60babfd8c
Decompile NP3 func_801B3D24 (#1346)
A simple function, but a weird one.

Does a lot of odd stuff with LOW on the x coordinate (and therefore also
y coordinate) of a Primitive.

It's possible that these are weird compiler optimizations (kind of like
the one that does the thing with animation frames on Entities, where it
loads both animation values to compare them), but hard to say for now.
Hopefully with it decompiled, the research to identify what this is
actually doing can come in the future.
2024-06-19 10:13:58 -07:00
bismurphy
19298c784b
Decompile NP3 func_801B32A8 (#1345)
Just an entity function, not clear what it is or how it is created.
2024-06-19 09:40:15 -07:00
sozud
669f46edec
Enable spu init (#1344)
This reworks enough writes to libsnd/libspu to make it through the call
to SsInitHot. Instead of raw pointers we have read/write_16 functions.
The writes are saved to an array so we can test against output from
mednafen. See `src/pc/psxsdk/expected/_spu_init.txt`. The gold file is
generated by running a real psx psy-q program that calls the same
function. A modified mednafen prints the writes. There are reads to
spustat and other regs that require particular values to be returned, so
I've also imported and hooked up the SPU part of mednafen.
2024-06-19 09:37:07 -07:00
bismurphy
3669c6a96b
Decompile NP3 func_801B28E4 (#1342)
Not a very difficult one, but it's a little weird. Not sure what this
entity is, it's modifying the GPU buffers directly, and also setting a
castle flag. No other uses of that castle flag as far as I can tell, so
who knows. Once the overlay is complete we can have the full picture to
figure out where this entity even comes from.
2024-06-18 21:23:59 -07:00
Jonathan Hohle
d5977d931a
Decompile WRP BSS (#1337)
Move BSS definitions to code. This is the last of the ASM configured for
WRP.

---------

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-18 16:01:03 -07:00
Jonathan Hohle
e8922b9fef
Decompile libgs Wrappers (#1132)
`GsInitVcount`, `GsGetVcount`, `GsClearVcount` were all small wrappers
around calls to respective root counter functions using the vsync
counter spec. This provides implementations for all, replacing the
previous ASM imports.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-18 15:45:32 -07:00
bismurphy
63d6f79575
Decompile NP3 EntityAlucardWaterEffect (#1341)
This function is kind of crazy and huge.

I also made its helper static.

The name for the function comes from the fact that the duplicate finder
matched this up with a function in NO3, which had been given that name,
so I named this one to make them match up.
2024-06-18 21:27:54 +01:00
bismurphy
36579d691e
Decompile NP3 func_801C4144 (#1340)
This is a helper function for the entity that comes right after it.

It's relatively simple in terms of functionality, but I have no idea
what it's actually doing, so unfortunately everything is completely
unnamed. At least it matches.
2024-06-18 12:45:30 -07:00
bismurphy
a01b944c2a
Deprecate the use of DECOMP_ME_WIP comments (#1339)
We have now fully decompiled every function which had a DECOMP_ME_WIP
comment, and we do not expect to ever have a need to add one in the
future.

Therefore, the function finder can be simplified by removing the process
of searching for these.

With no DECOMP_ME_WIP strings, `get_c_files` will never append anything
to `files`, so it always returns an empty list. We can therefore remove
the function.

With `c_files` always being an empty list, iterating over it will do
nothing, so we can remove `c_files` and the entire block of `for c_file
in c_files`.

Those are all the changes being made here, pretty simple.
2024-06-18 19:34:57 +01:00
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
sozud
edfd70c70a
Conditionally compile libsnd (#1335)
This makes changes to allow libsnd/libspu to compile when
WANT_LIBSND_LLE is set. If turned on it will immediately crash due to
trying to write to the SPU. A build is added to make sure it's
compiling.
2024-06-18 18:59:51 +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
sozud
e324ea5b92 Fixing PSP function finder 2024-06-17 20:48:29 -07:00
sozud
ef0e199d9a PSP function finder fixes 2024-06-17 16:07:44 -07:00
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