Merge pull request #1 from LDAsuku/main

update scripts to work on non-windows and match some Collider & LiveActor functions
This commit is contained in:
shibboleet 2024-08-09 18:11:45 -04:00 committed by GitHub
commit f9ee12f9ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 129 additions and 55 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ compiler/*
*.o
.vscode/*
.ninja_log
.ninja_deps
*.nso
__pycache__/*
build.ninja

View File

@ -18,7 +18,7 @@ if "-non-matching" in sys.argv:
if "-clean" in sys.argv:
subprocess.call("ninja -t clean", shell=True)
INCLUDE_DIRS = ["include", "lib\\ActionLibrary\\include", "lib\\agl\\include", "lib\\eui\\incldue", "lib\\nn\\include", "lib\\sead\\include", "compiler\\nx\\aarch64\\include", "compiler\\nx\\aarch64\\include\\c++" ]
INCLUDE_DIRS = ["include", "lib/ActionLibrary/include", "lib/agl/include", "lib/eui/incldue", "lib/nn/include", "lib/sead/include", "compiler/nx/aarch64/include", "compiler/nx/aarch64/include/c++" ]
LIBRARIES = [ "Game", "ActionLibrary", "agl", "eui", "nn", "sead"]
incdirs = ""
@ -26,13 +26,19 @@ for dir in INCLUDE_DIRS:
incdirs += f'-I {dir} '
COMPILER_CMD = f"-x c++ -O3 -fno-omit-frame-pointer -mno-implicit-float -fno-cxx-exceptions -fno-strict-aliasing -std=gnu++14 -fno-common -fno-short-enums -ffunction-sections -fdata-sections -fPIC -mcpu=cortex-a57+fp+simd+crypto+crc -g -Wall {nonmatching_str} {incdirs} -c "
COMPILER_PATH = pathlib.Path("compiler\\nx\\aarch64\\bin\\clang++")
OBJDUMP_PATH = pathlib.Path("compiler\\nx\\aarch64\\bin\\llvm-objdump")
COMPILER_PATH = pathlib.Path("compiler/nx/aarch64/bin/clang++.exe")
OBJDUMP_PATH = pathlib.Path("compiler/nx/aarch64/bin/llvm-objdump.exe")
isNotWindows = os.name != 'nt'
def genNinja(tasks):
with open('build.ninja', 'w') as ninja_file:
ninja_writer = Writer(ninja_file)
ninja_writer.rule("compile", command=f'{COMPILER_PATH} {COMPILER_CMD} $in -o $out',description=f'Compiling $in')
cmd = f'{COMPILER_PATH} {COMPILER_CMD} $in -o $out'
if isNotWindows:
cmd = f'wine {cmd}'
ninja_writer.rule("compile", command=cmd, description=f'Compiling $in')
for task in tasks:
source_path, build_path = task
@ -74,7 +80,11 @@ def generateMaps(path):
for task in objdump_tasks:
source_path, build_path, map_path = task
mapFileOutput = subprocess.check_output([OBJDUMP_PATH, build_path, "-t"]).decode("utf-8").replace("\r", "")
cmd = [OBJDUMP_PATH, build_path, "-t"]
if isNotWindows:
cmd = ["wine"] + cmd
mapFileOutput = subprocess.check_output(cmd).decode("utf-8").replace("\r", "")
lines = mapFileOutput.split("\n")
newOutput = []
@ -99,4 +109,4 @@ def generateMaps(path):
w.writelines(newOutput)
for lib in LIBRARIES:
compileLibrary(lib, f"lib\\{lib}\\source")
compileLibrary(lib, f"lib/{lib}/source")

View File

@ -4,6 +4,7 @@ from capstone import *
from capstone.arm64 import *
from elftools.elf.elffile import ELFFile
import time
import hashlib
LIBRARIES = ["ActionLibrary", "agl", "eui", "nn", "sead"]
@ -92,7 +93,14 @@ def getModule(map, sym):
def getFunctionData(functionAddr, functionSize):
with open("fury.nso", "rb") as f:
nso_file = nso.NSO(f.read())
data = f.read()
digest = hashlib.sha256(data).hexdigest().upper()
if digest != "80E48BC7BDF7AAA635E7B48C24F49C6A4D8AC19949FB1B9F66EADF2CFBA3BF85":
print("fury.nso is not valid")
sys.exit(1)
nso_file = nso.NSO(data)
return nso_file.getFunction(functionAddr, functionSize)
@ -119,7 +127,7 @@ path = getModule("map", sym)
if path == "":
for lib in LIBRARIES:
path = getModule(f"lib\\{lib}\\map", sym)
path = getModule(f"lib/{lib}/map", sym)
if path != "":
break

View File

@ -51534,7 +51534,7 @@ _ZNK2al9LiveActor18getSceneCameraInfoEv=00000071008499A0=0000000C=true
_ZThn56_NK2al9LiveActor18getSceneCameraInfoEv=00000071008499B0=0000000C=true
_ZNK2al9LiveActor20getCameraDirector_RSEv=00000071008499C0=0000000C=true
_ZThn64_NK2al9LiveActor20getCameraDirector_RSEv=00000071008499D0=0000000C=true
_ZN2al9LiveActor14initPoseKeeperEPNS_19ActorPoseKeeperBaseE=00000071008499E0=00000008=false
_ZN2al9LiveActor14initPoseKeeperEPNS_19ActorPoseKeeperBaseE=00000071008499E0=00000008=true
_ZN2al9LiveActor15initExecuteInfoEPNS_16ActorExecuteInfoE=00000071008499F0=00000008=false
_ZN2al9LiveActor15initModelKeeperEPNS_11ModelKeeperE=0000007100849A00=00000040=false
_ZN2al9LiveActor16initActionKeeperEPKcS2_=0000007100849A40=00000034=false
@ -51547,11 +51547,11 @@ _ZN2al9LiveActor19initOceanWaveKeeperEPNS_15OceanWaveKeeperE=0000007100849B60=00
_ZN2al9LiveActor21initStageSwitchKeeperEv=0000007100849B70=00000030=false
_ZThn32_N2al9LiveActor21initStageSwitchKeeperEv=0000007100849BA0=00000030=false
_ZN2al9LiveActor14initRailKeeperERKNS_13ActorInitInfoE=0000007100849BD0=00000030=false
_ZN2al9LiveActor12initColliderEffj=0000007100849C00=000000B8=false
_ZN2al9LiveActor12initColliderEffj=0000007100849C00=000000B8=true
_ZN2al9LiveActor16initShadowKeeperEPNS_12ShadowKeeperE=0000007100849CC0=00000008=false
_ZN2al9LiveActor14initItemKeeperEi=0000007100849CD0=00000044=false
_ZN2al9LiveActor15initScoreKeeperEv=0000007100849D20=00000030=false
_ZN2al9LiveActor27initActorPrePassLightKeeperEPNS_23ActorPrePassLightKeeperE=0000007100849D50=00000008=false
_ZN2al9LiveActor15initScoreKeeperEv=0000007100849D20=00000030=true
_ZN2al9LiveActor27initActorPrePassLightKeeperEPNS_23ActorPrePassLightKeeperE=0000007100849D50=00000008=true
_ZN2al9LiveActor18initSubActorKeeperEPNS_14SubActorKeeperE=0000007100849D60=0000000C=true
_ZN2al9LiveActor13initSceneInfoEPNS_14ActorSceneInfoE=0000007100849D70=00000008=true
_ZN2al9LiveActor18initActorAlphaCtrlEPNS_14ActorAlphaCtrlERKNS_13ActorInitInfoE=0000007100849D80=0000001C=false
@ -58392,7 +58392,7 @@ _ZN2al12ViewInfoCtrl13initActorInfoEPNS_17ClippingActorInfoEPNS_11PlacementIdE=0
_ZN2al12ViewInfoCtrl7endInitEv=00000071009544C0=00000030=false
_ZN2al12ViewInfoCtrl6updateEv=00000071009544F0=00000160=false
_ZNK2al12ViewInfoCtrl15tryFindViewInfoEPNS_11PlacementIdE=0000007100954650=00000070=false
_ZN2al8ColliderC1EPNS_17CollisionDirectorEPKN4sead8Matrix34IfEEPKNS3_7Vector3IfEESB_ffj=00000071009546C0=00000134=false
_ZN2al8ColliderC1EPNS_17CollisionDirectorEPKN4sead8Matrix34IfEEPKNS3_7Vector3IfEESB_ffj=00000071009546C0=00000134=true
_ZN2al8Collider5clearEv=0000007100954800=00000024=false
_ZN2al8Collider17setTriangleFilterEPKNS_18TriangleFilterBaseE=0000007100954830=00000008=false
_ZN2al8Collider23setCollisionPartsFilterEPKNS_24CollisionPartsFilterBaseE=0000007100954840=00000008=false

View File

@ -12,49 +12,39 @@ namespace al {
class Collider : public IUseCollision {
public:
Collider(CollisionDirector*, const sead::Matrix34f*, const sead::Vector3f*, const sead::Vector3f*, f32, f32, u32);
virtual CollisionDirector* getCollisionDirector() const;
void onInvalidate();
CollisionDirector* mCollisionDirector; // 0x08
TriangleFilterBase* mTriFilterBase; // 0x10
CollisionPartsFilterBase* mColFilterBase; // 0x18
void* _20;
void* _28;
void* _30;
f32 mRadius; // 0x38
f32 mOffsetY; // 0x3C
void* _40;
u32 _48;
u32 mStoredPlaneNum; // 0x4C
u8 _50[0x70 - 0x50];
Triangle mFloor; // 0x70
u32 _E0;
sead::Vector3f mGroundPos; // 0xE4
u8 _F0[0x110 - 0xF0];
f32 _110;
f32 _114;
Triangle mWall; // 0x118
u32 _188;
sead::Vector3f mWallPos; // 0x18C
u8 _198[0x1B8 - 0x198];
f32 _1B8;
f32 _1BC;
Triangle mCeiling; // 0x1C0
u32 _230;
sead::Vector3f mCeilingPos; // 0x234
u8 _240[0x260 - 0x240];
f32 _260;
u32 _264;
u32 _268;
u32 _26C;
u32 _270;
bool _274;
CollisionDirector* mCollisionDirector = nullptr; // 0x08
TriangleFilterBase* mTriFilterBase = nullptr; // 0x10
CollisionPartsFilterBase* mColFilterBase = nullptr; // 0x18
const sead::Matrix34f* mBaseMtx = nullptr; // 0x20
const sead::Vector3f* mTrans = nullptr; // 0x28
const sead::Vector3f* mGravity = nullptr; // 0x30
f32 mRadius = 0.0f; // 0x38
f32 mOffsetY = 0.0f; // 0x3C
void* _40 = nullptr;
u32 _48 = 0;
u32 mStoredPlaneNum = 0; // 0x4C
HitInfo *_50 = nullptr;
sead::Vector3f _58;
sead::Vector3f _64;
HitInfo mFloor; // 0x70
f32 _110 = 0.0f;
HitInfo mWall; // 0x118
f32 _1B8 = 0.0f;
HitInfo mCeiling; // 0x1c0
f32 _260 = 0.0f;
u32 _264 = 0;
sead::Vector3f _268;
u8 _274;
bool _275;
bool _276;
bool _277;
sead::Vector3f _278;
u32 _284;
f32 _284;
};
};

View File

@ -1,6 +1,7 @@
#pragma once
#include <math/seadVector.hpp>
#include <types.hpp>
namespace al {
class CollisionParts;
@ -40,6 +41,16 @@ namespace al {
sead::Vector3f mNormals[4]; // 0x18
sead::Vector3f mPos[3]; // 0x48
};
class HitInfo {
public:
HitInfo();
Triangle mTriangle; // 0x00
u32 _6C;
sead::Vector3f mPos; // 0x70
u8 _7C[0x9C - 0x7C];
};
};
bool operator==(const al::Triangle &, const al::Triangle &);

View File

@ -188,7 +188,7 @@ namespace al {
void initShadowKeeper(ShadowKeeper *);
void initItemKeeper(s32);
void initScoreKeeper();
void initACtorPrePassLightKeeper(ActorPrePassLightKeeper *);
void initActorPrePassLightKeeper(ActorPrePassLightKeeper *);
void initSubActorKeeper(SubActorKeeper *);
void initSceneInfo(ActorSceneInfo *);
void initActorAlphaCtrl(ActorAlphaCtrl *, const ActorInitInfo &);

View File

@ -0,0 +1,39 @@
#include "Library/Collision/Collider.hpp"
#include "Library/Collision/HitInfo.hpp"
namespace al {
Collider::Collider(CollisionDirector *pCollisionDirector, const sead::Matrix34f *pBaseMtx, const sead::Vector3f *pTrans, const sead::Vector3f *pGravity, f32 radius, f32 offsetY, u32 numHitInfos) :
mCollisionDirector(pCollisionDirector),
mBaseMtx(pBaseMtx),
mTrans(pTrans),
mGravity(pGravity),
mRadius(radius),
mOffsetY(offsetY),
_48(numHitInfos),
_58(sead::Vector3f(0.0f, 0.0f, 0.0f)),
_64(sead::Vector3f(0.0f, 0.0f, 0.0f)),
_268(sead::Vector3f(0.0f, 1.0f, 0.0f)),
_278(*pTrans),
_284(radius)
{
if (_48 == 0) {
_50 = nullptr;
}
else {
_50 = new HitInfo[_48]();
}
mStoredPlaneNum = 0;
_110 = -99999.0f;
_1B8 = -99999.0f;
_260 = -99999.0f;
_58 = sead::Vector3f(0.0f, 0.0f, 0.0f);
_64 = sead::Vector3f(0.0f, 0.0f, 0.0f);
_274 &= 0xc0;
_274 |= 0x03;
}
}

View File

@ -4,6 +4,7 @@
#include "Library/Actor/ActorInitInfo.hpp"
#include "Library/Actor/ActorPoseFunction.hpp"
#include "Library/Actor/ActorPoseKeeperBase.hpp"
#include "Library/Actor/ActorPoseUtil.hpp"
#include "Library/Actor/ActorPrePassLightKeeper.hpp"
#include "Library/Actor/ActorSceneInfo.hpp"
#include "Library/Audio/AudioKeeper.hpp"
@ -18,6 +19,7 @@
#include "Library/Execute/ActorSystemFunction.hpp"
#include "Library/HitSensor/HitSensorKeeper.hpp"
#include "Library/LiveActor/LiveActor.hpp"
#include "Library/Item/ActorScoreKeeper.hpp"
#include "Library/LiveActor/ActorPoseUtil.hpp"
#include "Library/LiveActor/LiveActorFlag.hpp"
#include "Library/LiveActor/LiveActorUtil.hpp"
@ -617,17 +619,30 @@ namespace al {
return mActorSceneInfo->mCameraDirector;
}
// al::LiveActor::initPoseKeeper
void LiveActor::initPoseKeeper(ActorPoseKeeperBase *pPoseKeeper) {
mActorPoseKeeper = pPoseKeeper;
}
// al::LiveActor::initRailKeeper
// al::LiveActor::initCollider
void LiveActor::initCollider(f32 radius, f32 offsetY, u32 numHitInfos) {
mCollider = new Collider(getCollisionDirector(), getBaseMtx(), &al::getTrans(this), &al::getGravity(this), radius, offsetY, numHitInfos);
mActorFlags->mIsNoCollide = false;
}
void LiveActor::initShadowKeeper(ShadowKeeper* pShadowKeeper) {
mShadowKeeper = pShadowKeeper;
}
// al::LiveActor::initItemKeeper
// al::LiveActor::initScoreKeepe
// al::LiveActor::initActorPrePassLightKeeper
void LiveActor::initScoreKeeper() {
mScoreKeeper = new ActorScoreKeeper();
}
void LiveActor::initActorPrePassLightKeeper(ActorPrePassLightKeeper *pLightKeeper) {
mLightKeeper = pLightKeeper;
}
void LiveActor::initSubActorKeeper(SubActorKeeper *pSubActorKeeper) {
mSubActorKeeper = pSubActorKeeper;