Fix diffs

This commit is contained in:
MonsterDruide1 2021-07-15 23:52:39 +02:00
parent 0f1f1dbf7a
commit 6aef5db802
29 changed files with 125 additions and 272 deletions

View File

@ -1,12 +1,12 @@
if (NOT DEFINED ENV{UKING_CLANG})
message(FATAL_ERROR "Please define the UKING_CLANG env variable. It should point to a path such that $UKING_CLANG/bin/clang exists")
if (NOT DEFINED ENV{ODYSSEY_CLANG})
message(FATAL_ERROR "Please define the ODYSSEY_CLANG env variable. It should point to a path such that $ODYSSEY_CLANG/bin/clang exists")
endif()
if (NOT DEFINED ENV{DEVKITA64})
message(FATAL_ERROR "Please define the DEVKITA64 env variable.")
endif()
set(UKING_CLANG "$ENV{UKING_CLANG}")
set(ODYSSEY_CLANG "$ENV{ODYSSEY_CLANG}")
set(DEVKITA64 "$ENV{DEVKITA64}")
set(NX64_OPT_FLAGS "-O3 -g")
set(triple aarch64-none-elf)
@ -15,10 +15,10 @@ set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSROOT ${UKING_CLANG})
set(CMAKE_C_COMPILER "${UKING_CLANG}/bin/clang")
set(CMAKE_SYSROOT ${ODYSSEY_CLANG})
set(CMAKE_C_COMPILER "${ODYSSEY_CLANG}/bin/clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER "${UKING_CLANG}/bin/clang++")
set(CMAKE_CXX_COMPILER "${ODYSSEY_CLANG}/bin/clang++")
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_C_FLAGS_RELEASE ${NX64_OPT_FLAGS})
@ -28,7 +28,7 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${NX64_OPT_FLAGS})
set(ARCH "-mcpu=cortex-a57+fp+simd+crypto+crc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH} -isystem ${DEVKITA64}/aarch64-none-elf/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${UKING_CLANG}/include/c++/v1 -D _LIBCPP_HAS_THREAD_API_PTHREAD ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${ODYSSEY_CLANG}/include/c++/v1 -D _LIBCPP_HAS_THREAD_API_PTHREAD ${CMAKE_C_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -x assembler-with-cpp ${ARCH}")
add_compile_options(-fPIC -stdlib=libc++ -mno-implicit-float)

View File

