mirror of
https://github.com/leoetlino/project-restoration
synced 2025-10-05 16:22:49 +02:00
Remove version utilities
rst only targets v100 now that patches are provided to downgrade all other versions to v100
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,9 +9,7 @@
|
||||
*.map
|
||||
newcodeinfo.h
|
||||
build/
|
||||
hooks/
|
||||
bak/
|
||||
/source/Version.cmake
|
||||
|
||||
# IDA
|
||||
*.id*
|
||||
|
@@ -22,14 +22,8 @@ build () {
|
||||
|
||||
print_status "building for $TARGET_VERSION"
|
||||
|
||||
# Copy the version-specific hooks
|
||||
rm -r $RST_ROOT/hooks/ || true
|
||||
mkdir $RST_ROOT/hooks
|
||||
cp $RST_ROOT/$TARGET_VERSION/hooks.hks $RST_ROOT/hooks/
|
||||
|
||||
# Copy the version-specific build files
|
||||
cp $RST_ROOT/$TARGET_VERSION/*.bin $RST_ROOT/
|
||||
cp $RST_ROOT/$TARGET_VERSION/Version.cmake $RST_ROOT/source/
|
||||
|
||||
# Touch main.cpp to get an up-to-date build time
|
||||
touch $RST_ROOT/source/rst/main.cpp
|
||||
@@ -55,7 +49,7 @@ build () {
|
||||
# Clean up
|
||||
rm -r $RST_ROOT/loader/*.bin $RST_ROOT/loader/*.sym || true
|
||||
rm -r $RST_ROOT/*.bin $RST_ROOT/*.sym || true
|
||||
rm -r $RST_ROOT/bak $RST_ROOT/hooks || true
|
||||
rm -r $RST_ROOT/bak || true
|
||||
}
|
||||
|
||||
build v100
|
||||
|
@@ -45,16 +45,14 @@ I personally consider the project to be pretty much complete. The game is **play
|
||||
* `common/`: small utilities.
|
||||
* `game/`: implementation for the known parts of *Majora's Mask 3D*. Contains headers and some reimplementation of game functions.
|
||||
* `rst/`: *Project Restoration* code.
|
||||
* `v100/`, `v101/` and `v110/`: Version-specific data.
|
||||
* `hooks.hks`: configuration for patches and hooks (for Magikoopa).
|
||||
* `Version.cmake`: defines for *Project Restoration* code.
|
||||
* `hooks/`: configuration for patches and hooks (for Magikoopa).
|
||||
* `loader/`: Code loader (from [Magikoopa](https://github.com/RicBent/Magikoopa)).
|
||||
|
||||
Sometimes you will find *Project Restoration* extensions and new code under `source/game`. Those extensions will always be clearly labelled as such.
|
||||
|
||||
### Build instructions
|
||||
|
||||
* Put the original code.bin and exheader.bin in v100, v101 and v110.
|
||||
* Put the original code.bin and exheader.bin files in the v100, v101 and v110 folders respectively. You must dump those binaries from the ExeFS yourself; those are **not** provided in this repository for copyright reasons.
|
||||
* Run make_release.sh. You need git and Magikoopa in your PATH. **Currently, a [fork](https://github.com/leoetlino/Magikoopa) is required**.
|
||||
* Generated code patches (code.bps) and patched exheaders can be found in `release/`.
|
||||
|
||||
|
@@ -97,5 +97,3 @@ add_custom_target(newcode_product ALL
|
||||
COMMAND sh -c "${CMAKE_OBJDUMP} -t newcode.elf>newcode.sym"
|
||||
BYPRODUCTS newcode.bin newcode.sym
|
||||
)
|
||||
|
||||
include(Version.cmake)
|
||||
|
@@ -9,23 +9,14 @@
|
||||
|
||||
namespace rst::util {
|
||||
|
||||
#if defined(RST_VER)
|
||||
constexpr u32 Version = RST_VER;
|
||||
#else
|
||||
constexpr u32 Version = 0;
|
||||
#endif
|
||||
static_assert(Version == 0 || Version == 1, "Unknown version");
|
||||
|
||||
template <class... Ts, typename std::enable_if_t<(Version < sizeof...(Ts))>* = nullptr>
|
||||
constexpr uintptr_t GetAddr(Ts... addresses) {
|
||||
return std::get<Version>(std::forward_as_tuple(addresses...));
|
||||
constexpr uintptr_t GetAddr(uintptr_t addr) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
/// Returns a version-specific address from a list of addresses and casts it to Type*.
|
||||
template <typename Type, class... Ts>
|
||||
constexpr auto GetPointer(Ts... addresses) {
|
||||
static_assert(Version < sizeof...(Ts), "Missing address!");
|
||||
return reinterpret_cast<Type*>(GetAddr(addresses...));
|
||||
template <typename Type>
|
||||
inline auto GetPointer(uintptr_t addr) {
|
||||
return reinterpret_cast<Type*>(GetAddr(addr));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -36,11 +27,10 @@ static void InitIfNeeded(T* instance, bool* init_flag, void (*init_fn)(T*)) {
|
||||
init_fn(instance);
|
||||
}
|
||||
|
||||
template <class T, class... A, class... B, class... C>
|
||||
static T& GetInstance(std::tuple<A...> ptrs, std::tuple<B...> flags, std::tuple<C...> fns) {
|
||||
T* instance = std::apply([](auto&&... a) { return GetPointer<T>(a...); }, ptrs);
|
||||
InitIfNeeded(instance, std::apply([](auto&&... a) { return GetPointer<bool>(a...); }, flags),
|
||||
std::apply([](auto&&... a) { return GetPointer<void(T*)>(a...); }, fns));
|
||||
template <class T>
|
||||
static T& GetInstance(uintptr_t ptr, uintptr_t init_flag, uintptr_t init_fn) {
|
||||
T* instance = GetPointer<T>(ptr);
|
||||
InitIfNeeded(instance, GetPointer<bool>(init_flag), GetPointer<void(T*)>(init_fn));
|
||||
return *instance;
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@ namespace game {
|
||||
|
||||
CommonData& GetCommonData() {
|
||||
// Right before the static context in .bss.
|
||||
return *rst::util::GetPointer<CommonData>(0x7751D8, 0x7761D8);
|
||||
return *rst::util::GetPointer<CommonData>(0x7751D8);
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
@@ -15,7 +15,7 @@ static void PlayerChangeStateToStill(Player* player, GlobalContext* gctx) {
|
||||
} // namespace
|
||||
|
||||
FormParam& GetFormParam(FormParamIndex idx) {
|
||||
return rst::util::GetPointer<FormParam>(0x7AE9E8, 0x7AF9E8)[u8(idx) % 8];
|
||||
return rst::util::GetPointer<FormParam>(0x7AE9E8)[u8(idx) % 8];
|
||||
}
|
||||
|
||||
Player::ArrowInfo Player::GetArrowInfo(GlobalContext* gctx) const {
|
||||
|
@@ -10,8 +10,7 @@ namespace game::sound {
|
||||
class StreamMgr;
|
||||
|
||||
static StreamMgr& GetStreamMgr() {
|
||||
return rst::util::GetInstance<StreamMgr>(std::tuple{0x7CB49C}, std::tuple{0x6B0A3C},
|
||||
std::tuple{0x1E11F8});
|
||||
return rst::util::GetInstance<StreamMgr>(0x7CB49C, 0x6B0A3C, 0x1E11F8);
|
||||
}
|
||||
|
||||
bool PlayEffect(EffectId id) {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
namespace game {
|
||||
|
||||
StaticContext& GetStaticContext() {
|
||||
return *rst::util::GetPointer<StaticContext>(0x7892D0, 0x78A2D0);
|
||||
return *rst::util::GetPointer<StaticContext>(0x7892D0);
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
@@ -173,8 +173,7 @@ Anim* LayoutClass::GetAnim(std::string_view name) const {
|
||||
}
|
||||
|
||||
LayoutMgr& LayoutMgr::Instance() {
|
||||
return rst::util::GetInstance<LayoutMgr>(std::tuple{0x7CDC9C}, std::tuple{0x6B0AFC},
|
||||
std::tuple{0x16963C});
|
||||
return rst::util::GetInstance<LayoutMgr>(0x7CDC9C, 0x6B0AFC, 0x16963C);
|
||||
}
|
||||
|
||||
void LayoutMgr::FreeLayout(Layout* layout) {
|
||||
|
@@ -1 +0,0 @@
|
||||
target_compile_definitions(newcode PRIVATE RST_VER=0)
|
@@ -1 +0,0 @@
|
||||
target_compile_definitions(newcode PRIVATE RST_VER=1)
|
@@ -1,87 +0,0 @@
|
||||
zora_swim_1a:
|
||||
# Remove fast swim magic check
|
||||
type: patch
|
||||
data: E3A00001
|
||||
addr: 0x00220F50
|
||||
reverse: true
|
||||
zora_swim_1b:
|
||||
# Remove fast swim magic check
|
||||
type: patch
|
||||
data: E3A00001
|
||||
addr: 0x002210CC
|
||||
reverse: true
|
||||
zora_swim_1c:
|
||||
# Remove fast swim magic check
|
||||
type: patch
|
||||
data: E3A00001
|
||||
addr: 0x001FFDA8
|
||||
reverse: true
|
||||
zora_swim_2:
|
||||
# Change fast swim start trigger (A+R -> A)
|
||||
type: branch
|
||||
link: true
|
||||
func: rst_trampoline_rst_link_ShouldUseZoraFastSwim
|
||||
addr: 0x220EEC
|
||||
zora_swim_2:
|
||||
type: patch
|
||||
data: 00 F0 20 E3 01 00 50 E3
|
||||
addr: 0x220F1C
|
||||
zora_swim_3a:
|
||||
# Change fast swim continue trigger (A+R -> A)
|
||||
type: branch
|
||||
link: true
|
||||
func: rst_trampoline_rst_link_ShouldUseZoraFastSwim
|
||||
addr: 0x1FFD64
|
||||
zora_swim_3a:
|
||||
type: patch
|
||||
data: 00 F0 20 E3 00 F0 20 E3 01 00 50 E3
|
||||
addr: 0x1FFD68
|
||||
zora_swim_3b:
|
||||
# Change fast swim continue trigger (A+R -> A)
|
||||
type: branch
|
||||
link: true
|
||||
func: rst_trampoline_rst_link_ShouldUseZoraFastSwim
|
||||
addr: 0x1FFA74
|
||||
zora_swim_3b:
|
||||
type: patch
|
||||
data: 00 F0 20 E3 00 F0 20 E3 01 00 50 E3
|
||||
addr: 0x1FFA78
|
||||
zora_swim_4:
|
||||
type: patch
|
||||
data: EA000009
|
||||
addr: 0x00220EF0
|
||||
reverse: true
|
||||
|
||||
fix_transformation_mask_equip_checks_1:
|
||||
# prevent forced transform when mask is not equipped
|
||||
type: patch
|
||||
data: E12FFF1E
|
||||
addr: 0x001E76A0
|
||||
reverse: true
|
||||
fix_transformation_mask_equip_checks_2a:
|
||||
# remove other checks (fix first-person mode, Goron rolling and potentially more)
|
||||
type: patch
|
||||
data: EA00003B
|
||||
addr: 0x001EDFA4
|
||||
reverse: true
|
||||
fix_transformation_mask_equip_checks_2b:
|
||||
type: patch
|
||||
data: EA000052
|
||||
reverse: true
|
||||
addr: 0x001F78BC
|
||||
|
||||
decouple_trigger_btns:
|
||||
type: patch
|
||||
data: 12 00 00 EA # skips over the ZL/ZR checks
|
||||
addr: 0x1167C8
|
||||
|
||||
ice_arrows:
|
||||
type: patch
|
||||
data: 00 F0 20 E3 # nop
|
||||
addr: 0x318898
|
||||
|
||||
main_hook:
|
||||
type: softbranch
|
||||
opcode: post
|
||||
func: rst_Calc
|
||||
addr: 0x106798
|
Reference in New Issue
Block a user