Commit Graph

883 Commits

Author SHA1 Message Date
Luciano Ciccariello
4fa9382271
DRA func_80109A44 matching (#1246) 2024-06-03 18:10:06 +01:00
sozud
0be3e44634
PSP WRP data (#1249) 2024-06-03 18:08:38 +01:00
sozud
9cad49bfde
Start importing wrp data (#1242)
The yaml changes were generated with a script.
https://gist.github.com/sozud/ae6837a24bc8bb4e8bcc89d3e14d83f4

The alignment of the yaml seems to be wrong so I had to check if the
address % 16 == 0 and only split at those spots. I put the data in
create_entity since it's the first file in the psp yaml.
2024-06-02 14:55:37 -07:00
Luciano Ciccariello
db2fc27776
DRA import data at 2F324 (#1240)
I think those are a bunch of animation indices? I am not yet sure how to
represent them as structured data, so there you go having them imported
as C files.
2024-06-02 20:37:19 +01:00
Luciano Ciccariello
97c8090b88
DRA import more data (#1239)
Importing some data from `DBD4` with the goal of making the _Sound_ app
more accurate.

I do not know in which file to put this data into, so I created a file
ad-hoc.

EDIT: I kept importing more
2024-06-02 19:29:17 +01:00
sozud
e390b2b9e1
Merge BottomCornerText (#1235) 2024-06-01 23:59:58 +01:00
Luciano Ciccariello
a221c614be
WRP PSP e_particles (#1227)
Quite a big one. I merged `EntitySoulStealOrb` across all overlays by
normalising the symbol names. The symbol types was all over the place,
so I had to fix that as well.

I solved the s16/u16 ifdef between PSX and PSP. The only part I couldn't
match without a ifdef was `angle = (angle - 1) * 8;` and `angle = (angle
* 8) - 8;`.

I also decompiled the exclusive PSP functions `func_psp_0923AD68` and
`func_psp_0923B2F0` and merged the PSX and PSP `e_particles.c` code. The
exclusive functions required a file split.
2024-06-01 20:32:59 +01:00
sozud
5b82ab061a
EntitySoulStealOrb (#1222)
I'm having trouble integrating the signedness changes but I figure this
gets us closer anyway
https://decomp.me/scratch/R41nc
2024-06-01 10:45:25 +01:00
Luciano Ciccariello
cec8424a09
WRP PSP merge e_room_fg.c (#1221)
Straightforward PR. Interestingly importing the data doesn't seem to
result to a match ad there's some `0x10` aligned padding added. Either
we know too little about importing data with MWCC or the file split was
wrong and the data belonged together with other functions in another C
file.

For now I had to use a `#ifdef`. It will probably get forgotten until we
decide to import the data from WRP PSP.
2024-05-30 16:18:36 -07:00
Luciano Ciccariello
2892fe478b
Merge g_CdVolumeTable with g_VolumeTable (#1219)
I found the variable `distance` in `func_80132A04` can be negative. The
array index will underflow unless the two global variables
`g_CdVolumeTable` and `g_VolumeTable` gets merged
2024-05-31 00:02:21 +01:00
sozud
eaf9e0716f
Factor out EntityIntenseExplosion (#1218) 2024-05-30 23:53:17 +01:00
sozud
626079ffd5
patchgte to asm (#1213)
I think this file is all handwritten asm

patch_gte
https://gist.github.com/sozud/f25a15fe190fc8fa77b59b2278de4d85

func_8001929C
https://gist.github.com/sozud/27df133a0207fa732991b0786ee2f34c

func_8001929C is the code used to patch the bios. The sequence
```
/* 9A3C 8001923C B0000A24 */  addiu      $t2, $zero, 0xB0
/* 9A40 80019240 09F84001 */  jalr       $t2
/* 9A44 80019244 56000924 */   addiu     $t1, $zero, 0x56
```
looks like a bios call to me and I'm not sure this can be generated by a
compiler? Scratch here
https://decomp.me/scratch/TlFnw
2024-05-30 22:43:04 +01:00
Luciano Ciccariello
2ad7900f95
Fix g_LayoutObjHorizontal and g_LayoutObjVertical types (#1209)
As discovered in [one of the recent PSP
functions](https://decomp.me/scratch/thtl9), the types for
`g_LayoutObjHorizontal` and `g_LayoutObjVertical` are not of
`LayoutObject*` but `u16*`. This saves some awkward casts that caused
Clang and modern GCC to fail to compile some recent code (specifically
`((u16*)g_LayoutObjVertical) = ` being not valid C).

This is a bit sad as it reverts part of the changes from #1166 that
aimed to improve code clarity.
2024-05-30 18:34:42 +01:00
bismurphy
1bcc1a2197
De-duplicate CollectGold (#1211)
This one had some small differences in MAD and ST0, so I worked them in
as ifdef.

Also, I cleaned up the function a bit, by removing the unneeded
pointers.

The GoldSizeIndex local variable is unneeded. It is possible to just use
the goldSize argument, and do `-=2`, but I think using the local
variable makes it more readable, so I left it in place.
2024-05-30 09:42:24 -07:00
Mark Street
dc3eb208e5
Bump mwccgap (#1210)
Made a small tweak to mwccgap so that we don't compile a .c file twice
if we don't need to... compiling psp used to take 2.7s and now takes
2.0s on my laptop - so not super noticeable at this point, but makes
sense not to compile things twice!

Also added sha1sum for the wrp.bin to avoid people copying in the wrong
file and having a bad time (dont know why I didnt catch that pspeu means
psp eu.. not psp us!)
2024-05-30 09:18:11 -07:00
sozud
4616104152
EntityEnemyBlood (#1208)
Thanks to @dezgeg
2024-05-29 16:39:13 -07:00
bismurphy
c53c0e82b5
De-duplicate EntityBigRedFireball (#1207)
This is an entity that is in every overlay, but appears to be unused, at
least so far.

It looks just like Gaibon's big fireball (in his second form), but that
is handled by a different entity. Presumably we will find its use in a
future overlay.

I also made some general improvements to the function, such as turning
the weird bit shifting into a simple division by 4, thus eliminating the
variables. I also created an entity extension for this entity.

Another victory for my automated deduplicator.
2024-05-28 20:29:41 -07:00
bismurphy
055f1a1a92
Deduplicate EntityOlroxDrool (#1205)
Another nice de-duplication. Cool to dig into these functions and see
what they do.

Continuing working on my automated de-duplication script. This one was
definitely much easier because of it. I didn't have to track down a
single symbol. In fact, most of my time putting this together was just
commenting in the .h file.
2024-05-28 17:42:15 -07:00
sozud
e04bb37a66
WRP PSP more functions (#1202) 2024-05-28 19:57:19 +01:00
bismurphy
82a41b260c
Deduplicate EntityUnkId14Spawner (#1204)
This spawns several copies of EntityUnkId14, very similarly to the
existing EntityUnkId15Spawner.

Most of the work for this PR (renaming all the functions,
cross-referencing symbols across overlays) was done by an automated
script I made. I am still testing this script, but it is nice to see
that it appears to be starting to work. I will test it on a few more
de-duplication PRs, and then consider adding it to the `tools`
directory.
2024-05-28 10:31:01 -07:00
bismurphy
30396cbb63
De-duplicate EntityUnkId14 (#1203)
Fairly standard function de-duplication PR. Starting to get kind of good
at these! I might look into automating parts of this process to make it
go faster...

Next I'll be doing the unkId14 spawner, which is just like the existing
unkid15 spawner.
2024-05-27 18:24:59 -07:00
bismurphy
6e07dd1831
Dedupe CheckColliderOffsets (#1200)
Found this function which is in every overlay, and is a dependency of
another function I'd like to de-duplicate.

See the comment on the .h file for a description of what this function
appears to do. I think the fact that it's taking the entity's position,
offsetting it based on the provided array, and running CheckCollision
makes CheckColliderOffsets a reasonable name without being too verbose.
Happy to use a different name if anyone has opinions.

This function had been decompiled in a few overlays, but was still
INCLUDE_ASM in others, so this will also unify them to all be
decompiled.
2024-05-27 22:10:20 +01:00
bismurphy
13528519a3
Decompile EntityEquipItemDrop ST0 and MAD (#1199)
Noticed these in the duplicates list. These are different from the
existing EntityEquipItemDrop, but they match each other.

I took the function from `wrp/e_collect.c` and pasted it in, and then
made adjustments until it matched.

Probably not worth de-duplicating. I left comments at the top of these
functions though, as future reminders.
2024-05-27 13:47:09 -07:00
sozud
029fbb7bac
WRP PSP EntityExplosion (#1198) 2024-05-27 20:46:52 +01:00
Luciano Ciccariello
9b39bb764a
WRP PSP merge st_common with PSX (#1197) 2024-05-27 11:32:41 -07:00
Luciano Ciccariello
7fdb064715
GetPlayerCollisionWith matching (#1196)
With this one in, we only have two functions missing to have the first
stage overlay with all the functions decompiled!
2024-05-27 11:21:44 -07:00
Luciano Ciccariello
8abf48df02
WRP PSP check-in more function (#1189)
The highlight is that `src/st/wrp/st_update.c` is shared across the two
overlays. `EntityMessageBox` and `EntityStageNamePopup` are vastly
different.
2024-05-27 18:47:49 +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
bismurphy
28b43f14d2
Decompile MAD BottomCornerText (#1192)
When decompiling MAD TestCollisions in my last PR, I noticed that the
call to BottomCornerText was going to func_80198BC8 in MAD, which was
not yet decompiled.

The duplicates report indicated that func_80198BC8 was a duplicate of
func_97000_8017AB54, a weapon function that I decompiled a few weeks
ago.

I copied the code for that function into here, and renamed it to
BottomCornerText to match the other overlays, even though it's not the
exact same code as is used in other overlays.
2024-05-27 16:27:36 +01:00
bismurphy
f04950a94f
Decompile MAD TestCollisions (#1191)
This should finish out the set :)

Can't say I understand the differences here (it's modifying
g_CastleFlags during the item drop randomization routine for crying out
loud) but hey, a match is a match.
2024-05-27 16:15:14 +01:00
bismurphy
c71ab44fdd
Decompile ST0 TestCollisions (#1190)
Got this one done too! ST0 is slightly simpler than the others.

I tried to adapt the existing matching TestCollisions directly, but I
found that it was easier to work on PSP to get the logic right and then
move to PSX instead.
2024-05-27 15:30:02 +01:00
sozud
c7ddd8281b
Wrp funcs 1 (#1188) 2024-05-27 10:06:22 +01:00
bismurphy
205f0e2156
De-duplicate TestCollisions (#1187)
I think I did this right, but this is my first time de-duplicating a
function, so please point out any mistakes :)

ST0 not included because it has different logic internally - will work
on decompiling that one next.
2024-05-27 10:04:31 +01:00
bismurphy
86af165e69
Decompile NP3 TestCollisions (#1186)
Well here we are, TestCollisions matching!

I'm going to start with this one, and once it's in, I will follow up by
de-duplicating it.

Please review this closely, especially the changes that are happening in
other files than the main C file.

I suspect we will learn a lot from studying this function; I've already
made some changes (including to the Entity struct) but there will surely
be more.

Nice that this was possible with only two `goto` statements.

I expect a fair bit of revision here, especially related to any
enums/defines I might not be aware of. Please be liberal with comments
:)
2024-05-26 20:30:40 -04:00
Luciano Ciccariello
88f221fb1f
ST WRP PSX re-organise C files (#1185)
Same as #1181 but on PSX. The imported data falls right at the top of
each new file based on some old assumptions of mine, suggesting we're
probably on the right track.
2024-05-26 23:44:33 +01:00
sozud
cd87f4da0a
WRP PSP ReplaceBreakableWithItemDrop and more (#1184) 2024-05-26 22:29:34 +01:00
Luciano Ciccariello
92812cc6c9
ST WRP re-organise C files (#1181)
A massive PR, I know. It's the smallest change I could do to make this
happen.

After comparing the function order from both ST/WRP PSX and ST/WRP PSP,
I was able to come up with a file split much different from the one
suggested from Splat. It still returns an 🆗 and it follows the same
group functions order from the two game builds.

As soon as we are on board with the C names, next PR will be to do the
same with the PSX overlay. Then in another PR we will be able to start
merging the C files between the two builds. Ideally the same approach
can be used for sharing C files across the different overlays instead of
relying to floating header files in `src/st`
2024-05-26 20:59:07 +01:00
sozud
2073f27ed0
WRP PSP UpdateRoomPosition (#1180) 2024-05-26 20:47:27 +01:00
sozud
c0222b4a92
CollectHeartVessel (#1179) 2024-05-26 20:44:22 +01:00
Luciano Ciccariello
fdb4b11359
PSP WRP functions (#1178)
A bunch of functions where I am using the shared headers whenever I
could. The plan is to switch into C files on the first good opportunity.
2024-05-26 19:58:12 +01:00
sozud
b0d6f28633
CollectHeart (#1177) 2024-05-26 19:30:35 +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
sozud
461d3338d9
FallEntity (#1174)
I get
```
mipsel-linux-gnu-ld: build/pspeu/src/st/wrp_psp/BF50.c.o: in function `FallEntity':
(.text+0x0): undefined reference to `g_CurrentEntity'
mipsel-linux-gnu-ld: (.text+0x4): undefined reference to `g_CurrentEntity'
mipsel-linux-gnu-ld: (.text+0x1c): undefined reference to `g_CurrentEntity'
mipsel-linux-gnu-ld: (.text+0x20): undefined reference to `g_CurrentEntity'
```
Not sure what the issue is
2024-05-26 13:26:51 +01:00
Luciano Ciccariello
5362c8b8da
Add ST/WRP from PSP (#1172)
Extract ST/WRP out of #1119 . All the function symbols should have been
cross-referenced. There as some PSX functions missing from PSP and some
new functions from PSP that are not present on PSX (e.g.
`st_init_wrp.c`).

The files `st_debug.c` and `e_breakable.c` are shared between WRP PSX
and WRP PSP. Everything else from PSP is isolated into its own folder. I
had to do some tricks on the YAML config to allow shared code.

`ST_WRP_MERGE = st_debug e_breakable` in the `Makefile` is a bit
annoying as MWCC complains about every single minute detail from the C
source that has been already decompiled for the PSX US build.

`EntityWarpSmallRocks` is matching on PSP but I couldn't extract the
rodata without having a bunch of linker errors. This might be a Splat
issue. I need to investigate further.

`func_psp_09244760` is soooo interesting. The values from `0x11` to
`0x17` matches the Entity IDs that are unique to the WRP overlay. This
aligns to what we have in `typedef enum EntityIDs`.

Overall I am very excited to the recent discoveries from the PSP build!
2024-05-25 11:56:06 -07:00
Jonathan Hohle
cb5458a693
Refactor entity.h Functions (#1171)
This organizes funcitons believed to be originally found in `entity.c`
into an equivalent `entity.h` based on the research of @Xeeynamo:

* `DestroyEntity`
* `DestroyEntitiesFromIndex`
* `AnimateEntity`
* `PreventEntityFromRespawning`

 Includes `entity.h` in place of stage implementations or ASM.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-05-24 23:56:59 -07: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
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
Jonathan Hohle
d677db6800
Share Stage Function Implementations (#1166)
Pulls out `CreateEntityFromLayout`, `CreateEntityWhenInVerticalRange`,
`CreateEntityWhenInHorizontalRange`, `FindFirstEntityToTheRight`,
`FindFirstEntityToTheLeft`, `CreateEntitiesToTheRight`,
`CreateEntitiesToTheLeft`, `FindFirstEntityAbove`,
`FindFirstEntityBelow`, `CreateEntitiesAbove`, `CreateEntitiesBelow`,
`InitRoomEntities`, `UpdateRoomPosition`,
`CreateEntityFromCurrentEntity`, `CreateEntityFromEntity`,
`EntityIsNearPlayer`, and `InitializeEntity` into headers to share the
implementation between stages.

`libstage.h` is a new header intended to bring in a sequential block of
functions shared by all stages.

`st_private.h` is a new header intended for declaring symbols used by
all stages that aren't otherwise accessible to code outside of a stage.

The only discrepency is `MAD` which has a unique implementation of
`CreateEntitiesToTheLeft`. Instead of being able to blanket include
`libstage.h` it needs to bring in individual headers before and after
its implementation.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-05-24 18:54:44 +01:00
Jonathan Hohle
d46b6666e9
Rename MAD Functions and Symbols (#1164)
These were missed in 3b0943b25a. Renames common stage functions for
later refactor.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
2024-05-23 12:21:49 -07:00