diff --git a/include/asm.h b/include/asm.h index c73f1c8da..dbf374d2f 100644 --- a/include/asm.h +++ b/include/asm.h @@ -16,6 +16,7 @@ extern void GenericConfused(struct Entity_*); extern void sub_08001290(struct Entity_*, u32); extern void GenericKnockback(struct Entity_*); extern u32 GetFuserId(struct Entity_*); +#define GetFuserIdAndFuserTextId(ent) ((union SplitDWord)(*(MultiReturnTypeSingleEntityArg)(&GetFuserId))(ent)) extern u32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); extern u32 GravityUpdate(struct Entity_* entity, u32 gravity); enum { diff --git a/include/gba/syscall.h b/include/gba/syscall.h index 48f35863b..aa09fd9e8 100644 --- a/include/gba/syscall.h +++ b/include/gba/syscall.h @@ -62,4 +62,6 @@ int MultiBoot(struct MultiBootParam* mp); s32 Div(s32 num, s32 denom); +#define DivAndMod(num, denom) ((union SplitDWord)(*(MultiReturnTypeTwoS32Arg)(&Div))(num, denom)) + #endif // SYSCALL_H diff --git a/include/global.h b/include/global.h index 3cd7c1d0b..f62b250d6 100644 --- a/include/global.h +++ b/include/global.h @@ -119,6 +119,17 @@ typedef struct { s8 y; } PACKED Coords8; +union SplitDWord { + s64 DWORD; + u64 DWORD_U; + struct { + s32 LO, HI; + } HALF; + struct { + u32 LO, HI; + } HALF_U; +}; + union SplitWord { s32 WORD; u32 WORD_U; @@ -152,4 +163,10 @@ struct Entity_; #define BIT(bit) (1 << (bit)) #define IS_BIT_SET(value, bit) ((value)&BIT(bit)) +/** + * Multi return function data type casts + */ +typedef u64 (*MultiReturnTypeSingleEntityArg)(struct Entity_*); +typedef s64 (*MultiReturnTypeTwoS32Arg)(s32, s32); + #endif // GLOBAL_H