@ -58007,7 +58007,7 @@
0x000000710090cc10,_ZN2al17HitReactionKeeper19tryFindReactionInfoEPKc,120,
0x000000710090cc88,_ZN2al17HitReactionKeeperC1EPKcPKN4sead7Vector3IfEEPNS_16IUseEffectKeeperEPKNS_15IUseAudioKeeperEPKNS_10IUseCameraEPNS_17PadRumbleDirectorEPNS_13SceneStopCtrlEPNS_18RadialBlurDirectorEPKNS_12PlayerHolderEPKNS_8ResourceES2_,1592,
0x000000710090d2c0,_ZNK2al17HitReactionKeeper19tryFindReactionInfoEPKc,120,
0x000000710090d338,_ZN2al9LiveActorC2EPKc,304,_ZN2al9LiveActorC2EPKc
0x000000710090d338,_ZN2al9LiveActorC2EPKc,304,
0x000000710090d468,_ZN2al9LiveActorC1EPKc,148,
0x000000710090d4fc,_ZN2al9LiveActor18initAfterPlacementEv,52,
0x000000710090d530,_ZN2al9LiveActor6appearEv,12,
@ -60072,16 +60072,16 @@
0x0000007100959c8c,_ZN2al12getNerveStepEPKNS_9IUseNerveE,32,_ZN2al12getNerveStepEPKNS_9IUseNerveE
0x0000007100959cac,_ZN2al15getCurrentNerveEPKNS_9IUseNerveE,28,_ZN2al15getCurrentNerveEPKNS_9IUseNerveE
0x0000007100959cc8,_ZN2al11isFirstStepEPKNS_9IUseNerveE,40,_ZN2al11isFirstStepEPKNS_9IUseNerveE
0x0000007100959cf0,_ZN2al10isLessStepEPKNS_9IUseNerveEi,52,_ZN2al15isLessEqualStepEPKNS_9IUseNerveEi
0x0000007100959d24,_ZN2al15isLessEqualStepEPKNS_9IUseNerveEi,52,_ZN2al10isLessStepEPKNS_9IUseNerveEi
0x0000007100959cf0,_ZN2al10isLessStepEPKNS_9IUseNerveEi,52,_ZN2al10isLessStepEPKNS_9IUseNerveEi
0x0000007100959d24,_ZN2al15isLessEqualStepEPKNS_9IUseNerveEi,52,_ZN2al15isLessEqualStepEPKNS_9IUseNerveEi
0x0000007100959d58,_ZN2al13isGreaterStepEPKNS_9IUseNerveEi,52,_ZN2al13isGreaterStepEPKNS_9IUseNerveEi
0x0000007100959d8c,_ZN2al13isInRangeStepEPKNS_9IUseNerveEii,68,_ZN2al13isInRangeStepEPKNS_9IUseNerveEii
0x0000007100959dd0,_ZN2al14isIntervalStepEPKNS_9IUseNerveEii,80,
0x0000007100959e20,_ZN2al19isIntervalOnOffStepEPKNS_9IUseNerveEii,64,
0x0000007100959e60,_ZN2al10isNewNerveEPKNS_9IUseNerveE,36,
0x0000007100959e84,_ZN2al17calcNerveIntervalEPKNS_9IUseNerveEii,80,
0x0000007100959e84,_ZN2al17calcNerveIntervalEPKNS_9IUseNerveEii,80,_ZN2al17calcNerveIntervalEPKNS_9IUseNerveEii
0x0000007100959ed4,_ZN2al13calcNerveRateEPKNS_9IUseNerveEi,104,_ZN2al13calcNerveRateEPKNS_9IUseNerveEi
0x0000007100959f3c,_ZN2al13calcNerveRateEPKNS_9IUseNerveEii,96,_ZN2al17calcNerveIntervalEPKNS_9IUseNerveEii
0x0000007100959f3c,_ZN2al13calcNerveRateEPKNS_9IUseNerveEii,96,
0x0000007100959f9c,_ZN2al19calcNerveEaseInRateEPKNS_9IUseNerveEi,104,
0x000000710095a004,_ZN2al19calcNerveEaseInRateEPKNS_9IUseNerveEii,96,
0x000000710095a064,_ZN2al20calcNerveEaseOutRateEPKNS_9IUseNerveEi,104,

Can't render this file because it is too large.

@ -1 +1 @@
Subproject commit 1838960fa158df935ae7f329cf1ebe062d80584a
Subproject commit a840c04b1749fbdb4c554fc55d24b72e4033797c

View File

@ -1,5 +1,7 @@
#pragma once
#include <basis/seadTypes.h>
namespace al
{
class ByamlContainerHeader
@ -8,6 +10,6 @@ namespace al
int getType() const;
int getCount(bool) const;
int mType; // _0
u32 mType; // _0
};
};

View File

@ -1,5 +1,7 @@
#pragma once
#include <basis/seadTypes.h>
namespace al
{
class ByamlStringTableIter
@ -9,7 +11,7 @@ namespace al
ByamlStringTableIter(const unsigned char *, bool);
int getSize() const;
const unsigned char* getAddressTable() const;
const u32* getAddressTable() const;
int getStringAddress(int) const;
int getEndAddress() const;
const char* getString(int) const;
@ -17,7 +19,7 @@ namespace al
int findStringIndex(const char *) const;
bool isValidate() const;
const unsigned char* mData; // _0
unsigned char _8;
const u8* mData; // _0
bool mReversed;
};
};

View File

