From 8db43a572f0083265d383b309e3d7cd3c2d68403 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Tue, 6 Oct 2020 16:00:58 -0400 Subject: [PATCH 1/7] decomp some xEnt functions --- asm/Game/zEntPlayer.s | 5 + include/rwsdk/rwcore.h | 19 ++ obj_files.mk | 1 + src/Core/x/xAnim.h | 4 + src/Core/x/xEnt.h | 6 +- src/Core/x/xModel.h | 57 +++++ src/Game/zEntPlayer.cpp | 445 +++++++++++++++++++++++++++++++++++++++- 7 files changed, 533 insertions(+), 4 deletions(-) diff --git a/asm/Game/zEntPlayer.s b/asm/Game/zEntPlayer.s index d1e898686..224b17afc 100644 --- a/asm/Game/zEntPlayer.s +++ b/asm/Game/zEntPlayer.s @@ -1,5 +1,6 @@ .include "macros.inc" +.if 0 .section .text # 0x80066210 - 0x80090E88 zEntPlayer_SpawnWandBubbles__FP5xVec3Ui: @@ -46089,6 +46090,9 @@ zGooIs__FP4xEnt: /* 80090E7C 0008DC7C 7C 08 03 A6 */ mtlr r0 /* 80090E80 0008DC80 38 21 00 10 */ addi r1, r1, 0x10 /* 80090E84 0008DC84 4E 80 00 20 */ blr + +.endif + .section .rodata lbl_80255F00: .incbin "baserom.dol", 0x252EE0, 0x58 @@ -46175,6 +46179,7 @@ lbl_803CB5B0: .global gSpongeBall gSpongeBall: .skip 0x4 +.global lbl_803CB5B8 lbl_803CB5B8: .skip 0x4 lbl_803CB5BC: diff --git a/include/rwsdk/rwcore.h b/include/rwsdk/rwcore.h index 28fd937e2..49ea06345 100644 --- a/include/rwsdk/rwcore.h +++ b/include/rwsdk/rwcore.h @@ -72,6 +72,25 @@ struct RwTexture RwInt32 refCount; }; +struct RwV3d +{ + float x; + float y; + float z; +}; + +struct RwMatrixTag +{ + RwV3d right; + unsigned int flags; + RwV3d up; + unsigned int pad1; + RwV3d at; + unsigned int pad2; + RwV3d pos; + unsigned int pad3; +}; + enum RwFogType { rwFOGTYPENAFOGTYPE, diff --git a/obj_files.mk b/obj_files.mk index 731b04d49..21353cb2f 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -83,6 +83,7 @@ TEXT_O_FILES := \ $(OBJ_DIR)/asm/Game/zEntHangable.o \ $(OBJ_DIR)/asm/Game/zEntPickup.o \ $(OBJ_DIR)/asm/Game/zEntPlayer.o \ + $(OBJ_DIR)/src/Game/zEntPlayer.o \ $(OBJ_DIR)/asm/Game/zEntSimpleObj.o \ $(OBJ_DIR)/asm/Game/zEntTrigger.o \ $(OBJ_DIR)/asm/Game/zEnv.o \ diff --git a/src/Core/x/xAnim.h b/src/Core/x/xAnim.h index 1fcc5dcba..a8b7d29c1 100644 --- a/src/Core/x/xAnim.h +++ b/src/Core/x/xAnim.h @@ -9,4 +9,8 @@ struct xAnimTable { }; +struct xAnimPlay +{ +}; + #endif \ No newline at end of file diff --git a/src/Core/x/xEnt.h b/src/Core/x/xEnt.h index 619762a4b..8b95e649a 100644 --- a/src/Core/x/xEnt.h +++ b/src/Core/x/xEnt.h @@ -1,6 +1,9 @@ #ifndef XENT_H #define XENT_H +#include +#include + #include "xBase.h" #include "xMath3.h" #include "xModel.h" @@ -9,9 +12,6 @@ #include "xBound.h" #include "xFFX.h" -#include -#include - struct xEntAsset : xBaseAsset { uint8 flags; diff --git a/src/Core/x/xModel.h b/src/Core/x/xModel.h index 1ca6471ad..ba01fc0bc 100644 --- a/src/Core/x/xModel.h +++ b/src/Core/x/xModel.h @@ -1,10 +1,67 @@ #ifndef XMODEL_H #define XMODEL_H +#include +#include + +#include "xAnim.h" +#include "xLightKit.h" +#include "xSurface.h" #include "xMath3.h" +struct xModelInstance; + +// TODO: this probably can be simplified +struct _class +{ + xVec3* verts; +}; + +struct xModelBucket +{ + RpAtomic* Data; + RpAtomic* OriginalData; + xModelInstance* List; + int32 ClipFlags; + uint32 PipeFlags; +}; + +struct xModelPool +{ + xModelPool* Next; + uint32 NumMatrices; + xModelInstance* List; +}; + struct xModelInstance { + xModelInstance* Next; + xModelInstance* Parent; + xModelPool* Pool; + xAnimPlay* Anim; + RpAtomic* Data; + uint32 PipeFlags; + float32 RedMultiplier; + float32 GreenMultiplier; + float32 BlueMultiplier; + float32 Alpha; + float32 FadeStart; + float32 FadeEnd; + xSurface* Surf; + xModelBucket** Bucket; + xModelInstance* BucketNext; + xLightKit* LightKit; + void* Object; + uint16 Flags; + uint8 BoneCount; + uint8 BoneIndex; + uint8* BoneRemap; + RwMatrixTag* Mat; + xVec3 Scale; + uint32 modelID; + uint32 shadowID; + RpAtomic* shadowmapAtomic; + _class anim_coll; }; struct xModelTag diff --git a/src/Game/zEntPlayer.cpp b/src/Game/zEntPlayer.cpp index a3044cdce..29601f8bb 100644 --- a/src/Game/zEntPlayer.cpp +++ b/src/Game/zEntPlayer.cpp @@ -1 +1,444 @@ -#include "zEntPlayer.h" \ No newline at end of file +#include "zEntPlayer.h" + +#include "../Core/x/xEnt.h" +#include "../Core/x/xVec3.h" + +#include "zGlobals.h" + +extern zGlobals globals; +extern uint32 lbl_803CB5B8; + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SpawnWandBubbles__FP5xVec3Ui") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerKillCarry__Fv") + +// void zEntPlayerControlOn(zControlOwner owner) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerControlOn__F13zControlOwner") + +// void zEntPlayerControlOff(zControlOwner owner) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerControlOff__F13zControlOwner") + +// void TellPlayerVillainIsNear(float visnear) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "TellPlayerVillainIsNear__Ff") + +// void SetPlayerKillsVillainTimer(float time) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "SetPlayerKillsVillainTimer__Ff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "DampenControls__FPfPfff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "CalcAnimSpeed__FP4xEntfPf") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "LeanUpdate__Fff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "TurnToFace__FP4xEntPC5xVec3ff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerArrive__FP4xEntP5xBase") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerAbsControl__FP4xEntfff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "InvReset__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "HealthReset__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunAnyCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunScaredCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunVictoryCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunSlipCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunOutOfWorldCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "WalkCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "IdleCheck__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "IdleSlipCheck__FP15xAnimTransitionP11xAnimSinglePv") + +// int zEntPlayer_InBossBattle() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_InBossBattle__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "SpatulaGrabCB__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "StopLCopterCB__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "DoWallJumpCheck__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "JumpCB__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "BounceCB__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "DblJumpCB__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "BoulderRollDoneCheck__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "BoulderRollDoneCB__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "speak_update__24_esc__2_unnamed_esc__2_zEntPlayer_cpp_esc__2_Ff") + +// void zEntPlayerSpeakStart(unsigned int sndid, int anim) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerSpeakStart__FUiUii") + +// void zEntPlayerSpeakStop() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerSpeakStop__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "GetPatrickTarget__FP4xEnt") + +// void zEntPlayer_LassoNotify(en_LASSO_EVENT event) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_LassoNotify__F14en_LASSO_EVENT") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "MeleeStopCB__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "LassoSwingBeginCB__FP15xAnimTransitionP11xAnimSinglePv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "StunBubbleTrail__FP11xAnimSingle") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "BubbleBashContrails__FP11xAnimSingle") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "BubbleBounceContrails__FP11xAnimSingle") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "MeleeAttackBoundCollide__FP4xEntP6zSceneP6xBound") + +// int zEntPlayer_IsSneaking() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_IsSneaking__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "load_talk_filter__FPUcP16xModelAssetParamUii") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "count_talk_anims__FP10xAnimTable") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "load_player_ini__FR15zPlayerSettingsR14xModelInstanceP16xModelAssetParamUi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "load_player_ini__Fv") + +// void zEntPlayer_Init(xEnt* ent, xEntAsset* asset) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_Init__FP4xEntP9xEntAsset") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_RestoreSounds__Fv") + +void zEntPlayer_Load(xEnt* ent, xSerial* serial) +{ + return; +} + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_StreakFX__FP4xEntf") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SpringboardFX__FP4xEntf") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "getPadDefl__FP13_tagPadAnalogP5xVec2") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_PredictionUpdate__FP4xEntf") + +// void zEntPlayer_PredictPos(xVec3* pos, float timeIntoFuture, float leadFactor, int useTurn) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_PredictPos__FP5xVec3ffi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerKnockToSafety__FP4xEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_FindGrabEnt__FP4xEntP6zScenePi") + +// void zEntPlayer_Update(xEnt* ent, xScene* sc, float dt) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_Update__FP4xEntP6xScenef") + +// void zEntPlayer_CheckCritterContact(xEnt* player, float dt) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_CheckCritterContact__FP4xEntf") + +// void zEntPlayer_PatrickLaunch(xEnt* patLauncher) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_PatrickLaunch__FP4xEnt") + +// void zEntPlayer_ShadowModelEnable() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_ShadowModelEnable__Fv") + +// void zEntPlayer_ShadowModelDisable() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_ShadowModelDisable__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_BubbleBowlLaneRender__FP4zEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_ReticleRender__FP4zEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "get_reticle_bound__FR5xVec3Rf") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerUpdateModelSB__Fv") + +// void zEntPlayerUpdateModel() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerUpdateModel__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerEmitTongueBubbles__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerEmitSlideBubbles__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerCheckHelmetPop__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerCheckShoePop__Fv") + +// void zEntPlayer_setBoulderMode(unsigned int mode) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_setBoulderMode__FUi") + +// int zEntPlayer_Damage(xBase* src, unsigned int damage, xVec3* knockback) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_Damage__FP5xBaseUiPC5xVec3") + +// int zEntPlayer_DamageNPCKnockBack(xBase* src, unsigned int damage, xVec3* npcPos) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_DamageNPCKnockBack__FP5xBaseUiP5xVec3") + +// void zEntPlayer_DamageKnockIntoAir(float height) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_DamageKnockIntoAir__Ff") + +// int zEntPlayer_Damage(xBase* src, unsigned int damage) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_Damage__FP5xBaseUi") + +// unsigned int zEntPlayer_MoveInfo() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_MoveInfo__Fv") + +void zEntPlayer_GiveHealth(int32 quantity) +{ + if (quantity < 0 && -quantity > (int32) globals.player.Health) + { + globals.player.Health = 0; + return; + } + + uint32 sum = globals.player.Health + quantity; + uint32 maxHealth = globals.player.MaxHealth; + globals.player.Health = sum; + + if (sum > maxHealth) + { + globals.player.Health = maxHealth; + } +} + +// void zEntPlayer_GiveSpatula(int quantity) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_GiveSpatula__Fi") + +void zEntPlayer_GiveShinyObject(int32 quantity) +{ + if (quantity < 0 && -quantity > (int32) globals.player.Inv_Shiny) + { + globals.player.Inv_Shiny = 0; + return; + } + + uint32 sum = globals.player.Inv_Shiny + quantity; + uint32 maxShinies = 99999; // TODO: make this defined somewhere globally + globals.player.Inv_Shiny = sum; + + if (sum > maxShinies) + { + globals.player.Inv_Shiny = maxShinies; + } +} + + +// void zEntPlayer_GivePatsSocksCurrentLevel(int quantity) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_GivePatsSocksCurrentLevel__Fi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_GiveLevelPickupCurrentLevel__Fi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "CalcJumpImpulse_Smooth__Ffffff") + +// void CalcJumpImpulse(zJumpParam* param, zPlayerSettings* settings) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "CalcJumpImpulse__FP10zJumpParamPC15zPlayerSettings") + +// void zEntPlayerJumpStart(xEnt* ent, zJumpParam* jump) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerJumpStart__FP4xEntP10zJumpParam") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerJumpAddDriver__FP4xEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerJumpLand__FP4xEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerJumpUpdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerEGenUpdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerVelUpdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "det3x3top1__Fffffff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "SlideTrackUpdate__FP4xEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerTSlideUpdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerFloorUpdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerSurfDamageUpdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerMountHackUpdate__Ff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerMountHackTakeAction__FP4xEntUi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerDriveUpdate__FP4xEntP6xScenef") + +// void zEntPlayerExit() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerExit__FP4xEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerHitAnimInit__FP14xModelInstanceP15xAnimTransitionPUi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_ObjIDIsTrack__FUi") + +// void zEntPlayerPreReset() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerPreReset__Fv") + +// void zEntPlayerReset(xEnt* ent) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerReset__FP4xEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollisBuildFromDepen__FP7xCollis") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "CollidePyramidBoxTop__FP7xCollisP4xBoxfP7xSphere") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollisTranslate__FP7xCollisfff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollsAllTranslate__FP7xCollisfff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollsWallsTranslate__FP7xCollisfff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollsWallsTranslate__FP7xCollisPC5xVec3") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollsSidesTranslate__FP7xCollisfff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollCheckEnv__FP4xEntP6xScene") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "ComputeFudge__Fff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "CalcCombinedDepen__FRfRffffff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollsSelectDepen__FP4xEntP6xScenef") + +// void zEntPlayerCollide(xEnt* ent, xScene* sc, float dt) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerCollide__FP4xEntP6xScenef") + +// void zEntPlayerCollTrigger(xEnt* ent, xScene* sc) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerCollTrigger__FP4xEntP6xScene") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "GetPosVec__FP5xBase") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerSwingUpdate__FP4xEntfff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerTeeterCheck__FP4xEntP6xScenef") + +// void zEntPlayer_StoreCheckPoint(xVec3* pos, float rot, unsigned int initCamID) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_StoreCheckPoint__FP5xVec3fUi") + +// void zEntPlayer_LoadCheckPoint() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_LoadCheckPoint__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "_SetupRumble__F14_tagePlayerSnd14_tagRumbleTypef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDInit__Fv") + +// void zEntPlayer_SNDPlay(_tagePlayerSnd player_snd, float delay) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlay__F14_tagePlayerSndf") + +// void zEntPlayer_SNDPlayStream(_tagePlayerStreamSnd player_snd) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStream__F20_tagePlayerStreamSnd") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStream__F20_tagePlayerStreamSndUi") + +// void zEntPlayer_SNDPlayDelayed(float seconds) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayDelayed__Ff") + +// void zEntPlayer_SNDPlayStream(unsigned int lower, unsigned int upper, _tagePlayerStreamSnd player_snd, unsigned int flags) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStream__FUiUi20_tagePlayerStreamSndUi") + +// void zEntPlayer_SNDPlayStreamRandom(unsigned int lower, unsigned int upper, _tagePlayerStreamSnd player_snd_start, _tagePlayerStreamSnd player_snd_end, float delay) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStreamRandom__FUiUi20_tagePlayerStreamSnd20_tagePlayerStreamSndf") + +// void zEntPlayer_SNDPlayStreamRandom(_tagePlayerStreamSnd player_snd_start, _tagePlayerStreamSnd player_snd_end, float delay) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStreamRandom__F20_tagePlayerStreamSnd20_tagePlayerStreamSndf") + +// void zEntPlayer_SNDPlayRandom(_tagePlayerSnd player_snd_start, _tagePlayerSnd player_snd_end, float delay) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayRandom__F14_tagePlayerSnd14_tagePlayerSndf") + +// void zEntPlayer_SNDSetVol(_tagePlayerSnd player_snd, float new_vol) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDSetVol__F14_tagePlayerSndf") + +// void zEntPlayer_SNDSetPitch(_tagePlayerSnd player_snd, float new_pitch) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDSetPitch__F14_tagePlayerSndf") + +// void zEntPlayer_SNDStop(_tagePlayerSnd player_snd) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDStop__F14_tagePlayerSnd") + +// void zEntPlayer_SNDStopStream() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDStopStream__Fv") + +void zEntPlayer_SNDNotifyPlaying(uint32 id) +{ + lbl_803CB5B8 = id; +} + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerBeginCollideNoBupdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerCollsDetect__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerHackFixBbashMiss__FP14xModelInstance") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerLedgeInit__FP16zLedgeGrabParamsP14xModelInstance") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerLedgeUpdate__FP4xEntP6xScenef") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "__as__10xEntCollisFRC10xEntCollis") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_UpdateVelocityBlur__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "dampen_velocity__FR5xVec3RC5xVec3f") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "player_sound_hop_load__FUii") + +// void zEntPlayer_LoadSounds() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_LoadSounds__Fv") + +// void zEntPlayer_UnloadSounds() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_UnloadSounds__Fv") + +// unsigned char zEntPlayer_MinimalUpdate(xEnt* ent, xScene* sc, float dt, xVec3& drive_motion) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_MinimalUpdate__FP4xEntP6xScenefR5xVec3") + +// void zEntPlayer_MinimalRender(zEnt* ent) +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_MinimalRender__FP4zEnt") + +// unsigned char zEntPlayerDyingInGoo() +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerDyingInGoo__Fv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "xVec3ScaleC__FP5xVec3PC5xVec3fff") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "xMat3x3RMulVec__FP5xVec3PC7xMat3x3PC5xVec3") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "xMat3x3SMul__FP7xMat3x3PC7xMat3x3f") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "XZDstSqToPlayer__10zNPCCommonFP5xVec3Pf") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "XZDstSqToPos__10zNPCCommonFPC5xVec3P5xVec3Pf") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "XZVecToPos__10zNPCCommonFP5xVec3PC5xVec3Pf") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "Pos__10zNPCCommonFv") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "xSndIsPlaying__FUi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "xSndIsPlayingByHandle__FUi") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "__as__12xSweptSphereFRC12xSweptSphere") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "__as__13xiMat4x3UnionFRC13xiMat4x3Union") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zCameraTranslate__FP7xCameraP5xVec3") + +// TODO: This belongs in zNPCSupport.h +// but the compiler put it here for some reason? +xVec3* NPCC_rightDir(xEnt* ent) +{ + // So this is actually a reference to a struct RwV3D + // which is the exact same as xVec3, but typed differently. + // TODO: figure out what to do with these duplicate types + return (xVec3*) &ent->model->Mat->right; +} + +xVec3* NPCC_faceDir(xEnt* ent) +{ + // TODO: see note in previous function + return (xVec3*) &ent->model->Mat->at; +} + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "NPCC_upDir__FP4xEnt") + +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zGooIs__FP4xEnt") \ No newline at end of file From 33ad4a30607e4a4629997c527923be1d60ff1ce8 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Tue, 6 Oct 2020 16:49:04 -0400 Subject: [PATCH 2/7] Remove decompiled functions --- asm/Game/zEntPlayer.s | 92 ++++------------------------------------- src/Game/zEntPlayer.cpp | 53 ++++++++++++++++-------- 2 files changed, 43 insertions(+), 102 deletions(-) diff --git a/asm/Game/zEntPlayer.s b/asm/Game/zEntPlayer.s index 224b17afc..6dde37ce7 100644 --- a/asm/Game/zEntPlayer.s +++ b/asm/Game/zEntPlayer.s @@ -18218,31 +18218,6 @@ lbl_800769AC: /* 800769C4 000737C4 38 21 00 20 */ addi r1, r1, 0x20 /* 800769C8 000737C8 4E 80 00 20 */ blr -.global zEntPlayer_GiveHealth__Fi -zEntPlayer_GiveHealth__Fi: -/* 800769CC 000737CC 2C 03 00 00 */ cmpwi r3, 0 -/* 800769D0 000737D0 40 80 00 28 */ bge lbl_800769F8 -/* 800769D4 000737D4 3C 80 80 3C */ lis r4, globals@ha -/* 800769D8 000737D8 7C A3 00 D0 */ neg r5, r3 -/* 800769DC 000737DC 38 84 05 58 */ addi r4, r4, globals@l -/* 800769E0 000737E0 80 04 16 B0 */ lwz r0, 0x16b0(r4) -/* 800769E4 000737E4 7C 05 00 00 */ cmpw r5, r0 -/* 800769E8 000737E8 40 81 00 10 */ ble lbl_800769F8 -/* 800769EC 000737EC 38 00 00 00 */ li r0, 0 -/* 800769F0 000737F0 90 04 16 B0 */ stw r0, 0x16b0(r4) -/* 800769F4 000737F4 4E 80 00 20 */ blr -lbl_800769F8: -/* 800769F8 000737F8 3C 80 80 3C */ lis r4, globals@ha -/* 800769FC 000737FC 38 84 05 58 */ addi r4, r4, globals@l -/* 80076A00 00073800 80 04 16 B0 */ lwz r0, 0x16b0(r4) -/* 80076A04 00073804 80 A4 17 38 */ lwz r5, 0x1738(r4) -/* 80076A08 00073808 7C 00 1A 14 */ add r0, r0, r3 -/* 80076A0C 0007380C 7C 00 28 40 */ cmplw r0, r5 -/* 80076A10 00073810 90 04 16 B0 */ stw r0, 0x16b0(r4) -/* 80076A14 00073814 4C 81 00 20 */ blelr -/* 80076A18 00073818 90 A4 16 B0 */ stw r5, 0x16b0(r4) -/* 80076A1C 0007381C 4E 80 00 20 */ blr - .global zEntPlayer_GiveSpatula__Fi zEntPlayer_GiveSpatula__Fi: /* 80076A20 00073820 94 21 FF F0 */ stwu r1, -0x10(r1) @@ -18272,32 +18247,6 @@ lbl_80076A50: /* 80076A7C 0007387C 38 21 00 10 */ addi r1, r1, 0x10 /* 80076A80 00073880 4E 80 00 20 */ blr -.global zEntPlayer_GiveShinyObject__Fi -zEntPlayer_GiveShinyObject__Fi: -/* 80076A84 00073884 2C 03 00 00 */ cmpwi r3, 0 -/* 80076A88 00073888 40 80 00 28 */ bge lbl_80076AB0 -/* 80076A8C 0007388C 3C 80 80 3C */ lis r4, globals@ha -/* 80076A90 00073890 7C A3 00 D0 */ neg r5, r3 -/* 80076A94 00073894 38 84 05 58 */ addi r4, r4, globals@l -/* 80076A98 00073898 80 04 1B 00 */ lwz r0, 0x1b00(r4) -/* 80076A9C 0007389C 7C 05 00 00 */ cmpw r5, r0 -/* 80076AA0 000738A0 40 81 00 10 */ ble lbl_80076AB0 -/* 80076AA4 000738A4 38 00 00 00 */ li r0, 0 -/* 80076AA8 000738A8 90 04 1B 00 */ stw r0, 0x1b00(r4) -/* 80076AAC 000738AC 4E 80 00 20 */ blr -lbl_80076AB0: -/* 80076AB0 000738B0 3C A0 80 3C */ lis r5, globals@ha -/* 80076AB4 000738B4 3C 80 00 02 */ lis r4, 0x0001869F@ha -/* 80076AB8 000738B8 38 C5 05 58 */ addi r6, r5, globals@l -/* 80076ABC 000738BC 80 A6 1B 00 */ lwz r5, 0x1b00(r6) -/* 80076AC0 000738C0 38 04 86 9F */ addi r0, r4, 0x0001869F@l -/* 80076AC4 000738C4 7C 65 1A 14 */ add r3, r5, r3 -/* 80076AC8 000738C8 7C 03 00 40 */ cmplw r3, r0 -/* 80076ACC 000738CC 90 66 1B 00 */ stw r3, 0x1b00(r6) -/* 80076AD0 000738D0 4C 81 00 20 */ blelr -/* 80076AD4 000738D4 90 06 1B 00 */ stw r0, 0x1b00(r6) -/* 80076AD8 000738D8 4E 80 00 20 */ blr - .global zEntPlayer_GivePatsSocksCurrentLevel__Fi zEntPlayer_GivePatsSocksCurrentLevel__Fi: /* 80076ADC 000738DC 94 21 FF F0 */ stwu r1, -0x10(r1) @@ -29097,7 +29046,7 @@ zEntPlayer_SNDPlayStream__F20_tagePlayerStreamSndUi: /* 800808E8 0007D6E8 C0 02 8C 20 */ lfs f0, lbl_803CD5A0-_SDA2_BASE_(r2) /* 800808EC 0007D6EC FC 01 00 40 */ fcmpo cr0, f1, f0 /* 800808F0 0007D6F0 41 81 00 64 */ bgt lbl_80080954 -/* 800808F4 0007D6F4 80 6D 8C B8 */ lwz r3, lbl_803CB5B8-_SDA_BASE_(r13) +/* 800808F4 0007D6F4 80 6D 8C B8 */ lwz r3, sCurrentStreamSndID-_SDA_BASE_(r13) /* 800808F8 0007D6F8 48 00 24 35 */ bl xSndIsPlayingByHandle__FUi /* 800808FC 0007D6FC 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 80080900 0007D700 40 82 00 54 */ bne lbl_80080954 @@ -29117,7 +29066,7 @@ zEntPlayer_SNDPlayStream__F20_tagePlayerStreamSndUi: /* 80080938 0007D738 38 E0 00 00 */ li r7, 0 /* 8008093C 0007D73C 4B FC 80 F1 */ bl xSndPlay__FUiffUiUiUi14sound_categoryf /* 80080940 0007D740 7F A0 EB 78 */ mr r0, r29 -/* 80080944 0007D744 90 6D 8C B8 */ stw r3, lbl_803CB5B8-_SDA_BASE_(r13) +/* 80080944 0007D744 90 6D 8C B8 */ stw r3, sCurrentStreamSndID-_SDA_BASE_(r13) /* 80080948 0007D748 7C 60 F2 14 */ add r3, r0, r30 /* 8008094C 0007D74C C0 03 00 04 */ lfs f0, 4(r3) /* 80080950 0007D750 7C 1D F5 2E */ stfsx f0, r29, r30 @@ -29252,7 +29201,7 @@ zEntPlayer_SNDPlayStreamRandom__F20_tagePlayerStreamSnd20_tagePlayerStreamSndf: /* 80080B0C 0007D90C 80 0D 8C C4 */ lwz r0, lbl_803CB5C4-_SDA_BASE_(r13) /* 80080B10 0007D910 2C 00 00 00 */ cmpwi r0, 0 /* 80080B14 0007D914 40 82 03 C4 */ bne lbl_80080ED8 -/* 80080B18 0007D918 80 6D 8C B8 */ lwz r3, lbl_803CB5B8-_SDA_BASE_(r13) +/* 80080B18 0007D918 80 6D 8C B8 */ lwz r3, sCurrentStreamSndID-_SDA_BASE_(r13) /* 80080B1C 0007D91C 48 00 22 11 */ bl xSndIsPlayingByHandle__FUi /* 80080B20 0007D920 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 80080B24 0007D924 40 82 03 B4 */ bne lbl_80080ED8 @@ -29511,7 +29460,7 @@ lbl_80080E80: /* 80080EC8 0007DCC8 38 E0 00 00 */ li r7, 0 /* 80080ECC 0007DCCC FC 60 10 90 */ fmr f3, f2 /* 80080ED0 0007DCD0 4B FC 7B 5D */ bl xSndPlay__FUiffUiUiUi14sound_categoryf -/* 80080ED4 0007DCD4 90 6D 8C B8 */ stw r3, lbl_803CB5B8-_SDA_BASE_(r13) +/* 80080ED4 0007DCD4 90 6D 8C B8 */ stw r3, sCurrentStreamSndID-_SDA_BASE_(r13) lbl_80080ED8: /* 80080ED8 0007DCD8 E3 E1 00 B8 */ psq_l f31, 184(r1), 0, qr0 /* 80080EDC 0007DCDC CB E1 00 B0 */ lfd f31, 0xb0(r1) @@ -29807,11 +29756,11 @@ zEntPlayer_SNDStopStream__Fv: /* 800812E4 0007E0E4 94 21 FF F0 */ stwu r1, -0x10(r1) /* 800812E8 0007E0E8 7C 08 02 A6 */ mflr r0 /* 800812EC 0007E0EC 90 01 00 14 */ stw r0, 0x14(r1) -/* 800812F0 0007E0F0 80 6D 8C B8 */ lwz r3, lbl_803CB5B8-_SDA_BASE_(r13) +/* 800812F0 0007E0F0 80 6D 8C B8 */ lwz r3, sCurrentStreamSndID-_SDA_BASE_(r13) /* 800812F4 0007E0F4 48 00 1A 39 */ bl xSndIsPlayingByHandle__FUi /* 800812F8 0007E0F8 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 800812FC 0007E0FC 41 82 00 0C */ beq lbl_80081308 -/* 80081300 0007E100 80 6D 8C B8 */ lwz r3, lbl_803CB5B8-_SDA_BASE_(r13) +/* 80081300 0007E100 80 6D 8C B8 */ lwz r3, sCurrentStreamSndID-_SDA_BASE_(r13) /* 80081304 0007E104 4B FC 7E FD */ bl xSndStop__FUi lbl_80081308: /* 80081308 0007E108 80 01 00 14 */ lwz r0, 0x14(r1) @@ -29819,11 +29768,6 @@ lbl_80081308: /* 80081310 0007E110 38 21 00 10 */ addi r1, r1, 0x10 /* 80081314 0007E114 4E 80 00 20 */ blr -.global zEntPlayer_SNDNotifyPlaying__FUi -zEntPlayer_SNDNotifyPlaying__FUi: -/* 80081318 0007E118 90 6D 8C B8 */ stw r3, lbl_803CB5B8-_SDA_BASE_(r13) -/* 8008131C 0007E11C 4E 80 00 20 */ blr - PlayerBeginCollideNoBupdate__FP4xEntP6xScenef: /* 80081320 0007E120 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80081324 0007E124 39 80 00 00 */ li r12, 0 @@ -46058,26 +46002,6 @@ zCameraTranslate__FP7xCameraP5xVec3: /* 80090E2C 0008DC2C 38 21 00 10 */ addi r1, r1, 0x10 /* 80090E30 0008DC30 4E 80 00 20 */ blr -.global NPCC_rightDir__FP4xEnt -NPCC_rightDir__FP4xEnt: -/* 80090E34 0008DC34 80 63 00 24 */ lwz r3, 0x24(r3) -/* 80090E38 0008DC38 80 63 00 4C */ lwz r3, 0x4c(r3) -/* 80090E3C 0008DC3C 4E 80 00 20 */ blr - -.global NPCC_faceDir__FP4xEnt -NPCC_faceDir__FP4xEnt: -/* 80090E40 0008DC40 80 63 00 24 */ lwz r3, 0x24(r3) -/* 80090E44 0008DC44 80 63 00 4C */ lwz r3, 0x4c(r3) -/* 80090E48 0008DC48 38 63 00 20 */ addi r3, r3, 0x20 -/* 80090E4C 0008DC4C 4E 80 00 20 */ blr - -.global NPCC_upDir__FP4xEnt -NPCC_upDir__FP4xEnt: -/* 80090E50 0008DC50 80 63 00 24 */ lwz r3, 0x24(r3) -/* 80090E54 0008DC54 80 63 00 4C */ lwz r3, 0x4c(r3) -/* 80090E58 0008DC58 38 63 00 10 */ addi r3, r3, 0x10 -/* 80090E5C 0008DC5C 4E 80 00 20 */ blr - .global zGooIs__FP4xEnt zGooIs__FP4xEnt: /* 80090E60 0008DC60 94 21 FF F0 */ stwu r1, -0x10(r1) @@ -46179,8 +46103,8 @@ lbl_803CB5B0: .global gSpongeBall gSpongeBall: .skip 0x4 -.global lbl_803CB5B8 -lbl_803CB5B8: +.global sCurrentStreamSndID +sCurrentStreamSndID: .skip 0x4 lbl_803CB5BC: .skip 0x4 diff --git a/src/Game/zEntPlayer.cpp b/src/Game/zEntPlayer.cpp index 29601f8bb..7219902f2 100644 --- a/src/Game/zEntPlayer.cpp +++ b/src/Game/zEntPlayer.cpp @@ -1,12 +1,14 @@ #include "zEntPlayer.h" +#include + #include "../Core/x/xEnt.h" #include "../Core/x/xVec3.h" #include "zGlobals.h" extern zGlobals globals; -extern uint32 lbl_803CB5B8; +extern uint32 sCurrentStreamSndID; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SpawnWandBubbles__FP5xVec3Ui") @@ -50,7 +52,8 @@ extern uint32 lbl_803CB5B8; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunSlipCheck__FP15xAnimTransitionP11xAnimSinglePv") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunOutOfWorldCheck__FP15xAnimTransitionP11xAnimSinglePv") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "RunOutOfWorldCheck__FP15xAnimTransitionP11xAnimSinglePv") #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "WalkCheck__FP15xAnimTransitionP11xAnimSinglePv") @@ -77,7 +80,8 @@ extern uint32 lbl_803CB5B8; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "BoulderRollDoneCB__Fv") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "speak_update__24_esc__2_unnamed_esc__2_zEntPlayer_cpp_esc__2_Ff") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "speak_update__24_esc__2_unnamed_esc__2_zEntPlayer_cpp_esc__2_Ff") // void zEntPlayerSpeakStart(unsigned int sndid, int anim) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerSpeakStart__FUiUii") @@ -92,7 +96,8 @@ extern uint32 lbl_803CB5B8; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "MeleeStopCB__FP15xAnimTransitionP11xAnimSinglePv") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "LassoSwingBeginCB__FP15xAnimTransitionP11xAnimSinglePv") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "LassoSwingBeginCB__FP15xAnimTransitionP11xAnimSinglePv") #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "StunBubbleTrail__FP11xAnimSingle") @@ -109,7 +114,8 @@ extern uint32 lbl_803CB5B8; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "count_talk_anims__FP10xAnimTable") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "load_player_ini__FR15zPlayerSettingsR14xModelInstanceP16xModelAssetParamUi") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "load_player_ini__FR15zPlayerSettingsR14xModelInstanceP16xModelAssetParamUi") #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "load_player_ini__Fv") @@ -192,7 +198,7 @@ void zEntPlayer_Load(xEnt* ent, xSerial* serial) void zEntPlayer_GiveHealth(int32 quantity) { - if (quantity < 0 && -quantity > (int32) globals.player.Health) + if (quantity < 0 && -quantity > (int32)globals.player.Health) { globals.player.Health = 0; return; @@ -213,7 +219,7 @@ void zEntPlayer_GiveHealth(int32 quantity) void zEntPlayer_GiveShinyObject(int32 quantity) { - if (quantity < 0 && -quantity > (int32) globals.player.Inv_Shiny) + if (quantity < 0 && -quantity > (int32)globals.player.Inv_Shiny) { globals.player.Inv_Shiny = 0; return; @@ -229,7 +235,6 @@ void zEntPlayer_GiveShinyObject(int32 quantity) } } - // void zEntPlayer_GivePatsSocksCurrentLevel(int quantity) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_GivePatsSocksCurrentLevel__Fi") @@ -272,7 +277,8 @@ void zEntPlayer_GiveShinyObject(int32 quantity) // void zEntPlayerExit() #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerExit__FP4xEnt") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerHitAnimInit__FP14xModelInstanceP15xAnimTransitionPUi") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "PlayerHitAnimInit__FP14xModelInstanceP15xAnimTransitionPUi") #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_ObjIDIsTrack__FUi") @@ -338,16 +344,22 @@ void zEntPlayer_GiveShinyObject(int32 quantity) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayDelayed__Ff") // void zEntPlayer_SNDPlayStream(unsigned int lower, unsigned int upper, _tagePlayerStreamSnd player_snd, unsigned int flags) -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStream__FUiUi20_tagePlayerStreamSndUi") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "zEntPlayer_SNDPlayStream__FUiUi20_tagePlayerStreamSndUi") // void zEntPlayer_SNDPlayStreamRandom(unsigned int lower, unsigned int upper, _tagePlayerStreamSnd player_snd_start, _tagePlayerStreamSnd player_snd_end, float delay) -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStreamRandom__FUiUi20_tagePlayerStreamSnd20_tagePlayerStreamSndf") +#pragma GLOBAL_ASM( \ + "asm/Game/zEntPlayer.s", \ + "zEntPlayer_SNDPlayStreamRandom__FUiUi20_tagePlayerStreamSnd20_tagePlayerStreamSndf") // void zEntPlayer_SNDPlayStreamRandom(_tagePlayerStreamSnd player_snd_start, _tagePlayerStreamSnd player_snd_end, float delay) -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayStreamRandom__F20_tagePlayerStreamSnd20_tagePlayerStreamSndf") +#pragma GLOBAL_ASM( \ + "asm/Game/zEntPlayer.s", \ + "zEntPlayer_SNDPlayStreamRandom__F20_tagePlayerStreamSnd20_tagePlayerStreamSndf") // void zEntPlayer_SNDPlayRandom(_tagePlayerSnd player_snd_start, _tagePlayerSnd player_snd_end, float delay) -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDPlayRandom__F14_tagePlayerSnd14_tagePlayerSndf") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "zEntPlayer_SNDPlayRandom__F14_tagePlayerSnd14_tagePlayerSndf") // void zEntPlayer_SNDSetVol(_tagePlayerSnd player_snd, float new_vol) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDSetVol__F14_tagePlayerSndf") @@ -363,7 +375,7 @@ void zEntPlayer_GiveShinyObject(int32 quantity) void zEntPlayer_SNDNotifyPlaying(uint32 id) { - lbl_803CB5B8 = id; + sCurrentStreamSndID = id; } #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerBeginCollideNoBupdate__FP4xEntP6xScenef") @@ -372,7 +384,8 @@ void zEntPlayer_SNDNotifyPlaying(uint32 id) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerHackFixBbashMiss__FP14xModelInstance") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerLedgeInit__FP16zLedgeGrabParamsP14xModelInstance") +#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ + "PlayerLedgeInit__FP16zLedgeGrabParamsP14xModelInstance") #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "PlayerLedgeUpdate__FP4xEntP6xScenef") @@ -430,15 +443,19 @@ xVec3* NPCC_rightDir(xEnt* ent) // So this is actually a reference to a struct RwV3D // which is the exact same as xVec3, but typed differently. // TODO: figure out what to do with these duplicate types - return (xVec3*) &ent->model->Mat->right; + return (xVec3*)&ent->model->Mat->right; } xVec3* NPCC_faceDir(xEnt* ent) { // TODO: see note in previous function - return (xVec3*) &ent->model->Mat->at; + return (xVec3*)&ent->model->Mat->at; } -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "NPCC_upDir__FP4xEnt") +xVec3* NPCC_upDir(xEnt* ent) +{ + // TODO: see note in previous function + return (xVec3*)&ent->model->Mat->up; +} #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zGooIs__FP4xEnt") \ No newline at end of file From 5e4dbea25e1d7bf8c9d4488f1d5ffece7f87f4c3 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Wed, 7 Oct 2020 14:08:51 -0400 Subject: [PATCH 3/7] address PR comments --- include/rwsdk/rwcore.h | 42 +++++++++++------------ src/Core/x/xModel.h | 77 ++++++++++++++++++++---------------------- 2 files changed, 58 insertions(+), 61 deletions(-) diff --git a/include/rwsdk/rwcore.h b/include/rwsdk/rwcore.h index 49ea06345..239424e01 100644 --- a/include/rwsdk/rwcore.h +++ b/include/rwsdk/rwcore.h @@ -57,38 +57,38 @@ enum RwRenderState struct RwLLLink { - RwLLLink* next; - RwLLLink* prev; + RwLLLink* next; + RwLLLink* prev; }; struct RwTexture { - RwRaster* raster; - RwTexDictionary* dict; - RwLLLink lInDictionary; - RwChar name[32]; - RwChar mask[32]; - RwUInt32 filterAddressing; - RwInt32 refCount; + RwRaster* raster; + RwTexDictionary* dict; + RwLLLink lInDictionary; + RwChar name[32]; + RwChar mask[32]; + RwUInt32 filterAddressing; + RwInt32 refCount; }; struct RwV3d { - float x; - float y; - float z; + RwReal x; + RwReal y; + RwReal z; }; struct RwMatrixTag { - RwV3d right; - unsigned int flags; - RwV3d up; - unsigned int pad1; - RwV3d at; - unsigned int pad2; - RwV3d pos; - unsigned int pad3; + RwV3d right; + RwUInt32 flags; + RwV3d up; + RwUInt32 pad1; + RwV3d at; + RwUInt32 pad2; + RwV3d pos; + RwUInt32 pad3; }; enum RwFogType @@ -113,7 +113,7 @@ struct RwCamera }; extern "C" { - extern RwBool RwRenderStateSet(RwRenderState state, void* value); +extern RwBool RwRenderStateSet(RwRenderState state, void* value); } #endif \ No newline at end of file diff --git a/src/Core/x/xModel.h b/src/Core/x/xModel.h index ba01fc0bc..4ef5ecd5b 100644 --- a/src/Core/x/xModel.h +++ b/src/Core/x/xModel.h @@ -11,57 +11,54 @@ struct xModelInstance; -// TODO: this probably can be simplified -struct _class -{ - xVec3* verts; -}; - struct xModelBucket { - RpAtomic* Data; - RpAtomic* OriginalData; - xModelInstance* List; - int32 ClipFlags; - uint32 PipeFlags; + RpAtomic* Data; + RpAtomic* OriginalData; + xModelInstance* List; + int32 ClipFlags; + uint32 PipeFlags; }; struct xModelPool { - xModelPool* Next; - uint32 NumMatrices; - xModelInstance* List; + xModelPool* Next; + uint32 NumMatrices; + xModelInstance* List; }; struct xModelInstance { xModelInstance* Next; - xModelInstance* Parent; - xModelPool* Pool; - xAnimPlay* Anim; - RpAtomic* Data; - uint32 PipeFlags; - float32 RedMultiplier; - float32 GreenMultiplier; - float32 BlueMultiplier; - float32 Alpha; - float32 FadeStart; - float32 FadeEnd; - xSurface* Surf; - xModelBucket** Bucket; - xModelInstance* BucketNext; - xLightKit* LightKit; - void* Object; - uint16 Flags; - uint8 BoneCount; - uint8 BoneIndex; - uint8* BoneRemap; - RwMatrixTag* Mat; - xVec3 Scale; - uint32 modelID; - uint32 shadowID; - RpAtomic* shadowmapAtomic; - _class anim_coll; + xModelInstance* Parent; + xModelPool* Pool; + xAnimPlay* Anim; + RpAtomic* Data; + uint32 PipeFlags; + float32 RedMultiplier; + float32 GreenMultiplier; + float32 BlueMultiplier; + float32 Alpha; + float32 FadeStart; + float32 FadeEnd; + xSurface* Surf; + xModelBucket** Bucket; + xModelInstance* BucketNext; + xLightKit* LightKit; + void* Object; + uint16 Flags; + uint8 BoneCount; + uint8 BoneIndex; + uint8* BoneRemap; + RwMatrixTag* Mat; + xVec3 Scale; + uint32 modelID; + uint32 shadowID; + RpAtomic* shadowmapAtomic; + struct + { + xVec3* verts; + } anim_coll; }; struct xModelTag From 24ac957668e620d888c10b5dab0a3cbc4a4aa208 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Wed, 7 Oct 2020 16:48:35 -0400 Subject: [PATCH 4/7] almost decomp isSneaking --- src/Core/x/xAnim.h | 81 ++++++++++++++++++++++++++++++++++++++++- src/Game/zEntPlayer.cpp | 34 ++++++++++++++++- src/Game/zGame.h | 8 +++- 3 files changed, 119 insertions(+), 4 deletions(-) diff --git a/src/Core/x/xAnim.h b/src/Core/x/xAnim.h index a8b7d29c1..c47a7fb98 100644 --- a/src/Core/x/xAnim.h +++ b/src/Core/x/xAnim.h @@ -1,16 +1,93 @@ #ifndef XANIM_H #define XANIM_H -struct xAnimState +#include "xModel.h" +#include "xMemMgr.h" +#include "xMath3.h" +#include "xVec3.h" + +struct xAnimState; +struct xAnimPlay; +struct xAnimFile; +struct xAnimMultiFile; +struct xAnimTransitionList; + +struct xAnimTable { }; -struct xAnimTable +struct xAnimEffect +{ +}; + +struct xAnimActiveEffect +{ +}; + +struct xAnimTransition { }; +struct xAnimSingle +{ + uint32 SingleFlags; + xAnimState* State; + float32 Time; + float32 CurrentSpeed; + float32 BilinearLerp[2]; + xAnimEffect* Effect; + uint32 ActiveCount; + float32 LastTime; + xAnimActiveEffect* ActiveList; + xAnimPlay* Play; + xAnimTransition* Sync; + xAnimTransition* Tran; + xAnimSingle* Blend; + float32 BlendFactor; + uint32 pad; +}; + +typedef void (*type_7)(xAnimPlay*, xQuat*, xVec3*, int32); + +// have to do this because for some reason +// including xModel.h doesn't put this before +// xAnimPlay is defined, which references it +struct xModelInstance; + struct xAnimPlay { + xAnimPlay* Next; + uint16 NumSingle; + uint16 BoneCount; + xAnimSingle* Single; + void* Object; + xAnimTable* Table; + xMemPool* Pool; + xModelInstance* ModelInst; + type_7 BeforeAnimMatrices; +}; + +struct xAnimState +{ + xAnimState* Next; + int8* Name; + uint32 ID; + uint32 Flags; + uint32 UserFlags; + float32 Speed; + xAnimFile* Data; + xAnimEffect* Effects; + xAnimTransitionList* Default; + xAnimTransitionList* List; + float32* BoneBlend; + float32* TimeSnap; + float32 FadeRecip; + uint16* FadeOffset; + void* CallbackData; + xAnimMultiFile* MultiFile; + void (*BeforeEnter)(xAnimPlay*, xAnimState*); + void (*StateCallback)(xAnimState*, xAnimSingle*, void*); + void (*BeforeAnimMatrices)(xAnimPlay*, xQuat*, xVec3*, int32); }; #endif \ No newline at end of file diff --git a/src/Game/zEntPlayer.cpp b/src/Game/zEntPlayer.cpp index 7219902f2..76a869606 100644 --- a/src/Game/zEntPlayer.cpp +++ b/src/Game/zEntPlayer.cpp @@ -5,9 +5,11 @@ #include "../Core/x/xEnt.h" #include "../Core/x/xVec3.h" +#include "zGame.h" #include "zGlobals.h" extern zGlobals globals; +extern int32 gCurrentPlayer; extern uint32 sCurrentStreamSndID; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SpawnWandBubbles__FP5xVec3Ui") @@ -107,7 +109,37 @@ extern uint32 sCurrentStreamSndID; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "MeleeAttackBoundCollide__FP4xEntP6zSceneP6xBound") -// int zEntPlayer_IsSneaking() +/* +int32 zEntPlayer_IsSneaking() +{ + if (gCurrentPlayer != eCurrentPlayerSpongeBob) + { + return false; + } + + uint32 flags = globals.player.ent.model->Anim->Single->State->UserFlags; + + // only two instructions before this matches + // it seems to be branching to the wrong result. + // inverting this chain of logic should fix it? + // flipping the return values below is the + // correct logic, but non-matching + if ((flags & 1) == 0) + { + flags &= 0x1e; + + if (flags != 2) + { + if (flags == 4) + { + return true; + } + } + } + + return false; +} +*/ #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_IsSneaking__Fv") #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "load_talk_filter__FPUcP16xModelAssetParamUii") diff --git a/src/Game/zGame.h b/src/Game/zGame.h index b9c3d8b89..874296d94 100644 --- a/src/Game/zGame.h +++ b/src/Game/zGame.h @@ -1,6 +1,12 @@ #ifndef ZGAME_H #define ZGAME_H - +enum _CurrentPlayer +{ + eCurrentPlayerSpongeBob, + eCurrentPlayerPatrick, + eCurrentPlayerSandy, + eCurrentPlayerCount +}; #endif \ No newline at end of file From bcc5a47edac3463c949de6436f5af13fbc2305d8 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Thu, 8 Oct 2020 14:26:14 -0400 Subject: [PATCH 5/7] few more functions --- src/Core/p2/iSnd.h | 2 +- src/Game/zEntPlayer.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Core/p2/iSnd.h b/src/Core/p2/iSnd.h index 5439837f8..900934e59 100644 --- a/src/Core/p2/iSnd.h +++ b/src/Core/p2/iSnd.h @@ -1,6 +1,6 @@ #ifndef ISND_H #define ISND_H - +uint8 iSndIsPlaying(uint32 assetID); #endif \ No newline at end of file diff --git a/src/Game/zEntPlayer.cpp b/src/Game/zEntPlayer.cpp index 76a869606..39c1fd6a0 100644 --- a/src/Game/zEntPlayer.cpp +++ b/src/Game/zEntPlayer.cpp @@ -2,6 +2,8 @@ #include +#include "../Core/p2/iSnd.h" + #include "../Core/x/xEnt.h" #include "../Core/x/xVec3.h" @@ -42,7 +44,10 @@ extern uint32 sCurrentStreamSndID; #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "InvReset__Fv") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "HealthReset__Fv") +void HealthReset() +{ + globals.player.Health = globals.player.MaxHealth; +} #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "RunAnyCheck__FP15xAnimTransitionP11xAnimSinglePv") @@ -458,7 +463,10 @@ void zEntPlayer_SNDNotifyPlaying(uint32 id) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "Pos__10zNPCCommonFv") -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "xSndIsPlaying__FUi") +uint8 xSndIsPlaying(uint32 assetID) +{ + return (uint8)iSndIsPlaying(assetID); +} #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "xSndIsPlayingByHandle__FUi") From a2d5d1d6f0fac53e2d54a6d0540637190b1b14b8 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Thu, 8 Oct 2020 16:18:35 -0400 Subject: [PATCH 6/7] decomp damage function --- Makefile | 1 + src/Core/x/xEnt.h | 54 ++++++++---- src/Game/zEntPlayer.cpp | 30 ++++++- src/Game/zEntPlayer.h | 186 ++++++++++++++++++++-------------------- 4 files changed, 158 insertions(+), 113 deletions(-) diff --git a/Makefile b/Makefile index 35871c083..ee8ff15fe 100644 --- a/Makefile +++ b/Makefile @@ -127,3 +127,4 @@ $(OBJ_DIR)/%.o: %.cpp $(CC) $(PREPROCESS) -o $*.cp $< $(GLBLASM) $*.cp $(CC) $(CFLAGS) -c -o $@ $*.cp + $(CC) -S -o $*.asm $@ \ No newline at end of file diff --git a/src/Core/x/xEnt.h b/src/Core/x/xEnt.h index 8b95e649a..d1da88bd2 100644 --- a/src/Core/x/xEnt.h +++ b/src/Core/x/xEnt.h @@ -14,27 +14,47 @@ struct xEntAsset : xBaseAsset { - uint8 flags; - uint8 subtype; - uint8 pflags; - uint8 moreFlags; - uint8 pad; - uint32 surfaceID; - xVec3 ang; - xVec3 pos; - xVec3 scale; - float32 redMult; - float32 greenMult; - float32 blueMult; - float32 seeThru; - float32 seeThruSpeed; - uint32 modelInfoID; - uint32 animListID; + uint8 flags; + uint8 subtype; + uint8 pflags; + uint8 moreFlags; + uint8 pad; + uint32 surfaceID; + xVec3 ang; + xVec3 pos; + xVec3 scale; + float32 redMult; + float32 greenMult; + float32 blueMult; + float32 seeThru; + float32 seeThruSpeed; + uint32 modelInfoID; + uint32 animListID; }; struct xEnt; struct xScene; -struct xEntFrame; + +struct xRot +{ + xVec3 axis; + float32 angle; +}; + +struct xEntFrame +{ + xMat4x3 mat; + xMat4x3 oldmat; + xVec3 oldvel; + xRot oldrot; + xRot drot; + xRot rot; + xVec3 dpos; + xVec3 dvel; + xVec3 vel; + uint32 mode; +}; + struct xEntCollis; struct xShadowSimpleCache; struct xEntShadow; diff --git a/src/Game/zEntPlayer.cpp b/src/Game/zEntPlayer.cpp index 39c1fd6a0..9aa9ee2bf 100644 --- a/src/Game/zEntPlayer.cpp +++ b/src/Game/zEntPlayer.cpp @@ -187,8 +187,10 @@ void zEntPlayer_Load(xEnt* ent, xSerial* serial) // void zEntPlayer_CheckCritterContact(xEnt* player, float dt) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_CheckCritterContact__FP4xEntf") -// void zEntPlayer_PatrickLaunch(xEnt* patLauncher) -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_PatrickLaunch__FP4xEnt") +void zEntPlayer_PatrickLaunch(xEnt* patLauncher) +{ + globals.player.carry.patLauncher = patLauncher; +} // void zEntPlayer_ShadowModelEnable() #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_ShadowModelEnable__Fv") @@ -218,8 +220,28 @@ void zEntPlayer_Load(xEnt* ent, xSerial* serial) // void zEntPlayer_setBoulderMode(unsigned int mode) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_setBoulderMode__FUi") -// int zEntPlayer_Damage(xBase* src, unsigned int damage, xVec3* knockback) -#pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_Damage__FP5xBaseUiPC5xVec3") +int32 zEntPlayer_Damage(xBase* src, uint32 damage, const xVec3* knockback) +{ + int32 newDamage = zEntPlayer_Damage(src, damage); + + if (newDamage == 0) + { + newDamage = 0; // galaxy brain + } + else + { + if (knockback != NULL) + { + globals.player.ent.frame->vel.x = knockback->x; + globals.player.ent.frame->vel.y = knockback->y; + globals.player.ent.frame->vel.z = knockback->z; + } + + newDamage = 1; + } + + return newDamage; +} // int zEntPlayer_DamageNPCKnockBack(xBase* src, unsigned int damage, xVec3* npcPos) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_DamageNPCKnockBack__FP5xBaseUiP5xVec3") diff --git a/src/Game/zEntPlayer.h b/src/Game/zEntPlayer.h index e6f07cfd3..c5952a5b9 100644 --- a/src/Game/zEntPlayer.h +++ b/src/Game/zEntPlayer.h @@ -24,116 +24,118 @@ enum _zPlayerWallJumpState struct zJumpParam { - float32 PeakHeight; - float32 TimeGravChange; - float32 TimeHold; - float32 ImpulseVel; + float32 PeakHeight; + float32 TimeGravChange; + float32 TimeHold; + float32 ImpulseVel; }; struct zLedgeGrabParams { - float32 animGrab; - float32 zdist; - xVec3 tranTable[60]; - int32 tranCount; - xEnt* optr; - xMat4x3 omat; - float32 y0det; - float32 dydet; - float32 r0det; - float32 drdet; - float32 thdet; - float32 rtime; - float32 ttime; - float32 tmr; - xVec3 spos; - xVec3 epos; - xVec3 tpos; - int32 nrays; - int32 rrand; - float32 startrot; - float32 endrot; + float32 animGrab; + float32 zdist; + xVec3 tranTable[60]; + int32 tranCount; + xEnt* optr; + xMat4x3 omat; + float32 y0det; + float32 dydet; + float32 r0det; + float32 drdet; + float32 thdet; + float32 rtime; + float32 ttime; + float32 tmr; + xVec3 spos; + xVec3 epos; + xVec3 tpos; + int32 nrays; + int32 rrand; + float32 startrot; + float32 endrot; }; struct zPlayerSettings { - _zPlayerType pcType; - float32 MoveSpeed[6]; - float32 AnimSneak[3]; + _zPlayerType pcType; + float32 MoveSpeed[6]; + float32 AnimSneak[3]; float32 AnimWalk[3]; float32 AnimRun[3]; - float32 JumpGravity; - float32 GravSmooth; - float32 FloatSpeed; - float32 ButtsmashSpeed; - zJumpParam Jump; - zJumpParam Bounce; - zJumpParam Spring; - zJumpParam Wall; - zJumpParam Double; - zJumpParam SlideDouble; - zJumpParam SlideJump; - float32 WallJumpVelocity; - zLedgeGrabParams ledge; - float32 spin_damp_xz; - float32 spin_damp_y; - uint8 talk_anims; - uint8 talk_filter_size; - uint8 talk_filter[4]; + float32 JumpGravity; + float32 GravSmooth; + float32 FloatSpeed; + float32 ButtsmashSpeed; + zJumpParam Jump; + zJumpParam Bounce; + zJumpParam Spring; + zJumpParam Wall; + zJumpParam Double; + zJumpParam SlideDouble; + zJumpParam SlideJump; + float32 WallJumpVelocity; + zLedgeGrabParams ledge; + float32 spin_damp_xz; + float32 spin_damp_y; + uint8 talk_anims; + uint8 talk_filter_size; + uint8 talk_filter[4]; }; struct zPlayerCarryInfo { - xEnt* grabbed; - uint32 grabbedModelID; - xMat4x3 spin; - xEnt* throwTarget; - xEnt* flyingToTarget; - float32 minDist; - float32 maxDist; - float32 minHeight; - float32 maxHeight; - float32 maxCosAngle; - float32 throwMinDist; - float32 throwMaxDist; - float32 throwMinHeight; - float32 throwMaxHeight; - float32 throwMaxStack; - float32 throwMaxCosAngle; - float32 throwTargetRotRate; - float32 targetRot; - uint32 grabTarget; - xVec3 grabOffset; - float32 grabLerpMin; - float32 grabLerpMax; - float32 grabLerpLast; - uint32 grabYclear; - float32 throwGravity; - float32 throwHeight; - float32 throwDistance; - float32 fruitFloorDecayMin; - float32 fruitFloorDecayMax; - float32 fruitFloorBounce; - float32 fruitFloorFriction; - float32 fruitCeilingBounce; - float32 fruitWallBounce; - float32 fruitLifetime; - xEnt* patLauncher; + xEnt* grabbed; + uint32 grabbedModelID; + xMat4x3 spin; + xEnt* throwTarget; + xEnt* flyingToTarget; + float32 minDist; + float32 maxDist; + float32 minHeight; + float32 maxHeight; + float32 maxCosAngle; + float32 throwMinDist; + float32 throwMaxDist; + float32 throwMinHeight; + float32 throwMaxHeight; + float32 throwMaxStack; + float32 throwMaxCosAngle; + float32 throwTargetRotRate; + float32 targetRot; + uint32 grabTarget; + xVec3 grabOffset; + float32 grabLerpMin; + float32 grabLerpMax; + float32 grabLerpLast; + uint32 grabYclear; + float32 throwGravity; + float32 throwHeight; + float32 throwDistance; + float32 fruitFloorDecayMin; + float32 fruitFloorDecayMax; + float32 fruitFloorBounce; + float32 fruitFloorFriction; + float32 fruitCeilingBounce; + float32 fruitWallBounce; + float32 fruitLifetime; + xEnt* patLauncher; }; struct zPlayerLassoInfo { - xEnt* target; - float32 dist; - uint8 destroy; - uint8 targetGuide; - float32 lassoRot; - xEnt* swingTarget; - xEnt* releasedSwing; - float32 copterTime; - int32 canCopter; - zLasso lasso; - xAnimState* zeroAnim; + xEnt* target; + float32 dist; + uint8 destroy; + uint8 targetGuide; + float32 lassoRot; + xEnt* swingTarget; + xEnt* releasedSwing; + float32 copterTime; + int32 canCopter; + zLasso lasso; + xAnimState* zeroAnim; }; +int32 zEntPlayer_Damage(xBase* src, uint32 damage); + #endif \ No newline at end of file From a6916567ceff142045a21b223a2dfc236d9705cd Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Fri, 9 Oct 2020 20:52:49 -0400 Subject: [PATCH 7/7] remove decomp'ed functions --- asm/Game/zEntPlayer.s | 65 ------------------------------------------- 1 file changed, 65 deletions(-) diff --git a/asm/Game/zEntPlayer.s b/asm/Game/zEntPlayer.s index 6dde37ce7..b6122b06e 100644 --- a/asm/Game/zEntPlayer.s +++ b/asm/Game/zEntPlayer.s @@ -2115,13 +2115,6 @@ lbl_80068010: /* 8006804C 00064E4C 38 21 00 20 */ addi r1, r1, 0x20 /* 80068050 00064E50 4E 80 00 20 */ blr -HealthReset__Fv: -/* 80068054 00064E54 3C 60 80 3C */ lis r3, globals@ha -/* 80068058 00064E58 38 63 05 58 */ addi r3, r3, globals@l -/* 8006805C 00064E5C 80 03 17 38 */ lwz r0, 0x1738(r3) -/* 80068060 00064E60 90 03 16 B0 */ stw r0, 0x16b0(r3) -/* 80068064 00064E64 4E 80 00 20 */ blr - RunAnyCheck__FP15xAnimTransitionP11xAnimSinglePv: /* 80068068 00064E68 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8006806C 00064E6C 7C 08 02 A6 */ mflr r0 @@ -9214,10 +9207,6 @@ zEntPlayer_RestoreSounds__Fv: /* 8006E68C 0006B48C 90 0D 8C C4 */ stw r0, lbl_803CB5C4-_SDA_BASE_(r13) /* 8006E690 0006B490 4E 80 00 20 */ blr -.global zEntPlayer_Load__FP4xEntP7xSerial -zEntPlayer_Load__FP4xEntP7xSerial: -/* 8006E694 0006B494 4E 80 00 20 */ blr - zEntPlayer_StreakFX__FP4xEntf: /* 8006E698 0006B498 94 21 FF E0 */ stwu r1, -0x20(r1) /* 8006E69C 0006B49C 7C 08 02 A6 */ mflr r0 @@ -15956,13 +15945,6 @@ lbl_80074928: /* 8007493C 0007173C 38 21 00 70 */ addi r1, r1, 0x70 /* 80074940 00071740 4E 80 00 20 */ blr -.global zEntPlayer_PatrickLaunch__FP4xEnt -zEntPlayer_PatrickLaunch__FP4xEnt: -/* 80074944 00071744 3C 80 80 3C */ lis r4, globals@ha -/* 80074948 00071748 38 84 05 58 */ addi r4, r4, globals@l -/* 8007494C 0007174C 90 64 18 7C */ stw r3, 0x187c(r4) -/* 80074950 00071750 4E 80 00 20 */ blr - .global zEntPlayer_ShadowModelEnable__Fv zEntPlayer_ShadowModelEnable__Fv: /* 80074954 00071754 3C 60 80 3C */ lis r3, globals@ha @@ -17679,41 +17661,6 @@ lbl_80076220: /* 8007622C 0007302C 90 0D 8D 30 */ stw r0, lbl_803CB630-_SDA_BASE_(r13) /* 80076230 00073030 4E 80 00 20 */ blr -.global zEntPlayer_Damage__FP5xBaseUiPC5xVec3 -zEntPlayer_Damage__FP5xBaseUiPC5xVec3: -/* 80076234 00073034 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 80076238 00073038 7C 08 02 A6 */ mflr r0 -/* 8007623C 0007303C 90 01 00 14 */ stw r0, 0x14(r1) -/* 80076240 00073040 93 E1 00 0C */ stw r31, 0xc(r1) -/* 80076244 00073044 7C BF 2B 78 */ mr r31, r5 -/* 80076248 00073048 48 00 01 E9 */ bl zEntPlayer_Damage__FP5xBaseUi -/* 8007624C 0007304C 2C 03 00 00 */ cmpwi r3, 0 -/* 80076250 00073050 40 82 00 0C */ bne lbl_8007625C -/* 80076254 00073054 38 60 00 00 */ li r3, 0 -/* 80076258 00073058 48 00 00 3C */ b lbl_80076294 -lbl_8007625C: -/* 8007625C 0007305C 28 1F 00 00 */ cmplwi r31, 0 -/* 80076260 00073060 41 82 00 30 */ beq lbl_80076290 -/* 80076264 00073064 3C 60 80 3C */ lis r3, globals@ha -/* 80076268 00073068 C0 1F 00 00 */ lfs f0, 0(r31) -/* 8007626C 0007306C 38 83 05 58 */ addi r4, r3, globals@l -/* 80076270 00073070 80 64 07 28 */ lwz r3, 0x728(r4) -/* 80076274 00073074 D0 03 00 D4 */ stfs f0, 0xd4(r3) -/* 80076278 00073078 C0 1F 00 04 */ lfs f0, 4(r31) -/* 8007627C 0007307C 80 64 07 28 */ lwz r3, 0x728(r4) -/* 80076280 00073080 D0 03 00 D8 */ stfs f0, 0xd8(r3) -/* 80076284 00073084 C0 1F 00 08 */ lfs f0, 8(r31) -/* 80076288 00073088 80 64 07 28 */ lwz r3, 0x728(r4) -/* 8007628C 0007308C D0 03 00 DC */ stfs f0, 0xdc(r3) -lbl_80076290: -/* 80076290 00073090 38 60 00 01 */ li r3, 1 -lbl_80076294: -/* 80076294 00073094 80 01 00 14 */ lwz r0, 0x14(r1) -/* 80076298 00073098 83 E1 00 0C */ lwz r31, 0xc(r1) -/* 8007629C 0007309C 7C 08 03 A6 */ mtlr r0 -/* 800762A0 000730A0 38 21 00 10 */ addi r1, r1, 0x10 -/* 800762A4 000730A4 4E 80 00 20 */ blr - .global zEntPlayer_DamageNPCKnockBack__FP5xBaseUiP5xVec3 zEntPlayer_DamageNPCKnockBack__FP5xBaseUiP5xVec3: /* 800762A8 000730A8 94 21 FF D0 */ stwu r1, -0x30(r1) @@ -31568,18 +31515,6 @@ Pos__10zNPCCommonFv: /* 80082D00 0007FB00 38 63 00 30 */ addi r3, r3, 0x30 /* 80082D04 0007FB04 4E 80 00 20 */ blr -.global xSndIsPlaying__FUi -xSndIsPlaying__FUi: -/* 80082D08 0007FB08 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 80082D0C 0007FB0C 7C 08 02 A6 */ mflr r0 -/* 80082D10 0007FB10 90 01 00 14 */ stw r0, 0x14(r1) -/* 80082D14 0007FB14 48 04 DA F5 */ bl iSndIsPlaying__FUi -/* 80082D18 0007FB18 80 01 00 14 */ lwz r0, 0x14(r1) -/* 80082D1C 0007FB1C 54 63 06 3E */ clrlwi r3, r3, 0x18 -/* 80082D20 0007FB20 7C 08 03 A6 */ mtlr r0 -/* 80082D24 0007FB24 38 21 00 10 */ addi r1, r1, 0x10 -/* 80082D28 0007FB28 4E 80 00 20 */ blr - .global xSndIsPlayingByHandle__FUi xSndIsPlayingByHandle__FUi: /* 80082D2C 0007FB2C 94 21 FF F0 */ stwu r1, -0x10(r1)