jkrthread partial fixup

This commit is contained in:
EpochFlame 2023-02-07 23:22:50 -05:00
parent 9a8ae3790a
commit 463a0368b7
5 changed files with 32 additions and 72 deletions
.vscode
docs
include/JSystem/JKernel
src
JSystem/JKernel
plugProjectKandoU

2
.vscode/warnings.h vendored

@ -1,3 +1,3 @@
// disables the "too many characters in character constant" intellisense error, because we have u64 constants all over the place
#pragma diag_suppress 26
//#pragma diag_suppress 1767
#pragma diag_suppress 1767

@ -71,8 +71,8 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/J3D/J3DJointTree.cpp">J3D/J3DJointTree.cpp</a> | 9807 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JParticle/JPAResourceLoader.cpp">JParticle/JPAResourceLoader.cpp</a> | 9814 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JParticle/JPAMath.cpp">JParticle/JPAMath.cpp</a> | 10028 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/J2D/J2DTevs.cpp">J2D/J2DTevs.cpp</a> | 10255 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JStudio/jstudio-control.cpp">JStudio/jstudio-control.cpp</a> | 10278 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAI/JAIBankWave.cpp">JAudio2/JAI/JAIBankWave.cpp</a> | 10600 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JUtility/JUTAssert.cpp">JUtility/JUTAssert.cpp</a> | 11115 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JStudio_JStage/control.cpp">JStudio_JStage/control.cpp</a> | 11936 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAS/JASCalc.cpp">JAudio2/JAS/JASCalc.cpp</a> | 11964 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JKernel/JKRThread.cpp">JKernel/JKRThread.cpp</a> | 12711 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JUtility/JUTAssert.cpp">JUtility/JUTAssert.cpp</a> | 11115 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JKernel/JKRThread.cpp">JKernel/JKRThread.cpp</a> | 11705 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JStudio_JStage/control.cpp">JStudio_JStage/control.cpp</a> | 11936 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAS/JASCalc.cpp">JAudio2/JAS/JASCalc.cpp</a> | 11964 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAI/JAIInitData.cpp">JAudio2/JAI/JAIInitData.cpp</a> | 12786 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAS/JASDSPChannel.cpp">JAudio2/JAS/JASDSPChannel.cpp</a> | 13031 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAS/JASOscillator.cpp">JAudio2/JAS/JASOscillator.cpp</a> | 13041 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAS/JASTaskThread.cpp">JAudio2/JAS/JASTaskThread.cpp</a> | 13156 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JMath/JMATrigonometric.cpp">JMath/JMATrigonometric.cpp</a> | 13423 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/JSystem/JAudio2/JAS/JASWSParser.cpp">JAudio2/JAS/JASWSParser.cpp</a> | 13470 |
@ -155,7 +155,7 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeJointMgr.cpp">SnakeJointMgr.cpp</a> | 10097 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ContRumble.cpp">ContRumble.cpp</a> | 12389 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Tank.cpp">Tank.cpp</a> | 13328 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/BabyState.cpp">BabyState.cpp</a> | 13378 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/JointShadowBase.cpp">JointShadowBase.cpp</a> | 14958 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Sarai.cpp">Sarai.cpp</a> | 15257 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/TadpoleState.cpp">TadpoleState.cpp</a> | 17799 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/UjiaState.cpp">UjiaState.cpp</a> | 18504 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/TadpoleState.cpp">TadpoleState.cpp</a> | 17799 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/UjiaState.cpp">UjiaState.cpp</a> | 18638 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/FuefukiState.cpp">FuefukiState.cpp</a> | 19005 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeWholeShadow.cpp">SnakeWholeShadow.cpp</a> | 19376 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeCrowShadow.cpp">SnakeCrowShadow.cpp</a> | 19385 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ImomushiState.cpp">ImomushiState.cpp</a> | 19882 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/RumbleMgr.cpp">RumbleMgr.cpp</a> | 21534 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ElecHiba.cpp">ElecHiba.cpp</a> | 21847 |

