You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
shorten call_native command (#733)
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
#define BC_HH(a, b) (_SHIFTL(a, 16, 16) | _SHIFTL(b, 0, 16))
|
||||
#define BC_W(a) ((uintptr_t)(u32)(a))
|
||||
#define BC_PTR(a) ((uintptr_t)(a))
|
||||
#define BC_BPTR(a, b) (_SHIFTL(a, 24, 8) + OS_K0_TO_PHYSICAL(b))
|
||||
|
||||
enum BehaviorCommands {
|
||||
/*0x00*/ BHV_CMD_BEGIN,
|
||||
@@ -180,8 +181,7 @@ enum BehaviorCommands {
|
||||
|
||||
// Executes a native game function.
|
||||
#define CALL_NATIVE(func) \
|
||||
BC_B(BHV_CMD_CALL_NATIVE), \
|
||||
BC_PTR(func)
|
||||
BC_BPTR(BHV_CMD_CALL_NATIVE, func)
|
||||
|
||||
// Adds a float to the specified field.
|
||||
#define ADD_FLOAT(field, value) \
|
||||
@@ -386,8 +386,7 @@ enum BehaviorCommands {
|
||||
|
||||
// Spawns a water droplet with the given parameters.
|
||||
#define SPAWN_WATER_DROPLET(dropletParams) \
|
||||
BC_B(BHV_CMD_SPAWN_WATER_DROPLET), \
|
||||
BC_PTR(dropletParams)
|
||||
BC_BPTR(BHV_CMD_SPAWN_WATER_DROPLET, dropletParams)
|
||||
|
||||
|
||||
const BehaviorScript bhvStarDoor[] = {
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
#include "game/puppylights.h"
|
||||
|
||||
// Macros for retrieving arguments from behavior scripts.
|
||||
#define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused
|
||||
#define BHV_CMD_GET_2ND_U8(index) (u8)((gCurBhvCommand[index] >> 16) & 0xFF)
|
||||
#define BHV_CMD_GET_3RD_U8(index) (u8)((gCurBhvCommand[index] >> 8) & 0xFF)
|
||||
#define BHV_CMD_GET_4TH_U8(index) (u8)((gCurBhvCommand[index]) & 0xFF)
|
||||
#define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused
|
||||
#define BHV_CMD_GET_2ND_U8(index) (u8)((gCurBhvCommand[index] >> 16) & 0xFF)
|
||||
#define BHV_CMD_GET_3RD_U8(index) (u8)((gCurBhvCommand[index] >> 8) & 0xFF)
|
||||
#define BHV_CMD_GET_4TH_U8(index) (u8)((gCurBhvCommand[index]) & 0xFF)
|
||||
|
||||
#define BHV_CMD_GET_1ST_S16(index) (s16)(gCurBhvCommand[index] >> 16)
|
||||
#define BHV_CMD_GET_2ND_S16(index) (s16)(gCurBhvCommand[index] & 0xFFFF)
|
||||
#define BHV_CMD_GET_1ST_S16(index) (s16)(gCurBhvCommand[index] >> 16)
|
||||
#define BHV_CMD_GET_2ND_S16(index) (s16)(gCurBhvCommand[index] & 0xFFFF)
|
||||
|
||||
#define BHV_CMD_GET_U32(index) (u32)(gCurBhvCommand[index])
|
||||
#define BHV_CMD_GET_VPTR(index) (void *)(gCurBhvCommand[index])
|
||||
#define BHV_CMD_GET_U32(index) (u32)(gCurBhvCommand[index])
|
||||
#define BHV_CMD_GET_VPTR(index) (void *)(gCurBhvCommand[index])
|
||||
#define BHV_CMD_GET_VPTR_SMALL(index) (void *)(OS_PHYSICAL_TO_K0(gCurBhvCommand[index] & 0xFFFFFF))
|
||||
|
||||
#define BHV_CMD_GET_ADDR_OF_CMD(index) (uintptr_t)(&gCurBhvCommand[index])
|
||||
|
||||
@@ -316,11 +317,11 @@ static s32 bhv_cmd_end_loop(void) {
|
||||
// Usage: CALL_NATIVE(func)
|
||||
typedef void (*NativeBhvFunc)(void);
|
||||
static s32 bhv_cmd_call_native(void) {
|
||||
NativeBhvFunc behaviorFunc = BHV_CMD_GET_VPTR(1);
|
||||
NativeBhvFunc behaviorFunc = BHV_CMD_GET_VPTR_SMALL(0);
|
||||
|
||||
behaviorFunc();
|
||||
|
||||
gCurBhvCommand += 2;
|
||||
gCurBhvCommand++;
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -734,11 +735,11 @@ static s32 bhv_cmd_parent_bit_clear(void) {
|
||||
// Command 0x37: Spawns a water droplet with the given parameters.
|
||||
// Usage: SPAWN_WATER_DROPLET(dropletParams)
|
||||
static s32 bhv_cmd_spawn_water_droplet(void) {
|
||||
struct WaterDropletParams *dropletParams = BHV_CMD_GET_VPTR(1);
|
||||
struct WaterDropletParams *dropletParams = BHV_CMD_GET_VPTR_SMALL(0);
|
||||
|
||||
spawn_water_droplet(gCurrentObject, dropletParams);
|
||||
|
||||
gCurBhvCommand += 2;
|
||||
gCurBhvCommand++;
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user