Commit Graph

922 Commits

Author SHA1 Message Date
Jonathan Hohle
703bf35fc3
Replace FLAG_UNK_800000 with FLAG_HAS_PRIMS (#1572)
Finishes the migration from `FLAG_UNK_800000` to `FLAG_HAS_PRIMS`.
2024-08-24 19:18:44 +01:00
Luciano Ciccariello
9112ccc88c
RIC: add more documentation (#1569)
I documented all the `PLAYER.step` for Richter and got the meaning of
most of the functions with their parameters. There are some additional
renaming and magic numbers documented that are not worth to mention
individually.

I plan to get rid of `EntityTypes` as it is not sustainable to document
256 combination of entities. Instead I am thinking it would be a better
approach to document the `g_Entities` indices as ranges. For example
from `32` to `47` we have particles, from `48` to `64` we have player
entities that can hit the stage entities and so on.

I re-organised and re-imported some of the data close to the function
that use them. This will allow me to later split entities into their own
units as separate C files.
2024-08-24 09:57:53 +01:00
bismurphy
7ab54b9cce
Eliminate ext.generic.unk88 (#1564)
Gradually removed each use of this variable, now the last one is gone so
it's removed from the ext as well :)
2024-08-22 19:02:05 +01:00
bismurphy
a11c22adef
Decompile ST0 func_801BD8F0 (#1563)
In addition to decompiling the function, two big changes were needed:

- Decompiling this function uncovered a maspsx bug with generating `nop`
padding instructions; that is now fixed and this PR includes a maspsx
update.
- We also discovered (thanks @mkst !) that g_Tilemap.bg was not actually
a member of g_Tilemap. I renamed it to g_BgLayers, and did a
find-and-replace across the repo to change all references. This appears
to have no impact on any existing function, but leads to the correct
register loading on this function.

It's a weird one, and was tricky to get matching (actually, this was a
super old decomp.me browser tab I discovered was still open, which is
why I came back to it), but these tricky ones are great for discovering
where we have mistakes in our structure of the game's data.
2024-08-22 18:19:49 +01:00
bismurphy
5ce562a3ed
Modernize NZ0 skeleton enemy (#1560)
This one was already pretty good, but mostly needed to have
`ext.generic` removed.

I noticed the structure of this file is identical to e_bone_scimitar, so
I decided to change the bone scimitar to use this Skeleton `ext` since
the skeleton is a more generalized enemy. Now that we see two enemies
both using this one, this almost looks something like object
inheritance, if that were a thing that existed.

So far NZ0 is the only overlay with the skeleton enemy, but I'm sure
once we pull in other overlays we'll find more skeletons all over. Then
this will be a .h file, but for now it's a normal .c file.
2024-08-22 18:18:35 +01:00
Josh Lory
ab5966e75c
Decompile func_ptr_80170004_w_006 (#1561)
https://decomp.me/scratch/Gwx79
2024-08-21 22:43:49 -07:00
bismurphy
55744a1f93
Lots of updating on NZ0/311C0.c (#1558)
This file was all decompiled, but overall had a lot of "old-looking"
traits to it. I went through and updated it in many ways. All the
functions are now named with real names (no `func_whatever`), several
constants are used in different places, I've added names to the list of
entity ID numbers in the .h file, etc.

One thing of interest: I went through starting to document the `.ext`
members, and noticed that they seemed to "keep away" from each other,
even across unrelated entities. Therefore, at least for now, I decided
to create an experimental `ext` which covers all the entities that
needed defining in this file. Maybe down the line we can split them up
to their own individual entities, but I find it interesting that some
entities use the unk80, unk84 offsets, while others only use unk88. I
don't see why you would skip to unk88 unless unk80 and unk84 were taken,
and the only way they're taken is if they share ext members.

The big thing is that nothing uses generic anymore. It looks like this
file was from the era when we were trying to use generic for everything
so there is lots of ugly casting, but that's all gone now, which is
nice.
2024-08-21 21:07:13 +01:00
SestrenExsis
283538a313
Rename unknown members of Zombie Spawner struct (#1557)
A minor PR that only aims to give a meaningful name to two of the
unknown variables in the `ET_ZombieSpawner` struct:
- `spawnDelay`: Number of frames until the next time the Zombie Spawner
will attempt to spawn another zombie
- `spawnSide`: Which side of the player the Zombie Spawner will attempt
to spawn the next zombie (zero for left, non-zero for right)
2024-08-20 23:51:47 -04:00
Jonathan Hohle
959ebe41ac
Update Symbol Name, Size Comment (#1553)
Renamed `PLAYER_ext_generic_unk7C` to `PLAYER_ext_player_anim` since we
know the player entity is being referenced.

Added a size comment to `WeaponAnimation` to help me find it next time
I'm looking for an `0x10` sized struct.
2024-08-20 18:21:16 -04:00
Josh Lory
c22cd8f9c7
Decompile func_ptr_8017000C_w_030 (#1545)
https://decomp.me/scratch/uusD5
2024-08-20 14:56:39 -07:00
bismurphy
bac0e55cd2
Modernize NO3/NP3 Bone Scimitar (#1551)
NO3 and NP3 had a weird mix of Bone Scimitar functions where each was
partially complete and missing different parts.

Now both are complete and modernized. Could use another pass to make it
PSP-matching, but for now I'll leave this one at this point where the
code seems nice.
2024-08-20 12:23:51 -07:00
Josh Lory
a62e1052e7
Finish two related files: w_012 and w_034 (#1549)
* https://decomp.me/scratch/h62LS
* https://decomp.me/scratch/FhCre
* https://decomp.me/scratch/N3tj5
2024-08-19 22:00:58 -07:00
bismurphy
d6eccc923d
Make ext.zombieSpawner for EntityZombieSpawner (#1547)
An old one that was using `generic`, easy swap to bring it up to have
its own dedicated `ext` member.
2024-08-19 20:56:22 -07:00
sozud
62857572c6
Improve sfx docs (#1540) 2024-08-19 23:01:59 +01:00
bismurphy
b9dab230fd
Update EntitySurfacingWater and ext.waterEffects (#1544)
Next one in my progress of removing `ext.generic.unk88`. This one is
duplicated two places; once we have NO3 and NP3 matching it will be cool
to de-duplicate them and see how many differences are actually left.
2024-08-19 10:42:22 -07:00
SynaMax
1bc839af1a
First group of vabID 0 sfx complete (#1542) 2024-08-18 21:29:24 -07:00
Josh Lory
569e9450b9
Decompile func_ptr_80170010_w_030 (#1541)
https://decomp.me/scratch/TPASg
2024-08-18 18:21:56 -07:00
bismurphy
e37ebe715b
Improve EntityWargExplosionPuffOpaque (#1538)
Main changes here involve renaming the Ext member from `et38` to
`wargpuff` which seems more descriptive.

Also added entity ID numbers across the overlays, to be used in the
function right before the warg puff function, which spawns the warg
puffs with a call to `CreateEntityFromEntity`.
2024-08-18 14:38:58 -07:00
bismurphy
7f176c3f1e
Eliminate remaining uses of ext.generic.unk8C (#1537)
My last few PRs have been targeting `ext.generic.unk8C` and removing
them one by one. This finishes the job. Next I'll start digging into
`unk88` :)
2024-08-18 19:17:28 +01:00
bismurphy
506d76280d
Modernize NO3 cavern door code (#1535)
Lots of little changes here. Getting away from using `ext.generic`,
using various enums/macros, using `prim` instead of `POLY_GT4`, making
variables have useful names, etc.

Also, these  functions both match on PSP now.

One interesting thing is that these functions don't overlap in their use
of the `ext`, so I had them share one. Kind of interesting.
2024-08-18 16:09:18 +01:00
Luciano Ciccariello
991d839291
Enforce ext.*.anim alignment (#1534)
`#ifdef` ugliness, but there is not much we can do if some of the `ext`
structs use 64-bit pointers. With _Static_assert we can ensure, at
compile time, that structs are aligned for `g_api.PlayAnimation` to work
correctly.

I removed a bit more of `ext.generic` here and there too.

cc. @bismurphy our weapon blacksmith xD
2024-08-18 14:03:35 +01:00
sozud
3ad9c50b71
Document some sfx variables (#1533) 2024-08-18 01:49:32 -07:00
bismurphy
0dddb4bed8
Improve some TT_000 code quality (#1532)
- Rename func_801733D4 to BatFamiliarBlueTrail
- Add PSP symbols for several various variables used in `func_80172120`
- Attempt to get `func_80172120` closer to matching on PSP. Almost got
it but not quite working; this is at least an improvement. Scratch:
https://decomp.me/scratch/QBytP
- Create `Ext` for BatFamiliarBlueTrail; all it uses is the parent which
is the same as Factory, but still better to have its own until we know
the real situation for entities.
- General commenting to make flow of functions clearer.
2024-08-18 09:38:13 +01:00
Jonathan Hohle
dc92c84193
Port EntityMerman & EntityMerman from NP3 to NO3 (#1529)
Copied the `EnttityMerman` and `EntityMerman2` implementations from NP3
to NO3. These are identical, however, rely on too many things which
require renaming to share at this point.

NO3's `EntityMerman2` was previously `EntityMerman3`, but is identical
to NP3's Merman2, so it was renamed to match.

A small amount of cleanup was done to the implementations to bring them
closer to current standards.
2024-08-17 11:41:47 -07:00
sozud
4f78ac7675
Document ANIM_FRAME_LOAD (#1523)
I don't think this is the same as ANIMSET_OVL_FLAG, see RenderEntities.
2024-08-17 11:02:56 -07:00
SynaMax
2bfd6cb6f9
Updated sfx script symbols (#1528) 2024-08-16 23:25:36 -07:00
SynaMax
03b1059c1a
Renaming func_80134714 to PlaySfxVolPan (#1527) 2024-08-16 14:22:08 -07:00
Jonathan Hohle
ec33f90170
Rename Entity unk4C to anim (#1522)
`unk4c` is used to store a reference to the entity's current animation.
Renaming the field to `anim` match the purpose.
2024-08-16 16:11:14 +01:00
Josh Lory
6c4e63fd12
Finish w_046 and import data (#1511)
https://decomp.me/scratch/dKGxs
https://decomp.me/scratch/YGyQp
2024-08-15 14:36:06 -07:00
bismurphy
899226c3c3
Document RIC Vibhuti crash cloud (#1517)
Got away from using `generic`. Only two fields are used, but unk8C was
taken in the main Vibhuti crash, so can't reuse it.

Trying to start using the `s32 : 32` syntax to indicate unused fields
moving forward, may help with figuring out how to handle the problem of
`Ext` and its mysteries.
2024-08-15 19:04:10 +01:00
Luciano Ciccariello
eca5393e43
Document Richter overlay (#1513)
This is a proposal on how I would like the naming scheme going forward
for the player. The proposal includes the naming and layout once we
document Alucard and decompile Maria (PSP). Please let's agree on naming
and structure so it can be easy to hack and plug new custom characters
at any time.

* Animations to have `XXX_anim_yyy` where `XXX` is three letters for
`arc`, `ric` or `mar` (`arc` taken from `BIN/ARC_F.BIN`). To mark them
`static` whenever it is possible to do so.
* `PL_S_xxx` to mark a player step. Steps might be similar between the
three different players, but they must be isolated into the respective
headers `dra.h` for Alucard, `ric.h` for Richter, `mar.h` for Maria. I
am aware that Alcuard steps are used in weapons, which is why they are
currently found in `game.h`. This needs to be addressed at some point.
* PL_T_xxx` for the various timers from `g_Player.D_80072F00`. Those
_might_ be need to be shared between all players, we need more research.
* `XxxHandleYyy` for the step handlers. You will see `RicHandleJump` to
handle `PL_S_JUMP`.
* `XxxSetYyy` for the functions responsible of transitioning into a
specific step (see `RicSetJump`)

Prefer imperative verbs than paste tense or anything else. So `dead`
instead of `killed`, `run` instead of `running` and so on.

Functions and animations have `Ric` or `ric_` pre-pended since those
symbols are publicly exported and not marked as static. But `#define`s
and `enum`s that are isolated into the player's header should be
generic.

I cracked the animation system, so I created the macros `A_END`,
`A_LOOP_AT` and so on.

In a next pull request I will change `Entity::unk4C` into
`Entity::anim`. I did not want to include it here to not change too many
files in one go.
2024-08-15 14:57:54 +01:00
bismurphy
7c4c077543
Start documenting some game engine stuff (#1515)
Just some symbol renaming; this is a big task and will probably take
lots of research to work out how all the different interwoven systems
work, but this is some starting steps.
2024-08-14 17:48:05 -07:00
bismurphy
d638afdb49
Rework ObjInit to remove multi (#1507)
I'm going through to find uses of Multi structs and remove them since
they are bloated.

ObjInit2 was using a Multi16 on its unk4 member. Surprisingly, there was
no ObjInit already, so I made the following changes:

1. ObjInit2 is renamed to ObjInit, and uses a u16 in its unk4 position.
Since this gets assigned to unk5A in an entity, it's called unk5A (we
should really figure out what Entity.unk5A is...)

2. We create a NEW ObjInit2 which instead splits up unk4 into the two
fields of facingLeft and unk5A. This version is very rarely used in the
repo.

3. We cleanup some init data which is used as the new ObjInit2 struct.
2024-08-13 21:58:35 -04:00
bismurphy
49fd8ab6ce
Remove Multi type from g_zEntityCenter (#1506)
This is actually what I was initially going for in my previous PR.

g_zEntityCenter was almost always used as an s32, but some of the
duplicates of e_collect which were scattered across overlays had weird
misuses that acted like it was s16, which necessitated the use of the
Multi.

Now that e_collect is unified across overlays, we can make this data
field a proper s32. Nice!

The only change made in this PR is the type of this variable, and a
find-and-replace to change it to not need to access the .unk element of
the Multi struct anymore, since now it's just a bare s32 (but still
contained in the unkGraphicsStruct of course).
2024-08-13 12:55:22 -07:00
Jonathan Hohle
a34dc9a778
Stage BSS Organizing, Padding Macros (#1497)
Maps `create_entity` and `e_collect` data, text, and bss for all stages.

Adds macros for defining padding for various sections by size.

Tables for section sizes have been added to common includes to make
calculating offsets easier when segments.
2024-08-11 15:49:53 +01:00
Jonathan Hohle
2e181ea9f3
Move Some cen Data to Logical Compile Unit (#1492)
This change moves BSS variables into their most appropriate compile
unit, "decompiles" several data files, and splits out some existing data
into its logical unit.

BSS data has all been removed from `bss.c` and moved to a file where the
data is either first used or where it can be made static.

Several data files have been converted to appropriate types and added
to the most appropriate file. This converts the header related
references and some of the other early data.

Finally, some data like has been rearranged and moved into logical
compile units like data from `entity.c` into `holyglassescutscene.c`.
Logical boundaries were chosen based on where data could be made static.
2024-08-09 10:30:12 +01:00
SynaMax
8fe46d2b87
g_SfxAttackGrunts, g_SfxPainGrunts, and sfxID enum up to 0x668 (#1491)
Thanks to @joshlory for figuring out these tables in #1403.
2024-08-08 19:12:58 -07:00
SynaMax
b5429e0ae8
More SFX reference updates (#1488)
I think we're all caught up with the current sfx enum so the next PR
will have some new sfx IDs added.
2024-08-08 15:55:29 -07:00
Luciano Ciccariello
f46c8dd4cf
DRA reorganise BSS section (#1478)
A follow-up to #1473 where I imported the whole BSS section by
respecting the symbol offset but ignoring their actual type. The work
here consists into checking all the almost 500 symbols in DRA one by
one. Each type in `bss.c` will be changed to respect the one actually
defined in `dra.h` and document the file that actually holds reference
to the symbol. If the symbol is only used in one file it will be removed
from `dra.h`. Once the work is done I am planning to get rid of
`src/dra/bss.c` and have each file to hold the reference.

The reason why I created `dra_bss.h` is because when GCC does not order
BSS by how they are declared, but when it finds them first in the code.
So doing `extern s32 b; s32 a; s32 b;` will order them as `b` then `a`.
`dra_bss.h` needs to not be included in `src/dra/bss.c` but all the
structs and enums should.

Tons of fake symbols have been addressed as part of this PR.
2024-08-08 23:06:26 +01:00
Jonathan Hohle
18a57a5eb5
Miscelaneous Header Cleanup (#1487)
* forward declaration for `struct Entity` prior to `PfnEntityUpdate`
* definition guard around `VERSION_PC` in `pc.h`
* various libc includes to avoid implicit signatures
* `const` string arguments to avoid dropping a const qualifier

This cleans up most of the warnings from the cmake build. There are
still a few from `libgte` and one more `const` to mutable assigment but
most have been resolved.
2024-08-08 22:57:13 +01:00
Jonathan Hohle
329c52189a
Finish EntityLockCamera Decomp (#1486)
Replaces the partial `EntityLockCamera` with a matching decomp.
2024-08-08 14:47:35 -07:00
Alejandro Asenjo Nitti
23a68b0c09
Import RIC data & the rest of rodata (#1483)
co-authored-by: @DerpPrincess
2024-08-08 10:11:15 -07:00
SynaMax
e34f2c3ada
Added MAD and e_red_door SFX (#1482)
By looking at how the gold pickup sfx are handled using `#ifdef`, I
chose to do the same thing here with swapping the sfx references in
`e_red_door.h`.

`SFX_METAL_CLANG_E` is the only sound effect that seems to be the same
between MAD and the final collision handler.
2024-08-07 19:07:29 +01:00
SynaMax
455a97c9e8
Major SFX reference update (#1479)
We've hit the first beta sound ID `0x640`, which is the old door open
sound effect (final is `0x642`). How do we want to implement the beta
sfx IDs in the enum?
2024-08-06 13:41:09 -07:00
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
943828b370
Decompile Axelord Shield func_ptr_80170024 (#1472)
Next one! Lots of collisions here which is interesting.
2024-08-04 09:55:34 -07:00
SynaMax
22d3bc5ad3
Added and updated SFX references (#1469)
Stopping at 0x633 (`SFX_UI_SELECT`) for now, but will continue to add
and update more sfx references soon.

So far we have 51 out of a potential 736 sfx IDs (`0x8E0` - `0x600`).  

For what it's worth, the last valid sound ID I have listed in my
spreadsheet is `0x8D2` found in `DRA`, `RIC`, `BO4`, `BO6`, and `RBO5`
so the actual number might be 722 enum IDs, but we'll see what happens
since the last sfx group in the list belongs to vabid 3.
2024-08-03 11:50:03 -07:00
SynaMax
8bdde29673
More SFX additions to enum (#1468)
I decided to rename `SFX_SKULL_HIT` to `SFX_METAL_CLANG`, as well as
`SFX_SWORD_SWISH` to `SFX_WEAPON_SWISH`.

These are more generic names that better match up with the actual sound.
While `SFX_SWORD` is mainly used for sword weapon cues, it is used for
other weapon entities so I renamed it.

Same idea also applied to `METAL_CLANG`; it's mainly used for the CGI
spinning Stone Skull enemies but it also shows up in CEN as an elevator
sound cue.

I also used `SFX_RIC_RSTONE_TINK` as an abbreviation for the Rebound
Stone "tink" sfx, to help keep these names short.
2024-08-02 18:58:30 -07:00
bismurphy
50f5ad9dca
Decompile Herald Shield EntityWeaponShieldSpell (#1464)
Nothing super special, pretty similar structure to some other shield
spells.
2024-08-02 09:25:32 +01:00
SynaMax
1eceab45db
More SFX added to enum (#1465)
Slowly adding more sounds and updating all the references in the
codebase.
2024-08-02 09:24:13 +01: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
Jonathan Hohle
b762258c33
Decompile Remaining w_037 (#1460)
Decompile `EntityWeaponAttack` and `func_ptr_80170008`.
2024-08-01 09:14:52 -07:00
SynaMax
e0647f9ade
Added SFX enum and SFX_RIC_WHIP_RATTLE_A (#1458)
Starting off with something simple. Per
[sozud](https://github.com/sozud)'s suggestion in #1441 , I put in a new
enum for sounds. There's only one reference to Richter's whip sound in
the codebase so far. According to my research, BO6 and RBO1 reference
this ID as well.

There's several other whip rattle sounds (0x603-0x606) immediately
following the commonly heard 0x602 cue. Unless BO6 or RBO1 uses random
sound calls (like Alucard's randomized grunts), I don't believe these
are referenced in the game and are unused.
2024-08-01 07:49:36 -07:00
Jonathan Hohle
e9685614c0
Decompiles Remaining rwrp Function & Data (#1437)
Adds an a PSX implementation of `EntityRWarpRoom`. This is similar to
`EntityWarpRoom`, but needs to raise and lower the player stands on, and
obviously has to warp to other inverted rooms.

This also pulls in the remaining data and static storage, completing the
`rwrp` mapping.

---------

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-07-29 21:30:24 -04: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
93c51db4fd
Decompile Shaman Shield EntityWeaponShieldSpell (#1448)
Alucard/Alucart shields are done, next is Shaman Shield. Lots of these
shield spells are very similar.
2024-07-28 07:37:33 -04:00
Josh Lory
a473a1fed0
More weapon funcs (#1443)
Includes:

* [func_ptr_80170004_w_010](https://decomp.me/scratch/SH0iK)
* [func_ptr_80170008_w_043](https://decomp.me/scratch/LeMEl)
* [EntityWeaponAttack_w_045](https://decomp.me/scratch/4oeHu)
2024-07-27 15:26:32 -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
Josh Lory
42107e8bb8
Various weapon pointer funcs (#1442) 2024-07-26 21:32:40 -04:00
bismurphy
12f8f7149d
Decompile w58 (Alucart Shield) Shield Spell (#1439)
This modifies a variable at 0x80097420, I noticed that was in the
g_UnkGraphicsStruct, so I went through all the uses of that variable and
made them all use the struct.
2024-07-26 19:13:51 +01:00
bismurphy
4b425c4cd0
Decompile RIC func_8015A9B0 (#1438)
This finishes RIC.

Very similar to the most recent DRA function 80115394, so noted that
here.
2024-07-26 12:29:12 -04:00
SynaMax
e81fbf3ca1
SFX defines for Karma Coin (#1423) 2024-07-26 08:44:27 -04:00
Luciano Ciccariello
c9f6e2b1b3
NP3 first steps to align C extraction (#1430)
Start to perform a series of code refactoring to align the various
overlays on how NZ0, WRP and RWRP are currently organised, aiming to
share as much code as possible. This is a good stop gap that does not
change too much. There are virtually no major changes other than the
removal of the fake symbol `D_8003BEEC`.

I found it is very hard to share every single line of code due to some
minor differences in the castle flags. I couldn't yet spot a reliable
pattern on how castle flags are manager across stages.

My vision is to share as much code as possible, possibly not as header
files but as C files in a similar fashion of #1425 . I am aiming to
model NP3 so we can merge it with NO3 given the fact they share a good
chunk of the code base.

I am waiting to split the rest of the entities into their own individual
files. My idea is to have a file per entity or per entity group with
their own set of data and helper functions, possibly all marked as
`static`. We agreed it is probably a good idea to wait exploring the PSP
build of NZ0, NO3 or NP3 before performing this step.
2024-07-26 08:36:05 -04:00
sozud
4fe662c4e3
Import gte code, candle test button (#1422)
This imports the psycross gte code and hooks it up. I added a hotkey to
create a candle with a subweapon. As far as I can tell you can't give
yourself a subweapon directly without breaking stuff since
EntityBreakable and the entity it spawns set up various things. I used
this to test the gte. This also fixes a couple of function pointers like
CheckCollision to fix the cross animation. This removes a few gte
functions we previously implemented in favor of their versions, I'm not
sure about the tradeoffs there.
2024-07-22 22:20:01 +01:00
Mark Street
20c3370f4f
Use allegrex assembler for PSP (#1424)
I moved *some* of the PSX-specific stuff out of the common `Makefile`
and into the `Makefile.psx.mk` -- there is still more that could be done
here, but this should be enough to have the correct rules for PSX and
PSP with the desired assembler.


Also threw in a bonus feature where I've removed the `move` macro from
`macro.inc` because `maspsx` does this automagically for you now.
2024-07-22 15:36:28 -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
2dfedc44c3
Rework D_8003C908 (#1418)
The next function of SEL, func_801B99E4, makes it clear that D_8003C908
is not a struct member. I do not know why it was placed in this struct.
I have that function now matching, but since we're changing around
variables that are used elsewhere, I decided to split the PR so that we
can handle one type of change at a time.

The D_8003C908 variable has not yet been used in any C code, so this
change does not affect anything.

Further, since both struct members were s32, I decided to make it a
2-member array for the sake of conciseness in the code.
2024-07-17 19:13:53 -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
d73363b83b
Decompile DRA func_8012F178 (#1408)
The way this one uses scratchpad is super weird, but hey, it matches.

It's always fun to come across super-unique functions and I'm pretty
confident to say this qualifies.
2024-07-13 10:42:43 -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
bismurphy
1bb611fe02
Decompile DRA RenderEntities (#1393)
Now with the maspsx changes, this can also match by using
SPRITESHEET_PTR.

Tried to document all the variables, use flags when possible, etc, so
hopefully this is mostly complete. Should be exciting to have
RenderEntities and RenderPrimitives both working now!
2024-07-11 11:41:07 -07:00
Josh Lory
d756e28f77
Use SFX constants (#1403)
Open to suggestions for how to break this change up to make it easier to
review. The data extraction necessary for naming values in `D_800ACF60`
and `D_800ACF84` could be a separate commit... but I'm not sure it's
worth it.
2024-07-11 10:03:39 -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
sozud
33566ce10b
Progress towards linking/loading weapons (#1384)
This links w_000 and allows the texture to be loaded to vram, as well as
the functions executed.

g_Cluts was renamed since the stages also have g_Cluts. A macro and
preprocessor defines are used to allow unique weapon function names.
This doesn't load the animsets since it seems like that stuff is getting
redone with the asset manager.
2024-07-10 13:53:04 -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
Jonathan Hohle
f724532c70
Extract Entity Definitions for CEN (#1395)
Entity definitions for `cen`.

Cleans up some declarations (like `D_8018068C`) to better match the
data.
2024-07-08 20:19:47 +01: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
Josh Lory
7feb9d0317
WIP: DRA cleanup (#1379)
- [x] Cleanup primitive drawModes
- [x] Cleanup entity drawFlags
- [ ] Cleanup usages of ext.generic
2024-07-06 17:00:59 -07:00
bismurphy
2791aea1a4
Minor cleanup on wolf function func_8013136C (#1378)
This is a relatively unimportant function, but it messes with some
variables that I am interested in learning more about, so I went ahead
and compared it to the PSP version.

This PR incorporates some lessons I learned from that PSP version. Most
importantly, the rotPivotX and rotPivotY in Entity are signed.

I also tracked down how this entity is created, it's a bit odd since it
doesn't call any entity creation function, and instead does a direct
write into g_Entities to create it.

On exit, this function calls `func_8012C600`, which I will be doing a
similar analysis for next.

There was a leftover rodata padding that doesn't do anything, so I
removed that too.
2024-07-05 21:16:31 -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
sozud
6a786d73f9
libgpu funcs (#1377) 2024-07-04 11:25:42 -07:00
Luciano Ciccariello
de46f99e2e
New asset manager (#1343)
This aims to deprecate all the Splat tools in `tools/splat_ext` in
favour of a more centralised asset manager. This brings the following
advantages:

* Much faster extraction
* Faster build
* Automatically define `static` symbols or unique names whenever
`static` is not possible
* Allow to embed assets into the output binary
* Drastically simplify `Makefile` by removing all the asset build rules
* Avoid situations where it is not possible to extract and build assets
that is not 4-byte aligned

This is achieved by having the splat YAML targeting a normal C file as
data and have an external tool to take care of the following:

1. Extract asset files straight from the overlay binary file into human
readable file in `assets/st/STAGE_NAME`
2. Build assets as header files that go into `src/st/STAGE_NAME` to just
include them from any C file

This requires each stage header to have the following new format: please
see `src/st/nz0/header.c`

Built assets in `src/st` are ignored by Git.

As for now, for simplicity sake, the steps `make extract_assets` and
`make build_assets` are just executed within `make extract` exclusively
for the US version.

I plan to auto-generate files such as `src/st/nz0/tile_data.c`.

For a first iteration I am aiming to handle the following:

* [X] Extract rooms: `assets/st/*/rooms.json`
* [X] Extract room layers: `assets/st/*/entity_layouts.json`
* [X] Extract tilemap data: `assets/st/*/tilemap_*.bin`
* [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json`
* [X] Extract sprites: `assets/st/*/sprites.json`
* [x] Extract entity layouts
* [X] Build rooms: `src/st/*/rooms.h`
* [X] Build room layers: `src/st/*/layers.h`
* [X] Build tilemap data: `src/st/*/tilemap_*.h`
* [X] Build tilemap definitions: `src/st/*/tiledef_*.h`
* [x] Build sprites (aka `g_SpriteBanks`)
* [x] Build entity layouts
* [x] Allow the tool to suggest how to adjust the Splat config for each
overlay

I want the tool to cover the following stages:
* [x] CEN
* [x] DRE
* ~MAD~ I do not think this can be done, it is way too different from
the other overlays
* [x] NO3
* [x] NP3
* [X] NZ0
* [x] ST0
* [X] WRP
* [x] RWRP
* ~WRP (PSP)~ Maybe in a follow-up PR

For a later iteration I plan on extracting and build:

* Entity GFX thingie
* The CLUT thingie in the header
* Uncompressed GFX data
* Cutscene data
* Blueprints
* The `src/config_us.h` thingie

---------

Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 21:38:36 +01:00
bismurphy
2399ca62cb
Decompile DRA RenderPrimitives (#1371)
Got this working with the aid of PSP!

Scratches here:

PS1: https://decomp.me/scratch/FDWxW
PSP: https://decomp.me/scratch/SObUR

These are identical aside from the versions defined at the top of the
context, and everything else is done with `ifdef`.

Several of the `ifdef` differences are in structs that are defined in
`include/psxsdk/libgpu.h`, and since they're in the PSX SDK, I don't
want to add those PSP differences into that file. I imagine at some
point we'll have a PSP libgpu.h or something, but until then, this
function will not actually match on PSP. But since PSP is not the focus
of this decomp, I think that's okay.

This is 99% similar to Xeeynamo's scratch, the main difference is the
treatment of the lines that look like `setSemiTrans(&primbuf->g2,
var_s0->drawMode & DRAW_TRANSP);`.
2024-07-02 19:14:59 +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
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
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
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
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
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