mirror of
https://github.com/zeldaret/ss
synced 2026-07-10 14:33:47 -04:00
More detail work
This commit is contained in:
@@ -1,21 +1,29 @@
|
||||
#include "egg/core/eggController.h"
|
||||
#include "MSL_C/string.h"
|
||||
#include "rvl/VI.h"
|
||||
|
||||
extern EGG::CoreControllerMgr *lbl_805767A8;
|
||||
extern EGG::CoreControllerMgr *lbl_805767AC;
|
||||
|
||||
const char *str = "EGG::CoreControllerMgr"; // TODO
|
||||
|
||||
EGG::NullController null_controller;
|
||||
|
||||
namespace EGG
|
||||
{
|
||||
// TODO vtable order in this TU is still messed up
|
||||
// TODO NullController implementation
|
||||
|
||||
void CoreStatus::init() {
|
||||
namespace EGG {
|
||||
|
||||
CoreControllerMgr *CoreControllerMgr::sInstance;
|
||||
CoreControllerMgr::T__Disposer *CoreControllerMgr::T__Disposer::sStaticDisposer;
|
||||
void *CoreControllerFactory; // TODO
|
||||
ConnectCallback CoreControllerMgr::sConnectCallback;
|
||||
// This controls whether EggController registers an allocator within the WPAD driver
|
||||
bool CoreControllerMgr::sUseBuiltinWpadAllocator;
|
||||
void *TODO_Allocator; // TODO
|
||||
|
||||
/* 0x80498F90 */ void CoreStatus::init() {
|
||||
memset(this, 0, sizeof(CoreStatus));
|
||||
}
|
||||
|
||||
u32 CoreStatus::getFSStickButton() const {
|
||||
/* 0x80498FA0 */ u32 CoreStatus::getFSStickButton() const {
|
||||
f32 button = this->fsStickButton;
|
||||
u32 result = 0;
|
||||
// TODO what are these flags and why is this code so weird?
|
||||
@@ -44,7 +52,7 @@ u32 CoreStatus::getFSStickButton() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
CoreController::CoreController(): mDpdPos(), mAccel(), mAccelFlags(nullptr) {
|
||||
/* 0x80499050 */ CoreController::CoreController() : mDpdPos(), mAccel(), mAccelFlags(nullptr) {
|
||||
this->mRumbleMgr = nullptr;
|
||||
this->mButtonHeld = 0;
|
||||
this->mButtonTriggered = 0;
|
||||
@@ -53,7 +61,7 @@ CoreController::CoreController(): mDpdPos(), mAccel(), mAccelFlags(nullptr) {
|
||||
this->mFlag.makeAllZero();
|
||||
}
|
||||
|
||||
void CoreController::sceneReset() {
|
||||
/* 0x804990B0 */ void CoreController::sceneReset() {
|
||||
this->mAccel.set(0.0, 0.0, 0.0);
|
||||
this->mDpdPos.x = 0.0;
|
||||
this->mDpdPos.y = 0.0;
|
||||
@@ -75,117 +83,147 @@ void CoreController::sceneReset() {
|
||||
this->stopRumbleMgr();
|
||||
}
|
||||
|
||||
Vector2f CoreController::getDpdRawPos() const {
|
||||
/* 0x80499170 */ Vector2f CoreController::getDpdRawPos() const {
|
||||
return Vector2f(this->coreStatus[0].dpdRawX, this->coreStatus[0].dpdRawY);
|
||||
}
|
||||
|
||||
s32 CoreController::getDpdDistance() const {
|
||||
/* 0x80499190 */ s32 CoreController::getDpdDistance() const {
|
||||
return this->coreStatus[0].dpdDistance;
|
||||
}
|
||||
|
||||
// TODO
|
||||
extern "C" void fn_803DB1E0(s32 channel, bool arg);
|
||||
|
||||
void CoreController::startMotor() {
|
||||
/* 0x804991A0 */ void CoreController::startMotor() {
|
||||
fn_803DB1E0(mChannelID, true);
|
||||
}
|
||||
|
||||
void CoreController::stopMotor() {
|
||||
/* 0x804991B0 */ void CoreController::stopMotor() {
|
||||
fn_803DB1E0(mChannelID, false);
|
||||
}
|
||||
|
||||
void CoreController::createRumbleMgr(u8 numUnits) {
|
||||
/* 0x804991C0 */ void CoreController::createRumbleMgr(u8 numUnits) {
|
||||
this->mRumbleMgr = new ControllerRumbleMgr();
|
||||
this->mRumbleMgr->createUnit(numUnits, this);
|
||||
}
|
||||
|
||||
void CoreController::startPatternRumble(const char *pattern, int duration, bool bGrabActive) {
|
||||
/* 0x80499220 */ void CoreController::startPatternRumble(const char *pattern, int duration, bool bGrabActive) {
|
||||
if (this->mRumbleMgr) {
|
||||
this->mRumbleMgr->startPattern(pattern, duration, bGrabActive);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreController::stopRumbleMgr() {
|
||||
/* 0x80499240 */ void CoreController::stopRumbleMgr() {
|
||||
if (this->mRumbleMgr) {
|
||||
this->mRumbleMgr->stop();
|
||||
}
|
||||
}
|
||||
|
||||
CoreStatus *CoreController::getCoreStatus(s32 idx) {
|
||||
/* 0x80499260 */ CoreStatus *CoreController::getCoreStatus(s32 idx) {
|
||||
return &this->coreStatus[idx];
|
||||
}
|
||||
|
||||
void CoreController::calc_posture_matrix(Matrix34f &mat, bool someBool) {
|
||||
/* 0x80499270 */ void CoreController::calc_posture_matrix(Matrix34f &mat, bool someBool) {
|
||||
if (!someBool || this->mAccelFlags.onBit(7)) {
|
||||
Vector3f vec = Vector3f(-mat(2, 3), -mat(2, 2), -mat(2, 1));
|
||||
Vector3f vec3 = vec;
|
||||
vec.normalise();
|
||||
// TODO
|
||||
// TODO lots of inlined math
|
||||
}
|
||||
}
|
||||
|
||||
void CoreController::beginFrame(void *padStatus) {
|
||||
/* 0x80499660 */ void CoreController::beginFrame(void *padStatus) {}
|
||||
|
||||
}
|
||||
|
||||
void CoreController::endFrame() {
|
||||
/* 0x80499A60 */ void CoreController::endFrame() {
|
||||
this->mAccel(0) = this->coreStatus[0].accel[0];
|
||||
this->mAccel(1) = this->coreStatus[0].accel[1];
|
||||
this->mAccel(2) = this->coreStatus[0].accel[2];
|
||||
this->mDpdPos = this->getDpdRawPos();
|
||||
}
|
||||
|
||||
f32 CoreController::getFreeStickX() const {
|
||||
/* 0x80499AC0 */ f32 CoreController::getFreeStickX() const {
|
||||
if (this->coreStatus[0].field_0x00[0x5C] == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
return ((f32*)(&this->coreStatus[0].field_0x00))[0x18];
|
||||
return ((f32 *)(&this->coreStatus[0].field_0x00))[0x18];
|
||||
}
|
||||
|
||||
f32 CoreController::getFreeStickY() const {
|
||||
/* 0x80499AE0 */ f32 CoreController::getFreeStickY() const {
|
||||
if (this->coreStatus[0].field_0x00[0x5C] == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
return ((f32*)(&this->coreStatus[0].field_0x00))[0x19];
|
||||
return ((f32 *)(&this->coreStatus[0].field_0x00))[0x19];
|
||||
}
|
||||
|
||||
CoreControllerMgr *CoreControllerMgr::createInstance() {
|
||||
if (lbl_805767A8 == nullptr) {
|
||||
/* 0x80499B00 */ CoreControllerMgr::T__Disposer::~T__Disposer() {
|
||||
if (this == CoreControllerMgr::T__Disposer::sStaticDisposer) {
|
||||
deleteInstance();
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x80499B80 */ CoreControllerMgr *CoreControllerMgr::createInstance() {
|
||||
if (CoreControllerMgr::sInstance == nullptr) {
|
||||
CoreControllerMgr *mgr = new CoreControllerMgr();
|
||||
lbl_805767A8 = mgr;
|
||||
CoreControllerMgr::sInstance = mgr;
|
||||
lbl_805767AC = mgr;
|
||||
}
|
||||
return lbl_805767A8;
|
||||
return CoreControllerMgr::sInstance;
|
||||
}
|
||||
|
||||
void CoreControllerMgr::deleteInstance() {
|
||||
lbl_805767A8 = nullptr;
|
||||
/* 0x80499BD0 */ void CoreControllerMgr::deleteInstance() {
|
||||
CoreControllerMgr::sInstance = nullptr;
|
||||
lbl_805767AC = nullptr;
|
||||
}
|
||||
|
||||
EGG::CoreController *CoreControllerMgr::getNthController(s32 n) {
|
||||
/* 0x80499BE0 */ EGG::CoreController *CoreControllerMgr::getNthController(s32 n) {
|
||||
return this->mControllers(n);
|
||||
}
|
||||
|
||||
void CoreControllerMgr::connectCallback(int a1, int a2) {
|
||||
|
||||
/* 0x80499C70 */ void *CoreControllerMgr::allocThunk(size_t size) {
|
||||
return nullptr; // TODO
|
||||
}
|
||||
/* 0x80499C90 */ void CoreControllerMgr::deleteThunk(void *ptr) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
CoreControllerMgr::CoreControllerMgr() {
|
||||
|
||||
/* 0x80499CD0 */ void CoreControllerMgr::connectCallback(int a1, int a2) {
|
||||
int args[] = {a1, a2};
|
||||
if (sConnectCallback != nullptr) {
|
||||
(sConnectCallback)(args);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreControllerMgr::beginFrame() {
|
||||
/* 0x80499D10 */ CoreControllerMgr::CoreControllerMgr() {
|
||||
const int idxes[] = {0, 1, 2, 3};
|
||||
if (sUseBuiltinWpadAllocator == false) {
|
||||
// TODO create heap, register allocator thunks
|
||||
}
|
||||
// init KPAD
|
||||
beginFrame();
|
||||
endFrame();
|
||||
VIWaitForRetrace();
|
||||
|
||||
// TODO there's likely an allocate call here but it shifts the
|
||||
// inline buffer methods up in the TU :(
|
||||
// mControllers.allocate(4, 0);
|
||||
// TODO moar
|
||||
}
|
||||
|
||||
/* 0x8049A130 */ void CoreControllerMgr::beginFrame() {
|
||||
for (int i = 0; i < mControllers.getSize(); ++i) {
|
||||
mControllers(i)->beginFrame(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreControllerMgr::endFrame() {
|
||||
|
||||
/* 0x8049A1E0 */ void CoreControllerMgr::endFrame() {
|
||||
for (int i = 0; i < mControllers.mSize; i++) {
|
||||
mControllers(i)->endFrame();
|
||||
// TODO WPADprobe
|
||||
// Update device type after probe?
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerRumbleUnit::init() {
|
||||
/* 0x8049A3B0 */ void ControllerRumbleUnit::init() {
|
||||
this->mPattern = nullptr;
|
||||
this->mPatternPos = nullptr;
|
||||
this->mTimer = 0;
|
||||
@@ -194,7 +232,7 @@ void ControllerRumbleUnit::init() {
|
||||
this->mFlag.makeAllZero();
|
||||
}
|
||||
|
||||
void ControllerRumbleUnit::startPattern(const char *pattern, int duration) {
|
||||
/* 0x8049A3E0 */ void ControllerRumbleUnit::startPattern(const char *pattern, int duration) {
|
||||
this->mPattern = pattern;
|
||||
this->mPatternPos = pattern;
|
||||
|
||||
@@ -211,7 +249,7 @@ void ControllerRumbleUnit::startPattern(const char *pattern, int duration) {
|
||||
this->mFlag.value = ((this->mFlag.value | 0x01) & 0xfd) | 0x8;
|
||||
}
|
||||
|
||||
f32 ControllerRumbleUnit::calc() {
|
||||
/* 0x8049A440 */ f32 ControllerRumbleUnit::calc() {
|
||||
f32 result = 0.0f;
|
||||
if (this->mFlag.onBit(3)) {
|
||||
if (this->mFlag.onBit(0)) {
|
||||
@@ -259,14 +297,14 @@ f32 ControllerRumbleUnit::calc() {
|
||||
}
|
||||
}
|
||||
|
||||
ControllerRumbleMgr::ControllerRumbleMgr() {
|
||||
/* 0x8049A530 */ ControllerRumbleMgr::ControllerRumbleMgr() {
|
||||
this->mController = nullptr;
|
||||
// TODO offsetof macro
|
||||
List_Init(&this->mActiveUnitList, 0x1c);
|
||||
List_Init(&this->mInactiveUnitList, 0x1c);
|
||||
}
|
||||
|
||||
void ControllerRumbleMgr::createUnit(u8 numUnits, CoreController *ctrl) {
|
||||
/* 0x8049A590 */ void ControllerRumbleMgr::createUnit(u8 numUnits, CoreController *ctrl) {
|
||||
for (u8 created = 0; created < numUnits; created++) {
|
||||
ControllerRumbleUnit *unit = new ControllerRumbleUnit();
|
||||
List_Append(&this->mInactiveUnitList, unit);
|
||||
@@ -274,22 +312,22 @@ void ControllerRumbleMgr::createUnit(u8 numUnits, CoreController *ctrl) {
|
||||
this->mController = ctrl;
|
||||
}
|
||||
|
||||
void ControllerRumbleMgr::stop() {
|
||||
/* 0x8049A620 */ void ControllerRumbleMgr::stop() {
|
||||
this->mController->stopMotor();
|
||||
while (List_GetSize(&this->mActiveUnitList) != 0) {
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit*>(List_GetNext(&this->mActiveUnitList, nullptr));
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit *>(List_GetNext(&this->mActiveUnitList, nullptr));
|
||||
List_Remove(&this->mActiveUnitList, unit);
|
||||
List_Append(&this->mInactiveUnitList, unit);
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerRumbleMgr::calc() {
|
||||
/* 0x8049A690 */ void ControllerRumbleMgr::calc() {
|
||||
if (List_GetSize(&this->mActiveUnitList) != 0) {
|
||||
void *object = List_GetFirst(&this->mActiveUnitList);
|
||||
f32 acc = 0.0f;
|
||||
|
||||
while (object != nullptr) {
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit*>(object);
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit *>(object);
|
||||
f32 x = unit->calc();
|
||||
void *nextObject = List_GetNext(&this->mActiveUnitList, object);
|
||||
if (x < 0.0f) {
|
||||
@@ -307,48 +345,26 @@ void ControllerRumbleMgr::calc() {
|
||||
this->mController->stopMotor();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ControllerRumbleMgr::startPattern(const char *pattern, int duration, bool bGrabActive) {
|
||||
/* 0x8049A7A0 */ void ControllerRumbleMgr::startPattern(const char *pattern, int duration, bool bGrabActive) {
|
||||
EGG::ControllerRumbleUnit *unit = getUnitFromList(bGrabActive);
|
||||
if (unit != nullptr) {
|
||||
unit->startPattern(pattern, duration);
|
||||
}
|
||||
}
|
||||
|
||||
ControllerRumbleUnit *ControllerRumbleMgr::getUnitFromList(bool bGrabActive) {
|
||||
/* 0x8049A7F0 */ ControllerRumbleUnit *ControllerRumbleMgr::getUnitFromList(bool bGrabActive) {
|
||||
void *first = List_GetFirst(&this->mInactiveUnitList);
|
||||
if (first != nullptr) {
|
||||
List_Remove(&this->mInactiveUnitList, first);
|
||||
List_Append(&this->mActiveUnitList, first);
|
||||
} else if (bGrabActive && (first = List_GetFirst(&this->mActiveUnitList), first != nullptr)) {
|
||||
} else if (bGrabActive && (first = List_GetFirst(&this->mActiveUnitList), first != nullptr)) {
|
||||
List_Remove(&this->mActiveUnitList, first);
|
||||
List_Append(&this->mActiveUnitList, first);
|
||||
}
|
||||
|
||||
return static_cast<ControllerRumbleUnit*>(first);
|
||||
return static_cast<ControllerRumbleUnit *>(first);
|
||||
}
|
||||
|
||||
ControllerRumbleMgr::~ControllerRumbleMgr() {
|
||||
|
||||
}
|
||||
|
||||
ControllerRumbleUnit::~ControllerRumbleUnit() {
|
||||
|
||||
}
|
||||
|
||||
void CoreController::setAccParam(f32 param1, f32 param2) {
|
||||
|
||||
}
|
||||
|
||||
void CoreController::setDistParam(f32 param1, f32 param2) {
|
||||
|
||||
}
|
||||
|
||||
void CoreController::setHoriParam(f32 param1, f32 param2) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
Reference in New Issue
Block a user