Skip to content

Commit

Permalink
Merge pull request #689 from KEKW555/KEKW555-patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
hytopoulos authored Jan 21, 2024
2 parents eaaeb3a + d7c0273 commit d8a9e54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions include/gba/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

0 comments on commit d8a9e54

Please sign in to comment.