Commit Graph

2268 Commits

Author SHA1 Message Date
bismurphy
ed7e5c0b70
Decompile RIC EntitySubwpnThrownDagger (#1411)
RIC had 3 functions remaining, one of which was this one. Given its
similarity to the one in DRA, I decided to revisit it, and thankfully it
now matches.

I also did some cleanup on the DRA one, including renaming variables,
using macros, etc.

We now have two functions remaining in RIC. They are both duplicates of
remaining DRA functions, which have the same issues as the DRA ones do.
This means that once DRA is solved, RIC will be too, which is amazing!
2024-07-16 09:35:43 -07:00
Luciano Ciccariello
512e162f51
DRA finish to import all data from US and HD to C files (#1410)
with the exception of those three SEQ files, which needs to be handled
with the asset manager
2024-07-14 09:35:13 -07:00
sozud
5f74dab165
Add software rendering (#1407)
This takes the GPU from Mednafen and hooks it up by using parts of
libgpu and writing to the fifo. I avoid using DMA and just write
directly and it seems to work fine. This means that the OTAG part isn't
required since that's part of the DMA system and not the GPU apparently.

The main bug I'm aware of is the TILE that fades to white in the warp
room doesn't show up. The GL renderer is still available. I made the
software renderer the default since it's faster and more accurate on
average. The two renderers can be toggled with F8. I turned on linear
logs by default since it's significantly faster.

The biggest gap I'm aware of is PutDispEnv needs to be properly
decompiled and hooked up.
2024-07-14 02:00:15 -07:00
bismurphy
e6efb57796
Decompile DRA func_8012F894 (#1409)
This function was previously the last function in its file.

Upon decompiling, the rodata (specifically the `00 00 00 00` pattern)
indicated that the file does not end here, and that in fact the entire
following file should be part of this file, so I had to change the
splits to accomplish this.

It's an ugly function, and was hard to get a match, but here it is. Did
what I could to document variables but it doesn't seem to make much
sense, if you ask me.
2024-07-13 15:09:54 -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
Luciano Ciccariello
c292aff6fc
Implement PadInit (#1396)
Tested with a dual sense
2024-07-13 01:31:31 +01:00
sozud
e5e98c7755
get_alarm (#1404)
Thanks to @dezgeg
2024-07-13 01:05:19 +01: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
c1455c9638
Decompile DRA func_801042C4 with help from @bismurphy (#1401)
PSX: https://decomp.me/scratch/PLi6k
PSP: https://decomp.me/scratch/nYr6M
2024-07-10 21:53:21 -07:00
sozud
8d5997d225
more libgpu funcs (#1402)
Thanks to @bismurphy for help with these
2024-07-10 21:09:56 -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
sozud
6e2c372ce8
_otc, register docs (#1399) 2024-07-10 14:30:30 -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
Jonathan Hohle
2220f6c5bd
Use PSP InitializeEntity Impl (#1394)
Update `InitializeEntity` to use the PSP decompilation and remove
duplicate implmeentations across stages.
2024-07-08 20:16: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
sozud
82d145ab72
More libgpu, maspsx update (#1391)
This file seems to use an older aspsx. Thanks to @mkst for the fixes
2024-07-08 08:19:21 +01:00
bismurphy
ff1d73211e
Change debug button to L2 (#1390)
Changing to deconflict with wolf transform button.
2024-07-08 08:17:53 +01:00
sozud
1742cb69bd
More libgpu funcs (#1386)
set_alarm thanks to @joshlory
2024-07-07 11:36:52 -07:00
Luciano Ciccariello
7d4f2d45be
MAD func_8018DF0C, func_8018E13C (#1387)
Thanks to @bismurphy for some major hints on how to get these two
functions right
2024-07-07 11:11:56 -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
bismurphy
e796fb44de
Cleanup on func_800F24F4 (#1389)
Lots of small changes here, but ultimately this ends up rewriting the
whole function.

I opened this one in PSP (it's `-O4`!) and found several differences
which I corrected. I also rewrote some of the if-statements to be a bit
more readable.

Kind of a weird function the way it's testing for hard-coded X and Y
values. Not sure what this function actually does.

We also end up only calling `func_801042C4` once, which is a nice
improvement for readability.

`func_801042C4` is not decompiled, so I'll move on to that next.
2024-07-07 15:21:14 +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
7f48523477
Cleanup DRA func_8012C600 (#1380)
Another adventure in examining a function alongside PSP.

The CLAMP_MAX and CLAMP_MIN seem like nice ideas, but I wasn't getting
them to match on PSP. And since they are very little-used in the repo,
keeping them around in here just didn't seem worth it.

As far as the `D_8013AE##` variables, I noticed they were consecutive in
addresses (they're all s32, and are all different by 4 bytes). Rather
than being a weird mix of individual values and arrays, I thought it
made more sense to treat them all as an array, and indeed it still
matches this way, so I think this is a more reasonable way to handle
this data.

I think those are all the changes that matter.
2024-07-06 12:15:18 -07:00
Tuomas Tynkkynen
e73000308d
Fix match with latest maspsx and update it (#1381)
See commit messages for details.
2024-07-06 11:29:17 -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
8ac5ebc378
Refactor/clean-up of some of Alucard's jumping logic (#1376)
There was a question in the decomp discord about the bounce when Alucard
dive-kicks and hits an enemy. I tracked this down, and in the process,
found some moderately old functions that could use some improvements to
their code style. I also cross-referenced these with PSP to make the
code make a bit more sense.

The PSP version makes it clear that D_800ACF7C is not a struct and is
just an array of s16, so I made that change. The struct version matched
on PS1, but now that PSP reveals that it was fake, we turn it back to
just an array.

Let me know if I missed anything! Nice to have real names for some of
these functions.
2024-07-05 10:58:54 -07:00
sozud
27d9dfeeb2
Fixes to load wrp/alk (#1374)
I don't understand the file loading code that well but this gets the ALK
vab running. Maybe SIM_PTR should just be D_80280000 so we have that
buffer to use?
2024-07-04 19:30:23 +01: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
8eadeef730
Fix test app regressions (#1373)
Very minor adjustments that I missed during the code reviews
2024-07-02 22:23:03 +01: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
f7882814b0
Decompile Karma Coin func_ptr_80170008 (#1372)
The Karma Coin, surprisingly, has the largest EntityWeaponAttack of all
the weapons. For that reason, I'm targeting it next.

It has one small other entity function, so this PR decompiles that
first, prior to going ahead and decompiling the EntityWeaponAttack
itself.

Otherwise, nothing too crazy special here. I imagine decompiling the
Karma Coin will make it clear what this helper entity is.
2024-07-02 12:56:30 -07: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
sozud
5dfdf6fc6c
Fix loadfilesim, connect cd audio (#1368)
The loading code comes from
8e78845e8b/src/dra/47BB8.c (L472)
which I think is correct

This will eventually hit an assert in _SpuSetVoiceAttr.
2024-07-02 00:20:34 -07:00
Josh Lory
342bdfcdd4
Decompile DRA EntitySubwpnThrownDagger (#1369)
Shout out to @bismurphy for doing most of the initial work on this
match.

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

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

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

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

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

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

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

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

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


c7484b6800/test.c (L201)

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

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

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

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

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

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

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

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

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

---------

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-30 09:26:53 +01:00