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 01/11] 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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 f5e1b8db0f1e7cbe3993223ef1d4a10b325742b8 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Mon, 12 Oct 2020 09:32:29 -0400 Subject: [PATCH 07/11] decomp zPortal.cpp --- asm/Game/zPortal.s | 105 ---------------------------------------- obj_files.mk | 2 +- src/Game/zCamMarker.cpp | 2 +- src/Game/zPortal.cpp | 63 +++++++++++++++++++++++- src/Game/zPortal.h | 13 ++++- src/Game/zScene.h | 33 +++++++------ 6 files changed, 92 insertions(+), 126 deletions(-) delete mode 100644 asm/Game/zPortal.s diff --git a/asm/Game/zPortal.s b/asm/Game/zPortal.s deleted file mode 100644 index b9b0b4826..000000000 --- a/asm/Game/zPortal.s +++ /dev/null @@ -1,105 +0,0 @@ -.include "macros.inc" - -.section .text # 0x800AC8A0 - 0x800AC9E8 - -.global zPortalInit__FPvPv -zPortalInit__FPvPv: -/* 800AC8A0 000A96A0 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 800AC8A4 000A96A4 7C 08 02 A6 */ mflr r0 -/* 800AC8A8 000A96A8 90 01 00 14 */ stw r0, 0x14(r1) -/* 800AC8AC 000A96AC 48 00 00 15 */ bl zPortalInit__FP8_zPortalP12xPortalAsset -/* 800AC8B0 000A96B0 80 01 00 14 */ lwz r0, 0x14(r1) -/* 800AC8B4 000A96B4 7C 08 03 A6 */ mtlr r0 -/* 800AC8B8 000A96B8 38 21 00 10 */ addi r1, r1, 0x10 -/* 800AC8BC 000A96BC 4E 80 00 20 */ blr - -.global zPortalInit__FP8_zPortalP12xPortalAsset -zPortalInit__FP8_zPortalP12xPortalAsset: -/* 800AC8C0 000A96C0 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 800AC8C4 000A96C4 7C 08 02 A6 */ mflr r0 -/* 800AC8C8 000A96C8 90 01 00 14 */ stw r0, 0x14(r1) -/* 800AC8CC 000A96CC 93 E1 00 0C */ stw r31, 0xc(r1) -/* 800AC8D0 000A96D0 7C 9F 23 78 */ mr r31, r4 -/* 800AC8D4 000A96D4 93 C1 00 08 */ stw r30, 8(r1) -/* 800AC8D8 000A96D8 7C 7E 1B 78 */ mr r30, r3 -/* 800AC8DC 000A96DC 4B F5 CB 25 */ bl xBaseInit__FP5xBaseP10xBaseAsset -/* 800AC8E0 000A96E0 3C 60 80 0B */ lis r3, lbl_800AC984@ha -/* 800AC8E4 000A96E4 93 FE 00 10 */ stw r31, 0x10(r30) -/* 800AC8E8 000A96E8 38 03 C9 84 */ addi r0, r3, lbl_800AC984@l -/* 800AC8EC 000A96EC 90 1E 00 0C */ stw r0, 0xc(r30) -/* 800AC8F0 000A96F0 88 1E 00 05 */ lbz r0, 5(r30) -/* 800AC8F4 000A96F4 28 00 00 00 */ cmplwi r0, 0 -/* 800AC8F8 000A96F8 41 82 00 10 */ beq lbl_800AC908 -/* 800AC8FC 000A96FC 80 7E 00 10 */ lwz r3, 0x10(r30) -/* 800AC900 000A9700 38 03 00 18 */ addi r0, r3, 0x18 -/* 800AC904 000A9704 90 1E 00 08 */ stw r0, 8(r30) -lbl_800AC908: -/* 800AC908 000A9708 80 01 00 14 */ lwz r0, 0x14(r1) -/* 800AC90C 000A970C 83 E1 00 0C */ lwz r31, 0xc(r1) -/* 800AC910 000A9710 83 C1 00 08 */ lwz r30, 8(r1) -/* 800AC914 000A9714 7C 08 03 A6 */ mtlr r0 -/* 800AC918 000A9718 38 21 00 10 */ addi r1, r1, 0x10 -/* 800AC91C 000A971C 4E 80 00 20 */ blr - -.global zPortalReset__FP8_zPortal -zPortalReset__FP8_zPortal: -/* 800AC920 000A9720 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 800AC924 000A9724 7C 08 02 A6 */ mflr r0 -/* 800AC928 000A9728 90 01 00 14 */ stw r0, 0x14(r1) -/* 800AC92C 000A972C 80 83 00 10 */ lwz r4, 0x10(r3) -/* 800AC930 000A9730 4B F5 CB C9 */ bl xBaseReset__FP5xBaseP10xBaseAsset -/* 800AC934 000A9734 80 01 00 14 */ lwz r0, 0x14(r1) -/* 800AC938 000A9738 7C 08 03 A6 */ mtlr r0 -/* 800AC93C 000A973C 38 21 00 10 */ addi r1, r1, 0x10 -/* 800AC940 000A9740 4E 80 00 20 */ blr - -.global zPortalSave__FP8_zPortalP7xSerial -zPortalSave__FP8_zPortalP7xSerial: -/* 800AC944 000A9744 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 800AC948 000A9748 7C 08 02 A6 */ mflr r0 -/* 800AC94C 000A974C 90 01 00 14 */ stw r0, 0x14(r1) -/* 800AC950 000A9750 4B F5 CA FD */ bl xBaseSave__FP5xBaseP7xSerial -/* 800AC954 000A9754 80 01 00 14 */ lwz r0, 0x14(r1) -/* 800AC958 000A9758 7C 08 03 A6 */ mtlr r0 -/* 800AC95C 000A975C 38 21 00 10 */ addi r1, r1, 0x10 -/* 800AC960 000A9760 4E 80 00 20 */ blr - -.global zPortalLoad__FP8_zPortalP7xSerial -zPortalLoad__FP8_zPortalP7xSerial: -/* 800AC964 000A9764 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 800AC968 000A9768 7C 08 02 A6 */ mflr r0 -/* 800AC96C 000A976C 90 01 00 14 */ stw r0, 0x14(r1) -/* 800AC970 000A9770 4B F5 CB 2D */ bl xBaseLoad__FP5xBaseP7xSerial -/* 800AC974 000A9774 80 01 00 14 */ lwz r0, 0x14(r1) -/* 800AC978 000A9778 7C 08 03 A6 */ mtlr r0 -/* 800AC97C 000A977C 38 21 00 10 */ addi r1, r1, 0x10 -/* 800AC980 000A9780 4E 80 00 20 */ blr -lbl_800AC984: -/* 800AC984 000A9784 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 800AC988 000A9788 7C 08 02 A6 */ mflr r0 -/* 800AC98C 000A978C 2C 05 00 10 */ cmpwi r5, 0x10 -/* 800AC990 000A9790 90 01 00 14 */ stw r0, 0x14(r1) -/* 800AC994 000A9794 41 82 00 20 */ beq lbl_800AC9B4 -/* 800AC998 000A9798 40 80 00 3C */ bge lbl_800AC9D4 -/* 800AC99C 000A979C 2C 05 00 0A */ cmpwi r5, 0xa -/* 800AC9A0 000A97A0 41 82 00 08 */ beq lbl_800AC9A8 -/* 800AC9A4 000A97A4 48 00 00 30 */ b lbl_800AC9D4 -lbl_800AC9A8: -/* 800AC9A8 000A97A8 7C 83 23 78 */ mr r3, r4 -/* 800AC9AC 000A97AC 4B FF FF 75 */ bl zPortalReset__FP8_zPortal -/* 800AC9B0 000A97B0 48 00 00 24 */ b lbl_800AC9D4 -lbl_800AC9B4: -/* 800AC9B4 000A97B4 3C 60 80 3C */ lis r3, globals@ha -/* 800AC9B8 000A97B8 38 63 05 58 */ addi r3, r3, globals@l -/* 800AC9BC 000A97BC 80 03 16 B0 */ lwz r0, 0x16b0(r3) -/* 800AC9C0 000A97C0 28 00 00 00 */ cmplwi r0, 0 -/* 800AC9C4 000A97C4 41 82 00 10 */ beq lbl_800AC9D4 -/* 800AC9C8 000A97C8 7C 83 23 78 */ mr r3, r4 -/* 800AC9CC 000A97CC 38 80 00 00 */ li r4, 0 -/* 800AC9D0 000A97D0 48 00 5A 29 */ bl zSceneSwitch__FP8_zPortali -lbl_800AC9D4: -/* 800AC9D4 000A97D4 80 01 00 14 */ lwz r0, 0x14(r1) -/* 800AC9D8 000A97D8 38 60 00 01 */ li r3, 1 -/* 800AC9DC 000A97DC 7C 08 03 A6 */ mtlr r0 -/* 800AC9E0 000A97E0 38 21 00 10 */ addi r1, r1, 0x10 -/* 800AC9E4 000A97E4 4E 80 00 20 */ blr diff --git a/obj_files.mk b/obj_files.mk index 21353cb2f..92c6fd8d3 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -110,7 +110,7 @@ TEXT_O_FILES := \ $(OBJ_DIR)/asm/Game/zPendulum.o \ $(OBJ_DIR)/asm/Game/zPickupTable.o \ $(OBJ_DIR)/asm/Game/zPlatform.o \ - $(OBJ_DIR)/asm/Game/zPortal.o \ + $(OBJ_DIR)/src/Game/zPortal.o \ $(OBJ_DIR)/asm/Game/zRenderState.o \ $(OBJ_DIR)/asm/Game/zRumble.o \ $(OBJ_DIR)/asm/Game/zSaveLoad.o \ diff --git a/src/Game/zCamMarker.cpp b/src/Game/zCamMarker.cpp index 223fd7690..adcf321ad 100644 --- a/src/Game/zCamMarker.cpp +++ b/src/Game/zCamMarker.cpp @@ -26,7 +26,7 @@ void zCamMarkerLoad(zCamMarker* m, xSerial* s) xBaseLoad(m, s); } -int zCamMarkerEventCB(xBase* from, xBase* to, uint32 toEvent, const float32* toParam, xBase* b3) +int32 zCamMarkerEventCB(xBase* from, xBase* to, uint32 toEvent, const float32* toParam, xBase* b3) { switch (toEvent) { diff --git a/src/Game/zPortal.cpp b/src/Game/zPortal.cpp index 14c727842..80592070c 100644 --- a/src/Game/zPortal.cpp +++ b/src/Game/zPortal.cpp @@ -1 +1,62 @@ -#include "zPortal.h" \ No newline at end of file +#include "../Core/x/xBase.h" +#include "../Core/x/xEvent.h" + +#include "zPortal.h" +#include "zGlobals.h" +#include "zScene.h" + +extern zGlobals globals; + +void zPortalInit(void* portal, void* passet) +{ + zPortalInit((_zPortal*)portal, (xPortalAsset*)passet); +} + +void zPortalInit(_zPortal* portal, xPortalAsset* passet) +{ + xBaseInit((xBase*)portal, (xBaseAsset*)passet); + + portal->passet = passet; + portal->eventFunc = (xBaseEventCB)zPortalEventCB; + + if (portal->linkCount != 0) + { + portal->link = (xLinkAsset*)(portal->passet + 1); + } +} + +void zPortalReset(_zPortal* portal) +{ + xBaseReset((xBase*)portal, (xBaseAsset*)portal->passet); +} + +void zPortalSave(_zPortal* ent, xSerial* s) +{ + xBaseSave((xBase*)ent, s); +} + +void zPortalLoad(_zPortal* ent, xSerial* s) +{ + xBaseLoad((xBase*)ent, s); +} + +int32 zPortalEventCB(xBase* from, xBase* to, uint32 toEvent, const float32* toParam, xBase* b3) +{ + switch (toEvent) + { + case eEventReset: + { + zPortalReset((_zPortal*)to); + break; + } + case eEventTeleportPlayer: + { + if (globals.player.Health != 0) + { + zSceneSwitch((_zPortal*)to, false); + } + break; + } + } + return eEventEnable; +} \ No newline at end of file diff --git a/src/Game/zPortal.h b/src/Game/zPortal.h index 822f85e61..49154d850 100644 --- a/src/Game/zPortal.h +++ b/src/Game/zPortal.h @@ -3,11 +3,20 @@ #include "../Core/x/xBase.h" -typedef struct xPortalAsset; +struct xPortalAsset : xBaseAsset +{ + uint32 assetCameraID; + uint32 assetMarkerID; + float32 ang; + uint32 sceneID; +}; struct _zPortal : xBase { - xPortalAsset* passet; + xPortalAsset* passet; }; +void zPortalInit(_zPortal* portal, xPortalAsset* passet); +int32 zPortalEventCB(xBase* from, xBase* to, uint32 toEvent, const float32* toParam, xBase* b3); + #endif \ No newline at end of file diff --git a/src/Game/zScene.h b/src/Game/zScene.h index f4ebdb224..ed6b33bea 100644 --- a/src/Game/zScene.h +++ b/src/Game/zScene.h @@ -10,24 +10,25 @@ struct zScene : xScene { - _zPortal* pendingPortal; - union - { - uint32 num_ents; - uint32 num_base; - }; - union - { - xBase** base; - zEnt** ents; - }; - uint32 num_update_base; - xBase** update_base; - uint32 baseCount[eBaseTypeCount]; - xBase* baseList[eBaseTypeCount]; - _zEnv* zen; + _zPortal* pendingPortal; + union + { + uint32 num_ents; + uint32 num_base; + }; + union + { + xBase** base; + zEnt** ents; + }; + uint32 num_update_base; + xBase** update_base; + uint32 baseCount[eBaseTypeCount]; + xBase* baseList[eBaseTypeCount]; + _zEnv* zen; }; xBase* zSceneFindObject(uint32 gameID); +void zSceneSwitch(_zPortal* p, int32 forceSameScene); #endif \ No newline at end of file From 107595dbc1ab9fa95078f8e6c49866542d5eebfa Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Mon, 12 Oct 2020 10:43:04 -0400 Subject: [PATCH 08/11] start zNPCTypeBoss.cpp --- .gitignore | 1 + Makefile | 2 +- asm/Game/zNPCTypeBoss.s | 58 +++++++-------------------------------- obj_files.mk | 1 + src/Game/zNPCTypeBoss.cpp | 51 +++++++++++++++++++++++++++++++++- 5 files changed, 63 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 6b545ab7a..8eaad6acc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ __pycache__ tools/mwcc_compiler/*.* tools/elf2dol +*.asm *.exe *.dol *.dump diff --git a/Makefile b/Makefile index ee8ff15fe..4cae20b31 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ $(ELF): $(O_FILES) $(LDSCRIPT) $(OBJ_DIR)/%.o: %.s $(AS) $(ASFLAGS) -o $@ $< - $(PPROC) $(PPROCFLAGS) $@ + @$(PPROC) $(PPROCFLAGS) $@ $(OBJ_DIR)/%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/asm/Game/zNPCTypeBoss.s b/asm/Game/zNPCTypeBoss.s index 25f6c4545..6927315d4 100644 --- a/asm/Game/zNPCTypeBoss.s +++ b/asm/Game/zNPCTypeBoss.s @@ -1,52 +1,10 @@ .include "macros.inc" +.if 0 .section .text # 0x8013612C - 0x801365C8 -.global ZNPC_Boss_Startup__Fv -ZNPC_Boss_Startup__Fv: -/* 8013612C 00132F2C 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 80136130 00132F30 7C 08 02 A6 */ mflr r0 -/* 80136134 00132F34 3C 80 80 2A */ lis r4, g_strz_bossanim@ha -/* 80136138 00132F38 3C 60 80 2A */ lis r3, g_hash_bossanim@ha -/* 8013613C 00132F3C 90 01 00 24 */ stw r0, 0x24(r1) -/* 80136140 00132F40 93 E1 00 1C */ stw r31, 0x1c(r1) -/* 80136144 00132F44 3B E4 93 A0 */ addi r31, r4, g_strz_bossanim@l -/* 80136148 00132F48 93 C1 00 18 */ stw r30, 0x18(r1) -/* 8013614C 00132F4C 3B C3 92 68 */ addi r30, r3, g_hash_bossanim@l -/* 80136150 00132F50 93 A1 00 14 */ stw r29, 0x14(r1) -/* 80136154 00132F54 3B A0 00 00 */ li r29, 0 -lbl_80136158: -/* 80136158 00132F58 80 7F 00 00 */ lwz r3, 0(r31) -/* 8013615C 00132F5C 4B F1 60 B9 */ bl xStrHash__FPCc -/* 80136160 00132F60 3B BD 00 01 */ addi r29, r29, 1 -/* 80136164 00132F64 90 7E 00 00 */ stw r3, 0(r30) -/* 80136168 00132F68 2C 1D 00 4E */ cmpwi r29, 0x4e -/* 8013616C 00132F6C 3B FF 00 04 */ addi r31, r31, 4 -/* 80136170 00132F70 3B DE 00 04 */ addi r30, r30, 4 -/* 80136174 00132F74 41 80 FF E4 */ blt lbl_80136158 -/* 80136178 00132F78 80 01 00 24 */ lwz r0, 0x24(r1) -/* 8013617C 00132F7C 83 E1 00 1C */ lwz r31, 0x1c(r1) -/* 80136180 00132F80 83 C1 00 18 */ lwz r30, 0x18(r1) -/* 80136184 00132F84 83 A1 00 14 */ lwz r29, 0x14(r1) -/* 80136188 00132F88 7C 08 03 A6 */ mtlr r0 -/* 8013618C 00132F8C 38 21 00 20 */ addi r1, r1, 0x20 -/* 80136190 00132F90 4E 80 00 20 */ blr - -.global ZNPC_Boss_Shutdown__Fv -ZNPC_Boss_Shutdown__Fv: -/* 80136194 00132F94 4E 80 00 20 */ blr - -.global zNPCBoss_ScenePrepare__Fv -zNPCBoss_ScenePrepare__Fv: -/* 80136198 00132F98 38 00 00 01 */ li r0, 1 -/* 8013619C 00132F9C 90 0D 96 40 */ stw r0, lbl_803CBF40-_SDA_BASE_(r13) -/* 801361A0 00132FA0 4E 80 00 20 */ blr - -.global zNPCBoss_SceneFinish__Fv -zNPCBoss_SceneFinish__Fv: -/* 801361A4 00132FA4 38 00 00 00 */ li r0, 0 -/* 801361A8 00132FA8 90 0D 96 40 */ stw r0, lbl_803CBF40-_SDA_BASE_(r13) -/* 801361AC 00132FAC 4E 80 00 20 */ blr +.global ZNPC_Create_Boss__FiP10RyzMemGrowPv +ZNPC_Create_Boss__FiP10RyzMemGrowPv: /* 801361B0 00132FB0 94 21 FF F0 */ stwu r1, -0x10(r1) /* 801361B4 00132FB4 7C 08 02 A6 */ mflr r0 /* 801361B8 00132FB8 3C C0 4E 54 */ lis r6, 0x4E544232@ha @@ -212,11 +170,11 @@ Setup__8zNPCBossFv: /* 801363F0 001331F0 7C 08 02 A6 */ mflr r0 /* 801363F4 001331F4 90 01 00 14 */ stw r0, 0x14(r1) /* 801363F8 001331F8 4B FB 90 69 */ bl Setup__10zNPCCommonFv -/* 801363FC 001331FC 80 0D 96 40 */ lwz r0, lbl_803CBF40-_SDA_BASE_(r13) +/* 801363FC 001331FC 80 0D 96 40 */ lwz r0, g_boss_is_in_the_house-_SDA_BASE_(r13) /* 80136400 00133200 2C 00 00 00 */ cmpwi r0, 0 /* 80136404 00133204 41 82 00 10 */ beq lbl_80136414 /* 80136408 00133208 38 00 00 00 */ li r0, 0 -/* 8013640C 0013320C 90 0D 96 40 */ stw r0, lbl_803CBF40-_SDA_BASE_(r13) +/* 8013640C 0013320C 90 0D 96 40 */ stw r0, g_boss_is_in_the_house-_SDA_BASE_(r13) /* 80136410 00133210 48 00 00 15 */ bl BOSS_InitEffects__Fv lbl_80136414: /* 80136414 00133214 80 01 00 14 */ lwz r0, 0x14(r1) @@ -346,6 +304,9 @@ __ct__9zNPCB_SB2Fi: /* 801365BC 001333BC 7C 08 03 A6 */ mtlr r0 /* 801365C0 001333C0 38 21 00 10 */ addi r1, r1, 0x10 /* 801365C4 001333C4 4E 80 00 20 */ blr + +.endif + .section .rodata lbl_8026CBB8: .incbin "baserom.dol", 0x269B98, 0x390 @@ -355,7 +316,8 @@ lbl_80324468: .skip 0x170 .section .sbss -lbl_803CBF40: +.global g_boss_is_in_the_house +g_boss_is_in_the_house: .skip 0x4 lbl_803CBF44: .skip 0x4 diff --git a/obj_files.mk b/obj_files.mk index 92c6fd8d3..c07624ef2 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -201,6 +201,7 @@ TEXT_O_FILES := \ $(OBJ_DIR)/asm/Game/zNPCTypeTest.o \ $(OBJ_DIR)/asm/Game/zNPCTypeSubBoss.o \ $(OBJ_DIR)/asm/Game/zNPCTypeBoss.o \ + $(OBJ_DIR)/src/Game/zNPCTypeBoss.o \ $(OBJ_DIR)/asm/Game/zNPCGoalVillager.o \ $(OBJ_DIR)/asm/Game/zNPCGoalSubBoss.o \ $(OBJ_DIR)/asm/Core/x/xShadowSimple.o \ diff --git a/src/Game/zNPCTypeBoss.cpp b/src/Game/zNPCTypeBoss.cpp index 2522bcf06..6bbd3738c 100644 --- a/src/Game/zNPCTypeBoss.cpp +++ b/src/Game/zNPCTypeBoss.cpp @@ -1 +1,50 @@ -#include "zNPCTypeBoss.h" \ No newline at end of file +#include "zNPCTypeBoss.h" + +#include +#include "../Core/x/xString.h" + +extern int32 g_boss_is_in_the_house; +extern uint32 g_hash_bossanim[78]; +extern int8* g_strz_bossanim[78]; + +void ZNPC_Boss_Startup() +{ + // TODO: document/replace hardcoded size + for (int32 i = 0; i < 78; i++) + { + g_hash_bossanim[i] = xStrHash(g_strz_bossanim[i]); + } +} + +void ZNPC_Boss_Shutdown() +{ + return; +} + +void zNPCBoss_ScenePrepare() +{ + g_boss_is_in_the_house = true; +} + +void zNPCBoss_SceneFinish() +{ + g_boss_is_in_the_house = false; +} + +// xFactoryInst* ZNPC_Create_Boss(int32 who, RyzMemGrow* grow) +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "ZNPC_Create_Boss__FiP10RyzMemGrowPv") + +// void Setup(zNPCBoss* this) +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "Setup__8zNPCBossFv") + +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "BOSS_InitEffects__Fv") + +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "__ct__8zNPCBossFi") + +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "__ct__9zNPCB_SB1Fi") + +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "__ct__12zNPCBPatrickFi") + +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "__ct__10zNPCBSandyFi") + +#pragma GLOBAL_ASM("asm/Game/zNPCTypeBoss.s", "__ct__9zNPCB_SB2Fi") From eacb0897e98ad4967193b15467fb9a4f0a273730 Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Mon, 12 Oct 2020 11:49:19 -0400 Subject: [PATCH 09/11] almost decomp 2 zEnt funcs --- asm/Game/zEntPlayer.s | 75 +++++++++++++++++++++-------------------- src/Core/x/xSnd.h | 3 +- src/Game/zEntPlayer.cpp | 26 ++++++++++++-- src/Game/zEntPlayer.h | 58 +++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 39 deletions(-) diff --git a/asm/Game/zEntPlayer.s b/asm/Game/zEntPlayer.s index 6dde37ce7..5ec80d0b8 100644 --- a/asm/Game/zEntPlayer.s +++ b/asm/Game/zEntPlayer.s @@ -5395,8 +5395,8 @@ lbl_8006AEFC: /* 8006AF28 00067D28 D0 23 1F 30 */ stfs f1, 0x1f30(r3) /* 8006AF2C 00067D2C 41 82 00 2C */ beq lbl_8006AF58 /* 8006AF30 00067D30 80 0D 8D 60 */ lwz r0, gCurrentPlayer-_SDA_BASE_(r13) -/* 8006AF34 00067D34 3C 60 80 29 */ lis r3, lbl_8028CE18@ha -/* 8006AF38 00067D38 38 63 CE 18 */ addi r3, r3, lbl_8028CE18@l +/* 8006AF34 00067D34 3C 60 80 29 */ lis r3, sPlayerSndID@ha +/* 8006AF38 00067D38 38 63 CE 18 */ addi r3, r3, sPlayerSndID@l /* 8006AF3C 00067D3C 1C 00 00 BC */ mulli r0, r0, 0xbc /* 8006AF40 00067D40 7C 63 02 14 */ add r3, r3, r0 /* 8006AF44 00067D44 80 03 00 98 */ lwz r0, 0x98(r3) @@ -11056,8 +11056,8 @@ lbl_800700D0: /* 80070158 0006CF58 40 82 00 3C */ bne lbl_80070194 lbl_8007015C: /* 8007015C 0006CF5C 1C 04 00 BC */ mulli r0, r4, 0xbc -/* 80070160 0006CF60 3C 60 80 29 */ lis r3, lbl_8028CE18@ha -/* 80070164 0006CF64 38 63 CE 18 */ addi r3, r3, lbl_8028CE18@l +/* 80070160 0006CF60 3C 60 80 29 */ lis r3, sPlayerSndID@ha +/* 80070164 0006CF64 38 63 CE 18 */ addi r3, r3, sPlayerSndID@l /* 80070168 0006CF68 7C 63 02 14 */ add r3, r3, r0 /* 8007016C 0006CF6C 80 03 00 B4 */ lwz r0, 0xb4(r3) /* 80070170 0006CF70 28 00 00 00 */ cmplwi r0, 0 @@ -11076,8 +11076,8 @@ lbl_80070194: /* 800701A0 0006CFA0 D0 0D 8C BC */ stfs f0, lbl_803CB5BC-_SDA_BASE_(r13) /* 800701A4 0006CFA4 48 00 00 24 */ b lbl_800701C8 lbl_800701A8: -/* 800701A8 0006CFA8 3C 60 80 29 */ lis r3, lbl_8028CE18@ha -/* 800701AC 0006CFAC 39 C3 CE 18 */ addi r14, r3, lbl_8028CE18@l +/* 800701A8 0006CFA8 3C 60 80 29 */ lis r3, sPlayerSndID@ha +/* 800701AC 0006CFAC 39 C3 CE 18 */ addi r14, r3, sPlayerSndID@l /* 800701B0 0006CFB0 80 6E 00 B4 */ lwz r3, 0xb4(r14) /* 800701B4 0006CFB4 4B FD 90 4D */ bl xSndStop__FUi /* 800701B8 0006CFB8 38 00 00 00 */ li r0, 0 @@ -14857,9 +14857,9 @@ lbl_800738F8: /* 80073918 00070718 80 9A 00 24 */ lwz r4, 0x24(r26) /* 8007391C 0007071C EC 20 08 28 */ fsubs f1, f0, f1 /* 80073920 00070720 C0 42 8E D4 */ lfs f2, lbl_803CD854-_SDA2_BASE_(r2) -/* 80073924 00070724 3C 60 80 29 */ lis r3, lbl_8028CE18@ha +/* 80073924 00070724 3C 60 80 29 */ lis r3, sPlayerSndID@ha /* 80073928 00070728 C0 02 8C 10 */ lfs f0, lbl_803CD590-_SDA2_BASE_(r2) -/* 8007392C 0007072C 38 63 CE 18 */ addi r3, r3, lbl_8028CE18@l +/* 8007392C 0007072C 38 63 CE 18 */ addi r3, r3, sPlayerSndID@l /* 80073930 00070730 80 84 00 0C */ lwz r4, 0xc(r4) /* 80073934 00070734 EC 42 00 7C */ fnmsubs f2, f2, f1, f0 /* 80073938 00070738 80 84 00 08 */ lwz r4, 8(r4) @@ -26386,12 +26386,12 @@ zEntPlayer_SNDInit__Fv: /* 8007DFE0 0007ADE0 94 21 FF D0 */ stwu r1, -0x30(r1) /* 8007DFE4 0007ADE4 7C 08 02 A6 */ mflr r0 /* 8007DFE8 0007ADE8 3C 60 80 2E */ lis r3, lbl_802DE3D0@ha -/* 8007DFEC 0007ADEC 3C 80 80 29 */ lis r4, lbl_8028C9B0@ha +/* 8007DFEC 0007ADEC 3C 80 80 29 */ lis r4, sPlayerSnd@ha /* 8007DFF0 0007ADF0 90 01 00 34 */ stw r0, 0x34(r1) /* 8007DFF4 0007ADF4 39 60 00 00 */ li r11, 0 /* 8007DFF8 0007ADF8 38 A3 E3 D0 */ addi r5, r3, lbl_802DE3D0@l /* 8007DFFC 0007ADFC BF 61 00 1C */ stmw r27, 0x1c(r1) -/* 8007E000 0007AE00 3B C4 C9 B0 */ addi r30, r4, lbl_8028C9B0@l +/* 8007E000 0007AE00 3B C4 C9 B0 */ addi r30, r4, sPlayerSnd@l /* 8007E004 0007AE04 39 1E 04 68 */ addi r8, r30, 0x468 /* 8007E008 0007AE08 39 3E 02 34 */ addi r9, r30, 0x234 /* 8007E00C 0007AE0C 39 5E 0C E0 */ addi r10, r30, 0xce0 @@ -28953,11 +28953,11 @@ zEntPlayer_SNDPlay__F14_tagePlayerSndf: /* 80080790 0007D590 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80080794 0007D594 7C 08 02 A6 */ mflr r0 /* 80080798 0007D598 3C 80 80 3C */ lis r4, globals@ha -/* 8008079C 0007D59C 3C A0 80 29 */ lis r5, lbl_8028C9B0@ha +/* 8008079C 0007D59C 3C A0 80 29 */ lis r5, sPlayerSnd@ha /* 800807A0 0007D5A0 90 01 00 14 */ stw r0, 0x14(r1) /* 800807A4 0007D5A4 38 84 05 58 */ addi r4, r4, globals@l /* 800807A8 0007D5A8 93 E1 00 0C */ stw r31, 0xc(r1) -/* 800807AC 0007D5AC 3B E5 C9 B0 */ addi r31, r5, lbl_8028C9B0@l +/* 800807AC 0007D5AC 3B E5 C9 B0 */ addi r31, r5, sPlayerSnd@l /* 800807B0 0007D5B0 93 C1 00 08 */ stw r30, 8(r1) /* 800807B4 0007D5B4 80 04 1F BC */ lwz r0, 0x1fbc(r4) /* 800807B8 0007D5B8 28 00 00 00 */ cmplwi r0, 0 @@ -29027,13 +29027,13 @@ zEntPlayer_SNDPlayStream__F20_tagePlayerStreamSndUi: /* 8008089C 0007D69C 94 21 FF E0 */ stwu r1, -0x20(r1) /* 800808A0 0007D6A0 7C 08 02 A6 */ mflr r0 /* 800808A4 0007D6A4 3C A0 80 3C */ lis r5, globals@ha -/* 800808A8 0007D6A8 3C C0 80 29 */ lis r6, lbl_8028C9B0@ha +/* 800808A8 0007D6A8 3C C0 80 29 */ lis r6, sPlayerSnd@ha /* 800808AC 0007D6AC 90 01 00 24 */ stw r0, 0x24(r1) /* 800808B0 0007D6B0 38 A5 05 58 */ addi r5, r5, globals@l /* 800808B4 0007D6B4 BF 61 00 0C */ stmw r27, 0xc(r1) /* 800808B8 0007D6B8 7C 7B 1B 78 */ mr r27, r3 /* 800808BC 0007D6BC 7C 9C 23 78 */ mr r28, r4 -/* 800808C0 0007D6C0 3B E6 C9 B0 */ addi r31, r6, lbl_8028C9B0@l +/* 800808C0 0007D6C0 3B E6 C9 B0 */ addi r31, r6, sPlayerSnd@l /* 800808C4 0007D6C4 80 05 1F BC */ lwz r0, 0x1fbc(r5) /* 800808C8 0007D6C8 28 00 00 00 */ cmplwi r0, 0 /* 800808CC 0007D6CC 40 82 00 88 */ bne lbl_80080954 @@ -29186,13 +29186,13 @@ zEntPlayer_SNDPlayStreamRandom__F20_tagePlayerStreamSnd20_tagePlayerStreamSndf: /* 80080AD0 0007D8D0 F3 E1 00 B8 */ psq_st f31, 184(r1), 0, qr0 /* 80080AD4 0007D8D4 BF 01 00 90 */ stmw r24, 0x90(r1) /* 80080AD8 0007D8D8 3C A0 80 3C */ lis r5, globals@ha -/* 80080ADC 0007D8DC 3C C0 80 29 */ lis r6, lbl_8028C9B0@ha +/* 80080ADC 0007D8DC 3C C0 80 29 */ lis r6, sPlayerSnd@ha /* 80080AE0 0007D8E0 38 A5 05 58 */ addi r5, r5, globals@l /* 80080AE4 0007D8E4 FF E0 08 90 */ fmr f31, f1 /* 80080AE8 0007D8E8 80 05 1F BC */ lwz r0, 0x1fbc(r5) /* 80080AEC 0007D8EC 7C 7A 1B 78 */ mr r26, r3 /* 80080AF0 0007D8F0 7C 9B 23 78 */ mr r27, r4 -/* 80080AF4 0007D8F4 3B E6 C9 B0 */ addi r31, r6, lbl_8028C9B0@l +/* 80080AF4 0007D8F4 3B E6 C9 B0 */ addi r31, r6, sPlayerSnd@l /* 80080AF8 0007D8F8 28 00 00 00 */ cmplwi r0, 0 /* 80080AFC 0007D8FC 40 82 03 DC */ bne lbl_80080ED8 /* 80080B00 0007D900 48 07 28 91 */ bl NPCC_NPCIsConversing__Fv @@ -29479,13 +29479,13 @@ zEntPlayer_SNDPlayRandom__F14_tagePlayerSnd14_tagePlayerSndf: /* 80080F04 0007DD04 F3 E1 00 B8 */ psq_st f31, 184(r1), 0, qr0 /* 80080F08 0007DD08 BF 21 00 94 */ stmw r25, 0x94(r1) /* 80080F0C 0007DD0C 3C A0 80 3C */ lis r5, globals@ha -/* 80080F10 0007DD10 3C C0 80 29 */ lis r6, lbl_8028C9B0@ha +/* 80080F10 0007DD10 3C C0 80 29 */ lis r6, sPlayerSnd@ha /* 80080F14 0007DD14 38 A5 05 58 */ addi r5, r5, globals@l /* 80080F18 0007DD18 FF E0 08 90 */ fmr f31, f1 /* 80080F1C 0007DD1C 80 05 1F BC */ lwz r0, 0x1fbc(r5) /* 80080F20 0007DD20 7C 7C 1B 78 */ mr r28, r3 /* 80080F24 0007DD24 7C 9D 23 78 */ mr r29, r4 -/* 80080F28 0007DD28 3B E6 C9 B0 */ addi r31, r6, lbl_8028C9B0@l +/* 80080F28 0007DD28 3B E6 C9 B0 */ addi r31, r6, sPlayerSnd@l /* 80080F2C 0007DD2C 28 00 00 00 */ cmplwi r0, 0 /* 80080F30 0007DD30 40 82 02 4C */ bne lbl_8008117C /* 80080F34 0007DD34 80 0D 8C C4 */ lwz r0, lbl_803CB5C4-_SDA_BASE_(r13) @@ -29660,9 +29660,9 @@ lbl_8008117C: zEntPlayer_SNDSetVol__F14_tagePlayerSndf: /* 80081198 0007DF98 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8008119C 0007DF9C 7C 08 02 A6 */ mflr r0 -/* 800811A0 0007DFA0 3C 80 80 29 */ lis r4, lbl_8028C9B0@ha +/* 800811A0 0007DFA0 3C 80 80 29 */ lis r4, sPlayerSnd@ha /* 800811A4 0007DFA4 90 01 00 14 */ stw r0, 0x14(r1) -/* 800811A8 0007DFA8 38 04 C9 B0 */ addi r0, r4, lbl_8028C9B0@l +/* 800811A8 0007DFA8 38 04 C9 B0 */ addi r0, r4, sPlayerSnd@l /* 800811AC 0007DFAC 54 64 10 3A */ slwi r4, r3, 2 /* 800811B0 0007DFB0 80 AD 8D 60 */ lwz r5, gCurrentPlayer-_SDA_BASE_(r13) /* 800811B4 0007DFB4 1C A5 00 BC */ mulli r5, r5, 0xbc @@ -29670,8 +29670,8 @@ zEntPlayer_SNDSetVol__F14_tagePlayerSndf: /* 800811BC 0007DFBC 7C 03 20 2E */ lwzx r0, r3, r4 /* 800811C0 0007DFC0 28 00 00 00 */ cmplwi r0, 0 /* 800811C4 0007DFC4 41 82 00 18 */ beq lbl_800811DC -/* 800811C8 0007DFC8 3C 60 80 29 */ lis r3, lbl_8028CE18@ha -/* 800811CC 0007DFCC 38 03 CE 18 */ addi r0, r3, lbl_8028CE18@l +/* 800811C8 0007DFC8 3C 60 80 29 */ lis r3, sPlayerSndID@ha +/* 800811CC 0007DFCC 38 03 CE 18 */ addi r0, r3, sPlayerSndID@l /* 800811D0 0007DFD0 7C 60 2A 14 */ add r3, r0, r5 /* 800811D4 0007DFD4 7C 63 20 2E */ lwzx r3, r3, r4 /* 800811D8 0007DFD8 4B FC 81 D1 */ bl xSndSetVol__FUif @@ -29685,9 +29685,9 @@ lbl_800811DC: zEntPlayer_SNDSetPitch__F14_tagePlayerSndf: /* 800811EC 0007DFEC 94 21 FF F0 */ stwu r1, -0x10(r1) /* 800811F0 0007DFF0 7C 08 02 A6 */ mflr r0 -/* 800811F4 0007DFF4 3C 80 80 29 */ lis r4, lbl_8028C9B0@ha +/* 800811F4 0007DFF4 3C 80 80 29 */ lis r4, sPlayerSnd@ha /* 800811F8 0007DFF8 90 01 00 14 */ stw r0, 0x14(r1) -/* 800811FC 0007DFFC 38 04 C9 B0 */ addi r0, r4, lbl_8028C9B0@l +/* 800811FC 0007DFFC 38 04 C9 B0 */ addi r0, r4, sPlayerSnd@l /* 80081200 0007E000 54 64 10 3A */ slwi r4, r3, 2 /* 80081204 0007E004 80 AD 8D 60 */ lwz r5, gCurrentPlayer-_SDA_BASE_(r13) /* 80081208 0007E008 1C A5 00 BC */ mulli r5, r5, 0xbc @@ -29695,8 +29695,8 @@ zEntPlayer_SNDSetPitch__F14_tagePlayerSndf: /* 80081210 0007E010 7C 03 20 2E */ lwzx r0, r3, r4 /* 80081214 0007E014 28 00 00 00 */ cmplwi r0, 0 /* 80081218 0007E018 41 82 00 18 */ beq lbl_80081230 -/* 8008121C 0007E01C 3C 60 80 29 */ lis r3, lbl_8028CE18@ha -/* 80081220 0007E020 38 03 CE 18 */ addi r0, r3, lbl_8028CE18@l +/* 8008121C 0007E01C 3C 60 80 29 */ lis r3, sPlayerSndID@ha +/* 80081220 0007E020 38 03 CE 18 */ addi r0, r3, sPlayerSndID@l /* 80081224 0007E024 7C 60 2A 14 */ add r3, r0, r5 /* 80081228 0007E028 7C 63 20 2E */ lwzx r3, r3, r4 /* 8008122C 0007E02C 4B FC 81 9D */ bl xSndSetPitch__FUif @@ -29710,9 +29710,9 @@ lbl_80081230: zEntPlayer_SNDStop__F14_tagePlayerSnd: /* 80081240 0007E040 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80081244 0007E044 7C 08 02 A6 */ mflr r0 -/* 80081248 0007E048 3C 80 80 29 */ lis r4, lbl_8028C9B0@ha +/* 80081248 0007E048 3C 80 80 29 */ lis r4, sPlayerSnd@ha /* 8008124C 0007E04C 90 01 00 14 */ stw r0, 0x14(r1) -/* 80081250 0007E050 38 04 C9 B0 */ addi r0, r4, lbl_8028C9B0@l +/* 80081250 0007E050 38 04 C9 B0 */ addi r0, r4, sPlayerSnd@l /* 80081254 0007E054 93 E1 00 0C */ stw r31, 0xc(r1) /* 80081258 0007E058 54 7F 10 3A */ slwi r31, r3, 2 /* 8008125C 0007E05C 80 AD 8D 60 */ lwz r5, gCurrentPlayer-_SDA_BASE_(r13) @@ -29721,19 +29721,19 @@ zEntPlayer_SNDStop__F14_tagePlayerSnd: /* 80081268 0007E068 7C 03 F8 2E */ lwzx r0, r3, r31 /* 8008126C 0007E06C 28 00 00 00 */ cmplwi r0, 0 /* 80081270 0007E070 41 82 00 60 */ beq lbl_800812D0 -/* 80081274 0007E074 3C 60 80 29 */ lis r3, lbl_8028CE18@ha -/* 80081278 0007E078 38 03 CE 18 */ addi r0, r3, lbl_8028CE18@l +/* 80081274 0007E074 3C 60 80 29 */ lis r3, sPlayerSndID@ha +/* 80081278 0007E078 38 03 CE 18 */ addi r0, r3, sPlayerSndID@l /* 8008127C 0007E07C 7C 60 22 14 */ add r3, r0, r4 /* 80081280 0007E080 7C 63 F8 2E */ lwzx r3, r3, r31 /* 80081284 0007E084 28 03 00 00 */ cmplwi r3, 0 /* 80081288 0007E088 41 82 00 48 */ beq lbl_800812D0 /* 8008128C 0007E08C 4B FC 7F 75 */ bl xSndStop__FUi /* 80081290 0007E090 80 0D 8D 60 */ lwz r0, gCurrentPlayer-_SDA_BASE_(r13) -/* 80081294 0007E094 3C 80 80 29 */ lis r4, lbl_8028CE18@ha +/* 80081294 0007E094 3C 80 80 29 */ lis r4, sPlayerSndID@ha /* 80081298 0007E098 3C 60 80 3C */ lis r3, globals@ha /* 8008129C 0007E09C 38 C0 00 00 */ li r6, 0 /* 800812A0 0007E0A0 1C A0 00 BC */ mulli r5, r0, 0xbc -/* 800812A4 0007E0A4 38 04 CE 18 */ addi r0, r4, lbl_8028CE18@l +/* 800812A4 0007E0A4 38 04 CE 18 */ addi r0, r4, sPlayerSndID@l /* 800812A8 0007E0A8 38 83 05 58 */ addi r4, r3, globals@l /* 800812AC 0007E0AC 80 64 1F C0 */ lwz r3, 0x1fc0(r4) /* 800812B0 0007E0B0 7C A0 2A 14 */ add r5, r0, r5 @@ -29911,11 +29911,11 @@ lbl_80081510: PlayerHackFixBbashMiss__FP14xModelInstance: /* 80081528 0007E328 94 21 F9 C0 */ stwu r1, -0x640(r1) /* 8008152C 0007E32C 7C 08 02 A6 */ mflr r0 -/* 80081530 0007E330 3C 80 80 29 */ lis r4, lbl_8028C9B0@ha +/* 80081530 0007E330 3C 80 80 29 */ lis r4, sPlayerSnd@ha /* 80081534 0007E334 90 01 06 44 */ stw r0, 0x644(r1) /* 80081538 0007E338 BF 01 06 20 */ stmw r24, 0x620(r1) /* 8008153C 0007E33C 7C 78 1B 78 */ mr r24, r3 -/* 80081540 0007E340 38 64 C9 B0 */ addi r3, r4, lbl_8028C9B0@l +/* 80081540 0007E340 38 64 C9 B0 */ addi r3, r4, sPlayerSnd@l /* 80081544 0007E344 3B 61 00 14 */ addi r27, r1, 0x14 /* 80081548 0007E348 3B C3 1C 30 */ addi r30, r3, 0x1c30 /* 8008154C 0007E34C 3B 40 00 00 */ li r26, 0 @@ -46039,9 +46039,12 @@ lbl_80256118: .incbin "baserom.dol", 0x2530F8, 0x37C8 .section .data -lbl_8028C9B0: + +.global sPlayerSnd +sPlayerSnd: .incbin "baserom.dol", 0x289990, 0x468 -lbl_8028CE18: +.global sPlayerSndID +sPlayerSndID: .incbin "baserom.dol", 0x289DF8, 0xFD8 lbl_8028DDF0: .incbin "baserom.dol", 0x28ADD0, 0x3DC diff --git a/src/Core/x/xSnd.h b/src/Core/x/xSnd.h index 83f09ea8c..a37990784 100644 --- a/src/Core/x/xSnd.h +++ b/src/Core/x/xSnd.h @@ -1,6 +1,7 @@ #ifndef XSND_H #define XSND_H - +void xSndSetVol(uint32 snd, float32 vol); +void xSndSetPitch(uint32 snd, float32 pitch); #endif \ No newline at end of file diff --git a/src/Game/zEntPlayer.cpp b/src/Game/zEntPlayer.cpp index 9aa9ee2bf..cdab849fa 100644 --- a/src/Game/zEntPlayer.cpp +++ b/src/Game/zEntPlayer.cpp @@ -4,6 +4,7 @@ #include "../Core/p2/iSnd.h" +#include "../Core/x/xSnd.h" #include "../Core/x/xEnt.h" #include "../Core/x/xVec3.h" @@ -14,6 +15,10 @@ extern zGlobals globals; extern int32 gCurrentPlayer; extern uint32 sCurrentStreamSndID; +// Multidimensional sound arrays for each player type +extern uint32 sPlayerSnd[ePlayer_MAXTYPES][ePlayerSnd_Total]; +extern uint32 sPlayerSndID[ePlayer_MAXTYPES][ePlayerSnd_Total]; + #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SpawnWandBubbles__FP5xVec3Ui") #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayerKillCarry__Fv") @@ -420,10 +425,27 @@ void zEntPlayer_GiveShinyObject(int32 quantity) #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", \ "zEntPlayer_SNDPlayRandom__F14_tagePlayerSnd14_tagePlayerSndf") -// void zEntPlayer_SNDSetVol(_tagePlayerSnd player_snd, float new_vol) +/* +void zEntPlayer_SNDSetVol(_tagePlayerSnd player_snd, float32 new_vol) +{ + // only 1 slightly incorrect instruction preventing match + if (sPlayerSnd[gCurrentPlayer][player_snd] != 0) + { + xSndSetVol(sPlayerSndID[gCurrentPlayer][player_snd], new_vol); + } +}*/ #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDSetVol__F14_tagePlayerSndf") -// void zEntPlayer_SNDSetPitch(_tagePlayerSnd player_snd, float new_pitch) +/* +void zEntPlayer_SNDSetPitch(_tagePlayerSnd player_snd, float32 new_pitch) +{ + // only 1 slightly incorrect instruction preventing match + if (sPlayerSnd[gCurrentPlayer][player_snd] != 0) + { + xSndSetPitch(sPlayerSndID[gCurrentPlayer][player_snd], new_pitch); + } +} +*/ #pragma GLOBAL_ASM("asm/Game/zEntPlayer.s", "zEntPlayer_SNDSetPitch__F14_tagePlayerSndf") // void zEntPlayer_SNDStop(_tagePlayerSnd player_snd) diff --git a/src/Game/zEntPlayer.h b/src/Game/zEntPlayer.h index c5952a5b9..5537faf2a 100644 --- a/src/Game/zEntPlayer.h +++ b/src/Game/zEntPlayer.h @@ -6,6 +6,64 @@ #include "../Core/x/xAnim.h" #include "zLasso.h" +enum _tagePlayerSnd +{ + ePlayerSnd_Invalid, + ePlayerSnd_Land, + ePlayerSnd_Jump, + ePlayerSnd_DoubleJump, + ePlayerSnd_BowlWindup, + ePlayerSnd_BowlRelease, + ePlayerSnd_BubbleBashStart, + ePlayerSnd_BubbleBashHit1, + ePlayerSnd_BubbleBashHitStart = 0x7, + ePlayerSnd_BubbleBashHit2, + ePlayerSnd_BubbleBashHitEnd = 0x8, + ePlayerSnd_BubbleWand, + ePlayerSnd_CruiseStart, + ePlayerSnd_CruiseNavigate, + ePlayerSnd_CruiseHit, + ePlayerSnd_BounceStrike, + ePlayerSnd_BoulderStart, + ePlayerSnd_BoulderRoll, + ePlayerSnd_BoulderEnd, + ePlayerSnd_BellyMelee, + ePlayerSnd_BellySmash, + ePlayerSnd_Lift1, + ePlayerSnd_Throw, + ePlayerSnd_Chop, + ePlayerSnd_Kick, + ePlayerSnd_Heli, + ePlayerSnd_LassoThrow, + ePlayerSnd_LassoYank, + ePlayerSnd_LassoStretch, + ePlayerSnd_Ouch1, + ePlayerSnd_OuchStart = 0x1b, + ePlayerSnd_Ouch2, + ePlayerSnd_Ouch3, + ePlayerSnd_Ouch4, + ePlayerSnd_OuchEnd = 0x1e, + ePlayerSnd_Death, + ePlayerSnd_FruitCrackle, + ePlayerSnd_CheckPoint, + ePlayerSnd_PickupSpatula, + ePlayerSnd_PickupUnderwear, + ePlayerSnd_Bus, + ePlayerSnd_Taxi, + ePlayerSnd_SlideLoop, + ePlayerSnd_BeginBungee, + ePlayerSnd_BungeeWind = 0x27, + ePlayerSnd_BungeeAttach, + ePlayerSnd_BungeeRelease, + ePlayerSnd_EndBungee = 0x29, + ePlayerSnd_PickupSpatulaComment, + ePlayerSnd_BungeeDive1, + ePlayerSnd_BungeeDive2, + ePlayerSnd_Sneak, + ePlayerSnd_SlipLoop, + ePlayerSnd_Total +}; + enum _zPlayerType { ePlayer_SB, From b2da195dce636adfb6fbac5753b3f92c9305cdea Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Mon, 12 Oct 2020 15:14:41 -0400 Subject: [PATCH 10/11] start xString.cpp --- asm/Core/x/xString.s | 5 ++- obj_files.mk | 1 + src/Core/x/xString.cpp | 99 +++++++++++++++++++++++++++++++++++++++++- src/Core/x/xString.h | 3 +- 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/asm/Core/x/xString.s b/asm/Core/x/xString.s index aa966325b..5569e95b3 100644 --- a/asm/Core/x/xString.s +++ b/asm/Core/x/xString.s @@ -1,5 +1,6 @@ .include "macros.inc" +.if 0 .section .text # 0x8004C214 - 0x8004D054 .global xStrHash__FPCc @@ -1085,7 +1086,9 @@ lbl_8004D038: /* 8004D048 00049E48 40 82 FF C0 */ bne lbl_8004D008 lbl_8004D04C: /* 8004D04C 00049E4C 38 60 00 00 */ li r3, 0 -/* 8004D050 00049E50 4E 80 00 20 */ blr +/* 8004D050 00049E50 4E 80 00 20 */ blr + +.endif .section .data lbl_8028A228: diff --git a/obj_files.mk b/obj_files.mk index c07624ef2..1f5ed5008 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -63,6 +63,7 @@ TEXT_O_FILES := \ $(OBJ_DIR)/asm/Core/x/xSpline.o \ $(OBJ_DIR)/asm/Core/x/xstransvc.o \ $(OBJ_DIR)/asm/Core/x/xString.o \ + $(OBJ_DIR)/src/Core/x/xString.o \ $(OBJ_DIR)/asm/Core/x/xSurface.o \ $(OBJ_DIR)/asm/Core/x/xTimer.o \ $(OBJ_DIR)/asm/Core/x/xTRC.o \ diff --git a/src/Core/x/xString.cpp b/src/Core/x/xString.cpp index 038bef674..5a37b3437 100644 --- a/src/Core/x/xString.cpp +++ b/src/Core/x/xString.cpp @@ -1 +1,98 @@ -#include "xString.h" \ No newline at end of file +#include "xString.h" + +uint32 xStrHash(const int8* str) +{ + uint32 hash = 0; + uint32 i; + + while (i = *str, i != NULL) + { + hash = (i - (i & (int32)i >> 1 & 0x20) & 0xff) + hash * 0x83; + str++; + } + + return hash; +} + +uint32 xStrHash(const int8* str, ulong32 size) +{ + uint32 hash = 0; + uint32 i = 0; + uint32 c; + + while (i < size && (c = *str, c != NULL)) + { + i++; + str++; + hash = (c - (c & (int32)c >> 1 & 0x20) & 0xff) + hash * 0x83; + } + + return hash; +} + +uint32 xStrHashCat(uint32 prefix, const int8* str) +{ + uint32 hash; + uint32 i; + + while (i = *str, i != NULL) + { + str++; + hash = (i - (i & (int32)i >> 1 & 0x20) & 0xff) + hash * 0x83; + } + + return hash; +} + +// char* xStrTok(char* string, char* control, char** nextoken) +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "xStrTok__FPcPCcPPc") + +// char* xStrTokBuffer(char* string, char* control, void* buffer) +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "xStrTokBuffer__FPCcPCcPv") + +// int xStricmp(char* string1, char* string2) +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "xStricmp__FPCcPCc") + +int8* xStrupr(int8* string) +{ + int8 p; + + while (p = *string, p != NULL) + { + bool isLowercase = false; + + // check if between lowercase ascii a-z + if ((p >= 97) && (p <= 122)) + { + isLowercase = true; + } + + if (isLowercase) + { + // Uppercase ascii character is offset by 32 + p -= 32; + } + + *string = p; + string++; + } +} + +// int xStrParseFloatList(float* dest, char* strbuf, int max) +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "xStrParseFloatList__FPfPCci") + +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "imemcmp__FPCvPCvUl") + +#pragma GLOBAL_ASM("asm/Core/x/xString.s", \ + "tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fc") + +#pragma GLOBAL_ASM("asm/Core/x/xString.s", \ + "tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi") + +// int icompare(substr& s1, substr& s2) +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "icompare__FRC6substrRC6substr") + +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "atox__FRC6substrRUl") + +// char* find_char(substr& s, substr& cs) +#pragma GLOBAL_ASM("asm/Core/x/xString.s", "find_char__FRC6substrRC6substr") diff --git a/src/Core/x/xString.h b/src/Core/x/xString.h index 49785b38d..5f89d29d5 100644 --- a/src/Core/x/xString.h +++ b/src/Core/x/xString.h @@ -3,6 +3,7 @@ #include -extern uint32 xStrHash(const char* str); +uint32 xStrHash(const int8* str); +uint32 xStrHash(const int8* str, ulong32 size); #endif \ No newline at end of file From 8a5d59fe6947b66778e6651769a9ebe012cc259d Mon Sep 17 00:00:00 2001 From: Matt <5638426+mattbruv@users.noreply.github.com> Date: Mon, 12 Oct 2020 16:30:13 -0400 Subject: [PATCH 11/11] almost decomp icompare --- asm/Core/x/xString.s | 93 ------------------------------------------ src/Core/x/xString.cpp | 53 +++++++++++++++++++++--- src/Core/x/xString.h | 15 +++++++ 3 files changed, 63 insertions(+), 98 deletions(-) diff --git a/asm/Core/x/xString.s b/asm/Core/x/xString.s index 5569e95b3..0d054d59d 100644 --- a/asm/Core/x/xString.s +++ b/asm/Core/x/xString.s @@ -3,69 +3,6 @@ .if 0 .section .text # 0x8004C214 - 0x8004D054 -.global xStrHash__FPCc -xStrHash__FPCc: -/* 8004C214 00049014 38 A0 00 00 */ li r5, 0 -/* 8004C218 00049018 48 00 00 24 */ b lbl_8004C23C -lbl_8004C21C: -/* 8004C21C 0004901C 7C 80 0E 70 */ srawi r0, r4, 1 -/* 8004C220 00049020 38 63 00 01 */ addi r3, r3, 1 -/* 8004C224 00049024 7C 80 00 38 */ and r0, r4, r0 -/* 8004C228 00049028 54 00 06 B4 */ rlwinm r0, r0, 0, 0x1a, 0x1a -/* 8004C22C 0004902C 7C 80 20 50 */ subf r4, r0, r4 -/* 8004C230 00049030 1C 05 00 83 */ mulli r0, r5, 0x83 -/* 8004C234 00049034 54 84 06 3E */ clrlwi r4, r4, 0x18 -/* 8004C238 00049038 7C A4 02 14 */ add r5, r4, r0 -lbl_8004C23C: -/* 8004C23C 0004903C 88 83 00 00 */ lbz r4, 0(r3) -/* 8004C240 00049040 28 04 00 00 */ cmplwi r4, 0 -/* 8004C244 00049044 40 82 FF D8 */ bne lbl_8004C21C -/* 8004C248 00049048 7C A3 2B 78 */ mr r3, r5 -/* 8004C24C 0004904C 4E 80 00 20 */ blr - -.global xStrHash__FPCcUl -xStrHash__FPCcUl: -/* 8004C250 00049050 38 C0 00 00 */ li r6, 0 -/* 8004C254 00049054 38 E0 00 00 */ li r7, 0 -/* 8004C258 00049058 48 00 00 28 */ b lbl_8004C280 -lbl_8004C25C: -/* 8004C25C 0004905C 7C A0 0E 70 */ srawi r0, r5, 1 -/* 8004C260 00049060 38 E7 00 01 */ addi r7, r7, 1 -/* 8004C264 00049064 7C A0 00 38 */ and r0, r5, r0 -/* 8004C268 00049068 38 63 00 01 */ addi r3, r3, 1 -/* 8004C26C 0004906C 54 00 06 B4 */ rlwinm r0, r0, 0, 0x1a, 0x1a -/* 8004C270 00049070 7C A0 28 50 */ subf r5, r0, r5 -/* 8004C274 00049074 1C 06 00 83 */ mulli r0, r6, 0x83 -/* 8004C278 00049078 54 A5 06 3E */ clrlwi r5, r5, 0x18 -/* 8004C27C 0004907C 7C C5 02 14 */ add r6, r5, r0 -lbl_8004C280: -/* 8004C280 00049080 7C 07 20 40 */ cmplw r7, r4 -/* 8004C284 00049084 40 80 00 10 */ bge lbl_8004C294 -/* 8004C288 00049088 88 A3 00 00 */ lbz r5, 0(r3) -/* 8004C28C 0004908C 28 05 00 00 */ cmplwi r5, 0 -/* 8004C290 00049090 40 82 FF CC */ bne lbl_8004C25C -lbl_8004C294: -/* 8004C294 00049094 7C C3 33 78 */ mr r3, r6 -/* 8004C298 00049098 4E 80 00 20 */ blr - -.global xStrHashCat__FUiPCc -xStrHashCat__FUiPCc: -/* 8004C29C 0004909C 48 00 00 24 */ b lbl_8004C2C0 -lbl_8004C2A0: -/* 8004C2A0 000490A0 7C A0 0E 70 */ srawi r0, r5, 1 -/* 8004C2A4 000490A4 38 84 00 01 */ addi r4, r4, 1 -/* 8004C2A8 000490A8 7C A0 00 38 */ and r0, r5, r0 -/* 8004C2AC 000490AC 54 00 06 B4 */ rlwinm r0, r0, 0, 0x1a, 0x1a -/* 8004C2B0 000490B0 7C A0 28 50 */ subf r5, r0, r5 -/* 8004C2B4 000490B4 1C 03 00 83 */ mulli r0, r3, 0x83 -/* 8004C2B8 000490B8 54 A3 06 3E */ clrlwi r3, r5, 0x18 -/* 8004C2BC 000490BC 7C 63 02 14 */ add r3, r3, r0 -lbl_8004C2C0: -/* 8004C2C0 000490C0 88 A4 00 00 */ lbz r5, 0(r4) -/* 8004C2C4 000490C4 28 05 00 00 */ cmplwi r5, 0 -/* 8004C2C8 000490C8 40 82 FF D8 */ bne lbl_8004C2A0 -/* 8004C2CC 000490CC 4E 80 00 20 */ blr - .global xStrTok__FPcPCcPPc xStrTok__FPcPCcPPc: /* 8004C2D0 000490D0 94 21 FF D0 */ stwu r1, -0x30(r1) @@ -356,30 +293,6 @@ lbl_8004C694: /* 8004C69C 0004949C 38 60 FF FF */ li r3, -1 /* 8004C6A0 000494A0 4E 80 00 20 */ blr -.global xStrupr__FPc -xStrupr__FPc: -/* 8004C6A4 000494A4 7C 65 1B 78 */ mr r5, r3 -/* 8004C6A8 000494A8 48 00 00 30 */ b lbl_8004C6D8 -lbl_8004C6AC: -/* 8004C6AC 000494AC 28 04 00 61 */ cmplwi r4, 0x61 -/* 8004C6B0 000494B0 38 00 00 00 */ li r0, 0 -/* 8004C6B4 000494B4 41 80 00 10 */ blt lbl_8004C6C4 -/* 8004C6B8 000494B8 28 04 00 7A */ cmplwi r4, 0x7a -/* 8004C6BC 000494BC 41 81 00 08 */ bgt lbl_8004C6C4 -/* 8004C6C0 000494C0 38 00 00 01 */ li r0, 1 -lbl_8004C6C4: -/* 8004C6C4 000494C4 54 00 06 3F */ clrlwi. r0, r0, 0x18 -/* 8004C6C8 000494C8 41 82 00 08 */ beq lbl_8004C6D0 -/* 8004C6CC 000494CC 38 84 FF E0 */ addi r4, r4, -32 -lbl_8004C6D0: -/* 8004C6D0 000494D0 98 85 00 00 */ stb r4, 0(r5) -/* 8004C6D4 000494D4 38 A5 00 01 */ addi r5, r5, 1 -lbl_8004C6D8: -/* 8004C6D8 000494D8 88 85 00 00 */ lbz r4, 0(r5) -/* 8004C6DC 000494DC 28 04 00 00 */ cmplwi r4, 0 -/* 8004C6E0 000494E0 40 82 FF CC */ bne lbl_8004C6AC -/* 8004C6E4 000494E4 4E 80 00 20 */ blr - .global xStrParseFloatList__FPfPCci xStrParseFloatList__FPfPCci: /* 8004C6E8 000494E8 94 21 FF E0 */ stwu r1, -0x20(r1) @@ -554,12 +467,6 @@ tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fc: /* 8004C920 00049720 38 21 00 10 */ addi r1, r1, 0x10 /* 8004C924 00049724 4E 80 00 20 */ blr -/* tolower__21@unnamed@xString_cpp@Fi */ -tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi: -/* 8004C928 00049728 54 60 FE B4 */ rlwinm r0, r3, 0x1f, 0x1a, 0x1a -/* 8004C92C 0004972C 7C 63 03 78 */ or r3, r3, r0 -/* 8004C930 00049730 4E 80 00 20 */ blr - .global icompare__FRC6substrRC6substr icompare__FRC6substrRC6substr: /* 8004C934 00049734 94 21 FF F0 */ stwu r1, -0x10(r1) diff --git a/src/Core/x/xString.cpp b/src/Core/x/xString.cpp index 5a37b3437..4289b469d 100644 --- a/src/Core/x/xString.cpp +++ b/src/Core/x/xString.cpp @@ -83,13 +83,56 @@ int8* xStrupr(int8* string) #pragma GLOBAL_ASM("asm/Core/x/xString.s", "imemcmp__FPCvPCvUl") -#pragma GLOBAL_ASM("asm/Core/x/xString.s", \ - "tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fc") +// @unnamed@xString_cpp@::tolower(char) +extern "C" { +uint32 tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fc(uint32 param_1) +{ + tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi(param_1 & 0xff); +} +} + +// @unnamed@xString_cpp@::tolower(int) +extern "C" { +uint32 tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi(uint32 param_1) +{ + return param_1 | ((param_1 >> 1) & 32); +} +} + +/* +// Non-matching +int32 icompare(const substr& s1, const substr& s2) +{ + int32 result; + uint32 len; + + len = s2.size; -#pragma GLOBAL_ASM("asm/Core/x/xString.s", \ - "tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi") + if (s1.size < s2.size) + { + len = s1.size; + } + + result = imemcmp(s1.text, s2.text, len); -// int icompare(substr& s1, substr& s2) + if (result == 0) + { + if (s1.size == s2.size) + { + result = 0; + } + else + { + result = 1; + if (s1.size < s2.size) + { + result = -1; + } + } + } + return result; +} +*/ #pragma GLOBAL_ASM("asm/Core/x/xString.s", "icompare__FRC6substrRC6substr") #pragma GLOBAL_ASM("asm/Core/x/xString.s", "atox__FRC6substrRUl") diff --git a/src/Core/x/xString.h b/src/Core/x/xString.h index 5f89d29d5..d210db7b6 100644 --- a/src/Core/x/xString.h +++ b/src/Core/x/xString.h @@ -3,7 +3,22 @@ #include +struct substr +{ + int8* text; + uint32 size; +}; + uint32 xStrHash(const int8* str); uint32 xStrHash(const int8* str, ulong32 size); +uint32 xStrHashCat(uint32 prefix, const int8* str); +int8* xStrupr(int8* string); + +int32 imemcmp(void const* d1, void const* d2, ulong32 size); + +extern "C" { +uint32 tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fc(uint32 param_1); +uint32 tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi(uint32 param_1); +} #endif \ No newline at end of file