Fixing changes for PR: npcPtr to npc, spacing on if, removed else block in EnableNpcShadow that wasn't needed

This commit is contained in:
Jdog 2020-08-19 15:48:15 -07:00
parent 65f1db2e87
commit bc8080788a
4 changed files with 99 additions and 60 deletions

View File

@ -40,6 +40,8 @@ extern Shadow* gWorldShadowList[60];
extern Shadow* gBattleShadowList[60];
extern Shadow** gCurrentShadowListPtr[60];
extern Camera gCameras[4];
extern f32 gGlobalTimeSpace;
extern s8 D_800A0900;

View File

@ -1,6 +1,44 @@
#include "common.h"
INCLUDE_API_ASM(code_ef070_len_3400, SetCamEnabled);
/*
ApiStatus SetCamEnabled(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode cameraID = get_variable(script, *ptrReadPos++);
Bytecode cameraEnable = get_variable(script, *ptrReadPos++);
Camera* cameraPtr = &gCameras[cameraID];
if (cameraEnable == 0) {
cameraPtr->flags |= 0x2;
} else {
cameraPtr->flags &= ~0x2;
}
return ApiStatus_DONE2;
/*
s32 temp_a1;
s32 temp_s0;
s32 temp_v0;
void *temp_s1;
u16 phi_v1;
void *phi_v0;
temp_s1 = arg0->unkC;
temp_a1 = *temp_s1;
temp_s1 = temp_s1 + 4;
temp_s0 = get_variable(temp_a1);
if (get_variable(arg0, *temp_s1) == 0) {
temp_v0 = (temp_s0 * 0x558) + 0x800B1D80;
phi_v1 = *temp_v0 | 2;
phi_v0 = (void *) temp_v0;
} else {
temp_v0 = (temp_s0 * 0x558) + 0x800B1D80;
phi_v1 = *temp_v0 & 0xFFFD;
phi_v0 = (void *) temp_v0;
}
*phi_v0 = phi_v1;
return 2;
}
*/
INCLUDE_API_ASM(code_ef070_len_3400, SetCamFlag80);

View File