@ -170,6 +170,13 @@ struct JKRTask : public JKRThread {
void waitQueueMessageBlock(OSMessageQueue*, int*);
void waitQueueMessage(OSMessageQueue*, int*);
OSMessage waitMessageBlock()
{
OSMessage msg;
// OSReceiveMessage(_94, &msg, OS_MESSAGE_BLOCKING);
return msg;
}
static void destroy(JKRTask*);
static JSUList<JKRTask> sTaskList;

@ -7,49 +7,6 @@
// TODO: Restore the other unused/inlined functions.
/*
Generated from dpostproc
.section .ctors, "wa" # 0x80472F00 - 0x804732C0
.4byte __sinit_JKRThread_cpp
.section .data, "wa" # 0x8049E220 - 0x804EFC20
.global __vt__7JKRTask
__vt__7JKRTask:
.4byte 0
.4byte 0
.4byte __dt__7JKRTaskFv
.4byte run__7JKRTaskFv
.global __vt__9JKRThread
__vt__9JKRThread:
.4byte 0
.4byte 0
.4byte __dt__9JKRThreadFv
.4byte run__9JKRThreadFv
.section .bss # 0x804EFC20 - 0x8051467C
.global sThreadList__9JKRThread
sThreadList__9JKRThread:
.skip 0x38
.global sTaskList__7JKRTask
sTaskList__7JKRTask:
.skip 0xC
.section .sbss # 0x80514D80 - 0x80516360
.global sManager__15JKRThreadSwitch
sManager__15JKRThreadSwitch:
.skip 0x4
.global sTotalCount__15JKRThreadSwitch
sTotalCount__15JKRThreadSwitch:
.skip 0x4
.global sTotalStart__15JKRThreadSwitch
sTotalStart__15JKRThreadSwitch:
.skip 0x4
.global lbl_80514EE4
lbl_80514EE4:
.skip 0x4
*/
JSUList<JKRThread> JKRThread::sThreadList(false);
JSUList<JKRTask> JKRTask::sTaskList;
@ -66,8 +23,7 @@ u64 JKRThreadSwitch::sTotalStart;
JKRThread::JKRThread(unsigned long stackSize, int msgCount, int threadPriority)
: JKRDisposer()
, mLink(this)
, _60()
, _70(0)
, mLoadInfo()
{
JKRHeap* heap = JKRHeap::findFromRoot(this);
if (heap == nullptr) {
@ -86,8 +42,7 @@ JKRThread::JKRThread(unsigned long stackSize, int msgCount, int threadPriority)
JKRThread::JKRThread(JKRHeap* heap, unsigned long stackSize, int msgCount, int threadPriority)
: JKRDisposer()
, mLink(this)
, _60()
, _70(0)
, mLoadInfo()
{
if (heap == nullptr) {
heap = JKRHeap::sCurrentHeap;
@ -105,8 +60,7 @@ JKRThread::JKRThread(JKRHeap* heap, unsigned long stackSize, int msgCount, int t
JKRThread::JKRThread(OSThread* thread, int msgCount)
: JKRDisposer()
, mLink(this)
, _60()
, _70(0)
, mLoadInfo()
{
mHeap = nullptr;
mThread = thread;
@ -146,8 +100,8 @@ void JKRThread::setCommon_mesgQueue(JKRHeap* heap, int msgCount)
mMsgBuffer = (OSMessage*)JKRHeap::alloc(mMsgCount << 2, 0, heap);
OSInitMessageQueue(&mMsgQueue, (void**)mMsgBuffer, mMsgCount);
JKRThread::sThreadList.append(&mLink);
_74 = 0;
_78 = 0;
mCurrentHeap = 0;
mCurrentHeapError = 0;
}
/*
@ -183,12 +137,12 @@ void* JKRThread::start(void* thread) { return static_cast<JKRThread*>(thread)->r
* Address: ........
* Size: 000038
*/
JKRThread_0x60* JKRThread::searchThreadLoad(OSThread* osThread)
JKRThread::TLoad* JKRThread::searchThreadLoad(OSThread* osThread)
{
// UNUSED FUNCTION
for (JSULink<JKRThread>* link = JKRThread::sThreadList.getFirst(); link != nullptr; link = link->getNext()) {
if (link->getObject()->mThread == osThread) {
return &link->getObject()->_60;
return &link->getObject()->mLoadInfo;
}
}
return nullptr;
@ -210,35 +164,35 @@ void JKRThreadSwitch::loopProc()
}
OSDisableInterrupts();
OSDisableScheduler();
JKRThread_0x60* v1 = JKRThread::searchThreadLoad(OSGetCurrentThread());
JKRThread::TLoad* v1 = JKRThread::searchThreadLoad(OSGetCurrentThread());
// OSThread* osThread = OSGetCurrentThread();
// JKRThread_0x60* v1;
// for (JSULink<JKRThread>* link = JKRThread::sThreadList.getFirst(); link != nullptr; link = link->getNext()) {
// if (link->getObject()->mThread == osThread) {
// v1 = &link->getObject()->_60;
// v1 = &link->getObject()->mLoadInfo;
// }
// }
// v1 = nullptr;
_0C = 0;
_18 = OSGetTime() - sTotalStart;
if (v1 != nullptr) {
v1->_04 += OSGetTick() - v1->_0C;
v1->mCost += OSGetTick() - v1->mLastTick;
}
if (_20 != 0) {
v_08(_24);
// v1->draw(_24);
} else {
v_0C(_24);
// v1->draw(_24);
}
for (JSULink<JKRThread>* link = JKRThread::sThreadList.getFirst(); link != nullptr; link = link->getNext()) {
JKRThread* thread = link->getObject();
thread->_60._08 = 0;
thread->_60._04 = 0;
thread->_60._0C = 0;
JKRThread* thread = link->getObject();
thread->mLoadInfo.mSwitchCount = 0;
thread->mLoadInfo.mCost = 0;
thread->mLoadInfo.mLastTick = 0;
}
sTotalCount = 0;
sTotalStart = OSGetTime();
if (v1 != nullptr) {
v1->_0C = OSGetTick();
v1->mLastTick = OSGetTick();
}
OSEnableScheduler();
OSEnableInterrupts();
@ -424,8 +378,9 @@ JKRTask* JKRTask::create(int msgCount, int threadPriority, unsigned long stackSi
void* JKRTask::run()
{
Message* msg;
OSInitFastCast();
while (true) {
OSReceiveMessage(&mMsgQueue, (void**)&msg, OS_MESSAGE_BLOCKING);
// OSReceiveMessage(&mMsgQueue, (OSMessage*)msg, OS_MESSAGE_BLOCKING);
if (msg->_00 != nullptr) {
msg->_00(msg->_04);
if (_94 != nullptr) {
@ -511,8 +466,8 @@ bool JKRTask::request(RequestCallback callback, void* p2, void* p3)
msg->_00 = callback;
msg->_04 = p2;
msg->_08 = p3;
bool sendResult = (OSSendMessage(&mMsgQueue, msg, OS_MESSAGE_NON_BLOCKING) != FALSE);
if (sendResult == false) {
bool sendResult = (OSSendMessage(&mMsgQueue, msg, OS_MESSAGE_NON_BLOCKING));
if (!sendResult) {
msg->_00 = nullptr;
}
return sendResult;

@ -151,7 +151,6 @@ void TekiStat::Info::read(Stream& stream)
* --INFO--
* Address: 80233B40
* Size: 0000C0
* NONMATCHING
* write__Q34Game8TekiStat3MgrFR6Stream
*/
void TekiStat::Mgr::write(Stream& stream)
@ -166,7 +165,6 @@ void TekiStat::Mgr::write(Stream& stream)
* --INFO--
* Address: 80233C00
* Size: 0000EC
* NOT SURE IF MATCHES
* read__Q34Game8TekiStat3MgrFR6Stream
*/
void TekiStat::Mgr::read(Stream& stream)