mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2026-11-07 09:16:07 -10:00
This change adds `WEAPON1` to the `us` build by refactoring the overlay header and `g_HandId`. Where possible, objects are reused between both weapon overlay bundles. Based on the PSP weapon layout it appeared that the header data and `g_HandId` for each weapon were in separate objects from the weapon code and data. Separating them allows the link order to be rearranged between platforms without any code changes or macros. This also eliminates the need to special case function interfaces that differed between weapons. The header only needs to resolve the symbol at link time. A single `w_init` object can be used for all weapons, regardless of hand. `left_hand` and `right_hand` objects can be linked to `w0_*` and `w1_*` weapons, respectively. In the majority of cases, a specific weapon object just needs to be linked to the corresponding "hand" object to match for both `WEAPON0` and `WEAPON1`. This involves a lot of file edits, but the changes are pretty simple: * remove the header `Weapon` struct from each weapon source (defined in `weapon_private.h`) and move into `w_init.c` * remove the `g_HandId` global from each weapon source and move into `left_hand.c` and `right_hand.c` * configure segments for `w_init` and hand and update the build system how to handle multiple data segments. Because `w_init` is resolved at link time, all weapon API functions are no longer `static`. These functions are no longer compiled with the header, so no compile time switches are needed to synchronize the header struct interfaces with the actual function interfaces. Not all `WEAPON1` weapons are matched, primarily because of missing data. This requires either symbol resolution or data imports. This can be done incrementally. Weapons that haven't been matched are using the `asm` segment type out of convenience. The build system has bespoke rules for weapons and this avoided the complexity of generating C stubs for now. There are some weapons that cannot share the same weapon object. For example `w0_051` and `w1_051` differ by one byte in the data segment. These will need to be split into separate objects in a future change. It's not clear to me that the `progress.py` changes will work correctly. Submitting as draft for now for discussion.
12 lines
155 B
Plaintext
12 lines
155 B
Plaintext
SECTIONS {
|
|
.WEAPON_OVL 0x8017D000 : AT(0) SUBALIGN(4)
|
|
{
|
|
*(.data)
|
|
*(.rodata)
|
|
*(.text)
|
|
*(.bss)
|
|
}
|
|
|
|
end = .;
|
|
}
|