Commit Graph

152 Commits

Author SHA1 Message Date
bismurphy
e44d51186b
Decompile Iron Shield func_ptr_80170024 (#1475)
Most important note on this one is that it uses the 0xA0 entity offset.
We already had `shield.unkA0` being used in a different shield. However,
on this shield it's accessed as a half-word, while the other one
accesses as a word.

I looked into it a bit, and realized that the other shield uses it as a
change in Y velocity, and ET_Weapon already uses 0xA0 as an
accelerationY. Therefore, I changed that shield to use ext.weapon for
that entry, and this allows us to change Shields to use 0xA0 as a
halfword.

In general, it looks like shields use a mix of the normal ET_Weapon and
the specific ET_Shield. Maybe we can work out what's what at some point
in the future, especially once all the weapons are done and we can start
truly digging into the purpose of every unkXX value in there.
2024-08-04 20:05:50 -07:00
bismurphy
c71a3dcf83
Decompile Herald Shield func_ptr_80170024 (#1461)
Continuing along. This one was a bit tough to work out with all the gte
transformations, but thankfully we made it work.
2024-08-01 10:38:56 -07:00
bismurphy
3491326b00
Decompile Dark Shield func_ptr_80170024 (#1453)
Yet another one, seems many of these shields are padding out the struct
as we go since we now have an unkA0.
2024-07-29 13:36:48 -04:00
bismurphy
a2ad5683be
Decompile EntityWeaponAttack for all remaining shields (#1450)
This PR is big, but it's because these functions are almost perfect
duplicates of each other. I figured it would make more sense to process
them all at once than to have 9 more PRs for essentially the same
function.

This basically handles the animation of holding up/putting down a
shield, so it makes sense that the shields are all mostly the same.

The differences are with shields that have an effect when something hits
them - this includes the Iron Shield, Dark Shield, and Herald Shield.
Aside from these ones, this function is a perfect copy-paste, only
requiring variables to be renamed. And with those three, it's still the
same function, just with a few lines added to create their special
effect. Search for "hitFlags" to see the effects on Iron and Herald, and
for ext.darkShield to see the madness going on with the Dark Shield.

Please let me know if you'd like this PR handled differently; hopefully
despite the size here, the level of shared code makes it reasonable to
have such a big PR.
2024-07-28 12:06:34 -04:00
bismurphy
47b3b3eb2c
Decompile w58 (Alucart Shield) EntityWeaponAttack (#1440)
Finishing the Alucart Shield.

Noticed we are doing stuff with offset 0xAC which sounds a lot like the
one in the Player entity, so I called it anim for now especially since
it seems connected with animations.

This finishes this shield. I'm going to try to go through all the
shields in the weapon overlays and get them done, they seem like some of
the most complicated since a lot of the shield spells do some kind of
crazy stuff with graphics.
2024-07-26 23:27:03 -04:00
Luciano Ciccariello
99bb97e859
HD WRP matching (#1421)
Mostly identical to MAD and PSP. There are four very different functions
from US that needs to be decompiled to be 100% complete:
* [x] `e_misc.c` `EntityMessageBox`
* [x] `e_misc.c` `EntityRelicOrb`
* [x] ~`e_stage_name.c` `StageNamePopupHelper`~ it does not exist
* [x] `e_stage_name.c` `EntityStageNamePopup`

These four very different functions are the only ones that use the JP
text instead of the US one. This overlay also lacks of `BlitChar`.

`EntityStageNamePopup` is very similar to the PSP counterpart. I used
@joshlory scratch to match the HD part.

`EntityRelicOrb` had some #ifdef between US and BETA (aka the MAD
overlay). I found some code that crossed between BETA and HD, so I just
put an `#else` after `VERSION_US`. We are starting to reconstruct how
the source code originally evolved across different game builds.
2024-07-19 19:05:26 -05:00
Josh Lory
2ec252543a
Decompile DRA EntityPlayerDissolves (#1420)
PSX: https://decomp.me/scratch/6ucWC
PSP: https://decomp.me/scratch/70r4s
2024-07-18 20:57:49 -07:00
bismurphy
f2e4197cfe
Decompile DRA EntityGuardText (#1416)
This brings us down to 3 DRA functions.

Some kind of weird stuff, like PSP using an extra function (I kept the
function forward-declaration in here for reference once we bring in PSP
DRA). It also uses a dedicated struct, so I'm defining that at the
location of the function, to keep it clean.
2024-07-17 13:58:31 -07:00
Luciano Ciccariello
91a0dab64e
e_collect.c adjustments (#1412)
Changelog:
* Import all the PSP WRP data that belong to `e_collect.c`
* Remove the `ext.generic` use in favour of `ET_EquipItemDrop`
* Document some fields from `ET_EquipItemDrop`
* Discover the extra field `mariaSubWeapon` on PSP
* `g_api.AddToInventory` signature changed to allow a better match on
[EntityEquipItemDrop](https://decomp.me/scratch/PULKm)
* Remove the fake array `D_8003BF9C` in favour of `g_CastleFlags`
* The `O_TAG` struct is also valid on PSP
* Decompile `EntityPrizeDrop` on PSP
* Align `func_8018CAB0` to PSP
* Align `EntityPrizeDrop` to PSP with a bunch of `#ifdef`
* Align `EntityEquipItemDrop` to PSP using the WIP scratch
[EntityEquipItemDrop](https://decomp.me/scratch/PULKm)
* `DestroyCurrentEntity` is just an dummy item collector from
`EntityPrizeDrop`
* Duplicate functions in other overlays are not yet aligned as I am
waiting to migrate them to use `e_collect`


I noticed splat is not able to successfully recognise pointers if the
data is too scattered. I had to merge the `data` in the YAML and allow
it to be exported into a single file before starting to import it.

The only missing function from `e_collect.c` is
[EntityEquipItemDrop](https://decomp.me/scratch/PULKm).

Data on PSX are slightly shuffled within the same C file. I believe the
PSP build retains the original data order.

Thanks to @sozud for the majority of the work on `EntityPrizeDrop` and
`EntityEquipItemDrop` on PSP. And thanks to @bismurphy for solving the
last piece of the puzzle to match `EntityPrizeDrop`.
2024-07-17 20:22:31 +01:00
bismurphy
d2db3606a2
Decompile DRA EntityNumberMovesToHPMeter (#1415)
This was decompiled by @joshlory , but due to some annoying rodata, I
ended up taking over the PR on their behalf and submitting. The file
split here was a bit tricky to get right, but now we're matching.

I did not do any reviewing of this code, it is presented here as it was
made by josh's scratch.
2024-07-16 21:27:16 -07:00
bismurphy
d09bbe8596
Decompile DRA EntityPlayerOutline (#1405)
This was EntityMPReplenished, but then I looked into how it is used and
found that it is used for many other things besides replenishing MP, so
I named it more generically.

I think I hunted down every situation where it is used and documented
them fairly well. In general, I think this is a relatively good-looking
function and is easy to read.

Looking forward to seeing any feedback!
2024-07-12 11:05:27 -07:00
Josh Lory
3e7c376143
Decompile DRA EntityStopWatch (#1383)
PSX: https://decomp.me/scratch/eMQyN
PSP: https://decomp.me/scratch/1Ktyt
2024-07-12 00:32:13 -07:00
Josh Lory
b98a3da1bd
Decompile DRA EntityBatEcho (#1400)
PSX: https://decomp.me/scratch/3MCaB
PSP: https://decomp.me/scratch/18Dbq
2024-07-10 20:25:28 -07:00
bismurphy
98c4284a7a
Cleanup NP3 EntityBloodSplatter (#1397)
Another one of these PRs that takes an old function that was decompiled
a while ago, and updates it to today's standards.

We move out of using ext.generic, and we use LOW() and LOH() macros
where relevant.

We also cleanup the logic by using PSP as a guide.

This looks nicer, and is also a great example of lots of LOW and LOH on
primitive members, which may be useful in studying what Primitive might
really be, and whether any of its members (such as the RGBP sets) might
actually be structs.
2024-07-10 14:20:43 -07:00
Jonathan Hohle
2305f1973c
rwrp Decomp (#1398)
Replace 14 ASM functions with common files, duplicates, near duplicates,
or new decomps.

---------

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-07-09 13:25:42 -07:00
bismurphy
d3c209eab9
Decompile DRA EntityPlayerBlinkWhite (#1392)
This is the largest function remaining in the decomp, and now it's dealt
with.

It's a giant beast and I can't claim to be anywhere near understanding a
single thing that it does. Researching this and documenting it will be a
second giant PR. Maybe I'll do that someday, but for now I'll leave it
to anyone else who wants to give it a try. None of the variables have
useful names. We could have "give the variables in this function useful
names relating to how they are used" be a "good first PR" issue, since
we set up several of those a while ago.

Data types on some of the externs it uses have been changed to match how
the function uses them.

This also uses g_PlOvlSpritesheet, which we have found seems to need to
be accessed as a numerical pointer, so I added a #define for that. It
seems to be working, so big thank you to everyone who was involved in
the process of setting that up. I believe this is the first function to
actually make use of that.

Besides that, I'll leave it to others to make their comments. There is
really too much in this function for me to talk about it, but hopefully
this is a reasonable start and we can make whatever tweaks are needed to
get this merged.
2024-07-08 00:54:25 -07:00
bismurphy
9d528eadde
Decompile DRA EntityMist (#1385)
This is a big messy function, but it's decompiled!

Did what I could to rename variables in a useful way, but I could only
get so far. Hopefully one day we can work out exactly what all the
different angles, XY variables, etc are. But this is one of the biggest
remaining functions and it's great to have matching.
2024-07-07 18:24:44 +01:00
Josh Lory
8ec6dcd2d7
Duplicate DRA EntityTransparentWhiteCircle (#1382)
PSX: https://decomp.me/scratch/GW1Hi

Near-duplicate of RIC `EntityShrinkingPowerUpRing` with a few
modifications.
2024-07-06 18:24:06 -07:00
bismurphy
9b6f76da4d
Decompile Karma Coin EntityWeaponAttack (#1375)
Decided to target this one since it's the largest remaining function in
`weapon` and now it's done. Kind of surprising that such a simple weapon
has such a huge function, but I guess it has a lot of graphics and
therefore a lot of primitive manipulation.
2024-07-04 19:28:41 +01:00
bismurphy
cae2cd1030
Decompile heaven sword EntityWeaponAttack (#1370)
Finishes the heaven sword.

More weirdness with the ext - it appears that unk84 is used differently
in different functions within this value.

Overall, this file could use some improvements, but to start out, having
it decompiled is better than not. Hopefully someone can figure out how
this actually all works.
2024-07-02 18:41:22 +01: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
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
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
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
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
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
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
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
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
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
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
bismurphy
a118211c10
De-duplicate EntityUnkId13 (#1270)
In the interest of reducing uses of `generic`, and especially the
`entityPtr` member of it, I found this function which had several
duplicates already, all of which used `generic`. Rather than cleaning it
up in every instance, I decided instead to de-duplicate it, and then
clean it up in the .h file.

I needed to make a new entity extension for this, and noticed that we
had `ET_Entity16`, but then I realized that this was being used for
`g_Entities[16]`, so I renamed that to be `ET_EntitySlot16`, leaving
`ET_EntityXX` available, for XX being the ID of an unknown entity.
2024-06-06 13:34:34 -07:00
Luciano Ciccariello
1df0706a04
Document animation-related code (#1269)
This took a few hours of research spread across a few days. A few
take-aways:

`.ext.weapon.anim` and `.ext.player.anim` are both on `0xAC` and they
NEED to stay aligned since they both call `PlayAnimation`, which
operates on `.anim`. I double-checked `EntityWeaponAttack` and the param
entity is definitively not `PLAYER`, despite `.anim` being in the same
offset. I did not encounter a single `.ext.generic.unkAC` that is not
related to animations, so this can be a pretty strong clue of a pattern.
I have this theory where not all the area of an entity from `0x7C` to
`0xBC` is reserved, but just from `0x7C` to _at least_ `0xAC`, with _at
least_ the last `0x10` bytes are part of a shared struct among all
entities.
```c
/* 0x7C */ Ext ext;
/* 0xAC*/ u8 anim;
[...]
};
```
I want to collect more proof before proceeding to mass-rename
everything.

I learnt what `g_Player.pl_vram_flag` is actually doing. It holds some
kind of state of the player towards the map collision. It holds a bunch
of flags that helps setting the animation. I still feel not confident
enough to create `#define`'s for it until we know more.

All the `condition = ((g_Player.pl_vram_flag & 0x20) != condition)` got
rewritten with the following:
```c
atLedge = 0;
if (g_Player.pl_vram_flag & 0x20) {
    atLedge = 1;
}
```
the `atLedge` adds up to the `anim` function. The animation table
essentially have one ID after the other where the first holds the Anim
ID when the player is not at the ledge and the next one where it is. For
example: `[ANIM_STAND, ANIM_STAND_ATLEDGE, ANIM_ATTACK,
ANIM_ATTACK_ATLEDGE]`.

`D_800ACF4C` and `D_800ACF54` are some kind-of animation helpers when
Alucard either stands still, jumps or falls. I burnt the values in
`stubs.c` while we wait for importing the remaining DRA data.
2024-06-06 20:12:26 +01:00
bismurphy
a744a90c07
Decompile weapon 41 func_ptr_80170004 (#1267)
Another one helped out by PSP :)

Not sure what's going on with the trigtemp and trigresult variables.
They aren't needed on PSP.
2024-06-05 17:26:37 -07:00
bismurphy
9a0ccbe43b
Decompile DRA EntitySummonSpirit (#1264)
This one is a nice surprise to get working! DRA is really getting slim
now.
2024-06-05 13:48:32 -07:00
bismurphy
e62f6c3a64
Decompile weapon 26 func_ptr_80170024 (#1256)
Kind of a crazy one with the way the vectors are dealt with, but
eventually got it to work. Hopefully this can be a nice reference for
some of those SDK functions.
2024-06-04 18:30:04 +01:00
bismurphy
b191658841
Decompile Weapon 27 func_ptr_80170024 (#1234)
I'm pretty sure this has to be the laser beams for the Medusa Shield.
They get spawned by the EntityWeaponShieldSpell.

This function is a pretty big mess. It could probably benefit from a
cleanup pass, potentially using PSP to assist.

But for now, the goal is matching, so hey, this matches :)
2024-06-01 16:50:44 -07:00
Luciano Ciccariello
a221c614be
WRP PSP e_particles (#1227)
Quite a big one. I merged `EntitySoulStealOrb` across all overlays by
normalising the symbol names. The symbol types was all over the place,
so I had to fix that as well.

I solved the s16/u16 ifdef between PSX and PSP. The only part I couldn't
match without a ifdef was `angle = (angle - 1) * 8;` and `angle = (angle
* 8) - 8;`.

I also decompiled the exclusive PSP functions `func_psp_0923AD68` and
`func_psp_0923B2F0` and merged the PSX and PSP `e_particles.c` code. The
exclusive functions required a file split.
2024-06-01 20:32:59 +01:00
bismurphy
ea0134f497
Decompile Weapon 28 func_ptr_80170024 (#1226)
Secondary function for the Skull Shield. Gets spawned by the ShieldSpell
that just got merged.

I also noticed too late that my previous PR reverted the update to
mwccgap since I hadn't updated that; this PR includes a fix to that
accidental revert.
2024-06-01 11:29:15 -07:00
bismurphy
8947665c9d
Decompile Weapon 28 shield spell (#1225)
This one was a beast, but nice to get it working.

This seemed to match the same entity extension as weapon 29. Weapons 28
and 29 are both shields, so I decided to rename the Weapon29 struct to
be Shield instead. We will see if it continues to match for the future
shields.

This had a ton of FIX(), enums, #defines, etc, so hopefully I got them
all :)
2024-06-01 16:23:14 +01:00
sozud
5b82ab061a
EntitySoulStealOrb (#1222)
I'm having trouble integrating the signedness changes but I figure this
gets us closer anyway
https://decomp.me/scratch/R41nc
2024-06-01 10:45:25 +01:00
sozud
4616104152
EntityEnemyBlood (#1208)
Thanks to @dezgeg
2024-05-29 16:39:13 -07:00
bismurphy
c53c0e82b5
De-duplicate EntityBigRedFireball (#1207)
This is an entity that is in every overlay, but appears to be unused, at
least so far.

It looks just like Gaibon's big fireball (in his second form), but that
is handled by a different entity. Presumably we will find its use in a
future overlay.

I also made some general improvements to the function, such as turning
the weird bit shifting into a simple division by 4, thus eliminating the
variables. I also created an entity extension for this entity.

Another victory for my automated deduplicator.
2024-05-28 20:29:41 -07:00
Luciano Ciccariello
8abf48df02
WRP PSP check-in more function (#1189)
The highlight is that `src/st/wrp/st_update.c` is shared across the two
overlays. `EntityMessageBox` and `EntityStageNamePopup` are vastly
different.
2024-05-27 18:47:49 +01:00
bismurphy
86af165e69
Decompile NP3 TestCollisions (#1186)
Well here we are, TestCollisions matching!

I'm going to start with this one, and once it's in, I will follow up by
de-duplicating it.

Please review this closely, especially the changes that are happening in
other files than the main C file.

I suspect we will learn a lot from studying this function; I've already
made some changes (including to the Entity struct) but there will surely
be more.

Nice that this was possible with only two `goto` statements.

I expect a fair bit of revision here, especially related to any
enums/defines I might not be aware of. Please be liberal with comments
:)
2024-05-26 20:30:40 -04:00
Luciano Ciccariello
5362c8b8da
Add ST/WRP from PSP (#1172)
Extract ST/WRP out of #1119 . All the function symbols should have been
cross-referenced. There as some PSX functions missing from PSP and some
new functions from PSP that are not present on PSX (e.g.
`st_init_wrp.c`).

The files `st_debug.c` and `e_breakable.c` are shared between WRP PSX
and WRP PSP. Everything else from PSP is isolated into its own folder. I
had to do some tricks on the YAML config to allow shared code.

`ST_WRP_MERGE = st_debug e_breakable` in the `Makefile` is a bit
annoying as MWCC complains about every single minute detail from the C
source that has been already decompiled for the PSX US build.

`EntityWarpSmallRocks` is matching on PSP but I couldn't extract the
rodata without having a bunch of linker errors. This might be a Splat
issue. I need to investigate further.

`func_psp_09244760` is soooo interesting. The values from `0x11` to
`0x17` matches the Entity IDs that are unique to the WRP overlay. This
aligns to what we have in `typedef enum EntityIDs`.

Overall I am very excited to the recent discoveries from the PSP build!
2024-05-25 11:56:06 -07:00
Luciano Ciccariello
0b9e94c4d3
EntityRedDoor matching (#1167)
Another One Bites the Dust

It matches 1:1 with the PSP counterpart too:
https://decomp.me/scratch/z1VlU
2024-05-24 19:41:07 +01:00