Commit Graph

138 Commits

Author SHA1 Message Date
bismurphy
2467f973d6
Various cleanup on a few things (#1858)
Some checks are pending
Build C code / build-linux (i686, RelWithDebInfo, clang, lle) (push) Blocked by required conditions
Build C code / build-linux (i686, RelWithDebInfo, gcc, custom) (push) Blocked by required conditions
Build C code / build-linux (i686, RelWithDebInfo, gcc, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, clang, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, clang, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, gcc, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, gcc, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, clang, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, clang, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, gcc, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, gcc, lle) (push) Blocked by required conditions
Build C code / build-macos (Debug, custom) (push) Blocked by required conditions
Build C code / build-macos (Debug, lle) (push) Blocked by required conditions
Build C code / build-macos (RelWithDebInfo, custom) (push) Blocked by required conditions
Build C code / build-macos (RelWithDebInfo, lle) (push) Blocked by required conditions
Build C code / build-windows (Debug, custom) (push) Blocked by required conditions
Build C code / build-windows (Debug, lle) (push) Blocked by required conditions
Build C code / build-windows (RelWithDebInfo, custom) (push) Blocked by required conditions
Build C code / build-windows (RelWithDebInfo, lle) (push) Blocked by required conditions
Build Saturn version / build-and-test-saturn (push) Waiting to run
Build Saturn version / function-finder-saturn (push) Waiting to run
Build Debug Module tool / build (push) Waiting to run
Build PSX and PSP version / build-and-test (pspeu, hd) (push) Waiting to run
Build PSX and PSP version / build-and-test (pspeu, pspeu) (push) Waiting to run
Build PSX and PSP version / build-and-test (us, us) (push) Waiting to run
Build PSX and PSP version / generate-progress-report (pspeu, hd) (push) Blocked by required conditions
Build PSX and PSP version / generate-progress-report (pspeu, pspeu) (push) Blocked by required conditions
Build PSX and PSP version / generate-progress-report (us, us) (push) Blocked by required conditions
Build PSX and PSP version / generate-duplicates-report (us, us) (push) Blocked by required conditions
Build PSX and PSP version / generate-duplicates-report-psp (pspeu, pspeu) (push) Blocked by required conditions
1. Give a name to the variable `g_PauseAllowed` - this is a bool which
gets tested when we're also testing for pressing START or SELECT to open
the menu or map, so to me it seems like it's flagging whether or not you
are allowed to pause. It is normally 1, but gets set to 0 at the start
of cutscenes, and then restored to 1 at the end of them.

2. Name LAYOUT_RECT_PARAMS_HIDEONMAP, which is relevant for item 3 on
this list. I already used the HideOnMap name when setting up this flag
in the assets handler in my previous PR.

3. Name `g_canRevealMap` - this is a variable that is normally set to
true, but for some particular rooms in the game, it's set to 0. Those
rooms will not appear on your map. Good examples include the forest area
left of the castle gate (the first moment we see Alucard), and the DRE
stage. This variable gets set to 0 if the LayerDef has the
LAYOUT_RECT_PARAMS_HIDEONMAP flag set.

4. Deduplicate a common structure in the code where entities have a
debug routine that lets the Player 2 controller control the behavior of
the entity. By pulling this out, the code can be more concise. Most
importantly, when searching the codebase for g_Pads[1] (which is an
interesting thing to do, since we're looking at uses of the Player 2
controller in a single-player game), you can focus on the interesting,
unique examples, rather than having a ton of copies of the same exact
code.

5. Change all instances of `g_Pads->` to `g_Pads[0].` A minor change,
but good to use a formatting which makes it clear that g_Pads is the
array of both pads, and not a pointer to one.

6. A couple functions I noticed with obvious fake stuff (including a
do{}while(0)) have been adjusted so that they will match on PSP.
Naturally, this also meant removing those fake things, which is always
nice.

Overall, this is several small changes combined into one PR; honestly I
just scrolled through the codebase for a while, finding things that made
me think "I know a way this could be better". Others may disagree with
some of these though, happy to take input, especially on the new names!
2024-10-31 23:44:05 +00:00
H.M. Burger
77cade4efe
Finishing refactor for tt_000 ET_Bat and updating game api call (#1793)
updating global api function func_8011A3AC with a better name. It
fetches the current familiar stats from the global game variables and
will also fetch an attack descriptor if ID is provided.

Refactoring names for ET_Bat that I forgot to update in my last PR.
Remaining unkXX vars appear to be unused.

Adding enum for g_SpellDefs table. Some familiar attacks appear to be in
that table as well as Alucard's spells. Some do not such as the bat's
fireball.
2024-10-16 11:26:54 -07:00
H.M. Burger
bc549c75e6
Small refactor for servant update (#1727)
A small refactor renaming a global variable for when the cutscene has
control of the engine.
In servant, it short cuts the main update function so that your familiar
isn't doing stuff while a cutscene is running.
Also some flag cleanup.

I've figured out quite a bit with the functions and how they are called.
It looks like most of the functions in ServantDesc are actually update
functions called by using the entityId as an offset. I want to update to
make that more clear, but I want to isolate that into it's own PR and I
already had this refactor in flight.
2024-10-04 20:52:23 -07:00
Josh Schreuder
f647b0c26b
Rename g_Player.unk0 to g_Player.status (#1721)
As discussed in
https://github.com/Xeeynamo/sotn-decomp/pull/1709#issuecomment-2386396310
2024-10-04 20:03:16 -07: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
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
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
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
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
sozud
6e2c372ce8
_otc, register docs (#1399) 2024-07-10 14:30:30 -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
Luciano Ciccariello
f96e0aa9fc Re-organise shared symbols 2024-06-12 21:06:51 +01:00
Luciano Ciccariello
8abb09e3ff
Update splat to 0.24.4 (#1112)
Still work in progress. I removed splat as a submodule and started using
it as a pip package instead. Everything is matching but the memory card
icons part in both DRA and SEL. I still have no idea what the issue is.
Once this PR is good to be merged, we can get rid of the splat fork too.
2024-06-12 18:50:32 +01:00
Jonathan Hohle
312c8441f5
More Descriptive func_801B9744 (#1137)
This adds some additional context for func_801B9744 and renames globals
to fit their assumed purpose.

Migrated various stream metadata to C definitions.

The makefile changes add a dependency on `sel.h` to all the objects that
get built from the `st/sel` directory.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-06-11 10:47:59 -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
Luciano Ciccariello
7ea1395567
DRA func_800F0CD8 (#1258)
Plus some refactoring here and there related to the global variables
`func_800F0CD8` uses.

Thanks to @bismurphy for solving the final regswap!
2024-06-04 17:30:28 -07:00
Luciano Ciccariello
e80168bec4
Link all DRA files (#1251) 2024-06-03 21:47:30 +01:00
bismurphy
02d5d97d81
Rename TestCollisions to HitDetection (#1193)
This is a simple find-and-replace to rename this function to more
accurately indicate its purpose.
2024-05-27 18:01:30 +01:00
Luciano Ciccariello
61eeba7f23
Prevent entity from respawning refactor (#1176)
Thanks to @sozud for the hint and @bismurphy for the refactoring idea.
The function `PreventEntityFromRespawning` on PSP hints that the struct
starts 8 bytes earlier. Also there's a missing `nop` at
`PreventEntityFromRespawning`, suggesting the function had to be moved
to the previous function.
2024-05-26 18:07:53 +01:00
bismurphy
8fdb4cce13
Rework g_unkGraphicsStruct (#1175)
I noticed that this struct had some overlap with other values in memory,
so I have pulled all those values into this struct.

The boundaries of this struct are uncertain and are a matter of ongoing
research.
2024-05-26 15:51:25 +01:00
Luciano Ciccariello
a7015bcbd7
Rename D_80072EF4 to padSim (#1168)
Discovered in #1167, where when the player approaches the red door it
forces the input. The line `g_Player.padPressed = g_Player.padSim;`
makes it even more obvious.

This needs to be rebased upon the other PR, otherwise it will break the
build if merged.
2024-05-24 19:59:00 +01:00
Jonathan Hohle
867c7e12c8
Rename Symbols For Scroll Position and Delta (#1158)
Based on their use in the game loop and during stage updates, it appears
the renamed variables store the scroll position delta for the current
loop and store off the current position for future delta calculation.
These vars are then used by stage code to determine if any entities need
to be created or destroyed based on the new position.
2024-05-22 21:28:04 +01:00
Luciano Ciccariello
ac8c3699c7
Weapon 051 (#1120)
Helping Mazen with his weapon modding
2024-05-11 23:29:26 +01:00
sozud
af23477a11
_SsSeqPlay (#1092) 2024-03-04 19:36:00 +00:00
Luciano Ciccariello
05e0334de3
DRA DrawMapCursor (#1079)
![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/e3b9b89c-6a6b-49a9-8804-b0f49da6dc79)

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

I renamed `D_8003C104` as `g_ClutIds`. I am not a fan of the name, but
it gets used by `poly->clut = g_ClutIds[xyz]`, the function that
populates the table is called `GetClut` and the [official
docs](file:///run/media/xeeynamo/wd_black/SDK/sony_ps1/psyq_sdk/DOCS/LIBREF46.PDF)
mentions _Calculates and returns the texture CLUT ID_ . So that seems to
be the most appropriate name.
2024-02-23 16:14:38 -08:00
sozud
cbf9f780d7
SpuVmInit (#1069)
Thanks to @Gillou68310
2024-02-19 11:23:05 -08:00
Mark Street
41ad71e388
Pass undefined_syms files to linker (#1065)
Creating a PR for this, will look at updating splat in a separate PR
2024-02-18 14:57:03 +00:00
sozud
f4e7805417
_SpuIsInAllocateArea_ (#1064) 2024-02-18 10:51:57 +00:00
sozud
276e8840f4
Spu note2pitch (#1062) 2024-02-17 13:49:11 -08:00
sozud
97e07c61d8
SsUtKeyOff SpuVmKeyOff (#1059) 2024-02-15 00:19:10 +00:00
sozud
6eb5b40e60
_SsClose (#1057) 2024-02-13 23:53:08 -08:00
Ross Squires
2294523fcc
Decomp CD_set_test_parmnum, CdReadCallback, & CdLastPos (#1056) 2024-02-11 11:33:03 -08:00
sozud
34185eebfa
Libsnd libspu 5 (#1050) 2024-02-10 11:06:42 +00:00
sozud
84871534cb
Fix some libsnd symbols (#1042) 2024-02-06 23:18:57 +00:00
Luciano Ciccariello
6011e02320
DRA RenderEntities (non matching) (#1034)
Another disappointing non-match, even closer than #1008 . There is only
one registry swap in one single line. I've been permuting for a day
without success. Putting this here if anyone wants to give it a try:
https://decomp.me/scratch/AuSvv
2024-02-06 10:54:35 -08:00
Luciano Ciccariello
62f28078c1
Remove overlapping symbols (#1040)
There were some symbols overlapping with the `g_Entities` array. By
fixing them I also de-faked `func_801B519C`. I included the removal of
`g_api_AllocPrimitives` too as I did not see much point of doing it in a
separate PR.

I am still unsure of the size of `g_CastleFlags` and unfortunately I
doubt it will be clearer before start decompiling new stage overlays.
2024-02-06 18:45:17 +00:00
Luciano Ciccariello
5f3c92dc72
DRA import 627C4 and 63ED4 data (#1037) 2024-02-05 23:39:41 +00:00
Luciano Ciccariello
04c9f49aef
DRA RenderTilemap (#1008)
I've been wanting to match this for a long time. I matched it by pure
coincidence by moving things around. This is one of the few functions
were the permuter was completely useless.

The function renders a room tilemap, with its background and foreground
layers. This is also the first function that uses the PlayStation 1
scratchpad. It took me a few trials to understand how to use it. This
match gives me the confidence to match the much bigger functions
`RenderPrimitives` and `RenderEntities`. They will be my next targets.

I noticed there were a few wrongs in the rendering system. I used one of
the PSY-Q SDK samples to help me understanding how to implement
`PutDrawEnv` and how to render a `SPRT`. The stealth changes in this PR
aims to easily have the tilemap rendering working. The map currently
appears black. This is not a regression, but the lack of logic of
loading a room.
2024-01-25 00:18:29 +00:00
Luciano Ciccariello
beb89d55a6
ItemTypes to EquipKind and blendMode to drawMode (#999)
[EquipKind](https://discord.com/channels/1079389589950705684/1087866009983139870/1196073673392652388)
group decision


[drawMode](https://discord.com/channels/1079389589950705684/1087866009983139870/1197935480428302476)
group decision

I was thinking a more soft PR, but in the light of `BLEND_VISIBLE` to
`DRAW_HIDE`, a mass rename would have happened anyway. So I decided to
rename everything since the majority of the code stands on the same line
of `BLEND_VISIBLE`.

The only changes other than the mass rename are:

```c
#define blendMode drawMode // maintained to easily migrate existing scratches
```
this might or not be useful

.

```c
#define DRAW_DEFAULT 0x00
#define DRAW_TRANSP 0x01   // make it semi transparent
#define DRAW_COLORS 0x04   // use color blending
#define DRAW_HIDE 0x08     // do not render the primitive
#define DRAW_TPAGE 0x10    // use custom tpage
#define DRAW_NOMENU 0x80   // do not render if D_800973EC is set
#define DRAW_ABSPOS 0x2000 // use absolute coordinates with DRAW_NOMENU
```
This is based on the research from the
[RenderPrimitives](https://decomp.me/scratch/geI8L) function.
2024-01-20 13:16:03 -08:00
Luciano Ciccariello
c539d3be9a
DRA AddToInventory (#978)
It took me over a year to understand this one.
2024-01-14 09:52:36 -08:00
Luciano Ciccariello
181f715ff2
DRA assets config (#948)
Creates the file `config_us.c` with all the configuration needed for the
game to know where to locate files in the disc (previously
`lba_stage.c`), equipments, accessories, menu strings (previously
`lang_us.c`, , spells, relics and enemy structures. There is also an exp
table for levelling up but I did not import it yet.

This is a major change in the codebase on how we handle assets.
Previously they were exported as JSON in `assets/dra`. The main problem
is that strings were not properly compiled, still relying on hardcoded
offsets expected to be found in the `.rodata` section.

I deducted all those information belong to a single C file because the
same strings in rodata were referenced from equipment to enemies. If
those strings are found in the same C file, the compiler will optimise
duplicated strings by de-duplicating them. This is how I reached the
conclusion of having all those definitions in a single file.

Obviously the major pain point of this is that a JSON was much more
declarative and easy to be consumed. Especially if tools were going to
use those files. Counting the commas with the struct definition on the
side is not the best thing for modding.

I had to comment out the HD `lba_stage` as it would require a major work
to support the Japanese text.
2024-01-07 02:28:34 +00:00
sozud
abad025e80
Fix svm_cur, add some symbols (#910) 2023-12-29 19:57:34 +00:00
bismurphy
bc13f83e48
Refactor g_Player.D_80072F00 (#904)
Loops in EntityAlucard and UpdateEntityRichter indicate that these 16
elements of g_Player are an array of 16 values. The known ones appear to
be player status effect timers.

While those functions have a long-standing issue preventing them from
matching, they provide enough evidence to suggest that we should make
this change. I have changed all existing uses, and changed the symbols
so that any remaining non-decompiled functions will use the proper form.

It would probably be beneficial to make an enum for the 16 elements of
this new array, but I'll hold off on that for now until we can identify
the purpose of more of them.

---------

Co-authored-by: Luciano Ciccariello <Xeeynamo@users.noreply.github.com>
2023-12-28 08:49:07 +00:00
Luciano Ciccariello
60a167896f
Fix D_80097488 overlaps (#879)
Remove a bunch of fake symbols that were overlapping with `D_80097488`.
I created a new struct called `Pos`. Since it is very similar to
`Camera` I placed them close-by as in future we might want to merge
them.

I created some symbol hints like `D_8009748A_x_i_hi` as there are a few
functions that still use them.
2023-12-22 20:52:51 +00:00
sozud
bb49cf9b96
SpuVmNoiseOff (#871) 2023-12-19 12:21:08 -05:00
Luciano Ciccariello
f88ded1823
PSXSDK: libgpu ext, sys (#862)
Decompile all the `ext.c` and a good chunk of `sys.c`
2023-12-18 16:27:54 -05:00
bismurphy
968a14a380
Rename some entity functions (#826)
After finding a copy of GetFreeDraEntity in RIC, I decided to rename the
function (in both DRA and RIC) to GetFreeEntity. Similarly, the function
right after it is GetFreeEntityReverse (since its logic runs in
reverse).

I also found CreateEntFactoryFromEntity in RIC, so I renamed that to
match the version in DRA. We will need to go through and use the FACTORY
macro for its uses, but I'm not going to tackle that quite yet.

Seems there is a lot of work to be done making RIC catch up to DRA,
we'll see if I keep working on that moving forward, it's neat to find
the ways the two match.
2023-12-10 10:08:41 -08:00
bismurphy
564640c219
Decompile DRA HandleSaveMenu (#812)
This appears to generate the menu that appears when you use a save room.
This is obvious by the strings present in the many calls to
`func_800F9D88`.

Appears to be closely related to some other functions which may make the
logic a bit more obvious. Cool to have this working though, might be
useful for some types of research into how saving works. I wonder if all
these messages have actually showed up before for real players.

Many of the strings feature Shift-JIS characters (specifically, the
periods, question marks, and the 0, 1, and 2 numerals). Big thank you to
Sozud for helping me understand those weird bytes in the strings!

Parsing rodata for strings is pretty fun!

Happy to change the name of this function, but wanted to at least
replace the numerical placeholder.
2023-12-02 08:14:53 -08:00