Commit Graph

2094 Commits

Author SHA1 Message Date
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
dc101d0ac7
BlitChar (#1237)
The function itself is matching for me locally but wrp.bin doesn't
match. I think it's possibly a wrong file split?
https://decomp.me/scratch/tsOag
2024-06-02 19:17:35 +01:00
bismurphy
d7f107d76f
Decompile Weapon 27 EntityWeaponAttack (#1238)
Started working on this one and then I realized it's identical to the
one on the previous shield, so it was a direct copy-paste, aside from
the names of the D_C1000 variables.

Maybe we'll de-duplicate in the future but for now I think weapons
should just be written individually.
2024-06-02 16:17:26 +01:00
bismurphy
b191658841
Decompile Weapon 27 func_ptr_80170024 (#1234)
I'm pretty sure this has to be the laser beams for the Medusa Shield.
They get spawned by the EntityWeaponShieldSpell.

This function is a pretty big mess. It could probably benefit from a
cleanup pass, potentially using PSP to assist.

But for now, the goal is matching, so hey, this matches :)
2024-06-01 16:50:44 -07:00
sozud
e390b2b9e1
Merge BottomCornerText (#1235) 2024-06-01 23:59:58 +01:00
sozud
d7efc69663
Merge prim_helpers (#1233) 2024-06-01 23:49:41 +01:00
sozud
446a0dfbe5
Factor out CreateEntity (#1236) 2024-06-01 23:48:50 +01:00
Luciano Ciccariello
270d8c6d3b
Add TILE rendering to SDL2 DrawOTag (#1232)
This allows the fade-in / fade-out effect from `func_801027C4` and the
content from `DrawEntitiesHitbox` to be rendered on screen.

The fade-in is a bit weird, it fades out to white instead of black. I
doubt the rendering is accurate at the moment, but better than not
showing anything.
2024-06-01 22:21:26 +01:00
Luciano Ciccariello
c1c39ba701
Fix AnsiToSotnMenuString to not spam logs (#1231)
Now with a much faster start-up
2024-06-01 21:30:12 +01:00
bismurphy
32b0664b5d
Fix args for func_80118B18 (#1230)
The Medusa Shield's laser-beams use this function for finding enemies to
target (I think).

I was reviewing this function and noticed the awkward line `if ((arg2 <<
0x10) != 0) {`, and realized that means `arg2` should be `s16`. It
matches, so I think this is right.

Named it facingLeft since that's what is used in the call that I have so
far. The function graphs indicate that there are 3 functions that use
this one (none decompiled yet), so we will see if this shifts as we
discover more. For now, I think this change makes the most sense.
2024-06-01 12:58:51 -07:00
bismurphy
0876d7d09f
Decompile W27 (Medusa Shield) EntityWeaponShieldSpell (#1229)
Noticing a lot of similarity among the shield spells. Not enough to
de-duplicate them, but enough that decompiling them is a breeze.

Unless there is something else that takes my attention, I will probably
focus on decompiling all the shields next. I'm already done with 2 and
there aren't many in the game.
2024-06-01 12:49:08 -07:00
bismurphy
45d7ab009e
Decompile weapon 28 EntityWeaponAttack (#1228)
This finishes out the Skull Shield.

Nothing too terribly special. I added a new #define for the player
status flag at 0x10000, since that's used here. Hopefully we can find
the function that actually sets that flag; I couldn't find it.
2024-06-01 12:39:28 -07: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
bismurphy
ea0134f497
Decompile Weapon 28 func_ptr_80170024 (#1226)
Secondary function for the Skull Shield. Gets spawned by the ShieldSpell
that just got merged.

I also noticed too late that my previous PR reverted the update to
mwccgap since I hadn't updated that; this PR includes a fix to that
accidental revert.
2024-06-01 11:29:15 -07:00
bismurphy
8947665c9d
Decompile Weapon 28 shield spell (#1225)
This one was a beast, but nice to get it working.

This seemed to match the same entity extension as weapon 29. Weapons 28
and 29 are both shields, so I decided to rename the Weapon29 struct to
be Shield instead. We will see if it continues to match for the future
shields.

This had a ton of FIX(), enums, #defines, etc, so hopefully I got them
all :)
2024-06-01 16:23:14 +01:00
sozud
14d3d9154c
BottomCornerText (#1224)
Seems to use a different character encoding on PSP.
https://decomp.me/scratch/OZfBf
2024-06-01 10:55:44 +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
sozud
7b8e97898f
EntityMessageBox (#1220)
https://decomp.me/scratch/nMwCS
2024-05-30 16:10:22 -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
24f1a1524a
factor out blinkitem (#1217) 2024-05-30 23:41:37 +01:00
sozud
4ba815e4ef
Factor out CollectHeartVessel (#1216) 2024-05-30 23:27:00 +01:00
sozud
385ad23949
Factor out UpdateRoomPosition (#1214) 2024-05-30 23:26:36 +01:00
Luciano Ciccariello
6cebe27c78
Delete tools/update.h
It was probably created by accident
2024-05-30 22:56:09 +01:00
sozud
0e805bafc6
Factor out CollectHeart (#1215) 2024-05-30 22:49:08 +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
64420082be
Nicer logs (#1212)
![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/81e07623-f2d5-4b00-9624-7aa678593aa8)

Add colours to the various logs to make sense out of all the produced
noise. Also gets rid of the square brackets and use a nicer column
separator. Don't mind the error log being mis-labeled. My hunger for
copy&pasting code consistently betrays me.


![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/1873521f-cb41-4a80-aa0c-7e6b6a752ffa)

but most importantly groups the logs to avoid spamming the same one for
every frame. The log count keeps getting updated on the left-hand side
of the log, replacing the beginning of the path (almost never relevant).
If the log is old, the logging function will go back, update the line
and go back down.

It is a tad bit slower than the original implementation, but logs are
never meant to be seen anyway, especially debug logs. I used a
relatively fast hashing function paired with a dictionary to avoid
unnecessary loops. There are two hashes. `logHash` simply works as an
index to the massive 65K entry dictionary to pick an index. If an entry
is found then check the other hash `altHash` to check if the dictionary
collided with an actually different log, effectively replacing it. Since
`entry->hash` is `0` at the beginning, that also works for new elements.

I believe the slowest part of the code are the two `while (nLinesBack--
> 0)`. I am thinking to maybe unroll the loop in a similar way `memcpy`
works internally to save `fputs` calls. But I have little clue on how to
measure improvements. If you know better on how to take advantage of
moving the cursor through the TTY, please let me know.

You can disable this entire functionality with `#define
FORCE_LINEAR_LOGS` and it gets disabled if `stderr` is not printing on a
terminal.
2024-05-30 22:10:53 +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
9df2df24fc
De-duplicate ClutLerp (#1206)
Another de-duplication done using my automated script. Still finding
some bugs, but these results are promising. The process becomes an
absolute breeze.
2024-05-28 18:48:34 -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
sozud
0057eb08ae
WRP PSP EntityIntenseExplosion (#1201) 2024-05-27 23:26:27 +01: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
sozud
e1e0a40bdc
PrimDecreaseBrightness (#1195)
I created Primitive2 to avoid doing a big refactor. Not sure how correct
the struct definition is or not but putting it up for comments.
https://decomp.me/scratch/DzATf
2024-05-27 19:14:32 +01: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
4d4c039ac4
Fix zero-related bug in decompile.py (#1194)
When using the `dec` script, it is possible to select a function where
there are multiple functions sharing a name. The test case I had for
this was `EntityEquipItemDrop`. If you run `dec EntityEquipItemDrop`, it
will tell you that there are 4 occurrences of functions with that name,
and list the four, telling you to re-run with -n or -f to specify which.

If you choose to specify option #0, with `dec EntityEquipItemDrop -n 0`,
then the number_occurence variable will be set to zero. But the
if-statement `if number_occurrence` fails, because the value is zero,
which is parsed as False. Decompilation therefore fails, as if you had
not passed `-n`.

This change explicitly tests for None, so that zero is a valid
selection.
2024-05-27 18:13:38 +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