@ -14,10 +14,10 @@ INCLUDE_ASM(code_f2470_len_27f0, set_npc_animation);
ApiStatus DeleteNpc(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Npc* npcPtr = get_npc_unsafe(get_variable(script, *ptrReadPos++));
Npc* npc = get_npc_unsafe(get_variable(script, *ptrReadPos++));
if (npcPtr) {
free_npc(npcPtr);
if (npc) {
free_npc(npc);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -42,14 +42,14 @@ ApiStatus SetNpcScale(ScriptInstance* script, s32 isInitialCall) {
f32 sizeX = get_float_variable(script, *ptrReadPos++);
f32 sizeY = get_float_variable(script, *ptrReadPos++);
f32 sizeZ = get_float_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
if (npc != NULL) {
s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching
if (todo) {
npcPtr->scale.x = sizeX;
npcPtr->scale.y = sizeY;
npcPtr->scale.z = sizeZ;
npc->scale.x = sizeX;
npc->scale.y = sizeY;
npc->scale.z = sizeZ;
}
return ApiStatus_DONE2;
}
@ -61,13 +61,13 @@ ApiStatus SetNpcCollisionSize(ScriptInstance* script, s32 isInitialCall) {
NpcId npcID = get_variable(script, *ptrReadPos++);
s32 height = get_variable(script, *ptrReadPos++);
s32 radius = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
if (npc != NULL) {
s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching
if (todo) {
npcPtr->collisionHeight = height;
npcPtr->collisionRadius = radius;
npc->collisionHeight = height;
npc->collisionRadius = radius;
}
return ApiStatus_DONE2;
}
@ -78,10 +78,10 @@ ApiStatus SetNpcSpeed(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
f32 speed = get_float_variable(script, *ptrReadPos);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if(npcPtr != NULL) {
npcPtr->moveSpeed = speed;
if(npc != NULL) {
npc->moveSpeed = speed;
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -91,10 +91,10 @@ ApiStatus SetNpcJumpscale(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
f32 jumpScale = get_float_variable(script, *ptrReadPos);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if(npcPtr != NULL) {
npcPtr->jumpScale = jumpScale;
if(npc != NULL) {
npc->jumpScale = jumpScale;
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -104,10 +104,10 @@ ApiStatus SetNpcAnimation(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
s32 animation = get_variable(script, *ptrReadPos);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
set_npc_animation(npcPtr, animation);
if (npc != NULL) {
set_npc_animation(npc, animation);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -117,10 +117,10 @@ ApiStatus GetNpcAnimation(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
Bytecode outVar = *ptrReadPos++;
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
set_variable(script, outVar, npcPtr->currentAnim);
if (npc != NULL) {
set_variable(script, outVar, npc->currentAnim);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -130,10 +130,10 @@ ApiStatus SetNpcAnimationSpeed(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
f32 animationSpeed = get_float_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
npcPtr->animationSpeed = animationSpeed;
if (npc != NULL) {
npc->animationSpeed = animationSpeed;
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -157,12 +157,12 @@ ApiStatus GetNpcYaw(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
Bytecode outVar = *ptrReadPos++;
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
if (npc != NULL) {
s32 todo = 1; // TODO: Figure out why this variable and subsequent if block is required for matching
if (todo) {
set_variable(script, outVar, clamp_angle(npcPtr->yaw));
set_variable(script, outVar, clamp_angle(npc->yaw));
}
return ApiStatus_DONE2;
}
@ -172,10 +172,10 @@ ApiStatus GetNpcYaw(ScriptInstance* script, s32 isInitialCall) {
ApiStatus SetNpcYaw(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
set_npc_yaw(npcPtr, get_variable(script, *ptrReadPos++));
if (npc != NULL) {
set_npc_yaw(npc, get_variable(script, *ptrReadPos++));
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -195,15 +195,15 @@ ApiStatus EnableNpcShadow(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
s32 enableShadow = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
if (npc != NULL) {
if (enableShadow) {
enable_npc_shadow(npcPtr);
enable_npc_shadow(npc);
return ApiStatus_DONE2;
}
else {
disable_npc_shadow(npcPtr);
disable_npc_shadow(npc);
}
}
return ApiStatus_DONE2;
@ -213,16 +213,14 @@ ApiStatus EnableNpcBlur(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
s32 enableBlur = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
if (npc != NULL) {
if (enableBlur) {
enable_npc_blur(npcPtr);
enable_npc_blur(npc);
return ApiStatus_DONE2;
}
else {
disable_npc_blur(npcPtr);
}
disable_npc_blur(npc);
}
return ApiStatus_DONE2;
}
@ -230,10 +228,10 @@ ApiStatus EnableNpcBlur(ScriptInstance* script, s32 isInitialCall) {
ApiStatus ClearPartnerMoveHistory(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
clear_partner_move_history(npcPtr);
if (npc != NULL) {
clear_partner_move_history(npc);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -247,12 +245,12 @@ ApiStatus GetPartnerPos(ScriptInstance* script, s32 isInitialCall) {
Bytecode posX = *ptrReadPos++;
Bytecode posY = *ptrReadPos++;
Bytecode posZ = *ptrReadPos++;
Npc* npcPtr = get_npc_unsafe(-4);
Npc* npc = get_npc_unsafe(-4);
if (npcPtr != NULL) {
set_variable(script, posX, npcPtr->pos.x);
set_variable(script, posY, npcPtr->pos.y);
set_variable(script, posZ, npcPtr->pos.z);
if (npc != NULL) {
set_variable(script, posX, npc->pos.x);
set_variable(script, posY, npc->pos.y);
set_variable(script, posZ, npc->pos.z);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -285,7 +283,7 @@ ApiStatus func_802CF56C(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
s32 value = get_variable(script, *ptrReadPos++);
if(value == 2) {
if( value == 2) {
func_800EF3E4();
} else {
func_800EF3D4(value);
@ -305,10 +303,10 @@ ApiStatus SetNpcEffect(ScriptInstance* script, s32 isInitialCall) {
NpcId npcID = get_variable(script, *ptrReadPos++);
s32 value1 = get_variable(script, *ptrReadPos++);
s32 value2 = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
func_8003C3D8(npcPtr, value1, value2);
if (npc != NULL) {
func_8003C3D8(npc, value1, value2);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -319,10 +317,10 @@ ApiStatus PlaySoundAtNpc(ScriptInstance* script, s32 isInitialCall) {
NpcId npcID = get_variable(script, *ptrReadPos++);
SoundId soundID = get_variable(script, *ptrReadPos++);
s32 value2 = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
if (npcPtr != NULL) {
play_sound_at_position(soundID, value2, npcPtr->pos.x, npcPtr->pos.y, npcPtr->pos.z);
if (npc != NULL) {
play_sound_at_position(soundID, value2, npc->pos.x, npc->pos.y, npc->pos.z);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
@ -332,9 +330,9 @@ ApiStatus SetNpcRenderMode(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
NpcId npcID = get_variable(script, *ptrReadPos++);
u8 renderMode = get_variable(script, *ptrReadPos++);
Npc* npcPtr = resolve_npc(script, npcID);
Npc* npc = resolve_npc(script, npcID);
npcPtr->renderMode = renderMode;
npc->renderMode = renderMode;
return ApiStatus_DONE2;
}

View File

@ -38,6 +38,7 @@ D_800959D4 = 0x800959D4;
D_8009A5D8 = 0x8009A5D8;
D_8009A650 = 0x8009A650;
D_800A0900 = 0x800A0900;
gCameras = 0x800B1D80;
D_800DC500 = 0x800DC500;
D_8010F6D0 = 0x8010F6D0;
gBackgroundImage = 0x80200000;