@ -8,8 +8,8 @@ namespace al
{
public:
NerveStateBase(const char *);
virtual ~NerveStateBase();
virtual void init();
virtual void appear();
virtual void kill();

View File

@ -34,7 +34,7 @@ namespace al
al::SensorHitGroup* mHitGroup; // _30
bool mIsValidBySystem; // _38
bool mIsValid; // _39
unsigned int _3A;
bool _3A[4]; // unknown type
unsigned short _3E;
al::LiveActor* mParentActor; // _40
const sead::Vector3<float>* mFollowPos; // _48

View File

@ -4,11 +4,6 @@
namespace al
{
LiveActor::LiveActor(const char *pName)
{
}
al::NerveKeeper* LiveActor::getNerveKeeper() const
{
return mNerveKeeper;

View File

@ -18,19 +18,12 @@ namespace al
return count;
}
void LiveActorGroup::removeActor(const al::LiveActor *pActor)
{
auto actorCount = mActorCount;
if (actorCount >= 1)
{
for (auto i = 0; i < actorCount; i++)
{
if (mActors[i] == pActor)
{
mActors[mActorCount] = mActors[mActorCount - 1];
mActorCount--;
}
void LiveActorGroup::removeActor(const al::LiveActor *pActor) {
for (int i = 0; i < mActorCount; i++) {
if (mActors[i] == pActor) {
mActors[i] = mActors[mActorCount - 1];
mActorCount--;
break;
}
}
}

View File

@ -1,4 +1,5 @@
#include "al/byaml/ByamlContainerHeader.h"
#include <byteswap.h>
namespace al
{
@ -10,17 +11,9 @@ namespace al
int ByamlContainerHeader::getCount(bool isRev) const
{
/* todo -- attempt to remove ASR instruction for the else block */
int val;
if (isRev)
{
val = ((mType >> 24) & 0xFF) | ((mType >> 16) & 0xFF) << 8 | ((mType >> 8) & 0xFF) << 16;
}
else
{
val = mType >> 8;
}
return ((mType >> 24) & 0xFF) | ((mType >> 16) & 0xFF) << 8 | ((mType >> 8) & 0xFF) << 16;
return val;
return (mType >> 8);
}
};

View File

@ -22,14 +22,9 @@ namespace al
int ByamlHashPair::getValue(bool isSwap) const
{
int swap = __bswap_32(mData);
int val;
if (isSwap)
val = swap;
if(isSwap)
return __bswap_32(mValue);
else
val = mData;
return val;
return mValue;
}
};

View File

@ -4,43 +4,34 @@
namespace al
{
ByamlStringTableIter::ByamlStringTableIter()
: mData(0), _8(0) { }
: mData(0), mReversed(0) { }
ByamlStringTableIter::ByamlStringTableIter(const unsigned char *pData, bool unk)
ByamlStringTableIter::ByamlStringTableIter(const u8* pData, bool pReversed)
{
mData = pData;
_8 = unk;
mReversed = pReversed;
}
int ByamlStringTableIter::getSize() const
{
/* todo -- why does this use different register numbers? */
return _8 != 0 ? ((*mData >> 24) & 0xFF) | ((*mData >> 16) & 0xFF) << 8 | ((*mData >> 8) & 0xFF) << 16 : *mData >> 8;
u32 type_and_size = *reinterpret_cast<const u32*>(mData);
if(mReversed)
return ((type_and_size >> 24) & 0xFF) | ((type_and_size >> 16) & 0xFF) << 8 | ((type_and_size >> 8) & 0xFF) << 16;
return type_and_size >> 8;
}
const unsigned char* ByamlStringTableIter::getAddressTable() const
const u32* ByamlStringTableIter::getAddressTable() const
{
// mData is an integer pointer, so getting to the table is just increasing the pointer by 1 (which is + 4)
return reinterpret_cast<const unsigned char *>(mData + 4);
return reinterpret_cast<const u32*>(mData + 4);
}
int ByamlStringTableIter::getStringAddress(int idx) const
{
/* todo -- scheduling issues */
int offs = *((int*)(mData + idx) + 1);
int offsRev = __bswap_32(offs);
int ret;
if (mReversed)
return __bswap_32(getAddressTable()[idx]);
if (_8)
{
ret = offsRev;
}
else
{
ret = offs;
}
return ret;
return getAddressTable()[idx];
}
bool ByamlStringTableIter::isValidate() const

View File

@ -6,11 +6,7 @@ namespace al
{
mIsDead = true;
}
NerveStateBase::~NerveStateBase()
{
delete this;
}
NerveStateBase::~NerveStateBase() = default;
void NerveStateBase::init()
{

View File

@ -6,7 +6,11 @@ namespace al
// adds a state to the list of states in the controller
void NerveStateCtrl::addState(al::NerveStateBase *pBase, const al::Nerve *pNerve, const char *pName)
{
mStates[mStateCount].mStateBase = pBase, mStates[mStateCount].mNerve = pNerve, mStates[mStateCount++].mName = pName;
auto& state = mStates[mStateCount];
state.mStateBase = pBase;
state.mNerve = pNerve;
state.mName = pName;
mStateCount++;
}
// run the state's update function, if there is a current state active

View File

@ -21,9 +21,6 @@ namespace al
Resource::Resource(const sead::SafeStringBase<char> &rPath, sead::ArchiveRes *pResource)
: mArchive(nullptr), mDevice(nullptr), mName(rPath)
{
mArchive = 0;
mDevice = 0;
mHeap = sead::HeapMgr::sInstancePtr->getCurrentHeap();
_B0 = 0;
mResFile = 0;
@ -40,13 +37,17 @@ namespace al
unsigned int Resource::getFileSize(const sead::SafeStringBase<char> &rFileName) const
{
unsigned int ret;
mDevice->tryGetFileSize(&ret, rFileName);
auto device = mDevice;
u32 ret = 0;
device->tryGetFileSize(&ret, rFileName);
return ret;
}
void Resource::cleanupResGraphicsFile()
{
if(!mResFile)
return;
mResFile->ReleaseTexture();
mResFile->Reset();
agl::g3d::ResFile::Cleanup(mResFile);

View File

@ -4,7 +4,8 @@ namespace al
{
void HitSensor::setFollowPosPtr(const sead::Vector3<float> *pFollowPos)
{
mFollowPos = pFollowPos, mFollowMtx = nullptr;
mFollowPos = pFollowPos;
mFollowMtx = nullptr;
}
void HitSensor::setFollowMtxPtr(const sead::Matrix34<float> *pFollowMtx)

View File

@ -2,11 +2,10 @@
namespace al
{
void SensorHitGroup::add(al::HitSensor *pSensor)
void SensorHitGroup::add(al::HitSensor* pSensor)
{
// todo -- fix incrementation issue
mSensors[mSensorCount] = pSensor;
++mSensorCount;
mSensorCount++;
}
al::HitSensor* SensorHitGroup::getSensor(int idx) const

View File

@ -3,62 +3,37 @@
namespace alByamlLocalUtil
{
/* doesn't match but it's close enough */
const char* getDataTypeString(int type)
{
const char* str;
switch (type)
{
const char* getDataTypeString(int type) {
switch (type) {
case 0x00:
return "None";
case 0xA0:
str = "String";
break;
return "String";
case 0xC0:
str = "Array";
break;
return "Array";
case 0xC1:
str = "Hash";
break;
return "Hash";
case 0xC2:
str = "StringTable";
break;
return "StringTable";
case 0xD0:
str = "Bool";
break;
return "Bool";
case 0xD1:
str = "Int";
break;
return "Int";
case 0xD2:
str = "Float";
break;
return "Float";
case 0xD3:
str = "UInt";
break;
return "UInt";
case 0xD4:
str = "Int64";
break;
return "Int64";
case 0xD5:
str = "UInt64";
break;
return "UInt64";
case 0xD6:
str = "Double";
break;
return "Double";
case 0xFF:
str = "NULL";
break;
return "NULL";
default:
if (type)
{
str = "Unknown";
}
else
{
str = "None";
}
break;
return "Unknown";
}
return str;
}
};
@ -167,8 +142,7 @@ namespace al
float y = 0;
bool y_ret = rIter.tryGetFloatByKey(&y, "YZ");
pOut->x = x;
pOut->y = y;
*pOut = {x, y};
return (x_ret | y_ret) & 0x1;
}

View File

@ -1,43 +1,19 @@
#include "al/util/MathUtil.h"
#include <cmath>
#include <math/seadMathCalcCommon.h>
namespace al
{
float normalize(float var, float min, float max)
{
float v4;
bool v5;
float result;
float v7;
float normalize(float var, float min, float max) {
if (sead::absf(max-min) < 0.001f) {
if (var < min)
return 0.0f;
else
return 1.0f;
}
v4 = -(max - min);
if ((max - min) > 0.0f)
{
v4 = max - min;
}
if (v4 >= 0.001f)
{
v7 = min;
if (var >= min)
{
v7 = var;
if (var > max)
{
v7 = max;
}
}
result = (v7 - min) / (max - min);
}
else
{
v5 = var < min;
result = 1.0f;
if (v5)
{
result = 0.0f;
}
}
return result;
float clamped = sead::clamp(var, min, max);
return (clamped - min) / (max - min);
}
@ -47,34 +23,23 @@ namespace al
float result;
if (var <= min)
{
return 0.0f;
}
if (max - min <= 0)
{
if (max - min <= 0) {
result = 1.0f;
if (var < min)
{
result = 0.0f;
}
}
else
{
if (var <= max)
{
v3 = var;
}
else
{
v3 = max;
}
if (var < min)
{
v3 = min;
}
result = (static_cast<float>(v3 - min) / static_cast<float>(max - min));
}
@ -144,13 +109,10 @@ namespace al
}
float lerpValue(float x, float y, float time) {
if (time >= 0.0f)
{
if (time > 1.0f)
time = 1.0f;
} else {
if(time < 0.0f)
time = 0.0f;
}
else if(time > 1.0f)
time = 1.0f;
return (x * (1.0f - time)) + (time * y);
}
};

View File

@ -1,6 +1,7 @@
#include "al/util/NerveUtil.h"
#include "al/nerve/NerveKeeper.h"
#include "al/nerve/NerveStateCtrl.h"
#include <algorithm>
namespace al
{
@ -75,51 +76,28 @@ namespace al
return (step <= high) & (step >= low);
}
// logic just won't add up for some reason
int calcNerveInterval(const al::IUseNerve *pKeeper, int start, int end)
{
int calcNerveInterval(const al::IUseNerve *pKeeper, int start, int end) {
al::NerveKeeper* keeper = pKeeper->getNerveKeeper();
if (start >= -1)
{
int dist = keeper->mStep - end;
int dist = keeper->mStep - end;
if (dist >= -1)
{
return dist / start;
}
}
if(start < 1 || dist < 1)
return 0;
return 0;
return dist / start;
}
float calcNerveRate(const al::IUseNerve *pKeeper, int step)
{
float ret;
float calcNerveRate(const al::IUseNerve *pKeeper, int step) {
if (step < 1)
{
ret = 1.0f;
}
else
{
float curStep = pKeeper->getNerveKeeper()->mStep;
ret = curStep / step;
return 1.0f;
// TODO -- technically the same code,
// but this one uses B.GE and not B.PL
if (ret >= 0)
{
if (ret > 1.0f)
{
ret = 1.0f;
}
}
else
{
ret = 0;
}
}
float curStep = pKeeper->getNerveKeeper()->mStep;
float ret = curStep / step;
if (ret < 0.0f)
ret = 0.0f;
else if (ret > 1.0f)
ret = 1.0f;
return ret;
}

View File

@ -32,59 +32,30 @@ namespace al
return strstr(pString_0, pString_1);
}
/*bool isEqualSubString(const sead::SafeStringBase<char> &pString_0, const sead::SafeStringBase<char> &pString_1)
{
pString_0.assureTerminationImpl_();
const char* str = pString_0.mStringTop;
pString_1.assureTerminationImpl_();
return strstr(str, pString_1.mStringTop);
}*/
bool isStartWithString(const char *pString_0, const char *pString_1)
{
char val = *pString_1;
bool isStartWithString(const char *pString_0, const char *pString_1) {
if (!*pString_1)
{
return true;
}
const char* nextVal = pString_1 + 1;
while(*pString_0 && *pString_0 == val)
{
char e = *nextVal++;
val = e;
while(*pString_0 && *pString_0 == *pString_1) {
++pString_0;
++pString_1;
if (!e)
{
if (!*pString_1)
return true;
}
}
return false;
}
bool isEqualString(const char *pString_0, const char *pString_1)
{
char val;
bool isEqualString(const char *pString_0, const char *pString_1) {
while (*pString_0 == *pString_1) {
char val = *pString_0; //required to match
while (1)
{
val = *pString_0;
if (val != *pString_1)
{
break;
}
if (!*pString_0)
return true;
++pString_1;
++pString_0;
if (!val)
{
return true;
}
}
return false;
@ -96,12 +67,8 @@ namespace al
int pString1_Len = strlen(pString_1);
if (pString0_Len < pString1_Len)
{
return false;
}
else
{
return isEqualString(&pString_0[pString0_Len - pString1_Len], pString_1);
}
return isEqualString(&pString_0[pString0_Len - pString1_Len], pString_1);
}
};