Commit Graph

1037 Commits

Author SHA1 Message Date
sozud
15e3cb5a78
EntityClockHands (#1613)
Thanks to sonicdcer
2024-09-15 22:52:05 -07:00
sozud
ee22761733
EntityClockRoomController (#1610)
Starting to import work from
https://github.com/Xeeynamo/sotn-decomp/pull/557
Credit to @sonicdcer
2024-09-15 22:42:35 -07:00
Luciano Ciccariello
d3875f72f1
Split C files for MAR (#1611)
Some checks failed
Format code / format (push) Failing after 0s
Build C code / extract-assets (push) Failing after 0s
Build C code / build-linux (push) Has been skipped
Build C code / build-macos (push) Has been skipped
Build C code / build-windows (push) Has been skipped
Build C code / build-linux-lle (push) Has been skipped
Build Saturn version / build-and-test-saturn (push) Has been skipped
Build Saturn version / function-finder-saturn (push) Has been skipped
Build Debug Module tool / build (push) Failing after 0s
Build PSX and PSP version / build-and-test (pspeu, hd) (push) Has been skipped
Build PSX and PSP version / build-and-test (pspeu, pspeu) (push) Has been skipped
Build PSX and PSP version / build-and-test (us, us) (push) Has been skipped
Build PSX and PSP version / generate-progress-report (pspeu, hd) (push) Has been skipped
Build PSX and PSP version / generate-progress-report (pspeu, pspeu) (push) Has been skipped
Build PSX and PSP version / generate-progress-report (us, us) (push) Has been skipped
Build PSX and PSP version / generate-duplicates-report (us, us) (push) Has been skipped
Build PSX and PSP version / generate-duplicates-report-psp (pspeu, pspeu) (push) Has been skipped
This PR prepares MAR to be de-duplicated easily. I just de-duplicate
some easy C files. I am submitting this as it is to allow @sozud to
submit #1610 without any delay.

note: it took me longer than I expected to do this. It is a step it
would really be beneficial to have automated in the future via
`make-config.py`
2024-09-15 23:38:46 +01:00
bismurphy
ff3ff091f8
Deduplicate st_update.c across overlays (#1609)
Renames the file, imports the data, and uses the .h in every overlay.

Given that this one doesn't have any PSP craziness, would this maybe be
a place where it would make sense to copy in the function C code? Right
now st_update.h is just an array definition and a few #include calls for
the .h files for `random.h`, `update.h`, and `update_stage_entities.h`.
2024-09-15 22:54:34 +01:00
Luciano Ciccariello
fffa28c7f7
Add BOSS/MAR.BIN (#1608)
Small PR to enable #557 and to let be used as an example for [our
wiki](https://github.com/Xeeynamo/sotn-decomp/wiki/Decompilation#add-new-overlay).

This was done with the new `make-config.py` tool.
2024-09-15 21:49:56 +01:00
bismurphy
908bd1d2eb
Deduplicate st_common.c across all existing stages (#1606)
I noticed that there was large overlap between these, but it was
incomplete as different stages had different levels of de-duplication
completed.

I went through and completely de-duplicated this file, so it is now
st_common.h everywhere.

There were a few leftover functions in MAD and ST0, so I decompiled
those in my previous PRs, and now in this one, I'm doing ifdef to make
it all match for all stages.

This is pretty cool and represents a large amount of code reduction.

The original C file which was used as the basis for st_common.h was the
WRP one, which has PSP support, so this may be a great step to making
many overlays match on PSP too.
2024-09-15 21:31:15 +01:00
bismurphy
f1128926cc
Decompile ST0 GetPlayerCollisionWith (#1605)
Some checks failed
Format code / format (push) Failing after 0s
Build C code / extract-assets (push) Failing after 0s
Build C code / build-linux (push) Has been skipped
Build C code / build-macos (push) Has been skipped
Build C code / build-windows (push) Has been skipped
Build C code / build-linux-lle (push) Has been skipped
Build Saturn version / build-and-test-saturn (push) Has been skipped
Build Saturn version / function-finder-saturn (push) Has been skipped
Build Debug Module tool / build (push) Failing after 0s
Build PSX and PSP version / build-and-test (pspeu, hd) (push) Has been skipped
Build PSX and PSP version / build-and-test (pspeu, pspeu) (push) Has been skipped
Build PSX and PSP version / build-and-test (us, us) (push) Has been skipped
Build PSX and PSP version / generate-progress-report (pspeu, hd) (push) Has been skipped
Build PSX and PSP version / generate-progress-report (pspeu, pspeu) (push) Has been skipped
Build PSX and PSP version / generate-progress-report (us, us) (push) Has been skipped
Build PSX and PSP version / generate-duplicates-report (us, us) (push) Has been skipped
Build PSX and PSP version / generate-duplicates-report-psp (pspeu, pspeu) (push) Has been skipped
ST0 has a different version of this function, which was not yet
decompiled. Other people had some scratches, but they weren't very
close.

I took the function that exists in other overlays, and removed code
until it matched.

Might try to de-duplicate this with ST0 ifdef stuff, but for now, I
wanted to just get the single decompiled function reviewed.
2024-09-15 18:19:17 +01:00
sozud
85dd4a6540
Mark libgte funcs as asm (#1600)
RotMatrix
RotMatrixYXZ
RotMatrixX
RotMatrixY
RotMatrixZ
ScaleMatrix

I think these are handwritten because they heavily use $t registers,
which is not like the code gcc produces. It makes sense for these to be
hand-optimized since they are speed-critical. Also, these don't use the
`ctc2` etc. instructions so I don't think it's a mix of C and gte
macros.

I dumped all the remaining gte funcs to a gist if others want to inspect
these https://gist.github.com/sozud/62a6a4a7f751010d435714a5191c46f3
2024-09-15 18:13:38 +01:00
Luciano Ciccariello
0df1cccf2a
Add some missing US undefined symbols (#1592)
Allows to compile overlays without necessarily having to splat DRA to
generate `undefined_syms_auto.us.dra.txt`
2024-09-09 08:04:39 +01:00
Luciano Ciccariello
edb4f0ebc0
RIC and Alucard share field docs (#1588)
Not a big PR. The highlights are `g_Player.timers` and
`entity->hitParams`. The last one is a bit weird as it looks like a mix
between `attackElement` and `hitEffect`.

The `var_s4` on `RicMain` is uninitialised and it leads to an undefined
behaviour. Recompiling the code for PSX by moving things around, that
variable will not be `0` at the beginning but some random value. This
prevented Richter's run, blade dash and high jump to work. I added an
`#ifdef` in case people wants to mod the overlay.

This is probably the last batch of changes for RIC for a while.
2024-09-07 18:00:44 +01:00
Luciano Ciccariello
f448782618
RIC blueprint docs (#1577)
List of the most important changes:
* The two fields in `FACTORY` are now reversed; what used to be
`FACTORY(0x2000, 44)` is now `FACTORY(44, 0x20)`
* Introduce `WFACTORY` to imply `((g_HandId + 1) << 0xC)` in it
(`((g_HandId + 1) << 0xE)` is not yet cracked)
* Remove `assets/ric/blueprints.json` in favour of baking the info into
a C file to easily link enums
* Add `B_MAKE` to define a blueprint entry
* Document almost all RIC entities
* Document almost all RIC blueprints
2024-09-07 01:29:56 +01:00
Luciano Ciccariello
af503baa43
RIC: add more documentation (#1573)
Follow-up to #1569 .

Loads of changes, where the most prominent one is synchronising the
`self->ext.*.subweaponId` field across entities to make it work on
`RicSetSubweaponParams`. I added some static assertions with the new
macro `SYNC_FIELD`, which is easier to read.

The new `enum RicSubweapons` decouples the subweapons of Richter from
those found in DRA. This is important because
`assets/ric/subweapondefs.json` is different from the definition stored
in DRA.

I discovered new entities and renamed them accordingly. I am following
the format `RicEntity` for each entity. Then `RicEntitySubwpn` or
`RicEntityCrash` for the appropriate category.

The BSS section has been assigned to the right places and `ric.h` has
been cleaned as most of the declarations are no longer necessary. More
data and functions have been marked as `static`.

`src/st/st0/2DAC8.c` had a reference to `.ext.agunea`, which was
probably put there by mistake. The fake symbol `D_801758D0` has been
removed and I think I found a way to fix the stopwatch subweapon without
the `#ifdef`.

```c
#ifdef VERSION_PC
#ifdef _MSC_VER
            {
                s32 temp_x = (rcos(primLine->angle) << 8);
                s32 temp_y = (-(rsin(primLine->angle) << 8));
                primLine->velocityX = *(f32*)&temp_x;
                primLine->velocityY = *(f32*)&temp_y;
            }
#else
            primLine->velocityX = (f32)(rcos(primLine->angle) << 8);
            primLine->velocityY = (f32) - (rsin(primLine->angle) << 8);
#endif
#else
            primLine->velocityX = (rcos(primLine->angle) << 8);
            primLine->velocityY = -(rsin(primLine->angle) << 8);
#endif
```
this one has been resolved by just using `velocityX.val`.
2024-08-27 18:18:26 +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
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
a8572f8922
Deduplicate Bone Scimitar enemy (#1559)
After modernizing this, I've gone ahead and pulled out the functions in
this file into a .h, as with other duplicate functions.
2024-08-21 23:19:15 +01:00
sozud
6b4254b2fc
More dedupes (#1556) 2024-08-20 20:57:18 -07:00
sozud
88024b24ff
More dedupes (#1555) 2024-08-20 16:02:21 -07: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
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
sozud
99ef943f6b
More dedupes (#1550)
Merging to prevent more conflicts with other work
2024-08-20 11:24:52 -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
sozud
f40e9a1639
More dedupes (#1548) 2024-08-19 21:36:45 -07:00
sozud
7433787b9b
more stage dedupes (#1543) 2024-08-19 23:00:03 +01:00
Josh Lory
f21224fb6f
Import data for w_041 and link (#1546)
Also links `w_052` which I missed in
https://github.com/Xeeynamo/sotn-decomp/pull/1524
2024-08-19 10:51:24 -07:00
Josh Lory
247f58f90e
Finish w_007 and import data (#1539)
https://decomp.me/scratch/Zn2uO
2024-08-18 14:52:32 -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
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
Josh Lory
c939079eab
Finish w_045 and import data (#1521)
Unfortunately this build will fail until the fix is merged to decouple
`func_ptr_*` signatures.

* [func_ptr_80170004_w_045](https://decomp.me/scratch/OmJXk)
* [func_ptr_8017000C_w_045](https://decomp.me/scratch/c5Qrm)
2024-08-18 09:22:14 +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
Josh Lory
912153bed3
Import data for w_044 (#1526)
Might try replacing the clut with actual 16 bit colors. Is this the
right macro to use?

```
#define COLOR16(r, g, b, a) (r) + ((g) << 5) + ((b) << 10) + ((a) << 15)
```
2024-08-17 11:09:13 -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
b3ef37a4a7
Import data for w_052 (#1524)
Finishes the `.data` section. I thought I could just update sizes and
`.bss` would work as well, but I'm running into issues.
2024-08-15 23:18:19 -07: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
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
efecb91c2d
Use e_collect.h for NP3, CEN, MAD, DRE, ST0 (#1502)
Came across e_collect.c in NP3, and it wasn't using the e_collect.h, but
now it is. Overall just a big deduplication.
2024-08-13 12:28:57 -07:00
Jonathan Hohle
e4a9eb1a17
Decompile and Split NO3 to Match NP3 (#1504)
This is a simple synchronization between methods already decompiled in
NP3 to their counterparts in NO3. Player water effect has been split to
match, but no data has been mapped in this pass.

Decompiles methods based on the NP3 implementation:

* `EntityBackgroundBushes`
* `func_801B94F0`
* `func_801D0A2C`
* `EntityAlucardWaterEffect`
* `EntityMermanSpawner`
* `EntityMermanExplosion`

Splits `e_bone_scimitar`, and `player_water_effect` into a separates
file to match `NP3`.
2024-08-13 11:03:18 -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
Luciano Ciccariello
551f3c8bae
NZ0 data import and code refactor (#1494)
plus some minor edits to link the stage
2024-08-09 18:25:53 +01:00
Luciano Ciccariello
e2ca7ee416
Import w_002 data and link overlay (#1493)
This PR aims to be a blueprint to what needs to be done for the
remaining 56 weapon overlays
2024-08-09 17:53:10 +01:00
Josh Lory
a148db7885
Decompile DRE EntityUnkId23 (#1434)
https://decomp.me/scratch/LLpca
2024-08-09 09:51:53 -07:00
sozud
301f3128d9
some ric fixes (#1490)
This fixes a few RIC crashes, gets it up to the point that the
blueprints need to be loaded
2024-08-09 09:24:58 -07: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
Luciano Ciccariello
f1faef333a
Weapon assets and statically linked (#1470)
Allow to compile weapon overlays as a single C files. The benefit is to
disallow symbols to be exported by statically compile them all but the
header. We would no longer need to use `OVL_EXPORT` as long as the
symbols are marked as `static`. The frames data is also generated as an
array of data that can be just included into their respective C files,
generated by JSON files on the fly.

I changed `animset` to `frameset` as the data does not represent a set
of animations but rather a set of frames, where every frame has multiple
sprites. The information on how the frames are played (e.g. animation)
is found elsewhere.

Following the full list of changes to achieve this project:
* The `animset` from splat is now dummied out
* The `frameset` JSON is now generated by the asset manager
* The `frameset` JSON is now compiled into `src/weapon/w_0xx_y.h`
* The `header.c` has been moved into `shared.h`
* For simplicity I added a `#define g_Animset w_000_1`. I did not want
to hack the asset manager too much to force the name to be `g_Animset`
and I did not want to change all the symbols yet.
* Simplified `weapon_pc.c` as we now only need the exported header
* Always try to build the most up-to-date asset manager: this should
avoid weird errors whenever people pull new changes

As the asset manager now can accept those `config` files, now the CLI
supports the following commands:
* `stage extract`
* `stage build`
* `config extract` (NEW)
* `config build` (NEW)

The config structure is heavily inspired to Splat to maintain
consistency and continuity.
2024-08-09 00:57:26 +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
Luciano Ciccariello
358b7a10df
Import BSS section across all overlays (#1473)
I did not do it for `weapon`. This is the script I used:

`python3 a.py asm/us/st/dre/data/23264.sbss.s > src/st/dre/bss.c`

```python
import sys

with open(sys.argv[1], "r") as f:
    lines = f.readlines()

print('#include "common.h"')
print("")
for line in lines:
    if line == "\n":
        continue
    elif line.startswith(".include"):
        continue
    elif line.startswith(".section"):
        continue
    elif line.startswith("glabel"):
        label = line[7:].replace("\n", "")
        len = 0
    elif ".word" in line:
        if len > 0 and n != 4:
            print(f"WARN: {label}", file=sys.stderr)
        n = 4
        len += 1
    elif ".short" in line:
        if len > 0 and n != 2:
            print(f"WARN: {label}", file=sys.stderr)
        n = 2
        len += 1
    elif ".byte" in line:
        if len > 0 and n != 1:
            print(f"WARN: {label}", file=sys.stderr)
        n = 1
        len += 1
    elif line.startswith(".size"):
        if len == 1:
            if n == 1:
                print(f"u8 {label};")
            elif n == 2:
                print(f"u16 {label};")
            elif n == 4:
                print(f"u32 {label};")
        else:
            if n == 1:
                print(f"u8 {label}[{len}];")
            elif n == 2:
                print(f"u16 {label}[{len}];")
            elif n == 4:
                print(f"u32 {label}[{len}];")

```

the script is a bit dumb. It does not account of the header. Some types
are wrong compared to their prototype. The memory layout matches though,
so we can keep iterating on top of this.
2024-08-04 16:14:49 -07:00
sozud
a869b920b9
Start documenting sfx scripts (#1459) 2024-08-01 12:23:03 -07:00
Jonathan Hohle
d89e1ea8c1
Symbol Matching (#1455)
Matching several symbols for consistent names across duplicates.
2024-07-31 22:44:37 +01:00