mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
allocate_mario_action fix and improvement (#453)
This commit is contained in:
parent
610bdfcf04
commit
31c2e23c48
7 changed files with 31 additions and 6 deletions
|
@ -7597,6 +7597,9 @@ ACT_IDLE = 0x0C400201
|
|||
--- @type integer
|
||||
ACT_ID_MASK = 0x000001FF
|
||||
|
||||
--- @type integer
|
||||
ACT_INDEX_MASK = (ACT_ID_MASK & ~ACT_GROUP_MASK)
|
||||
|
||||
--- @type integer
|
||||
ACT_INTRO_CUTSCENE = 0x04001301
|
||||
|
||||
|
@ -7672,6 +7675,12 @@ ACT_METAL_WATER_WALKING = 0x000044F2
|
|||
--- @type integer
|
||||
ACT_MOVE_PUNCHING = 0x00800457
|
||||
|
||||
--- @type integer
|
||||
ACT_NUM_ACTIONS_PER_GROUP = (ACT_INDEX_MASK + 1)
|
||||
|
||||
--- @type integer
|
||||
ACT_NUM_GROUPS = ((ACT_GROUP_MASK >> 6) + 1)
|
||||
|
||||
--- @type integer
|
||||
ACT_PANTING = 0x0C400205
|
||||
|
||||
|
|
|
@ -2714,6 +2714,7 @@
|
|||
- ACT_HOLD_WATER_JUMP
|
||||
- ACT_IDLE
|
||||
- ACT_ID_MASK
|
||||
- ACT_INDEX_MASK
|
||||
- ACT_INTRO_CUTSCENE
|
||||
- ACT_IN_CANNON
|
||||
- ACT_IN_QUICKSAND
|
||||
|
@ -2739,6 +2740,8 @@
|
|||
- ACT_METAL_WATER_STANDING
|
||||
- ACT_METAL_WATER_WALKING
|
||||
- ACT_MOVE_PUNCHING
|
||||
- ACT_NUM_ACTIONS_PER_GROUP
|
||||
- ACT_NUM_GROUPS
|
||||
- ACT_PANTING
|
||||
- ACT_PICKING_UP
|
||||
- ACT_PICKING_UP_BOWSER
|
||||
|
|
|
@ -151,6 +151,10 @@
|
|||
#define ACT_GROUP_AUTOMATIC /* 0x00000140 */ (5 << 6)
|
||||
#define ACT_GROUP_OBJECT /* 0x00000180 */ (6 << 6)
|
||||
|
||||
#define ACT_INDEX_MASK (ACT_ID_MASK & ~ACT_GROUP_MASK)
|
||||
#define ACT_NUM_GROUPS ((ACT_GROUP_MASK >> 6) + 1)
|
||||
#define ACT_NUM_ACTIONS_PER_GROUP (ACT_INDEX_MASK + 1)
|
||||
|
||||
#define ACT_FLAG_STATIONARY /* 0x00000200 */ (1 << 9)
|
||||
#define ACT_FLAG_MOVING /* 0x00000400 */ (1 << 10)
|
||||
#define ACT_FLAG_AIR /* 0x00000800 */ (1 << 11)
|
||||
|
|
|
@ -2678,6 +2678,9 @@ char gSmluaConstants[] = ""
|
|||
"ACT_GROUP_CUTSCENE = (4 << 6)\n"
|
||||
"ACT_GROUP_AUTOMATIC = (5 << 6)\n"
|
||||
"ACT_GROUP_OBJECT = (6 << 6)\n"
|
||||
"ACT_INDEX_MASK = (ACT_ID_MASK & ~ACT_GROUP_MASK)\n"
|
||||
"ACT_NUM_GROUPS = ((ACT_GROUP_MASK >> 6) + 1)\n"
|
||||
"ACT_NUM_ACTIONS_PER_GROUP = (ACT_INDEX_MASK + 1)\n"
|
||||
"ACT_FLAG_STATIONARY = (1 << 9)\n"
|
||||
"ACT_FLAG_MOVING = (1 << 10)\n"
|
||||
"ACT_FLAG_AIR = (1 << 11)\n"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "smlua.h"
|
||||
#include "sm64.h"
|
||||
#include "behavior_commands.h"
|
||||
#include "pc/mods/mod.h"
|
||||
#include "src/game/object_list_processor.h"
|
||||
|
@ -851,11 +852,11 @@ struct LuaHookedMarioAction {
|
|||
struct Mod* mod;
|
||||
};
|
||||
|
||||
#define MAX_HOOKED_ACTIONS 128
|
||||
#define MAX_HOOKED_ACTIONS (ACT_NUM_GROUPS * ACT_NUM_ACTIONS_PER_GROUP)
|
||||
|
||||
static struct LuaHookedMarioAction sHookedMarioActions[MAX_HOOKED_ACTIONS] = { 0 };
|
||||
static int sHookedMarioActionsCount = 0;
|
||||
u32 gLuaMarioActionIndex = 0;
|
||||
u32 gLuaMarioActionIndex[ACT_NUM_GROUPS] = { 0 };
|
||||
|
||||
int smlua_hook_mario_action(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
@ -1564,7 +1565,7 @@ void smlua_clear_hooks(void) {
|
|||
hooked->mod = NULL;
|
||||
}
|
||||
sHookedBehaviorsCount = 0;
|
||||
gLuaMarioActionIndex = 0;
|
||||
memset(gLuaMarioActionIndex, 0, sizeof(gLuaMarioActionIndex));
|
||||
}
|
||||
|
||||
void smlua_bind_hooks(void) {
|
||||
|
|
|
@ -98,7 +98,7 @@ static const char* LuaActionHookTypeArgName[] = {
|
|||
"max (dummy)",
|
||||
};
|
||||
|
||||
extern u32 gLuaMarioActionIndex;
|
||||
extern u32 gLuaMarioActionIndex[];
|
||||
|
||||
int smlua_hook_custom_bhv(BehaviorScript *bhvScript, const char *bhvName);
|
||||
|
||||
|
|
|
@ -441,8 +441,13 @@ bool is_transition_playing(void) {
|
|||
///
|
||||
|
||||
u32 allocate_mario_action(u32 actFlags) {
|
||||
actFlags = actFlags & (~((u32)0x3F));
|
||||
return actFlags | ACT_FLAG_CUSTOM_ACTION | gLuaMarioActionIndex++;
|
||||
u32 actGroup = ((actFlags & ACT_GROUP_MASK) >> 6);
|
||||
u32 actIndex = gLuaMarioActionIndex[actGroup]++;
|
||||
if (actIndex >= ACT_NUM_ACTIONS_PER_GROUP) {
|
||||
LOG_LUA("Cannot allocate more actions for group %u", actGroup);
|
||||
return 0;
|
||||
}
|
||||
return (actFlags & ~ACT_INDEX_MASK) | ACT_FLAG_CUSTOM_ACTION | actIndex;
|
||||
}
|
||||
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue