Commit Graph

35 Commits

Author SHA1 Message Date
Luciano Ciccariello
9861f51336
Extract stage map into individual files (#1316)
This took me a lot of manual work. But I think I confirmed a pattern
that will help me to automate all of this for all the next stage
overlays that will be imported in the repo.

I noticed some stages with only one room having more than two layers or
more than two tile definitions, it might be either debugging or unused
content? I did not have time to explore any of that.

I modified the `tiledef` splat extension to greatly minimise the set-up
and noise.
2024-06-13 20:01:10 +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
bismurphy
4ae980706e
Decompile NO3 EntityDeathCutscene (#1309)
As far as the duplicate-finder can tell, this is the last of the
cutscenes, but who knows - we may find more. Luckily, the pattern is
pretty recognizable.

Named it due to what we see at the very end in `case 7`, with the
TimeAttackController getting triggered.
2024-06-12 10:09:19 -07:00
Luciano Ciccariello
e685273893
Move WRP data to match C file structure (#1292)
More data imported into the C files. I reached this stopgap due to
`st_debug.c`, where I am failing to import the data from PSP. Strangely
enough, PSP suggests `st_debug`, `e_breakable` and even `warp` being in
the same file?!

The INIT section seems to follow the `PfnEntityUpdates` on both PSP and
PSX. But on PSX this is very close to the top while on PSP is right in
the middle.

Overall the PSX C and DATA order seem to align perfectly. PSP is far
more unpredictable, but the DATA order seem to also follow the C files.
The advantage of PSP is that almost everything is out of order compared
to PSX, which easily suggests file splits.

Another key difference between PSP and PSX is that arrays filled with
`0x00` are found in DATA on PSX and in BSS on PSP.
2024-06-09 21:14:03 -07:00
Luciano Ciccariello
7a5baed841
Share more code and data between stage overlays (#1281)
Given the fact that sharing compiled C objects is not exactly possible
(code heavily copy&pasted maybe? this initiative is now abandoned 👉
53a566f075)
I decided to keep pressing forward with shared headers. Thanks a lot to
@hohle for making our life much easier by cross-referencing symbols.

The file split on WRP seems to be the closest file split we might have
compared to the original source code (still speculating here). I think
it would be a good idea to start splitting other overlays too with the
same approach.

My idea is to have a file split like the following:

```
st/
   cen/
       e_particles.c
       e_misc.c
       st_common.c
   nz0/
       e_particles.c
       e_misc.c
       st_common.c
   wrp/
       e_particles.c
       e_misc.c
       st_common.c
   e_particles.h
   e_misc.h
   st_common.h
```

each of those C files will just be a one-line `#include
"../the_shared_code.h"` as usual. Right now we create individual headers
for single functions, sometimes for more than one function when we think
grouping makes sense. But I think we can start merging some of those
headers and consolidate the code. This can be done gradually. For
example `src/st/e_particles.h` is still importing function headers under
the hood. That is okay for now, but later on I wish to import those
headers functions into their respective parent headers.

Another important aspect to consider that will validate a correct file
split is to start importing the data inside these new C files. Right now
we have floating data such as `src/st/wrp_psp/wrp_data_EA00.c` or
monstrosities such as `src/st/wrp/6FD0.c`. An example of a (possibly)
correct migrated data is what this PR does with WRP PSP and NZ0 PSX,
with data pointing in `src/st/*/e_particles.c`.
2024-06-08 20:34:58 +01:00
Luciano Ciccariello
0b9e94c4d3
EntityRedDoor matching (#1167)
Another One Bites the Dust

It matches 1:1 with the PSP counterpart too:
https://decomp.me/scratch/z1VlU
2024-05-24 19:41:07 +01:00
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
Luciano Ciccariello
f9ed954c29
EntityStageNamePopup (#994)
Decompile and de-duplicate EntityStageNamePopup for all the overlays the
function is in.

I also detected a helper function I renamed as `PrimDecreaseBrightness`
that was originally accepting a completely wrong parameter type. This
helped me to get rid of `Unkstruct_80128BBC` too.
2024-01-19 03:07:13 +00:00
Luciano Ciccariello
a5fb6df72c
Deduplicate functions and un-fake use of some Primitive structs (#991) 2024-01-18 19:04:04 +00:00
Luciano Ciccariello
78d7d0f20c
MAD func_8019bed4 (#806)
Follow-up to #797 by decompiling the MAD counterpart and share all the
functions within the same file. I renamed the function as
`UnkPrimHelper` as I do not know what it does.
2023-11-23 20:04:41 +00:00
bismurphy
3642dca31d
Decompile highly duplicated GTE-using function (#797)
Not sure what this one does, but it's in all the overlays.

I couldn't get `mad` to work, since it gives errors when I reference
functions like `RotMatrixZ` (which isn't even one of the new `gte_`
defines). I figured we can leave that for later since `mad` is its own
weird thing.

I also found an issue with the splat for `no3` where some boundaries
were being drawn in the wrong places; this is now corrected which allows
the function to work in that location.

The function takes a primitive as its argument and does some stuff with
it. I don't know what it actually does. It appears that the different
overlays use it in different places (and some overlays don't call it at
all). The function loads an external SVECTOR from a variable, which I
added to the `.h` file for each overlay. The vector is in a weird
location in some overlays, especially in no3 where it appears to be the
last few bytes of the rodata.

Anyway, happy to take naming ideas for either the function or the
SVECTOR that it loads. And I imagine we'll end up renaming those sp
variables.

We have a lot of casts and especially LOH calls in this one. Maybe we're
interpreting the primitive wrong. It doesn't match up with the FakePrim
we've been using lately, so I don't know what to make of this.

I think those are the main highlights! There aren't many functions that
use the GTE and it's nice that there is so much duplication so we can
deal with a lot of them all at once. I expect a lot of changes on this
one so please don't hold back :)

Here's the scratch for one instance of the function, in case you'd like
to play around with anything: https://decomp.me/scratch/N5RR5
2023-11-20 16:28:33 -08:00
Luciano Ciccariello
bc92406dcc Update external tools (#764)
Occasional maintenance:

* asm-differ: latest commit
* m2c: latest commit
* maspsx: latest commit
* spimdisasm: 0.18.0 latest
* splat: 0.17.3

The latest version of splat is 0.19.1 but a breaking change in
[0.18.0](https://github.com/ethteck/splat/pull/294) is preventing me to
upgrade further ([discussion
here](https://discord.com/channels/710646040331681844/813939516385525790/1172978921000669274))

Some YAML were malformed and since splat 0.17.0 there are additional
checks to ensure they are compliant. There are also new checks that
prevents a malformed symbol list including duplicates, which I fixed
too.
2023-11-19 13:44:44 +00:00
Luciano Ciccariello
24f92e9a3c
Revert "Update external tools" (#776)
Reverts Xeeynamo/sotn-decomp#764 due to the CI failing at fetching
decompme
2023-11-16 09:02:15 +00:00
Luciano Ciccariello
14c55dc75b
Update external tools (#764)
Occasional maintenance:

* asm-differ: latest commit
* m2c: latest commit
* maspsx: latest commit
* spimdisasm: 0.18.0 latest
* splat: 0.17.3

The latest version of splat is 0.19.1 but a breaking change in
[0.18.0](https://github.com/ethteck/splat/pull/294) is preventing me to
upgrade further ([discussion
here](https://discord.com/channels/710646040331681844/813939516385525790/1172978921000669274))

Some YAML were malformed and since splat 0.17.0 there are additional
checks to ensure they are compliant. There are also new checks that
prevents a malformed symbol list including duplicates, which I fixed
too.
2023-11-15 23:38:30 +00:00
Luciano Ciccariello
fa21ce1442
Enhance make extract on PSX (#662)
Previously if either the YAML or the symbol list were changed, we were
forced to either manually delete the `asm` folder of the specific
overlay or to invoke `make clean`, where the latter forced us to
re-extract all the overlays via `make -j extract`.

That changes with this PR. How `make` works is `target: dep1 dep2` where
if one of the dependencies has the last modified date greater than the
target, the rule is triggered again. Previously we were extracting
overlays doing `make extract_stcen`. But since every overlay extraction
generates a linker script I now changed the rules to do `make
build/us/stcen.ld` to extract the same overlay. As I explained above, if
either the YAML or one of the related symbols changes, the linker
modified date will be older and the extraction for that overlay to be
trigger again.

The above allowed me to stop polluting the repo root with the linker
scripts as they are now moved into `build/us` or `build/hd` depending of
what you're trying to build. If you do `make extract` twice in a row you
will be welcomed with a `make: Nothing to be done for 'extract'.`.

There are still some instances where you **might** need `make clean`
beforehand, especially when modifying the `segment` section in the YAML
or renaming the symbols. A `rm -rf asm/$(VERSION)/$*` can help but I
want to see if the current solution will be enough.

### Please try removing `make clean` from your workflow, once this is
merged, to quickly detect possible problems with this new approach.

I am also planning to make more substantial changes on our build-chain
like this PR or #660 in the future. I am aiming to small incremental
changes over time in case I break someone's flow or detect design flaws.
I am also considering the breaking changes introduced in make 4.4, which
will most likely be included in Ubuntu 24.04 LTS. I set March 2024 as a
deadline to finish all the new build-chain work.

---------

Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-10-05 09:26:29 +01:00
Luciano Ciccariello
0461c80c33
Start sharing some common stage code (#464)
Following up #454 , #453 and related from @sozud , I started to convert
some previously defined headers into proper shared C code. The advantage
from the header is the C file is completely independent, it will have
its own `.data` and `.rodata` and it will be compiled once.

I also took the opportunity to move `include/st/AnimateEntity.h` to
`src/st/animate_entity.h` for consistency. I think the change is small
enough to be included as part of this PR.
2023-09-02 23:55:48 -07:00
Luciano Ciccariello
9cf510b37d
Decompile EntityMessageBox (#536)
![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/e967866c-1349-4264-b089-d5debc1e5d7a)

Used to display a temporary message that displays a certain information
to the player. It needs a new name before getting merged.
2023-09-01 10:08:20 +01:00
Luciano Ciccariello
4adf1da469
EntityRelicOrb duplicates (#529)
As I finished importing the data in WRP, I came with a possible new
pattern when de-duplicating functions. I kept using a header file
(easily indexable from VS Code) in `src/st`. But this time it gets
included by `entity_relic_orb.c`. All the sections `.data`, `.rodata`
and `.text` are migrated into `entity_relic_orb.c` but the file itself
just includes `src/st/entity_relic_orb.h`. Thinking forward, once we
will be able to fix the problem present in #464 it will just be a matter
of renaming `entity_relic_orb.h` into `entity_relic_orb.c` and remove
each individual `entity_relic_orb.c` that currently acts as a proxy.

~~This PR is a draft. If you agree this is a good pattern I will proceed
to do the same with the remaining overlays after #528 is good to be
merged.~~
2023-08-30 19:59:19 +01:00
Alejandro Asenjo Nitti
9be9460716
NO3 EntityWargExplosionPuffOpaque (#525)
https://decomp.me/scratch/9mxII
2023-08-29 10:32:09 -07:00
Alejandro Asenjo Nitti
14ddc656c5
NO3 EntityDeath (#523)
https://decomp.me/scratch/I4ap0

![image](https://github.com/Xeeynamo/sotn-decomp/assets/96613413/e0efb102-514d-48c2-9f71-9d3c0b2c695c)

Ahhh, Alucard. What is your business here?
2023-08-28 22:41:32 +01:00
Alejandro Asenjo Nitti
945bf69a4b
NO3 EntityDeathStolenItem (#519)
https://decomp.me/scratch/0vUkl

Co-authored-by:  @pixel-stuck
2023-08-28 09:02:18 -07:00
Alejandro Asenjo Nitti
8286b24fb9
NO3 & NP3 EntityStairwayPiece + merman rock Docs (#511)
![image](https://github.com/Xeeynamo/sotn-decomp/assets/96613413/8cd5262d-cdbc-40c0-bb46-3ace3f0ba316)

I've been trying to match this one since two weeks now, i very happy to
finally being able to decompile it.
https://decomp.me/scratch/AZMMV

I'm including a few duplicates and doc corrections since they are in the
same file for consistency.
2023-08-25 19:00:12 -07:00
Alejandro Asenjo Nitti
3d82553abd
NO3 EntityCastleDoor (#470) 2023-08-14 09:04:20 +01:00
sozud
967db3e206
Split on TestCollisions (#456)
This splits on TestCollisions, giving a block of the following 3
functions in a separate file and that are fully decompiled with the
exception of MAD.

```
#include "../random.h"
#include "../update.h"
#include "../update_stage_entities.h"
```

It should now be possible to change the build system to make that a C
file that is shared among the overlays.
2023-08-08 13:07:51 -07:00
sozud
93257d5eab
Split files at Random() (#450)
The point of this PR is splitting overlays at the `Random()` function in
preparation for making it a C file eventually. After this I will do a
split at `Update()`. I have a script to partially automate this that I
will include in a separate PR.
2023-08-07 23:35:35 -07:00
bismurphy
a7edf4380b
Decompile NO3 EntityRoomTransition2 (#405)
I'm still not super confident decompiling jump table/rodata functions,
but I think I did this one right. Took a while fighting the splat to get
things to match.

Two things of note with this function. Thing 1: In my initial
decompilation, I had the local variables `newEntity`, `i`, and
`primIndex`. I found that `i` and `primIndex` used the same register,
and in my code I was seeing them on different registers. I ended up
lumping them into one variable. Since it serves two totally unrelated
purposes, I don't have a good name for it, so I just called it localVar.

Thing 2: The function starts by preloading pointers for `g_Entities` and
`g_CurrentRoomTileLayout`. I couldn't get the compiler to do this by
itself, so I ended up creating two local variables that hold these
locations. It's ugly, but I guess it works.

This ends up matching. Note that this calls my other recently-decompiled
function func_800FF7B8/InitStatsAndGear (which is how I wound up
decompiling this one in the first place), so these two PR's will create
a conflict since this one still calls that function by its old name.

---------

Co-authored-by: bismurphy <bismurphy@users.noreply.github.com>
Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-07-30 13:55:38 -07:00
Mark Street
a4475e0655
use jlabel for rodata labels (#260)
Compare https://decomp.me/scratch/dhUE5 with
https://decomp.me/scratch/NZt5p.

e.g. with this PR:


![image](https://github.com/Xeeynamo/sotn-decomp/assets/22226349/bf999863-a66f-4b64-abbe-a41e4be34181)

vs without:

![image](https://github.com/Xeeynamo/sotn-decomp/assets/22226349/04141d82-aedd-4451-817c-ff98e9e10a17)
2023-06-18 15:17:36 +01:00
Alejandro Asenjo Nitti
61373e862c
NZ0 + NP3 Functions (#181)
NZ0:
EntityAxeKnight (I'm proud to present the first enemy decompiled in the
project perhaps?)
Here is the scratch in case somebody wants to tune it and provide
changes:
https://decomp.me/scratch/LKkYQ

EntitySubWeaponContainer
EntityBloodSplatter
func_801B69E8
func_801C0D08
func_801C9E98

NP3:
EntityBloodSplatter
EntityZombie
func_801B8CC0
2023-04-12 23:20:57 +01:00
Alejandro Asenjo Nitti
22cd239a2a
Remaining EntityEquipItemDrop duplicates (#165) 2023-03-26 16:25:05 +01:00
Luciano Ciccariello
a7e5a1f80f EntityPrizeDrop matching 2023-03-25 21:42:31 +00:00
Luciano Ciccariello
137f4b80c2 Extract g_Rooms for all the overlays 2023-03-13 21:15:25 +00:00
Luciano Ciccariello
d7417b7375 Change how game assets are managed 2023-02-21 23:25:31 +00:00
Luciano Ciccariello
089bbcb252 Writes built binaries into build/us/ 2023-02-21 20:06:27 +00:00
Luciano Ciccariello
e03a4d15e2 Change assembly location from asm/ to asm/us/ 2023-02-21 19:12:52 +00:00
Luciano Ciccariello
651deb2f82 Rename config folder to use game version 2023-02-21 01:42:33 +00:00