Commit Graph

818 Commits

Author SHA1 Message Date
Luciano Ciccariello
aa6c5692fb
More TT_000 PSP functions matching (#1115) 2024-04-23 20:06:05 +01:00
Luciano Ciccariello
bb21cb6f47
Un-fake some previous matches for the psp build (#1114)
This improves the function readability from the already decompiled PSX
functions. Since the PSP build is compiled with `-O0`, the statement
order is much clearer. Even `if (entity->facingLeft != 0)` and `if
(!entity->facingLeft)` produces different output on the PSP build. I was
able to remove a couple of temp variables too.

---

There are a few functions I cannot match due to a trailing `nop` at the
end of the function. It looks like the overlay have functions aligned by
`8`. I do not know how to trigger that using MWCC or if it is a linker
thing. Two functions that have this problem are `DestroyEntity` and
`func_801746A0`.


![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/754fe1ef-5d2d-4b86-a3fb-736a8058347d)
2024-04-21 11:38:10 +01:00
Luciano Ciccariello
791e321b43
Add TT_000 overlay from PSP (#1113)
TT_000 is the first overlay from PlayStation 1 that we are now able to
compile from the source and produce a 1:1 binary. This lead me to start
exploring the same overlay from the game Castlevania: Dracula X
Chronicles, which contains a PSP re-build of Symphony of the Night.

This PR adds all the infrastructure to add the same flow for a PSP
matching decomp. Use `export VERSION=pspeu` and then the usual `sotn`
command to splat the overlay, build it and check if it matches. Running
`make extract_disk` should not be necessary as the same ISO used from
`VERSION=hd` is also used for `pspeu`, so you will probably have it
extracted already.

Some important notes about the PSP build:
* The whole PSP build seems to be compiled with `-O0`, which makes it
much easier to decompile
* Having ŧhe PSX, PSP and Saturn builds will allow to easily
cross-reference the code and reduce fake matches
* `disks/pspeu/PSP_GAME/USRDIR/res/ps/hdbin/tt_000.bin` is the HD PSX
build
* `disks/pspeu/PSP_GAME/USRDIR/res/ps/PSPBIN/tt_000.bin` has the same
code from the HD build, but for PSP
* `disks/pspeu/PSP_GAME/USRDIR/res/ps/PACK_E/TP00.BIN` is the same as
above, but it packs both overlay and graphics. This is the file the PSP
game seems to actually use
* The PSP build uses the Metrowerk CodeWarrior's C compiler, which is
very different from the GCC one used on PSX.
* Thanks to @mkst lead, we found a way to still use the GNU assembler
and linker
* MWCC uses [wibo](https://github.com/decompals/WiBo/), a think
compatibility layer to run Windows CLI tools on Linux. It is much more
lightweight than Wine.
* MWCC does not support the `INCLUDE_ASM` dialect, so the custom
pre-processor `tools/mwcpp` had to be created
* The exact MWCC compiler version is unknown, but I suspect it is `build
147`
* I am not yet sure of any implications for using GNU AS and GNU LD
instead of the MW correspondent tools
* Not all the functions can be correctly disassembled, spimdisasm will
just produce a bunch of `.word 0x________` due to the in-progress effort
of adding the Allegrex-specific opcodes support

---

TO-DO list before marking the PR as ready:
- [X] Add PSP build to the CI
- [x] Add progress reporting to the PSP build
- [x] Integrate source file from `src/servant/tt_000_psp` to
`src/servant/tt_000` to promote the psp build as first-citizen

---

TO-DO in a follow-up PR:
* Figure out what `header` is: can we extract it as assembly code? or
maybe as custom re-compilable asset via splat? Is it a MW stuff or a
Castlevania-specific file?
 * Get rid of the last line in `Makefile.psp.mk`
2024-04-21 02:18:10 +01:00
Luciano Ciccariello
9e7e87eaac
Add TT_000 from the HD version (#1111)
100% decompiled.

`US` adds some padding to have the file exactly 40KB long. The HD
version does not add any padding, hence why I ended up producing
`tt_000_raw.bin`. I would have used just `tt_000.bin` as a name as found
in `disks/pspeu/PSP_GAME/USRDIR/res/ps/hdbin/tt_000.bin`, but on
Windows-based file system it would collide with `TT_000.BIN` due to the
OS having case insensitive names.

I modified `make clean` as I found annoying that `VERSION=hd make clean`
would wipe out `us` build stuff.

The only different function in HD is `ProcessEvent`, which has a weaker
check. Another hint suggesting HD being older than US.

`s32 _unused[26];` added enough padding in the bss section to get an
🆗 . I am pretty sure it is unused data because the final binary is
not aligned by any power of 2.
2024-04-04 22:28:57 +01:00
Luciano Ciccariello
cd71d838cb
TT_000 import BSS section (#1110)
I had to cherry-pick the following PR on our splat fork:
https://github.com/ethteck/splat/pull/305
2024-04-03 23:26:07 +01:00
bismurphy
2bd1a44f4e
Decompile ST0 EntityDraculaFinalForm (#1058)
Big thanks to @mkst and @Xeeynamo for looking into my rodata issue on
this one! Still not sure why it worked the way it did but glad we got it
working and we can now get this function in.
2024-04-02 21:56:14 +01:00
Tuomas Tynkkynen
e6046aa106
Correct the split of libapi/l10.c (#1099)
Correct the split of libapi/l10.c and decompile few trivial functions in
it.
2024-03-14 15:57:27 -07:00
Luciano Ciccariello
c5159842c5
DRA func_8010DA70 (#1095)
Thanks to the anonymous person who managed to match the last part:
https://decomp.me/scratch/3mKBR
2024-03-07 22:19:44 +00:00
sozud
af23477a11
_SsSeqPlay (#1092) 2024-03-04 19:36:00 +00:00
Luciano Ciccariello
b81f2c557a
DRA HandleGameOver (#1086)
Solves an annoying fake match that made the US version to match but not
in the HD version. Special thanks to @Gillou68310 for figuring out the
right switch/case pattern!
2024-02-25 22:14:00 +00:00
Mark Street
3bda9c043f
Migrate rodata to functions for dra (#1084) 2024-02-25 17:44:11 +00:00
Luciano Ciccariello
3897106248
DRA func_800F1D54 (#1083) 2024-02-24 22:55:13 +00:00
Luciano Ciccariello
ff06ca54f8
DRA func_800F1B08 (#1082)
Don't get fooled by the size of this function. I struggled more than I
thought I would. I think it generates the map bitmap but I am not yet
sure. There is a lot that I still do not understand of how the map gets
filled while walking through the castle. I do not even know how
partially explored maps work (e.g. when you get the Castle Map 1 or 2
from the Librarian but you do not actually pass by those unexplored
areas). I would like to wait to know more of the logic here before
documenting.
2024-02-24 22:04:26 +00:00
Mark Street
dfc74d4acd
Migrate .rodata to functions for main.exe (#1078)
I feel like getting all the rodata migrated will make it easier to
update splat (also makes it easier to match functions that use rodata).
2024-02-24 11:35:01 +00:00
Luciano Ciccariello
05e0334de3
DRA DrawMapCursor (#1079)
![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/e3b9b89c-6a6b-49a9-8804-b0f49da6dc79)

This thing here. Special thanks to @sonicdcer who helped me on the final
reg swaps!

I renamed `D_8003C104` as `g_ClutIds`. I am not a fan of the name, but
it gets used by `poly->clut = g_ClutIds[xyz]`, the function that
populates the table is called `GetClut` and the [official
docs](file:///run/media/xeeynamo/wd_black/SDK/sony_ps1/psyq_sdk/DOCS/LIBREF46.PDF)
mentions _Calculates and returns the texture CLUT ID_ . So that seems to
be the most appropriate name.
2024-02-23 16:14:38 -08:00
sozud
3810fbd2c3
_SsSetControlChange (#1074) 2024-02-21 23:23:15 +00:00
Luciano Ciccariello
2b3610c336
DRA func_800F24F4 (#1073)
A relatively small but complicated function. I matched it by decompiling
from scratch while taking some inspiration from an old scratch made by
@sonicdcer
2024-02-20 13:43:00 -08:00
sozud
cbf9f780d7
SpuVmInit (#1069)
Thanks to @Gillou68310
2024-02-19 11:23:05 -08:00
Luciano Ciccariello
d6dd9f1891
DRA Import some data in 7E4BC (#1068)
Some data belong to `7A4D0.c` but I had to import to `7E4BC.c` instead
due to the `factory_blueprint` getting extracted in the between. I think
in the future those JSON assets need to generate C files.
2024-02-18 14:24:03 -08:00
Mark Street
dd7d4b83d1
weapon rodata migration (#1067)
this is a step along the way to getting splat updated, but im not there
yet :)
2024-02-18 12:02:02 -08:00
Mark Street
41ad71e388
Pass undefined_syms files to linker (#1065)
Creating a PR for this, will look at updating splat in a separate PR
2024-02-18 14:57:03 +00:00
sozud
f4e7805417
_SpuIsInAllocateArea_ (#1064) 2024-02-18 10:51:57 +00:00
sozud
276e8840f4
Spu note2pitch (#1062) 2024-02-17 13:49:11 -08:00
Luciano Ciccariello
d4453b3340
DRA func_801309B4, func_80130E94, func_8013136C (#1063)
Completes `90264.c` with the exception of the BSS section.

After this PR I am thinking to either decompile and move
`func_8012F178`, `func_8012F83C` and `func_8012F894` into `90264.c` as
they all follow the same pattern, or move back `90264.c` before the
split back into `8D3E8.c` as all the code seem to be related to the wolf
form.
2024-02-17 11:18:26 -08:00
Luciano Ciccariello
de51521ac6
DRA func_80130264 and func_80130618 (#1060)
As per title.

`#if !defined(VERSION_PC) && !defined(M2CTX)` allows
`tools/decompile.py` to work on files where the GTE instructions are
used. Otherwise it wouldn't normally work.
2024-02-15 12:44:01 -08:00
sozud
97e07c61d8
SsUtKeyOff SpuVmKeyOff (#1059) 2024-02-15 00:19:10 +00:00
sozud
6eb5b40e60
_SsClose (#1057) 2024-02-13 23:53:08 -08:00
Ross Squires
2294523fcc
Decomp CD_set_test_parmnum, CdReadCallback, & CdLastPos (#1056) 2024-02-11 11:33:03 -08:00
sozud
34185eebfa
Libsnd libspu 5 (#1050) 2024-02-10 11:06:42 +00:00
bismurphy
a33f88b0ca
Decompile ST0 func_801AF774 (#1048)
Big function, does a bunch of stuff with DRAWENV which is neat.

Had to create an inline for addition, otherwise all my `lh` instructions
were becoming `lhu`. Maybe there's a better solution, I'm not sure.

This is going out to a new file due to weird rodata stuff, I'm hoping
decompiling EntityDraculaFinalForm (which I have a working scratch of)
will allow everything to settle into place, but we'll see.
2024-02-08 18:14:50 -08:00
sozud
f7f634a10a
Libsnd sync 2 (#1047)
ssvkoff/on have the wrong filenames, we know this because the libraries
have the filenames embedded in them.
2024-02-09 00:28:13 +00:00
sozud
84871534cb
Fix some libsnd symbols (#1042) 2024-02-06 23:18:57 +00:00
bismurphy
fc78c026e5
Decompile ST0 func_801ABBBC (#1041)
First function of my new effort to make progress in ST0.

There's a fun bug in case 5 where they forgot to increment their prim.

This required the creation of a new variety of Primitive, since there's
strong evidence of an `f32` at offset 0x20. For now it's
draculaPrimitive, but maybe we'll find more uses of it in the future.

I think those are the main highlights. No pressure to merge this one
quickly, I'm expecting progress on ST0 to be slow.
2024-02-06 23:01:05 +00:00
Luciano Ciccariello
6011e02320
DRA RenderEntities (non matching) (#1034)
Another disappointing non-match, even closer than #1008 . There is only
one registry swap in one single line. I've been permuting for a day
without success. Putting this here if anyone wants to give it a try:
https://decomp.me/scratch/AuSvv
2024-02-06 10:54:35 -08:00
Luciano Ciccariello
62f28078c1
Remove overlapping symbols (#1040)
There were some symbols overlapping with the `g_Entities` array. By
fixing them I also de-faked `func_801B519C`. I included the removal of
`g_api_AllocPrimitives` too as I did not see much point of doing it in a
separate PR.

I am still unsure of the size of `g_CastleFlags` and unfortunately I
doubt it will be clearer before start decompiling new stage overlays.
2024-02-06 18:45:17 +00:00
Luciano Ciccariello
5f3c92dc72
DRA import 627C4 and 63ED4 data (#1037) 2024-02-05 23:39:41 +00:00
Luciano Ciccariello
78953c01aa
Allow spritesheet to be extracted from the CLI (#1035)
A side-project I've been working on that helped me understanding some
structures that are now a bit better documented in #1034 . Richter
sprites are extracted as usual. Doing `python3
tools/splat_ext/spritesheet.py decode disks/us/BIN/ARC_F.BIN assets/arc
alucard disks/us/BIN/F_GAME.BIN 1` can extract Alucard sprites too.
There is no repacking yet as I want to avoid using splat for this one.
2024-02-05 21:57:48 +00:00
bismurphy
a11a4096b6
Decompile RIC func_8016DF74 (#1033)
Big file shuffle to get this one working, but it works!

I have now made some degree of attempt at every function in RIC. Now we
circle back to finish the hard ones!
2024-02-04 22:24:26 +00:00
bismurphy
c3acea5f04
Decompile RIC func_8016D9C4 (#1032)
Required splitting to a new file.

Yet another instance of PRIM_LINE_G2 using its own type of Primitive,
which is neat.

Also resolved another member of that primitive. This is getting wild!
RIC is so close!
2024-02-04 21:06:27 +00:00
bismurphy
053fabffed
Decompile DRA and RIC EntityAguneaHitEnemy (#1030)
This one was pretty complicated but I'm glad I got it working. Not
completely certain what this does but good enough for now. The two
functions are even more similar than DRA and RIC functions usually are.

For any comments to be made, feel free to only comment on one of the two
instances and I will make the change on both.
2024-02-04 18:27:07 +00:00
bismurphy
40c41d9a08
Decompile RIC EntitySubpwnAgunea (#1029)
Another one very similar to a DRA function.

Noticed the DRA one still had a placeholder `func_` name so I've also
renamed that.
2024-02-03 22:10:18 +00:00
Ross Squires
e2c5cdf45c
Decomp RWRP func_8018EC10 (#1026)
howdy bit cowboys
2024-02-03 10:43:42 -08:00
bismurphy
d9d4560317
Decompile RIC EntitySubwpnCrashCrossParticles (#1022)
Did the DRA version of this a while ago, now here is RIC. Very little
overlap, generally speaking, which kind of surprises me. Anyway, more
progress on RIC!
2024-02-01 20:00:06 -08:00
bismurphy
042d989ba1
Decompile DRA and RIC EntityHolyWaterFlame (#1021)
The arrays on the stack are weird. Couldn't have solved them without
@ser-pounce , thanks again for yet another function of collaboration!
2024-02-01 17:35:32 -08:00
bismurphy
dc50ebb9b3
Decompile RIC func_80166784 (#1020)
This monster is finally done thanks to the assistance of @ser-pounce .

Really not sure what any of this logic is for, but there you go. Great
to have more collaboration happening!

------------------
Co-authored-by: ser-pounce <ser-pounce@users.noreply.github.com>
2024-02-01 22:08:10 +00:00
bismurphy
387164b7d9
Decompile RIC EntityCrossBoomerang (#1019)
Tried to comment this one pretty heavily since it's a relatively more
comprehensible function than usual.

Otherwise nothing too special or surprising here. I'm surprised at how
case 1 works though, I wonder what condition it's actually testing for.

Oh, and there was one pesky fake variable in there, but it's not too
egregious. It's in case 5.
2024-02-01 10:31:17 -08:00
bismurphy
b2e2c78f7c
Decompile RIC EntityRichterRevivalColumn (#1018)
This is the entity that runs when Richter dies in the prologue, gets
revived, and makes a glowing white pillar effect out from his body. You
can see it at 1:33 here: https://www.youtube.com/watch?v=7_RhQR3aQ_0

It is extremely similar to the column that appears when the cross
subweapon crash is used (visible at 1:15 in the same video), but lacks
the screen-filling giant white flash that comes after. A huge amount of
the code is copy-pasted between these two entities, even the `one` and
`three` variables from the cross entity that was just merged.

It's hard to come up with a good descriptive name for this, but I think
this one is at least good enough.
2024-01-31 18:21:34 -08:00
bismurphy
8649c7bb1a
Decompile DRA and RIC EntitySubwpnCrashCross (#1017)
Similar thing to what I've had a lot of lately - I decompiled the RIC
version, then went through the process of cross-referencing RIC and DRA
to identify the duplicate function. There are a fair number of
differences between these, so it wasn't super straightforward to go from
the RIC match to the DRA match.

There's a lot of weird stuff in these, especially the "one" and "three"
variables. Probably some weirdness that I didn't quite write the same as
the original, but a match is a match.

Scratches here if you'd like to take a crack at any of the weird junk.
RIC: https://decomp.me/scratch/rRANW
DRA: https://decomp.me/scratch/jWF5h
2024-01-31 23:30:18 +00:00
bismurphy
c2efce5a9a
Decompile RIC EntityHolyWater (#1016)
There is already EntityHolyWater in DRA, but this one is quite different
(which makes sense, because Richter's is very different in behavior from
Alucard's). Still, there are some small overlaps here and there.

Due to the ongoing failure to match `func_80166784` (the previous
rodata-using function), this is being split out to a new file, even
though I'm pretty sure they're supposed to be in the same file. We will
reunify the files once `func_80166784` can be solved.

There is a function which is identical in the overlays, and is only used
by this function. I have gone ahead and named it identically in both
overlays.
2024-01-31 01:14:14 +00:00
bismurphy
4c4c570ef0
Decompile DRA DrawRichterHudSubweapon (#1013)
This one was tricky and required some restructuring of an area of
memory, but it matches now, so that's cool!

No big comments from me but this one has a lot of random stuff so let me
know if I missed some enum or something!
2024-01-29 16:17:29 -08:00