Commit Graph

2293 Commits

Author SHA1 Message Date
bismurphy
12f8f7149d
Decompile w58 (Alucart Shield) Shield Spell (#1439)
This modifies a variable at 0x80097420, I noticed that was in the
g_UnkGraphicsStruct, so I went through all the uses of that variable and
made them all use the struct.
2024-07-26 19:13:51 +01:00
bismurphy
4b425c4cd0
Decompile RIC func_8015A9B0 (#1438)
This finishes RIC.

Very similar to the most recent DRA function 80115394, so noted that
here.
2024-07-26 12:29:12 -04:00
bismurphy
8cd4eb91bc
Decompile DRA func_80115394 (#1436)
Brings DRA up to one function remaining.

I think everything is in order, but looking forward to any suggestions.

The last missing function is a pretty irrelevant Kanji function, so it
will be nice to have all the material to really start understanding DRA
now.
2024-07-26 08:53:04 -04:00
SynaMax
e81fbf3ca1
SFX defines for Karma Coin (#1423) 2024-07-26 08:44:27 -04:00
Luciano Ciccariello
c9f6e2b1b3
NP3 first steps to align C extraction (#1430)
Start to perform a series of code refactoring to align the various
overlays on how NZ0, WRP and RWRP are currently organised, aiming to
share as much code as possible. This is a good stop gap that does not
change too much. There are virtually no major changes other than the
removal of the fake symbol `D_8003BEEC`.

I found it is very hard to share every single line of code due to some
minor differences in the castle flags. I couldn't yet spot a reliable
pattern on how castle flags are manager across stages.

My vision is to share as much code as possible, possibly not as header
files but as C files in a similar fashion of #1425 . I am aiming to
model NP3 so we can merge it with NO3 given the fact they share a good
chunk of the code base.

I am waiting to split the rest of the entities into their own individual
files. My idea is to have a file per entity or per entity group with
their own set of data and helper functions, possibly all marked as
`static`. We agreed it is probably a good idea to wait exploring the PSP
build of NZ0, NO3 or NP3 before performing this step.
2024-07-26 08:36:05 -04:00
Josh Lory
ef4bd2feef
Idea: allow postfixing of func names (#1435)
Now that @sozud has added function similarity, I wonder if it's worth
including prefix matches in the results of function_finder. This would
let us name a scratch ex: `EntityWeaponAttack_w_053` and have it still
show up in functions.md. Thoughts?
2024-07-26 07:59:12 -04:00
sozud
1e0458ff10
cd funcs (#1431)
some of these by @joshlory
2024-07-25 07:54:53 -04:00
sozud
3ae8f4d883
Compare function similiarity in function_finder (#1432)
This changes the psx function finder to compare the local and remote asm
to find a match. Right now there's a lot of false positives due to name
collisions. The new output looks like this:

https://gist.github.com/sozud/4eaa80c2ebb475551986b4f55d42d036

This should be off by default for the other platforms but I can't check
saturn locally right now.
2024-07-25 08:30:34 +01:00
Josh Lory
91ddf19d8f
Decompile NO3 func_801CE740 (#1433)
https://decomp.me/scratch/inbZb
2024-07-24 20:43:23 -04:00
sozud
1d53f6e715
cd funcs (#1429)
some funcs by @joshlory
2024-07-22 22:20:33 +01:00
sozud
4fe662c4e3
Import gte code, candle test button (#1422)
This imports the psycross gte code and hooks it up. I added a hotkey to
create a candle with a subweapon. As far as I can tell you can't give
yourself a subweapon directly without breaking stuff since
EntityBreakable and the entity it spawns set up various things. I used
this to test the gte. This also fixes a couple of function pointers like
CheckCollision to fix the cross animation. This removes a few gte
functions we previously implemented in favor of their versions, I'm not
sure about the tradeoffs there.
2024-07-22 22:20:01 +01:00
Mark Street
20c3370f4f
Use allegrex assembler for PSP (#1424)
I moved *some* of the PSX-specific stuff out of the common `Makefile`
and into the `Makefile.psx.mk` -- there is still more that could be done
here, but this should be enough to have the correct rules for PSX and
PSP with the desired assembler.


Also threw in a bonus feature where I've removed the `move` macro from
`macro.inc` because `maspsx` does this automagically for you now.
2024-07-22 15:36:28 -04:00
sozud
6d727283f1
PSX libcd funcs (#1426) 2024-07-22 18:36:10 +01:00
bismurphy
54009dbdcb
Attempt fixing analyze_calls build issue (#1428)
Iterating on this problem in master.

Now that wrp/rwrp are sharing so much code, analyze_calls is having
trouble telling what functions call each other in which overlay.

I think this will resolve all the issues we have for now, but I'm sure
more will appear over time.
2024-07-22 12:32:19 -04:00
Luciano Ciccariello
b8f87761e7
Merge RWRP with WRP (#1425)
This will decompile all the functions but the new `EntityRWarpRoom` from
the RWRP overlay.

Note that as `e_misc.c` has a function with a different castle flag, I
had to use a shared header. Everything else was identical.

---------

Co-authored-by: bismurphy <tjmurphy@mit.edu>
2024-07-22 10:57:21 -04:00
Luciano Ciccariello
99bb97e859
HD WRP matching (#1421)
Mostly identical to MAD and PSP. There are four very different functions
from US that needs to be decompiled to be 100% complete:
* [x] `e_misc.c` `EntityMessageBox`
* [x] `e_misc.c` `EntityRelicOrb`
* [x] ~`e_stage_name.c` `StageNamePopupHelper`~ it does not exist
* [x] `e_stage_name.c` `EntityStageNamePopup`

These four very different functions are the only ones that use the JP
text instead of the US one. This overlay also lacks of `BlitChar`.

`EntityStageNamePopup` is very similar to the PSP counterpart. I used
@joshlory scratch to match the HD part.

`EntityRelicOrb` had some #ifdef between US and BETA (aka the MAD
overlay). I found some code that crossed between BETA and HD, so I just
put an `#else` after `VERSION_US`. We are starting to reconstruct how
the source code originally evolved across different game builds.
2024-07-19 19:05:26 -05:00
Josh Lory
2ec252543a
Decompile DRA EntityPlayerDissolves (#1420)
PSX: https://decomp.me/scratch/6ucWC
PSP: https://decomp.me/scratch/70r4s
2024-07-18 20:57:49 -07:00
bismurphy
9a08a85b8f
Decompile SEL func_801B99E4 (#1419)
The vast majority of this comes from a 6-month-old scratch by
@ser-pounce , here: https://decomp.me/scratch/7Ram0

I finished it up, and made some changes to make it fit into the current
state of the repo.

That scratch puts the isrgb24 value into a StreamCtl struct. I'm
inclined to agree with that, but want to minimize the impact of this PR
on the larger repo for the moment. I expect StreamCtl to be used more
heavily in the final function for SEL, but we'll see how that goes.

The StreamEnv struct is in exactly the same location as
Unkstruct_801B9B7C (which was actually unused), so I eliminated that
one.

That's just about all I have to say for now.
2024-07-17 21:20:24 -07:00
bismurphy
2dfedc44c3
Rework D_8003C908 (#1418)
The next function of SEL, func_801B99E4, makes it clear that D_8003C908
is not a struct member. I do not know why it was placed in this struct.
I have that function now matching, but since we're changing around
variables that are used elsewhere, I decided to split the PR so that we
can handle one type of change at a time.

The D_8003C908 variable has not yet been used in any C code, so this
change does not affect anything.

Further, since both struct members were s32, I decided to make it a
2-member array for the sake of conciseness in the code.
2024-07-17 19:13:53 -07:00
bismurphy
023c8676af
Decompile SEL func_801B38B4 (#1417)
I'm frustrated about DRA so I'm taking a bit of a diversion - I noticed
SEL only has three functions left, so here's the first of three!
2024-07-17 17:36:28 -07:00
sozud
c48138c65e
Tetra spirit fixes, macro system (#1413)
This adds some fixes to get tetra spirit mostly working. It copies part
of the framebuffer with MoveImage to warp it, so that's added. Right now
there's some bugs with DrawEnv or DispEnv stuff so that the copy is from
the wrong place every other frame and shows as black. There's a couple
of out of bound issues that have speculative fixes I'm not sure about.

The spells are hard for me to do so I added a macro/hotkey system to be
able to test them quickly. I tried calling the spell functions directly
but they didn't work right. I think there's probably code scattered
around to support them so doing the inputs is the only way to activate
it all correctly
2024-07-17 15:13:17 -07:00
bismurphy
f2e4197cfe
Decompile DRA EntityGuardText (#1416)
This brings us down to 3 DRA functions.

Some kind of weird stuff, like PSP using an extra function (I kept the
function forward-declaration in here for reference once we bring in PSP
DRA). It also uses a dedicated struct, so I'm defining that at the
location of the function, to keep it clean.
2024-07-17 13:58:31 -07:00
Luciano Ciccariello
91a0dab64e
e_collect.c adjustments (#1412)
Changelog:
* Import all the PSP WRP data that belong to `e_collect.c`
* Remove the `ext.generic` use in favour of `ET_EquipItemDrop`
* Document some fields from `ET_EquipItemDrop`
* Discover the extra field `mariaSubWeapon` on PSP
* `g_api.AddToInventory` signature changed to allow a better match on
[EntityEquipItemDrop](https://decomp.me/scratch/PULKm)
* Remove the fake array `D_8003BF9C` in favour of `g_CastleFlags`
* The `O_TAG` struct is also valid on PSP
* Decompile `EntityPrizeDrop` on PSP
* Align `func_8018CAB0` to PSP
* Align `EntityPrizeDrop` to PSP with a bunch of `#ifdef`
* Align `EntityEquipItemDrop` to PSP using the WIP scratch
[EntityEquipItemDrop](https://decomp.me/scratch/PULKm)
* `DestroyCurrentEntity` is just an dummy item collector from
`EntityPrizeDrop`
* Duplicate functions in other overlays are not yet aligned as I am
waiting to migrate them to use `e_collect`


I noticed splat is not able to successfully recognise pointers if the
data is too scattered. I had to merge the `data` in the YAML and allow
it to be exported into a single file before starting to import it.

The only missing function from `e_collect.c` is
[EntityEquipItemDrop](https://decomp.me/scratch/PULKm).

Data on PSX are slightly shuffled within the same C file. I believe the
PSP build retains the original data order.

Thanks to @sozud for the majority of the work on `EntityPrizeDrop` and
`EntityEquipItemDrop` on PSP. And thanks to @bismurphy for solving the
last piece of the puzzle to match `EntityPrizeDrop`.
2024-07-17 20:22:31 +01:00
bismurphy
8c5bb8d625
Decompile RIC EntityPlayerBlinkWhite (#1414)
Wow! With this one, Richter is now down to a single non-matching
function (it's a duplicate of a DRA function which is missing - the one
with the funny pointer math which is connected with
EntityPlayerDissolves).

Anyway, we're matching. This is different from DRA's
EntityPlayerBlinkWhite, but in weird ways that made it a huge pain to
get matching. Definitely was not a matter of replacing a few lines like
some duplicated functions are.

Anyway, looking forward to see if there's anything to fix!
2024-07-17 12:05:56 -07:00
bismurphy
d2db3606a2
Decompile DRA EntityNumberMovesToHPMeter (#1415)
This was decompiled by @joshlory , but due to some annoying rodata, I
ended up taking over the PR on their behalf and submitting. The file
split here was a bit tricky to get right, but now we're matching.

I did not do any reviewing of this code, it is presented here as it was
made by josh's scratch.
2024-07-16 21:27:16 -07:00
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