Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

LibUser

Jinnosuke9 edited this page Dec 12, 2023 · 3 revisions

What is LibUser?

LibUser is custom code file assembled from the source files inside src/lib_user/. This file is injected into 80700000 address in the memory. This code will be available for all custom actors and most of the code. Boot won't necessary be able to access this code as loading this will not happen immediately on boot. It will be available for boot title and after that.

Main usage for this would be to do your system changes while having good amount of room to change game behaviour.

Another usage would be having your own "PlayState" here, where you have values or states going on. This will be accesible for all files that has #include <uLib.h> included for them.

Limits

LibUser has only 724.00kB reserved for it. Having a ton of data here might not be optimal but can definitely be done.

Asm Vanilla Hook

This will behave somewhat same as LibCode but the difference is in that it will only write a hook into this function. This way you do not need to care about the original code size limitations.

In order to hook a function into here you'll have to have the function name matching exactly to what the z64hdr has that function named. Basically having overlapping name. Also on top of that you'll have to use Asm_VanillaHook macro in order for the hooking to be possible.

Example:

Asm_VanillaHook(Player_IsChildWithHylianShield);
s32 Player_IsChildWithHylianShield(Player* this) {
#if Patch_WieldHylianShieldLikeKokiriShield == true
    
    return 0;
#endif
    
    return gSaveContext.linkAge && (this->currentShield == PLAYER_SHIELD_HYLIAN);
}

Useful New Functions

Debug_Text(r, g, b, x, y, fmt, ...)

  • Draw text on screen

osLibPrintf(fmt, ...)

  • Print text on console, by default the vanilla prints are muted